


import itertools
from dataclasses import dataclass
from typing import Optional

import pyarrow as pa

import datasets
from datasets.table import table_cast


UpperCAmelCase__            =							datasets.utils.logging.get_logger(__name__)







@dataclass
class 				lowerCamelCase__       (	datasets.BuilderConfig):
     SCREAMING_SNAKE_CASE__				      =      None







class 				lowerCamelCase__       (	datasets.ArrowBasedBuilder):
     SCREAMING_SNAKE_CASE__				      =      ArrowConfig





     def 					__A (self	)					->       Union[str, Any]:
      return datasets.DatasetInfo(features=self.config.features	)





     def 					__A (self		,					UpperCAmelCase	)					->       Any:
      if not self.config.data_files:
       raise ValueError(f"At least one data file must be specified, but got data_files={self.config.data_files}"	)
      _lowercase											=dl_manager.download_and_extract(self.config.data_files	)
      if isinstance(UpperCAmelCase		,					(str, list, tuple)	):
       _lowercase											=data_files
       if isinstance(UpperCAmelCase		,					UpperCAmelCase	):
        _lowercase											=[files]
       # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
       _lowercase											=[dl_manager.iter_files(UpperCAmelCase	) for file in files]
       return [datasets.SplitGenerator(name=datasets.Split.TRAIN		,					gen_kwargs={'''files''': files}	)]
      _lowercase											=[]
      for split_name, files in data_files.items():
       if isinstance(UpperCAmelCase		,					UpperCAmelCase	):
        _lowercase											=[files]
       # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
       _lowercase											=[dl_manager.iter_files(UpperCAmelCase	) for file in files]
       # Infer features is they are stoed in the arrow schema
       if self.info.features is None:
        for file in itertools.chain.from_iterable(UpperCAmelCase	):
         with open(UpperCAmelCase		,					'''rb'''	) as f:
          _lowercase											=datasets.Features.from_arrow_schema(pa.ipc.open_stream(UpperCAmelCase	).schema	)
         break
       splits.append(datasets.SplitGenerator(name=UpperCAmelCase		,					gen_kwargs={'''files''': files}	)	)
      return splits





     def 					__A (self		,					UpperCAmelCase	)					->       pa.Table:
      if self.info.features is not None:
       # more expensive cast to support nested features with keys in a different order
       # allows str <-> int/float or str to Audio for example
       _lowercase											=table_cast(UpperCAmelCase		,					self.info.features.arrow_schema	)
      return pa_table





     def 					__A (self		,					UpperCAmelCase	)					->       Union[str, Any]:
      for file_idx, file in enumerate(itertools.chain.from_iterable(UpperCAmelCase	)	):
       with open(UpperCAmelCase		,					'''rb'''	) as f:
        try:
         for batch_idx, record_batch in enumerate(pa.ipc.open_stream(UpperCAmelCase	)	):
          _lowercase											=pa.Table.from_batches([record_batch]	)
          # Uncomment for debugging (will print the Arrow table size and elements)
          # logger.warning(f"pa_table: {pa_table} num rows: {pa_table.num_rows}")
          # logger.warning('\n'.join(str(pa_table.slice(i, 1).to_pydict()) for i in range(pa_table.num_rows)))
          yield f"{file_idx}_{batch_idx}", self._cast_table(UpperCAmelCase	)
        except ValueError as e:
         logger.error(f"Failed to read file '{file}' with error {type(UpperCAmelCase	)}: {e}"	)
         raise





from math import sqrt
def     UpperCAmelCase_ (							__snake_case						)					->      list[int]:







 """simple docstring"""


 _lowercase											=[1]
 for i in range(2					,						int(sqrt(__snake_case						)						) + 1					,						1						):
  if number % i == 0:
   values.append(__snake_case						)
   if int(number // i						) != i:
    values.append(int(number // i						)						)
 return sorted(__snake_case						)
def     UpperCAmelCase_ (							__snake_case						)					->      bool:







 """simple docstring"""


 return sum(factors(__snake_case						)						) > n
def     UpperCAmelCase_ (							__snake_case						)					->      bool:







 """simple docstring"""


 _lowercase											=factors(__snake_case						)
 _lowercase											=len(__snake_case						)
 _lowercase											=[[0 for i in range(number + 1						)] for j in range(r + 1						)]
 for i in range(r + 1						):
  _lowercase											=True

 for i in range(1					,						number + 1						):
  _lowercase											=False

 for i in range(1					,						r + 1						):
  for j in range(1					,						number + 1						):
   if j < values[i - 1]:
    _lowercase											=subset[i - 1][j]
   else:
    _lowercase											=subset[i - 1][j] or subset[i - 1][j - values[i - 1]]

 return subset[r][number] != 0
def     UpperCAmelCase_ (							__snake_case						)					->      bool:







 """simple docstring"""


 return abundant(__snake_case						) and not semi_perfect(__snake_case						)


if __name__ == "__main__":
  import doctest

  doctest.testmod(verbose=True)
  for number in (69, 70, 71):
    print(f'''{number} is {'' if weird(number) else 'not '}weird.''')

