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






def 				UpperCAmelCase_						(				__SCREAMING_SNAKE_CASE					,				__SCREAMING_SNAKE_CASE					,				__SCREAMING_SNAKE_CASE					,				__SCREAMING_SNAKE_CASE				):
	lowercase	    =       sum(a_i[j] for j in range(UpperCamelCase__					,				len(UpperCamelCase__				)				)				)
	lowercase	    =       sum(a_i[j] * base[j] for j in range(min(len(UpperCamelCase__				)					,				UpperCamelCase__				)				)				)

	lowercase    ,   lowercase	    =       0, 0
	lowercase	    =       n - i

	lowercase	    =       memo.get(UpperCamelCase__				)

	if sub_memo is not None:
		lowercase	    =       sub_memo.get(UpperCamelCase__				)

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

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

		else:
			lowercase	    =       []
	else:
		lowercase	    =       {c: []}
		lowercase	    =       sub_memo

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

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

	lowercase	    =       sub_memo[c]

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

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






def 				UpperCAmelCase_						(				__SCREAMING_SNAKE_CASE					,				__SCREAMING_SNAKE_CASE					,				__SCREAMING_SNAKE_CASE					,				__SCREAMING_SNAKE_CASE				):






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

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

	while i < n:
		i += 1
		lowercase	    =       ds_c + ds_b
		diff += addend
		lowercase	    =       0
		for j in range(UpperCamelCase__				):
			lowercase	    =       a_i[j] + addend
			lowercase    ,   lowercase	    =       divmod(UpperCamelCase__					,				10				)

			ds_c += a_i[j]

		if addend > 0:
			break

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






def 				UpperCAmelCase_						(				__SCREAMING_SNAKE_CASE					,				__SCREAMING_SNAKE_CASE					,				__SCREAMING_SNAKE_CASE				):






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

		if addend == 0:
			break

	while addend > 0:
		lowercase    ,   lowercase	    =       divmod(UpperCamelCase__					,				10				)
		digits.append(UpperCamelCase__				)






def 				UpperCAmelCase_						(				__SCREAMING_SNAKE_CASE = 10**15				):
	lowercase	    =       [1]
	lowercase	    =       1
	lowercase	    =       0
	while True:
		lowercase    ,   lowercase	    =       next_term(UpperCamelCase__					,				20					,				i + dn					,				UpperCamelCase__				)
		dn += terms_jumped
		if dn == n - i:
			break

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


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




import argparse

import torch

from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert
from transformers.utils import logging


logging.set_verbosity_info()





def    __lowerCamelCase      (					UpperCamelCase__  ,				UpperCamelCase__  ,				UpperCamelCase__ ):







							'''simple docstring'''






							snake_case_     							=       BertConfig.from_json_file(UpperCamelCase__ )
							print(F'''Building PyTorch model from configuration: {config}''' )
							snake_case_     							=       BertForPreTraining(UpperCamelCase__ )

							# Load weights from tf checkpoint
							load_tf_weights_in_bert(UpperCamelCase__  ,				UpperCamelCase__  ,				UpperCamelCase__ )

							# Save pytorch-model
							print(F'''Save PyTorch model to {pytorch_dump_path}''' )
							torch.save(model.state_dict()  ,				UpperCamelCase__ )


if __name__ == "__main__":
					_UpperCAmelCase						:  Union[str, Any]									=			argparse.ArgumentParser()
					# Required parameters
					parser.add_argument(
					    """--tf_checkpoint_path""", default=None, type=str, required=True, help="""Path to the TensorFlow checkpoint path."""
					)
					parser.add_argument(
					    """--bert_config_file""",
					    default=None,
					    type=str,
					    required=True,
					    help=(
					        """The config json file corresponding to the pre-trained BERT model. \n"""
					        """This specifies the model architecture."""
					    ),
					)
					parser.add_argument(
					    """--pytorch_dump_path""", default=None, type=str, required=True, help="""Path to the output PyTorch model."""
					)
					_UpperCAmelCase						:  Any									=			parser.parse_args()
					convert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.bert_config_file, args.pytorch_dump_path)




