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

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

#pragma warning(disable : 4996)

using namespace std;

typedef long long ll;

#define INF 100000000
#define EPS 1e-9

#define MAX_N 1000000

vector<int> ans_list;

int main() {

  while (true) {

    int e;
    cin >> e;
    if (e == 0)
      break;

    int min_ans = MAX_N;

    for (int i = 0; i <= 100; i++) {
      if (i * i * i > e)
        break;
      for (int j = 0; j <= 1000; j++) {
        if (i * i * i + j * j > e)
          break;

        if (i * i * i + j * j <= e)
          min_ans = min(min_ans, i + j + e - i * i * i - j * j);
      }
    }

    ans_list.push_back(min_ans);
  }

  for (int i = 0; i < ans_list.size(); i++) {
    cout << ans_list[i] << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

#pragma warning(disable : 4996)

using namespace std;

typedef long long ll;

#define INF 100000000
#define EPS 1e-9

#define MAX_N 1000000

vector<int> ans_list;

int main() {

  while (true) {

    int e;
    cin >> e;
    if (e == 0)
      break;

    for (int i = 0;; i++) {
      if (e < i)
        break;
      for (int j = 0;; j++) {
        if (i + j * j > e)
          break;
        for (int k = 0;; k++) {
          if (i + j * j + k * k * k > e)
            break;
          if (i + j * j + k * k * k == e) {
            ans_list.push_back(i + j + k);
            i = j = k = e;
            break;
          }
        }
      }
    }
  }

  for (int i = 0; i < ans_list.size(); i++) {
    cout << ans_list[i] << endl;
  }

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

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

typedef long long ll;

ll e, m, x, min_;

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

  while (cin >> e, e) {
    min_ = m = (int)(1e9 + 7);

    for (int y = 0; y <= sqrt((double)e); y++) {
      for (int z = 0; z <= sqrt((double)e); z++) {
        x = e - y * y - z * z * z;
        if (x < 0)
          break;
        else {
          m = x + y + z;
          // cout << "x, m = " << x << " " << m << endl;
          if (min_ > m)
            min_ = m;
        }
      }
    }

    cout << min_ << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

typedef long long ll;

ll e, m, tmp;

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

  while (cin >> e, e) {
    m = (int)(1e9 + 7);

    for (int y = 0; y <= e; y++) {
      for (int z = 0; z <= e; z++) {
        tmp = e - y * y - z * z * z;
        if (tmp < 0)
          break;
        else {
          tmp += y + z;
          if (m > tmp)
            m = tmp;
        }
      }
    }

    cout << m << endl;
  }

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

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

int e = 0;

int solve() {
  int x, y, z;

  int z_max;
  int res = INT_MAX;
  for (y = 0; y <= e; ++y) {
    if ((e - y * y) < 0) {
      break;
    }
    z_max = pow(e - y * y, 1.0 / 3.0) + 1;
    for (z = 0; z <= z_max; ++z) {
      x = e - y * y - z * z * z;
      if (x >= 0) {
        res = std::min(res, x + y + z);
      } else {
        break;
      }
    }
  }
  return res;
}

int main(void) {
  while (true) {
    std::cin >> e;
    if (e == 0)
      break;
    std::cout << solve() << std::endl;
  }
}

Error: TLE

Fixed submission:

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

int e = 0;

int solve() {
  int x, y, z;

  int z_max;
  int res = INT_MAX;
  for (y = 0; y <= e; ++y) {
    z_max = pow(e - y * y, 1.0 / 3.0) + 1;
    for (z = 0; z <= z_max; ++z) {
      x = e - y * y - z * z * z;
      if (x >= 0) {
        res = std::min(res, x + y + z);
      }
    }
  }
  return res;
}

int main(void) {
  while (true) {
    std::cin >> e;
    if (e == 0)
      break;
    std::cout << solve() << std::endl;
  }
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int e;

  while (cin >> e, e) {
    int m = e;

    for (int z = 0; z * z * z <= e; z++) {
      const int z3 = z * z * z;
      for (int y = 0; y * y + z3 <= e; y++) {
        int x = e - z3 - y * y;
        if (m > x + y + z && x >= 0)
          m = x + y + z;
      }
    }
    cout << m << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int e;

  while (cin >> e, e) {
    if (e == 1)
      cout << e << endl;
    else {
      int x = e, y = round(pow((double)e, 1.0 / 2.0)),
          z = round(pow((double)e, 1.0 / 3.0)), m = x;

      for (int i = 0; i < x; i++) {
        for (int j = 0; j <= y; j++) {
          for (int k = 0; k <= z; k++) {
            if (i + round(pow((double)j, 2.0)) + round(pow((double)k, 3.0)) ==
                    e &&
                m > i + j + k) {
              m = i + j + k;
              break;
            } else if (i + round(pow((double)j, 2.0)) +
                           round(pow((double)k, 3.0)) >
                       e) {
              break;
            }
          }
          if (m != x)
            break;
        }
        if (m != x)
          break;
      }
      cout << m << endl;
    }
  }

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

#include <iostream>

using namespace std;

int main() {

  int e;
  int ans;
  int find;

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

    ans = 10000000;
    for (int i = 0; i * i <= e; i++) {
      for (int j = 0; i * i + j * j * j <= e; j++) {
        if (i + j + (e - i * i - j * j * j) < ans &&
            e - i * i - j * j * j >= 0) {
          ans = i + j + (e - i * i - j * j * j);
        }
      }
    }
    cout << ans << endl;
  }
}


Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {

  int e;
  int ans;

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

    ans = 10000000;
    for (int i = 0; i <= e; i++) {
      for (int j = 0; j * j <= e; j++) {
        for (int k = 0; k * k * k <= e; k++) {
          if (i + j * j + k * k * k == e && ans > i + j + k) {
            ans = i + j + k;
          }
        }
      }
    }
    cout << ans << endl;
  }
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;
int main() {
  int e;
  while (cin >> e && e > 0) {
    int min_sum = 100000;
    for (int i = 0; i * i * i <= e; i++) {
      int j = sqrt(e - i * i * i);
      int k = e - i * i * i - j * j;
      int temp = i + j + k;
      min_sum = min(temp, min_sum);
    }
    cout << min_sum << endl;
  }
}


Error: TLE

Fixed submission:

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

using namespace std;
int main() {
  int e;
  while (cin >> e && e > 0) {
    int min_sum = 100000;
    for (int i = 0; i <= e; i++) {
      int j = sqrt(e - i * i * i);
      int k = e - i * i * i - j * j;
      int temp = i + j + k;
      min_sum = min(temp, min_sum);
    }
    cout << min_sum << endl;
  }
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iostream>
using namespace std;
int x, y, z;
int e;
int solve() {
  int minnum = 1000000;
  for (int z = 0; pow(z, 3) <= e; z++) {
    y = (int)sqrt(e - pow(z, 3));
    minnum = min(minnum, (int)(e - pow(z, 3) - pow(y, 2)) + y + z);
  }
  return minnum;
};
int main() {
  int A[100000];
  int k = 0;
  while (cin >> e && e > 0) {
    A[k] = solve();
    k++;
  }
  for (int l = 0; l < k; l++) {
    cout << A[l] << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int x, y, z;
int e;
int solve() {
  int minsum = 1000000;
  for (z = 0; z <= e; z++) {
    for (y = 0; y <= e; y++) {
      if (e - y * y - z * z * z >= 0)
        minsum = min(minsum, e - y * y - z * z * z + y + z);
    }
  }
  return minsum;
};
int main() {
  int A[100000];
  int k = 0;
  while (cin >> e && e > 0) {
    A[k] = solve();
    k++;
  }
  for (int l = 0; l < k; l++) {
    cout << A[l] << endl;
  }
  return 0;
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int e, m;

int main() {
  int i, j, k, max;
  bool ch = 0;
  while (1) {
    cin >> e;
    if (e == 0)
      break;
    m = inf;
    ch = 0;
    max = sqrt(e);
    for (i = max; i >= 0; i--)
      for (j = max; j >= 0; j--)
        if (!ch) {
          int x = i * i * i + j * j;
          if (x <= e) {
            if (i + j + e - x < m)
              m = i + j + e - x;
          }
        }
    cout << m << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

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

int e, m;

int main() {
  int i, j, k, max;
  while (1) {
    cin >> e;
    if (e == 0)
      break;
    m = inf;
    max = sqrt(e);
    for (i = 0; i < e; i++)
      for (j = 0; j <= max; j++)
        for (k = 0; k < max; k++) {
          if (i + j * j + k * k * k > e)
            break;
          if (i + j * j + k * k * k == e && m > i + j + k)
            m = i + j + k;
        }
    cout << m << endl;
  }
  return 0;
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;

int main(void) {
  int e;
  while (cin >> e, e) {
    bool hit = false;
    int answer = 1000001, sq_y = (int)(sqrt((double)e) + 1);
    for (int z = 100; z > -1 && !hit; --z) {
      int sum_z = z * z * z;
      if (sum_z == e) {
        answer = min(answer, z);
        continue;
      } else if (sum_z > e)
        continue;
      for (int y = 0; y < sq_y; ++y) {
        int sum_zy = sum_z + y * y;
        if (sum_zy == e) {
          answer = min(answer, z + y);
          break;
        } else if (sum_zy > e)
          break;
        else {
          answer = min(answer, (z + y + e - sum_zy));
        }
      }
    }
    cout << answer << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

using namespace std;

int main(void) {
  int e;
  while (cin >> e, e) {
    int Min = 1000001, sq_y = (int)(sqrt((double)e) + 1);
    for (int z = 0; z < 100; ++z) {
      int sum_z = z * z * z;
      if (sum_z > e)
        break;
      for (int y = 0; y < sq_y; ++y) {
        int sum_zy = sum_z + y * y;
        if (sum_zy > e)
          break;
        for (int x = 0; x <= e; ++x) {
          int sum_zyx = sum_zy + x;
          if (sum_zyx == e) {
            Min = min(Min, z + y + x);
            break;
          } else if (sum_zyx > e)
            break;
        }
      }
    }
    cout << Min << endl;
  }
  return 0;
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
int main() {
  int e;
  while (scanf("%d", &e), e) {
    int m = 1 << 25;
    for (int i = 0; i * i * i <= e; i++) {
      for (int j = 0; i * i * i + j * j <= e; j++) {
        int val = i * i * i + j * j;
        m = min(m, i + j + (e - val));
      }
    }
    printf("%d\\n", m);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
int main() {
  int e;
  while (scanf("%d", &e), e) {
    int m = 1 << 25;
    for (int i = 0; i <= e; i++) {
      for (int j = 0; i + j * j <= e; j++) {
        for (int k = 0; i + j * j + k * k * k <= e; k++) {
          if (i + j * j + k * k * k == e) {
            m = min(m, i + j + k);
          }
        }
      }
    }
    printf("%d\\n", m);
  }
  return 0;
}
Problem p01138 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 1000000000
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rev(i, a, b) for (int i = (a)-1; i >= b; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef queue<int> qi;
typedef vector<int> vi;
typedef vector<string> vs;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

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

    vector<pii> vp;
    rep(i, 0, n) {
      int h, m, s;
      scanf("%d:%d:%d", &h, &m, &s);
      vp.push_back(pii(h * 3600 + m * 60 + s, 1));
      scanf("%d:%d:%d", &h, &m, &s);
      vp.push_back(pii(h * 3600 + m * 60 + s, -1));
    }

    sort(vp.begin(), vp.end());

    int ans = 0, tmp = 0;
    rep(i, 0, vp.size()) {
      tmp += vp[i].second;
      ans = max(ans, tmp);
    }
    cout << ans << endl;
  }
}

Error: -11

Fixed submission:

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 1000000000
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rev(i, a, b) for (int i = (a)-1; i >= b; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef queue<int> qi;
typedef vector<int> vi;
typedef vector<string> vs;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

static const int MAX = 24 * 3600 + 60 * 60 + 60;
int t[MAX];

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

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

    rep(i, 0, MAX) t[i] = 0;
    rep(i, 0, n) {
      int h, m, s;
      scanf("%d:%d:%d", &h, &m, &s);
      t[h * 3600 + m * 60 + s]++;
      scanf("%d:%d:%d", &h, &m, &s);
      t[h * 3600 + m * 60 + s]--;
    }

    int ans = -1, tmp = 0;
    rep(i, 0, MAX) {
      tmp += t[i];
      ans = max(ans, tmp);
    }
    cout << ans << endl;
  }

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

#include <bits/stdc++.h>
using namespace std;
int main() {

  for (;;) {

    int n;
    cin >> n;
    if (!n)
      break;

    pair<string, string> train[n];

    for (int i = 0; i < n; i++) {

      string s1, s2;
      cin >> s1 >> s2;

      train[i] = make_pair(s1, s2);
    }

    sort(train, train + n);

    priority_queue<string, vector<string>, greater<string>> train_q;
    int r = 0;

    for (int i = 0; i < n; i++) {

      if (train_q.empty() || train_q.top() > train[i].first)
        r++;
      else
        train_q.pop();

      train_q.push(train[i].second);
    }

    cout << r << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

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

  string a, b[10000];
  int i, n, result = 0, use;

  while (cin >> n, n) {
    cin >> a;
    result = 1;
    for (i = 0; i < n - 1; i++) {
      use = 0;
      cin >> b[i] >> a;
      sort(b, b + i + 1);
      for (int j = i; j != -1 && b[j] != "0"; j--) {
        if (b[j] <= a) {
          b[j] = "0";
          use = 1;
          break;
        }
      }
      // for(int j=0;j<i+1;j++) cout<<b[j]<<" ";
      // cout<<endl;
      if (use == 0)
        result++;
    }
    cin >> a;
    cout << result << endl;
  }
  return 0;
}
Problem p01138 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;

const int INF = 1e+8;

typedef struct {
  int start, end;
} jikan;

int jikanShori(int h, int m, int s) { return h * 3600 + m * 60 + s; }

// 比較関数
int comp(const void *c1, const void *c2) {
  jikan jikan1 = *(jikan *)c1;
  jikan jikan2 = *(jikan *)c2;

  int tmp1 = jikan1.end;
  int tmp2 = jikan2.end;

  return tmp1 - tmp2;
}

int main() {
  int n, cnt, ans;
  int h, m, s;
  jikan interval[10001];

  while (cin >> n, n) {
    cnt = 1;
    ans = 1;
    for (int i = 0; i < 10001; i++) {
      interval[i].start = INF;
      interval[i].end = INF;
    }

    for (int i = 0; i < n; i++) {
      scanf("%d:%d:%d", &h, &m, &s);
      interval[i].start = jikanShori(h, m, s);
      scanf("%d:%d:%d", &h, &m, &s);
      interval[i].end = jikanShori(h, m, s);
    }

    qsort(interval, n + 1, sizeof(jikan), comp);

    for (int i = 0; i < n; i++) {
      cnt = 1;
      for (int j = i + 1; j < n; j++) {
        if (interval[i].end > interval[j].start) {
          cnt++;
        }
      }
      ans = max(ans, cnt);
    }

    cout << ans << endl;
  }
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;

const int INF = 1e+8;

typedef struct {
  int start, end;
} jikan;

int jikanShori(int h, int m, int s) { return h * 3600 + m * 60 + s; }

// 比較関数
int comp(const void *c1, const void *c2) {
  jikan jikan1 = *(jikan *)c1;
  jikan jikan2 = *(jikan *)c2;

  int tmp1 = jikan1.end;
  int tmp2 = jikan2.end;

  return tmp1 - tmp2;
}

int main() {
  int n, cnt, ans;
  int h, m, s;
  jikan interval[10000];

  while (cin >> n, n) {
    cnt = 1;
    ans = 1;
    for (int i = 0; i < 10000; i++) {
      interval[i].start = INF;
      interval[i].end = INF;
    }

    for (int i = 0; i < n; i++) {
      scanf("%d:%d:%d", &h, &m, &s);
      interval[i].start = jikanShori(h, m, s);
      scanf("%d:%d:%d", &h, &m, &s);
      interval[i].end = jikanShori(h, m, s);
    }

    qsort(interval, n + 1, sizeof(jikan), comp);

    for (int i = 0; i < n; i++) {
      cnt = 1;
      for (int j = i + 1; j < n; j++) {
        if (interval[i].end > interval[j].start) {
          cnt++;
        }
      }
      ans = max(ans, cnt);
    }

    cout << ans << endl;
  }
}
Problem p01138 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
  int n;
  while (cin >> n, n) {
    int m[86400] = {};
    for (int i = 0; i < n; i++) {
      int bh, bm, bs, eh, em, es;
      scanf("%d:%d:%d %d:%d:%d", &bh, &bm, &bs, &eh, &em, &es);
      m[(bh * 60 * 60) + (bm * 60) + bs] += 1;
      m[(eh * 60 * 60) + (em * 60) + es] += -1;
    }
    int count = 0, ans = 0;
    for (int i = 0; i < 86400; i++) {
      count += m[i];
      ans = max(ans, count);
    }
    cout << ans << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    int bh[n], bm[n], bs[n], eh[n], em[n], es[n];
    for (int i = 0; i < n; i++)
      scanf("%d:%d:%d %d:%d:%d", &bh[i], &bm[i], &bs[i], &eh[i], &em[i],
            &es[i]);
    int count = 0, m = 1;
    for (int i = 0; i < n; i++) {
      for (int j = 1; i + j < n; j++) {
        if (((eh[i] == bh[i + j]) && (em[i] == bm[i + j]) &&
             (es[i] > bs[i + j])) ||
            ((eh[i] == bh[i + j]) && (em[i] > bm[i + j])) ||
            eh[i] > bh[i + j]) {
          count++;
        } else {
          i = j;
          break;
        }
      }
      m = max(m, count);
    }
    cout << m << endl;
  }
}
Problem p01138 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#define M 86401
using namespace std;

int main() {
  int i, n, v, tf, tt, h, m, s, l[M];
  while (1) {
    scanf("%d", &n);
    if (!n) {
      break;
    }
    fill(l, l + M, 0);
    v = 0;
    for (i = 0; i < n; i++) {
      scanf("%d:%d:%d", &h, &m, &s);
      tf = h * 3600 + m * 60 + s;
      scanf("%d:%d:%d", &h, &m, &s);
      tt = h * 3600 + m * 60 + s;
      l[tf]++;
      l[tt]--;
    }
    for (i = 1; i < M; i++) {
      l[i] += l[i - 1];
    }
    for (i = 0; i < M; i++) {
      v = max(v, l[i]);
    }
    printf("%d\\n", v);
  }
  return 0;
}


Error: WA

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;

int main() {
  vector<vector<int>> trains;
  vector<int> buf(86401, 0);
  int i, k, h, m, s, ts, te, n, isd;

  while (1) {
    scanf("%d", &n);
    if (!n) {
      break;
    }
    for (i = 0; i < n; i++) {
      scanf("%d:%d:%d", &h, &m, &s);
      ts = h * 3600 + m * 60 + s;
      scanf("%d:%d:%d", &h, &m, &s);
      te = h * 3600 + m * 60 + s;

      if (trains.empty()) {
        fill(buf.begin() + ts, buf.begin() + te, 1);
        trains.push_back(buf);
        fill(buf.begin() + ts, buf.begin() + te, 0);
      } else {
        isd = 0;
        for (auto j = trains.begin(); j != trains.end() && !isd; j++) {
          for (k = ts + 1; k <= te - 1; k++) {
            if ((*j)[k]) {
              isd = 1;
              fill((*j).begin() + ts, (*j).begin() + te, 1);
              break;
            }
          }
        }
        if (isd) {
          fill(buf.begin() + ts, buf.begin() + te, 1);
          trains.push_back(buf);
          fill(buf.begin() + ts, buf.begin() + te, 0);
        }
      }
    }
    printf("%lu\\n", trains.size());
  }
  return 0;
}
Problem p01138 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
#define MAX_N 100000
int x[MAX_N];

int main() {
  int n, a, b, c, d, e, maxn = 0;
  ;
  while (true) {
    for (int i = 0; i < MAX_N; i++) {
      x[i] = 0;
    }
    cin >> n;
    maxn = 0;
    if (n == 0) {
      break;
    }
    for (int i = 0; i < n; i++) {
      scanf("%02d:%02d:%02d", &a, &b, &c);
      d = a * 3600 + b * 60 + c;
      scanf("%02d:%02d:%02d", &a, &b, &c);
      e = a * 3600 + b * 60 + c;
      x[d]++;
      x[e]--;
    }
    for (int i = 1; i < 99999; i++) {
      x[i] += x[i - 1];
      maxn = max(maxn, x[i]);
    }
    cout << maxn << endl;
  }
}


Error: -11

Fixed submission:

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

using namespace std;

int main(void) {

  int n;
  int sum[3000];
  int h, m, s;

  while (1) {
    scanf("%d", &n);
    if (n == 0)
      break;
    memset(sum, 0, sizeof(sum));
    for (int i = 0; i < n; i++) {

      scanf("%02d:%02d:%02d", &h, &m, &s);
      sum[h * 60 * 60 + m * 60 + s]++;
      scanf("%02d:%02d:%02d", &h, &m, &s);
      sum[h * 60 * 60 + m * 60 + s]--;
    }
    int res = sum[0];
    for (int i = 0; i <= 24 * 60 * 60; i++) {
      sum[i + 1] += sum[i];
      res = max(res, sum[i + 1]);
    }
    printf("%d\\n", res);
  }
  return 0;
}