



'''simple docstring'''




def    __lowerCamelCase						(      _lowercase			,       _lowercase			,       _lowercase	)   ->    Tuple:






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

														UpperCAmelCase  :	Any							  =	update_area_of_max_square(a__			,       col + 1	)
														UpperCAmelCase  :	List[Any]							  =	update_area_of_max_square(row + 1			,       col + 1	)
														UpperCAmelCase  :	Union[str, Any]							  =	update_area_of_max_square(row + 1			,       a__	)

														if mat[row][col]:
																					UpperCAmelCase  :	List[str]							  =	1 + min([right, diagonal, down]	)
																					UpperCAmelCase  :	Optional[int]							  =	max(largest_square_area[0]			,       a__	)
																					return sub_problem_sol
														else:
																					return 0

							UpperCAmelCase  :	Any							  =	[0]
							update_area_of_max_square(0			,       0	)
							return largest_square_area[0]



def    __lowerCamelCase						(      _lowercase			,       _lowercase			,       _lowercase	)   ->    Tuple:






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

														UpperCAmelCase  :	str							  =	update_area_of_max_square_using_dp_array(a__			,       col + 1			,       a__	)
														UpperCAmelCase  :	Any							  =	update_area_of_max_square_using_dp_array(row + 1			,       col + 1			,       a__	)
														UpperCAmelCase  :	Optional[int]							  =	update_area_of_max_square_using_dp_array(row + 1			,       a__			,       a__	)

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

							UpperCAmelCase  :	Any							  =	[0]
							UpperCAmelCase  :	Any							  =	[[-1] * cols for _ in range(a__	)]
							update_area_of_max_square_using_dp_array(0			,       0			,       a__	)

							return largest_square_area[0]



def    __lowerCamelCase						(      _lowercase			,       _lowercase			,       _lowercase	)   ->    List[str]:
							UpperCAmelCase  :	List[str]							  =	[[0] * (cols + 1) for _ in range(rows + 1	)]
							UpperCAmelCase  :	str							  =	0
							for row in range(rows - 1			,       -1			,       -1	):
														for col in range(cols - 1			,       -1			,       -1	):
																					UpperCAmelCase  :	Optional[int]							  =	dp_array[row][col + 1]
																					UpperCAmelCase  :	List[str]							  =	dp_array[row + 1][col + 1]
																					UpperCAmelCase  :	Any							  =	dp_array[row + 1][col]

																					if mat[row][col] == 1:
																												UpperCAmelCase  :	Tuple							  =	1 + min(a__			,       a__			,       a__	)
																												UpperCAmelCase  :	Tuple							  =	max(dp_array[row][col]			,       a__	)
																					else:
																												UpperCAmelCase  :	Union[str, Any]							  =	0

							return largest_square_area



def    __lowerCamelCase						(      _lowercase			,       _lowercase			,       _lowercase	)   ->    Tuple:
							UpperCAmelCase  :	Dict							  =	[0] * (cols + 1)
							UpperCAmelCase  :	Optional[int]							  =	[0] * (cols + 1)
							UpperCAmelCase  :	str							  =	0
							for row in range(rows - 1			,       -1			,       -1	):
														for col in range(cols - 1			,       -1			,       -1	):
																					UpperCAmelCase  :	Tuple							  =	current_row[col + 1]
																					UpperCAmelCase  :	Optional[Any]							  =	next_row[col + 1]
																					UpperCAmelCase  :	Any							  =	next_row[col]

																					if mat[row][col] == 1:
																												UpperCAmelCase  :	Union[str, Any]							  =	1 + min(a__			,       a__			,       a__	)
																												UpperCAmelCase  :	Optional[int]							  =	max(current_row[col]			,       a__	)
																					else:
																												UpperCAmelCase  :	List[str]							  =	0
														UpperCAmelCase  :	Optional[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]]))









'''simple docstring'''




a     :    Tuple      						=					[sum(int(c, 1_0) ** 2 for c in i.__str__()) for i in range(1_0_0_0_0_0)]



def    __lowerCamelCase						(      _lowercase	)   ->    int:
							UpperCAmelCase  :	str							  =	0
							while number:
														# Increased Speed Slightly by checking every 5 digits together.
														sum_of_digits_squared += DIGITS_SQUARED[number % 1_0_0_0_0_0]
														number //= 1_0_0_0_0_0

							return sum_of_digits_squared


# There are 2 Chains made,
# One ends with 89 with the chain member 58 being the one which when declared first,
# there will be the least number of iterations for all the members to be checked.

# The other one ends with 1 and has only one element 1.

# So 58 and 1 are chosen to be declared at the starting.

# Changed dictionary to an array to quicken the solution
a     :    list[bool | None]      						=					[None] * 1_0_0_0_0_0_0_0
a     :    Optional[Any]      						=					True
a     :    List[Any]      						=					False



def    __lowerCamelCase						(      _lowercase	)   ->    bool:

							if CHAINS[number - 1] is not None:
														return CHAINS[number - 1]  # type: ignore

							UpperCAmelCase  :	List[str]							  =	chain(next_number(_lowercase	)	)
							UpperCAmelCase  :	Tuple							  =	number_chain

							while number < 1_0_0_0_0_0_0_0:
														UpperCAmelCase  :	List[str]							  =	number_chain
														number *= 1_0

							return number_chain



def    __lowerCamelCase						(      _lowercase = 1_0_0_0_0_0_0_0	)   ->    int:
							for i in range(1			,       _lowercase	):
														if CHAINS[i] is None:
																					chain(i + 1	)

							return CHAINS[:number].count(_lowercase	)


if __name__ == "__main__":
							import doctest

							doctest.testmod()
							print(F'''{solution() = }''')

