Let $d_5(n)$ be the number of solutions of the equation $x_1x_2x_3x_4x_5=n$ in positive integers. Observe that $d_5(p^\alpha)=\frac{(\alpha+1)(\alpha+2)(\alpha+3)(\alpha+4)}{24}$ for any prime $p$ and any $\alpha \geq 0$. For $\alpha=1$ we have $d_5(p^\alpha)=5>d(p^\alpha)^2=4$ and for $\alpha>1$ the inequalities $(\alpha+1)(\alpha+2)>(\alpha+1)^2$ and $(\alpha+3)(\alpha+4)\geq 30$ are satisfied. Thus, for any $\alpha>1$ and any prime $p$ the inequality $$d_5(p^\alpha)=\frac{1}{24}(\alpha+1)(\alpha+2)(\alpha+3)(\alpha+4)\geq \frac{30}{24}(\alpha+1)^2>(\alpha+1)^2=d(p^\alpha)^2$$ holds. For $\alpha=1$ we have trivially $d_5(1)=d(1)^2=1$. Functions $d_5(n)$ and $d(n)^2$ are multiplicative, so for any $n \in \mathbb N$ we have $d_5(n) \geq d(n)^2$. By [this paper](https://www.jstor.org/stable/2000368?seq=1#page_scan_tab_contents) (see Lemma 2) by J. Galambos, K.-H. Indlekofer and I. Kátai we have for any $\varepsilon>0$ and arbitrary $H$ and $Q$ with $Q^\varepsilon\leq H\leq Q$ $$\sum\limits_{Q\leq n\leq Q+H} d_5(n) \leq c(5,\varepsilon)H(\log Q)^4$$ for some positive constant $c(5,\varepsilon)$ dependent on $\varepsilon$. Consequently, if $Q\geq H\geq Q^\varepsilon$ then the estimate $$\sum\limits_{Q\leq n\leq Q+H} d(n)^2 \leq \sum\limits_{Q\leq n\leq Q+H} d_5(n) \ll_\varepsilon H(\log Q)^4$$ holds. The remaining case $H \geq Q$ is easily covered by the bound $$\sum\limits_{1\leq n\leq X} d(n)^2 \ll X(\log X)^3,$$ which is classical. Also, by the comment of GH, the restriction $\varepsilon=\frac{\log H}{\log Q}\gg 1$ cannot be replaced by anything like $\varepsilon\gg f(Q)$ with $f(Q)=o(\frac{1}{\log\log Q})$. P.S. I believe that $T=4$ from my answer could be improved to $T=3$, but I cannot find a corresponding reference:( EDIT: [There it is!](http://eprints.nottingham.ac.uk/28304/1/281269.pdf) Theorem 1, p.27, gives us the bound with $T=3$. (Once again: thanks, Lucia)