


"""simple docstring"""



def 		__lowercase					(       snake_case_  :  list    ,snake_case_  :  list    ,snake_case_  :  int						)       ->int:



    '''simple docstring'''







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

    # Creating a copy of the list and sorting profit/weight in ascending order
    __A   :						Any									=					sorted(snake_case_						)

    # declaring useful variables
    __A   :						Tuple									=					len(snake_case_						)
    __A   :						Optional[int]									=					0
    __A   :						List[Any]									=					0
    __A   :						Optional[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
        __A   :						str									=					sorted_profit_by_weight[length - i - 1]
        __A   :						Union[str, Any]									=					profit_by_weight.index(snake_case_						)
        __A   :						int									=					-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."""
       )

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

       # Function Call
       calc_profit(profit, weight, max_weight)











"""simple docstring"""



import numpy as np
import qiskit







def 		__lowercase					(       snake_case_  :  int = 8    ,snake_case_  :  int | None = None						)       ->str:



    '''simple docstring'''







    __A   :						str									=					np.random.default_rng(seed=snake_case_						)

    # Roughly 25% of the qubits will contribute to the key.
    # So we take more than we need.
    __A   :						str									=					6 * key_len
    # Measurement basis for Alice's qubits.
    __A   :						Any									=					rng.integers(2    ,size=snake_case_						)
    # The set of states Alice will prepare.
    __A   :						Any									=					rng.integers(2    ,size=snake_case_						)
    # Measurement basis for Bob's qubits.
    __A   :						str									=					rng.integers(2    ,size=snake_case_						)

    # Quantum Circuit to simulate BB84
    __A   :						Dict									=					qiskit.QuantumCircuit(snake_case_    ,name='''BB84'''						)

    # Alice prepares her qubits according to rules above.
    for index, _ in enumerate(snake_case_						):
        if alice_state[index] == 1:
            bbaa_circ.x(snake_case_						)
        if alice_basis[index] == 1:
            bbaa_circ.h(snake_case_						)
    bbaa_circ.barrier()

    # Bob measures the received qubits according to rules above.
    for index, _ in enumerate(snake_case_						):
        if bob_basis[index] == 1:
            bbaa_circ.h(snake_case_						)

    bbaa_circ.barrier()
    bbaa_circ.measure_all()

    # Simulate the quantum circuit.
    __A   :						List[str]									=					qiskit.Aer.get_backend('''aer_simulator'''						)
    # We only need to run one shot because the key is unique.
    # Multiple shots will produce the same key.
    __A   :						List[str]									=					qiskit.execute(snake_case_    ,snake_case_    ,shots=1    ,seed_simulator=snake_case_						)
    # Returns the result of measurement.
    __A   :						Union[str, Any]									=					job.result().get_counts(snake_case_						).most_frequent()

    # Extracting the generated key from the simulation results.
    # Only keep measurement results where Alice and Bob chose the same basis.
    __A   :						int									=					''''''.join(
        [
            result_bit
            for alice_basis_bit, bob_basis_bit, result_bit in zip(
                snake_case_    ,snake_case_    ,snake_case_						)
            if alice_basis_bit == bob_basis_bit
        ]						)

    # Get final key. Pad with 0 if too short, otherwise truncate.
    __A   :						Union[str, Any]									=					gen_key[:key_len] if len(snake_case_						) >= key_len else gen_key.ljust(snake_case_    ,'''0'''						)
    return key


if __name__ == "__main__":
       print(f'''The generated key is : {bbaa(8, seed=0)}''')
       from doctest import testmod

       testmod()




