alexjercan/bugnet huggingface dataset:
Problem p02613 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <functional>
#include <iostream>
#include <string>
using namespace std;

#include <climits>
#include <iomanip>
#include <math.h>
#include <queue>
#include <vector>
using Graph = vector<vector<int>>;
const double PI = 3.14159265358979323846;

long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

// 約数をベクトル形式で返す
vector<int> vect_yakusuu(int n) {
  vector<int> ret;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

int main() {

  long long N;
  string S[100100];
  int ans[5];

  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> S[i];
  }

  for (int i = 0; i < 4; i++) {
    ans[i] = 0;
  }

  for (int i = 0; i < N; i++) {
    if (S[i] == "AC") {
      ans[0]++;
    }
    if (S[i] == "WA") {
      ans[1]++;
    }
    if (S[i] == "TLE") {
      ans[2]++;
    }
    if (S[i] == "RE") {
      ans[3]++;
    }
  }

  cout << "AC x " << ans[0] << endl;
  cout << "WA x " << ans[1] << endl;
  cout << "TLE x " << ans[2] << endl;
  cout << "RE x " << ans[3] << endl;

  cin >> ans[0];

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <functional>
#include <iostream>
#include <string>
using namespace std;

#include <climits>
#include <iomanip>
#include <math.h>
#include <queue>
#include <vector>
using Graph = vector<vector<int>>;
const double PI = 3.14159265358979323846;

long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

// 約数をベクトル形式で返す
vector<int> vect_yakusuu(int n) {
  vector<int> ret;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

int main() {

  long long N;
  string S[10100];
  int ans[5];

  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> S[i];
  }

  for (int i = 0; i < 4; i++) {
    ans[i] = 0;
  }

  for (int i = 0; i < N; i++) {
    if (S[i] == "AC") {
      ans[0]++;
    }
    if (S[i] == "WA") {
      ans[1]++;
    }
    if (S[i] == "TLE") {
      ans[2]++;
    }
    if (S[i] == "RE") {
      ans[3]++;
    }
  }

  cout << "AC x " << ans[0] << endl;
  cout << "WA x " << ans[1] << endl;
  cout << "TLE x " << ans[2] << endl;
  cout << "RE x " << ans[3] << endl;

  cin >> ans[0];

  return 0;
}
Problem p02613 (C++) — buggy submission, verdict: Time Limit Exceeded

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

void change(vector<string> &st, int n) {
  int a = 0, w = 0, t = 0, r = 0;
  for (int i = 0; i < n; i++) {
    if (st[i] == "AC") {
      a++;
    } else if (st[i] == "WA") {
      w++;
    } else if (st[i] == "TLE") {
      t++;
    } else if (st[i] == "RE") {
      r++;
    }
  }
  cout << "AC x " << a << endl;
  cout << "WA x " << w << endl;
  cout << "TLE x " << t << endl;
  cout << "RE x " << r;
}

int main() {
  int n;
  cin >> n;
  vector<string> st;
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    st.push_back(s);
  }
  change(st, n);
  // cout<<res;
}

Error: TLE

Fixed submission:

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

int change(vector<string> &st, int n) {
  int a = 0, w = 0, t = 0, r = 0;
  for (int i = 0; i < n; i++) {
    if (st[i] == "AC") {
      a++;
    }
    if (st[i] == "WA") {
      w++;
    }
    if (st[i] == "TLE") {
      t++;
    }
    if (st[i] == "RE") {
      r++;
    }
  }
  cout << "AC X " << a << endl;
  cout << "WA X " << w << endl;
  cout << "TLE X " << t << endl;
  cout << "RE X " << r;
}

int main() {
  int n;
  cin >> n;
  vector<string> st;
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    st.push_back(s);
  }
  change(st, n);
  // cout<<res;
}
Problem p02613 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int a = 0, b = 0, c = 0, d = 0, N;
  cin >> N;
  vector<string> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    if (vec.at(i) == "AC") {
      a += 1;
      continue;
    } else if (vec.at(i) == "WA") {
      b += 1;
      continue;
    } else if (vec.at(i) == "TLE") {
      c += 1;
      continue;
    } else {
      d += 1;
      continue;
    }
  }
  cout << "AC x " << a << endl;
  cout << "WA x " << b << endl;
  cout << "TLE x " << c << endl;
  cout << "RE x " << d << endl;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int a = 0, b = 0, c = 0, d = 0, N;
  cin >> N;
  vector<string> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    if (vec.at(i) == "AC") {
      a += 1;
      continue;
    } else if (vec.at(i) == "WA") {
      b += 1;
      continue;
    } else if (vec.at(i) == "TLE") {
      c += 1;
      continue;
    } else {
      d += 1;
      continue;
    }
  }
  cout << "AC x " + a << endl;
  cout << "WA x " + b << endl;
  cout << "TLE x " + c << endl;
  cout << "RE x " + d << endl;
}
Problem p02613 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> a(4);

  for (int i = 0; i < N; i++) {
    string tmp;
    cin >> tmp;
    if (tmp == "AC") {
      a[0]++;
    } else if (tmp == "WA") {
      a[1]++;

    } else if (tmp == "TLE") {
      a[2]++;

    } else {
      a[3]++;
    }
  }

  cout << "AC x " << a[0] << endl;
  cout << "WA x " << a[1] << endl;
  cout << "TLE x " << a[2] << endl;
  cout << "RE x " << a[3] << endl;

  return 0;
}


Error: WA

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main(void) {
  int i, n, w = 0, x = 0, y = 0, z = 0;
  string a = "AC";
  string b = "WA";
  string c = "TLE";
  string d = "RE";
  string word[1000];
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> word[i];
  }
  for (i = 0; i < n; i++) {
    if (a == (word[i])) {
      w++;
    } else if (b == (word[i])) {
      x++;
    } else if (c == (word[i])) {
      y++;
    } else if (d == (word[i])) {
      z++;
    }
  }
  cout << "AC "
       << " x " << w << "\\n"
       << "WA "
       << " x " << x << "\\n"
       << "TLE "
       << " x " << y << "\\n"
       << "RE "
       << " x " << z << "\\n";
  return 0;
}
Problem p02613 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n;
  cin >> n;
  map<string, int> cnt;
  rep(i, n) {
    string s;
    cin >> s;
    cnt[s]++;
  }
  for (string s : {"AC", "WA", "TLE", "RE"}) {
    cout << s << " x " << cnt[s] << endl;
  }
  return 0;
}

Error: -6
terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string: construction from null is not valid


Fixed submission:

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

int main() {
  int n;
  cin >> n;
  map<string, int> a;
  rep(i, n) {
    string s;
    cin >> s;
    a[s]++;
  }
  for (string s : {"AC", "WA", "TLE", "RE"}) {
    cout << s << " × " << a[0] << endl;
  }
  return 0;
}
Problem p02613 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int N;
  cin >> N;
  vector<string> result(N);
  for (int i = 0; i < N; i++) {
    cin >> result.at(i);
  }
  int a, b, c, d;
  a = 0;
  b = 0;
  c = 0;
  d = 0;
  for (int i = 0; i < N; i++) {
    if (result.at(i) == "AC") {
      a++;
    } else if (result.at(i) == "WA") {
      b++;
    } else if (result.at(i) == "TLE") {
      c++;
    } else {
      d++;
    }
  }
  cout << "AC x " << a << endl;
  cout << "WA x " << b << endl;
  cout << "TLE x " << c << endl;
  cout << "RE x " << d << endl;
}


Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)


Fixed submission:

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

int main() {
  int N;
  cin >> N;
  vector<string> result;
  for (int i = 0; i < N; i++) {
    cin >> result.at(i);
  }
  int a, b, c, d;
  a = 0;
  b = 0;
  c = 0;
  d = 0;
  for (int i = 0; i < N; i++) {
    if (result.at(i) == "AC") {
      a++;
    } else if (result.at(i) == "WA") {
      b++;
    } else if (result.at(i) == "TLE") {
      c++;
    } else {
      d++;
    }
  }
  cout << "AC x " << a << endl;
  cout << "WA x " << b << endl;
  cout << "TLE x " << c << endl;
  cout << "RE x " << d << endl;
}
Problem p02613 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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

  int n, i, ac = 0, tle = 0, re = 0, wa = 0;
  cin >> n;
  vector<string> a(n);

  for (i = 0; i < n; i++) {
    cin >> a[i];

    if (a[i].compare("AC") == 0)
      ac++;

    else if (a[i].compare("TLE") == 0)
      tle++;

    else if (a[i].compare("RE") == 0)
      re++;

    else if (a[i].compare("WA") == 0)
      wa++;
  }

  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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

  int n, i, ac, tle, re, wa;
  cin >> n;
  vector<string> a(n);

  for (i = 0; i < n; i++) {
    cin >> a[i];

    ac = count(a.begin(), a.end(), "AC");
    tle = count(a.begin(), a.end(), "TLE");
    re = count(a.begin(), a.end(), "RE");
    wa = count(a.begin(), a.end(), "WA");
  }

  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;

  return 0;
}
Problem p02613 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int ac, wa, tle, re;
  ac = wa = tle = re = 0;
  int N;
  cin >> N;

  for (int i = 0; i < N; i++) {
    string str;
    cin >> str;
    if (str == "AC") {
      ac++;
    } else if (str == "WA") {
      wa++;
    } else if (str == "TLE") {
      tle++;
    } else if (str == "RE") {
      re++;
    }
  }

  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re;
}

Error: -11

Fixed submission:

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

int main() {
  int AC, WA, TLE, RE;
  int N;
  cin >> N;

  for (int i = 0; i < N; i++) {
    string str;
    cin >> str;
    if (str == "AC") {
      AC++;
    } else if (str == "WA") {
      WA++;
    } else if (str == "TLE") {
      TLE++;
    } else if (str == "RE") {
      RE++;
    }
  }

  cout << "AC x " + AC << endl;
  cout << "WA x " + WA << endl;
  cout << "TLE x " + TLE << endl;
  cout << "RE x " + RE << endl;
}
Problem p02613 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {

  int c1 = 0, c2 = 0, c3 = 0, c4 = 0, n;
  cin >> n;
  string ch;
  for (int i = 0; i < n; i++) {
    cin >> ch;
    if (ch == "AC")
      c1++;
    else if (ch == "WA")
      c2++;
    else if (ch == "TLE")
      c3++;
    else if (ch == "RE")
      c4++;
  }
  cout << "AC x " << c1 << endl;
  cout << "WA x " << c2 << endl;
  cout << "TLE x " << c3 << endl;
  cout << "RE x " << c4 << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int c1 = 0, c2 = 0, c3 = 0, c4 = 0, n;
  cin >> n;
  string ch;
  while (n != 0) {
    cin >> ch;
    if (ch == "AC")
      c1++;
    else if (ch == "WA")
      c2++;
    else if (ch == "TLE")
      c3++;
    else
      c4++;
  }
  cout << "AC"
       << " " << 'x' << " " << c1 << endl;
  cout << "WA"
       << " " << 'x' << " " << c2 << endl;
  cout << "TLE"
       << " " << 'x' << " " << c3 << endl;
  cout << "RE"
       << " " << 'x' << " " << c4 << endl;
  return 0;
}
Problem p02613 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define V(i) vector<i>
#define rep(i, n) for (__typeof(n) i = 0; i < n; i++)
#define crep(i, N, n) for (__typeof(n) i = N; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define P(i, j) pair<i, j>
#define MP make_pair
#define MOD 1000000007
typedef long long ll;
typedef long l;
#define fio                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL)
int main() {
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  ll n;
  cin >> n;
  map<string, ll> mp;
  rep(i, n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  cout << "AC x " << mp["AC"] << "\\n";
  cout << "WA x " << mp["WA"] << "\\n";
  cout << "TLE x " << mp["TLE"] << "\\n";
  cout << "RE x " << mp["RE"] << "\\n";

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define V(i) vector<i>
#define rep(i, n) for (__typeof(n) i = 0; i < n; i++)
#define crep(i, N, n) for (__typeof(n) i = N; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define P(i, j) pair<i, j>
#define MP make_pair
#define MOD 1000000007
typedef long long ll;
typedef long l;
#define fio                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL)
int main() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  ll n;
  cin >> n;
  map<string, ll> mp;
  rep(i, n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  cout << "AC x " << mp["AC"] << "\\n";
  cout << "WA x " << mp["WA"] << "\\n";
  cout << "TLE x " << mp["TLE"] << "\\n";
  cout << "RE x " << mp["RE"] << "\\n";

  return 0;
}
Problem p02613 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  string str[N];
  for (int i = 0; i < N; i++) {
    cin >> str[i];
  }
  int AC = 0;
  int WA = 0;
  int TLE = 0;
  int RE = 0;
  for (int i = 0; i < N; i++) {
    if (str[i] == "AC") {
      AC++;
    }
    if (str[i] == "WA") {
      WA++;
    }
    if (str[i] == "TLE") {
      TLE++;
    }
    if (str[i] == "RE") {
      RE++;
    }
  }
  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;
  return 0;
}


Error: -11

Fixed submission:

#include <iostream>
#include <string.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  string str[N];
  for (int i = 0; i < N; i++) {
    cin >> str[N];
  }
  int AC = 0;
  int WA = 0;
  int TLE = 0;
  int RE = 0;
  for (int i = 0; i < N; i++) {
    if (str[i] == "AC") {
      AC++;
    }
    if (str[i] == "WA") {
      WA++;
    }
    if (str[i] == "TLE") {
      TLE++;
    }
    if (str[i] == "RE") {
      RE++;
    }
  }
  cout << "AC × " << AC << endl;
  cout << "WA × " << WA << endl;
  cout << "TLE × " << TLE << endl;
  cout << "RE × " << RE << endl;
  return 0;
}
Problem p02613 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define FASTIO                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);
using namespace std;
using ii = pair<int, int>;
using ll = long long int;

int a, b, c, d;

int main() {
  FASTIO;
  int T;
  cin >> T;
  while (T--) {
    string s;
    cin >> s;
    if (s == "AC")
      a++;
    else if (s == "WA")
      b++;
    else if (s == "TLE")
      c++;
    else
      d++;
  }

  cout << "AC x " << a << endl;
  cout << "WA x " << b << endl;
  cout << "TLE x " << c << endl;
  cout << "RE x " << d << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define FASTIO                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);
using namespace std;
using ii = pair<int, int>;
using ll = long long int;

int a, b, c, d;

int main() {
  FASTIO;
  int T;
  cin >> T;
  while (1) {
    string s;
    cin >> s;
    if (s == "AC")
      a++;
    else if (s == "WA")
      b++;
    else if (s == "TLE")
      c++;
    else
      d++;
  }

  cout << "AC x " << a << endl;
  cout << "WA x " << b << endl;
  cout << "TLE x " << c << endl;
  cout << "RE x " << d << endl;
  return 0;
}
Problem p02613 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<string> s;
  string s1;
  int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  for (int i = 0; i < n; i++) {
    cin >> s1;
    s.push_back(s1);
    if (s[i] == "AC")
      c1++;
    else if (s[i] == "WA")
      c2++;
    else if (s[i] == "TLE")
      c3++;
    else if (s[i] == "RE")
      c4++;
  }
  cout << "AC x " << c1 << endl;
  cout << "WA x " << c2 << endl;
  cout << "TLE x " << c3 << endl;
  cout << "RE x " << c4;
  return (0);
}


Error: -11

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n;
  vector<string> s;
  cin >> n;
  int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    if (s[i] == "AC")
      c1++;
    else if (s[i] == "WA")
      c2++;
    else if (s[i] == "TLE")
      c3++;
    else if (s[i] == "RE")
      c4++;
  }
  cout << "AC x " << c1 << endl;
  cout << "WA x " << c2 << endl;
  cout << "TLE x " << c3 << endl;
  cout << "RE x " << c4;
  return (0);
}
Problem p02613 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int N;
  cin >> N;

  int ac = 0, wa = 0, tle = 0, re = 0;

  vector<string> S(N);
  for (auto &x : S) {
    cin >> x;
    if (x == "AC") {
      ac++;
    } else if (x == "WA") {
      wa++;
    } else if (x == "TLE") {
      tle++;
    } else {
      re++;
    }
  }

  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;

  return 0;
}

Error: -11

Fixed submission:

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

int main() {
  int N;
  cin >> N;

  int AC, WA, TLE, RE = 0;

  vector<char *> S(N);
  for (auto &x : S) {
    cin >> x;
  }

  for (const auto &x : S) {
    if (strncmp(x, "AC", 2)) {
      AC++;
    } else if (strncmp(x, "WA", 2)) {
      WA++;
    } else if (strncmp(x, "TLE", 3)) {
      TLE++;
    } else {
      RE++;
    }
  }

  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;
}
Problem p02613 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int main() {
  int N, verdict[4] = {0}; // AC, WA, TLE, RE
  scanf("%d", &N);

  for (int i = 0; i < N; i++) {
    char str[5];
    scanf("%s", str);
    switch (str[0]) {
    case 'A':
      verdict[0]++;
      break;
    case 'W':
      verdict[1]++;
      break;
    case 'T':
      verdict[2]++;
      break;
    case 'R':
      verdict[3]++;
      break;
    }
  }

  printf("AC x %d\\n", verdict[0]);
  printf("WA x %d\\n", verdict[1]);
  printf("TLE x %d\\n", verdict[2]);
  printf("RE x %d\\n", verdict[3]);
  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  string s;
  int i, N, first = 0, sec = 0, third = 0, fourth = 0;
  cin >> N;
  for (i = 0; i < N * 2; i++) {
    cin >> s[i];
    if (s[i] == 'C')
      first++;
    else if (s[i] == 'T')
      sec++;
    else if (s[i] == 'W')
      third++;
    else if (s[i] == 'R')
      fourth++;
  }

  cout << "AC x " << first << endl;

  cout << "WA x " << third << endl;
  cout << "TLE x " << sec << endl;
  cout << "RE x " << fourth;

  return 0;
}
Problem p02613 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
#include <string.h>
int main() {
  int N;
  int x;
  char S[255];
  scanf("%d", &N);
  int ctr[8] = {0};
  for (int i = 0; i < N; i++) {
    scanf("%s", &S);
    if (x = strcmp(S, "AC") == 0) {
      ++ctr[1];
    }
    if (x = strcmp(S, "WA") == 0) {
      ++ctr[2];
    }
    if (x = strcmp(S, "TLE") == 0) {
      ++ctr[3];
    }
    if (x = strcmp(S, "RE") == 0) {
      ++ctr[4];
    }
  }
  printf("AC x %d\\n", ctr[1]);
  printf("WA x %d\\n", ctr[2]);
  printf("TLE x %d\\n", ctr[3]);
  printf("RE x %d\\n", ctr[4]);
  return 0;
}

Error: WA

Fixed submission:

#include <stdio.h>
int main() {
  // N test cases
  // each case, theres a string for the verdict of it
  // find the values of AC, WA, TLE, and RE
  // 1<N<1e5
  int n;
  scanf("%d", &n);
  char str[n];

  int AC = 0;
  int WA = 0;
  int TLE = 0;
  int RE = 0;

  for (int i = 0; i < n; i++) {
    scanf("%s", str[i]);
    switch (str[i]) {
    case 'AC':
      AC++;
      break;
    case 'WA':
      WA++;
      break;
    case 'TLE':
      TLE++;
      break;
    case 'RE':
      RE++;
      break;
    }
  }
  printf("AC x %d\\n", AC);
  printf("WA x %d\\n", WA);
  printf("TLE x %d\\n", TLE);
  printf("RE x %d\\n", RE);

  return 0;
}