





'''simple docstring'''

import os

def     __magic_name__							(				__UpperCAmelCase = "input.txt"   )    ->       str:

   '''simple docstring'''







   with open(os.path.join(os.path.dirname(_UpperCAmelCase   )				,						_UpperCAmelCase   )   ) as input_file:
      __SCREAMING_SNAKE_CASE   				=							[
          [int(_UpperCAmelCase   ) for element in line.split(""","""   )]
          for line in input_file.readlines()
      ]

   __SCREAMING_SNAKE_CASE   				=							len(_UpperCAmelCase   )
   __SCREAMING_SNAKE_CASE   				=							len(matrix[0]   )

   __SCREAMING_SNAKE_CASE   				=							[[-1 for _ in range(_UpperCAmelCase   )] for _ in range(_UpperCAmelCase   )]
   for i in range(_UpperCAmelCase   ):
      __SCREAMING_SNAKE_CASE   				=							matrix[i][0]

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

      for i in range(1				,						_UpperCAmelCase   ):
         __SCREAMING_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   ):
         __SCREAMING_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() = }''')












"""simple docstring"""
from __future__ import annotations

def 		_SCREAMING_SNAKE_CASE			(_UpperCAmelCase					:    list[float]			):
 lowerCAmelCase    				= 0.00
 lowerCAmelCase    				= 0
 for resistor in resistors:
  if resistor <= 0:
   lowerCAmelCase    				= F'Resistor at index {index} has a negative or zero value!'
   raise ValueError(_UpperCAmelCase			)
  first_sum += 1 / float(_UpperCAmelCase			)
  index += 1
 return 1 / first_sum

def 		_SCREAMING_SNAKE_CASE			(_UpperCAmelCase					:    list[float]			):
 lowerCAmelCase    				= 0.00
 lowerCAmelCase    				= 0
 for resistor in resistors:
  sum_r += resistor
  if resistor < 0:
   lowerCAmelCase    				= F'Resistor at index {index} has a negative value!'
   raise ValueError(_UpperCAmelCase			)
  index += 1
 return sum_r


if __name__ == "__main__":
       import doctest

       doctest.testmod()





