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

#include <ctype.h>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;
string str, str2;
int main() {
  int count = 0;
  std::cin >> str2;
  for (int i = 0; i < str2.size(); i++)
    str2[i] = tolower(str2[i]);

  while (std::cin.eof() == false) {
    std::cin >> str;
    if (str == "END_OF_TEXT")
      break;
    for (int i = 0; i < str.size(); i++) {
      str[i] = tolower(str[i]);
    }
    if (str2 == str)
      count++;
  }
  std::cout << count << "\\n";
}


Error: 1

Fixed submission:

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

bool icompare_pred(unsigned char a, unsigned char b) {
  return tolower(a) == tolower(b);
}

bool icompare(string const &a, string const &b) {
  if (a.length() == b.length())
    return equal(b.begin(), b.end(), a.begin(), icompare_pred);
  else
    return false;
}

int main() {
  string word;
  cin >> word;
  string s;
  int cnt = 0;

  while (!icompare(s, "END_OF_TEXT")) {
    cin >> s;
    if (icompare(s, word))
      cnt++;
  }
  cout << cnt << endl;
  return 1;
}
Problem p02419 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define vvi vector<vector<int>>
#define vi vector<int>
#define All(X) X.begin(), X.end()
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

int main() {
  string W = "";
  string S = "";
  string T = "";
  int j = 0;
  int b = 0;
  int i = 0;
  cin >> W;
  getline(cin, T);
  do {
    S += T;
    getline(cin, T);
    T += " ";
  } while (T != "END_OF_TEXT ");
  T = "";
  S = upper(S);
  W = upper(W);
  while (i < S.size()) {
    while (S[i] != ' ') {
      T += S[i];
      i++;
    }
    if (T == W) {
      b++;
    }
    T = "";
    i++;
  }
  cout << b << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define vvi vector<vector<int>>
#define vi vector<int>
#define All(X) X.begin(), X.end()
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

int main() {
  string W;
  string S, T = "";
  int j, b = 0;
  cin >> W;
  do {
    S += T;
    getline(cin, T);
  } while (T != "END_OF_TEXT");
  REP(i, S.size()) {
    if (S[i] == W[j]) {
      j = j + 1;
    } else {
      j = 0;
    }
    if (W.size() == j) {
      b = b + 1;
    }
  }
  cout << b << endl;
  return 0;
}
Problem p02419 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <stack>
#include <string>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define llong long long
#define INF 999999999
#define pb(a) push_back(a)

using namespace std;

vector<string> split(string str, char delim) {
  vector<string> res;
  size_t current = 0, found;
  while ((found = str.find_first_of(delim, current)) != string::npos) {
    string tmp = string(str, current, found - current);
    res.push_back(tmp);
    current = found + 1;
  }
  string tmp = string(str, current, found - current);
  tmp.replace(tmp.size() - 1, tmp.size(), "\\0");
  res.push_back(string(str, current, str.size() - current));
  return res;
}

char *StrToUpper(char *s) {
  char *p;
  for (p = s; *p; p++) {
    *p = toupper(*p);
  }
  return s;
}

int main() {
  char cword[11];
  cin >> cword;

  int cnt = 0;

  while (1) {
    char cstr[1001];
    cin >> cstr;

    if (string(cstr).find("END_OF_TEXT") != string::npos)
      break;

    string word = StrToUpper(cword);
    vector<string> vec = split(StrToUpper(cstr), ' ');
    // transform(word.begin(), word.end(), word.begin(), toupper);
    // transform(str.begin(), str.end(), str.begin(), toupper);
    int num = 0;

    for (int i = 0; i < vec.size(); i++) {
      if (vec[i] == word)
        cnt++;
    }
  }

  printf("%d\\n", cnt);
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <stack>
#include <string>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define llong long long
#define INF 999999999
#define pb(a) push_back(a)

using namespace std;

vector<string> split(string str, char delim) {
  vector<string> res;
  size_t current = 0, found;
  while ((found = str.find_first_of(delim, current)) != string::npos) {
    string tmp = string(str, current, found - current);
    res.push_back(tmp);
    current = found + 1;
  }
  string tmp = string(str, current, found - current);
  tmp.replace(tmp.size() - 1, tmp.size(), "\\0");
  res.push_back(string(str, current, str.size() - current));
  return res;
}

char *StrToUpper(char *s) {
  char *p;
  for (p = s; *p; p++) {
    *p = toupper(*p);
  }
  return s;
}

int main() {
  char cword[11];
  cin >> cword;

  int cnt = 0;

  while (1) {
    char cstr[1001];
    cin >> cstr;

    if (string(cstr).find("END_OF_TEXT") != string::npos)
      break;

    string word = StrToUpper(cword);
    vector<string> vec = split(StrToUpper(cstr), ' ');
    // transform(word.begin(), word.end(), word.begin(), toupper);
    // transform(str.begin(), str.end(), str.begin(), toupper);
    int num = 0;

    for (int i = 0; i < vec.size(); i++) {
      if (vec[i] == word)
        cnt++;
    }
  }

  printf("%d\\n", cnt);

  while (1) {
  }
}
Problem p02419 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int judge, count = 0;
  char str[1001];
  string word;
  string text;
  string eot = "END_OF_TEXT";

  cin >> word;
  transform(word.begin(), word.end(), word.begin(), ::tolower);
  while (1) {
    cin >> text;
    if (text == eot)
      break;
    // if ( 0== (judge=stricmp( word.c_str() , text.c_str()))) count+=1;
    transform(text.begin(), text.end(), text.begin(), ::tolower);
    if (word == text)
      count += 1;
  }
  cout << count << endl;
  return 0;
}

Error: -11

Fixed submission:

#include <cstdio>
#include <iostream>
int main() {
  int i = 0, j = 0, k, num, num2, count = 0;
  char text[1001];
  char word[11];
  char tmp = 1;
  while (scanf("%c", &tmp) != '\\n') {
    word[j] = tmp;
    j++;
  }
  num2 = j - 1;
  while (scanf("%c", &tmp) != EOF) {
    text[i] = tmp;
    i++;
  }
  num = i - 12;
  for (i = 0; i < num; i++) {
    for (j = 0, k = i; j < num2; j++, k++) {
      if (word[j] != text[k])
        break;
      if (j == num2 - 1) {
        count += 1;
      }
    }
  }
  std::cout << count << std::endl;
  return 0;
}
Problem p02419 (C++) — buggy submission, verdict: Runtime Error

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

string low(string w) {
  string w_ = "";
  for (int i = 0; i < w.size(); i++) {
    if (w[i] >= 'A' && w[i] <= 'Z') {
      w_ += w[i] + 32;
    } else {
      w_ += w[i];
    }
  }
  return w_;
}

int main() {
  string w;
  cin >> w;
  string t;
  string tmp = "";
  int cnt = 0;
  int line = 0;
  w = low(w);

  string tango = "";

  while (true) {
    getline(cin, t);
    if (t == "END_OF_TEXT") {
      if (tango == w) {
        cnt += 1;
      }
      break;
    }
    t = low(t);

    // for(int i=0;i<t.size();i++){
    //     if(i==0){
    //         if(tmp==w){
    //             cnt++;
    //         }
    //         tmp="";
    //     }

    //     if(t[i]!=' '){
    //         tmp += t[i];
    //     }else{
    //         if(tmp==w){
    //             cnt++;
    //         }
    //         tmp="";
    //     }
    // }
    for (int i = 0; i < t.size(); i++) {
      if (i == 0) {
        if (tango == w) {
          cnt += 1;
        }
        tango = "";
      }

      if (t[i] != ' ') {
        tango += t[i];
      } else {
        if (tango == w) {
          cnt += 1;
        }
        tango = "";
      }
    }
    // cout << cnt<< endl;
  }

  cout << cnt << endl;
  return 0;
}


Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr: __pos (which is 4) > this->size() (which is 3)


Fixed submission:

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

string low(string w) {
  string w_ = "";
  for (int i = 0; i < w.size(); i++) {
    if (w[i] >= 'A' && w[i] <= 'Z') {
      w_ += w[i] + 32;
    } else {
      w_ += w[i];
    }
  }
  return w_;
}

int main() {
  string w;
  string t;
  int cnt = 0;
  cin >> w;
  w = low(w);

  while (true) {
    cin >> t;
    if (t == "END_OF_TEXT")
      break;
    t = low(t);
    for (int i = 0; i < t.size() - w.size() + 1; i++) {
      if (t.substr(i, w.size()) == w) {
        cnt++;
        // cout << t.substr(i, w.size()) << endl;
      }
    }
    // cout << cnt << endl;
  }
  cout << cnt << endl;
  return 0;
}
Problem p02419 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;

#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define For(i, a, b) for (int(i) = (a); (i) < (b); (i)++)

int main() {
  string s;
  cin >> s;
  transform(s.begin(), s.end(), s.begin(), ::tolower);
  string w;
  int cnt = 0;
  while (cin >> w, w != "END_OF_TEXT") {
    transform(w.begin(), w.end(), w.begin(), ::tolower);
    if (s == w)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;

#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define For(i, a, b) for (int(i) = (a); (i) < (b); (i)++)

int main() {
  string s;
  cin >> s;
  string w;
  int cnt = 0;
  while (cin >> w, w != "EOF_OF_TEXT") {
    if (w == s)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}
Problem p02419 (C++) — buggy submission, verdict: Runtime Error


#include <cctype>
#include <cstring>
#include <ctype.h>
#include <iostream>
#include <locale>
#include <stdio.h>
#include <string>
using namespace std;

int main() {
  char s[20];
  cin >> s;
  int n = 0;
  while (true) {

    char p[20];

    cin >> p;

    if (strcmp(p, "END_OF_TEXT") == 0) {
      break;
    } else {
      for (int i = 0; i < strlen(p); i++) {
        p[i] = tolower(p[i]);
      }

      if (strcmp(p, s) == 0) {
        n += 1;
      }
    }
  }

  cout << n << endl;
  return 0;
}


Error: WA

Fixed submission:


#include <cctype>
#include <cstring>
#include <ctype.h>
#include <iostream>
#include <locale>
#include <stdio.h>
#include <string>
using namespace std;

int main() {
  string s;
  cin >> s;
  int n = 0;
  while (true) {

    char *p;
    cin >> p;
    if (strcmp(p, "END_OF_TEXT")) {
      break;
    } else {
      for (int i = 0; i < strlen(p); i++) {
        p[i] = tolower(p[i]);
      }
      if (p == s) {
        n++;
      }
    }
  }

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

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

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

Error: WA

Fixed submission:

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

int main() {
  int i, j, count, wn, tn;
  string w, t;
  cin >> w;
  cin >> t;
  wn = w.size();
  tn = t.size();
  while (i != tn) {
    if (islower(w[i])) {
      w[i] = toupper(w[i]);
    }
    if (islower(t[j])) {
      t[j] = toupper(t[j]);
    }
    if (t[i] == '\\n') {
      break;
    }
    if (t[i] == w[j]) {
      j++;
      if (j == wn) {
        j = 0;
        count++;
      }
    }
    if (j != 0 && t[i] != w[j]) {
      j = 0;
    }
    i++;
  }
  cout << count << endl;
}
Problem p02419 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
using namespace std;
int main() {
  string a, b; //??????????????????????????\\????????????????????\\????????????
  int sum = 0;
  cin >> a;
  while (cin >> b) //????????\\??¨cin????°±?????¨??????????????????????\\????
  {
    if (b == "END_OF_TEXT")
      break;
    //??\\????????°?????°
    //?°±?????¨??????????????????????????\\?????¨for
    for (int j = 0; j < b.length(); j++)
      b[j] = tolower(b[j]);

    if (b[0] != a[0])
      continue;

    int i = b.find(a[0]); // a?????????
    int k = 0;

    for (
        i;
        i <
        b.length();) //??????????????????????????°??¨?\\????????????\\??¨cin??´?§£?????????????°±????????????
    {

      if (b[i] ==
          a[k]) //?????????i?????\\????????°b???0???????¬¬????????????,??????????????°??????????????°????¬¬???????????????????????¨???,??????i?????\\????¬¬??????????????????
      {
        i++;
        k++;

        if (k == a.length() &&
            i ==
                b.length()) //????????°????????????????????????????????????.&&i==b.length()
        {
          sum++;
          break;
        }

      } else
        break;
    }
  }

  cout << sum << endl; //???????????????????????¬???
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
using namespace std;
int main() {
  string a, b; //??????????????????????????\\????????????????????\\????????????
  int sum = 0;
  cin >> a;
  while (getline(cin, b)) {
    if (b == "END_OF_TEXT")
      break;
    //??\\????????°?????°
    //?°±?????¨??????????????????????????\\?????¨for
    int i = b.find(a[0], 0); // a?????????
    int k = 0;
    for (
        ;
        i <
        b.length();) //??????????????????????????°??¨?\\????????????\\??¨cin??´?§£?????????????°±????????????
    {

      if (b[i] ==
          a[k]) //?????????i?????\\????????°b???0???????¬¬????????????,??????????????°??????????????°????¬¬???????????????????????¨???,??????i?????\\????¬¬??????????????????
      {

        i++;
        k++;
        if (k == a.length()) //????????°????????????????????????????????????.
        {
          sum++;
          break;
        }
      }
    }
  }
  cout << sum << endl; //???????????????????????¬???
}
Problem p02419 (C++) — buggy submission, verdict: Time Limit Exceeded

/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_9_A
 */
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>

using namespace std;

template <typename T_char> T_char ToLower(T_char c) { return tolower(c); }

int main() {
  ios::sync_with_stdio(false);

  string W;
  getline(cin, W);

  int count = 0;
  while (true) {
    string line;
    getline(cin, line);

    if (line == "END_OF_TEXT") {
      break;
    }
    transform(line.begin(), line.end(), line.begin(), ToLower<char>);
    stringstream ss(line);
    while (!ss.eof()) {
      string s;
      ss >> s;
      if (s == W) {
        count++;
      }
    }
  }
  cout << count << endl;

  return 0;
}

Error: TLE

Fixed submission:

/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_9_A
 */
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

template <typename T_char> T_char ToLower(T_char c) { return tolower(c); }

int main() {
  ios::sync_with_stdio(false);

  string W;
  getline(cin, W);

  int count = 0;
  while (true) {
    string line;
    getline(cin, line);
    transform(line.begin(), line.end(), line.begin(), ToLower<char>);

    if (line == "END_OF_TEXT") {
      break;
    }
    int pos = 0;
    while (true) {
      size_t found = line.find(W, pos);
      if (found == string::npos) {
        break;
      }
      count++;
      pos = found + 1;
    }
  }
  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;

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

  int cnt = 0;

  while (true) {
    string T;
    cin >> T;

    if (T == "END_OF_TEXT")
      break;

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

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

  cout << cnt << endl;

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int i, count = 0;
  char w[10], t[1000];
  int T_length;
  std::string s, W;

  cin >> w;
  for (i = 0; w[i] != 0; i++) {
    if (isupper(w[i]))
      w[i] = tolower(w[i]);
  }

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

    if (s.length() > W.length() + 1)
      continue;
    for (i = 0; w[i] != 0; i++) {
      if (isupper(t[i]))
        t[i] = tolower(t[i]);
    }
    if (s == w)
      count++;
  }
  cout << count << endl;
  return 0;
}
Problem p02419 (C++) — buggy submission, verdict: Runtime Error

#include <cctype>
#include <iostream>
#include <string>
using namespace std;
int main() {
  string a;
  string b;
  string f;
  string g;
  int c = 0, d, e;
  cin >> a;
  d = a.size();
  while (true) {
    b = "";
    cin >> f;
    e = f.size();
    if (f == "END_OF_TEXT") {
      cout << c << endl;
      break;
    }
    for (int i = 0; i < e; i++) {
      b += tolower(f[i]);
    }
    if (b == a) {
      c++;
    }
  }
  return 0;
}

Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr: __pos (which is 4) > this->size() (which is 3)


Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  string a;
  string b;
  int c = 0;
  cin >> a;
  while (true) {
    cin >> b;
    if (b == "END_OF_TEXT") {
      cout << c << endl;
      break;
    }
    for (int i = 0; i <= b.size() - a.size(); i++) {
      if (a == b.substr(i, a.size())) {
        c++;
      }
    }
  }
  return 0;
}
Problem p02419 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cctype>
#include <climits>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <string>

using namespace std;

int main() {
  string W, str;
  int cnt = 0;
  cin >> W;
  transform(W.begin(), W.end(), W.begin(), ::tolower);
  while (cin >> str) {
    if (str == "END_OF_TEXT")
      break;
    transform(str.begin(), str.end(), str.begin(), ::tolower);
    if (W == str)
      cnt++;
  }
  cout << cnt << endl;
}

Error: TLE

Fixed submission:

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

using namespace std;

int main() {
  string W, str;
  int cnt = 0;
  cin >> W;
  transform(W.begin(), W.end(), W.begin(), ::tolower);
  do {
    cin >> str;
    transform(str.begin(), str.end(), str.begin(), ::tolower);
    if (W == str)
      cnt++;
  } while (str != "END_OF_TEXT");
  cout << cnt << endl;
}
Problem p02419 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int count = 0;
  std::string W;
  std::cin >> W;
  std::string str;
  while (1) {
    std::cin >> str;
    if (str == "END_OF_TEXT")
      break;
    std::transform(str.begin(), str.end(), str.begin(), tolower);
    if (str == W) {
      count++;
    }
  }
  std::cout << count << std::endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
#include <string>

int BruteForceSearch(std::string w, std::string t) {
  int i = 0, j = 0, n = 0;
  while (i < t.length()) {
    while (j < w.length()) {
      if (t[i] == w[j]) {
        i++;
        j++;
      } else {
        i = i - j + 1;
        j = 0;
      }
    }
    if (j == w.length())
      n++;
  }
  return n;
}

int main(void) {
  std::string t, w;
  std::getline(std::cin, w);
  int n = 0;
  while (1) {
    std::getline(std::cin, t);
    if (t == "END_OF_TEXT")
      break;
    n += BruteForceSearch(w, t);
  }
  std::cout << n << std::endl;
  return 0;
}
Problem p02419 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string y;
  int a = 0;
  cin >> y;
  string x;
  while (true) {
    cin >> x;
    if (x == "END_OF_TEXT")
      break;
    for (int i = 0; i < x.size(); i++) {
      x.at(i) = (char)tolower(x.at(i));
    }

    if (x == y)
      a++;
  }
  cout << a << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string y;
  int a = 0;
  cin >> y;
  string x;
  while (true) {
    cin >> x;
    for (int i = 0; i < x.size(); i++) {
      x.at(i) = (char)tolower(x.at(i));
    }
    if (x == "END_OF_TEXT")
      break;
    if (x == y)
      a++;
  }
  cout << a << endl;
  return 0;
}
Problem p02419 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string>

using namespace std;

int main() {
  int count = 0;
  string W, word;
  cin >> W;
  int size = W.size();
  for (int i = 0; i < size; i++) {
    W[i] = toupper(W[i]);
  }
  while (1) {
    cin >> word;
    if (word == "END_OF_TEXT")
      break;
    int size = word.size();
    for (int i = 0; i < size; i++) {
      word[i] = toupper(word[i]);
    }
    if (word == W)
      count++;
  }
  cout << count << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

int main() {
  int count = 0;
  string W, word;
  while (1) {
    cin >> W;
    if (W == "END_OF_TEXT")
      break;
    cin >> word;
    if (word == W)
      count++;
  }
  cout << count << endl;
  return 0;
}