Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 220000
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld", &s);
#define sout(s) printf("%lld\\n", s);
#define in(s) cin >> s
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\\n'
#define sp ' '
#define gear_change ios_base::sync_with_stdio(false), cin.tie(0)
#define nfl(i, n) for (i = 0; i < n; i++)
#define sfl(i, s, e) for (i = s; i < e; i++)
#define ufl(i, n) for (i = n - 1; i >= 0; i--)
ll power(ll x, ll y) {
  ll ret = 1;
  while (y > 0) {
    if (y & 1)
      ret = (ret * x);
    y /= 2;
    x = (x * x);
  }
  return ret;
}
vector<ll> divs(ll n) {
  vector<ll> ret;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      if (i * i == n) {
        ret.push_back(i);
      } else {
        ret.push_back(i);
        ret.push_back(n / i);
      }
    }
  }
  return ret;
}
unordered_map<ll, ll> m;
inline ll val(ll x, ll y, ll z) {
  return x * x + y * y + z * z + x * y + y * z + z * x;
}
void pre() {
  ll i, j, k;
  sfl(i, 1, 1000) {
    sfl(j, 1, 1000) {
      sfl(k, 1, 1000) {
        m[val(i, j, k)]++;
        if (val(i, j, k) > 11000) {
          break;
        }
      }
    }
  }
}
void solve() {
  ll n, i, x;
  cin >> n;
  sfl(i, 1, n + 1) { cout << m[i] << endl; }
}
int main() {
  gear_change;
  ll test = 1;
  pre();
  // in(test);
  while (test--) {
    solve();
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 220000
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld", &s);
#define sout(s) printf("%lld\\n", s);
#define in(s) cin >> s
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\\n'
#define sp ' '
#define gear_change ios_base::sync_with_stdio(false), cin.tie(0)
#define nfl(i, n) for (i = 0; i < n; i++)
#define sfl(i, s, e) for (i = s; i < e; i++)
#define ufl(i, n) for (i = n - 1; i >= 0; i--)
ll power(ll x, ll y) {
  ll ret = 1;
  while (y > 0) {
    if (y & 1)
      ret = (ret * x);
    y /= 2;
    x = (x * x);
  }
  return ret;
}
vector<ll> divs(ll n) {
  vector<ll> ret;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      if (i * i == n) {
        ret.push_back(i);
      } else {
        ret.push_back(i);
        ret.push_back(n / i);
      }
    }
  }
  return ret;
}
unordered_map<ll, ll> m;
inline ll val(ll x, ll y, ll z) {
  return x * x + y * y + z * z + x * y + y * z + z * x;
}
void pre() {
  ll i, j, k;
  sfl(i, 1, 1000) {
    sfl(j, 1, 1000) {
      sfl(k, 1, 1000) { m[val(i, j, k)]++; }
    }
  }
}
void solve() {
  ll n, i, x;
  cin >> n;
  sfl(i, 1, n + 1) { cout << m[i] << endl; }
}
int main() {
  gear_change;
  ll test = 1;
  pre();
  // in(test);
  while (test--) {
    solve();
  }
}