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

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

using namespace std;

#define fr first
#define sc second
#define mp make_pair
#define foreach(c, it) for (typeof(c) it = (c).begin(); it != (c).end(); it++)

typedef long long int64;
typedef pair<int, int> iP;
typedef pair<iP, int> iiP;

const int INF = 2 << 28;
const double EPS = 1e-10;

int main() {

  int N, M, s, t, e;
  cin >> N >> M;
  vector<vector<pair<int, int>>> cnt(N + 1);
  while (scanf("%d %d %d", &s, &t, &e), e)
    cnt[s].push_back(mp(t, e));
  int L;
  cin >> L;
  while (L--) {
    vector<int> sum(N + 1, 0), c(M);
    for (int i = 0; i < M; i++)
      scanf("%d", &c[i]);
    for (int i = 1; i <= N; i++) {
      for (int j = 0; j < cnt[i].size(); j++) {
        sum[i] += c[cnt[i][j].fr - 1] * cnt[i][j].sc;
      }
    }
    for (int i = 1; i <= N; i++) {
      printf("%d%c", sum[i], (i != N ? ' ' : '\\n'));
    }
  }
}

Error: TLE

Fixed submission:

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

using namespace std;

#define fr first
#define sc second
#define mp make_pair
#define foreach(c, it) for (typeof(c) it = (c).begin(); it != (c).end(); it++)

typedef long long int64;
typedef pair<int, int> iP;
typedef pair<iP, int> iiP;

const int INF = 2 << 28;
const double EPS = 1e-10;

map<pair<int, int>, int> cnt;

int main() {

  int N, M, s, t, e;
  cin >> N >> M;
  while (scanf("%d %d %d", &s, &t, &e), e)
    cnt[mp(s, t)] = e;
  int L;
  cin >> L;
  while (L--) {
    vector<int> sum(N, 0);
    for (int i = 0; i < M; i++) {
      int c;
      scanf("%d", &c);
      for (int j = 0; j < N; j++) {
        sum[j] += cnt[mp(j + 1, i + 1)] * c;
      }
    }
    for (int i = 0; i < N; i++) {
      printf("%d%c", sum[i], (i != N - 1 ? ' ' : '\\n'));
    }
  }
}
Problem p00281 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include <algorithm>
#include <bitset>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;

  vector<int> s, t, e;
  for (;;) {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == 0)
      break;
    s.push_back(a - 1);
    t.push_back(b - 1);
    e.push_back(c);
  }

  int l;
  cin >> l;
  while (--l >= 0) {
    vector<int> b(m);
    for (int i = 0; i < m; ++i)
      cin >> b[i];

    vector<long long> ans(n);
    for (unsigned i = 0; i < s.size(); ++i)
      ans[s[i]] += b[t[i]] * e[i];

    cout << ans[0];
    for (int i = 1; i < n; ++i)
      cout << ' ' << ans[i];
    cout << endl;
  }

  return 0;
}

Error: MLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;

  vector<vector<int>> task(n, vector<int>(m));
  for (;;) {
    int s, t, e;
    cin >> s >> t >> e;
    if (s == 0)
      break;
    task[s - 1][t - 1] = e;
  }

  int l;
  cin >> l;
  while (--l >= 0) {
    vector<int> b(m);
    for (int i = 0; i < m; ++i)
      cin >> b[i];

    for (int i = 0; i < n; ++i) {
      long long ans = 0;
      for (int j = 0; j < m; ++j)
        ans += task[i][j] * b[j];
      cout << ans;
      if (i < n - 1)
        cout << ' ';
      else
        cout << endl;
    }
  }

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

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

const long N = 51000;

int main() {
  int n, m, l;
  long s[N], t[N], e[N];

  // 入力
  scanf(" %d %d", &n, &m);

  long count = 0;
  while (1) {
    scanf(" %ld %ld %ld", &s[count], &t[count], &e[count]);
    if (s[count] == 0 && t[count] == 0 && e[count] == 0)
      break;
    s[count]--;
    t[count]--;
    ++count;
  }
  // printf("%ld\\n", count);

  // 計算
  scanf(" %d", &l);
  for (int i = 0; i < l; ++i) {
    long b[10000];
    long long c[10000];

    for (long j = 0; j < n; ++j)
      c[j] = 0; // 初期化

    for (long j = 0; j < m; ++j) {
      scanf(" %ld", &b[j]);
    }

    for (long j = 0; j < count; ++j) {
      c[s[j]] += e[j] * b[t[j]];
    }

    for (long j = 0; j < n; ++j) {
      if (j != 0)
        printf(" ");
      printf("%lld", c[j]);
    }
    printf("\\n");
  }

  return 0;
}

Error: MLE

Fixed submission:

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

const int MAX = 10000;
int a[MAX][MAX] = {0}; // 職人(1)が工事(2)をこなした回数
int b[100][MAX] = {0};
long c[100][MAX] = {0};

int main() {
  int n, m, l;

  // 入力
  scanf(" %d %d", &n, &m);
  while (1) {
    int s, t, e;
    scanf(" %d %d %d", &s, &t, &e);
    if (s == 0 && t == 0 && e == 0)
      break;

    a[s - 1][t - 1] = e;
  }

  scanf(" %d", &l);
  for (int i = 0; i < l; ++i) {
    for (int j = 0; j < m; ++j) {
      scanf(" %d", &b[i][j]);
    }
  }

  // 計算
  for (int i = 0; i < l; ++i) {
    for (int j = 0; j < m; ++j) {
      long d = b[i][j];
      for (int k = 0; k < n; ++k) {
        c[i][k] += d * a[k][j];
      }
    }
  }

  for (int i = 0; i < l; ++i) {
    for (int j = 0; j < n; ++j) {
      if (j)
        printf(" ");
      printf("%ld", c[i][j]);
    }
    printf("\\n");
  }

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

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

vector<P> a[10000];
int b[10000];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int s, t, e;
  while (scanf("%d%d%d", &s, &t, &e), s) {
    s--;
    t--;
    a[s].push_back(P(t, e));
  }
  int l;
  scanf("%d", &l);
  rep(i, l) {
    rep(j, m) scanf("%d", &b[j]);
    rep(j, n) {
      int sum = 0;
      for (P p : a[j])
        sum += p.second * b[p.first];
      if (j)
        printf(" ");
      printf("%d", sum);
    }
    printf("\\n");
  }
}

Error: MLE

Fixed submission:

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

int a[10000][10000];
int b[10000];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int s, t, e;
  while (scanf("%d%d%d", &s, &t, &e), s) {
    s--;
    t--;
    a[s][t] = e;
  }
  int l;
  scanf("%d", &l);
  rep(i, l) {
    rep(j, m) scanf("%d", &b[j]);
    rep(j, n) {
      int sum = 0;
      rep(k, m) sum += a[j][k] * b[k];
      if (j)
        printf(" ");
      printf("%d", sum);
    }
    printf("\\n");
  }
}
Problem p00281 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for (int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

vector<vector<P>> d;

signed main() {
  int n, m;
  cin >> n >> m;
  d.resize(n, vector<P>());
  while (1) {
    int s, t, e;
    cin >> s >> t >> e;
    if (s + t + e == 0)
      break;
    d[s - 1].push_back(make_pair(t - 1, e));
  }
  int l;
  cin >> l;
  rep(i, 0, l) {
    vector<int> b(m);
    rep(j, 0, m) cin >> b[j];
    rep(j, 0, n) {
      int sum = 0;
      rep(k, 0, d[j].size()) { sum += d[j][k].second * b[d[j][k].first]; }
      if (j != 0)
        cout << ' ';
      cout << sum;
    }
    cout << endl;
  }
}

Error: MLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for (int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;
typedef pair<string, int> psi;

int d[10010][10010];

signed main() {
  int n, m;
  cin >> n >> m;
  while (1) {
    int s, t, e;
    cin >> s >> t >> e;
    if (s + t + e == 0)
      break;
    d[s - 1][t - 1] = e;
  }
  int l;
  cin >> l;
  rep(i, 0, l) {
    vector<int> b(m);
    rep(j, 0, m) cin >> b[j];
    rep(j, 0, n) {
      int sum = 0;
      rep(k, 0, m) { sum += d[j][k] * b[k]; }
      if (j != 0)
        cout << ' ';
      cout << sum;
    }
    cout << endl;
  }
}
Problem p00281 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include "bits/stdc++.h"
#include <unordered_map>
#include <unordered_set>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class T> using Table = vector<vector<T>>;
const ld eps = 1e-9;

//// < "D:\\D_Download\\Visual Studio
///2015\\Projects\\programing_contest_c++\\Debug\\a.txt"
int main() {
  int N, M;
  cin >> N >> M;
  vector<map<int, long long int>> mps(N);
  while (1) {
    int s, t, e;
    cin >> s >> t >> e;
    if (!s)
      break;
    s--;
    t--;
    mps[s][t] += e;
  }
  int L;
  cin >> L;
  for (int i = 0; i < L; ++i) {
    vector<long long int> moneys;
    for (int j = 0; j < M; ++j) {
      int a;
      cin >> a;
      moneys.push_back(a);
    }
    for (int i = 0; i < N; ++i) {
      long long int salary = 0;
      for (auto w : mps[i]) {
        salary += moneys[w.first] * w.second;
      }
      cout << salary;
      if (i != N - 1)
        cout << " ";
      else
        cout << endl;
    }
  }
  return 0;
}

Error: MLE

Fixed submission:

#include "bits/stdc++.h"
#include <unordered_map>
#include <unordered_set>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class T> using Table = vector<vector<T>>;
const ld eps = 1e-9;

//// < "D:\\D_Download\\Visual Studio
///2015\\Projects\\programing_contest_c++\\Debug\\a.txt"
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<long long int>> works(N, vector<long long int>(M));
  while (1) {
    int s, t, e;
    cin >> s >> t >> e;
    if (!s)
      break;
    s--;
    t--;
    works[s][t] += e;
  }
  int L;
  cin >> L;
  for (int i = 0; i < L; ++i) {
    vector<long long int> moneys(M);
    for (int j = 0; j < M; ++j) {
      int b;
      cin >> b;
      moneys[j] = b;
    }
    for (int j = 0; j < N; ++j) {
      long long int salary = 0;
      for (int k = 0; k < M; ++k) {
        salary += works[j][k] * moneys[k];
      }
      cout << salary;
      if (j != N - 1)
        cout << " ";
      else
        cout << endl;
    }
  }
  return 0;
}
Problem p00281 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>

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

using namespace std;
typedef long long ll;

ll c[10005];

int main() {
  int n, m;
  cin >> n >> m;

  vector<pair<pair<int, int>, int>> a;
  while (true) {
    int s, t, e;
    cin >> s >> t >> e;

    if (s == 0 && t == 0 && e == 0)
      break;

    s--;
    t--;

    a.push_back(make_pair(make_pair(s, t), e));
  }

  int l;
  cin >> l;
  rep(q, l) {
    memset(c, 0, sizeof(c));
    vector<int> b(m);
    rep(i, m) cin >> b[i];

    rep(i, a.size()) {
      int s = a[i].first.first;
      int t = a[i].first.second;
      int e = a[i].second;

      c[s] += b[t] * e;
    }

    rep(i, n) {
      cout << c[i];
      if (i == n - 1)
        cout << endl;
      else
        cout << " ";
    }
  }

  return 0;
}

Error: MLE

Fixed submission:

#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>

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

using namespace std;
typedef long long ll;

int a[10005][10005], b[10005];
ll c[10005];

int main() {
  int n, m;
  cin >> n >> m;

  memset(a, 0, sizeof(a));
  memset(b, 0, sizeof(b));

  while (true) {
    int s, t, e;
    cin >> s >> t >> e;

    if (s == 0 && t == 0 && e == 0)
      break;

    s--;
    t--;

    a[s][t] = e;
  }

  int l;
  cin >> l;
  rep(q, l) {
    memset(c, 0, sizeof(c));
    rep(i, m) cin >> b[i];

    rep(i, n) {
      c[i];
      rep(j, m) { c[i] = c[i] + a[i][j] * b[j]; }

      cout << c[i];
      if (i == n - 1)
        cout << endl;
      else
        cout << " ";
    }
  }

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

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

int s[100010], t[100010], e[100010];

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

  int n, m;
  cin >> n >> m;

  int i0 = 0;
  while (1) {
    cin >> s[i0] >> t[i0] >> e[i0];
    if (s[i0] == 0 && t[i0] == 0 && e[i0] == 0)
      break;
    ++i0;
  }

  int l;
  cin >> l;

  for (int i = 0; i < l; ++i) {
    int b[100010];
    for (int j = 0; j < m; ++j) {
      cin >> b[j];
    }
    int score[100010] = {};
    for (int j = 0; j < i0; ++j) {
      score[s[j] - 1] += e[j] * b[t[j] - 1];
    }
    for (int j = 0; j < n; ++j) {
      if (j != 0)
        cout << " ";
      cout << score[j];
    }
    cout << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

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

int s[10010], t[10010], e[10010];

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

  int n, m;
  cin >> n >> m;

  int i0 = 0;
  while (1) {
    cin >> s[i0] >> t[i0] >> e[i0];
    if (s[i0] == 0 && t[i0] == 0 && e[i0] == 0)
      break;
    ++i0;
  }

  int l;
  cin >> l;

  for (int i = 0; i < l; ++i) {
    int b[10010];
    for (int j = 0; j < m; ++j) {
      cin >> b[j];
    }
    int score[10010] = {};
    for (int j = 0; j < i0; ++j) {
      score[s[j] - 1] += e[j] * b[t[j] - 1];
    }
    for (int j = 0; j < n; ++j) {
      if (j != 0)
        cout << " ";
      cout << score[j];
    }
    cout << endl;
  }

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

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
  ll N, M, s, t, e;
  cin >> N >> M;
  vector<ll> S, T, E, c(N);
  while (cin >> s >> t >> e, s) {
    S.push_back(s - 1);
    T.push_back(t - 1);
    E.push_back(e);
  }
  ll L;
  cin >> L;
  for (int i = 0; i < L; i++) {
    ll b[M];
    for (int j = 0; j < N; j++) {
      c[j] = 0;
    }
    for (int j = 0; j < M; j++) {
      cin >> b[j];
    }
    for (int j = 0; j < (int)S.size(); j++) {
      c[S[j]] += b[T[j]] * E[j];
    }
    for (int j = 0; j < N; j++) {
      if (j > 0) {
        cout << " ";
      }
      cout << c[j];
    }
    cout << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
  ll N, M, s, t, e;
  cin >> N >> M;
  vector<ll> S, T, E, c(N);
  while (cin >> s >> t >> e, s) {
    S.push_back(s - 1);
    T.push_back(t - 1);
    E.push_back(e);
  }
  ll L;
  cin >> L;
  for (int i = 0; i < L; i++) {
    ll b[L];
    for (int j = 0; j < N; j++) {
      c[j] = 0;
    }
    for (int j = 0; j < M; j++) {
      cin >> b[j];
    }
    for (int j = 0; j < (int)S.size(); j++) {
      c[S[j]] += b[T[j]] * E[j];
    }
    for (int j = 0; j < N; j++) {
      if (j > 0) {
        cout << " ";
      }
      cout << c[j];
    }
    cout << endl;
  }
  return 0;
}
Problem p00281 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int n, m, l, s, t, e, cnt = 0, a[100000][3], b[100000];
  cin >> n >> m;
  while (1) {
    scanf("%d %d %d", &s, &t, &e);
    if (s + t + e == 0)
      break;
    a[cnt][0] = s;
    a[cnt][1] = t;
    a[cnt][2] = e;
    cnt++;
  }
  cin >> l;
  for (int i = 0; i < l; i++) {
    int c[100000] = {};
    for (int j = 1; j <= m; j++) {
      scanf("%d", &b[j]);
    }
    for (int j = 0; j < cnt; j++) {
      c[a[j][0]] += a[j][2] * b[a[j][1]];
    }
    for (int j = 1; j <= n; j++) {
      printf("%d", c[j]);
      if (j != n)
        printf(" ");
    }
    printf("\\n");
  }
  return 0;
}

Error: -11

Fixed submission:

#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int n, m, l, s, t, e, cnt = 0, a[1000000][3], b[1000000];
  cin >> n >> m;
  while (1) {
    scanf("%d %d %d", &s, &t, &e);
    if (s + t + e == 0)
      break;
    a[cnt][0] = s;
    a[cnt][1] = t;
    a[cnt][2] = e;
    cnt++;
  }
  cin >> l;
  for (int i = 0; i < l; i++) {
    int c[1000000] = {};
    for (int j = 1; j <= m; j++) {
      scanf("%d", &b[j]);
    }
    for (int j = 0; j < cnt; j++) {
      c[a[j][0]] += a[j][2] * b[a[j][1]];
    }
    for (int j = 1; j <= n; j++) {
      printf("%d", c[j]);
      if (j != n)
        printf(" ");
    }
    printf("\\n");
  }
  return 0;
}
Problem p00281 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a, b, c;
  int x, y, z;
  while (1) {
    cin >> x >> y >> z;
    if (x == 0 && y == 0 && z == 0)
      break;
    a.push_back(x - 1);
    b.push_back(y - 1);
    c.push_back(z);
  }
  int l;
  cin >> l;
  vector<int> d(m);
  for (int i = 0; i < l; i++) {
    vector<int> co(n, 0);
    for (int j = 0; j < m; j++) {
      int bu;
      cin >> bu;
      d[j] = bu;
    }
    for (int j = 0; j < a.size(); j++) {
      co[a[j]] += d[b[j]] * c[j];
    }
    for (int j = 0; j < n; j++) {
      cout << co[j];
      if (j + 1 != n) {
        cout << ' ';
      }
    }
    cout << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int p[10001][10001], a, b, c, n, m, q;
int main() {
  cin >> n >> m;
  while (scanf("%d%d%d", &a, &b, &c), a) {
    p[a][b] = c;
  }
  cin >> q;
  while (q--) {
    int d[10001] = {};
    for (int i = 1; i <= m; i++) {
      scanf("%d", &a);
      for (int j = 1; j <= n; j++)
        d[j] += p[j][i] * a;
    }
    for (int i = 1; i <= n; i++) {
      if (i > 1)
        cout << ' ';
      printf("%d", d[i]);
    }
    cout << endl;
  }
}
Problem p00282 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  string s[100] = {{""},    {"Man"}, {"Oku"}, {"Cho"}, {"Kei"}, {"Gai"},
                   {"Jo"},  {"Jou"}, {"Ko"},  {"Kan"}, {"Sei"}, {"Sai"},
                   {"Gok"}, {"Ggs"}, {"Asg"}, {"Nyt"}, {"Fks"}, {"Mts"}};
  int n, m;
  while (true) {
    cin >> m >> n;
    if (m == 0 && n == 0)
      break;
    vector<int> p;
    p.resize(101);
    p[0] = 1;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < 100; j++) {
        p[j] *= m;
      }
      for (int j = 0; j < 100; j++) {
        p[j + 1] += p[j] / 10000;
        p[j] %= 10000;
      }
    }
    for (int i = 100; i >= 0; i--) {
      if (p[i] > 0) {
        cout << p[i];
        cout << s[i];
      }
    }
    cout << endl;
  }
}

Error: -6
malloc(): corrupted top size


Fixed submission:

#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  string s[100] = {{""},    {"Man"}, {"Oku"}, {"Cho"}, {"Kei"}, {"Gai"},
                   {"Jo"},  {"Jou"}, {"Ko"},  {"Kan"}, {"Sei"}, {"Sai"},
                   {"Gok"}, {"Ggs"}, {"Asg"}, {"Nyt"}, {"Fks"}, {"Mts"}};
  int n, m;
  while (true) {
    cin >> m >> n;
    if (m == 0 && n == 0)
      break;
    vector<int> p;
    p.resize(50);
    p[0] = 1;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < 100; j++) {
        p[j] *= m;
      }
      for (int j = 0; j < 100; j++) {
        p[j + 1] += p[j] / 10000;
        p[j] %= 10000;
      }
    }
    for (int i = 100; i >= 0; i--) {
      if (p[i] > 0) {
        cout << p[i];
        cout << s[i];
      }
    }
  }
}
Problem p00283 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <list>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

struct a {
  int b, c, d;
};
a e[500];
int dp[501][501]; //????????????n????¨???????m
int main() {
  int f, g;
  while (cin >> f >> g, f | g) {
    int MAX = 500;
    for (int h = 0; h < g; h++) {
      int i, j, k;
      scanf("%d%d%d", &i, &j, &k);
      e[h] = {i, j, k};
    }
    for (int h = 0; h <= f; h++) {
      for (int i = 0; i <= MAX; i++) {
        dp[h][i] = 1 << 29;
        if (h == 0)
          dp[h][i] = 0;
      }
    }
    for (int h = 1; h <= f; h++) {
      for (int i = MAX; i >= 0; i--) {
        for (int j = 0; j < g; j++) {
          if (i >= e[j].d) {
            dp[h][i] =
                min(dp[h][i], 1 + dp[max(0, h - e[j].b)][min(MAX, i + e[j].c)]);
          }
        }
      }
    }
    if (dp[f][0] >= 100000)
      puts("NA");
    else
      cout << dp[f][0] << endl;
  }
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <list>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

struct c {
  int d, e, f;
};
unordered_map<int, c> k;
int a, b;
unordered_map<int, unordered_map<int, int>> memo;
int saiki(int n, int m) { //????????????n??§????¨???????m
  if (memo[n][m] != -1)
    return memo[n][m];
  int MIN = 1 << 29;
  for (int i = 0; i < b; i++) {
    if (k[i].f <= m) {
      if (k[i].d >= n)
        return memo[n][m] = 1;
      MIN = min(MIN, 1 + saiki(n - k[i].d, min(100, k[i].e + m)));
    }
  }
  return memo[n][m] = MIN;
}
int main() {
  while (cin >> a >> b, a | b) {
    for (int i = 0; i <= 100; i++) {
      for (int j = 0; j <= 100; j++) {
        memo[i][j] = -1;
      }
    }
    for (int g = 0; g < b; g++) {
      int h, i, j;
      scanf("%d%d%d", &h, &i, &j);
      k[g] = {h, i, j};
    }
    int S = saiki(a, 0);
    if (S >= 1 << 29) {
      puts("NA");
    } else
      cout << S << endl;
  }
}