alexjercan/bugnet huggingface dataset:
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ans[10050] = {0};
  for (int i = 1; i <= 105; i++) {
    for (int j = 1; j <= 105; j++) {
      for (int k = 1; k <= 105; k++) {
        int v = i * i + j * j + k * k + i * j + j * k + k * i;
        if (v < 10050)
          ans[v] += 1;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int f(int n) {
  if (n < 6)
    return 0;
  int count = 0;
  for (int i = 1; i < n; i++) {
    for (int j = 1; j < n; j++) {
      for (int k = 1; k < n; k++) {
        if (i * i + j * j + k * k + i * j + i * k + j * k == n)
          count++;
      }
    }
  }
  return count;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++)
    cout << f(i) << endl;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll ans[10005];

int g(int x, int y, int z) {
  return x * x + y * y + z * z + x * y + y * z + z * x;
}

int main() {
  int N;
  cin >> N;
  for (int x = 1; x <= 100; ++x) {
    if (x * x + x > N)
      break;
    for (int y = 1; y <= 100; ++y) {
      if (x * x + x + y * y + y > N)
        break;
      for (int z = 1; z <= 100; ++z) {
        if (g(x, y, z) <= N)
          ans[g(x, y, z)]++;
      }
    }
  }
  for (int i = 1; i <= N; ++i) {
    cout << ans[i] << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int g(int x, int y, int z) {
  return x * x + y * y + z * z + x * y + y * z + z * x;
}

int main() {
  int N;
  cin >> N;
  for (int i = 1; i <= N; ++i) {
    ll ans = 0;
    for (int x = 1; x <= 100; ++x) {
      if (x * x + x > i)
        break;
      for (int y = 1; y <= 100; ++y) {
        if (x * x + x + y * y + y > i)
          break;
        for (int z = 1; z <= 100; ++z) {
          if (g(x, y, z) == i)
            ans++;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;

vector<int> buf;
vector<int> fn;
void dfs(int i, int size, int str, int end, int N) {
  if (i == size) {
    int ans = pow(buf[0], 2) + pow(buf[1], 2) + pow(buf[2], 2) +
              buf[0] * buf[1] + buf[1] * buf[2] + buf[2] * buf[0];
    if (ans <= N) {
      fn.at(ans) = fn.at(ans) + 1;
    }
  } else {
    for (int j = str; j <= end; j++) {
      buf[i] = j;
      dfs(i + 1, size, str, end, N);
    }
  }
}
int main() {
  int N;
  cin >> N;

  int size = 3;
  int str = 1;
  int end;
  end = pow(N, 0.5);

  fn.resize(N + 1, 0);
  buf.resize(size);
  dfs(0, size, str, end, N);

  for (int i = 1; i <= N; i++) {
    cout << fn.at(i) << endl;
  }
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

vector<int> buf;
vector<int> fn;
void dfs(int i, int size, int str, int end) {
  if (i == size) {
    int ans = pow(buf[0], 2) + pow(buf[1], 2) + pow(buf[2], 2) +
              buf[0] * buf[1] + buf[1] * buf[2] + buf[2] * buf[0];
    if (ans <= fn.size()) {
      fn.at(ans) = fn.at(ans) + 1;
    }
  } else {
    for (int j = str; j <= end; j++) {
      buf[i] = j;
      dfs(i + 1, size, str, end);
    }
  }
}
int main() {
  int N;
  cin >> N;

  int size = 3;
  int str = 1;
  int end;
  end = pow(N, 0.5);

  fn.resize(N + 1, 0);
  buf.resize(size);
  dfs(0, size, str, end);

  for (int i = 1; i <= N; i++) {
    cout << fn.at(i) << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC                                                                     \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);                                                                 \\
  cin.sync_with_stdio(0);
int main() {
  map<int, int> mp;
  int counter = 0, i, j, n;
  scanf("%d", &n);
  for (i = 1; i < 106; ++i) {
    for (int j = 1; j < 106; ++j) {
      for (int k = 1; k < 106; ++k) {
        mp[(i * i) + (j * j) + (k * k) + (i * j) + (i * k) + (j * k)] += 1;
      }
    }
  }
  for (i = 1; i <= n; ++i) {
    printf("%d\\n", mp[i]);
  }

  return 0;
}


Error: 0

Fixed submission:

#include <iostream>
using namespace std;
const int Size = 10004;
int Arr[3], Arr2[Size];
int main() {
  int N;
  cin >> N;
  Arr[0] = 1;
  Arr[1] = 1;
  Arr[2] = 1;
  int cond = 0; // The maximum no. of the triplets, The satisfied no.
  for (int i = 1; i <= N; i = cond) {
    cond = (Arr[0] * Arr[0]) + ((Arr[2] * Arr[2])) + ((Arr[1] * Arr[1])) +
           (Arr[0] * Arr[1]) + (Arr[1] * Arr[2]) + (Arr[2] * Arr[0]);
    if (i == cond) {
      if (Arr[1] != Arr[0] && Arr[0] != Arr[2] && Arr[1] != Arr[2]) {
        Arr2[i] = 6;
      } else {
        if (Arr[0] == Arr[1] && Arr[1] == Arr[2])
          Arr2[i] = 1;
        else
          Arr2[i] = 3;
      }
      Arr[2]++;
    }
  }
  cond = 11;
  Arr[2] = 2;
  while (cond <= N) {
    cond = (Arr[1] * Arr[1]) + ((Arr[2] * Arr[2])) + ((Arr[0] * Arr[0])) +
           (Arr[0] * Arr[1]) + (Arr[1] * Arr[2]) + (Arr[2] * Arr[0]);
    if (Arr[0] != Arr[1] && Arr[0] != Arr[2] && Arr[1] != Arr[2]) {
      Arr2[cond] = 6;
    } else {
      if (Arr[0] == Arr[1] && Arr[1] == Arr[2]) {
        Arr2[cond] = 1;
      } else
        Arr2[cond] = 3;
    }
    Arr[1]++;
  }
  cond = 17;
  Arr[1] = 2;
  while (cond <= N) {
    cond = (Arr[1] * Arr[1]) + ((Arr[2] * Arr[2])) + ((Arr[0] * Arr[0])) +
           (Arr[0] * Arr[1]) + (Arr[1] * Arr[2]) + (Arr[2] * Arr[0]);
    if (Arr[0] != Arr[1] && Arr[0] != Arr[2] && Arr[1] != Arr[2]) {
      Arr2[cond] = 6;
    } else {
      if (Arr[0] == Arr[1] && Arr[1] == Arr[2]) {
        Arr2[cond] = 1;
      } else
        Arr2[cond] = 3;
    }
    Arr[0]++;
  }
  for (int i = 1; i <= N; i++)
    cout << Arr2[i] << endl;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int n, m, x, y, z, cnt = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (x = 1; x < n; x++) {
      for (y = 1; y < n; y++) {
        for (z = 1; z < n; z++) {
          if (x * x + y * y + z * z + x * y + x * z + y * z == i)
            cnt++;
          if (x * x + y * y + z * z + x * y + x * z + y * z > i)
            break;
        }
        z = 1;
        if (x * x + y * y + z * z + x * y + x * z + y * z > i)
          break;
      }
      z = 1, y = 1;
      if (x * x + y * y + z * z + x * y + x * z + y * z > i)
        break;
    }
    cout << cnt << endl;
    cnt = 0;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

int fun(long long n) {
  int c = 0;
  for (int x = 1; x <= n; x++) {
    if (x * x > n)
      return c;
    for (int y = 1; y <= n; y++) {
      if (pow(x, 2) + pow(y, 2) + +x * y > n) {
        break;
      };
      for (int z = 1; z <= n; z++) {
        if (pow(x, 2) + pow(y, 2) + pow(z, 2) + +x * y + y * z + x * z > n) {
          break;
        };
        if (pow(x, 2) + pow(y, 2) + pow(z, 2) + +x * y + y * z + x * z == n)
          c++;
      }
    }
  }
  return c;
}

int main() {

  long long n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cout << fun(i) << endl;
    ;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

/* In the name of Allah */
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  vector<int> v(999999, 0);
  cin >> n;
  for (int i = 1; i <= 100; i++)
    for (int j = 1; j <= 100; j++)
      for (int k = 1; k <= 100; k++)
        v[(pow((i + j), 2) + pow((k + j), 2) + pow((i + k), 2)) / 2]++;
  for (int i = 1; i <= n; i++)
    cout << v[i] << endl;
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int MAX = 100;
const int SIZE = 1e6;

int main() {

  int n;
  cin >> n;
  vector<int> v(SIZE, 0);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      for (int k = 1; k <= n; ++k) {
        v[i * i + k * k + j * j + i * j + i * k + j * k] = 1;
      }
    }
  }
  for (int i = 0; i < n; ++i)
    cout << v[i] << endl;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
using namespace std;
int arr[100000] = {0};
int main() {
  unsigned long long x, y = 0, a = 0, d = 0;
  cin >> x;

  for (int i = 1; i <= 130; i++) {
    for (int w = 1; w <= 130; w++) {
      for (int y = 1; y <= 130; y++) {
        if (((i * i) + (w * w) + (y * y) + (i * w) + (i * y) + (y * w)) <= x) {
          arr[((i * i) + (w * w) + (y * y) + (i * w) + (i * y) + (y * w))]++;
        }
      }
    }
  }
  for (int i = 1; i <= x; i++) {
    cout << arr[i] << "\\n";
  }
}


Error: TLE

Fixed submission:

#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
int main() {
  int N = 0;
  scanf("%d", &N);
  int increament = 0;
  vector<long> v(N, 0);

  for (int x = 1; x < N; x++) {
    for (int y = 1; y < N; y++) {
      for (int z = 1; z < N; z++) {
        if ((x * x + y * y + z * z + x * y + x * z + z * y) != 0 &&
            ((x * x + y * y + z * z + x * y + x * z + z * y) < v.size())) {
          v[(x * x + y * y + z * z + x * y + x * z + z * y) - 1]++;
        }
      }
    }
  }

  for (int i = 0; i < v.size(); i++) {
    string str = to_string(v[i]);
    const char *l = str.c_str();
    printf(l);
    printf("\\n");
  }

  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <map>
using namespace std;

int main() {
  long long n, res;
  cin >> n;
  map<long long, long long> count;
  for (long long x = 1; x <= n; ++x) {
    for (long long y = 1; y <= n - x; ++y) {
      for (long long z = 1; z <= n - y; ++z) {
        res = x * x + y * y + z * z + x * y + y * z + z * x;
        if (res <= n) {
          count[res]++;
        } else
          break;
      }
    }
  }
  for (long long i = 1; i <= n; ++i)
    cout << count[i] << endl;
  ios::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int d(long long x) {
  int c = 0;
  for (int i = 1; i <= x; i++) {
    for (int j = 1; j <= x; j++) {
      for (int k = 1; k <= x; k++) {
        if (i * i + j * j + k * k + i * j + j * k + i * k == x) {
          c++;
        }
      }
    }
  }
  return c;
}
int main() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cout << d(i) << endl;
  }

  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <array>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <unordered_map>
#include <utility>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[]) {
  ll n;
  cin >> n;

  for (ll i = 1; i <= n; i++) {
    ll ans = 0;

    for (ll x = 1; x * x < i; x++) {
      for (ll y = 1; y * y + x * y + x * x < i; y++) {
        for (ll z = 1; x * x + y * y + z * z + x * y + y * z + z * x <= i;
             z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
            ans++;
          }
        }
      }
    }

    cout << ans << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <array>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <unordered_map>
#include <utility>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[]) {
  ll n;
  cin >> n;

  for (ll i = 1; i <= n; i++) {
    ll ans = 0;

    for (ll x = 1; x * x < i; x++) {
      for (ll y = 1; y * y < i; y++) {
        for (ll z = 1; z * z < i; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
            ans++;
          }
        }
      }
    }

    cout << ans << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> l(10005);
  for (int x = 1; x <= 105; x++)
    for (int y = 1; y <= 105; y++)
      for (int z = 1; z <= 101; z++)
        if (x * x + y * y + z * z + x * y + y * z + z * x < 10005)
          l[x * x + y * y + z * z + x * y + y * z + z * x]++;
  for (int i = 1; i <= n; i++) {
    cout << l[i] << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <iostream>

using namespace std;

/****************
******* D *******
****************/

int N;

int chkVld(int num, int x, int y, int z) {
  int summ = (x * x) + (y * y) + (z * z) + (x * y) + (x * z) + (y * z);
  if (summ == num)
    return 1;
  else if (summ > num)
    return -1;
  return 0;
}

int gnrt(int num) {
  int cnt = 0;
  //    cout << "** " << num << " **" << endl;
  for (int i = 1; i <= sqrt(num); i++) {
    for (int j = 1; j <= sqrt(num); j++) {
      for (int k = 1; k <= sqrt(num); k++) {
        if (chkVld(num, i, j, k) == 1) {
          //                    printf("(%d, %d, %d) ", i, j, k);
          cnt++;
        } else if (chkVld(num, i, j, k) == -1)
          break;
      }
    }
  }
  //    cout << endl;
  return cnt;
}

int main() {
  cin >> N;

  for (int i = 1; i <= N; i++) {
    cout << gnrt(i) << endl;
  }

  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int findThefn(int n) {
  int count = 0;

  for (int i = 1; i <= int(sqrt(n)); i++) {
    for (int j = 1; j <= n - i * i; j++) {
      if (i * i + j * j + i * j > n)
        break;
      for (int k = 1; k <= n - (i * i + j * j + i * j); k++) {
        if (i * i + j * j + k * k + i * j + i * k + k * j > n) {
          break;
        }
        if (i * i + j * j + k * k + i * j + i * k + k * j == n) {
          count++;
        }
      }
    }
  }

  return count;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cout << findThefn(i) << "\\n";
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int findThefn(int n) {
  int count = 0;

  for (int i = 1; i <= int(sqrt(n)); i++) {
    for (int j = 1; j <= n - i * i; j++) {
      for (int k = 1; k <= n - (i * i + j * j + i * j); k++) {
        if (i * i + j * j + k * k + i * j + i * k + k * j == n) {
          count++;
        }
      }
    }
  }

  return count;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cout << findThefn(i) << "\\n";
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long int INT;

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int cnt = 0;
    for (int x = 1; x <= sqrt(n); ++x) {
      for (int y = 1; y <= sqrt(n); ++y) {
        if ((x + y) * (x + y) - 4 * (x * x + y * y + x * y - i) > 0) {
          double z1 = (-(x + y) + sqrt((x + y) * (x + y) -
                                       4 * (x * x + y * y + x * y - i))) /
                      2;
          double z2 = (-(x + y) - sqrt((x + y) * (x + y) -
                                       4 * (x * x + y * y + x * y - i))) /
                      2;
          if (floor(z1) == z1 && z1 >= 1) {
            cnt += 1;
          }
          if (floor(z2) == z2 && z2 >= 1) {
            cnt += 1;
          }
        } else if ((x + y) * (x + y) - 4 * (x * x + y * y + x * y - i) == 0) {
          double z1 = (-(x + y) + sqrt((x + y) * (x + y) -
                                       4 * (x * x + y * y + x * y - i))) /
                      2;
          if (floor(z1) == z1 && z1 >= 1) {
            cnt += 1;
          }
        }
      }
    }
    cout << cnt << endl;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long int INT;

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int cnt = 0;
    for (int x = 1; x <= sqrt(n); ++x) {
      for (int y = 1; y <= sqrt(n); ++y) {
        if (x * x + y * y + x * y >= n) {
          break;
        }
        for (int z = 1; z <= sqrt(n); ++z) {
          int tmp = x * x + y * y + z * z + x * y + y * z + z * x;
          if (tmp == i) {
            cnt += 1;
            break;
          }
        }
      }
    }
    cout << cnt << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

int g(int x, int y, int z) {
  return x * x + y * y + z * z + x * y + y * z + z * x;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  int n = sqrt(N);
  vector<int> f(N + 1);
  FOR(i, 1, n + 1) {
    FOR(j, 1, n + 1) {
      FOR(k, 1, n + 1) {
        int v = g(i, j, k);
        if (v <= N) {
          f[v]++;
        }
      }
    }
  }
  FOR(i, 1, N + 1) { cout << f[i] << endl; }

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

int g(int x, int y, int z) {
  return x * x + y * y + z * z + x * y + y * z + z * x;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  int n = sqrt(N);
  vector<int> f(N + 1);
  FOR(i, 1, N + 1) {
    FOR(j, 1, N + 1) {
      FOR(k, 1, N + 1) {
        int v = g(i, j, k);
        if (v <= N) {
          f[v]++;
        }
      }
    }
  }
  FOR(i, 1, N + 1) { cout << f[i] << endl; }

  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001001001001001;
const int MOD = 1000000007;

template <typename T> void print(const T &v);

int main() {
  int n;
  cin >> n;
  vector<int> cnts(n + 1);
  int cnt = 0;
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        int num = i * i + j * j + k * k + i * j + j * k + k * i;
        if (num <= n) {
          ++cnts[num - 1];
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << cnts[i] << endl;
  }
  return 0;
}

// Use For Debug
template <typename T> void print(T const &v) {
  for (int i = 0; i < v.size(); i++) {
    if (i)
      cout << ' ';
    cout << v[i];
  }
  cout << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001001001001001;
const int MOD = 1000000007;

template <typename T> void print(const T &v);

int main() {
  int n;
  cin >> n;
  for (int x = 1; x <= n; x++) {
    int cnt = 0;
    for (int i = 1; i < 100; i++) {
      for (int j = 1; j < 100; j++) {
        for (int k = 1; k < 100; k++) {
          int num = i * i + j * j + k * k + i * j + j * k + k * i;
          if (num == x) {
            ++cnt;
          }
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

// Use For Debug
template <typename T> void print(T const &v) {
  for (int i = 0; i < v.size(); i++) {
    if (i)
      cout << ' ';
    cout << v[i];
  }
  cout << endl;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
#pragma warning(disable : 4996)

// prototype
int counter(int);

int main() {
  // input
  int N;
  (void)scanf("%d", &N);

  // output
  for (int i = 1; i <= N; i++) {
    printf("%d\\n", counter(i));
  }
}

int counter(int i) {
  int count = 0;
  for (int x = 1; x * (x + 2) <= (i - 3); x++) {
    for (int y = 1; y * (x + y + 1) <= i - ((x * x) + x + 1); y++) {
      for (int z = 1;
           ((x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x)) <= i;
           z++) {
        if (((x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x)) == i)
          count++;
      }
    }
  }
  return count;
}

Error: TLE

Fixed submission:

#include <stdio.h>
#pragma warning(disable : 4996)

// prototype
int counter(int);

int main() {
  // input
  int N;
  (void)scanf("%d", &N);

  // output
  for (int i = 1; i <= N; i++) {
    printf("%d\\n", counter(i));
  }
}

int counter(int i) {
  int count = 0;
  for (int x = 1; x * x < i; x++) {
    for (int y = 1; y * y < i - (x * x); y++) {
      for (int z = 1; z * z < i - (x * x) - (y * y); z++) {
        if (((x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x)) == i)
          count++;
      }
    }
  }
  return count;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int a[10010];
int main() {
  int n;
  cin >> n;

  for (int i = 1; i <= sqrt(n); i++) {
    for (int j = 1; j <= sqrt(n); j++) {
      for (int k = 1; k <= sqrt(n); k++) {
        int temp = i * i + j * j + k * k + i * j + i * k + j * k;
        if (temp <= n) {
          a[temp]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << a[i] << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int x, y, z;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int x = 1; x <= sqrt(i); x++) {

      for (int y = 1; y <= sqrt(i); y++) {
        if (x * x + y * y + x * y >= i - 2)
          break;
        for (int z = 1; z <= sqrt(i); z++) {
          if (x * x + y * y + z * z + x * y + x * z + y * z == i) {
            ans++;
            break;
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}