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

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

#define rep(i, n) for (int i = 0; i < int(n); ++i)

static const double PI = 6 * asin(0.5);
typedef complex<double> P;
typedef long long ll;

ll n;

int main() {
  while (cin >> n, n != 0) {
    ll id[4005] = {0};
    int a[8000] = {0};

    rep(i, n) {
      ll t1, t2, t3;
      cin >> t1 >> t2 >> t3;
      a[i] = t1;
      // if(id[t1]>0){
      id[t1] += t2 * t3;
      //}
      /*
      else{
              id[t1]=t2*t3;
      }
      */
    }
    bool f = true;
    rep(i, 4005) {
      if (id[a[i]] >= 1000000) {
        cout << a[i] << endl;
        id[a[i]] = 0;
        f = false;
      }
    }
    if (f)
      cout << "NA" << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

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

#define rep(i, n) for (int i = 0; i < int(n); ++i)

static const double PI = 6 * asin(0.5);
typedef complex<double> P;
typedef long long ll;

int n;
int id[5000];

int main() {
  while (cin >> n, n != 0) {
    vector<int> a;
    rep(i, n) {
      int t1, t2, t3;
      a.push_back(t1);
      cin >> t1 >> t2 >> t3;
      id[t1] += t2 * t3;
    }
    bool f = true;
    rep(i, a.size()) {
      if (id[a[i]] >= 1000000) {
        cout << a[i] << endl;
        id[a[i]] = 0;
        f = false;
      }
    }
    if (f)
      cout << "NA" << endl;
  }
}
Problem p00100 (C++) — buggy submission, verdict: Runtime Error

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

using namespace std;

int main(void) {
  int n;
  while (1) {
    cin >> n;
    if (n == 0)
      break;
    long int c[4001] = {};
    int id[100000];
    for (int i = 0; i < n; i++) {
      long int p, q;
      cin >> id[i] >> p >> q;
      c[id[i]] += p * q;
    }
    bool f = 1;
    for (int i = 0; i < n; i++) {
      if (c[id[i]] >= 1000000) {
        cout << id[i] << endl;
        c[id[i]] = 0;
        f = 0;
      }
    }
    if (f)
      cout << "NA" << endl;
  }

  return 0;
}

Error: -11

Fixed submission:

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

using namespace std;

int main(void) {
  int n;
  while (1) {
    cin >> n;
    if (n == 0)
      break;
    int c[4001] = {}, id[10000000];
    for (int i = 0; i < n; i++) {
      int p, q;
      cin >> id[i] >> p >> q;
      c[id[i]] += p * q;
    }
    bool f = 1;
    for (int i = 0; i < n; i++) {
      if (c[id[i]] >= 1000000) {
        cout << id[i] << endl;
        c[id[i]] = 0;
        f = 0;
      }
    }
    if (f)
      cout << "NA" << endl;
  }

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

// 2011/01/12 Tazoe

#include <iostream>
using namespace std;

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0)
      break;

    int emp[4000][3];
    for (int i = 0; i < 4000; i++) {
      emp[i][0] = i + 1;
      emp[i][1] = 0;
      emp[i][2] = 5000;
    }

    int ord = 1;
    for (int i = 0; i < n; i++) {
      int id, p, q;
      cin >> id >> p >> q;
      if (p != 0 && 1000000 / p + 1 <= q)
        emp[id - 1][1] = 1000000;
      else if (emp[id - 1][1] < 1000000)
        emp[id - 1][1] += p * q;
      if (emp[id - 1][2] == 5000) {
        emp[id - 1][2] = ord;
        ord++;
      }
    }

    for (int i = 0; i < 3999; i++)
      for (int j = i + 1; j < 4000; j++)
        if (emp[i][2] > emp[j][2]) {
          int tmp1 = emp[i][0];
          int tmp2 = emp[i][1];
          int tmp3 = emp[i][2];
          emp[i][0] = emp[j][0];
          emp[i][1] = emp[j][1];
          emp[i][2] = emp[j][2];
          emp[j][0] = tmp1;
          emp[j][1] = tmp2;
          emp[j][2] = tmp3;
        }

    int cnt = 0;
    for (int i = 0; emp[i][2] != 5000 && i < 4000; i++)
      if (emp[i][1] >= 1000000) {
        cout << emp[i][0] << endl;
        cnt++;
      }
    if (cnt == 0)
      cout << "NA" << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

// 2011/01/12 Tazoe

#include <iostream>
using namespace std;

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0)
      break;

    int emp[4000][3];
    for (int i = 0; i < 4000; i++) {
      emp[i][0] = i + 1;
      emp[i][1] = 0;
      emp[i][2] = 5000;
    }

    int ord = 1;
    for (int i = 0; i < n; i++) {
      int id, p, q;
      cin >> id >> p >> q;
      if (1000000 / p + 1 <= q)
        emp[id - 1][1] = 1000000;
      else if (emp[id - 1][1] < 1000000)
        emp[id - 1][1] += p * q;
      if (emp[id - 1][2] == 5000) {
        emp[id - 1][2] = ord;
        ord++;
      }
    }

    for (int i = 0; i < 3999; i++)
      for (int j = i + 1; j < 4000; j++)
        if (emp[i][2] > emp[j][2]) {
          int tmp1 = emp[i][0];
          int tmp2 = emp[i][1];
          int tmp3 = emp[i][2];
          emp[i][0] = emp[j][0];
          emp[i][1] = emp[j][1];
          emp[i][2] = emp[j][2];
          emp[j][0] = tmp1;
          emp[j][1] = tmp2;
          emp[j][2] = tmp3;
        }

    int cnt = 0;
    for (int i = 0; emp[i][2] != 5000 && i < 4000; i++)
      if (emp[i][1] >= 1000000) {
        cout << emp[i][0] << endl;
        cnt++;
      }
    if (cnt == 0)
      cout << "NA" << endl;
  }

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

#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

int main(void) {
  int i, l, k;
  int n;
  long long id, c, q;
  long long data_list[4001];
  int id_list[4001];
  bool id_flag;
  bool na_flag;

  while (cin >> n, n != 0) {
    k = 0;
    memset(data_list, 0, sizeof(data_list));
    memset(id_list, 0, sizeof(id_list));
    for (l = 0; l < n; l++) {
      cin >> id >> c >> q;
      if (data_list[id] >= 1000000)
        data_list[id] = 1000000;
      else {
        data_list[id] += (c * q);
      }
      id_flag = true;
      for (i = 0; i < k + 1; i++) {
        if (id_list[i] == id) {
          id_flag = false;
        }
      }

      if (id_flag) {
        id_list[k] = id;
        k++;
      }
    }
    na_flag = true;
    for (l = 0; l < k; l++) {
      if (data_list[id_list[l]] >= 1000000) {
        cout << id_list[l] << endl;
        na_flag = false;
      }
    }
    if (na_flag) {
      cout << "NA" << endl;
    }
  }
  return (0);
}

Error: WA

Fixed submission:

#include <iostream>

using namespace std;

int main(void) {
  int i, l, k;
  int n;
  long long id, c, q;
  long long data_list[5000];
  int id_list[4000];
  bool id_flag;
  bool na_flag;

  while (cin >> n, n != 0) {
    k = 0;
    fill(&data_list[0], &data_list[4001], 0);
    for (l = 0; l < n; l++) {
      data_list[id] += (c * q);
      cin >> id >> c >> q;
      id_flag = true;
      for (i = 0; i < k + 1; i++) {
        if (id_list[i] == id) {
          id_flag = false;
        }
      }
      if (id_flag) {
        id_list[k] = id;
        k++;
      }
    }
    na_flag = true;
    for (l = 0; l < k; l++) {
      if (data_list[id_list[l]] >= 1000000) {
        cout << id_list[l] << endl;
        na_flag = false;
      }
    }
    if (na_flag) {
      cout << "NA" << endl;
    }
  }
  return (0);
}
Problem p00100 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
typedef unsigned long long ll;
int main() {
  int n, val, num, inindex;
  vector<int> Index;
  map<int, ll> List;
  while (true) {
    scanf("%d", &n);
    if (n == 0)
      break;
    List.clear();
    Index.clear();
    for (int i = 0; i < n; i++) {
      scanf("%d %d %d", &inindex, &val, &num);
      if (!List[inindex]) {
        Index.push_back(inindex);
      }
      List[inindex] += val * num;
    }
    bool NAf = true;
    for (int i = 0; i < Index.size(); i++) {
      if (List[Index[i]] >= 1000000) {
        printf("%d\\n", Index[i]);
        NAf = false;
      }
    }
    if (NAf)
      printf("NA\\n");
  }

  return 0;
}

Error: -11

Fixed submission:

/*Kim Jong Il*/
#include <cstdio>
#include <iostream>
#define N1 4000
using namespace std;

int main() {
  int n, id[N1], array[N1][N1], i, j, count;

  while (1) {
    count = 0;
    cin >> n;
    if (n == 0)
      break;

    for (i = 0; i < n; i++) {
      cin >> id[i];
      for (j = 0; j < 2; j++) {
        cin >> array[i][j];
      }
    }
    for (i = 0; i < n; i++) {
      if (array[i][0] * array[i][1] >= 1000000) {
        cout << id[i] << endl;
        count++;
      }
    }
    if (count == 0)
      cout << "NA" << endl;
  }
}
Problem p00100 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
#define max 1000000

long long int id[4000], raw[4000];

int main() {
  long long int num, sale, d;
  int n, i, j, count, k, l, m;

  for (;;) {

    scanf("%lld", &n);

    for (k = 0; k <= 4000; k++) {

      id[k] = 0;
    }

    if (n == 0)
      break;

    else {
      count = 0;
      for (i = 1; i <= n; i++) {
        scanf("%lld %lld %lld", &num, &sale, &d);
        id[num] += (sale * d);
        raw[i] = num;
      }
      for (l = 0; l < 4000; l++) {
        for (m = l + 1; m <= 4000; m++) {
          if (raw[l] == raw[m])
            raw[m] = 0;
        }
      }
      for (j = 1; j < 4000; j++) {
        if (id[raw[j]] >= max) {
          printf("%lld\\n", raw[j]);
          count++;
        }
      }
      if (count == 0)
        printf("NA\\n");
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main(void) {
  int n, i, j, k = 0, l = 0, x, y, z;
  int a[4001] = {0};
  long long b[4001] = {0};
  int c[4001] = {0};
  int flag[4001] = {0};
  int flag2[4001] = {0};
  for (;;) {
    k = 0;
    for (j = 0; j < n; j++) {
      a[j] = 0;
      b[j] = 0;
      flag[j] = 0;
      x = 0;
      c[j] = 0;
    }
    scanf("%d", &n);
    if (n == 0)
      break;
    k = 1;
    for (i = 0; i < n; i++) {
      scanf("%d", &x);
      scanf("%d", &y);
      scanf("%d", &z);

      if (flag[x] == 1)
        i--;
      else {
        b[x] = b[x] + y * z;
        a[i] = x;
        flag2[i] = 1;
      }
    }
    if (b[x] >= 1000000) {

      flag[x] = 1;

      k++;
    }

    if (k != 1) {
      for (l = 0; l < n; l++) {
        if (flag2[l] == 1 && flag[a[l]] == 1) {
          printf("%d\\n", a[l]);
        }
      }
    } else if (k == 1) {
      printf("NA\\n");
    }
  }

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

#include <algorithm>
#include <iostream>
#include <string>
#define N 4001
using namespace std;
int main() {

  int n, a, b, tanka, uriage, jun[N];
  long long int num[N];
  bool judge;

  while (cin >> n) {
    if (n == 0)
      break;

    for (int i = 0; i < N; i++) {
      num[i] = 0;
      jun[i] = 0;
    }

    for (int i = 0, b = 0; i < n; i++) {
      judge = true;
      cin >> a >> tanka >> uriage;
      num[a] += (long long int)tanka * (long long int)uriage;
      for (int j = 0; j < i; j++) {
        if (jun[j] == a) {
          judge = false;
          break;
        }
      }
      if (judge) {
        jun[b] = a;
        b++;
      }
    }

    judge = true;
    for (a = 0; jun[a] != 0; a++) {
      if (num[jun[a]] >= 1000000) {
        cout << jun[a] << endl;
        judge = false;
      }
    }
    if (judge)
      cout << "NA" << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <iostream>
#include <string>
#define N 4001
using namespace std;
int main() {

  int n;
  int a, num[N], tanka, uriage, jun[N];
  bool judge;

  while (cin >> n) {
    if (n == 0)
      break;

    judge = true;
    for (int i = 0; i < N; i++) {
      num[i] = 0;
    }

    for (int i = 0; i < n; i++) {
      cin >> a >> tanka >> uriage;
      num[a] += tanka * uriage;
      jun[i] = a;
    }

    for (int i = 1; i < N; i++) {
      if (num[jun[i]] >= 1000000) {
        cout << jun[i] << endl;
        judge = false;
      }
    }
    if (judge)
      cout << "NA" << endl;
  }
  return 0;
}
Problem p00100 (C++) — buggy submission, verdict: Time Limit Exceeded


#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
#define p 1000000

int main(void) {
  // FILE* fp_in = freopen("data.txt", "r", stdin);

  while (1) {
    long long int n, tmp[3], cnt = 0;
    vector<long long int> number;
    vector<long long int> sales;
    vector<long long int> flg;
    cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < 4000; i++) {
      sales.push_back(0);
      flg.push_back(0);
    }
    for (int i = 0; i < n; i++) {
      cin >> tmp[0] >> tmp[1] >> tmp[2];
      sales.at(tmp[0]) += tmp[1] * tmp[2];
      if (flg.at(tmp[0]) == 1)
        continue;
      number.push_back(tmp[0]);
      flg.at(tmp[0]) = 1;
    }
    for (int i = 0; i < number.size(); i++) {
      if (sales.at(number.at(i)) >= p) {
        cout << number.at(i) << endl;
        cnt++;
      }
    }
    if (cnt == 0) {
      cout << "NA" << endl;
    }
  }

  // while(1){}
  return 0;
}

Error: TLE

Fixed submission:


#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
#define p 1000000

int main(void) {
  //	FILE* fp_in = freopen("data.txt", "r", stdin);

  while (1) {
    long long int n, tmp[3], cnt = 0, flg = 0;
    vector<long long int> number;
    vector<long long int> sales;
    cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      flg = 0;
      cin >> tmp[0] >> tmp[1] >> tmp[2];
      for (int j = 0; j < number.size(); j++) {
        if (number.at(j) == tmp[0]) {
          sales.at(j) += tmp[1] * tmp[2];
          flg = 1;
          break;
        }
      }
      if (flg == 1)
        break;
      number.push_back(tmp[0]);
      sales.push_back(tmp[1] * tmp[2]);
    }
    for (int i = 0; i < number.size(); i++) {
      if (sales.at(i) >= p) {
        cout << number.at(i) << endl;
        cnt++;
      }
    }
    if (cnt == 0) {
      cout << "NA" << endl;
    }
  }

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

#include <algorithm>
#include <iostream>

using namespace std;
typedef long long Int;
Int n, b, c, num[4320];
Int sum[4320];
int main() {
  while (cin >> n, n) {
    fill(sum, sum + 4320, 0);
    for (int i = 0; i < n; i++) {
      cin >> num[i] >> b >> c;
      sum[num[i]] += b * c;
    }
    bool na = true;
    for (int i = 0; i < n; i++) {
      if (sum[num[i]] >= 1000000) {
        na = false;
        cout << num[i] << endl;
        sum[num[i]] = 0;
      }
    }
    if (na)
      cout << "NA" << endl;
  }
  return 0;
}

Error: -6
double free or corruption (out)


Fixed submission:

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

int main() {
  int n;
  while (cin >> n, n) {
    vector<int> num;
    vector<bool> used(n, false);
    map<int, long long> sales;
    int a, b, c;
    for (int i = 0; i < n; i++) {
      cin >> a >> b >> c;
      num.push_back(a);
      sales[a] += b * c;
    }
    bool ok = false;
    for (int i = 0; i < n; i++) {
      int p = num[i];
      if (used[p])
        continue;
      used[p] = true;
      if (sales[p] >= 1000000) {
        cout << p << endl;
        ok = true;
      }
    }
    if (!ok)
      cout << "NA" << endl;
  }
  return 0;
}
Problem p00100 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
int main(void) {
  int n;
  long long int ban[4001], tan, suu;
  long long int bansum[4001], banf[4001], i;
  while (1) {
    scanf("%d", &n);
    if (n == 0) {
      break;
    }
    for (i = 1; i <= 4000; i++) {
      bansum[i] = banf[i] = 0;
    }
    for (i = 0; i < n; i++) {
      scanf("%ld %ld %ld", &ban[i], &tan, &suu);
      bansum[ban[i]] += tan * suu;
    }
    int flg = 0;
    for (i = 0; i < n; i++) {
      if (bansum[ban[i]] >= 1000000 && banf[ban[i]] == 0) {
        printf("%d\\n", ban[i]);
        banf[ban[i]] = 1;
        flg = 1;
      }
    }
    if (flg == 0) {
      printf("NA\\n");
    }
  }
  return 0;
}

Error: WA

Fixed submission:

// a.c.cpp : ??????????????? ??¢????????±????????§????????¨?????????
// ?????????????????????????????????
//

#include <stdio.h>
long long int bango[4001];
int main(void) {
  int n;
  long long ban, tan, suu;
  int flg, i;
  while (1) {
    for (i = 1; i <= 4000; i++) {
      bango[i] = 0;
    }
    scanf("%d", &n);
    if (n == 0) {
      break;
    }
    for (i = 0; i < n; i++) {
      scanf("%d %d %d", &ban, &tan, &suu);
      bango[ban] += tan * suu;
    }
    flg = 0;
    for (i = 1; i <= 4000; i++) {
      if (bango[i] >= 1000000) {
        printf("%d\\n", i);
        flg = 1;
      }
    }
    if (!flg) {
      printf("NA\\n");
    }
  }
  return 0;
}
Problem p00100 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>
#include <utility>
#include <vector>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
int main() {
  int n;
  while (scanf("%d\\n", &n), n) {
    vector<pair<ll, ll>> v;
    rep(i, n) {
      ll x, y, z;
      cin >> x >> y >> z;
      bool f = false;
      for (int j = 0; j < v.size(); ++j) {
        if (v[j].first == x) {
          v[j].second += y * z;
          f = true;
          break;
        }
      }
      if (!f) {
        v.push_back(make_pair(x, y * z));
      }
    }
    bool flag = false;
    for (int j = 0; j < v.size(); ++j) {
      if (v[j].second >= 1000000) {
        flag = true;
        cout << v[j].first << endl;
      }
    }
    if (!flag)
      cout << "NA" << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>
#include <utility>
#include <vector>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
int main() {
  ll n;
  while (scanf("%d\\n", &n), n) {
    vector<pair<ll, ll>> v;
    rep(i, n) {
      ll x, y, z;
      cin >> x >> y >> z;
      bool f = false;
      for (int j = 0; j < v.size(); ++j) {
        if (v[j].first == x) {
          v[j].second += y * z;
          f = true;
          break;
        }
      }
      if (!f) {
        v.push_back(make_pair(x, y * z));
      }
    }
    bool flag = false;
    for (int j = 0; j < v.size(); ++j) {
      if (v[j].second >= 1000000) {
        flag = true;
        cout << v[j].first << endl;
      }
    }
    if (!flag)
      cout << "NA" << endl;
  }
  return 0;
}
Problem p00100 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include <cstring>
#include <iostream>
using namespace std;
#define MAX_N 1000000
long long x[MAX_N], a, b, c, n, cnt;
int main() {
  while (1) {
    memset(x, 0, sizeof(x));
    cnt = 0;
    cin >> n;
    if (!n) {
      break;
    }
    for (int i = 0; i < n; i++) {
      cin >> a >> b >> c;
      x[a] += b * c;
      if (x[a] >= 1000000) {
        cout << a << endl;
        cnt++;
      }
    }
    if (cnt == 0) {
      cout << "NA" << endl;
    }
  }
}

Error: MLE

Fixed submission:

#include <cstring>
#include <iostream>
using namespace std;
#define MAX_N 10000000
long long x[MAX_N], a, b, c, n;
int main() {
  while (1) {
    memset(x, 0, sizeof(x));
    cin >> n;
    if (!n) {
      break;
    }
    for (int i = 0; i < n; i++) {
      cin >> a >> b >> c;
      x[a] += b * c;
      if (x[a] >= 1000000) {
        cout << a << endl;
      }
    }
  }
}
Problem p00100 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int main() {
  int n;
  int id[4000], cid;
  long long int price, num, sale[4000];
  bool f;
  int i, j, idcount;
  while (scanf("%d", &n), n) {

    f = true;
    idcount = 0;

    for (i = 0; i < n; i++) {
      scanf("%d %lld %lld", &cid, &price, &num);

      for (j = 0; j < idcount; j++) {
        if (id[j] == cid) {
          sale[j] = sale[j] + price * num;
        }
      }

      if (j == idcount) {
        id[idcount] = cid;
        sale[idcount] = price * num;
        idcount++;
      }
    }

    for (i = 0; i < idcount; i++) {
      if (sale[i] >= 1000000) {
        printf("%d\\n", id[i]);
        f = false;
      }
    }
    if (f != false)
      printf("NA\\n");
  }
  return 0;
}

Error: -11

Fixed submission:

#include <stdio.h>

int main() {
  int n;
  int id, price, num;
  bool f = false;
  int i;
  while (scanf("%d", &n), n) {

    for (i = 0; i < n; i++) {
      scanf("%d %d %d", id, price, num);
      if (price * num > 1000000) {
        printf("%d\\n", id);
        f = true;
      }
    }
    if (f) {
      printf("NA\\n");
    }
  }
  return 0;
}
Problem p00100 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int main(void) {
  int i, j, k;
  int n, num[4000];
  long long int tanka, sale_num, sale_sum[4000], sale_all[4001];
  bool judge[4001];

  while (scanf("%d", &n), n) {

    // 初期化

    k = 0;
    for (j = 0; j <= 4001; j++) {
      judge[j] = 0;
      sale_all[j] = 0;
    }

    for (i = 0; i < n; i++) {
      scanf("%d %lld %lld", &num[i], &tanka, &sale_num);
      sale_sum[i] = tanka * sale_num;
    }

    // idに対応したsaleに+
    for (i = 0; i < n; i++) {
      sale_all[num[i]] = sale_all[num[i]] + sale_sum[i];
    }

    for (i = 0; i < n; i++) {
      if ((sale_all[num[i]] >= 1000000) && (judge[num[i]] == 0)) {
        printf("%d\\n", num[i]);
        judge[num[i]] = 1;
        k = 1;
      }
    }

    if (k != 1)
      printf("NA\\n");
  }

  return 0;
}

Error: -6
*** stack smashing detected ***: terminated


Fixed submission:

#include <stdio.h>

int main(void) {
  int i, j, k;
  int n, num[4000];
  long long int tanka[4000], sale_num[4000], sale_all[4001];
  bool judge[4001];

  while (scanf("%d", &n), n) {

    // 初期化

    k = 0;
    for (j = 0; j <= 4001; j++) {
      judge[j] = 0;
      sale_all[j] = 0;
    }

    for (i = 0; i < n; i++) {
      scanf("%d %lld %lld", &num[i], &tanka[i], &sale_num[i]);
    }

    // idに対応したsaleに+
    for (i = 0; i < n; i++) {
      sale_all[num[i]] = sale_all[num[i]] + tanka[i] * sale_num[i];
    }

    for (i = 0; i < n; i++) {
      if ((sale_all[num[i]] >= 1000000) && (judge[num[i]] == 0)) {
        printf("%d\\n", num[i]);
        judge[num[i]] = 1;
        k = 1;
      }
    }

    if (k != 1)
      printf("NA\\n");
  }

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

#include <iostream>
using namespace std;

#define SHINE_MAX 4000
#define ELITE 1000000
#define AHO "NA"

int shineN, eliteN;
int shineI[SHINE_MAX];      //??????????????????
long int shineU[SHINE_MAX]; //?£??????????

int dataN, num;
long int tanka, suryo;
int i, j;

int main() {
  while (1) {
    //??\\???
    cin >> dataN;
    if (dataN == 0) {
      break;
    }
    shineN = 0;
    for (j = 0; j < dataN; j++) {
      cin >> num >> tanka >> suryo;
      num--;
      //???????????????????????????????????¨??????????????????
      for (i = 0; i < shineN; i++) {
        if (shineI[i] == num) {
          break;
        }
      }
      if (i == shineN) { //?????¨???????????£????????????
        shineU[num] = 0;
        shineI[shineN] = num;
        shineN++;
      }
      shineU[num] += suryo * tanka;
    }
    //??????
    eliteN = 0;
    for (j = 0; j < shineN; j++) {
      i = shineI[j];
      if (ELITE <= shineU[i]) {
        cout << i + 1 << endl;
        eliteN++;
      }
    }
    if (eliteN == 0) {
      cout << AHO << endl;
    }
  }
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
using namespace std;

#define SHINE_MAX 4000
#define ELITE 1000000
#define AHO "NA"

int shineN, eliteN;
long int shineU[SHINE_MAX]; //?£??????????

int num, tanka, suryo;
int i;

int main() {
  while (1) {
    cin >> shineN;
    if (shineN == 0) {
      break;
    }
    for (i = 0; i < SHINE_MAX; i++) {
      shineU[i] = 0;
    }
    for (i = 0; i < shineN; i++) {
      cin >> num, tanka, suryo;
      shineU[num - 1] += tanka * suryo;
    }
    //??¨?????????????????¨
    eliteN = 0;
    for (i = 0; i < SHINE_MAX && eliteN < shineN; i++) {
      if (ELITE <= shineU[i]) {
        cout << i << endl;
        eliteN++;
      }
    }
    if (eliteN == 0) {
      cout << AHO << endl;
    }
  }
  return 0;
}