from sympy.solvers.diophantine import diop_quadratic
from sympy import symbols
import json
x, y, t = symbols("x, y, t", integer=True)
def fn(n):
parametrics = diop_quadratic(x**2+2*x*y+y**2-n*x-y,t)
temp = { (xp.subs(t,i),yp.subs(t,i)) for (xp,yp) in parametrics for i in [-1,0,1]}
result = { (x0,y0) for (x0,y0) in temp if x0 < n and y0 <n and x0 > 0 and y0 > 0}
return list(result)
ls = []
for i in range(2,10):
ls.append({'n':i,'ls':fn(i)})
print(json.dumps(ls))