Optimal first-order methods for convex functions with a quadratic upper bound