
import qiskit
from qiskit.providers import Backend

def 					SCREAMING_SNAKE_CASE  (   __UpperCamelCase			:    int				,    __UpperCamelCase			:    int							)			->							List[str]:

				"""simple docstring"""







				A__							,				A__	:						List[str]								=				bin(__lowerCamelCase							)[2:], bin(__lowerCamelCase							)[2:]  # Remove leading '0b'

				# Ensure that both strings are of the same length
				if len(__lowerCamelCase							) > len(__lowerCamelCase							):
								A__	:						Optional[int]								=				y.zfill(len(__lowerCamelCase							)							)
				else:
								A__	:						str								=				x.zfill(len(__lowerCamelCase							)							)

				# We need (3 * number of bits in the larger number)+1 qBits
				# The second parameter is the number of classical registers, to measure the result
				A__	:						Tuple								=				qiskit.QuantumCircuit((len(__lowerCamelCase							) * 3) + 1				,    len(__lowerCamelCase							) + 1							)

				# We are essentially "not-ing" the bits that are 1
				# Reversed because it's easier to perform ops on more significant bits
				for i in range(len(__lowerCamelCase							)							):
								if x[::-1][i] == "1":
												circuit.x(__lowerCamelCase							)
				for j in range(len(__lowerCamelCase							)							):
								if y[::-1][j] == "1":
												circuit.x(len(__lowerCamelCase							) + j							)

				return circuit, x, y

def 					SCREAMING_SNAKE_CASE  (   __UpperCamelCase			:    qiskit.QuantumCircuit				,    __UpperCamelCase			:    int				,    __UpperCamelCase			:    int				,    __UpperCamelCase			:    int				,    __UpperCamelCase			:    int				,    )			->							Tuple:

				"""simple docstring"""







				circuit.ccx(__lowerCamelCase				,    __lowerCamelCase				,    __lowerCamelCase							)
				circuit.cx(__lowerCamelCase				,    __lowerCamelCase							)
				circuit.ccx(__lowerCamelCase				,    __lowerCamelCase				,    __lowerCamelCase							)
				circuit.cx(__lowerCamelCase				,    __lowerCamelCase							)
				circuit.cx(__lowerCamelCase				,    __lowerCamelCase							)

def 					SCREAMING_SNAKE_CASE  (   __UpperCamelCase			:    int				,    __UpperCamelCase			:    int				,    __UpperCamelCase			:    Backend = qiskit.Aer.get_backend('''aer_simulator'''							)				,    )			->							Optional[Any]:

				"""simple docstring"""







				if vala < 0 or vala < 0:
								raise ValueError('''Both Integers must be positive!'''							)

				# Store the Integers
				A__							,				A__							,				A__	:						Any								=				store_two_classics(__lowerCamelCase				,    __lowerCamelCase							)
				for i in range(len(__lowerCamelCase							)							):
								full_adder(__lowerCamelCase				,    __lowerCamelCase				,    len(__lowerCamelCase							) + i				,    len(__lowerCamelCase							) + len(__lowerCamelCase							) + i				,    len(__lowerCamelCase							) + len(__lowerCamelCase							) + i + 1							)
								circuit.barrier()  # Optional, just for aesthetics

				# Measure the resultant qBits
				for i in range(len(__lowerCamelCase							) + 1							):
								circuit.measure([(len(__lowerCamelCase							) * 2) + i]				,    [i]							)

				A__	:						Any								=				qiskit.execute(__lowerCamelCase				,    __lowerCamelCase				,    shots=1							).result()

				# The result is in binary. Convert it back to int
				return int(list(res.get_counts()							)[0]				,    2							)


if __name__ == "__main__":
					import doctest

					doctest.testmod()



from __future__ import annotations

from statistics import mean




def SCREAMING_SNAKE_CASE_  (				__lowerCamelCase:		list[int]  ):







	'''simple docstring'''



	lowercase_			 = 2
	lowercase_			 = list(__lowerCamelCase  )
	lowercase_			 = [0] * len(__lowerCamelCase  )
	lowercase_			 = 0
	while True:
		lowercase_			 = True
		for i, burst_time in enumerate(__lowerCamelCase  ):
			if rem_burst_times[i] > 0:
				lowercase_			 = False
				if rem_burst_times[i] > quantum:
					t += quantum
					rem_burst_times[i] -= quantum
				else:
					t += rem_burst_times[i]
					lowercase_			 = t - burst_time
					lowercase_			 = 0
		if done is True:
			return waiting_times




def SCREAMING_SNAKE_CASE_  (				__lowerCamelCase:		list[int]  ,			__lowerCamelCase:		list[int]  ):







	'''simple docstring'''



	return [burst + waiting for burst, waiting in zip(__lowerCamelCase  ,			__lowerCamelCase  )]


if __name__ == "__main__":
							SCREAMING_SNAKE_CASE__       			=				[3, 5, 7]
							SCREAMING_SNAKE_CASE__       			=				calculate_waiting_times(burst_times)
							SCREAMING_SNAKE_CASE__       			=				calculate_turn_around_times(burst_times, waiting_times)
							print("""Process ID \tBurst Time \tWaiting Time \tTurnaround Time""")
							for i, burst_time in enumerate(burst_times):
														print(
														    f"""  {i + 1}\t\t  {burst_time}\t\t  {waiting_times[i]}\t\t  """
														    f"""{turn_around_times[i]}"""
														)
							print(f"""\nAverage waiting time = {mean(waiting_times):.5f}""")
							print(f"""Average turn around time = {mean(turn_around_times):.5f}""")

