

import math



def     lowerCAmelCase__							(		SCREAMING_SNAKE_CASE_:							int					)	->					Any:




				'''simple docstring'''





				A__						=	[True] * n
				A__						=	False
				A__						=	False
				A__						=	True

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

				A__						=	[2]

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

				return primes



def     lowerCAmelCase__							(		SCREAMING_SNAKE_CASE_:							Optional[Any] = 9_9_9_9_6_6_6_6_3_3_3_3					)	->					Union[str, Any]:




				'''simple docstring'''





				A__						=	math.floor(math.sqrt(UpperCamelCase__					)					) + 1_0_0
				A__						=	prime_sieve(UpperCamelCase__					)

				A__						=	0
				A__						=	0
				A__						=	primes[prime_index]

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

								A__						=	last_prime**2
								A__						=	next_prime**2

								# Get numbers divisible by lps(current)
								A__						=	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)
								A__						=	upper_bound - next_prime
								while current > lower_bound:
												matches_sum += current
												current -= next_prime

								# Remove the numbers divisible by both ups and lps
								A__						=	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
								A__						=	next_prime
								prime_index += 1

				return matches_sum


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




import json
import os
import tempfile

import datasets
from utils import generate_example_dataset, get_duration


_UpperCAmelCase		:   Optional[int]										=       5_0000
_UpperCAmelCase		:   Dict										=       5000

_UpperCAmelCase				,						_UpperCAmelCase		:   Optional[int]										=       os.path.split(__file__)
_UpperCAmelCase		:   List[str]										=       os.path.join(RESULTS_BASEPATH, """results""", RESULTS_FILENAME.replace(""".py""", """.json"""))





@get_duration
def 					__lowerCamelCase	( UpperCamelCase__   ,							UpperCamelCase__      ):







							'''simple docstring'''






							for i in range(UpperCamelCase__      ):
														snake_case_							=    dataset[i]





@get_duration
def 					__lowerCamelCase	( UpperCamelCase__   ,							UpperCamelCase__   ,							UpperCamelCase__      ):







							'''simple docstring'''






							for i in range(0   ,							len(UpperCamelCase__      )   ,							UpperCamelCase__      ):
														snake_case_							=    dataset[i : i + batch_size]





@get_duration
def 					__lowerCamelCase	( UpperCamelCase__   ,							UpperCamelCase__   ,							UpperCamelCase__      ):







							'''simple docstring'''






							with dataset.formatted_as(type=UpperCamelCase__      ):
														for i in range(UpperCamelCase__      ):
																					snake_case_							=    dataset[i]





@get_duration
def 					__lowerCamelCase	( UpperCamelCase__   ,							UpperCamelCase__   ,							UpperCamelCase__   ,							UpperCamelCase__      ):







							'''simple docstring'''






							with dataset.formatted_as(type=UpperCamelCase__      ):
														for i in range(0   ,							UpperCamelCase__   ,							UpperCamelCase__      ):
																					snake_case_							=    dataset[i : i + batch_size]





def 					__lowerCamelCase	( ):







							'''simple docstring'''






							snake_case_							=    {'num examples': SPEED_TEST_N_EXAMPLES}
							snake_case_							=    [
							    (read, {'length': SMALL_TEST}),
							    (read, {'length': SPEED_TEST_N_EXAMPLES}),
							    (read_batch, {'length': SPEED_TEST_N_EXAMPLES, 'batch_size': 10}),
							    (read_batch, {'length': SPEED_TEST_N_EXAMPLES, 'batch_size': 100}),
							    (read_batch, {'length': SPEED_TEST_N_EXAMPLES, 'batch_size': 1000}),
							    (read_formatted, {'type': 'numpy', 'length': SMALL_TEST}),
							    (read_formatted, {'type': 'pandas', 'length': SMALL_TEST}),
							    (read_formatted, {'type': 'torch', 'length': SMALL_TEST}),
							    (read_formatted, {'type': 'tensorflow', 'length': SMALL_TEST}),
							    (read_formatted_batch, {'type': 'numpy', 'length': SMALL_TEST, 'batch_size': 10}),
							    (read_formatted_batch, {'type': 'numpy', 'length': SMALL_TEST, 'batch_size': 1000}),
							]

							snake_case_							=    [
							    (read, {'length': SMALL_TEST}),
							    (read, {'length': SPEED_TEST_N_EXAMPLES}),
							    (read_batch, {'length': SPEED_TEST_N_EXAMPLES, 'batch_size': 10}),
							    (read_batch, {'length': SPEED_TEST_N_EXAMPLES, 'batch_size': 100}),
							    (read_batch, {'length': SPEED_TEST_N_EXAMPLES, 'batch_size': 1000}),
							    (read_formatted, {'type': 'numpy', 'length': SMALL_TEST}),
							    (read_formatted_batch, {'type': 'numpy', 'length': SMALL_TEST, 'batch_size': 10}),
							    (read_formatted_batch, {'type': 'numpy', 'length': SMALL_TEST, 'batch_size': 1000}),
							]
							with tempfile.TemporaryDirectory() as tmp_dir:
														print('generating dataset'      )
														snake_case_							=    datasets.Features(
														    {'list': datasets.Sequence(datasets.Value('float32'      )      ), 'numbers': datasets.Value('float32'      )}      )
														snake_case_							=    generate_example_dataset(
														    os.path.join(UpperCamelCase__   ,							'dataset.arrow'      )   ,							UpperCamelCase__   ,							num_examples=UpperCamelCase__   ,							seq_shapes={'list': (100,)}   ,							)
														print('first set of iterations'      )
														for func, kwargs in functions:
																					print(func.__name__   ,							str(UpperCamelCase__      )      )
																					snake_case_							=    func(UpperCamelCase__   ,							**UpperCamelCase__      )

														print('shuffling dataset'      )
														snake_case_							=    dataset.shuffle()
														print('Second set of iterations (after shuffling'      )
														for func, kwargs in functions_shuffled:
																					print('shuffled '   ,							func.__name__   ,							str(UpperCamelCase__      )      )
																					snake_case_							=    func(
																					    UpperCamelCase__   ,							**UpperCamelCase__      )

							with open(UpperCamelCase__   ,							'wb'      ) as f:
														f.write(json.dumps(UpperCamelCase__      ).encode('utf-8'      )      )


if __name__ == "__main__":  # useful to run the profiler
					benchmark_iterating()




