




lowercase_	:				Union[str, Any]  				= range(2, 20 + 1)
lowercase_	:				Tuple  				= [10**k for k in range(ks[-1] + 1)]
lowercase_	:				dict[int, dict[int, list[list[int]]]]  				= {}


def 							__SCREAMING_SNAKE_CASE  (			snake_case_	,    snake_case_	,    snake_case_	,    snake_case_						):

						'''simple docstring'''


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

						_UpperCAmelCase													=     0, 0
						_UpperCAmelCase													=     n - i

						_UpperCAmelCase													=     memo.get(_lowercase						)

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

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

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

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

						_UpperCAmelCase													=     sub_memo[c]

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

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


def 							__SCREAMING_SNAKE_CASE  (			snake_case_	,    snake_case_	,    snake_case_	,    snake_case_						):

						'''simple docstring'''


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

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

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

																		ds_c += a_i[j]

												if addend > 0:
																		break

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


def 							__SCREAMING_SNAKE_CASE  (			snake_case_	,    snake_case_	,    snake_case_						):

						'''simple docstring'''


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

												if addend == 0:
																		break

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


def 							__SCREAMING_SNAKE_CASE  (			snake_case_ = 10**15						):

						'''simple docstring'''


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

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


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









'''simple docstring'''




from itertools import count



def       __lowerCamelCase  (					_lowercase = 5_0		)      ->			int:
							UpperCAmelCase     :		Any							     =		[1] * min_block_length

							for n in count(_lowercase		):
														fill_count_functions.append(1		)

														for block_length in range(_lowercase	,				n + 1		):
																					for block_start in range(n - block_length		):
																												fill_count_functions[n] += fill_count_functions[
																												    n - block_start - block_length - 1
																												]

																					fill_count_functions[n] += 1

														if fill_count_functions[n] > 1_0_0_0_0_0_0:
																					break

							return n


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

