## Python, <s>133</s> 129 bytes from itertools import* n=input() l=[];s=0 for i in range(-n,n+1):l.append(i**2) for j in product(l,l): if sum(j)==n:s+=1 print s This demonstrates the use of itertools cartesian product. [Try it online](http://ideone.com/iq0N9h)