



def 	_lowerCAmelCase						(				__lowerCamelCase   :     int		,	__lowerCamelCase   :     int		,	__lowerCamelCase   :     list[list[int]]     ):



 """simple docstring"""





 def update_area_of_max_square(__lowerCamelCase   :     int		,	__lowerCamelCase   :     int     ) -> int:
  # BASE CASE
  if row >= rows or col >= cols:
   return 0

  __SCREAMING_SNAKE_CASE       :    List[str]       =	update_area_of_max_square(__lowerCamelCase		,	col + 1     )
  __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	update_area_of_max_square(row + 1		,	col + 1     )
  __SCREAMING_SNAKE_CASE       :    Optional[int]       =	update_area_of_max_square(row + 1		,	__lowerCamelCase     )

  if mat[row][col]:
   __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	1 + min([right, diagonal, down]     )
   __SCREAMING_SNAKE_CASE       :    str       =	max(largest_square_area[0]		,	__lowerCamelCase     )
   return sub_problem_sol
  else:
   return 0

 __SCREAMING_SNAKE_CASE       :    Optional[int]       =	[0]
 update_area_of_max_square(0		,	0     )
 return largest_square_area[0]






def 	_lowerCAmelCase						(				__lowerCamelCase   :     int		,	__lowerCamelCase   :     int		,	__lowerCamelCase   :     list[list[int]]     ):



 """simple docstring"""





 def update_area_of_max_square_using_dp_array(
     __lowerCamelCase   :     int		,	__lowerCamelCase   :     int		,	__lowerCamelCase   :     list[list[int]]     ) -> int:
  if row >= rows or col >= cols:
   return 0
  if dp_array[row][col] != -1:
   return dp_array[row][col]

  __SCREAMING_SNAKE_CASE       :    Optional[int]       =	update_area_of_max_square_using_dp_array(__lowerCamelCase		,	col + 1		,	__lowerCamelCase     )
  __SCREAMING_SNAKE_CASE       :    List[Any]       =	update_area_of_max_square_using_dp_array(row + 1		,	col + 1		,	__lowerCamelCase     )
  __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	update_area_of_max_square_using_dp_array(row + 1		,	__lowerCamelCase		,	__lowerCamelCase     )

  if mat[row][col]:
   __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	1 + min([right, diagonal, down]     )
   __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	max(largest_square_area[0]		,	__lowerCamelCase     )
   __SCREAMING_SNAKE_CASE       :    Any       =	sub_problem_sol
   return sub_problem_sol
  else:
   return 0

 __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	[0]
 __SCREAMING_SNAKE_CASE       :    Tuple       =	[[-1] * cols for _ in range(__lowerCamelCase     )]
 update_area_of_max_square_using_dp_array(0		,	0		,	__lowerCamelCase     )

 return largest_square_area[0]






def 	_lowerCAmelCase						(				__lowerCamelCase   :     int		,	__lowerCamelCase   :     int		,	__lowerCamelCase   :     list[list[int]]     ):



 """simple docstring"""





 __SCREAMING_SNAKE_CASE       :    str       =	[[0] * (cols + 1) for _ in range(rows + 1     )]
 __SCREAMING_SNAKE_CASE       :    List[Any]       =	0
 for row in range(rows - 1		,	-1		,	-1     ):
  for col in range(cols - 1		,	-1		,	-1     ):
   __SCREAMING_SNAKE_CASE       :    Optional[int]       =	dp_array[row][col + 1]
   __SCREAMING_SNAKE_CASE       :    Dict       =	dp_array[row + 1][col + 1]
   __SCREAMING_SNAKE_CASE       :    Any       =	dp_array[row + 1][col]

   if mat[row][col] == 1:
    __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	1 + min(__lowerCamelCase		,	__lowerCamelCase		,	__lowerCamelCase     )
    __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	max(dp_array[row][col]		,	__lowerCamelCase     )
   else:
    __SCREAMING_SNAKE_CASE       :    Union[str, Any]       =	0

 return largest_square_area






def 	_lowerCAmelCase						(				__lowerCamelCase   :     int		,	__lowerCamelCase   :     int		,	__lowerCamelCase   :     list[list[int]]     ):



 """simple docstring"""





 __SCREAMING_SNAKE_CASE       :    Dict       =	[0] * (cols + 1)
 __SCREAMING_SNAKE_CASE       :    int       =	[0] * (cols + 1)
 __SCREAMING_SNAKE_CASE       :    Optional[int]       =	0
 for row in range(rows - 1		,	-1		,	-1     ):
  for col in range(cols - 1		,	-1		,	-1     ):
   __SCREAMING_SNAKE_CASE       :    List[Any]       =	current_row[col + 1]
   __SCREAMING_SNAKE_CASE       :    Tuple       =	next_row[col + 1]
   __SCREAMING_SNAKE_CASE       :    Dict       =	next_row[col]

   if mat[row][col] == 1:
    __SCREAMING_SNAKE_CASE       :    Optional[Any]       =	1 + min(__lowerCamelCase		,	__lowerCamelCase		,	__lowerCamelCase     )
    __SCREAMING_SNAKE_CASE       :    str       =	max(current_row[col]		,	__lowerCamelCase     )
   else:
    __SCREAMING_SNAKE_CASE       :    Tuple       =	0
  __SCREAMING_SNAKE_CASE       :    Any       =	current_row

 return largest_square_area


if __name__ == "__main__":
      import doctest

      doctest.testmod()
      print(largest_square_area_in_matrix_bottom_up(2, 2, [[1, 1], [1, 1]]))











from math import sqrt






def 	_lowerCAmelCase						(				__lowerCamelCase   :     int = 1000000     ):



 """simple docstring"""





 __SCREAMING_SNAKE_CASE       :    int       =	0
 __SCREAMING_SNAKE_CASE       :    int       =	0
 __SCREAMING_SNAKE_CASE       :    int

 while num_cuboids <= limit:
  max_cuboid_size += 1
  for sum_shortest_sides in range(2		,	2 * max_cuboid_size + 1     ):
   if sqrt(sum_shortest_sides**2 + max_cuboid_size**2     ).is_integer():
    num_cuboids += (
        min(__lowerCamelCase		,	sum_shortest_sides // 2     )
        - max(1		,	sum_shortest_sides - max_cuboid_size     )
        + 1
    )

 return max_cuboid_size


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






