alexjercan/bugnet huggingface dataset:
Problem p00047 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  char cur = 'A';
  char x, y;
  while (scanf("%c,%c ", &x, &y) == 2) {
    if (x == cur) {
      cur = y;
    } else if (y == cur) {
      cur = x;
    }
  }
  printf("%c\\n", cur);
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  char cur = 'A';
  char x, y;
  while (scanf("%c,%c ", &x, &y)) {
    if (x == cur) {
      cur = x;
    } else if (y == cur) {
      cur = y;
    }
  }
  printf("%c\\n", cur);
}
Problem p00047 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  char ans = 'A', ch[3];
  while (cin >> ch)
    if (ch[0] == ans || ch[2] == ans)
      ans = (ch[0] == ans ? ch[2] : ch[0]);
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int x, y, is[3] = {1, 0, 0};
  while (!scanf("%d,%d", &x, &y)) {
    if (is[(int)(x - 'A')]) {
      is[(int)(x - 'A')] = 0;
      is[(int)(y - 'A')] = 1;
    } else if (is[y - 'A']) {
      is[(int)(y - 'A')] = 0;
      is[(int)(x - 'A')] = 1;
    }
  }
  for (int i = 0; i < 3; i++)
    if (is[i])
      cout << (char)(i + 'A') << endl;
}
Problem p00047 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main() {
  int cup[3] = {1, 0, 0}, temp = 0, count = 0;
  char cup_str[5] = "ABC,";
  char cup1, cup2, cup3;

  while (1) {
    cin >> cup1 >> cup2 >> cup3;

    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        if (cup1 == cup_str[j] && cup3 == cup_str[i]) {
          temp = cup[j];
          cup[j] = cup[i];
          cup[i] = temp;
        }
      }
    }

    count++;
    if (count == 50)
      break;
  }

  for (int i = 0; i < 3; i++) {
    if (cup[i] == 1)
      cout << cup_str[i] << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int cup[3] = {1, 0, 0}, temp = 0, count = 0;
  char cup_str[5] = "ABC,";
  char cup1, cup2, cup3;

  while (1) {
    cin >> cup1 >> cup2 >> cup3;

    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        if (cup1 == cup_str[j] && cup3 == cup_str[i]) {
          temp = cup[j];
          cup[j] = cup[i];
          cup[i] = temp;
        }
      }
    }

    for (int i = 0; i < 3; i++) {
      if (cup[i] == 1)
        cout << cup_str[i] << endl;
    }
  }

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

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

int main() {
  char A, B, C;
  char D;
  while (1) {
    cin >> A >> D >> B;
    if (A == 'A') {
      C = B;
    } else if (B == 'A') {
      C = A;
    }
    if (C == 'B' || C == 'C') {
      break;
    }
  }
  while (cin >> A >> D >> B) {
    if (A == C) {
      C = B;
    } else if (B == C) {
      C = A;
    }
  }
  cout << C << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  string A, B, C;
  while (1) {
    cin >> A >> B;
    if (A == "A") {
      C = B;
    } else if (B == "A") {
      C = A;
    }
    if (C == "B" && C == "C")
      break;
  }
  while (1) {
    cin >> A >> B;
    if (A == C) {
      C = B;
    } else if (B == C) {
      C = A;
    }
  }
  cout << C << endl;
  return 0;
}
Problem p00047 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
using namespace std;
int main() {
  int a[3] = {1, 0, 0};
  unsigned char c1, c2;
  while (scanf("%c,%c", &c1, &c2) != EOF) {
    swap(a[c1 - 'A'], a[c2 - 'A']);
  }
  printf("%c\\n", a[0] * 'A' + a[1] * 'B' + a[2] * 'C');
}

Error: WA

Fixed submission:

#include <cstdio>
#include <iostream>

using namespace std;

int main() {

  int t, x[64];
  char i, j;

  x[0] = 1;
  x[1] = 0;
  x[2] = 0;

  while (scanf("%s %s", &i, &j) != EOF) {
    if (i == 'A' && j == 'B' || i == 'B' && j == 'A') {
      t = x[0];
      x[0] = x[1];
      x[1] = t;
    } else if (i == 'B' && j == 'C' || i == 'C' && j == 'B') {
      t = x[1];
      x[1] = x[2];
      x[2] = t;
    } else if (i == 'C' && j == 'A' || i == 'A' && j == 'C') {
      t = x[2];
      x[2] = x[0];
      x[0] = t;
    }
  }

  if (x[0] == 1)
    cout << "A" << endl;
  else if (x[1] == 1)
    cout << "B" << endl;
  else
    cout << "C" << endl;

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

#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int cup[3] = {1};
  char x, y;
  while (scanf(" %c", &x) != EOF) {
    scanf(",%c", &y);
    swap(cup[x - 'A'], cup[y - 'A']);
  }
  for (int i = 0; i < 3; i++) {
    if (cup[i] > 0) {
      printf("%c\\n", 'A' + i);
      break;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int cup[3] = {1};
  int x, y;
  while (scanf(" %d,%d", &x, &y) != EOF) {
    swap(cup[x - 'A'], cup[y - 'A']);
  }
  for (int i = 0; i < 3; i++) {
    if (cup[i] > 0) {
      printf("%c\\n", 'A' + i);
      break;
    }
  }
  return 0;
}
Problem p00048 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  double w;
  while (cin >> w) {
    if (w <= 48.0)
      cout << "light fly";
    else if (w <= 51.0)
      cout << "fly";
    else if (w <= 54.0)
      cout << "bantam";
    else if (w <= 57.0)
      cout << "feather";
    else if (w <= 60.0)
      cout << "light";
    else if (w <= 64.0)
      cout << "light welter";
    else if (w <= 69.0)
      cout << "welter";
    else if (w <= 75.0)
      cout << "light middle";
    else if (w <= 81.0)
      cout << "middle";
    else if (w <= 91.0)
      cout << "light heavy";
    else
      cout << "heavy";

    cout << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  double w;
  while (scanf("%d", &w) != EOF) {
    if (w <= 48.0)
      cout << "light fly";
    else if (w <= 51.0)
      cout << "fly";
    else if (w <= 54.0)
      cout << "bantam";
    else if (w <= 57.0)
      cout << "feather";
    else if (w <= 60.0)
      cout << "light";
    else if (w <= 64.0)
      cout << "light welter";
    else if (w <= 69.0)
      cout << "welter";
    else if (w <= 75.0)
      cout << "lihgt middle";
    else if (w <= 81.0)
      cout << "middle";
    else if (w <= 91.0)
      cout << "light heavy";
    else
      cout << "heavy";

    cout << endl;
  }

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

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

const string cls[] = {"",
                      "light fly",
                      "fly",
                      "bantam",
                      "feather",
                      "light",
                      "light welter",
                      "welter",
                      "light middle",
                      "middle",
                      "light heavy",
                      "heavy"};

const int a[] = {-100, 48, 51, 54, 57, 60, 64, 69, 75, 81, 91, 100000000};

int main() {
  double w;
  while (cin >> w) {
    int i = 0;
    while (w > a[i])
      i++;
    cout << cls[i] << endl;
  }
}

Error: 0

Fixed submission:

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

const string cls[] = {"",
                      "light fly",
                      "fly",
                      "bantam",
                      "feather",
                      "light",
                      "light welter",
                      "welter",
                      "light middle",
                      "middle",
                      "light heavy",
                      "heavy"};

const int a[] = {-100, 48, 51, 54, 57, 60, 64, 69, 75, 81, 91};

int main() {
  double w;
  while (cin >> w) {
    int i = 0;
    while (w > a[i])
      i++;
    cout << cls[i] << endl;
  }
}
Problem p00048 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>

int main() {
  float n;
  int m;
  const char *rank[] = {"light fly", "fly",          "bantam", "feather",
                        "light",     "light welter", "welter", "light middle",
                        "middle",    "light heavy",  "heavy"};
  while (~scanf("%f\\n", &n)) {
    if (n <= 48.0)
      m = 0;
    else if (n <= 51.0)
      m = 1;
    else if (n <= 54.0)
      m = 2;
    else if (n <= 57.0)
      m = 3;
    else if (n <= 60.0)
      m = 4;
    else if (n <= 64.0)
      m = 5;
    else if (n <= 69.0)
      m = 6;
    else if (n <= 75.0)
      m = 7;
    else if (n <= 81.0)
      m = 8;
    else if (n <= 91.0)
      m = 9;
    else
      m = 10;
    puts(rank[m]);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>

int main() {
  float n;
  int m;
  const char *rank[] = {"light fly", "fly",          "bantam", "feather",
                        "light",     "light welter", "welter", "light middle",
                        "middle",    "light heavy",  "heavy"};
  while (scanf("%f\\n", &n)) {
    if (n <= 48.0)
      m = 0;
    else if (n <= 51.0)
      m = 1;
    else if (n <= 54.0)
      m = 2;
    else if (n <= 57.0)
      m = 3;
    else if (n <= 60.0)
      m = 4;
    else if (n <= 64.0)
      m = 5;
    else if (n <= 69.0)
      m = 6;
    else if (n <= 75.0)
      m = 7;
    else if (n <= 81.0)
      m = 8;
    else if (n <= 91.0)
      m = 9;
    else
      m = 10;
    puts(rank[m]);
  }
  return 0;
}
Problem p00048 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string.h>
#include <string>

using namespace std;

int main(void) {

  double weight[] = {48, 51, 54, 57, 60, 64, 69, 75, 81, 91};
  double n;
  string name[11] = {"light fly", "fly",          "bantam", "feather",
                     "light",     "light welter", "welter", "light middle",
                     "middle",    "light heavy",  "heavy"};

  while (scanf("%lf", &n) != EOF) {

    if (n <= weight[0]) {
      cout << name[0] << endl;
    } else if (weight[9] < n) {
      cout << name[10] << endl;
    } else {
      for (int i = 0; i < sizeof(weight) - 1; i++) {
        if (weight[i] < n && n <= weight[i + 1]) {
          cout << name[i + 1] << endl;
          break;
        }
      }
    }
  }
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string.h>
#include <string>

using namespace std;

int main(void) {

  double weight[] = {48, 51, 54, 57, 60, 64, 69, 75, 81, 91};
  double n;
  string name[11] = {"lght fly", "fly",          "bantam", "feather",
                     "light",    "light welter", "welter", "light middle",
                     "middle",   "light heavy",  "heavy"};

  while (scanf("%d", &n) != EOF) {

    if (n <= weight[0]) {
      cout << name[0] << endl;
    } else if (weight[9] < n) {
      cout << name[10] << endl;
    } else {
      for (int i = 0; i < sizeof(weight) - 1; i++) {
        if (weight[i] < n && n <= weight[i + 1]) {
          cout << name[i + 1] << endl;
          break;
        }
      }
    }
  }
}
Problem p00048 (C++) — buggy submission, verdict: Runtime Error

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

string s[11] = {"light fly", "fly",          "bantam", "feather",
                "light",     "light welter", "welter", "light middle",
                "middle",    "light heavy",  "heavy"};
double g[] = {48.0, 51.0, 54.0, 57.0, 60.0, 64.0, 69.0, 75.0, 81.0, 91.0};

int main() {
  double n;
  while (cin >> n) {
    int m;
    for (m = 0; m < 10 && n > g[m]; m++)
      ;
    cout << s[m] << endl;
  }
  return 0;
}

/*
60.2
70.2
48.0
80.2
*/

Error: 0

Fixed submission:

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

string s[11] = {"light fly", "fly",          "bantam", "feather",
                "light",     "light welter", "welter", "light middle",
                "middle",    "light heavy",  "heavy"};
double g[] = {48.0, 51.0, 54.0, 57.0, 60.0, 64.0, 69.0, 75.0, 81.0, 91.0};

int main() {
  double n;
  while (cin >> n) {
    int m;
    for (m = 0; m < 11 && n > g[m]; m++)
      ;
    cout << s[m] << endl;
  }
  return 0;
}

/*
60.2
70.2
48.0
80.2
*/
Problem p00048 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define fi first
#define se second
using namespace std;
bool value(int y, int x, int R, int C) {
  return 0 <= y && y < R && 0 <= x && x < C;
}
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vi> vvi;
double pie = acos(-1);
int INF = 10000009;
int dx[4] = {0, -1, 0, 1};
int dy[4] = {-1, 0, 1, 0};
int main() {
  double w;
  while (true) {
    cin >> w;
    if (cin.eof())
      break;
    if (w <= 48.00) {
      cout << "light"
           << " "
           << "fly" << endl;
    }
    if (48.00 < w && w <= 51.00) {
      cout << "fly" << endl;
    }
    if (51.00 < w && w <= 54.00) {
      cout << "bantam" << endl;
    }
    if (54.00 < w && w <= 57.00) {
      cout << "feather" << endl;
    }
    if (57.00 < w && w <= 60.00) {
      cout << "light" << endl;
    }
    if (60.00 < w && w <= 64.00) {
      cout << "light"
           << " "
           << "welter" << endl;
    }
    if (64.00 < w && w <= 69.00) {
      cout << "welter" << endl;
    }
    if (69.00 < w && w <= 75.00) {
      cout << "light"
           << " "
           << "middle" << endl;
    }
    if (75.00 < w && w <= 81.00) {
      cout << "middle" << endl;
    }
    if (81.00 < w && w <= 91.00) {
      cout << "light"
           << " "
           << "heavy" << endl;
    }
    if (91.00 < w) {
      cout << "heavy" << endl;
    }
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define fi first
#define se second
using namespace std;
bool value(int y, int x, int R, int C) {
  return 0 <= y && y < R && 0 <= x && x < C;
}
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vi> vvi;
double pie = acos(-1);
int INF = 10000009;
int dx[4] = {0, -1, 0, 1};
int dy[4] = {-1, 0, 1, 0};
int main() {
  double w;
  while (true) {
    cin >> w;
    if (w <= 48.00) {
      cout << "light fly" << endl;
    }
    if (48.00 < w && w <= 51.00) {
      cout << "fly" << endl;
    }
    if (51.00 < w && w <= 54.00) {
      cout << "bantam" << endl;
    }
    if (54.00 < w && w <= 57.00) {
      cout << "feather" << endl;
    }
    if (57.00 < w && w <= 60.00) {
      cout << "light" << endl;
    }
    if (60.00 < w && w <= 64.00) {
      cout << "light welter";
    }
    if (64.00 < w && w <= 69.00) {
      cout << "welter" << endl;
    }
    if (69.00 < w && w <= 75.00) {
      cout << "light middle" << endl;
    }
    if (75.00 < w && w <= 81.00) {
      cout << "middle" << endl;
    }
    if (81.00 < w && w <= 91.00) {
      cout << "light heavy" << endl;
    }
    if (91.00 < w) {
      cout << "heavy" << endl;
    }
  }
}
Problem p00048 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>

using namespace std;

int main() {
  double a;
  while (cin >> a) {
    if (a <= 48.00) {
      cout << "light fly" << endl;
    } else if (a > 48.00 && a <= 51.00) {
      cout << "fly" << endl;
    } else if (a > 51.00 && a <= 54.00) {
      cout << "bantam" << endl;
    } else if (a > 54.00 && a <= 57.00) {
      cout << "feather" << endl;
    } else if (a > 57.00 && a <= 60.00) {
      cout << "light" << endl;
    } else if (a > 60.00 && a <= 64.00) {
      cout << "light welter" << endl;
    } else if (a > 64.00 && a <= 69.00) {
      cout << "welter" << endl;
    } else if (a > 69.00 && a <= 75.00) {
      cout << "light middle" << endl;
    } else if (a > 75.00 && a <= 81.00) {
      cout << "middle" << endl;
    } else if (a > 81.00 && a <= 91.00) {
      cout << "light heavy" << endl;
    } else if (a > 91.00) {
      cout << "heavy" << endl;
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  for (int i = 0; i <= 1000000; i++) {
    double a;
    cin >> a;
    if (a <= 48) {
      cout << "light fly" << endl;
    }
    if (a > 48 && a <= 51) {
      cout << "fly" << endl;
    }
    if (a > 51 && a <= 54) {
      cout << "bantam" << endl;
    }
    if (a > 54 && a <= 57) {
      cout << "feather" << endl;
    }
    if (a > 57.00 && a <= 60.00) {
      cout << "light" << endl;
    }
    if (a > 60 && a <= 64) {
      cout << "light welter" << endl;
    }
    if (a > 64 && a <= 69) {
      cout << "welter" << endl;
    }
    if (a > 69 && a <= 75) {
      cout << "light middle" << endl;
    }
    if (a > 75 && a <= 81) {
      cout << "middle" << endl;
    }
    if (a > 81 && a <= 91) {
      cout << "light heavy" << endl;
    }
    if (a > 91) {
      cout << "heavy" << endl;
    }
  }

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

#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main() {
  int n;
  string str;
  int blood[4] = {0};
  while (scanf("%d,", &n) != EOF) {
    cin >> str;
    if (str == "A")
      blood[0]++;
    else if (str == "B")
      blood[1]++;
    else if (str == "AB")
      blood[2]++;
    else if (str == "O")
      blood[3]++;
  }
  cout << blood[0] << endl
       << blood[1] << endl
       << blood[2] << endl
       << blood[3] << endl;
  return 0;
}

Error: -6
free(): invalid pointer


Fixed submission:

#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main() {
  int n;
  string str;
  int blood[4] = {0};
  while (scanf("%d,%s", &n, &str) != EOF) {
    if (str == "A")
      blood[0]++;
    else if (str == "B")
      blood[1]++;
    else if (str == "AB")
      blood[2]++;
    else if (str == "O")
      blood[3]++;
  }
  cout << blood[0] << endl
       << blood[1] << endl
       << blood[2] << endl
       << blood[3] << endl;
  return 0;
}
Problem p00049 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main() {
  int n;
  char h;
  string s;
  int abo[4] = {0};

  while (cin >> n >> h >> s) {
    if (s == "A") {
      abo[0]++;
    } else if (s == "B") {
      abo[1]++;
    } else if (s == "AB") {
      abo[2]++;
    } else {
      abo[3]++;
    }
  }

  for (int i = 0; i < 4; i++) {
    cout << abo[i] << endl;
  }
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int n;
  char s[3];
  int abo[4] = {0};
  while (scanf("%d,%s", &n, s)) {
    if (s == "A") {
      abo[0]++;
    } else if (s == "B") {
      abo[1]++;
    } else if (s == "AB") {
      abo[2]++;
    } else {
      abo[3]++;
    }
  }
  for (int i = 0; i < 4; i++) {
    cout << abo[i] << endl;
  }
}
Problem p00049 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int a;
  int A, B, O, AB;
  char k;
  string b;

  A = B = AB = O = 0;

  while (cin >> a >> k >> b) {
    if (b == "A") {
      A++;
    }
    if (b == "B") {
      B++;
    }
    if (b == "AB") {
      AB++;
    }
    if (b == "O") {
      O++;
    }
  }

  printf("%d\\n%d\\n%d\\n%d\\n", A, B, AB, O);

  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>

using namespace std;

int main() {
  int a;
  char b[2];
  int A, B, O, AB;
  A = B = AB = O = 0;

  while (scanf("%d,%s", &a, b)) {
    if (b[0] == 'A' && b[1] != 'B') {
      A++;
    }
    if (b[0] == 'B') {
      B++;
    }
    if (b[0] == 'A' && b[1] == 'B') {
      AB++;
    }
    if (b[0] == 'O') {
      O++;
    }
  }

  printf("%d\\n%d\\n%d\\n%d\\n", A, B, AB, O);

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

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
int ta[4];
string dx[] = {"A", "B", "AB", "O"};
int main() {

  int a;
  string b;
  while (cin >> a) {
    cin.ignore();
    cin >> b;
    for (int j = 0; j < 4; j++)
      if (b == dx[j])
        ta[j]++;
  }
  for (int j = 0; j < 4; j++)
    cout << ta[j] << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
int ta[4];
string dx[] = {"A", "B", "AB", "O"};
int main() {

  int a;
  string b;
  while (cin >> a, a != EOF) {
    cin.ignore();
    cin >> b;
    for (int i = 0; i < a; i++) {
      for (int j = 0; j < 4; j++)
        if (b == dx[j])
          ta[j]++;
    }
    for (int j = 0; j < 4; j++)
      cout << ta[j] << endl;
  }
  return 0;
}
Problem p00049 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main() {
  string str;
  int K, TB = 0, TA = 0, Tab = 0, TM = 0;
  char ch, chc;
  while (scanf("%d,%c%c", &K, &ch, &chc) != EOF) {

    if (ch == 'A') {
      if (chc == 'B')
        Tab++;
      else
        TA++;
    } else if (ch == 'B')
      TB++;
    // else if(str=="AB")Tab++;
    else if (ch == 'O')
      TM++;
  }
  printf("%d\\n%d\\n%d\\n%d\\n", TA, TB, Tab, TM);

  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {

  int K, TB = 0, TA = 0, Tab = 0, TM = 0;
  char ch;
  while (scanf("%d,%c", &K, &ch) != EOF) {
    if (ch == 'A')
      TA++;
    else if (ch == 'B')
      TB++;
    else if (ch == 'AB')
      Tab++;
    else if (ch == 'O')
      TM++;
  }
  printf("%d\\n%d\\n%d\\n%d\\n", TA, TB, Tab, TM);

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

#include <algorithm>
#include <cstdio>
#include <string>
using namespace std;

int main() {
  int A = 0, B = 0, C = 0, D = 0;
  char bl[3];
  while (scanf("%*d,%2s", bl) != EOF) {
    if (string(bl) == "A") {
      A++;
    } else if (string(bl) == "B") {
      B++;
    } else if (string(bl) == "AB") {
      C++;
    } else if (string(bl) == "O") {
      D++;
    }
  }
  printf("%d\\n%d\\n%d\\n%d\\n", A, B, C, D);
}

Error: -11

Fixed submission:

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

int main() {
  int A = 0, B = 0, C = 0, D = 0;
  int num;
  string bl;
  while (scanf("%d,%s", &num, &bl) != EOF) {
    if (bl == "A") {
      A++;
    } else if (bl == "B") {
      B++;
    } else if (bl == "AB") {
      C++;
    } else if (bl == "O") {
      D++;
    }
  }
  printf("%d\\n%d\\n%d\\n%d\\n", A, B, C, D);
}
Problem p00049 (C++) — buggy submission, verdict: Runtime Error

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

int main(void) {
  int a, b, ab, o;
  int temp;
  char blood[3];

  a = b = ab = o = 0;

  while (scanf("%d,%s", &temp, blood) != EOF) {
    if (strcmp(blood, "AB") == 0)
      ab++;
    else if (strcmp(blood, "A") == 0)
      a++;
    else if (strcmp(blood, "B") == 0)
      b++;
    else if (strcmp(blood, "O") == 0)
      o++;
  }

  printf("%d\\n%d\\n%d\\n%d\\n", a, b, ab, o);

  return 0;
}

Error: 0

Fixed submission:

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

int main(void) {
  int a, b, ab, o;
  int temp;
  char blood[2];

  a = b = ab = o = 0;

  while (scanf("%d,%s", &temp, blood) != EOF) {
    if (strcmp(blood, "AB") == 0)
      ab++;
    else if (strcmp(blood, "A") == 0)
      a++;
    else if (strcmp(blood, "B") == 0)
      b++;
    else if (strcmp(blood, "O") == 0)
      o++;
  }

  printf("%d\\n%d\\n%d\\n%d\\n", a, b, ab, o);

  return 0;
}