input: from typing import List
  
  def optimize_equation(equation: str) -> str:
      """
      Optimize an equation by combining like terms.
      Each term in the equation is represented as variable followed by a count.
      The optimized equation will combine like terms and use an exponent to represent multiple occurrences.
      
      >>> optimize_equation('x + x + y + y + y')
      'x^2 + y^3'
      >>> optimize_equation('a + a + a + b + b + c')
      'a^3 + b^2 + c'
      """
      variables = []
      for term in equation.split('+'):
          var, count = term.strip().split(' ')
          variables.append((var, int(count)))
  
      new_equation = ""
      for var, count in variables:
          new_equation += (var + '^' + str(count)) + ' + '
      return new_equation[:-3]
output:     terms = {}
      for term in equation.split('+'):
          var = term.strip()
          if var in terms:
              terms[var] += 1
          else:
              terms[var] = 1
  
      optimized_terms = []
      for var, count in terms.items():
          if count > 1:
              optimized_terms.append(f"{var}^{count}")
          else:
              optimized_terms.append(var)
  
      return ' + '.join(optimized_terms)