Finding $x$'s parity in the discrete log problem
Claim. $a^{(p-1)/2} = 1$ if and only if $x$ is even.

Proof. If $x$ is even, let $x = 2y$. Then
$$a^{(p-1)/2} = (g^x)^{(p-1)/2} = g^{2y(p-1)/2} = (g^{p-1})^y = 1^y = 1.$$

If $x$ is odd, let $x = 2y+1$. Then
$$a^{(p-1)/2} = g^{(2y+1)(p-1)/2} = \dots$$
(remember here that $g$ is a generator of $\mathbf{F}_p^*$).