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

#include <iostream>
using namespace std;
int main(void) {
  int i, h, w, e, k;
  int D = 0, E = 0, K = 0;
  int a[101], b[101], c[101], d[101], z[203] = {0}, p[203] = {0};
  cin >> h;
  for (i = 0; i < 101; i++) {
    a[i] = 999;
    b[i] = 999;
    d[i] = 999;
    c[i] = 999;
  }
  for (i = 0; i < h; i++) {
    cin >> a[i] >> b[i];
  }
  cin >> w;
  for (i = 0; i < w; i++) {
    cin >> c[i] >> d[i];
  }
  while (1) {
    if (D >= h && E >= w)
      break;
    if (a[D] < c[E] || (a[D] == c[E] && b[D] < d[E])) {
      z[K] = a[D];
      p[K] = b[D];
      D++;
    } else if (a[D] > c[E] || (a[D] == c[E] && b[D] > d[E])) {
      z[K] = c[E];
      p[K] = d[E];
      E++;
    } else {
      z[K] = a[D];
      p[K] = b[D];
      D++;
      E++;
    }
    K++;
  }
  // cout<<K<<" "<<D<<" "<<E;
  for (i = 0; i < K - 1; i++) {
    if (p[i] >= 10) {
      cout << z[i] << ":" << p[i] << " ";
    } else {
      cout << z[i] << ":0" << p[i] << " ";
    }
  }
  if (p[K - 1] >= 10) {
    cout << z[K - 1] << ":" << p[K - 1] << endl;
  } else {
    cout << z[K - 1] << ":0" << p[K - 1] << endl;
  }
  // for(i=0;i<h+w;i++){
  //		cout<<a[i]<<b[i]<<endl;
  // }

  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;
int main(void) {
  int i, j, h, w, e, k, min = 9999;
  int D = 0, A = 0, R = 0, E = 0, K = 0;
  int a[101], b[101], c[101], d[101], scride, z[101] = {0}, p[101] = {0};
  cin >> h;
  for (i = 0; i < 101; i++) {
    a[i] = 999;
    b[i] = 999;
    d[i] = 999;
    c[i] = 999;
  }
  for (i = 0; i < h; i++) {
    cin >> a[i] >> b[i];
  }
  cin >> w;
  for (i = 0; i < w; i++) {
    cin >> c[i] >> d[i];
  }
  while (1) {
    if (D >= h && E >= w)
      break;
    if (a[D] < c[E] || (a[D] == c[E] && b[D] < d[E])) {
      z[K] = a[D];
      p[K] = b[D];
      D++;
    } else if (a[D] > c[E] || (a[D] == c[E] && b[D] > d[E])) {
      z[K] = c[E];
      p[K] = d[E];
      E++;
    } else {
      z[K] = a[D];
      p[K] = b[D];
      D++;
      E++;
    }
    K++;
  }
  // cout<<K<<" "<<D<<" "<<E;
  for (i = 0; i < K - 1; i++) {
    if (p[i] >= 10) {
      cout << z[i] << ":" << p[i] << " ";
    } else {
      cout << z[i] << ":0" << p[i] << " ";
    }
  }
  if (p[K - 1] >= 10) {
    cout << z[K - 1] << ":" << p[K - 1] << endl;
  } else {
    cout << z[K - 1] << ":0" << p[K - 1] << endl;
  }
  // for(i=0;i<h+w;i++){
  //		cout<<a[i]<<b[i]<<endl;
  // }

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int h[300] = {}, k[300] = {}, g[300];
  for (int i = 0; i < 300; i++) {
    g[i] = 100000;
  }
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> h[i] >> k[i];
  }
  cin >> m;
  for (int i = n; i < n + m; i++) {
    cin >> h[i] >> k[i];
  }
  for (int i = 0; i < n + m; i++) {
    g[i] = h[i] * 60 + k[i];
    sort(g, g + n + m);
  }

  for (int i = 0; i < n + m; i++) {
    if (g[i] == g[i + 1])
      continue;
    cout << g[i] / 60 << ":";
    if (g[i] % 60 < 10)
      cout << "0" << g[i] % 60;
    else
      cout << g[i] % 60;
    if (i != n + m - 1)
      cout << " ";
  }
  cout << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int h[110] = {}, k[110] = {}, g[110];
  for (int i = 0; i < 110; i++) {
    g[i] = 100000;
  }
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> h[i] >> k[i];
  }
  cin >> m;
  for (int i = n; i < n + m; i++) {
    cin >> h[i] >> k[i];
  }
  for (int i = 0; i < n + m; i++) {
    g[i] = h[i] * 60 + k[i];
    sort(g, g + n + m);
  }

  for (int i = 0; i < n + m; i++) {
    if (g[i] == g[i + 1])
      continue;
    cout << g[i] / 60 << ":";
    if (g[i] % 60 < 10)
      cout << "0" << g[i] % 60;
    else
      cout << g[i] % 60;
    if (i != n + m - 1)
      cout << " ";
  }
  cout << endl;
  return 0;
}
Problem p00293 (C++) — buggy submission, verdict: Runtime Error

#include "bits/stdc++.h"
using namespace std;
#define Max 24 * 60 + 60 + 1
int main() {
  int n, m, n2[101], m2[101];
  cin >> n;
  for (int i = 0; i < 100; i++)
    n2[i] = Max;
  for (int i = 0; i < n; i++) {
    int h, m;
    cin >> h >> m;
    n2[i] = h * 60 + m;
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    int k, g;
    cin >> k >> g;
    m2[i] = k * 60 + g;
  }
  for (int i = n; i < m + n; i++) {
    n2[i] = m2[i - n];
  }
  sort(n2, n2 + (m + n));
  int suu = 0;
  for (int i = 0; i < m + n; i++) {
    if (n2[i] == n2[i + 1]) {
      for (int j = i + 1; n2[i] == n2[j] && n2[j] != Max; j++) {
        i++;
      }
    }
    if (i != m + n - 1) {
      printf("%d:%02d ", n2[i] / 60, n2[i] % 60);
    } else
      printf("%d:%02d\\n", n2[i] / 60, n2[i] % 60);
  }
}

Error: 0

Fixed submission:

#include "bits/stdc++.h"
using namespace std;
#define Max 24 * 60 + 60 + 1
int main() {
  int n, m, n2[101], m2[101];
  cin >> n;
  for (int i = 0; i < 100; i++)
    n2[i] = Max;
  for (int i = 0; i < n; i++) {
    int h, m;
    cin >> h >> m;
    n2[i] = h * 60 + m;
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    int k, g;
    cin >> k >> g;
    n2[i + n] = k * 60 + g;
  }
  sort(n2, n2 + (m + n));
  int suu = 0;
  for (int i = 0; i < m + n; i++) {
    if (n2[i] == n2[i + 1]) {
      for (int j = i + 1; n2[i] == n2[j] && n2[j] != Max; j++) {
        i++;
      }
    }
    if (i != m + n - 1) {
      printf("%d:%02d ", n2[i] / 60, n2[i] % 60);
    } else
      printf("%d:%02d\\n", n2[i] / 60, n2[i] % 60);
  }
}
Problem p00293 (C++) — buggy submission, verdict: Runtime Error

#include <math.h>
#include <stdio.h>
#include <string.h>
int main(void) {
  int a, s[1001], d[1001], f, g, h, i, j, z;
  scanf("%d", &a);
  for (i = 0; i < a; i++)
    scanf("%d %d", &s[i], &d[i]);
  scanf("%d", &f);
  for (i = a; i < a + f; i++)
    scanf("%d %d", &s[i], &d[i]);
  for (i = 0; i < a + f; i++) {
    for (j = i + 1; j < a + f; j++) {
      if (s[i] > s[j]) {
        g = s[i];
        s[i] = s[j];
        s[j] = g;
        g = d[i];
        d[i] = d[j];
        d[j] = g;
      }
    }
  }
  h = a + f;
  for (i = 0; i < a + f; i++) {
    for (j = i + 1; j < a + f; j++) {
      if (s[i] == s[j] && d[i] > d[j]) {
        g = s[i];
        s[i] = s[j];
        s[j] = g;
        g = d[i];
        d[i] = d[j];
        d[j] = g;
      }
      if (s[i] == s[j] && d[i] == d[j]) {
        s[i] = -1;
        d[i] = -1;
      }
    }
  }
  for (i = 0; i < a + f; i++) {
    z = 0;
    if (s[i] != -1 && d[i] != -1) {
      printf("%d:%02d", s[i], d[i]);
      z = 1;
      if (i == a + f - 1)
        z = 0;
    }
    if (z == 1)
      printf(" ");
  }
  printf("\\n");
}

Error: 0

Fixed submission:

#include <math.h>
#include <stdio.h>
#include <string.h>
int main(void) {
  int a, s[101], d[101], f, g, h, i, j, z;
  scanf("%d", &a);
  for (i = 0; i < a; i++)
    scanf("%d %d", &s[i], &d[i]);
  scanf("%d", &f);
  for (i = a; i < a + f; i++)
    scanf("%d %d", &s[i], &d[i]);
  for (i = 0; i < a + f; i++) {
    for (j = i + 1; j < a + f; j++) {
      if (s[i] > s[j]) {
        g = s[i];
        s[i] = s[j];
        s[j] = g;
        g = d[i];
        d[i] = d[j];
        d[j] = g;
      }
    }
  }
  h = a + f;
  for (i = 0; i < a + f; i++) {
    for (j = i + 1; j < a + f; j++) {
      if (s[i] == s[j] && d[i] > d[j]) {
        g = s[i];
        s[i] = s[j];
        s[j] = g;
        g = d[i];
        d[i] = d[j];
        d[j] = g;
      }
      if (s[i] == s[j] && d[i] == d[j]) {
        s[i] = -1;
        d[i] = -1;
      }
    }
  }
  for (i = 0; i < a + f; i++) {
    z = 0;
    if (s[i] != -1 && d[i] != -1) {
      printf("%d:%02d", s[i], d[i]);
      z = 1;
      if (i == a + f - 1)
        z = 0;
    }
    if (z == 1)
      printf(" ");
  }
  printf("\\n");
}
Problem p00293 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  int N = 0;
  int h[201];
  int m[201];
  int M = 0;
  int k[201];
  int g[201];
  int L = 0;
  cin >> N;
  int tem = 0;
  int i = 0;

  int AH[201];
  int AM[201];
  int DH = 100;
  int DM = 100;
  for (int i = 0; i < N; i++) {
    cin >> h[i] >> m[i];
  }

  cin >> M;
  for (int i = 0; i < M; i++) {
    cin >> k[i] >> g[i];
  }
  int A = N + M;
  for (int i = 0; i < M; i++) {
    h[N + i] = k[i];
    m[N + i] = g[i];
  }

  for (int i = 0; i < A - 1; i++) {
    for (int q = i; q < A - 1; q++) {
      if (h[i] > h[q + 1]) {
        tem = h[i];
        h[i] = h[q + 1];
        h[q + 1] = tem;
        tem = m[i];
        m[i] = m[q + 1];
        m[q + 1] = tem;
      }
    }
  }
  for (int i = 0; i < A - 1; i++) {
    for (int q = i; q < A - 1; q++) {
      if ((h[i] == h[q + 1]) && (m[i] > m[q + 1])) {
        tem = m[i];
        m[i] = m[q + 1];
        m[q + 1] = tem;
      }
    }
  }

  int cont = 0;
  for (int i = 0; i < A; i++) {
    if ((DH != h[i]) || (DM != m[i])) {
      AH[cont] = h[i];
      DH = h[i];
      AM[cont] = m[i];
      DM = m[i];
      cont++;
    }
  }
  for (int i = 0; i < cont; i++) {
    if (AM[i] <= 9) {
      cout << AH[i] << ":0" << AM[i];
    } else {
      cout << AH[i] << ":" << AM[i];
    }
    if (i < cont - 1) {
      cout << " ";
    }
  }
  cout << endl;
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int N = 0;
  int h[200];
  int m[200];
  int M = 0;
  int k[200];
  int g[200];
  int L = 0;
  cin >> N;
  int tem = 0;
  int i = 0;
  for (int i = 0; i < N; i++) {
    cin >> h[i] >> m[i];
  }

  cin >> M;
  for (int i = 0; i < M; i++) {
    cin >> k[i] >> g[i];
  }
  int A = N + M;
  for (int i = 0; i < M; i++) {
    h[N + i] = k[i];
    m[N + i] = g[i];
  }
  for (int i = 0; i < A - 1; i++) {
    for (int q = i; q < A - 1; q++) {
      if (h[i] > h[q + 1]) {
        tem = h[i];
        h[i] = h[q + 1];
        h[q + 1] = tem;
        tem = m[i];
        m[i] = m[q + 1];
        m[q + 1] = tem;
      }
      if ((h[i] == h[q + 1]) && (m[i] == m[q + 1])) {
        h[q + 1] = h[q + 2];
        m[q + 1] = m[q + 2];
        A--;
        q--;
      }
    }
    for (int q = i; q < A - 1; q++) {
      if ((h[i] == h[q + 1]) && (m[i] > m[q + 1])) {
        tem = m[i];
        m[i] = m[q + 1];
        m[q + 1] = tem;
      }
    }
  }
  while (1) {
    if (m[i] < 10) {
      cout << h[i] << ":0" << m[i];
    } else {
      cout << h[i] << ":" << m[i];
    }
    i++;
    if (A == 0) {
      cout << endl;
      break;
    } else {
      cout << " ";
    }
  }
  return 0;
}
Problem p00293 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int n, m, iimo1[201], iimo2[201], turu1[201], turu2[201], co1 = 0, co2 = 0;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> iimo1[i] >> iimo2[i];
  cin >> m;
  for (int i = 0; i < m; i++)
    cin >> turu1[i] >> turu2[i];
  while (n != co1 || m != co2) {
    if (co1 != 0 || co2 != 0)
      cout << " ";
    if (iimo1[co1] > turu1[co2] || n == co1) {
      cout << turu1[co2] << ":";
      if (turu2[co2] < 10)
        cout << "0" << turu2[co2];
      else
        cout << turu2[co2];
      co2++;
    } else if (iimo1[co1] < turu1[co2] || m == co2) {
      cout << iimo1[co1] << ":";
      if (iimo2[co1] < 10)
        cout << "0" << iimo2[co1];
      else
        cout << iimo2[co1];
      co1++;
    } else if (iimo2[co1] > turu2[co2]) {
      cout << turu1[co2] << ":";
      if (turu2[co2] < 10)
        cout << "0" << turu2[co2];
      else
        cout << turu2[co2];
      co2++;
    } else if (iimo2[co1] < turu2[co2]) {
      cout << iimo1[co1] << ":";
      if (iimo2[co1] < 10)
        cout << "0" << iimo2[co1];
      else
        cout << iimo2[co1];
      co1++;
    } else {
      cout << iimo1[co1] << ":";
      if (iimo2[co1] < 10)
        cout << "0" << iimo2[co1];
      else
        cout << iimo2[co1];
      co1++;
      co2++;
    }
  }
  cout << endl;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int n, m, iimo1[201], iimo2[201], turu1[101], turu2[101], co1 = 0, co2 = 0;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> iimo1[i] >> iimo2[i];
  cin >> m;
  for (int i = 0; i < m; i++)
    cin >> turu1[i] >> turu2[i];
  while (n != co1 || m != co2) {
    if (co1 != 0 || co2 != 0)
      cout << " ";
    if (iimo1[co1] > turu1[co2] || n == co1) {
      cout << turu1[co2] << ":";
      if (turu2[co2] < 10)
        cout << "0" << turu2[co2];
      else
        cout << turu2[co2];
      co2++;
    } else if (iimo1[co1] < turu1[co2] || m == co2) {
      cout << iimo1[co1] << ":";
      if (iimo2[co1] < 10)
        cout << "0" << iimo2[co1];
      else
        cout << iimo2[co1];
      co1++;
    } else if (iimo2[co1] > turu2[co2]) {
      cout << turu1[co2] << ":";
      if (turu2[co2] < 10)
        cout << "0" << turu2[co2];
      else
        cout << turu2[co2];
      co2++;
    } else if (iimo2[co1] < turu2[co2]) {
      cout << iimo1[co1] << ":";
      if (iimo2[co1] < 10)
        cout << "0" << iimo2[co1];
      else
        cout << iimo2[co1];
      co1++;
    } else {
      cout << iimo1[co1] << ":";
      if (iimo2[co1] < 10)
        cout << "0" << iimo2[co1];
      else
        cout << iimo2[co1];
      co1++;
      co2++;
    }
  }
  cout << endl;
}
Problem p00293 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define loop(i, n) for (int i = 0; i < n; i++)
int main() {
  int n, m, k = 0;
  int h[200], m1[200];
  cin >> n;
  loop(i, n) {
    cin >> h[i] >> m1[i];
    k++;
  }
  cin >> m;
  loop(i, m) { cin >> h[i + k] >> m1[i + k]; }
  vector<pair<int, int>> p(n + m);
  loop(i, n + m) { p[i] = make_pair(h[i], m1[i]); }
  sort(p.begin(), p.end());
  loop(i, n + m) {}
  loop(i, n + m) {
    if (p[i] == p[i - 1] && i > 0)
      continue;
    if (p[i].second >= 10) {
      if (i == 0)
        cout << p[i].first << ":" << p[i].second;
      else
        cout << " " << p[i].first << ":" << p[i].second;
    } else {
      if (i == 0)
        cout << p[i].first << ":"
             << "0" << p[i].second;
      else
        cout << " " << p[i].first << ":"
             << "0" << p[i].second;
    }
  }
  cout << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define loop(i, n) for (int i = 0; i < n; i++)
int main() {
  int n, m, k = 0;
  int h[100], m1[100];
  cin >> n;
  loop(i, n) {
    cin >> h[i] >> m1[i];
    k++;
  }
  cin >> m;
  loop(i, m) { cin >> h[i + k] >> m1[i + k]; }
  vector<pair<int, int>> p(m + n);
  loop(i, n + m) { p[i] = make_pair(h[i], m1[i]); }
  sort(p.begin(), p.end());
  loop(i, n + m) {}
  loop(i, n + m) {
    if (p[i] == p[i - 1] && i > 0)
      continue;
    if (p[i].second >= 10) {
      if (i == 0)
        cout << p[i].first << ":" << p[i].second;
      else
        cout << " " << p[i].first << ":" << p[i].second;
    } else {
      if (i == 0)
        cout << p[i].first << ":"
             << "0" << p[i].second;
      else
        cout << " " << p[i].first << ":"
             << "0" << p[i].second;
    }
  }
  cout << endl;
  return 0;
}
Problem p00293 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
int main(void) {
  int i, j, p, a, b, h, m, cnt = 0, hun[200], temp;
  scanf("%d", &a);
  for (i = 0; i < a; i++) {
    scanf("%d %d", &h, &m);
    hun[i] = h * 60 + m;
  }
  scanf("%d", &b);
  for (i = a; i < a + b; i++) {
    scanf("%d %d", &h, &m);
    hun[i] = h * 60 + m;
  }
  for (i = 0; i < a + b - 1; i++) {
    for (j = i + 1; j < a + b; j++) {
      if (hun[i] > hun[j]) {
        temp = hun[i];
        hun[i] = hun[j];
        hun[j] = temp;
      }
    }
  }
  p = hun[0];
  for (i = 1; i < a + b; i++) {
    if (p == hun[i]) {
      cnt++;
    } else {
      hun[i - cnt] = hun[i];
      p = hun[i];
    }
  }
  for (i = 0; i < a + b - 1 - cnt; i++) {
    printf("%d:%02d ", hun[i] / 60, hun[i] % 60);
  }
  printf("%d:%02d\\n", hun[i] / 60, hun[i] % 60);
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main(void) {
  int b[50], j, i, x, t, n;
  float k, k2, sum[50], max, syo, y, r;
  while (1) {
    max = -1;
    scanf("%d", &n);
    if (n == 0)
      break;
    scanf("%f", &y);
    for (i = 0; i < n; i++) {
      scanf("%d %f %d", &b[i], &r, &t);
      //          printf("%d\\n",r);
      if (t == 1) {
        syo = r / 100;
        sum[i] = 10000 * (1 + y * syo);
      }
      if (t == 2) {
        syo = r / 100;
        k = 1 + syo;
        k2 = k;
        //              printf("%f\\n",k);
        for (j = 0; j < y - 1; j++) {
          k = k * k2;
        }
        sum[i] = 10000 * k;
      }
    }
    for (i = 0; i < n; i++) {
      //          printf("%f\\n",sum[i]);
      if (max < sum[i]) {
        max = sum[i];
        x = b[i];
      }
    }
    printf("%d\\n", x);
  }
  return 0;
}
Problem p00293 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  int N;
  cin >> N;
  int h[101], m[101];
  for (int i = 0; i < N; i++) {
    cin >> h[i] >> m[i];
  }
  h[N] = 24;
  m[N] = 0;

  int M;
  cin >> M;

  int k[101], g[101];
  for (int j = 0; j < M; j++) {
    cin >> k[j] >> g[j];
  }
  k[M] = 24;
  g[M] = 0;

  for (int i = 0, j = 0; i < N || j < M;) {
    if (h[i] == k[j] && m[i] == g[j]) {
      cout << h[i] << ':' << m[i] / 10 << m[i] % 10;
      i++;
      j++;
    } else if (h[i] < k[j] || (h[i] == k[j] && m[i] < g[j])) {
      cout << h[i] << ':' << m[i] / 10 << m[i] % 10;
      i++;
    } else {
      cout << k[j] << ':' << g[j] / 10 << g[j] % 10;
      j++;
    }
    if (i == N && j == M) {
      cout << endl;
    } else {
      cout << ' ';
    }
  }
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int N;
  cin >> N;
  int h[101], m[101];
  for (int i = 0; i < N; i++) {
    cin >> h[i] >> m[i];
  }
  h[N] = 24;
  m[N] = 0;

  int M;
  cin >> M;

  int k[101], g[101];
  for (int j = 0; j < M; j++) {
    cin >> k[j] >> g[j];
  }
  k[M] = 24;
  g[M] = 0;

  for (int i = 0, j = 0; i < N || j < M;) {
    if (h[i] == k[j] && m[i] == g[j]) {
      cout << h[i] << ';' << m[i] / 10 << m[i] % 10;
      i++;
      j++;
    } else if (h[i] < k[i] || (h[i] == k[j] && m[i] < g[j])) {
      cout << h[i] << ';' << m[i] / 10 << m[i] % 10;
      i++;
    } else {
      cout << k[j] << ';' << g[j] / 10 << g[j] % 10;
      j++;
    }
    if (i == N && j == M) {
      cout << endl;
    } else {
      cout << ' ';
    }
  }
  return 0;
}
Problem p00293 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <queue>
#include <vector>

typedef std::pair<int, int> P;

int main() {
  std::priority_queue<P, std::vector<P>, std::greater<P>> que;
  int n, m;

  std::cin >> n;
  while (n--) {
    int hour, min;
    std::cin >> hour >> min;
    que.push(P(hour, min));
  }

  std::cin >> m;
  while (m--) {
    int hour, min;
    std::cin >> hour >> min;
    que.push(P(hour, min));
  }

  bool flag = false;
  int lmin = 100, lhour = 100;
  while (!que.empty()) {
    P p = que.top();
    que.pop();
    if (!(lhour == p.first && lmin == p.second)) {
      if (flag)
        std::cout << " ";
      std::cout << p.first << ":";
      if (p.second < 10)
        std::cout << 0;
      std::cout << p.second;
    }
    lhour = p.first;
    lmin = p.second;
    if (que.size() == 0)
      std::cout << std::endl;
    if (!flag)
      flag = true;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <queue>
#include <vector>

typedef std::pair<int, int> P;

int main() {
  bool flag[24][60] = {false};
  std::priority_queue<P, std::vector<P>, std::greater<P>> que;

  int n, m;

  std::cin >> n;
  for (int i = 0; i < n; ++i) {
    int m, h;
    std::cin >> h >> m;
    que.push(P(h, m));
  }

  std::cin >> m;
  for (int i = 0; i < m; ++i) {
    int m, h;
    std::cin >> h >> m;
    que.push(P(h, m));
  }

  int lm, lh;
  int len = que.size() + 1;
  for (int i = 0; i < len; ++i) {
    P p = que.top();
    que.pop();
    if (p.second != lm && p.first != lh) {
      std::cout << p.first << ":";
      if (p.second < 10)
        std::cout << 0;
      std::cout << p.second;
      if (!que.size())
        std::cout << std::endl;
      else
        std::cout << " ";
    }
    lm = p.second, lh = p.first;
  }

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

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
int hen(int h, int m) { return h * 60 + m; }
void input(int &num, vector<int> &line) {
  cin >> num;
  for (int i = 0; i < num; ++i) {
    int h, m;
    cin >> h >> m;
    line.push_back(hen(h, m));
  }
  sort(line.begin(), line.end());
  line.push_back(hen(24, 0));
}

void kan(int num) { printf("%d:%02d", num / 60, num % 60); }

void output(int &N, int &M, vector<int> &nline, vector<int> &mline) {
  int i, j;
  i = j = 0;
  for (int k = 0; k < N + M; ++k) {
    if (nline[i] == mline[j]) {
      kan(nline[i]);
      ++k;
      ++i;
      ++j;
    } else if (nline[i] < mline[j]) {
      kan(nline[i]);
      ++i;
    } else {
      kan(mline[j]);
      ++j;
    }
    cout << (k + 1 == N + M ? '\\n' : ' ');
  }
}

int main() {
  int N, M;
  vector<int> nline, mline;
  input(N, nline);
  input(M, mline);
  output(N, M, nline, mline);
}

Error: 0

Fixed submission:

#include <cstdio>
#include <iostream>
#include <list>
using namespace std;
int main() {
  int time;
  list<int> line1, line2;
  cin >> time;
  int zikan, hun;
  for (int i = 0; i < time; ++i) {
    cin >> zikan >> hun;
    line1.push_back(zikan * 60 + hun);
  }
  cin >> time;
  for (int i = 0; i < time; ++i) {
    cin >> zikan >> hun;
    line2.push_back(zikan * 60 + hun);
  }
  while (line1.size() + line2.size() > 1) {
    if (line1.empty()) {
      printf("%d:%02d ", line2.front() / 60, line2.front() % 60);
      line2.pop_front();
    } else if (line2.empty()) {
      printf("%d:%02d ", line1.front() / 60, line1.front() % 60);
      line1.pop_front();
    } else if (line1.front() == line2.front()) {
      printf("%d:%02d ", line2.front() / 60, line2.front() % 60);
      line1.pop_front();
      line2.pop_front();
    } else if (line1.front() > line2.front()) {
      printf("%d:%02d ", line2.front() / 60, line2.front() % 60);
      line2.pop_front();
    } else {
      printf("%d:%02d ", line1.front() / 60, line1.front() % 60);
      line1.pop_front();
    }
  }
  if (line1.empty()) {
    printf("%d:%02d\\n", line2.front() / 60, line2.front() % 60);
    line2.pop_front();
  } else {
    printf("%d:%02d\\n", line1.front() / 60, line1.front() % 60);
    line1.pop_front();
  }
  return 0;
}