Solution (source code)

= Solution

If $x^2\equiv a$ and $y^2\equiv a\pmod p$, then $(x-y)(x+y)\equiv0$, hence $y\equiv\pm x$; these differ for odd $p$. It fails for composite <moduli>: $1$ has four square roots modulo $8$.