

'''simple docstring'''
import os


def        _lowerCAmelCase					(						_UpperCamelCase						:     Union[str, Any]				)      ->			Optional[Any]:
     """simple docstring"""




     _SCREAMING_SNAKE_CASE							    =len(grid[0]				)
     _SCREAMING_SNAKE_CASE							    =len(_UpperCamelCase				)

     _SCREAMING_SNAKE_CASE							    =0
     _SCREAMING_SNAKE_CASE							    =0
     _SCREAMING_SNAKE_CASE							    =0

     # Check vertically, horizontally, diagonally at the same time (only works
     # for nxn grid)
     for i in range(_UpperCamelCase				):
          for j in range(n_rows - 3				):
               _SCREAMING_SNAKE_CASE							    =grid[j][i] * grid[j + 1][i] * grid[j + 2][i] * grid[j + 3][i]
               _SCREAMING_SNAKE_CASE							    =grid[i][j] * grid[i][j + 1] * grid[i][j + 2] * grid[i][j + 3]

               # Left-to-right diagonal (\) product
               if i < n_columns - 3:
                    _SCREAMING_SNAKE_CASE							    =(
                        grid[i][j]
                        * grid[i + 1][j + 1]
                        * grid[i + 2][j + 2]
                        * grid[i + 3][j + 3]
                    )

               # Right-to-left diagonal(/) product
               if i > 2:
                    _SCREAMING_SNAKE_CASE							    =(
                        grid[i][j]
                        * grid[i - 1][j + 1]
                        * grid[i - 2][j + 2]
                        * grid[i - 3][j + 3]
                    )

               _SCREAMING_SNAKE_CASE							    =max(
                   _UpperCamelCase							, _UpperCamelCase							, _UpperCamelCase							, _UpperCamelCase				)
               if max_product > largest:
                    _SCREAMING_SNAKE_CASE							    =max_product

     return largest


def        _lowerCAmelCase					(						)      ->			Any:
     """simple docstring"""




     _SCREAMING_SNAKE_CASE							    =[]
     with open(os.path.dirname(_UpperCamelCase				) + '/grid.txt'				) as file:
          for line in file:
               grid.append(line.strip('\n'				).split(' '				)				)

     _SCREAMING_SNAKE_CASE							    =[[int(_UpperCamelCase				) for i in grid[j]] for j in range(len(_UpperCamelCase				)				)]

     return largest_product(_UpperCamelCase				)


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





'''simple docstring'''




from __future__ import annotations


def 				lowerCAmelCase_   (	_lowerCamelCase:   list[int]       ,      _lowerCamelCase:   list[int]       ,      _lowerCamelCase:   int					):
		__SCREAMING_SNAKE_CASE       :		List[Any]           =		list(range(len(_lowerCamelCase					)					)					)
		__SCREAMING_SNAKE_CASE       :		Optional[Any]           =		[v / w for v, w in zip(_lowerCamelCase       ,      _lowerCamelCase					)]
		index.sort(key=lambda _lowerCamelCase					: ratio[i]       ,      reverse=_lowerCamelCase					)

		__SCREAMING_SNAKE_CASE       :		float           =		0
		__SCREAMING_SNAKE_CASE       :		list[float]           =		[0] * len(_lowerCamelCase					)
		for i in index:
				if weight[i] <= capacity:
						__SCREAMING_SNAKE_CASE       :		str           =		1
						max_value += value[i]
						capacity -= weight[i]
				else:
						__SCREAMING_SNAKE_CASE       :		int           =		capacity / weight[i]
						max_value += value[i] * capacity / weight[i]
						break

		return max_value, fractions


if __name__ == "__main__":
						import doctest

						doctest.testmod()