"""simple docstring"""





_UpperCamelCase     :		int											=					[sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(10_00_00)]





def        a_  (   _lowerCAmelCase						:				int  ):





       '''simple docstring'''

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

       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     :		list[bool | None]											=					[None] * 10_00_00_00
_UpperCamelCase     :		Optional[int]											=					True
_UpperCamelCase     :		List[Any]											=					False





def        a_  (   _lowerCAmelCase						:				int  ):





       '''simple docstring'''

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

       lowercase__    :	Tuple     					=			chain(next_number(_lowerCAmelCase  )  )
       lowercase__    :	List[Any]     					=			number_chain

       while number < 1000_0000:
              lowercase__    :	Tuple     					=			number_chain
              number *= 10

       return number_chain





def        a_  (   _lowerCAmelCase						:				int = 1000_0000  ):





       '''simple docstring'''

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

       return CHAINS[:number].count(_lowerCAmelCase  )


if __name__ == "__main__":
       import doctest

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


"""simple docstring"""





def        a_  (   _lowerCAmelCase						:				str  ):





       '''simple docstring'''

       lowercase__    :	Any     					=			[0] * len(_lowerCAmelCase  )

       for i in range(1     ,				len(_lowerCAmelCase  )  ):
              # use last results for better performance - dynamic programming
              lowercase__    :	List[str]     					=			prefix_result[i - 1]
              while j > 0 and input_string[i] != input_string[j]:
                     lowercase__    :	Dict     					=			prefix_result[j - 1]

              if input_string[i] == input_string[j]:
                     j += 1
              lowercase__    :	Union[str, Any]     					=			j

       return prefix_result





def        a_  (   _lowerCAmelCase						:				str  ):





       '''simple docstring'''

       return max(prefix_function(_lowerCAmelCase  )  )


if __name__ == "__main__":
       import doctest

       doctest.testmod()

