





import os

def   a_    ( lowerCAmelCase_      :			str = "input.txt"	):

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

   __lowerCAmelCase								=	len(lowerCAmelCase_	)
   __lowerCAmelCase								=	len(matrix[0]	)

   __lowerCAmelCase								=	[[-1 for _ in range(lowerCAmelCase_	)] for _ in range(lowerCAmelCase_	)]
   for i in range(lowerCAmelCase_	):
      __lowerCAmelCase								=	matrix[i][0]

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

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

      for i in range(rows - 2,	-1,	-1	):
         __lowerCAmelCase								=	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() = }""")








from __future__ import annotations

import math

def   a_    ( lowerCAmelCase_      :			int,	lowerCAmelCase_      :			int,	lowerCAmelCase_      :			bool,	lowerCAmelCase_      :			list[int],	lowerCAmelCase_      :			float	):

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

   if len(lowerCAmelCase_	) == 0:
      raise ValueError('Scores cannot be empty'	)

   if depth == height:
      return scores[node_index]

   if is_max:
      return max(
          minimax(depth + 1,	node_index * 2,	lowerCAmelCase_,	lowerCAmelCase_,	lowerCAmelCase_	),	minimax(depth + 1,	node_index * 2 + 1,	lowerCAmelCase_,	lowerCAmelCase_,	lowerCAmelCase_	),	)

   return min(
       minimax(depth + 1,	node_index * 2,	lowerCAmelCase_,	lowerCAmelCase_,	lowerCAmelCase_	),	minimax(depth + 1,	node_index * 2 + 1,	lowerCAmelCase_,	lowerCAmelCase_,	lowerCAmelCase_	),	)

def   a_    ( ):
   __lowerCAmelCase								=	[90, 23, 6, 33, 21, 65, 123, 3_4423]
   __lowerCAmelCase								=	math.log(len(lowerCAmelCase_	),	2	)
   print('Optimal value : ',	end=''	)
   print(minimax(0,	0,	lowerCAmelCase_,	lowerCAmelCase_,	lowerCAmelCase_	)	)


if __name__ == "__main__":
     import doctest

     doctest.testmod()
     main()

