prithivMLmods/Coder-Stat huggingface dataset:
Problem p02772 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <iomanip>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> vec{n};
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  bool H = 1;
  for (int i = 0; i < n; i++) {
    if (vec.at(i) % 2 == 0) {
      if (vec.at(i) % 3 == 0 || vec.at(i) % 5 == 0) {
        H = 1;
      } else {
        H = 0;
        break;
      }
    }
  }
  if (H) {
    cout << "APPROVED" << endl;
  } else {
    cout << "DENIED" << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
#include <iomanip>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  bool H = 1;
  for (int i = 0; i < n; i++) {
    if (vec.at(i) % 2 == 0) {
      if (vec.at(i) % 3 == 0 || vec.at(i) % 5 == 0) {
        H = 1;
      } else {
        H = 0;
        break;
      }
    }
  }
  if (H) {
    cout << "APPROVED" << endl;
  } else {
    cout << "DENIED" << endl;
  }
}
Problem p02772 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
#include <stdlib.h>

#include <fstream>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <stdint.h>
#include <string.h>

// #define _USE_MATH_DEFINES
// #include <math.h>

#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <algorithm>
#include <bitset>
#include <chrono>
#include <functional>
#include <random>
#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 1000000007; // 10000000000000007ll;

const double eps = 1e-8;

const i64 MAXN = 52;
const i64 MAXM = 20004;

i64 n;
i64 a[MAXN];

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.precision(15);
  cout.setf(ios::fixed);

  cin >> n;
  for (i64 i = 0; i < n; i++) {
    cin >> a[i];
  }

  for (i64 i = 0; i < n; i++) {
    if (a[i] % 2 == 0) {
      if (a[i] % 3 != 0 && a[i] % 5 != 0) {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }

  cout << "APPROVED" << endl;

  return 0;
}

Fixed submission:
#include <stdio.h>
#include <stdlib.h>

#include <fstream>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <stdint.h>
#include <string.h>

// #define _USE_MATH_DEFINES
// #include <math.h>

#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <algorithm>
#include <bitset>
#include <chrono>
#include <functional>
#include <random>
#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 1000000007; // 10000000000000007ll;

const double eps = 1e-8;

const i64 MAXN = 52;
const i64 MAXM = 20004;

i64 n;
i64 a[MAXN];

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.precision(15);
  cout.setf(ios::fixed);

  cin >> n;
  for (i64 i = 0; i < n; i++) {
    i64 t;
    cin >> t;
    if (t % 2 == 0) {
      if (t % 3 != 0 && t % 5 != 0) {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }

  cout << "APPROVED" << endl;

  return 0;
}
Problem p02772 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

#define all(vec) vec.begin(), vec.end()
#define rall(vec) vec.rbegin(), vec.rend()
#define sz(r) r.size()
#define rem1(v, i) (v.erase(v.begin() + i))
#define rem2(v, i, j) (v.erase(v.begin() + i, v.begin() + j + 1))
#define rev(v, i, j) (reverse(v.begin() + i, v.begin() + j + 1))
#define digits(i) (int)((log(i) / log(10)) + 1)
#define dround(num)                                                            \
  (int)floor(num + 0.5) // Rounds num to int (int)num+(<.5 to 0, > .5 to 1)
#define first_bit_index(num) __builtin_ctz(num) // count trailing zeros
#define last_bit_index(num) __builtin_clz(num)  // count leading zeros
#define UNDEFINED_BIT 32
#define test_bit(num, bit) ((num & 1 << bit) != 0)
#define num_bits(num) __builtin_popcount(num)
#define pb push_back
#define pf push_front
#define ins insert

#define inf INT_MAX
#define mn_inf INT_MIN
#define endl '\n'
using namespace std;
#define init                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(nullptr);
typedef long long ll;

int main() {
  init
#ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    if (x % 2 == 0 && (x % 3 != 0 && x % 5 != 0)) {
      cout << "DENIED"
           << "\n";
      return 0;
    }
  }
  cout << "APPROVED"
       << "\n";
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

#define all(vec) vec.begin(), vec.end()
#define rall(vec) vec.rbegin(), vec.rend()
#define sz(r) r.size()
#define rem1(v, i) (v.erase(v.begin() + i))
#define rem2(v, i, j) (v.erase(v.begin() + i, v.begin() + j + 1))
#define rev(v, i, j) (reverse(v.begin() + i, v.begin() + j + 1))
#define digits(i) (int)((log(i) / log(10)) + 1)
#define dround(num)                                                            \
  (int)floor(num + 0.5) // Rounds num to int (int)num+(<.5 to 0, > .5 to 1)
#define first_bit_index(num) __builtin_ctz(num) // count trailing zeros
#define last_bit_index(num) __builtin_clz(num)  // count leading zeros
#define UNDEFINED_BIT 32
#define test_bit(num, bit) ((num & 1 << bit) != 0)
#define num_bits(num) __builtin_popcount(num)
#define pb push_back
#define pf push_front
#define ins insert

#define inf INT_MAX
#define mn_inf INT_MIN
#define endl '\n'
using namespace std;
#define init                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(nullptr);
typedef long long ll;

int main() {
  init
      // #ifndef ONLINE_JUDGE
      //     freopen("input.txt", "r", stdin);
      // //    freopen("output.txt", "w", stdout);
      // #endif
      int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    if (x % 2 == 0 && (x % 3 != 0 && x % 5 != 0)) {
      cout << "DENIED"
           << "\n";
      return 0;
    }
  }
  cout << "APPROVED"
       << "\n";
  return 0;
}
Problem p02772 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[n], i, flag = 0;
  cin >> n;
  for (i = 0; i < n; i++)
    cin >> a[i];
  for (i = 0; i < n; i++) {
    if (a[i] % 2 == 0) {
      if (a[i] % 3 != 0 && a[i] % 5 != 0) {
        flag = 1;
        break;
      }
    }
  }
  if (flag == 0)
    cout << "APPROVED";
  else
    cout << "DENIED";
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a[n], i, flag = 0;
  cin >> n;
  for (i = 0; i < n; i++)
    cin >> a[i];
  for (i = 0; i < n; i++) {
    if (a[i] % 2 == 0) {
      if (a[i] % 3 != 0 && a[i] % 5 != 0) {
        flag = 1;
        break;
      }
    }
  }
  if (flag == 0)
    cout << "APPROVED";
  else
    cout << "DENIED";
  return 0;
}
Problem p02772 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define itn int
#define gI gi

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<int, PII> PIII;

inline int gi() {
  int f = 1, x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-')
      f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = x * 10 + c - '0', c = getchar();
  return f * x;
}

inline LL gl() {
  LL f = 1, x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-')
      f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = x * 10 + c - '0', c = getchar();
  return f * x;
}

int n, m, x, y, z, a[5];

int main() {
  // freopen(".in", "r", stdin);
  // freopen(".out", "w", stdout);
  cin >> n;
  for (int i = 1; i <= n; i += 1)
    cin >> a[i];
  bool fl = true;
  for (int i = 1; i <= n; i += 1)
    if (a[i] % 2 == 0) {
      if (a[i] % 3 != 0 && a[i] % 5 != 0)
        fl = false;
    }
  if (fl)
    puts("APPROVED");
  else
    puts("DENIED");
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define itn int
#define gI gi

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<int, PII> PIII;

inline int gi() {
  int f = 1, x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-')
      f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = x * 10 + c - '0', c = getchar();
  return f * x;
}

inline LL gl() {
  LL f = 1, x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-')
      f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = x * 10 + c - '0', c = getchar();
  return f * x;
}

int n, m, x, y, z, a[303];

int main() {
  // freopen(".in", "r", stdin);
  // freopen(".out", "w", stdout);
  cin >> n;
  for (int i = 1; i <= n; i += 1)
    cin >> a[i];
  bool fl = true;
  for (int i = 1; i <= n; i += 1)
    if (a[i] % 2 == 0) {
      if (a[i] % 3 != 0 && a[i] % 5 != 0)
        fl = false;
    }
  if (fl)
    puts("APPROVED");
  else
    puts("DENIED");
  return 0;
}
Problem p02772 (C++)

Buggy submission (status: Runtime Error):
/* ***********************************************
Author        :taciturnity
Created Time  :2020/2/3 22:02:32
File Name     :main.cpp
************************************************ */
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define INF 1e9
#define bug puts("--------------")
const ll N = 2e5 + 10;
const ll mod = 1e9 + 7;
const int Max_n = 1e6 + 10;
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int a;
    cin >> a;
    if ((a & 1))
      continue;
    if (a % 3 == 0 || a % 5 == 0) {
    } else
      return puts("DENIED");
  }
  puts("APPROVED");
}

Fixed submission:
/* ***********************************************
Author        :taciturnity
Created Time  :2020/2/3 22:02:32
File Name     :main.cpp
************************************************ */
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define INF 1e9
#define bug puts("--------------")
const ll N = 2e5 + 10;
const ll mod = 1e9 + 7;
const int Max_n = 1e6 + 10;
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int a;
    cin >> a;
    if ((a & 1))
      continue;
    if (a % 3 == 0 || a % 5 == 0) {
    } else
      return puts("DENIED"), 0;
  }
  puts("APPROVED");
}
Problem p02772 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {

  int N;
  cin >> N;

  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  for (int i = 0; i < N; i++) {
    if (A.at(i) % 2 != 0)
      A.at(i) = 1;
    else {
      if (A.at(i) % 3 == 0 || A.at(i) % 5 == 0)
        A.at(i) = 1;
      else
        A.at(i) = 0;
    }
  }

  int ans = 1;

  for (int i = 0; i < N; i++) {
    ans *= A.at(1);
  }

  if (ans == 1)
    cout << "APPROVED" << endl;
  else
    cout << "DENIED" << endl;
}

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

int main() {

  int N;
  cin >> N;

  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  for (int i = 0; i < N; i++) {
    if (A.at(i) % 2 != 0)
      A.at(i) = 1;
    else {
      if (A.at(i) % 3 == 0 || A.at(i) % 5 == 0)
        A.at(i) = 1;
      else
        A.at(i) = 0;
    }
  }

  int ans = 1;

  for (int i = 0; i < N; i++) {
    //    cout << "A.at(" << i << ")" << A.at(i) << ", ";
    ans *= A.at(i);
    //    cout << "ans(" << i << ")" << ans << ", ";
  }

  if (ans == 1)
    cout << "APPROVED" << endl;
  else
    cout << "DENIED" << endl;
}
Problem p02772 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define R(i, n) for (int i = 0; i < n; i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define P(a) printf("%d", a)
#define INF 1000000000
using namespace std;
using ll = long long;
using IR = pair<int, int>;

int N, A[100];

int main() {
  S(N);
  R(i, N) {
    S(A + i);
    if (A[i] % 2 == 0) {
      if (A[i] % 3 != 0 && A[i] % 5 != 0) {
        printf("DENIED");
        return 0;
      }
    }
  }
  printf("APPROVED");
}


Fixed submission:
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define R(i, n) for (int i = 0; i < n; i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define P(a) printf("%d", a)
#define INF 1000000000
using namespace std;
using ll = long long;
using IR = pair<int, int>;

int N, A[100];

int main() {
  S(N);
  R(i, N) {
    S(A[i]);
    if (A[i] % 2 == 0) {
      if (A[i] % 3 != 0 && A[i] % 5 != 0) {
        printf("DENIED");
        return 0;
      }
    }
  }
  printf("APPROVED");
}
Problem p02773 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int n, k, mx, i;
string b[100005];
string s[100005];
map<string, int> m, f;
int main() {
  cin >> n;
  for (k = 1; k <= n; k++) {
    cin >> s[k];
    m[s[k]]++;
    mx = max(m[s[k]], mx);
  }

  for (k = 1; k <= n; k++) {
    if (m[s[k]] == mx && f[s[k]] == 0) {
      i++;
      f[s[k]] = 1;
      b[i] = s[k];
    }
  }
  sort(b + 1, b + i + 1);
  for (k = 1; k <= i; k++) {
    if (k != i)
      cout << b[k] << endl;
    else
      cout << b[k];
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int n, k, mx, i;
string b[200005];
string s[200005];
map<string, int> m, f;
int main() {
  cin >> n;
  for (k = 1; k <= n; k++) {
    cin >> s[k];
    m[s[k]]++;
    mx = max(m[s[k]], mx);
  }

  for (k = 1; k <= n; k++) {
    if (m[s[k]] == mx && f[s[k]] == 0) {
      i++;
      f[s[k]] = 1;
      b[i] = s[k];
    }
  }
  sort(b + 1, b + i + 1);
  for (k = 1; k <= i; k++) {
    if (k != i)
      cout << b[k] << endl;
    else
      cout << b[k];
  }
}
Problem p02773 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main(void) {
  int N;
  vector<string> s(20000);
  unordered_map<string, int> mp;
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> s[i];
  }
  mp[s[0]] = 1;
  for (int i = 1; i < N; i++) {
    if (mp.find(s[i]) == mp.end()) {
      mp[s[i]] = 1;
    } else {
      mp[mp.find(s[i])->first]++;
    }
  }
  int max = 1;
  vector<string> maxs;
  for (auto it = mp.begin(); it != mp.end(); it++) {
    if (it->second > max) {
      max = it->second;
    }
  }
  for (auto it = mp.begin(); it != mp.end(); it++) {
    if (it->second == max) {
      maxs.push_back(it->first);
    }
  }
  sort(maxs.begin(), maxs.end());
  for (int k = 0; k < maxs.size(); k++) {
    cout << maxs[k] << endl;
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main(void) {
  int N;
  vector<string> s(200000);
  unordered_map<string, int> mp;
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> s[i];
  }
  mp[s[0]] = 1;
  for (int i = 1; i < N; i++) {
    if (mp.find(s[i]) == mp.end()) {
      mp[s[i]] = 1;
    } else {
      mp[mp.find(s[i])->first]++;
    }
  }
  int max = 1;
  vector<string> maxs;
  for (auto it = mp.begin(); it != mp.end(); it++) {
    if (it->second > max) {
      max = it->second;
    }
  }
  for (auto it = mp.begin(); it != mp.end(); it++) {
    if (it->second == max) {
      maxs.push_back(it->first);
    }
  }
  sort(maxs.begin(), maxs.end());
  for (int k = 0; k < maxs.size(); k++) {
    cout << maxs[k] << endl;
  }
  return 0;
}
Problem p02773 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstring>
#include <iostream>
#include <stdio.h>
using namespace std;
string vote[200000], temp;
int cot[200000];
int sol[200000];
string ans[200000];
int main() {
  int n, i, j, k, ma;
  cin >> n;
  for (i = 0; i < n; i++)
    cot[i] = 1;
  for (i = 0; i < n; i++) {
    cin >> vote[i];
  }
  sort(vote, vote + i);
  j = 0;
  for (i = 0; i < n; i++) {
    while (vote[i + 1] == vote[i]) {
      cot[j]++;
      i++;
    }
    if (cot[j] > 1)
      sol[j] = i - 1;
    else
      sol[j] = i;
    j++;
  }
  ma = cot[0];
  for (i = 0; i < n; i++) {
    ma = max(cot[i], ma);
  }
  j = 0;
  for (i = 0; i < n; i++) {
    if (cot[i] == ma) {
      ans[j] = vote[sol[i]];
      j++;
    }
  }
  sort(ans, ans + j);
  for (i = 0; i < j; i++)
    cout << ans[i] << endl;
}


Fixed submission:
#include <algorithm>
#include <cstring>
#include <iostream>
#include <stdio.h>
using namespace std;
string vote[2000000], temp;
int cot[2000000];
int sol[2000000];
string ans[2000000];
int main() {
  int n, i, j, k, ma;
  cin >> n;
  for (i = 0; i < n; i++)
    cot[i] = 1;
  for (i = 0; i < n; i++) {
    cin >> vote[i];
  }
  sort(vote, vote + i);
  j = 0;
  for (i = 0; i < n; i++) {
    while (vote[i + 1] == vote[i]) {
      cot[j]++;
      i++;
    }
    if (cot[j] > 1)
      sol[j] = i - 1;
    else
      sol[j] = i;
    j++;
  }
  ma = cot[0];
  for (i = 0; i < n; i++) {
    ma = max(cot[i], ma);
  }
  j = 0;
  for (i = 0; i < n; i++) {
    if (cot[i] == ma) {
      ans[j] = vote[sol[i]];
      j++;
    }
  }
  sort(ans, ans + j);
  for (i = 0; i < j; i++)
    cout << ans[i] << endl;
}
Problem p02773 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdint>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

ll ans, mx, sum, mn = 1e8, cnt;

string c[1000];
ll idx;
int main() {
  ll n;
  cin >> n;
  map<string, ll> mp;
  for (ll i = 0; i < n; i++) {
    string s;
    cin >> s;
    mp[s]++;
  }
  for (auto i : mp) {
    mx = max(mx, i.second);
  }
  for (auto i : mp) {
    if (i.second == mx)
      c[idx++] = i.first;
  }
  sort(c, c + idx);
  for (ll i = 0; i < idx; i++) {
    cout << c[i] << endl;
  }
}

Fixed submission:
#include <algorithm>
#include <cstdint>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

ll ans, mx, sum, mn = 1e8, cnt;

string c[200001];
ll idx;
int main() {
  ll n;
  cin >> n;
  map<string, ll> mp;
  for (ll i = 0; i < n; i++) {
    string s;
    cin >> s;
    mp[s]++;
  }
  for (auto i : mp) {
    mx = max(mx, i.second);
  }
  for (auto i : mp) {
    if (i.second == mx)
      c[idx++] = i.first;
  }
  sort(c, c + idx);
  for (ll i = 0; i < idx; i++) {
    cout << c[i] << endl;
  }
}
Problem p02773 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for (auto &&a : s)
    cin >> a;
  sort(s.begin(), s.end());
  // for(auto&& a : s)cout << a << endl;
  int count = 0, max = 0, j = 0;
  int memo[200000][2];
  for (int i = 0; i < n; i++) {
    count++;
    if (s[i] != s[i + 1]) {
      memo[j][0] = i;
      memo[j][1] = count;
      j++;
      if (count > max) {
        max = count;
      }
      count = 0;
    }
  }
  for (int i = 0; i < j; i++) {
    if (memo[i][1] == max) {
      cout << s[memo[i][0]] << endl;
    }
  }
}

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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for (auto &&a : s)
    cin >> a;
  sort(s.begin(), s.end());
  // for(auto&& a : s)cout << a << endl;
  int count = 0, max = 0, j = 0;
  int memo[200000][2];
  for (int i = 0; i < n; i++) {
    count++;
    if (i + 1 < n) {
      if (s[i] != s[i + 1]) {
        memo[j][0] = i;
        memo[j][1] = count;
        j++;
        if (count > max) {
          max = count;
        }
        count = 0;
      }
    } else {
      memo[j][0] = i;
      memo[j][1] = count;
      j++;
      if (count > max) {
        max = count;
      }
      count = 0;
    }
  }
  for (int i = 0; i < j; i++) {
    if (memo[i][1] == max) {
      cout << s[memo[i][0]] << endl;
    }
  }
}
Problem p02773 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define fs first
#define se second
#define M 1000000007

vector<ll> tree(100000, LLONG_MAX);
void build(ll s, ll e, ll p, vector<ll> &arr) {
  if (s == e) {
    tree[p] = arr[s];
    return;
  }
  ll mid = (s + e) / 2;
  build(s, mid, 2 * p + 1, arr);
  build(mid + 1, e, 2 * p + 2, arr);
  tree[p] = min(tree[2 * p + 1], tree[2 * p + 2]);
}

ll query(ll s, ll e, ll l, ll u, ll p) {
  if (e < l || s > u)
    return LLONG_MAX;
  else if (s <= l && u <= e && l <= u)
    return tree[p];
  ll mid = (l + u) / 2;
  ll left = query(s, e, l, mid, 2 * p + 1);
  ll right = query(s, e, mid + 1, u, 2 * p + 2);
  return min(left, right);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;
  unordered_map<string, ll> um;
  ll m = 0;
  for (ll i = 0; i < n; i++) {
    string s;
    cin >> s;
    um[s]++;
    m = max(m, um[s]);
  }
  vector<pair<ll, string>> h;
  for (auto i : um) {
    string st = i.fs;
    ll num = i.se;
    h.pb({num, st});
  }
  sort(h.begin(), h.end());
  for (ll i = 0; i < n; i++) {
    if (h[i].fs == m)
      cout << h[i].se << endl;
  }
}

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

#define ll long long
#define pb push_back
#define fs first
#define se second
#define M 1000000007

vector<ll> tree(100000, LLONG_MAX);
void build(ll s, ll e, ll p, vector<ll> &arr) {
  if (s == e) {
    tree[p] = arr[s];
    return;
  }
  ll mid = (s + e) / 2;
  build(s, mid, 2 * p + 1, arr);
  build(mid + 1, e, 2 * p + 2, arr);
  tree[p] = min(tree[2 * p + 1], tree[2 * p + 2]);
}

ll query(ll s, ll e, ll l, ll u, ll p) {
  if (e < l || s > u)
    return LLONG_MAX;
  else if (s <= l && u <= e && l <= u)
    return tree[p];
  ll mid = (l + u) / 2;
  ll left = query(s, e, l, mid, 2 * p + 1);
  ll right = query(s, e, mid + 1, u, 2 * p + 2);
  return min(left, right);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;
  unordered_map<string, ll> um;
  ll m = 0;
  for (ll i = 0; i < n; i++) {
    string s;
    cin >> s;
    um[s]++;
    m = max(m, um[s]);
  }
  vector<pair<ll, string>> h;
  for (auto i : um) {
    string st = i.fs;
    ll num = i.se;
    h.pb({num, st});
  }
  sort(h.begin(), h.end());
  for (ll i = 0; i < h.size(); i++) {
    if (h[i].fs == m)
      cout << h[i].se << endl;
  }
}
Problem p02773 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define srep(i, n, m) for (int i = n; i < m; i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
int n, m = -1, a = 0, aa[110000], cnt = 0;
pair<int, string> p[220000];
string s, ss[220000];
char c;
signed main() {
  cin >> n;
  rep(i, n) { cin >> ss[i]; }
  sort(ss, ss + n);
  rep(i, n) {
    if (p[m].second != ss[i]) {
      p[m].first = cnt;
      a = max(a, cnt);
      m++;
      p[m].second = ss[i];
      cnt = 1;
    } else {
      cnt++;
    }
  }
  p[m].first = cnt;
  a = max(a, cnt);
  rep(i, m + 1) {
    if (p[i].first == a) {
      cout << p[i].second << endl;
    }
  }
}

Fixed submission:
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define srep(i, n, m) for (int i = n; i < m; i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
int n, m = 0, a = 0, aa[110000], cnt = 0;
pair<int, string> p[220000];
string s, ss[220000];
char c;
signed main() {
  cin >> n;
  rep(i, n) { cin >> ss[i]; }
  sort(ss, ss + n);
  rep(i, n) {
    if (p[m].second != ss[i]) {
      p[m].first = cnt;
      a = max(a, cnt);
      m++;
      p[m].second = ss[i];
      cnt = 1;
    } else {
      cnt++;
    }
  }
  p[m].first = cnt;
  a = max(a, cnt);
  rep(i, m + 1) {
    if (p[i].first == a) {
      cout << p[i].second << endl;
    }
  }
}
Problem p02773 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
// #define MOD 998244353
#define INF 1145141919810893364
// #define INF 810114514
// #define PI 3.141592653589
typedef pair<int, int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define OREP(i, n) for (int i = 1; i <= (n); ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define GOODBYE                                                                \
  do {                                                                         \
    cout << "0" << endl;                                                       \
    return 0;                                                                  \
  } while (false)
#define MM << " " <<
#define Endl endl

signed main(void) {
  int N;
  string S[114514];
  cin >> N;
  REP(i, N) { cin >> S[i]; }
  sort(S, S + N);
  map<string, int> M;
  REP(i, N) { M[S[i]]++; }
  int mx = 0;
  REP(i, N) { mx = max(mx, M[S[i]]); }
  REP(i, N) {
    if (M[S[i]] == mx) {
      M[S[i]] = 0;
      cout << S[i] << endl;
    }
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
// #define MOD 998244353
#define INF 1145141919810893364
// #define INF 810114514
// #define PI 3.141592653589
typedef pair<int, int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define OREP(i, n) for (int i = 1; i <= (n); ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define GOODBYE                                                                \
  do {                                                                         \
    cout << "0" << endl;                                                       \
    return 0;                                                                  \
  } while (false)
#define MM << " " <<
#define Endl endl

signed main(void) {
  int N;
  string S[214514];
  cin >> N;
  REP(i, N) { cin >> S[i]; }
  sort(S, S + N);
  map<string, int> M;
  REP(i, N) { M[S[i]]++; }
  int mx = 0;
  REP(i, N) { mx = max(mx, M[S[i]]); }
  REP(i, N) {
    if (M[S[i]] == mx) {
      M[S[i]] = 0;
      cout << S[i] << endl;
    }
  }
  return 0;
}
Problem p02773 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
int n;
string s[N];
map<string, int> mp;
int main() {
  cin >> n;
  int ma = 0;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    mp[s[i]]++;
    ma = max(ma, mp[s[i]]);
  }
  for (auto it = mp.begin(); it != mp.end(); it++) {
    if (it->second == ma)
      cout << it->first << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
int n;
string s[N];
map<string, int> mp;
int main() {
  cin >> n;
  int ma = 0;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    mp[s[i]]++;
    ma = max(ma, mp[s[i]]);
  }
  for (auto it = mp.begin(); it != mp.end(); it++) {
    if (it->second == ma)
      cout << it->first << endl;
  }
}
Problem p02773 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  x = 0;
  char c = getchar();
  while (!isdigit(c))
    c = getchar();
  while (isdigit(c))
    x = x * 10 + c - '0', c = getchar();
}
map<string, int> mp;
set<pair<int, string>> s;
string tp[1005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i)
    cin >> tp[i], ++mp[tp[i]];
  for (int i = 1; i <= n; ++i)
    s.insert(make_pair(-mp[tp[i]], tp[i]));
  int num = (*s.begin()).first;
  for (auto it = s.begin(); it != s.end(); ++it) {
    if ((*it).first != num)
      break;
    cout << (*it).second << endl;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  x = 0;
  char c = getchar();
  while (!isdigit(c))
    c = getchar();
  while (isdigit(c))
    x = x * 10 + c - '0', c = getchar();
}
map<string, int> mp;
set<pair<int, string>> s;
string tp[200005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i)
    cin >> tp[i], ++mp[tp[i]];
  for (int i = 1; i <= n; ++i)
    s.insert(make_pair(-mp[tp[i]], tp[i]));
  int num = (*s.begin()).first;
  for (auto it = s.begin(); it != s.end(); ++it) {
    if ((*it).first != num)
      break;
    cout << (*it).second << endl;
  }
  return 0;
}
Problem p02773 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#define INF 0x3f3f3f3f;

using namespace std;

string s[200005];
bool cmp(string a, string b) { return a.compare(b) < 1; }

int main() {
  int n, i;
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    cin >> s[i];
  sort(s, s + n, cmp);
  int m = 1, cnt = 1;
  for (i = 1; i < n; i++) {
    if (s[i].compare(s[i - 1]) == 0)
      cnt++;
    else
      cnt = 1;
    m = max(cnt, m);
  }
  cnt = 1;
  if (m == 1)
    cout << s[0] << endl;
  for (i = 1; i < n; i++) {
    if (s[i].compare(s[i - 1]) == 0)
      cnt++;
    else
      cnt = 1;
    if (cnt == m)
      cout << s[i] << endl;
  }
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#define INF 0x3f3f3f3f;

using namespace std;

string s[200005];

bool cmp(string a, string b) { return a.compare(b) < 0; }

int main() {
  int n, i;
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    cin >> s[i];
  sort(s, s + n, cmp);
  int m = 1, cnt = 1;
  for (i = 1; i < n; i++) {
    if (s[i].compare(s[i - 1]) == 0)
      cnt++;
    else
      cnt = 1;
    m = max(cnt, m);
  }
  cnt = 1;
  if (m == 1)
    cout << s[0] << endl;
  for (i = 1; i < n; i++) {
    if (s[i].compare(s[i - 1]) == 0)
      cnt++;
    else
      cnt = 1;
    if (cnt == m)
      cout << s[i] << endl;
  }
}
Problem p02773 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

inline long long read() {
  long long s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return s * w;
}
const int MAX_N = 1e5 + 10;
map<string, int> pq;
struct xcj {
  string nam;
  int num;
} q[MAX_N];
int n, cnt;
bool cmp(xcj x, xcj y) {
  if (x.num != y.num) {
    return x.num > y.num;
  }
  return x.nam < y.nam;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    if (pq[s] == 0) {
      cnt++;
      q[cnt].nam = s;
    }
    pq[s]++;
  }
  for (int i = 1; i <= cnt; i++) {
    q[i].num = pq[q[i].nam];
  }
  sort(q + 1, q + 1 + cnt, cmp);
  int Max = q[1].num;
  for (int i = 1; i <= cnt; i++) {
    if (q[i].num < Max) {
      break;
    }
    cout << q[i].nam << endl;
  }

  return 0;
}


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

inline long long read() {
  long long s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return s * w;
}
const int MAX_N = 1e6;
map<string, int> pq;
struct xcj {
  string nam;
  int num;
} q[MAX_N];
int n, cnt;
bool cmp(xcj x, xcj y) {
  if (x.num != y.num) {
    return x.num > y.num;
  }
  return x.nam < y.nam;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    if (pq[s] == 0) {
      cnt++;
      q[cnt].nam = s;
    }
    pq[s]++;
  }
  for (int i = 1; i <= cnt; i++) {
    q[i].num = pq[q[i].nam];
  }
  sort(q + 1, q + 1 + cnt, cmp);
  int Max = q[1].num;
  for (int i = 1; i <= cnt; i++) {
    if (q[i].num < Max) {
      break;
    }
    cout << q[i].nam << endl;
  }

  return 0;
}
Problem p02773 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main(void) {
  int N;
  scanf("%d", &N);
  string word;
  vector<string> v1;
  vector<string> v2;
  vector<int> c1;

  for (int i = 0; i < N; i++) {
    cin >> word;
    v1.push_back(word);
  }

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

  int count = 0;
  int maxlen = 0;

  for (int i = 0; i < N; i++) {
    if (v1[i] != v1[i + 1]) {
      if (maxlen < count)
        maxlen = count;
      v2.push_back(v1[i]);
      c1.push_back(count);
      count = 0;
    } else {
      count++;
    }
  }

  for (int i = 0; i < c1.size(); i++) {
    if (c1[i] == maxlen) {
      cout << v2[i] << endl;
    }
  }

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main(void) {
  int N;
  scanf("%d", &N);
  string word;
  vector<string> v1;
  vector<string> v2;
  vector<int> c1;

  for (int i = 0; i < N; i++) {
    cin >> word;
    v1.push_back(word);
  }

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

  int count = 0;
  int maxlen = 0;

  for (int i = 0; i < N; i++) {
    if (v1[i] != v1[i + 1]) {
      if (maxlen < count)
        maxlen = count;
      v2.push_back(v1[i]);
      c1.push_back(count);
      count = 0;
    } else {
      count++;
    }
  }

  for (int i = 0; i < c1.size(); i++) {
    if (c1[i] == maxlen) {
      cout << v2[i] << endl;
    }
  }
  return 0;
}
Problem p02773 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <vector>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const int mod = 1000000007;

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

ll gcd(ll a, ll b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//----------------------------------------------------------------

int main() {
  map<string, int> dict;

  int n;
  cin >> n;
  vector<string> a(n);
  int ans = -INF;
  int i = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    dict[a[i]]++;
    chmax(ans, dict[a[i]]);
  }
  vector<string> out;
  int j = 0;
  for (int i = 0; i < n; i++) {
    if (dict[a[i]] == ans) {
      out.push_back(a[i]);
    }
  }
  sort(out.begin(), out.end());
  out.push_back("{{{{{");
  for (int i = 0; i < out.size(); i++) {
    if (out[i] != out[i + 1]) {
      cout << out[i] << endl;
    }
  }
}

Fixed submission:
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <vector>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const int mod = 1000000007;

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

ll gcd(ll a, ll b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//----------------------------------------------------------------

int main() {
  map<string, int> dict;

  int n;
  cin >> n;
  vector<string> a(n);
  int ans = -INF;
  int i = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    dict[a[i]]++;
    chmax(ans, dict[a[i]]);
  }
  vector<string> out;
  int j = 0;
  for (int i = 0; i < n; i++) {
    if (dict[a[i]] == ans) {
      out.push_back(a[i]);
    }
  }
  sort(out.begin(), out.end());
  out.push_back("{{{{{");
  for (int i = 0; i < out.size() - 1; i++) {
    if (out[i] != out[i + 1]) {
      cout << out[i] << endl;
    }
  }
}
Problem p02773 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll N;
  cin >> N;
  vector<string> vec(N);
  for (ll i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  ll a = 0;
  vector<ll> veco(1);
  vector<string> ve(1);
  ve.at(0) = vec.at(0);
  for (ll i = 1; i < N; i++) {
    if (vec.at(i - 1) == vec.at(i)) {
      veco.at(veco.size() - 1) += 1;
      a = max(veco.at(veco.size() - 1), a);
    } else {
      veco.push_back(0);
      ve.push_back(vec.at(i));
    }
  }
  vector<string> result(0);
  for (ll i = 0; i < N; i++) {
    if (veco.at(i) == a) {
      result.push_back(ve.at(i));
    }
  }
  sort(result.begin(), result.end());
  for (ll i = 0; i < result.size(); i++) {
    cout << result.at(i) << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll N;
  cin >> N;
  vector<string> vec(N);
  for (ll i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  ll a = 0;
  vector<ll> veco(1);
  vector<string> ve(1);
  ve.at(0) = vec.at(0);
  for (ll i = 1; i < N; i++) {
    if (vec.at(i - 1) == vec.at(i)) {
      veco.at(veco.size() - 1) += 1;
      a = max(veco.at(veco.size() - 1), a);
    } else {
      veco.push_back(0);
      ve.push_back(vec.at(i));
    }
  }
  vector<string> result(0);
  for (ll i = 0; i < veco.size(); i++) {
    if (veco.at(i) == a) {
      result.push_back(ve.at(i));
    }
  }
  sort(result.begin(), result.end());
  for (ll i = 0; i < result.size(); i++) {
    cout << result.at(i) << endl;
  }
}
Problem p02773 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(void) {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string arr[n];
  int i = 0;
  int j = 0;
  int max = 0;
  string winner[n + 1];
  int count = 1;
  while (i < n)
    cin >> arr[i++];
  sort(arr, arr + n);
  arr[n] = "";
  i = 1;
  while (i <= n) {
    if (arr[i - 1] == arr[i])
      count++;
    else
      count = 1;
    if (count >= max) {
      if (count > max)
        j = 0;
      max = count;
      winner[j] = arr[i - 1];
      winner[++j] = "";
    }
    i++;
  }
  i = 0;
  while (winner[i] != "")
    cout << winner[i++] << '\n';
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(void) {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string arr[n + 1];
  int i = 0;
  int j = 0;
  int max = 0;
  string winner[n + 1];
  int count = 1;
  while (i < n)
    cin >> arr[i++];
  sort(arr, arr + n);
  arr[n] = "";
  i = 1;
  while (i <= n) {
    if (arr[i - 1] == arr[i])
      count++;
    else
      count = 1;
    if (count >= max) {
      if (count > max)
        j = 0;
      max = count;
      winner[j] = arr[i - 1];
      winner[++j] = "";
    }
    i++;
  }
  i = 0;
  while (winner[i] != "")
    cout << winner[i++] << '\n';
}
Problem p02773 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<pair<int, string>> a;
  rep(i, n) { cin >> s[i]; }
  sort(s.begin(), s.end());

  int cnt = 1, cntmax = 1;
  rep(i, n) {
    if (s[i] == s[i + 1])
      cnt++;
    else {
      pair<int, string> p = make_pair(cnt, s[i]);
      a.push_back(p);
      cntmax = max(cnt, cntmax);
      cnt = 1;
    }
  }
  sort(a.begin(), a.end());
  rep(i, a.size()) {
    if (a[i].first == cntmax)
      cout << a[i].second << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<pair<int, string>> a;
  rep(i, n) { cin >> s[i]; }
  sort(s.begin(), s.end());

  s.push_back(" ");

  int cnt = 1, cntmax = 1;
  rep(i, n) {
    if (s[i] == s[i + 1])
      cnt++;
    else {
      pair<int, string> p = make_pair(cnt, s[i]);
      a.push_back(p);
      cntmax = max(cnt, cntmax);
      cnt = 1;
    }
  }
  sort(a.begin(), a.end());
  rep(i, a.size()) {
    if (a[i].first == cntmax)
      cout << a[i].second << endl;
  }
}
Problem p02773 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <vector>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

bool func(pair<int64_t, string> a, pair<int64_t, string> b) {
  if (a.first > b.first) {
    return true;
  } else if (a.first == b.first) {
    return a.second < b.second;
  } else {
    return false;
  }
}

int main(int argc, const char *argv[]) {
  // fasten cin
  cin.tie(0);
  ios::sync_with_stdio(false);
  // implement
  int64_t n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s.at(i);
  sort(s.begin(), s.end());
  vector<pair<int64_t, string>> pair;
  pair.push_back(make_pair(1, s.at(0)));
  for (int64_t i = 0; i < n - 1; i++) {
    if (s.at(i + 1) == s.at(i)) {
      pair.at(pair.size() - 1).first++;
    } else {
      pair.push_back(make_pair(1, s.at(i + 1)));
    }
  }
  sort(pair.begin(), pair.end(), func);
  rep(i, pair.size()) {
    cout << pair.at(i).second << endl;
    if (i == n - 1)
      break;
    if (pair.at(i + 1).first < pair.at(i).first)
      break;
  }
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <vector>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

bool func(pair<int64_t, string> a, pair<int64_t, string> b) {
  if (a.first > b.first) {
    return true;
  } else if (a.first == b.first) {
    return a.second < b.second;
  } else {
    return false;
  }
}

int main(int argc, const char *argv[]) {
  // fasten cin
  cin.tie(0);
  ios::sync_with_stdio(false);
  // implement
  int64_t n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s.at(i);
  sort(s.begin(), s.end());
  vector<pair<int64_t, string>> pair;
  pair.push_back(make_pair(1, s.at(0)));
  for (int64_t i = 0; i < n - 1; i++) {
    if (s.at(i + 1) == s.at(i)) {
      pair.at(pair.size() - 1).first++;
    } else {
      pair.push_back(make_pair(1, s.at(i + 1)));
    }
  }
  sort(pair.begin(), pair.end(), func);
  rep(i, pair.size()) {
    cout << pair.at(i).second << endl;
    if (i == pair.size() - 1)
      break;
    if (pair.at(i + 1).first < pair.at(i).first)
      break;
  }
}
Problem p02773 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rb(a, b, c) for (int a = b; a <= c; a++)
#define rl(a, b, c) for (int a = b; a >= c; a--)
#define vbe(v) v.begin()
#define ven(v) v.end()
#define all(v) v.begin(), v.end()
#define ll long long
#define vi vector<int>
#define vf vector<float>
#define vd vector<double>
#define vs vector<string>
#define vl vector<long>
#define PB push_back
#define POB pop_back

using namespace std;
const int INF = 1e9, MOD = 1e9 + 7;

int main() {
  ll n, max = 0;
  string s;
  cin >> n;
  vs S;
  map<string, ll> mp;
  rep(i, n) {
    cin >> s;
    if (mp[s] == 0)
      S.PB(s);
    mp[s] += 1;
    if (max < mp[s])
      max = mp[s];
  }
  rep(i, n) {
    if (max == mp[S[i]])
      cout << S[i] << endl;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rb(a, b, c) for (int a = b; a <= c; a++)
#define rl(a, b, c) for (int a = b; a >= c; a--)
#define vbe(v) v.begin()
#define ven(v) v.end()
#define all(v) v.begin(), v.end()
#define ll long long
#define vi vector<int>
#define vf vector<float>
#define vd vector<double>
#define vs vector<string>
#define vl vector<long>
#define PB push_back
#define POB pop_back

using namespace std;
const int INF = 1e9, MOD = 1e9 + 7;

int main() {
  ll n, max = 0;
  string s;
  cin >> n;
  vs S;
  map<string, ll> mp;
  rep(i, n) {
    cin >> s;
    if (mp[s] == 0)
      S.PB(s);
    mp[s] += 1;
    if (max < mp[s])
      max = mp[s];
  }
  sort(all(S));
  rep(i, S.size()) {
    if (max == mp[S[i]])
      cout << S[i] << endl;
  }
  return 0;
}
Problem p02773 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <map>
#include <string.h>
char s1[100000][15];
int main() {
  ll test, i, j = 0, k, m;
  map<string, ll> mp;
  cin >> k;
  for (i = 0; i < k; i++) {
    cin >> s1[i];
    mp[s1[i]]++;
  }
  ll mx = 0;
  for (i = 0; i < k; i++) {
    mx = max(mx, mp[s1[i]]);
  }
  set<string> st;
  ll cnt = 0;
  for (i = 0; i < k; i++) {
    if (mp[s1[i]] == mx) {
      st.insert(s1[i]);
    }
  }
  set<string>::iterator it;
  string c;
  for (it = st.begin(); it != st.end(); it++) {
    c = *it;
    cout << c << endl;
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <map>
#include <string.h>
char s1[300000][15];
int main() {
  ll test, i, j = 0, k, m;
  map<string, ll> mp;
  cin >> k;
  for (i = 0; i < k; i++) {
    cin >> s1[i];
    mp[s1[i]]++;
  }
  ll mx = 0;
  for (i = 0; i < k; i++) {
    mx = max(mx, mp[s1[i]]);
  }
  set<string> st;
  ll cnt = 0;
  for (i = 0; i < k; i++) {
    if (mp[s1[i]] == mx) {
      st.insert(s1[i]);
    }
  }
  set<string>::iterator it;
  string c;
  for (it = st.begin(); it != st.end(); it++) {
    c = *it;
    cout << c << endl;
  }
  return 0;
}