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

#include <iostream>
#include <map>

int main(void) {
  int n, N;
  int i, num_item = 0;
  std::string s;
  std::map<std::string, int> item;

  std::cin >> N;

  for (n = 0; n < N; n++) {
    std::cin >> s;
    item[s] = 1;
  }

  std::cout << item.size() << std::endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

#define MAXLINE 200000

int main(void) {
  int n, N;
  int flg;
  int i, num_item = 0;
  std::string s;
  std::string S[MAXLINE];

  std::cin >> N;

  for (n = 0; n < N; n++) {
    std::cin >> s;
    flg = 0;

    for (i = 0; i < num_item; i++) {
      if (S[i] == s) {
        flg = 1;
        break;
      }
    }

    if (!flg) {
      S[num_item] = s;
      num_item = num_item + 1;
    }
  }

  std::cout << num_item << std::endl;

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

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
int main() {
  vector<vector<string>> s(10, vector<string>());
  vector<int> k(10, 0);
  string l;
  int c, x = 0, p;
  cin >> c;
  for (int i = 0; i < c; i++) {
    cin >> l;
    p = l.size();
    s.at(p - 1).push_back(l);
    k.at(p - 1) += 1;
    if (i % 1000 == 0) {
      for (int q = 0; q < 10; q++) {
        if (k.at(q) != s.at(q).size()) {
          sort(s.at(q).begin(), s.at(q).end());
          s.at(q).erase(unique(s.at(q).begin(), s.at(q).end()), s.at(q).end());
        }
      }
    }
  }
  for (int q = 0; q < 10; q++) {
    sort(s.at(q).begin(), s.at(q).end());
    s.at(q).erase(unique(s.at(q).begin(), s.at(q).end()), s.at(q).end());
  }
  for (int i = 0; i < 10; i++)
    x += s.at(i).size();
  cout << x;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
int main() {
  vector<string> s;
  string l;
  int c, x;
  cin >> c;
  for (int i = 0; i < c; i++) {
    cin >> l;
    s.push_back(l);
    if (i % 1000 == 0) {
      sort(s.begin(), s.end());
      s.erase(unique(s.begin(), s.end()), s.end());
    }
  }
  sort(s.begin(), s.end());
  s.erase(unique(s.begin(), s.end()), s.end());
  x = s.size();
  cout << x;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define rep0(i, n) for (int i = 1; i <= (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LO

int main() {
  int n;
  vector<string> s;
  cin >> n;
  rep(i, n) {
    string S;
    cin >> S;
    s.push_back(S);
  }

  sort(s.begin(), s.end());

  int ans = 1;
  rep(i, n - 1) {
    if (s[i] != s[i + 1]) {
      ans++;
    }
  }

  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define rep0(i, n) for (int i = 1; i <= (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LO

int main() {
  int n;
  vector<string> s;
  cin >> n;
  rep(i, n) {
    string S;
    cin >> S;
    s.push_back(S);
  }
  rep(i, n) { sort(s.begin(), s.end()); }
  int ans = 1;
  rep(i, n - 1) {
    if (s[i] != s[i + 1]) {
      ans++;
    }
  }

  cout << ans << endl;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#include <iostream>
#include <string.h>
#include <string>

using namespace std;

int main() {
  int n;
  cin >> n;
  set<string> s;
  for (int i = 0; i < n; i++) {
    string x;
    cin >> x;
    s.insert(x);
  }

  cout << s.size() << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <iostream>
#include <string.h>
#include <string>

using namespace std;

int main() {
  int n;
  string s[210000];
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> s[i];

  sort(s, s + n);

  int cnt = 1, t;
  for (int i = 0; i < n; i++) {
    bool flag = 0;
    for (int j = i + 1; j < n; j++) {
      if (s[i] != s[j]) {
        flag = 1;
        t = j;
        break;
      }
    }
    if (flag) {
      i = t - 1;
      cnt++;
    }
  }

  cout << cnt << endl;
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;

int main(void) {
  int n;
  scanf("%d", &n);
  char s[10];
  map<string, int> mp;
  for (int i = 0; i < n; i++) {
    scanf("%s", &s[0]);
    auto itr = mp.find(s);
    if (itr == mp.end()) {
      mp[s] = 1;
    }
  }
  printf("%d\\n", mp.size());
  return (0);
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

int main(void) {
  int n;
  scanf("%d", &n);
  char s[200000][10];
  for (int i = 0; i < n; i++)
    scanf("%s", &s[i][0]);
  int ans = 0;

  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (strcmp(s[i], s[j]) == 0)
        s[j][0] = 'A';
    }
  }

  for (int i = 0; i < n; i++) {
    if (s[i][0] != 'A')
      ans++;
  }

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

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

#include <iostream>
#include <set>
#include <string>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main() {
  int n, i;
  string input;
  set<string> s;
  cin >> n;
  rep(i, n) {
    cin >> input;
    s.insert(input);
  }
  cout << s.size() << endl;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

int main() {
  int n, i, j, pointer = 0, flag = 0, ans = 0;
  cin >> n;
  string input, a[n];
  for (i = 0; i < n; i++) {
    cin >> input;
    for (j = 0; j <= pointer; j++) {
      if (a[j].compare(input) == 0) {
        flag = 1;
      }
    }
    if (flag == 0) {
      a[pointer++] = input;
      ans++;
    } else {
      flag = 0;
    }
  }
  // for(i=0;i<pointer;i++){
  //     cout<<i<<";"<<a[i]<<endl;
  // }
  cout << ans << endl;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  set<string> S;
  for (int i = 0; i < N; i++) {
    string ST;
    cin >> ST;
    S.insert(ST);
  }
  cout << S.size() << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  int count1 = 1;
  vector<string> a(N);
  for (int i = 0; i < N; i++) {
    string ST;
    cin >> ST;
    a.at(i) = ST;
  }
  for (int i = 1; i < N; i++) {
    int count2 = 0;
    for (int k = 0; k < i; k++) {
      if (a.at(i) == a.at(k)) {
        count2++;
      }
    }
    if (count2 == 0)
      count1++;
  }

  cout << count1 << endl;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, flag = 0;
  cin >> N;
  string tmp;
  std::map<std::string, int> salary{};
  for (int i = 0; i < N; i++) {
    cin >> tmp;
    salary[tmp] = 0;
  }
  cout << salary.size();
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, flag = 0;
  cin >> N;
  string a[N];
  string tmp;
  int ans = 1;

  cin >> a[0];
  for (int i = 1; i < N; i++) {
    cin >> tmp;

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

      if (tmp == a[j]) {
        flag++;
        break;
      }
    }
    if (flag != 1) {
      ans++;
      a[i] = tmp;
    }
    flag = 0;
  }
  cout << ans;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#include <numeric>
#define mod 1000000007
using namespace std;

int main() {
  int t;
  vector<string> vec;
  cin >> t;
  while (t--) {
    string str;
    cin >> str;

    vec.push_back(str);
  }
  int ans = set<string>(vec.begin(), vec.end()).size();
  cout << ans;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <numeric>
#include <vector>
#define mod 1000000007
using namespace std;

int main() {
  int t;
  vector<string> vec;
  cin >> t;
  while (t--) {
    std::vector<string>::iterator it;
    string str;
    cin >> str;
    it = std::find(vec.begin(), vec.end(), str);
    if (it != vec.end()) {
      continue;
    } else
      vec.push_back(str);
  }
  cout << vec.size();
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <vector>

using namespace std;
using ll = long long;
const ll res = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n;
  cin >> n;
  int cnt = 1;
  vector<string> s(n);

  rep(i, n) cin >> s[i];
  sort(s.begin(), s.end());

  for (int i = 0; i < n - 1; i++) {
    if (s[i] != s[i + 1])
      cnt++;
  }

  cout << cnt << endl;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <vector>

using namespace std;
using ll = long long;
const ll res = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n;
  cin >> n;
  int cnt = 0;
  vector<string> s(n);
  vector<int> f(n, 0);

  rep(i, n) cin >> s[i];

  rep(i, n) {
    if (f[i] == 0) {
      cnt++;
      f[i] = 1;
      for (int j = i + 1; j < n; j++) {
        if (s[i] == s[j])
          f[j] = 1;
      }
    } else {
      continue;
    }
  }

  cout << cnt << endl;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
using p = pair<int, int>;
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)

signed main() {
  int N;
  cin >> N;
  vector<string> A(N);
  rep(i, N) cin >> A[i];
  int ans = 1;
  sort(begin(A), end(A));
  rep(i, N - 1) {
    if (A[i] != A[i + 1])
      ans += 1;
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using p = pair<int, int>;
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)

signed main() {
  int N;
  cin >> N;
  vector<string> A(N), B(N);
  int co = 0, ans = 0;
  rep(i, N) cin >> A[i];
  rep(i, N) {
    int equal = 0;
    rep(j, B.size()) if (A[i] == B[j]) equal += 1;
    if (equal == 0) {
      B[co] = A[i];
      ans++;
      co++;
    }
  }
  cout << ans << endl;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++)
    cin >> s[i];
  sort(s.begin(), s.end());
  s.erase(unique(s.begin(), s.end()), s.end());
  cout << s.size() << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

bool vector_finder(vector<string> vec, string str) {
  auto itr = find(vec.begin(), vec.end(), str);
  size_t index = distance(vec.begin(), itr);
  if (index != vec.size()) {
    return false;
  } else {
    return true;
  }
}

int main() {
  int n, ans = 0;
  cin >> n;
  vector<string> s(n);
  vector<string> a;
  for (int i = 0; i < n; i++)
    cin >> s[i];
  for (int i = 0; i < n; i++) {
    if (vector_finder(a, s[i])) {
      ans++;
      a.push_back(s[i]);
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < n; i++)
using namespace std;

int main() {
  long long N, K, gcd_ab;
  long long count = 0;
  string temp;
  bool chohuku;
  vector<string> S;

  cin >> N;
  count = N;

  rep(i, N) {
    cin >> temp;
    S.push_back(temp);
    //     cout << S[i];
  }
  // sort(S.begin(),S.end());
  std::sort(S.begin(), S.end());

  rep(i, N - 1) {
    //     cout << S[i];
    if (S[i] == S[i + 1]) {
      count--;
    }
  }

  cout << count << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < n; i++)
using namespace std;

int main() {
  long long N, K, gcd_ab;
  long long count = 0;
  string temp;
  bool chohuku;
  vector<string> S(300000);

  cin >> N;

  rep(i, N) {
    cin >> temp;
    if (count == 0) {
      S[0] = temp;
      count++;
      continue;
    }
    chohuku = false;
    rep(j, count) {
      if (temp == S[j]) {
        chohuku = true;
        break;
      }
    }
    if (chohuku == false) {
      S[count] = temp;
      count++;
    }
  }

  cout << count << endl;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;

int main() {
  unordered_map<string, int> u;
  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (u.count(s) == 0) {
      u[s] = 1;
    }
  }
  cout << u.size();
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  string arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int sum = 1;
  int j;
  for (int i = 1; i < n; i++) {
    for (j = 0; j < i; j++) {
      if (arr[i] == arr[j]) {
        break;
      }
    }
    if (j == i) {
      sum = sum + 1;
    }
  }
  cout << sum;
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  sort(s.begin(), s.end());
  int cnt = 1;
  for (int i = 1; i < n; i++) {
    if (s[i] != s[i - 1])
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  sort(s.begin(), s.end());
  int cnt = 0;
  rep(i, n) {
    if (s[i] != s[i - 1])
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<string> str(n);
  rep(i, n) cin >> str[i];
  sort(str.begin(), str.end());
  int cnt = 1;
  for (int i = 1; i < n; i++) {
    if (str[i - 1] != str[i])
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<string> str(n);
  rep(i, n) cin >> str[i];
  sort(str.begin(), str.end());
  int cnt = 1;
  rep(i, n - 1) {
    if (str[i - 1] != str[i])
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  sort(s.begin(), s.end());
  int cnt = 1;
  for (int i = 1; i < n; i++) {
    if (s[i - 1] != s[i])
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  sort(s.begin(), s.end());
  int cnt = 0;
  rep(i, n) {
    if (s[i - 1] != s[i])
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  int cnt = 1;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  sort(s.begin(), s.end());
  for (int i = 1; i < n; i++) {
    if (s[i - 1] != s[i])
      cnt++;
  }
  cout << cnt << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  int cnt = 0;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  sort(s.begin(), s.end());
  rep(i, n) {
    if (s[i - 1] != s[i]) {
      cnt++;
    }
  }
  cout << cnt << endl;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;

int main() {
  long long n, cnt = 0;
  cin >> n;
  map<string, int> s;
  for (int i = 0; i < n; i++) {
    string a;
    cin >> a;

    if (s[a] == 0)
      s[a] = -1;
    else if (s[a] = -1) {
      cnt++;
    }
  }
  cout << n - cnt << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

int main() {
  long long n, cnt = 0;
  cin >> n;
  vector<string> str(11);

  for (int i = 0; i < n; i++) {
    string a;
    cin >> a;
    bool judge = false;
    int l = a.length();
    int vl = str[l].size();

    for (int k = 0; k < vl; k++) {
      string b = "";
      int t;
      for (t = k; t < l + k; t++) {
        b += str[l][t];
      }

      if (a == b) {
        judge = true;
        break;
      }
      k = t - 1;
    }

    if (!judge) {
      str[l] += a;
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < S.size(); i++)
    cin >> S.at(i);

  sort(S.begin(), S.end());

  int ans = N;

  for (int i = 1; i < S.size(); i++) {
    if (S.at(i) == S.at(i - 1))
      ans -= 1;
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  string word[N];
  int sum = 0;

  for (int i = 0; i < N; i++) {
    sum++;
    cin >> word[i];
    for (int j = 0; j < i; j++) {
      if (word[i].compare(word[j]) == 0) {
        sum = sum - 1;
        break;
      }
    }
  }
  cout << sum << endl;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

int main() {
  // freopen("input.txt", "r", stdin);

  int n;
  char str[11];
  map<string, int> item;

  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    scanf("%s", str);
    item[str]++;
  }

  printf("%d\\n", item.size());

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n, repeated_word_array[15];
  char item[200000][11];

  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%s", item[i]);

  for (int j = 0; j < n; j++)
    repeated_word_array[j] = 1;
  int c = 0;
  for (int j = 0; j < n - 1; j++) {
    if (item[j][0] != '\\0') {
      for (int l = j + 1; l < n; l++) {
        if (strcmp(item[j], item[l]) == 0) {
          repeated_word_array[c]++;
          item[l][0] = '\\0';
        }
      }
      c++;
    }
  }

  int count = 0;
  for (int i = 0; i < n; i++) {
    if (item[i][0] != '\\0')
      count++;
  }

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

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

#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, x = 0, sum = 1;
  cin >> n;
  bool p = 1, q = 1;
  vector<string> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  while (p) {
    q = 1;
    for (int k = 1; k < n - x; k++) {
      if (a[x] != a[x + k]) {
        sum++;
        x += k;
        q = 0;
        break;
      }
    }
    if (q == 1)
      p = 0;
  }
  cout << sum;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, x = 0, sum = 1;
  cin >> n;
  bool q = 1;
  vector<string> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  while (x < n) {
    for (int k = 1; k < n - x; k++) {
      if (a[x] != a[x + k]) {
        sum++;
        x += k;
      }
    }
  }
  cout << sum;
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

int main(void) {
  int N;
  string s;
  cin >> N;
  set<string> v;

  for (int i = 0; i < N; i++) {
    cin >> s;
    v.insert(s);
  }

  cout << v.size() << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main(void) {
  int N;
  string s;
  cin >> N;
  vector<string> v;

  for (int i = 0; i < N; i++) {
    cin >> s;
    if (find(v.begin(), v.end(), s) == v.end()) {
      v.push_back(s);
    }
  }

  cout << v.size() << endl;
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define REP(i, n) REPI(i, 0, n)
#define REPI(i, a, b) for (int i = (int)(a); i < (int)(b); i++)

#define SZ(x) ((int)(x).size())

using ll = long long;
using namespace std;

int main() {
  ll N;
  cin >> N;
  vector<string> S(N);
  string l;
  for (int i = 0; i < N; i++) {
    cin >> l;
    S.push_back(l);
  }

  sort(S.begin(), S.end());
  S.erase(unique(S.begin(), S.end()), S.end());
  // for (auto it = S.begin() ; it!=S.end(); ++it)
  // {
  //     cout << *it << endl;
  // }
  cout << S.size() - 1 << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define REP(i, n) REPI(i, 0, n)
#define REPI(i, a, b) for (int i = (int)(a); i < (int)(b); i++)

#define SZ(x) ((int)(x).size())

using ll = long long;
using namespace std;
int result = 0;

vector<string> Storage(vector<string> storage, string compare) {
  for (int i = 0; i < storage.size(); i++) {
    if (compare == storage[i]) {
      return storage;
    }
  }
  storage.push_back(compare);
  result += 1;
  return storage;
}

int main() {
  ll N;
  cin >> N;
  vector<string> S(N);
  string l;
  for (int i = 0; i < N; i++) {
    cin >> l;
    S = Storage(S, l);
  }
  cout << result << endl;
  return 0;
}