'''simple docstring'''






import flax.linen as nn
import jax
import jax.numpy as jnp







class lowercase_       (		nn.Module			):







   """simple docstring"""

   __lowerCAmelCase         =   4_2
   __lowerCAmelCase         =   jnp.floataa
   def 	__UpperCAmelCase   (      self      :			Optional[int]     )  ->			str:
        _A    		=  nn.Conv(
            self.out_channels, kernel_size=(3, 3), strides=(1, 1), padding=((1, 1), (1, 1)), dtype=self.dtype, )

   def __call__(      self      :			Any, UpperCamelCase__      :			Optional[int]     )  ->			Any:
        _A    		=  hidden_states.shape
        _A    		=  jax.image.resize(
            UpperCamelCase__, shape=(batch, height * 2, width * 2, channels), method='nearest', )
        _A    		=  self.conv(UpperCamelCase__     )
        return hidden_states







class lowercase_       (		nn.Module			):







   """simple docstring"""

   __lowerCAmelCase         =   4_2
   __lowerCAmelCase         =   jnp.floataa
   def 	__UpperCAmelCase   (      self      :			Optional[int]     )  ->			int:
        _A    		=  nn.Conv(
            self.out_channels, kernel_size=(3, 3), strides=(2, 2), padding=((1, 1), (1, 1)), dtype=self.dtype, )

   def __call__(      self      :			List[str], UpperCamelCase__      :			Union[str, Any]     )  ->			Any:
        _A    		=  self.conv(UpperCamelCase__     )
        return hidden_states







class lowercase_       (		nn.Module			):







   """simple docstring"""

   __lowerCAmelCase         =   4_2
   __lowerCAmelCase         =   None
   __lowerCAmelCase         =   0.0
   __lowerCAmelCase         =   None
   __lowerCAmelCase         =   jnp.floataa
   def 	__UpperCAmelCase   (      self      :			Optional[Any]     )  ->			List[str]:
        _A    		=  self.in_channels if self.out_channels is None else self.out_channels

        _A    		=  nn.GroupNorm(num_groups=32, epsilon=1e-5     )
        _A    		=  nn.Conv(
            UpperCamelCase__, kernel_size=(3, 3), strides=(1, 1), padding=((1, 1), (1, 1)), dtype=self.dtype, )

        _A    		=  nn.Dense(UpperCamelCase__, dtype=self.dtype     )

        _A    		=  nn.GroupNorm(num_groups=32, epsilon=1e-5     )
        _A    		=  nn.Dropout(self.dropout_prob     )
        _A    		=  nn.Conv(
            UpperCamelCase__, kernel_size=(3, 3), strides=(1, 1), padding=((1, 1), (1, 1)), dtype=self.dtype, )

        _A    		=  self.in_channels != out_channels if self.use_nin_shortcut is None else self.use_nin_shortcut

        _A    		=  None
        if use_nin_shortcut:
             _A    		=  nn.Conv(
                 UpperCamelCase__, kernel_size=(1, 1), strides=(1, 1), padding='VALID', dtype=self.dtype, )

   def __call__(      self      :			List[Any], UpperCamelCase__      :			Optional[Any], UpperCamelCase__      :			Optional[Any], UpperCamelCase__      :			List[Any]=True     )  ->			List[Any]:
        _A    		=  hidden_states
        _A    		=  self.norma(UpperCamelCase__     )
        _A    		=  nn.swish(UpperCamelCase__     )
        _A    		=  self.conva(UpperCamelCase__     )

        _A    		=  self.time_emb_proj(nn.swish(UpperCamelCase__     )     )
        _A    		=  jnp.expand_dims(jnp.expand_dims(UpperCamelCase__, 1     ), 1     )
        _A    		=  hidden_states + temb

        _A    		=  self.norma(UpperCamelCase__     )
        _A    		=  nn.swish(UpperCamelCase__     )
        _A    		=  self.dropout(UpperCamelCase__, UpperCamelCase__     )
        _A    		=  self.conva(UpperCamelCase__     )

        if self.conv_shortcut is not None:
             _A    		=  self.conv_shortcut(UpperCamelCase__     )

        return hidden_states + residual










def   __snake_case    (       _lowerCAmelCase			:			list					,					_lowerCAmelCase			:			list					,					_lowerCAmelCase			:			int						)			->    int:
   if len(_lowerCAmelCase						) != len(_lowerCAmelCase						):
      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.
   A_       :					Dict        =      [p / w for p, w in zip(_lowerCAmelCase					,					_lowerCAmelCase						)]

   # Creating a copy of the list and sorting profit/weight in ascending order
   A_       :					Optional[Any]        =      sorted(_lowerCAmelCase						)

   # declaring useful variables
   A_       :					List[Any]        =      len(_lowerCAmelCase						)
   A_       :					List[Any]        =      0
   A_       :					Any        =      0
   A_       :					List[Any]        =      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
      A_       :					List[Any]        =      sorted_profit_by_weight[length - i - 1]
      A_       :					List[Any]        =      profit_by_weight.index(_lowerCAmelCase						)
      A_       :					List[Any]        =      -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.'''
 )

 _lowerCAmelCase				:   int						       =						[int(x) for x in input('''Input profits separated by spaces: ''').split()]
 _lowerCAmelCase				:   Dict						       =						[int(x) for x in input('''Input weights separated by spaces: ''').split()]
 _lowerCAmelCase				:   Union[str, Any]						       =						int(input('''Max weight allowed: '''))

 # Function Call
 calc_profit(profit, weight, max_weight)
