
'''simple docstring'''
import functools







def        A_     (						__SCREAMING_SNAKE_CASE						:  list[int]			,     __SCREAMING_SNAKE_CASE						:  list[int] )				->       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""" )

  __A		:     Any												=		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()





'''simple docstring'''
def        A_     (						__SCREAMING_SNAKE_CASE						:  Dict )				->       Optional[Any]:





  """simple docstring"""

  if not head:
    return True
  # split the list to two parts
  __A							,					__A		:     Any												=		head.next, head
  while fast and fast.next:
    __A		:     List[str]												=		fast.next.next
    __A		:     List[Any]												=		slow.next
  __A		:     int												=		slow.next
  __A		:     List[str]												=		None  # Don't forget here! But forget still works!
  # reverse the second part
  __A		:     Dict												=		None
  while second:
    __A		:     Dict												=		second.next
    __A		:     str												=		node
    __A		:     int												=		second
    __A		:     Optional[int]												=		nxt
  # compare two parts
  # second part has the same or one less node
  while node:
    if node.val != head.val:
      return False
    __A		:     List[Any]												=		node.next
    __A		:     Tuple												=		head.next
  return True







def        A_     (						__SCREAMING_SNAKE_CASE						:  Union[str, Any] )				->       Optional[int]:





  """simple docstring"""

  if not head or not head.next:
    return True

  # 1. Get the midpoint (slow)
  __A		:     int												=		head
  while fast and fast.next:
    __A							,					__A		:     Optional[int]												=		fast.next.next, slow.next

  # 2. Push the second half into the stack
  __A		:     Union[str, Any]												=		[slow.val]
  while slow.next:
    __A		:     List[str]												=		slow.next
    stack.append(slow.val )

  # 3. Comparison
  while stack:
    if stack.pop() != cur.val:
      return False
    __A		:     Tuple												=		cur.next

  return True







def        A_     (						__SCREAMING_SNAKE_CASE						:  Dict )				->       Any:





  """simple docstring"""

  if not head or not head.next:
    return True
  __A		:     List[Any]												=		{}
  __A		:     Optional[int]												=		0
  while head:
    if head.val in d:
      d[head.val].append(__SCREAMING_SNAKE_CASE )
    else:
      __A		:     Tuple												=		[pos]
    __A		:     List[Any]												=		head.next
    pos += 1
  __A		:     List[Any]												=		pos - 1
  __A		:     List[str]												=		0
  for v in d.values():
    if len(__SCREAMING_SNAKE_CASE ) % 2 != 0:
      middle += 1
    else:
      __A		:     List[Any]												=		0
      for i in range(0			,     len(__SCREAMING_SNAKE_CASE ) ):
        if v[i] + v[len(__SCREAMING_SNAKE_CASE ) - 1 - step] != checksum:
          return False
        step += 1
    if middle > 1:
      return False
  return True



