
'''simple docstring'''







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







def 				SCREAMING_SNAKE_CASE__	(   __A			,				__A			,				__A			,				__A	)       ->	Any:
	_snake_case   						=		sum(a_i[j] for j in range(__A			,				len(__A	)	)	)
	_snake_case   						=		sum(a_i[j] * base[j] for j in range(min(len(__A	)			,				__A	)	)	)

	_snake_case						, _snake_case   						=		0, 0
	_snake_case   						=		n - i

	_snake_case   						=		memo.get(__A	)

	if sub_memo is not None:
		_snake_case   						=		sub_memo.get(__A	)

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

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

		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						, _snake_case   						=		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
		_snake_case						, _snake_case   						=		compute(__A			,				__A			,				i + dn			,				__A	)
		diff += _diff
		dn += terms_jumped

	_snake_case   						=		sub_memo[c]

	# keep jumps sorted by # of terms skipped
	_snake_case   						=		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 				SCREAMING_SNAKE_CASE__	(   __A			,				__A			,				__A			,				__A	)       ->	List[Any]:
	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)
	_snake_case   						=		i
	_snake_case						, _snake_case						, _snake_case   						=		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
		_snake_case   						=		ds_c + ds_b
		diff += addend
		_snake_case   						=		0
		for j in range(__A	):
			_snake_case   						=		a_i[j] + addend
			_snake_case						, _snake_case   						=		divmod(__A			,				10	)

			ds_c += a_i[j]

		if addend > 0:
			break

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







def 				SCREAMING_SNAKE_CASE__	(   __A			,				__A			,				__A	)       ->	Tuple:
	for j in range(__A			,				len(__A	)	):
		_snake_case   						=		digits[j] + addend
		if s >= 10:
			_snake_case						, _snake_case   						=		divmod(__A			,				10	)
			_snake_case   						=		addend // 10 + quotient
		else:
			_snake_case   						=		s
			_snake_case   						=		addend // 10

		if addend == 0:
			break

	while addend > 0:
		_snake_case						, _snake_case   						=		divmod(__A			,				10	)
		digits.append(__A	)







def 				SCREAMING_SNAKE_CASE__	(   __A = 10**15	)       ->	int:
	_snake_case   						=		[1]
	_snake_case   						=		1
	_snake_case   						=		0
	while True:
		_snake_case						, _snake_case   						=		next_term(__A			,				20			,				i + dn			,				__A	)
		dn += terms_jumped
		if dn == n - i:
			break

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


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



'''simple docstring'''







import warnings

from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowercase    :							int      =					logging.get_logger(__name__)

lowercase    :							Union[str, Any]      =					{
    "xlnet-base-cased": "https://huggingface.co/xlnet-base-cased/resolve/main/config.json",
    "xlnet-large-cased": "https://huggingface.co/xlnet-large-cased/resolve/main/config.json",
}


class 						__UpperCAmelCase      (					_lowerCamelCase						):
							__lowercase      		=       """xlnet"""
							__lowercase      		=       ["""mems"""]
							__lowercase      		=       {
							    """n_token""": """vocab_size""",  # Backward compatibility
							    """hidden_size""": """d_model""",
							    """num_attention_heads""": """n_head""",
							    """num_hidden_layers""": """n_layer""",
							}


							def __init__(       self    ,   lowerCAmelCase_=3_20_00    ,   lowerCAmelCase_=10_24    ,   lowerCAmelCase_=24    ,   lowerCAmelCase_=16    ,   lowerCAmelCase_=40_96    ,   lowerCAmelCase_="gelu"    ,   lowerCAmelCase_=True    ,   lowerCAmelCase_="bi"    ,   lowerCAmelCase_=0.02    ,   lowerCAmelCase_=1E-12    ,   lowerCAmelCase_=0.1    ,   lowerCAmelCase_=5_12    ,   lowerCAmelCase_=None    ,   lowerCAmelCase_=True    ,   lowerCAmelCase_=False    ,   lowerCAmelCase_=False    ,   lowerCAmelCase_=-1    ,   lowerCAmelCase_=False    ,   lowerCAmelCase_="last"    ,   lowerCAmelCase_=True    ,   lowerCAmelCase_="tanh"    ,   lowerCAmelCase_=0.1    ,   lowerCAmelCase_=5    ,   lowerCAmelCase_=5    ,   lowerCAmelCase_=5    ,   lowerCAmelCase_=1    ,   lowerCAmelCase_=2    ,   **lowerCAmelCase_    ,   ):





								"""simple docstring"""






								_snake_case   						=		vocab_size
								_snake_case   						=		d_model
								_snake_case   						=		n_layer
								_snake_case   						=		n_head
								if d_model % n_head != 0:
									raise ValueError(F'\'d_model % n_head\' ({d_model % n_head}) should be equal to 0'  )
								if "d_head" in kwargs:
									if kwargs["d_head"] != d_model // n_head:
										raise ValueError(
										    F'`d_head` ({kwargs["d_head"]}) should be equal to `d_model // n_head` ({d_model // n_head})'  )
								_snake_case   						=		d_model // n_head
								_snake_case   						=		ff_activation
								_snake_case   						=		d_inner
								_snake_case   						=		untie_r
								_snake_case   						=		attn_type

								_snake_case   						=		initializer_range
								_snake_case   						=		layer_norm_eps

								_snake_case   						=		dropout
								_snake_case   						=		mem_len
								_snake_case   						=		reuse_len
								_snake_case   						=		bi_data
								_snake_case   						=		clamp_len
								_snake_case   						=		same_length

								_snake_case   						=		summary_type
								_snake_case   						=		summary_use_proj
								_snake_case   						=		summary_activation
								_snake_case   						=		summary_last_dropout
								_snake_case   						=		start_n_top
								_snake_case   						=		end_n_top

								_snake_case   						=		bos_token_id
								_snake_case   						=		pad_token_id
								_snake_case   						=		eos_token_id

								if "use_cache" in kwargs:
									warnings.warn(
									    'The `use_cache` argument is deprecated and will be removed in a future version, use `use_mems_eval`'
									    ' instead.'    ,   lowerCAmelCase_    ,   )
									_snake_case   						=		kwargs['use_cache']

								_snake_case   						=		use_mems_eval
								_snake_case   						=		use_mems_train
								super().__init__(pad_token_id=lowerCAmelCase_    ,   bos_token_id=lowerCAmelCase_    ,   eos_token_id=lowerCAmelCase_    ,   **lowerCAmelCase_  )


							@property
							def  lowerCamelCase				(       self  ):





								"""simple docstring"""






								logger.info(F'The model {self.model_type} is one of the few models that has no sequence length limit.'  )
								return -1




							@max_position_embeddings.setter
							def  lowerCamelCase				(       self    ,   lowerCAmelCase_  ):





								"""simple docstring"""






								raise NotImplementedError(
								    F'The model {self.model_type} is one of the few models that has no sequence length limit.'  )

