p={} for i in range(1,334): for j in range(i+1,500): for k in range(j+1,1001-i-j): if i*i+j*j==k*k: p[i+j+k]=p.get(i+j+k,0)+1 print max([p[i],i] for i in p)[1]