

lowerCAmelCase__						 =			range(2, 2_0 + 1)
lowerCAmelCase__						 =			[1_0**k for k in range(ks[-1] + 1)]
lowerCAmelCase__						 =			{}



def        lowerCAmelCase__				(						SCREAMING_SNAKE_CASE_:				Any						,							SCREAMING_SNAKE_CASE_:				List[str]						,							SCREAMING_SNAKE_CASE_:				int						,							SCREAMING_SNAKE_CASE_:				Optional[Any]   )      ->   str:




				'''simple docstring'''





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

				A__          =      0, 0
				A__          =      n - i

				A__          =      memo.get(SCREAMING_SNAKE_CASE_   )

				if sub_memo is not None:
								A__          =      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
												A__          =      -1
												for _k in range(len(SCREAMING_SNAKE_CASE_   ) - 1						,							-1						,							-1   ):
																if jumps[_k][2] <= k and jumps[_k][1] <= max_dn:
																				A__          =      _k
																				break

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

								else:
												A__          =      []
				else:
								A__          =      {c: []}
								A__          =      sub_memo

				if dn >= max_dn or c + diff >= base[k]:
								return diff, dn

				if k > ks[0]:
								while True:
												# keep doing smaller jumps
												A__          =      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
								A__          =      compute(SCREAMING_SNAKE_CASE_						,							SCREAMING_SNAKE_CASE_						,							i + dn						,							SCREAMING_SNAKE_CASE_   )
								diff += _diff
								dn += terms_jumped

				A__          =      sub_memo[c]

				# keep jumps sorted by # of terms skipped
				A__          =      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        lowerCAmelCase__				(						SCREAMING_SNAKE_CASE_:				Optional[Any]						,							SCREAMING_SNAKE_CASE_:				Optional[Any]						,							SCREAMING_SNAKE_CASE_:				Dict						,							SCREAMING_SNAKE_CASE_:				Optional[int]   )      ->   Optional[int]:




				'''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)
				A__          =      i
				A__          =      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
								A__          =      ds_c + ds_b
								diff += addend
								A__          =      0
								for j in range(SCREAMING_SNAKE_CASE_   ):
												A__          =      a_i[j] + addend
												A__          =      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        lowerCAmelCase__				(						SCREAMING_SNAKE_CASE_:				Dict						,							SCREAMING_SNAKE_CASE_:				Union[str, Any]						,							SCREAMING_SNAKE_CASE_:				Tuple   )      ->   Union[str, Any]:




				'''simple docstring'''





				for j in range(SCREAMING_SNAKE_CASE_						,							len(SCREAMING_SNAKE_CASE_   )   ):
								A__          =      digits[j] + addend
								if s >= 1_0:
												A__          =      divmod(SCREAMING_SNAKE_CASE_						,							1_0   )
												A__          =      addend // 1_0 + quotient
								else:
												A__          =      s
												A__          =      addend // 1_0

								if addend == 0:
												break

				while addend > 0:
								A__          =      divmod(SCREAMING_SNAKE_CASE_						,							1_0   )
								digits.append(SCREAMING_SNAKE_CASE_   )



def        lowerCAmelCase__				(						SCREAMING_SNAKE_CASE_:				Optional[int] = 1_0**1_5   )      ->   Optional[Any]:




				'''simple docstring'''





				A__          =      [1]
				A__          =      1
				A__          =      0
				while True:
								A__          =      next_term(SCREAMING_SNAKE_CASE_						,							2_0						,							i + dn						,							SCREAMING_SNAKE_CASE_   )
								dn += terms_jumped
								if dn == n - i:
												break

				A__          =      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 math

import tensorflow as tf
from packaging import version




def 		lowerCAmelCase_ (						lowerCamelCase ):
				__magic_name__						:						str										=tf.convert_to_tensor(lowerCamelCase )
				__magic_name__						:						List[str]										=0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0 )						,  x.dtype ) ))

				return x * cdf




def 		lowerCAmelCase_ (						lowerCamelCase ):
				__magic_name__						:						str										=tf.convert_to_tensor(lowerCamelCase )
				__magic_name__						:						Optional[Any]										=tf.cast(math.pi						,  x.dtype )
				__magic_name__						:						int										=tf.cast(0.0_4_4_7_1_5						,  x.dtype )
				__magic_name__						:						Tuple										=0.5 * (1.0 + tf.tanh(tf.sqrt(2.0 / pi ) * (x + coeff * tf.pow(lowerCamelCase						,  3 )) ))

				return x * cdf




def 		lowerCAmelCase_ (						lowerCamelCase ):
				__magic_name__						:						Any										=tf.convert_to_tensor(lowerCamelCase )

				return x * tf.tanh(tf.math.softplus(lowerCamelCase ) )




def 		lowerCAmelCase_ (						lowerCamelCase ):
				__magic_name__						:						Optional[Any]										=tf.convert_to_tensor(lowerCamelCase )
				__magic_name__						:						Union[str, Any]										=tf.cast(0.0_4_4_7_1_5						,  x.dtype )
				__magic_name__						:						Tuple										=tf.cast(0.7_9_7_8_8_4_5_6_0_8						,  x.dtype )

				return 0.5 * x * (1.0 + tf.tanh(x * coeffa * (1.0 + coeffa * x * x) ))




def 		lowerCAmelCase_ (						lowerCamelCase ):
				__magic_name__						:						List[str]										=tf.convert_to_tensor(lowerCamelCase )
				__magic_name__						:						Dict										=tf.cast(1.7_0_2						,  x.dtype )
				return x * tf.math.sigmoid(coeff * x )




def 		lowerCAmelCase_ (						lowerCamelCase ):
				return tf.clip_by_value(_gelu(lowerCamelCase )						,  -10						,  10 )




def 		lowerCAmelCase_ (						lowerCamelCase						,  lowerCamelCase=-1 ):
				__magic_name__					,			__magic_name__						:						List[Any]										=tf.split(lowerCamelCase						,  2						,  axis=lowerCamelCase )
				return a * tf.math.sigmoid(lowerCamelCase )


if version.parse(tf.version.VERSION) >= version.parse("2.4"):




							def 		lowerCAmelCase_ (						lowerCamelCase ):
											return tf.keras.activations.gelu(lowerCamelCase						,  approximate=lowerCamelCase )

							UpperCAmelCase_		:					List[str]          =  tf.keras.activations.gelu



							UpperCAmelCase_		:					Dict          =  approximate_gelu_wrap
else:
							UpperCAmelCase_		:					Dict          =  _gelu
							UpperCAmelCase_		:					str          =  _gelu_new


UpperCAmelCase_		:					Any          =  {
    "gelu": gelu,
    "gelu_10": gelu_aa,
    "gelu_fast": gelu_fast,
    "gelu_new": gelu_new,
    "glu": glu,
    "mish": mish,
    "quick_gelu": quick_gelu,
    "relu": tf.keras.activations.relu,
    "sigmoid": tf.keras.activations.sigmoid,
    "silu": tf.keras.activations.swish,
    "swish": tf.keras.activations.swish,
    "tanh": tf.keras.activations.tanh,
}




def 		lowerCAmelCase_ (						lowerCamelCase ):
				if activation_string in ACTaFN:
								return ACTaFN[activation_string]
				else:
								raise KeyError(F"function {activation_string} not found in ACT2FN mapping {list(ACTaFN.keys() )}" )




