Prove the equivalent form of the Selberg's Formula $\psi(x)\log x+\sum_{p\leq x}\psi\left(\frac xp\right)\log p=2x\log x+\mathcal O(x).$ This is the Selberg's Formula: $$\psi(x)\log x+\sum_{n\leq x}\Lambda(n)\psi\bigg(\dfrac xn\bigg)=2x\log x+\mathcal O(x).$$
In the book Apostol Analytic Number Theory, the exercise tells me to use this Formula to give an equivalent formula which is $$\psi(x)\log x+\sum_{p\leq x}\psi\bigg(\dfrac xp\bigg)\log p=2x\log x+\mathcal O(x).$$
I spotted the only difference is the sum terms, so I decided to prove that $$\sum_{n\leq x}\Lambda(n)\psi\bigg(\dfrac xn\bigg)-\sum_{p\leq x}\psi\bigg(\dfrac xp\bigg)\log p=\mathcal O(x).$$
Then since the von mangoldt function is nonzero when $n$ is a prime power, I found that the sum over $n\leq x$ can be written as 
\begin{align*}
\sum_{n\leq x}\Lambda (n)\psi\bigg(\dfrac xn\bigg)&=\sum_{m=1}^{\big[\frac{\log x}{\log 2}\big]}\sum_{p^m\leq x} \psi\bigg(\dfrac x{p^m}\bigg)\log p\\
&=\sum_{p\leq x}\psi\bigg(\dfrac xp\bigg)\log p+\sum_{m=2}^{\big[\frac{\log x}{\log 2}\big]}\sum_{p^m\leq x}\psi\bigg(\dfrac x{p^m}\bigg)\log p
\end{align*}
So the last thing I want to show is that $$\sum_{m=2}^{\big[\frac{\log x}{\log 2}\big]}\sum_{p^m\leq x}\psi\bigg(\dfrac x{p^m}\bigg)\log p
=\mathcal O(x)$$
But this is a bit ugly to see, I don't know what should I do next. Any suggestion?
 A: In asymptotic formulæ we can often ignore perfect powers — in the sense that including or excluding them doesn't change the formula or error term, so we can include or exclude them at our convenience. Or the formula changes, but in a way that is fully under control. This is because the sum of the reciprocals of the perfect powers converges. More,
$$\sum_{n \text{ perfect power}} \frac{1}{n^{\sigma}}$$
converges for $\sigma > \frac{1}{2}$, and hence
$$\sum_{n \text{ perfect power}} \frac{f(n)}{n^{\sigma}}$$
converges for $\sigma > \frac{1}{2}$ whenever $f(n) \in O(n^{\varepsilon})$ for every $\varepsilon > 0$, e.g. $f(n) = (\log n)^r$ or $f(n) = \tau(n)^r$ (where $\tau = \sigma_0$ is the divisor counting function).
To see the first assertion, note that every perfect power $n > 1$ has by definition at least one representation $n = m^k$ with $m,k \geqslant 2$, so
\begin{align}
\sum_{n \text{ perfect power}} \frac{1}{n^{\sigma}}
&\leqslant 1 + \sum_{m = 2}^{\infty}\sum_{k = 2}^{\infty} \frac{1}{m^{k\sigma}} \tag{repetitions} \\
&= 1 + \sum_{m = 2}^{\infty} \frac{1}{m^{2\sigma}(1 - m^{-\sigma})} \\
&\leqslant 1 + \frac{1}{1 - 2^{-\sigma}} \sum_{m = 2}^{\infty} \frac{1}{m^{2\sigma}} \\
&= 1 + \frac{\zeta(2\sigma) - 1}{1 - 2^{-\sigma}} \\
&< +\infty
\end{align}
for $\sigma > \frac{1}{2}$. A fortiori
$$\sum_{p} \sum_{k = 2}^{\infty} \frac{1}{p^{k\sigma}} < +\infty$$
for $\sigma > \frac{1}{2}$, and the convergence remains if we multiply with arbitrary powers of $\log p$.
How much of this is used varies of course. Here we use the convergence of
$$\sum_p \sum_{k = 2}^{\infty} \frac{\log p}{p^k}$$
which together with Chebyshev's bound $\psi(y) \leqslant C y$ readily yields
$$0 \leqslant \sum_{\substack{p^m \leqslant x \\ m \geqslant 2}}  \psi\biggl(\frac{x}{p^m}\biggr)\log p \leqslant Cx \sum_{\substack{p^m \leqslant x \\ m \geqslant 2}} \frac{\log p}{p^m} \leqslant Cx \sum_p\sum_{m = 2}^{\infty} \frac{\log p}{p^m} = K\cdot x\,.$$
We obtain a similar bound (just with a somewhat larger $K$) if we extend the sum to all perfect powers and not just the prime powers, as in reuns' comment.
This option of including or excluding perfect powers can often simplify things. Sometimes it's easier if one only has primes to consider, at other times it is more convenient to include the (proper) prime powers because the von Mangoldt function $\Lambda$ has much nicer arithmetic properties — $1 \ast \Lambda = \log$ — than the prime logarithm $\ell(n) = \vartheta(n) - \vartheta(n-1)$.
