


"""simple docstring"""






import multiprocessing
from typing import TYPE_CHECKING, Optional, Union

from .. import Dataset, Features, config
from ..formatting import query_table
from ..packaged_modules.sql.sql import Sql
from ..utils import logging
from .abc import AbstractDatasetInputStream


if TYPE_CHECKING:
   import sqlitea

   import sqlalchemy


class     __lowerCamelCase  (					a__				):

     '''simple docstring'''


     def __init__(      self    ,				__UpperCAmelCase    ,				__UpperCAmelCase    ,				__UpperCAmelCase = None    ,				__UpperCAmelCase = None    ,				__UpperCAmelCase = False    ,				**__UpperCAmelCase    ,				)       ->							List[str]:
          super().__init__(features=__UpperCAmelCase    ,				cache_dir=__UpperCAmelCase    ,				keep_in_memory=__UpperCAmelCase    ,				**__UpperCAmelCase							)
          _a    	=				Sql(
              cache_dir=__UpperCAmelCase    ,				features=__UpperCAmelCase    ,				sql=__UpperCAmelCase    ,				con=__UpperCAmelCase    ,				**__UpperCAmelCase    ,				)





     def 							_UpperCAmelCase      (      self							)       ->							List[str]:
          _a    	=				None
          _a    	=				None
          _a    	=				None
          _a    	=				None

          self.builder.download_and_prepare(
              download_config=__UpperCAmelCase    ,				download_mode=__UpperCAmelCase    ,				verification_mode=__UpperCAmelCase    ,				base_path=__UpperCAmelCase    ,				)

          # Build dataset for splits
          _a    	=				self.builder.as_dataset(
              split='''train'''    ,				verification_mode=__UpperCAmelCase    ,				in_memory=self.keep_in_memory							)
          return dataset







class     __lowerCamelCase  :

     '''simple docstring'''


     def __init__(      self    ,				__UpperCAmelCase    ,				__UpperCAmelCase    ,				__UpperCAmelCase    ,				__UpperCAmelCase = None    ,				__UpperCAmelCase = None    ,				**__UpperCAmelCase    ,				)       ->							Union[str, Any]:
          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    	=				name
          _a    	=				con
          _a    	=				batch_size if batch_size else config.DEFAULT_MAX_BATCH_SIZE
          _a    	=				num_proc
          _a    	=				to_sql_kwargs


     def 							_UpperCAmelCase      (      self							)       ->							int:
          _a    	=				self.to_sql_kwargs.pop('''sql'''    ,				__UpperCAmelCase							)
          _a    	=				self.to_sql_kwargs.pop('''con'''    ,				__UpperCAmelCase							)
          _a    	=				self.to_sql_kwargs.pop('''index'''    ,				__UpperCAmelCase							)

          _a    	=				self._write(index=__UpperCAmelCase    ,				**self.to_sql_kwargs							)
          return written


     def 							_UpperCAmelCase      (      self    ,				__UpperCAmelCase							)       ->							List[str]:
          _a	,      _a	,      _a    	=				args
          _a    	=				{**to_sql_kwargs, '''if_exists''': '''append'''} if offset > 0 else to_sql_kwargs
          _a    	=				query_table(
              table=self.dataset.data    ,				key=slice(__UpperCAmelCase    ,				offset + self.batch_size							)    ,				indices=self.dataset._indices    ,				)
          _a    	=				batch.to_pandas()
          _a    	=				df.to_sql(self.name    ,				self.con    ,				index=__UpperCAmelCase    ,				**__UpperCAmelCase							)
          return num_rows or len(__UpperCAmelCase							)





     def 							_UpperCAmelCase      (      self    ,				__UpperCAmelCase    ,				**__UpperCAmelCase							)       ->							int:
          _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 SQL from Arrow format'''    ,				):
                    written += self._batch_sql((offset, index, to_sql_kwargs)							)
          else:
               _a	,      _a    	=				len(self.dataset							), self.batch_size
               with multiprocessing.Pool(self.num_proc							) as pool:
                    for num_rows in logging.tqdm(
                        pool.imap(
                            self._batch_sql    ,				[(offset, index, to_sql_kwargs) for offset in range(0    ,				__UpperCAmelCase    ,				__UpperCAmelCase							)]    ,				)    ,				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 SQL from Arrow format'''    ,				):
                         written += num_rows

          return written



"""simple docstring"""






def       A_   (   _lowerCAmelCase     :					Dict=2_81_23       ):






     """simple docstring"""

     _a    	=				[1] * (limit + 1)

     for i in range(2,     int(limit**0.5       ) + 1       ):
          sum_divs[i * i] += i
          for k in range(i + 1,     limit // i + 1       ):
               sum_divs[k * i] += k + i

     _a    	=				set()
     _a    	=				0

     for n in range(1,     limit + 1       ):
          if sum_divs[n] > n:
               abundants.add(_lowerCAmelCase       )

          if not any((n - a in abundants) for a in abundants       ):
               res += n

     return res


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