





lowerCAmelCase_        =							range(2, 2_0 + 1)
lowerCAmelCase_        =							[1_0**k for k in range(ks[-1] + 1)]
lowerCAmelCase_        =							{}






def 	lowerCamelCase_		(							_UpperCamelCase					,							_UpperCamelCase					,							_UpperCamelCase					,							_UpperCamelCase					)						->		Any:






				"""simple docstring"""


				snake_case_		:       List[Any]           =    sum(a_i[j] for j in range(_UpperCamelCase					,							len(_UpperCamelCase					)					)					)
				snake_case_		:       Optional[Any]           =    sum(a_i[j] * base[j] for j in range(min(len(_UpperCamelCase					)					,							_UpperCamelCase					)					)					)

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

				snake_case_		:       Any           =    memo.get(_UpperCamelCase					)

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

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

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

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

				snake_case_		:       str           =    sub_memo[c]

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

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






def 	lowerCamelCase_		(							_UpperCamelCase					,							_UpperCamelCase					,							_UpperCamelCase					,							_UpperCamelCase					)						->		Optional[Any]:






				"""simple docstring"""


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

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

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

												ds_c += a_i[j]

								if addend > 0:
												break

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






def 	lowerCamelCase_		(							_UpperCamelCase					,							_UpperCamelCase					,							_UpperCamelCase					)						->		Dict:






				"""simple docstring"""


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

								if addend == 0:
												break

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






def 	lowerCamelCase_		(							_UpperCamelCase = 10**15					)						->		int:






				"""simple docstring"""


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

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


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




"""simple docstring"""






import warnings

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding






class      A(  lowerCamelCase__		):

		"""simple docstring"""





		A    =							["image_processor", "tokenizer"]
		A    =							"ViTImageProcessor"
		A    =							("CLIPTokenizer", "CLIPTokenizerFast")
		def __init__( self					,				SCREAMING_SNAKE_CASE__=None					,				SCREAMING_SNAKE_CASE__=None					,				**SCREAMING_SNAKE_CASE__   )      ->	List[str]:

					"""simple docstring"""



					_UpperCamelCase					:List[str]					     =	None
					if "feature_extractor" in kwargs:
								warnings.warn(
								    '''The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`'''
								    ''' instead.'''					,				SCREAMING_SNAKE_CASE__					,				)
								_UpperCamelCase					:List[str]					     =	kwargs.pop('''feature_extractor'''   )

					_UpperCamelCase					:Optional[Any]					     =	image_processor if image_processor is not None else feature_extractor
					if image_processor is None:
								raise ValueError('''You need to specify an `image_processor`.'''   )
					if tokenizer is None:
								raise ValueError('''You need to specify a `tokenizer`.'''   )

					super().__init__(SCREAMING_SNAKE_CASE__					,				SCREAMING_SNAKE_CASE__   )
		def __call__( self					,				SCREAMING_SNAKE_CASE__=None					,				SCREAMING_SNAKE_CASE__=None					,				SCREAMING_SNAKE_CASE__=None					,				SCREAMING_SNAKE_CASE__=None					,				**SCREAMING_SNAKE_CASE__   )      ->	Tuple:

					"""simple docstring"""



					if text is None and visual_prompt is None and images is None:
								raise ValueError('''You have to specify either text, visual prompt or images.'''   )

					if text is not None and visual_prompt is not None:
								raise ValueError('''You have to specify exactly one type of prompt. Either text or visual prompt.'''   )

					if text is not None:
								_UpperCamelCase					:Dict					     =	self.tokenizer(SCREAMING_SNAKE_CASE__					,				return_tensors=SCREAMING_SNAKE_CASE__					,				**SCREAMING_SNAKE_CASE__   )

					if visual_prompt is not None:
								_UpperCamelCase					:Optional[Any]					     =	self.image_processor(SCREAMING_SNAKE_CASE__					,				return_tensors=SCREAMING_SNAKE_CASE__					,				**SCREAMING_SNAKE_CASE__   )

					if images is not None:
								_UpperCamelCase					:Union[str, Any]					     =	self.image_processor(SCREAMING_SNAKE_CASE__					,				return_tensors=SCREAMING_SNAKE_CASE__					,				**SCREAMING_SNAKE_CASE__   )

					if visual_prompt is not None and images is not None:
								_UpperCamelCase					:List[str]					     =	{
								    '''pixel_values''': image_features.pixel_values,
								    '''conditional_pixel_values''': prompt_features.pixel_values,
								}
								return encoding
					elif text is not None and images is not None:
								_UpperCamelCase					:List[Any]					     =	image_features.pixel_values
								return encoding
					elif text is not None:
								return encoding
					elif visual_prompt is not None:
								_UpperCamelCase					:Optional[Any]					     =	{
								    '''conditional_pixel_values''': prompt_features.pixel_values,
								}
								return encoding
					else:
								return BatchEncoding(data=dict(**SCREAMING_SNAKE_CASE__   )					,				tensor_type=SCREAMING_SNAKE_CASE__   )
		def   _UpperCamelCase( self					,				*SCREAMING_SNAKE_CASE__					,				**SCREAMING_SNAKE_CASE__   )      ->	Any:

					"""simple docstring"""



					return self.tokenizer.batch_decode(*SCREAMING_SNAKE_CASE__					,				**SCREAMING_SNAKE_CASE__   )
		def   _UpperCamelCase( self					,				*SCREAMING_SNAKE_CASE__					,				**SCREAMING_SNAKE_CASE__   )      ->	Tuple:

					"""simple docstring"""



					return self.tokenizer.decode(*SCREAMING_SNAKE_CASE__					,				**SCREAMING_SNAKE_CASE__   )
		@property
		def   _UpperCamelCase( self   )      ->	Tuple:

					"""simple docstring"""



					warnings.warn(
					    '''`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.'''					,				SCREAMING_SNAKE_CASE__					,				)
					return self.image_processor_class





		@property
		def   _UpperCamelCase( self   )      ->	Union[str, Any]:

					"""simple docstring"""



					warnings.warn(
					    '''`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.'''					,				SCREAMING_SNAKE_CASE__					,				)
					return self.image_processor

