
"""simple docstring"""





class A_	:




  '''simple docstring'''







  def __init__(		self  ):

     """simple docstring"""
     UpperCAmelCase_					:					List[Any]			     =    ""
     UpperCAmelCase_					:					Optional[int]			     =    ""
     UpperCAmelCase_					:					Optional[Any]			     =    []







  def        UpperCamelCase__					(		self				,   lowercase_				,   lowercase_  ):

     """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_					:					Any			     =    self.__min_dist_top_down_dp(m - 1				,   n - 1  )
        else:
           UpperCAmelCase_					:					int			     =    self.__min_dist_top_down_dp(lowercase_				,   n - 1  )
           UpperCAmelCase_					:					int			     =    self.__min_dist_top_down_dp(m - 1				,   lowercase_  )
           UpperCAmelCase_					:					Any			     =    self.__min_dist_top_down_dp(m - 1				,   n - 1  )
           UpperCAmelCase_					:					Union[str, Any]			     =    1 + min(lowercase_				,   lowercase_				,   lowercase_  )

        return self.dp[m][n]







  def        UpperCamelCase__					(		self				,   lowercase_				,   lowercase_  ):

     """simple docstring"""
     UpperCAmelCase_					:					int			     =    worda
     UpperCAmelCase_					:					Union[str, Any]			     =    worda
     UpperCAmelCase_					:					Union[str, Any]			     =    [[-1 for _ in range(len(lowercase_  )  )] for _ in range(len(lowercase_  )  )]

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







  def        UpperCamelCase__					(		self				,   lowercase_				,   lowercase_  ):

     """simple docstring"""
     UpperCAmelCase_					:					str			     =    worda
     UpperCAmelCase_					:					List[Any]			     =    worda
     UpperCAmelCase_					:					Any			     =    len(lowercase_  )
     UpperCAmelCase_					:					Dict			     =    len(lowercase_  )
     UpperCAmelCase_					:					str			     =    [[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_					:					Optional[Any]			     =    i
           elif worda[i - 1] == worda[j - 1]:  # last characters are equal
              UpperCAmelCase_					:					int			     =    self.dp[i - 1][j - 1]
           else:
              UpperCAmelCase_					:					Union[str, Any]			     =    self.dp[i][j - 1]
              UpperCAmelCase_					:					Union[str, Any]			     =    self.dp[i - 1][j]
              UpperCAmelCase_					:					Tuple			     =    self.dp[i - 1][j - 1]
              UpperCAmelCase_					:					Union[str, Any]			     =    1 + min(lowercase_				,   lowercase_				,   lowercase_  )
     return self.dp[m][n]


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

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

    _a		       =							input('Enter the first string: ').strip()
    _a		       =							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 ***************')




"""simple docstring"""





def 	__a     (		__lowerCamelCase = 3,		__lowerCamelCase = 7,		__lowerCamelCase = 100_0000  ):
   UpperCAmelCase_					:					Dict			     =    0
   UpperCAmelCase_					:					List[Any]			     =    1

   for current_denominator in range(1,		limit + 1  ):
      UpperCAmelCase_					:					Dict			     =    current_denominator * numerator // denominator
      if current_denominator % denominator == 0:
         current_numerator -= 1
      if current_numerator * max_denominator > current_denominator * max_numerator:
         UpperCAmelCase_					:					List[Any]			     =    current_numerator
         UpperCAmelCase_					:					Optional[int]			     =    current_denominator
   return max_numerator


if __name__ == "__main__":
    print(solution(numerator=3, denominator=7, limit=1_000_000))


