Problem p02802 (C++)

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

using ll = long long;
using pint = pair<int, int>;

#define INF 99999999
#define rep(i, n) for (int(i) = 0, temp = (int)(n); (i) < temp; ++(i))
#define repi(i, start, end)                                                    \
  for (int(i) = (start), temp = (int)(end); i < (end); ++(i))
#define rfor(v, x) for (const auto &(x) : (v)) // xは値を表す
#define all(x) (x).begin(), (x).end()
#define SORT(v, n) sort((v), (v) + (n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v, lambda) sort(all((v)), (lambda))
#define vint vector<int>
#define vvint vector<vector<int>> // vvint v(n,vint(n))のように宣言できる
#define vin(v)                                                                 \
  rep(i, (v).size()) { cin >> (v)[i]; }
// 最終奥義(使うときはINFも書き換えろ!!)
// #define int long long
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int ctoi(char c) { return c - '0'; }
// lambda式 -> [&](int x, int y){return x<y;}
// vector内の重複を削除-> v.erase(unique(all(v)),v.end());

signed main(void) {
  int n, m;
  cin >> n >> m;
  vector<pint> ps(m);
  vint sum(n, 0);
  vint wa(n, 0);
  rep(i, m) {
    int p;
    string s;
    cin >> p >> s;
    p--;
    if (sum[p] > 0) {
      continue;
    } else if (s == "WA") {
      wa[p]++;
    } else {
      sum[p]++;
    }
  }
  rep(i, m) if (sum[i] == 0) wa[i] = 0;
  cout << accumulate(all(sum), 0) << " " << accumulate(all(wa), 0) << endl;
}


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

using ll = long long;
using pint = pair<int, int>;

#define INF 99999999
#define rep(i, n) for (int(i) = 0, temp = (int)(n); (i) < temp; ++(i))
#define repi(i, start, end)                                                    \
  for (int(i) = (start), temp = (int)(end); i < (end); ++(i))
#define rfor(v, x) for (const auto &(x) : (v)) // xは値を表す
#define all(x) (x).begin(), (x).end()
#define SORT(v, n) sort((v), (v) + (n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v, lambda) sort(all((v)), (lambda))
#define vint vector<int>
#define vvint vector<vector<int>> // vvint v(n,vint(n))のように宣言できる
#define vin(v)                                                                 \
  rep(i, (v).size()) { cin >> (v)[i]; }
// 最終奥義(使うときはINFも書き換えろ!!)
// #define int long long
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int ctoi(char c) { return c - '0'; }
// lambda式 -> [&](int x, int y){return x<y;}
// vector内の重複を削除-> v.erase(unique(all(v)),v.end());

signed main(void) {
  int n, m;
  cin >> n >> m;
  vector<pint> ps(m);
  vint sum(n, 0);
  vint wa(n, 0);
  rep(i, m) {
    int p;
    string s;
    cin >> p >> s;
    p--;
    if (sum[p] > 0) {
      continue;
    } else if (s == "WA") {
      wa[p]++;
    } else {
      sum[p]++;
    }
  }
  rep(i, n) if (sum[i] == 0) wa[i] = 0;
  cout << accumulate(all(sum), 0) << " " << accumulate(all(wa), 0) << endl;
}