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

#include <bits/stdc++.h>

#define FOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000            // 2000000000
#define LLINF 1000000000000000000 // 9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

int main(void) {
  string s;
  string t;
  int count = 0;

  cin >> s;
  while (1) {
    cin >> t;
    if (t == "END_OF_TEXT") {
      break;
    } else {
      transform(t.begin(), t.end(), t.begin(), ::tolower);
      if (s == t) {
        count++;
      }
    }
  }

  cout << count << endl;

  return 0;
}


Error: TLE

Fixed submission:

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

using namespace std;

int main(void) {
  int count = 0;
  string t;
  string w;
  int position;
  int length_t, length_w;

  getline(cin, w);
  length_w = w.size();
  while (1) {
    position = 0;
    getline(cin, t);
    length_t = t.size();
    if (string(t).find("END_OF_TEXT") != string::npos) {
      break;
    }
    transform(t.begin(), t.end(), t.begin(), ::tolower);
    do {
      if (t.find(w, position) != string::npos) {
        position = (int)(t.find(w)) + 1;
        count++;
      } else {
        break;
      }
    } while (position <= length_t - length_w);
  }
  cout << count << endl;
  return 0;
}
Problem p02419 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cctype>
#include <iostream>
#include <string>

using namespace std;

int main() {
  string W;
  cin >> W;

  int ans = 0;
  while (1) {
    string T;
    cin >> T;
    if (T == "END_OF_TEXT") {
      break;
    }

    for (int i = 0; i < T.size(); i++) {
      T[i] = tolower(T[i]);
    }

    if (W == T) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

int main() {
  string T;
  cin >> T;

  int ans = 0;
  while (true) {
    string W;
    cin >> W;
    if (W == "END_OF_TEXT") {
      break;
    }

    while (W.find(T) >= 0) {
      int pos = W.find(T) - 1;
      if (W[pos] == ' ') {
        ans++;
      }
    }
  }

  cout << ans << endl;

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

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

int main() {
  string W, T;
  int cnt = 0;
  cin >> W;
  while (true) {
    cin >> T;
    if (T == "END_OF_TEXT")
      break;
    for (int i = 0; i < T.size(); i++) {
      if ('A' <= T[i] && T[i] <= 'Z') {
        T[i] += 32;
      }
    }
    if (W == T)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  string W, T;
  int cnt = 0;
  cin >> W;
  while (T != "END_OF_TEXT") {
    cin >> T;
    for (int i = 0; i < T.size(); i++) {
      if ('A' <= T[i] && T[i] <= 'Z') {
        T[i] += 34;
      }
    }
    if (W == T)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}
Problem p02419 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n)-1; (i) >= 0; --i)
#define SZ(n) (int)(n).size()
#define ALL(n) (n).begin(), (n).end()
#define MOD LL(1e9 + 7)
#define INF 1000000
using namespace std;
using LL = long long;

int main() {
  string w, t;
  cin >> w;
  for (auto &e : w) {
    if (e >= 'A' && e <= 'Z')
      e += 32;
  }
  int sum = 0;
  while (cin >> t) {
    for (auto &e : t) {
      if (e >= 'A' && e <= 'Z')
        e += 32;
    }
    if (t == w)
      sum++;
  }
  cout << sum << endl;
  return 0;
}


Error: -11

Fixed submission:

#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n)-1; (i) >= 0; --i)
#define SZ(n) (int)(n).size()
#define ALL(n) (n).begin(), (n).end()
#define MOD LL(1e9 + 7)
#define INF 1000000
using namespace std;
using LL = long long;

int main() {
  string w, t;
  cin >> w;
  int sum = 0;
  while (getline(cin, t)) {
    for (auto it = t.begin(); it != t.end() - w.size(); it++) {
      if (*it >= 'A' && *it <= 'Z')
        *it += 32;
      if (string(it, it + w.size()) == w)
        sum++;
    }
  }
  cout << sum << endl;
  return 0;
}
Problem p02419 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <string>

using namespace std;

int main() {
  char buf[1 << 11];
  scanf("%s", buf);
  string W(buf);
  transform(W.begin(), W.end(), W.begin(),
            [](char c) -> char { return c |= 0x20; });

  int res = 0;
  string T;
  for (char c; scanf("%c", &c) != EOF;) {
    if (((c | 0x20) >= 'a' && (c | 0x20) <= 'z') || c == '-' || c == '_') {
      T += c;
      continue;
    }

    if (T == "END_OF_TEXT")
      break;
    if (!T.length())
      continue;

    transform(T.begin(), T.end(), T.begin(),
              [](char c) -> char { return c |= 0x20; });

    if (W == T)
      ++res;

    T = "";
  }

  printf("%d\\n", res);
  return 0;
}

Error: 0
nurtures
computer
scientists
and
highly-skilled
computer
engineers
who
will
create
and
exploit
knowledge
for
the
new
era
provides
an
outstanding
computer
environment


Fixed submission:

#include <algorithm>
#include <cstdio>
#include <string>

using namespace std;

int main() {
  char buf[1 << 4];
  scanf("%s", buf);
  string W(buf);
  transform(W.begin(), W.end(), W.begin(), [](char c) { return c |= 0x20; });

  int res = 0;
  string T;
  for (char c; scanf("%c", &c) != EOF;) {
    if (((c | 0x20) >= 'a' && (c | 0x20) <= 'z') || c == '-' || c == '_') {
      T += c;
      continue;
    }

    if (T == "END_OF_TEXT")
      break;
    if (!T.length())
      continue;

    transform(T.begin(), T.end(), T.begin(), [](char c) { return c |= 0x20; });

    fprintf(stderr, "%s\\n", T.c_str());

    if (W == T)
      ++res;

    T = "";
  }

  printf("%d\\n", res);
  return 0;
}
Problem p02419 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll, ll> P;
typedef vector<P> vp;
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FORR(i, n, m) for (int i = n - 1; i >= m; i--)
#define all(in) in.begin(), in.end()
#define ALL(in, K) in, in + K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define pi 3.14159265358979323846

int main() {
  ll ans = 0;
  string w;
  cin >> w;
  REP(i, w.size()) {
    if (65 < w[i] && w[i] < 91) {
      w[i] += 32;
    }
  }
  while (1) {
    string s;
    cin >> s;
    if (s == "END_OF_TEXT") {
      cout << ans << endl;
      return 0;
    }
    if (s.size() == w.size()) {
      REP(i, s.size()) {
        if (64 < s[i] && s[i] < 91) {
          s[i] += 32;
        }
      }
      // cout << s << endl;
      if (s == w) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll, ll> P;
typedef vector<P> vp;
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FORR(i, n, m) for (int i = n - 1; i >= m; i--)
#define all(in) in.begin(), in.end()
#define ALL(in, K) in, in + K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define pi 3.14159265358979323846

int main() {
  ll ans = 0;
  string w;
  cin >> w;
  REP(i, w.size()) {
    if (65 < w[i] && w[i] < 91) {
      w[i] += 32;
    }
  }
  while (1) {
    string s;
    cin >> s;
    if (s.size() == w.size()) {
      REP(i, s.size()) {
        if (65 < s[i] && s[i] < 91) {
          s[i] += 32;
        }
      }
      if (s == "END_OF_TEXT") {
        cout << ans << endl;
        return 0;
      }
      if (s == w) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02419 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string w, t;
  int counter = 0;
  cin >> w;
  for (int i = 0; i < w.length(); i++) {
    if (islower(w[i]))
      w[i] = toupper(w[i]);
  }
  while (cin >> t) {
    if (t == "END_OF_TEXT") {
      cout << counter << endl;
      break;
    }
    for (int i = 0; i < t.length(); i++) {
      if (islower(t[i]))
        t[i] = toupper(t[i]);
    }
    if (t == w)
      counter++;
  }

  return 0;
}

Error: 0

Fixed submission:

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

int main() {
  string w, t;
  int counter = 0;
  cin >> w;
  for (int i = 0; w[i] != w.length(); i++) {
    if (islower(w[i]))
      w[i] = toupper(w[i]);
  }
  while (1) {
    cin >> t;
    if (t == "END_OF_TEXT") {
      cout << counter << endl;
      break;
    }
    for (int i = 0; i < t.length(); i++) {
      if (islower(t[i]))
        t[i] = toupper(t[i]);
    }
    if (t == w)
      counter++;
  }

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

#include <iostream>
using namespace std;
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NUM 200

int main() {
  static long i, j, k, l;
  static char p[1005];
  static char s[13];
  static char ch;
  static int sum[26];
  static char r[12] = "END_OF_TEXT";
  int cnt = 0;
  char ok;
  char end = 0;
  fgets(s, 13, stdin);

  while (end == 0) {
    fgets(p, 1010, stdin);
    for (i = 0; p[i]; i++) {
      if ('a' <= p[i] && p[i] <= 'z' || 'A' <= p[i] && p[i] <= 'Z') {
        if (p[i] == r[0]) {
          end = 1;
          for (j = 0; r[j]; j++) {
            if (p[i + j] != r[j]) {
              end = 0;
              break;
            }
          }
          if (end)
            break;
        }
        if (tolower(p[i]) == tolower(s[0])) {
          ok = 1;
          j = i;
          for (; s[i - j] != '\\n'; i++) {
            if (tolower(p[i]) != tolower(s[i - j])) {
              ok = 0;
              i--;
              break;
            }
          }
          if ('a' <= p[i] && p[i] <= 'z' || 'A' <= p[i] && p[i] <= 'Z')
            ok = 0;

          if (ok) {
            cnt++;
            i--;
          }
        }
      }
      for (;; i++) {
        if ('a' <= p[i] && p[i] <= 'z' || 'A' <= p[i] && p[i] <= 'Z')
          ;
        else
          break;
      }
    }
  }
  cout << cnt;
  cout << endl;

  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
using namespace std;
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NUM 200

int main() {
  static long i, j, k, l;
  static char p[1005];
  static char s[13];
  static char ch;
  static int sum[26];
  static char r[12] = "END_OF_TEXT";
  int cnt = 0;
  char ok;
  char end = 0;
  FILE *fp;
  fp = fopen("in3.txt", "r");
  fgets(s, 13, stdin);

  while (end == 0) {
    fgets(p, 1010, stdin);
    for (i = 0; p[i]; i++) {
      if ('a' <= p[i] && p[i] <= 'z' || 'A' <= p[i] && p[i] <= 'Z') {
        if (p[i] == r[0]) {
          end = 1;
          for (j = 0; r[j]; j++) {
            if (p[i + j] != r[j]) {
              end = 0;
              break;
            }
          }
          if (end)
            break;
        }
        if (tolower(p[i]) == tolower(s[0])) {
          ok = 1;
          j = i;
          for (; s[i - j] != '\\n'; i++) {
            if (tolower(p[i]) != tolower(s[i - j])) {
              ok = 0;
              i--;
              break;
            }
          }
          if (ok) {
            cnt++;
            i--;
          }
        }
      }
      for (;; i++) {
        if ('a' <= p[i] && p[i] <= 'z' || 'A' <= p[i] && p[i] <= 'Z')
          ;
        else
          break;
      }
    }
  }
  fclose(fp);
  cout << cnt;
  cout << endl;

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

#include <iostream>
#include <string>
using namespace std;
int main() {
  string w;
  string t;
  cin >> w;
  int i;
  for (i = 0; i < w.size(); i++) {
    if ('A' <= w[i] && w[i] <= 'Z') {
      w[i] += 'a' - 'A';
    }
  }
  int o = 0;
  cin >> t;
  while (t != "END_OF_TEXT") {
    for (i = 0; i < t.size(); i++) {
      if ('A' <= t[i] && t[i] <= 'Z') {
        t[i] += 'a' - 'A';
      }
    }
    if (w == t) {
      o++;
      // cin >> t;
    }
    cin >> t;
  }
  cout << o << endl;
}


Error: TLE

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  string w;
  string t;
  cin >> w;
  int i;
  for (i = 0; i < w.size(); i++) {
    if ('A' <= w[i] && w[i] <= 'Z') {
      w[i] += 'a' - 'A';
    }
  }
  int o = 0;
  cin >> t;
  while (t != "END_OF_TEXT") {
    for (i = 0; i < t.size(); i++) {
      if ('A' <= t[i] && t[i] <= 'Z') {
        t[i] += 'a' - 'A';
      }
    }
    if (w == t) {
      o++;
      cin >> t;
    }
  }
  cout << o << endl;
}
Problem p02419 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string>
using namespace std;
int main() {
  int count = 0;
  string word, the;
  cin >> the;
  while (1) {
    cin >> word;
    if (word == "END_OF_TEXT")
      break;
    for (int i = 0; i < sizeof(word); i++) {
      word[i] = tolower(word[i]);
    }
    if (word == the)
      count++;
  }
  cout << count << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  int count = 0;
  string word, the;
  cin >> the;
  while (1) {
    cin >> word;
    for (int i = 0; i < sizeof(word); i++) {
      word[i] = tolower(word[i]);
    }
    if (word == "END_OF_TEXT")
      break;
    else if (word == the) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}
Problem p02419 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  string w;
  string t;
  int i;
  int count = 0;

  cin >> w;

  for (i = 0; w[i] != '\\0'; i++) {
    w[i] = static_cast<char>(toupper(w[i]));
  }

  while (cin >> t) {
    // cin >> t;
    if (t == "END_OF_TEXT")
      break;

    for (i = 0; t[i] != '\\0'; i++) {
      t[i] = static_cast<char>(toupper(t[i]));
    }

    if (t == w) {
      count++;
    }
  }

  cout << count << "\\n";
}

Error: TLE

Fixed submission:

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

int main() {
  string w;
  string t;
  int i;
  int count;
  char w2;

  cin >> w;

  for (i = 0; w[i] != '\\0'; i++) {
    w[i] = static_cast<char>(tolower(w[i]));
  }

  cout << w << "\\n";
  while (1) {
    cin >> t;

    for (i = 0; t[i] != '\\0'; i++) {
      t[i] = static_cast<char>(tolower(t[i]));
    }
    cout << t << "\\n";
    if (t == w) {
      count++;
    }

    if (t == "END_OF_TEXT")
      break;
  }

  cout << count << "\\n";
}
Problem p02419 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
char tolower(char ch) {
  if ('A' <= ch && ch && ch <= 'Z') {
    return ch - 'A' + 'a';
  } else {
    return ch;
  }
}
int main() {
  int count = 0;
  string W;
  cin >> W;
  string str;
  while (1) {
    cin >> str;
    if (str == "END_OF_TEXT")
      break;
    for (int i = 0; i < (int)str.size(); i++) {
      str[i] = tolower(str[i]);
    }
    if (str == W) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
char tolower(char ch) {
  if ('A' <= ch && ch && ch <= 'Z') {
    return ch - 'A' + 'a';
  } else {
    return ch;
  }
}
int main() {
  int count = 0;
  string W;
  cin >> W;
  string str;
  while (1) {
    cin >> str;
    if (str == "END_PF_TEXT")
      break;
    for (int i = 0; i < (int)str.size(); i++) {
      str[i] = tolower(str[i]);
    }
    if (str == W) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}
Problem p02419 (C++) — buggy submission, verdict: Runtime Error

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

string Transition(string Word) {
  for (int i = 0; i < Word.size(); i++) {
    if ('a' <= Word[i] && Word[i] <= 'z')
      Word[i] += 'A' - 'a';
  }
  return Word;
}

vector<string> ReadWords(vector<string> Sentence) {
  //	?????????????????????????????????END_OF_TEXT??§???????????°??§???????????´?????????????????????????????????
  while (1) {
    string Go;
    cin >> Go;
    if (Go == "END_OF_TEXT")
      break;
    for (int i = 0; i < Go.size(); i++) {
      if ('a' <= Go[i] && Go[i] <= 'z')
        Go[i] += 'A' - 'a';
    }
    Sentence.push_back(Go);
  }
  return Sentence;
}

int Count(string Word, vector<string> Sentence) {
  //	?????????????????????????????????????????????????????°?????????
  int C = 0;
  for (int i = 0; i < Sentence.size(); i++) {
    if (Sentence[i] == Word)
      C++;
  }
  return C;
}

int main() {
  //	??????????????????????????§???????????´??????
  string Word;
  cin >> Word;
  Word = Transition(Word);
  //	????????????????????????
  vector<string> Sentence;
  Sentence = ReadWords(Sentence);
  //	for(int i = 0; i < Sentence.size(); i++){
  //		cout << Sentence[i];
  //	}
  //	?????????????????????????????????????????°??????????????????
  int X = Count(Word, Sentence);
  cout << X << endl;

  //	system("pause");
  return 0;
}

Error: -11

Fixed submission:

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

int main() {
  string Word;
  string Sentence;
  int Count = 0;
  vector<int> Judge(1000, 1);

  cin >> Word;
  while (getline(cin, Sentence)) {
    if (Sentence == "END_OF_TEXT")
      break;
    for (int i = 0; i <= Sentence.size() - Word.size(); i++) {
      for (int j = 0; j < Word.size(); j++) {
        if (Word[j] != Sentence[i + j])
          Judge[i] = 0;
      }
      if (Judge[i] == 1)
        Count++;
    }
  }
  cout << Count << endl;

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

#include <iostream>
#include <string>

using namespace std;

int main() {
  string T, S;
  int count = 0, i;
  cin >> S;
  while (cin >> T, T != "END_OF_TEXT") {
    for (i = 0; i < T.size(); i++) {
      if (T[i] >= 'A' && T[i] <= 'Z')
        T[i] += 32;
    }
    if (T == S)
      count++;
  }
  cout << count << endl;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

int main() {
  string T, S;
  int count = 0, i;
  cin >> S;
  while (T != "END_OF_TEXT") {
    cin >> T;
    for (i = 0; i < T.size(); i++) {
      if (T[i] >= 'A' && T[i] <= 'Z')
        T[i] += 32;
    }
    if (T == S)
      count++;
  }
  cout << count << endl;
}
Problem p02419 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  string p[1000];
  int i, j, k;
  string W, T, line;
  cin >> W;
  while (getline(cin, T)) {
    if (T == "END_OF_TEXT")
      break;

    line = line + T + " ";
  }
  transform(W.begin(), W.end(), W.begin(), ::tolower);
  transform(line.begin(), line.end(), line.begin(), ::tolower);
  k = 0;
  for (i = 0; i < line.size(); i++) {
    if (line[i] >= 'a' && line[i] <= 'z') {
      string s;
      for (j = i;; j++) {
        if (isspace(line[j])) {
          i = j--;
          break;
        } else {
          s.push_back(line[j]);
        }
      }
      p[k] = s;
      k++;
    }
  }
  int c = 0;
  for (int i = 0; i < 1000; i++)
    if (p[i] == W)
      c++;

  cout << c << endl;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
string f(string x) {
  for (int i = 0; i < x.size(); i++) {
    if (x[i] <= 'Z' and x[i] >= 'A') {
      x[i] = x[i + 32];
    }
  }
  return x;
}
int main() {
  freopen("input.txt", "r", stdin);
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string a;
  cin >> a;
  string d = f(a);
  map<string, int> m;
  string b;
  while (cin >> b) {
    string c = f(b);
    m[c]++;
  }
  map<string, int>::iterator it;
  for (it = m.begin(); it != m.end(); it++) {
    cout << m[a];
    return 0;
  }
}
Problem p02419 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
int main() {

  string s, S;
  int cnt = 0;
  getline(cin, s);
  for (int i = 0; i < s.size(); i++) {
    s[i] = tolower(s[i]);
  }
  while (getline(cin, S) && S != "END_OF_TEXT") {
    stringstream ss;
    ss << S;
    string w;
    while (ss >> w) {
      for (int i = 0; i < w.size(); i++) {
        w[i] = tolower(w[i]);
      }
      if (w == s) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <locale.h>
#include <map>
#include <set>
#include <string>
#include <vector>

#define all(x) x.begin(), x.end()
#define sz(x) (int)(x.size())
#define pb push_back
#define mp make_pair
#define endl "\\n"
#define rep(i, x, y) for (int i = x; i <= y; ++i)
#define repr(i, x, y) for (int i = x; i >= y; --i)
#define y1 wearsdfasdf
#define fi first
#define se second

typedef long long ll;

const int N = (int)(5e5) + 322;
const ll INF = (ll)(1e9) + 7;
const double eps = (1e-9);

using namespace std;

int main() {
  string s;
  cin >> s;
  rep(i, 0, sz(s) - 1) { s[i] = tolower(s[i]); }
  string t;
  int cnt = 0;
  while (true) {
    string cur;
    cin >> cur;
    rep(i, 0, sz(cur) - 1) { cur[i] = tolower(cur[i]); }
    if (cur == "END_OF_TEXT")
      break;
    if (cur == s)
      cnt++;
  }
  cout << cnt;
  return 0;
}
Problem p02419 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
using namespace std;
int main(void) {
  string w;
  string t;
  int count = 0;

  cin >> w;
  for (int i = 0; i < w.size(); i++) {
    if ('A' <= w[i] && w[i] <= 'Z')
      w[i] += 'a' - 'A';
  }

  cin >> t;
  while (t != "END_OF_TEXT") {
    for (int i = 0; i < t.size(); i++) {
      if ('A' <= t[i] && t[i] <= 'Z')
        t[i] += 'a' - 'A';
    }
    if (w == t)
      count++;
    cin >> t;
  }
  cout << count << endl;
}


Error: -11

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main(void) {
  string w;
  string t;
  int count = 0;

  cin >> w;
  for (int i = 0; w.size(); i++) {
    if ('A' <= w[i] && w[i] <= 'Z')
      w[i] += 'a' - 'A';
  }

  cin >> t;
  while (t != "END_OF_TEXT") {
    for (int i = 0; i < t.size(); i++) {
      if ('A' <= w[i] && w[i] <= 'Z')
        t[i] += 'a' - 'A';
    }
    if (w == t)
      count++;
  }
  cout << count << endl;
  cin >> t;

  return 0;
}