





"""simple docstring"""






import itertools
from dataclasses import dataclass
from io import StringIO
from typing import Optional

import pyarrow as pa

import datasets
from datasets.features.features import require_storage_cast
from datasets.table import table_cast


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



@dataclass
class 						lowerCAmelCase       (   datasets.BuilderConfig				):
       lowerCAmelCase__    			=	None
       lowerCAmelCase__    			=	"utf-8"
       lowerCAmelCase__    			=	None
       lowerCAmelCase__    			=	10 << 20  # 10MB
       lowerCAmelCase__    			=	False
       lowerCAmelCase__    			=	"line"



class 						lowerCAmelCase       (   datasets.ArrowBasedBuilder				):
       lowerCAmelCase__    			=	TextConfig






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






       def 				__A			( self     ,	a__  ):
              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}"""  )
              _UpperCAmelCase			     =  dl_manager.download_and_extract(self.config.data_files  )
              if isinstance(a__     ,	(str, list, tuple)  ):
                     _UpperCAmelCase			     =  data_files
                     if isinstance(a__     ,	a__  ):
                            _UpperCAmelCase			     =  [files]
                     _UpperCAmelCase			     =  [dl_manager.iter_files(a__  ) for file in files]
                     return [datasets.SplitGenerator(name=datasets.Split.TRAIN     ,	gen_kwargs={'files': files}  )]
              _UpperCAmelCase			     =  []
              for split_name, files in data_files.items():
                     if isinstance(a__     ,	a__  ):
                            _UpperCAmelCase			     =  [files]
                     _UpperCAmelCase			     =  [dl_manager.iter_files(a__  ) for file in files]
                     splits.append(datasets.SplitGenerator(name=a__     ,	gen_kwargs={'files': files}  )  )
              return splits






       def 				__A			( self     ,	a__  ):
              if self.config.features is not None:
                     _UpperCAmelCase			     =  self.config.features.arrow_schema
                     if all(not require_storage_cast(a__  ) for feature in self.config.features.values()  ):
                            # cheaper cast
                            _UpperCAmelCase			     =  pa_table.cast(a__  )
                     else:
                            # more expensive cast; allows str <-> int/float or str to Audio for example
                            _UpperCAmelCase			     =  table_cast(a__     ,	a__  )
                     return pa_table
              else:
                     return pa_table.cast(pa.schema({'text': pa.string()}  )  )






       def 				__A			( self     ,	a__  ):
              _UpperCAmelCase			     =  list(self.config.features  ) if self.config.features is not None else ['text']
              for file_idx, file in enumerate(itertools.chain.from_iterable(a__  )  ):
                     # open in text mode, by default translates universal newlines ("\n", "\r\n" and "\r") into "\n"
                     with open(a__     ,	encoding=self.config.encoding     ,	errors=self.config.errors  ) as f:
                            if self.config.sample_by == "line":
                                   _UpperCAmelCase			     =  0
                                   while True:
                                          _UpperCAmelCase			     =  f.read(self.config.chunksize  )
                                          if not batch:
                                                 break
                                          batch += f.readline()  # finish current line
                                          # StringIO.readlines, by default splits only on "\n" (and keeps line breaks)
                                          _UpperCAmelCase			     =  StringIO(a__  ).readlines()
                                          if not self.config.keep_linebreaks:
                                                 _UpperCAmelCase			     =  [line.rstrip('\n'  ) for line in batch]
                                          _UpperCAmelCase			     =  pa.Table.from_arrays([pa.array(a__  )]     ,	names=a__  )
                                          # 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 (file_idx, batch_idx), self._cast_table(a__  )
                                          batch_idx += 1
                            elif self.config.sample_by == "paragraph":
                                   _UpperCAmelCase			     =  0
                                   _UpperCAmelCase			     =  ''
                                   while True:
                                          _UpperCAmelCase			     =  f.read(self.config.chunksize  )
                                          if not new_batch:
                                                 break
                                          batch += new_batch
                                          batch += f.readline()  # finish current line
                                          _UpperCAmelCase			     =  batch.split('\n\n'  )
                                          _UpperCAmelCase			     =  pa.Table.from_arrays(
                                              [pa.array([example for example in batch[:-1] if example]  )]     ,	names=a__  )
                                          # 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 (file_idx, batch_idx), self._cast_table(a__  )
                                          batch_idx += 1
                                          _UpperCAmelCase			     =  batch[-1]
                                   if batch:
                                          _UpperCAmelCase			     =  pa.Table.from_arrays([pa.array([batch]  )]     ,	names=a__  )
                                          yield (file_idx, batch_idx), self._cast_table(a__  )
                            elif self.config.sample_by == "document":
                                   _UpperCAmelCase			     =  f.read()
                                   _UpperCAmelCase			     =  pa.Table.from_arrays([pa.array([text]  )]     ,	names=a__  )
                                   yield file_idx, self._cast_table(a__  )













"""simple docstring"""






def    __lowerCamelCase     (							SCREAMING_SNAKE_CASE				)		->							Dict:






       """simple docstring"""




       _UpperCAmelCase			     =  [701, 301, 132, 57, 23, 10, 4, 1]
       for gap in gaps:
              for i in range(SCREAMING_SNAKE_CASE,len(SCREAMING_SNAKE_CASE				)				):
                     _UpperCAmelCase			     =  collection[i]
                     _UpperCAmelCase			     =  i
                     while j >= gap and collection[j - gap] > insert_value:
                            _UpperCAmelCase			     =  collection[j - gap]
                            j -= gap
                     if j != i:
                            _UpperCAmelCase			     =  insert_value
       return collection


if __name__ == "__main__":
    from doctest import testmod

    testmod()
    lowerCAmelCase_      =				input('''Enter numbers separated by a comma:\n''').strip()
    lowerCAmelCase_      =				[int(item) for item in user_input.split(''',''')]
    print(shell_sort(unsorted))






