


"""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 snake_case   (	_UpperCamelCase):







		def __init__(       self   :							Optional[Any]     , a__   :							NestedDataStructureLike[PathLike]     , a__   :							Optional[NamedSplit] = None     , a__   :							Optional[Features] = None     , a__   :							str = None     , a__   :							bool = False     , a__   :							bool = False     , a__   :							Optional[int] = None     , **a__   :							Optional[int]     , )							->    Union[str, Any]:





						'''simple docstring'''







						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 			a_			(       self   :							Optional[Any]		)							->    Dict:





						'''simple docstring'''







						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 snake_case   :







		def __init__(       self   :							Optional[int]     , a__   :							Dataset     , a__   :							Union[PathLike, BinaryIO]     , a__   :							Optional[int] = None     , a__   :							Optional[int] = None     , **a__   :							List[Any]     , )							->    List[Any]:





						'''simple docstring'''







						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 			a_			(       self   :							Tuple		)							->    int:





						'''simple docstring'''







						_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 			a_			(       self   :							Optional[int]     , a__   :							Dict		)							->    Tuple:





						'''simple docstring'''







						_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 			a_			(       self   :							Dict     , a__   :							BinaryIO     , a__   :							Dict     , a__   :							int     , **a__   :							Union[str, Any]		)							->    int:





						'''simple docstring'''







						_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 factorial






def   a__			(					__lowercase  ,      __lowercase )						->						List[Any]:
				return factorial(__lowercase ) / (factorial(__lowercase ) * factorial(n - r ))






def   a__			(					)						->						List[str]:
				_A       	=      0

				for i in range(1  ,      101 ):
								for j in range(1  ,      i + 1 ):
												if combinations(__lowercase  ,      __lowercase ) > 1E6:
																total += 1
				return total


if __name__ == "__main__":
		print(solution())