


"""simple docstring"""

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


def lowerCAmelCase_      (				UpperCamelCase__	: Union[str, Any]				,   UpperCamelCase__	: Union[str, Any]				,   UpperCamelCase__	: List[str]				,   UpperCamelCase__	: Dict ):






 """simple docstring"""







 __lowercase									=	sum(a_i[j] for j in range(UpperCamelCase__				,   len(UpperCamelCase__ ) ) )
 __lowercase									=	sum(a_i[j] * base[j] for j in range(min(len(UpperCamelCase__ )				,   UpperCamelCase__ ) ) )

 __lowercase							,		__lowercase									=	0, 0
 __lowercase									=	n - i

 __lowercase									=	memo.get(UpperCamelCase__ )

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

  if jumps is not None and len(UpperCamelCase__ ) > 0:
   # find and make the largest jump without going over
   __lowercase									=	-1
   for _k in range(len(UpperCamelCase__ ) - 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(UpperCamelCase__				,   len(UpperCamelCase__ ) ) ):
     __lowercase							,		__lowercase									=	divmod(UpperCamelCase__				,   10 )
    if new_c > 0:
     add(UpperCamelCase__				,   UpperCamelCase__				,   UpperCamelCase__ )

  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(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
  __lowercase							,		__lowercase									=	compute(UpperCamelCase__				,   UpperCamelCase__				,   i + dn				,   UpperCamelCase__ )
  diff += _diff
  dn += terms_jumped

 __lowercase									=	sub_memo[c]

 # keep jumps sorted by # of terms skipped
 __lowercase									=	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 lowerCAmelCase_      (				UpperCamelCase__	: Tuple				,   UpperCamelCase__	: Union[str, Any]				,   UpperCamelCase__	: List[str]				,   UpperCamelCase__	: Optional[Any] ):






 """simple docstring"""







 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)
 __lowercase									=	i
 __lowercase							,		__lowercase							,		__lowercase									=	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
  __lowercase									=	ds_c + ds_b
  diff += addend
  __lowercase									=	0
  for j in range(UpperCamelCase__ ):
   __lowercase									=	a_i[j] + addend
   __lowercase							,		__lowercase									=	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 lowerCAmelCase_      (				UpperCamelCase__	: Union[str, Any]				,   UpperCamelCase__	: Tuple				,   UpperCamelCase__	: Union[str, Any] ):






 """simple docstring"""







 for j in range(UpperCamelCase__				,   len(UpperCamelCase__ ) ):
  __lowercase									=	digits[j] + addend
  if s >= 10:
   __lowercase							,		__lowercase									=	divmod(UpperCamelCase__				,   10 )
   __lowercase									=	addend // 10 + quotient
  else:
   __lowercase									=	s
   __lowercase									=	addend // 10

  if addend == 0:
   break

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


def lowerCAmelCase_      (				UpperCamelCase__	: int = 10**15 ):






 """simple docstring"""







 __lowercase									=	[1]
 __lowercase									=	1
 __lowercase									=	0
 while True:
  __lowercase							,		__lowercase									=	next_term(UpperCamelCase__				,   20				,   i + dn				,   UpperCamelCase__ )
  dn += terms_jumped
  if dn == n - i:
   break

 __lowercase									=	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 ...configuration_utils import PretrainedConfig
from ...utils import logging


UpperCAmelCase__  							=logging.get_logger(__name__)

UpperCAmelCase__  							={
    "microsoft/swinv2-tiny-patch4-window8-256": (
        "https://huggingface.co/microsoft/swinv2-tiny-patch4-window8-256/resolve/main/config.json"
    ),
}





class    lowerCamelCase__						(		_a    ):
      a :     List[Any]											=		"""swinv2"""

      a :     Any											=		{
          """num_attention_heads""": """num_heads""",
          """num_hidden_layers""": """num_layers""",
      }
      def __init__(		self	:	List[str]      ,       A_	:	Any=2_2_4      ,       A_	:	int=4      ,       A_	:	Optional[int]=3      ,       A_	:	List[Any]=9_6      ,       A_	:	List[Any]=[2, 2, 6, 2]      ,       A_	:	List[str]=[3, 6, 1_2, 2_4]      ,       A_	:	Union[str, Any]=7      ,       A_	:	int=4.0      ,       A_	:	List[str]=True      ,       A_	:	str=0.0      ,       A_	:	Any=0.0      ,       A_	:	Union[str, Any]=0.1      ,       A_	:	Optional[Any]="gelu"      ,       A_	:	int=False      ,       A_	:	List[Any]=0.02      ,       A_	:	Tuple=1e-5      ,       A_	:	Tuple=3_2      ,       **A_	:	int      ,       ):






       '''simple docstring'''


       super().__init__(**A_							)

       __lowercase									=	image_size
       __lowercase									=	patch_size
       __lowercase									=	num_channels
       __lowercase									=	embed_dim
       __lowercase									=	depths
       __lowercase									=	len(A_							)
       __lowercase									=	num_heads
       __lowercase									=	window_size
       __lowercase									=	mlp_ratio
       __lowercase									=	qkv_bias
       __lowercase									=	hidden_dropout_prob
       __lowercase									=	attention_probs_dropout_prob
       __lowercase									=	drop_path_rate
       __lowercase									=	hidden_act
       __lowercase									=	use_absolute_embeddings
       __lowercase									=	layer_norm_eps
       __lowercase									=	initializer_range
       __lowercase									=	encoder_stride
       # we set the hidden_size attribute in order to make Swinv2 work with VisionEncoderDecoderModel
       # this indicates the channel dimension after the last stage of the model
       __lowercase									=	int(embed_dim * 2 ** (len(A_							) - 1)							)
       __lowercase									=	(0, 0, 0, 0)
