'''simple docstring'''

import qiskit
from qiskit.providers import Backend



def 				UpperCamelCase__      (      a__      ,   a__   ):


						'''simple docstring'''






						_lowerCAmelCase    ,					_lowerCAmelCase					    =bin(a__   )[2:], bin(a__   )[2:]  # Remove leading '0b'

						# Ensure that both strings are of the same length
						if len(a__   ) > len(a__   ):
												_lowerCAmelCase					    =y.zfill(len(a__   )   )
						else:
												_lowerCAmelCase					    =x.zfill(len(a__   )   )

						# 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
						_lowerCAmelCase					    =qiskit.QuantumCircuit((len(a__   ) * 3) + 1      ,   len(a__   ) + 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(a__   )   ):
												if x[::-1][i] == "1":
																		circuit.x(a__   )
						for j in range(len(a__   )   ):
												if y[::-1][j] == "1":
																		circuit.x(len(a__   ) + j   )

						return circuit, x, y



def 				UpperCamelCase__      (      a__      ,   a__      ,   a__      ,   a__      ,   a__      ,   ):


						'''simple docstring'''






						circuit.ccx(a__      ,   a__      ,   a__   )
						circuit.cx(a__      ,   a__   )
						circuit.ccx(a__      ,   a__      ,   a__   )
						circuit.cx(a__      ,   a__   )
						circuit.cx(a__      ,   a__   )



def 				UpperCamelCase__      (      a__      ,   a__      ,   a__ = qiskit.Aer.get_backend('aer_simulator'   )      ,   ):


						'''simple docstring'''






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

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

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

						_lowerCAmelCase					    =qiskit.execute(a__      ,   a__      ,   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()






'''simple docstring'''

from itertools import compress, repeat
from math import ceil, sqrt



def 				UpperCamelCase__      (      a__   ):


						'''simple docstring'''






						if num <= 2:
												return []
						if num == 3:
												return [2]

						# Odd sieve for numbers in range [3, num - 1]
						_lowerCAmelCase					    =bytearray(B'\x01'   ) * ((num >> 1) - 1)

						for i in range(3      ,   int(sqrt(a__   )   ) + 1      ,   2   ):
												if sieve[(i >> 1) - 1]:
																		_lowerCAmelCase					    =i**2
																		_lowerCAmelCase					    =repeat(
																		    0      ,   ceil((num - i_squared) / (i << 1)   )   )

						return [2] + list(compress(range(3      ,   a__      ,   2   )      ,   a__   )   )


if __name__ == "__main__":
							import doctest

							doctest.testmod()





