



import os
import sys
import unittest


snake_case__					:     Optional[Any]    		=   os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
sys.path.append(os.path.join(git_repo_path, """utils"""))

import check_dummies  # noqa: E402
from check_dummies import create_dummy_files, create_dummy_object, find_backend, read_init  # noqa: E402


# Align TRANSFORMERS_PATH in check_dummies with the current path
snake_case__					:     Optional[int]    		=   os.path.join(git_repo_path, """src""", """transformers""")

snake_case__					:     Tuple    		=   """
{0} = None
"""

snake_case__					:     List[str]    		=   """
class {0}(metaclass=DummyObject):
    _backends = {1}

    def __init__(self, *args, **kwargs):
        requires_backends(self, {1})
"""


snake_case__					:     Dict    		=   """
def {0}(*args, **kwargs):
    requires_backends({0}, {1})
"""

class   _A   ( unittest.TestCase	):


						'''simple docstring'''





						def     _snake_case	(	self	:							str	):






							'''simple docstring'''



							__lowercase		       =			find_backend("    _import_structure[\"models.albert\"].append(\"AlbertTokenizerFast\")"	)
							self.assertIsNone(lowerCamelCase	)

							__lowercase		       =			find_backend("    if not is_tokenizers_available():"	)
							self.assertEqual(lowerCamelCase							,      "tokenizers"	)

							__lowercase		       =			find_backend("    if not is_tensorflow_text_available():"	)
							self.assertEqual(lowerCamelCase							,      "tensorflow_text"	)

							__lowercase		       =			find_backend("    if not (is_sentencepiece_available() and is_tokenizers_available()):"	)
							self.assertEqual(lowerCamelCase							,      "sentencepiece_and_tokenizers"	)

							__lowercase		       =			find_backend(
							    "    if not (is_sentencepiece_available() and is_tensorflow_text_available()):"	)
							self.assertEqual(lowerCamelCase							,      "sentencepiece_and_tensorflow_text"	)

							__lowercase		       =			find_backend(
							    "    if not (is_sentencepiece_available() and is_tokenizers_available() and is_vision_available()):"	)
							self.assertEqual(lowerCamelCase							,      "sentencepiece_and_tokenizers_and_vision"	)



						def     _snake_case	(	self	:							Optional[int]	):






							'''simple docstring'''



							__lowercase		       =			read_init()
							# We don't assert on the exact list of keys to allow for smooth grow of backend-specific objects
							self.assertIn("torch"							,      lowerCamelCase	)
							self.assertIn("tensorflow_text"							,      lowerCamelCase	)
							self.assertIn("sentencepiece_and_tokenizers"							,      lowerCamelCase	)

							# Likewise, we can't assert on the exact content of a key
							self.assertIn("BertModel"							,      objects["torch"]	)
							self.assertIn("TFBertModel"							,      objects["tf"]	)
							self.assertIn("FlaxBertModel"							,      objects["flax"]	)
							self.assertIn("BertModel"							,      objects["torch"]	)
							self.assertIn("TFBertTokenizer"							,      objects["tensorflow_text"]	)
							self.assertIn("convert_slow_tokenizer"							,      objects["sentencepiece_and_tokenizers"]	)



						def     _snake_case	(	self	:							Optional[int]	):






							'''simple docstring'''



							__lowercase		       =			create_dummy_object("CONSTANT"							,      "'torch'"	)
							self.assertEqual(lowerCamelCase							,      "\nCONSTANT = None\n"	)

							__lowercase		       =			create_dummy_object("function"							,      "'torch'"	)
							self.assertEqual(
							    lowerCamelCase							,      "\ndef function(*args, **kwargs):\n    requires_backends(function, 'torch')\n"	)

							__lowercase		       =			"\nclass FakeClass(metaclass=DummyObject):\n    _backends = 'torch'\n\n    def __init__(self, *args, **kwargs):\n        requires_backends(self, 'torch')\n"
							__lowercase		       =			create_dummy_object("FakeClass"							,      "'torch'"	)
							self.assertEqual(lowerCamelCase							,      lowerCamelCase	)



						def     _snake_case	(	self	:							Union[str, Any]	):






							'''simple docstring'''



							__lowercase		       =			"# This file is autogenerated by the command `make fix-copies`, do not edit.\nfrom ..utils import DummyObject, requires_backends\n\n\nCONSTANT = None\n\n\ndef function(*args, **kwargs):\n    requires_backends(function, [\"torch\"])\n\n\nclass FakeClass(metaclass=DummyObject):\n    _backends = [\"torch\"]\n\n    def __init__(self, *args, **kwargs):\n        requires_backends(self, [\"torch\"])\n"
							__lowercase		       =			create_dummy_files({"torch": ["CONSTANT", "function", "FakeClass"]}	)
							self.assertEqual(dummy_files["torch"]							,      lowerCamelCase	)








def    snake_case_				(    _SCREAMING_SNAKE_CASE  ,	_SCREAMING_SNAKE_CASE  ,	_SCREAMING_SNAKE_CASE   ):
	if len(_SCREAMING_SNAKE_CASE   ) != len(_SCREAMING_SNAKE_CASE   ):
		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.
	__lowercase		       =			[p / w for p, w in zip(_SCREAMING_SNAKE_CASE  ,	_SCREAMING_SNAKE_CASE   )]

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

	# declaring useful variables
	__lowercase		       =			len(_SCREAMING_SNAKE_CASE   )
	__lowercase		       =			0
	__lowercase		       =			0
	__lowercase		       =			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
		__lowercase		       =			sorted_profit_by_weight[length - i - 1]
		__lowercase		       =			profit_by_weight.index(_SCREAMING_SNAKE_CASE   )
		__lowercase		       =			-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."""
	)

	snake_case__					:     str    		=   [int(x) for x in input("""Input profits separated by spaces: """).split()]
	snake_case__					:     str    		=   [int(x) for x in input("""Input weights separated by spaces: """).split()]
	snake_case__					:     Optional[Any]    		=   int(input("""Max weight allowed: """))

	# Function Call
	calc_profit(profit, weight, max_weight)



