alexjercan/bugnet huggingface dataset:
Problem p00093 (C++) — buggy submission, verdict: Runtime Error

#include <stdbool.h>
#include <stdio.h>

bool is_leap_year(int y);

int get_leap_years(int *a, int b, int c);

int main() {
  int leap_years_list[1000]; // A.D. 0 - A.D. 3000
                             // の間に閏年は高々1000個しかない

  bool first_set = true; // 一つ目のセットの前にだけは改行を入れてはいけないので

  while (true) {
    int year_begin, year_end;

    // 読み込み
    scanf("%d %d", &year_begin, &year_end);

    // 終了判定
    if (year_begin == 0 && year_end == 0) {
      break;
    }

    // 閏年を計算する
    int leap_years_count =
        get_leap_years(leap_years_list, year_begin, year_end);

    // セットとセットの間には空行を入れる
    if (first_set) {
      first_set = false;
    } else {
      putchar('\\n'); // putcharは一文字だけ出力する関数です
    }

    // 閏年を出力
    if (leap_years_count == 0) {
      puts("NA"); // putsは与えられた文字列を出力した後改行する関数です
    } else {
      for (int i = 0; i < leap_years_count; i++) {
        printf("%d\\n", leap_years_list[i]);
      }
    }
  }
  return 0;
}

bool is_leap_year(int y) {
  if (y % 400 == 0) {
    return true;
  } else if (y % 100 == 0) {
    return false;
  } else {
    return y % 4 == 0;
  }
}

int get_leap_years(int *a, int b, int c) {
  int s = 0;
  for (int i = 0; b <= c; ++b) {
    if (is_leap_year(b) == true) {
      a[i] = b;
      ++s;
      ++i;
    }
  }
  return s;
}

Error: WA

Fixed submission:

#include <stdbool.h>
#include <stdio.h>

bool is_leap_year(int y);

int get_leap_years(int *a, int b, int c);

int main() {
  int leap_years_list[1000]; // A.D. 0 - A.D. 3000
                             // の間に閏年は高々1000個しかない

  bool first_set = true; // 一つ目のセットの前にだけは改行を入れてはいけないので

  while (true) {
    int year_begin, year_end;

    // 読み込み
    scanf("%d %d", &year_begin, &year_end);

    // 終了判定
    if (year_begin == 0 && year_end == 0) {
      break;
    }

    // 閏年を計算する
    int leap_years_count =
        get_leap_years(leap_years_list, year_begin, year_end);

    // セットとセットの間には空行を入れる
    if (first_set) {
      first_set = false;
    } else {
      putchar('\\n'); // putcharは一文字だけ出力する関数です
    }

    // 閏年を出力
    if (leap_years_count == 0) {
      puts("NA"); // putsは与えられた文字列を出力した後改行する関数です
    } else {
      for (int i = 0; i < leap_years_count; i++) {
        printf("%d\\n", leap_years_list[i]);
      }
    }
  }
}

bool is_leap_year(int y) {
  if (y % 400 == 0) {
    return true;
  } else if (y % 100 == 0) {
    return false;
  } else {
    return y % 4 == 0;
  }
}

int get_leap_years(int *a, int b, int c) {
  int s;
  for (int i = 0; b <= c; ++i) {
    if (is_leap_year(b) == true) {
      a[i] = b;
      ++s;
    }
    ++b;
  }
  return s;
}
Problem p00094 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
int main() {
  int a, b;
  for (; ~scanf("%d%d", &a, &b);)
    printf("%f", (double)a * b / 3.305785);
}

Error: TLE

Fixed submission:

#include <cstdio>
int main() {
  int a, b;
  for (; scanf("%d%d", &a, &b);)
    printf("%f", (double)a * b / 3.305785);
}
Problem p00095 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  int n[20], num, a[20], z, max = 0;
  cin >> num;
  for (int i = 0; i < num; i++) {
    cin >> a[i] >> n[i];
    if (max < n[i]) {
      max = n[i];
      z = i;
    } else if (max == n[i]) {
      if (a[z] > a[i])
        z = i;
    }
  }
  cout << a[z] << " " << n[z] << endl;
  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n[20] = {0}, num, a, z = 21, max = 0;
  cin >> num;
  for (int i = 0; i < num; i++) {
    cin >> a >> n[a];
    if (max <= n[a]) {
      if (z > a)
        z = a;
      max = n[a];
    }
  }
  cout << z << " " << max << endl;
  return 0;
}
Problem p00095 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main() {

  int x, y, n;
  int X = 0, Y = 0;

  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    scanf("%d %d", &x, &y);
    if (i == 0) {
      Y = y;
      X = x;
    }
    if (Y == y && x < X) {
      X = x;
      Y = y;
    } else if (Y < y) {
      X = x;
      Y = y;
    }
  }

  printf("%d %d\\n", X, Y);
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {

  int x, y, n;
  int X = 0, Y = 0;

  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    scanf("%d %d", &x, &y);
    if (i = 0) {
      Y = y;
      X = x;
    }
    if (Y == y && x < X) {
      X = x;
      Y = y;
    } else if (Y < y) {
      X = x;
      Y = y;
    }
  }

  printf("%d %d\\n", X, Y);
  return 0;
}
Problem p00095 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int n, a, v, ma, mv = -1;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> v;
    if (v > mv) {
      ma = a;
      mv = v;
    } else if (v == mv && ma > a) {
      ma = a;
    }
  }
  cout << ma << ' ' << mv << endl;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

template <class T> inline T sqr(T x) { return x * x; }

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c)                                                             \\
  for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

const double EPS = 1e-10;
const double PI = acos(-1.0);

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                                               \\
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \\
       << " " << __FILE__ << endl;

int dx[8] = {-1, 0, 1, 0, -1, -1, 1, 1};
int dy[8] = {0, -1, 0, 1, -1, 1, -1, 1};

int main() {
  int n;
  map<int, int> p;

  cin >> n;
  REP(i, n) {
    int a, v;
    cin >> a >> v;
    p.insert(MP(v, a));
  }

  map<int, int>::iterator it = p.end();
  it--;
  map<int, int>::iterator ans = it;
  int max = it->first;
  while (max <= it->first) {
    if (it->second > ans->second)
      ans = it;
    it--;
  }

  cout << ans->second << ' ' << ans->first << endl;
}
Problem p00095 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

int info[22];

int main() {
  int n, a, v;
  int max_idx = 0;

  cin >> n;

  info[max_idx] = -10;
  for (int i = 0; i < n; i++) {
    cin >> a >> v;
    info[a] = v;
  }

  for (int i = 1; i <= n; i++)
    if (info[max_idx] < info[i])
      max_idx = i;
  cout << max_idx << " " << info[max_idx] << endl;

  return 0;
}

Error: WA

Fixed submission:

#include <iostream>

using namespace std;

int info[22];

int main() {
  int n, a, v;
  int max_idx = -1;

  cin >> n;
  cerr << n << endl;
  ;

  for (int i = 0; i < n; i++) {
    cin >> a >> v;
    cerr << a << " " << v << endl;
    info[a] = v;
  }

  // for (int i = 1; i <= n; i++)
  //     if (info[max_idx] < info[i])
  //         max_idx = i;
  // cout << max_idx << " " << info[max_idx] << endl;

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

#include <iostream>
using namespace std;

int main() {
  int n;
  int min = 21, max = 0;
  int a, v;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> v;
    if (max < v) {
      max = v;
      min = a;
    } else if (max == v) {
      if (min > a) {
        min = a;
      }
    }
  }
  cout << min << ' ' << max << endl;
  return (0);
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a[21], b[21];
  int n;
  int max = 0;
  int mx;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
    if (b[i] >= max) {
      max = b[i];
    }
  }
  int i = 0;
  while (1) {
    if (b[i] == max) {
      cout << mx << " " << max << endl;
      i++;
      break;
    }
  }

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

#include <iostream>
using namespace std;

int main() {
  int n;
  int g[20] = {}, p[20] = {};

  cin >> n;

  for (int i = 0; i < n; i++)
    cin >> g[i] >> p[i];

  int max = -1;
  for (int i = 0; i < n; i++) {
    if (max < p[i])
      max = p[i];
  }

  int min = 1000;
  for (int i = 0; i < n; i++) {
    if (p[i] == max) {
      if (min > g[i])
        min = g[i];
    }
  }

  cout << min << " " << max << endl;

  return 0;
}


Error: WA

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int n;
  int p[21] = {};

  cin >> n;

  int max = -1, t;
  for (int i = 0; i < n; i++) {
    cin >> t >> p[t];
    if (max < p[t])
      max = p[t];
  }

  int min = 1000;
  for (int i = 1; i <= 20; i++) {
    if (p[i] == max && i < min)
      min = i;
  }

  cout << min << " " << max;

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

#include <iomanip>
#include <iostream>
#include <list>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) range(i, 0, b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main() {
  int n, r[2];
  int max = 0, num = 20;
  cin >> n;
  rep(i, n) {
    cin >> r[0] >> r[1];
    if (max < r[1]) {
      max = r[1];
      num = r[0];
    } else if (max == r[1] && num > r[0]) {
      num = r[0];
    }
  }
  cout << num << ' ' << max << endl;
}

Error: 0

Fixed submission:

#include <iomanip>
#include <iostream>
#include <list>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) range(i, 0, b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main() {
  int n, res[20][2];
  cin >> n;
  rep(i, n) { cin >> res[i][0] >> res[i][1]; }
  int max = 0, j;
  rep(i, n) {
    if (max < res[i][1]) {
      max = res[i][1];
      j = i;
    }
  }
  cout << res[j][0] << ' ' << res[j][1] << endl;
}
Problem p00096 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define reep(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) reep((i), 0, (n))
#define ALL(v) (v).begin(), (v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI = 6 * asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
static const int INF = 1 << 24;

template <class T>
void initvv(vector<vector<T>> &v, int a, int b, const T &t = T()) {
  v.assign(a, vector<T>(b, t));
}

// v.erase(unique(v.begin(),v.end()),v.end());

int main() {
  int n;
  while (cin >> n) {
    ll ans = 0;
    int large = n;
    int small = max(n - 1000, 0);
    rep(i, 1001) {
      if (i > n)
        break;
      // cout<<i<<endl;
      rep(j, 1001) {
        // if(i+j>=1990) cout<<i<<" "<<j<<endl;
        if (i + j > n)
          continue;
        if (n - i - j > 2000)
          continue;
        int a = min(large - i - j, 1000), b = max(small - i - j, 0);
        // if(i+j==2000) cout<<a<<" "<<b<<endl;
        if (a < 0 || b > 1000)
          continue;
        // if(i+j==2000) cout<<a<<" "<<b<<" "<<i+j<<endl;
        ans += (ll)a - b + 1;
      }
    }
    cout << ans << endl;
  }
}

/*
10
20
8436
*/

Error: 0

Fixed submission:

#include <algorithm>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

#define reep(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) reep((i), 0, (n))
#define ALL(v) (v).begin(), (v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI = 6 * asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
static const int INF = 1 << 24;

/*
0 1 1   1
1 2 3   1+3
2 3 6   1+3+6
3 4 10  1+3+6+10
4



*/

int main() {
  ll a[4][1010] = {0};
  int n = 1005;
  rep(i, n) { a[0][i] = i + 1; }
  a[1][0] = 1;
  rep(i, n) {
    if (i)
      a[1][i] = a[1][i - 1] + i + 1;
  }
  a[2][0] = 1;
  rep(i, n) {
    if (i)
      a[2][i] = a[2][i - 1] + a[1][i];
  }
  while (cin >> n) {
    cout << a[2][n] << endl;
  }
  return 0;
}
Problem p00096 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    int cnt = 0;
    for (int a = 0; a <= 1000; a++) {
      for (int b = 0; b <= 1000; b++) {
        if (n - a - b < 0)
          continue;
        else if (n - a - b <= 1000)
          cnt += n - a - b + 1;
        else if (n - a - b <= 2000)
          cnt += 2000 - (n - a - b) + 1;
      }
    }
    cout << cnt << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int a, b;
  while (cin >> a) {
    b = 0;
    for (int i = 0; i < min(a, 1000); i++)
      for (int j = 0; j < min(a, 1000); j++)
        for (int k = 0; k < min(a, 1000); k++)
          for (int l = 0; l < min(a, 1000); l++)
            if (i + j + k + l == a)
              b++;
    cout << b + 4 << endl;
  }
}
Problem p00096 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
//---------------------------------------------------
//????????????????????????????????????
#define int long long
#define str string
typedef long long ll;
typedef long double ld;
const ll inf = 999999999999999999;
struct P {
  ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
  ll to, cost;
};
ll gcm(ll i, ll j) { //?????§??¬?´???°
  if (i > j)
    swap(i, j);
  if (i == 0)
    return j;
  return gcm(j % i, i);
}
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
int n, dp[5][4001];
signed main() {
  dp[0][0] = 1;
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j <= 4000; j++) {
      for (int z = 0; z <= 1000; z++) {
        if (j + z > 4000)
          break;
        dp[i + 1][j + z] += dp[i][j];
      }
    }
  }
  while (cin >> n) {
    cout << dp[4][n] << endl;
  }
  getchar();
  getchar();
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    int a, b, c, d, e = 0;
    for (a = 0; a <= n; a++) {
      for (b = 0; b <= n; b++) {
        for (c = 0; c <= n; c++) {
          d = n - a - b - c;
          if (d >= 0)
            e++;
          if (a + b + c > n)
            break;
        }
        if (a + b > n)
          break;
      }
    }
    cout << e << endl;
  }
}
Problem p00096 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int n;
  int dp[4100];
  fill(dp, dp + 4100, 0);

  for (int i = 0; i <= 1000; i++) {
    for (int j = 0; j <= 1000; j++) {
      dp[i + j]++;
    }
  }

  while (cin >> n) {
    int ans = 0;
    for (int i = 0; i <= n; i++) {
      ans += dp[i] * dp[n - i];
    }
    cout << ans << endl;
  }
}

Error: TLE

Fixed submission:

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

int search_around(int k[], int i, int n) {
  int ans = 1;
  for (int j = i - 1; 0 <= j && j <= 1001 * 1001 && k[j] == n; j--)
    ans++;
  for (int j = i + 1; 0 <= j && j <= 1001 * 1001 && k[j] == n; j++)
    ans++;
  return ans;
}

int search(int k[], int n) {
  int l = 0, r = 1001 * 1001;
  while (r - l >= 1) {
    int i = (l + r) / 2;
    if (k[i] == n)
      return search_around(k, i, n);
    else if (k[i] < n)
      l = i + 1;
    else
      r = i;
  }
  return 0;
}

int main() {
  int k[1001 * 1001];
  ;
  for (int i = 0; i <= 1000; i++) {
    for (int j = 0; j <= 1000; j++) {
      k[1001 * i + j] = i + j;
    }
  }
  sort(k, k + 1001 * 1001);

  int n;
  while (cin >> n) {
    int ans = 0;
    for (int i = 0; i <= 1000; i++) {
      for (int j = 0; j <= 1000; j++) {
        ans += search(k, n - i - j);
      }
    }
    cout << ans << endl;
  }
}
Problem p00096 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
#define rep(i, a) for (int i = 0; i < a; i++)
#define L 1000

long long getvalue(long long x) {
  if (x <= L)
    return x + 1;
  else
    return L - x % (L + 1);
}

int main(void) {
  int n;
  int tcase = 0;
  while (cin >> n) {
    tcase++;
    long long cnt = 0;

    for (int i = 0; i <= 2 * L; i++) {
      int t = n - i;
      if (0 <= t && t <= 2 * L) {

        cnt += getvalue(i) * getvalue(t);
      }
    }
    cout << cnt << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
#define rep(i, a) for (int i = 0; i < a; i++)
int main(void) {
  int n;
  while (cin >> n) {
    int cnt = 0;

    rep(i, n + 1) rep(j, n + 1) rep(k, n + 1)
        rep(l, n + 1) if (i + j + k + l == n) cnt++;
    cout << cnt << endl;
  }
}
Problem p00096 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int sum[2001];
int main() {
  for (int i = 0; i < 1001; ++i) {
    for (int j = 0; j < 1001; ++j) {
      sum[i + j]++;
    }
  }
  int n;
  while (cin >> n) {
    long long ans = 0;
    for (int i = 0; i <= 1000; ++i) {
      for (int j = 0; j <= 1000; ++j) {
        if (n - i - j > 2001)
          continue;
        if (n - i - j < 0)
          break;
        ans += sum[n - i - j];
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;
int sum[2001];
int main() {
  for (int i = 0; i < 1001; ++i) {
    for (int j = 0; j < 1001; ++j) {
      sum[i + j]++;
    }
  }
  int n;
  while (cin >> n) {
    int ans = 0;
    for (int i = 0; i <= n; ++i) {
      for (int j = 0; i + j <= n; ++j) {
        ans += sum[n - i - j];
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p00096 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {

  int n;

  long long int tbl[5][4001] = {0};
  // 0  <= a <= 1000
  tbl[0][0] = 1;

  for (int i = 1; i < 5; i++) {
    for (int j = 0; j < 4001; j++) {
      for (int k = 0; k < 1001; k++) {
        if (j - k < 0)
          break;
        tbl[i][j] += tbl[i - 1][j - k];
      }
    }
  }

  while (cin >> n) {
    cout << tbl[4][n] << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {

  int n;

  while (cin >> n) {

    int cnt = 0;

    for (int a = 0; a <= 1000; a++) {
      for (int b = 0; b <= 1000; b++) {
        for (int c = 0; c <= 1000; c++) {
          int d = n - (a + b + c);
          if (d <= 1000 && d >= 0)
            cnt++;
        }
      }
    }
    cout << cnt << endl;
  }

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

#include <iostream>
using namespace std;

int main() {
  int n, a, b, sum, t[2001];

  for (int i = 0; i <= 1000; ++i)
    t[i] = i + 1;
  for (int i = 1001; i <= 2000; ++i)
    t[i] = 2001 - i;

  while (cin >> n) {
    sum = 0;
    for (int i = 0; i <= 2000; ++i) {
      for (int j = 0; j <= 2000; ++j) {
        if (i + j == n)
          sum += t[i] * t[j];
      }
    }
    cout << sum << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int n, a, b, c, d;
  unsigned long int sum;

  while (cin >> n) {

    sum = 0;
    for (a = 0; a <= 1000; ++a) {
      if (a > n)
        break;
      if (n - a > 3000)
        continue;
      for (b = a; b <= 1000; ++b) {
        if (a + b > n)
          break;
        if (n - a - b > 2000)
          continue;
        for (c = b; c <= 1000; ++c) {
          if (a + b + c > n)
            break;
          else if (n - a - b - c <= 1000) {
            if (a != b && b != c && c != a)
              sum += 6;
            else if (a == b && b == c && c == a)
              sum += 1;
            else
              sum += 3;
          }
        }
      }
    }

    cout << sum << endl;
  }

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

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define vi vector<int>
#define vvi vector<vector<int>>
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i, n) for (int i = 0; i < n; i++)
#define loop(i, s, n) for (int i = s; i < n; i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
int main() {
  vvi dp(10, vi(5000, 0));
  /*dp[i][j] := i????????°???(0,1000)?????´??°??§j???????????´????????°*/
  rep(i, 1001) dp[1][i] = 1;
  for (int i = 1; i < 3; i++)
    rep(j, 2001) rep(k, 2001) dp[i + i][j + k] += dp[i][k] * dp[i][j]; //??´??°
  int n;
  while (cin >> n)
    cout << dp[4][n] << endl;
}

Error: -6
corrupted size vs. prev_size


Fixed submission:

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define vi vector<int>
#define vvi vector<vector<int>>
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i, n) for (int i = 0; i < n; i++)
#define loop(i, s, n) for (int i = s; i < n; i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
int main() {
  vvi dp(10, vi(5000, 0));
  /*dp[i][j] := i????????°???(0,1000)?????´??°??§j???????????´????????°*/
  rep(i, 4500) dp[1][i] = 1;
  for (int i = 1; i < 3; i++)
    rep(j, 4001) rep(k, 4001) dp[i + i][j + k] += dp[i][k] * dp[i][j]; //??´??°
  int n;
  while (cin >> n)
    cout << dp[4][n] << endl;
}