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

#include <iostream>
using namespace std;
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while (1) {
    c -= b;
    if (c <= 0) {
      cout << "Yes" << endl;
      return 0;
    }
    a -= d;
    if (a <= 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while (1) {
    d -= a;
    if (d <= 0)
      cout << "Yes" << endl;
    b -= c;
    if (b <= 0)
      cout << "No" << endl;
  }
  return 0;
}
Problem p02700 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using ii = pair<int, int>;

#define eb emplace_back

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int a, b, c, d;
  cin >> a >> b >> c >> d;
  bool first = 1;
  while (a > 0 && c > 0) {
    if (first) {
      c -= b;
    } else {
      a -= d;
    }
    first = !first;
  }

  if (a > 0) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}


Error: TLE

Fixed submission:

#include <stdio.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using ii = pair<int, int>;

#define eb emplace_back

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int a, b, c, d;
  cin >> a >> b >> c >> d;
  bool first = 1;
  while (a || c) {
    if (first) {
      c -= b;
    } else {
      a -= d;
    }
  }

  if (a) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}
Problem p02700 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int res = 0;

  while (a > 0 || c > 0) {
    if ((c - b) <= 0) {
      res = 1;
      break;
    } else if ((a - d) <= 0) {
      res = -1;
      break;
    }
    c = c - b;
    a = a - d;
  }

  if (res == 1)
    cout << "Yes";
  else
    cout << "No";
}


Error: TLE

Fixed submission:

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int res = 0;

  while (a > 0 || c > 0) {
    if ((c - b) <= 0) {
      res = 1;
      break;
    } else if ((a - d) <= 0) {
      res = -1;
      break;
    }
  }

  if (res == 1)
    cout << "Yes";
  else
    cout << "No";
}
Problem p02700 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define int long long
using namespace std;
signed main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int X, Y;

  if (C % B == 0) {
    X = C / B;
  } else {
    X = C / B + 1;
  }
  if (A % D == 0) {
    Y = A / D;
  } else {
    Y = A / D + 1;
  }
  if (X > Y) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define int long long
using namespace std;
signed main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int X = 0;
  int Y = 0;

  for (int i = 0;; i++) {
    A = A - D;
    if (A <= 0) {
      X = i;
      break;
    }
  }
  for (int i = 0;; i++) {
    C = C - B;
    if (B <= 0) {
      Y = i;
      break;
    }
  }
  if (X > Y) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p02700 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int A, B, C, D;
  cin >> A >> B >> C >> D;
  while (A != 0 || C != 0) {
    C = C - B;
    if (C <= 0) {
      cout << "Yes";
      break;
    }
    A = A - D;
    if (A <= 0) {
      cout << "No";
      break;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int A, B, C, D;
  cin >> A >> B >> C >> D;
  while (A != 0 || B != 0) {
    A = A - C;
    D = D - B;
  }
  if (A == 0) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}
Problem p02700 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while (true) {
    c -= b;
    if (c <= 0 && a > 0) {
      cout << "Yes" << endl;
      break;
    }
    a -= d;
    if (a <= 0 && c > 0) {
      cout << "No" << endl;
      break;
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while (true) {
    a -= d;
    c -= b;
    if (a <= 0 && c > 0) {
      cout << "No" << endl;
      break;
    } else if (a > 0 && c <= 0) {
      cout << "Yes" << endl;
      break;
    }
  }
  return 0;
}
Problem p02700 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main(void) {
  // Your code here!
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  int TAKA, AOKI;
  TAKA = (A - 1) / D; // 攻撃に耐える回数
  AOKI = (C - 1) / B;

  if (TAKA >= AOKI) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main(void) {
  // Your code here!
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  while (A > 0 || B > 0) {
    A -= D;
    C -= B;
  }

  if (A > 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p02700 (C++) — buggy submission, verdict: Time Limit Exceeded

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

long long a, b, c, d;

int main() {
  cin >> a >> b >> c >> d;
  if ((c + b - 1) / b <= (a + d - 1) / d)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

long long a, b, c, d;

int main() {
  cin >> a >> b >> c >> d;
  while (a && c) {
    c -= b;
    if (c == 0)
      break;
    a -= d;
    if (a == 0)
      break;
  }
  if (a)
    cout << "Yes" << endl;
  else
    cout << "No" << 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> result(N);
  for (int i = 0; i < N; i++)
    cin >> result.at(i);
  sort(result.begin(), result.end());
  int count = 1;
  for (int i = 0; i < N - 1; i++) {
    if (result.at(i) != result.at(i + 1))
      count++;
  }
  cout << count << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<string> result;
  result.reserve(200000);
  string s;
  cin >> s;
  result.push_back(s);
  for (int i = 0; i < N - 1; i++) {
    cin >> s;
    bool judge = true;
    for (int j = 0; j < result.size(); j++) {
      if (s == result.at(j)) {
        judge = false;
        break;
      }
    }
    if (judge)
      result.push_back(s);
  }
  cout << result.size() << endl;
  return 0;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

Error: TLE

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

#include <bits/stdc++.h>

using namespace std;

int main() {

  int N;
  cin >> N;

  string S[N + 1];

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

  set<string> members;

  for (int i = 1; i <= N; i++) {
    members.insert(S[i]);
  }

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

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {

  int N;
  cin >> N;

  string S[N + 1];

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

  vector<string> members;
  vector<string> trash;

  members.push_back(S[1]);

  int j = 1;

  for (int i = 2; i <= N; i++) {

    while (j < i) {

      if (S[i] == S[j]) {
        trash.push_back(S[i]);
        j = i;

      } else {
        if (j == i - 1) {
          members.push_back(S[i]);
        }
        i++;
      }
    }
  }

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

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

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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  sort(S.begin(), S.end());
  for (int i = 0; i < N; i++) {
    bool memo = true;
    if (i != N - 1) {
      if (S.at(i) == S.at(i + 1)) {
        memo = false;
      }
    }
    if (memo == true) {
      ans++;
    }
  }
  cout << ans << endl;
}

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 <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  sort(S.begin(), S.end());
  for (int i = 0; i < N; i++) {
    bool memo = true;
    if (S.at(i) == S.at(i + 1)) {
      memo = false;
    }
    if (memo == true) {
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p02701 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

using namespace std;

int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }

int main() {
  int N;
  cin >> N;
  vector<string> S;
  ll ans = 1;
  string tmp;

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

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

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

  for (int i = 0; i < N - 1; i++) {
    tmp = S[i];
    if (tmp.compare(S[i + 1]) != 0) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

using namespace std;

int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }

int main() {
  int N;
  cin >> N;
  vector<string> S;
  ll ans = 0;
  string tmp;

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

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

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

  for (int i = 1; i < N + 1; i++) {
    tmp = S[i];
    if (tmp.compare(S[i - 1]) != 0) {
      ans++;
    }
  }

  cout << ans << 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 < N; i++)
    cin >> S[i];
  sort(S.begin(), S.end());

  int ans = 1;
  for (int i = 1; i < N; i++) {
    if (S[i] == S[i - 1])
      continue;
    ans++;
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#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];

  int ans = 1;
  for (int i = 1; i < N; i++) {
    bool n = true;
    for (int j = 0; j < i; j++) {
      if (S[i] == S[j]) {
        n = false;
        break;
      }
    }
    if (n)
      ans++;
  }
  cout << ans << endl;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
void findering(vector<string> &vec) {
  int k = vec.size();
  int count = 1;
  for (int i = 1; i < k; i++) {
    if (vec.at(0) == vec.at(i)) {
      count++;
    } else {
      break;
    }
  }
  for (int i = 0; i < count; i++) {
    vec.erase(vec.begin());
  }
}
int main() {
  int N;
  cin >> N;
  vector<string> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  int counter = 0;
  while (!vec.size() == 0) {
    findering(vec);
    counter++;
  }
  cout << counter << endl;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;
int main(void) {
  long long int N;
  cin >> N;
  string S[N];
  long long int count = 1;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> S[i];
  }
  sort(S, S + N);
  for (int i = 1; i < N; i++) {
    if (S[i] != S[i - 1]) {
      count++;
    }
  }
  cout << count << endl;
}


Error: TLE

Fixed submission:

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

using namespace std;
int main(void) {
  long long int N;
  cin >> N;
  string S[N];
  string T[N];
  long long int t = 0;
  long long int count = 0;
  long long int answer = 0;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> S[i];
    count = 0;
    for (int j = 0; j <= t; j++) {
      if (S[i] == T[j]) {
        count++;
      }
    }
    if (count == 0) {
      T[t] = S[i];
      t++;
      answer++;
    }
  }
  cout << answer << endl;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <assert.h>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

#define ll long long
#define rep(i, n) for (i = 0; i < n; i++)

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  vector<string> T;
  for (int i = 0; i < N; i++) {
    cin >> S[i];
    T.push_back(S[i]);
  }
  sort(T.begin(), T.end());
  reverse(T.begin(), T.end());
  int ans = 1;
  for (int i = 1; i < T.size(); i++) {
    if (T[i] != T[i - 1]) {
      ans++;
    }
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <assert.h>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

#define ll long long
#define rep(i, n) for (i = 0; i < n; i++)

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  vector<string> T;
  for (int i = 0; i < N; i++) {
    cin >> S[i];
    if (!binary_search(T.begin(), T.end(), S[i])) {
      auto it = lower_bound(T.begin(), T.end(), S[i]);
      // int index = it - T.begin();

      T.insert(it, S[i]);
    }
  }
  cout << T.size() << endl;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 10000000000000
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define repN_1(i, n) for (ll i = 0; i < (ll)(n - 1); i++)
#define repM(i, n) for (ll i = (ll)(n - 1); i >= 0; i--)
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  int n;
  set<string> s;
  int ans = 0;

  cin >> n;
  rep(i, n) {
    string t;
    cin >> t;
    auto it = s.find(t);
    if (it == s.end()) {
      s.insert(t);
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 10000000000000
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define repN_1(i, n) for (ll i = 0; i < (ll)(n - 1); i++)
#define repM(i, n) for (ll i = (ll)(n - 1); i >= 0; i--)
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  int n;
  vector<string> s;
  int ans = 0;

  cin >> n;
  rep(i, n) {
    string t;
    cin >> t;
    if (s.empty()) {
      ans++;
      s.push_back(t);
    } else {
      auto it = lower_bound(s.begin(), s.end(), t);
      if (it == s.end()) {
        ans++;
        s.push_back(t);
      } else if (*it != t) {
        ans++;
        s.insert(it, t);
      }
    }
  }

  cout << ans << 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 < N; i++) {
    cin >> S.at(i);
  }
  sort(S.begin(), S.end());
  int count = 0;
  for (int i = 0; i < N - 1; i++) {
    if (S.at(i) == S.at(i + 1)) {
      count++;
    }
  }
  cout << N - count;
}

Error: TLE

Fixed submission:

#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);
  }
  int count = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < i; j++) {
      if (S.at(i) == S.at(j)) {
        count++;
        S.at(j) = "aaaaaaaaaaaaa";
      }
    }
  }
  cout << N - count;
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <cmath>
#include <ctime>
#include <map>
#include <math.h>
#define R(i, n) for (int i = 0; i < n; i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SL2(a, b) scanf("%lld%lld", &a, &b)
#define SL3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SA(i, n, a) R(i, n) scanf("%d", a + i)
#define SAL(i, n, a) R(i, n) scanf("%lld", a + i)
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;

int N;

int main() {
  S(N);
  set<string> ss;
  string s = "";
  cin >> s;
  ss.insert(s);
  int ans = 1;
  for (int i = 1; i < N; i++) {
    string st = "";
    cin >> st;
    if (ss.count(st) == 0) {
      ss.insert(st);
      ans++;
    }
  }
  P(ans);
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <cmath>
#include <ctime>
#include <map>
#include <math.h>
#define R(i, n) for (int i = 0; i < n; i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SL2(a, b) scanf("%lld%lld", &a, &b)
#define SL3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SA(i, n, a) R(i, n) scanf("%d", a + i)
#define SAL(i, n, a) R(i, n) scanf("%lld", a + i)
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;

int N;
string I[200000];

int main() {
  S(N);
  R(i, N) {
    string st = "";
    cin >> st;
    I[i] = st;
  }
  int ans = N;
  R(i, N) {
    for (int j = i + 1; j < N; j++) {
      if (I[i] == I[j]) {
        ans--;
        break;
      }
    }
  }
  P(ans);
}
Problem p02701 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

  // vector<string> gifts;
  set<string> gifts;

  for (int i = 0; i < N; i++) {
    cin >> s;
    auto ite = gifts.find(s);

    if (ite == gifts.end()) {
      gifts.insert(s);
    }
  }

  std::cout << gifts.size();

  return 0;
}


Error: TLE

Fixed submission:

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

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

  vector<string> gifts;

  for (int i = 0; i < N; i++) {
    bool get = false;
    cin >> s;
    for (int j = 0; j < gifts.size(); j++) {
      if (gifts.at(j) == s) {
        get = true;
        break;
      }
    }
    if (!get) {
      gifts.push_back(s);
    }
  }

  cout << gifts.size();

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

#include <iostream>
#include <set>
using namespace std;
int main() {
  int N;
  cin >> N;
  set<string> S;
  for (int i = 0; i < N; i++) {
    string tmp;
    cin >> tmp;
    S.insert(tmp);
  };
  cout << S.size() << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<string> S;
  for (int i = 0; i < N; i++) {
    string tmp;
    cin >> tmp;
    auto itr = find(S.begin(), S.end(), tmp);
    if (itr == S.end())
      S.push_back(tmp);
  };
  cout << S.size() << endl;
  return 0;
}