Solution (source code)

= Solution

<Euler's criterion> gives
$$
\left(\frac{ab}p\right)\equiv (ab)^{(p-1)/2}
\equiv a^{(p-1)/2}b^{(p-1)/2}
\equiv\left(\frac ap\right)\left(\frac bp\right)\pmod p.
$$
If either factor is divisible by $p$, both asserted values are zero. Otherwise the two values lie in $\{1,-1\}$, whose elements are distinct modulo an <odd prime>. The <modular congruence> is therefore equality:
$$
\boxed{\left(\frac{ab}p\right)=\left(\frac ap\right)\left(\frac bp\right).}
$$
Finally, $a\equiv b\pmod p$ means they give the same <residue class> and thus the same set of square-congruence solutions. Divisibility by $p$ is also identical. Hence $\left(\frac ap\right)=\left(\frac bp\right)$.