




__UpperCAmelCase : int 			=				range(2, 20 + 1)
__UpperCAmelCase : List[str] 			=				[10**k for k in range(ks[-1] + 1)]
__UpperCAmelCase : int 			=				{}


def      a	(							SCREAMING_SNAKE_CASE_      :		Dict							,			SCREAMING_SNAKE_CASE_      :		List[str]							,			SCREAMING_SNAKE_CASE_      :		Dict							,			SCREAMING_SNAKE_CASE_      :		Any       ):






       """simple docstring"""





       UpperCamelCase    :	Dict   	=		sum(a_i[j] for j in range(SCREAMING_SNAKE_CASE_							,			len(SCREAMING_SNAKE_CASE_       )       )       )
       UpperCamelCase    :	List[Any]   	=		sum(a_i[j] * base[j] for j in range(min(len(SCREAMING_SNAKE_CASE_       )							,			SCREAMING_SNAKE_CASE_       )       )       )

       UpperCamelCase	, UpperCamelCase    :	Tuple   	=		0, 0
       UpperCamelCase    :	Tuple   	=		n - i

       UpperCamelCase    :	List[str]   	=		memo.get(SCREAMING_SNAKE_CASE_       )

       if sub_memo is not None:
              UpperCamelCase    :	List[str]   	=		sub_memo.get(SCREAMING_SNAKE_CASE_       )

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

                     if max_jump >= 0:
                            UpperCamelCase	, UpperCamelCase	, UpperCamelCase    :	int   	=		jumps[max_jump]
                            # since the difference between jumps is cached, add c
                            UpperCamelCase    :	Union[str, Any]   	=		diff + c
                            for j in range(min(SCREAMING_SNAKE_CASE_							,			len(SCREAMING_SNAKE_CASE_       )       )       ):
                                   UpperCamelCase	, UpperCamelCase    :	Any   	=		divmod(SCREAMING_SNAKE_CASE_							,			1_0       )
                            if new_c > 0:
                                   add(SCREAMING_SNAKE_CASE_							,			SCREAMING_SNAKE_CASE_							,			SCREAMING_SNAKE_CASE_       )

              else:
                     UpperCamelCase    :	str   	=		[]
       else:
              UpperCamelCase    :	Union[str, Any]   	=		{c: []}
              UpperCamelCase    :	Optional[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
                     UpperCamelCase	, UpperCamelCase    :	List[str]   	=		next_term(SCREAMING_SNAKE_CASE_							,			k - 1							,			i + dn							,			SCREAMING_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
              UpperCamelCase	, UpperCamelCase    :	Any   	=		compute(SCREAMING_SNAKE_CASE_							,			SCREAMING_SNAKE_CASE_							,			i + dn							,			SCREAMING_SNAKE_CASE_       )
              diff += _diff
              dn += terms_jumped

       UpperCamelCase    :	Tuple   	=		sub_memo[c]

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

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


def      a	(							SCREAMING_SNAKE_CASE_      :		List[str]							,			SCREAMING_SNAKE_CASE_      :		List[str]							,			SCREAMING_SNAKE_CASE_      :		List[Any]							,			SCREAMING_SNAKE_CASE_      :		List[str]       ):






       """simple docstring"""





       if i >= n:
              return 0, i
       if k > len(SCREAMING_SNAKE_CASE_       ):
              a_i.extend([0 for _ in range(k - len(SCREAMING_SNAKE_CASE_       )       )]       )

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

       while i < n:
              i += 1
              UpperCamelCase    :	Optional[Any]   	=		ds_c + ds_b
              diff += addend
              UpperCamelCase    :	List[str]   	=		0
              for j in range(SCREAMING_SNAKE_CASE_       ):
                     UpperCamelCase    :	Optional[int]   	=		a_i[j] + addend
                     UpperCamelCase	, UpperCamelCase    :	str   	=		divmod(SCREAMING_SNAKE_CASE_							,			1_0       )

                     ds_c += a_i[j]

              if addend > 0:
                     break

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


def      a	(							SCREAMING_SNAKE_CASE_      :		Optional[int]							,			SCREAMING_SNAKE_CASE_      :		Union[str, Any]							,			SCREAMING_SNAKE_CASE_      :		List[Any]       ):






       """simple docstring"""





       for j in range(SCREAMING_SNAKE_CASE_							,			len(SCREAMING_SNAKE_CASE_       )       ):
              UpperCamelCase    :	Tuple   	=		digits[j] + addend
              if s >= 1_0:
                     UpperCamelCase	, UpperCamelCase    :	List[Any]   	=		divmod(SCREAMING_SNAKE_CASE_							,			1_0       )
                     UpperCamelCase    :	Any   	=		addend // 1_0 + quotient
              else:
                     UpperCamelCase    :	Optional[int]   	=		s
                     UpperCamelCase    :	Any   	=		addend // 1_0

              if addend == 0:
                     break

       while addend > 0:
              UpperCamelCase	, UpperCamelCase    :	Optional[Any]   	=		divmod(SCREAMING_SNAKE_CASE_							,			1_0       )
              digits.append(SCREAMING_SNAKE_CASE_       )


def      a	(							SCREAMING_SNAKE_CASE_      :		int = 1_0**1_5       ):






       """simple docstring"""





       UpperCamelCase    :	Union[str, Any]   	=		[1]
       UpperCamelCase    :	Optional[int]   	=		1
       UpperCamelCase    :	Tuple   	=		0
       while True:
              UpperCamelCase	, UpperCamelCase    :	Dict   	=		next_term(SCREAMING_SNAKE_CASE_							,			2_0							,			i + dn							,			SCREAMING_SNAKE_CASE_       )
              dn += terms_jumped
              if dn == n - i:
                     break

       UpperCamelCase    :	Optional[Any]   	=		0
       for j in range(len(SCREAMING_SNAKE_CASE_       )       ):
              a_n += digits[j] * 1_0**j
       return a_n


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





import copy
from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging
from ..auto import CONFIG_MAPPING


__UpperCAmelCase : Optional[Any] 			=				logging.get_logger(__name__)

__UpperCAmelCase : List[str] 			=				{
    "microsoft/conditional-detr-resnet-50": (
        "https://huggingface.co/microsoft/conditional-detr-resnet-50/resolve/main/config.json"
    ),
}



class    UpperCAmelCase_	(							_a):
       '''simple docstring'''
       __UpperCamelCase      :     Optional[int]							=					"conditional_detr"
       __UpperCamelCase      :     Optional[Any]							=					["past_key_values"]
       __UpperCamelCase      :     Union[str, Any]							=					{
           "hidden_size": "d_model",
           "num_attention_heads": "encoder_attention_heads",
       }






       def __init__(     self ,					__SCREAMING_SNAKE_CASE=True ,					__SCREAMING_SNAKE_CASE=None ,					__SCREAMING_SNAKE_CASE=3 ,					__SCREAMING_SNAKE_CASE=300 ,					__SCREAMING_SNAKE_CASE=6 ,					__SCREAMING_SNAKE_CASE=2_048 ,					__SCREAMING_SNAKE_CASE=8 ,					__SCREAMING_SNAKE_CASE=6 ,					__SCREAMING_SNAKE_CASE=2_048 ,					__SCREAMING_SNAKE_CASE=8 ,					__SCREAMING_SNAKE_CASE=0.0 ,					__SCREAMING_SNAKE_CASE=0.0 ,					__SCREAMING_SNAKE_CASE=True ,					__SCREAMING_SNAKE_CASE="relu" ,					__SCREAMING_SNAKE_CASE=256 ,					__SCREAMING_SNAKE_CASE=0.1 ,					__SCREAMING_SNAKE_CASE=0.0 ,					__SCREAMING_SNAKE_CASE=0.0 ,					__SCREAMING_SNAKE_CASE=0.02 ,					__SCREAMING_SNAKE_CASE=1.0 ,					__SCREAMING_SNAKE_CASE=False ,					__SCREAMING_SNAKE_CASE="sine" ,					__SCREAMING_SNAKE_CASE="resnet50" ,					__SCREAMING_SNAKE_CASE=True ,					__SCREAMING_SNAKE_CASE=False ,					__SCREAMING_SNAKE_CASE=2 ,					__SCREAMING_SNAKE_CASE=5 ,					__SCREAMING_SNAKE_CASE=2 ,					__SCREAMING_SNAKE_CASE=1 ,					__SCREAMING_SNAKE_CASE=1 ,					__SCREAMING_SNAKE_CASE=2 ,					__SCREAMING_SNAKE_CASE=5 ,					__SCREAMING_SNAKE_CASE=2 ,					__SCREAMING_SNAKE_CASE=0.25 ,					**__SCREAMING_SNAKE_CASE ,					):




              """simple docstring"""




              if backbone_config is not None and use_timm_backbone:
                     raise ValueError('''You can\'t specify both `backbone_config` and `use_timm_backbone`.'''						)

              if not use_timm_backbone:
                     if backbone_config is None:
                            logger.info('''`backbone_config` is `None`. Initializing the config with the default `ResNet` backbone.'''						)
                            UpperCamelCase    :	str   	=		CONFIG_MAPPING['''resnet'''](out_features=['''stage4''']						)
                     elif isinstance(__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE						):
                            UpperCamelCase    :	Tuple   	=		backbone_config.get('''model_type'''						)
                            UpperCamelCase    :	Optional[Any]   	=		CONFIG_MAPPING[backbone_model_type]
                            UpperCamelCase    :	Any   	=		config_class.from_dict(__SCREAMING_SNAKE_CASE						)

              UpperCamelCase    :	List[str]   	=		use_timm_backbone
              UpperCamelCase    :	int   	=		backbone_config
              UpperCamelCase    :	Any   	=		num_channels
              UpperCamelCase    :	Optional[Any]   	=		num_queries
              UpperCamelCase    :	Tuple   	=		d_model
              UpperCamelCase    :	Optional[Any]   	=		encoder_ffn_dim
              UpperCamelCase    :	Optional[int]   	=		encoder_layers
              UpperCamelCase    :	Union[str, Any]   	=		encoder_attention_heads
              UpperCamelCase    :	Optional[Any]   	=		decoder_ffn_dim
              UpperCamelCase    :	Optional[int]   	=		decoder_layers
              UpperCamelCase    :	Optional[Any]   	=		decoder_attention_heads
              UpperCamelCase    :	Any   	=		dropout
              UpperCamelCase    :	List[Any]   	=		attention_dropout
              UpperCamelCase    :	List[Any]   	=		activation_dropout
              UpperCamelCase    :	List[str]   	=		activation_function
              UpperCamelCase    :	Optional[int]   	=		init_std
              UpperCamelCase    :	Optional[Any]   	=		init_xavier_std
              UpperCamelCase    :	Union[str, Any]   	=		encoder_layerdrop
              UpperCamelCase    :	Optional[Any]   	=		decoder_layerdrop
              UpperCamelCase    :	Tuple   	=		encoder_layers
              UpperCamelCase    :	Optional[Any]   	=		auxiliary_loss
              UpperCamelCase    :	Union[str, Any]   	=		position_embedding_type
              UpperCamelCase    :	Optional[int]   	=		backbone
              UpperCamelCase    :	Dict   	=		use_pretrained_backbone
              UpperCamelCase    :	Tuple   	=		dilation
              # Hungarian matcher
              UpperCamelCase    :	Union[str, Any]   	=		class_cost
              UpperCamelCase    :	List[Any]   	=		bbox_cost
              UpperCamelCase    :	Optional[Any]   	=		giou_cost
              # Loss coefficients
              UpperCamelCase    :	Optional[Any]   	=		mask_loss_coefficient
              UpperCamelCase    :	Optional[int]   	=		dice_loss_coefficient
              UpperCamelCase    :	Optional[Any]   	=		cls_loss_coefficient
              UpperCamelCase    :	Optional[int]   	=		bbox_loss_coefficient
              UpperCamelCase    :	Optional[int]   	=		giou_loss_coefficient
              UpperCamelCase    :	Optional[int]   	=		focal_alpha
              super().__init__(is_encoder_decoder=__SCREAMING_SNAKE_CASE ,					**__SCREAMING_SNAKE_CASE						)






       @property
       def  _lowercase   (     self						):




              """simple docstring"""




              return self.encoder_attention_heads






       @property
       def  _lowercase   (     self						):




              """simple docstring"""




              return self.d_model






       def  _lowercase   (     self						):




              """simple docstring"""




              UpperCamelCase    :	Union[str, Any]   	=		copy.deepcopy(self.__dict__						)
              if self.backbone_config is not None:
                     UpperCamelCase    :	List[Any]   	=		self.backbone_config.to_dict()
              UpperCamelCase    :	List[Any]   	=		self.__class__.model_type
              return output




class    UpperCAmelCase_	(							_a):
       '''simple docstring'''
       __UpperCamelCase      :     Dict							=					version.parse("1.11")






       @property
       def  _lowercase   (     self						):




              """simple docstring"""




              return OrderedDict(
                  [
                      ('''pixel_values''', {0: '''batch''', 1: '''num_channels''', 2: '''height''', 3: '''width'''}),
                      ('''pixel_mask''', {0: '''batch'''}),
                  ]						)






       @property
       def  _lowercase   (     self						):




              """simple docstring"""




              return 1e-5






       @property
       def  _lowercase   (     self						):




              """simple docstring"""




              return 12

