
import pytest

from datasets import Dataset, DatasetDict, Features, NamedSplit, Value
from datasets.io.text import TextDatasetReader

from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases
def 							SCREAMING_SNAKE_CASE_	(					UpperCAmelCase_	:     int			,							UpperCAmelCase_	:     Optional[int]				)			->						Optional[Any]:
       assert isinstance(UpperCAmelCase_			,							UpperCAmelCase_				)
       assert dataset.num_rows == 4
       assert dataset.num_columns == 1
       assert dataset.column_names == ["text"]
       for feature, expected_dtype in expected_features.items():
              assert dataset.features[feature].dtype == expected_dtype
@pytest.mark.parametrize('''keep_in_memory'''			,							[False, True]				)
def 							SCREAMING_SNAKE_CASE_	(					UpperCAmelCase_	:     Optional[Any]			,							UpperCAmelCase_	:     int			,							UpperCAmelCase_	:     Optional[int]				)			->						Optional[int]:
       SCREAMING_SNAKE_CASE_							:				int		=tmp_path / '''cache'''
       SCREAMING_SNAKE_CASE_							:				str		={'''text''': '''string'''}
       with assert_arrow_memory_increases() if keep_in_memory else assert_arrow_memory_doesnt_increase():
              SCREAMING_SNAKE_CASE_							:				List[Any]		=TextDatasetReader(UpperCAmelCase_			,							cache_dir=UpperCAmelCase_			,							keep_in_memory=UpperCAmelCase_				).read()
       _check_text_dataset(UpperCAmelCase_			,							UpperCAmelCase_				)
@pytest.mark.parametrize(
    '''features'''			,							[
        None,
        {'''text''': '''string'''},
        {'''text''': '''int32'''},
        {'''text''': '''float32'''},
    ]			,							)
def 							SCREAMING_SNAKE_CASE_	(					UpperCAmelCase_	:     List[str]			,							UpperCAmelCase_	:     Dict			,							UpperCAmelCase_	:     List[Any]				)			->						str:
       SCREAMING_SNAKE_CASE_							:				Any		=tmp_path / '''cache'''
       SCREAMING_SNAKE_CASE_							:				Any		={'''text''': '''string'''}
       SCREAMING_SNAKE_CASE_							:				Dict		=features.copy() if features else default_expected_features
       SCREAMING_SNAKE_CASE_							:				Optional[Any]		=(
           Features({feature: Value(UpperCAmelCase_				) for feature, dtype in features.items()}				) if features is not None else None
       )
       SCREAMING_SNAKE_CASE_							:				Union[str, Any]		=TextDatasetReader(UpperCAmelCase_			,							features=UpperCAmelCase_			,							cache_dir=UpperCAmelCase_				).read()
       _check_text_dataset(UpperCAmelCase_			,							UpperCAmelCase_				)
@pytest.mark.parametrize('''split'''			,							[None, NamedSplit('''train'''				), '''train''', '''test''']				)
def 							SCREAMING_SNAKE_CASE_	(					UpperCAmelCase_	:     List[Any]			,							UpperCAmelCase_	:     Union[str, Any]			,							UpperCAmelCase_	:     List[str]				)			->						int:
       SCREAMING_SNAKE_CASE_							:				List[Any]		=tmp_path / '''cache'''
       SCREAMING_SNAKE_CASE_							:				List[Any]		={'''text''': '''string'''}
       SCREAMING_SNAKE_CASE_							:				Tuple		=TextDatasetReader(UpperCAmelCase_			,							cache_dir=UpperCAmelCase_			,							split=UpperCAmelCase_				).read()
       _check_text_dataset(UpperCAmelCase_			,							UpperCAmelCase_				)
       assert dataset.split == split if split else "train"
@pytest.mark.parametrize('''path_type'''			,							[str, list]				)
def 							SCREAMING_SNAKE_CASE_	(					UpperCAmelCase_	:     Union[str, Any]			,							UpperCAmelCase_	:     Optional[int]			,							UpperCAmelCase_	:     Union[str, Any]				)			->						Optional[Any]:
       if issubclass(UpperCAmelCase_			,							UpperCAmelCase_				):
              SCREAMING_SNAKE_CASE_							:				Optional[Any]		=text_path
       elif issubclass(UpperCAmelCase_			,							UpperCAmelCase_				):
              SCREAMING_SNAKE_CASE_							:				Optional[Any]		=[text_path]
       SCREAMING_SNAKE_CASE_							:				Optional[Any]		=tmp_path / '''cache'''
       SCREAMING_SNAKE_CASE_							:				Optional[Any]		={'''text''': '''string'''}
       SCREAMING_SNAKE_CASE_							:				Dict		=TextDatasetReader(UpperCAmelCase_			,							cache_dir=UpperCAmelCase_				).read()
       _check_text_dataset(UpperCAmelCase_			,							UpperCAmelCase_				)
def 							SCREAMING_SNAKE_CASE_	(					UpperCAmelCase_	:     Optional[int]			,							UpperCAmelCase_	:     int			,							UpperCAmelCase_	:     Union[str, Any]=("train",)				)			->						int:
       assert isinstance(UpperCAmelCase_			,							UpperCAmelCase_				)
       for split in splits:
              SCREAMING_SNAKE_CASE_							:				List[Any]		=dataset_dict[split]
              assert dataset.num_rows == 4
              assert dataset.num_columns == 1
              assert dataset.column_names == ["text"]
              for feature, expected_dtype in expected_features.items():
                     assert dataset.features[feature].dtype == expected_dtype
@pytest.mark.parametrize('''keep_in_memory'''			,							[False, True]				)
def 							SCREAMING_SNAKE_CASE_	(					UpperCAmelCase_	:     Any			,							UpperCAmelCase_	:     Union[str, Any]			,							UpperCAmelCase_	:     Optional[int]				)			->						Tuple:
       SCREAMING_SNAKE_CASE_							:				Tuple		=tmp_path / '''cache'''
       SCREAMING_SNAKE_CASE_							:				Dict		={'''text''': '''string'''}
       with assert_arrow_memory_increases() if keep_in_memory else assert_arrow_memory_doesnt_increase():
              SCREAMING_SNAKE_CASE_							:				Dict		=TextDatasetReader({'''train''': text_path}			,							cache_dir=UpperCAmelCase_			,							keep_in_memory=UpperCAmelCase_				).read()
       _check_text_datasetdict(UpperCAmelCase_			,							UpperCAmelCase_				)
@pytest.mark.parametrize(
    '''features'''			,							[
        None,
        {'''text''': '''string'''},
        {'''text''': '''int32'''},
        {'''text''': '''float32'''},
    ]			,							)
def 							SCREAMING_SNAKE_CASE_	(					UpperCAmelCase_	:     List[str]			,							UpperCAmelCase_	:     Optional[int]			,							UpperCAmelCase_	:     Optional[int]				)			->						Tuple:
       SCREAMING_SNAKE_CASE_							:				List[str]		=tmp_path / '''cache'''
       # CSV file loses col_1 string dtype information: default now is "int64" instead of "string"
       SCREAMING_SNAKE_CASE_							:				Optional[int]		={'''text''': '''string'''}
       SCREAMING_SNAKE_CASE_							:				Any		=features.copy() if features else default_expected_features
       SCREAMING_SNAKE_CASE_							:				Optional[int]		=(
           Features({feature: Value(UpperCAmelCase_				) for feature, dtype in features.items()}				) if features is not None else None
       )
       SCREAMING_SNAKE_CASE_							:				Tuple		=TextDatasetReader({'''train''': text_path}			,							features=UpperCAmelCase_			,							cache_dir=UpperCAmelCase_				).read()
       _check_text_datasetdict(UpperCAmelCase_			,							UpperCAmelCase_				)

@pytest.mark.parametrize('''split'''			,							[None, NamedSplit('''train'''				), '''train''', '''test''']				)
def 							SCREAMING_SNAKE_CASE_	(					UpperCAmelCase_	:     int			,							UpperCAmelCase_	:     str			,							UpperCAmelCase_	:     Dict				)			->						Optional[Any]:
       if split:
              SCREAMING_SNAKE_CASE_							:				List[str]		={split: text_path}
       else:
              SCREAMING_SNAKE_CASE_							:				List[Any]		='''train'''
              SCREAMING_SNAKE_CASE_							:				Union[str, Any]		={'''train''': text_path, '''test''': text_path}
       SCREAMING_SNAKE_CASE_							:				Union[str, Any]		=tmp_path / '''cache'''
       SCREAMING_SNAKE_CASE_							:				List[str]		={'''text''': '''string'''}
       SCREAMING_SNAKE_CASE_							:				Union[str, Any]		=TextDatasetReader(UpperCAmelCase_			,							cache_dir=UpperCAmelCase_				).read()
       _check_text_datasetdict(UpperCAmelCase_			,							UpperCAmelCase_			,							splits=list(path.keys()				)				)
       assert all(dataset[split].split == split for split in path.keys()				)


def 							SCREAMING_SNAKE_CASE_	(					UpperCAmelCase_	:     int = 1_0_0_0				)			->						int:
       SCREAMING_SNAKE_CASE_							:				int		=2**power
       SCREAMING_SNAKE_CASE_							:				Tuple		=0
       while n:
              SCREAMING_SNAKE_CASE_	,     SCREAMING_SNAKE_CASE_							:				Union[str, Any]		=r + n % 1_0, n // 1_0
       return r


if __name__ == "__main__":
 print(solution(int(str(input()).strip())))
