'''simple docstring'''




import json
import os
from dataclasses import dataclass

import numpy as np
import pyarrow as pa

import datasets
from utils import get_duration


__SCREAMING_SNAKE_CASE	:					int					=  100_000_000_000
__SCREAMING_SNAKE_CASE	:					int					=  10_000

__SCREAMING_SNAKE_CASE	:					str					=  os.path.split(__file__)
__SCREAMING_SNAKE_CASE	:					str					=  os.path.join(RESULTS_BASEPATH, """results""", RESULTS_FILENAME.replace(""".py""", """.json"""))

def      UpperCamelCase_							( _UpperCAmelCase  :				int      ,     _UpperCAmelCase  :				int   )   ->   datasets.Dataset:


							"""simple docstring"""







							_UpperCAmelCase					:  List[Any]											=   pa.Table.from_pydict({"col": [0] * chunk_size}   )
							_UpperCAmelCase					:  Dict											=   pa.concat_tables([table] * (num_examples // chunk_size)   )
							return datasets.Dataset(__lowercase      ,     fingerprint="table_100B"   )

@dataclass
class      lowerCamelCase_     :
						'''simple docstring'''

						__UpperCamelCase:  Any      =						4_2
						__UpperCamelCase:  Union[str, Any]      =						4_2
						__UpperCamelCase:  List[Any]      =						4_2
						__UpperCamelCase:  Optional[int]      =						4_2




						def 					_A     (	self						:    Dict	):
													_UpperCAmelCase					:  str											=   np.random.default_rng(self.seed	)
													_UpperCAmelCase					:  Optional[int]											=   rng.integers(low=self.low						, high=self.high						, size=self.size	).tolist()




						def __iter__(	self						:    Optional[Any]	):
													return iter(self._sampled_values	)





						def __len__(	self						:    Any	):
													return self.size

@get_duration
def      UpperCamelCase_							( _UpperCAmelCase  :				datasets.Dataset   )   ->   List[Any]:


							"""simple docstring"""







							_UpperCAmelCase					:  Any											=   dataset[0]

@get_duration
def      UpperCamelCase_							( _UpperCAmelCase  :				datasets.Dataset   )   ->   List[str]:


							"""simple docstring"""







							_UpperCAmelCase					:  Dict											=   dataset[-1]

@get_duration
def      UpperCamelCase_							( _UpperCAmelCase  :				datasets.Dataset   )   ->   List[str]:


							"""simple docstring"""







							_UpperCAmelCase					:  Optional[Any]											=   dataset[range(len(__lowercase   ) // 2      ,     len(__lowercase   ) // 2 + 1_024   )]

@get_duration
def      UpperCamelCase_							( _UpperCAmelCase  :				datasets.Dataset   )   ->   Tuple:


							"""simple docstring"""







							_UpperCAmelCase					:  Any											=   dataset[RandIter(0      ,     len(__lowercase   )      ,     1_024      ,     seed=42   )]

def      UpperCamelCase_							( )   ->   Optional[int]:


							"""simple docstring"""







							_UpperCAmelCase					:  Dict											=   {"num examples": SPEED_TEST_N_EXAMPLES}
							_UpperCAmelCase					:  List[str]											=   (get_first_row, get_last_row, get_batch_of_aaaa_rows, get_batch_of_aaaa_random_rows)
							print("generating dataset"   )
							_UpperCAmelCase					:  Dict											=   generate_100B_dataset(num_examples=__lowercase      ,     chunk_size=__lowercase   )
							print("Functions"   )
							for func in functions:
														print(func.__name__   )
														_UpperCAmelCase					:  Optional[Any]											=   func(__lowercase   )

							with open(__lowercase      ,     "wb"   ) as f:
														f.write(json.dumps(__lowercase   ).encode("utf-8"   )   )


if __name__ == "__main__":  # useful to run the profiler
		benchmark_table_100B()


'''simple docstring'''




def      UpperCamelCase_							( _UpperCAmelCase  :				int   )   ->   bool:


       """simple docstring"""







       _UpperCAmelCase					:  Optional[int]											=   9

       while num > 0:
              if num % 10 != digit:
                     return False
              num //= 100
              digit -= 1

       return True

def      UpperCamelCase_							( )   ->   int:


       """simple docstring"""







       _UpperCAmelCase					:  Optional[Any]											=   138_902_663

       while not is_square_form(num * num   ):
              if num % 10 == 3:
                     num -= 6  # (3 - 6) % 10 = 7
              else:
                     num -= 4  # (7 - 4) % 10 = 3

       return num * 10


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

