
def      __lowerCAmelCase						(							UpperCAmelCase__				:      list			,				UpperCAmelCase__				:      list			,				UpperCAmelCase__				:      int       )  ->    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.
							lowerCamelCase_							  =					[p / w for p, w in zip(UpperCAmelCase__			,				UpperCAmelCase__       )]

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

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

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

		# Function Call
		calc_profit(profit, weight, max_weight)







import os
import socket
from contextlib import contextmanager

import torch

from ..commands.config.default import write_basic_config  # noqa: F401
from ..state import PartialState
from .dataclasses import DistributedType
from .imports import is_deepspeed_available, is_tpu_available
from .transformer_engine import convert_model
from .versions import is_torch_version


if is_deepspeed_available():
		from deepspeed import DeepSpeedEngine

if is_tpu_available(check_device=False):
		import torch_xla.core.xla_model as xm



def      __lowerCAmelCase						(							UpperCAmelCase__				:      Any       )  ->    List[str]:
							if is_torch_version("""<"""			,				"""2.0.0"""       ) or not hasattr(UpperCAmelCase__			,				"""_dynamo"""       ):
														return False
							return isinstance(UpperCAmelCase__			,				torch._dynamo.eval_frame.OptimizedModule       )



def      __lowerCAmelCase						(							UpperCAmelCase__				:      str			,				UpperCAmelCase__				:      bool = True       )  ->    str:
							lowerCamelCase_							  =					(torch.nn.parallel.DistributedDataParallel, torch.nn.DataParallel)

							lowerCamelCase_							  =					is_compiled_module(UpperCAmelCase__       )
							if is_compiled:
														lowerCamelCase_							  =					model
														lowerCamelCase_							  =					model._orig_mod

							if is_deepspeed_available():
														options += (DeepSpeedEngine,)

							while isinstance(UpperCAmelCase__			,				UpperCAmelCase__       ):
														lowerCamelCase_							  =					model.module

							if not keep_fpaa_wrapper:
														lowerCamelCase_							  =					getattr(UpperCAmelCase__			,				"""forward"""       )
														lowerCamelCase_							  =					model.__dict__.pop("""_original_forward"""			,				UpperCAmelCase__       )
														if original_forward is not None:
																					while hasattr(UpperCAmelCase__			,				"""__wrapped__"""       ):
																												lowerCamelCase_							  =					forward.__wrapped__
																												if forward == original_forward:
																																			break
																					lowerCamelCase_							  =					forward
														if getattr(UpperCAmelCase__			,				"""_converted_to_transformer_engine"""			,				UpperCAmelCase__       ):
																					convert_model(UpperCAmelCase__			,				to_transformer_engine=UpperCAmelCase__       )

							if is_compiled:
														lowerCamelCase_							  =					model
														lowerCamelCase_							  =					compiled_model

							return model



def      __lowerCAmelCase						(							)  ->    Any:
							PartialState().wait_for_everyone()



def      __lowerCAmelCase						(							UpperCAmelCase__				:      Union[str, Any]			,				UpperCAmelCase__				:      Tuple       )  ->    Dict:
							if PartialState().distributed_type == DistributedType.TPU:
														xm.save(UpperCAmelCase__			,				UpperCAmelCase__       )
							elif PartialState().local_process_index == 0:
														torch.save(UpperCAmelCase__			,				UpperCAmelCase__       )



@contextmanager
def      __lowerCAmelCase						(							**UpperCAmelCase__				:      Any       )  ->    Dict:
							for key, value in kwargs.items():
														lowerCamelCase_							  =					str(UpperCAmelCase__       )

							yield

							for key in kwargs:
														if key.upper() in os.environ:
																					del os.environ[key.upper()]



def      __lowerCAmelCase						(							UpperCAmelCase__				:      Union[str, Any]       )  ->    str:
							if not hasattr(UpperCAmelCase__			,				"""__qualname__"""       ) and not hasattr(UpperCAmelCase__			,				"""__name__"""       ):
														lowerCamelCase_							  =					getattr(UpperCAmelCase__			,				"""__class__"""			,				UpperCAmelCase__       )
							if hasattr(UpperCAmelCase__			,				"""__qualname__"""       ):
														return obj.__qualname__
							if hasattr(UpperCAmelCase__			,				"""__name__"""       ):
														return obj.__name__
							return str(UpperCAmelCase__       )



def      __lowerCAmelCase						(							UpperCAmelCase__				:      str			,				UpperCAmelCase__				:      Union[str, Any]       )  ->    Dict:
							for key, value in source.items():
														if isinstance(UpperCAmelCase__			,				UpperCAmelCase__       ):
																					lowerCamelCase_							  =					destination.setdefault(UpperCAmelCase__			,				{}       )
																					merge_dicts(UpperCAmelCase__			,				UpperCAmelCase__       )
														else:
																					lowerCamelCase_							  =					value

							return destination



def      __lowerCAmelCase						(							UpperCAmelCase__				:      int = None       )  ->    bool:
							if port is None:
														lowerCamelCase_							  =					2_9_5_0_0
							with socket.socket(socket.AF_INET			,				socket.SOCK_STREAM       ) as s:
														return s.connect_ex(("""localhost""", port)       ) == 0





