






'''simple docstring'''




__lowerCamelCase   :					Dict   							=					range(2, 20 + 1)
__lowerCamelCase   :					Optional[Any]   							=					[10**k for k in range(ks[-1] + 1)]
__lowerCamelCase   :					dict[int, dict[int, list[list[int]]]]   							=					{}

def 	__UpperCAmelCase       ( __magic_name__     ,__magic_name__     ,__magic_name__     ,__magic_name__						)->    List[Any]:



			"""simple docstring"""



			snake_case_				:					Dict   =       sum(a_i[j] for j in range(__magic_name__     ,len(__magic_name__						)						)						)
			snake_case_				:					Any   =       sum(a_i[j] * base[j] for j in range(min(len(__magic_name__						)     ,__magic_name__						)						)						)

			snake_case_				:					Any   =       0, 0
			snake_case_				:					Union[str, Any]   =       n - i

			snake_case_				:					str   =       memo.get(__magic_name__						)

			if sub_memo is not None:
						snake_case_				:					Tuple   =       sub_memo.get(__magic_name__						)

						if jumps is not None and len(__magic_name__						) > 0:
									# find and make the largest jump without going over
									snake_case_				:					Any   =       -1
									for _k in range(len(__magic_name__						) - 1     ,-1     ,-1						):
												if jumps[_k][2] <= k and jumps[_k][1] <= max_dn:
															snake_case_				:					Optional[int]   =       _k
															break

									if max_jump >= 0:
												snake_case_				:					int   =       jumps[max_jump]
												# since the difference between jumps is cached, add c
												snake_case_				:					Any   =       diff + c
												for j in range(min(__magic_name__     ,len(__magic_name__						)						)						):
															snake_case_				:					Dict   =       divmod(__magic_name__     ,10						)
												if new_c > 0:
															add(__magic_name__     ,__magic_name__     ,__magic_name__						)

						else:
									snake_case_				:					Tuple   =       []
			else:
						snake_case_				:					Optional[Any]   =       {c: []}
						snake_case_				:					Dict   =       sub_memo

			if dn >= max_dn or c + diff >= base[k]:
						return diff, dn

			if k > ks[0]:
						while True:
									# keep doing smaller jumps
									snake_case_				:					Optional[int]   =       next_term(__magic_name__     ,k - 1     ,i + dn     ,__magic_name__						)
									diff += _diff
									dn += terms_jumped

									if dn >= max_dn or c + diff >= base[k]:
												break
			else:
						# would be too small a jump, just compute sequential terms instead
						snake_case_				:					str   =       compute(__magic_name__     ,__magic_name__     ,i + dn     ,__magic_name__						)
						diff += _diff
						dn += terms_jumped

			snake_case_				:					Optional[Any]   =       sub_memo[c]

			# keep jumps sorted by # of terms skipped
			snake_case_				:					Any   =       0
			while j < len(__magic_name__						):
						if jumps[j][1] > dn:
									break
						j += 1

			# cache the jump for this value digitsum(b) and c
			sub_memo[c].insert(__magic_name__     ,(diff, dn, k)						)
			return (diff, dn)

def 	__UpperCAmelCase       ( __magic_name__     ,__magic_name__     ,__magic_name__     ,__magic_name__						)->    Optional[Any]:



			"""simple docstring"""



			if i >= n:
						return 0, i
			if k > len(__magic_name__						):
						a_i.extend([0 for _ in range(k - len(__magic_name__						)						)]						)

			# note: a_i -> b * 10^k + c
			# ds_b -> digitsum(b)
			# ds_c -> digitsum(c)
			snake_case_				:					int   =       i
			snake_case_				:					Optional[Any]   =       0, 0, 0
			for j in range(len(__magic_name__						)						):
						if j >= k:
									ds_b += a_i[j]
						else:
									ds_c += a_i[j]

			while i < n:
						i += 1
						snake_case_				:					str   =       ds_c + ds_b
						diff += addend
						snake_case_				:					Union[str, Any]   =       0
						for j in range(__magic_name__						):
									snake_case_				:					Optional[Any]   =       a_i[j] + addend
									snake_case_				:					Optional[Any]   =       divmod(__magic_name__     ,10						)

									ds_c += a_i[j]

						if addend > 0:
									break

			if addend > 0:
						add(__magic_name__     ,__magic_name__     ,__magic_name__						)
			return diff, i - start_i

def 	__UpperCAmelCase       ( __magic_name__     ,__magic_name__     ,__magic_name__						)->    Union[str, Any]:



			"""simple docstring"""



			for j in range(__magic_name__     ,len(__magic_name__						)						):
						snake_case_				:					Tuple   =       digits[j] + addend
						if s >= 10:
									snake_case_				:					Optional[int]   =       divmod(__magic_name__     ,10						)
									snake_case_				:					str   =       addend // 10 + quotient
						else:
									snake_case_				:					Optional[Any]   =       s
									snake_case_				:					Optional[Any]   =       addend // 10

						if addend == 0:
									break

			while addend > 0:
						snake_case_				:					Optional[int]   =       divmod(__magic_name__     ,10						)
						digits.append(__magic_name__						)

def 	__UpperCAmelCase       ( __magic_name__ = 10**15						)->    int:



			"""simple docstring"""



			snake_case_				:					List[str]   =       [1]
			snake_case_				:					Optional[Any]   =       1
			snake_case_				:					Any   =       0
			while True:
						snake_case_				:					Optional[Any]   =       next_term(__magic_name__     ,20     ,i + dn     ,__magic_name__						)
						dn += terms_jumped
						if dn == n - i:
									break

			snake_case_				:					Optional[Any]   =       0
			for j in range(len(__magic_name__						)						):
						a_n += digits[j] * 10**j
			return a_n


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












'''simple docstring'''




from typing import TYPE_CHECKING

from ...file_utils import _LazyModule, is_torch_available
from ...utils import OptionalDependencyNotAvailable


__lowerCamelCase   :					Dict   							=					{
    '''configuration_gpt_neox_japanese''': ['''GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTNeoXJapaneseConfig'''],
    '''tokenization_gpt_neox_japanese''': ['''GPTNeoXJapaneseTokenizer'''],
}

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		__lowerCamelCase   :					int   							=					[
		    '''GPT_NEOX_JAPANESE_PRETRAINED_MODEL_ARCHIVE_LIST''',
		    '''GPTNeoXJapaneseForCausalLM''',
		    '''GPTNeoXJapaneseLayer''',
		    '''GPTNeoXJapaneseModel''',
		    '''GPTNeoXJapanesePreTrainedModel''',
		]


if TYPE_CHECKING:
		from .configuration_gpt_neox_japanese import GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP, GPTNeoXJapaneseConfig
		from .tokenization_gpt_neox_japanese import GPTNeoXJapaneseTokenizer

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_gpt_neox_japanese import (
				    GPT_NEOX_JAPANESE_PRETRAINED_MODEL_ARCHIVE_LIST,
				    GPTNeoXJapaneseForCausalLM,
				    GPTNeoXJapaneseLayer,
				    GPTNeoXJapaneseModel,
				    GPTNeoXJapanesePreTrainedModel,
				)


else:
		import sys

		__lowerCamelCase   :					Optional[int]   							=					_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)




