Problem p02613 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <array>
#include <bitset>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>
// #define _LIBCPP_DEBUG 0
// #define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(), (a), end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
// setprecision(16)

void outi(int x) { cout << x << endl; }
void outl(ll x) { cout << x << endl; }
void outs(string x) { cout << x << endl; }
ll max(ll a, ll b) {
  ll max;
  if (a > b)
    max = a;
  else
    max = b;
  return max;
}
ll min(ll a, ll b) {
  ll min;
  if (a < b)
    min = a;
  else
    min = b;
  return min;
}
int gcd(int x, int y) {
  /*最大公約数 O(log MAX_X)*/
  if (y == 0)
    return x;
  return gcd(y, x % y);
}
//---------------------------------------------------------------

int main() {

  int n;
  cin >> n;
  string s;

  int countAC = 0;
  int countWA = 0;
  int countTLE = 0;
  int countRE = 0;

  rep(i, n) {
    cin >> s;
    if (s == "AC") {
      countAC++;
    }
    if (s == "WA") {
      countWA++;
    }
    if (s == "TLE") {
      countTLE++;
    }
    if (s == "RE") {
      countRE++;
    }
  }

  cout << "AC x " << countAC << endl;
  cout << "WA x " << countWA << endl;
  cout << "TLE x " << countTLE << endl;
  cout << "RE x " << countRE << endl;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <array>
#include <bitset>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>
// #define _LIBCPP_DEBUG 0
// #define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(), (a), end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
// setprecision(16)

void outi(int x) { cout << x << endl; }
void outl(ll x) { cout << x << endl; }
void outs(string x) { cout << x << endl; }
ll max(ll a, ll b) {
  ll max;
  if (a > b)
    max = a;
  else
    max = b;
  return max;
}
ll min(ll a, ll b) {
  ll min;
  if (a < b)
    min = a;
  else
    min = b;
  return min;
}
int gcd(int x, int y) {
  /*最大公約数 O(log MAX_X)*/
  if (y == 0)
    return x;
  return gcd(y, x % y);
}
//---------------------------------------------------------------

int main() {

  int n;
  cin >> n;
  string s;
  rep(i, n) { cin >> s[i]; }

  int countAC = 0;
  int countWA = 0;
  int countTLE = 0;
  int countRE = 0;

  rep(i, n) {
    if (s[i] == 'AC') {
      countAC++;
    }
    if (s[i] == 'WA') {
      countWA++;
    }
    if (s[i] == 'TLE') {
      countTLE++;
    }
    if (s[i] == 'RE') {
      countRE++;
    }
  }
  cout << "AC x " << countAC << endl;
  cout << "WA x " << countWA << endl;
  cout << "TLE x " << countTLE << endl;
  cout << "RE x " << countRE << endl;
}