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

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <sstream>
#include <stack>

typedef long long ll;
using namespace std;

typedef pair<int, int> P;

int main() {

  int a;
  map<int, int> num;
  queue<int> que;
  while (~scanf("%d", &a)) {
    num[a]++;
  }

  int max_freq = -1;

  for (map<int, int>::iterator it = num.begin(); it != num.end(); it++) {
    if (it->second == max_freq) {
      que.push(it->first);
    } else if (it->second > max_freq) {
      while (!que.empty()) {
        que.pop();
      }
      max_freq = it->second;
      que.push(it->first);
    }
  }

  while (!que.empty()) {
    cout << que.front() << endl;
    que.pop();
  }
}

Error: -11

Fixed submission:

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <sstream>
#include <stack>

typedef long long ll;
using namespace std;

typedef pair<int, int> P;

int main() {

  int a;
  map<int, int> num;
  queue<int> que;
  while (~scanf("%d", &a)) {
    num[a]++;
  }

  int max_freq = -1;

  for (map<int, int>::iterator it; it != num.end(); it++) {
    if (it->second == max_freq) {
      que.push(it->first);
    } else if (it->second > max_freq) {
      while (!que.empty()) {
        que.pop();
      }
      max_freq = it->second;
      que.push(it->first);
    }
  }

  while (que.empty()) {
    cout << que.front() << endl;
    que.pop();
  }
}
Problem p00028 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

int main() {
  int ans[101] = {0}, i, n;
  int b = 0;
  while (cin >> n) {
    ans[n]++;
    if (ans[n] > b) {
      b = ans[n];
    }
  }

  for (i = 1; i <= 100; i++) {
    if (b == ans[i]) {
      cout << i << endl;
    }
  }

  return 0;
}

Error: 0

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int ans[100] = {0}, i, n;
  int b = 0;
  while (cin >> n) {
    ans[n]++;
    if (ans[n] > b) {
      b = ans[n];
    }
  }

  for (i = 1; i <= 100; i++) {
    if (b == ans[i]) {
      cout << i << endl;
    }
  }

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

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
// #define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).rbegin(), (c).rend())
#define CLR(a) memset((a), 0, sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

int main() {
  int a[100] = {0};
  int n;
  while (cin >> n)
    a[n - 1]++;

  int ma = 0;
  REP(i, 100) { ma = max(ma, a[i]); }
  REP(i, 100) {
    if (a[i] == ma)
      cout << (i + 1) << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
// #define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).rbegin(), (c).rend())
#define CLR(a) memset((a), 0, sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

int main() {
  int a[100] = {0};
  int n;
  while (cin >> n, n)
    a[n - 1]++;

  int ma = 0;
  REP(i, 100) { ma = max(ma, a[i]); }
  REP(i, 100) {
    if (a[i] == ma)
      cout << (i + 1) << endl;
  }
  return 0;
}
Problem p00028 (C++) — buggy submission, verdict: Runtime Error

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

int num[101];
int big = 0;
int input;
int main() {
  for (int i = 0; i <= 101; i++)
    num[i] = 0;
  while (scanf("%d", &input) != EOF)
    num[input]++;
  for (int i = 0; i <= 100; i++)
    big = max(big, num[i]);
  for (int i = 0; i <= 100; i++)
    if (num[i] == big)
      cout << i << endl;
}

Error: 0

Fixed submission:

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

int num[10];
int big = 0;
int input;
int main() {
  for (int i = 0; i < 10; i++)
    num[i] = 0;
  while (cin >> input)
    num[input]++;
  for (int i = 0; i < 10; i++)
    big = max(big, num[i]);
  for (int i = 0; i < 10; i++) {
    if (num[i] == big) {
      cout << i << endl;
    }
  }
}
Problem p00028 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {

  int n, max = 0, x[100] = {0};
  int x_max;

  while (scanf("%d", &n) != EOF) {
    x[n - 1]++;
  }

  for (int i = 0; i < 100; i++) {
    if (max < x[i]) {
      max = x[i];
      x_max = i;
    }
  }
  cout << x_max + 1 << endl;

  for (int i = x_max + 1; i < 100; i++) {
    if (x[x_max] == x[i]) {
      cout << i + 1 << endl;
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {

  int n, max = 0, x[100] = {0};
  int x_max;

  while (scanf("%d", &n)) {
    if (n == 0) {
      break;
    }
    x[n - 1]++;
  }

  for (int i = 0; i < 100; i++) {
    if (max < x[i]) {
      max = x[i];
      x_max = i;
    }
  }
  cout << x_max + 1 << endl;

  for (int i = x_max + 1; i < 100; i++) {
    if (x[x_max] == x[i]) {
      cout << i + 1 << endl;
    }
  }

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

#include <iostream>

using namespace std;

int main(void) {
  int n;
  int a[101] = {0};
  while (cin >> n) {
    a[n]++;
  }
  int max = 0;
  for (int i = 0; i < 101; i++) {
    if (a[i] > max) {
      max = a[i];
    }
  }
  for (int i = 0; i < 101; i++) {
    if (a[i] == max) {
      cout << i << endl;
    }
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>

using namespace std;

int main(void) {
  int n;
  int a[10] = {0};
  while (cin >> n) {
    a[n]++;
  }
  int max = 0;
  for (int i = 0; i < 10; i++) {
    if (a[i] > max) {
      max = a[i];
    }
  }
  for (int i = 0; i < 10; i++) {
    if (a[i] == max) {
      cout << i << endl;
    }
  }
  return 0;
}
Problem p00028 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

int main() {
  int n, max = 0;
  int in[100] = {0};
  while (cin >> n) {
    in[n]++;
    if (max < in[n])
      max = in[n];
  }
  for (int i = 0; i < 100; i++) {

    if (max == in[i])
      cout << i << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int n, max = 0;
  int in[100] = {0};
  while (cin >> n) {
    in[n]++;
    if (max < in[n])
      max = in[n];
  }
  for (int i = 1; i <= 100; i++) {

    if (max == in[i])
      cout << i << endl;
  }
  return 0;
}
Problem p00028 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>

using namespace std;

int main(void) {
  int in[100], data, ans[100], cnt, work = 0;
  int i, j; // ループカウンタ

  for (i = 0; i < 100; i++) {
    ans[i] = 0;
    in[i] = 0;
  }

  for (i = 0; i < 100; i++) {
    if (scanf("%d", &data) == EOF)
      break; // EOF=Ctrl+z
    in[data]++;
  }

  for (i = 1; i < 100; i++)
    if (in[work] < in[i])
      work = i;

  ans[0] = work;
  cnt = 0;
  for (i = 1; i < 100; i++) {
    if (in[work] == in[i] && i != work) {
      cnt++;
      ans[cnt] = i;
    }
  }

  for (i = 0; i <= cnt - 1; i++) {
    for (j = 1; j <= cnt; j++) {
      if (ans[i] > ans[j]) {
        work = ans[i];
        ans[i] = ans[j];
        ans[j] = work;
      }
    }
  }

  for (i = 0; i <= cnt; i++)
    printf("%d\\n", ans[i]);

  return 0;
}

Error: 0

Fixed submission:

#include <cstdio>

using namespace std;

int main(void) {
  int in[100], data[100], ans[100], cnt, work = 0;
  int i, j; // ループカウンタ

  for (i = 0; i < 100; i++)
    ans[i] = 0;
  for (i = 0; i < 100; i++)
    in[i] = 0;
  for (i = 0; i < 100; i++)
    data[i] = 0;

  for (i = 0; i < 100; i++) {
    if (scanf("%d", &data[i]) == EOF)
      break; // EOF=Ctrl+z
    in[data[i]]++;
  }

  for (i = 1; i < 100; i++)
    if (in[work] < in[i])
      work = i;

  ans[0] = work;
  cnt = 0;
  for (i = 1; i < 100; i++) {
    if (in[work] == in[i] && i != work) {
      cnt++;
      ans[cnt] = i;
    }
  }

  for (i = 0; i <= cnt - 1; i++) {
    for (j = 1; j <= cnt; j++) {
      if (ans[i] > ans[j]) {

        work = ans[i];
        ans[i] = ans[j];
        ans[j] = work;
      }
    }
  }

  for (i = 0; i <= cnt; i++)
    printf("%d\\n", ans[i]);

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

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

int main(int argc, char *argv[]) {
  int x;
  vector<int> freq;
  int X[120] = {0};
  while (cin >> x) {
    freq.push_back(x);
  }
  int maxf = 0;
  for (int i = 0; i < freq.size(); i++) {
    X[freq[i]]++;
    maxf = max(maxf, X[freq[i]]);
  }
  for (int j = 0; j < 100; j++) {
    if (X[j] == maxf) {
      cout << j << endl;
    }
  }

  return 0;
}

Error: 0

Fixed submission:

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

int main(int argc, char *argv[]) {
  int x;
  vector<int> freq;
  int X[100] = {0};
  while (cin >> x) {
    freq.push_back(x);
  }
  int maxf = 0;
  for (int i = 0; i < freq.size(); i++) {
    X[freq[i]]++;
    maxf = max(maxf, X[freq[i]]);
  }
  for (int j = 0; j < 100; j++) {
    if (X[j] == maxf) {
      cout << j << endl;
    }
  }

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

#include <iostream>

using namespace std;

int main() {
  int num, max;
  int list[100] = {0};

  max = 0;

  while (cin >> num) {
    list[num - 1]++;
  }
  for (int i = 0; i < 100; i++) {
    if (max < list[i]) {
      max = list[i];
    }
  }
  for (int j = 0; j < 100; j++) {
    if (max == list[j]) {
      cout << j + 1 << endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  int num;
  int list[100] = {0};

  while (cin >> num) {
    list[num]++;
  }

  sort(list, list + 100);

  cout << list[99] << endl;

  for (;;) {
    int i = 98;
    if (list[i] == list[i + 1]) {
      cout << list[i] << endl;
    } else {
      break;
    }
    i--;
  }

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

#include <iostream>
#include <string>
using namespace std;
int main() {
  int a[100];
  int b;
  b = 0;
  while (b < 100) {
    a[b] = 0;
    b = b + 1;
  }
  int n;
  while (cin >> n) {
    a[n] = a[n] + 1;
  }
  int c;
  c = 0;
  b = 0;
  while (b < 100) {
    if (a[b] > c) {
      c = a[b];
    }
    b = b + 1;
  }
  b = 0;
  while (b < 100) {
    if (c == a[b]) {
      cout << b << endl;
    }
    b = b + 1;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  int a[100];
  int b;
  b = 0;
  while (b < 100) {
    a[b] = 0;
  }
  int n;
  while (cin >> n) {
    a[n] = a[n] + 1;
  }
  int c;
  c = 0;
  b = 0;
  while (b < 100) {
    if (a[b] > c) {
      c = a[b];
    }
    b = b + 1;
  }
  b = 0;
  while (b < 100) {
    if (c == a[b]) {
      cout << b << endl;
    }
    b = b + 1;
  }
}
Problem p00028 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int a[100] = {0};
  int b[100][2] = {0};
  int B1, B2;
  int i = 0;
  for (int h = 0; h < 100; h++) {
    b[h][1] = h + 1;
  }
  while (cin >> a[i]) {
    b[a[i] - 1][0]++;
    i++;
  }
  for (int j = 0; j < i; j++) {
    for (int k = j + 1; k < i; k++) {
      if (b[k][0] > b[j][0]) {
        B1 = b[k][0];
        b[k][0] = b[j][0];
        b[j][0] = B1;
        B2 = b[k][1];
        b[k][1] = b[j][1];
        b[j][1] = B2;
      }
    }
  }
  int l = 0;
  while (b[l][0] == b[0][0]) {
    cout << b[l][1] << endl;
    l++;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int a[100] = {0};
  int b[100][2] = {0};
  int B1, B2;
  int i = 0;
  for (int h = 0; h < 100; h++) {
    b[h][1] = h + 1;
  }
  while (cin >> a[i]) {
    b[a[1] - 1][0]++;
    i++;
  }
  for (int j = 0; j < i; j++) {
    for (int k = i - 1; j <= j + 1; j++) {
      if (b[i][0] > b[j][0]) {
        B1 = b[i][0];
        b[i][0] = b[j][0];
        b[j][0] = B1;
        B2 = b[i][1];
        b[i][1] = b[j][1];
        b[j][1] = B2;
      }
    }
  }
  int l = 0;
  while (b[l][0] == b[0][0]) {
    cout << b[l][1] << endl;
  }
}
Problem p00028 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

typedef long long Int;
#define REP(i, n) for (int i = 0; i < n; ++i)
using namespace std;

Int aa[120];

int main() {
  int a = -1;
  while (cin >> a) {
    ++aa[a];
  }

  Int b = 0;

  REP(i, 120) { b = max(b, aa[i]); }

  REP(i, 120) {
    if (aa[i] == b)
      cout << i << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

typedef long long Int;
#define REP(i, n) for (int i = 0; i < n; ++i)
using namespace std;

Int aa[120];

int main() {
  int a = -1;
  while (cin >> a, a != -1) {
    ++aa[a];
  }

  Int b = 0;

  REP(i, 120) { b = max(b, aa[i]); }

  REP(i, 120) {
    if (aa[i] == b)
      cout << i << endl;
  }

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

#include <iostream>
#define NUM 10000

using namespace std;

int main(void) {
  int times[NUM];
  int i, n;
  int max;

  for (i = 0; i < NUM; i++) {
    times[i] = 0;
  }

  while (cin >> n) {
    times[n]++;
  }

  max = 0;
  for (i = 0; i < NUM; i++) {
    if (max < times[i]) {
      max = times[i];
    }
  }

  for (i = 0; i < NUM; i++) {
    if (max == times[i]) {
      cout << i << endl;
    }
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>

using namespace std;

int main(void) {
  int times[10];
  int i, n;
  int max;

  for (i = 0; i < 10; i++) {
    times[i] = 0;
  }

  while (cin >> n) {
    times[n]++;
  }

  max = 0;
  for (i = 0; i < 10; i++) {
    if (max < times[i]) {
      max = times[i];
    }
  }

  for (i = 0; i < 10; i++) {
    if (max == times[i]) {
      cout << i << endl;
    }
  }
  return 0;
}
Problem p00028 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

int main() {
  int n, max = 0;
  int in[100] = {0};
  while (cin >> n) {
    in[n]++;
    if (max < in[n])
      max = in[n];
  }
  for (int i = 0; i < 100; i++) {

    if (max == in[i])
      cout << i << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int n, max = 0;
  int in[10] = {0};
  while (cin >> n) {
    in[n]++;
    if (max < in[n])
      max = in[n];
  }
  for (int i = 0; i < 10; i++) {

    if (max == in[i])
      cout << i << endl;
  }
  return 0;
}
Problem p00028 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n, m;
  int a[100] = {0};
  while (cin >> n)
    a[n - 1]++;
  m = *max_element(a, a + 100);
  for (int i = 0; i < 100; i++) {
    if (m == a[i])
      cout << i + 1 << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

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

int main() {
  int n, m;
  int a[10] = {0};
  while (cin >> n)
    a[n - 1]++;
  m = *max_element(a, a + 10);
  for (int i = 0; i < 10; i++) {
    if (m == a[i])
      cout << i + 1 << endl;
  }
  return 0;
}
Problem p00028 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <complex>
#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 <typeinfo>
#include <utility>
#include <vector>

using namespace std;

int main(void) {
  int a;
  int maxa = 0;
  vector<int> ans;
  map<int, int> f;
  for (a = 0; a <= 100; a++) {
    f.insert(map<int, int>::value_type(a, 0));
  }
  while (~scanf("%d", &a)) {
    f[a]++;
  }
  for (a = 0; a <= 100; a++) {
    maxa = max(maxa, f[a]);
  }
  for (a = 0; a <= 100; a++) {
    if (maxa == f[a])
      ans.push_back(a);
  }
  sort(ans.begin(), ans.end());

  for (a = 0; a < ans.size(); a++) {
    cout << ans[a] << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <complex>
#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 <typeinfo>
#include <utility>
#include <vector>

using namespace std;

int main(void) {
  int a;
  int maxa = 0;
  vector<int> ans;
  map<int, int> f;
  for (a = 0; a <= 100; a++) {
    f.insert(map<int, int>::value_type(a, 0));
  }
  while (~scanf("%d", &a)) {
    f[a]++;
  }
  for (a = 0; a <= 100; a++) {
    maxa = max(maxa, f[a]);
  }
  for (a = 0; a <= 100; a++) {
    if (maxa == f[a])
      ans.push_back(a);
  }
  sort(ans.begin(), ans.end());

  while (!ans.empty()) {
    cout << ans[a] << endl;
  }
  return 0;
}
Problem p00028 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define INF 100000000
#define MAXN 110
typedef long long ll;

int a[MAXN];

int main(void) {
  int n;
  while (cin >> n)
    a[n]++;
  int ma = 0;
  for (int i = 0; i <= 100; i++)
    ma = max(ma, a[i]);
  vector<int> ans;
  for (int i = 0; i <= 100; i++) {
    if (a[i] == ma)
      ans.push_back(i);
  }
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

Error: MLE

Fixed submission:

#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define INF 100000000
#define MAXN 110
typedef long long ll;

int a[MAXN];

int main(void) {
  int cur, b;
  while (cin >> b) {
    a[cur++] = b;
  }
  map<int, int> m;
  for (int i = 0; i <= cur; i++) {
    m[a[i]]++;
  }
  // maxを見つける
  int ma = 0;
  for (int i = 0; i <= m.size(); i++) {
    ma = max(m[i], ma);
  }
  // maxの数を探す
  for (int i = 0; i <= m.size(); i++) {
    if (m[i] == ma) {
      cout << i << endl;
    }
  }
  return 0;
}
Problem p00028 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string>
using namespace std;
int main() {
  int a[100] = {0}, b, c = 1;
  while (cin >> b) {
    a[b - 1]++;
    if (a[b - 1] > c)
      c = a[b - 1];
  }
  for (int i = 0; i < 100; i++) {
    if (a[i] == c)
      cout << i + 1 << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  int a[100], b[100], c;
  for (int i = 0; i < 100; i++) {
    a[i] = 0;
    b[i] = 0;
  }
  while (cin >> c) {
    int i = 0;
    while (true) {
      if (a[i] == c || a[i] == 0) {
        b[i]++;
        break;
      }
      i++;
    }
  }
  for (int i = 0; i < 99; i++) {
    for (int j = 99; j > i; j--) {
      if (a[j] > a[j - 1]) {
        int t = a[j];
        a[j] = a[j - 1];
        a[j - 1] = t;
        t = b[j];
        b[j] = b[j - 1];
        b[j - 1] = t;
      }
    }
  }
  int k = 0;
  while (true) {
    if (b[k] != b[0])
      break;
  }
  for (int i = 0; i < k - 1; i++) {
    for (int j = k - 1; j > i; j--) {
      if (a[j] < a[j - 1]) {
        int t = a[j];
        a[j] = a[j - 1];
        a[j - 1] = t;
      }
    }
  }
  for (int i = 0; i < k; i++)
    cout << a[i] << endl;
  return 0;
}
Problem p00028 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  int n;
  int d[102] = {0};
  int max = 0;
  while (cin >> n) {
    d[n]++;
    if (max < d[n]) {
      max = d[n];
    }
  }
  if (max != 0) {
    for (int i = 0; i < 101; i++) {
      if (d[i] == max) {
        cout << i << endl;
      }
    }
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n;
  int d[10] = {0};
  int max = 0;
  while (cin >> n) {
    d[n]++;
    if (max < d[n]) {
      max = d[n];
    }
  }
  if (max != 0) {
    for (int i = 0; i < 10; i++) {
      if (d[i] == max) {
        cout << i << endl;
      }
    }
  }
  return 0;
}
Problem p00028 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
using namespace std;

int main() {
  int data[101] = {0};
  int n, max = 0;

  while (scanf("%d", &n) != EOF) {
    data[n]++;
  }

  for (int i = 0; i < 101; i++) {
    if (max < data[i]) {
      max = data[i];
    }
  }

  for (int i = 0; i < 101; i++) {
    if (max == data[i]) {
      printf("%d\\n", i);
    }
  }

  return (0);
}

Error: TLE

Fixed submission:

#include <cstdio>
using namespace std;

int main() {
  int data[101] = {0};
  int n, max;

  while (scanf("%d", &n)) {
    data[n]++;
  }

  for (int i = 0; i < 101; i++) {
    if (max < data[i]) {
      max = data[i];
    }
  }

  for (int i = 0; i < 101; i++) {
    if (max == data[i]) {
      printf("%d", i);
    }
  }

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

#include <iostream>
using namespace std;
int main() {
  int n[101];
  int i;
  for (i = 0; i < 101; i++) {
    n[i] = 0;
  }
  for (i = 1; i != 0; i) {
    i = 0;
    cin >> i;
    n[i]++;
  }
  int max = 1;
  for (i = 2; i < 101; i++) {

    if (n[max] <= n[i]) {
      max = i;
    }
  }
  for (i = 1; i < 101; i++) {
    if (n[i] == n[max]) {
      cout << i << endl;
    }
  }
  return 0;
}


Error: 0

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n[100];
  for (int i = 0; i <= 100; i++) {
    n[i] = 0;
  }
  for (int i = 1; i != 0; i) {
    i = 0;
    cin >> i;
    n[i]++;
  }
  int max = 1;
  for (int i = 2; i <= 100; i++) {
    if (n[max] < n[i]) {
      max = i;
    }
  }
  for (int i = 0; i <= 100; i++) {
    if (n[i] == n[max]) {
      cout << i << endl;
    }
  }
}