






"""simple docstring"""



from __future__ import annotations

import math



def 		lowercase       (							__snake_case							:					Optional[int]						,   __snake_case							:					Any						,   __snake_case							:					Tuple						,   __snake_case							:					Dict						,   __snake_case							:					str      ):

		if depth < 0:
				raise ValueError('''Depth cannot be less than 0'''      )

		if not scores:
				raise ValueError('''Scores cannot be empty'''      )

		if depth == height:
				return scores[node_index]

		return (
		    max(
		        minimax(depth + 1						,   node_index * 2						,   UpperCAmelCase_						,   UpperCAmelCase_						,   UpperCAmelCase_      )						,   minimax(depth + 1						,   node_index * 2 + 1						,   UpperCAmelCase_						,   UpperCAmelCase_						,   UpperCAmelCase_      )						,   )
		    if is_max
		    else min(
		        minimax(depth + 1						,   node_index * 2						,   UpperCAmelCase_						,   UpperCAmelCase_						,   UpperCAmelCase_      )						,   minimax(depth + 1						,   node_index * 2 + 1						,   UpperCAmelCase_						,   UpperCAmelCase_						,   UpperCAmelCase_      )						,   )
		)



def 		lowercase       (							):
		lowercase_					:					Tuple							=  [9_0, 2_3, 6, 3_3, 2_1, 6_5, 1_2_3, 3_4_4_2_3]
		lowercase_					:					Dict							=  math.log(len(UpperCAmelCase_      )						,   2      )
		print(F'''Optimal value : {minimax(0						,   0						,   UpperCAmelCase_						,   UpperCAmelCase_						,   UpperCAmelCase_      )}'''      )


if __name__ == "__main__":
						import doctest

						doctest.testmod()
						main()










'''simple docstring'''




import os




def 						__lowerCamelCase			(	UpperCAmelCase_ = "input.txt"							)   ->int:

	with open(os.path.join(os.path.dirname(UpperCAmelCase_							)					,				UpperCAmelCase_							)							) as input_file:
		snake_case__	       =   [
		    [int(UpperCAmelCase_							) for element in line.split(','							)]
		    for line in input_file.readlines()
		]

	snake_case__	       =   len(UpperCAmelCase_							)
	snake_case__	       =   len(matrix[0]							)

	snake_case__	       =   [[-1 for _ in range(UpperCAmelCase_							)] for _ in range(UpperCAmelCase_							)]
	for i in range(UpperCAmelCase_							):
		snake_case__	       =   matrix[i][0]

	for j in range(1					,				UpperCAmelCase_							):
		for i in range(UpperCAmelCase_							):
			snake_case__	       =   minimal_path_sums[i][j - 1] + matrix[i][j]

		for i in range(1					,				UpperCAmelCase_							):
			snake_case__	       =   min(
			    minimal_path_sums[i][j]					,				minimal_path_sums[i - 1][j] + matrix[i][j]							)

		for i in range(rows - 2					,				-1					,				-1							):
			snake_case__	       =   min(
			    minimal_path_sums[i][j]					,				minimal_path_sums[i + 1][j] + matrix[i][j]							)

	return min(minimal_path_sums_row[-1] for minimal_path_sums_row in minimal_path_sums							)


if __name__ == "__main__":
			print(f"""{solution() = }""")



