'''simple docstring'''






import pyarrow.parquet as pq
import pytest

from datasets import Audio, Dataset, DatasetDict, Features, NamedSplit, Sequence, Value, config
from datasets.features.image import Image
from datasets.io.parquet import ParquetDatasetReader, ParquetDatasetWriter, get_writer_batch_size

from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases






def   __UpperCAmelCase     (    a_:			List[str],   a_:			Tuple				):
   assert isinstance(snake_case_,   snake_case_				)
   assert dataset.num_rows == 4
   assert dataset.num_columns == 3
   assert dataset.column_names == ["col_1", "col_2", "col_3"]
   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     (    a_:			int,   a_:			Optional[Any],   a_:			Optional[int]				):
   _UpperCAmelCase				:      List[Any]				=  tmp_path / '''cache'''
   _UpperCAmelCase				:      Dict				=  {'''col_1''': '''string''', '''col_2''': '''int64''', '''col_3''': '''float64'''}
   with assert_arrow_memory_increases() if keep_in_memory else assert_arrow_memory_doesnt_increase():
      _UpperCAmelCase				:      List[Any]				=  ParquetDatasetReader(snake_case_,   cache_dir=snake_case_,   keep_in_memory=snake_case_				).read()
   _check_parquet_dataset(snake_case_,   snake_case_				)






@pytest.mark.parametrize(
    "features",   [
        None,
        {"col_1": "string", "col_2": "int64", "col_3": "float64"},
        {"col_1": "string", "col_2": "string", "col_3": "string"},
        {"col_1": "int32", "col_2": "int32", "col_3": "int32"},
        {"col_1": "float32", "col_2": "float32", "col_3": "float32"},
    ],   )
def   __UpperCAmelCase     (    a_:			List[Any],   a_:			int,   a_:			int				):
   _UpperCAmelCase				:      List[Any]				=  tmp_path / '''cache'''
   _UpperCAmelCase				:      List[str]				=  {'''col_1''': '''string''', '''col_2''': '''int64''', '''col_3''': '''float64'''}
   _UpperCAmelCase				:      Tuple				=  features.copy() if features else default_expected_features
   _UpperCAmelCase				:      Dict				=  (
       Features({feature: Value(snake_case_				) for feature, dtype in features.items()}				) if features is not None else None
   )
   _UpperCAmelCase				:      Optional[int]				=  ParquetDatasetReader(snake_case_,   features=snake_case_,   cache_dir=snake_case_				).read()
   _check_parquet_dataset(snake_case_,   snake_case_				)






@pytest.mark.parametrize("split",   [None, NamedSplit("train"				), "train", "test"]				)
def   __UpperCAmelCase     (    a_:			List[str],   a_:			Union[str, Any],   a_:			List[Any]				):
   _UpperCAmelCase				:      Dict				=  tmp_path / '''cache'''
   _UpperCAmelCase				:      Union[str, Any]				=  {'''col_1''': '''string''', '''col_2''': '''int64''', '''col_3''': '''float64'''}
   _UpperCAmelCase				:      Union[str, Any]				=  ParquetDatasetReader(snake_case_,   cache_dir=snake_case_,   split=snake_case_				).read()
   _check_parquet_dataset(snake_case_,   snake_case_				)
   assert dataset.split == split if split else "train"






@pytest.mark.parametrize("path_type",   [str, list]				)
def   __UpperCAmelCase     (    a_:			Optional[Any],   a_:			str,   a_:			Any				):







   if issubclass(snake_case_,   snake_case_				):
      _UpperCAmelCase				:      Optional[Any]				=  parquet_path
   elif issubclass(snake_case_,   snake_case_				):
      _UpperCAmelCase				:      int				=  [parquet_path]
   _UpperCAmelCase				:      str				=  tmp_path / '''cache'''
   _UpperCAmelCase				:      Any				=  {'''col_1''': '''string''', '''col_2''': '''int64''', '''col_3''': '''float64'''}
   _UpperCAmelCase				:      int				=  ParquetDatasetReader(snake_case_,   cache_dir=snake_case_				).read()
   _check_parquet_dataset(snake_case_,   snake_case_				)






def   __UpperCAmelCase     (    a_:			Dict,   a_:			str,   a_:			str=("train",)				):
   assert isinstance(snake_case_,   snake_case_				)
   for split in splits:
      _UpperCAmelCase				:      int				=  dataset_dict[split]
      assert dataset.num_rows == 4
      assert dataset.num_columns == 3
      assert dataset.column_names == ["col_1", "col_2", "col_3"]
      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     (    a_:			Union[str, Any],   a_:			Any,   a_:			Dict				):
   _UpperCAmelCase				:      List[Any]				=  tmp_path / '''cache'''
   _UpperCAmelCase				:      Dict				=  {'''col_1''': '''string''', '''col_2''': '''int64''', '''col_3''': '''float64'''}
   with assert_arrow_memory_increases() if keep_in_memory else assert_arrow_memory_doesnt_increase():
      _UpperCAmelCase				:      Optional[int]				=  ParquetDatasetReader(
          {"train": parquet_path},   cache_dir=snake_case_,   keep_in_memory=snake_case_				).read()
   _check_parquet_datasetdict(snake_case_,   snake_case_				)






@pytest.mark.parametrize(
    "features",   [
        None,
        {"col_1": "string", "col_2": "int64", "col_3": "float64"},
        {"col_1": "string", "col_2": "string", "col_3": "string"},
        {"col_1": "int32", "col_2": "int32", "col_3": "int32"},
        {"col_1": "float32", "col_2": "float32", "col_3": "float32"},
    ],   )
def   __UpperCAmelCase     (    a_:			Optional[Any],   a_:			List[Any],   a_:			Optional[int]				):
   _UpperCAmelCase				:      List[Any]				=  tmp_path / '''cache'''
   _UpperCAmelCase				:      Optional[Any]				=  {'''col_1''': '''string''', '''col_2''': '''int64''', '''col_3''': '''float64'''}
   _UpperCAmelCase				:      List[Any]				=  features.copy() if features else default_expected_features
   _UpperCAmelCase				:      int				=  (
       Features({feature: Value(snake_case_				) for feature, dtype in features.items()}				) if features is not None else None
   )
   _UpperCAmelCase				:      Tuple				=  ParquetDatasetReader({"train": parquet_path},   features=snake_case_,   cache_dir=snake_case_				).read()
   _check_parquet_datasetdict(snake_case_,   snake_case_				)






@pytest.mark.parametrize("split",   [None, NamedSplit("train"				), "train", "test"]				)
def   __UpperCAmelCase     (    a_:			int,   a_:			int,   a_:			List[str]				):







   if split:
      _UpperCAmelCase				:      Tuple				=  {split: parquet_path}
   else:
      _UpperCAmelCase				:      str				=  '''train'''
      _UpperCAmelCase				:      Optional[int]				=  {'''train''': parquet_path, '''test''': parquet_path}
   _UpperCAmelCase				:      Tuple				=  tmp_path / '''cache'''
   _UpperCAmelCase				:      List[Any]				=  {'''col_1''': '''string''', '''col_2''': '''int64''', '''col_3''': '''float64'''}
   _UpperCAmelCase				:      Optional[int]				=  ParquetDatasetReader(snake_case_,   cache_dir=snake_case_				).read()
   _check_parquet_datasetdict(snake_case_,   snake_case_,   splits=list(path.keys()				)				)
   assert all(dataset[split].split == split for split in path.keys()				)






def   __UpperCAmelCase     (    a_:			Tuple,   a_:			int				):
   _UpperCAmelCase				:      List[Any]				=  ParquetDatasetWriter(snake_case_,   tmp_path / "foo.parquet"				)
   assert writer.write() > 0
   _UpperCAmelCase				:      Any				=  pq.ParquetFile(tmp_path / "foo.parquet"				)
   _UpperCAmelCase				:      Union[str, Any]				=  pf.read()
   assert dataset.data.table == output_table






def   __UpperCAmelCase     (    a_:			List[str],   a_:			Optional[int]				):
   _UpperCAmelCase				:      Any				=  str(shared_datadir / "test_image_rgb.jpg"				)
   _UpperCAmelCase				:      int				=  {'''image''': [image_path]}
   _UpperCAmelCase				:      str				=  Features({"image": Image()}				)
   _UpperCAmelCase				:      List[Any]				=  Dataset.from_dict(snake_case_,   features=snake_case_				)
   _UpperCAmelCase				:      Tuple				=  ParquetDatasetWriter(snake_case_,   tmp_path / "foo.parquet"				)
   assert writer.write() > 0

   _UpperCAmelCase				:      List[str]				=  Dataset.from_parquet(str(tmp_path / "foo.parquet"				)				)
   assert dataset.features == reloaded_dataset.features

   _UpperCAmelCase				:      List[Any]				=  ParquetDatasetReader(str(tmp_path / "foo.parquet"				),   streaming=snake_case_				).read()
   assert dataset.features == reloaded_iterable_dataset.features






@pytest.mark.parametrize(
    "feature, expected",   [
        (Features({"foo": Value("int32"				)}				), None),
        (Features({"image": Image(), "foo": Value("int32"				)}				), config.PARQUET_ROW_GROUP_SIZE_FOR_IMAGE_DATASETS),
        (Features({"nested": Sequence(Audio()				)}				), config.PARQUET_ROW_GROUP_SIZE_FOR_AUDIO_DATASETS),
    ],   )
def   __UpperCAmelCase     (    a_:			List[str],   a_:			List[str]				):
   assert get_writer_batch_size(snake_case_				) == expected






"""simple docstring"""



from collections import defaultdict
from math import gcd







def 						__lowercase	(  snake_case_    :    int = 1500000		)  ->int:



    '''simple docstring'''







    __A       :		defaultdict							=	defaultdict(snake_case_		)
    __A       :		Any							=	2
    while 2 * euclid_m * (euclid_m + 1) <= limit:
        for euclid_n in range((euclid_m % 2) + 1							,snake_case_							,2		):
            if gcd(snake_case_							,snake_case_		) > 1:
                continue
            __A       :		List[Any]							=	2 * euclid_m * (euclid_m + euclid_n)
            for perimeter in range(snake_case_							,limit + 1							,snake_case_		):
                frequencies[perimeter] += 1
        euclid_m += 1
    return sum(1 for frequency in frequencies.values() if frequency == 1		)


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




