





'''simple docstring'''




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



def 						__A						(   lowerCamelCase_       ,       lowerCamelCase_       ,       lowerCamelCase_       ,       lowerCamelCase_     ):


		"""simple docstring"""



		SCREAMING_SNAKE_CASE      :							Tuple						=       sum(a_i[j] for j in range(__snake_case       ,       len(__snake_case     )     )     )
		SCREAMING_SNAKE_CASE      :							str						=       sum(a_i[j] * base[j] for j in range(min(len(__snake_case     )       ,       __snake_case     )     )     )

		SCREAMING_SNAKE_CASE      :							Optional[int]						=       0, 0
		SCREAMING_SNAKE_CASE      :							Union[str, Any]						=       n - i

		SCREAMING_SNAKE_CASE      :							List[Any]						=       memo.get(__snake_case     )

		if sub_memo is not None:
				SCREAMING_SNAKE_CASE      :							Optional[Any]						=       sub_memo.get(__snake_case     )

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

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

				else:
						SCREAMING_SNAKE_CASE      :							List[Any]						=       []
		else:
				SCREAMING_SNAKE_CASE      :							str						=       {c: []}
				SCREAMING_SNAKE_CASE      :							Tuple						=       sub_memo

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

		if k > ks[0]:
				while True:
						# keep doing smaller jumps
						SCREAMING_SNAKE_CASE      :							int						=       next_term(__snake_case       ,       k - 1       ,       i + dn       ,       __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
				SCREAMING_SNAKE_CASE      :							Dict						=       compute(__snake_case       ,       __snake_case       ,       i + dn       ,       __snake_case     )
				diff += _diff
				dn += terms_jumped

		SCREAMING_SNAKE_CASE      :							int						=       sub_memo[c]

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

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



def 						__A						(   lowerCamelCase_       ,       lowerCamelCase_       ,       lowerCamelCase_       ,       lowerCamelCase_     ):


		"""simple docstring"""



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

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

		while i < n:
				i += 1
				SCREAMING_SNAKE_CASE      :							Tuple						=       ds_c + ds_b
				diff += addend
				SCREAMING_SNAKE_CASE      :							Optional[int]						=       0
				for j in range(__snake_case     ):
						SCREAMING_SNAKE_CASE      :							List[str]						=       a_i[j] + addend
						SCREAMING_SNAKE_CASE      :							Union[str, Any]						=       divmod(__snake_case       ,       10     )

						ds_c += a_i[j]

				if addend > 0:
						break

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



def 						__A						(   lowerCamelCase_       ,       lowerCamelCase_       ,       lowerCamelCase_     ):


		"""simple docstring"""



		for j in range(__snake_case       ,       len(__snake_case     )     ):
				SCREAMING_SNAKE_CASE      :							Tuple						=       digits[j] + addend
				if s >= 10:
						SCREAMING_SNAKE_CASE      :							Tuple						=       divmod(__snake_case       ,       10     )
						SCREAMING_SNAKE_CASE      :							Optional[int]						=       addend // 10 + quotient
				else:
						SCREAMING_SNAKE_CASE      :							Tuple						=       s
						SCREAMING_SNAKE_CASE      :							Optional[int]						=       addend // 10

				if addend == 0:
						break

		while addend > 0:
				SCREAMING_SNAKE_CASE      :							List[str]						=       divmod(__snake_case       ,       10     )
				digits.append(__snake_case     )



def 						__A						(   lowerCamelCase_ = 10**15     ):


		"""simple docstring"""



		SCREAMING_SNAKE_CASE      :							List[Any]						=       [1]
		SCREAMING_SNAKE_CASE      :							int						=       1
		SCREAMING_SNAKE_CASE      :							Union[str, Any]						=       0
		while True:
				SCREAMING_SNAKE_CASE      :							int						=       next_term(__snake_case       ,       20       ,       i + dn       ,       __snake_case     )
				dn += terms_jumped
				if dn == n - i:
						break

		SCREAMING_SNAKE_CASE      :							List[Any]						=       0
		for j in range(len(__snake_case     )     ):
				a_n += digits[j] * 10**j
		return a_n


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





"""simple docstring"""




import os
import zipfile

import requests
from get_ci_error_statistics import download_artifact, get_artifacts_links


def   __magic_name__	(      __snake_case				:       Union[str, Any]     , __snake_case				:       List[str]=7  ) ->				str:
       lowercase    :				int       		=							None
       if token is not None:
              lowercase    :				Any       		=							{"Accept": "application/vnd.github+json", "Authorization": f"""Bearer {token}"""}

       # The id of a workflow (not of a workflow run)
       lowercase    :				int       		=							"636036"

       lowercase    :				Dict       		=							f"""https://api.github.com/repos/huggingface/transformers/actions/workflows/{workflow_id}/runs"""
       # On `main` branch + event being `schedule` + not returning PRs + only `num_runs` results
       url += f"""?branch=main&event=schedule&exclude_pull_requests=true&per_page={num_runs}"""

       lowercase    :				int       		=							requests.get(__snake_case     , headers=__snake_case  ).json()

       return result["workflow_runs"]


def   __magic_name__	(      __snake_case				:       Dict  ) ->				Tuple:
       lowercase    :				Tuple       		=							get_daily_ci_runs(__snake_case  )
       lowercase    :				Union[str, Any]       		=							None
       for workflow_run in workflow_runs:
              if workflow_run["status"] == "completed":
                     lowercase    :				List[Any]       		=							workflow_run["id"]
                     break

       return workflow_run_id


def   __magic_name__	(      __snake_case				:       Optional[int]     , __snake_case				:       Optional[Any]     , __snake_case				:       Union[str, Any]  ) ->				int:
       lowercase    :				Dict       		=							get_last_daily_ci_runs(__snake_case  )
       if workflow_run_id is not None:
              lowercase    :				Dict       		=							get_artifacts_links(worflow_run_id=__snake_case     , token=__snake_case  )
              for artifact_name in artifact_names:
                     if artifact_name in artifacts_links:
                            lowercase    :				Optional[int]       		=							artifacts_links[artifact_name]
                            download_artifact(
                                artifact_name=__snake_case     , artifact_url=__snake_case     , output_dir=__snake_case     , token=__snake_case  )


def   __magic_name__	(      __snake_case				:       List[Any]     , __snake_case				:       Optional[int]     , __snake_case				:       Tuple  ) ->				Optional[int]:
       get_last_daily_ci_artifacts(__snake_case     , __snake_case     , __snake_case  )

       lowercase    :				str       		=							{}
       for artifact_name in artifact_names:
              lowercase    :				Optional[Any]       		=							os.path.join(__snake_case     , f"""{artifact_name}.zip"""  )
              if os.path.isfile(__snake_case  ):
                     lowercase    :				List[Any]       		=							{}
                     with zipfile.ZipFile(__snake_case  ) as z:
                            for filename in z.namelist():
                                   if not os.path.isdir(__snake_case  ):
                                          # read the file
                                          with z.open(__snake_case  ) as f:
                                                 lowercase    :				str       		=							f.read().decode("UTF-8"  )

       return results


