
"""simple docstring"""





def 	__a     (		__lowerCamelCase,		__lowerCamelCase,		__lowerCamelCase  ):

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

      UpperCAmelCase_					:					Dict			     =    update_area_of_max_square(__lowerCamelCase,		col + 1  )
      UpperCAmelCase_					:					List[str]			     =    update_area_of_max_square(row + 1,		col + 1  )
      UpperCAmelCase_					:					Union[str, Any]			     =    update_area_of_max_square(row + 1,		__lowerCamelCase  )

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

   UpperCAmelCase_					:					Union[str, Any]			     =    [0]
   update_area_of_max_square(0,		0  )
   return largest_square_area[0]







def 	__a     (		__lowerCamelCase,		__lowerCamelCase,		__lowerCamelCase  ):

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

      UpperCAmelCase_					:					Union[str, Any]			     =    update_area_of_max_square_using_dp_array(__lowerCamelCase,		col + 1,		__lowerCamelCase  )
      UpperCAmelCase_					:					Optional[Any]			     =    update_area_of_max_square_using_dp_array(row + 1,		col + 1,		__lowerCamelCase  )
      UpperCAmelCase_					:					List[Any]			     =    update_area_of_max_square_using_dp_array(row + 1,		__lowerCamelCase,		__lowerCamelCase  )

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

   UpperCAmelCase_					:					Tuple			     =    [0]
   UpperCAmelCase_					:					str			     =    [[-1] * cols for _ in range(__lowerCamelCase  )]
   update_area_of_max_square_using_dp_array(0,		0,		__lowerCamelCase  )

   return largest_square_area[0]







def 	__a     (		__lowerCamelCase,		__lowerCamelCase,		__lowerCamelCase  ):
   UpperCAmelCase_					:					Optional[int]			     =    [[0] * (cols + 1) for _ in range(rows + 1  )]
   UpperCAmelCase_					:					Dict			     =    0
   for row in range(rows - 1,		-1,		-1  ):
      for col in range(cols - 1,		-1,		-1  ):
         UpperCAmelCase_					:					List[str]			     =    dp_array[row][col + 1]
         UpperCAmelCase_					:					Tuple			     =    dp_array[row + 1][col + 1]
         UpperCAmelCase_					:					Tuple			     =    dp_array[row + 1][col]

         if mat[row][col] == 1:
            UpperCAmelCase_					:					Tuple			     =    1 + min(__lowerCamelCase,		__lowerCamelCase,		__lowerCamelCase  )
            UpperCAmelCase_					:					Any			     =    max(dp_array[row][col],		__lowerCamelCase  )
         else:
            UpperCAmelCase_					:					int			     =    0

   return largest_square_area







def 	__a     (		__lowerCamelCase,		__lowerCamelCase,		__lowerCamelCase  ):
   UpperCAmelCase_					:					Optional[Any]			     =    [0] * (cols + 1)
   UpperCAmelCase_					:					int			     =    [0] * (cols + 1)
   UpperCAmelCase_					:					List[Any]			     =    0
   for row in range(rows - 1,		-1,		-1  ):
      for col in range(cols - 1,		-1,		-1  ):
         UpperCAmelCase_					:					str			     =    current_row[col + 1]
         UpperCAmelCase_					:					str			     =    next_row[col + 1]
         UpperCAmelCase_					:					int			     =    next_row[col]

         if mat[row][col] == 1:
            UpperCAmelCase_					:					Any			     =    1 + min(__lowerCamelCase,		__lowerCamelCase,		__lowerCamelCase  )
            UpperCAmelCase_					:					List[str]			     =    max(current_row[col],		__lowerCamelCase  )
         else:
            UpperCAmelCase_					:					Tuple			     =    0
      UpperCAmelCase_					:					Dict			     =    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"""





from collections import namedtuple

_a		       =							namedtuple('from_to', 'from_ to')

_a		       =							{
    'cubicmeter': from_to(1, 1),
    'litre': from_to(0.001, 1_000),
    'kilolitre': from_to(1, 1),
    'gallon': from_to(0.0_0454, 264.172),
    'cubicyard': from_to(0.7_6455, 1.3_0795),
    'cubicfoot': from_to(0.028, 35.3147),
    'cup': from_to(0.0_0023_6588, 4226.75),
}







def 	__a     (		__lowerCamelCase,		__lowerCamelCase,		__lowerCamelCase  ):
   if from_type not in METRIC_CONVERSION:
      raise ValueError(
          f"""Invalid 'from_type' value: {from_type!r}  Supported values are:\n"""
          + ", ".join(__lowerCamelCase  )  )
   if to_type not in METRIC_CONVERSION:
      raise ValueError(
          f"""Invalid 'to_type' value: {to_type!r}.  Supported values are:\n"""
          + ", ".join(__lowerCamelCase  )  )
   return value * METRIC_CONVERSION[from_type].from_ * METRIC_CONVERSION[to_type].to


if __name__ == "__main__":
    import doctest

    doctest.testmod()


