#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[4445][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; REP(i, mod) cnt[z][i] = cnt[z-1][i]; cnt[z][z3%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++) { int z3 = (a + mod - (p3[x] + p3[y])%mod)%mod; if(cnt[4444][z3] <= 0) continue; ll zmax = p4[4444] - p4[x] - p4[y]; if(zmax <= 0) break; zmax = SQRT4(zmax); int c = cnt[zmax][z3]; if(c > 0 && cnt[4444][z3] == 0) cerr << x << " " << y << " " << zmax << " " << z3 << " " << c << endl; ans += c; } //cerr << x << "\n"; } cout << ans << endl; }