


"""simple docstring"""



__snake_case             =   range(2, 20 + 1)
__snake_case             =   [10**k for k in range(ks[-1] + 1)]
__snake_case             =   {}







def   __lowerCAmelCase						(						lowercase  :  List[Any]						,							lowercase  :  Dict						,							lowercase  :  int						,							lowercase  :  Optional[Any]			)     ->						Union[str, Any]:


    """simple docstring"""





    snake_case   :				str				 =   sum(a_i[j] for j in range(lowercase						,							len(lowercase			)			)			)
    snake_case   :				int				 =   sum(a_i[j] * base[j] for j in range(min(len(lowercase			)						,							lowercase			)			)			)

    snake_case ,snake_case   :				Any				 =   0, 0
    snake_case   :				Dict				 =   n - i

    snake_case   :				Any				 =   memo.get(lowercase			)

    if sub_memo is not None:
        snake_case   :				int				 =   sub_memo.get(lowercase			)

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

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

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

    snake_case   :				Optional[Any]				 =   sub_memo[c]

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

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







def   __lowerCAmelCase						(						lowercase  :  List[str]						,							lowercase  :  List[str]						,							lowercase  :  int						,							lowercase  :  Any			)     ->						Any:


    """simple docstring"""





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

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

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

            ds_c += a_i[j]

        if addend > 0:
            break

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







def   __lowerCAmelCase						(						lowercase  :  List[Any]						,							lowercase  :  int						,							lowercase  :  Union[str, Any]			)     ->						Dict:


    """simple docstring"""





    for j in range(lowercase						,							len(lowercase			)			):
        snake_case   :				Optional[Any]				 =   digits[j] + addend
        if s >= 10:
            snake_case ,snake_case   :				List[str]				 =   divmod(lowercase						,							10			)
            snake_case   :				Dict				 =   addend // 10 + quotient
        else:
            snake_case   :				Union[str, Any]				 =   s
            snake_case   :				Optional[Any]				 =   addend // 10

        if addend == 0:
            break

    while addend > 0:
        snake_case ,snake_case   :				Optional[int]				 =   divmod(lowercase						,							10			)
        digits.append(lowercase			)







def   __lowerCAmelCase						(						lowercase  :  int = 10**15			)     ->						int:


    """simple docstring"""





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

    snake_case   :				List[str]				 =   0
    for j in range(len(lowercase			)			):
        a_n += digits[j] * 10**j
    return a_n


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









"""simple docstring"""



from . import __version__

# Backward compatibility imports, to make sure all those objects can be found in file_utils
from .utils import (
    CLOUDFRONT_DISTRIB_PREFIX,
    CONFIG_NAME,
    DISABLE_TELEMETRY,
    DUMMY_INPUTS,
    DUMMY_MASK,
    ENV_VARS_TRUE_AND_AUTO_VALUES,
    ENV_VARS_TRUE_VALUES,
    FEATURE_EXTRACTOR_NAME,
    FLAX_WEIGHTS_NAME,
    HF_MODULES_CACHE,
    HUGGINGFACE_CO_PREFIX,
    HUGGINGFACE_CO_RESOLVE_ENDPOINT,
    MODEL_CARD_NAME,
    MULTIPLE_CHOICE_DUMMY_INPUTS,
    PYTORCH_PRETRAINED_BERT_CACHE,
    PYTORCH_TRANSFORMERS_CACHE,
    S3_BUCKET_PREFIX,
    SENTENCEPIECE_UNDERLINE,
    SPIECE_UNDERLINE,
    TF2_WEIGHTS_NAME,
    TF_WEIGHTS_NAME,
    TORCH_FX_REQUIRED_VERSION,
    TRANSFORMERS_CACHE,
    TRANSFORMERS_DYNAMIC_MODULE_NAME,
    USE_JAX,
    USE_TF,
    USE_TORCH,
    WEIGHTS_INDEX_NAME,
    WEIGHTS_NAME,
    ContextManagers,
    DummyObject,
    EntryNotFoundError,
    ExplicitEnum,
    ModelOutput,
    PaddingStrategy,
    PushToHubMixin,
    RepositoryNotFoundError,
    RevisionNotFoundError,
    TensorType,
    _LazyModule,
    add_code_sample_docstrings,
    add_end_docstrings,
    add_start_docstrings,
    add_start_docstrings_to_model_forward,
    cached_property,
    copy_func,
    default_cache_path,
    define_sagemaker_information,
    get_cached_models,
    get_file_from_repo,
    get_full_repo_name,
    get_torch_version,
    has_file,
    http_user_agent,
    is_apex_available,
    is_bsa_available,
    is_coloredlogs_available,
    is_datasets_available,
    is_detectrona_available,
    is_faiss_available,
    is_flax_available,
    is_ftfy_available,
    is_in_notebook,
    is_ipex_available,
    is_librosa_available,
    is_offline_mode,
    is_onnx_available,
    is_pandas_available,
    is_phonemizer_available,
    is_protobuf_available,
    is_psutil_available,
    is_pyanvml_available,
    is_pyctcdecode_available,
    is_pytesseract_available,
    is_pytorch_quantization_available,
    is_rjieba_available,
    is_sagemaker_dp_enabled,
    is_sagemaker_mp_enabled,
    is_scipy_available,
    is_sentencepiece_available,
    is_seqio_available,
    is_sklearn_available,
    is_soundfile_availble,
    is_spacy_available,
    is_speech_available,
    is_tensor,
    is_tensorflow_probability_available,
    is_tfaonnx_available,
    is_tf_available,
    is_timm_available,
    is_tokenizers_available,
    is_torch_available,
    is_torch_bfaa_available,
    is_torch_cuda_available,
    is_torch_fx_available,
    is_torch_fx_proxy,
    is_torch_mps_available,
    is_torch_tfaa_available,
    is_torch_tpu_available,
    is_torchaudio_available,
    is_training_run_on_sagemaker,
    is_vision_available,
    replace_return_docstrings,
    requires_backends,
    to_numpy,
    to_py_obj,
    torch_only_method,
)





