






'''simple docstring'''







from copy import deepcopy




class   __SCREAMING_SNAKE_CASE       :


  """simple docstring"""


  def __init__(			self   ,	UpperCamelCase__ = None   ,	UpperCamelCase__ = None	):






         """simple docstring"""


         if arr is None and size is not None:
                a_						     =			size
                a_						     =			[0] * size
         elif arr is not None:
                self.init(UpperCamelCase__	)
         else:
                raise ValueError('Either arr or size must be specified'	)







  def    _a       (			self   ,	UpperCamelCase__	):






         """simple docstring"""


         a_						     =			len(UpperCamelCase__	)
         a_						     =			deepcopy(UpperCamelCase__	)
         for i in range(1   ,	self.size	):
                a_						     =			self.next_(UpperCamelCase__	)
                if j < self.size:
                       self.tree[j] += self.tree[i]







  def    _a       (			self	):






         """simple docstring"""


         a_						     =			self.tree[:]
         for i in range(self.size - 1   ,	0   ,	-1	):
                a_						     =			self.next_(UpperCamelCase__	)
                if j < self.size:
                       arr[j] -= arr[i]
         return arr







  @staticmethod
  def    _a       (			UpperCamelCase__	):






         """simple docstring"""


         return index + (index & (-index))







  @staticmethod
  def    _a       (			UpperCamelCase__	):






         """simple docstring"""


         return index - (index & (-index))







  def    _a       (			self   ,	UpperCamelCase__   ,	UpperCamelCase__	):






         """simple docstring"""


         if index == 0:
                self.tree[0] += value
                return
         while index < self.size:
                self.tree[index] += value
                a_						     =			self.next_(UpperCamelCase__	)







  def    _a       (			self   ,	UpperCamelCase__   ,	UpperCamelCase__	):






         """simple docstring"""


         self.add(UpperCamelCase__   ,	value - self.get(UpperCamelCase__	)	)







  def    _a       (			self   ,	UpperCamelCase__	):






         """simple docstring"""


         if right == 0:
                return 0
         a_						     =			self.tree[0]
         right -= 1  # make right inclusive
         while right > 0:
                result += self.tree[right]
                a_						     =			self.prev(UpperCamelCase__	)
         return result







  def    _a       (			self   ,	UpperCamelCase__   ,	UpperCamelCase__	):






         """simple docstring"""


         return self.prefix(UpperCamelCase__	) - self.prefix(UpperCamelCase__	)







  def    _a       (			self   ,	UpperCamelCase__	):






         """simple docstring"""


         return self.query(UpperCamelCase__   ,	index + 1	)







  def    _a       (			self   ,	UpperCamelCase__	):






         """simple docstring"""


         value -= self.tree[0]
         if value < 0:
                return -1

         a_						     =			1  # Largest power of 2 <= size
         while j * 2 < self.size:
                j *= 2

         a_						     =			0

         while j > 0:
                if i + j < self.size and self.tree[i + j] <= value:
                       value -= self.tree[i + j]
                       i += j
                j //= 2
         return i


if __name__ == "__main__":
  import doctest

  doctest.testmod()












'''simple docstring'''







import math

import qiskit


def       __UpperCamelCase					(      lowercase_       :  int = 1   ,       lowercase_       :  int = 1   ,       lowercase_       :  int = 1   ):
       """simple docstring"""




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

       a_						     =			qiskit.QuantumCircuit(lowercase_   ,       lowercase_   )

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

       a_						     =			qiskit.Aer.get_backend('aer_simulator'   )
       a_						     =			qiskit.execute(lowercase_   ,       lowercase_   ,       shots=1_000   )

       return job.result().get_counts(lowercase_   )


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




