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> str;

  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    auto itr = str.find(s);
    if (itr == str.end()) {
      str.insert(s);
    }
  }

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

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;

  cin >> n;
  vector<string> str;

  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    auto itr = find(str.begin(), str.end(), s);
    if (itr == str.end()) {
      str.emplace_back(s);
    }
  }

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

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

using namespace std;

int main() {
  long n;
  cin >> n;
  string s;
  vector<string> ss;
  long flg;
  for (int i = 0; i < n; i++) {
    cin >> s;
    ss.push_back(s);
  }

  set<string> sss(ss.begin(), ss.end());
  cout << (long)(sss.size()) << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

using namespace std;

int main() {
  int n;
  cin >> n;
  string s;
  vector<string> ss;
  int flg;
  for (int i = 0; i < n; i++) {
    cin >> s;
    flg = 0;
    for (int j = 0; j < ss.size(); j++) {
      if (s == ss[j]) {
        flg = 1;
        break;
      }
    }

    if (flg == 0) {
      ss.push_back(s);
    }
  }

  cout << ss.size();
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n;
  cin >> n;
  std::vector<string> s(n);
  std::map<string, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> s.at(i);
    mp[s.at(i)] = 0;
  }
  for (int i = 0; i < n; i++) {
    mp[s.at(i)]++;
  }
  std::cout << mp.size() << '\\n';
  return 0;
}


Error: 0

Fixed submission:

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

int main() {
  int n;
  std::vector<string> s(n);
  cin >> n;
  std::map<string, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> s.at(i);
    mp[s.at(i)]++;
  }
  std::cout << mp.size() << '\\n';
  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 < N; i++) {
    cin >> S.at(i);
  }
  sort(S.begin(), S.end());
  int count = 1;
  for (int i = 1; i < N; i++) {
    if (S.at(i - 1) != S.at(i)) {
      count++;
    }
  }
  cout << count << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  int N;
  cin >> N;
  vector<string> S(1);
  string str;
  for (int i = 0; i < N; i++) {
    cin >> str;
    if (i == 0) {
      S.at(0) = str;
    } else {
      bool flag = false;
      for (int j = 0; j < S.size(); j++) {
        if (str == S.at(j)) {
          flag = true;
          break;
        }
      }
      if (flag) {
        continue;
      } else {
        S.push_back(str);
      }
    }
  }
  cout << S.size() << endl;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

Error: TLE

Fixed submission:

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

int main() {
  int N;
  cin >> N;
  string S;
  vector<string> Slist(N);
  int count = 0;
  for (int i = 0; i < N; i++) {
    cin >> S;
    bool SIsNew = true;
    for (int j = 0; j <= count; j++) {
      if (S == Slist.at(j)) {
        SIsNew = false;
        break;
      }
    }
    if (SIsNew) {
      Slist.at(count) = S;
      count++;
    }
  }
  cout << count << endl;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

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

void solve(long long N, std::vector<std::string> S) {

  std::sort(S.begin(), S.end());
  S.erase(std::unique(S.begin(), S.end()), S.end());
  cout << S.size() << endl;
  return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<std::string> S(N);
  for (int i = 0; i < N; i++) {
    std::cin >> S[i];
  }
  solve(N, std::move(S));
  return 0;
}


Error: TLE

Fixed submission:

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

void solve(long long N, std::vector<std::string> S) {

  long long ans = 0;
  std::vector<std::string> tmp;
  std::vector<std::string>::iterator sIter;

  for (long long i = 0; i < N; i++) {

    sIter = std::find(tmp.begin(), tmp.end(), S[i]);
    if (sIter == tmp.end()) {
      tmp.push_back(S[i]);
      ans += 1;
    }
  }

  cout << ans << endl;
  return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<std::string> S(N);
  for (int i = 0; i < N; i++) {
    std::cin >> S[i];
  }
  solve(N, std::move(S));
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];

  set<string> a;
  rep(i, n) a.insert(s[i]);
  int ans = a.size();
  cout << ans << endl;
}


Error: -11

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  vector<string> s;
  rep(i, n) cin >> s[i];

  set<string> a;
  rep(i, n) a.insert(s[i]);
  int ans = a.size();
  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, i = 0;
  cin >> n;
  vector<string> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  for (int j = 1; j < n; ++j) {
    if (equal(v[i].begin(), v[i].end(), v[j].begin(), v[j].end()) != true) {
      i++;
      v[i] = v[j];
    }
  }
  cout << ++i << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int n, ans;
  cin >> n;
  ans = n;
  vector<string> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  for (int i = 0; i < n - 1; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (equal(v[i].begin(), v[i].end(), v[j].begin(), v[j].end()) == true) {
        ans--;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main(void) {
  int n, ans = 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])
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

int main(void) {
  int n, total = 1;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++)
    cin >> s[i];
  for (int i = 1; i < n; i++) {
    bool exists = false;
    for (int j = 0; j < i; j++) {
      if (s[i] == s[j]) {
        exists = true;
        break;
      }
    }
    if (!exists)
      total++;
  }
  cout << total << endl;
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, count = 1;
  cin >> n;
  string s[200000];
  long long i, j;
  for (i = 0; i < n; i++) {
    cin >> s[i];
  }
  sort(s, s + n);
  for (i = 1; i < n; i++)
    if (s[i] != s[i - 1])
      count++;
  cout << count << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, count = 1;
  cin >> n;
  string s[n + 1];
  long long i, j;
  for (i = 0; i < n; i++) {
    cin >> s[i];
    if (i >= 1) {
      for (j = 0; j < i; j++) {
        if (s[i] == s[j])
          break;
      }
      if (i == j)
        count++;
    }
  }
  cout << count << endl;
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;
int main() {
  unordered_map<string, int> m;
  int n;
  string s;
  std::cin >> n;
  while (n > 0) {
    std::cin >> s;
    if (m.count(s)) {
      m[s] += 1;
    } else {
      m.insert(pair<string, int>(s, 1));
    }
    n--;
  }
  cout << m.size() << "\\n";
  return 0;
}

Error: 2

Fixed submission:

#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;
int main() {
  unordered_map<string, int> m;
  int n;
  string s;
  std::cin >> n;
  while (n > 0) {
    std::cin >> s;
    if (m.count(s)) {
      m[s] += 1;
    } else {
      m.insert(pair<string, int>(s, 1));
    }
    n--;
  }
  return m.size();
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

/*
 * Project: AtCoder Beginners Contest 164 C - gacha
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/07/07
 * Copyright (c) 2020 toms74209200
 *
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <map>
#include <string>
using namespace std;

int n;
map<string, int> items;

void solve() {
  int num = items.size();
  printf("%d\\n", num);
}

int main() {

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    char s[10];
    scanf("%s", s);
    items[(string)s]++;
  }

  solve();
}

Error: TLE

Fixed submission:

/*
 * Project: AtCoder Beginners Contest 164 C - gacha
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/04/26
 * Copyright (c) 2020 toms74209200
 *
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

int n;
string s[200000];

void solve() {
  int num = 0;
  string name[200000];
  bool is_same = false;
  for (int i = 0; i < n; i++) {
    is_same = false;
    for (int j = 0; j <= i; j++) {
      if (s[i] == name[j]) {
        is_same = true;
        break;
      }
    }
    if (!is_same) {
      num++;
      name[i + 1] = s[i];
    }
  }
  printf("%d\\n", num);
}

int main() {

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

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

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

int main() {
  int N, cnt = 0;
  string s;
  cin >> N;
  map<string, bool> S;
  for (int i = 0; i < N; i++) {
    cin >> s;
    if (S[s] == false) {
      S[s] = true;
      cnt++;
    }
  }
  cout << cnt << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  int N, cnt = 0;
  bool can;
  cin >> N;
  string s;
  vector<string> S(N);
  for (int i = 0; i < N; i++) {
    cin >> s;
    can = true;
    for (int j = 0; j < cnt; j++) {
      if (S.at(j) == s) {
        can = false;
        break;
      }
    }
    if (can) {
      S.at(cnt) = s;
      cnt++;
    }
  }
  cout << cnt << endl;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

Error: TLE

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  int count = n;
  vector<string> gift(n);
  vector<bool> buf(n, true);
  rep(i, n) { cin >> gift[i]; }
  rep(i, n) {
    if (!buf[i])
      continue;
    for (int j = i + 1; j < n; j++) {
      if (!buf[j])
        continue;
      if (gift[i] == gift[j]) {
        count--;
        buf[j] = false;
      }
    }
  }
  cout << count << endl;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main(void) {
  int n;
  string str[200000];
  set<string> strset;

  cin >> n;
  cin.ignore();
  int count = 0;

  for (int i = 0; i < n; i++) {
    // cin >> str[i];
    getline(cin, str[i]);
    count++;

    decltype(strset)::iterator it = strset.find(str[i]);
    if (it != strset.end()) {
      count--;
      // break;
    }

    strset.insert(str[i]);
    // cout << str[i] << " " << count << " " << i << endl;

    /*
    for (int j=i-1; j>=0; j--){

        //if(str[i] == str[j]) {
        //if(equal(str[i].begin(), str[i].end(), str[j].begin(), str[j].end())){
        //if(equal(str[i].begin(), str[i].end(), str[j].begin())){
        //cout << j << " " << str[i] << " " << str[j] << endl;
        if(it != strset.end()){
            count--;
            break;
        }
    }
    */
  }

  cout << count;
  return 0;
}

Error: TLE

Fixed submission:

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

int main(void) {
  int n;
  string str[200000];

  cin >> n;
  cin.ignore();
  int count = 0;
  for (int i = 0; i < n; i++) {
    // cin >> str[i];
    getline(cin, str[i]);
    count++;
    // cout << str[i] << " " << count << " " << i << endl;
    for (int j = i - 1; j >= 0; j--) {

      // cout << j << " " << str[i] << " " << str[j] << endl;
      // if(str[i] == str[j]) {
      if (equal(str[i].begin(), str[i].end(), str[j].begin(), str[j].end())) {
        // if(equal(str[i].begin(), str[i].end(), str[j].begin())){
        count--;
        break;
      }
    }
  }

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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n;
  cin >> n;

  map<string, ll> mp;
  vector<string> s(n);
  for (ll i = 0; i < n; i++) {
    cin >> s.at(i);
    mp[s.at(i)]++;
  }
  cout << mp.size() << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n;
  cin >> n;
  ll h = 0;
  ll sum = 0;
  vector<string> s(n);
  for (ll i = 0; i < n; i++) {
    cin >> s.at(i);
    h = 0;
    for (ll j = 0; j < i; j++) {
      if (s.at(j) == s.at(i)) {
        h++;
      }
    }
    if (h == 0)
      sum++;
  }
  cout << sum << endl;
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define ll long long
#define INF 99999999
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
  int N, t = 0;

  cin >> N;

  vector<string> s(N);
  vector<string> l;

  rep(i, N) { cin >> s[i]; }

  set<string> st;

  rep(i, N) { st.insert(s[i]); }

  cout << st.size() << endl;
}


Error: TLE

Fixed submission:

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

#define ll long long
#define INF 99999999
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
  int N, t = 0;

  cin >> N;

  vector<string> s(N);
  vector<string> l;

  rep(i, N) { cin >> s[i]; }

  rep(i, N) {
    bool w = true;
    rep(j, i) {
      if (s[i] == s[j]) {
        w = false;
        break;
      }
    }

    if (w == false) {
      continue;
    }
    t++;
  }

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

#include <algorithm>
#include <chrono>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
constexpr double PI = 3.14159265358979323846;

int main() {
  int n = 0;
  cin >> n;
  std::string str;
  std::vector<std::string> v;
  for (int i = 0; i < n; i++) {
    cin >> str;
    v.push_back(str);
  }
  std::sort(v.begin(), v.end());

  v.erase(std::unique(v.begin(), v.end()), v.end());
  std::cout << v.size() << std::endl;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <chrono>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
constexpr double PI = 3.14159265358979323846;

int main() {
  int n = 0;
  cin >> n;
  std::string str;
  std::vector<std::string> v;
  for (int i = 0; i < n; i++) {
    cin >> str;
    auto it = std::find(v.begin(), v.end(), str);
    auto index = std::distance(v.begin(), it);
    if (index != v.size()) { // 発見できたとき
      continue;
    } else { // 発見できなかったとき
      v.push_back(str);
    }
  }

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

#include <bits/stdc++.h>

using namespace std;

int main() {

  int a;
  cin >> a;
  string in;
  set<string> s;
  for (int i = 0; i < a; i++) {
    cin >> in;
    s.insert(in);
  }
  cout << s.size();
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {

  int a, c;
  cin >> a;
  string s[a];
  for (int i = 0; i < a; i++) {
    cin >> s[i];
    c++;
    for (int j = 0; j < i; j++) {
      if (s[i] == s[j]) {
        c--;
        break;
      }
    }
  }
  cout << c;
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const long long INF = 1LL << 60;

int main() {
  ll n;
  int cnt;
  map<string, int> m;
  cin >> n;
  string str;
  vector<string> s;
  for (ll i = 0; i < n; i++) {
    cnt = 0;
    cin >> str;
    m[str] = 1;
  }

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


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const long long INF = 1LL << 60;

int main() {
  ll n;
  int cnt;
  cin >> n;
  string str;
  vector<string> s;
  for (ll i = 0; i < n; i++) {
    cnt = 0;
    cin >> str;
    for (ll j = 0; j < s.size(); j++) {
      if (str == s[j]) {
        cnt++;
        break;
      }
    }
    if (cnt == 0)
      s.push_back(str);
  }

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

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

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

  vector<string> s(n);
  rep(i, n) cin >> s.at(i);
  sort(s.begin(), s.end());
  s.erase(unique(s.begin(), s.end()), s.end());

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

  // rep(i, n) cout << s.at(i) << endl;
}

Error: TLE

Fixed submission:

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

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

  vector<string> s(n);
  rep(i, n) cin >> s.at(i);

  long long equal = 0;
  rep(i, n) {
    bool erase = false;
    for (int j = i + 1; j < n; j++) {
      if (s.at(i) == s.at(j)) {
        erase = true;
        break;
      }
    }
    if (erase)
      equal++;
  }

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

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

int main() {
  int n;
  cin >> n;
  /*int count=0;
  vector<string> goods(0);
  for (int i=0; i<n; i++){
      string now; cin >> now;
      if (i!=0){
          if (!(binary_search(goods.begin(), goods.end(), now))) {
              goods.push_back(now);
              //goods.at(count)=now;
              count++;
              sort(goods.begin(), goods.end());
          }
      } else {//i==0
          goods.emplace_back(now);
          //goods.at(count)=now;
          count++;
          sort(goods.begin(), goods.end());
      }
  }
  cout << count << endl;*/

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

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

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  int count = 0;
  vector<string> goods(0);
  for (int i = 0; i < n; i++) {
    string now;
    cin >> now;
    // bool judge=true;
    /*if (i!=0){
        for (int j=0; j<count && now<=goods.at(j); j++){
            if (now == goods.at(j)){
                judge=false;
                break;
            }
        }
    } */
    if (i != 0) {
      if (!(binary_search(goods.begin(), goods.end(), now))) {
        goods.push_back(now);
        // goods.at(count)=now;
        count++;
        sort(goods.begin(), goods.end());
      }
    } else {
      goods.push_back(now);
      // goods.at(count)=now;
      count++;
      sort(goods.begin(), goods.end());
    }
  }
  cout << count << 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;
  string s[n];
  set<string> S;
  int count = 0;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    S.insert(s[i]);
  }
  cout << S.size() << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

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

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

int main() {
  long long n, i, uniq = 1;
  cin >> n;
  string s[n];
  for (i = 0; i < n; i++) {
    cin >> s[i];
  }
  sort(s, s + n);
  for (int i = 0; i < n - 1; i++) {
    if (s[i] != s[i + 1])
      uniq++;
  }
  cout << uniq << endl;
}


Error: 0

Fixed submission:

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

int main() {
  long long int n, i, uniq = 1;
  string s[10];
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> s[i];
  }
  sort(s, s + n);
  for (int i = 0; i < n - 1; i++) {
    if (s[i] != s[i + 1])
      uniq++;
  }
  cout << uniq << endl;
}
Problem p02701 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#include <vector>3
using namespace std;
void init() {
  cin.tie(0);
  cin.sync_with_stdio(0);
}
int main() {
  init();
  long long a, t, c = 0;
  cin >> a;
  string s;
  set<string> v;
  for (int i = 0; i < a; i++) {
    cin >> s;
    v.insert(s);
  }
  cout << v.size();
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#include <vector>3
using namespace std;
void init() {
  cin.tie(0);
  cin.sync_with_stdio(0);
}
int main() {
  init();
  long long a, t, c = 0;
  cin >> a;
  string s;
  vector<string> v;
  for (int i = 0; i < a; i++) {
    cin >> s;
    for (int o = 0; o < i; o++) {
      if (s == v[o]) {
        c++;
        break;
      }
    }
    if (c == 0) {
      v.push_back(s);
    } else
      c = 0;
  }
  cout << v.size();
}