
from __future__ import annotations

from collections.abc import Callable

lowerCamelCase      =list[list[float | int]]


def 							SCREAMING_SNAKE_CASE_      (			UpperCamelCase__ ,		UpperCamelCase__		):
      UpperCamelCase__    :   int					=				len(UpperCamelCase__		)
      UpperCamelCase__    :   Matrix					=				[[0 for _ in range(size + 1		)] for _ in range(UpperCamelCase__		)]
      UpperCamelCase__    :   int
      UpperCamelCase__    :   int
      UpperCamelCase__    :   int
      UpperCamelCase__    :   int
      UpperCamelCase__    :   int
      UpperCamelCase__    :   float

      for row in range(UpperCamelCase__		):
            for col in range(UpperCamelCase__		):
                  UpperCamelCase__    :   List[str]					=				matrix[row][col]

            UpperCamelCase__    :   Any					=				vector[row][0]

      UpperCamelCase__    :   List[str]					=				0
      UpperCamelCase__    :   Optional[Any]					=				0
      while row < size and col < size:
            # pivoting
            UpperCamelCase__    :   Optional[int]					=				max((abs(augmented[rowa][col]		), rowa) for rowa in range(UpperCamelCase__ ,		UpperCamelCase__		)		)[
                1
            ]
            if augmented[pivot_row][col] == 0:
                  col += 1
                  continue
            else:
                  UpperCamelCase__				,UpperCamelCase__    :   Union[str, Any]					=				augmented[pivot_row], augmented[row]

            for rowa in range(row + 1 ,		UpperCamelCase__		):
                  UpperCamelCase__    :   Dict					=				augmented[rowa][col] / augmented[row][col]
                  UpperCamelCase__    :   Union[str, Any]					=				0
                  for cola in range(col + 1 ,		size + 1		):
                        augmented[rowa][cola] -= augmented[row][cola] * ratio

            row += 1
            col += 1

      # back substitution
      for col in range(1 ,		UpperCamelCase__		):
            for row in range(UpperCamelCase__		):
                  UpperCamelCase__    :   Union[str, Any]					=				augmented[row][col] / augmented[col][col]
                  for cola in range(UpperCamelCase__ ,		size + 1		):
                        augmented[row][cola] -= augmented[col][cola] * ratio

    # round to get rid of numbers like 2.000000000000004
      return [
          [round(augmented[row][size] / augmented[row][row] ,		1_0		)] for row in range(UpperCamelCase__		)
      ]


def 							SCREAMING_SNAKE_CASE_      (			UpperCamelCase__		):
      UpperCamelCase__    :   int					=				len(UpperCamelCase__		)
      UpperCamelCase__    :   Matrix					=				[[0 for _ in range(UpperCamelCase__		)] for _ in range(UpperCamelCase__		)]
      UpperCamelCase__    :   Matrix					=				[[0] for _ in range(UpperCamelCase__		)]
      UpperCamelCase__    :   Matrix
      UpperCamelCase__    :   int
      UpperCamelCase__    :   int
      UpperCamelCase__    :   int

      for x_val, y_val in enumerate(UpperCamelCase__		):
            for col in range(UpperCamelCase__		):
                  UpperCamelCase__    :   int					=				(x_val + 1) ** (size - col - 1)
            UpperCamelCase__    :   Optional[Any]					=				y_val

      UpperCamelCase__    :   List[Any]					=				solve(UpperCamelCase__ ,		UpperCamelCase__		)

      def interpolated_func(UpperCamelCase__		) -> int:
            return sum(
                round(coeffs[x_val][0]		) * (var ** (size - x_val - 1))
                for x_val in range(UpperCamelCase__		)		)

      return interpolated_func


def 							SCREAMING_SNAKE_CASE_      (			UpperCamelCase__		):
      return (
          1
          - variable
          + variable**2
          - variable**3
          + variable**4
          - variable**5
          + variable**6
          - variable**7
          + variable**8
          - variable**9
          + variable**1_0
      )


def 							SCREAMING_SNAKE_CASE_      (			UpperCamelCase__ = question_function ,		UpperCamelCase__ = 1_0		):
      UpperCamelCase__    :   list[int]					=				[func(UpperCamelCase__		) for x_val in range(1 ,		order + 1		)]

      UpperCamelCase__    :   list[Callable[[int], int]]					=				[
          interpolate(data_points[:max_coeff]		) for max_coeff in range(1 ,		order + 1		)
      ]

      UpperCamelCase__    :   int					=				0
      UpperCamelCase__    :   Callable[[int], int]
      UpperCamelCase__    :   int

      for poly in polynomials:
            UpperCamelCase__    :   str					=				1
            while func(UpperCamelCase__		) == poly(UpperCamelCase__		):
                  x_val += 1

            ret += poly(UpperCamelCase__		)

      return ret


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




class 				_lowerCamelCase :





     """simple docstring"""







     def __init__(							self  )  ->   Tuple:




           """simple docstring"""







           UpperCamelCase__    :   Union[str, Any]					=				''''''
           UpperCamelCase__    :   int					=				''''''
           UpperCamelCase__    :   Optional[int]					=				[]






     def    __SCREAMING_SNAKE_CASE			(							self						,						__SCREAMING_SNAKE_CASE						,						__SCREAMING_SNAKE_CASE  )  ->   int:




           """simple docstring"""







           if m == -1:
                 return n + 1
           elif n == -1:
                 return m + 1
           elif self.dp[m][n] > -1:
                 return self.dp[m][n]
           else:
                 if self.worda[m] == self.worda[n]:
                       UpperCamelCase__    :   Union[str, Any]					=				self.__min_dist_top_down_dp(m - 1						,						n - 1  )
                 else:
                       UpperCamelCase__    :   int					=				self.__min_dist_top_down_dp(__SCREAMING_SNAKE_CASE						,						n - 1  )
                       UpperCamelCase__    :   Tuple					=				self.__min_dist_top_down_dp(m - 1						,						__SCREAMING_SNAKE_CASE  )
                       UpperCamelCase__    :   Optional[Any]					=				self.__min_dist_top_down_dp(m - 1						,						n - 1  )
                       UpperCamelCase__    :   Optional[int]					=				1 + min(__SCREAMING_SNAKE_CASE						,						__SCREAMING_SNAKE_CASE						,						__SCREAMING_SNAKE_CASE  )

                 return self.dp[m][n]






     def    __SCREAMING_SNAKE_CASE			(							self						,						__SCREAMING_SNAKE_CASE						,						__SCREAMING_SNAKE_CASE  )  ->   int:




           """simple docstring"""







           UpperCamelCase__    :   Union[str, Any]					=				worda
           UpperCamelCase__    :   Any					=				worda
           UpperCamelCase__    :   List[str]					=				[[-1 for _ in range(len(__SCREAMING_SNAKE_CASE  )  )] for _ in range(len(__SCREAMING_SNAKE_CASE  )  )]

           return self.__min_dist_top_down_dp(len(__SCREAMING_SNAKE_CASE  ) - 1						,						len(__SCREAMING_SNAKE_CASE  ) - 1  )






     def    __SCREAMING_SNAKE_CASE			(							self						,						__SCREAMING_SNAKE_CASE						,						__SCREAMING_SNAKE_CASE  )  ->   int:




           """simple docstring"""







           UpperCamelCase__    :   int					=				worda
           UpperCamelCase__    :   List[str]					=				worda
           UpperCamelCase__    :   int					=				len(__SCREAMING_SNAKE_CASE  )
           UpperCamelCase__    :   Optional[Any]					=				len(__SCREAMING_SNAKE_CASE  )
           UpperCamelCase__    :   int					=				[[0 for _ in range(n + 1  )] for _ in range(m + 1  )]

           for i in range(m + 1  ):
                 for j in range(n + 1  ):
                       if i == 0:  # first string is empty
                             UpperCamelCase__    :   List[Any]					=				j
                       elif j == 0:  # second string is empty
                             UpperCamelCase__    :   Union[str, Any]					=				i
                       elif worda[i - 1] == worda[j - 1]:  # last characters are equal
                             UpperCamelCase__    :   List[Any]					=				self.dp[i - 1][j - 1]
                       else:
                             UpperCamelCase__    :   Union[str, Any]					=				self.dp[i][j - 1]
                             UpperCamelCase__    :   str					=				self.dp[i - 1][j]
                             UpperCamelCase__    :   Union[str, Any]					=				self.dp[i - 1][j - 1]
                             UpperCamelCase__    :   List[Any]					=				1 + min(__SCREAMING_SNAKE_CASE						,						__SCREAMING_SNAKE_CASE						,						__SCREAMING_SNAKE_CASE  )
           return self.dp[m][n]


if __name__ == "__main__":
    lowerCamelCase      =EditDistance()

    print("****************** Testing Edit Distance DP Algorithm ******************")
    print()

    lowerCamelCase      =input("Enter the first string: ").strip()
    lowerCamelCase      =input("Enter the second string: ").strip()

    print()
    print(F'''The minimum edit distance is: {solver.min_dist_top_down(Sa, Sa)}''')
    print(F'''The minimum edit distance is: {solver.min_dist_bottom_up(Sa, Sa)}''')
    print()
    print("*************** End of Testing Edit Distance DP Algorithm ***************")


