





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






def 		lowerCAmelCase  (	UpperCamelCase__   :   Any       ,			UpperCamelCase__   :   Any       ,			UpperCamelCase__   :   Optional[int]       ,			UpperCamelCase__   :   Any					)      ->    int:

						"""simple docstring"""





						__SCREAMING_SNAKE_CASE:				str           =   sum(a_i[j] for j in range(A__       ,			len(A__					)					)					)
						__SCREAMING_SNAKE_CASE:				Union[str, Any]           =   sum(a_i[j] * base[j] for j in range(min(len(A__					)       ,			A__					)					)					)

						__SCREAMING_SNAKE_CASE       ,__SCREAMING_SNAKE_CASE:				List[str]           =   0, 0
						__SCREAMING_SNAKE_CASE:				Optional[Any]           =   n - i

						__SCREAMING_SNAKE_CASE:				Optional[int]           =   memo.get(A__					)

						if sub_memo is not None:
												__SCREAMING_SNAKE_CASE:				str           =   sub_memo.get(A__					)

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

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

												else:
																		__SCREAMING_SNAKE_CASE:				Optional[int]           =   []
						else:
												__SCREAMING_SNAKE_CASE:				Dict           =   {c: []}
												__SCREAMING_SNAKE_CASE:				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
																		__SCREAMING_SNAKE_CASE       ,__SCREAMING_SNAKE_CASE:				Any           =   next_term(A__       ,			k - 1       ,			i + dn       ,			A__					)
																		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
												__SCREAMING_SNAKE_CASE       ,__SCREAMING_SNAKE_CASE:				Tuple           =   compute(A__       ,			A__       ,			i + dn       ,			A__					)
												diff += _diff
												dn += terms_jumped

						__SCREAMING_SNAKE_CASE:				Any           =   sub_memo[c]

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

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






def 		lowerCAmelCase  (	UpperCamelCase__   :   Union[str, Any]       ,			UpperCamelCase__   :   Dict       ,			UpperCamelCase__   :   Any       ,			UpperCamelCase__   :   Dict					)      ->    str:

						"""simple docstring"""





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

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

						while i < n:
												i += 1
												__SCREAMING_SNAKE_CASE:				List[str]           =   ds_c + ds_b
												diff += addend
												__SCREAMING_SNAKE_CASE:				Dict           =   0
												for j in range(A__					):
																		__SCREAMING_SNAKE_CASE:				Dict           =   a_i[j] + addend
																		__SCREAMING_SNAKE_CASE       ,__SCREAMING_SNAKE_CASE:				str           =   divmod(A__       ,			10					)

																		ds_c += a_i[j]

												if addend > 0:
																		break

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






def 		lowerCAmelCase  (	UpperCamelCase__   :   Optional[Any]       ,			UpperCamelCase__   :   Tuple       ,			UpperCamelCase__   :   Optional[int]					)      ->    List[str]:

						"""simple docstring"""





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

												if addend == 0:
																		break

						while addend > 0:
												__SCREAMING_SNAKE_CASE       ,__SCREAMING_SNAKE_CASE:				Optional[int]           =   divmod(A__       ,			10					)
												digits.append(A__					)






def 		lowerCAmelCase  (	UpperCamelCase__   :   int = 10**15					)      ->    int:

						"""simple docstring"""





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

						__SCREAMING_SNAKE_CASE:				str           =   0
						for j in range(len(A__					)					):
												a_n += digits[j] * 10**j
						return a_n


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






import flax.linen as nn
import jax
import jax.numpy as jnp





class 					__lowerCAmelCase	(   nn.Module				):
  _a		     =    42
  _a		     =    jnp.floataa




  def     A__	(							self   )    ->					int:
        '''simple docstring'''






        _lowercase      			=nn.Conv(
            self.out_channels				,  kernel_size=(3, 3)				,  strides=(1, 1)				,  padding=((1, 1), (1, 1))				,  dtype=self.dtype				,  )




  def __call__(							self				,  lowerCAmelCase   )    ->					Any:
        '''simple docstring'''






        _lowercase			,			_lowercase			,			_lowercase			,			_lowercase      			=hidden_states.shape
        _lowercase      			=jax.image.resize(
            lowerCAmelCase				,  shape=(batch, height * 2, width * 2, channels)				,  method='nearest'				,  )
        _lowercase      			=self.conv(lowerCAmelCase   )
        return hidden_states





class 					__lowerCAmelCase	(   nn.Module				):
  _a		     =    42
  _a		     =    jnp.floataa




  def     A__	(							self   )    ->					Any:
        '''simple docstring'''






        _lowercase      			=nn.Conv(
            self.out_channels				,  kernel_size=(3, 3)				,  strides=(2, 2)				,  padding=((1, 1), (1, 1))				,  dtype=self.dtype				,  )




  def __call__(							self				,  lowerCAmelCase   )    ->					Optional[int]:
        '''simple docstring'''






        _lowercase      			=self.conv(lowerCAmelCase   )
        return hidden_states





class 					__lowerCAmelCase	(   nn.Module				):
  _a		     =    42
  _a		     =    None
  _a		     =    0.0
  _a		     =    None
  _a		     =    jnp.floataa




  def     A__	(							self   )    ->					Optional[int]:
        '''simple docstring'''






        _lowercase      			=self.in_channels if self.out_channels is None else self.out_channels

        _lowercase      			=nn.GroupNorm(num_groups=32				,  epsilon=1e-5   )
        _lowercase      			=nn.Conv(
            lowerCAmelCase				,  kernel_size=(3, 3)				,  strides=(1, 1)				,  padding=((1, 1), (1, 1))				,  dtype=self.dtype				,  )

        _lowercase      			=nn.Dense(lowerCAmelCase				,  dtype=self.dtype   )

        _lowercase      			=nn.GroupNorm(num_groups=32				,  epsilon=1e-5   )
        _lowercase      			=nn.Dropout(self.dropout_prob   )
        _lowercase      			=nn.Conv(
            lowerCAmelCase				,  kernel_size=(3, 3)				,  strides=(1, 1)				,  padding=((1, 1), (1, 1))				,  dtype=self.dtype				,  )

        _lowercase      			=self.in_channels != out_channels if self.use_nin_shortcut is None else self.use_nin_shortcut

        _lowercase      			=None
        if use_nin_shortcut:
              _lowercase      			=nn.Conv(
                  lowerCAmelCase				,  kernel_size=(1, 1)				,  strides=(1, 1)				,  padding='VALID'				,  dtype=self.dtype				,  )




  def __call__(							self				,  lowerCAmelCase				,  lowerCAmelCase				,  lowerCAmelCase=True   )    ->					Tuple:
        '''simple docstring'''






        _lowercase      			=hidden_states
        _lowercase      			=self.norma(lowerCAmelCase   )
        _lowercase      			=nn.swish(lowerCAmelCase   )
        _lowercase      			=self.conva(lowerCAmelCase   )

        _lowercase      			=self.time_emb_proj(nn.swish(lowerCAmelCase   )   )
        _lowercase      			=jnp.expand_dims(jnp.expand_dims(lowerCAmelCase				,  1   )				,  1   )
        _lowercase      			=hidden_states + temb

        _lowercase      			=self.norma(lowerCAmelCase   )
        _lowercase      			=nn.swish(lowerCAmelCase   )
        _lowercase      			=self.dropout(lowerCAmelCase				,  lowerCAmelCase   )
        _lowercase      			=self.conva(lowerCAmelCase   )

        if self.conv_shortcut is not None:
              _lowercase      			=self.conv_shortcut(lowerCAmelCase   )

        return hidden_states + residual


