





'''simple docstring'''





UpperCAmelCase_      							=     [sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(100000)]





def 						lowerCamelCase__     (     UpperCamelCase__			:       int						)			-> int:



					'''simple docstring'''




					_snake_case									=				0
					while number:
										# Increased Speed Slightly by checking every 5 digits together.
										sum_of_digits_squared += DIGITS_SQUARED[number % 100_000]
										number //= 100_000

					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
UpperCAmelCase_      							=     [None] * 10000000
UpperCAmelCase_      							=     True
UpperCAmelCase_      							=     False





def 						lowerCamelCase__     (     UpperCamelCase__			:       int						)			-> bool:



					'''simple docstring'''




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

					_snake_case									=				chain(next_number(UpperCamelCase__						)						)
					_snake_case									=				number_chain

					while number < 10_000_000:
										_snake_case									=				number_chain
										number *= 10

					return number_chain





def 						lowerCamelCase__     (     UpperCamelCase__			:       int = 10_000_000						)			-> int:



					'''simple docstring'''




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

					return CHAINS[:number].count(UpperCamelCase__						)


if __name__ == "__main__":
					import doctest

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










def 						lowerCamelCase__     (     UpperCamelCase__			:       List[Any]       ,    UpperCamelCase__			:       Dict       ,    UpperCamelCase__			:       str       ,    UpperCamelCase__			:       int       ,    UpperCamelCase__			:       List[str]       ,    UpperCamelCase__			:       str						)			-> List[Any]:



					'''simple docstring'''




					if index == r:
										for j in range(UpperCamelCase__						):
															print(data[j]       ,    end=' '						)
										print(' '						)
										return
					#  When no more elements are there to put in data[]
					if i >= n:
										return
					# current is included, put next at next location
					_snake_case									=				arr[i]
					combination_util(UpperCamelCase__       ,    UpperCamelCase__       ,    UpperCamelCase__       ,    index + 1       ,    UpperCamelCase__       ,    i + 1						)
					# current is excluded, replace it with
					# next (Note that i+1 is passed, but
					# index is not changed)
					combination_util(UpperCamelCase__       ,    UpperCamelCase__       ,    UpperCamelCase__       ,    UpperCamelCase__       ,    UpperCamelCase__       ,    i + 1						)
					# The main function that prints all combinations
					# of size r in arr[] of size n. This function
					# mainly uses combinationUtil()





def 						lowerCamelCase__     (     UpperCamelCase__			:       Optional[int]       ,    UpperCamelCase__			:       Tuple       ,    UpperCamelCase__			:       List[str]						)			-> Tuple:



					'''simple docstring'''




					_snake_case									=				[0] * r
					# Print all combination using temporary array 'data[]'
					combination_util(UpperCamelCase__       ,    UpperCamelCase__       ,    UpperCamelCase__       ,    0       ,    UpperCamelCase__       ,    0						)


if __name__ == "__main__":
					# Driver code to check the function above
					UpperCAmelCase_      							=     [10, 20, 30, 40, 50]
					print_combination(arr, len(arr), 3)
					# This code is contributed by Ambuj sahu



