
import qiskit
from qiskit.providers import Backend



def 		UpperCamelCase    (					_UpperCAmelCase     :      int   , _UpperCAmelCase     :      int     )      -> tuple[qiskit.QuantumCircuit, str, str]:






						'''simple docstring'''

						_lowercase					:  int    			=      bin(_UpperCAmelCase     )[2:], bin(_UpperCAmelCase     )[2:]  # Remove leading '0b'

						# Ensure that both strings are of the same length
						if len(_UpperCAmelCase     ) > len(_UpperCAmelCase     ):
												_lowercase					:  Optional[int]    			=      y.zfill(len(_UpperCAmelCase     )     )
						else:
												_lowercase					:  List[Any]    			=      x.zfill(len(_UpperCAmelCase     )     )

						# We need (3 * number of bits in the larger number)+1 qBits
						# The second parameter is the number of classical registers, to measure the result
						_lowercase					:  Union[str, Any]    			=      qiskit.QuantumCircuit((len(_UpperCAmelCase     ) * 3) + 1   , len(_UpperCAmelCase     ) + 1     )

						# We are essentially "not-ing" the bits that are 1
						# Reversed because it's easier to perform ops on more significant bits
						for i in range(len(_UpperCAmelCase     )     ):
												if x[::-1][i] == "1":
																		circuit.x(_UpperCAmelCase     )
						for j in range(len(_UpperCAmelCase     )     ):
												if y[::-1][j] == "1":
																		circuit.x(len(_UpperCAmelCase     ) + j     )

						return circuit, x, y



def 		UpperCamelCase    (					_UpperCAmelCase     :      qiskit.QuantumCircuit   , _UpperCAmelCase     :      int   , _UpperCAmelCase     :      int   , _UpperCAmelCase     :      int   , _UpperCAmelCase     :      int   , )      -> Tuple:






						'''simple docstring'''

						circuit.ccx(_UpperCAmelCase   , _UpperCAmelCase   , _UpperCAmelCase     )
						circuit.cx(_UpperCAmelCase   , _UpperCAmelCase     )
						circuit.ccx(_UpperCAmelCase   , _UpperCAmelCase   , _UpperCAmelCase     )
						circuit.cx(_UpperCAmelCase   , _UpperCAmelCase     )
						circuit.cx(_UpperCAmelCase   , _UpperCAmelCase     )



def 		UpperCamelCase    (					_UpperCAmelCase     :      int   , _UpperCAmelCase     :      int   , _UpperCAmelCase     :      Backend = qiskit.Aer.get_backend("aer_simulator"     )   , )      -> int:






						'''simple docstring'''

						if vala < 0 or vala < 0:
												raise ValueError("Both Integers must be positive!"     )

						# Store the Integers
						_lowercase					:  Optional[int]    			=      store_two_classics(_UpperCAmelCase   , _UpperCAmelCase     )
						for i in range(len(_UpperCAmelCase     )     ):
												full_adder(_UpperCAmelCase   , _UpperCAmelCase   , len(_UpperCAmelCase     ) + i   , len(_UpperCAmelCase     ) + len(_UpperCAmelCase     ) + i   , len(_UpperCAmelCase     ) + len(_UpperCAmelCase     ) + i + 1     )
												circuit.barrier()  # Optional, just for aesthetics

						# Measure the resultant qBits
						for i in range(len(_UpperCAmelCase     ) + 1     ):
												circuit.measure([(len(_UpperCAmelCase     ) * 2) + i]   , [i]     )

						_lowercase					:  Optional[Any]    			=      qiskit.execute(_UpperCAmelCase   , _UpperCAmelCase   , shots=1     ).result()

						# The result is in binary. Convert it back to int
						return int(list(res.get_counts()     )[0]   , 2     )


if __name__ == "__main__":
							import doctest

							doctest.testmod()








import os



def 		UpperCamelCase    (					)      -> Optional[int]:






						'''simple docstring'''

						_lowercase					:  Tuple    			=      0
						_lowercase					:  List[Any]    			=      0
						with open(os.path.dirname(_UpperCAmelCase     ) + "/p022_names.txt"     ) as file:
												_lowercase					:  Any    			=      str(file.readlines()[0]     )
												_lowercase					:  int    			=      name.replace("\""   , ""     ).split(","     )

						name.sort()
						for i in range(len(_UpperCAmelCase     )     ):
												for j in name[i]:
																		temp_sum += ord(_UpperCAmelCase     ) - ord("A"     ) + 1
												total_sum += (i + 1) * temp_sum
												_lowercase					:  Tuple    			=      0
						return total_sum


if __name__ == "__main__":
							print(solution())




