alexjercan/bugnet huggingface dataset:
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;
  string ss;
  for (int i = 0; i < n; i++) {
    cin >> ss;
    s.insert(ss);
  }

  printf("%lu\\n", s.size());
  return 0;
}

Error: TLE

Fixed submission:

#define FOR(i, a, b) for (int i = a; i < b; i++)
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
#include <utility>
using namespace std;

int main() {
  int n;
  scanf("%d", &n);

  char ss[n][100];
  string s[n];
  bool scanned[n];

  FOR(i, 0, n) {
    scanf("%s", ss[i]);
    // printf("%s\\n", ss[i]);
    // if(strcmp(ss[0], ss[i])==0) printf("a\\n");
    scanned[i] = false;
  }

  int ans = 0;
  FOR(i, 0, n) {
    if (scanned[i])
      continue;
    ans++;
    FOR(j, i, n) {
      if (scanned[j])
        continue;
      if (strcmp(ss[i], ss[j]) == 0)
        scanned[j] = true;
    }
  }

  printf("%d\\n", ans);
}
Problem p02701 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  string s[200005];
  long n, i;
  map<string, long> mp;
  while (cin >> n) {
    for (i = 0; i < n; i++) {
      cin >> s[i];
      mp[s[i]] = i;
    }
    cout << mp.size() << endl;
    mp.clear();
  }
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  string s[100005];
  long n, i;
  map<string, long> mp;
  while (cin >> n) {
    for (i = 0; i < n; i++) {
      cin >> s[i];
      mp[s[i]] = i;
    }
    cout << mp.size() << endl;
    mp.clear();
  }
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iomanip>
#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.at(i);
  }

  int k = 0;

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

  for (int i = 0; i < N - 1; ++i) {
    if (s.at(i) == s.at(i + 1)) {
      ++k;
    }
  }

  cout << N - k << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  int N;
  cin >> N;

  vector<string> s(N);

  cin >> s.at(0);

  int k = 1;

  for (int i = 1; i <= N - 1; ++i) {
    cin >> s.at(i);
    for (int j = 0; j <= i - 1; ++j) {
      if (s.at(i) == s.at(j)) {
        goto xyz;
      }
    }
    ++k;
  xyz:;
  }

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

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

int main() {
  int N, count = 0, ans = 1;
  cin >> N;
  vector<string> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  for (int i = 0; i < N - 1; i++) {
    if (A.at(i) != A.at(i + 1)) {
      ans++;
      continue;
    } else {
      continue;
    }
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  int N, count = 0, ans = 0;
  cin >> N;
  vector<string> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < i; j++) {
      if (A.at(i) != A.at(j)) {
        continue;
      } else {
        count = 1;
        break;
      }
    }
    ans++;
    ans -= count;
    count = 0;
  }
  cout << ans << endl;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int num;
  int kekka = 0;
  bool chk = true;
  string tmp;

  cin >> num;

  vector<string> vec(num);
  for (int i = 0; i < num; i++) {
    cin >> vec.at(i);
  }

  sort(vec.begin(), vec.end(), greater<string>());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  cout << vec.size();
}


Error: TLE

Fixed submission:

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

int main() {
  int num;
  int kekka = 0;
  bool chk = true;
  string tmp;

  cin >> num;

  vector<string> vec(num);
  for (int i = 0; i < num; i++) {
    cin >> tmp;

    chk = true;
    for (int j = 0; j < vec.size(); j++) {
      if (vec.at(j) == tmp) {
        chk = false;
        break;
      }
    }
    if (chk == true) {
      vec.at(i) = tmp;
      kekka++;
    }
  }
  cout << kekka;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define MAX 200000
using namespace std;

int main(void) {
  vector<string> v;
  int N;
  cin >> N;
  string str[MAX];
  for (int i = 0; i < N; i++) {
    string tmp;
    cin >> tmp;
    v.push_back(tmp);
  }

  if (N == 1) {
    cout << 1 << endl;
    return 0;
  }

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

  int sum = 1;
  for (int n = 1; n < N - 1; n++) {
    if (v[n] != v[n - 1])
      sum++;
  }
  if (v[N - 1] != v[N - 2])
    sum++;
  cout << sum << endl;
  return 0;
}


Error: TLE

Fixed submission:

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

#define MAX 200000
using namespace std;

int main(void) {
  vector<string> v;
  int N;
  cin >> N;
  string str[MAX];
  for (int i = 0; i < N; i++) {
    string tmp;
    cin >> tmp;
    str[i] = tmp;
  }

  v.push_back(str[0]);
  // cout << "flag" << endl;
  for (int i = 1; i < N; i++) {
    bool flag = true;
    for (int n = 0; n < v.size(); n++) {
      if (v[n] == str[i]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      v.push_back(str[i]);
    }
  }
  cout << v.size() << 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;
  long long nagasa, trans;
  // int array[n];
  vector<long long> v;
  int ans = 0;
  string s;
  set<string> ss;

  for (int i = 0; i < n; i++) {
    cin >> s;
    // nagasa = s.length();
    // trans = 0;
    /*
    for (int j = nagasa; j > 0; j--){
        trans += ((s[nagasa-j]-'a')+1) * pow(27,j-1);
    }
    */
    // auto itr = find(v.begin(),v.end(),trans);
    /*
    if(!binary_search(v.begin(),v.end(),trans)){
        v.push_back(trans);
        ans += 1;
        sort(v.begin(),v.end());
    }
    */
    ss.emplace(s);
  }
  cout << ss.size() << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  long long nagasa, trans;
  // int array[n];
  vector<long long> v;
  int ans = 0;
  string s;

  for (int i = 0; i < n; i++) {
    cin >> s;
    nagasa = s.length();
    trans = 0;
    for (int j = nagasa; j > 0; j--) {
      trans += ((s[nagasa - j] - 'a') + 1) * pow(27, j - 1);
    }
    // auto itr = find(v.begin(),v.end(),trans);
    if (!binary_search(v.begin(), v.end(), trans)) {
      v.push_back(trans);
      ans += 1;
      sort(v.begin(), v.end());
    }
  }
  cout << ans << endl;
}
Problem p02701 (C++) — buggy submission, verdict: Runtime Error

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

using namespace std;

typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;

const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int k;

int gcd(int a, int b) {
  if (b == 0)
    return a;

  return gcd(b, a % b);
}

int main() {
  int n;
  cin >> n;
  vector<string> s_(n);

  rep(j, n) cin >> s_[j];

  sort(s_.begin(), s_.end());
  int count = 1;

  rep(i, n) {
    if (i == 0)
      continue;
    else {
      if (s_[i] == s_[i - 1])
        continue;
      else
        count++;
    }
  }

  cout << count;

  return 0;
}

Error: -6
terminate called after throwing an instance of 'std::length_error'
  what():  cannot create std::vector larger than max_size()


Fixed submission:

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

using namespace std;

typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;

const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int k;

int gcd(int a, int b) {
  if (b == 0)
    return a;

  return gcd(b, a % b);
}

int main() {
  int n;
  vector<string> s_(n);

  cin >> n;
  rep(j, n) cin >> s_[j];

  sort(s_.begin(), s_.end());
  int count = 1;

  rep(i, n) {
    if (i == 0)
      continue;
    else {
      if (s_[i] == s_[i - 1])
        continue;
      else
        count++;
    }
  }

  cout << count;

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  set<string> a;
  for (int i = 0; i < n; i++) {
    string ai;
    cin >> ai;
    a.insert(ai);
  }
  cout << a.size() << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m = 1;
  string a0;
  cin >> n >> a0;
  vector<string> a(1);
  a.at(0) = a0;
  if (n > 1) {
    for (int i = 1; i < n; i++) {
      int c = 0;
      string ai;
      cin >> ai;
      for (int j = 0; j < m; j++) {
        if (a.at(j) == ai) {
          c++;
          break;
        }
      }
      if (c == 0) {
        a.push_back(ai);
        m++;
      }
    }
  }
  cout << m << endl;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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


Error: TLE

Fixed submission:

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

int main(void) {
  int N;
  cin >> N;
  string s[N];
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    bool flg = false;
    for (int j = 0; j < cnt; j++) {
      if (s[j] == S) {
        flg = true;
        break;
      }
    }
    if (!flg) {
      s[cnt] = S;
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N, ans;
  ans = 1;
  cin >> N;
  vector<string> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }

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

  for (int i = 0; i < N - 1; i++) {
    if (vec.at(i) != vec.at(i + 1)) {
      ans++;
    }
  }

  cout << ans << "\\n";
}

Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 3) >= this->size() (which is 3)


Fixed submission:

#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N, ans;
  ans = 1;
  cin >> N;
  vector<string> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }

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

  for (int i = 0; i < N; i++) {
    if (vec.at(i) != vec.at(i + 1)) {
      ans++;
    }
  }

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

#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void) {
  // Your code here!
  int N;
  cin >> N;
  int cnt = 0;
  std::vector<long> S = {0};
  for (int i = 0; i < N; i++) {
    string tmp;
    cin >> tmp;
    long keta = 1;
    long sum = 0;
    for (int j = 0; j < tmp.size(); j++) {
      keta = pow(26, j);
      sum += (tmp[j] - ('a' - 1)) * keta;
    }

    // cout << sum << endl;
    auto it = lower_bound(S.begin(), S.end(), sum);
    if (*it != sum) {
      S.insert(it, sum);
      cnt++;
    }
  }
  cout << S.size() - 1 << endl;
}

Error: TLE

Fixed submission:

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

long s2i(string tmp) {
  long keta = 1;
  long sum = 0;
  for (int j = 0; j < tmp.size(); j++) {
    keta = pow(26, j);
    sum += (tmp[j] - ('a' - 1)) * keta;
  }
  return sum;
}
int main(void) {
  // Your code here!
  // Your code here!
  int N;
  cin >> N;
  std::vector<long> S;

  for (int i = 0; i < N; i++) {
    string tmp;
    cin >> tmp;
    S.push_back(s2i(tmp));
  }
  int sum = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] != -1) {
      sum++;
      while (1) {
        auto index = std::find(S.begin() + i + 1, S.end(), S[i]);
        if (index != S.end()) {
          index[0] = -1;
        } else {
          break;
        }
      }
    }
  }

  std::cout << sum << std::endl;
}
Problem p02701 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3f
const int maxn = 5e6 + 100;
int tree[maxn][30];
bool flag[maxn];
int tot;
void insertt(string s) {
  int len = s.size();
  int root = 0;
  for (int i = 0; i < len; i++) {
    int id = s[i] - 'a';
    if (!tree[root][id])
      tree[root][id] = ++tot;
    root = tree[root][id];
  }
  flag[root] = true;
}
bool findt(string s) {
  int len = s.size();
  int root = 0;
  for (int i = 0; i < len; i++) {
    int id = s[i] - 'a';
    if (!tree[root][id])
      return true;
    root = tree[root][id];
  }
  if (flag[root])
    return false;
  else
    return true;
}
string s;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    if (findt(s)) {
      ans++;
      insertt(s);
    }
  }
  cout << ans;
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3f
const int maxn = 2e5 + 100;
int tree[maxn][30];
bool flag[maxn];
int tot;
void insertt(string s) {
  int len = s.size();
  int root = 0;
  for (int i = 0; i < len; i++) {
    int id = s[i] - 'a';
    if (!tree[root][id])
      tree[root][id] = ++tot;
    root = tree[root][id];
  }
  flag[root] = true;
}
bool findt(string s) {
  int len = s.size();
  int root = 0;
  for (int i = 0; i < len; i++) {
    int id = s[i] - 'a';
    if (!tree[root][id])
      return true;
    root = tree[root][id];
  }
  if (flag[root])
    return false;
  else
    return true;
}
string s;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    if (findt(s)) {
      ans++;
      insertt(s);
    }
  }
  cout << ans;
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int n, cnt = 0;
  string a;
  set<string> s;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    cin >> a;
    auto itr = s.find(a);
    if (itr == s.end()) {
      s.insert(a);
      cnt++;
    }
  }

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

Error: TLE

Fixed submission:

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

int main() {
  int n, cnt = 0;
  string a;
  vector<string> s;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    auto itr = find(s.begin(), s.end(), a);
    if (itr == s.end()) {
      s.push_back(a);
      cnt++;
    }
  }

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

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

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  ll N;
  cin >> N;
  vector<string> S(N);
  for (ll i = 0; i < N; i++) {
    cin >> S[i];
  }

  ll ans = 1;
  sort(S.begin(), S.end());
  string pre = S[0];
  for (ll i = 1; i < N; i++) {
    if (pre != S[i]) {
      ans++;
    }
    pre = S[i];
  }
  cout << ans << endl;

  return 0;
}


Error: TLE

Fixed submission:

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

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  ll N;
  cin >> N;
  vector<string> S(N);
  vector<string> T(N);
  ll j = 0;
  for (ll i = 0; i < N; i++) {
    cin >> S[i];
    if (find(T.begin(), T.end(), S[i]) == T.end()) {
      T[j++] = S[i];
    }
  }

  cout << j << endl;

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

#include <algorithm>
#include <functional>
#include <iostream>
#include <iterator>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main(void) {
  int n;
  cin >> n;
  vector<size_t> v(20000);
  int sum = 0;

  unordered_map<size_t, int> um;
  for (int i = 0; i < n; i++) {
    string str;
    cin >> str;
    size_t hs = hash<string>()(str);
    auto itr = lower_bound(v.begin(), v.end(), hs);

    if (itr == v.end()) {
      v.push_back(hs);
      sum++;
    } else if (*itr != hs) {
      v.insert(itr, hs);
      sum++;
    } else {
    }
  }
  cout << sum << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <functional>
#include <iostream>
#include <iterator>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main(void) {
  int n;
  cin >> n;
  vector<size_t> v(20000);
  int sum = 0;

  unordered_map<size_t, int> um;
  for (int i = 0; i < n; i++) {
    string str;
    cin >> str;
    size_t hs = hash<string>()(str);
    auto itr = lower_bound(v.begin(), v.end(), hs);

    if (itr == v.end()) {
      v.push_back(hs);
      sum++;
    } else if (*itr != hs) {
      v.push_back(hs);
      sort(v.begin(), v.end());
      sum++;
    } else {
    }
  }
  cout << sum << endl;

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

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

int main() {
  int n;
  cin >> n;

  map<string, int> t;

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

    t[s];
  };

  cout << t.size() << endl;

  return 0;
}


Error: 1

Fixed submission:

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

int main() {
  int n;
  cin >> n;

  map<string, int> t;

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

    t[s];
  };

  cout << t.size() << endl;

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

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

int main() {
  int n = 0;
  cin >> n;
  set<string> s;
  for (int i = 0; i < n; i++) {
    char str[100] = "";
    cin >> str;
    s.insert(str);
  }
  cout << s.size() << endl;
  return 0;
}

Error: -6
*** stack smashing detected ***: terminated


Fixed submission:

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

int main() {
  int n = 0;
  cin >> n;
  set<string> s;
  for (int i = 0; i < n; i++) {
    char str[] = "";
    cin >> str;
    s.insert(str);
  }
  cout << s.size() << 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);
  int result = 1;
  for (int a = 0; a < N; a++)
    cin >> S.at(a);

  sort(S.begin(), S.end());
  for (int a = 1; a < N; a++) {
    if (S.at(a - 1) != S.at(a))
      result++;
  }

  cout << result << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  int N;
  cin >> N;
  string S[N];
  int result = 0;
  int flag = 0;
  for (int a = 0; a < N; a++)
    cin >> S[a];
  for (int a = 0; a < N; a++) {
    flag = 0;
    for (int b = 0; b < a; b++) {
      if (S[a] == S[b])
        flag = 1;
    }
    if (flag == 0)
      result++;
  }
  cout << result << endl;
}
Problem p02701 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int N, i, j, s;
  string S;
  cin >> N;
  set<string> st;
  s = N;
  for (i = 0; i < N; i++) {
    cin >> S;
    st.insert(S);
  }

  // if(s>0)
  cout << st.size() << endl;
  return 0;
}

Error: 0

Fixed submission:

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

int main() {
  int N, i, j, s;
  cin >> N;
  vector<string> S(i);
  s = N;
  for (i = 0; i < N; i++) {
    cin >> S[i];
    for (j = 0; j < i; j++) {
      if (S[i] == S[j]) {
        s -= 1;
        break;
      }
    }
  }
  cout << s << endl;
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Runtime Error

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

  int i, j, n, p, q, r, k, y, l;
  string b;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> b;
    a.insert(b);
  }
  cout << a.size() << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#include <string.h>
using namespace std;
char a[10][10];
int main() {
  int n, num;
  scanf("%d", &n);
  num = n;
  for (int i = 0; i < n; i++)
    scanf("%s", a[i]);
  // printf("%d\\n",num);
  for (int i = 0; i < n; i++)
    for (int j = i - 1; j >= 0; j--)
      if (!strcmp(*(a + j), *(a + i))) {
        num--;
        break;
      }
  printf("%d\\n", num);
  getchar();
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstring>
#include <iostream>
#include <set>
#include <vector>
#define MAX_N 200000
using namespace std;

long long N;
string S[MAX_N];
set<string> gift;

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> S[i];
    gift.insert(S[i]);
  }
  cout << gift.size();

  return 0;
}


Error: WA

Fixed submission:

#include <algorithm>
#include <cstring>
#include <iostream>
#include <set>
#include <vector>
#define MAX_N 100000
using namespace std;

long long N;
string S[MAX_N];
set<string> gift;

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> S[i];
    gift.insert(S[i]);
  }
  cout << gift.size();

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, cnt = 1;
  cin >> n;
  vector<string> S(n);
  for (int i = 0; i < n; i++)
    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: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, count = 0;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++)
    cin >> s[i];
  for (int i = 0; i < n; i++) {
    bool t = true;
    for (int j = i + 1; j < n; j++) {
      if (s[i] == s[j])
        t = false;
    }
    if (t)
      count++;
  }
  cout << count << endl;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int N;
  cin >> N;
  vector<string> vec(N);
  string S;
  for (int i = 0; i < N; i++) {
    cin >> S;
    vec.at(i) = S;
  }
  sort(vec.begin(), vec.end());
  int counter = 1;
  for (int i = 1; i < N; i++) {
    if (vec.at(i) == vec.at(i - 1))
      continue;
    if (vec.at(i) != vec.at(i - 1))
      counter++;
  }
  cout << counter << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  int N;
  cin >> N;
  vector<string> vec(N);
  string S;
  for (int i = 0; i < N; i++) {
    cin >> S;
    vec.at(i) = S;
  }
  sort(vec.rbegin(), vec.rend());
  int counter = 1;
  if (N == 1)
    cout << 1 << endl;
  else {
    for (int i = 1; i < N; i++) {
      for (int j = 0; j < i; j++) {
        if (vec.at(i) == vec.at(j)) {
          break;
        } else if (vec.at(i) != vec.at(j) && j < i - 1)
          continue;
        else if (vec.at(i) != vec.at(j) && j == i - 1)
          counter++;
      }
    }
    cout << counter << endl;
  }
}