





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






def       _A  (      lowerCamelCase							, lowerCamelCase							, lowerCamelCase							, lowerCamelCase   ):
   a__	:						List[str]      		=  sum(a_i[j] for j in range(lowerCamelCase							, len(lowerCamelCase   )   )   )
   a__	:						Any      		=  sum(a_i[j] * base[j] for j in range(min(len(lowerCamelCase   )							, lowerCamelCase   )   )   )

   a__		,     a__	:						List[str]      		=  0, 0
   a__	:						str      		=  n - i

   a__	:						Dict      		=  memo.get(lowerCamelCase   )

   if sub_memo is not None:
      a__	:						Union[str, Any]      		=  sub_memo.get(lowerCamelCase   )

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

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

      else:
         a__	:						List[Any]      		=  []
   else:
      a__	:						Optional[int]      		=  {c: []}
      a__	:						Union[str, 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__	:						Dict      		=  compute(lowerCamelCase							, lowerCamelCase							, i + dn							, lowerCamelCase   )
      diff += _diff
      dn += terms_jumped

   a__	:						Tuple      		=  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       _A  (      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)
   a__	:						str      		=  i
   a__		,     a__		,     a__	:						int      		=  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__	:						int      		=  ds_c + ds_b
      diff += addend
      a__	:						Dict      		=  0
      for j in range(lowerCamelCase   ):
         a__	:						Tuple      		=  a_i[j] + addend
         a__		,     a__	:						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       _A  (      lowerCamelCase							, lowerCamelCase							, lowerCamelCase   ):
   for j in range(lowerCamelCase							, len(lowerCamelCase   )   ):
      a__	:						int      		=  digits[j] + addend
      if s >= 10:
         a__		,     a__	:						Optional[Any]      		=  divmod(lowerCamelCase							, 10   )
         a__	:						Optional[Any]      		=  addend // 10 + quotient
      else:
         a__	:						int      		=  s
         a__	:						Optional[int]      		=  addend // 10

      if addend == 0:
         break

   while addend > 0:
      a__		,     a__	:						Union[str, Any]      		=  divmod(lowerCamelCase							, 10   )
      digits.append(lowerCamelCase   )






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

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


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








SCREAMING_SNAKE_CASE__       :			Union[str, Any]			      =						9.80665






def       _A  (      lowerCamelCase							, lowerCamelCase							, lowerCamelCase = g   ):

   if fluid_density <= 0:
      raise ValueError("Impossible fluid density"   )
   if volume < 0:
      raise ValueError("Impossible Object volume"   )
   if gravity <= 0:
      raise ValueError("Impossible Gravity"   )

   return fluid_density * gravity * volume


if __name__ == "__main__":
  import doctest

  # run doctest
  doctest.testmod()

