



__snake_case       :	int            =range(2, 2_0 + 1)
__snake_case       :	int            =[1_0**k for k in range(ks[-1] + 1)]
__snake_case       :	dict[int, dict[int, list[list[int]]]]            ={}






def 			lowerCAmelCase__	(					lowerCamelCase_	:	List[Any] ,lowerCamelCase_	:	Optional[int] ,lowerCamelCase_	:	int ,lowerCamelCase_	:	Optional[int]):





    '''simple docstring'''

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

    lowerCAmelCase__  :       Tuple				=  0, 0
    lowerCAmelCase__  :       Tuple				=  n - i

    lowerCAmelCase__  :       int				=  memo.get(snake_case_)

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

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

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

        else:
            lowerCAmelCase__  :       List[Any]				=  []
    else:
        lowerCAmelCase__  :       str				=  {c: []}
        lowerCAmelCase__  :       str				=  sub_memo

    if dn >= max_dn or c + diff >= base[k]:
        return diff, dn

    if k > ks[0]:
        while True:
            # keep doing smaller jumps
            lowerCAmelCase__  :       Any				=  next_term(snake_case_ ,k - 1 ,i + dn ,snake_case_)
            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
        lowerCAmelCase__  :       List[Any]				=  compute(snake_case_ ,snake_case_ ,i + dn ,snake_case_)
        diff += _diff
        dn += terms_jumped

    lowerCAmelCase__  :       Optional[Any]				=  sub_memo[c]

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

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






def 			lowerCAmelCase__	(					lowerCamelCase_	:	int ,lowerCamelCase_	:	Any ,lowerCamelCase_	:	str ,lowerCamelCase_	:	Optional[int]):





    '''simple docstring'''

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

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

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

            ds_c += a_i[j]

        if addend > 0:
            break

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






def 			lowerCAmelCase__	(					lowerCamelCase_	:	Optional[int] ,lowerCamelCase_	:	List[str] ,lowerCamelCase_	:	List[str]):





    '''simple docstring'''

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

        if addend == 0:
            break

    while addend > 0:
        lowerCAmelCase__  :       List[str]				=  divmod(snake_case_ ,10)
        digits.append(snake_case_)






def 			lowerCAmelCase__	(					lowerCamelCase_	:	int = 10**15):





    '''simple docstring'''

    lowerCAmelCase__  :       List[Any]				=  [1]
    lowerCAmelCase__  :       int				=  1
    lowerCAmelCase__  :       List[Any]				=  0
    while True:
        lowerCAmelCase__  :       Optional[Any]				=  next_term(snake_case_ ,20 ,i + dn ,snake_case_)
        dn += terms_jumped
        if dn == n - i:
            break

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


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






import copy

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


__snake_case       :	Any            =logging.get_logger(__name__)



class  lowerCamelCase__    (							lowerCamelCase__):




		'''simple docstring'''



		snake_case_			="""encoder-decoder"""
		snake_case_			=True



		def __init__(self	,**__lowerCamelCase				)  ->    Union[str, Any]:

						"""simple docstring"""






						super().__init__(**__lowerCamelCase				)
						assert (
						    "encoder" in kwargs and "decoder" in kwargs
						), "Config has to be initialized with encoder and decoder config"
						lowerCAmelCase__  :       Optional[Any]				=  kwargs.pop('''encoder'''				)
						lowerCAmelCase__  :       Any				=  encoder_config.pop('''model_type'''				)
						lowerCAmelCase__  :       str				=  kwargs.pop('''decoder'''				)
						lowerCAmelCase__  :       Tuple				=  decoder_config.pop('''model_type'''				)

						from ..auto.configuration_auto import AutoConfig

						lowerCAmelCase__  :       Tuple				=  AutoConfig.for_model(__lowerCamelCase	,**__lowerCamelCase				)
						lowerCAmelCase__  :       Any				=  AutoConfig.for_model(__lowerCamelCase	,**__lowerCamelCase				)
						lowerCAmelCase__  :       str				=  True



		@classmethod
		def 	lowerCAmelCase__   (cls	,__lowerCamelCase	,__lowerCamelCase	,**__lowerCamelCase				)  ->    PretrainedConfig:

						"""simple docstring"""






						logger.info('''Set `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config'''				)
						lowerCAmelCase__  :       Optional[int]				=  True
						lowerCAmelCase__  :       List[str]				=  True

						return cls(encoder=encoder_config.to_dict()	,decoder=decoder_config.to_dict()	,**__lowerCamelCase				)



		def 	lowerCAmelCase__   (self				)  ->    Tuple:

						"""simple docstring"""






						lowerCAmelCase__  :       int				=  copy.deepcopy(self.__dict__				)
						lowerCAmelCase__  :       Optional[Any]				=  self.encoder.to_dict()
						lowerCAmelCase__  :       str				=  self.decoder.to_dict()
						lowerCAmelCase__  :       Optional[int]				=  self.__class__.model_type
						return output

