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

#include <iostream>
using namespace std;
int main() {
  char s[10010] = {0};
  while (cin >> s) {
    int J = 0;
    int I = 0;
    int len = 0;
    while (1) {
      if (s[len] == 0) {
        break;
      }
      len++;
    }
    for (int i = 0; i < len - 2; i++) {
      if (s[i] == 'J' && s[i + 1] == 'O' && s[i + 2] == 'I') {
        J++;
        i++;
      } else if (s[i] == 'I' && s[i + 1] == 'O' && s[i + 2] == 'I') {
        I++;
        i++;
      }
    }
    cout << J << endl << I << endl;
    for (int i = 0; i < 10010; i++) {
      s[i] = 0;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  char s[10010] = {0};
  while (cin >> s) {
    int J = 0;
    int I = 0;
    int len = 0;
    while (1) {
      if (s[len] == 0) {
        break;
      }
    }
    for (int i = 0; i < len - 2; i++) {
      if (s[i] == 'J' && s[i + 1] == 'O' && s[i + 2] == 'I') {
        J++;
        i++;
      } else if (s[i] == 'I' && s[i + 1] == 'O' && s[i + 2] == 'I') {
        I++;
        i++;
      }
    }
    cout << J << endl << I << endl;
    for (int i = 0; i < 10010; i++) {
      s[i] = 0;
    }
  }
  return 0;
}
Problem p00445 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
#include <string.h>
int main() {
  char str[10000] = {0}, str2[10000];
  int i, m, n, j, cnt1 = 0, cnt2 = 0;
  while (scanf("%s", str) != EOF) {
    cnt1 = 0;
    cnt2 = 0;
    n = strlen(str);
    for (i = 0; i < n; i++) {
      if (str[i] == 'J' && str[i + 1] == 'O' && str[i + 2] == 'I') {
        cnt1++;
      }
      if (str[i] == 'I' && str[i + 1] == 'O' && str[i + 2] == 'I') {
        cnt2++;
      }
    }
    printf("%d\\n%d\\n", cnt1, cnt2);
  }
}

Error: WA

Fixed submission:

#include <stdio.h>
#include <string.h>
int main() {
  char str[1000], str2[10000];
  int i, m, n, j, cnt1, cnt2;
  while (scanf("%s", str) != EOF) {
    n = strlen(str);
    for (i = 0; i < n; i++) {
      if (str[i] == 'J' && str[i + 1] == 'O' && str[i + 2] == 'I') {
        cnt1++;
      }
      if (str[i] == 'J' && str[i + 1] == 'O' && str[i + 2] == 'I') {
        cnt2++;
      }
    }
    printf("%d\\n%d\\n", cnt1, cnt2);
  }
}
Problem p00445 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  while (true) {
    string line;
    cin >> line;
    if (!line.size()) {
      break;
    }
    int joi = 0, ioi = 0;

    for (int i = 0; i < line.size() - 2; i++) {
      if (line[i + 1] == 'O' && line[i + 2] == 'I') {
        if (line[i] == 'J') {
          joi++;
        } else if (line[i] == 'I') {
          ioi++;
        }
      }
    }
    cout << joi << endl << ioi << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

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

int main() {
  while (true) {
    string line;
    cin >> line;
    if (line[0] == 'EOF') {
      break;
    }
    int joi = 0, ioi = 0;

    for (int i = 0; i < line.size() - 2; i++) {
      if (line[i + 1] == 'O' && line[i + 2] == 'I') {
        if (line[i] == 'J') {
          joi++;
        } else if (line[i] == 'I') {
          ioi++;
        }
      }
    }
    cout << joi << endl << ioi << endl;
  }
  return 0;
}
Problem p00445 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  string str;
  while (cin >> str) {
    int j = 0, i = 0, joi = 0, ioi = 0;
    while (j < str.size()) {
      if (str.find("JOI", j) == string::npos)
        break;
      j = str.find("JOI", j) + 1;
      joi++;
    }
    while (i < str.size()) {
      if (str.find("IOI", i) == string::npos)
        break;
      i = str.find("IOI", i) + 1;
      ioi++;
    }
    cout << joi << endl << ioi << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  string str;
  while (cin >> str) {
    int j = 0, i = 0, joi = 0, ioi = 0;
    while (j < str.size()) {
      if (str.find("JOI", j) == string::npos)
        break;
      j = str.find("JOI", j);
      joi++;
    }
    while (i < str.size()) {
      if (str.find("IOI", i) == string::npos)
        break;
      i = str.find("IOI", i);
      ioi++;
    }
    cout << joi << endl << ioi << endl;
  }
  return 0;
}
Problem p00445 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
#include <string.h>
int main(void) {
  int i, cantj = 0, canti = 0;
  char a[10001];
  while (scanf("%s", a) != EOF) {
    for (i = 0; i < strlen(a) - 2; i++) {
      if (a[i] == 'J' && a[i + 1] == 'O' && a[i + 2] == 'I') {
        cantj++;
      }
      if (a[i] == 'I' && a[i + 1] == 'O' && a[i + 2] == 'I') {
        canti++;
      }
    }
    printf("%d\\n", cantj);
    printf("%d\\n", canti);
    canti = 0;
    cantj = 0;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <stdio.h>
#include <string.h>
int main(void) {
  int flgi = 0, flgj = 0, i, cantj = 0, canti = 0, m;
  char a[1001], b[4] = "JOI", c[4] = "IOI";
  while (scanf("%s", a) != EOF) {
    for (i = 0; i < strlen(a); i++) {
      if (a[i] == 'J' || a[i] == 'I') {
        for (m = 0; m < 3; m++) {
          if (a[i + m] != b[m]) {
            flgj = 1;
          }
          if (a[i + m] != c[m]) {
            flgi = 1;
          }
        }
        if (flgj == 0) {
          cantj++;
        }
        if (flgi == 0) {
          canti++;
        }
        flgi = 0;
        flgj = 0;
      }
    }
    printf("%d\\n", cantj);
    printf("%d\\n", canti);
    canti = 0;
    cantj = 0;
  }
  return 0;
}
Problem p00445 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bits/stdc++.h>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  int I = 0, J = 0;
  char d[10000];
  while (cin >> d) {
    for (int i = 0; i < 10000; i++)
      if (d[i + 2] == 0)
        break;
      else {
        if (d[i + 1] == 'O' && d[i + 2] == 'I') {
          if (d[i] == 'J')
            J++;
          if (d[i] == 'I')
            I++;
        }
      }
    printf("%d\\n%d\\n", J, I);
    I = 0, J = 0;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  int I = 0, J = 0;
  char d[10000];
  while (scanf("%s", d) && d[0]) {
    for (int i = 0; i < 10000; i++)
      if (d[i + 2] == 0)
        break;
      else {
        if (d[i + 1] == 'O' && d[i + 2] == 'I') {
          if (d[i] == 'J')
            J++;
          if (d[i] == 'I')
            I++;
        }
      }
    printf("%d\\n%d\\n", J, I);
    I = 0, J = 0;
  }
}
Problem p00445 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string>
using namespace std;
int o, S1, S2;
int main() {
  string S;
  while (o < 5) {
    cin >> S;
    S1 = 0;
    S2 = 0;
    for (int i = 0; i < S.size() - 2; i++) {
      if (S.substr(i, 3) == "JOI") {
        S1++;
      }
      if (S.substr(i, 3) == "IOI") {
        S2++;
      }
    }
    cout << S1 << endl;
    cout << S2 << endl;
    o++;
  }
}

Error: TLE

Fixed submission:

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

int main() {
  string S;
  int S1, S2;
  while (true) {
    cin >> S;
    S1 = 0;
    S2 = 0;
    for (int i = 0; i < S.size() - 2; i++) {
      if (S.substr(i, 3) == "JOI") {
        S1++;
      }
      if (S.substr(i, 3) == "IOI") {
        S2++;
      }
    }
    cout << S1 << endl;
    cout << S2 << endl;
  }
}
Problem p00445 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
#include <string.h>
int main(void) {
  int lol = 0, joi = 0, naga = 0, k = 0, count[100][500] = {0};
  char mozi[10001];
  while (k != 5) {
    scanf("%s", mozi);
    naga = strlen(mozi);
    for (int i = 0; i < naga; i++) {
      if (mozi[i] == 'J') {
        if (mozi[i + 1] == 'O') {
          if (mozi[i + 2] == 'I') {
            joi++;
          }
        }
      } else if (mozi[i] == 'I') {
        if (mozi[i + 1] == 'O') {
          if (mozi[i + 2] == 'I') {
            lol++;
          }
        }
      }
    }
    count[k][0] = lol;
    count[k][1] = joi;
    lol = 0;
    joi = 0;
    k++;
  }
  for (int i = 0; i < 5; i++) {
    printf("%d\\n%d\\n", count[i][1], count[i][0]);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
#include <string.h>
int main(void) {
  int lol = 0, joi = 0, naga = 0, k = 0;
  char mozi[10001];
  while (k == 0) {
    scanf("%s", mozi);
    naga = strlen(mozi);
    for (int i = 0; i < naga; i++) {
      if (mozi[i] == 'J') {
        if (mozi[i + 1] == 'O') {
          if (mozi[i + 2] == 'I') {
            joi++;
          }
        }
      } else if (mozi[i] == 'I') {
        if (mozi[i + 1] == 'O') {
          if (mozi[i + 2] == 'I') {
            lol++;
          }
        }
      }
    }
    printf("%d\\n%d\\n", joi, lol);
    lol = 0;
    joi = 0;
  }
  return 0;
}
Problem p00445 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(x, y, z) for (int x = y; x < z; x++)
#define INF 9999999;
#define VEC vector<int>
#define in push_back
#define ans(x) cout << x << endl
#define ll long long int

using namespace std;

int main() {
  string s;
  while (cin >> s) {
    int IOI = 0, JOI = 0;
    for (int i = 0; i < s.length() - 2; i++) {
      if (s[i] == 'J' && s[i + 1] == 'O' && s[i + 2] == 'I')
        JOI++;
      if (s[i] == 'I' && s[i + 1] == 'O' && s[i + 2] == 'I')
        IOI++;
    }
    ans(JOI);
    ans(IOI);
  }
}

Error: -11

Fixed submission:

#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(x, y, z) for (int x = y; x < z; x++)
#define INF 9999999;
#define VEC vector<int>
#define in push_back
#define ans(x) cout << x << endl
#define ll long long int

using namespace std;

int main() {
  while (1) {
    string s;
    cin >> s;
    if (s == "EOF")
      break;
    int IOI = 0, JOI = 0;
    for (int i = 0; i < s.length() - 2; i++) {
      if (s[i] == 'J' && s[i + 1] == 'O' && s[i + 2] == 'I')
        JOI++;
      else if (s[i] == 'I' && s[i + 1] == 'O' && s[i + 2] == 'I')
        IOI++;
    }
    ans(JOI);
    ans(IOI);
  }
}
Problem p00445 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main() {
  int i, j, n, m, s1 = 0, cut1 = 0, s2 = 0, cut2 = 0, len;
  char a[] = {"JOI"};
  char b[] = {"IOI"};
  char c[10000];
  while (scanf("%s", c) != EOF) {
    len = strlen(c);
    s1 = 0;
    s2 = 0;
    cut1 = 0;
    cut2 = 0;
    for (i = 0; i < len; i++) {
      if (a[s1] == c[i]) {
        s1++;
        if (s1 == 3) {
          cut1++;
          s1 = 0;
        }
      } else {
        s1 = 0;
        if (a[s1] == c[i]) {
          s1++;
        }
      }
      if (b[s2] == c[i]) {
        s2++;
        if (s2 == 3) {
          cut2++;
          s2 = 1;
        }
      } else {
        s2 = 0;
        if (b[s2] == c[i]) {
          s2++;
        }
      }
    }
    cout << cut1 << endl << cut2 << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string.h>
using namespace std;
int main() {
  int i, j, n, m, s1 = 0, cut1 = 0, s2 = 0, cut2 = 0, len;
  char a[] = {"JOI"};
  char b[] = {"IOI"};
  char c[10000];
  while (1) {
    cin >> c;
    len = strlen(c);
    s1 = 0;
    s2 = 0;
    cut1 = 0;
    cut2 = 0;
    for (i = 0; i < len; i++) {
      if (a[s1] == c[i]) {
        s1++;
        if (s1 == 3) {
          cut1++;
          s1 = 0;
        }
      } else {
        s1 = 0;
      }
      if (b[s2] == c[i]) {
        s2++;
        if (s2 == 3) {
          cut2++;
          s2 = 1;
        }
      } else {
        s2 = 0;
      }
    }
    cout << cut1 << endl << cut2 << endl;
  }
  return 0;
}
Problem p00445 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

using namespace std;

char ch[10100];
int cnt_J = 0, cnt_I = 0;

int search_JOI() {
  cnt_J = 0;
  REP(i, 10001) {
    if (ch[i] == 'J')
      if (ch[i + 1] == 'O' && ch[i + 2] == 'I' && i + 1 <= 10000 &&
          i + 2 <= 10000)
        cnt_J++;
    if (ch[i] == 0)
      break;
  }
  return 0;
}

int search_IOI() {
  cnt_I = 0;
  REP(i, 10001) {
    if (ch[i] == 'I' && ch[i + 2] == 'I' && i + 1 <= 10000 && i + 2 <= 10000)
      if (ch[i + 1] == 'O' && ch[i + 2] == 'I')
        cnt_I++;
    if (ch[i] == 0)
      break;
  }
  return 0;
}

int main() {
  while (1) {
    REP(i, 10000) ch[i] = 0;
    if (scanf("%s", &ch) == EOF)
      break;
    search_JOI();
    search_IOI();
    cout << cnt_J << endl;
    cout << cnt_I << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

using namespace std;

char ch[10100];
int cnt_J = 0, cnt_I = 0;

int search_JOI() {
  cnt_J = 0;
  REP(i, 1000) {
    if (ch[i] == 'J')
      if (ch[i + 1] == 'O' && ch[i + 2] == 'I')
        cnt_J++;
    if (ch[i] == 0)
      break;
  }
  return cnt_J++;
}

int search_IOI() {
  cnt_I = 0;
  REP(i, 10001) {
    if (ch[i] == 'I')
      if (ch[i + 1] == 'O' && ch[i + 2] == 'I')
        cnt_I++;
    if (ch[i] == 0)
      break;
  }
  return cnt_I++;
}

int main() {
  while (1) {
    if (!scanf("%s", &ch))
      break;
    int ansJ = search_JOI();
    int ansI = search_IOI();
    cout << ansJ << endl;
    cout << ansI << endl;
  }
  return 0;
}
Problem p00445 (C++) — buggy submission, verdict: Runtime Error

//
//  main.cpp

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

int main() {
  while (1) {
    char input[100001];
    int JOI = 0, IOI = 0;

    if (scanf("%s", input) == EOF) {
      break;
    }

    for (int i = 0; i < strlen(input) - 2; i++) {
      if (input[i] == 'J' && input[i + 1] == 'O' && input[i + 2] == 'I') {
        JOI++;
      }
      if (input[i] == 'I' && input[i + 1] == 'O' && input[i + 2] == 'I') {
        IOI++;
      }
    }

    cout << JOI << endl << IOI << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

//
//  main.cpp

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

int main() {
  bool Break = false;
  while (1) {
    string input = "";
    int JOI = 0, IOI = 0;
    char c;
    while (1) {
      if (scanf("%c", &c) == EOF) {
        Break = true;
        break;
      }
      if (c == '\\n') {
        break;
      } else {
        input += c;
      }
    }

    for (int i = 0; i < input.size() - 2; i++) {
      if (input[i] == 'J' && input[i + 1] == 'O' && input[i + 2] == 'I') {
        JOI++;
      }
      if (input[i] == 'I' && input[i + 1] == 'O' && input[i + 2] == 'I') {
        IOI++;
      }
    }

    cout << JOI << endl << IOI << endl;
    if (Break) {
      break;
    }
  }
  return 0;
}
Problem p00445 (C++) — buggy submission, verdict: Time Limit Exceeded

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <vector>
using namespace std;
int main() {

  char s[12000];

  while (scanf("%s", s) != EOF) {
    int len = strlen(s);
    int n = 0, m = 0;
    for (int i = 0; i < len - 2; i++) {
      if (s[i] == 'J' && s[i + 1] == 'O' && s[i + 2] == 'I')
        n++;
      else if (s[i] == 'I' && s[i + 1] == 'O' && s[i + 2] == 'I')
        m++;
    }
    cout << n << endl;
    cout << m << endl;
  }
}

Error: TLE

Fixed submission:

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main() {

  int n = 0, m = 0;
  string s;

  while (cin >> s, s != "") {
    int n = 0, m = 0;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == 'J' && s[i + 1] == 'O' && s[i + 2] == 'I')
        n++;
      else if (s[i] == 'I' && s[i + 1] == 'O' && s[i + 2] == 'I')
        m++;
    }
    cout << n << endl;
    cout << m << endl;
  }
}
Problem p00445 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string>

using namespace std;

const string IOI = "IOI";
const string JOI = "JOI";

int main() {
  while (1) {
    string str;
    cin >> str;

    if (str == "")
      break;

    int ioicnt = 0;
    int joicnt = 0;
    int len = str.length();

    for (int i = 0; i < len; i++) {
      if (str[i] == IOI[0]) {
        if (i + 1 < len && i + 2 < len && str[i + 1] == IOI[1] &&
            str[i + 2] == IOI[2]) {
          ioicnt++;
        } else if (i + 1 < len && str[i + 1] == JOI[0]) {
          i++;
          goto JOI;
        }
      } else if (str[i] == JOI[0]) {
      JOI:
        if (i + 1 < len && i + 2 < len && str[i + 1] == JOI[1] &&
            str[i + 2] == JOI[2]) {
          joicnt++;
          i++;
        }
      }
    }

    cout << joicnt << endl;

    cout << ioicnt << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

const string IOI = "IOI";
const string JOI = "JOI";

int main() {
  string str;

  while (1) {
    cin >> str;

    if (str == "")
      break;

    int ioicnt = 0;
    int joicnt = 0;
    int len = str.length();

    for (int i = 0; i < len; i++) {
      if (str[i] == IOI[0]) {
        if (i + 1 < len && i + 2 < len && str[i + 1] == IOI[1] &&
            str[i + 2] == IOI[2]) {
          ioicnt++;
        } else if (i + 1 < len && str[i + 1] == JOI[0]) {
          i++;
          goto JOI;
        }
      } else if (str[i] == JOI[0]) {
      JOI:
        if (i + 1 < len && i + 2 < len && str[i + 1] == JOI[1] &&
            str[i + 2] == JOI[2]) {
          joicnt++;
          i++;
        }
      }
    }

    cout << joicnt << endl;

    cout << ioicnt << endl;
  }

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

#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>

using namespace std;

int main(void) {

  while (true) {

    int cnt[2] = {};
    string str;
    cin >> str;
    if (cin.eof())
      break;
    for (int i = 0; i < str.length() - 3; i++) {
      if (str[i] == 'J' && str[i + 1] == 'O' && str[i + 2] == 'I')
        cnt[0]++;
      if (str[i] == 'I' && str[i + 1] == 'O' && str[i + 2] == 'I')
        cnt[1]++;
    }
    for (int i = 0; i < 2; i++)
      cout << cnt[i] << endl;
  }

  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>

using namespace std;

int main(void) {

  while (true) {
    if (cin.eof())
      break;
    int cnt[2] = {};
    string str;
    cin >> str;

    for (int i = 0; i < str.length() - 2; i++) {
      if (str[i] == 'J' && str[i + 1] == 'O' && str[i + 2] == 'I')
        cnt[0]++;
      if (str[i] == 'I' && str[i + 1] == 'O' && str[i + 2] == 'I')
        cnt[1]++;
    }
    for (int i = 0; i < 2; i++)
      cout << cnt[i] << endl;
  }

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

#include <cstdio>
int main() {
  char a[10003];

  while (true) {
    int io = 0, jo = 0;
    int b = 0, f = 0;
    if (scanf("%s", a) == EOF)
      break;
    for (int i = 0; a[i]; i++) {
      if (a[i] == 'J')
        f = 1;
      if (a[i] == 'I')
        f = 2;
      if (f) {
        b = 0;
        while (a[i]) {
          if (a[++i] != 'O') {
            i--;
            if (f == 2)
              io += b;
            else if (b > 0) {
              jo++;
              io += b - 1;
            }
            b = f = 0;
            break;
          }
          if (a[++i] != 'I') {
            i--;
            if (f == 2)
              io += b;
            else if (b > 0) {
              jo++;
              io += b - 1;
            }
            b = f = 0;
            break;
          }
          b++;
        }
      }
    }

    if (f == 2)
      io += b;
    if (f == 1 && b > 0) {
      jo++;
      io += b - 1;
    }
    printf("%d\\n%d\\n", jo, io);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
int main() {
  char a[10003];
  int io = 0, jo = 0;
  int b = 0, f = 0;

  while (true) {
    scanf("%s", a);
    if (a[0] == 0)
      break;
    for (int i = 0; a[i]; i++) {
      if (a[i] == 'J')
        f = 1;
      if (a[i] == 'I')
        f = 2;
      if (f) {
        b = 0;
        while (a[i]) {
          if (a[++i] != 'O') {
            i--;
            if (f == 2)
              io += b;
            else if (b > 0) {
              jo++;
              io += b - 1;
            }
            b = f = 0;
            break;
          }
          if (a[++i] != 'I') {
            i--;
            if (f == 2)
              io += b;
            else if (b > 0) {
              jo++;
              io += b - 1;
            }
            b = f = 0;
            break;
          }
          b++;
        }
      }
    }

    if (f == 2)
      io += b;
    if (f == 1 && b > 0) {
      jo++;
      io += b - 1;
    }
    printf("%d\\n%d\\n", jo, io);
  }
  return 0;
}
Problem p00445 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define a 'J'
#define b 'O'
#define c 'I'
int main(void) {
  int n = 0, m = 0, d = 0, j = 0;
  char wd[10000];

  cin >> wd;
  while (j < 5) {
    d = strlen(wd);
    for (int i = 0; i < d - 2; i++) {
      if (wd[i] == a) {
        if (wd[i + 1] == b) {
          if (wd[i + 2] == c) {
            n++;
            i += 2;
          }
        }
      }
      if (wd[i] == c) {
        if (wd[i + 1] == b) {
          if (wd[i + 2] == c) {
            m++;
            i += 1;
          }
        }
      }
    }
    cout << n << endl;
    cout << m << endl;
    n = 0;
    m = 0;
    j++;
    cin >> wd;
  }

  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
#include <string.h>
using namespace std;
int main(void) {
  char s[100];
  int a = 0;
  int b = 0;

  cin >> s;

  for (int i = 0; i <= strlen(s) - 3; i++) {
    if (s[i] == 'J' && s[i + 1] == 'O' && s[i + 2] == 'I') {
      a++;
    } else if (s[i] == 'I' && s[i + 1] == 'O' && s[i + 2] == 'I') {
      b++;
    }
  }

  cout << a << "\\n" << b << endl;

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

#include <algorithm>
#include <iostream>
#include <string>
int i;
int ioi = 0, joi = 0;
std::string s;
#define I if (s[i] == 'I')
#define J if (s[i] == 'J')
int main() {
  while (std::cin >> s) {
    for (i = 0; i < s.size(); i++) {
      I {
        if (s[i + 1] == 'O') {
          if (s[i + 2] == 'I') {
            ioi++;
          }
        }
      }
      J {
        if (s[i + 1] == 'O') {
          if (s[i + 2] == 'I') {
            joi++;
          }
        }
      }
    }
    std::cout << joi << std::endl;
    std::cout << ioi << std::endl;
    ioi = 0, joi = 0;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <string>
int i;
int ioi = 0, joi = 0;
std::string s;
#define I if (s[i] == 'I')
#define J if (s[i] == 'J')
int main() {
  while (true) {
    std::cin >> s;
    if (s == "EOF" || s == "eof")
      break;
    for (i = 0; i < s.size(); i++) {
      I {
        if (s[i + 1] == 'O') {
          if (s[i + 2] == 'I') {
            ioi++;
          }
        }
      }
      J {
        if (s[i + 1] == 'O') {
          if (s[i + 2] == 'I') {
            joi++;
          }
        }
      }
    }
    std::cout << joi << std::endl;
    std::cout << ioi << std::endl;
    ioi = 0, joi = 0;
  }
}