"""simple docstring"""







import math

import qiskit


def      __lowerCAmelCase(		__UpperCAmelCase = 1     ,__UpperCAmelCase = 1     ,__UpperCAmelCase = 1			):






	"""simple docstring"""





	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
	_lowercase :    Tuple							=							qiskit.QuantumRegister(4     ,'qr'			)
	_lowercase :    Dict							=							qiskit.ClassicalRegister(2     ,'cr'			)
	# list the entries
	_lowercase :    str							=							[input_a, input_a, carry_in]

	_lowercase :    Tuple							=							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

	_lowercase :    List[Any]							=							qiskit.Aer.get_backend('aer_simulator'			)
	_lowercase :    List[str]							=							qiskit.execute(__UpperCAmelCase     ,__UpperCAmelCase     ,shots=1_000			)

	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"""







def      __lowerCAmelCase(		__UpperCAmelCase			):






	"""simple docstring"""





	_lowercase :    str							=							[0 for i in range(len(__UpperCAmelCase			)			)]

	# initialize interval's left pointer and right pointer
	_lowercase				,      _lowercase :    str							=							0, 0

	for i in range(1     ,len(__UpperCAmelCase			)			):
		# case when current index is inside the interval
		if i <= right_pointer:
			_lowercase :    Union[str, Any]							=							min(right_pointer - i + 1     ,z_result[i - left_pointer]			)
			_lowercase :    Any							=							min_edge

		while go_next(__UpperCAmelCase     ,__UpperCAmelCase     ,__UpperCAmelCase			):
			z_result[i] += 1

		# if new index's result gives us more right interval,
		# we've to update left_pointer and right_pointer
		if i + z_result[i] - 1 > right_pointer:
			_lowercase				,      _lowercase :    Optional[int]							=							i, i + z_result[i] - 1

	return z_result


def      __lowerCAmelCase(		__UpperCAmelCase     ,__UpperCAmelCase     ,__UpperCAmelCase			):






	"""simple docstring"""





	return i + z_result[i] < len(__UpperCAmelCase			) and s[z_result[i]] == s[i + z_result[i]]


def      __lowerCAmelCase(		__UpperCAmelCase     ,__UpperCAmelCase			):






	"""simple docstring"""





	_lowercase :    Union[str, Any]							=							0
	# concatenate 'pattern' and 'input_str' and call z_function
	# with concatenated string
	_lowercase :    List[str]							=							z_function(pattern + input_str			)

	for val in z_result:
		# if value is greater then length of the pattern string
		# that means this index is starting position of substring
		# which is equal to pattern string
		if val >= len(__UpperCAmelCase			):
			answer += 1

	return answer


if __name__ == "__main__":
						import doctest

						doctest.testmod()



