
import os




def 				__magic_name__				(     )    ->     int:
				__lowerCamelCase					      =			os.path.dirname(os.path.realpath(__lowerCAmelCase							)							)
				__lowerCamelCase					      =			os.path.join(__lowerCAmelCase	,						'''triangle.txt'''							)

				with open(__lowerCAmelCase							) as in_file:
								__lowerCamelCase					      =			[[int(__lowerCAmelCase							) for i in line.split()] for line in in_file]

				while len(__lowerCAmelCase							) != 1:
								__lowerCamelCase					      =			triangle.pop()
								__lowerCamelCase					      =			triangle[-1]
								for j in range(len(__lowerCAmelCase							) - 1							):
												curr_row[j] += max(last_row[j]	,						last_row[j + 1]							)
				return triangle[0][0]


if __name__ == "__main__":
					print(solution())




def 				__magic_name__				(     __lowerCAmelCase			:		list	,						__lowerCAmelCase			:		int	,						__lowerCAmelCase			:		int	,						__lowerCAmelCase			:		int							)    ->     int:
				__lowerCamelCase					      =			int((lower_bound + upper_bound) // 2							)
				if array[r] == value:
								return r
				if lower_bound >= upper_bound:
								return -1
				if array[r] < value:
								return binary_search(__lowerCAmelCase	,						r + 1	,						__lowerCAmelCase	,						__lowerCAmelCase							)
				else:
								return binary_search(__lowerCAmelCase	,						__lowerCAmelCase	,						r - 1	,						__lowerCAmelCase							)




def 				__magic_name__				(     __lowerCAmelCase			:		int	,						__lowerCAmelCase			:		list							)    ->     list:
				__lowerCamelCase					      =			0
				if matrix[index][0] == value:
								return [index, 0]
				while index < len(__lowerCAmelCase							) and matrix[index][0] < value:
								__lowerCamelCase					      =			binary_search(matrix[index]	,						0	,						len(matrix[index]							) - 1	,						__lowerCAmelCase							)
								if r != -1:
												return [index, r]
								index += 1
				return [-1, -1]


if __name__ == "__main__":
					import doctest

					doctest.testmod()



