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

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

int main() {
  int N;

  cin >> N;

  int count = 1;
  vector<string> gacha(N);

  for (int i = 0; i < N; i++) {
    cin >> gacha.at(i);
  }

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

  // sting first = gacha.at(0);

  for (int i = 0; i < N - 1; i++) {
    if (gacha.at(i + 1) != gacha.at(i)) {
      count++;
    }
  }
  cout << count << endl;
}


Error: WA

Fixed submission:

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

int main() {
  int N;
  int count = 0;
  vector<string> gacha(N);

  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> gacha.at(i);
  }

  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (gacha.at(i) == gacha.at(j))
        count++;
    }
  }

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

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

using namespace std;

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


Error: TLE

Fixed submission:

#include <algorithm>
#include <array>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  vector<string> keihin(N);
  for (int i = 0; i < N; i++) {
    cin >> keihin[i];
  }

  int count = 0;
  vector<string> result;
  // for (int i = 0; i < N; i++)
  // 	cout << keihin[i];
  for (int i = 0; i < N; i++) {
    if (find(result.begin(), result.end(), keihin[i]) == result.end()) {
      result.push_back(keihin[i]);
    }
  }
  cout << result.size();
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define NewNode (TreeNode *)malloc(sizeof(TreeNode))
#define Mem(a, b) memset(a, b, sizeof(a))
const int N = 5e5 + 5;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-10;
const unsigned long long mod = 19999999999999997;
const int II = 3.1415926535;
typedef long long ll;
typedef unsigned long long ull;
ull HASH[N];
char str[N];
int num = 279;
ull Hash(char str[]) {
  ull ans = 0;
  int len = strlen(str);
  for (int i = 0; i < len; i++)
    ans = (ans * num + (ull)str[i]) % mod;
  return ans % mod;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", str);
    HASH[i] = Hash(str);
  }
  int sum = n;
  sort(HASH + 1, HASH + n + 1);
  for (int i = 1; i < n; i++)
    if (HASH[i] == HASH[i + 1])
      sum--;
  cout << sum << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define NewNode (TreeNode *)malloc(sizeof(TreeNode))
#define Mem(a, b) memset(a, b, sizeof(a))
const int N = 5e5 + 5;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-10;
const unsigned long long mod = 19999999999999997;
const int II = 3.1415926535;
typedef long long ll;
typedef unsigned long long ull;
ull HASH[30050];
char str[30050];
int num = 279;
ull Hash(char str[]) {
  ull ans = 0;
  int len = strlen(str);
  for (int i = 0; i < len; i++)
    ans = (ans * num + (ull)str[i]) % mod;
  return ans % mod;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", str);
    HASH[i] = Hash(str);
  }
  int sum = n;
  sort(HASH + 1, HASH + n + 1);
  for (int i = 1; i < n; i++)
    if (HASH[i] == HASH[i + 1])
      sum--;
  cout << sum << endl;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

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

  return 0;
}

Error: TLE

Fixed submission:

#define _GLIBCXX_DEBUG
#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[i];

  vector<string> result(0);
  result.push_back(S[0]);

  for (int i = 0; i < N; i++) {
    bool check = true;
    for (int j = 0; j < result.size(); j++) {
      if (result[j] == S[i]) {
        check = false;
        break;
      }
    }
    if (check)
      result.push_back(S[i]);
  }

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

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

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define vi vector<int>
#define pb push_back
#define sz(s) (int)s.size()
#define all(v) v.begin(), v.end()
#define show(a) cerr << #a << " -> " << a << "\\n"

ll mn = 1000000, mx = -1000000000;
ll cnt, cnt2, sum, x, y;
int n;
string s[300001];

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  sort(s, s + n);
  for (int i = 0; i < n; i++) {
    if (s[i] != s[i + 1]) {
      cnt++;
    }
  }
  cout << cnt;
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define vi vector<int>
#define pb push_back
#define sz(s) (int)s.size()
#define all(v) v.begin(), v.end()
#define show(a) cerr << #a << " -> " << a << "\\n"

ll mn = 1000000, mx = -1000000000;
ll cnt, cnt2, sum, x, y;
int n;
string s[10000];

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  sort(s, s + n);
  for (int i = 0; i < n; i++) {
    if (s[i] != s[i + 1]) {
      cnt++;
    }
  }
  cout << cnt;
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {

  int N;
  cin >> N;

  string S[N];
  set<string> gachas;
  for (int i = 0; i < N; i++) {
    cin >> S[i];
    gachas.insert(S[i]);
  }

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

Error: TLE

Fixed submission:

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

int main() {

  int N;
  cin >> N;

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

  sort(S, S + N);
  int kind_number = 1;
  for (int i = 0; i < N; i++) {
    if (kind[i] == 0) {
      kind[i] = kind_number;
      for (int j = i + 1; j < N; j++) {
        if (S[i] == S[j]) {
          kind[j] = kind_number;
        }
      }

      kind_number++;
    }
  }

  cout << kind_number - 1 << 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> arr(N);
  for (int i = 0; i < N; i++) {
    cin >> arr[i];
  }

  sort(arr.begin(), arr.end());
  arr.erase(unique(arr.begin(), arr.end()), arr.end());
  cout << arr.size() << endl;
}


Error: TLE

Fixed submission:

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

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

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

  int flag = true;
  vector<string> kind;
  for (int i = 0; i < N; i++) {
    flag = true;
    for (int j = 0; j < kind.size(); j++) {
      if (arr[i] == kind[j]) {
        flag = false;
        break;
      }
    }
    if (flag)
      kind.push_back(arr[i]);
  }
  cout << kind.size() << endl;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll a;
  cin >> a;
  vector<string> vec(a);
  for (ll i = 0; i < a; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  ll b = 1;
  if (a > 1) {
    for (ll i = 0; i < a - 1; i++) {
      if (vec.at(i) != vec.at(i + 1)) {
        b += 1;
      }
    }
  }
  cout << b << endl;
}


Error: TLE

Fixed submission:

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

#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, cnt = 0;
  cin >> n;
  string s[n];
  rep(i, n) cin >> s[i];
  sort(s, s + n);
  rep(i, n - 1) {
    if (s[i].compare(s[i + 1]) == 0)
      cnt++;
  }
  int ans = n - cnt;
  cout << ans << endl;
  return 0;
}

Error: TLE

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;
  string s[n];
  rep(i, n) cin >> s[i];
  int cnt = 0;
  int temp;
  rep(i, n - 1) {
    temp = 0;
    for (int j = i + 1; j < n; ++j) {
      if (s[i].compare(s[j]) == 0) {
        temp = 1;
      }
    }
    if (temp == 1) {
      cnt = cnt + 1;
    }
  }
  cout << n - 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> Spin(N);
  string ch;
  int c = 1;

  for (int i = 0; i < N; i++) {
    cin >> Spin.at(i);
  }
  sort(Spin.begin(), Spin.end());
  ch = Spin.at(0);
  for (int i = 0; i < N; i++) {
    string dh = Spin.at(i);
    if (ch != dh) {
      ch = dh;
      c++;
    }
  }

  cout << c << endl;
}


Error: TLE

Fixed submission:

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

int main() {
  int N;
  cin >> N;
  vector<string> Spin(N);
  vector<string> Cpin(N);
  int c = 0;

  for (int i = 0; i < N; i++) {
    cin >> Spin.at(i);
  }

  for (int i = 0; i < N; i++) {
    string &d = Spin.at(i);
    bool flag = true;

    for (int j = 0; j < c; j++) {
      string &e = Cpin.at(j);

      if (d == e) {
        flag = false;
        break;
      }
    }
    if (flag) {
      Cpin.at(c) = d;
      c++;
    }
  }

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

#include <algorithm>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <stdlib.h>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(A) A.begin(), A.end()
int main() {
  int n;
  cin >> n;
  map<string, bool> mp;
  int ans = 0;
  rep(i, n) {
    string s;
    cin >> s;
    if (mp.find(s) == mp.end()) {
      mp[s] = true;
      ans++;
    }
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <stdlib.h>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(A) A.begin(), A.end()
int main() {
  int n;
  cin >> n;
  vector<string> words(0);
  int ans = 0;

  rep(i, n) {
    string s;
    cin >> s;
    bool kaburi = false;
    for (string word : words) {
      if (s == word) {
        kaburi = true;
      }
    }
    if (!kaburi) {
      ans++;
      words.push_back(s);
    }
  }
  cout << ans << endl;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1001001
using namespace std;

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

Error: TLE

Fixed submission:

#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1001001
using namespace std;

int main() {
  int n;
  vector<string> dict;
  cin >> n;
  string s;
  int flag = 0;
  rep(i, n) {
    cin >> s;
    flag = 0;
    rep(j, dict.size()) {
      if (s == dict[j]) {
        flag = 1;
        break;
      }
    }
    if (flag == 0)
      dict.push_back(s);
  }
  cout << dict.size() << 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> v;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    v.push_back(s);
  }
  vector<string>::iterator ip;

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

  count = std::distance(v.begin(), std::unique(v.begin(), v.begin() + n));

  cout << count;

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int count(string s[1000000], int n) {
  int x = 1;
  int j = 0;
  for (int i = 1; i < n; i++) {
    for (j = 0; j < i; j++)
      if (s[i] == s[j])
        break;

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

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

int main() {
  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;
}


Error: -11

Fixed submission:

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

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

#include <iostream>
#include <string>

using namespace std;

long long int cnt = 0;

struct _str {
  string str;
  struct _str *ll;
  struct _str *rr;
};

void count() { cnt++; }

int main() {
  long long int nn, res;
  cin >> nn;
  string tmp;
  cin >> tmp;
  struct _str *root;
  count();
  root = (struct _str *)malloc(sizeof(struct _str));
  root->str = tmp;
  root->rr = NULL;
  root->ll = NULL;
  struct _str *memo;
  for (long long int ii = 1; ii < nn; ii++) {
    cin >> tmp;
    memo = root;
    while (1) {
      res = memo->str.compare(tmp);
      if (res == 0) {
        break;
      } else if (res < 0) {
        if (memo->ll == NULL) {
          count();
          memo->ll = (struct _str *)malloc(sizeof(struct _str));
          memo->ll->str = tmp;
          memo->ll->ll = NULL;
          memo->ll->rr = NULL;
          break;
        } else {
          memo = memo->ll;
        }
      } else if (res > 0) {
        if (memo->rr == NULL) {
          count();
          memo->rr = (struct _str *)malloc(sizeof(struct _str));
          memo->rr->str = tmp;
          memo->rr->ll = NULL;
          memo->rr->rr = NULL;
          break;
        } else {
          memo = memo->rr;
        }
      }
    }
  }

  cout << cnt << '\\n';
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  long long int nn, cnt = 0;
  bool flag;
  cin >> nn;
  string str[nn], tmp;
  for (long long int ii = 0; ii < nn; ii++) {
    cin >> tmp;
    flag = true;
    for (long long int jj = 0; jj < cnt; jj++) {
      if (str[jj] == tmp) {
        flag = false;
        break;
      }
    }
    if (flag) {
      str[cnt] = tmp;
      cnt++;
    }
  }
  cout << cnt << '\\n';
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int N, cnt = 0;
  cin >> N;
  vector<string> gift(N);
  string copy;
  for (int i = 0; i < N; i++)
    cin >> gift.at(i);
  sort(gift.begin(), gift.end());
  for (int i = 0; i < N; i++) {
    if (i == 0) {
      copy = gift.at(0);
      cnt++;
    } else if (copy != gift.at(i)) {
      copy = gift.at(i);
      cnt++;
    }
  }

  cout << cnt << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  int N, j, cnt = 0;
  cin >> N;
  vector<string> gift(N);
  vector<string> num(N);
  for (int i = 0; i < N; i++) {
    int flag = 0;
    cin >> gift.at(i);
    if (i == 0) {
      cnt++;
      num.at(i) = gift.at(i);
    } else {
      for (j = 0; j < cnt; j++) {
        if (gift.at(i) != num.at(j)) {
          flag++;
        }
      }
      if (flag == cnt) {
        num.at(cnt) = gift.at(i);
        cnt++;
      }
    }
  }
  cout << cnt << 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;

  string str;

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

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


Error: TLE

Fixed submission:

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

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

  cin >> s.at(0);
  int v = 1;
  int count = 0;

  if (N >= 2) {

    for (int i = 1; i < N; i++) {
      cin >> s.at(i);

      for (int j = 0; j < i; j++) {
        if (s.at(j) != s.at(i)) {
          count++;
        }
      }

      if (count == i) {
        v++;
      }

      count = 0;
    }
  }

  cout << v << endl;

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

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

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


Error: TLE

Fixed submission:

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

int main() {
  int n;
  vector<string> S;
  cin >> n;
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (S.size() == 0)
      S.push_back(s);
    for (int j = 0; j < S.size() + 1; ++j)
      if (s == S[j])
        break;
      else if (j == S.size()) {
        S.push_back(s);
        break;
      }
  }
  cout << S.size();
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  long long n, cnt;
  cin >> n;
  cnt = 0;
  unordered_set<string> a;

  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    if (a.find(s) == a.end()) {
      a.insert(s);
      cnt++;
    }
  }
  cout << cnt << endl;
}


Error: TLE

Fixed submission:

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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  long long n, cnt;
  cin >> n;
  cnt = 0;
  vector<string> a(n);
  a = {};

  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    bool b = false;
    for (int j = 0; j < cnt; ++j)
      if (s == a[j]) {
        b = true;
        break;
      }
    if (!b) {
      a.push_back(s);
      cnt++;
    }
  }
  cout << cnt << endl;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int n;
set<string> s;
string word;

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

  cin >> n;
  while (n--) {
    cin >> word;
    s.insert(word);
  }

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

  return 0;
}

Error: TLE

Fixed submission:

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

int n;
string s[200005];
char a[11];

int main() {
  scanf("%d", &n);
  int p = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%s", a);
    s[i] = a;
    int j;
    for (j = 1; j < i; j++)
      if (s[i].compare(s[j]) == 0)
        break;
    if (j == i)
      p++;
    else
      i--, n--;
  }
  printf("%d", p);
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using p = pair<int, int>;
int main(int argc, const char *argv[]) {

  cin.tie(0);
  ios::sync_with_stdio(false);

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

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using p = pair<int, int>;
int main(int argc, const char *argv[]) {

  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, k = 0;
  cin >> n;
  string s[n];
  rep(i, n) cin >> s[i];
  vector<string> z;
  rep(i, n) {
    int flag = 0;
    rep(j, z.size()) {
      if (s[i] == z[j]) {
        flag = 1;
        break;
      }
    }
    if (flag != 1) {
      z.push_back(s[i]);
    }
  }
  cout << z.size() << endl;

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

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii> P1;

#define rep(i, n) for (int i = 0; i < n; i++)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define mp1(a, b, c) P1(a, P(b, c))
#define get_arsize(a) (sizeof(a) / sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  int n;
  vector<string> v;
  cin >> n;
  int cnt = 0;
  rep(i, n) {
    string s;
    cin >> s;
    v.push_back(s);
  }
  std::sort(v.begin(), v.end());
  decltype(v)::iterator result = std::unique(v.begin(), v.end());
  v.erase(result, v.end());
  cout << v.size() << endl;
  return 0;
}


Error: TLE

Fixed submission:

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii> P1;

#define rep(i, n) for (int i = 0; i < n; i++)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define mp1(a, b, c) P1(a, P(b, c))
#define get_arsize(a) (sizeof(a) / sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  int n;
  vector<string> v;
  cin >> n;
  int cnt = 0;
  rep(i, n) {
    string s;
    cin >> s;
    auto iter = find(v.begin(), v.end(), s);
    if (iter == v.end()) {
      v.push_back(s);
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define LL long long
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
using namespace std;

const int mn = 2e5 + 7;
string s[mn], t;

int main() {
  int n, ans = 0;
  scanf("%d", &n);
  FOR(i, 1, n) cin >> s[i];
  sort(s + 1, s + n + 1);
  FOR(i, 1, n) if (s[i] != t) t = s[i], ans++;
  cout << ans;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define LL long long
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
using namespace std;

const int mn = 1e5 + 7;
string s[mn], t;

int main() {
  int n, ans = 0;
  scanf("%d", &n);
  FOR(i, 1, n) cin >> s[i];
  sort(s + 1, s + n + 1);
  FOR(i, 1, n) if (s[i] != t) t = s[i], ans++;
  cout << ans;
}