

def 							__SCREAMING_SNAKE_CASE							(			lowerCAmelCase:					int	)				->    int:
				_UpperCAmelCase    :						Dict							=      [1]

				_UpperCAmelCase						,							_UpperCAmelCase						,							_UpperCAmelCase    :						int							=      0, 0, 0
				_UpperCAmelCase    :						Tuple							=      ugly_nums[ia] * 2
				_UpperCAmelCase    :						Any							=      ugly_nums[ia] * 3
				_UpperCAmelCase    :						List[str]							=      ugly_nums[ia] * 5

				for _ in range(1					, lowerCAmelCase	):
								_UpperCAmelCase    :						str							=      min(lowerCAmelCase					, lowerCAmelCase					, lowerCAmelCase	)
								ugly_nums.append(lowerCAmelCase	)
								if next_num == next_a:
												ia += 1
												_UpperCAmelCase    :						Optional[int]							=      ugly_nums[ia] * 2
								if next_num == next_a:
												ia += 1
												_UpperCAmelCase    :						Any							=      ugly_nums[ia] * 3
								if next_num == next_a:
												ia += 1
												_UpperCAmelCase    :						Optional[Any]							=      ugly_nums[ia] * 5
				return ugly_nums[-1]


if __name__ == "__main__":
					from doctest import testmod

					testmod(verbose=True)
					print(F'''{ugly_numbers(200) = }''')





from __future__ import annotations

from random import choice

def 							__SCREAMING_SNAKE_CASE							(			lowerCAmelCase:					Any	)				->    Optional[int]:
				return choice(lowerCAmelCase	)

def 							__SCREAMING_SNAKE_CASE							(			lowerCAmelCase:					list[int]					, lowerCAmelCase:					int	)				->    int:
				_UpperCAmelCase    :						List[Any]							=      random_pivot(lowerCAmelCase	)

				# partition based on pivot
				# linear time
				_UpperCAmelCase    :						List[str]							=      [e for e in lst if e < pivot]
				_UpperCAmelCase    :						Any							=      [e for e in lst if e > pivot]

				# if we get lucky, pivot might be the element we want.
				# we can easily see this:
				# small (elements smaller than k)
				# + pivot (kth element)
				# + big (elements larger than k)
				if len(lowerCAmelCase	) == k - 1:
								return pivot
				# pivot is in elements bigger than k
				elif len(lowerCAmelCase	) < k - 1:
								return kth_number(lowerCAmelCase					, k - len(lowerCAmelCase	) - 1	)
				# pivot is in elements smaller than k
				else:
								return kth_number(lowerCAmelCase					, lowerCAmelCase	)


if __name__ == "__main__":
					import doctest

					doctest.testmod()


