






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





def 	lowerCAmelCase_		(lowercase__						:       Tuple     ,					lowercase__						:       Optional[int]     ,					lowercase__						:       List[str]     ,					lowercase__						:       Optional[int]       )		->    Optional[int]:


				'''simple docstring'''




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

				lowerCAmelCase__      			=						0, 0
				lowerCAmelCase__      			=						n - i

				lowerCAmelCase__      			=						memo.get(a_       )

				if sub_memo is not None:
								lowerCAmelCase__      			=						sub_memo.get(a_       )

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

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

								else:
												lowerCAmelCase__      			=						[]
				else:
								lowerCAmelCase__      			=						{c: []}
								lowerCAmelCase__      			=						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__      			=						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
								lowerCAmelCase__      			=						compute(a_     ,					a_     ,					i + dn     ,					a_       )
								diff += _diff
								dn += terms_jumped

				lowerCAmelCase__      			=						sub_memo[c]

				# keep jumps sorted by # of terms skipped
				lowerCAmelCase__      			=						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_		(lowercase__						:       List[str]     ,					lowercase__						:       Optional[Any]     ,					lowercase__						:       Dict     ,					lowercase__						:       str       )		->    Any:


				'''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)
				lowerCAmelCase__      			=						i
				lowerCAmelCase__      			=						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
								lowerCAmelCase__      			=						ds_c + ds_b
								diff += addend
								lowerCAmelCase__      			=						0
								for j in range(a_       ):
												lowerCAmelCase__      			=						a_i[j] + addend
												lowerCAmelCase__      			=						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_		(lowercase__						:       Tuple     ,					lowercase__						:       Optional[int]     ,					lowercase__						:       Dict       )		->    List[str]:


				'''simple docstring'''




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

								if addend == 0:
												break

				while addend > 0:
								lowerCAmelCase__      			=						divmod(a_     ,					10       )
								digits.append(a_       )





def 	lowerCAmelCase_		(lowercase__						:       int = 10**15       )		->    int:


				'''simple docstring'''




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

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


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













from typing import Optional

import pyspark

from .. import Features, NamedSplit
from ..download import DownloadMode
from ..packaged_modules.spark.spark import Spark
from .abc import AbstractDatasetReader
class  lowerCAmelCase_       (				snake_case__					):




							def __init__(   self     :   str ,							SCREAMING_SNAKE_CASE_     :   pyspark.sql.DataFrame ,							SCREAMING_SNAKE_CASE_     :   Optional[NamedSplit] = None ,							SCREAMING_SNAKE_CASE_     :   Optional[Features] = None ,							SCREAMING_SNAKE_CASE_     :   bool = True ,							SCREAMING_SNAKE_CASE_     :   str = None ,							SCREAMING_SNAKE_CASE_     :   bool = False ,							SCREAMING_SNAKE_CASE_     :   str = None ,							SCREAMING_SNAKE_CASE_     :   bool = True ,							SCREAMING_SNAKE_CASE_     :   str = "arrow" ,							**SCREAMING_SNAKE_CASE_     :   Optional[Any] ,							):
											super().__init__(
											    split=SCREAMING_SNAKE_CASE_ ,							features=SCREAMING_SNAKE_CASE_ ,							cache_dir=SCREAMING_SNAKE_CASE_ ,							keep_in_memory=SCREAMING_SNAKE_CASE_ ,							streaming=SCREAMING_SNAKE_CASE_ ,							**SCREAMING_SNAKE_CASE_ ,							)
											lowerCAmelCase__      			=						load_from_cache_file
											lowerCAmelCase__      			=						file_format
											lowerCAmelCase__      			=						Spark(
											    df=SCREAMING_SNAKE_CASE_ ,							features=SCREAMING_SNAKE_CASE_ ,							cache_dir=SCREAMING_SNAKE_CASE_ ,							working_dir=SCREAMING_SNAKE_CASE_ ,							**SCREAMING_SNAKE_CASE_ ,							)




							def 						__snake_case					(   self     :   List[str]	):
											if self.streaming:
															return self.builder.as_streaming_dataset(split=self.split	)
											lowerCAmelCase__      			=						None if self._load_from_cache_file else DownloadMode.FORCE_REDOWNLOAD
											self.builder.download_and_prepare(
											    download_mode=SCREAMING_SNAKE_CASE_ ,							file_format=self._file_format ,							)
											return self.builder.as_dataset(split=self.split	)





