

'''simple docstring'''


from __future__ import annotations

from fractions import Fraction
from math import gcd, sqrt




def 	_a       (				__lowerCAmelCase		:      int     ):

		"""simple docstring"""

		snake_case__						:       int       						=  int(number**0.5     )
		return number == sq * sq




def 	_a       (				__lowerCAmelCase		:      int   ,							__lowerCAmelCase		:      int   ,							__lowerCAmelCase		:      int   ,							__lowerCAmelCase		:      int   ,							__lowerCAmelCase		:      int   ,							__lowerCAmelCase		:      int     ):

		"""simple docstring"""

		snake_case__						:       int       						=  x_num * y_den * z_den + y_num * x_den * z_den + z_num * x_den * y_den
		snake_case__						:       int       						=  x_den * y_den * z_den
		snake_case__						:       int       						=  gcd(UpperCAmelCase__   ,							UpperCAmelCase__     )
		top //= hcf
		bottom //= hcf
		return top, bottom




def 	_a       (				__lowerCAmelCase		:      int = 35     ):

		"""simple docstring"""

		snake_case__						:       set       						=  set()
		snake_case__						:       int
		snake_case__						:       Fraction       						=  Fraction(0     )
		snake_case__						:       tuple[int, int]

		for x_num in range(1   ,							order + 1     ):
				for x_den in range(x_num + 1   ,							order + 1     ):
						for y_num in range(1   ,							order + 1     ):
								for y_den in range(y_num + 1   ,							order + 1     ):
										# n=1
										snake_case__						:       str       						=  x_num * y_den + x_den * y_num
										snake_case__						:       Optional[int]       						=  x_den * y_den
										snake_case__						:       Optional[int]       						=  gcd(UpperCAmelCase__   ,							UpperCAmelCase__     )
										z_num //= hcf
										z_den //= hcf
										if 0 < z_num < z_den <= order:
												snake_case__						:       List[str]       						=  add_three(
												    UpperCAmelCase__   ,							UpperCAmelCase__   ,							UpperCAmelCase__   ,							UpperCAmelCase__   ,							UpperCAmelCase__   ,							UpperCAmelCase__     )
												unique_s.add(UpperCAmelCase__     )

										# n=2
										snake_case__						:       List[str]       						=  (
										    x_num * x_num * y_den * y_den + x_den * x_den * y_num * y_num
										)
										snake_case__						:       Optional[int]       						=  x_den * x_den * y_den * y_den
										if is_sq(UpperCAmelCase__     ) and is_sq(UpperCAmelCase__     ):
												snake_case__						:       Optional[Any]       						=  int(sqrt(UpperCAmelCase__     )     )
												snake_case__						:       Optional[Any]       						=  int(sqrt(UpperCAmelCase__     )     )
												snake_case__						:       List[Any]       						=  gcd(UpperCAmelCase__   ,							UpperCAmelCase__     )
												z_num //= hcf
												z_den //= hcf
												if 0 < z_num < z_den <= order:
														snake_case__						:       List[Any]       						=  add_three(
														    UpperCAmelCase__   ,							UpperCAmelCase__   ,							UpperCAmelCase__   ,							UpperCAmelCase__   ,							UpperCAmelCase__   ,							UpperCAmelCase__     )
														unique_s.add(UpperCAmelCase__     )

                    # n=-1
										snake_case__						:       List[Any]       						=  x_num * y_num
										snake_case__						:       Any       						=  x_den * y_num + x_num * y_den
										snake_case__						:       Any       						=  gcd(UpperCAmelCase__   ,							UpperCAmelCase__     )
										z_num //= hcf
										z_den //= hcf
										if 0 < z_num < z_den <= order:
												snake_case__						:       List[Any]       						=  add_three(
												    UpperCAmelCase__   ,							UpperCAmelCase__   ,							UpperCAmelCase__   ,							UpperCAmelCase__   ,							UpperCAmelCase__   ,							UpperCAmelCase__     )
												unique_s.add(UpperCAmelCase__     )

										# n=2
										snake_case__						:       str       						=  x_num * x_num * y_num * y_num
										snake_case__						:       Tuple       						=  (
										    x_den * x_den * y_num * y_num + x_num * x_num * y_den * y_den
										)
										if is_sq(UpperCAmelCase__     ) and is_sq(UpperCAmelCase__     ):
												snake_case__						:       Optional[Any]       						=  int(sqrt(UpperCAmelCase__     )     )
												snake_case__						:       int       						=  int(sqrt(UpperCAmelCase__     )     )
												snake_case__						:       Optional[int]       						=  gcd(UpperCAmelCase__   ,							UpperCAmelCase__     )
												z_num //= hcf
												z_den //= hcf
												if 0 < z_num < z_den <= order:
														snake_case__						:       List[str]       						=  add_three(
														    UpperCAmelCase__   ,							UpperCAmelCase__   ,							UpperCAmelCase__   ,							UpperCAmelCase__   ,							UpperCAmelCase__   ,							UpperCAmelCase__     )
														unique_s.add(UpperCAmelCase__     )

		for num, den in unique_s:
				total += Fraction(UpperCAmelCase__   ,							UpperCAmelCase__     )

		return total.denominator + total.numerator


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






'''simple docstring'''


from bisect import bisect
from itertools import accumulate




def 	_a       (				__lowerCAmelCase		:      Optional[int]   ,							__lowerCAmelCase		:      Tuple   ,							__lowerCAmelCase		:      List[Any]   ,							__lowerCAmelCase		:      Optional[Any]     ):

		"""simple docstring"""

		snake_case__						:       Any       						=  sorted(zip(__lowerCAmelCase   ,							__lowerCAmelCase     )   ,							key=lambda __lowerCAmelCase     : x[0] / x[1]   ,							reverse=__lowerCAmelCase     )
		snake_case__						,       snake_case__						:       Union[str, Any]       						=  [i[0] for i in r], [i[1] for i in r]
		snake_case__						:       Dict       						=  list(accumulate(__lowerCAmelCase     )     )
		snake_case__						:       Optional[int]       						=  bisect(__lowerCAmelCase   ,							__lowerCAmelCase     )
		return (
		    0
		    if k == 0
		    else sum(vl[:k]     ) + (w - acc[k - 1]) * (vl[k]) / (wt[k])
		    if k != n
		    else sum(vl[:k]     )
		)


if __name__ == "__main__":
					import doctest

					doctest.testmod()



