Solution (source code)

= Solution

Let
$$
F(n)=\prod_{i=1}^r(n+h_i)
$$
and let $W$ be the product of the finitely many primes at most $r$ or dividing some nonzero difference $h_i-h_j$. Sieve with the primes $p\nmid W$. For such a prime, the congruence $F(n)\equiv0\pmod p$ has exactly $r$ distinct roots. By the <Chinese remainder theorem>, the root-counting function $\rho(d)$ is multiplicative on squarefree $d$ coprime to $W$, and
$$
\#\{n\leq x:d\mid F(n)\}
=x\frac{\rho(d)}d+O(\rho(d)).
$$
Thus the <polynomial root density in a sieve> applies with
$$
g(p)=\frac rp,\qquad r_d=O(\rho(d)).
$$

Take $z=x^{1/4}$ and $D=z$. For squarefree $d$ coprime to $W$,
$$
h(d)=\prod_{p\mid d}\frac r{p-r}
\geq\frac{r^{\omega(d)}}d.
$$
The supplied mean-value estimate, <partial summation>, and removal of square factors using $r^{\omega(n)}\ll_{r,\epsilon}n^\epsilon$ give
$$
G(z,z)\gg_{r,W}(\log z)^r.
$$
The error in the <Selberg upper-bound sieve> is
$$
\ll\sum_{d<z^2}(3r)^{\omega(d)}
\ll_{r,\epsilon}z^{2+\epsilon}
=o\left(\frac{x}{(\log x)^r}\right).
$$
Consequently
$$
S(\mathcal A,\mathcal P;z)
\ll_{h_1,\ldots,h_r,r}\frac{x}{(\log x)^r}.
$$

If every $n+h_i$ is prime and all of them exceed $z$, then $F(n)$ has no prime divisor $p<z$ with $p\nmid W$, apart from a fixed finite set of divisibility cases absorbed into the implied constant. The cases with some $n+h_i\leq z$ contribute $O_r(z)$. Therefore
$$
\boxed{
\#\{n\leq x:n+h_1,\ldots,n+h_r\text{ are all prime}\}
\ll_{h_1,\ldots,h_r,r}\frac{x}{(\log x)^r}.
}
$$