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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
const int N = 100005, INF = 1000000000;

int n, m;
int d[N];
vector<pair<int, int>> a[N];

char c[N];
int ans[N];

void dfs(int x) {
  for (int i = 0; i < a[x].size(); ++i) {
    int h = a[x][i].first;
    if (!c[h]) {
      if (d[h] > d[x]) {
        c[h] = c[x];
        ans[a[x][i].second] = d[h] - d[x];
        dfs(h);
      }
    }
  }
}

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &d[i]);
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    a[x].push_back(m_p(y, i));
    a[y].push_back(m_p(x, i));
    ans[i] = INF;
    if (d[x] == d[y]) {
      if (!c[x] && !c[y]) {
        c[x] = 'W';
        c[y] = 'B';
        ans[i] = d[x];
      } else if (!c[y]) {
        if (c[x] == 'W')
          c[y] = 'B';
        else
          c[y] = 'W';
        ans[i] = d[x];
      } else if (!c[x]) {
        if (c[y] == 'W')
          c[x] = 'B';
        else
          c[x] = 'W';
        ans[i] = d[x];
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (c[i])
      dfs(i);
  }
  for (int i = 1; i <= n; ++i) {
    if (!c[i]) {
      printf("-1\n");
      return 0;
    }
  }
  for (int i = 1; i <= n; ++i)
    printf("%c", c[i]);
  printf("\n");
  for (int i = 0; i < m; ++i)
    printf("%d\n", ans[i]);
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
const int N = 200005, INF = 1000000000;

int n, m;
int d[N];
vector<pair<int, int>> a[N];

char c[N];
int ans[N];

void dfs(int x) {
  for (int i = 0; i < a[x].size(); ++i) {
    int h = a[x][i].first;
    if (!c[h]) {
      if (d[h] > d[x]) {
        c[h] = c[x];
        ans[a[x][i].second] = d[h] - d[x];
        dfs(h);
      }
    }
  }
}

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &d[i]);
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    a[x].push_back(m_p(y, i));
    a[y].push_back(m_p(x, i));
    ans[i] = INF;
    if (d[x] == d[y]) {
      if (!c[x] && !c[y]) {
        c[x] = 'W';
        c[y] = 'B';
        ans[i] = d[x];
      } else if (!c[y]) {
        if (c[x] == 'W')
          c[y] = 'B';
        else
          c[y] = 'W';
        ans[i] = d[x];
      } else if (!c[x]) {
        if (c[y] == 'W')
          c[x] = 'B';
        else
          c[x] = 'W';
        ans[i] = d[x];
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (c[i])
      dfs(i);
  }
  for (int i = 1; i <= n; ++i) {
    if (!c[i]) {
      printf("-1\n");
      return 0;
    }
  }
  for (int i = 1; i <= n; ++i)
    printf("%c", c[i]);
  printf("\n");
  for (int i = 0; i < m; ++i)
    printf("%d\n", ans[i]);
  return 0;
}
Problem p02801 (C++)

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

void solve() {

  int n, m;
  cin >> n >> m;

  // pair--------------->penalty,mark if ac

  vector<pair<ll, bool>> answer(n + 1);

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

    int p;
    string s;

    cin >> p >> s;
    p--;

    if (answer[p].second == true) {
      continue;
    } else {

      if (s == "WA") {
        answer[p].first++;
      } else {
        answer[p].second = true;
      }
    }
  }

  int ac = 0;
  ll penalty = 0;

  for (int i = 0; i < n; i++) {
    if (answer[i].second == true) {
      ac++;
    }

    penalty += answer[i].first;
  }

  cout << ac << " " << penalty;
}

int main() {

  int y;

  y = 1;
  // cin>>y ;

  while (y--) {
    solve();
  }
}

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

void solve() {

  char c;
  cin >> c;
  cout << char(c + 1);
}

int main() {

  int y;

  y = 1;
  // cin>>y ;

  while (y--) {
    solve();
  }
}
Problem p02801 (C++)

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

int main() {
  string c;
  cin >> c;
  vector<string> p;
  p.push_back("a");
  p.push_back("b");
  p.push_back("c");
  p.push_back("d");
  p.push_back("e");
  p.push_back("f");
  p.push_back("g");
  p.push_back("h");
  p.push_back("j");
  p.push_back("k");
  p.push_back("l");
  p.push_back("m");
  p.push_back("n");
  p.push_back("o");
  p.push_back("p");
  p.push_back("q");
  p.push_back("r");
  p.push_back("s");
  p.push_back("t");
  p.push_back("u");
  p.push_back("v");
  p.push_back("w");
  p.push_back("x");
  p.push_back("y");
  p.push_back("z");

  rep(i, 26) {
    if (p[i] == c) {
      p[0] = p[i + 1];
    }
  }

  cout << p[0] << endl;
  return 0;
}

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

int main() {
  string c;
  cin >> c;
  vector<string> p;
  p.push_back("a");
  p.push_back("b");
  p.push_back("c");
  p.push_back("d");
  p.push_back("e");
  p.push_back("f");
  p.push_back("g");
  p.push_back("h");
  p.push_back("j");
  p.push_back("k");
  p.push_back("l");
  p.push_back("m");
  p.push_back("n");
  p.push_back("o");
  p.push_back("p");
  p.push_back("q");
  p.push_back("r");
  p.push_back("s");
  p.push_back("t");
  p.push_back("u");
  p.push_back("v");
  p.push_back("w");
  p.push_back("x");
  p.push_back("y");
  p.push_back("z");

  rep(i, 26) {
    if (p[i] == c) {
      p[0] = p[i + 1];
      break;
    }
  }

  cout << p[0] << endl;
  return 0;
}
Problem p02801 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  char C;
  do {
    cin >> C;
  } while (C != 'z');
  cout << C + 1 << endl;
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  char C;
  do {
    cin >> C;
  } while (C == 'z');
  cout << char(C + 1) << endl;
  return 0;
}
Problem p02801 (Python)

Buggy submission (status: Runtime Error):
c = input()

txt = "abcdefghijklmnopqrstuvwxyz"

for i in range(27):
    if txt[i] == c:
        print(txt[i + 1])


Fixed submission:
c = input()

txt = "abcdefghijklmnopqrstuvwxyz"
for i in range(26):
    if txt[i] == c:
        print(txt[i + 1])
Problem p02801 (Python)

Buggy submission (status: Runtime Error):
import string

AL = string.lowercase

C = input()
idx = AL.find(C)
idy = (idx + 1) % 26
print(AL[idy])


Fixed submission:
import string

AL = string.ascii_lowercase

C = input()
idx = AL.find(C)
idy = (idx + 1) % 26
print(AL[idy])
Problem p02801 (Python)

Buggy submission (status: Runtime Error):
import sys

args = sys.argv

a = "abcdefghijklmnopqrstuvwxyz"

c = args[1]
idx = a.index(c)
print(a[idx + 1])


Fixed submission:
import sys

args = sys.argv

a = "abcdefghijklmnopqrstuvwxyz"

c = input()
idx = a.index(c)
print(a[idx + 1])
Problem p02801 (C++)

Buggy submission (status: Runtime Error):
// Goodbye stupid girls & Hello L0u1Za, Codeforces and my friends(nobody)
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
// #include <Windows.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
template <class T> using pt = std::pair<T, T>;
using namespace std;

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#else
#endif
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  char c;
  cin >> c;
  cout << char(c + 1);
  return 0;
}

Fixed submission:
// Goodbye stupid girls & Hello L0u1Za, Codeforces and my friends(nobody)
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
// #include <Windows.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
template <class T> using pt = std::pair<T, T>;
using namespace std;

int main() {
#ifndef ONLINE_JUDGE
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#else
#endif
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  char c;
  cin >> c;
  cout << char(c + 1);
  return 0;
}
Problem p02801 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
int main() {
  char c;

  scanf("%[^z]", &c);
  printf("%c", c + 1);
  return 0;
}

Fixed submission:
#include <stdio.h>
int main() {
  char c;

  scanf("%c", &c);
  printf("%c\n", c + 1);
  return 0;
}
Problem p02801 (C++)

Buggy submission (status: Runtime Error):
// verma_ankit484

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

typedef long long ll;
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define endl "\n"
#define pb push_back
const ll mod = (ll)1e9 + 7;

using namespace std;
// using namespace __gnu_pbds;

// #define ordered_set tree<ll, null_type,less<ll>,
// rb_tree_tag,tree_order_statistics_node_update>

int main() {
  IOS
#ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
#endif
  char ch;
  cin >> ch;
  ch++;
  cout << ch << endl;
  return 0;
}


Fixed submission:
// verma_ankit484

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

typedef long long ll;
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define endl "\n"
#define pb push_back
const ll mod = (ll)1e9 + 7;

using namespace std;
// using namespace __gnu_pbds;

// #define ordered_set tree<ll, null_type,less<ll>,
// rb_tree_tag,tree_order_statistics_node_update>

int main() {
  char ch;
  cin >> ch;
  ch++;
  cout << ch << endl;
  return 0;
}
Problem p02801 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  freopen("input.txt", "r", stdin);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  char a;
  cin >> a;
  cout << char(a + 1);
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  // freopen("input.txt","r",stdin);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  char a;
  cin >> a;
  cout << char(a + 1);
}
Problem p02801 (Python)

Buggy submission (status: Runtime Error):
import sys

input = sys.stdin.readline


alphabets = "abcdefghijklmnopqrstuvwxyz"

c = input()
i = alphabets.index(c)

answer = alphabets[i + 1]
print(answer)


Fixed submission:
import sys

input = sys.stdin.readline


alphabets = "abcdefghijklmnopqrstuvwxyz"

c = input().strip()
i = alphabets.index(c)

answer = alphabets[i + 1]
print(answer)
Problem p02801 (C++)

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

int main() {
  string c = "abcdefghijklmnopqrstuvwxyz";
  char i;
  cin >> i;
  cout << c.at(i++) << endl;
}


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

int main() {
  char c;
  cin >> c;
  c++;
  cout << c << endl;
}
Problem p02801 (C++)

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

typedef long long ll;
const int MOD = 1000000007;

int main() {
  char z;
  cin >> z;
  printf("%s\n", z + 1);
}


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

typedef long long ll;
const int MOD = 1000000007;

int main() {
  char z;
  cin >> z;
  z++;
  cout << z << endl;
}
Problem p02801 (C++)

Buggy submission (status: Time Limit Exceeded):
/* author: Tarek */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
int main() {
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  int n;
  cin >> n;
  int r = 1;
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int sum = a + b + c + d;
  int g = n - 1;
  while (g--) {
    int m, h, j, k;
    cin >> m >> h >> j >> k;
    int mount = m + j + k + h;
    if (mount > sum)
      r++;
  }
  cout << r << endl;
  return 0;
}


Fixed submission:
/* author: Tarek */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
int main() {
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  char a;
  cin >> a;
  int k = (int)a;
  k += 1;
  cout << (char)k << endl;
  return 0;
}
Problem p02801 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  char a;
  cin >> a;
  cout << char(a + 1);
  return 1;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  char a;
  cin >> a;
  cout << char(a + 1);
  return 0;
}
Problem p02801 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define fastio()                                                               \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double
#define fill(a, val) memset(a, val, sizeof(a))
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define endl "\n"
#define int long long
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;
const ll MOD2 = 998244353;
const ll N = 1000 * 100 + 5;
const ll N2 = 2000 * 1000 * 10;
const ld PI = 3.14159265;
ll gcd(ll a, ll b) {
  if (!b)
    return a;
  return gcd(b, a % b);
}
ll power(ll x, ll y, ll p = INF) {
  ll res = 1;
  x %= p;
  while (y > 0) {
    if (y & 1)
      res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
signed main() {
  fastio();
// cout<<fixed<<setprecision(20);
// CHECK for LONG LONG and LONG DOUBLE
//*comment for all except cc/cf
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif //*/
  char c;
  cin >> c;
  int dum = c;
  dum++;
  cout << char(dum);
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define fastio()                                                               \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double
#define fill(a, val) memset(a, val, sizeof(a))
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define endl "\n"
#define int long long
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;
const ll MOD2 = 998244353;
const ll N = 1000 * 100 + 5;
const ll N2 = 2000 * 1000 * 10;
const ld PI = 3.14159265;
ll gcd(ll a, ll b) {
  if (!b)
    return a;
  return gcd(b, a % b);
}
ll power(ll x, ll y, ll p = INF) {
  ll res = 1;
  x %= p;
  while (y > 0) {
    if (y & 1)
      res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
signed main() {
  fastio();
  // cout<<fixed<<setprecision(20);
  // CHECK for LONG LONG and LONG DOUBLE
  /*comment for all except cc/cf
  #ifndef ONLINE_JUDGE
         freopen("input.txt","r",stdin);
         freopen("output.txt","w",stdout);
  #endif//*/
  char c;
  cin >> c;
  int dum = c;
  dum++;
  cout << char(dum);
  return 0;
}
Problem p02801 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
int main() {
  char c;
  int i;
  scanf("%c", &c);
  i = ((int)c) + 1;
  printf("%c", i);
  return 1;
}

Fixed submission:
#include <stdio.h>
int main() {
  char a;
  scanf("%c", &a);
  printf("%c\n", a + 1);
}
Problem p02801 (Python)

Buggy submission (status: Runtime Error):
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys

# import itertools
# import math

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H = readline().decode("utf8")
print(chr(ord(H) + 1))


Fixed submission:
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys

# import itertools
# import math

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H = readline().decode("utf8").strip()
print(chr(ord(H) + 1))
Problem p02801 (C++)

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

int main() {
  char C;
  cin >> C;
  string str = "abcdefghijklmnopqrstuvwxy";
  for (int i = 0; i < 26; i++) {
    if (C == str.at(i)) {
      cout << str.at(i + 1) << endl;
    }
  }
}


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

int main() {
  char C;
  cin >> C;
  string str = "abcdefghijklmnopqrstuvwxyz";
  for (int i = 0; i < 25; i++) {
    if (C == str.at(i)) {
      cout << str.at(i + 1) << endl;
    }
  }
}
Problem p02801 (C++)

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

int main() {
  string alfa[] = {"a", "b", "c", "d", "e"};
  string c;
  cin >> c;
  int i = 0;
  while (i < 25) {
    if (alfa[i] == c) {
      break;
    }
    i++;
  }
  cout << alfa[i + 1] << endl;
}


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

int main() {
  string alfa[] = {"a", "b", "c", "d", "e", "f", "g", "h", "i",
                   "j", "k", "l", "m", "n", "o", "p", "q", "r",
                   "s", "t", "u", "v", "w", "x", "y", "z"};
  string c;
  cin >> c;
  int i = 0;
  while (i < 25) {
    if (alfa[i] == c) {
      break;
    }
    i++;
  }
  cout << alfa[i + 1] << endl;
}
Problem p02801 (C++)

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

#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define int long long
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repn(i, a, b) for (int i = a; i >= b; i--)
#define F first
#define S second
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define mod2 998244353
#define pi 3.14159265358979323846

int solve() {
  int n;
  char c;
  cin >> c;
  c++;
  cout << c;
  //    cin>>n;

  return 0;
}

signed main() {
  IOS;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int t = 1;
  // cin>>t;
  while (t--) {
    solve();
    // if(solve()) cout<<"YES";
    // else cout<<"NO";
    cout << "\n";
  }
  return 0;
}

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

#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define int long long
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repn(i, a, b) for (int i = a; i >= b; i--)
#define F first
#define S second
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define mod2 998244353
#define pi 3.14159265358979323846

int solve() {
  int n;
  char c;
  cin >> c;
  c++;
  cout << c;
  //    cin>>n;

  return 0;
}

signed main() {
  IOS;
  int t = 1;
  // cin>>t;
  while (t--) {
    solve();
    // if(solve()) cout<<"YES";
    // else cout<<"NO";
    cout << "\n";
  }
  return 0;
}
Problem p02801 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main(int argc, char const *argv[]) {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);   // for getting input from input.txt
  freopen("output.txt", "w", stdout); // for writing output to output.txt
  freopen("error.txt", "w", stderr);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  char ch;
  cin >> ch;
  ch = ch + 1;
  cout << ch;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main() {
  char ch;
  cin >> ch;
  ch = ch + 1;
  cout << ch;
  return 0;
}
Problem p02801 (C++)

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

int main() {
  int n, k, m, s;
  cin >> n >> k >> m;
  vector<int> vec(n - 1);
  s = m * n;
  for (int i = 0; i < n - 1; i++) {
    cin >> vec.at(i);
    s -= vec.at(i);
  }

  if (s >= k)
    cout << -1 << endl;
  else if (s <= 0)
    cout << 0 << endl;
  else
    cout << s << endl;
}


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

int main() {
  char C;
  cin >> C;
  cout << (char)(C + 1) << endl;
}
Problem p02801 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cstdio>
#include <iostream>
using namespace std;

int main() {
  char ch[10];
  while (scanf("%s", ch) != 0) {
    printf("%c\n", ch[0] + 1);
  }

  return 0;
}


Fixed submission:
#include <cstdio>
#include <iostream>
using namespace std;

int main() {
  char ch[10];
  scanf("%s", ch);
  printf("%c\n", ch[0] + 1);

  return 0;
}
Problem p02801 (Python)

Buggy submission (status: Runtime Error):
from collections import deque
import sys
from copy import deepcopy

input = sys.stdin.readline


def bfs(table, i, j):
    dq = deque()
    if table[i][j] == "#":
        return -1
    h = len(table)
    w = len(table[0])
    ans = 0
    dq.append((i, j, 0))  # x,y,distance
    while dq:
        x, y, dis = dq.popleft()
        ans = max(ans, dis)
        if x > 0 and (x - 1, y) and table[x - 1][y] != "#":
            dq.append((x - 1, y, dis + 1))
            table[x - 1][y] = "#"
        if x < h - 1 and (x + 1, y) and table[x + 1][y] != "#":
            dq.append((x + 1, y, dis + 1))
            table[x + 1][y] = "#"
        if y > 0 and (x, y - 1) and table[x][y - 1] != "#":
            dq.append((x, y - 1, dis + 1))
            table[x][y - 1] = "#"
        if y < w - 1 and (x, y + 1) and table[x][y + 1] != "#":
            dq.append((x, y + 1, dis + 1))
            table[x][y + 1] = "#"
    return ans


def main():
    h, w = [int(i) for i in input().strip().split()]
    grid = [list(input().strip()) for _ in range(h)]
    ans = 0
    for i in range(h):
        for j in range(w):
            if grid[i][j] == ".":
                _grid = deepcopy(grid)
                max_path = bfs(_grid, i, j)
                ans = max(ans, max_path)

    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
c = input()
print(chr(ord(c) + 1))
Problem p02802 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) { // 階乗
  if (i == 0)
    return 1;
  return (factorial(i - 1)) * i;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, string>> a(m);
  set<int> ac;
  vector<int> wa(n);
  for (auto p : a)
    cin >> p.first >> p.second;
  for (auto p : a) {
    if (p.second == "AC")
      ac.insert(p.first);
    else if (!ac.count(p.first))
      wa[p.first - 1]++;
    else
      continue;
  }
  int pena = 0;
  rep(i, n) {
    if (ac.count(i + 1))
      pena += wa[i];
  }
  cout << ac.size() << ' ' << pena << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) { // 階乗
  if (i == 0)
    return 1;
  return (factorial(i - 1)) * i;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, string>> a(m);
  set<int> ac;
  vector<int> wa(n);
  for (auto &p : a)
    cin >> p.first >> p.second;
  for (auto p : a) {
    if (p.second == "AC")
      ac.insert(p.first);
    else if (!ac.count(p.first))
      wa[p.first - 1]++;
    else
      continue;
  }
  int pena = 0;
  rep(i, n) {
    if (ac.count(i + 1))
      pena += wa[i];
  }
  cout << ac.size() << ' ' << pena << endl;
}
Problem p02802 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define ll long long
using namespace std;
struct all_init {
  all_init() { cout << fixed << setprecision(12); }
} All_init;

int main() {
  ll n, m, ac = 0, wa = 0;
  cin >> n >> m;
  vector<bool> b(n + 1, false);
  vector<ll> wav(n);

  for (ll i = 0; i < m; i++) {
    ll p;
    string s;
    cin >> p >> s;
    if (!b[p] && s == "WA") {
      wav[p]++;
    } else if (!b[p] && s == "AC") {
      ac++;
      b[p] = true;
    }
  }
  for (ll i = 1; i <= n; i++) {
    if (b[i]) {
      wa += wav[i];
    }
  }
  cout << ac << " " << wa << endl;
}


Fixed submission:
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define ll long long
using namespace std;
struct all_init {
  all_init() { cout << fixed << setprecision(12); }
} All_init;

int main() {
  ll n, m, ac = 0, wa = 0;
  cin >> n >> m;
  vector<bool> b(100001, false);
  vector<ll> wav(100001);

  for (ll i = 0; i < m; i++) {
    ll p;
    string s;
    cin >> p >> s;
    if (!b[p] && s == "WA") {
      wav[p]++;
    } else if (!b[p] && s == "AC") {
      ac++;
      b[p] = true;
    }
  }
  for (ll i = 1; i <= n; i++) {
    if (b[i]) {
      wa += wav[i];
    }
  }
  cout << ac << " " << wa << endl;
}
Problem p02802 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, p, a = 0, w = 0;
  string J;
  cin >> N >> M;
  vector<bool> x(N, false);
  vector<int> WA(N, 0);
  for (int i = 0; i < M; i++) {
    cin >> p >> J[i];
    if (J == "AC") {
      if (!x.at(p - 1)) {
        a++;
        x.at(p - 1) = true;
        w += WA.at(p - 1);
      }
    } else if (!x.at(p - 1))
      WA.at(p - 1)++;
  }
  cout << a << " " << w << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, p, a = 0, w = 0;
  string J;
  cin >> N >> M;
  vector<bool> x(N, false);
  vector<int> WA(N, 0);
  for (int i = 0; i < M; i++) {
    cin >> p >> J;
    if (J == "AC") {
      if (!x.at(p - 1)) {
        a++;
        x.at(p - 1) = true;
        w += WA.at(p - 1);
      }
    } else if (!x.at(p - 1))
      WA.at(p - 1)++;
  }
  cout << a << " " << w << endl;
}
Problem p02802 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

#define ll long long
using vt = ll; // ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for (vt i = (vt)(s); i < (vt)(n); i++)
#define MOD 1000000007

int main() {
  vt n, m, a = 0, w = 0;
  cin >> n >> m;
  vector<pair<vt, string>> vec(m);
  rep(i, m) {
    cin >> vec.at(i).first >> vec.at(i).second;
    vec.at(i).first--;
  }
  vector<bool> wa(n, true);
  vector<vt> ac(n, 0);
  rep(i, m) {
    if (vec.at(i).second.at(0) == 'W' && vec[i].second.at(1) == 'A') {
      if (wa.at(vec.at(i).first))
        ac.at(vec.at(i).first)++;
    } else {
      if (wa.at(vec.at(i).first)) {
        wa.at(vec.at(i).first) = false;
        a++;
      }
    }
  }
  rep(i, n) {
    if (!(wa.at(i))) {
      w += ac.at(vec.at(i).first);
    }
  }
  cout << a << " " << w << endl;
  return 0;
}

Fixed submission:
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

#define ll long long
using vt = ll; // ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for (vt i = (vt)(s); i < (vt)(n); i++)
#define MOD 1000000007

int main() {
  vt n, m, a = 0, w = 0;
  cin >> n >> m;
  vector<pair<vt, string>> vec(m);
  rep(i, m) {
    cin >> vec.at(i).first >> vec.at(i).second;
    vec.at(i).first--;
  }
  vector<bool> wa(n, true);
  vector<vt> ac(n, 0);
  rep(i, m) {
    if (vec.at(i).second.at(0) == 'W' && vec[i].second.at(1) == 'A') {
      if (wa.at(vec.at(i).first))
        ac.at(vec.at(i).first)++;
    } else {
      if (wa.at(vec.at(i).first)) {
        wa.at(vec.at(i).first) = false;
        a++;
      }
    }
  }
  rep(i, n) {
    if (!(wa.at(i))) {
      w += ac.at(i);
    }
  }
  cout << a << " " << w << endl;
  return 0;
}
Problem p02802 (C++)

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

using namespace std;

typedef long long LL;

LL mod = 1000000007;

int main() {
  LL n, m;
  cin >> n >> m;

  vector<pair<LL, string>> d(m);

  for (auto &e : d) {
    cin >> e.first >> e.second;
  }

  vector<LL> done(n, 0);

  LL ac = 0;
  LL cnt = 0;
  for (LL i = 0; i < m; ++i) {
    LL f = d[i].first - 1;
    string s = d[i].second;
    if (!done[f]) {
      if (s == "AC") {
        done[f] = 1;
        ac++;
      } else {
        cnt++;
      }
    }
  }
  for (LL i = 0; i < n; ++i) {
    LL f = d[i].first - 1;
    string s = d[i].second;
    if (!done[f]) {
      cnt--;
    }
  }
  cout << ac << " " << cnt << endl;
}

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

using namespace std;

typedef long long LL;

LL mod = 1000000007;

int main() {
  LL n, m;
  cin >> n >> m;

  vector<pair<LL, string>> d(m);

  for (auto &e : d) {
    cin >> e.first >> e.second;
  }

  vector<LL> done(n, 0);

  LL ac = 0;
  LL cnt = 0;
  for (LL i = 0; i < m; ++i) {
    LL f = d[i].first - 1;
    string s = d[i].second;
    if (!done[f]) {
      if (s == "AC") {
        done[f] = 1;
        ac++;
      } else {
        cnt++;
      }
    }
  }
  for (LL i = 0; i < m; ++i) {
    LL f = d[i].first - 1;
    string s = d[i].second;
    if (!done[f]) {
      cnt--;
    }
  }
  cout << ac << " " << cnt << endl;
}
Problem p02802 (Python)

Buggy submission (status: Runtime Error):
import collections


def solve(n, m, hist):
    cor = 0
    pen = 0
    for p, tries in hist.items():
        for i, t in enumerate(tries):
            if t == "AC":
                cor += 1
                pen += i
                break
    return f"{cor} {pen}"


def input_to_int():
    return [int(r) for r in input().split(" ")]


if __name__ == "__main__":
    n, m = input_to_int()
    hist = collections.defaultdict(list)
    for _ in range(m):
        p, s = input().split(" ")
        hist[p].append(s)
    print(solve(n, m, hist))


Fixed submission:
import collections


def solve(n, m, hist):
    cor = 0
    pen = 0
    for p, tries in hist.items():
        for i, t in enumerate(tries):
            if t == "AC":
                cor += 1
                pen += i
                break
    return "{0} {1}".format(cor, pen)


def input_to_int():
    return [int(r) for r in input().split(" ")]


if __name__ == "__main__":
    n, m = input_to_int()
    hist = collections.defaultdict(list)
    for _ in range(m):
        p, s = input().split(" ")
        hist[p].append(s)
    print(solve(n, m, hist))
Problem p02802 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, m, acc = 0, pen = 0;
  cin >> n >> m;
  vector<bool> test(n);
  vector<int> arr(m);
  vector<int> p(m);
  vector<string> s(m);
  for (int i = 0; i < m; i++) {
    cin >> p[i];
    cin >> s[i];
    if (test[p[i]] == false && s[i] == "AC") {
      test[p[i]] = true;
      acc++;
      pen += arr[p[i]];
    }
    if (test[p[i]] == false && s[i] == "WA") {
      arr[p[i]]++;
    }
  }
  cout << acc << endl << pen << endl;
  return 0;
}

Fixed submission:
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, m, acc = 0, pen = 0;
  cin >> n >> m;
  vector<bool> test(n + 1);
  vector<int> arr(n + 1);
  vector<int> p(m);
  vector<string> s(m);
  for (int i = 0; i < m; i++) {
    cin >> p[i];
    cin >> s[i];
    if (test[p[i]] == false && s[i] == "AC") {
      test[p[i]] = true;
      acc++;
      pen += arr[p[i]];
    }
    if (test[p[i]] == false && s[i] == "WA") {
      arr[p[i]]++;
    }
  }
  cout << acc << endl << pen << endl;
  return 0;
}
Problem p02802 (C++)

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(m);
  vector<string> s(m);
  rep(i, m) cin >> p[i] >> s[i];
  vector<bool> flag(n);
  vector<int> pn_cnt(m);
  int ac_cnt = 0, pn_sum = 0;

  rep(i, m) {
    if (s[i] == "AC") {
      if (flag[p[i] - 1] == false) {
        flag[p[i] - 1] = true;
        ac_cnt++;
        pn_sum = pn_sum + pn_cnt[p[i] - 1];
      }
    } else if (s[i] == "WA") {
      if (flag[p[i] - 1] == false)
        pn_cnt[p[i] - 1]++;
    }
  }

  cout << ac_cnt << " " << pn_sum << endl;

  return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(m);
  vector<string> s(m);
  rep(i, m) cin >> p[i] >> s[i];
  vector<bool> flag(n);
  vector<int> pn_cnt(n);
  int ac_cnt = 0, pn_sum = 0;

  rep(i, m) {
    if (s[i] == "AC") {
      if (flag[p[i] - 1] == false) {
        flag[p[i] - 1] = true;
        ac_cnt++;
        pn_sum = pn_sum + pn_cnt[p[i] - 1];
      }
    } else if (s[i] == "WA") {
      if (flag[p[i] - 1] == false)
        pn_cnt[p[i] - 1]++;
    }
  }

  cout << ac_cnt << " " << pn_sum << endl;

  return 0;
}
Problem p02802 (C++)

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

#define ll long long
#define p_q priority_queue
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main() {
  int n, m;
  cin >> n >> m;

  vector<int> jud(n, 0);
  vector<int> was(n, 0);

  ll ACs = 0, WAs = 0;

  // 1->AC 0-> WA
  int p;
  string S;
  for (int i = 0; i < m; i++) {
    cin >> p >> S;
    if (jud.at(p - 1) == 0) {
      if (S == "WA") {
        was.at(p - 1)++;
      } else {
        ACs++;
        jud.at(p - 1) = 1;
      }
    }
  }

  rep(i, m) {
    if (jud.at(i) == 1) {
      WAs += was.at(i);
    }
  }

  cout << ACs << ' ' << WAs << endl;
}


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

#define ll long long
#define p_q priority_queue
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main() {
  int n, m;
  cin >> n >> m;

  vector<int> jud(n, 0);
  vector<int> was(n, 0);

  ll ACs = 0, WAs = 0;

  // 1->AC 0-> WA
  int p;
  string S;
  for (int i = 0; i < m; i++) {
    cin >> p >> S;
    if (jud.at(p - 1) == 0) {
      if (S == "WA") {
        was.at(p - 1)++;
      } else {
        ACs++;
        jud.at(p - 1) = 1;
      }
    }
  }

  rep(i, n) {
    if (jud.at(i) == 1) {
      WAs += was.at(i);
    }
  }

  cout << ACs << ' ' << WAs << endl;
}
Problem p02802 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
using namespace std;

int main() {
  ll N, M;
  ll seikai = 0, pena = 0;
  cin >> N >> M;
  vector<ll> count(N, 0);
  vector<ll> ans(N, 0);
  rep(i, M) {
    ll p;
    string S;
    cin >> p >> S;
    if (ans[p - 1] == 1)
      continue;
    if (S == "AC")
      ans[p - 1] = 1;
    else
      count[p - 1]++;
  }
  rep(j, M) {
    seikai += ans[j];
    if (ans[j] == 1)
      pena += count[j];
  }
  cout << seikai << " " << pena << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
using namespace std;

int main() {
  ll N, M;
  ll seikai = 0, pena = 0;
  cin >> N >> M;
  vector<ll> count(N, 0);
  vector<ll> ans(N, 0);
  rep(i, M) {
    ll p;
    string S;
    cin >> p >> S;
    if (ans[p - 1] == 1)
      continue;
    if (S == "AC")
      ans[p - 1] = 1;
    else
      count[p - 1]++;
  }
  rep(j, N) {
    seikai += ans[j];
    if (ans[j] == 1)
      pena += count[j];
  }
  cout << seikai << " " << pena << endl;

  return 0;
}
Problem p02802 (C++)

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

int main() {
  int N, M;
  cin >> N >> M;
  set<int> st;
  int fail = 0;
  vector<int> f(M + 1, 0);
  rep(i, M) {
    int a;
    string b;
    cin >> a >> b;
    if (b == "AC" && !(st.count(a))) {
      st.insert(a);
      fail += f[a];
    } else {
      if (st.count(a)) {
        continue;
      } else {
        f[a]++;
      }
    }
  }
  cout << st.size() << " " << fail << endl;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  set<int> st;
  int fail = 0;
  vector<int> f(N + 1, 0);
  rep(i, M) {
    int a;
    string b;
    cin >> a >> b;
    if (b == "AC" && !(st.count(a))) {
      st.insert(a);
      fail += f[a];
    } else {
      if (st.count(a)) {
        continue;
      } else {
        f[a]++;
      }
    }
  }
  cout << st.size() << " " << fail << endl;
}
Problem p02802 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  int N, M;
  cin >> N >> M;
  vector<bool> Ans(N);
  vector<int> pena(N);
  rep(i, M) {
    int p;
    string s;
    cin >> p >> s;
    if (Ans.at(p - 1))
      continue;
    if (s == "AC") {
      Ans.at(p - 1) = true;
    } else {
      pena.at(p)++;
    }
  }
  int num = 0, p = 0;
  rep(i, N) {
    if (Ans.at(i) == true) {
      p += pena.at(i);
      num++;
    }
  }
  cout << num << " " << p << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  int N, M;
  cin >> N >> M;
  vector<bool> Ans(N);
  vector<int> pena(N);
  rep(i, M) {
    int p;
    string s;
    cin >> p >> s;
    if (Ans.at(p - 1))
      continue;
    if (s == "AC") {
      Ans.at(p - 1) = true;
    } else {
      pena.at(p - 1)++;
    }
  }
  int num = 0, p = 0;
  rep(i, N) {
    if (Ans.at(i) == true) {
      p += pena.at(i);
      num++;
    }
  }
  cout << num << " " << p << endl;
}
Problem p02802 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>

int main() {
  long long N, M;
  std::cin >> N >> M;
  std::map<long long, long long> C;
  std::vector<long long> D(N + 1);
  long long wa = 0;
  long long ac = 0;
  for (int i = 0; i < M; ++i) {
    long long c;
    std::string s;
    std::cin >> c >> s;
    if (s == "WA" && D[c] != 1) {
      D[c] = 5;
      ++C[c];
      ++wa;
    }
    if (s == "AC" && D[c] != 1) {
      D[c] = 1;
      ++ac;
    }
  }
  for (int i = 0; i < M + 1; ++i) {
    if (D[i] == 5)
      wa -= C[i];
  }
  std::cout << ac << " " << wa << std::endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>

int main() {
  long long N, M;
  std::cin >> N >> M;
  std::map<long long, long long> C;
  std::vector<long long> D(N + 1);
  long long wa = 0;
  long long ac = 0;
  for (int i = 0; i < M; ++i) {
    long long c;
    std::string s;
    std::cin >> c >> s;
    if (s == "WA" && D[c] != 1) {
      D[c] = 5;
      ++C[c];
      ++wa;
    }
    if (s == "AC" && D[c] != 1) {
      D[c] = 1;
      ++ac;
    }
  }
  for (int i = 0; i < N + 1; ++i) {
    if (D[i] == 5)
      wa -= C[i];
  }
  std::cout << ac << " " << wa << std::endl;

  return 0;
}
Problem p02802 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <chrono>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;
int main() {

  long long n, m;

  int ans = 0, cnt = 0;
  cin >> n >> m;
  string s;
  vector<int> w(10005);
  map<int, int> ac;
  long long p;
  rep(i, m) {
    cin >> p >> s;
    if (ac[p] == 0 && s == "WA") {
      w[p]++;
    } else if (ac[p] == 0 && s == "AC") {
      cnt += w[p];
      ac[p]++;
      ans++;
    }
  }
  cout << ans << " " << cnt;
}

Fixed submission:
#include <algorithm>
#include <chrono>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;
int main() {

  long long n, m;

  int ans = 0, cnt = 0;
  cin >> n >> m;
  string s;
  vector<int> w(100005);
  map<int, int> ac;
  long long p;
  rep(i, m) {
    cin >> p >> s;
    if (ac[p] == 0 && s == "WA") {
      w[p]++;
    } else if (ac[p] == 0 && s == "AC") {
      cnt += w[p];
      ac[p]++;
      ans++;
    }
  }
  cout << ans << " " << cnt;
}
Problem p02802 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template <class F> auto recursive(F f) {
  return [f](auto... a) { return f(f, a...); };
}
template <class I, class V = typename I::value_type>
V sum_up(const I &l, const I &r) {
  V v;
  for (I i = l; i != r; i++)
    v = i == l ? *i : v + *i;
  return v;
}
template <class I, class T = iterator_traits<I>> I operator+(I it, int n) {
  for (int i = 0; i < n; i++)
    it++;
  return it;
}
template <class I, class T = iterator_traits<I>> I operator-(I it, int n) {
  for (int i = 0; i < n; i++)
    it--;
  return it;
}
template <class T>
using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> using vector2d = vector<vector<T>>;
struct fixprec {
  int x;
  fixprec(int d) : x(d) {}
};
ostream &operator<<(ostream &o, fixprec f) {
  return o << fixed << setprecision(f.x);
}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> P(N, 0), S(N, 0);
  queue<int> q;
  for (int i = 0; i < M; i++) {
    int p;
    string s;
    cin >> p >> s;
    p--;
    if (s == "WA" && !S[p])
      P[p]++;
    if (s == "AC")
      S[p] = 1;
  }
  for (int i = 0; i < M; i++) {
    if (!S[i])
      P[i] = 0;
  }
  cout << accumulate(WHOLE(S), 0) << " " << accumulate(WHOLE(P), 0) << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template <class F> auto recursive(F f) {
  return [f](auto... a) { return f(f, a...); };
}
template <class I, class V = typename I::value_type>
V sum_up(const I &l, const I &r) {
  V v;
  for (I i = l; i != r; i++)
    v = i == l ? *i : v + *i;
  return v;
}
template <class I, class T = iterator_traits<I>> I operator+(I it, int n) {
  for (int i = 0; i < n; i++)
    it++;
  return it;
}
template <class I, class T = iterator_traits<I>> I operator-(I it, int n) {
  for (int i = 0; i < n; i++)
    it--;
  return it;
}
template <class T>
using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> using vector2d = vector<vector<T>>;
struct fixprec {
  int x;
  fixprec(int d) : x(d) {}
};
ostream &operator<<(ostream &o, fixprec f) {
  return o << fixed << setprecision(f.x);
}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> P(N, 0), S(N, 0);
  queue<int> q;
  for (int i = 0; i < M; i++) {
    int p;
    string s;
    cin >> p >> s;
    p--;
    if (s == "WA" && !S[p])
      P[p]++;
    if (s == "AC")
      S[p] = 1;
  }
  for (int i = 0; i < N; i++) {
    if (!S[i])
      P[i] = 0;
  }
  cout << accumulate(WHOLE(S), 0) << " " << accumulate(WHOLE(P), 0) << endl;
  return 0;
}