Problem p02608 (C++) — buggy submission, verdict: Runtime Error

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

typedef long long int ll;
#define int ll
#define FIO                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define endl "\\n"
#define scan(n) scanf("%lld", &n)
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define rep0 for (int i = 0; i < n; i++)
#define rep1 for (int i = 1; i <= n; i++)
#define inputar0(ar)                                                           \\
  for (int i = 0; i < n; i++)                                                  \\
  cin >> ar[i]
#define inputar1(ar)                                                           \\
  for (int i = 1; i <= n; i++)                                                 \\
  cin >> ar[i]
#define showar0(ar)                                                            \\
  for (int i = 0; i < n; i++)                                                  \\
  cout << ar[i] << " "
#define showar1(ar)                                                            \\
  for (int i = 1; i <= n; i++)                                                 \\
  cout << ar[i] << " "
int mod = 1000000007;
int maxn = 200001;
int binpow(int a, int b, int mod) {
  int res = 1;
  while (b > 0) {
    if (b % 2) {
      res = (res * a) % mod;
      b--;
    }
    a = (a * a) % mod;
    b /= 2;
  }
  return res % mod;
}
int binpow(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b % 2) {
      res = (res * a);
      b--;
    }
    a = (a * a);
    b /= 2;
  }
  return res;
}
bool isPrime(int n) {
  if (n == 1)
    return false;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return false;
  }
  return true;
}
int mul(int a, int b) { return ((a % mod) * (b % mod)) % mod; }

int ar[10008];

void fun() {
  for (int a = 1; a < 100; a++) {
    for (int b = 1; b < 100; b++) {
      for (int c = 1; c < 100; c++) {
        int x = a * a + b * b + c * c + a * b + b * c + c * a;
        if (x <= 10000)
          ar[x]++;
      }
    }
  }
}

signed main() {
  int t = 1;
  //    scan(t);
  fun();
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cout << ar[i] << endl;
    }
  }
}


Error: 0

Fixed submission:

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

typedef long long int ll;
#define int ll
#define FIO                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define endl "\\n"
#define scan(n) scanf("%lld", &n)
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define rep0 for (int i = 0; i < n; i++)
#define rep1 for (int i = 1; i <= n; i++)
#define inputar0(ar)                                                           \\
  for (int i = 0; i < n; i++)                                                  \\
  cin >> ar[i]
#define inputar1(ar)                                                           \\
  for (int i = 1; i <= n; i++)                                                 \\
  cin >> ar[i]
#define showar0(ar)                                                            \\
  for (int i = 0; i < n; i++)                                                  \\
  cout << ar[i] << " "
#define showar1(ar)                                                            \\
  for (int i = 1; i <= n; i++)                                                 \\
  cout << ar[i] << " "
int mod = 1000000007;
int maxn = 200001;
int binpow(int a, int b, int mod) {
  int res = 1;
  while (b > 0) {
    if (b % 2) {
      res = (res * a) % mod;
      b--;
    }
    a = (a * a) % mod;
    b /= 2;
  }
  return res % mod;
}
int binpow(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b % 2) {
      res = (res * a);
      b--;
    }
    a = (a * a);
    b /= 2;
  }
  return res;
}
bool isPrime(int n) {
  if (n == 1)
    return false;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return false;
  }
  return true;
}
int mul(int a, int b) { return ((a % mod) * (b % mod)) % mod; }

int ar[1008];

void fun(int a, int b, int c) {
  for (int a = 1; a < 100; a++) {
    for (int b = 1; b < 100; b++) {
      for (int c = 1; c < 100; c++) {
        int x = (a * a) + b * b + c * c + a * b + b * c + c * a;
        if (x <= 1000)
          ar[x]++;
      }
    }
  }
}

signed main() {
  int t = 1;
  //    scan(t);
  fun(1, 1, 1);
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cout << ar[i] << endl;
    }
  }
}