





import math

def       A__(		__lowerCAmelCase ):
				_snake_case :			int  						=   [True] * n
				_snake_case :			str  						=   False
				_snake_case :			int  						=   False
				_snake_case :			Optional[int]  						=   True

				for i in range(3	,			int(n**0.5 + 1 )	,			2 ):
								_snake_case :			List[str]  						=   i * 2
								while index < n:
												_snake_case :			Optional[int]  						=   False
												_snake_case :			Tuple  						=   index + i

				_snake_case :			List[str]  						=   [2]

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

				return primes

def       A__(		__lowerCAmelCase = 99_99_66_66_33_33 ):
				_snake_case :			Dict  						=   math.floor(math.sqrt(__lowerCAmelCase ) ) + 1_00
				_snake_case :			Dict  						=   prime_sieve(__lowerCAmelCase )

				_snake_case :			Union[str, Any]  						=   0
				_snake_case :			Dict  						=   0
				_snake_case :			Union[str, Any]  						=   primes[prime_index]

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

								_snake_case :			Optional[int]  						=   last_prime**2
								_snake_case :			List[Any]  						=   next_prime**2

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

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

				return matches_sum


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













import functools

def       A__(		__lowerCAmelCase	,			__lowerCAmelCase ):

				# Validation
				if not isinstance(__lowerCAmelCase	,			__lowerCAmelCase ) or not all(isinstance(__lowerCAmelCase	,			__lowerCAmelCase ) for day in days ):
								raise ValueError('The parameter days should be a list of integers' )

				if len(__lowerCAmelCase ) != 3 or not all(isinstance(__lowerCAmelCase	,			__lowerCAmelCase ) for cost in costs ):
								raise ValueError('The parameter costs should be a list of three integers' )

				if len(__lowerCAmelCase ) == 0:
								return 0

				if min(__lowerCAmelCase ) <= 0:
								raise ValueError('All days elements should be greater than 0' )

				if max(__lowerCAmelCase ) >= 3_66:
								raise ValueError('All days elements should be less than 366' )

				_snake_case :			Optional[int]  						=   set(__lowerCAmelCase )

				@functools.cache
				def dynamic_programming(__lowerCAmelCase ) -> int:
								if index > 3_65:
												return 0

								if index not in days_set:
												return dynamic_programming(index + 1 )

								return min(
								    costs[0] + dynamic_programming(index + 1 )	,			costs[1] + dynamic_programming(index + 7 )	,			costs[2] + dynamic_programming(index + 30 )	,			)

				return dynamic_programming(1 )


if __name__ == "__main__":
		import doctest

		doctest.testmod()






