






'''simple docstring'''





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



def        __snake_case						(__UpperCAmelCase       ,	__UpperCAmelCase       ,	__UpperCAmelCase       ,	__UpperCAmelCase    ):





	"""simple docstring"""
	lowerCamelCase_					:  Union[str, Any]						=    sum(a_i[j] for j in range(SCREAMING_SNAKE_CASE__       ,	len(SCREAMING_SNAKE_CASE__    )    )    )
	lowerCamelCase_					:  List[str]						=    sum(a_i[j] * base[j] for j in range(min(len(SCREAMING_SNAKE_CASE__    )       ,	SCREAMING_SNAKE_CASE__    )    )    )

	lowerCamelCase_					:  int						=    0, 0
	lowerCamelCase_					:  Optional[Any]						=    n - i

	lowerCamelCase_					:  List[Any]						=    memo.get(SCREAMING_SNAKE_CASE__    )

	if sub_memo is not None:
		lowerCamelCase_					:  Union[str, Any]						=    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
			lowerCamelCase_					:  int						=    -1
			for _k in range(len(SCREAMING_SNAKE_CASE__    ) - 1       ,	-1       ,	-1    ):
				if jumps[_k][2] <= k and jumps[_k][1] <= max_dn:
					lowerCamelCase_					:  Optional[Any]						=    _k
					break

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

		else:
			lowerCamelCase_					:  int						=    []
	else:
		lowerCamelCase_					:  Dict						=    {c: []}
		lowerCamelCase_					:  Dict						=    sub_memo

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

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

	lowerCamelCase_					:  Any						=    sub_memo[c]

	# keep jumps sorted by # of terms skipped
	lowerCamelCase_					:  Optional[int]						=    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        __snake_case						(__UpperCAmelCase       ,	__UpperCAmelCase       ,	__UpperCAmelCase       ,	__UpperCAmelCase    ):





	"""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)
	lowerCamelCase_					:  Optional[int]						=    i
	lowerCamelCase_					:  Optional[int]						=    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
		lowerCamelCase_					:  str						=    ds_c + ds_b
		diff += addend
		lowerCamelCase_					:  Optional[int]						=    0
		for j in range(SCREAMING_SNAKE_CASE__    ):
			lowerCamelCase_					:  Any						=    a_i[j] + addend
			lowerCamelCase_					:  Dict						=    divmod(SCREAMING_SNAKE_CASE__       ,	10    )

			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        __snake_case						(__UpperCAmelCase       ,	__UpperCAmelCase       ,	__UpperCAmelCase    ):





	"""simple docstring"""


	for j in range(SCREAMING_SNAKE_CASE__       ,	len(SCREAMING_SNAKE_CASE__    )    ):
		lowerCamelCase_					:  Union[str, Any]						=    digits[j] + addend
		if s >= 10:
			lowerCamelCase_					:  List[Any]						=    divmod(SCREAMING_SNAKE_CASE__       ,	10    )
			lowerCamelCase_					:  List[str]						=    addend // 10 + quotient
		else:
			lowerCamelCase_					:  List[str]						=    s
			lowerCamelCase_					:  List[str]						=    addend // 10

		if addend == 0:
			break

	while addend > 0:
		lowerCamelCase_					:  Dict						=    divmod(SCREAMING_SNAKE_CASE__       ,	10    )
		digits.append(SCREAMING_SNAKE_CASE__    )



def        __snake_case						(__UpperCAmelCase = 10**15    ):





	"""simple docstring"""
	lowerCamelCase_					:  Optional[Any]						=    [1]
	lowerCamelCase_					:  str						=    1
	lowerCamelCase_					:  Union[str, Any]						=    0
	while True:
		lowerCamelCase_					:  Any						=    next_term(SCREAMING_SNAKE_CASE__       ,	20       ,	i + dn       ,	SCREAMING_SNAKE_CASE__    )
		dn += terms_jumped
		if dn == n - i:
			break

	lowerCamelCase_					:  Dict						=    0
	for j in range(len(SCREAMING_SNAKE_CASE__    )    ):
		a_n += digits[j] * 10**j
	return a_n


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








'''simple docstring'''
import enum
import os
from hashlib import shaaaa
from typing import Optional

from .. import config
from .logging import get_logger


lowercase__						       =      get_logger(__name__)






class 	snake_case__       (      enum.Enum					):







		"""simple docstring"""

		lowerCamelCase     							=						"""all_checks"""
		lowerCamelCase     							=						"""basic_checks"""
		lowerCamelCase     							=						"""no_checks"""







class 	snake_case__       (      __SCREAMING_SNAKE_CASE					):







		"""simple docstring"""








class 	snake_case__       (      __SCREAMING_SNAKE_CASE					):







		"""simple docstring"""








class 	snake_case__       (      __SCREAMING_SNAKE_CASE					):







		"""simple docstring"""








class 	snake_case__       (      __SCREAMING_SNAKE_CASE					):







		"""simple docstring"""








def    _UpperCamelCase						(       SCREAMING_SNAKE_CASE__ ,       SCREAMING_SNAKE_CASE__ ,       SCREAMING_SNAKE_CASE__=None			)  ->							str:


		'''simple docstring'''


		if expected_checksums is None:
				logger.info('''Unable to verify checksums.'''			)
				return
		if len(set(SCREAMING_SNAKE_CASE__			) - set(SCREAMING_SNAKE_CASE__			)			) > 0:
				raise ExpectedMoreDownloadedFiles(str(set(SCREAMING_SNAKE_CASE__			) - set(SCREAMING_SNAKE_CASE__			)			)			)
		if len(set(SCREAMING_SNAKE_CASE__			) - set(SCREAMING_SNAKE_CASE__			)			) > 0:
				raise UnexpectedDownloadedFile(str(set(SCREAMING_SNAKE_CASE__			) - set(SCREAMING_SNAKE_CASE__			)			)			)
		snake_case  :       Any     			=						[url for url in expected_checksums if expected_checksums[url] != recorded_checksums[url]]
		snake_case  :       Union[str, Any]     			=						''' for ''' + verification_name if verification_name is not None else ''''''
		if len(SCREAMING_SNAKE_CASE__			) > 0:
				raise NonMatchingChecksumError(
				    F'Checksums didn\'t match{for_verification_name}:\n'
				    F'{bad_urls}\n'
				    '''Set `verification_mode=\'no_checks\'` to skip checksums verification and ignore this error'''			)
		logger.info('''All the checksums matched successfully''' + for_verification_name			)






class 	snake_case__       (      __SCREAMING_SNAKE_CASE					):







		"""simple docstring"""








class 	snake_case__       (      __SCREAMING_SNAKE_CASE					):







		"""simple docstring"""








class 	snake_case__       (      __SCREAMING_SNAKE_CASE					):







		"""simple docstring"""








class 	snake_case__       (      __SCREAMING_SNAKE_CASE					):







		"""simple docstring"""








def    _UpperCamelCase						(       SCREAMING_SNAKE_CASE__ ,       SCREAMING_SNAKE_CASE__			)  ->							List[str]:


		'''simple docstring'''


		if expected_splits is None:
				logger.info('''Unable to verify splits sizes.'''			)
				return
		if len(set(SCREAMING_SNAKE_CASE__			) - set(SCREAMING_SNAKE_CASE__			)			) > 0:
				raise ExpectedMoreSplits(str(set(SCREAMING_SNAKE_CASE__			) - set(SCREAMING_SNAKE_CASE__			)			)			)
		if len(set(SCREAMING_SNAKE_CASE__			) - set(SCREAMING_SNAKE_CASE__			)			) > 0:
				raise UnexpectedSplits(str(set(SCREAMING_SNAKE_CASE__			) - set(SCREAMING_SNAKE_CASE__			)			)			)
		snake_case  :       Dict     			=						[
		    {'''expected''': expected_splits[name], '''recorded''': recorded_splits[name]}
		    for name in expected_splits
		    if expected_splits[name].num_examples != recorded_splits[name].num_examples
		]
		if len(SCREAMING_SNAKE_CASE__			) > 0:
				raise NonMatchingSplitsSizesError(str(SCREAMING_SNAKE_CASE__			)			)
		logger.info('''All the splits matched successfully.'''			)




def    _UpperCamelCase						(       SCREAMING_SNAKE_CASE__ ,       SCREAMING_SNAKE_CASE__ = True			)  ->							dict:


		'''simple docstring'''


		if record_checksum:
				snake_case  :       Any     			=						shaaaa()
				with open(SCREAMING_SNAKE_CASE__ ,       '''rb'''			) as f:
						for chunk in iter(lambda: f.read(1 << 20			) ,       B''''''			):
								m.update(SCREAMING_SNAKE_CASE__			)
						snake_case  :       Any     			=						m.hexdigest()
		else:
				snake_case  :       Tuple     			=						None
		return {"num_bytes": os.path.getsize(SCREAMING_SNAKE_CASE__			), "checksum": checksum}




def    _UpperCamelCase						(       SCREAMING_SNAKE_CASE__			)  ->							Dict:


		'''simple docstring'''


		if dataset_size and config.IN_MEMORY_MAX_SIZE:
				return dataset_size < config.IN_MEMORY_MAX_SIZE
		else:
				return False


