

"""simple docstring"""




from __future__ import annotations

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

lowerCAmelCase							:  Union[str, Any]            =						TypeVar("""T""")



class   __lowercase    (			Generic[T]     ):




			"""simple docstring"""







			_UpperCAmelCase       :							deque[T]  # Cache store of keys
			_UpperCAmelCase       :							set[T]  # References of the keys in cache
			_UpperCAmelCase       :							int      							=					10  # Maximum capacity of cache



			def __init__(			self  :					int       ,						lowerCAmelCase__  :					int):
									SCREAMING_SNAKE_CASE_:			List[str]  		=	deque()
									SCREAMING_SNAKE_CASE_:			Union[str, Any]  		=	set()
									if not n:
															SCREAMING_SNAKE_CASE_:			List[str]  		=	sys.maxsize
									elif n < 0:
															raise ValueError("n should be an integer greater than 0.")
									else:
															SCREAMING_SNAKE_CASE_:			Tuple  		=	n



			def 	_SCREAMING_SNAKE_CASE      (			self  :					int       ,						lowerCAmelCase__  :					T):
									if x not in self.key_reference:
															if len(self.dq_store) == LRUCache._MAX_CAPACITY:
																					SCREAMING_SNAKE_CASE_:			Union[str, Any]  		=	self.dq_store.pop()
																					self.key_reference.remove(_UpperCamelCase)
									else:
															self.dq_store.remove(_UpperCamelCase)

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



			def 	_SCREAMING_SNAKE_CASE      (			self  :					Optional[int]):
									for k in self.dq_store:
															print(_UpperCamelCase)




			def __repr__(			self  :					Any):
									return F"LRUCache({self._MAX_CAPACITY}) => {list(self.dq_store)}"


if __name__ == "__main__":
						import doctest

						doctest.testmod()

						lowerCAmelCase							:  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 doctest
from collections import deque

import numpy as np



class   __lowercase    :




			"""simple docstring"""







			def __init__(			self  :					Union[str, Any]):
									SCREAMING_SNAKE_CASE_:			int  		=	[2, 1, 2, -1]
									SCREAMING_SNAKE_CASE_:			Optional[Any]  		=	[1, 2, 3, 4]




			def 	_SCREAMING_SNAKE_CASE      (			self  :					Tuple):
									SCREAMING_SNAKE_CASE_:			Any  		=	len(self.first_signal)
									SCREAMING_SNAKE_CASE_:			Dict  		=	len(self.second_signal)

									SCREAMING_SNAKE_CASE_:			Union[str, Any]  		=	max(lowerCAmelCase__       ,						lowerCAmelCase__)

									# create a zero matrix of max_length x max_length
									SCREAMING_SNAKE_CASE_:			List[Any]  		=	[[0] * max_length for i in range(lowerCAmelCase__)]

									# fills the smaller signal with zeros to make both signals of same length
									if length_first_signal < length_second_signal:
															self.first_signal += [0] * (max_length - length_first_signal)
									elif length_first_signal > length_second_signal:
															self.second_signal += [0] * (max_length - length_second_signal)
									for i in range(lowerCAmelCase__):
															SCREAMING_SNAKE_CASE_:			Tuple  		=	deque(self.second_signal)
															rotated_signal.rotate(lowerCAmelCase__)
															for j, item in enumerate(lowerCAmelCase__):
																					matrix[i][j] += item

        # multiply the matrix with the first signal
									SCREAMING_SNAKE_CASE_:			Optional[Any]  		=	np.matmul(np.transpose(lowerCAmelCase__)       ,						np.transpose(self.first_signal))

									# rounding-off to two decimal places
									return [round(lowerCAmelCase__       ,						2) for i in final_signal]


if __name__ == "__main__":
						doctest.testmod()






