Is this a programming contest?
This problem is originally prepared by _rqy. The detailed solution is described in the paper: 1 and 2.
In short, the Theorem (Tunnell) tells us:
Let $n$ be a square-free positive integer, and
$$\begin{aligned} f(n) &= \#\{(x, y, z) \in \mathbb{Z}^3 \mid x^2 + 2y^2 + 8z^2 = n \} \\ g(n) &= \#\{(x, y, z) \in \mathbb{Z}^3 \mid x^2 + 2y^2 + 32z^2 = n \} \\ h(n) &= \#\{(x, y, z) \in \mathbb{Z}^3 \mid x^2 + 4y^2 + 8z^2 = n/2 \} \\ k(n) &= \#\{(x, y, z) \in \mathbb{Z}^3 \mid x^2 + 4y^2 + 32z^2 = n/2 \} \end{aligned}$$
If $n$ is congruent, then $\begin{cases}f(n) = 2g(n) & n \equiv 1 \pmod 2 \\ h(n) = 2k(n) & \text{otherwise}\end{cases}$. If the Weak Birch and Swinnerton-Dyer conjecture is true for the curve $y^2 = x^3 - n^2x$, then the converse of the implication is also true.