






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





def        _snake_case   (_snake_case				:       Dict      ,    _snake_case				:       Optional[int]      ,    _snake_case				:       Any      ,    _snake_case				:       Optional[Any])					->	List[Any]:
   _lowercase              =sum(a_i[j] for j in range(_snake_case      ,    len(_snake_case)))
   _lowercase              =sum(a_i[j] * base[j] for j in range(min(len(_snake_case)      ,    _snake_case)))

   _lowercase       ,       _lowercase              =0, 0
   _lowercase              =n - i

   _lowercase              =memo.get(_snake_case)

   if sub_memo is not None:
      _lowercase              =sub_memo.get(_snake_case)

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

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

      else:
         _lowercase              =[]
   else:
      _lowercase              ={c: []}
      _lowercase              =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              =next_term(_snake_case      ,    k - 1      ,    i + dn      ,    _snake_case)
         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              =compute(_snake_case      ,    _snake_case      ,    i + dn      ,    _snake_case)
      diff += _diff
      dn += terms_jumped

   _lowercase              =sub_memo[c]

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

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





def        _snake_case   (_snake_case				:       List[str]      ,    _snake_case				:       List[Any]      ,    _snake_case				:       int      ,    _snake_case				:       str)					->	Any:
   if i >= n:
      return 0, i
   if k > len(_snake_case):
      a_i.extend([0 for _ in range(k - len(_snake_case))])

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

   while i < n:
      i += 1
      _lowercase              =ds_c + ds_b
      diff += addend
      _lowercase              =0
      for j in range(_snake_case):
         _lowercase              =a_i[j] + addend
         _lowercase       ,       _lowercase              =divmod(_snake_case      ,    10)

         ds_c += a_i[j]

      if addend > 0:
         break

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





def        _snake_case   (_snake_case				:       Optional[Any]      ,    _snake_case				:       str      ,    _snake_case				:       Any)					->	Union[str, Any]:
   for j in range(_snake_case      ,    len(_snake_case)):
      _lowercase              =digits[j] + addend
      if s >= 10:
         _lowercase       ,       _lowercase              =divmod(_snake_case      ,    10)
         _lowercase              =addend // 10 + quotient
      else:
         _lowercase              =s
         _lowercase              =addend // 10

      if addend == 0:
         break

   while addend > 0:
      _lowercase       ,       _lowercase              =divmod(_snake_case      ,    10)
      digits.append(_snake_case)





def        _snake_case   (_snake_case				:       int = 10**15)					->	int:
   _lowercase              =[1]
   _lowercase              =1
   _lowercase              =0
   while True:
      _lowercase       ,       _lowercase              =next_term(_snake_case      ,    20      ,    i + dn      ,    _snake_case)
      dn += terms_jumped
      if dn == n - i:
         break

   _lowercase              =0
   for j in range(len(_snake_case)):
      a_n += digits[j] * 10**j
   return a_n


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










from typing import List, Optional, Union

from ...image_utils import ImageInput
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType






class 					SCREAMING_SNAKE_CASE_  (       _a ):
       """simple docstring"""


       __lowerCAmelCase    :		Dict					=['''image_processor''', '''tokenizer''']
       __lowerCAmelCase    :		List[Any]					='''BlipImageProcessor'''
       __lowerCAmelCase    :		Union[str, Any]					=('''BertTokenizer''', '''BertTokenizerFast''')





       def __init__(				self	:Optional[int],      snake_case	:int,      snake_case	:Optional[int]):



          """simple docstring"""

          _lowercase              =False
          super().__init__(snake_case,      snake_case)
          _lowercase              =self.image_processor





       def __call__(				self	:Dict,      snake_case	:ImageInput = None,      snake_case	:Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None,      snake_case	:bool = True,      snake_case	:Union[bool, str, PaddingStrategy] = False,      snake_case	:Union[bool, str, TruncationStrategy] = None,      snake_case	:Optional[int] = None,      snake_case	:int = 0,      snake_case	:Optional[int] = None,      snake_case	:Optional[bool] = None,      snake_case	:bool = False,      snake_case	:bool = False,      snake_case	:bool = False,      snake_case	:bool = False,      snake_case	:bool = False,      snake_case	:bool = True,      snake_case	:Optional[Union[str, TensorType]] = None,      **snake_case	:str,      ):



          """simple docstring"""

          if images is None and text is None:
             raise ValueError('You have to specify either images or text.')

          # Get only text
          if images is None:
             _lowercase              =self.tokenizer
             _lowercase              =self.tokenizer(
                 text=snake_case,      add_special_tokens=snake_case,      padding=snake_case,      truncation=snake_case,      max_length=snake_case,      stride=snake_case,      pad_to_multiple_of=snake_case,      return_attention_mask=snake_case,      return_overflowing_tokens=snake_case,      return_special_tokens_mask=snake_case,      return_offsets_mapping=snake_case,      return_token_type_ids=snake_case,      return_length=snake_case,      verbose=snake_case,      return_tensors=snake_case,      **snake_case,      )
             return text_encoding

          # add pixel_values
          _lowercase              =self.image_processor(snake_case,      return_tensors=snake_case)

          if text is not None:
             _lowercase              =self.tokenizer(
                 text=snake_case,      add_special_tokens=snake_case,      padding=snake_case,      truncation=snake_case,      max_length=snake_case,      stride=snake_case,      pad_to_multiple_of=snake_case,      return_attention_mask=snake_case,      return_overflowing_tokens=snake_case,      return_special_tokens_mask=snake_case,      return_offsets_mapping=snake_case,      return_token_type_ids=snake_case,      return_length=snake_case,      verbose=snake_case,      return_tensors=snake_case,      **snake_case,      )
          else:
             _lowercase              =None

          if text_encoding is not None:
             encoding_image_processor.update(snake_case)

          return encoding_image_processor





       def 				UpperCamelCase__						(				self	:List[Any],      *snake_case	:int,      **snake_case	:str):



          """simple docstring"""

          return self.tokenizer.batch_decode(*snake_case,      **snake_case)





       def 				UpperCamelCase__						(				self	:Tuple,      *snake_case	:List[str],      **snake_case	:str):



          """simple docstring"""

          return self.tokenizer.decode(*snake_case,      **snake_case)





       @property
       def 				UpperCamelCase__						(				self	:List[Any]):



          """simple docstring"""

          _lowercase              =self.tokenizer.model_input_names
          _lowercase              =self.image_processor.model_input_names
          return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names))


