import math

import qiskit





def 						__lowerCamelCase				(UpperCAmelCase__  :				int = 1   ,			UpperCAmelCase__  :				int = 1   ,			UpperCAmelCase__  :				int = 1	):


					if (
					    isinstance(UpperCAmelCase__   ,			UpperCAmelCase__	)
					    or isinstance(UpperCAmelCase__   ,			UpperCAmelCase__	)
					    or isinstance(UpperCAmelCase__   ,			UpperCAmelCase__	)
					):
										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(UpperCAmelCase__	) != input_a)
					    or (math.floor(UpperCAmelCase__	) != input_a)
					    or (math.floor(UpperCAmelCase__	) != 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
					SCREAMING_SNAKE_CASE           =							qiskit.QuantumRegister(4   ,			"qr"	)
					SCREAMING_SNAKE_CASE           =							qiskit.ClassicalRegister(2   ,			"cr"	)
					# list the entries
					SCREAMING_SNAKE_CASE           =							[input_a, input_a, carry_in]

					SCREAMING_SNAKE_CASE           =							qiskit.QuantumCircuit(UpperCAmelCase__   ,			UpperCAmelCase__	)

					for i in range(0   ,			3	):
										if entry[i] == 2:
															quantum_circuit.h(UpperCAmelCase__	)  # for hadamard entries
										elif entry[i] == 1:
															quantum_circuit.x(UpperCAmelCase__	)  # for 1 entries
										elif entry[i] == 0:
															quantum_circuit.i(UpperCAmelCase__	)  # 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]   ,			UpperCAmelCase__	)  # measure the last two qbits

					SCREAMING_SNAKE_CASE           =							qiskit.Aer.get_backend("aer_simulator"	)
					SCREAMING_SNAKE_CASE           =							qiskit.execute(UpperCAmelCase__   ,			UpperCAmelCase__   ,			shots=1_0_0_0	)

					return job.result().get_counts(UpperCAmelCase__	)


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










'''simple docstring'''


from __future__ import annotations

from collections import deque
from collections.abc import Iterator
from dataclasses import dataclass

@dataclass
class      A       :
							lowercase_							     =							42
							lowercase_							     =							42



class      A       :







							def __init__(    self			:    Optional[Any]				,     lowerCAmelCase_			:    int   )     ->				str:


														"""simple docstring"""


														_a      	=							[[] for _ in range(lowerCAmelCase_   )]
														_a      	=							size







							def __getitem__(    self			:    Any				,     lowerCAmelCase_			:    int   )     ->				Iterator[Edge]:


														"""simple docstring"""


														return iter(self._graph[vertex]   )







							@property
							def   __lowerCAmelCase     (    self			:    str   )     ->				Tuple:


														"""simple docstring"""


														return self._size







							def   __lowerCAmelCase     (    self			:    Union[str, Any]				,     lowerCAmelCase_			:    int				,     lowerCAmelCase_			:    int				,     lowerCAmelCase_			:    int   )     ->				Dict:


														"""simple docstring"""


														if weight not in (0, 1):
																					raise ValueError('''Edge weight must be either 0 or 1.'''   )

														if to_vertex < 0 or to_vertex >= self.size:
																					raise ValueError('''Vertex indexes must be in [0; size).'''   )

														self._graph[from_vertex].append(Edge(lowerCAmelCase_				,     lowerCAmelCase_   )   )







							def   __lowerCAmelCase     (    self			:    Tuple				,     lowerCAmelCase_			:    int				,     lowerCAmelCase_			:    int   )     ->				int | None:


														"""simple docstring"""


														_a      	=							deque([start_vertex]   )
														_a      	=							[None] * self.size
														_a      	=							0

														while queue:
																					_a      	=							queue.popleft()
																					_a      	=							distances[current_vertex]
																					if current_distance is None:
																												continue

																					for edge in self[current_vertex]:
																												_a      	=							current_distance + edge.weight
																												_a      	=							distances[edge.destination_vertex]
																												if (
																												    isinstance(lowerCAmelCase_				,     lowerCAmelCase_   )
																												    and new_distance >= dest_vertex_distance
																												):
																																			continue
																												_a      	=							new_distance
																												if edge.weight == 0:
																																			queue.appendleft(edge.destination_vertex   )
																												else:
																																			queue.append(edge.destination_vertex   )

														if distances[finish_vertex] is None:
																					raise ValueError('''No path from start_vertex to finish_vertex.'''   )

														return distances[finish_vertex]


if __name__ == "__main__":
				import doctest

				doctest.testmod()

