
'''simple docstring'''






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







def 		A_							(						_lowerCAmelCase :     Any					,						_lowerCAmelCase :     Optional[Any]					,						_lowerCAmelCase :     List[str]					,						_lowerCAmelCase :     Optional[Any]				):



      """simple docstring"""




      _lowerCamelCase					: List[Any]		    = sum(a_i[j] for j in range(_lowerCAmelCase					,						len(_lowerCAmelCase				)				)				)
      _lowerCamelCase					: List[str]		    = sum(a_i[j] * base[j] for j in range(min(len(_lowerCAmelCase				)					,						_lowerCAmelCase				)				)				)

      _lowerCamelCase    ,		_lowerCamelCase					: int		    = 0, 0
      _lowerCamelCase					: Dict		    = n - i

      _lowerCamelCase					: int		    = memo.get(_lowerCAmelCase				)

      if sub_memo is not None:
            _lowerCamelCase					: List[str]		    = sub_memo.get(_lowerCAmelCase				)

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

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

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

      _lowerCamelCase					: List[str]		    = sub_memo[c]

      # keep jumps sorted by # of terms skipped
      _lowerCamelCase					: 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 		A_							(						_lowerCAmelCase :     Dict					,						_lowerCAmelCase :     Any					,						_lowerCAmelCase :     List[str]					,						_lowerCAmelCase :     List[Any]				):



      """simple docstring"""




      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)
      _lowerCamelCase					: List[str]		    = i
      _lowerCamelCase    ,		_lowerCamelCase    ,		_lowerCamelCase					: 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
            _lowerCamelCase					: int		    = ds_c + ds_b
            diff += addend
            _lowerCamelCase					: List[str]		    = 0
            for j in range(_lowerCAmelCase				):
                  _lowerCamelCase					: List[Any]		    = a_i[j] + addend
                  _lowerCamelCase    ,		_lowerCamelCase					: 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 :     List[Any]					,						_lowerCAmelCase :     str					,						_lowerCAmelCase :     List[Any]				):



      """simple docstring"""




      for j in range(_lowerCAmelCase					,						len(_lowerCAmelCase				)				):
            _lowerCamelCase					: Tuple		    = digits[j] + addend
            if s >= 10:
                  _lowerCamelCase    ,		_lowerCamelCase					: Optional[int]		    = divmod(_lowerCAmelCase					,						10				)
                  _lowerCamelCase					: Any		    = addend // 10 + quotient
            else:
                  _lowerCamelCase					: Tuple		    = s
                  _lowerCamelCase					: List[Any]		    = addend // 10

            if addend == 0:
                  break

      while addend > 0:
            _lowerCamelCase    ,		_lowerCamelCase					: str		    = divmod(_lowerCAmelCase					,						10				)
            digits.append(_lowerCAmelCase				)







def 		A_							(						_lowerCAmelCase :     int = 10**15				):



      """simple docstring"""




      _lowerCamelCase					: Tuple		    = [1]
      _lowerCamelCase					: List[Any]		    = 1
      _lowerCamelCase					: List[str]		    = 0
      while True:
            _lowerCamelCase    ,		_lowerCamelCase					: Dict		    = next_term(_lowerCAmelCase					,						20					,						i + dn					,						_lowerCAmelCase				)
            dn += terms_jumped
            if dn == n - i:
                  break

      _lowerCamelCase					: 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"""





import warnings

from ...utils import logging
from .image_processing_imagegpt import ImageGPTImageProcessor


__UpperCamelCase    : List[str]				 =						logging.get_logger(__name__)







class 							SCREAMING_SNAKE_CASE   (						a_			):






					"""simple docstring"""



					def __init__(			self     :							Any  ,*lowercase_     :							Dict  ,**lowercase_     :							List[str]						):
						warnings.warn(
						    '''The class ImageGPTFeatureExtractor is deprecated and will be removed in version 5 of Transformers.'''
						    ''' Please use ImageGPTImageProcessor instead.'''  ,lowercase_  ,)
						super().__init__(*lowercase_  ,**lowercase_						)




