CW. this turns out to be  a question from May 2020 in a Hungarian magazine for high school students; a bit deflating. The deadline was June 10th and an answer became available online; they did squares but did not bother with twice squares.

[![enter image description here][1]][1]


  [1]: https://i.sstatic.net/t53YS.png