




import heapq as hq
import math
from collections.abc import Iterator




class 						__lowercase		:




      """simple docstring"""





      def __init__(				self    ,				A     )		->    int:
         snake_case				:    List[str]           =	str(id_     )
         snake_case				:    Tuple           =	None
         snake_case				:    List[Any]           =	None
         snake_case				:    Any           =	[]
         snake_case				:    List[Any]           =	{}  # {vertex:distance}

      def __lt__(				self    ,				A     )		->    Tuple:
         return self.key < other.key

      def __repr__(				self     )		->    Dict:
         return self.id

      def      UpperCAmelCase				(				self    ,				A     )		->    int:
         self.neighbors.append(A     )

      def      UpperCAmelCase				(				self    ,				A    ,				A     )		->    Any:
         snake_case				:    List[str]           =	weight




def 						SCREAMING_SNAKE_CASE__ (   lowercase						,lowercase						,lowercase						,lowercase					)  ->       List[Any]:
   # add the neighbors:
   graph[a - 1].add_neighbor(graph[b - 1]					)
   graph[b - 1].add_neighbor(graph[a - 1]					)
   # add the edges:
   graph[a - 1].add_edge(graph[b - 1]						,lowercase					)
   graph[b - 1].add_edge(graph[a - 1]						,lowercase					)




def 						SCREAMING_SNAKE_CASE__ (   lowercase						,lowercase					)  ->       list:
   snake_case				:    List[str]           =	[]
   for u in graph:
      snake_case				:    Optional[int]           =	math.inf
      snake_case				:    Any           =	None
   snake_case				:    Union[str, Any]           =	0
   snake_case				:    List[Any]           =	graph[:]
   while q:
      snake_case				:    List[str]           =	min(lowercase					)
      q.remove(lowercase					)
      for v in u.neighbors:
         if (v in q) and (u.edges[v.id] < v.key):
            snake_case				:    List[str]           =	u
            snake_case				:    Any           =	u.edges[v.id]
   for i in range(1						,len(lowercase					)					):
      a.append((int(graph[i].id					) + 1, int(graph[i].pi.id					) + 1)					)
   return a




def 						SCREAMING_SNAKE_CASE__ (   lowercase						,lowercase					)  ->       Iterator[tuple]:
   for u in graph:
      snake_case				:    Dict           =	math.inf
      snake_case				:    str           =	None
   snake_case				:    Union[str, Any]           =	0

   snake_case				:    Any           =	list(lowercase					)
   hq.heapify(lowercase					)

   while h:
      snake_case				:    int           =	hq.heappop(lowercase					)
      for v in u.neighbors:
         if (v in h) and (u.edges[v.id] < v.key):
            snake_case				:    str           =	u
            snake_case				:    Any           =	u.edges[v.id]
            hq.heapify(lowercase					)

   for i in range(1						,len(lowercase					)					):
      yield (int(graph[i].id					) + 1, int(graph[i].pi.id					) + 1)




def 						SCREAMING_SNAKE_CASE__ (   )  ->       None:
   pass


if __name__ == "__main__":
       import doctest

       doctest.testmod()











import functools




def 						SCREAMING_SNAKE_CASE__ (   lowercase						,lowercase					)  ->       int:

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

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

   if len(lowercase					) == 0:
      return 0

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

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

   snake_case				:    List[str]           =	set(lowercase					)

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





