



"""simple docstring"""







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

def   lowerCAmelCase__			(     lowerCamelCase__				,      lowerCamelCase__				,      lowerCamelCase__				,      lowerCamelCase__			) ->							Optional[Any]:
							A         =					sum(a_i[j] for j in range(lowerCamelCase__				,      len(lowerCamelCase__			)			)			)
							A         =					sum(a_i[j] * base[j] for j in range(min(len(lowerCamelCase__			)				,      lowerCamelCase__			)			)			)

							A      ,  A         =					0, 0
							A         =					n - i

							A         =					memo.get(lowerCamelCase__			)

							if sub_memo is not None:
														A         =					sub_memo.get(lowerCamelCase__			)

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

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

														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      ,  A         =					next_term(lowerCamelCase__				,      k - 1				,      i + dn				,      lowerCamelCase__			)
																					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      ,  A         =					compute(lowerCamelCase__				,      lowerCamelCase__				,      i + dn				,      lowerCamelCase__			)
														diff += _diff
														dn += terms_jumped

							A         =					sub_memo[c]

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

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

def   lowerCAmelCase__			(     lowerCamelCase__				,      lowerCamelCase__				,      lowerCamelCase__				,      lowerCamelCase__			) ->							List[str]:
							if i >= n:
														return 0, i
							if k > len(lowerCamelCase__			):
														a_i.extend([0 for _ in range(k - len(lowerCamelCase__			)			)]			)

							# note: a_i -> b * 10^k + c
							# ds_b -> digitsum(b)
							# ds_c -> digitsum(c)
							A         =					i
							A      ,  A      ,  A         =					0, 0, 0
							for j in range(len(lowerCamelCase__			)			):
														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(lowerCamelCase__			):
																					A         =					a_i[j] + addend
																					A      ,  A         =					divmod(lowerCamelCase__				,      10			)

																					ds_c += a_i[j]

														if addend > 0:
																					break

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

def   lowerCAmelCase__			(     lowerCamelCase__				,      lowerCamelCase__				,      lowerCamelCase__			) ->							int:
							for j in range(lowerCamelCase__				,      len(lowerCamelCase__			)			):
														A         =					digits[j] + addend
														if s >= 10:
																					A      ,  A         =					divmod(lowerCamelCase__				,      10			)
																					A         =					addend // 10 + quotient
														else:
																					A         =					s
																					A         =					addend // 10

														if addend == 0:
																					break

							while addend > 0:
														A      ,  A         =					divmod(lowerCamelCase__				,      10			)
														digits.append(lowerCamelCase__			)

def   lowerCAmelCase__			(     lowerCamelCase__ = 10**15			) ->							int:
							A         =					[1]
							A         =					1
							A         =					0
							while True:
														A      ,  A         =					next_term(lowerCamelCase__				,      20				,      i + dn				,      lowerCamelCase__			)
														dn += terms_jumped
														if dn == n - i:
																					break

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


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








"""simple docstring"""







from __future__ import annotations

import sys
from collections import deque
from typing import Generic, TypeVar

A    =			TypeVar('T')






class      UpperCAmelCase__		(      Generic[T]     ):
		lowerCAmelCase_       :	deque[T]  # Cache store of keys
		lowerCAmelCase_       :	set[T]  # References of the keys in cache
		lowerCAmelCase_       :	int 							=     10  # Maximum capacity of cache



		def __init__( self  :    int      ,							snake_case  :    int				)			->						None:






									'''simple docstring'''

									A         =					deque()
									A         =					set()
									if not n:
																A         =					sys.maxsize
									elif n < 0:
																raise ValueError('n should be an integer greater than 0.'				)
									else:
																A         =					n



		def 					A_		( self  :    Optional[Any]      ,							snake_case  :    T				)			->						None:






									'''simple docstring'''

									if x not in self.key_reference:
																if len(self.dq_store				) == LRUCache._MAX_CAPACITY:
																							A         =					self.dq_store.pop()
																							self.key_reference.remove(snake_case				)
									else:
																self.dq_store.remove(snake_case				)

									self.dq_store.appendleft(snake_case				)
									self.key_reference.add(snake_case				)



		def 					A_		( self  :    Dict				)			->						None:






									'''simple docstring'''

									for k in self.dq_store:
																print(snake_case				)



		def __repr__( self  :    int				)			->						str:






									'''simple docstring'''

									return f"""LRUCache({self._MAX_CAPACITY}) => {list(self.dq_store				)}"""


if __name__ == "__main__":
							import doctest

							doctest.testmod()

							A    =			LRUCache(4)
							lru_cache.refer('A')
							lru_cache.refer(2)
							lru_cache.refer(3)
							lru_cache.refer('A')
							lru_cache.refer(4)
							lru_cache.refer(5)
							lru_cache.display()

							print(lru_cache)
							assert str(lru_cache) == "LRUCache(4) => [5, 4, 'A', 3]"



