


'''simple docstring'''






import multiprocessing
import os
from typing import BinaryIO, Optional, Union

from .. import Dataset, Features, NamedSplit, config
from ..formatting import query_table
from ..packaged_modules.csv.csv import Csv
from ..utils import logging
from ..utils.typing import NestedDataStructureLike, PathLike
from .abc import AbstractDatasetReader




class 			a  (  __A							):
 def __init__(			self   ,					__magic_name__   ,					__magic_name__ = None   ,					__magic_name__ = None   ,					__magic_name__ = None   ,					__magic_name__ = False   ,					__magic_name__ = False   ,					__magic_name__ = None   ,					**__magic_name__   ,					)       ->				Dict:
      super().__init__(
          A_   ,					split=A_   ,					features=A_   ,					cache_dir=A_   ,					keep_in_memory=A_   ,					streaming=A_   ,					num_proc=A_   ,					**A_   ,					)
      _a         =				path_or_paths if isinstance(A_   ,					A_    ) else {self.split: path_or_paths}
      _a         =				Csv(
          cache_dir=A_   ,					data_files=A_   ,					features=A_   ,					**A_   ,					)




 def 				__UpperCAmelCase		(			self    )       ->				List[str]:



      if self.streaming:
           _a         =				self.builder.as_streaming_dataset(split=self.split    )
      # Build regular (map-style) dataset
      else:
           _a         =				None
           _a         =				None
           _a         =				None
           _a         =				None

           self.builder.download_and_prepare(
               download_config=A_   ,					download_mode=A_   ,					verification_mode=A_   ,					base_path=A_   ,					num_proc=self.num_proc   ,					)
           _a         =				self.builder.as_dataset(
               split=self.split   ,					verification_mode=A_   ,					in_memory=self.keep_in_memory    )
      return dataset





class 			a  :
 def __init__(			self   ,					__magic_name__   ,					__magic_name__   ,					__magic_name__ = None   ,					__magic_name__ = None   ,					**__magic_name__   ,					)       ->				int:



      if num_proc is not None and num_proc <= 0:
           raise ValueError(f'num_proc {num_proc} must be an integer > 0.'    )

      _a         =				dataset
      _a         =				path_or_buf
      _a         =				batch_size if batch_size else config.DEFAULT_MAX_BATCH_SIZE
      _a         =				num_proc
      _a         =				'utf-8'
      _a         =				to_csv_kwargs
 def 				__UpperCAmelCase		(			self    )       ->				Union[str, Any]:
      _a         =				self.to_csv_kwargs.pop('path_or_buf'   ,					A_    )
      _a         =				self.to_csv_kwargs.pop('header'   ,					A_    )
      _a         =				self.to_csv_kwargs.pop('index'   ,					A_    )

      if isinstance(self.path_or_buf   ,					(str, bytes, os.PathLike)    ):
           with open(self.path_or_buf   ,					'wb+'    ) as buffer:
                _a         =				self._write(file_obj=A_   ,					header=A_   ,					index=A_   ,					**self.to_csv_kwargs    )
      else:
           _a         =				self._write(file_obj=self.path_or_buf   ,					header=A_   ,					index=A_   ,					**self.to_csv_kwargs    )
      return written
 def 				__UpperCAmelCase		(			self   ,					__magic_name__    )       ->				Optional[int]:
      _a   , _a   , _a   , _a         =				args

      _a         =				query_table(
          table=self.dataset.data   ,					key=slice(A_   ,					offset + self.batch_size    )   ,					indices=self.dataset._indices   ,					)
      _a         =				batch.to_pandas().to_csv(
          path_or_buf=A_   ,					header=header if (offset == 0) else False   ,					index=A_   ,					**A_    )
      return csv_str.encode(self.encoding    )




 def 				__UpperCAmelCase		(			self   ,					__magic_name__   ,					__magic_name__   ,					__magic_name__   ,					**__magic_name__    )       ->				List[str]:
      _a         =				0

      if self.num_proc is None or self.num_proc == 1:
           for offset in logging.tqdm(
               range(0   ,					len(self.dataset    )   ,					self.batch_size    )   ,					unit='ba'   ,					disable=not logging.is_progress_bar_enabled()   ,					desc='Creating CSV from Arrow format'   ,					):
                _a         =				self._batch_csv((offset, header, index, to_csv_kwargs)    )
                written += file_obj.write(A_    )

      else:
           _a   , _a         =				len(self.dataset    ), self.batch_size
           with multiprocessing.Pool(self.num_proc    ) as pool:
                for csv_str in logging.tqdm(
                    pool.imap(
                        self._batch_csv   ,					[(offset, header, index, to_csv_kwargs) for offset in range(0   ,					A_   ,					A_    )]   ,					)   ,					total=(num_rows // batch_size) + 1 if num_rows % batch_size else num_rows // batch_size   ,					unit='ba'   ,					disable=not logging.is_progress_bar_enabled()   ,					desc='Creating CSV from Arrow format'   ,					):
                     written += file_obj.write(A_    )

      return written






"""simple docstring"""






from math import gcd


def 							A__ (     UpperCamelCase__ = 12_000    ):


  '''simple docstring'''


  _SCREAMING_SNAKE_CASE        =			0
  for d in range(max_d + 1    ):
    for n in range(d // 3 + 1       ,							(d + 1) // 2    ):
      if gcd(UpperCamelCase__       ,							UpperCamelCase__    ) == 1:
        fractions_number += 1
  return fractions_number


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