input: from typing import List
  
  def optimize_equation(equation: str) -> str:
      """Given an equation with repeated variables, optimize it by combining like terms.
      Example:
      >>> optimize_equation('x + x + y + y + y')
      'x^2 + y^3'
      >>> optimize_equation('a + a + a + b + b + c')
      'a^3 + b^2 + c'
      """
output:     from collections import Counter
      
      terms = equation.split(' + ')
      term_counts = Counter(terms)
      
      optimized_terms = []
      for term, count in term_counts.items():
          if count > 1:
              optimized_terms.append(f"{term}^{count}")
          else:
              optimized_terms.append(term)
      
      return ' + '.join(optimized_terms)