<s>[INST] Characterizing an integer in terms of associated binary quadratic forms Let’s say I have a positive integer $n$, and I know the following:

*

*$4n+1$ is of the form $a^2+b^2$

*$16n+3$ is of the form $a^2+2b^2$.

*$16n+1$ is of both forms $a^2+b^2$ and $a^2+2b^2$.

QUESTION: Is there a simple/elegant way to characterize all such integers $n$? I’m imagining that quadratic reciprocity will give some constraints… Are there other elementary means one can apply?
EDIT: A brute search on $n ≤ 200$ yields
$$n \in \{1, 3, 6, 15, 18, 21, 28, 36, 39, 42, 48, 55, 58, 60, 61, 78, 81, 88, 105, 106,\\ 111, 120, 126, 130, 133, 139, 150, 151, 175, 189, 190, 193, 196, \dots\}.$$
There are some obvious patterns/members in there (e.g., most [but not all!] triangular numbers), but I’d like a complete characterization, if possible.
 [/INST] Suppose a is odd and:
$a^2\equiv 1 \bmod 16$
and b is even, then:
$A=4n+1=a^2+b^2\equiv 1\bmod 16$
$B=16n+3=c^2+2d^2$
c must be odd, suppose:
$c^2\equiv 1\bmod 16$
let d be odd and:
$d^2\equiv 1\bmod 16$
therefore:
$c^2+2d^2\equiv 3\bmod 16$
$C=16n+1$
It can be seen that a family of n can be of the form $n=16m+1$ and we have:
$A=4n+1=64m+5$
$B=16n+3=256m+19$
$C=16n+1=256m+17$
For example for $m=5$ we have:
$A=325=15^2+10^2$
$B=1299=7^2+2\times 25^2$
$C=1297=1^2+36^2=35^2+2\times 6^2$
These values of A, B and C are primitive solutions, clearly any  multiple such as $k^2$ will give another solution.
Update:
For $m=2^6+1=65$ we obtain:
$A=4165=42^2+49^2$
$B=16659=39^2+2\times 87^2$
$C=16657=67^2+2\times 78^2=129^2+4^2$
I checked more powers up to $m=2^{14}+1$ and could not find more solutions. May be there are some more results with higher powers.
</s>