from __future__ import annotations

import sys
from collections import deque
from typing import Generic, TypeVar

lowercase__     :							Any            =      TypeVar('''T''')




class   lowercase_    (    Generic[T]		):



	"""simple docstring"""





	UpperCAmelCase_    :   Any  =							42  # Cache store of keys
	UpperCAmelCase_    :   Tuple  =							42  # References of the keys in cache
	UpperCAmelCase_    :   Optional[Any]  =							10  # Maximum capacity of cache


	def __init__(				self						,     __SCREAMING_SNAKE_CASE							)		->int:
								lowerCAmelCase      						=						deque()
								lowerCAmelCase      						=						set()
								if not n:
															lowerCAmelCase      						=						sys.maxsize
								elif n < 0:
															raise ValueError('''n should be an integer greater than 0.'''							)
								else:
															lowerCAmelCase      						=						n


	def      SCREAMING_SNAKE_CASE_							(				self						,     __SCREAMING_SNAKE_CASE							)		->Optional[int]:

								if x not in self.key_reference:
															if len(self.dq_store							) == LRUCache._MAX_CAPACITY:
																						lowerCAmelCase      						=						self.dq_store.pop()
																						self.key_reference.remove(snake_case__							)
								else:
															self.dq_store.remove(snake_case__							)

								self.dq_store.appendleft(snake_case__							)
								self.key_reference.add(snake_case__							)


	def      SCREAMING_SNAKE_CASE_							(				self							)		->Any:

								for k in self.dq_store:
															print(snake_case__							)




	def __repr__(				self							)		->Optional[int]:
								return F"LRUCache({self._MAX_CAPACITY}) => {list(self.dq_store							)}"


if __name__ == "__main__":
	import doctest

	doctest.testmod()

	lowercase__     :							LRUCache[str | int]            =      LRUCache(4)
	lru_cache.refer('''A''')
	lru_cache.refer(2)
	lru_cache.refer(3)
	lru_cache.refer('''A''')
	lru_cache.refer(4)
	lru_cache.refer(5)
	lru_cache.display()

	print(lru_cache)
	assert str(lru_cache) == "LRUCache(4) => [5, 4, 'A', 3]"









import functools


def 					_a							(					lowerCAmelCase    ,						lowerCAmelCase )->	int:

		# 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 ) >= 366:
				raise ValueError('All days elements should be less than 366' )

		SCREAMING_SNAKE_CASE_					      =							set(lowerCAmelCase )

		@functools.cache
		def dynamic_programming(lowerCAmelCase ) -> int:
				if index > 365:
						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()