Solution (source code)

= Solution

For $p>3$, <quadratic reciprocity> gives
$$
\left(\frac3p\right)=(-1)^{(p-1)/2}\left(\frac p3\right).
$$
The second <Legendre symbol> is $1$ when $p\equiv1\pmod3$ and $-1$ when $p\equiv2\pmod3$. Combining it with the sign determined by $p\pmod4$ shows that a <quadratic residue> occurs precisely for
$$
\boxed{p\equiv1\text{ or }11\pmod{12}}.
$$