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

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

int N, M, h[200], r[200];

int main() {
  while (true) {
    cin >> N;
    if (N == 0)
      break;
    for (int j = 0; j < N; ++j) {
      cin >> h[j] >> r[j];
    }
    cin >> M;
    for (int j = 0; j < M; ++j) {
      cin >> h[j + N] >> r[j + N];
    }

    int arr[1001][1001];
    for (int j = 0; j <= 1000; ++j)
      fill(arr[j], arr[j] + 1001, 0);

    for (int j = 0; j < N + M; ++j) {
      arr[h[j]][r[j]] = 1;
    }

    int dp[1001][1001];
    for (int j = 0; j <= 1000; ++j)
      fill(dp[j], dp[j] + 1001, 0);

    for (int j = 0; j <= 1000; ++j) {
      for (int k = 0; k <= 1000; ++k) {
        if (j > 0 && k > 0) {
          dp[j][k] = max(dp[j - 1][k - 1] + arr[j][k],
                         max(dp[j - 1][k], dp[j][k - 1]));
        } else if (j > 0) {
          dp[j][k] = dp[j - 1][k];
        } else if (k > 0) {
          dp[j][k] = dp[j][k - 1];
        }
      }
    }

    cout << dp[1000][1000] << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

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

int N, M, h[200], r[200];

int main() {
  while (true) {
    cin >> N;
    if (N == 0)
      break;
    for (int j = 0; j < N; ++j) {
      cin >> h[j] >> r[j];
    }
    cin >> M;
    for (int j = 0; j < M; ++j) {
      cin >> h[j + N] >> r[j + N];
    }

    int arr[201][201];
    for (int j = 0; j <= 200; ++j)
      fill(arr[j], arr[j] + 201, 0);

    for (int j = 0; j < N + M; ++j) {
      arr[h[j]][r[j]] = 1;
    }

    int dp[201][201];
    for (int j = 0; j <= 200; ++j)
      fill(dp[j], dp[j] + 201, 0);

    for (int j = 0; j <= 200; ++j) {
      for (int k = 0; k <= 200; ++k) {
        if (j > 0 && k > 0) {
          dp[j][k] = max(dp[j - 1][k - 1] + arr[j][k],
                         max(dp[j - 1][k], dp[j][k - 1]));
        } else if (j > 0) {
          dp[j][k] = dp[j - 1][k];
        } else if (k > 0) {
          dp[j][k] = dp[j][k - 1];
        }
      }
    }

    cout << dp[200][200] << endl;
  }
  return 0;
}
Problem p00157 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(), in.end()
const double PI = acos(-1);
const double EPS = 1e-10;
const int inf = 1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
int main() {
  int n;
  while (cin >> n, n) {
    vector<pii> in;
    while (n--) {
      int a, b;
      cin >> a >> b;
      in.pb(pii(a, b));
    }
    cin >> n;
    while (n--) {
      int a, b;
      cin >> a >> b;
      in.pb(pii(a, b));
    }
    sort(all(in));
    n = in.size();
    vi dp(210, 1);
    loop(i, 1, n) {
      int ma = 0;
      rep(j, i) if (in[j].first < in[i].first && in[j].second < in[i].second)
          ma = max(ma, dp[j]);
      dp[i] += ma;
    }
    int ma = 0;
    rep(i, n) ma = max(ma, dp[i]);
    cout << ma << endl;
  }
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(), in.end()
const double PI = acos(-1);
const double EPS = 1e-10;
const int inf = 1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
int main() {
  int n;
  while (cin >> n, n) {
    vector<pii> in;
    while (n--) {
      int a, b;
      cin >> a >> b;
      in.pb(pii(a, b));
    }
    cin >> n;
    while (n--) {
      int a, b;
      cin >> a >> b;
      in.pb(pii(a, b));
    }
    sort(all(in));
    n = in.size();
    vi dp(110, 1);
    loop(i, 1, n) {
      int ma = 0;
      rep(j, i) if (in[j].first < in[i].first && in[j].second < in[i].second)
          ma = max(ma, dp[j]);
      dp[i] += ma;
    }
    int ma = 0;
    rep(i, n) ma = max(ma, dp[i]);
    cout << ma << endl;
  }
}
Problem p00157 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int n, m, h[201], r[201];
int dp[201];
int rec(int idx) {
  if (~dp[idx])
    return dp[idx];
  int ret = 0;
  for (int i = 0; i < n + m; i++) {
    if (h[idx] > h[i] && r[idx] > r[i]) {
      ret = max(ret, rec(i) + 1);
    }
  }
  return dp[idx] = ret;
}
int main() {
  while (cin >> n, n) {
    fill_n(dp, 201, -1);
    for (int i = 0; i < n; i++) {
      cin >> h[i] >> r[i];
    }
    cin >> m;
    for (int i = 0; i < m; i++) {
      cin >> h[n + i] >> r[n + i];
    }
    h[n + m] = 1000, r[n + m] = 1000;
    cout << rec(n + m) << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int n, m, h[200], r[200];
int rec(int idx) {
  int ret = 0;
  for (int i = 0; i < n + m; i++) {
    if (h[idx] > h[i] && r[idx] > r[i]) {
      ret = max(ret, rec(i) + 1);
    }
  }
  return ret;
}
int main() {
  while (cin >> n, n) {
    for (int i = 0; i < n; i++) {
      cin >> h[i] >> r[i];
    }
    cin >> m;
    for (int i = 0; i < m; i++) {
      cin >> h[n + i] >> r[n + i];
    }
    h[n + m] = 1000, r[n + m] = 1000;
    cout << rec(n + m) << endl;
  }
}
Problem p00157 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

int main(void) {
  int n, m, h[201], r[201];

  while (cin >> n, n) {
    for (int i = 0; i < n; i++)
      cin >> h[i] >> r[i];
    cin >> m;
    for (int i = n; i < n + m; i++)
      cin >> h[i] >> r[i];

    for (int i = 0; i < n + m; i++) {
      for (int j = i; j < n + m; j++) {
        int t;
        if (h[i] > h[j]) {
          t = h[i];
          h[i] = h[j];
          h[j] = t;
          t = r[i];
          r[i] = r[j];
          r[j] = t;
        }
        if (h[i] == h[j] && r[i] > r[j]) {
          t = h[i];
          h[i] = h[j];
          h[j] = t;
          t = r[i];
          r[i] = r[j];
          r[j] = t;
        }
      }
    }

    int dp[201] = {0};
    dp[0] = 1;
    for (int i = 0; i < n + m; i++) {
      for (int j = i + 1; j < n + m; j++) {
        if (h[i] < h[j] && r[i] < r[j] && dp[i] >= dp[j])
          dp[j] = dp[i] + 1;
      }
    }
    int res = 0;
    for (int i = 0; i < n + m; i++)
      res = max(res, dp[i]);
    cout << res << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

#include <iostream>

using namespace std;

int main(void) {
  int n, m, h[101], r[101];

  while (cin >> n, n) {
    for (int i = 0; i < n; i++)
      cin >> h[i] >> r[i];
    cin >> m;
    for (int i = n; i < n + m; i++)
      cin >> h[i] >> r[i];

    for (int i = 0; i < n + m; i++) {
      for (int j = i; j < n + m; j++) {
        if (h[i] > h[j]) {
          int t = h[i];
          h[i] = h[j];
          h[j] = t;
          t = r[i];
          r[i] = r[j];
          r[j] = t;
        }
      }
    }
    for (int i = 0; i < n + m; i++) {
      for (int j = i; j < n + m; j++) {
        if (r[i] > r[j]) {
          int t = h[i];
          h[i] = h[j];
          h[j] = t;
          t = r[i];
          r[i] = r[j];
          r[j] = t;
        }
      }
    }

    int dp[101] = {0};
    dp[0] = 1;
    for (int i = 0; i < n + m; i++) {
      for (int j = i + 1; j < n + m; j++) {
        if (h[i] < h[j] && r[i] < r[j] && dp[i] >= dp[j])
          dp[j] = dp[i] + 1;
      }
    }
    int res = 0;
    for (int i = 0; i < n + m; i++)
      res = max(res, dp[i]);
    cout << res << endl;
  }

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

#include <algorithm>
#include <iostream>
#include <limits>
#include <vector>
using namespace std;
int main(void) {
  for (;;) {
    int cnt = 0, buf;
    cin >> buf;
    if (!buf)
      return 0;
    for (; buf != 1;) {
      buf = buf % 2 ? buf * 3 + 1 : buf / 2;
      cnt++;
    }
    cout << cnt << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <limits>
#include <vector>
using namespace std;
int main(void) {
  for (;;) {
    int cnt = 0, buf;
    cin >> buf;
    if (!buf)
      return 0;
    for (; buf != 1;) {
      buf = buf % 2 ? buf / 2 : buf * 3 + 1;
      cnt++;
    }
    cout << cnt << endl;
  }
}
Problem p00158 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define pb push_back

using namespace std;

int main() {
  // freopen("0158.inp", "r", stdin);
  int n = 1;
  while (n != 0) {
    cin >> n;
    if (!n)
      break;
    int count = 0;
    while (n != 1) {
      if (n % 2 == 0)
        n /= 2;
      else
        n = 3 * n + 1;
      count++;
    }
    cout << count << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define pb push_back

using namespace std;

int main() {
  int n = 1;
  while (n != 0) {
    cin >> n;
    int count = 0;
    while (n != 1) {
      if (n % 2 == 0)
        n /= 2;
      else
        n = 3 * n + 1;
      count++;
    }
    cout << count << endl;
  }
}
Problem p00158 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main() {

  int n;
  while (1) {
    scanf("%d", &n);
    if (n == 0)
      break;
    int c = 0;
    while (n != 1) {
      if (n % 2 == 0)
        n = n / 2;
      else {
        n = 3 * n + 1;
      }
      c++;
    }

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

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  int n, c = 0;
  while (scanf("%d", &n) != EOF) {
    c = 0;
    while (n != 1) {
      if (n % 2 == 1)
        n = n * 3 + 1;
      else if (n % 2 == 0)
        n = n / 2;
      c++;
    }
    printf("%d\\n", c);
  }
  return 0;
}
Problem p00158 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, l, n) for (int i = l; i < n; i++)
#define rer(i, l, n) for (int i = l; i <= n; i++)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;

int main() {
  int n;
  while (1) {
    cin >> n;
    if (n == 0)
      break;
    int c = 0;
    while (1) {
      if (n == 1)
        break;
      if (n % 2)
        n = 3 * n + 1;
      else
        n /= 2;
      c++;
    }
    o(c);
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, l, n) for (int i = l; i < n; i++)
#define rer(i, l, n) for (int i = l; i <= n; i++)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;

int main() {
  int n;
  while (cin >> n) {
    int c = 0;
    while (1) {
      if (n == 1)
        break;
      if (n % 2)
        n = 3 * n + 1;
      else
        n /= 2;
      c++;
    }
    o(c);
  }
}
Problem p00158 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int n;
  while (cin >> n, n) {
    int cnt = 0;
    while (n != 1) {
      if (n % 2 == 0)
        n /= 2;
      else
        n = n * 3 + 1;
      cnt++;
    }
    cout << cnt << endl;
  }
  return (0);
}

Error: TLE

Fixed submission:

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

int main() {
  int n;
  while (cin >> n, n) {
    int cnt = 0;
    while (n != 0) {
      if (n % 2 == 0)
        n /= 2;
      else
        n = n * 3 + 1;
      cnt++;
    }
    cout << cnt << endl;
  }
  return (0);
}
Problem p00159 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iostream>
using namespace std;
int h, w, maxid, n, b;
double maxn = 1000000000.00;
int main() {
  while (true) {
    cin >> n;
    if (n == 0) {
      break;
    }
    maxn = 1000000000.00;
    for (int i = 0; i < n; i++) {
      cin >> b >> h >> w;
      if (maxn >= abs(10000.00 * w / (h * h) - 22.00)) {
        maxn = abs(10000.00 * w / (h * h) - 22.00);
        maxid = b;
      }
    }
    cout << maxid << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int h, w, maxid, n, b;
double maxn = 1000000000.00;
int main() {
  while (true) {
    cin >> n;
    maxn = 1000000000.00;
    for (int i = 0; i < n; i++) {
      cin >> b >> h >> w;
      if (maxn >= 10000.00 * w / (h * h) - 22.00) {
        maxn = 10000.00 * w / (h * h) - 22.00;
        maxid = b;
      }
    }
    cout << maxid << endl;
  }
}
Problem p00159 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
#define rep2(x, from, to) for (int x = (from); x < (to); ++(x))
#define rep(x, to) rep2(x, 0, to)
#define pint pair<double, int>
int main() {
  int n, h, w;
  pint a;
  while (cin >> n, n) {
    vector<pint> v;
    rep(i, n) {
      cin >> a.second;
      cin >> h >> w;
      a.first = abs(w / ((h / 100.0) * (h / 100.0)) - 22);
      v.push_back(a);
    }
    sort(v.begin(), v.end());
    cout << v[0].second << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <utility>
#include <vector>
using namespace std;
#define rep2(x, from, to) for (int x = (from); x < (to); ++(x))
#define rep(x, to) rep2(x, 0, to)
#define pdi pair<double, int>
const double EPS = 1e-10;
int main() {
  int n, h, w;
  pdi a;
  while (cin >> n, n) {
    vector<pdi> v;
    rep(i, n) {
      cin >> a.second;
      cin >> h >> w;
      a.first = abs(w / ((h / 100.0) * (h / 100.0)) - 22);
      v.push_back(a);
    }
    sort(v.begin(), v.end());

    cout << v[0].second << endl;
    int i = 1;
    while (v[i + 1].first - v[i].first < EPS) {
      cout << v[i].second << endl;
      i++;
    }
  }
  return 0;
}
Problem p00159 (C++) — buggy submission, verdict: Runtime Error

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

#define ABS(X) ((X) < 0 ? -(X) : (X))
typedef pair<double, int> Subj;

int main(void) {
  int n;

  while (cin >> n) {
    if (n == 0)
      break;
    vector<Subj> v;
    for (int i = 0; i < n; i++) {
      int id;
      double h, w, bmi;
      cin >> id >> h >> w;
      h /= 100;
      bmi = w / (h * h);
      v.push_back(make_pair(ABS(bmi - 22), id));
    }
    sort(v.begin(), v.end());
    cout << v[0].second << endl;
  }

  return 0;
}


Error: -11

Fixed submission:

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

#define ABS(X) ((X) < 0 ? -(X) : (X))
typedef pair<double, int> Subj;

int main(void) {
  int n;

  while (cin >> n) {
    vector<Subj> v;
    for (int i = 0; i < n; i++) {
      int id;
      double h, w, bmi;
      cin >> id >> h >> w;
      h /= 100;
      bmi = w / (h * h);
      v.push_back(make_pair(ABS(bmi - 22), id));
    }
    sort(v.begin(), v.end());
    cout << v[0].second << endl;
  }

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

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

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

int main(void) {
  int n;
  while (cin >> n) {
    if (n == 0)
      break;
    vector<pair<double, int>> data;
    REP(i, n) {
      int num;
      double h, w;
      cin >> num >> h >> w;
      data.push_back(pair<double, int>(w * 10000 / (h * h), num));
    }
    sort(data.begin(), data.end());
    vector<pair<double, int>>::iterator itl, itu;
    itl = lower_bound(data.begin(), data.end(), pair<double, int>(22, 0));
    itu = (itl != data.begin()) ? itl - 1 : itl;
    if (abs(22 - (*itl).first) > abs(22 - (*itu).first)) {
      cout << (*itu).second << endl;
    } else {
      cout << (*itl).second << endl;
    }
  }

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

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

int main(void) {
  int n;
  while (cin >> n) {
    if (n == 0)
      break;
    vector<pair<double, int>> data;
    REP(i, n) {
      int num;
      double h, w;
      cin >> num >> h >> w;
      data.push_back(pair<double, int>(w * 10000 / (h * h), num));
    }
    sort(data.begin(), data.end());
    vector<pair<double, int>>::iterator itl, itu;
    itl = lower_bound(data.begin(), data.end(), pair<double, int>(22, 0));
    itu = itl - 1;
    if (abs(22 - (*itl).first) > abs(22 - (*itu).first)) {
      cout << (*itu).second << endl;
    } else {
      cout << (*itl).second << endl;
    }
  }

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

#include <stdio.h>

int main(void) {
  int x, y, z, w, n, i;
  int sum, l;

  while (0 == 0) {
    scanf("%d", &n);
    if (n == 0)
      break;
    sum = 0;
    for (i = 0; i < n; i++) {
      scanf("%d %d %d %d", &x, &y, &z, &w);
      l = x + y + z;
      if (l <= 60 && w <= 2)
        sum += 600;
      else if (l <= 80 && w <= 5)
        sum += 800;
      else if (l <= 100 && w <= 10)
        sum += 1000;
      else if (l <= 120 && w <= 15)
        sum += 1200;
      else if (l <= 140 && w <= 20)
        sum += 1400;
      else if (l <= 160 && w <= 25)
        sum += 1600;
    }
    printf("%d\\n", sum);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main(void) {
  int x, y, z, w, n, i;
  int sum, l;

  while (scanf("%d", &n) != 0) {
    sum = 0;
    for (i = 0; i < n; i++) {
      scanf("%d %d %d %d", &x, &y, &z, &w);
      l = x + y + z;
      if (l <= 60 && w <= 2)
        sum += 600;
      else if (l <= 80 && w <= 5)
        sum += 800;
      else if (l <= 100 && w <= 10)
        sum += 1000;
      else if (l <= 120 && w <= 15)
        sum += 1200;
      else if (l <= 140 && w <= 20)
        sum += 1400;
      else if (l <= 160 && w <= 25)
        sum += 1600;
    }
    printf("%d\\n", sum);
  }
  return 0;
}
Problem p00160 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    if (n == 0)
      return 0;
    int sum = 0;
    for (int i = 0; i < n; i++) {
      int a, b, c, d;
      cin >> a >> b >> c >> d;
      a += b + c;
      if (a <= 60 && d <= 2)
        sum += 600;
      else if (a <= 80 && d <= 5)
        sum += 800;
      else if (a <= 100 && d <= 10)
        sum += 1000;
      else if (a <= 120 && d <= 15)
        sum += 1200;
      else if (a <= 140 && d <= 20)
        sum += 1400;
      else if (a <= 160 && d <= 25)
        sum += 1600;
      else {
      }
    }
    cout << sum << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;
int main() {
  vector<int> l;
  int n;
  int a, b, c, x;
  while (true) {
    cin >> n;
    if (n == 0)
      break;
    int sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> a >> b >> c >> x;
      a += b + c;
      if (a <= 60 && x <= 2)
        sum += 600;
      else if (a <= 80 && x <= 5)
        sum += 800;
      else if (a <= 100 && x <= 10)
        sum += 1000;
      else if (a <= 120 && b <= 15)
        sum += 1200;
      else if (a <= 140 && b <= 20)
        sum += 1400;
      else if (a <= 160 && b <= 25)
        sum += 1600;
      l.push_back(sum);
    }
  }
  for (int i : l)
    cout << i << endl;
}
Problem p00161 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

class Score {
public:
  int num;
  int time;

  Score() {
    this->num = 0;
    this->time = 0;
  }

  Score(int num, int time) {
    this->num = num;
    this->time = time;
  }
};

int main(int argc, const char *argv[]) {

  while (true) {
    int n;
    cin >> n;

    if (n == 0) {
      break;
    }

    Score max, pre, biri, boobie;

    for (int i = 0; i < n; i++) {
      int c1;
      cin >> c1;
      int sum = 0;
      for (int i = 0; i < 4; i++) {
        int m, s;
        cin >> m >> s;
        sum += 60 * m + s;
      }

      if (max.time == 0 || max.time > sum) {
        pre = max;
        max = Score(c1, sum);
      } else if (pre.time == 0 || pre.time > sum) {
        if (biri.time == 0) {
          biri = pre;
        } else if (boobie.time == 0) {
          boobie = pre;
        }
        pre = Score(c1, sum);
      } else if (biri.time < sum) {
        boobie = biri;
        biri = Score(c1, sum);
      } else if (boobie.time < sum) {
        boobie = Score(c1, sum);
      }
    }

    cout << max.num << endl;
    cout << pre.num << endl;
    cout << boobie.num << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

class Score {
public:
  int num;
  int time;

  Score() {
    this->num = 0;
    this->time = 0;
  }

  Score(int num, int time) {
    this->num = num;
    this->time = time;
  }
};

int main(int argc, const char *argv[]) {

  while (true) {
    int n;
    cin >> n;

    Score max, pre, biri, boobie;

    for (int i = 0; i < n; i++) {
      int c1;
      cin >> c1;
      int sum = 0;
      for (int i = 0; i < 4; i++) {
        int m, s;
        cin >> m >> s;
        sum += 60 * m + s;
      }

      if (max.time == 0 || max.time > sum) {
        pre = max;
        max = Score(c1, sum);
      } else if (pre.time == 0 || pre.time > sum) {
        if (biri.time == 0) {
          biri = pre;
        } else if (boobie.time == 0) {
          boobie = pre;
        }
        pre = Score(c1, sum);
      } else if (biri.time < sum) {
        boobie = biri;
        biri = Score(c1, sum);
      } else if (boobie.time < sum) {
        boobie = Score(c1, sum);
      }
    }

    cout << max.num << endl;
    cout << pre.num << endl;
    cout << boobie.num << endl;
  }

  return 0;
}