#include #include int main(void) { int n,d; int x,y,z,w; int k; int ans = 0; int *cnt1,*cnt2; cnt1 = (int *)malloc(sizeof(int)*8000000); cnt2 = (int *)malloc(sizeof(int)*8000000); scanf("%d%d",&n,&d); for(x=1;x<=n;x++){ for(y=1;y<=n;y++){ cnt1[(x*x+y*y)]++; } } for(z=1;z<=n;z++){ for(w=1;w<=n;w++){ if((w*w-z*z+d)>=0){ cnt2[(w*w-z*z+d)]++; } } } for(k=1;k<=8000000;k++){ ans += cnt1[k]*cnt2[k]; } printf("%d\n",ans); free(cnt1); free(cnt2); return 0; }