





'''simple docstring'''






lowerCAmelCase									=   range(2, 20 + 1)
lowerCAmelCase									=   [10**k for k in range(ks[-1] + 1)]
lowerCAmelCase									=   {}






def   __A    (				a_    :	Union[str, Any]   ,a_    :	Dict   ,a_    :	Tuple   ,a_    :	Optional[int]						):
		lowerCAmelCase  :     Optional[int]       						= sum(a_i[j] for j in range(a_   ,len(a_						)						)						)
		lowerCAmelCase  :     List[str]       						= sum(a_i[j] * base[j] for j in range(min(len(a_						)   ,a_						)						)						)

		lowerCAmelCase						,		lowerCAmelCase  :     str       						= 0, 0
		lowerCAmelCase  :     Any       						= n - i

		lowerCAmelCase  :     List[str]       						= memo.get(a_						)

		if sub_memo is not None:
				lowerCAmelCase  :     Optional[Any]       						= sub_memo.get(a_						)

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

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

				else:
						lowerCAmelCase  :     Optional[int]       						= []
		else:
				lowerCAmelCase  :     Any       						= {c: []}
				lowerCAmelCase  :     Union[str, Any]       						= 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						,		lowerCAmelCase  :     Optional[int]       						= 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						,		lowerCAmelCase  :     Any       						= compute(a_   ,a_   ,i + dn   ,a_						)
				diff += _diff
				dn += terms_jumped

		lowerCAmelCase  :     Union[str, Any]       						= sub_memo[c]

		# keep jumps sorted by # of terms skipped
		lowerCAmelCase  :     str       						= 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   __A    (				a_    :	int   ,a_    :	List[str]   ,a_    :	Union[str, Any]   ,a_    :	Optional[Any]						):
		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  :     Optional[int]       						= i
		lowerCAmelCase						,		lowerCAmelCase						,		lowerCAmelCase  :     int       						= 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  :     Any       						= ds_c + ds_b
				diff += addend
				lowerCAmelCase  :     str       						= 0
				for j in range(a_						):
						lowerCAmelCase  :     Optional[int]       						= a_i[j] + addend
						lowerCAmelCase						,		lowerCAmelCase  :     Any       						= divmod(a_   ,1_0						)

						ds_c += a_i[j]

				if addend > 0:
						break

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






def   __A    (				a_    :	Dict   ,a_    :	Union[str, Any]   ,a_    :	Tuple						):
		for j in range(a_   ,len(a_						)						):
				lowerCAmelCase  :     int       						= digits[j] + addend
				if s >= 1_0:
						lowerCAmelCase						,		lowerCAmelCase  :     Any       						= divmod(a_   ,1_0						)
						lowerCAmelCase  :     Any       						= addend // 1_0 + quotient
				else:
						lowerCAmelCase  :     List[Any]       						= s
						lowerCAmelCase  :     Union[str, Any]       						= addend // 1_0

				if addend == 0:
						break

		while addend > 0:
				lowerCAmelCase						,		lowerCAmelCase  :     List[str]       						= divmod(a_   ,1_0						)
				digits.append(a_						)






def   __A    (				a_    :	int = 1_0**1_5						):
		lowerCAmelCase  :     str       						= [1]
		lowerCAmelCase  :     Optional[Any]       						= 1
		lowerCAmelCase  :     Optional[int]       						= 0
		while True:
				lowerCAmelCase						,		lowerCAmelCase  :     str       						= next_term(a_   ,2_0   ,i + dn   ,a_						)
				dn += terms_jumped
				if dn == n - i:
						break

		lowerCAmelCase  :     Dict       						= 0
		for j in range(len(a_						)						):
				a_n += digits[j] * 1_0**j
		return a_n


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










'''simple docstring'''






from __future__ import annotations






def   __A    (				a_    :	float   ,a_    :	float   ,a_    :	float   ,):
		if (electron_conc, hole_conc, intrinsic_conc).count(0						) != 1:
				raise ValueError("You cannot supply more or less than 2 values"						)
		elif electron_conc < 0:
				raise ValueError("Electron concentration cannot be negative in a semiconductor"						)
		elif hole_conc < 0:
				raise ValueError("Hole concentration cannot be negative in a semiconductor"						)
		elif intrinsic_conc < 0:
				raise ValueError(
				    "Intrinsic concentration cannot be negative in a semiconductor"						)
		elif electron_conc == 0:
				return (
				    "electron_conc",
				    intrinsic_conc**2 / hole_conc,
				)
		elif hole_conc == 0:
				return (
				    "hole_conc",
				    intrinsic_conc**2 / electron_conc,
				)
		elif intrinsic_conc == 0:
				return (
				    "intrinsic_conc",
				    (electron_conc * hole_conc) ** 0.5,
				)
		else:
				return (-1, -1)


if __name__ == "__main__":
					import doctest

					doctest.testmod()



