input: 
  def optimize_equation(equation):
      """
      You are required to write a Python program to optimize an equation. This function takes
      a string representing an equation where each term is the sum of the same variable
      and a number representing how many times to add that variable. The function should
      return an optimized version of the equation where each variable is raised to the power
      of the count of its occurrences.
  
      Example:
      >>> optimize_equation('x + x + y + y + y')
      'x^2 + y^3'
      """
      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:     variables = {}
      for term in equation.split('+'):
          var, count = term.strip().split(' ')
          var = var.strip()
          count = int(count.strip())
          if var in variables:
              variables[var] += count
          else:
              variables[var] = count
  
      new_equation = ""
      for var, count in variables.items():
          new_equation += (var + '^' + str(count)) + ' + '
      return new_equation[:-3]