





'''simple docstring'''


import bza
import gzip
import lzma
import os
import shutil
import struct
import tarfile
import warnings
import zipfile
from abc import ABC, abstractmethod
from pathlib import Path
from typing import Dict, List, Optional, Type, Union

from .. import config
from .filelock import FileLock
from .logging import get_logger


_SCREAMING_SNAKE_CASE	 =							get_logger(__name__)

class    lowerCAmelCase_		:




 def __init__(	self			,     _lowerCAmelCase = None		)    ->							List[str]:
     _lowerCAmelCase				=      (
         os.path.join(_lowerCAmelCase			,     config.EXTRACTED_DATASETS_DIR		) if cache_dir else config.EXTRACTED_DATASETS_PATH
     )
     _lowerCAmelCase				=      Extractor




 def 							_snake_case   (	self			,     _lowerCAmelCase		)    ->							str:
     from .file_utils import hash_url_to_filename

     # Path where we extract compressed archives
     # We extract in the cache dir, and get the extracted path name by hashing the original path"
     _lowerCAmelCase				=      os.path.abspath(_lowerCAmelCase		)
     return os.path.join(self.extract_dir			,     hash_url_to_filename(_lowerCAmelCase		)		)




 def 							_snake_case   (	self			,     _lowerCAmelCase			,     _lowerCAmelCase		)    ->							bool:
     return force_extract or (
         not os.path.isfile(_lowerCAmelCase		) and not (os.path.isdir(_lowerCAmelCase		) and os.listdir(_lowerCAmelCase		))
     )





 def 							_snake_case   (	self			,     _lowerCAmelCase			,     _lowerCAmelCase = False		)    ->							str:
     _lowerCAmelCase				=      self.extractor.infer_extractor_format(_lowerCAmelCase		)
     if not extractor_format:
         return input_path
     _lowerCAmelCase				=      self._get_output_path(_lowerCAmelCase		)
     if self._do_extract(_lowerCAmelCase			,     _lowerCAmelCase		):
         self.extractor.extract(_lowerCAmelCase			,     _lowerCAmelCase			,     _lowerCAmelCase		)
     return output_path







class    lowerCAmelCase_		(		__magic_name__		):




 @classmethod
 @abstractmethod
 def 							_snake_case   (	cls			,     _lowerCAmelCase			,     **_lowerCAmelCase		)    ->							bool:
     ...





 @staticmethod
 @abstractmethod
 def 							_snake_case   (	_lowerCAmelCase			,     _lowerCAmelCase		)    ->							None:
     ...







class    lowerCAmelCase_		(		__magic_name__						,__magic_name__		):
 __lowerCamelCase						:							List[bytes]         =					[]




 @staticmethod
 def 							_snake_case   (	_lowerCAmelCase			,     _lowerCAmelCase		)    ->							Any:
     with open(_lowerCAmelCase			,     "rb"		) as f:
         return f.read(_lowerCAmelCase		)





 @classmethod
 def 							_snake_case   (	cls			,     _lowerCAmelCase			,     _lowerCAmelCase = b""		)    ->							bool:
     if not magic_number:
         _lowerCAmelCase				=      max(len(_lowerCAmelCase		) for cls_magic_number in cls.magic_numbers		)
         try:
             _lowerCAmelCase				=      cls.read_magic_number(_lowerCAmelCase			,     _lowerCAmelCase		)
         except OSError:
             return False
     return any(magic_number.startswith(_lowerCAmelCase		) for cls_magic_number in cls.magic_numbers		)







class    lowerCAmelCase_		(		__magic_name__		):




 @classmethod
 def 							_snake_case   (	cls			,     _lowerCAmelCase			,     **_lowerCAmelCase		)    ->							bool:
     return tarfile.is_tarfile(_lowerCAmelCase		)




 @staticmethod
 def 							_snake_case   (	_lowerCAmelCase			,     _lowerCAmelCase		)    ->							Any:

     def resolved(_lowerCAmelCase		) -> str:
         return os.path.realpath(os.path.abspath(_lowerCAmelCase		)		)

     def badpath(_lowerCAmelCase			,     _lowerCAmelCase		) -> bool:
         # joinpath will ignore base if path is absolute
         return not resolved(os.path.join(_lowerCAmelCase			,     _lowerCAmelCase		)		).startswith(_lowerCAmelCase		)

     def badlink(_lowerCAmelCase			,     _lowerCAmelCase		) -> bool:
         # Links are interpreted relative to the directory containing the link
         _lowerCAmelCase				=      resolved(os.path.join(_lowerCAmelCase			,     os.path.dirname(info.name		)		)		)
         return badpath(info.linkname			,     base=_lowerCAmelCase		)

     _lowerCAmelCase				=      resolved(_lowerCAmelCase		)

     for finfo in members:
         if badpath(finfo.name			,     _lowerCAmelCase		):
             logger.error(f'''Extraction of {finfo.name} is blocked (illegal path)'''		)
         elif finfo.issym() and badlink(_lowerCAmelCase			,     _lowerCAmelCase		):
             logger.error(f'''Extraction of {finfo.name} is blocked: Symlink to {finfo.linkname}'''		)
         elif finfo.islnk() and badlink(_lowerCAmelCase			,     _lowerCAmelCase		):
             logger.error(f'''Extraction of {finfo.name} is blocked: Hard link to {finfo.linkname}'''		)
         else:
             yield finfo





 @staticmethod
 def 							_snake_case   (	_lowerCAmelCase			,     _lowerCAmelCase		)    ->							None:
     os.makedirs(_lowerCAmelCase			,     exist_ok=_lowerCAmelCase		)
     _lowerCAmelCase				=      tarfile.open(_lowerCAmelCase		)
     tar_file.extractall(_lowerCAmelCase			,     members=TarExtractor.safemembers(_lowerCAmelCase			,     _lowerCAmelCase		)		)
     tar_file.close()







class    lowerCAmelCase_		(		__magic_name__		):
 __lowerCamelCase						:							int         =					[B"\x1F\x8B"]




 @staticmethod
 def 							_snake_case   (	_lowerCAmelCase			,     _lowerCAmelCase		)    ->							None:
     with gzip.open(_lowerCAmelCase			,     "rb"		) as gzip_file:
         with open(_lowerCAmelCase			,     "wb"		) as extracted_file:
             shutil.copyfileobj(_lowerCAmelCase			,     _lowerCAmelCase		)







class    lowerCAmelCase_		(		__magic_name__		):
 __lowerCamelCase						:							int         =					[
     B"PK\x03\x04",
     B"PK\x05\x06",  # empty archive
     B"PK\x07\x08",  # spanned archive
 ]




 @classmethod
 def 							_snake_case   (	cls			,     _lowerCAmelCase			,     _lowerCAmelCase = b""		)    ->							bool:
     if super().is_extractable(_lowerCAmelCase			,     magic_number=_lowerCAmelCase		):
         return True
     try:
         # Alternative version of zipfile.is_zipfile that has less false positives, but misses executable zip archives.
         # From: https://github.com/python/cpython/pull/5053
         from zipfile import (
             _CD_SIGNATURE,
             _ECD_DISK_NUMBER,
             _ECD_DISK_START,
             _ECD_ENTRIES_TOTAL,
             _ECD_OFFSET,
             _ECD_SIZE,
             _EndRecData,
             sizeCentralDir,
             stringCentralDir,
             structCentralDir,
         )

         with open(_lowerCAmelCase			,     "rb"		) as fp:
             _lowerCAmelCase				=      _EndRecData(_lowerCAmelCase		)
             if endrec:
                 if endrec[_ECD_ENTRIES_TOTAL] == 0 and endrec[_ECD_SIZE] == 0 and endrec[_ECD_OFFSET] == 0:
                     return True  # Empty zipfiles are still zipfiles
                 elif endrec[_ECD_DISK_NUMBER] == endrec[_ECD_DISK_START]:
                     fp.seek(endrec[_ECD_OFFSET]		)  # Central directory is on the same disk
                     if fp.tell() == endrec[_ECD_OFFSET] and endrec[_ECD_SIZE] >= sizeCentralDir:
                         _lowerCAmelCase				=      fp.read(_lowerCAmelCase		)  # CD is where we expect it to be
                         if len(_lowerCAmelCase		) == sizeCentralDir:
                             _lowerCAmelCase				=      struct.unpack(_lowerCAmelCase			,     _lowerCAmelCase		)  # CD is the right size
                             if centdir[_CD_SIGNATURE] == stringCentralDir:
                                 return True  # First central directory entry  has correct magic number
         return False
     except Exception:  # catch all errors in case future python versions change the zipfile internals
         return False





 @staticmethod
 def 							_snake_case   (	_lowerCAmelCase			,     _lowerCAmelCase		)    ->							None:
     os.makedirs(_lowerCAmelCase			,     exist_ok=_lowerCAmelCase		)
     with zipfile.ZipFile(_lowerCAmelCase			,     "r"		) as zip_file:
         zip_file.extractall(_lowerCAmelCase		)
         zip_file.close()







class    lowerCAmelCase_		(		__magic_name__		):
 __lowerCamelCase						:							List[str]         =					[B"\xFD\x37\x7A\x58\x5A\x00"]




 @staticmethod
 def 							_snake_case   (	_lowerCAmelCase			,     _lowerCAmelCase		)    ->							None:
     with lzma.open(_lowerCAmelCase		) as compressed_file:
         with open(_lowerCAmelCase			,     "wb"		) as extracted_file:
             shutil.copyfileobj(_lowerCAmelCase			,     _lowerCAmelCase		)







class    lowerCAmelCase_		(		__magic_name__		):
 __lowerCamelCase						:							Tuple         =					[B"Rar!\x1a\x07\x00", B"Rar!\x1a\x07\x01\x00"]  # RAR_ID  # RAR5_ID




 @staticmethod
 def 							_snake_case   (	_lowerCAmelCase			,     _lowerCAmelCase		)    ->							None:
     if not config.RARFILE_AVAILABLE:
         raise ImportError("Please pip install rarfile"		)
     import rarfile

     os.makedirs(_lowerCAmelCase			,     exist_ok=_lowerCAmelCase		)
     _lowerCAmelCase				=      rarfile.RarFile(_lowerCAmelCase		)
     rf.extractall(_lowerCAmelCase		)
     rf.close()







class    lowerCAmelCase_		(		__magic_name__		):
 __lowerCamelCase						:							Tuple         =					[B"\x28\xb5\x2F\xFD"]




 @staticmethod
 def 							_snake_case   (	_lowerCAmelCase			,     _lowerCAmelCase		)    ->							None:
     if not config.ZSTANDARD_AVAILABLE:
         raise ImportError("Please pip install zstandard"		)
     import zstandard as zstd

     _lowerCAmelCase				=      zstd.ZstdDecompressor()
     with open(_lowerCAmelCase			,     "rb"		) as ifh, open(_lowerCAmelCase			,     "wb"		) as ofh:
         dctx.copy_stream(_lowerCAmelCase			,     _lowerCAmelCase		)







class    lowerCAmelCase_		(		__magic_name__		):
 __lowerCamelCase						:							List[Any]         =					[B"\x42\x5A\x68"]




 @staticmethod
 def 							_snake_case   (	_lowerCAmelCase			,     _lowerCAmelCase		)    ->							None:
     with bza.open(_lowerCAmelCase			,     "rb"		) as compressed_file:
         with open(_lowerCAmelCase			,     "wb"		) as extracted_file:
             shutil.copyfileobj(_lowerCAmelCase			,     _lowerCAmelCase		)







class    lowerCAmelCase_		(		__magic_name__		):
 __lowerCamelCase						:							int         =					[B"\x37\x7A\xBC\xAF\x27\x1C"]




 @staticmethod
 def 							_snake_case   (	_lowerCAmelCase			,     _lowerCAmelCase		)    ->							None:
     if not config.PY7ZR_AVAILABLE:
         raise ImportError("Please pip install py7zr"		)
     import pyazr

     os.makedirs(_lowerCAmelCase			,     exist_ok=_lowerCAmelCase		)
     with pyazr.SevenZipFile(_lowerCAmelCase			,     "r"		) as archive:
         archive.extractall(_lowerCAmelCase		)







class    lowerCAmelCase_		(		__magic_name__		):
 __lowerCamelCase						:							List[Any]         =					[B"\x04\x22\x4D\x18"]




 @staticmethod
 def 							_snake_case   (	_lowerCAmelCase			,     _lowerCAmelCase		)    ->							None:
     if not config.LZ4_AVAILABLE:
         raise ImportError("Please pip install lz4"		)
     import lza.frame

     with lza.frame.open(_lowerCAmelCase			,     "rb"		) as compressed_file:
         with open(_lowerCAmelCase			,     "wb"		) as extracted_file:
             shutil.copyfileobj(_lowerCAmelCase			,     _lowerCAmelCase		)







class    lowerCAmelCase_		:
 #  Put zip file to the last, b/c it is possible wrongly detected as zip (I guess it means: as tar or gzip)
 __lowerCamelCase						:							Dict[str, Type[BaseExtractor]]         =					{
     "tar": TarExtractor,
     "gzip": GzipExtractor,
     "zip": ZipExtractor,
     "xz": XzExtractor,
     "rar": RarExtractor,
     "zstd": ZstdExtractor,
     "bz2": BzipaExtractor,
     "7z": SevenZipExtractor,  # <Added version="2.4.0"/>
     "lz4": LzaExtractor,  # <Added version="2.4.0"/>
 }




 @classmethod
 def 							_snake_case   (	cls		)    ->							List[Any]:
     return max(
         len(_lowerCAmelCase		)
         for extractor in cls.extractors.values()
         if issubclass(_lowerCAmelCase			,     _lowerCAmelCase		)
         for extractor_magic_number in extractor.magic_numbers		)




 @staticmethod
 def 							_snake_case   (	_lowerCAmelCase			,     _lowerCAmelCase		)    ->							Union[str, Any]:
     try:
         return MagicNumberBaseExtractor.read_magic_number(_lowerCAmelCase			,     magic_number_length=_lowerCAmelCase		)
     except OSError:
         return b""




 @classmethod
 def 							_snake_case   (	cls			,     _lowerCAmelCase			,     _lowerCAmelCase = False		)    ->							bool:
     warnings.warn(
         "Method 'is_extractable' was deprecated in version 2.4.0 and will be removed in 3.0.0. "
         "Use 'infer_extractor_format' instead."			,     category=_lowerCAmelCase			,     )
     _lowerCAmelCase				=      cls.infer_extractor_format(_lowerCAmelCase		)
     if extractor_format:
         return True if not return_extractor else (True, cls.extractors[extractor_format])
     return False if not return_extractor else (False, None)




 @classmethod
 def 							_snake_case   (	cls			,     _lowerCAmelCase		)    ->							str:  # <Added version="2.4.0"/>
     _lowerCAmelCase				=      cls._get_magic_number_max_length()
     _lowerCAmelCase				=      cls._read_magic_number(_lowerCAmelCase			,     _lowerCAmelCase		)
     for extractor_format, extractor in cls.extractors.items():
         if extractor.is_extractable(_lowerCAmelCase			,     magic_number=_lowerCAmelCase		):
             return extractor_format





 @classmethod
 def 							_snake_case   (	cls			,     _lowerCAmelCase			,     _lowerCAmelCase			,     _lowerCAmelCase = None			,     _lowerCAmelCase = "deprecated"			,     )    ->							None:
     os.makedirs(os.path.dirname(_lowerCAmelCase		)			,     exist_ok=_lowerCAmelCase		)
     # Prevent parallel extractions
     _lowerCAmelCase				=      str(Path(_lowerCAmelCase		).with_suffix(".lock"		)		)
     with FileLock(_lowerCAmelCase		):
         shutil.rmtree(_lowerCAmelCase			,     ignore_errors=_lowerCAmelCase		)
         if extractor_format or extractor != "deprecated":
             if extractor != "deprecated" or not isinstance(_lowerCAmelCase			,     _lowerCAmelCase		):  # passed as positional arg
                 warnings.warn(
                     "Parameter 'extractor' was deprecated in version 2.4.0 and will be removed in 3.0.0. "
                     "Use 'extractor_format' instead."			,     category=_lowerCAmelCase			,     )
                 _lowerCAmelCase				=      extractor if extractor != "deprecated" else extractor_format
             else:
                 _lowerCAmelCase				=      cls.extractors[extractor_format]
             return extractor.extract(_lowerCAmelCase			,     _lowerCAmelCase		)
         else:
             warnings.warn(
                 "Parameter 'extractor_format' was made required in version 2.4.0 and not passing it will raise an "
                 "exception in 3.0.0."			,     category=_lowerCAmelCase			,     )
             for extractor in cls.extractors.values():
                 if extractor.is_extractable(_lowerCAmelCase		):
                     return extractor.extract(_lowerCAmelCase			,     _lowerCAmelCase		)









'''simple docstring'''


from math import isqrt, loga


def 	__a(SCREAMING_SNAKE_CASE_  :					int    ):



    '''simple docstring'''





    _lowerCAmelCase				=      [True] * max_number
    for i in range(2		,       isqrt(max_number - 1    ) + 1    ):
        if is_prime[i]:
            for j in range(i**2		,       SCREAMING_SNAKE_CASE_		,       SCREAMING_SNAKE_CASE_    ):
                _lowerCAmelCase				=      False

    return [i for i in range(2		,       SCREAMING_SNAKE_CASE_    ) if is_prime[i]]


def 	__a(SCREAMING_SNAKE_CASE_  :					int = 800800		,       SCREAMING_SNAKE_CASE_  :					int = 800800    ):



    '''simple docstring'''





    _lowerCAmelCase				=      degree * loga(SCREAMING_SNAKE_CASE_    )
    _lowerCAmelCase				=      int(SCREAMING_SNAKE_CASE_    )
    _lowerCAmelCase				=      calculate_prime_numbers(SCREAMING_SNAKE_CASE_    )

    _lowerCAmelCase				=      0
    _lowerCAmelCase				=      0
    _lowerCAmelCase				=      len(SCREAMING_SNAKE_CASE_    ) - 1
    while left < right:
        while (
            prime_numbers[right] * loga(prime_numbers[left]    )
            + prime_numbers[left] * loga(prime_numbers[right]    )
            > upper_bound
        ):
            right -= 1
        hybrid_integers_count += right - left
        left += 1

    return hybrid_integers_count


if __name__ == "__main__":
       print(f'''{solution() = }''')


