

def 		UpperCamelCase_(     snake_case__:    str    ,       snake_case__:    Any    ,       snake_case__:    List[str]  )			->					str:



 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__     							=							[p / w for p, w in zip(_UpperCamelCase    ,       _UpperCamelCase  )]

 # Creating a copy of the list and sorting profit/weight in ascending order
 UpperCAmelCase__     							=							sorted(_UpperCamelCase  )

 # declaring useful variables
 UpperCAmelCase__     							=							len(_UpperCamelCase  )
 UpperCAmelCase__     							=							0
 UpperCAmelCase__     							=							0
 UpperCAmelCase__     							=							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__     							=							sorted_profit_by_weight[length - i - 1]
  UpperCAmelCase__     							=							profit_by_weight.index(_UpperCamelCase  )
  UpperCAmelCase__     							=							-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.'''
 )

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

 # Function Call
 calc_profit(profit, weight, max_weight)





"""simple docstring"""




import unittest

import numpy as np

from transformers.testing_utils import is_flaky, require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
  import torch

if is_vision_available():
  from PIL import Image

  from transformers import DonutImageProcessor


class       __magic_name__							(							unittest.TestCase			):
       def __init__(  self			,					A_			,					A_=7			,					A_=3			,					A_=18			,					A_=30			,					A_=400			,					A_=True			,					A_=None			,					A_=True			,					A_=False			,					A_=True			,					A_=True			,					A_=[0.5, 0.5, 0.5]			,					A_=[0.5, 0.5, 0.5]			,					)  ->						Optional[int]:





         """simple docstring"""




         _lowercase:      Optional[int]   			=  parent
         _lowercase:      str   			=  batch_size
         _lowercase:      Any   			=  num_channels
         _lowercase:      Any   			=  image_size
         _lowercase:      Any   			=  min_resolution
         _lowercase:      int   			=  max_resolution
         _lowercase:      Union[str, Any]   			=  do_resize
         _lowercase:      List[Any]   			=  size if size is not None else {'''height''': 18, '''width''': 20}
         _lowercase:      Optional[int]   			=  do_thumbnail
         _lowercase:      List[str]   			=  do_align_axis
         _lowercase:      int   			=  do_pad
         _lowercase:      Optional[Any]   			=  do_normalize
         _lowercase:      List[Any]   			=  image_mean
         _lowercase:      Union[str, Any]   			=  image_std



       def 				lowercase_				(  self							)  ->						List[str]:





         """simple docstring"""




         return {
             "do_resize": self.do_resize,
             "size": self.size,
             "do_thumbnail": self.do_thumbnail,
             "do_align_long_axis": self.do_align_axis,
             "do_pad": self.do_pad,
             "do_normalize": self.do_normalize,
             "image_mean": self.image_mean,
             "image_std": self.image_std,
         }


@require_torch
@require_vision
class       __magic_name__							(							SCREAMING_SNAKE_CASE__ ,       unittest.TestCase			):
       UpperCamelCase_ =		DonutImageProcessor if is_vision_available() else None
       def 				lowercase_				(  self							)  ->						Optional[int]:





         """simple docstring"""




         _lowercase:      str   			=  DonutImageProcessingTester(self							)
       @property
       def 				lowercase_				(  self							)  ->						int:





         """simple docstring"""




         return self.image_processor_tester.prepare_image_processor_dict()
       def 				lowercase_				(  self							)  ->						Dict:





         """simple docstring"""




         _lowercase:      Optional[int]   			=  self.image_processing_class(**self.image_processor_dict							)
         self.assertTrue(hasattr(A_			,					'''do_resize'''							)							)
         self.assertTrue(hasattr(A_			,					'''size'''							)							)
         self.assertTrue(hasattr(A_			,					'''do_thumbnail'''							)							)
         self.assertTrue(hasattr(A_			,					'''do_align_long_axis'''							)							)
         self.assertTrue(hasattr(A_			,					'''do_pad'''							)							)
         self.assertTrue(hasattr(A_			,					'''do_normalize'''							)							)
         self.assertTrue(hasattr(A_			,					'''image_mean'''							)							)
         self.assertTrue(hasattr(A_			,					'''image_std'''							)							)
       def 				lowercase_				(  self							)  ->						List[Any]:





         """simple docstring"""




         _lowercase:      Optional[Any]   			=  self.image_processing_class.from_dict(self.image_processor_dict							)
         self.assertEqual(image_processor.size			,					{'''height''': 18, '''width''': 20}							)

         _lowercase:      List[str]   			=  self.image_processing_class.from_dict(self.image_processor_dict			,					size=42							)
         self.assertEqual(image_processor.size			,					{'''height''': 42, '''width''': 42}							)

         # Previous config had dimensions in (width, height) order
         _lowercase:      Any   			=  self.image_processing_class.from_dict(self.image_processor_dict			,					size=(42, 84)							)
         self.assertEqual(image_processor.size			,					{'''height''': 84, '''width''': 42}							)
       def 				lowercase_				(  self							)  ->						Union[str, Any]:





         """simple docstring"""




         pass
       @is_flaky()
       def 				lowercase_				(  self							)  ->						str:





         """simple docstring"""




         _lowercase:      str   			=  self.image_processing_class(**self.image_processor_dict							)
         # create random PIL images
         _lowercase:      Dict   			=  prepare_image_inputs(self.image_processor_tester			,					equal_resolution=A_							)
         for image in image_inputs:
           self.assertIsInstance(A_			,					Image.Image							)

         # Test not batched input
         _lowercase:      Tuple   			=  image_processing(image_inputs[0]			,					return_tensors='''pt'''							).pixel_values
         self.assertEqual(
             encoded_images.shape			,					(
                 1,
                 self.image_processor_tester.num_channels,
                 self.image_processor_tester.size['''height'''],
                 self.image_processor_tester.size['''width'''],
             )			,					)

         # Test batched
         _lowercase:      List[Any]   			=  image_processing(A_			,					return_tensors='''pt'''							).pixel_values
         self.assertEqual(
             encoded_images.shape			,					(
                 self.image_processor_tester.batch_size,
                 self.image_processor_tester.num_channels,
                 self.image_processor_tester.size['''height'''],
                 self.image_processor_tester.size['''width'''],
             )			,					)
       @is_flaky()
       def 				lowercase_				(  self							)  ->						Any:





         """simple docstring"""




         _lowercase:      str   			=  self.image_processing_class(**self.image_processor_dict							)
         # create random numpy tensors
         _lowercase:      str   			=  prepare_image_inputs(self.image_processor_tester			,					equal_resolution=A_			,					numpify=A_							)
         for image in image_inputs:
           self.assertIsInstance(A_			,					np.ndarray							)

         # Test not batched input
         _lowercase:      Union[str, Any]   			=  image_processing(image_inputs[0]			,					return_tensors='''pt'''							).pixel_values
         self.assertEqual(
             encoded_images.shape			,					(
                 1,
                 self.image_processor_tester.num_channels,
                 self.image_processor_tester.size['''height'''],
                 self.image_processor_tester.size['''width'''],
             )			,					)

         # Test batched
         _lowercase:      Dict   			=  image_processing(A_			,					return_tensors='''pt'''							).pixel_values
         self.assertEqual(
             encoded_images.shape			,					(
                 self.image_processor_tester.batch_size,
                 self.image_processor_tester.num_channels,
                 self.image_processor_tester.size['''height'''],
                 self.image_processor_tester.size['''width'''],
             )			,					)



       @is_flaky()
       def 				lowercase_				(  self							)  ->						Tuple:





         """simple docstring"""




         _lowercase:      List[Any]   			=  self.image_processing_class(**self.image_processor_dict							)
         # create random PyTorch tensors
         _lowercase:      List[Any]   			=  prepare_image_inputs(self.image_processor_tester			,					equal_resolution=A_			,					torchify=A_							)
         for image in image_inputs:
           self.assertIsInstance(A_			,					torch.Tensor							)

         # Test not batched input
         _lowercase:      Union[str, Any]   			=  image_processing(image_inputs[0]			,					return_tensors='''pt'''							).pixel_values
         self.assertEqual(
             encoded_images.shape			,					(
                 1,
                 self.image_processor_tester.num_channels,
                 self.image_processor_tester.size['''height'''],
                 self.image_processor_tester.size['''width'''],
             )			,					)

         # Test batched
         _lowercase:      Dict   			=  image_processing(A_			,					return_tensors='''pt'''							).pixel_values
         self.assertEqual(
             encoded_images.shape			,					(
                 self.image_processor_tester.batch_size,
                 self.image_processor_tester.num_channels,
                 self.image_processor_tester.size['''height'''],
                 self.image_processor_tester.size['''width'''],
             )			,					)
