




"""simple docstring"""




import math

import qiskit



def        a__					(							snake_case__ = 1			,					snake_case__ = 1			,					snake_case__ = 1							)		->   qiskit.result.counts.Counts:
			if (
			    isinstance(snake_case__			,					snake_case__							)
			    or isinstance(snake_case__			,					snake_case__							)
			    or isinstance(snake_case__			,					snake_case__							)
			):
						raise TypeError("""inputs must be integers."""							)

			if (input_a < 0) or (input_a < 0) or (carry_in < 0):
						raise ValueError("""inputs must be positive."""							)

			if (
			    (math.floor(snake_case__							) != input_a)
			    or (math.floor(snake_case__							) != input_a)
			    or (math.floor(snake_case__							) != carry_in)
			):
						raise ValueError("""inputs must be exact integers."""							)

			if (input_a > 2) or (input_a > 2) or (carry_in > 2):
						raise ValueError("""inputs must be less or equal to 2."""							)

			# build registers
			lowerCamelCase      =   qiskit.QuantumRegister(4			,					"""qr"""							)
			lowerCamelCase      =   qiskit.ClassicalRegister(2			,					"""cr"""							)
			# list the entries
			lowerCamelCase      =   [input_a, input_a, carry_in]

			lowerCamelCase      =   qiskit.QuantumCircuit(snake_case__			,					snake_case__							)

			for i in range(0			,					3							):
						if entry[i] == 2:
									quantum_circuit.h(snake_case__							)  # for hadamard entries
						elif entry[i] == 1:
									quantum_circuit.x(snake_case__							)  # for 1 entries
						elif entry[i] == 0:
									quantum_circuit.i(snake_case__							)  # for 0 entries

    # build the circuit
			quantum_circuit.ccx(0			,					1			,					3							)  # ccx = toffoli gate
			quantum_circuit.cx(0			,					1							)
			quantum_circuit.ccx(1			,					2			,					3							)
			quantum_circuit.cx(1			,					2							)
			quantum_circuit.cx(0			,					1							)

			quantum_circuit.measure([2, 3]			,					snake_case__							)  # measure the last two qbits

			lowerCamelCase      =   qiskit.Aer.get_backend("""aer_simulator"""							)
			lowerCamelCase      =   qiskit.execute(snake_case__			,					snake_case__			,					shots=10_00							)

			return job.result().get_counts(snake_case__							)


if __name__ == "__main__":
					print(F"""Total sum count for state is: {quantum_full_adder(1, 1, 1)}""")









"""simple docstring"""




def        a__					(							snake_case__							)		->   list:

			if len(snake_case__							) <= 1:
						return [tuple(snake_case__							)]

			lowerCamelCase      =   []

			def generate(snake_case__			,					snake_case__							):
						lowerCamelCase      =   [0] * n
						res.append(tuple(snake_case__							)							)

						lowerCamelCase      =   0
						while i < n:
									if c[i] < i:
												if i % 2 == 0:
															lowerCamelCase ,  lowerCamelCase      =   arr[i], arr[0]
												else:
															lowerCamelCase ,  lowerCamelCase      =   arr[i], arr[c[i]]
												res.append(tuple(snake_case__							)							)
												c[i] += 1
												lowerCamelCase      =   0
									else:
												lowerCamelCase      =   0
												i += 1

			generate(len(snake_case__							)			,					snake_case__							)
			return res


if __name__ == "__main__":
					lowerCAmelCase				:     str					=				input("""Enter numbers separated by a comma:\n""").strip()
					lowerCAmelCase				:     List[Any]					=				[int(item) for item in user_input.split(""",""")]
					print(heaps(arr))



