
'''simple docstring'''






import itertools
from dataclasses import dataclass
from typing import List, Optional

import pyarrow as pa
import pyarrow.parquet as pq

import datasets
from datasets.table import table_cast


UpperCAmelCase_							: Any =							datasets.utils.logging.get_logger(__name__)

@dataclass
class 			UpperCAmelCase__    (							datasets.BuilderConfig			):
    lowerCAmelCase_					     =		10000
    lowerCAmelCase_					     =		None
    lowerCAmelCase_					     =		None


class 			UpperCAmelCase__    (							datasets.ArrowBasedBuilder			):
    lowerCAmelCase_					     =		ParquetConfig



    def 	lowerCamelCase_	(						self   :							Any  ):
          return datasets.DatasetInfo(features=self.config.features  )



    def 	lowerCamelCase_	(						self   :							Union[str, Any],__A   :							Tuple  ):
          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}'  )
          _lowerCamelCase					: Optional[Any]		    = dl_manager.download_and_extract(self.config.data_files  )
          if isinstance(__A,(str, list, tuple)  ):
                _lowerCamelCase					: List[Any]		    = data_files
                if isinstance(__A,__A  ):
                      _lowerCamelCase					: Optional[Any]		    = [files]
                # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
                _lowerCamelCase					: Optional[int]		    = [dl_manager.iter_files(__A  ) for file in files]
                return [datasets.SplitGenerator(name=datasets.Split.TRAIN,gen_kwargs={"files": files}  )]
          _lowerCamelCase					: List[Any]		    = []
          for split_name, files in data_files.items():
                if isinstance(__A,__A  ):
                      _lowerCamelCase					: List[str]		    = [files]
                # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
                _lowerCamelCase					: List[str]		    = [dl_manager.iter_files(__A  ) 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(__A  ):
                            with open(__A,"rb"  ) as f:
                                  _lowerCamelCase					: List[Any]		    = datasets.Features.from_arrow_schema(pq.read_schema(__A  )  )
                            break
                splits.append(datasets.SplitGenerator(name=__A,gen_kwargs={"files": files}  )  )
          return splits



    def 	lowerCamelCase_	(						self   :							List[Any],__A   :							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
                _lowerCamelCase					: Any		    = table_cast(__A,self.info.features.arrow_schema  )
          return pa_table



    def 	lowerCamelCase_	(						self   :							Union[str, Any],__A   :							Union[str, Any]  ):
          _lowerCamelCase					: Optional[Any]		    = self.info.features.arrow_schema if self.info.features is not None else None
          if self.info.features is not None and self.config.columns is not None:
                if sorted(field.name for field in schema  ) != sorted(self.config.columns  ):
                      raise ValueError(
                          f'Tried to load parquet data with columns \'{self.config.columns}\' with mismatching features \'{self.info.features}\''  )
          for file_idx, file in enumerate(itertools.chain.from_iterable(__A  )  ):
                with open(__A,"rb"  ) as f:
                      _lowerCamelCase					: int		    = pq.ParquetFile(__A  )
                      try:
                            for batch_idx, record_batch in enumerate(
                                parquet_file.iter_batches(batch_size=self.config.batch_size,columns=self.config.columns  )  ):
                                  _lowerCamelCase					: Optional[int]		    = 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(__A  )
                      except ValueError as e:
                            logger.error(f'Failed to read file \'{file}\' with error {type(__A  )}: {e}'  )
                            raise



'''simple docstring'''







def       lowercase					(_A       ):







       """simple docstring"""







       if len(_A       ) <= 1:
              return [tuple(_A       )]

       _lowerCAmelCase     :				List[str]       =							[]

       def generate(_A ,    _A       ):
              _lowerCAmelCase     :				Any       =							[0] * n
              res.append(tuple(_A       )       )

              _lowerCAmelCase     :				Any       =							0
              while i < n:
                     if c[i] < i:
                            if i % 2 == 0:
                                   _lowerCAmelCase      ,  _lowerCAmelCase     :				Tuple       =							arr[i], arr[0]
                            else:
                                   _lowerCAmelCase      ,  _lowerCAmelCase     :				List[str]       =							arr[i], arr[c[i]]
                            res.append(tuple(_A       )       )
                            c[i] += 1
                            _lowerCAmelCase     :				Optional[int]       =							0
                     else:
                            _lowerCAmelCase     :				Any       =							0
                            i += 1

       generate(len(_A       ) ,    _A       )
       return res


if __name__ == "__main__":
       lowerCAmelCase     :  int											=    input("""Enter numbers separated by a comma:\n""").strip()
       lowerCAmelCase     :  Optional[int]											=    [int(item) for item in user_input.split(""",""")]
       print(heaps(arr))

