


import math_equivalence  # From: git+https://github.com/hendrycks/math.git

import datasets


SCREAMING_SNAKE_CASE       :		List[Any]         =				"\\n@article{hendrycksmath2021,\n  title={Measuring Mathematical Problem Solving With the MATH Dataset},\n  author={Dan Hendrycks\n    and Collin Burns\n    and Saurav Kadavath\n    and Akul Arora\n    and Steven Basart\n    and Eric Tang\n    and Dawn Song\n    and Jacob Steinhardt},\n  journal={arXiv preprint arXiv:2103.03874},\n  year={2021}\n}\n"


SCREAMING_SNAKE_CASE       :		List[str]         =				"\\nThis metric is used to assess performance on the Mathematics Aptitude Test of Heuristics (MATH) dataset.\nIt first canonicalizes the inputs (e.g., converting \"1/2\" to \"\\frac{1}{2}\") and then computes accuracy.\n"


SCREAMING_SNAKE_CASE       :		str         =				r"\nCalculates accuracy after canonicalizing inputs.\n\nArgs:\n    predictions: list of predictions to score. Each prediction\n        is a string that contains natural language and LaTex.\n    references: list of reference for each prediction. Each\n        reference is a string that contains natural language\n        and LaTex.\nReturns:\n    accuracy: accuracy after canonicalizing inputs\n        (e.g., converting \"1/2\" to \"\\frac{1}{2}\")\n\nExamples:\n    >>> metric = datasets.load_metric(\"competition_math\")\n    >>> results = metric.compute(references=[\"\\frac{1}{2}\"], predictions=[\"1/2\"])\n    >>> print(results)\n    {'accuracy': 1.0}\n"






@datasets.utils.file_utils.add_end_docstrings(_DESCRIPTION						,      _KWARGS_DESCRIPTION     )
class      UpperCamelCase					(		datasets.Metric     ):


   '''simple docstring'''







   def 		UpperCamelCase  (     self		):
        return datasets.MetricInfo(
            description=_DESCRIPTION   ,							citation=_CITATION   ,							inputs_description=_KWARGS_DESCRIPTION   ,							features=datasets.Features(
                {
                    '''predictions''': datasets.Value('''string'''		),
                    '''references''': datasets.Value('''string'''		),
                }		)   ,							homepage='''https://github.com/hendrycks/math'''   ,							codebase_urls=['''https://github.com/hendrycks/math''']   ,							)




   def 		UpperCamelCase  (     self   ,							UpperCamelCase_   ,							UpperCamelCase_		):
        lowercase_       :int     =       0.0
        for i, j in zip(UpperCamelCase_   ,							UpperCamelCase_		):
             n_correct += 1.0 if math_equivalence.is_equiv(UpperCamelCase_   ,							UpperCamelCase_		) else 0.0
        lowercase_       :str     =       n_correct / len(UpperCamelCase_		)
        return {
            "accuracy": accuracy,
        }





def     UpperCamelCase    (      _a       ,		_a       ,		_a		)					->							int:
     '''simple docstring'''





     def count_of_possible_combinations(_a		) -> int:
          if target < 0:
               return 0
          if target == 0:
               return 1
          return sum(count_of_possible_combinations(target - item		) for item in array		)

     return count_of_possible_combinations(_a		)




def     UpperCamelCase    (      _a       ,		_a       ,		_a		)					->							int:
     '''simple docstring'''





     def count_of_possible_combinations_with_dp_array(
         _a       ,		_a		) -> int:
          if target < 0:
               return 0
          if target == 0:
               return 1
          if dp_array[target] != -1:
               return dp_array[target]
          lowercase_       :Optional[int]     =       sum(
              count_of_possible_combinations_with_dp_array(target - item       ,		_a		)
              for item in array		)
          lowercase_       :List[Any]     =       answer
          return answer

     lowercase_       :Dict     =       [-1] * (target + 1)
     return count_of_possible_combinations_with_dp_array(_a       ,		_a		)




def     UpperCamelCase    (      _a       ,		_a       ,		_a		)					->							int:
     '''simple docstring'''





     lowercase_       :Optional[int]     =       [0] * (target + 1)
     lowercase_       :int     =       1

     for i in range(1       ,		target + 1		):
          for j in range(_a		):
               if i - array[j] >= 0:
                    dp_array[i] += dp_array[i - array[j]]

     return dp_array[target]


if __name__ == "__main__":
   import doctest

   doctest.testmod()
   SCREAMING_SNAKE_CASE       :		Optional[Any]         =				3
   SCREAMING_SNAKE_CASE       :		Tuple         =				5
   SCREAMING_SNAKE_CASE       :		List[Any]         =				[1, 2, 5]
   print(combination_sum_iv(n, array, target))

