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

#include <iostream>
#include <string>
using namespace std;
string arr[1000000];
int main() {

  int n;
  cin >> n;

  int count1 = 0;
  int count2 = 0;
  int count3 = 0;
  int count4 = 0;

  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  for (int i = 1; i <= n; i++) {
    if (arr[i] == "AC") {
      count1++;
    } else if (arr[i] == "WA") {
      count2++;
    } else if (arr[i] == "TLE") {
      count3++;
    } else if (arr[i] == "RE") {
      count4++;
    }
  }
  if (count1 != 0) {
    cout << "AC"
         << " "
         << "x"
         << " " << count1 << endl;
  } else if (count1 == 0) {
    cout << "AC"
         << " "
         << "x"
         << " " << count1 << endl;
  }
  if (count2 != 0) {
    cout << "WA"
         << " "
         << "x"
         << " " << count2 << endl;
  } else if (count2 == 0) {
    cout << "WA"
         << " "
         << "x"
         << " " << count2 << endl;
  }
  if (count3 != 0) {
    cout << "TLE"
         << " "
         << "x"
         << " " << count3 << endl;
  } else if (count3 == 0) {
    cout << "TLE"
         << " "
         << "x"
         << " " << count3 << endl;
  }
  if (count4 != 0) {
    cout << "RE"
         << " "
         << "x"
         << " " << count4 << endl;
  } else if (count4 == 0) {
    cout << "RE"
         << " "
         << "x"
         << " " << count4 << endl;
  }
  system("pause");
  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  string arr[1000];
  int n;
  cin >> n;
  int count1 = 0;
  int count2 = 0;
  int count3 = 0;
  int count4 = 0;

  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  for (int i = 1; i <= n; i++) {
    if (arr[i] == "AC") {
      count1++;
    } else if (arr[i] == "WA") {
      count2++;
    } else if (arr[i] == "TLE") {
      count3++;
    } else if (arr[i] == "RE") {
      count4++;
    }
  }
  if (count1 != 0) {
    cout << "AC"
         << " "
         << "*"
         << " " << count1 << endl;
  } else if (count1 == 0) {
    cout << "AC"
         << " "
         << "*"
         << " " << count1 << endl;
  }
  if (count2 != 0) {
    cout << "WA"
         << " "
         << "*"
         << " " << count2 << endl;
  } else if (count2 == 0) {
    cout << "WA"
         << " "
         << "*"
         << " " << count2 << endl;
  }
  if (count3 != 0) {
    cout << "TLE"
         << " "
         << "*"
         << " " << count3 << endl;
  } else if (count3 == 0) {
    cout << "TLE"
         << " "
         << "*"
         << " " << count3 << endl;
  }
  if (count4 != 0) {
    cout << "RE"
         << " "
         << "*"
         << " " << count4 << endl;
  } else if (count4 == 0) {
    cout << "RE"
         << " "
         << "*"
         << " " << count4 << endl;
  }
}
Problem p02613 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
#include <string.h>

int main() {
  char str[10];
  int A;
  int AC = 0;
  int WA = 0;
  int TLE = 0;
  int RE = 0;
  scanf("%d", &A);

  for (int i = 0; i < A; i++) {
    scanf("%s", str);
    if (strcmp(str, "AC") == 0) {
      AC++;
    } else if (strcmp(str, "WA") == 0) {
      WA++;
    } else if (strcmp(str, "TLE") == 0) {
      TLE++;
    } else if (strcmp(str, "RE") == 0) {
      RE++;
    }
  }

  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;
}

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[0]) { // biar dia bacanya chara pertama aja
    case 'A':         // switch cmn bisa 1 chara ya casenya
      AC++;
      break;
    case 'W':
      WA++;
      break;
    case 'T':
      TLE++;
      break;
    case 'R':
      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;
}
Problem p02613 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
int main() {
  int AC = 0;
  int WA = 0;
  int TLE = 0;
  int RE = 0;
  int batas;
  scanf("%d", &batas);
  for (int i = 0; i < batas; i++) {
    char string[6] = "";
    scanf("%s", &string);
    if (string[0] == 'A')
      AC++;
    else if (string[0] == 'W')
      WA++;
    else if (string[0] == 'T')
      TLE++;
    else if (string[0] == 'R')
      RE++;
  }
  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;
}

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 <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const long long INF = 1LL << 60;

int N;
string S;
int main() {
  cin >> N;
  vector<int> C(4);
  rep(i, N) {
    cin >> S;
    if (S == "AC")
      C[0]++;
    else if (S == "WA")
      C[1]++;
    else if (S == "TLE")
      C[2]++;
    else
      C[3]++;
  }

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

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const long long INF = 1LL << 60;

int N;
vector<string> S(N + 10);

int main() {
  cin >> N;
  rep(i, N) cin >> S[i];

  vector<int> C(4);

  sort(S.begin(), S.end());

  rep(i, N) {
    if (S[i] == "AC")
      C[0]++;
    else if (S[i] == "WA")
      C[1]++;
    else if (S[i] == "TLE")
      C[2]++;
    else
      C[3]++;
  }
  cout << "AC"
       << " "
       << "x"
       << " " << C[0] << endl;
  cout << "WA"
       << " "
       << "x"
       << " " << C[1] << endl;
  cout << "TLE"
       << " "
       << "x"
       << " " << C[2] << endl;
  cout << "RE"
       << " "
       << "x"
       << " " << C[3] << endl;
}
Problem p02613 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> ans(4);

  rep(i, n) { cin >> s.at(i); }
  rep(i, n) {
    if (s.at(i) == "AC") {
      ans.at(0)++;
    } else if (s.at(i) == "WA") {
      ans.at(1)++;
    } else if (s.at(i) == "TLE") {
      ans.at(2)++;
    } else if (s.at(i) == "RE") {
      ans.at(3)++;
    }
  }

  cout << "AC x " << ans.at(0) << endl;
  cout << "WA x " << ans.at(1) << endl;
  cout << "TLE x " << ans.at(2) << endl;
  cout << "RE x " << ans.at(3) << endl;

  return 0;
}

Error: -6
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc


Fixed submission:

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

int main() {
  int n;
  vector<string> s(n - 1);
  vector<int> ans(4);
  cin >> n;
  rep(i, n) { cin >> s.at(i); }
  rep(i, n) {
    if (s.at(i) == "AC") {
      ans.at(0)++;
    } else if (s.at(i) == "WA") {
      ans.at(1)++;
    } else if (s.at(i) == "TLE") {
      ans.at(2)++;
    } else if (s.at(i) == "RE") {
      ans.at(3)++;
    }
  }

  cout << "AC　x　" << ans.at(0) << endl;
  cout << "WA　x　" << ans.at(1) << endl;
  cout << "TLE　x　" << ans.at(2) << endl;
  cout << "RE　x　" << ans.at(3) << endl;

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

#include <stdio.h>

int main() {
  int N;
  int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    char msg[5];
    scanf("%s", msg);
    if (msg[0] == 'A') {
      c1++;
    } else if (msg[0] == 'W') {
      c2++;
    } else if (msg[0] == 'T') {
      c3++;
    } else {
      c4++;
    }
  }
  printf("AC x %d\\nWA x %d\\nTLE x %d\\nRE x %d\\n", c1, c2, c3, c4);
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  string ac = "AC";
  string WA = "WA";
  string TLE = "TLE";
  string RE = "RE";
  int n, a = 0, w = 0, t = 0, r = 0;
  string *ar = new string[n];
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> ar[i];
  for (int i = 0; i < n; i++) {
    if (ar[i] == "AC") {
      a++;
    } else if (ar[i] == "WA") {
      w++;
    } else if (ar[i] == "TLE") {
      t++;
    } else if (ar[i] == "RE") {
      r++;
    }
  }
  cout << ac << " "
       << "x"
       << " " << a << endl;
  cout << WA << " "
       << "x"
       << " " << w << endl;
  cout << TLE << " "
       << "x"
       << " " << t << endl;
  cout << RE << " "
       << "x"
       << " " << r << endl;
  return 0;
}
Problem p02613 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  string S;
  char s[4];
  int N;
  int C[4] = {0};
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> s;
    S = s;
    if (S == "AC")
      C[0]++;
    else if (S == "WA")
      C[1]++;
    else if (S == "TLE")
      C[2]++;
    else if (S == "RE")
      C[3]++;
  }

  cout << "AC x " << C[0] << '\\n';
  cout << "WA x " << C[1] << '\\n';
  cout << "TLE x " << C[2] << '\\n';
  cout << "RE x " << C[3] << '\\n';

  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  string S[254];
  char s[254];
  long int N;
  int C[4] = {0};
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> s;
    S[i] = s;
    if (S[i] == "AC")
      C[0]++;
    else if (S[i] == "WA")
      C[1]++;
    else if (S[i] == "TLE")
      C[2]++;
    else if (S[i] == "RE")
      C[3]++;
  }

  cout << "AC x " << C[0] << '\\n';
  cout << "WA x " << C[1] << '\\n';
  cout << "TLE x " << C[2] << '\\n';
  cout << "RE x " << C[3] << '\\n';

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

#include <bits/stdc++.h>
#define ll long long
#define endl "\\n"
#define pb push_back
#define READ(FILE) freopen(FILE, "r", stdin)
#define WRITE(FILE) freopen(FILE, "w", stdout)
#define loop(i, s, e) for (int i = s; i < e; i++)
#define mego fast();
using namespace std;
void fast() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

ll lcm(ll x, ll y) { return (x * y) / __gcd(x, y); }
int sum(string s) {
  int x = 0, sz = s.size();
  loop(i, 0, sz) x += (s[i] - '0');
  return x;
}
/*
struct node
{
int data;
node *link;
};
typedef node* nodeptr;
void head_insert(nodeptr& head,int x)
{
    nodeptr tmp;
    tmp=new node;
    tmp->data=x;
    tmp->link=head;
    head=tmp;
}
nodeptr search(nodeptr head,int x)
{
    nodeptr cur=head;
    if(cur ==  nullptr)return cur;
    while(cur->data!=x&&cur->link!=nullptr)
    {
        cur=cur->link;
    }
    if(cur->data==x)return cur;
    else return nullptr;
}
void show(nodeptr head)
{
    nodeptr cur=head;
    if(cur==nullptr)return;
   // cout<<head->data<<" ";
    while(cur->link!=nullptr){
        cout<<cur->data<<" ";
        cur=cur->link;
    }
    cout<<endl;
}
*/

int main() {
  mego int n, a = 0, b = 0, c = 0, d = 0;
  string s;
  cin >> n;
  loop(i, 0, n) {
    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;
  return 0;
}


Error: 0

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  string s[100];
  int i, n;
  int AC = 0, WA = 0, TLE = 0, RE = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> s[i];
  }
  for (i = 0; i < n; i++) {
    if (s[i] == "AC") {
      AC += 1;
    } else if (s[i] == "WA") {
      WA += 1;
    } else if (s[i] == "TLE") {
      TLE += 1;
    } else if (s[i] == "RE") {
      RE += 1;
    }
  }
  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 <iostream>
using namespace std;
int main() {
  int tc;
  cin >> tc;
  int acCount, waCount, tleCount, reCount;
  acCount = waCount = tleCount = reCount = 0;
  while (tc > 0) {
    char arr[4];
    cin >> arr;
    if (arr[0] == 'A' && arr[1] == 'C')
      acCount++;
    else if (arr[0] == 'W' && arr[1] == 'A')
      waCount++;
    else if (arr[0] == 'R' && arr[1] == 'E')
      reCount++;
    else
      tleCount++;
    tc--;
  }
  cout << "AC x " << acCount << "\\n";
  cout << "WA x " << waCount << "\\n";
  cout << "TLE x " << tleCount << "\\n";
  cout << "RE x " << reCount << "\\n";
  return 0;
}


Error: WA

Fixed submission:

#include <iostream>

using namespace std;
int main() {
  int n, m = 0, e = 0, b = 0, d = 0;
  string a[100];
  cin >> n;

  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }

  for (int i = 1; i <= n; i++) {
    if (a[i] == "AC") {
      m++;
    } else if (a[i] == "TLE") {
      e++;
    } else if (a[i] == "WA") {
      b++;
    } else {
      d++;
    }
  }
  cout << "AC"
       << "x" << m << endl;
  cout << "WA"
       << "x" << b << endl;
  cout << "TLE"
       << "x" << e << endl;
  cout << "RE"
       << "x" << d << endl;

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

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  cin >> n;
  string s;
  int arr[4] = {0};
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (s == "AC")
      arr[0]++;
    else if (s == "WA")
      arr[1]++;
    else if (s == "TLE")
      arr[2]++;
    else
      arr[3]++;
  }
  cout << "AC x " << arr[0] << "\\n";
  cout << "WA x " << arr[1] << "\\n";
  cout << "TLE x " << arr[2] << "\\n";
  cout << "RE x " << arr[3];

  return 0;
}


Error: WA

Fixed submission:

#include <iostream>

using namespace std;
int main() {
  int n, m = 0, e = 0, b = 0, d = 0;
  string a[100];
  cin >> n;

  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }

  for (int i = 1; i <= n; i++) {
    if (a[i] == "AC") {
      m++;
    } else if (a[i] == "TLE") {
      e++;
    } else if (a[i] == "WA") {
      b++;
    } else {
      d++;
    }
  }
  cout << "AC x"
       << "" << m << endl;
  cout << "WA x"
       << "" << b << endl;
  cout << "TLE x"
       << "" << e << endl;
  cout << "RE x "
       << "" << d << endl;

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

#include <algorithm>
#include <iostream>
#include <math.h>

using namespace std;

int main() {
  string S;
  int N, c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> S;
    if (S == "AC")
      c1++;
    if (S == "WA")
      c2++;
    if (S == "TLE")
      c3++;
    if (S == "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: 0

Fixed submission:

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

int main() {
  int num, accounter = 0, wacounter = 0, tlecounter = 0, recounter = 0;
  cin >> num;
  string arr[100];
  for (int i = 0; i < num; i++) {
    cin >> arr[i];
    if (arr[i] == "AC")
      accounter++;
    else if (arr[i] == "WA")
      wacounter++;
    else if (arr[i] == "TLE")
      tlecounter++;
    else
      recounter++;
  }
  cout << "AC"
       << " "
       << "x " << accounter << endl;
  cout << "WA"
       << " "
       << "x " << wacounter << endl;
  cout << "TLE"
       << " "
       << "x " << tlecounter << endl;
  cout << "RE"
       << " "
       << "x " << recounter << endl;

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

#include <stdio.h>

int main() {
  int n, ac = 0, wa = 0, tle = 0, re = 0;
  char stat[100];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", stat);
    if (stat[1] == 'C') {
      ac++;
    } else if (stat[1] == 'A') {
      wa++;
    } else if (stat[1] == 'L') {
      tle++;
    } else if (stat[1] == 'E') {
      re++;
    }
  }
  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;
}


Error: WA

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  string arr[20];
  int countAC = 0, countTLE = 0, countWA = 0, countRE = 0;
  int num;
  cin >> num;
  for (int i = 0; i < num; i++) {
    cin >> arr[i];
    if (arr[i] == "AC")
      countAC++;
    else if (arr[i] == "TLE")
      countTLE++;
    else if (arr[i] == "WA")
      countWA++;
    else if (arr[i] == "RE")
      countRE++;
  }
  cout << "\\nAC X " << countAC;
  cout << "\\n WA X " << countWA;
  cout << "\\n TLE X " << countTLE;
  cout << "\\n RE x " << countRE;
  return 0;
}
Problem p02613 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <iostream>
#include <string>
using namespace std;
int main() {
  string arr[100000];
  int countAC = 0, countTLE = 0, countWA = 0, countRE = 0;
  int num;
  cin >> num;
  for (int i = 0; i < num; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < num; i++) {
    if (arr[i] == "AC")
      countAC++;
    else if (arr[i] == "TLE")
      countTLE++;
    else if (arr[i] == "WA")
      countWA++;
    else if (arr[i] == "RE")
      countRE++;
  }
  cout << "\\nAC"
       << " "
       << "x"
       << " " << countAC;
  cout << "\\nWA"
       << " "
       << "x"
       << " " << countWA;
  cout << "\\nTLE"
       << " "
       << "x"
       << " " << countTLE;
  cout << "\\n RE "
       << " "
       << "x"
       << " " << countRE;
  return 0;
}

Error: WA

Fixed submission:

#include <stdio.h>
int main() {
  int n;
  int AC = 0;
  int WA = 0;
  int TLE = 0;
  int RE = 0;
  char kata[12];

  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    scanf("%s", &kata[i]);
    for (int i = 0; i < n; i++) {

      if (kata[i] == 'A') {
        AC++;
        continue;
      } else if (kata[i] == 'W') {
        WA++;
        continue;
      } else if (kata[i] == 'T') {
        TLE++;
        continue;
      } else if (kata[i] == 'R') {
        RE++;
        continue;
      }
    }
  }
  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;
}
Problem p02613 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int main() {
  int N;
  int AC = 0, WA = 0, TLE = 0, RE = 0;
  char S[5];
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%s", &S);
    if (S[0] == 'A') {
      AC++;
    } else if (S[0] == 'W') {
      WA++;
    } else if (S[0] == 'T') {
      TLE++;
    } else if (S[0] == 'R') {
      RE++;
    }
  }
  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;
}

Error: -6
*** stack smashing detected ***: terminated


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[5];

  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[0]) { // biar dia bacanya chara pertama aja
    case 'A':         // switch cmn bisa 1 chara ya casenya
      AC++;
      break;
    case 'W':
      WA++;
      break;
    case 'T':
      TLE++;
      break;
    case 'R':
      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;
}
Problem p02613 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
#include <string.h>

int main() {
  int N;
  char tmp;
  scanf("%d%c", &N, &tmp);

  int ac = 0, wa = 0, tle = 0, re = 0;
  char s[5];
  for (int i = 0; i < N; i++) {
    fgets(s, 5, stdin);
    if (!strcmp(s, "AC\\n"))
      ac++;
    if (!strcmp(s, "WA\\n"))
      wa++;
    if (!strcmp(s, "TLE\\n"))
      tle++;
    if (!strcmp(s, "RE\\n"))
      re++;
  }

  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;
}

Error: -11

Fixed submission:

#include <stdio.h>
#include <string.h>

int main() {
  int N;
  char tmp;
  scanf("%d%c", &N, &tmp);

  int ac = 0, wa = 0, tle = 0, re = 0;
  char *s;
  for (int i = 0; i < N; i++) {
    fgets(s, 5, stdin);
    if (!strcmp(s, "AC\\n"))
      ac++;
    if (!strcmp(s, "WA\\n"))
      wa++;
    if (!strcmp(s, "TLE\\n"))
      tle++;
    if (!strcmp(s, "RE\\n"))
      re++;
  }

  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;
}
Problem p02613 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int N;
  cin >> N;
  string S;
  int A = 0, W = 0, T = 0, R = 0;
  for (int i = 0; i < N; i++) {
    cin >> S;
    if (S == "AC")
      A++;
    else if (S == "WA")
      W++;
    else if (S == "TLE")
      T++;
    else if (S == "RE")
      R++;
  }
  cout << "AC x " << A << endl;
  cout << "WA x " << W << endl;
  cout << "TLE x " << T << endl;
  cout << "RE x " << R << endl;
}


Error: WA

Fixed submission:

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

int main() {
  int N;
  cin >> N;
  string S;
  int A = 0, W = 0, T = 0, R = 0;
  for (int i = 0; i < N; i++) {
    cin >> S;
    if (S == "AC")
      A++;
    else if (S == "WA")
      W++;
    else if (S == "TLE")
      T++;
    else if (S == "RE")
      R++;
  }
  cout << "AC x " + A << endl;
  cout << "WA x " + W << endl;
  cout << "TLE x " + T << endl;
  cout << "RE x " + R << endl;
}
Problem p02613 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
#include <string.h>
int main() {
  int n;
  int AC = 0;
  int WA = 0;
  int TLE = 0;
  int RE = 0;
  char kata[100];

  scanf("%d", &n);
  while (n--) {

    scanf("%s", &kata);
    if (kata[0] == 'A') {
      AC++;
    } else if (kata[0] == 'W') {
      WA++;
    } else if (kata[0] == 'T') {
      TLE++;
    } else if (kata[0] == 'R') {
      RE++;
    }
  }
  //	for(int i=0;i<n;i++){
  //		scanf("%s", &kata[i]);
  //	for(int i=0;i<n;i++){
  //
  //		if(kata[i]=='A'&&kata[i+1]=='C'){
  //			AC++;
  //			continue;
  //		}else if(kata[i]=='W'&&kata[i+1]=='A'){
  //			WA++;
  //			continue;
  //		}else if(kata[i]=='T'&&kata[i+1]=='L'&&kata[i+2]=='E'){
  //			TLE++;
  //			continue;
  //		}else if(kata[i]=='R'&&kata[i+1]=='E'){
  //			RE++;
  //			continue;
  //		}
  // }
  //	}
  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;
}

Error: 0

Fixed submission:

#include <stdio.h>
#include <string.h>

int main() {
  long long N;
  int AC = 0, WA = 0, TLE = 0, RE = 0;
  scanf("%lld", &N);
  char a[50][N];
  for (int i = 0; i < N; i++) {
    scanf("%s", &a[i]);
    if (strcmp(a[i], "AC") == 0) {
      AC++;
    }
    if (strcmp(a[i], "WA") == 0) {
      WA++;
    }
    if (strcmp(a[i], "TLE") == 0) {
      TLE++;
    }
    if (strcmp(a[i], "RE") == 0) {
      RE++;
    }
  }
  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;
}