from collections.abc import Sequence







def 			A__      (	snake_case_ :		List[str]       ,				snake_case_ :		List[Any] = False      ):







 if not arr:
  return 0

 SCREAMING_SNAKE_CASE__:   Tuple=      0 if allow_empty_subarrays else float('''-inf'''      )
 SCREAMING_SNAKE_CASE__:   Dict=      0.0
 for num in arr:
  SCREAMING_SNAKE_CASE__:   Any=      max(0 if allow_empty_subarrays else num       ,				curr_sum + num      )
  SCREAMING_SNAKE_CASE__:   int=      max(__UpperCAmelCase       ,				__UpperCAmelCase      )

 return max_sum


if __name__ == "__main__":
    from doctest import testmod

    testmod()

    lowercase_     :   Optional[int] 				=				[-2, 1, -3, 4, -1, 2, 1, -5, 4]
    print(f'''{max_subarray_sum(nums) = }''')


import os







def 			A__      (	snake_case_ :		str = "matrix.txt"      ):
 with open(os.path.join(os.path.dirname(snake_case_      )       ,				snake_case_      )      ) as in_file:
  SCREAMING_SNAKE_CASE__:   Dict=      in_file.read()

 SCREAMING_SNAKE_CASE__:   Optional[int]=      [[int(snake_case_      ) for cell in row.split(''','''      )] for row in data.strip().splitlines()]
 SCREAMING_SNAKE_CASE__:   int=      [[0 for cell in row] for row in grid]
 SCREAMING_SNAKE_CASE__:   Dict=      len(grid[0]      )

 SCREAMING_SNAKE_CASE__:   Dict=      [[0 for i in range(snake_case_      )] for j in range(snake_case_      )]
 SCREAMING_SNAKE_CASE__:   Optional[int]=      grid[0][0]
 for i in range(1       ,				snake_case_      ):
  SCREAMING_SNAKE_CASE__:   Optional[int]=      grid[0][i] + dp[0][i - 1]
 for i in range(1       ,				snake_case_      ):
  SCREAMING_SNAKE_CASE__:   List[Any]=      grid[i][0] + dp[i - 1][0]

 for i in range(1       ,				snake_case_      ):
  for j in range(1       ,				snake_case_      ):
   SCREAMING_SNAKE_CASE__:   Dict=      grid[i][j] + min(dp[i - 1][j]       ,				dp[i][j - 1]      )

 return dp[-1][-1]


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

