Problem p02802 (C++)

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

//----------------------------------------------------------------------------------------------------------------------
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

#define mp make_pair
#define pb push_back
#define FOR(x, to) for (x = 0; x < (to); x++)
#define FORR(x, arr) for (auto &x : arr)
#define ITR(x, c) for (__typeof(c.begin()) x = c.begin(); x != c.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define fastio                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL)
//----------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << ": " << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  for (int i = 0; i < (int)v.size(); i++) {
    if (i)
      os << ", ";
    os << v[i];
  }
  os << "}";
  return os;
}

// #define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
//----------------------------------------------------------------------------------------------------------------------

int main() {
  fastio;

  long n, m;
  cin >> n >> m;
  vector<bool> ac(n, false);
  vector<long> pen(n, 0);
  string v;
  long p;

  long ca = 0;
  long wa = 0;
  for (long i = 0; i < m; i++) {
    cin >> p >> v;
    if (ac[p])
      continue;
    if (v == "WA")
      pen[p]++;
    else {
      wa += pen[p];
      ca++;
      ac[p] = true;
    }
  }
  cout << ca << " " << wa;

  return 0;
}

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

//----------------------------------------------------------------------------------------------------------------------
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

#define mp make_pair
#define pb push_back
#define FOR(x, to) for (x = 0; x < (to); x++)
#define FORR(x, arr) for (auto &x : arr)
#define ITR(x, c) for (__typeof(c.begin()) x = c.begin(); x != c.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define fastio                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL)
//----------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << ": " << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  for (int i = 0; i < (int)v.size(); i++) {
    if (i)
      os << ", ";
    os << v[i];
  }
  os << "}";
  return os;
}

// #define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
//----------------------------------------------------------------------------------------------------------------------

int main() {
  fastio;

  long n, m;
  cin >> n >> m;
  vector<bool> ac(n + 1, false);
  vector<long> pen(n + 1, 0);
  string v;
  long p;

  long ca = 0;
  long wa = 0;
  for (long i = 0; i < m; i++) {
    cin >> p >> v;
    if (ac[p])
      continue;
    if (v == "WA")
      pen[p]++;
    else {
      wa += pen[p];
      ca++;
      ac[p] = true;
    }
  }
  cout << ca << " " << wa;

  return 0;
}