  In this paper, we solve the Rankin--Selberg problem. That is, we break the
well known Rankin--Selberg's bound on the error term of the second moment of
Fourier coefficients of a $\mathrm{GL}(2)$ cusp form (both holomorphic and
Maass), which remains its record since its birth for more than 80 years. We
extend our method to deal with averages of coefficients of L-functions which
can be factorized as a product of a degree one and a degree three L-functions.
