input: def optimize_equation(equation: str) -> str:
      """ Optimizes a given equation by grouping the variables with their counts.
      The input should be a string of terms separated by '+'. Each term is of the form
      'variable count'. The task is to group all variables with the same name and 
      transform the equation into a simplified form where each term is represented 
      as 'variable^count'. 
      Example:
      >>> optimize_equation('x + x + y + y + y')
      'x^2 + y^3'
      """
output:     terms = equation.split(' + ')
      counts = {}
      for term in terms:
          if term in counts:
              counts[term] += 1
          else:
              counts[term] = 1
      optimized_terms = []
      for term, count in counts.items():
          optimized_terms.append(f"{term}^{count}")
      return ' + '.join(optimized_terms)