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

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> p(M);
  vector<string> S(M);
  rep(i, M) cin >> p.at(i) >> S.at(i);

  vector<int> AC(N, 0), WA(N, 0);

  for (int i = 0; i < M; i++) {
    if (AC.at(p.at(i) - 1) == 0) {
      if (S.at(i) == "WA")
        WA.at(p.at(i) - 1)++;
      else
        AC.at(p.at(i) - 1)++;
    }
  }
  for (int i = 0; i < M; i++) {
    if (AC.at(i) == 0)
      WA.at(i) = 0;
  }

  int ac = accumulate(all(AC), 0);
  int wa = accumulate(all(WA), 0);

  cout << ac << " " << wa << endl;

  return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> p(M);
  vector<string> S(M);
  rep(i, M) cin >> p.at(i) >> S.at(i);

  vector<int> AC(N, 0), WA(N, 0);

  for (int i = 0; i < M; i++) {
    if (AC.at(p.at(i) - 1) == 0) {
      if (S.at(i) == "WA")
        WA.at(p.at(i) - 1)++;
      else
        AC.at(p.at(i) - 1)++;
    }
  }

  for (int i = 0; i < N; i++) {
    if (AC.at(i) == 0)
      WA.at(i) = 0;
  }

  int ac = accumulate(all(AC), 0);
  int wa = accumulate(all(WA), 0);

  cout << ac << " " << wa << endl;

  return 0;
}
Problem p02802 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
template <class T> void sort(vector<T> &v) { sort(v.begin(), v.end()); }

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(m);
  vector<string> s(m);
  for (int i = 0; i < m; i++)
    cin >> p[i] >> s[i];

  for (int i = 0; i < m; i++)
    p[i]--;
  vector<int> pen(m);
  set<int> done;

  for (int i = 0; i < m; i++) {
    if (s[i] == "WA" && done.count(p[i]) == 0)
      pen[p[i]]++;
    if (s[i] == "AC")
      done.insert(p[i]);
  }

  set<int> sac;
  for (int i = 0; i < m; i++)
    if (s[i] == "AC")
      sac.insert(p[i]);
  vector<int> ac;
  for (auto itr = sac.begin(); itr != sac.end(); itr++)
    ac.push_back(*itr);

  int ans = 0;
  for (auto i : ac)
    ans += pen[i];

  cout << ac.size() << " " << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
template <class T> void sort(vector<T> &v) { sort(v.begin(), v.end()); }

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(m);
  vector<string> s(m);
  for (int i = 0; i < m; i++)
    cin >> p[i] >> s[i];

  for (int i = 0; i < m; i++)
    p[i]--;
  vector<int> pen(n);
  set<int> done;

  for (int i = 0; i < m; i++) {
    if (s[i] == "WA" && done.count(p[i]) == 0)
      pen[p[i]]++;
    if (s[i] == "AC")
      done.insert(p[i]);
  }

  set<int> sac;
  for (int i = 0; i < m; i++)
    if (s[i] == "AC")
      sac.insert(p[i]);
  vector<int> ac;
  for (auto itr = sac.begin(); itr != sac.end(); itr++)
    ac.push_back(*itr);

  int ans = 0;
  for (auto i : ac)
    ans += pen[i];

  cout << ac.size() << " " << ans << endl;
  return 0;
}
Problem p02802 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// ll lcm(ll x, ll y){ return x*y/__gcd(x, y);}
int main() {
  ll N, M;
  cin >> N >> M;
  bool ac[N + 1];
  int wa[N + 1];
  for (ll i = 1; i <= N; i++) {
    ac[i] = false;
    wa[i] = 0;
  }
  ll n_ac = 0;
  ll n_wa = 0;
  for (ll i = 0; i < M; i++) {
    ll p;
    string s;
    cin >> p >> s;
    if (ac[p]) {
      continue;
    }
    if (!ac[p] && s == "AC") {
      n_ac++;
      ac[p] = true;
      continue;
    }
    if (!ac[p] && s == "WA") {
      wa[i + 1]++;
      continue;
    }
  }
  for (ll i = 1; i <= N; i++) {
    if (ac[i]) {
      n_wa += wa[i];
    }
  }
  cout << n_ac << ' ' << n_wa;

  // for(ll i=0; i<n; i++){}
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// ll lcm(ll x, ll y){ return x*y/__gcd(x, y);}
int main() {
  ll N, M;
  cin >> N >> M;
  bool ac[N + 1];
  int wa[N + 1];
  for (ll i = 1; i <= N; i++) {
    ac[i] = false;
    wa[i] = 0;
  }
  ll n_ac = 0;
  ll n_wa = 0;
  for (ll i = 0; i < M; i++) {
    ll p;
    string s;
    cin >> p >> s;
    if (ac[p]) {
      continue;
    }
    if (!ac[p] && s == "AC") {
      n_ac++;
      ac[p] = true;
      continue;
    }
    if (!ac[p] && s == "WA") {
      wa[p]++;
      continue;
    }
  }
  for (ll i = 1; i <= N; i++) {
    if (ac[i]) {
      n_wa += wa[i];
    }
  }
  cout << n_ac << ' ' << n_wa;

  // for(ll i=0; i<n; i++){}
}
Problem p02802 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

// output
#define SPBR(w, n) std::cout << (w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define RFOR(i, a, n) for (int i = (n)-1; i >= (a); --i)
#define REP(i, n) for (int i = 0; i < int(n); ++i)
#define RREP(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define IN(a, x, b) (a <= x && x < b)
#define OUT(a, x, b) (x < a || b <= x)
template <class T> inline T chmax(T &a, const T b) {
  return a = (a < b) ? b : a;
}
template <class T> inline T chmin(T &a, const T b) {
  return a = (a > b) ? b : a;
}

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;

signed main() {
  int N, M;
  cin >> N >> M;

  pair<int, int> ans = make_pair(0, 0);
  vector<int> cnt(M + 10, 0);
  vector<bool> used(M + 10, false);

  REP(k, M) {
    int i;
    string s;
    cin >> i >> s;
    i--;
    if (used[i])
      continue;

    if (s == "WA")
      cnt[i]++;
    else {
      used[i] = true;
      ans.first++;
      ans.second += cnt[i];
    }
  }

  cout << ans.first << " " << ans.second << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

// output
#define SPBR(w, n) std::cout << (w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define RFOR(i, a, n) for (int i = (n)-1; i >= (a); --i)
#define REP(i, n) for (int i = 0; i < int(n); ++i)
#define RREP(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define IN(a, x, b) (a <= x && x < b)
#define OUT(a, x, b) (x < a || b <= x)
template <class T> inline T chmax(T &a, const T b) {
  return a = (a < b) ? b : a;
}
template <class T> inline T chmin(T &a, const T b) {
  return a = (a > b) ? b : a;
}

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;

signed main() {
  int N, M;
  cin >> N >> M;

  pair<int, int> ans = make_pair(0, 0);
  vector<int> cnt(100100, 0);
  vector<bool> used(100100, false);

  REP(k, M) {
    int i;
    string s;
    cin >> i >> s;
    i--;
    if (used[i])
      continue;

    if (s == "WA")
      cnt[i]++;
    else {
      used[i] = true;
      ans.first++;
      ans.second += cnt[i];
    }
  }

  cout << ans.first << " " << ans.second << endl;

  return 0;
}
Problem p02802 (C++)

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> cnt(m), b(n);
  int res = 0;
  for (int i = 0; i < m; i++) {
    int p;
    cin >> p, p--;
    string c;
    cin >> c;
    if (c == "AC") {
      if (b[p] == 0) {
        b[p] = 1;
        res += cnt[p];
      }
    }
    if (c == "WA") {
      cnt[p]++;
    }
  }
  cout << accumulate(begin(b), end(b), 0) << " " << res << endl;
  return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> cnt(n), b(n);
  int res = 0;
  for (int i = 0; i < m; i++) {
    int p;
    cin >> p, p--;
    string c;
    cin >> c;
    if (c == "AC") {
      if (b[p] == 0) {
        b[p] = 1;
        res += cnt[p];
      }
    }
    if (c == "WA") {
      cnt[p]++;
    }
  }
  cout << accumulate(begin(b), end(b), 0) << " " << res << endl;
  return 0;
}
Problem p02802 (C++)

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

int main() {
  int N = 0, M = 0;
  std::cin >> N >> M;

  int p;
  std::string S;
  std::vector<std::pair<bool, int>> c(N);
  for (int i = 0; i < N; i++) {
    c[i].first = false;
    c[i].second = 0;
  }

  std::pair<int, int> ans;
  for (int i = 0; i < M; i++) {
    std::cin >> p >> S;
    if (c[p - 1].first)
      continue;
    if (S == "AC") {
      c[p - 1].first = true;
      ans.first++;
      ans.second += c[i].second;
    } else if (S == "WA")
      c[p - 1].second++;
  }

  std::cout << ans.first << " " << ans.second << std::endl;

  return 0;
}

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

int main() {
  int N = 0, M = 0;
  std::cin >> N >> M;

  int p;
  std::string S;
  std::vector<std::pair<bool, int>> c(N);
  for (int i = 0; i < N; i++) {
    c[i].first = false;
    c[i].second = 0;
  }

  std::pair<int, int> ans;
  for (int i = 0; i < M; i++) {
    std::cin >> p >> S;
    if (c[p - 1].first)
      continue;
    if (S == "AC") {
      c[p - 1].first = true;
      ans.first++;
      ans.second += c[p - 1].second;
    } else if (S == "WA")
      c[p - 1].second++;
  }

  std::cout << ans.first << " " << ans.second << std::endl;

  return 0;
}
Problem p02802 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define fast_IO                                                                \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);
using namespace std;

int wa[10500];
bool ac[10500];

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

  for (int i = 0; i < n; i++) {
    wa[i] = 0;
    ac[i] = false;
  }

  int wan = 0, acn = 0;

  int p;
  string s;
  while (m--) {
    cin >> p >> s;

    if (ac[p] == true)
      continue;
    if (s == "AC") {
      ac[p] = true;
      acn++;
      wan += wa[p];
    } else if (s == "WA") {
      wa[p]++;
    }
  }

  cout << acn << " " << wan << endl;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define fast_IO                                                                \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);
using namespace std;

int wa[105000];
bool ac[105000];

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

  for (int i = 0; i < n; i++) {
    wa[i] = 0;
    ac[i] = false;
  }

  int wan = 0, acn = 0;

  int p;
  string s;
  while (m--) {
    cin >> p >> s;

    if (ac[p] == true)
      continue;
    if (s == "AC") {
      ac[p] = true;
      acn++;
      wan += wa[p];
    } else if (s == "WA") {
      wa[p]++;
    }
  }

  cout << acn << " " << wan << endl;

  return 0;
}
Problem p02802 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <unordered_map>

typedef long long ll;
typedef long double ld;

using namespace std;
int main() {
  ll n, m, p[100010], ac = 0, wa = 0;
  string s[100010];
  unordered_map<ll, int> score;

  cin >> n >> m;
  for (ll i = 0; i < m; ++i) {
    cin >> p[i] >> s[i];
  }

  for (ll i = 0; i < m; ++i) {
    if (s[i] == "AC" && score[p[i]] != 1) {
      score[p[i]] = 1;
      ++ac;
      for (ll j = i - 1; j >= 0; --j) {
        if (s[j] == "WA" && p[i] == p[j])
          ++wa;
      }
    }
  }

  cout << ac << " " << wa;
}


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

typedef long long ll;
typedef long double ld;

using namespace std;
int main() {
  ll n, m, p[100010], ac = 0, wa = 0;
  string s[100010];
  unordered_map<ll, int> score;

  cin >> n >> m;
  for (ll i = 0; i < m; ++i) {
    cin >> p[i] >> s[i];
  }

  for (ll i = 0; i < m; ++i) {
    if (score[p[i]] != -1) {
      if (s[i] == "WA")
        ++score[p[i]];
      else {
        wa += score[p[i]];
        ++ac;
        score[p[i]] = -1;
      }
    }
  }

  cout << ac << " " << wa;
}
Problem p02802 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <queue>
#include <stdio.h>
#include <string.h>

#define F first
#define S second
#define R cin >>
#define Z class
#define ll long long
#define ln cout << '\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n", a)
#define mem(a) memset(a, 0, sizeof(a))
#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define REP(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define tr(it, c) for (iter(c) it = (c).begin(); it != (c).end(); it++)
using namespace std;

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

  ll i, j, k, x, y, z, p, q;
  ll n, m, tmp;
  string s[200000];
  string str;
  ll sum = 0, ac = 0, wa = 0;
  ll strr[200005];
  cin >> m >> n;
  if (n == 0) {
    cout << 0 << " " << 0 << endl;
    return 0;
  } else {
    vector<int> c(n);
    vector<int> aced(n);
    ll no;
    rep(i, n) {
      cin >> no;
      cin >> str;
      if (aced[no] == 1)
        continue;
      if (str[0] == 'W') {
        c[no]++;
      } else {
        sum += c[no];
        aced[no] = 1;
        ac++;
      }
    }
    cout << ac << " " << sum << endl;
    return 0;
  }
}

Fixed submission:
#include <bits/stdc++.h>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <queue>
#include <stdio.h>
#include <string.h>

#define F first
#define S second
#define R cin >>
#define Z class
#define ll long long
#define ln cout << '\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n", a)
#define mem(a) memset(a, 0, sizeof(a))
#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define REP(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define tr(it, c) for (iter(c) it = (c).begin(); it != (c).end(); it++)
using namespace std;

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

  ll i, j, k, x, y, z, p, q;
  ll n, m, tmp;
  string s[200000];
  string str;
  ll sum = 0, ac = 0, wa = 0;
  ll strr[200005];
  cin >> m >> n;
  if (n == 0) {
    cout << 0 << " " << 0 << endl;
    return 0;
  } else {
    vector<int> c(m);
    vector<int> aced(m);
    ll no;
    rep(i, n) {
      cin >> no;
      cin >> str;
      if (aced[no] == 1)
        continue;
      if (str[0] == 'W') {
        c[no]++;
      } else {
        sum += c[no];
        aced[no] = 1;
        ac++;
      }
    }
    cout << ac << " " << sum << endl;
    return 0;
  }
}
Problem p02802 (C++)

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

using namespace std;
#define ll long long
#define ld long double
#define rep(i, h) for (int i = 0; i < h; ++i)
#define rep1(i, h) for (int i = 0; i <= h; ++i)
#define rep2(i, k, h) for (int i = k; i < h; ++i)
#define rep3(i, k, h) for (int i = k; i <= h; ++i)
#define INF LLong_MAX // long long INF
#define inf INT_MAX   // int inf

typedef pair<int, int> int_pair;
typedef pair<string, string> string_pair;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ac(n), pena(n);
  rep(i, m) {
    int p;
    string s;
    cin >> p >> s;
    --p;
    if (ac[p])
      continue;
    if (s == "AC") {
      ac[p] = 1;
    } else {
      pena[p]++;
    }
  }
  int AC = 0, PENA = 0;
  rep(i, m) {
    AC += ac[i];
    if (ac[i])
      PENA += pena[i];
  }
  printf("%d %d\n", AC, PENA);
}

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

using namespace std;
#define ll long long
#define ld long double
#define rep(i, h) for (int i = 0; i < h; ++i)
#define rep1(i, h) for (int i = 0; i <= h; ++i)
#define rep2(i, k, h) for (int i = k; i < h; ++i)
#define rep3(i, k, h) for (int i = k; i <= h; ++i)
#define INF LLong_MAX // long long INF
#define inf INT_MAX   // int inf

typedef pair<int, int> int_pair;
typedef pair<string, string> string_pair;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ac(n), pena(n);
  rep(i, m) {
    int p;
    string s;
    cin >> p >> s;
    --p;
    if (ac[p])
      continue;
    if (s == "AC") {
      ac[p] = 1;
    } else {
      pena[p]++;
    }
  }
  int AC = 0, PENA = 0;
  rep(i, n) {
    AC += ac[i];
    if (ac[i])
      PENA += pena[i];
  }
  printf("%d %d\n", AC, PENA);
}
Problem p02802 (C++)

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

int main() {
  int N, M, p, tsum = 0, bsum = 0, csum = 0;
  string s;
  cin >> N >> M;
  vector<bool> ac(N, false);
  vector<int> acn(N, 0);

  for (int i = 0; i < M; i++) {
    s = "", p = -1;
    cin >> p >> s;
    if (p == -1)
      break;
    if (!(ac.at(p - 1))) {
      if (s == "AC") {
        ac.at(p - 1) = true;
        tsum += 1;
      } else if (s == "WA") {
        acn.at(p - 1) = acn.at(p - 1) + 1;
      }
    }
  }

  for (int i = 0; i < M; i++) {
    if (ac.at(i)) {
      csum += acn.at(i);
    }
  }

  cout << tsum << " " << csum << endl;
}

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

int main() {
  int N, M, p, tsum = 0, bsum = 0, csum = 0;
  string s;
  cin >> N >> M;
  vector<bool> ac(N, false);
  vector<int> acn(N, 0);

  for (int i = 0; i < M; i++) {
    s = "", p = -1;
    cin >> p >> s;
    if (p == -1)
      break;
    if (!(ac.at(p - 1))) {
      if (s == "AC") {
        ac.at(p - 1) = true;
        tsum += 1;
      } else if (s == "WA") {
        acn.at(p - 1) = acn.at(p - 1) + 1;
      }
    }
  }

  for (int i = 0; i < N; i++) {
    if (ac.at(i)) {
      csum += acn.at(i);
    }
  }

  cout << tsum << " " << csum << endl;
}
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;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ac(n), pena(n);
  rep(i, m) {
    int p;
    string s;
    cin >> p >> s;
    if (ac.at(p))
      continue;
    if (s == "WA") {
      pena.at(p)++;
    } else {
      ac.at(p) = 1;
    }
  }
  int AC = 0;
  int PENA = 0;
  rep(i, n) {
    AC += ac.at(i);
    if (ac.at(i))
      PENA += pena.at(i);
  }
  cout << AC << " " << PENA << endl;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ac(n), pena(n);
  rep(i, m) {
    int p;
    string s;
    cin >> p >> s;
    p--;
    if (ac.at(p))
      continue;
    if (s == "WA") {
      pena.at(p)++;
    } else {
      ac.at(p) = 1;
    }
  }
  int AC = 0;
  int PENA = 0;
  rep(i, n) {
    AC += ac.at(i);
    if (ac.at(i))
      PENA += pena.at(i);
  }
  cout << AC << " " << PENA << endl;
}
Problem p02802 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bits/stdc++.h>
#include <cctype>
#include <cfloat>
#include <climits>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <numeric>
#include <stdio.h>
#include <string>
#include <unordered_map>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n), pt(n);
  int ans = 0;
  int PT = 0;
  for (int i = 0; i < n; i++) {
    a.at(i) = 0;
    pt.at(i) = 0;
  }
  for (int i = 0; i < m; i++) {
    int p;
    string s;
    cin >> p >> s;
    if (!a.at(p - 1) && s == "AC") {
      a.at(p - 1) = 1;
    }
    if (!a.at(p - 1) && s == "WA") {
      pt.at(p - 1)++;
    }
  }
  for (int i = 0; i < n; i++) {
    if (a.at(i)) {
      ans++;
      PT += pt.at(i - 1);
    }
  }
  cout << ans << " " << PT << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#include <cctype>
#include <cfloat>
#include <climits>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <numeric>
#include <stdio.h>
#include <string>
#include <unordered_map>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n), pt(n);
  int ans = 0;
  int PT = 0;
  for (int i = 0; i < n; i++) {
    a.at(i) = 0;
    pt.at(i) = 0;
  }
  for (int i = 0; i < m; i++) {
    int p;
    string s;
    cin >> p >> s;
    if (!a.at(p - 1) && s == "AC") {
      a.at(p - 1) = 1;
    }
    if (!a.at(p - 1) && s == "WA") {
      pt.at(p - 1)++;
    }
  }
  for (int i = 0; i < n; i++) {
    if (a.at(i)) {
      ans++;
      PT += pt.at(i);
    }
  }
  cout << ans << " " << PT << endl;
  return 0;
}
Problem p02802 (C++)

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

int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> ac(n), pena(n);
  for (int i = 0; i < m; i++) {
    int p;
    string s;
    cin >> p >> s;
    p--;
    if (ac[p] == 1)
      continue;
    if (s == "AC")
      ac[p] = 1;
    else
      pena[p]++;
  }
  int AC = 0, PENA = 0;
  for (int i = 0; i < m; i++) {
    AC += ac[i];
    if (ac[i] == 1)
      PENA += pena[i];
  }
  printf("%d %d\n", AC, PENA);
}


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

int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> ac(n), pena(n);
  for (int i = 0; i < m; i++) {
    int p;
    string s;
    cin >> p >> s;
    p--;
    if (ac[p] == 1)
      continue;
    if (s == "AC")
      ac[p] = 1;
    else
      pena[p]++;
  }
  int AC = 0, PENA = 0;
  for (int i = 0; i < n; i++) {
    AC += ac[i];
    if (ac[i] == 1)
      PENA += pena[i];
  }
  printf("%d %d\n", AC, PENA);
}
Problem p02802 (Python)

Buggy submission (status: Runtime Error):
N, M = map(int, input().split())
accepted = [0] * N
penalties = [0] * N
for _ in range(M):
    p, ac = input().split()
    p, ac = int(p), ac == "AC"
    accepted[p] |= ac
    penalties[p] += not accepted[p]
print(sum(accepted), sum(p for ac, p in zip(accepted, penalties) if ac))


Fixed submission:
N, M = map(int, input().split())
accepted = [0] * N
penalties = [0] * N
for _ in range(M):
    p, ac = input().split()
    p, ac = int(p) - 1, ac == "AC"
    accepted[p] |= ac
    penalties[p] += not accepted[p]
print(sum(accepted), sum(p for ac, p in zip(accepted, penalties) if ac))
Problem p02802 (Python)

Buggy submission (status: Runtime Error):
n, m = map(int, input().split())

scores = [[0, False] for _ in range(n)]

for _ in range(m):
    p, S = input().split()
    p = int(p)

    if scores[p][1]:
        continue

    if S == "AC":
        scores[p][1] = True
        continue

    if S == "WA":
        scores[p][0] += 1

score = pena = 0
for count, ac in scores:
    if ac:
        score += 1
        pena += count

print(score, pena)


Fixed submission:
n, m = map(int, input().split())

scores = [[0, False] for _ in range(n + 1)]

for _ in range(m):
    p, S = input().split()
    p = int(p)

    if scores[p][1]:
        continue

    if S == "AC":
        scores[p][1] = True
        continue

    if S == "WA":
        scores[p][0] += 1

score = pena = 0
for count, ac in scores:
    if ac:
        score += 1
        pena += count

print(score, pena)
Problem p02802 (Python)

Buggy submission (status: Runtime Error):
N, M = map(int, input().split())
pS = {}
for i in range(N):
    pS[i] = [0, 0, 0]  # is_ac, penatly, AC

for i in range(M):
    p, S = input().split()
    p = int(p) - 1
    if pS[p][0] == 0 and S == "WA":
        pS[p][1] += 1
    elif pS[p][0] == 0 and S == "AC":
        pS[p][0] = 1
        pS[p][2] = 1

AC = 0
penatly = 0
for i in range(N):
    if pS[p][0] == 1:
        penatly += pS[int(i)][1]
        AC += pS[int(i)][2]
print(AC, penatly)


Fixed submission:
N, M = map(int, input().split())
pS = {}
for i in range(N):
    pS[i] = [0, 0, 0]  # is_ac, penatly, AC

for i in range(M):
    p, S = input().split()
    p = int(p) - 1
    if pS[p][0] == 0 and S == "WA":
        pS[p][1] += 1
    elif pS[p][0] == 0 and S == "AC":
        pS[p][0] = 1
        pS[p][2] = 1

AC = 0
penatly = 0
for i in range(N):
    if pS[i][0] == 1:
        penatly += pS[int(i)][1]
        AC += pS[int(i)][2]
print(AC, penatly)
Problem p02802 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(m + 1);
  vector<string> s(m + 1);
  for (int i = 1; i <= m; i++)
    cin >> p[i] >> s[i];
  vector<int> waNum(n + 1);
  int acNum = 0;
  vector<bool> ok(n + 1);
  for (int i = 1; i <= m; i++) {
    if (s[i] == "WA" && !ok[p[i]]) {
      waNum[i]++;
    }
    if (s[i] == "AC" && !ok[p[i]]) {
      acNum++;
      ok[p[i]] = true;
    }
  }
  int waAns = 0;
  for (int i = 1; i <= n; i++) {
    if (!ok[i])
      continue;
    waAns += waNum[i];
  }
  cout << acNum << " " << waAns << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(m + 1);
  vector<string> s(m + 1);
  for (int i = 1; i <= m; i++)
    cin >> p[i] >> s[i];
  vector<int> waNum(n + 1);
  int acNum = 0;
  vector<bool> ok(n + 1);
  for (int i = 1; i <= m; i++) {
    if (s[i] == "WA" && !ok[p[i]]) {
      waNum[p[i]]++;
    }
    if (s[i] == "AC" && !ok[p[i]]) {
      acNum++;
      ok[p[i]] = true;
    }
  }
  int waAns = 0;
  for (int i = 1; i <= n; i++) {
    if (!ok[i])
      continue;
    waAns += waNum[i];
  }
  cout << acNum << " " << waAns << endl;
}
Problem p02802 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n - 1); i >= 0; i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector<vector<ll>>;
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;
}

// 0 false, 1 true
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> ac(n);
  vector<ll> wa(n);
  rep(i, m) {
    ll p;
    string s;
    cin >> p >> s;
    if (s == "AC") {
      ac.at(p)++;
    }
    if (s == "WA") {
      if (ac.at(p) == 0) {
        wa.at(p)++;
      }
    }
  }

  ll ac_ans = 0;
  ll wa_ans = 0;
  rep(i, n) {
    if (ac.at(i) != 0) {
      ac_ans++;
      wa_ans += wa.at(i);
    }
  }

  cout << ac_ans << " " << wa_ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n - 1); i >= 0; i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector<vector<ll>>;
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;
}

// 0 false, 1 true
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> ac(n);
  vector<ll> wa(n);
  rep(i, m) {
    ll p;
    string s;
    cin >> p >> s;
    p--;
    if (s == "AC") {
      ac.at(p)++;
    }
    if (s == "WA") {
      if (ac.at(p) == 0) {
        wa.at(p)++;
      }
    }
  }

  ll ac_ans = 0;
  ll wa_ans = 0;
  rep(i, n) {
    if (ac.at(i) != 0) {
      ac_ans++;
      wa_ans += wa.at(i);
    }
  }

  cout << ac_ans << " " << wa_ans << endl;
}
Problem p02802 (C++)

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

using ll = long long;
using p = pair<ll, ll>;
constexpr ll INF = 1LL << 62;

int main(void) {
  ll N, M;
  cin >> N >> M;
  vector<ll> wacount(N + 1, 0), account(N + 1, 0);
  for (ll i = 0; i < M; i++) {
    ll p;
    string S;
    cin >> p >> S;
    if (account[p] != 0) {
      continue;
    }
    if (S == "WA") {
      wacount[p]++;
    } else if (S == "AC") {
      account[p]++;
    }
  }
  ll answa = 0;
  for (ll p = 1; p <= M; p++) {
    if (account[p]) {
      answa += wacount[p];
    }
  }

  cout << accumulate(account.begin(), account.end(), 0) << " " << answa << endl;
  return 0;
}

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

using ll = long long;
using p = pair<ll, ll>;
constexpr ll INF = 1LL << 62;

int main(void) {
  ll N, M;
  cin >> N >> M;
  vector<ll> wacount(N + 1, 0), account(N + 1, 0);
  for (ll i = 0; i < M; i++) {
    ll p;
    string S;
    cin >> p >> S;
    if (account[p] != 0) {
      continue;
    }
    if (S == "WA") {
      wacount[p]++;
    } else if (S == "AC") {
      account[p]++;
    }
  }
  ll answa = 0;
  for (ll p = 1; p <= N; p++) {
    if (account[p]) {
      answa += wacount[p];
    }
  }

  cout << accumulate(account.begin(), account.end(), 0) << " " << answa << endl;
  return 0;
}
Problem p02802 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int N, M;
  cin >> N >> M;
  vi AC(M), WA(N);
  int ac = 0, wa = 0;
  rep(i, M) {
    int p;
    string S;
    cin >> p >> S;
    if (S == "AC") {
      if (AC.at(p - 1) == 0) {
        ac++;
        wa += WA.at(p - 1);
      }
      AC.at(p - 1) = 1;
    } else {
      WA.at(p - 1)++;
    }
  }
  cout << ac << " " << wa << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int N, M;
  cin >> N >> M;
  vi AC(N), WA(N);
  int ac = 0, wa = 0;
  rep(i, M) {
    int p;
    string S;
    cin >> p >> S;
    if (S == "AC") {
      if (AC.at(p - 1) == 0) {
        ac++;
        wa += WA.at(p - 1);
      }
      AC.at(p - 1) = 1;
    } else {
      WA.at(p - 1)++;
    }
  }
  cout << ac << " " << wa << endl;
}
Problem p02802 (C++)

Buggy submission (status: Runtime Error):


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define PB pop_back
#define nn "\n"
#define O_O                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL)
#define all(p) p.begin(), p.end()
#define zz(v) v.size()
#define ss ' '
#define S(a) scanf("%lld", &a)
#define SS(a, b) scanf("%lld %lld", &a, &b)
#define SSS(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define pi acos(-1.0)
typedef long long ll;
typedef vector<ll> vll;

ll a[100500] = {0};
string b[100500];
int main() {
  // O_O ;
  ll n, m, temp = 0, temp2 = 0, temp3, w[10000] = {0}, ans = 0;
  cin >> n >> m;
  for (ll i = 1; i <= m; i++) {
    cin >> temp3;
    // a[temp3];
    cin >> b[temp3];
    // cout<<a[temp3]<<nn;
    if (a[temp3] == 0 && b[temp3] == "WA") {
      w[temp3]++;
    }

    else if (a[temp3] == 0 && b[temp3] == "AC") {
      temp++;
      a[temp3] = 1;
      ans = ans + w[temp3];
      // cout<<temp<<nn;
    }
  }

  cout << temp << " " << ans << nn;

  return 0;
}


Fixed submission:


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define PB pop_back
#define nn "\n"
#define O_O                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL)
#define all(p) p.begin(), p.end()
#define zz(v) v.size()
#define ss ' '
#define S(a) scanf("%lld", &a)
#define SS(a, b) scanf("%lld %lld", &a, &b)
#define SSS(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define pi acos(-1.0)
typedef long long ll;
typedef vector<ll> vll;

ll a[100500] = {0};
string b[100500];
int main() {
  // O_O ;
  ll n, m, temp = 0, temp2 = 0, temp3, w[100000] = {0}, ans = 0;
  cin >> n >> m;
  for (ll i = 1; i <= m; i++) {
    cin >> temp3;
    // a[temp3];
    cin >> b[temp3];
    // cout<<a[temp3]<<nn;
    if (a[temp3] == 0 && b[temp3] == "WA") {
      w[temp3]++;
    }

    else if (a[temp3] == 0 && b[temp3] == "AC") {
      temp++;
      a[temp3] = 1;
      ans = ans + w[temp3];
      // cout<<temp<<nn;
    }
  }

  cout << temp << " " << ans << nn;

  return 0;
}
Problem p02802 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
using namespace std;
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ll long long
#define ld long double
#define ii pair<int, int>
#define heap priority_queue
#define all(k) k.begin(), k.end()
#define rall(k) k.rbegin(), k.rend()
#define len(v) ((int)v.size())
#define fa(a, c) for (auto &a : c)
#define endl '\n'

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

  int n, m;
  vector<int> ac(11111);
  vector<int> wa(111111);
  string sit;
  int p;
  int pen = 0, acs = 0;
  cin >> n >> m;

  while (m--) {
    cin >> p >> sit;
    if (sit == "AC" and !ac[p]) {
      ac[p] = 1;
      pen += wa[p];
    } else if (sit == "WA") {
      wa[p]++;
    }
  }
  fa(b, ac) acs += b;
  cout << acs << ' ' << pen << endl;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
using namespace std;
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ll long long
#define ld long double
#define ii pair<int, int>
#define heap priority_queue
#define all(k) k.begin(), k.end()
#define rall(k) k.rbegin(), k.rend()
#define len(v) ((int)v.size())
#define fa(a, c) for (auto &a : c)
#define endl '\n'

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

  int n, m;
  vector<int> ac(111111);
  vector<int> wa(111111);
  string sit;
  int p;
  int pen = 0, acs = 0;
  cin >> n >> m;

  while (m--) {
    cin >> p >> sit;
    if (sit == "AC" and !ac[p]) {
      ac[p] = 1;
      pen += wa[p];
    } else if (sit == "WA") {
      wa[p]++;
    }
  }
  fa(b, ac) acs += b;
  cout << acs << ' ' << pen << 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 < n; i++)
#define MOD 1000000007
#define el endl
typedef long long ll;
typedef long double ld;

int main() {
  struct s {
    bool is_ac;
    int penalty;
  };
  int n, m, pena = 0, ac = 0;
  cin >> n >> m;
  vector
 sv(n);
  rep(i, m) {
    int p_n;
    string res;
    cin >> p_n;
    cin >> res;

    if (res == "AC") {
      if (!sv[p_n].is_ac) {
        sv[p_n].is_ac = true;
        ac++;
        pena += sv[p_n].penalty;
      }
    } else {
      sv[p_n].penalty++;
    }
  }
  cout << ac << " " << pena << el;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
typedef long long ll;
typedef long double ld;

int main() {
  struct s {
    bool is_ac;
    int penalty;
  };
  int n, m, pena = 0, ac = 0;
  cin >> n >> m;
  vector
 sv(n);
  rep(i, m) {
    int p_n;
    string res;
    cin >> p_n;
    cin >> res;

    p_n--;

    if (res == "AC") {
      if (!sv[p_n].is_ac) {
        sv[p_n].is_ac = true;
        ac++;
        pena += sv[p_n].penalty;
      }
    } else {
      sv[p_n].penalty++;
    }
  }
  cout << ac << " " << pena << el;
}
Problem p02802 (C++)

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

int main() {
  ll n, m, ans, wa, i, b;
  cin >> n >> m;
  ll w[n];
  wa = 0;
  ans = 0;
  for (i = 0; i <= m; i++) {
    w[i] = 0;
  }
  string c;
  for (i = 0; i < m; i++) {
    cin >> b >> c;
    if (w[b] != -1) {
      if (c == "WA") {
        w[b] += 1;
      }
      if (c == "AC") {
        wa += w[b];
        w[b] = -1;
        ans += 1;
      }
    }
  }
  cout << ans << " " << wa;
}

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

int main() {
  ll n, m, ans, wa, i, b;
  cin >> n >> m;
  ll w[n];
  wa = 0;
  ans = 0;
  for (i = 0; i <= n; i++) {
    w[i] = 0;
  }
  string c;
  for (i = 0; i < m; i++) {
    cin >> b >> c;
    if (w[b] != -1) {
      if (c == "WA") {
        w[b] += 1;
      }
      if (c == "AC") {
        wa += w[b];
        w[b] = -1;
        ans += 1;
      }
    }
  }
  cout << ans << " " << wa;
}
Problem p02802 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

// #define DEBUG

int main(void) {
  ll N, M;
  cin >> N >> M;
  vector<ll> p(M);
  vector<string> S(M);
  vector<bool> isCorrectProb(N, false); // 問題(i)が正当したか否か
  ll correct_ans_num = 0;               // 正答数
  vector<ll> kai_correct_ans_num(N, 0); // 正当したらtrueに
  ll ng_ans_to_correct_num = 0;         // 正答までの失敗数
  for (ll i = 0; i < M; i++) {
    cin >> p[i] >> S[i]; // 代入

    // 注意！　正当済みの場合、カウントしない
    if (isCorrectProb[p[i]] == true) {
      continue;
    }

    // 失敗の場合、失敗数をカウント
    //    if(S[i] == "WA")
    if (equal(S[i].begin(), S[i].end(), "WA") == true) {
      //      ng_ans_to_correct_num++;
      kai_correct_ans_num[p[i]]++; // 最後にtrueになるかチェック
    } else {
      correct_ans_num++;
      isCorrectProb[p[i]] = true;
      ng_ans_to_correct_num += kai_correct_ans_num[p[i]];
    }
  }
  cout << correct_ans_num << " " << ng_ans_to_correct_num;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

// #define DEBUG

int main(void) {
  ll N, M;
  cin >> N >> M;
  vector<ll> p(M);
  vector<string> S(M);
  vector<bool> isCorrectProb(N + 1, false); // 問題(i)が正当したか否か
  ll correct_ans_num = 0;                   // 正答数
  vector<ll> kai_correct_ans_num(N + 1, 0); // 正当したらtrueに
  ll ng_ans_to_correct_num = 0;             // 正答までの失敗数
  for (ll i = 0; i < M; i++) {
    cin >> p[i] >> S[i]; // 代入

    // 注意！　正当済みの場合、カウントしない
    if (isCorrectProb[p[i]] == true) {
      continue;
    }

    // 失敗の場合、失敗数をカウント
    //    if(S[i] == "WA")
    if (equal(S[i].begin(), S[i].end(), "WA") == true) {
      //      ng_ans_to_correct_num++;
      kai_correct_ans_num[p[i]]++; // 最後にtrueになるかチェック
    } else {
      correct_ans_num++;
      isCorrectProb[p[i]] = true;
      ng_ans_to_correct_num += kai_correct_ans_num[p[i]];
    }
  }
  cout << correct_ans_num << " " << ng_ans_to_correct_num;

  return 0;
}
Problem p02802 (C++)

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

int main() {
  while (true) {
    int m, n;
    cin >> m >> n;
    map<int, int> was;
    map<int, int> acs;
    int sum = 0;
    for (int i = 0; i < n; i++) {
      int a;
      string b;
      cin >> a >> b;
      if (b == "WA")
        was[a]++;
      else {
        if (!acs.count(a))
          sum += was[a];
        acs[a] = 1;
      }
    }
    cout << acs.size() << " " << sum << endl;
  }

  return 0;
}

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

int main() {
  // while(true)
  {
    int m, n;
    cin >> m >> n;
    map<int, int> was;
    map<int, int> acs;
    int sum = 0;
    for (int i = 0; i < n; i++) {
      int a;
      string b;
      cin >> a >> b;
      if (b == "WA")
        was[a]++;
      else {
        if (!acs.count(a))
          sum += was[a];
        acs[a] = 1;
      }
    }
    cout << acs.size() << " " << sum << endl;
  }

  return 0;
}
Problem p02802 (C++)

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

#define I inline
#define fi first
#define se second
#define R register
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int, int>
#define fo(i, a, b) for (reg i = a; i <= b; i++)
#define fd(i, a, b) for (reg i = a; i >= b; i--)
#define cr const reg &
using namespace std;
const int inf = 2147483647;
const int N = 101;

I int _max(cr x, cr y) { return x > y ? x : y; }
I int _min(cr x, cr y) { return x < y ? x : y; }
I int read() {
  reg x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
  return x * f;
}
I void ptt(cr x) {
  if (x >= 10)
    ptt(x / 10);
  putchar(x % 10 + '0');
}
I void put(cr x) { x < 0 ? putchar('-'), ptt(-x) : ptt(x); }
I void pr1(cr x) { put(x), putchar(' '); }
I void pr2(cr x) { put(x), puts(""); }

bool ok[N];
int cnt[N];
int main() {
  int n = read(), m = read();
  int A = 0, B = 0;
  while (m--) {
    int now = read();
    string s;
    cin >> s;
    if (s == "AC") {
      if (!ok[now]) {
        ok[now] = 1, A++, B += cnt[now];
      }
    } else {
      cnt[now]++;
    }
  }
  pr1(A), pr2(B);
}


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

#define I inline
#define fi first
#define se second
#define R register
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int, int>
#define fo(i, a, b) for (reg i = a; i <= b; i++)
#define fd(i, a, b) for (reg i = a; i >= b; i--)
#define cr const reg &
using namespace std;
const int inf = 2147483647;
const int N = 1e5 + 1;

I int _max(cr x, cr y) { return x > y ? x : y; }
I int _min(cr x, cr y) { return x < y ? x : y; }
I int read() {
  reg x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
  return x * f;
}
I void ptt(cr x) {
  if (x >= 10)
    ptt(x / 10);
  putchar(x % 10 + '0');
}
I void put(cr x) { x < 0 ? putchar('-'), ptt(-x) : ptt(x); }
I void pr1(cr x) { put(x), putchar(' '); }
I void pr2(cr x) { put(x), puts(""); }

bool ok[N];
int cnt[N];
int main() {
  int n = read(), m = read();
  int A = 0, B = 0;
  while (m--) {
    int now = read();
    string s;
    cin >> s;
    if (s == "AC") {
      if (!ok[now]) {
        ok[now] = 1, A++, B += cnt[now];
      }
    } else {
      cnt[now]++;
    }
  }
  pr1(A), pr2(B);
}
Problem p02802 (C++)

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

using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, a, b) for (int64_t i = (a); i < (b); ++i)
const int MOD = 1e9 + 7;
typedef long long ll;
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(m);
  vector<string> s(m);
  for (int i = 0; i < m; i++)
    cin >> p[i] >> s[i];
  vector<bool> a(n, false); // n問の問題
  vector<int> k(n, 0);
  int ac = 0;
  int wa = 0;
  for (int i = 0; i < m; i++) {
    if (a[p[i] - 1] == false) {
      if (s[i] == "WA")
        k[p[i] - 1]++;
      if (s[i] == "AC") {
        a[p[i] - 1] = true;
        ac++;
      }
    }
  }

  for (int i = 0; i < n; i++) {
    if (a[i] == true) {
      wa += k[p[i] - 1];
    }
  }
  cout << ac << " " << wa << endl;
}


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

using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, a, b) for (int64_t i = (a); i < (b); ++i)
const int MOD = 1e9 + 7;
typedef long long ll;
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(m);
  vector<string> s(m);
  for (int i = 0; i < m; i++)
    cin >> p[i] >> s[i];
  vector<bool> a(n, false); // n問の問題
  vector<int> k(n, 0);
  int ac = 0;
  int wa = 0;
  for (int i = 0; i < m; i++) {
    if (a[p[i] - 1] == false) {
      if (s[i] == "WA")
        k[p[i] - 1]++;
      if (s[i] == "AC") {
        a[p[i] - 1] = true;
        ac++;
      }
    }
  }

  for (int i = 0; i < n; i++) {
    if (a[i] == true) {
      wa += k[i];
    }
  }
  cout << ac << " " << wa << endl;
}
Problem p02802 (C++)

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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V)                                                           \
  for (auto v : (V))                                                           \
    cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

int main() {
  /* code */
  int N, M;
  cin >> N >> M;
  vector<int> P(M);
  vector<string> S(M);
  REP(i, M) { cin >> P[i] >> S[i]; }
  ll ac = 0LL, wa = 0LL;
  set<int> ACed;
  vector<int> WABuf(M + 100);
  REP(i, M) {
    if (ACed.find((P[i])) != ACed.end()) {
      continue;
    }
    if (S[i] == "AC") {
      ACed.insert(P[i]);
      ++ac;
      wa += WABuf[P[i]];
    } else {
      WABuf[P[i]]++;
    }
  }
  cout << ac << " " << wa << endl;
  return 0;
}

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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V)                                                           \
  for (auto v : (V))                                                           \
    cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

int main() {
  /* code */
  int N, M;
  cin >> N >> M;
  vector<int> P(M);
  vector<string> S(M);
  REP(i, M) { cin >> P[i] >> S[i]; }
  ll ac = 0LL, wa = 0LL;
  set<int> ACed;
  vector<int> WABuf(N + 1, 0);
  REP(i, M) {
    if (ACed.find((P[i])) != ACed.end()) {
      continue;
    }
    if (S[i] == "AC") {
      ACed.insert(P[i]);
      ++ac;
      wa += WABuf[P[i]];
    } else {
      WABuf[P[i]]++;
    }
  }
  cout << ac << " " << wa << endl;
  return 0;
}