


"""simple docstring"""







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      UpperCAmelCase__ (lowerCAmelCase_						,		lowerCAmelCase_     ):




					'''simple docstring'''


					assert isinstance(lowerCAmelCase_						,		lowerCAmelCase_     )
					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      UpperCAmelCase__ (lowerCAmelCase_						,		lowerCAmelCase_						,		lowerCAmelCase_     ):




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE		     =       tmp_path / "cache"
					__SCREAMING_SNAKE_CASE		     =       {"text": "string"}
					with assert_arrow_memory_increases() if keep_in_memory else assert_arrow_memory_doesnt_increase():
										__SCREAMING_SNAKE_CASE		     =       TextDatasetReader(lowerCAmelCase_						,		cache_dir=lowerCAmelCase_						,		keep_in_memory=lowerCAmelCase_     ).read()
					_check_text_dataset(lowerCAmelCase_						,		lowerCAmelCase_     )




@pytest.mark.parametrize(
    "features"						,		[
        None,
        {"text": "string"},
        {"text": "int32"},
        {"text": "float32"},
    ]						,		)
def      UpperCAmelCase__ (lowerCAmelCase_						,		lowerCAmelCase_						,		lowerCAmelCase_     ):




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE		     =       tmp_path / "cache"
					__SCREAMING_SNAKE_CASE		     =       {"text": "string"}
					__SCREAMING_SNAKE_CASE		     =       features.copy() if features else default_expected_features
					__SCREAMING_SNAKE_CASE		     =       (
					    Features({feature: Value(lowerCAmelCase_     ) for feature, dtype in features.items()}     ) if features is not None else None
					)
					__SCREAMING_SNAKE_CASE		     =       TextDatasetReader(lowerCAmelCase_						,		features=lowerCAmelCase_						,		cache_dir=lowerCAmelCase_     ).read()
					_check_text_dataset(lowerCAmelCase_						,		lowerCAmelCase_     )




@pytest.mark.parametrize("split"						,		[None, NamedSplit("train"     ), "train", "test"]     )
def      UpperCAmelCase__ (lowerCAmelCase_						,		lowerCAmelCase_						,		lowerCAmelCase_     ):




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE		     =       tmp_path / "cache"
					__SCREAMING_SNAKE_CASE		     =       {"text": "string"}
					__SCREAMING_SNAKE_CASE		     =       TextDatasetReader(lowerCAmelCase_						,		cache_dir=lowerCAmelCase_						,		split=lowerCAmelCase_     ).read()
					_check_text_dataset(lowerCAmelCase_						,		lowerCAmelCase_     )
					assert dataset.split == split if split else "train"




@pytest.mark.parametrize("path_type"						,		[str, list]     )
def      UpperCAmelCase__ (lowerCAmelCase_						,		lowerCAmelCase_						,		lowerCAmelCase_     ):




					'''simple docstring'''


					if issubclass(lowerCAmelCase_						,		lowerCAmelCase_     ):
										__SCREAMING_SNAKE_CASE		     =       text_path
					elif issubclass(lowerCAmelCase_						,		lowerCAmelCase_     ):
										__SCREAMING_SNAKE_CASE		     =       [text_path]
					__SCREAMING_SNAKE_CASE		     =       tmp_path / "cache"
					__SCREAMING_SNAKE_CASE		     =       {"text": "string"}
					__SCREAMING_SNAKE_CASE		     =       TextDatasetReader(lowerCAmelCase_						,		cache_dir=lowerCAmelCase_     ).read()
					_check_text_dataset(lowerCAmelCase_						,		lowerCAmelCase_     )




def      UpperCAmelCase__ (lowerCAmelCase_						,		lowerCAmelCase_						,		lowerCAmelCase_=("train",)     ):




					'''simple docstring'''


					assert isinstance(lowerCAmelCase_						,		lowerCAmelCase_     )
					for split in splits:
										__SCREAMING_SNAKE_CASE		     =       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      UpperCAmelCase__ (lowerCAmelCase_						,		lowerCAmelCase_						,		lowerCAmelCase_     ):




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE		     =       tmp_path / "cache"
					__SCREAMING_SNAKE_CASE		     =       {"text": "string"}
					with assert_arrow_memory_increases() if keep_in_memory else assert_arrow_memory_doesnt_increase():
										__SCREAMING_SNAKE_CASE		     =       TextDatasetReader({"train": text_path}						,		cache_dir=lowerCAmelCase_						,		keep_in_memory=lowerCAmelCase_     ).read()
					_check_text_datasetdict(lowerCAmelCase_						,		lowerCAmelCase_     )




@pytest.mark.parametrize(
    "features"						,		[
        None,
        {"text": "string"},
        {"text": "int32"},
        {"text": "float32"},
    ]						,		)
def      UpperCAmelCase__ (lowerCAmelCase_						,		lowerCAmelCase_						,		lowerCAmelCase_     ):




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE		     =       tmp_path / "cache"
					# CSV file loses col_1 string dtype information: default now is "int64" instead of "string"
					__SCREAMING_SNAKE_CASE		     =       {"text": "string"}
					__SCREAMING_SNAKE_CASE		     =       features.copy() if features else default_expected_features
					__SCREAMING_SNAKE_CASE		     =       (
					    Features({feature: Value(lowerCAmelCase_     ) for feature, dtype in features.items()}     ) if features is not None else None
					)
					__SCREAMING_SNAKE_CASE		     =       TextDatasetReader({"train": text_path}						,		features=lowerCAmelCase_						,		cache_dir=lowerCAmelCase_     ).read()
					_check_text_datasetdict(lowerCAmelCase_						,		lowerCAmelCase_     )




@pytest.mark.parametrize("split"						,		[None, NamedSplit("train"     ), "train", "test"]     )
def      UpperCAmelCase__ (lowerCAmelCase_						,		lowerCAmelCase_						,		lowerCAmelCase_     ):




					'''simple docstring'''


					if split:
										__SCREAMING_SNAKE_CASE		     =       {split: text_path}
					else:
										__SCREAMING_SNAKE_CASE		     =       "train"
										__SCREAMING_SNAKE_CASE		     =       {"train": text_path, "test": text_path}
					__SCREAMING_SNAKE_CASE		     =       tmp_path / "cache"
					__SCREAMING_SNAKE_CASE		     =       {"text": "string"}
					__SCREAMING_SNAKE_CASE		     =       TextDatasetReader(lowerCAmelCase_						,		cache_dir=lowerCAmelCase_     ).read()
					_check_text_datasetdict(lowerCAmelCase_						,		lowerCAmelCase_						,		splits=list(path.keys()     )     )
					assert all(dataset[split].split == split for split in path.keys()     )




"""simple docstring"""







from __future__ import annotations




def      UpperCAmelCase__ (lowerCAmelCase_     ):




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE		     =       str(lowerCAmelCase_     )
					return n == n[::-1]




def      UpperCAmelCase__ (lowerCAmelCase_ = 100_0000     ):




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE		     =       0

					for i in range(1						,		lowerCAmelCase_     ):
										if is_palindrome(lowerCAmelCase_     ) and is_palindrome(bin(lowerCAmelCase_     ).split("b"     )[1]     ):
															total += i
					return total


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