




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



def 					UpperCAmelCase__     (   lowerCamelCase,	lowerCamelCase,	lowerCamelCase,	lowerCamelCase      ):
  lowercase			:Optional[int]							=  sum(a_i[j] for j in range(lowerCamelCase,	len(lowerCamelCase      )      )      )
  lowercase			:Union[str, Any]							=  sum(a_i[j] * base[j] for j in range(min(len(lowerCamelCase      ),	lowerCamelCase      )      )      )

  lowercase		,			lowercase			:str							=  0, 0
  lowercase			:Optional[int]							=  n - i

  lowercase			:List[Any]							=  memo.get(lowerCamelCase      )

  if sub_memo is not None:
    lowercase			:Optional[Any]							=  sub_memo.get(lowerCamelCase      )

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

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

    else:
      lowercase			:Optional[Any]							=  []
  else:
    lowercase			:Any							=  {c: []}
    lowercase			:Dict							=  sub_memo

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

  if k > ks[0]:
    while True:
      # keep doing smaller jumps
      lowercase		,			lowercase			:Optional[Any]							=  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
    lowercase		,			lowercase			:Dict							=  compute(lowerCamelCase,	lowerCamelCase,	i + dn,	lowerCamelCase      )
    diff += _diff
    dn += terms_jumped

  lowercase			:Any							=  sub_memo[c]

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

    if addend == 0:
      break

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



def 					UpperCAmelCase__     (   lowerCamelCase = 10**15      ):
  lowercase			:int							=  [1]
  lowercase			:str							=  1
  lowercase			:Tuple							=  0
  while True:
    lowercase		,			lowercase			:List[str]							=  next_term(lowerCamelCase,	20,	i + dn,	lowerCamelCase      )
    dn += terms_jumped
    if dn == n - i:
      break

  lowercase			:Any							=  0
  for j in range(len(lowerCamelCase      )      ):
    a_n += digits[j] * 10**j
  return a_n


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









from typing import TYPE_CHECKING

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


_UpperCAmelCase		:  int	=   {"configuration_swin": ["SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP", "SwinConfig", "SwinOnnxConfig"]}


try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     _UpperCAmelCase		:  List[str]	=   [
         "SWIN_PRETRAINED_MODEL_ARCHIVE_LIST",
         "SwinForImageClassification",
         "SwinForMaskedImageModeling",
         "SwinModel",
         "SwinPreTrainedModel",
         "SwinBackbone",
     ]

try:
     if not is_tf_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     _UpperCAmelCase		:  int	=   [
         "TF_SWIN_PRETRAINED_MODEL_ARCHIVE_LIST",
         "TFSwinForImageClassification",
         "TFSwinForMaskedImageModeling",
         "TFSwinModel",
         "TFSwinPreTrainedModel",
     ]

if TYPE_CHECKING:
     from .configuration_swin import SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP, SwinConfig, SwinOnnxConfig

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_swin import (
              SWIN_PRETRAINED_MODEL_ARCHIVE_LIST,
              SwinBackbone,
              SwinForImageClassification,
              SwinForMaskedImageModeling,
              SwinModel,
              SwinPreTrainedModel,
          )

     try:
          if not is_tf_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_tf_swin import (
              TF_SWIN_PRETRAINED_MODEL_ARCHIVE_LIST,
              TFSwinForImageClassification,
              TFSwinForMaskedImageModeling,
              TFSwinModel,
              TFSwinPreTrainedModel,
          )

else:
     import sys

     _UpperCAmelCase		:  int	=   _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)



