



'''simple docstring'''





import random





def   a_   (		_UpperCAmelCase    :      int ,_UpperCAmelCase    :      Optional[Any] ,_UpperCAmelCase    :      Optional[int]				)    ->  Any:
      __snake_case :   Union[str, Any]													=    a[left_index]
      __snake_case :   List[str]													=    left_index + 1
      for j in range(left_index + 1 ,_UpperCAmelCase				):
            if a[j] < pivot:
                  __snake_case							,     __snake_case :   List[Any]													=    a[i], a[j]
                  i += 1
      __snake_case							,     __snake_case :   Optional[int]													=    a[i - 1], a[left_index]
      return i - 1





def   a_   (		_UpperCAmelCase    :      Any ,_UpperCAmelCase    :      List[Any] ,_UpperCAmelCase    :      Optional[int]				)    ->  Union[str, Any]:
      if left < right:
            __snake_case :   List[str]													=    random.randint(_UpperCAmelCase ,right - 1				)
            __snake_case							,     __snake_case :   Dict													=    (
                a[left],
                a[pivot],
            )  # switches the pivot with the left most bound
            __snake_case :   List[Any]													=    partition(_UpperCAmelCase ,_UpperCAmelCase ,_UpperCAmelCase				)
            quick_sort_random(
                _UpperCAmelCase ,_UpperCAmelCase ,_UpperCAmelCase				)  # recursive quicksort to the left of the pivot point
            quick_sort_random(
                _UpperCAmelCase ,pivot_index + 1 ,_UpperCAmelCase				)  # recursive quicksort to the right of the pivot point





def   a_   (		)    ->  Tuple:
      __snake_case :   Optional[int]													=    input('Enter numbers separated by a comma:\n'				).strip()
      __snake_case :   List[str]													=    [int(_UpperCAmelCase				) for item in user_input.split(','				)]

      quick_sort_random(_UpperCAmelCase ,0 ,len(_UpperCAmelCase				)				)

      print(_UpperCAmelCase				)


if __name__ == "__main__":
    main()








'''simple docstring'''





import functools





def   a_   (		_UpperCAmelCase    :      list[int] ,_UpperCAmelCase    :      list[int]				)    ->  int:

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

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

      if len(_UpperCAmelCase				) == 0:
            return 0

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

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

      __snake_case :   str													=    set(_UpperCAmelCase				)

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



