



'''simple docstring'''






def  UpperCamelCase__					(					_lowercase    :				List[str]   ,    _lowercase    :				int   ,    _lowercase    :				List[str]     )							->	int:





  if len(UpperCamelCase__     ) != len(UpperCamelCase__     ):
    raise ValueError("""The length of profit and weight must be same."""     )
  if max_weight <= 0:
    raise ValueError("""max_weight must greater than zero."""     )
  if any(p < 0 for p in profit     ):
    raise ValueError("""Profit can not be negative."""     )
  if any(w < 0 for w in weight     ):
    raise ValueError("""Weight can not be negative."""     )

  # List created to store profit gained for the 1kg in case of each weight
  # respectively.  Calculate and append profit/weight for each element.
  __UpperCAmelCase:					List[str]		= [p / w for p, w in zip(UpperCamelCase__   ,    UpperCamelCase__     )]

  # Creating a copy of the list and sorting profit/weight in ascending order
  __UpperCAmelCase:					Dict		= sorted(UpperCamelCase__     )

  # declaring useful variables
  __UpperCAmelCase:					List[str]		= len(UpperCamelCase__     )
  __UpperCAmelCase:					str		= 0
  __UpperCAmelCase:					int		= 0
  __UpperCAmelCase:					int		= 0

  # loop till the total weight do not reach max limit e.g. 15 kg and till i<length
  while limit <= max_weight and i < length:
    # flag value for encountered greatest element in sorted_profit_by_weight
    __UpperCAmelCase:					Dict		= sorted_profit_by_weight[length - i - 1]
    __UpperCAmelCase:					Optional[Any]		= profit_by_weight.index(UpperCamelCase__     )
    __UpperCAmelCase:					List[str]		= -1

    # check if the weight encountered is less than the total weight
    # encountered before.
    if max_weight - limit >= weight[index]:
      limit += weight[index]
      # Adding profit gained for the given weight 1 ===
      # weight[index]/weight[index]
      gain += 1 * profit[index]
    else:
      # Since the weight encountered is greater than limit, therefore take the
      # required number of remaining kgs and calculate profit for it.
      # weight remaining / weight[index]
      gain += (max_weight - limit) / weight[index] * profit[index]
      break
    i += 1
  return gain


if __name__ == "__main__":
    print(
        'Input profits, weights, and then max_weight (all positive ints) separated by '
        'spaces.'
    )

    SCREAMING_SNAKE_CASE_	   =			[int(x) for x in input('Input profits separated by spaces: ').split()]
    SCREAMING_SNAKE_CASE_	   =			[int(x) for x in input('Input weights separated by spaces: ').split()]
    SCREAMING_SNAKE_CASE_	   =			int(input('Max weight allowed: '))

    # Function Call
    calc_profit(profit, weight, max_weight)
'''simple docstring'''






from __future__ import annotations






def  UpperCamelCase__					(					_lowercase    :				list[int]   ,    _lowercase    :				int   ,    _lowercase    :				int   ,    _lowercase    :				int     )							->	None:
  if (direction == 1 and array[indexa] > array[indexa]) or (
      direction == 0 and array[indexa] < array[indexa]
  ):
    __UpperCAmelCase, __UpperCAmelCase:					str		= array[indexa], array[indexa]






def  UpperCamelCase__					(					_lowercase    :				list[int]   ,    _lowercase    :				int   ,    _lowercase    :				int   ,    _lowercase    :				int     )							->	None:
  if length > 1:
    __UpperCAmelCase:					List[str]		= int(length / 2     )
    for i in range(_lowercase   ,    low + middle     ):
      comp_and_swap(_lowercase   ,    _lowercase   ,    i + middle   ,    _lowercase     )
    bitonic_merge(_lowercase   ,    _lowercase   ,    _lowercase   ,    _lowercase     )
    bitonic_merge(_lowercase   ,    low + middle   ,    _lowercase   ,    _lowercase     )






def  UpperCamelCase__					(					_lowercase    :				list[int]   ,    _lowercase    :				int   ,    _lowercase    :				int   ,    _lowercase    :				int     )							->	None:
  if length > 1:
    __UpperCAmelCase:					Any		= int(length / 2     )
    bitonic_sort(_lowercase   ,    _lowercase   ,    _lowercase   ,    1     )
    bitonic_sort(_lowercase   ,    low + middle   ,    _lowercase   ,    0     )
    bitonic_merge(_lowercase   ,    _lowercase   ,    _lowercase   ,    _lowercase     )


if __name__ == "__main__":
    SCREAMING_SNAKE_CASE_	   =			input('Enter numbers separated by a comma:\n').strip()
    SCREAMING_SNAKE_CASE_	   =			[int(item.strip()) for item in user_input.split(',')]

    bitonic_sort(unsorted, 0, len(unsorted), 1)
    print('\nSorted array in ascending order is: ', end='')
    print(*unsorted, sep=', ')

    bitonic_merge(unsorted, 0, len(unsorted), 0)
    print('Sorted array in descending order is: ', end='')
    print(*unsorted, sep=', ')