





'''simple docstring'''






snake_case_     =	range(2, 20 + 1)
snake_case_     =	[10**k for k in range(ks[-1] + 1)]
snake_case_     =	{}
def 							_lowerCamelCase(  UpperCamelCase__    : Optional[Any]    ,       UpperCamelCase__    : List[Any]    ,       UpperCamelCase__    : Dict    ,       UpperCamelCase__    : List[str]		)		->  List[Any]:
    A       :       Optional[int]							=						sum(a_i[j] for j in range(lowerCAmelCase__    ,       len(lowerCAmelCase__		)		)		)
    A       :       Optional[int]							=						sum(a_i[j] * base[j] for j in range(min(len(lowerCAmelCase__		)    ,       lowerCAmelCase__		)		)		)

    A,	A       :       Union[str, Any]							=						0, 0
    A       :       Optional[int]							=						n - i

    A       :       int							=						memo.get(lowerCAmelCase__		)

    if sub_memo is not None:
        A       :       Optional[int]							=						sub_memo.get(lowerCAmelCase__		)

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

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

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

    A       :       List[Any]							=						sub_memo[c]

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

    # cache the jump for this value digitsum(b) and c
    sub_memo[c].insert(lowerCAmelCase__    ,       (diff, dn, k)		)
    return (diff, dn)
def 							_lowerCamelCase(  UpperCamelCase__    : Tuple    ,       UpperCamelCase__    : List[Any]    ,       UpperCamelCase__    : int    ,       UpperCamelCase__    : int		)		->  Tuple:
    if i >= n:
        return 0, i
    if k > len(lowerCAmelCase__		):
        a_i.extend([0 for _ in range(k - len(lowerCAmelCase__		)		)]		)

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

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

            ds_c += a_i[j]

        if addend > 0:
            break

    if addend > 0:
        add(lowerCAmelCase__    ,       lowerCAmelCase__    ,       lowerCAmelCase__		)
    return diff, i - start_i
def 							_lowerCamelCase(  UpperCamelCase__    : Tuple    ,       UpperCamelCase__    : int    ,       UpperCamelCase__    : List[Any]		)		->  Optional[int]:
    for j in range(lowerCAmelCase__    ,       len(lowerCAmelCase__		)		):
        A       :       List[Any]							=						digits[j] + addend
        if s >= 10:
            A,	A       :       Any							=						divmod(lowerCAmelCase__    ,       10		)
            A       :       Tuple							=						addend // 10 + quotient
        else:
            A       :       Tuple							=						s
            A       :       Dict							=						addend // 10

        if addend == 0:
            break

    while addend > 0:
        A,	A       :       Optional[Any]							=						divmod(lowerCAmelCase__    ,       10		)
        digits.append(lowerCAmelCase__		)
def 							_lowerCamelCase(  UpperCamelCase__    : int = 10**15		)		->  int:
    A       :       str							=						[1]
    A       :       Optional[int]							=						1
    A       :       Optional[int]							=						0
    while True:
        A,	A       :       List[str]							=						next_term(lowerCAmelCase__    ,       20    ,       i + dn    ,       lowerCAmelCase__		)
        dn += terms_jumped
        if dn == n - i:
            break

    A       :       Optional[Any]							=						0
    for j in range(len(lowerCAmelCase__		)		):
        a_n += digits[j] * 10**j
    return a_n


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







'''simple docstring'''






from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available


snake_case_     =	{
    """configuration_biogpt""": ["""BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BioGptConfig"""],
    """tokenization_biogpt""": ["""BioGptTokenizer"""],
}

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     snake_case_     =	[
         """BIOGPT_PRETRAINED_MODEL_ARCHIVE_LIST""",
         """BioGptForCausalLM""",
         """BioGptForTokenClassification""",
         """BioGptForSequenceClassification""",
         """BioGptModel""",
         """BioGptPreTrainedModel""",
     ]


if TYPE_CHECKING:
     from .configuration_biogpt import BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP, BioGptConfig
     from .tokenization_biogpt import BioGptTokenizer

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_biogpt import (
              BIOGPT_PRETRAINED_MODEL_ARCHIVE_LIST,
              BioGptForCausalLM,
              BioGptForSequenceClassification,
              BioGptForTokenClassification,
              BioGptModel,
              BioGptPreTrainedModel,
          )


else:
     import sys

     snake_case_     =	_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)
