


from __future__ import annotations

from collections.abc import Callable
from typing import Generic, TypeVar

snake_case							:       str     			=      TypeVar('''T''')
snake_case							:       str     			=      TypeVar('''U''')







class        snake_case_   (Generic[T, U]      ):
					def __init__(      self   :Any			,__snake_case   :T | None			,__snake_case   :U | None      )					->    str:
												a__             =     key
												a__             =     val
												a__             =     None
												a__             =     None



					def __repr__(      self   :str      )					->    str:
												return (
												    F'Node: key: {self.key}, val: {self.val}, '
												    F'has next: {bool(self.next      )}, has prev: {bool(self.prev      )}'
												)







class        snake_case_   (Generic[T, U]      ):
					def __init__(      self   :Any      )					->    None:
												a__             =     DoubleLinkedListNode(__snake_case			,__snake_case      )
												a__             =     DoubleLinkedListNode(__snake_case			,__snake_case      )
												a__      ,					a__             =     self.rear, self.head
					def __repr__(      self   :List[str]      )					->    str:
												a__             =     ['DoubleLinkedList']
												a__             =     self.head
												while node.next is not None:
																			rep.append(str(__snake_case      )      )
																			a__             =     node.next
												rep.append(str(self.rear      )      )
												return ",\n    ".join(__snake_case      )
					def  lowerCamelCase__(      self   :Dict			,__snake_case   :DoubleLinkedListNode[T, U]      )					->    None:
												a__             =     self.rear.prev

												# All nodes other than self.head are guaranteed to have non-None previous
												assert previous is not None

												a__             =     node
												a__             =     previous
												a__             =     node
												a__             =     self.rear



					def  lowerCamelCase__(      self   :Optional[Any]			,__snake_case   :DoubleLinkedListNode[T, U]      )					->    DoubleLinkedListNode[T, U] | None:

												if node.prev is None or node.next is None:
																			return None

												a__             =     node.next
												a__             =     node.prev
												a__             =     None
												a__             =     None
												return node







class        snake_case_   (Generic[T, U]      ):
					UpperCAmelCase__					:    dict[Callable[[T], U], LRUCache[T, U]]          =			{}
					def __init__(      self   :str			,__snake_case   :int      )					->    List[str]:
												a__             =     DoubleLinkedList()
												a__             =     capacity
												a__             =     0
												a__             =     0
												a__             =     0
												a__             =     {}
					def __repr__(      self   :List[Any]      )					->    str:
												return (
												    F'CacheInfo(hits={self.hits}, misses={self.miss}, '
												    F'capacity={self.capacity}, current size={self.num_keys})'
												)
					def __contains__(      self   :Any			,__snake_case   :T      )					->    bool:
												return key in self.cache
					def  lowerCamelCase__(      self   :List[Any]			,__snake_case   :T      )					->    U | None:
												# Note: pythonic interface would throw KeyError rather than return None

												if key in self.cache:
																			self.hits += 1
																			a__             =     self.cache[key]
																			a__             =     self.list.remove(self.cache[key]      )
																			assert node == value_node

																			# node is guaranteed not None because it is in self.cache
																			assert node is not None
																			self.list.add(__snake_case      )
																			return node.val
												self.miss += 1
												return None
					def  lowerCamelCase__(      self   :int			,__snake_case   :T			,__snake_case   :U      )					->    None:

												if key not in self.cache:
																			if self.num_keys >= self.capacity:
																										# delete first node (oldest) when over capacity
																										a__             =     self.list.head.next

																										# guaranteed to have a non-None first node when num_keys > 0
																										# explain to type checker via assertions
																										assert first_node is not None
																										assert first_node.key is not None
																										assert (
																										    self.list.remove(__snake_case      ) is not None
																										)  # node guaranteed to be in list assert node.key is not None

																										del self.cache[first_node.key]
																										self.num_keys -= 1
																			a__             =     DoubleLinkedListNode(__snake_case			,__snake_case      )
																			self.list.add(self.cache[key]      )
																			self.num_keys += 1

												else:
																			# bump node to the end of the list, update value
																			a__             =     self.list.remove(self.cache[key]      )
																			assert node is not None  # node guaranteed to be in list
																			a__             =     value
																			self.list.add(__snake_case      )



					@classmethod
					def  lowerCamelCase__(      cls   :Any			,__snake_case   :int = 1_28      )					->    Callable[[Callable[[T], U]], Callable[..., U]]:

												def cache_decorator_inner(__snake_case   :Callable[[T], U]      ) -> Callable[..., U]:
																			def cache_decorator_wrapper(*__snake_case   :T      ) -> U:
																										if func not in cls.decorator_function_to_instance_map:
																																	a__             =     LRUCache(__snake_case      )

																										a__             =     cls.decorator_function_to_instance_map[func].get(args[0]      )
																										if result is None:
																																	a__             =     func(*__snake_case      )
																																	cls.decorator_function_to_instance_map[func].put(args[0]			,__snake_case      )
																										return result

																			def cache_info() -> LRUCache[T, U]:
																										return cls.decorator_function_to_instance_map[func]

																			setattr(__snake_case			,'cache_info'			,__snake_case      )  # noqa: B010

																			return cache_decorator_wrapper

												return cache_decorator_inner


if __name__ == "__main__":
						import doctest

						doctest.testmod()








import math






def 							__lowercase   ( __lowerCAmelCase							:				int   ):
							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					,    __lowerCAmelCase					,    2   ):
														if is_prime[i]:
																					primes.append(__lowerCAmelCase   )

							return primes






def 							__lowercase   ( __lowerCAmelCase							:				int = 9_9_9_9_6_6_6_6_3_3_3_3   ):
							a__             =     math.floor(math.sqrt(__lowerCAmelCase   )   ) + 1_0_0
							a__             =     prime_sieve(__lowerCAmelCase   )

							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())




