


class 	_a							:

							def __init__(							self:     Optional[Any]   ,						UpperCamelCase_:     Dict   ,						UpperCamelCase_:     str   ,						UpperCamelCase_:     Any							)      ->       Optional[int]:





									"""simple docstring"""







									lowercase__						=				name
									lowercase__						=				value
									lowercase__						=				weight

							def __repr__(							self:     List[Any]							)      ->       Dict:





									"""simple docstring"""







									return f'{self.__class__.__name__}({self.name}, {self.value}, {self.weight})'

							def 				lowerCamelCase_			(							self:     Optional[Any]							)      ->       str:





									"""simple docstring"""







									return self.value

							def 				lowerCamelCase_			(							self:     Optional[int]							)      ->       Dict:





									"""simple docstring"""







									return self.name

							def 				lowerCamelCase_			(							self:     Optional[int]							)      ->       List[str]:





									"""simple docstring"""







									return self.weight


							def 				lowerCamelCase_			(							self:     Optional[int]							)      ->       Optional[int]:





									"""simple docstring"""







									return self.value / self.weight
def       _a			(				SCREAMING_SNAKE_CASE						,    SCREAMING_SNAKE_CASE						,    SCREAMING_SNAKE_CASE					):


		"""simple docstring"""




		lowercase__						=				[]
		for i in range(len(SCREAMING_SNAKE_CASE					)					):
				menu.append(Things(name[i]						,    value[i]						,    weight[i]					)					)
		return menu
def       _a			(				SCREAMING_SNAKE_CASE						,    SCREAMING_SNAKE_CASE						,    SCREAMING_SNAKE_CASE					):


		"""simple docstring"""




		lowercase__						=				sorted(SCREAMING_SNAKE_CASE						,    key=SCREAMING_SNAKE_CASE						,    reverse=SCREAMING_SNAKE_CASE					)
		lowercase__						=				[]
		lowercase__					,		lowercase__						=				0.0, 0.0
		for i in range(len(SCREAMING_SNAKE_CASE					)					):
				if (total_cost + items_copy[i].get_weight()) <= max_cost:
						result.append(items_copy[i]					)
						total_cost += items_copy[i].get_weight()
						total_value += items_copy[i].get_value()
		return (result, total_value)
def       _a			(				):


		"""simple docstring"""










if __name__ == "__main__":
			import doctest

			doctest.testmod()






lowerCAmelCase	=							[sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(10_0000)]
def       _a			(				SCREAMING_SNAKE_CASE					):


		"""simple docstring"""




		lowercase__						=				0
		while number:
				# Increased Speed Slightly by checking every 5 digits together.
				sum_of_digits_squared += DIGITS_SQUARED[number % 10_00_00]
				number //= 10_00_00

		return sum_of_digits_squared


# There are 2 Chains made,
# One ends with 89 with the chain member 58 being the one which when declared first,
# there will be the least number of iterations for all the members to be checked.

# The other one ends with 1 and has only one element 1.

# So 58 and 1 are chosen to be declared at the starting.

# Changed dictionary to an array to quicken the solution
lowerCAmelCase	=							[None] * 1000_0000
lowerCAmelCase	=							True
lowerCAmelCase	=							False
def       _a			(				SCREAMING_SNAKE_CASE					):


		"""simple docstring"""




		if CHAINS[number - 1] is not None:
				return CHAINS[number - 1]  # type: ignore

		lowercase__						=				chain(next_number(SCREAMING_SNAKE_CASE					)					)
		lowercase__						=				number_chain

		while number < 10_00_00_00:
				lowercase__						=				number_chain
				number *= 10

		return number_chain
def       _a			(				SCREAMING_SNAKE_CASE = 10_00_00_00					):


		"""simple docstring"""




		for i in range(1						,    SCREAMING_SNAKE_CASE					):
				if CHAINS[i] is None:
						chain(i + 1					)

		return CHAINS[:number].count(SCREAMING_SNAKE_CASE					)


if __name__ == "__main__":
			import doctest

			doctest.testmod()
			print(f"""{solution() = }""")


