


lowerCAmelCase__			:      Union[str, Any]								=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 						a__			(				A__,      A__,      A__,      A__				):
			SCREAMING_SNAKE_CASE_		:     List[Any]					=					sum(a_i[j] for j in range(A__,      len(A__				)				)				)
			SCREAMING_SNAKE_CASE_		:     Tuple					=					sum(a_i[j] * base[j] for j in range(min(len(A__				),      A__				)				)				)

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

			SCREAMING_SNAKE_CASE_		:     Tuple					=					memo.get(A__				)

			if sub_memo is not None:
						SCREAMING_SNAKE_CASE_		:     str					=					sub_memo.get(A__				)

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

									if max_jump >= 0:
												SCREAMING_SNAKE_CASE_		,      SCREAMING_SNAKE_CASE_		,      SCREAMING_SNAKE_CASE_		:     Dict					=					jumps[max_jump]
												# since the difference between jumps is cached, add c
												SCREAMING_SNAKE_CASE_		:     str					=					diff + c
												for j in range(min(A__,      len(A__				)				)				):
															SCREAMING_SNAKE_CASE_		,      SCREAMING_SNAKE_CASE_		:     Tuple					=					divmod(A__,      1_0				)
												if new_c > 0:
															add(A__,      A__,      A__				)

						else:
									SCREAMING_SNAKE_CASE_		:     List[str]					=					[]
			else:
						SCREAMING_SNAKE_CASE_		:     Any					=					{c: []}
						SCREAMING_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
									SCREAMING_SNAKE_CASE_		,      SCREAMING_SNAKE_CASE_		:     int					=					next_term(A__,      k - 1,      i + dn,      A__				)
									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
						SCREAMING_SNAKE_CASE_		,      SCREAMING_SNAKE_CASE_		:     Dict					=					compute(A__,      A__,      i + dn,      A__				)
						diff += _diff
						dn += terms_jumped

			SCREAMING_SNAKE_CASE_		:     List[str]					=					sub_memo[c]

			# keep jumps sorted by # of terms skipped
			SCREAMING_SNAKE_CASE_		:     Union[str, Any]					=					0
			while j < len(A__				):
						if jumps[j][1] > dn:
									break
						j += 1

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






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

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

			while i < n:
						i += 1
						SCREAMING_SNAKE_CASE_		:     str					=					ds_c + ds_b
						diff += addend
						SCREAMING_SNAKE_CASE_		:     Optional[int]					=					0
						for j in range(A__				):
									SCREAMING_SNAKE_CASE_		:     List[Any]					=					a_i[j] + addend
									SCREAMING_SNAKE_CASE_		,      SCREAMING_SNAKE_CASE_		:     int					=					divmod(A__,      1_0				)

									ds_c += a_i[j]

						if addend > 0:
									break

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






def 						a__			(				A__,      A__,      A__				):
			for j in range(A__,      len(A__				)				):
						SCREAMING_SNAKE_CASE_		:     Optional[Any]					=					digits[j] + addend
						if s >= 1_0:
									SCREAMING_SNAKE_CASE_		,      SCREAMING_SNAKE_CASE_		:     List[Any]					=					divmod(A__,      1_0				)
									SCREAMING_SNAKE_CASE_		:     Any					=					addend // 1_0 + quotient
						else:
									SCREAMING_SNAKE_CASE_		:     Union[str, Any]					=					s
									SCREAMING_SNAKE_CASE_		:     Tuple					=					addend // 1_0

						if addend == 0:
									break

			while addend > 0:
						SCREAMING_SNAKE_CASE_		,      SCREAMING_SNAKE_CASE_		:     List[Any]					=					divmod(A__,      1_0				)
						digits.append(A__				)






def 						a__			(				A__ = 1_0**1_5				):
			SCREAMING_SNAKE_CASE_		:     int					=					[1]
			SCREAMING_SNAKE_CASE_		:     Tuple					=					1
			SCREAMING_SNAKE_CASE_		:     Dict					=					0
			while True:
						SCREAMING_SNAKE_CASE_		,      SCREAMING_SNAKE_CASE_		:     Optional[Any]					=					next_term(A__,      2_0,      i + dn,      A__				)
						dn += terms_jumped
						if dn == n - i:
									break

			SCREAMING_SNAKE_CASE_		:     Any					=					0
			for j in range(len(A__				)				):
						a_n += digits[j] * 1_0**j
			return a_n


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









'''simple docstring'''
from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
    is_vision_available,
)


__snake_case				 =	{
    '''configuration_clip''': [
        '''CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''CLIPConfig''',
        '''CLIPOnnxConfig''',
        '''CLIPTextConfig''',
        '''CLIPVisionConfig''',
    ],
    '''processing_clip''': ['''CLIPProcessor'''],
    '''tokenization_clip''': ['''CLIPTokenizer'''],
}

try:
		if not is_tokenizers_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		__snake_case				 =	['''CLIPTokenizerFast''']

try:
		if not is_vision_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		__snake_case				 =	['''CLIPFeatureExtractor''']
		__snake_case				 =	['''CLIPImageProcessor''']

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		__snake_case				 =	[
		    '''CLIP_PRETRAINED_MODEL_ARCHIVE_LIST''',
		    '''CLIPModel''',
		    '''CLIPPreTrainedModel''',
		    '''CLIPTextModel''',
		    '''CLIPTextModelWithProjection''',
		    '''CLIPVisionModel''',
		    '''CLIPVisionModelWithProjection''',
		]

try:
		if not is_tf_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		__snake_case				 =	[
		    '''TF_CLIP_PRETRAINED_MODEL_ARCHIVE_LIST''',
		    '''TFCLIPModel''',
		    '''TFCLIPPreTrainedModel''',
		    '''TFCLIPTextModel''',
		    '''TFCLIPVisionModel''',
		]

try:
		if not is_flax_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		__snake_case				 =	[
		    '''FlaxCLIPModel''',
		    '''FlaxCLIPPreTrainedModel''',
		    '''FlaxCLIPTextModel''',
		    '''FlaxCLIPTextPreTrainedModel''',
		    '''FlaxCLIPVisionModel''',
		    '''FlaxCLIPVisionPreTrainedModel''',
		]


if TYPE_CHECKING:
		from .configuration_clip import (
		    CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP,
		    CLIPConfig,
		    CLIPOnnxConfig,
		    CLIPTextConfig,
		    CLIPVisionConfig,
		)
		from .processing_clip import CLIPProcessor
		from .tokenization_clip import CLIPTokenizer

		try:
				if not is_tokenizers_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .tokenization_clip_fast import CLIPTokenizerFast

		try:
				if not is_vision_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .feature_extraction_clip import CLIPFeatureExtractor
				from .image_processing_clip import CLIPImageProcessor

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_clip import (
				    CLIP_PRETRAINED_MODEL_ARCHIVE_LIST,
				    CLIPModel,
				    CLIPPreTrainedModel,
				    CLIPTextModel,
				    CLIPTextModelWithProjection,
				    CLIPVisionModel,
				    CLIPVisionModelWithProjection,
				)

		try:
				if not is_tf_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_tf_clip import (
				    TF_CLIP_PRETRAINED_MODEL_ARCHIVE_LIST,
				    TFCLIPModel,
				    TFCLIPPreTrainedModel,
				    TFCLIPTextModel,
				    TFCLIPVisionModel,
				)

		try:
				if not is_flax_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_flax_clip import (
				    FlaxCLIPModel,
				    FlaxCLIPPreTrainedModel,
				    FlaxCLIPTextModel,
				    FlaxCLIPTextPreTrainedModel,
				    FlaxCLIPVisionModel,
				    FlaxCLIPVisionPreTrainedModel,
				)


else:
		import sys

		__snake_case				 =	_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)