Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define w(x)                                                                   \
  int x;                                                                       \
  cin >> x;                                                                    \
  while (x--)
#define pw(b, p) pow(b, p) + 0.1
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<pii, null_type, less<pii>, rb_tree_tag,
             tree_order_statistics_node_update>
    pbds;

void c_p_c() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int arr1[20];
int arr2[20];
vector<int> adj[100005];
vector<int> sz(100005);
int ans = 0;

void dfs(int v, int par = 0) {
  sz[v] = 1;
  for (auto x : adj[v]) {
    if (x == par)
      continue;
    dfs(x, v);
    sz[v] += sz[x];
  }
  if (sz[v] % 2 == 0)
    ans++;
}

int32_t main() {
  c_p_c();
  int n;
  cin >> n;
  vector<int> c(n + 1);

  for (int x = 1; x <= n; x++) {
    for (int y = 1; y <= n; y++) {
      for (int z = 1; z <= n; z++) {
        int res = x * x + y * y + z * z + x * y + y * z + x * z;
        if (res <= n)
          c[res]++;
      }
    }
  }

  for (int i = 1; i <= n; i++) {
    cout << c[i] << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define w(x)                                                                   \
  int x;                                                                       \
  cin >> x;                                                                    \
  while (x--)
#define pw(b, p) pow(b, p) + 0.1
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<pii, null_type, less<pii>, rb_tree_tag,
             tree_order_statistics_node_update>
    pbds;

void c_p_c() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int arr1[20];
int arr2[20];
vector<int> adj[100005];
vector<int> sz(100005);
int ans = 0;

void dfs(int v, int par = 0) {
  sz[v] = 1;
  for (auto x : adj[v]) {
    if (x == par)
      continue;
    dfs(x, v);
    sz[v] += sz[x];
  }
  if (sz[v] % 2 == 0)
    ans++;
}

int32_t main() {
  c_p_c();
  int n;
  cin >> n;
  vector<int> c(n + 1);

  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int res = x * x + y * y + z * z + x * y + y * z + x * z;
        if (res <= n)
          c[res]++;
      }
    }
  }

  for (int i = 1; i <= n; i++) {
    cout << c[i] << endl;
  }
}