


"""simple docstring"""



def   __lowerCAmelCase						(						lowercase  :  int			)     ->						int:


    """simple docstring"""





    snake_case   :				Dict				 =   0
    while num > 0:
        digit_sum += num % 10
        num //= 10
    return digit_sum







def   __lowerCAmelCase						(						lowercase  :  int = 100			)     ->						int:


    """simple docstring"""





    snake_case   :				Dict				 =   1
    snake_case   :				Union[str, Any]				 =   2

    for i in range(2						,							max_n + 1			):
        snake_case   :				List[Any]				 =   pre_numerator
        snake_case   :				Dict				 =   2 * i // 3 if i % 3 == 0 else 1
        snake_case   :				Any				 =   cur_numerator
        snake_case   :				str				 =   e_cont * pre_numerator + temp

    return sum_digits(lowercase__			)


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










"""simple docstring"""



def   __lowerCAmelCase						(						lowercase  :  int						,							lowercase  :  int						,							lowercase  :  list[list[int]]			)     ->						int:


    """simple docstring"""





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

        snake_case   :				Dict				 =   update_area_of_max_square(lowercase						,							col + 1			)
        snake_case   :				Tuple				 =   update_area_of_max_square(row + 1						,							col + 1			)
        snake_case   :				Any				 =   update_area_of_max_square(row + 1						,							lowercase			)

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

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







def   __lowerCAmelCase						(						lowercase  :  int						,							lowercase  :  int						,							lowercase  :  list[list[int]]			)     ->						int:


    """simple docstring"""





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

        snake_case   :				List[str]				 =   update_area_of_max_square_using_dp_array(lowercase						,							col + 1						,							lowercase			)
        snake_case   :				Optional[int]				 =   update_area_of_max_square_using_dp_array(row + 1						,							col + 1						,							lowercase			)
        snake_case   :				Optional[int]				 =   update_area_of_max_square_using_dp_array(row + 1						,							lowercase						,							lowercase			)

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

    snake_case   :				Union[str, Any]				 =   [0]
    snake_case   :				int				 =   [[-1] * cols for _ in range(lowercase			)]
    update_area_of_max_square_using_dp_array(0						,							0						,							lowercase			)

    return largest_square_area[0]







def   __lowerCAmelCase						(						lowercase  :  int						,							lowercase  :  int						,							lowercase  :  list[list[int]]			)     ->						int:


    """simple docstring"""





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

            if mat[row][col] == 1:
                snake_case   :				Optional[int]				 =   1 + min(lowercase						,							lowercase						,							lowercase			)
                snake_case   :				Tuple				 =   max(dp_array[row][col]						,							lowercase			)
            else:
                snake_case   :				List[Any]				 =   0

    return largest_square_area







def   __lowerCAmelCase						(						lowercase  :  int						,							lowercase  :  int						,							lowercase  :  list[list[int]]			)     ->						int:


    """simple docstring"""





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

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





