prithivMLmods/Coder-Stat huggingface dataset:
Problem p02700 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  while (true) {
    C -= B;
    if (C == 0) {
      cout << "Yes";
      return 1;
    }
    A -= D;
    if (A == 0) {
      cout << "No";
      return 1;
    }
  }
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int X = (A + D - 1) / D;
  int Y = (C + B - 1) / B;
  cout << (X >= Y ? "Yes" : "No") << "\n";
}
Problem p02700 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A / (A - B) < C / (C - D)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (C - B <= 0) {
    cout << "Yes" << endl;
  } else if (A - D <= 0) {
    cout << "No" << endl;
  } else if (C % B == 0 && A % D != 0) {
    if (C / B <= A / D + 1) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else if (C % B != 0 && A % D == 0) {
    if (C / B + 1 <= A / D) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else if (C / B <= A / D) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p02700 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

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


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int count = 0;
  count = (a + d - 1) / d;
  if (b * count >= c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p02700 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;

int main(int argc, char **argv) {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  bool t{true};

  while (1) {
    if (t)
      c -= b;
    else
      a -= d;

    if (a == 0 || c == 0)
      break;
    t ^= true;
  }
  std::cout << (t ? "Yes" : "No") << std::endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;

int main(int argc, char **argv) {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  bool t{true};

  while (1) {
    if (t)
      c -= b;
    else
      a -= d;

    if (a <= 0 || c <= 0)
      break;
    t ^= true;
  }
  std::cout << (t ? "Yes" : "No") << std::endl;
}
Problem p02700 (C++)

Buggy submission (status: 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;
    }
  }

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


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;
    }
    c = c - b;
    a = a - d;
  }

  if (res == 1)
    cout << "Yes";
  else
    cout << "No";
}
Problem p02700 (C++)

Buggy submission (status: 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 || B != 0) {
    A = A - C;
    D = D - B;
  }
  if (A == 0) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}

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 || C != 0) {
    C = C - B;
    if (C <= 0) {
      cout << "Yes";
      break;
    }
    A = A - D;
    if (A <= 0) {
      cout << "No";
      break;
    }
  }
  return 0;
}
Problem p02700 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  int turn = 1;
  while (c != 0 && a != 0) {
    if (turn == 1) {
      turn ^= 1;
      c = c - b;
    } else {
      turn ^= 1;
      a = a - d;
    }
  }
  if (turn == 0)
    cout << "Yes";
  else
    cout << "No";
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  int turn = 1;
  while (c > 0 && a > 0) {
    if (turn == 1) {
      turn ^= 1;
      c = c - b;
    } else {
      turn ^= 1;
      a = a - d;
    }
  }
  if (turn == 0)
    cout << "Yes";
  else
    cout << "No";
}
Problem p02700 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  while (true) {
    bool chokudai = false;
    for (int i = 0; i < 101; i++) {
      A -= B;
      C -= D;
      if (A < 0) {
        chokudai = true;
      }
      if (C < 0) {
        chokudai = true;
      }
      if (A < C) {
        cout << "Yes" << endl;
      } else if (A > C) {
        cout << "No" << endl;
      }
    }
  }
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if ((A + D - 1) / D >= (C + B - 1) / B) {
    cout << "Yes" << endl;
  }

  else {
    cout << "No" << endl;
  }
}
Problem p02700 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  ll a, b, c, d, count = 1;
  cin >> a >> b >> c >> d;
  while (a != 0 && c != 0) {
    if (count % 2 != 0)
      c = c - b;
    else
      a = a - d;
    count++;
  }
  if (a <= 0)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  ll a, b, c, d, count = 1;
  cin >> a >> b >> c >> d;
  while (a > 0 && c > 0) {
    if (count % 2 != 0)
      c = c - b;
    else
      a = a - d;
    count++;
  }
  if (a <= 0)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}
Problem p02700 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
// #ifndef ONLINE_JUDGE
// #  define LOG(x) (cerr << #x << " = " << (x) << endl)
// #else
// #  define LOG(x) 0
// #endif
#define pb push_back
#define mod 1000000007
#define endl '\n'
typedef int integer;
#define int long long
using namespace std;

int powmod(int a, int b) {
  int res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1)
      res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const integer NN = 200005;
int ar[NN];
int n, m, k;

integer main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int a, b, c, d;
  cin >> a >> b >> c >> d;
  k = 1;
  while (a && c) {
    if (k) {
      c -= b;
    } else {
      a -= d;
    }
    k ^= 1;
  }
  if (!k)
    cout << "Yes";
  else
    cout << "No";
}

Fixed submission:
#include <bits/stdc++.h>
// #ifndef ONLINE_JUDGE
// #  define LOG(x) (cerr << #x << " = " << (x) << endl)
// #else
// #  define LOG(x) 0
// #endif
#define pb push_back
#define mod 1000000007
#define endl '\n'
typedef int integer;
#define int long long
using namespace std;

int powmod(int a, int b) {
  int res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1)
      res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const integer NN = 200005;
int ar[NN];
int n, m, k;

integer main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int a, b, c, d;
  cin >> a >> b >> c >> d;
  k = 1;
  while (a > 0 && c > 0) {
    if (k) {
      c -= b;
    } else {
      a -= d;
    }
    k ^= 1;
  }
  if (!k)
    cout << "Yes";
  else
    cout << "No";
}
Problem p02700 (Python)

Buggy submission (status: Time Limit Exceeded):
ht, st, ha, sa = list(map(int, input().split(" ")))
bool_player = True  # Takashi
while ht > 0 or st > 0:
    if bool_player:
        ha -= st
        bool_player = False
    else:
        ht -= sa
        bool_player = True

if ht <= 0:
    print("No")
else:
    print("Yes")


Fixed submission:
ht, st, ha, sa = list(map(int, input().split(" ")))
bool_player = True  # Takashi
while ht > 0 and ha > 0:
    if bool_player:
        ha -= st
        bool_player = False
    else:
        ht -= sa
        bool_player = True

if ht <= 0:
    print("No")
else:
    print("Yes")
Problem p02700 (C++)

Buggy submission (status: Time Limit Exceeded):
#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;
}

Fixed submission:
#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;
}
Problem p02700 (Python)

Buggy submission (status: Time Limit Exceeded):
A, B, C, D = list(map(int, input().split()))
while A and C:
    A -= D
    C -= B
    if C <= 0:
        print("Yes")
    elif A <= 0:
        print("No")


Fixed submission:
A, B, C, D = list(map(int, input().split()))
t1 = (A + D - 1) // D
t2 = (C + B - 1) // B
print("Yes" if t2 <= t1 else "No")
Problem p02701 (C++)

Buggy submission (status: 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;
  rep(i, n) cin >> s[i];

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

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(n);
  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 (status: Runtime Error):
#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;
}


Fixed submission:
#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;
}
Problem p02701 (C++)

Buggy submission (status: 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 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 0;
}
Problem p02701 (C++)

Buggy submission (status: 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.push_back(hs);
      sort(v.begin(), v.end());
      sum++;
    } else {
    }
  }
  cout << sum << endl;

  return 0;
}

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.insert(itr, hs);
      sum++;
    } else {
    }
  }
  cout << sum << endl;

  return 0;
}
Problem p02701 (C++)

Buggy submission (status: 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 = 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;
}

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 = 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;
}
Problem p02701 (C++)

Buggy submission (status: 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; i++) {
    if (vec.at(i) != vec.at(i + 1)) {
      ans++;
    }
  }

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

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 - 1; i++) {
    if (vec.at(i) != vec.at(i + 1)) {
      ans++;
    }
  }

  cout << ans << "\n";
}
Problem p02701 (Python)

Buggy submission (status: Runtime Error):
import collections

n = int(input())
a = [list(input() for i in range(n))]
b = collections.Counter(a)
print(len(b))


Fixed submission:
import collections

n = int(input())
a = [input() for i in range(n)]
b = collections.Counter(a)
print(len(b))
Problem p02701 (Python)

Buggy submission (status: Runtime Error):
n = int(input)
lis = [input() for i in range(n)]
print(len(set(lis)))


Fixed submission:
n = int(input())
lis = [input() for i in range(n)]
print(len(set(lis)))
Problem p02701 (Python)

Buggy submission (status: Runtime Error):
N = input()
List = list(input() for i in range(N))
print(len(set(List)))


Fixed submission:
N = int(input())
List = list(input() for i in range(N))
print(len(set(List)))
Problem p02701 (Python)

Buggy submission (status: Runtime Error):
n = int(input())
s = (input() for _ in range(n))
print(len(s))


Fixed submission:
n = int(input())
s = {input() for _ in range(n)}
print(len(s))
Problem p02701 (Python)

Buggy submission (status: Time Limit Exceeded):
n = int(input())

ans = 0
u_l = []
for _ in range(n):
    s = input()
    if s not in u_l:
        u_l.append(s)
        ans += 1
print(ans)


Fixed submission:
n = int(input())

l = [input() for _ in range(n)]
print(len(set(l)))
Problem p02701 (Python)

Buggy submission (status: Time Limit Exceeded):
import sys


def main():
    readline = sys.stdin.readline
    N = int(readline())
    li = []
    for _ in range(N):
        S = readline()
        if S not in li:
            li.append(S)
    print(len(li))


if __name__ == "__main__":
    main()


Fixed submission:
import sys


def main():
    readline = sys.stdin.readline
    N = int(readline())
    se = set([readline() for _ in range(N)])
    print(len(se))


if __name__ == "__main__":
    main()
Problem p02701 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

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

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

  cout << ans << endl;
}


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

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

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

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

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

  cout << ans << endl;
}
Problem p02701 (Python)

Buggy submission (status: Runtime Error):
n = int(input())
s = [int(input()) for _ in range(n)]
ans = set()

for i in s:
    ans.add(i)

print(len(ans))


Fixed submission:
n = int(input())
s = [input() for _ in range(n)]
ans = set()

for i in s:
    ans.add(i)

print(len(ans))
Problem p02701 (Python)

Buggy submission (status: Runtime Error):
a = map(int, input().split())
s = list(map(int, input().split()))

print(len(set(s)))


Fixed submission:
a = int(input())
s = [input() for i in range(a)]

print(len(set(s)))
Problem p02701 (Python)

Buggy submission (status: Runtime Error):
import collections

N = int(input())
S = []

for i in range(N):
    S.append(input())

c = collections.counter(S)

print(len(c))


Fixed submission:
import collections

N = int(input())
S = []

for i in range(N):
    S.append(input())

c = collections.Counter(S)

print(len(c))
Problem p02701 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define vec(a, y, x) vector<vector<char>> a(y, vector<char>(x))
const double PI = 3.14159265358979323846;
const in MOD = 1000000007;
const in INF = 1e18 + 7;
const int inf = 1e9 + 7;
const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};

int main() {
  int n;
  cin >> n;
  vector<string> num = {};
  int ans = 1;
  rep(i, n) {
    string a;
    cin >> a;
    if (find(all(num), a) == num.end()) {
      // ans++;
      num.push_back(a);
      // sort(all(num));
    }
  }
  sort(all(num));
  for (int i = 1; i < n; i++) {
    if (num.at(i - 1) != num.at(i))
      ans++;
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define vec(a, y, x) vector<vector<char>> a(y, vector<char>(x))
const double PI = 3.14159265358979323846;
const in MOD = 1000000007;
const in INF = 1e18 + 7;
const int inf = 1e9 + 7;
const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};

int main() {
  int n;
  cin >> n;
  vector<string> num = {};
  int ans = 1;
  rep(i, n) {
    string a;
    cin >> a;

    num.push_back(a);
  }
  sort(all(num));
  for (int i = 1; i < n; i++) {
    if (num.at(i - 1) != num.at(i))
      ans++;
  }
  cout << ans << endl;
}
Problem p02701 (C++)

Buggy submission (status: 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 = 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;
}

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 = 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;
}
Problem p02701 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n) for (int i = 1; i <= n; i++)
// ----GCC ONLY---- //
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// ----        ---- //
#define ll long long
#define PB push_back
#define MOD 10000007
#define PI 3.14159265359

using namespace std;

int main() {

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

  int count = 0;

  sort(s.begin(), s.begin() + n);

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

    if (s.at(i) == s.at(i + 1)) {
      count += 0;
    } else {
      count++;
    }
  }
  cout << count << "\n";
}


Fixed submission:
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n) for (int i = 1; i <= n; i++)
// ----GCC ONLY---- //
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// ----        ---- //
#define ll long long
#define PB push_back
#define MOD 10000007
#define PI 3.14159265359

using namespace std;

int main() {

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

  int count = 0;

  sort(s.begin(), s.begin() + n);

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

    if (s.at(i) == s.at(i + 1)) {
      count += 0;
    } else {
      count++;
    }
  }
  cout << count << "\n";
}
Problem p02701 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template <typename Container>
bool include(const Container &c, const typename Container::value_type &v) {
  return (c.end() != std::find(c.begin(), c.end(), v));
}

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  int cnt = 0;
  rep(i, N) {
    string tmp;
    cin >> tmp;
    if (!include(S, tmp)) {
      cnt++;
    }
    S[i] = tmp;
  }
  cout << cnt << endl;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template <typename Container>
bool include(const Container &c, const typename Container::value_type &v) {
  return (c.end() != std::find(c.begin(), c.end(), v));
}

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  int cnt = 0;
  rep(i, N) cin >> S[i];

  std::sort(S.begin(), S.end());
  S.erase(std::unique(S.begin(), S.end()), S.end());

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

  return 0;
}
Problem p02701 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

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

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

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

  cout << count << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

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

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

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

  cout << count << endl;
  return 0;
}
Problem p02701 (C++)

Buggy submission (status: 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--;
  }
  return m.size();
}

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--;
  }
  cout << m.size() << "\n";
  return 0;
}
Problem p02701 (Python)

Buggy submission (status: Runtime Error):
N = int(input())
S = []
while True:
    Si = input()
    if Si:
        S.append(Si)
    else:
        break
g = S[:N]
print(g)


Fixed submission:
n = int(input())
s = set(input() for _ in range(n))
print(len(s))
Problem p02701 (Python)

Buggy submission (status: Time Limit Exceeded):
N = int(input())
S = []
for i in range(N):
    s = input()
    if s not in S:
        S.append(s)
print(len(S))


Fixed submission:
N = int(input())
S = []
for i in range(N):
    s = input()
    S.append(s)
ans = len(S)
S.sort()
for i in range(1, N):
    if S[i] == S[i - 1]:
        ans -= 1
print(ans)
Problem p02701 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<string> prise(N);
  for (int i = 0; i < N; i++) {
    cin >> prise.at(i);
  }
  int minus = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (prise.at(i) == prise.at(j)) {
        prise.at(j) = j;
        minus++;
      }
    }
  }
  cout << N - minus << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> prise(N);
  for (int i = 0; i < N; i++) {
    cin >> prise.at(i);
  }
  int minus = 0;
  sort(prise.begin(), prise.end());
  for (int i = 1; i < N; i++) {
    if (prise.at(i - 1) == prise.at(i)) {
      minus++;
    }
  }
  cout << N - minus << endl;
}
Problem p02701 (C++)

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

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

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

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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int, int>
#define vvi vector<vi>
#define vvl vector<vl>
#define all(x) x.begin(), x.end()
#define contains(con, x) con.find(x) != con.end()
#define fastread ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int main() {
  fastread;

  int T = 1;
  // cin >> T;

  while (T--) {
    int N;
    cin >> N;

    vector<string> s;
    set<string> uniq;
    for (int i = 0; i < N; i++) {
      cin >> s[i];
      uniq.insert(s[i]);
    }
    cout << uniq.size() << '\n';
  }
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int, int>
#define vvi vector<vi>
#define vvl vector<vl>
#define all(x) x.begin(), x.end()
#define contains(con, x) con.find(x) != con.end()
#define fastread ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int main() {
  fastread;

  int T = 1;
  // cin >> T;

  while (T--) {
    int N;
    cin >> N;

    vector<string> s(N);
    set<string> uniq;
    for (int i = 0; i < N; i++) {
      cin >> s[i];
      uniq.insert(s[i]);
    }
    cout << uniq.size() << '\n';
  }
}
Problem p02701 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(void) {
  int i, t;
  cin >> t;
  string val;
  vector<string> name;
  for (i = 0; i < t; i++) {
    cin >> val;
    name.push_back(val);
  }

  sort(name.begin(), name.end());
  for (i = 0; i < t; i++) {
    name.erase(unique(name.begin(), name.end()), name.end());
  }

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

  return 0;
}


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

typedef long long ll;

int main(void) {
  int i, t;
  cin >> t;
  string val;
  vector<string> name;
  for (i = 0; i < t; i++) {
    cin >> val;
    name.push_back(val);
  }

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

  name.erase(unique(name.begin(), name.end()), name.end());

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

  return 0;
}
Problem p02701 (C++)

Buggy submission (status: Time Limit Exceeded):
/*
 * WelcomeToAtCoder.cpp
 *
 *  Created on: 2020/02/19
 *      Author: black
 */
#include <algorithm>
#include <iostream>
#include <unordered_set>
#include <vector>
using namespace std;

int main() {
  int N;
  unordered_set<string> strList;
  string tmp;
  cin >> N;

  int count = 0;
  for (int i = 0; i < N; ++i) {
    cin >> tmp;
    if (std::find(strList.begin(), strList.end(), tmp) == strList.end()) {
      strList.insert(tmp);
      count++;
    }
  }

  cout << count << endl;

  return 0;
}


Fixed submission:
/*
 * WelcomeToAtCoder.cpp
 *
 *  Created on: 2020/02/19
 *      Author: black
 */
#include <algorithm>
#include <iostream>
#include <unordered_set>
#include <vector>
using namespace std;

int main() {
  int N;
  unordered_set<string> strList;
  string tmp;
  cin >> N;

  int count = 0;
  for (int i = 0; i < N; ++i) {
    cin >> tmp;
    if (strList.find(tmp) == strList.end()) {
      strList.insert(tmp);
      count++;
    }
  }

  cout << count << endl;

  return 0;
}
Problem p02701 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

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

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

  sort(s, s + n);

  int ans = 1;
  string prev = s[1];
  for (int i = 1; i < n; i++)
    if (prev != s[i]) {
      ans++;
      prev = s[i];
    }

  cout << ans;
}

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

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

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

  sort(s, s + n);

  int ans = 1;
  string prev = s[0];
  for (int i = 1; i < n; i++)
    if (prev != s[i]) {
      ans++;
      prev = s[i];
    }

  cout << ans;
}
Problem p02701 (C++)

Buggy submission (status: 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[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;
}

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[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;
}
Problem p02701 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  // Your code here!
  int n;
  cin >> n;

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

  int ct = 0;
  for (int i = 0; i < n; i++) {
    ct++;
    for (int j = i + 1; j < n; j++) {
      if (s[i] == s[j]) {
        ct--;
        break;
      }
    }
  }
  cout << ct << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  // Your code here!
  int n;
  cin >> n;

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

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

  cout << s.size() << endl;
}
Problem p02701 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<string> k(N);
  for (int i = 0; i < N; i++) {
    cin >> k.at(i);
  }
  sort(k.begin(), k.end());
  cout << k.at(1) << endl;
  k.erase(unique(k.begin(), k.end()));
  cout << k.at(1) << endl;
  cout << k.size() << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> k(N);
  for (int i = 0; i < N; i++) {
    cin >> k.at(i);
  }
  sort(k.begin(), k.end());
  k.erase(unique(k.begin(), k.end()), k.end());
  cout << k.size() << endl;
}
Problem p02701 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

long long inp_c, i1, out_n;

string inp_a[100005];

long long readNumber() {
  long long temp_func;
  scanf("%lld", &temp_func);
  return temp_func;
};
long long printNumber(long long temp_func) {
  printf("%lld", temp_func);
  return 0;
};

int main() {

  inp_c = readNumber();

  for (i1 = 1; i1 <= inp_c; i1++) {

    cin >> inp_a[i1];
  };

  sort(inp_a + 1, inp_a + 1 + inp_c);

  for (i1 = 1; i1 <= inp_c; i1++) {

    out_n += inp_a[i1] != inp_a[i1 - 1];
  };

  printNumber(out_n);
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

long long inp_c, i1, out_n;

string inp_a[200005];

long long readNumber() {
  long long temp_func;
  scanf("%lld", &temp_func);
  return temp_func;
};
long long printNumber(long long temp_func) {
  printf("%lld", temp_func);
  return 0;
};

int main() {

  inp_c = readNumber();

  for (i1 = 1; i1 <= inp_c; i1++) {

    cin >> inp_a[i1];
  };

  sort(inp_a + 1, inp_a + 1 + inp_c);

  for (i1 = 1; i1 <= inp_c; i1++) {

    out_n += inp_a[i1] != inp_a[i1 - 1];
  };

  printNumber(out_n);
}
Problem p02701 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

  return 0;
}

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

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

  return 0;
}
Problem p02701 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <set>
using namespace std;

int main() {
  int N;
  int i, num;
  string S[1000];
  cin >> N;
  set<string> gift;

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

Fixed submission:
#include <iostream>
#include <set>
using namespace std;

int main() {
  int N;
  int i, num;
  N >= 1;
  N <= 200000;
  string S[200000];
  cin >> N;
  set<string> gift;

  for (i = 0; i < N; i++) {
    cin >> S[i];
  }
  for (i = 0; i < N; i++) {
    gift.insert(S[i]);
  }
  num = gift.size();
  cout << num << endl;
}
Problem p02701 (C++)

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

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

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

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

Buggy submission (status: Runtime Error):
#include <iostream>
#include <set>
using namespace std;

int main() {
  int N;
  int i, num;
  N >= 1;
  N <= 20000;
  string S[20000];
  cin >> N;
  set<string> gift;

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

Fixed submission:
#include <iostream>
#include <set>
using namespace std;

int main() {
  int N;
  int i, num;
  N >= 1;
  N <= 200000;
  string S[200000];
  cin >> N;
  set<string> gift;

  for (i = 0; i < N; i++) {
    cin >> S[i];
  }
  for (i = 0; i < N; i++) {
    gift.insert(S[i]);
  }
  num = gift.size();
  cout << num << endl;
}
Problem p02701 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  string s[n];
  for (int i = 0; i < n; i++)
    cin >> s[i];
  int count = n;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (s[i] != "A" && s[i] == s[j]) {
        count--;
        s[j] = "A";
      }
    }
  }
  cout << count << endl;
}


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

int main() {
  int n;
  cin >> n;
  string s[n];
  for (int i = 0; i < n; i++)
    cin >> s[i];
  int count = n;
  sort(s, s + n);
  for (int i = 1; i < n; i++) {
    if (s[i - 1] == s[i]) {
      count--;
    }
  }
  cout << count << endl;
}
Problem p02701 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
using Graph = vector<vector<int>>;
// MOD
const int MOD = 1000000007;

long long GCD(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return GCD(b, a % b);
}

int H, W;
int field[100][100];

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double PI = 3.14159265358979323846;
bool seen[100][100];

string N[100];

bool memo[110];
bool flag;
Graph G;

int dist[100][100];

void dfs(int v, vector<bool> &seen, int &res) {
  bool end = true;
  for (int i = 0; i < seen.size(); ++i)
    if (!seen[i] && i != v)
      end = false;
  if (end) {
    ++res;
    return;
  }

  seen[v] = true;
  for (auto nv : G[v]) {
    if (seen[nv])
      continue;
    dfs(nv, seen, res);
  }
  seen[v] = false;
}
bool compare_f(pair<int, int> &x, pair<int, int> &y) {
  return x.second < y.second;
}

int dp[100000];

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

  int res = 0;
  for (int i = 0; i < n; i++) {
    bool ans = false;
    for (int j = i + 1; j < n; j++) {
      if (s[i] == s[j])
        ans = true;
    }
    if (!ans)
      res++;
  }
  cout << res << endl;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
using Graph = vector<vector<int>>;
// MOD
const int MOD = 1000000007;

long long GCD(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return GCD(b, a % b);
}

int H, W;
int field[100][100];

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double PI = 3.14159265358979323846;
bool seen[100][100];

string N[100];

bool memo[110];
bool flag;
Graph G;

int dist[100][100];

void dfs(int v, vector<bool> &seen, int &res) {
  bool end = true;
  for (int i = 0; i < seen.size(); ++i)
    if (!seen[i] && i != v)
      end = false;
  if (end) {
    ++res;
    return;
  }

  seen[v] = true;
  for (auto nv : G[v]) {
    if (seen[nv])
      continue;
    dfs(nv, seen, res);
  }
  seen[v] = false;
}
bool compare_f(pair<int, int> &x, pair<int, int> &y) {
  return x.second < y.second;
}

int dp[100000];

int main() {
  int n;
  cin >> n;
  // int n=3;
  string s[n];
  for (int i = 0; i < n; i++)
    cin >> s[i];
  int res = 1;
  sort(s, s + n);
  for (int i = 1; i < n; i++) {
    if (s[i] != s[i - 1])
      res++;
  }
  cout << res << endl;
}
Problem p02701 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

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

  vector<string> v;

  while (n--) {
    string s;
    cin >> s;
    v.push_back(s);
  }

  vector<string>::iterator ip;
  ip = unique(v.begin(), v.begin() + n);
  v.resize(distance(v.begin(), ip));
  cout << v.size() << endl;
}


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

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

  vector<string> v;

  while (n--) {
    string s;
    cin >> s;
    v.push_back(s);
  }

  unordered_set<string> s;
  int distinct = 0;
  for (int i = 0; i < v.size(); i++) {
    if (s.find(v[i]) == s.end()) {
      s.insert(v[i]);
      distinct++;
    }
  }
  cout << distinct << endl;
}
Problem p02701 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repp(i, n) for (int i = 1; i <= (int)(n); i++)
#define co(x) cout << x << endl
typedef long long int lint;

int main() {
  int N;
  cin >> N;
  vector<string> S(0);
  string si;
  bool flg = true;

  for (int i = 0; i < N; i++) {
    cin >> si;
    flg = true;
    for (int j = 0; j < S.size(); j++) {
      if (S.at(j) == si) {
        flg = false;
        break;
      }
    }
    if (flg == true) {
      S.push_back(si);
    }
  }
  co(S.size());
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repp(i, n) for (int i = 1; i <= (int)(n); i++)
#define co(x) cout << x << endl
typedef long long int lint;

int main() {
  int 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());
  co(S.size());
}