





"""simple docstring"""




import builtins
import sys

from ...utils.imports import _is_package_available
from . import cursor, input
from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor
from .keymap import KEYMAP


A   : List[str]			=				False
try:
					A   : Tuple			=				_is_package_available('''google.colab''')
except ModuleNotFoundError:
					pass


@input.register
class   A      :
			'''simple docstring'''




			def __init__(      self       :   Optional[int]							,     __lowerCAmelCase       :   str = None							,     __lowerCAmelCase       :   list = []       )     ->     List[Any]:







					"""simple docstring"""






					A__  				=       0
					A__  				=       choices
					A__  				=       prompt
					if sys.platform == "win32":
							A__  				=       """*"""
					else:
							A__  				=       """➔ """






			def        a_	(      self       :   Dict							,     __lowerCAmelCase       :   Tuple							,     __lowerCAmelCase       :   str = ""       )     ->     str:







					"""simple docstring"""






					if sys.platform != "win32":
							writeColor(self.choices[index]							,     32							,     _UpperCAmelCase       )
					else:
							forceWrite(self.choices[index]							,     _UpperCAmelCase       )






			def        a_	(      self       :   List[str]							,     __lowerCAmelCase       :   int       )     ->     Optional[Any]:







					"""simple docstring"""






					if index == self.position:
							forceWrite(f' {self.arrow_char} '       )
							self.write_choice(_UpperCAmelCase       )
					else:
							forceWrite(f'    {self.choices[index]}'       )
					reset_cursor()






			def        a_	(      self       :   Optional[Any]							,     __lowerCAmelCase       :   Direction							,     __lowerCAmelCase       :   int = 1       )     ->     Dict:







					"""simple docstring"""






					A__  				=       self.position
					if direction == Direction.DOWN:
							if self.position + 1 >= len(self.choices       ):
									return
							self.position += num_spaces
					else:
							if self.position - 1 < 0:
									return
							self.position -= num_spaces
					clear_line()
					self.print_choice(_UpperCAmelCase       )
					move_cursor(_UpperCAmelCase							,     direction.name       )
					self.print_choice(self.position       )






			@input.mark(KEYMAP["""up"""]       )
			def        a_	(      self       :   Union[str, Any]       )     ->     Optional[Any]:







					"""simple docstring"""






					self.move_direction(Direction.UP       )






			@input.mark(KEYMAP["""down"""]       )
			def        a_	(      self       :   Dict       )     ->     Tuple:







					"""simple docstring"""






					self.move_direction(Direction.DOWN       )






			@input.mark(KEYMAP["""newline"""]       )
			def        a_	(      self       :   Optional[Any]       )     ->     Optional[Any]:







					"""simple docstring"""






					move_cursor(len(self.choices       ) - self.position							,     """DOWN"""       )
					return self.position






			@input.mark(KEYMAP["""interrupt"""]       )
			def        a_	(      self       :   Optional[int]       )     ->     str:







					"""simple docstring"""






					move_cursor(len(self.choices       ) - self.position							,     """DOWN"""       )
					raise KeyboardInterrupt






			@input.mark_multiple(*[KEYMAP[str(_UpperCAmelCase       )] for number in range(10       )]       )
			def        a_	(      self       :   Tuple       )     ->     Union[str, Any]:







					"""simple docstring"""






					A__  				=       int(chr(self.current_selection       )       )
					A__  				=       index - self.position
					if index == self.position:
							return
					if index < len(self.choices       ):
							if self.position > index:
									self.move_direction(Direction.UP							,     -movement       )
							elif self.position < index:
									self.move_direction(Direction.DOWN							,     _UpperCAmelCase       )
							else:
									return
					else:
							return







			def        a_	(      self       :   int							,     __lowerCAmelCase       :   int = 0       )     ->     str:







					"""simple docstring"""






					if self.prompt:
							linebreak()
							forceWrite(self.prompt							,     """\n"""       )
							if in_colab:
									forceWrite("""Please input a choice index (starting from 0), and press enter"""							,     """\n"""       )
							else:
									forceWrite("""Please select a choice using the arrow or number keys, and selecting with enter"""							,     """\n"""       )
					A__  				=       default_choice
					for i in range(len(self.choices       )       ):
							self.print_choice(_UpperCAmelCase       )
							forceWrite("""\n"""       )
					move_cursor(len(self.choices       ) - self.position							,     """UP"""       )
					with cursor.hide():
							while True:
									if in_colab:
											try:
													A__  				=       int(builtins.input()       )
											except ValueError:
													A__  				=       default_choice
									else:
											A__  				=       self.handle_input()
									if choice is not None:
											reset_cursor()
											for _ in range(len(self.choices       ) + 1       ):
													move_cursor(1							,     """UP"""       )
													clear_line()
											self.write_choice(_UpperCAmelCase							,     """\n"""       )
											return choice










def        __lowerCamelCase (							__a       :int = 3   ,					__a       :int = 7   ,					__a       :int = 1_0_0_0_0_0_0   )		->    int:






		"""simple docstring"""

		A__  				=       0
		A__  				=       1

		for current_denominator in range(1   ,					limit + 1   ):
				A__  				=       current_denominator * numerator // denominator
				if current_denominator % denominator == 0:
						current_numerator -= 1
				if current_numerator * max_denominator > current_denominator * max_numerator:
						A__  				=       current_numerator
						A__  				=       current_denominator
		return max_numerator


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



