






"""simple docstring"""



import argparse
import json
import re
import string
import sys
from collections import Counter
def 						_SCREAMING_SNAKE_CASE			(   __snake_case      :  Dict   ):





  '''simple docstring'''





  def remove_articles(__snake_case      :  List[str]   ):
    return re.sub(r'\b(a|an|the)\b'		, ' '		, __snake_case   )

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

  def remove_punc(__snake_case      :  List[str]   ):
    lowercase							   =	set(string.punctuation   )
    return "".join(ch for ch in text if ch not in exclude   )

  def lower(__snake_case      :  Optional[Any]   ):
    return text.lower()

  return white_space_fix(remove_articles(remove_punc(lower(__snake_case   )   )   )   )
def 						_SCREAMING_SNAKE_CASE			(   __snake_case      :  Union[str, Any]		, __snake_case      :  Union[str, Any]   ):





  '''simple docstring'''





  lowercase							   =	normalize_answer(__snake_case   ).split()
  lowercase							   =	normalize_answer(__snake_case   ).split()
  lowercase							   =	Counter(__snake_case   ) & Counter(__snake_case   )
  lowercase							   =	sum(common.values()   )
  if num_same == 0:
    return 0
  lowercase							   =	1.0 * num_same / len(__snake_case   )
  lowercase							   =	1.0 * num_same / len(__snake_case   )
  lowercase							   =	(2 * precision * recall) / (precision + recall)
  return fa
def 						_SCREAMING_SNAKE_CASE			(   __snake_case      :  List[Any]		, __snake_case      :  int   ):





  '''simple docstring'''





  return normalize_answer(__snake_case   ) == normalize_answer(__snake_case   )
def 						_SCREAMING_SNAKE_CASE			(   __snake_case      :  str		, __snake_case      :  int		, __snake_case      :  int   ):





  '''simple docstring'''





  lowercase							   =	[]
  for ground_truth in ground_truths:
    lowercase							   =	metric_fn(__snake_case		, __snake_case   )
    scores_for_ground_truths.append(__snake_case   )
  return max(__snake_case   )
def 						_SCREAMING_SNAKE_CASE			(   __snake_case      :  Any		, __snake_case      :  Union[str, Any]   ):





  '''simple docstring'''





  lowercase							   =	lowercase							   =	lowercase							   =	0
  for article in dataset:
    for paragraph in article["paragraphs"]:
      for qa in paragraph["qas"]:
        total += 1
        if qa["id"] not in predictions:
          lowercase							   =	'Unanswered question ' + qa['id'] + ' will receive score 0.'
          print(__snake_case		, file=sys.stderr   )
          continue
        lowercase							   =	[x['text'] for x in qa['answers']]
        lowercase							   =	predictions[qa['id']]
        exact_match += metric_max_over_ground_truths(__snake_case		, __snake_case		, __snake_case   )
        fa += metric_max_over_ground_truths(__snake_case		, __snake_case		, __snake_case   )

  lowercase							   =	100.0 * exact_match / total
  lowercase							   =	100.0 * fa / total

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


if __name__ == "__main__":
    _UpperCamelCase		:  Optional[int]						=		'1.1'
    _UpperCamelCase		:  Optional[int]						=		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		:  List[str]						=		parser.parse_args()
    with open(args.dataset_file) as dataset_file:
        _UpperCamelCase		:  str						=		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		:  int						=		dataset_json['data']
    with open(args.prediction_file) as prediction_file:
        _UpperCamelCase		:  Optional[Any]						=		json.load(prediction_file)
    print(json.dumps(evaluate(dataset, predictions)))










"""simple docstring"""



def 						_SCREAMING_SNAKE_CASE			(   ):





  '''simple docstring'''





  for a in range(3_00   ):
    for b in range(a + 1		, 4_00   ):
      for c in range(b + 1		, 5_00   ):
        if (a + b + c) == 10_00 and (a**2) + (b**2) == (c**2):
          return a * b * c

  return -1
def 						_SCREAMING_SNAKE_CASE			(   ):





  '''simple docstring'''





  for a in range(3_00   ):
    for b in range(4_00   ):
      lowercase							   =	10_00 - a - b
      if a < b < c and (a**2) + (b**2) == (c**2):
        return a * b * c

  return -1
def 						_SCREAMING_SNAKE_CASE			(   ):





  '''simple docstring'''





  import timeit

  print(
      timeit.timeit('solution()'		, setup='from __main__ import solution'		, number=10_00   )   )
  print(
      timeit.timeit(
          'solution_fast()'		, setup='from __main__ import solution_fast'		, number=10_00   )   )


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


