



"""simple docstring"""


from __future__ import annotations

from typing import Any
class 			_a :
   """simple docstring"""



   def __init__(		self     :    Optional[int]				,   __UpperCamelCase     :    Optional[int] = 6   )->None:
       _UpperCAmelCase					=    None
       _UpperCAmelCase					=    None
       self.create_linked_list(__UpperCamelCase   )



   def  lowercase__						(		self     :    Union[str, Any]				,   __UpperCamelCase     :    Optional[Any]   )->None:
       _UpperCAmelCase					=    Node()
       _UpperCAmelCase					=    current_node
       _UpperCAmelCase					=    current_node
       _UpperCAmelCase					=    current_node
       for _ in range(1				,   __UpperCamelCase   ):
           _UpperCAmelCase					=    Node()
           _UpperCAmelCase					=    current_node
           _UpperCAmelCase					=    previous_node
           _UpperCAmelCase					=    current_node
       _UpperCAmelCase					=    self.front
       _UpperCAmelCase					=    previous_node



   def  lowercase__						(		self     :    Any   )->bool:
       return (
           self.front == self.rear
           and self.front is not None
           and self.front.data is None
       )



   def  lowercase__						(		self     :    List[str]   )->Any | None:
       self.check_can_perform_operation()
       return self.front.data if self.front else None



   def  lowercase__						(		self     :    Tuple				,   __UpperCamelCase     :    List[str]   )->None:
       if self.rear is None:
           return

       self.check_is_full()
       if not self.is_empty():
           _UpperCAmelCase					=    self.rear.next
       if self.rear:
           _UpperCAmelCase					=    data



   def  lowercase__						(		self     :    Optional[Any]   )->Any:
       self.check_can_perform_operation()
       if self.rear is None or self.front is None:
           return None
       if self.front == self.rear:
           _UpperCAmelCase					=    self.front.data
           _UpperCAmelCase					=    None
           return data

       _UpperCAmelCase					=    self.front
       _UpperCAmelCase					=    old_front.next
       _UpperCAmelCase					=    old_front.data
       _UpperCAmelCase					=    None
       return data



   def  lowercase__						(		self     :    Dict   )->None:
       if self.is_empty():
           raise Exception('''Empty Queue'''   )



   def  lowercase__						(		self     :    Dict   )->None:
       if self.rear and self.rear.next == self.front:
           raise Exception('''Full Queue'''   )



class 			_a :
   """simple docstring"""



   def __init__(		self     :    List[Any]   )->None:
       _UpperCAmelCase					=    None
       _UpperCAmelCase					=    None
       _UpperCAmelCase					=    None


if __name__ == "__main__":
     import doctest

     doctest.testmod()








"""simple docstring"""


import functools







def  lowercase	(      _SCREAMING_SNAKE_CASE   :						list[int]					,     _SCREAMING_SNAKE_CASE   :						list[int]				):






				'''simple docstring'''



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

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

				if len(_SCREAMING_SNAKE_CASE				) == 0:
								return 0

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

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

				_UpperCAmelCase					=    set(_SCREAMING_SNAKE_CASE				)

				@functools.cache
				def dynamic_programming(_SCREAMING_SNAKE_CASE   :						int				) -> 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()



