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

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

  while (1) {
    int a = 1;
    int b;
    int c = 0;
    int cz = 0;

    cin >> a;
    if (a == 0) {
      break;
    }
    b = 1000 - a;

    if (b >= 500) {
      cz = b / 500;
      c = c + cz;
      b = b % 500;
    }
    if (b >= 100) {
      cz = b / 100;
      c = c + cz;
      b = b % 100;
    }
    if (b >= 50) {
      cz = b / 50;
      c = c + cz;
      b = b % 50;
    }
    if (b >= 10) {
      cz = b / 10;
      c = c + cz;
      b = b % 10;
    }
    if (b >= 5) {
      cz = b / 5;
      c = c + cz;
      b = b % 5;
    }
    if (b >= 1) {
      cz = b / 1;
      c = c + cz;
      b = b % 1;
    }

    cout << c << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int a = 1;
  int b;
  int c;

  while (1) {
    cin >> a;
    if (a = 0) {
      break;
    }
    b = a;
    while (b != 0) {
      if (b >= 500) {
        b = b - 500;
        c++;
      } else if (b >= 100) {
        b = b - 100;
        c++;
      } else if (b >= 50) {
        b = b - 50;
        c++;
      } else if (b >= 10) {
        b = b - 10;
        c++;
      } else if (b >= 5) {
        b = b - 5;
        c++;
      } else if (b >= 1) {
        b = b - 1;
        c++;
      }
    }
    cout << c << endl;
  }
  return 0;
}
Problem p00444 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
using namespace std;

int main() {
  int x, y;
  while (scanf("%d", &x)) {
    if (x == 0) {
      break;
    }
    x = 1000 - x;
    y = 0;
    while (x >= 500) {
      x -= 500;
      y++;
    }
    while (x >= 100) {
      x -= 100;
      y++;
    }
    while (x >= 50) {
      x -= 50;
      y++;
    }
    while (x >= 10) {
      x -= 10;
      y++;
    }
    while (x >= 5) {
      x -= 5;
      y++;
    }
    while (x >= 1) {
      x -= 1;
      y++;
    }
    printf("%d\\n", y);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
using namespace std;

int main() {
  int x, y;
  while (scanf("%d", &x) != 0) {
    x = 1000 - x;
    y = 0;
    while (x >= 500) {
      x -= 500;
      y++;
    }
    while (x >= 100) {
      x -= 100;
      y++;
    }
    while (x >= 50) {
      x -= 50;
      y++;
    }
    while (x >= 10) {
      x -= 10;
      y++;
    }
    while (x >= 5) {
      x -= 5;
      y++;
    }
    while (x >= 1) {
      x -= 1;
      y++;
    }
    printf("%d\\n", y);
  }
  return 0;
}
Problem p00444 (C++) — buggy submission, verdict: Time Limit Exceeded



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

    int n, m;
    cin >> n;
    if (n == 0)
      return 0;
    m = 0;
    n = 1000 - n;

    if (n >= 500) {
      m = n / 500;
      n = n % 500;
    }
    if (n >= 100) {
      m = m + n / 100;
      n = n % 100;
    }
    if (n >= 50) {
      m = m + n / 50;
      n = n % 50;
    }
    if (n >= 10) {
      m = m + n / 10;
      n = n % 10;
    }
    if (n >= 5) {
      m = m + n / 5;
      n = n % 5;
    }
    if (n >= 1) {
      m = m + n / 1;
    }

    cout << m << endl;
  }
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n, m;
  cin >> n;
  m = 0;
  n = 1000 - n;

  while (n <= 500) {
    n = n - 500;
    m++;
  }
  while (n <= 100) {
    n = n - 100;
    m++;
  }
  while (n <= 50) {
    n = n - 50;
    m++;
  }
  while (n <= 10) {
    n = n - 10;
    m++;
  }
  while (n <= 5) {
    n = n - 5;
    m++;
  }
  while (n <= 1) {
    n = n - 1;
    m++;
  }

  cout << m << endl;

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

#include <iostream>
using namespace std;

int change[6] = {1, 5, 10, 50, 100, 500};
int cnt;
int n;

int main() {
  while (cin >> n) {
    if (!n)
      break;
    cnt = 0;
    n = 1000 - n;
    for (int i = 5; i >= 0; i--) {
      while (n >= change[i]) {
        n -= change[i];
        cnt++;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int change[6] = {1, 10, 50, 100, 500};
int cnt[6];
int n;

int main() {
  cin >> n;
  n = 1000 - n;
  for (int i = 5; i >= 0; i--) {
    while (n >= change[i]) {
      n -= change[i];
      cnt[i]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < 6; i++)
    ans += cnt[i];
  cout << ans << endl;
  return 0;
}
Problem p00445 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
using namespace std;
int main() {
  string a;
  int b;
  int c;
  int f;
  int g;
  while (cin >> a) {
    b = a.size();
    int e[b];
    c = 0;
    while (c < b) {
      string d(a, c, 1);
      if (d == "J") {
        e[c] = 1;
      } else if (d == "O") {
        e[c] = 2;
      } else if (d == "I") {
        e[c] = 3;
      } else {
        e[c] = 0;
      }
      c = c + 1;
    }
    f = 0;
    g = 0;
    c = 0;
    while (c < b - 2) {
      if (e[c] == 1) {
        if (e[c + 1] == 2) {
          if (e[c + 2] == 3) {
            f = f + 1;
          }
        }
      }
      if (e[c] == 3) {
        if (e[c + 1] == 2) {
          if (e[c + 2] == 3) {
            g = g + 1;
          }
        }
      }
      c = c + 1;
    }
    cout << f << endl;
    cout << g << endl;
  }
}

Error: -11

Fixed submission:

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

int main() {

  string a;
  int f;
  cin >> a;
  f = a.size();
  int c;
  c = 0;
  int d[f];
  while (c < f) {
    string b(a, c, 1);
    if (b == "J") {
      d[c] = 1;
    }
    if (b == "O") {
      d[c] = 2;
    }
    if (b == "I") {
      d[c] = 3;
    }
    c = c + 1;
  }
  c = 0;
  int g;
  int h;
  g = 0;
  h = 0;
  while (c < 10000) {
    if (d[c] == 1) {
      if (d[c + 1] == 2) {
        if (d[c + 2] == 3) {
          g = g + 1;
        }
      }
    }
    if (d[c] == 3) {
      if (d[c + 1] == 2) {
        if (d[c + 2] == 3) {
          h = h + 1;
        }
      }
    }
    c = c + 1;
  }
  cout << g << endl;
  cout << h << endl;
}
Problem p00445 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
  string a;
  while (cin >> a) {
    int b = 0;
    int c = 0;
    for (int i = 0; i < a.size(); i++) {
      if (a[i] == 'J') {
        if (a[i + 1] == 'O' && a[i + 2] == 'I') {
          b++;
        }
      }
      if (a[i] == 'I') {
        if (a[i + 1] == 'O' && a[i + 2] == 'I') {
          c++;
        }
      }
    }
    cout << b << endl << c << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

using namespace std;

int main() {
  while (1) {
    char ch[10000];
    cin >> ch;
    int count = 0, bcount = 0;
    for (int i = 0; i < 10000; i++) {
      if (ch[i] == 'J' && ch[i + 1] == 'O' && ch[i + 2] == 'I') {
        count++;
      }
      if (ch[i] == 'I' && ch[i + 1] == 'O' && ch[i + 2] == 'I') {
        bcount++;
      }
    }
    cout << count << endl << bcount << endl;
  }

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

#include <iostream>
using namespace std;

int main() {
  char x[10005];
  while (scanf("%s", &x) != EOF) {
    int k = 0, JOI = 0, IOI = 0;
    while (x[k + 2] != '\\0') {
      if (x[k + 1] == 'O' && x[k + 2] == 'I') {
        if (x[k] == 'J')
          JOI++;
        if (x[k] == 'I')
          IOI++;
      }
      k++;
    }
    printf("%d\\n%d\\n", JOI, IOI);
    for (int i = 0; i < 10005; i++)
      x[i] = '\\0';
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

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

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

  for (int j = 0; j < 5; j++) {

    string A;
    cin >> A;

    if (A == "EOF")
      return 0;

    int joi = 0, ioi = 0;

    for (int i = 0; i < A.size(); i++) {
      if ((A[i] == 'J' && A[i + 1] == 'O') && A[i + 2] == 'I')
        joi++;
      if ((A[i] == 'I' && A[i + 1] == 'O') && A[i + 2] == 'I')
        ioi++;
    }

    cout << joi << endl << ioi << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

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

  while (true) {

    string A;
    cin >> A;

    if (A == "EOF")
      return 0;
    ;

    int joi = 0, ioi = 0;

    for (int i = 0; i < A.size(); i++) {
      if ((A[i] == 'J' && A[i + 1] == 'O') && A[i + 2] == 'I')
        joi++;
      if ((A[i] == 'I' && A[i + 1] == 'O') && A[i + 2] == 'I')
        ioi++;
    }

    cout << joi << endl << ioi << endl;
  }

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

#include <iostream>
using namespace std;
int main() {
  char text[10001];
  int joi, ioi;
  while (cin >> text) {
    for (int i = 0; i < 9998; i++) {
      if (text[i] == 'J' && text[i + 1] == 'O' && text[i + 2] == 'I')
        joi++;
      if (text[i] == 'I' && text[i + 1] == 'O' && text[i + 2] == 'I')
        ioi++;
    }
    cout << joi << endl << ioi << endl;
    joi = 0;
    ioi = 0;
    for (int i = 0; i < 10000; i++) {
      text[i] = '\\0';
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

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

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

int main() {
  string unco;
  while (cin >> unco) {
    int joi = 0, ioi = 0;
    for (int i = 2; i < unco.size(); i++) {
      if (unco[i] == 'I' && unco[i - 1] == 'O') {
        if (unco[i - 2] == 'I') {
          ioi++;
        }
        if (unco[i - 2] == 'J') {
          joi++;
        }
      }
    }
    cout << joi << endl << ioi << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  while (true) {
    int joi = 0, ioi = 0;
    string str;
    cin >> str;
    for (int i = 0; i < str.size() - 2; i++) {
      if (str[i + 1] == 'O' && str[i + 2] == 'I') {
        if (str[i] == 'J')
          joi++;
        if (str[i] == 'I')
          ioi++;
      }
    }
    cout << joi << endl << ioi << endl;
  }
  return 0;
}
Problem p00445 (C++) — buggy submission, verdict: Runtime Error

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

using namespace std;

int main() {
  string s, comp[2] = {"JOI", "IOI"};

  while (cin >> s) {
    for (int k = 0; k < 2; ++k) {
      int ans = 0;
      for (int i = 0; (i = s.find(comp[k], i)) != string::npos; ++i) {
        ans++;
      }
      cout << ans << endl;
    }
  }

  return 0;
}

Error: TLE

Fixed submission:


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

int main() {
  int result[2][1000], suffix = 0;

  while (1) {
    char s[10001], len = 0, joi = 0, ioi = 0;

    char c;
    while (1) {
      c = getchar();
      if (c == '\\n') {
        break;
      }
      s[len] = c;
      len++;
    }

    if (len == 0) {
      break;
    }

    for (int i = 0; i < len; i++) {
      if (s[i] == 'J') {
        if (s[i + 1] == 'O' && s[i + 2] == 'I') {
          joi++;
        }
      } else if (s[i] == 'I') {
        if (s[i + 1] == 'O' && s[i + 2] == 'I') {
          ioi++;
        }
      }
    }

    result[0][suffix] = joi;
    result[1][suffix] = ioi;

    suffix++;
  }

  for (int i = 0; i < suffix; i++) {
    printf("%d\\n%d\\n", result[0][i], result[1][i]);
  }

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

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

int main() {
  string label;
  int joiCount = 0;
  int ioiCount = 0;
  int joiIndex = 0;
  int ioiIndex = 0;
  while (true) {
    cin >> label;
    if (cin.eof()) {
      break;
    }
    joiCount = 0;
    ioiCount = 0;
    joiIndex = 0;
    ioiIndex = 0;

    while (label.find("JOI", joiIndex) != string::npos) {
      joiIndex = label.find("JOI", joiIndex) + 1;
      joiCount++;
    }

    while (label.find("IOI", ioiIndex) != string::npos) {
      ioiIndex = label.find("IOI", ioiIndex) + 1;
      ioiCount++;
    }

    cout << joiCount << '\\n' << ioiCount << '\\n';
  }
  return 0;
}

Error: WA

Fixed submission:

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

int main() {
  char str[1001];
  char JOI[4] = "JOI";
  char IOI[4] = "IOI";

  int length;
  bool joiSame = true;
  bool ioiSame = true;
  int joiSameCount = 0;
  int ioiSameCount = 0;
  while (true) {
    cin >> str;
    if (cin.eof()) {
      break;
    }
    length = strlen(str);
    for (int i = 0; i < length - 3; i++) {
      joiSame = true;
      ioiSame = true;
      for (int j = 0; j < 3; j++) {
        if (str[i + j] != JOI[j]) {
          joiSame = false;
        }
        if (str[i + j] != IOI[j]) {
          ioiSame = false;
        }
        if (!joiSame && !ioiSame) {
          break;
        }
      }
      if (joiSame) {
        joiSameCount++;
      } else if (ioiSame) {
        ioiSameCount++;
      }
    }
    cout << joiSameCount << '\\n' << ioiSameCount << '\\n';
    joiSameCount = 0;
    ioiSameCount = 0;
  }
  return 0;
}
Problem p00445 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  string s;
  while (cin >> s) {
    int a = 0, b = 0;
    for (int i = 0; i < s.size() - 1; i++) {
      if (s[i] == 'J' && s[i + 1] == 'O' && s[i + 2] == 'I') {
        a += 1;
      }
      if (s[i] == 'I' && s[i + 1] == 'O' && s[i + 2] == 'I') {
        b += 1;
      }
    }
    cout << a << endl << b << endl;
  }
  return 0;
}


Error: -11

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  while (true) {
    string s;
    cin >> s;
    // if(cin.eof()==false)break;
    int a = 0, b = 0;
    for (int i = 0; i < s.size() - 1; i++) {
      if (s[i] == 'J' && s[i + 1] == 'O' && s[i + 2] == 'I') {
        a += 1;
      }
      if (s[i] == 'I' && s[i + 1] == 'O' && s[i + 2] == 'I') {
        b += 1;
      }
    }
    cout << a << endl << b << endl;
  }
  return 0;
}
Problem p00445 (C++) — buggy submission, verdict: Time Limit Exceeded

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

char ary[10010];
int main() {
  int cnt, cnj, cni;
  while (true) {
    cin >> ary;
    if (cin.eof())
      break;
    cnj = cni = 0;
    cnt = strlen(ary);
    for (int i = 2; i < cnt; i++) {
      if (ary[i] == 'I' && ary[i - 1] == 'O') {
        if (ary[i - 2] == 'J')
          cnj++;
        else if (ary[i - 2] == 'I')
          cni++;
      }
    }
    cout << cnj << endl << cni << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

char ary[10010];
int main() {
  int cnt, cnj, cni;
  while (true) {
    cin >> ary;
    if (ary[0] == (-1))
      break;
    cnj = cni = 0;
    cnt = strlen(ary);
    for (int i = 2; i < cnt; i++) {
      if (ary[i] == 'I' && ary[i - 1] == 'O') {
        if (ary[i - 2] == 'J')
          cnj++;
        else if (ary[i - 2] == 'I')
          cni++;
      }
    }
    cout << cnj << endl << cni << endl;
  }
  return 0;
}
Problem p00445 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void) {

  string DATA;
  while (cin >> DATA) {
    int JOI = 0, IOI = 0;
    for (int i = 0; i < DATA.size() - 3; i++) {
      string S;
      for (int j = 0; j < 3; j++) {
        S += DATA[i + j];
        // cout << S << endl;
        if (S == "JOI")
          JOI++;
        if (S == "IOI")
          IOI++;
      }
    }
    cout << JOI << endl;
    cout << IOI << endl;
  }
}

Error: -11

Fixed submission:

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void) {

  while (1) {
    string DATA;
    int JOI = 0, IOI = 0;
    cin >> DATA;
    for (int i = 0; i < DATA.size() - 3; i++) {
      string S;
      for (int j = 0; j < 3; j++) {
        S += DATA[i + j];
        // cout << S << endl;
        if (S == "JOI")
          JOI++;
        if (S == "IOI")
          IOI++;
      }
    }
    cout << JOI << endl;
    cout << IOI << endl;
  }
}
Problem p00445 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {

  char str[10001];

  int joi = 0, ioi = 0;

  while (cin >> str) {

    joi = 0;
    ioi = 0;

    for (int i = 0; str[i + 2] != '\\0'; i++) {

      if (str[i] == 'I' && str[i + 1] == 'O' && str[i + 2] == 'I')
        ioi++;

      else if (str[i] == 'J' && str[i + 1] == 'O' && str[i + 2] == 'I')
        joi++;
    }

    cout << joi << endl << ioi << endl;
  }
}

Error: TLE

Fixed submission:

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

int main() {

  string str;

  int joi = 0, ioi = 0, i = 0;

  bool check = true;

  while (cin >> str) {

    if (str[0] == '0')
      break;

    while (check) {

      if (str.find("JOI", i)) {

        i = str.find("JOI", i);

        joi++;

        check = true;

      }

      else
        check = false;
    }

    i = 0;

    check = true;

    while (check) {

      if (str.find("IOI", i)) {

        i = str.find("IOI", i);

        ioi++;

        check = true;

      }

      else
        check = false;
    }

    cout << joi << endl << ioi << endl;
  }

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

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define ll long long
#define INF 999999999
using namespace std;

int main() {
  string s;
  while (cin >> s) {
    int jo = 0, io = 0;
    for (int i = 0; i < s.size() - 2; i++) {
      if (s[i] == 'J' && s[i + 1] == 'O' && s[i + 2] == 'I')
        jo++;
      if (s[i] == 'I' && s[i + 1] == 'O' && s[i + 2] == 'I')
        io++;
    }
    cout << jo << endl;
    cout << io << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  while (1) {
    string s;
    int jo = 0, io = 0;
    cin >> s;
    for (int i = 0; i < s.size() - 2; i++) {
      if (s[i] == 'J' && s[i + 1] == 'O' && s[i + 2] == 'I')
        jo++;
      if (s[i] == 'I' && s[i + 1] == 'O' && s[i + 2] == 'I')
        io++;
    }
    cout << jo << endl;
    cout << io << endl;
  }
  return 0;
}
Problem p00445 (C++) — buggy submission, verdict: Runtime Error

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

void solve(string s) {
  int i, joi = 0, ioi = 0;
  for (i = 0; i < s.size() - 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++;
  }
  cout << joi << endl;
  cout << ioi << endl;
}

int main() {
  string s;
  while (cin >> s) {
    solve(s);
  }
  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int counta = 0, countb = 0;
  char words[99];
  cin >> words;
  for (int i = 0; i < sizeof(words) - 2; i++) {
    if (words[i] == 'J' && words[i + 1] == 'O' && words[i + 2] == 'I')
      counta++;
    if (words[i] == 'I' && words[i + 1] == 'O' && words[i + 2] == 'I')
      countb++;
  }
  cout << counta << endl;
  cout << countb << endl;
  return 0;
}
Problem p00445 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <cstring>
using namespace std;
char s[10002];
int J, I;
int main() {
  while (scanf("%s", s) != EOF) {
    J = 0;
    I = 0;
    for (int i = 0; i < strlen(s) - 2; i++) {
      if (s[i] == 'J' && s[i + 1] == 'O' && s[i + 2] == 'I')
        J++;
      if (s[i] == 'I' && s[i + 1] == 'O' && s[i + 2] == 'I')
        I++;
    }
    printf("%d\\n%d\\n", J, I);
  }
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <cstring>
using namespace std;
char s[10002];
int J, I;
int main() {
  while (1) {
    scanf("%s", s);
    if (s[0] == 0xff)
      return 0;
    J = 0;
    I = 0;
    for (int i = 0; i < strlen(s) - 2; i++) {
      if (s[i] == 'J' && s[i + 1] == 'O' && s[i + 2] == 'I')
        J++;
      if (s[i] == 'I' && s[i + 1] == 'O' && s[i + 2] == 'I')
        I++;
    }
    printf("%d\\n%d\\n", J, I);
  }
}
Problem p00445 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>

using namespace std;

int main() {
  for (;;) {
    char str[10001];
    int joi = 0, ioi = 0, temp;

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

    // JOIツ板サツ津ィ
    for (int i = 2; str[i] != '\\0'; i++) {
      if (str[i - 2] == 'J' && str[i - 1] == 'O' && str[i] == 'I') {
        joi++;
      }
    }
    for (int i = 0; str[i] != '\\0'; i++) {
      if (str[i - 2] == 'I' && str[i - 1] == 'O' && str[i] == 'I') {
        ioi++;
      }
    }

    cout << joi << endl;
    cout << ioi << endl;
  }
}

Error: 0

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

int main() {
  for (;;) {
    char str[1000];
    int joi = 0, ioi = 0, temp;

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

    // JOIツ板サツ津ィ
    for (int i = 2; str[i] != '\\0'; i++) {
      if (str[i - 2] == 'J' && str[i - 1] == 'O' && str[i] == 'I') {
        joi++;
      }
    }
    for (int i = 0; str[i] != '\\0'; i++) {
      if (str[i - 2] == 'I' && str[i - 1] == 'O' && str[i] == 'I') {
        ioi++;
      }
    }

    cout << joi << endl;
    cout << ioi << endl;
  }
}
Problem p00445 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string a;
  while (cin >> a) {

    int cnt = 0;
    int cnt1 = 0;

    for (int i = 0; i < a.size(); i++) {
      if (a[i] == 'J' && a[i + 1] == 'O' && a[i + 2] == 'I') {
        cnt++;
      }
      if (a[i] == 'I' && a[i + 1] == 'O' && a[i + 2] == 'I') {
        cnt1++;
      }
    }
    cout << cnt << endl;
    cout << cnt1 << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main(void) {
  char a[10001];
  while (1) {
    cin >> a;
    if (a[0] == 'E' && a[1] == 'O' && a[2] == 'F') {
      break;
    }
    int x = strlen(a);
    int cnt = 0;
    int cnt1 = 0;

    for (int i = 0; i < x; i++) {
      if (a[i] == 'J' && a[i + 1] == 'O' && a[i + 2] == 'I') {
        cnt++;
      }
      if (a[i] == 'I' && a[i + 1] == 'O' && a[i + 2] == 'I') {
        cnt1++;
      }
    }
    cout << cnt << endl;
    cout << cnt1 << endl;
  }
  return 0;
}