#include #define REP(i,n) for(int i=0,i##_len=int(n);i bisearch(ll l,ll r,std::function f){ while((l+1)((n/x)/x)/x;}).first;} constexpr int mod = 333; ll cnt[4446][mod] = {}; // iまでにz^3がj mod 333であるような数 ll p4[4445]; ll p3[4445]; int main(){ int a;cin>>a; for(ll z = 1; z <= 4444; z++) { ll z3 = z*z*z; cnt[z][z3%mod]++; memcpy(&cnt[z+1][0], &cnt[z][0], mod); p3[z] = z3; p4[z] = z3*z; } int ans = 0; for(int x = 1; x < 4444; x++) { for(int y = 1; y < 4444; y++) { ll zmax = p4[4444] - p4[x] - p4[y]; if(zmax <= 0) break; zmax = SQRT4(zmax); int z3 = (a + mod - (p3[x] + p3[y])%mod)%mod; int c = cnt[zmax][z3]; //if(c) cerr << x << " " << y << " " << zmax << " " << z3 << " " << c << endl; ans += c; } //cerr << x << "\n"; } cout << ans << endl; }