


'''simple docstring'''
UpperCAmelCase_			:  Dict										=   range(2, 2_0 + 1)
UpperCAmelCase_			:  Any										=   [1_0**k for k in range(ks[-1] + 1)]
UpperCAmelCase_			:  dict[int, dict[int, list[list[int]]]]										=   {}


def       _lowercase							(					UpperCamelCase__							:       Optional[int],					UpperCamelCase__							:       int,					UpperCamelCase__							:       Optional[Any],					UpperCamelCase__							:       int      ):
 __A	:		str	  =      sum(a_i[j] for j in range(UpperCamelCase__,					len(UpperCamelCase__      )      )      )
 __A	:		str	  =      sum(a_i[j] * base[j] for j in range(min(len(UpperCamelCase__      ),					UpperCamelCase__      )      )      )

 __A  ,__A	:		int	  =      0, 0
 __A	:		Tuple	  =      n - i

 __A	:		List[str]	  =      memo.get(UpperCamelCase__      )

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

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

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

  else:
   __A	:		List[Any]	  =      []
 else:
  __A	:		List[Any]	  =      {c: []}
  __A	:		List[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[Any]	  =      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
  __A  ,__A	:		List[Any]	  =      compute(UpperCamelCase__,					UpperCamelCase__,					i + dn,					UpperCamelCase__      )
  diff += _diff
  dn += terms_jumped

 __A	:		Dict	  =      sub_memo[c]

 # keep jumps sorted by # of terms skipped
 __A	:		Optional[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       _lowercase							(					UpperCamelCase__							:       List[str],					UpperCamelCase__							:       Optional[Any],					UpperCamelCase__							:       Union[str, Any],					UpperCamelCase__							:       int      ):
 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)
 __A	:		Optional[Any]	  =      i
 __A  ,__A  ,__A	:		Union[str, 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
  __A	:		str	  =      ds_c + ds_b
  diff += addend
  __A	:		Optional[Any]	  =      0
  for j in range(UpperCamelCase__      ):
   __A	:		Any	  =      a_i[j] + addend
   __A  ,__A	:		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       _lowercase							(					UpperCamelCase__							:       Tuple,					UpperCamelCase__							:       Dict,					UpperCamelCase__							:       Optional[Any]      ):
 for j in range(UpperCamelCase__,					len(UpperCamelCase__      )      ):
  __A	:		Tuple	  =      digits[j] + addend
  if s >= 10:
   __A  ,__A	:		Dict	  =      divmod(UpperCamelCase__,					10      )
   __A	:		Any	  =      addend // 10 + quotient
  else:
   __A	:		List[str]	  =      s
   __A	:		List[Any]	  =      addend // 10

  if addend == 0:
   break

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


def       _lowercase							(					UpperCamelCase__							:       int = 10**15      ):
 __A	:		Optional[Any]	  =      [1]
 __A	:		Union[str, Any]	  =      1
 __A	:		Dict	  =      0
 while True:
  __A  ,__A	:		Optional[Any]	  =      next_term(UpperCamelCase__,					20,					i + dn,					UpperCamelCase__      )
  dn += terms_jumped
  if dn == n - i:
   break

 __A	:		str	  =      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 typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


UpperCAmelCase_			:  Dict										=   {
    'configuration_distilbert': [
        'DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'DistilBertConfig',
        'DistilBertOnnxConfig',
    ],
    'tokenization_distilbert': ['DistilBertTokenizer'],
}

try:
 if not is_tokenizers_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 UpperCAmelCase_			:  List[Any]										=   ['DistilBertTokenizerFast']

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 UpperCAmelCase_			:  int										=   [
     'DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
     'DistilBertForMaskedLM',
     'DistilBertForMultipleChoice',
     'DistilBertForQuestionAnswering',
     'DistilBertForSequenceClassification',
     'DistilBertForTokenClassification',
     'DistilBertModel',
     'DistilBertPreTrainedModel',
 ]

try:
 if not is_tf_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 UpperCAmelCase_			:  Optional[int]										=   [
     'TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
     'TFDistilBertForMaskedLM',
     'TFDistilBertForMultipleChoice',
     'TFDistilBertForQuestionAnswering',
     'TFDistilBertForSequenceClassification',
     'TFDistilBertForTokenClassification',
     'TFDistilBertMainLayer',
     'TFDistilBertModel',
     'TFDistilBertPreTrainedModel',
 ]

try:
 if not is_flax_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 UpperCAmelCase_			:  List[str]										=   [
     'FlaxDistilBertForMaskedLM',
     'FlaxDistilBertForMultipleChoice',
     'FlaxDistilBertForQuestionAnswering',
     'FlaxDistilBertForSequenceClassification',
     'FlaxDistilBertForTokenClassification',
     'FlaxDistilBertModel',
     'FlaxDistilBertPreTrainedModel',
 ]


if TYPE_CHECKING:
 from .configuration_distilbert import (
     DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
     DistilBertConfig,
     DistilBertOnnxConfig,
 )
 from .tokenization_distilbert import DistilBertTokenizer

 try:
  if not is_tokenizers_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .tokenization_distilbert_fast import DistilBertTokenizerFast

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_distilbert import (
      DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
      DistilBertForMaskedLM,
      DistilBertForMultipleChoice,
      DistilBertForQuestionAnswering,
      DistilBertForSequenceClassification,
      DistilBertForTokenClassification,
      DistilBertModel,
      DistilBertPreTrainedModel,
  )

 try:
  if not is_tf_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_tf_distilbert import (
      TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
      TFDistilBertForMaskedLM,
      TFDistilBertForMultipleChoice,
      TFDistilBertForQuestionAnswering,
      TFDistilBertForSequenceClassification,
      TFDistilBertForTokenClassification,
      TFDistilBertMainLayer,
      TFDistilBertModel,
      TFDistilBertPreTrainedModel,
  )

 try:
  if not is_flax_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_flax_distilbert import (
      FlaxDistilBertForMaskedLM,
      FlaxDistilBertForMultipleChoice,
      FlaxDistilBertForQuestionAnswering,
      FlaxDistilBertForSequenceClassification,
      FlaxDistilBertForTokenClassification,
      FlaxDistilBertModel,
      FlaxDistilBertPreTrainedModel,
  )

else:
 import sys

 UpperCAmelCase_			:  Optional[Any]										=   _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)






