input: def optimize_equation(equation):
      variables = []
      for term in equation.split(' + '):
          if term:
              var, count = term.strip().split(' ')
              if (var, int(count)) not in variables:
                  variables.append((var, int(count)))
      new_equation = ""
      for var, count in variables:
          new_equation += (var + '^' + str(count)) + ' + '
      return new_equation[:-3]
  
  print(optimize_equation('x + x + y + y + y'))
  
  # Example Output:
  # x^2 + y^3
output:     variables = {}
      for term in equation.split(' + '):
          if term:
              var, count = term.strip().split(' ')
              count = int(count)
              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]