


import itertools
from dataclasses import dataclass
from typing import Optional

import pandas as pd
import pyarrow as pa

import datasets
from datasets.table import table_cast




@dataclass
class    UpperCAmelCase					(       datasets.BuilderConfig    ):
			lowercase						= None




class    UpperCAmelCase					(       datasets.ArrowBasedBuilder    ):
			lowercase						= PandasConfig




			def   lowerCamelCase_					(						self							:		int						):







						"""simple docstring"""







						return datasets.DatasetInfo(features=self.config.features						)




			def   lowerCamelCase_					(						self							:		Optional[Any]       ,       __magic_name__							:		Optional[Any]						):







						"""simple docstring"""







						if not self.config.data_files:
									raise ValueError(F'At least one data file must be specified, but got data_files={self.config.data_files}'						)
						UpperCamelCase         =					dl_manager.download_and_extract(self.config.data_files						)
						if isinstance(__magic_name__       ,       (str, list, tuple)						):
									UpperCamelCase         =					data_files
									if isinstance(__magic_name__       ,       __magic_name__						):
												UpperCamelCase         =					[files]
									# Use `dl_manager.iter_files` to skip hidden files in an extracted archive
									UpperCamelCase         =					[dl_manager.iter_files(__magic_name__						) for file in files]
									return [datasets.SplitGenerator(name=datasets.Split.TRAIN       ,       gen_kwargs={"""files""": files}						)]
						UpperCamelCase         =					[]
						for split_name, files in data_files.items():
									if isinstance(__magic_name__       ,       __magic_name__						):
												UpperCamelCase         =					[files]
									# Use `dl_manager.iter_files` to skip hidden files in an extracted archive
									UpperCamelCase         =					[dl_manager.iter_files(__magic_name__						) for file in files]
									splits.append(datasets.SplitGenerator(name=__magic_name__       ,       gen_kwargs={"""files""": files}						)						)
						return splits




			def   lowerCamelCase_					(						self							:		Union[str, Any]       ,       __magic_name__							:		pa.Table						):







						"""simple docstring"""







						if self.config.features is not None:
									# more expensive cast to support nested features with keys in a different order
									# allows str <-> int/float or str to Audio for example
									UpperCamelCase         =					table_cast(__magic_name__       ,       self.config.features.arrow_schema						)
						return pa_table





			def   lowerCamelCase_					(						self							:		Union[str, Any]       ,       __magic_name__							:		Tuple						):







						"""simple docstring"""







						for i, file in enumerate(itertools.chain.from_iterable(__magic_name__						)						):
									with open(__magic_name__       ,       """rb"""						) as f:
												UpperCamelCase         =					pa.Table.from_pandas(pd.read_pickle(__magic_name__						)						)
												yield i, self._cast_table(__magic_name__						)








import math






def 							_lowercase    (		SCREAMING_SNAKE_CASE_   :		int	):





			"""simple docstring"""




			UpperCamelCase         =					[True] * n
			UpperCamelCase         =					False
			UpperCamelCase         =					False
			UpperCamelCase         =					True

			for i in range(3       ,  int(n**0.5 + 1	)       ,  2	):
						UpperCamelCase         =					i * 2
						while index < n:
									UpperCamelCase         =					False
									UpperCamelCase         =					index + i

			UpperCamelCase         =					[2]

			for i in range(3       ,  SCREAMING_SNAKE_CASE_       ,  2	):
						if is_prime[i]:
									primes.append(SCREAMING_SNAKE_CASE_	)

			return primes






def 							_lowercase    (		SCREAMING_SNAKE_CASE_   :		int = 999_966_663_333	):





			"""simple docstring"""




			UpperCamelCase         =					math.floor(math.sqrt(SCREAMING_SNAKE_CASE_	)	) + 100
			UpperCamelCase         =					prime_sieve(SCREAMING_SNAKE_CASE_	)

			UpperCamelCase         =					0
			UpperCamelCase         =					0
			UpperCamelCase         =					primes[prime_index]

			while (last_prime**2) <= limit:
						UpperCamelCase         =					primes[prime_index + 1]

						UpperCamelCase         =					last_prime**2
						UpperCamelCase         =					next_prime**2

						# Get numbers divisible by lps(current)
						UpperCamelCase         =					lower_bound + last_prime
						while upper_bound > current <= limit:
									matches_sum += current
									current += last_prime

						# Reset the upper_bound
						while (upper_bound - next_prime) > limit:
									upper_bound -= next_prime

						# Add the numbers divisible by ups(current)
						UpperCamelCase         =					upper_bound - next_prime
						while current > lower_bound:
									matches_sum += current
									current -= next_prime

						# Remove the numbers divisible by both ups and lps
						UpperCamelCase         =					0
						while upper_bound > current <= limit:
									if current <= lower_bound:
												# Increment the current number
												current += last_prime * next_prime
												continue

									if current > limit:
												break

									# Remove twice since it was added by both ups and lps
									matches_sum -= current * 2

									# Increment the current number
									current += last_prime * next_prime

						# Setup for next pair
						UpperCamelCase         =					next_prime
						prime_index += 1

			return matches_sum


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




