

"""simple docstring"""


from __future__ import annotations

from fractions import Fraction
from math import gcd, sqrt






def    a__   (   __SCREAMING_SNAKE_CASE			)     ->     bool:
		__lowerCAmelCase:	int   				=      int(number**0.5			)
		return number == sq * sq






def    a__   (   __SCREAMING_SNAKE_CASE ,			__SCREAMING_SNAKE_CASE ,			__SCREAMING_SNAKE_CASE ,			__SCREAMING_SNAKE_CASE ,			__SCREAMING_SNAKE_CASE ,			__SCREAMING_SNAKE_CASE			)     ->     tuple[int, int]:
		__lowerCAmelCase:	int   				=      x_num * y_den * z_den + y_num * x_den * z_den + z_num * x_den * y_den
		__lowerCAmelCase:	int   				=      x_den * y_den * z_den
		__lowerCAmelCase:	int   				=      gcd(__UpperCAmelCase ,			__UpperCAmelCase			)
		top //= hcf
		bottom //= hcf
		return top, bottom






def    a__   (   __SCREAMING_SNAKE_CASE = 3_5			)     ->     int:
		__lowerCAmelCase:	set   				=      set()
		__lowerCAmelCase:	int
		__lowerCAmelCase:	Fraction   				=      Fraction(0			)
		__lowerCAmelCase:	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
										__lowerCAmelCase:	Union[str, Any]   				=      x_num * y_den + x_den * y_num
										__lowerCAmelCase:	str   				=      x_den * y_den
										__lowerCAmelCase:	Dict   				=      gcd(__UpperCAmelCase ,			__UpperCAmelCase			)
										z_num //= hcf
										z_den //= hcf
										if 0 < z_num < z_den <= order:
												__lowerCAmelCase:	List[str]   				=      add_three(
												    __UpperCAmelCase ,			__UpperCAmelCase ,			__UpperCAmelCase ,			__UpperCAmelCase ,			__UpperCAmelCase ,			__UpperCAmelCase			)
												unique_s.add(__UpperCAmelCase			)

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

												  # n=-1
										__lowerCAmelCase:	Optional[Any]   				=      x_num * y_num
										__lowerCAmelCase:	Any   				=      x_den * y_num + x_num * y_den
										__lowerCAmelCase:	Tuple   				=      gcd(__UpperCAmelCase ,			__UpperCAmelCase			)
										z_num //= hcf
										z_den //= hcf
										if 0 < z_num < z_den <= order:
												__lowerCAmelCase:	int   				=      add_three(
												    __UpperCAmelCase ,			__UpperCAmelCase ,			__UpperCAmelCase ,			__UpperCAmelCase ,			__UpperCAmelCase ,			__UpperCAmelCase			)
												unique_s.add(__UpperCAmelCase			)

										# n=2
										__lowerCAmelCase:	List[str]   				=      x_num * x_num * y_num * y_num
										__lowerCAmelCase:	Union[str, Any]   				=      (
										    x_den * x_den * y_num * y_num + x_num * x_num * y_den * y_den
										)
										if is_sq(__UpperCAmelCase			) and is_sq(__UpperCAmelCase			):
												__lowerCAmelCase:	Union[str, Any]   				=      int(sqrt(__UpperCAmelCase			)			)
												__lowerCAmelCase:	Tuple   				=      int(sqrt(__UpperCAmelCase			)			)
												__lowerCAmelCase:	Tuple   				=      gcd(__UpperCAmelCase ,			__UpperCAmelCase			)
												z_num //= hcf
												z_den //= hcf
												if 0 < z_num < z_den <= order:
														__lowerCAmelCase:	List[Any]   				=      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 math import ceil






def    a__   (   __SCREAMING_SNAKE_CASE ,			__SCREAMING_SNAKE_CASE			)     ->     str:
		__lowerCAmelCase:	Tuple   				=      list(range(0 ,			__SCREAMING_SNAKE_CASE			)			)

		__lowerCAmelCase:	Optional[Any]   				=      [item for sublist in list(device_map.values()			) for item in sublist]

		# Duplicate check
		__lowerCAmelCase:	List[Any]   				=      []
		for i in device_map_blocks:
				if device_map_blocks.count(__SCREAMING_SNAKE_CASE			) > 1 and i not in duplicate_blocks:
						duplicate_blocks.append(__SCREAMING_SNAKE_CASE			)
    # Missing blocks
		__lowerCAmelCase:	Optional[Any]   				=      [i for i in blocks if i not in device_map_blocks]
		__lowerCAmelCase:	List[Any]   				=      [i for i in device_map_blocks if i not in blocks]

		if len(__SCREAMING_SNAKE_CASE			) != 0:
				raise ValueError(
				    "Duplicate attention blocks specified in device_map. Attention blocks must be specified to one device."
				    " These attention blocks were specified more than once: " + str(__SCREAMING_SNAKE_CASE			)			)
		if len(__SCREAMING_SNAKE_CASE			) != 0:
				raise ValueError(
				    "There are attention blocks for this model that are not specified in the device_map. Add these attention "
				    "blocks to a device on the device_map: " + str(__SCREAMING_SNAKE_CASE			)			)
		if len(__SCREAMING_SNAKE_CASE			) != 0:
				raise ValueError(
				    "The device_map contains more attention blocks than this model has. Remove these from the device_map:"
				    + str(__SCREAMING_SNAKE_CASE			)			)






def    a__   (   __SCREAMING_SNAKE_CASE ,			__SCREAMING_SNAKE_CASE			)     ->     str:
		__lowerCAmelCase:	List[Any]   				=      list(range(__SCREAMING_SNAKE_CASE			)			)
		__lowerCAmelCase:	Dict   				=      int(ceil(n_layers / len(__SCREAMING_SNAKE_CASE			)			)			)
		__lowerCAmelCase:	Union[str, Any]   				=      [layers[i : i + n_blocks] for i in range(0 ,			__SCREAMING_SNAKE_CASE ,			__SCREAMING_SNAKE_CASE			)]

		return dict(zip(__SCREAMING_SNAKE_CASE ,			__SCREAMING_SNAKE_CASE			)			)


