




'''simple docstring'''

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


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

					'''simple docstring'''

					snake_case_									=				sum(a_i[j] for j in range(lowercase__,      len(lowercase__	)	)	)
					snake_case_									=				sum(a_i[j] * base[j] for j in range(min(len(lowercase__	),      lowercase__	)	)	)

					snake_case_									=				0, 0
					snake_case_									=				n - i

					snake_case_									=				memo.get(lowercase__	)

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

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

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

										else:
															snake_case_									=				[]
					else:
										snake_case_									=				{c: []}
										snake_case_									=				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_									=				next_term(lowercase__,      k - 1,      i + dn,      lowercase__	)
															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_									=				compute(lowercase__,      lowercase__,      i + dn,      lowercase__	)
										diff += _diff
										dn += terms_jumped

					snake_case_									=				sub_memo[c]

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

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


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

					'''simple docstring'''

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

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

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

															ds_c += a_i[j]

										if addend > 0:
															break

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


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

					'''simple docstring'''

					for j in range(lowercase__,      len(lowercase__	)	):
										snake_case_									=				digits[j] + addend
										if s >= 10:
															snake_case_									=				divmod(lowercase__,      10	)
															snake_case_									=				addend // 10 + quotient
										else:
															snake_case_									=				s
															snake_case_									=				addend // 10

										if addend == 0:
															break

					while addend > 0:
										snake_case_									=				divmod(lowercase__,      10	)
										digits.append(lowercase__	)


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

					'''simple docstring'''

					snake_case_									=				[1]
					snake_case_									=				1
					snake_case_									=				0
					while True:
										snake_case_									=				next_term(lowercase__,      20,      i + dn,      lowercase__	)
										dn += terms_jumped
										if dn == n - i:
															break

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


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







"""simple docstring"""






from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


lowercase__     						=						{"""configuration_ibert""": ["""IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """IBertConfig""", """IBertOnnxConfig"""]}

try:
			if not is_torch_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			lowercase__     						=						[
			    """IBERT_PRETRAINED_MODEL_ARCHIVE_LIST""",
			    """IBertForMaskedLM""",
			    """IBertForMultipleChoice""",
			    """IBertForQuestionAnswering""",
			    """IBertForSequenceClassification""",
			    """IBertForTokenClassification""",
			    """IBertModel""",
			    """IBertPreTrainedModel""",
			]

if TYPE_CHECKING:
			from .configuration_ibert import IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, IBertConfig, IBertOnnxConfig

			try:
						if not is_torch_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_ibert import (
						    IBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
						    IBertForMaskedLM,
						    IBertForMultipleChoice,
						    IBertForQuestionAnswering,
						    IBertForSequenceClassification,
						    IBertForTokenClassification,
						    IBertModel,
						    IBertPreTrainedModel,
						)

else:
			import sys

			lowercase__     						=						_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)