alexjercan/bugnet huggingface dataset:
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;

int main() {
  int N;
  cin >> N;

  int cnt = 0;
  for (int i = 1; i <= N; i++) {
    cnt = 0;
    for (int x = 1; x <= sqrt(i); x++) {
      for (int y = x; y <= sqrt(i); y++) {
        for (int z = y; z <= sqrt(i); z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
            if ((x == y) && (y == z)) {
              cnt += 1;
            } else if ((x != y) && (y != z) && (z != x)) {
              cnt += 6;
            } else {
              cnt += 3;
            }
          }
        }
      }
    }
    printf("%d\\n", cnt);
    // cout << cnt << 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;

int main() {
  int N;
  cin >> N;

  int cnt = 0;
  for (int i = 1; i <= N; i++) {
    cnt = 0;
    for (int x = 1; x <= sqrt(i); x++) {
      for (int y = 1; y <= sqrt(i); y++) {
        for (int z = 1; z <= sqrt(i); z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
            cnt++;
          }
        }
      }
    }
    printf("%d\\n", cnt);
    // cout << cnt << endl;
  }

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

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

#define LL long long
#define DD long double

#define M 1000000007
#define INF 1e18

void setIO(string s = "") {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if (s.size())
    s += ".in", freopen(s.c_str(), "r", stdin);
}

int tt = 1;
void solve() {
  int n;
  cin >> n;
  vector<int> f(100050);

  for (LL i = 1; i <= 105; i++) {
    for (LL j = 1; j <= 105; j++) {
      for (LL k = 1; k <= 105; k++) {
        LL ff = i * i + j * j + k * k + i * j + j * k + i * k;
        if (ff <= n)
          f[ff]++;
      }
    }
  }

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

int main() {
  setIO();
  while (tt--) {
    solve();
  }
  return 0;
}

Error: TLE

Fixed submission:

/**
 * Frank Stein
 **/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // freopen("data.in", "r", stdin);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    bool done = false;
    set<int> nums;
    for (int x = 1; x <= 100; x++) {
      for (int y = x; y <= 100; y++) {
        for (int z = y; z <= 100; z++) {
          if (test(x, y, z) == i) {
            done = true;
            nums.insert({x, y, z});
          }
        }
      }
    }
    if (!done) {
      cout << 0 << endl;
      continue;
    }
    if (nums.size() == 1) {
      cout << 1 << endl;
    } else if (nums.size() == 2) {
      cout << 3 << endl;
    } else {
      cout << 5 << endl;
    }
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

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

#define NINJA                                                                  \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0)
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define dloop(i, n) for (int i = n - 1; i >= 0; i--)
#define iii tuple<int, int, int>
#define vi vector<int>
#define ii pair<int, int>
#define vii vector<ii>
#define int long long
#define ld long double
#define pb push_back
#define endl "\\n"
#define setbits __builtin_popcountll
#define mp map<int, int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

const int mxn = 1e6 + 10;
int a[mxn];

int32_t main() {
  NINJA;

  int n;
  cin >> n;

  for (int i = 1; i * i <= n; i++) {
    for (int j = 1; j * j <= n; j++) {
      for (int k = 1; k * k <= n; k++) {
        int ans = ((i + j) * (i + j) + (j + k) * (j + k) + (k + i) * (k + i));
        ans /= 2;
        a[ans]++;
        // if(i==j && j==k && k==i){
        // 	a[ans] = 1;
        // }else{
        // 	a[ans] = 3;
        // }
      }
    }
  }

  for (int i = 1; i <= n; i++)
    cout << a[i] << endl;

  return 0;
}

Error: 0

Fixed submission:

// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

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

#define NINJA                                                                  \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0)
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define dloop(i, n) for (int i = n - 1; i >= 0; i--)
#define iii tuple<int, int, int>
#define vi vector<int>
#define ii pair<int, int>
#define vii vector<ii>
#define int long long
#define ld long double
#define pb push_back
#define endl "\\n"
#define setbits __builtin_popcountll
#define mp map<int, int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

const int mxn = 1e4 + 10;
int a[mxn];

int32_t main() {
  NINJA;

  int n;
  cin >> n;

  for (int i = 1; i * i <= n; i++) {
    for (int j = 1; j * j <= n; j++) {
      for (int k = 1; k * k <= n; k++) {
        int ans = ((i + j) * (i + j) + (j + k) * (j + k) + (k + i) * (k + i));
        ans /= 2;
        if (i == j && j == k && k == i) {
          a[ans] = 1;
        } else {
          a[ans] = 3;
        }
      }
    }
  }

  for (int i = 1; i <= n; i++)
    cout << a[i] << endl;

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

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

int main() {
  int a, b, c, d, e, x, y, z = 0;
  cin >> a;
  if (a <= 5) {
    for (int i = 0; i < a; i++) {
      cout << 0 << endl;
    }
  } else {
    for (int i = 0; i < 5; i++) {
      cout << 0 << endl;
    }
    for (int i = 6; i <= a; i++) {
      c = sqrt(i);
      for (x = 1; x <= c; x++) {
        for (y = 1; y <= x; y++) {
          for (z = 1; z <= y; z++) {
            if (x * x + y * y + z * z + x * y + y * z + x * z == i) {
              if (x == y && y == z) {
                e++;
              } else if (x != y && y != z) {
                e += 6;
              } else {
                e += 3;
              }
            }
          }
        }
      }
      cout << e << endl;
      e = 0;
    }
  }
}

Error: TLE

Fixed submission:

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

int main() {
  int a, b, c, d, e, x, y, z = 0;
  cin >> a;
  if (a <= 5) {
    for (int i = 0; i < a; i++) {
      cout << 0 << endl;
    }
  } else {
    for (int i = 0; i < 5; i++) {
      cout << 0 << endl;
    }
    for (int i = 6; i <= a; i++) {
      c = 96;
      for (x = 1; x <= c; x++) {
        for (y = 1; y <= x; y++) {
          for (z = 1; z <= y; z++) {
            if (x * x + y * y + z * z + x * y + y * z + x * z == i) {
              if (x == y && y == z) {
                e++;
              } else if (x != y && y != z) {
                e += 6;
              } else {
                e += 3;
              }
            }
          }
        }
      }
      cout << e << endl;
      e = 0;
    }
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

const int MAX_N = 10010;

int main(void) {
  int n;
  cin >> n;

  vector<int> v(MAX_N, 0);
  for (int x = 1; x * x <= MAX_N; ++x) {
    for (int y = 1; y * y <= MAX_N; ++y) {
      if (x * x + y * y > MAX_N)
        break;
      for (int z = 1; z * z <= MAX_N; ++z) {
        ll num = (ll)x * x + y * y + z * z + x * y + y * z + z * x;
        if (num < MAX_N)
          v[num]++;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    cout << v[i] << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

const int MAX_N = 10000;
// vector<vector<vector<int>>> xyz(MAX_N, vector<vector<int>>(MAX_N,
// vector<int>(MAX_N)));

int solve(int n) {
  int ans = 0;

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

  return ans;
}

int main(void) {
  int n;
  cin >> n;

  int ans;
  for (int i = 1; i <= n; ++i) {
    ans = solve(i);
    cout << ans << endl;
  }

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

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

int main() {

  int n;
  cin >> n;

  vector<int> vec(10005, 0);
  int v = 0;
  for (int i = 1; i <= sqrt(n); i++) {
    for (int j = 1; j <= sqrt(n); j++) {
      for (int k = 1; k <= sqrt(n); k++) {

        v = j * (i + j + k) + k * (i + k) + i * i;
        if (v <= 10000) {
          vec[v]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << vec[i] << endl;
}

Error: TLE

Fixed submission:

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

int main() {

  int n;
  cin >> n;
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    for (int x = 1; x <= sqrt(i); x++) {
      for (int y = 1; y <= sqrt(i); y++) {
        for (int z = 1; z <= sqrt(i); z++) {
          if ((x + y) * (x + y) > 2 * i)
            break;
          if ((z + y) * (z + y) > 2 * i)
            break;
          if ((x + z) * (x + z) > 2 * i)
            break;

          if ((x + y) * (x + y) + (y + z) * (y + z) + (z + x) * (z + x) > 2 * i)
            break;
          if ((x + y) * (x + y) + (y + z) * (y + z) + (z + x) * (z + x) ==
              2 * i)
            cnt++;
        }
        if ((x + y) * (x + y) > 2 * i)
          break;
      }
    }

    cout << cnt << endl;
    cnt = 0;
  }
}
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;
using ll = long long;
using vi = vector<int>;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int x = 1; x <= n; ++x) {
    int cnt = 0;
    for (int i = 1; i <= x; ++i) {
      if (((i * i) + 1 + 1 + i + 1 + i) > x)
        break;
      for (int j = 1; j <= x; ++j) {
        if (((i * i) + (j * j) + 1 + (i * j) + j + i) > x)
          break;
        for (int k = 1; k <= x; ++k) {
          if (((i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (k * i)) > x)
            break;
          if (((i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (k * i)) == x)
            ++cnt;
        }
      }
    }
    cout << cnt << "\\n";
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int x = 1; x <= n; ++x) {
    int cnt = 0;
    for (int i = 1; i <= x; ++i) {
      for (int j = 1; j <= x; ++j) {
        if (((i * i) + (j * j) + 1 + (i * j) + j + i) > x)
          break;
        for (int k = 1; k <= x; ++k) {
          if (((i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (k * i)) > x)
            break;
          if (((i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (k * i)) == x)
            ++cnt;
        }
      }
    }
    cout << cnt << "\\n";
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int funcx(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;

  int x, y, z;
  int n;

  int nn = sqrt(N);
  // cout << nn << endl;

  for (n = 1; n <= N; n++) {
    int count = 0;
    for (x = 1; x <= nn + 1; x++) {
      for (y = 1; y <= nn + 1; y++) {
        for (z = 1; z <= nn + 1; z++) {
          if (funcx(x, y, z) == n) {
            count++;
          }
          if (funcx(x, y, z) > n) {
            break;
          }
        }
      }
    }
    cout << count << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int funcx(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;

  int x, y, z;
  int n;

  for (n = 1; n <= N; n++) {
    int count = 0;
    for (x = 1; x <= N; x++) {
      for (y = 1; y <= N; y++) {
        for (z = 1; z <= N; z++) {
          if (funcx(x, y, z) == n) {
            count++;
          }
          if (funcx(x, y, z) > n) {
            break;
          }
        }
      }
    }
    cout << count << endl;
  }

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

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mp make_pair
#define S second
#define F first
ll mod = 1e9 + 7;
#define fastIO                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define input_from_file freopen("input.txt", "r", stdin);
using namespace std::chrono;

int main() {
  // input_from_file
  fastIO ll n;
  cin >> n;
  vector<ll> vec(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        ll x = i * i + j * j + k * k + i * j + j * k + k * i;
        if (x > n)
          break;
        vec[x]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << vec[i] << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mp make_pair
#define S second
#define F first
ll mod = 1e9 + 7;
#define fastIO                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define input_from_file freopen("input.txt", "r", stdin);
using namespace std::chrono;

int main() {
  // input_from_file
  fastIO ll n;
  cin >> n;
  vector<ll> vec(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        ll x = i * i + j * j + k * k + i * j + j * k + k * i;
        if (x > n)
          continue;
        vec[x]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << vec[i] << endl;
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int ans[100000] = {0};
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        ans[((i + j) * (i + j) + (i + k) * (i + k) + (j + k) * (j + k)) / 2]++;
      }
    }
  }
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++)
    cout << ans[i] << endl;
  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  int n, cnt = 0;
  cin >> n;
  for (int u = 1; u <= n; u++) {
    cnt = 0;
    for (int i = 1; i <= sqrt(u); i++) {
      for (int j = 1; j <= sqrt(u); j++) {
        for (int k = 1; k <= sqrt(u); k++) {
          if ((i + j) * (i + j) + (i + k) * (i + k) + (j + k) * (j + k) ==
              2 * u)
            cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k, a[10010] = {0}, x, y, z;
  scanf("%d", &n);
  for (x = 1; x <= 100; x++) {
    for (y = 1; y <= 100; y++) {
      for (z = 1; z <= 100; z++) {
        k = x * x + y * y + z * z + x * y + x * z + y * z;
        if (k <= 10000)
          a[k]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%d\\n", a[i]);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k = 0, a[200] = {0};
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int k = 0;
    for (int x = 1; x <= sqrt(i); x++) {
      for (int y = 1; y <= sqrt(i); y++) {
        for (int z = 1; z <= sqrt(i); z++) {
          if (x * x + y * y + z * z + x * y + x * z + y * z == i) {
            k++;
            break;
          }
        }
      }
    }
    cout << k << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;

int main() {
  int N;
  cin >> N;

  vector<int> v(N + 1, 0);
  int max = (int)sqrt((double)N);
  for (int x = 1; x < max; x++) {
    for (int y = 1; y < max; y++) {
      for (int z = 1; z < max; z++) {
        int result = (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x);
        if (result <= N) {
          v[result]++;
        }
        // else {
        //	goto END;
        // }
      }
    }
  }
  // END:
  for (int n = 1; n <= N; n++) {
    cout << v[n] << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

using namespace std;

int main() {
  int N;
  cin >> N;

  for (int n = 1; n <= N; n++) {
    int count = 0;
    if (n >= 6) {
      int max = (int)sqrt((double)n);
      for (int x = 1; x < max; x++) {
        for (int y = 1; y < max; y++) {
          for (int z = 1; z < max; z++) {
            if (((x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x)) ==
                n) {
              count++;
            }
          }
        }
      }
    }
    cout << count << endl;
  }

  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define debug(x) cerr << #x << ": " << x << endl;
#define MOD 1000000007ULL;
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  ll N;
  cin >> N;
  int count[10000000];
  rep(i, N) count[i] = 0;

  rep(x, 100) {
    rep(y, 100) {
      rep(z, 100) {
        int s = x + 1, t = y + 1, u = z + 1;
        int ans = s * s + t * t + u * u + s * t + t * u + u * s;
        if (ans > 10000)
          continue;
        count[ans]++;
      }
    }
  }

  rep(i, N) cout << count[i + 1] << endl;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define debug(x) cerr << #x << ": " << x << endl;
#define MOD 1000000007ULL;
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  ll N;
  cin >> N;
  int count[N];
  rep(i, N) count[i] = 0;

  rep(x, 100) {
    rep(y, 100) {
      rep(z, 100) {
        int s = x + 1, t = y + 1, u = z + 1;
        int ans = s * s + t * t + u * u + s * t + t * u + u * s;
        if (ans >= 10000)
          continue;
        count[ans]++;
      }
    }
  }

  rep(i, N) cout << count[i + 1] << endl;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

// マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 // 10^12
#define MOD 10000007      // 10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

ll func(ll n) {
  ll ans = 0;
  /* cout << "now start search " << n << endl; */
  for (ll i = 1; i * i <= n; i++) {
    for (ll j = 1; j * j <= n; j++) {
      /* cout << "i and j " << i << " " << j << endl; */
      ll left = 0, right = 101;
      ll a = i + j, b = n - i * i - j * j - i * j;
      /* cout << "a is " << a << " b is " << b << endl; */
      while (left + 1 != right) {
        ll mid = (left + right) / 2;
        ll tmp = mid * mid + a * mid - b;
        /* cout << left << " " << right << " " << mid << " " << tmp << endl; */
        /* cout << mid << " " << tmp << endl; */
        if (tmp > 0)
          right = mid;
        else if (tmp < 0)
          left = mid;
        else if (tmp == 0) {
          ans++;
          break;
        }
      }
    }
  }
  return ans;
}

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  /* init(); */
  FOR(i, 1, n) {
    ll tmp = func(i);
    printf("%lld\\n", tmp);
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

// マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 // 10^12
#define MOD 10000007      // 10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

ll func(ll n) {
  ll ans = 0;
  for (ll i = 1; i * i < n; i++) {
    for (ll j = 1; j * j < n; j++) {
      for (ll k = 1; k * k < n; k++) {
        ll tmp = i * i + j * j + k * k + i * j + j * k + k * i;
        if (tmp == n)
          ans++;
      }
    }
  }
  return ans;
}

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  FOR(i, 1, n) {
    ll tmp = func(i);
    printf("%lld\\n", tmp);
    /* cout << func(i) << endl; */
  }

  return 0;
}