





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'''
from ...configuration_utils import PretrainedConfig
from ...utils import logging


_SCREAMING_SNAKE_CASE			=						logging.get_logger(__name__)

_SCREAMING_SNAKE_CASE			=						{"openai-gpt": "https://huggingface.co/openai-gpt/resolve/main/config.json"}
class   __UpperCAmelCase				(     lowerCAmelCase				):



					'''simple docstring'''





					_UpperCamelCase							=		"""openai-gpt"""
					_UpperCamelCase							=		{
					    """max_position_embeddings""": """n_positions""",
					    """hidden_size""": """n_embd""",
					    """num_attention_heads""": """n_head""",
					    """num_hidden_layers""": """n_layer""",
					}



					def __init__(	self     :						Any      ,       _lowercase     :						List[Any]=40_478      ,       _lowercase     :						Tuple=512      ,       _lowercase     :						Dict=768      ,       _lowercase     :						List[str]=12      ,       _lowercase     :						Optional[int]=12      ,       _lowercase     :						Tuple="gelu"      ,       _lowercase     :						int=0.1      ,       _lowercase     :						Tuple=0.1      ,       _lowercase     :						Any=0.1      ,       _lowercase     :						List[str]=1E-5      ,       _lowercase     :						str=0.02      ,       _lowercase     :						Optional[Any]="cls_index"      ,       _lowercase     :						int=True      ,       _lowercase     :						str=None      ,       _lowercase     :						Tuple=True      ,       _lowercase     :						List[Any]=0.1      ,       **_lowercase     :						int      ,       )    ->							Optional[int]:
								A_									= vocab_size
								A_									= n_positions
								A_									= n_embd
								A_									= n_layer
								A_									= n_head
								A_									= afn
								A_									= resid_pdrop
								A_									= embd_pdrop
								A_									= attn_pdrop
								A_									= layer_norm_epsilon
								A_									= initializer_range
								A_									= summary_type
								A_									= summary_use_proj
								A_									= summary_activation
								A_									= summary_first_dropout
								A_									= summary_proj_to_labels
								super().__init__(**_lowercase)




