




"""simple docstring"""







import math

import qiskit
def    __lowerCAmelCase    (_UpperCamelCase = 1	,  _UpperCamelCase = 1	,  _UpperCamelCase = 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
	__lowerCAmelCase      :						List[Any]						      =				qiskit.QuantumRegister(4	,  'qr'		)
	__lowerCAmelCase      :						List[Any]						      =				qiskit.ClassicalRegister(2	,  'cr'		)
	# list the entries
	__lowerCAmelCase      :						Tuple						      =				[input_a, input_a, carry_in]

	__lowerCAmelCase      :						Dict						      =				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

	__lowerCAmelCase      :						List[str]						      =				qiskit.Aer.get_backend('aer_simulator'		)
	__lowerCAmelCase      :						str						      =				qiskit.execute(_UpperCamelCase	,  _UpperCamelCase	,  shots=1000		)

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







import os
def    __lowerCAmelCase    (_UpperCamelCase = "input.txt"		):

	with open(os.path.join(os.path.dirname(_UpperCamelCase		)	,  _UpperCamelCase		)		) as input_file:
		__lowerCAmelCase      :						Optional[Any]						      =				[
		    [int(_UpperCamelCase		) for element in line.split(','		)]
		    for line in input_file.readlines()
		]

	__lowerCAmelCase      :						List[str]						      =				len(_UpperCamelCase		)
	__lowerCAmelCase      :						Tuple						      =				len(matrix[0]		)

	__lowerCAmelCase      :						int						      =				[[-1 for _ in range(_UpperCamelCase		)] for _ in range(_UpperCamelCase		)]
	for i in range(_UpperCamelCase		):
		__lowerCAmelCase      :						Any						      =				matrix[i][0]

	for j in range(1	,  _UpperCamelCase		):
		for i in range(_UpperCamelCase		):
			__lowerCAmelCase      :						Optional[Any]						      =				minimal_path_sums[i][j - 1] + matrix[i][j]

		for i in range(1	,  _UpperCamelCase		):
			__lowerCAmelCase      :						Optional[Any]						      =				min(
			    minimal_path_sums[i][j]	,  minimal_path_sums[i - 1][j] + matrix[i][j]		)

		for i in range(rows - 2	,  -1	,  -1		):
			__lowerCAmelCase      :						List[str]						      =				min(
			    minimal_path_sums[i][j]	,  minimal_path_sums[i + 1][j] + matrix[i][j]		)

	return min(minimal_path_sums_row[-1] for minimal_path_sums_row in minimal_path_sums		)


if __name__ == "__main__":
							print(f'{solution() = }')