

__a    :Optional[int]      =			[sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(10_0000)]

def       __snake_case						( __UpperCamelCase	: int    ):



      """simple docstring"""

      A_						  =				0
      while number:
            # Increased Speed Slightly by checking every 5 digits together.
            sum_of_digits_squared += DIGITS_SQUARED[number % 10_0000]
            number //= 10_0000

      return sum_of_digits_squared


# There are 2 Chains made,
# One ends with 89 with the chain member 58 being the one which when declared first,
# there will be the least number of iterations for all the members to be checked.

# The other one ends with 1 and has only one element 1.

# So 58 and 1 are chosen to be declared at the starting.

# Changed dictionary to an array to quicken the solution
__a    :list[bool | None]      =			[None] * 1000_0000
__a    :Optional[Any]      =			True
__a    :List[Any]      =			False

def       __snake_case						( __UpperCamelCase	: int    ):



      """simple docstring"""

      if CHAINS[number - 1] is not None:
            return CHAINS[number - 1]  # type: ignore

      A_						  =				chain(next_number(__UpperCamelCase    )    )
      A_						  =				number_chain

      while number < 1000_0000:
            A_						  =				number_chain
            number *= 10

      return number_chain

def       __snake_case						( __UpperCamelCase	: int = 1000_0000    ):



      """simple docstring"""

      for i in range(1				,__UpperCamelCase    ):
            if CHAINS[i] is None:
                  chain(i + 1    )

      return CHAINS[:number].count(__UpperCamelCase    )


if __name__ == "__main__":
      import doctest

      doctest.testmod()
      print(F"{solution() = }")





from pathlib import Path

import fire
from tqdm import tqdm




def 		lowerCAmelCase_ (						lowerCamelCase="ro"						,  lowerCamelCase="en"						,  lowerCamelCase="wmt16"						,  lowerCamelCase=None ):
				try:
								import datasets
				except (ModuleNotFoundError, ImportError):
								raise ImportError("""run pip install datasets""" )
				__magic_name__						:						Dict										=F"{src_lang}-{tgt_lang}"
				print(F"Converting {dataset}-{pair}" )
				__magic_name__						:						Dict										=datasets.load_dataset(lowerCamelCase						,  lowerCamelCase )
				if save_dir is None:
								__magic_name__						:						Optional[int]										=F"{dataset}-{pair}"
				__magic_name__						:						int										=Path(lowerCamelCase )
				save_dir.mkdir(exist_ok=lowerCamelCase )

				for split in ds.keys():
								print(F"Splitting {split} with {ds[split].num_rows} records" )

								# to save to val.source, val.target like summary datasets
								__magic_name__						:						Dict										="""val""" if split == """validation""" else split
								__magic_name__						:						List[Any]										=save_dir.joinpath(F"{fn}.source" )
								__magic_name__						:						Optional[int]										=save_dir.joinpath(F"{fn}.target" )
								__magic_name__						:						Optional[Any]										=src_path.open("""w+""" )
								__magic_name__						:						List[Any]										=tgt_path.open("""w+""" )

								# reader is the bottleneck so writing one record at a time doesn't slow things down
								for x in tqdm(ds[split] ):
												__magic_name__						:						str										=x["""translation"""]
												src_fp.write(ex[src_lang] + """\n""" )
												tgt_fp.write(ex[tgt_lang] + """\n""" )

				print(F"Saved {dataset} dataset to {save_dir}" )


if __name__ == "__main__":
							fire.Fire(download_wmt_dataset)




