


import argparse
import json
import re
import string
import sys
from collections import Counter
def     UpperCamelCase_(			_A				:Optional[int]					)->						Optional[int]:

			def remove_articles(_A				:List[Any]					):
						return re.sub(r"\b(a|an|the)\b"			,       " "			,       _A					)

			def white_space_fix(_A				:Tuple					):
						return " ".join(text.split()					)

			def remove_punc(_A				:Any					):
						UpperCamelCase__   =    set(string.punctuation					)
						return "".join(ch for ch in text if ch not in exclude					)

			def lower(_A				:Tuple					):
						return text.lower()

			return white_space_fix(remove_articles(remove_punc(lower(_A					)					)					)					)
def     UpperCamelCase_(			_A				:Union[str, Any]			,       _A				:Union[str, Any]					)->						str:
			UpperCamelCase__   =    normalize_answer(_A					).split()
			UpperCamelCase__   =    normalize_answer(_A					).split()
			UpperCamelCase__   =    Counter(_A					) & Counter(_A					)
			UpperCamelCase__   =    sum(common.values()					)
			if num_same == 0:
						return 0
			UpperCamelCase__   =    1.0 * num_same / len(_A					)
			UpperCamelCase__   =    1.0 * num_same / len(_A					)
			UpperCamelCase__   =    (2 * precision * recall) / (precision + recall)
			return fa
def     UpperCamelCase_(			_A				:int			,       _A				:Optional[Any]					)->						Union[str, Any]:
			return normalize_answer(_A					) == normalize_answer(_A					)
def     UpperCamelCase_(			_A				:Dict			,       _A				:str			,       _A				:List[Any]					)->						List[str]:
			UpperCamelCase__   =    []
			for ground_truth in ground_truths:
						UpperCamelCase__   =    metric_fn(_A			,       _A					)
						scores_for_ground_truths.append(_A					)
			return max(_A					)
def     UpperCamelCase_(			_A				:List[Any]			,       _A				:Optional[Any]					)->						Dict:
			UpperCamelCase__   =    UpperCamelCase__   =    UpperCamelCase__   =    0
			for article in dataset:
						for paragraph in article["paragraphs"]:
									for qa in paragraph["qas"]:
												total += 1
												if qa["id"] not in predictions:
															UpperCamelCase__   =    "Unanswered question " + qa["id"] + " will receive score 0."
															print(_A			,       file=sys.stderr					)
															continue
												UpperCamelCase__   =    [x["text"] for x in qa["answers"]]
												UpperCamelCase__   =    predictions[qa["id"]]
												exact_match += metric_max_over_ground_truths(_A			,       _A			,       _A					)
												fa += metric_max_over_ground_truths(_A			,       _A			,       _A					)

			UpperCamelCase__   =    1_00.0 * exact_match / total
			UpperCamelCase__   =    1_00.0 * fa / total

			return {"exact_match": exact_match, "f1": fa}


if __name__ == "__main__":
						__UpperCamelCase      						=    '1.1'
						__UpperCamelCase      						=    argparse.ArgumentParser(description='Evaluation for SQuAD ' + expected_version)
						parser.add_argument('dataset_file', help='Dataset file')
						parser.add_argument('prediction_file', help='Prediction File')
						__UpperCamelCase      						=    parser.parse_args()
						with open(args.dataset_file) as dataset_file:
												__UpperCamelCase      						=    json.load(dataset_file)
												if dataset_json["version"] != expected_version:
																		print(
																		    'Evaluation expects v-' + expected_version + ', but got dataset with v-' + dataset_json['version'],
																		    file=sys.stderr,
																		)
												__UpperCamelCase      						=    dataset_json['data']
						with open(args.prediction_file) as prediction_file:
												__UpperCamelCase      						=    json.load(prediction_file)
						print(json.dumps(evaluate(dataset, predictions)))






import qiskit
from qiskit.providers import Backend
def     UpperCamelCase_(			_A				:int			,       _A				:int					)->						tuple[qiskit.QuantumCircuit, str, str]:
			UpperCamelCase__, UpperCamelCase__   =    bin(_A					)[2:], bin(_A					)[2:]  # Remove leading '0b'

			# Ensure that both strings are of the same length
			if len(_A					) > len(_A					):
						UpperCamelCase__   =    y.zfill(len(_A					)					)
			else:
						UpperCamelCase__   =    x.zfill(len(_A					)					)

			# 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
			UpperCamelCase__   =    qiskit.QuantumCircuit((len(_A					) * 3) + 1			,       len(_A					) + 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(_A					)					):
						if x[::-1][i] == "1":
									circuit.x(_A					)
			for j in range(len(_A					)					):
						if y[::-1][j] == "1":
									circuit.x(len(_A					) + j					)

			return circuit, x, y
def     UpperCamelCase_(			_A				:qiskit.QuantumCircuit			,       _A				:int			,       _A				:int			,       _A				:int			,       _A				:int			,       )->						Union[str, Any]:
			circuit.ccx(_A			,       _A			,       _A					)
			circuit.cx(_A			,       _A					)
			circuit.ccx(_A			,       _A			,       _A					)
			circuit.cx(_A			,       _A					)
			circuit.cx(_A			,       _A					)
def     UpperCamelCase_(			_A				:int			,       _A				:int			,       _A				:Backend = qiskit.Aer.get_backend("aer_simulator"					)			,       )->						int:

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

			# Store the Integers
			UpperCamelCase__, UpperCamelCase__, UpperCamelCase__   =    store_two_classics(_A			,       _A					)
			for i in range(len(_A					)					):
						full_adder(_A			,       _A			,       len(_A					) + i			,       len(_A					) + len(_A					) + i			,       len(_A					) + len(_A					) + i + 1					)
						circuit.barrier()  # Optional, just for aesthetics

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

			UpperCamelCase__   =    qiskit.execute(_A			,       _A			,       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()


