Let $\omega(n)$ denote the number of distinct prime divisors of $n$. I learned from Cojocaru & Murty that
$$ \sum_{n\le x}\omega(n)^2=x(\log\log x)^2+O(x\log\log x).\tag1 $$
I wonder whether it is possible to extract more terms from the O-error. This will be crucial because (1) only implies
$$ \sum_{n\le x}(\omega(n)-\log\log x)^2=O(x\log\log x).\tag2 $$
If (1)’s second term can be extracted, then (2) will become an asymptotic formula instead of some error bound.
In my attempt, the main difficulty lies in the treatments for
$$S=\sum_{p_1p_2\le x}{1\over p_1p_2}$$
If we only roughly estimate $S$ via
$$ \left(\sum_{p\le\sqrt x}\frac1p\right)^2\le S\le\left(\sum_{p\le x}\frac1p\right)^2, $$
then we only end up with (1).
By graphing a hyperbola, one finds that
$$ \sum_{p_1p_2\le x}{1\over p_1p_2}=\left(\sum_{p\le x}\frac1p\right)^2-\sum_{p_1\le\sqrt x}{1\over p_1}\sum_{x/p_1<p_2\le x}{1\over p_2}-\left(\sum_{\sqrt x<p\le x}\frac1p\right)^2. $$
The last two terms are bounded, and the first square term is asymptotic to
$$ (\log\log x)^2+2B_1\log\log x+o(1). $$
due to Mertens' theorem. As a consequence, we have
$$ \sum_{n\le x}\omega^2(n)=\sum_{p_1\ne p_2}\left\lfloor x\over p_1p_2\right\rfloor+\sum_{p\le x}\left\lfloor\frac xp\right\rfloor=x(\log\log x)^2+(2B_1+1)x\log\log x+O(x). $$