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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int q;
  scanf("%d", &q);
  while (q--) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    int k = (max(a, b) - 1) / (min(a, b) + 1) + 1;
    // printf("k is %d\n",k);
    int lo = 0, hi = a + b;
    while (lo < hi) {
      int m = (lo + hi) / 2;
      int b1 = m / (k + 1);
      int a1 = m - b1;
      int b2 = b - b1;
      int a2 = a - a1;
      if ((ll)b2 < (ll)(a2 + 1) * k) {
        /// first part
        lo = m;
      } else {
        hi = m - 1;
      }
    }
    for (int i = c; i <= d; i++) {
      if (i <= lo) {
        printf("%c", i % (k + 1) == 0 ? 'B' : 'A');
      } else {
        printf("%c", (a + b - i + 1) % (k + 1) == 0 ? 'A' : 'B');
      }
    }
    printf("\n");
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int q;
  scanf("%d", &q);
  while (q--) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    int k = (max(a, b) - 1) / (min(a, b) + 1) + 1;
    // printf("k is %d\n",k);
    int lo = 0, hi = a + b;
    while (lo < hi) {
      int m = (lo + hi + 1) / 2;
      int b1 = m / (k + 1);
      int a1 = m - b1;
      int b2 = b - b1;
      int a2 = a - a1;
      if ((ll)b2 < (ll)(a2 + 1) * k) {
        /// first part
        lo = m;
      } else {
        hi = m - 1;
      }
    }
    for (int i = c; i <= d; i++) {
      if (i <= lo) {
        printf("%c", i % (k + 1) == 0 ? 'B' : 'A');
      } else {
        printf("%c", (a + b - i + 1) % (k + 1) == 0 ? 'A' : 'B');
      }
    }
    printf("\n");
  }
}
Problem p03466 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long
#define mid (l + r >> 1)
using namespace std;
int main() {
  ll T;
  cin >> T;
  while (T--) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a == b) {
      for (ll i = c; i <= d; i++)
        putchar(i & 1 ? 'A' : 'B');
      puts("");
      continue;
    }
    ll now = max(a, b) / (min(a, b) + 1);
    if (max(a, b) % (min(a, b) + 1))
      now++;
    if (now == 1) {
      if (a > b)
        for (ll i = c; i <= d; i++)
          putchar(i & 1 ? 'A' : 'B');
      else
        for (ll i = c; i <= d; i++)
          putchar(i & 1 ? 'B' : 'A');
      puts("");
      continue;
    }
    ll l = 0, r = a / now, ret = 0;
    while (l <= r) {
      ll A = a - now * mid, B = b - mid;
      if (max(B / (A + 1), (A - 1) / (B + 1)) < now)
        ret = mid, l = mid + 1;
      else
        r = mid - 1;
    }
    ll lim = ret;
    l = 0, r = min(now, a - lim * now), ret = 0;
    while (l <= r) {
      ll A = a - now * lim - mid, B = b - lim;
      if (max((mid ? B : B - (lim == 0)) / (A + 1), (A - 1) / (B + 1)) < now)
        ret = mid, l = mid + 1;
      else
        r = mid - 1;
    }
    lim *= now + 1;
    lim += mid + 1;
    for (ll i = c; i < lim && i <= d; i++)
      putchar(i % (now + 1) == 0 ? 'B' : 'A');
    for (ll i = max(lim, c); i <= d; i++)
      putchar((a + b - i + 1) % (now + 1) == 0 ? 'A' : 'B');
    puts("");
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define ll long long
#define mid (l + r >> 1)
using namespace std;
int main() {
  ll T;
  cin >> T;
  while (T--) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll now = max((a - 1) / (b + 1), (b - 1) / (a + 1)) + 1;
    ll l = 0, r = min(a / now, b), ret = 0;
    while (l <= r) {
      ll A = a - now * mid, B = b - mid;
      if (max(B / (A + 1), (A - 1) / (B + 1)) < now)
        ret = mid, l = mid + 1;
      else
        r = mid - 1;
    }
    ll lim = ret;
    l = 0, r = min(now, a - lim * now), ret = 0;
    while (l <= r) {
      ll A = a - now * lim - mid, B = b - lim;
      if (max((mid ? B : B - (lim == 0)) / (A + 1), (A - 1) / (B + 1)) < now)
        ret = mid, l = mid + 1;
      else
        r = mid - 1;
    }
    lim *= now + 1;
    lim += mid + 1;
    for (ll i = c; i < lim && i <= d; i++)
      putchar(i % (now + 1) == 0 ? 'B' : 'A');
    for (ll i = max(lim, c); i <= d; i++)
      putchar((a + b - i + 1) % (now + 1) == 0 ? 'A' : 'B');
    puts("");
  }
  return 0;
}
Problem p03466 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
#define INF (1 << 29)
#define LINF (1LL << 60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int calck(int a, int b) {
  if (a > b)
    swap(a, b);
  return b / (a + 1) + (b % (a + 1) != 0);
}

void solve() {
  Int a, b, c, d;
  cin >> a >> b >> c >> d;
  int k = calck(a, b);
  int bottom = 0, top = a + b;
  if ((a + b) / (k + 1) == a)
    top = 0;
  while (top - bottom > 1) {
    int mid = (top + bottom) / 2;
    int l = mid;
    while (l > 0 && l % (k + 1) == k && (a + b - l) % (k + 1) == 0 &&
               (a + b - l) > 0 ||
           l % (k + 1) == 0 && l > 0 && (a + b - l) % (k + 1) == k)
      l--;
    if (l / (k + 1) * k + l % (k + 1) + (a + b - l) / (k + 1) >= a)
      top = mid;
    else
      bottom = mid;
  }
  int l = top;
  if (l % (k + 1) == k && (a + b - l) % (k + 1) == 0 && (a + b - l) > 0)
    l--;
  else if (l % (k + 1) == 0 && l > 0 && (a + b - l) % (k + 1) == k)
    l--;
  //  cout << l << endl;
  for (int i = c; i <= d; i++) {
    if (i <= l) {
      if (i % (k + 1) == 0)
        cout << 'B';
      else
        cout << 'A';
    } else {
      if ((a + b - i + 1) % (k + 1) == 0)
        cout << 'A';
      else
        cout << 'B';
    }
  }
  cout << endl;
}

int main() {
  Int q;
  cin >> q;
  while (q--)
    solve();
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
#define INF (1 << 29)
#define LINF (1LL << 60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int calck(int a, int b) {
  if (a > b)
    swap(a, b);
  return b / (a + 1) + (b % (a + 1) != 0);
}

void solve() {
  Int a, b, c, d;
  cin >> a >> b >> c >> d;
  int k = calck(a, b);
  int bottom = 0, top = a + b;
  if ((a + b) / (k + 1) == a)
    top = 0;
  if ((a + b) / (k + 1) == b)
    bottom = a + b;
  while (top - bottom > 1) {
    int mid = (top + bottom) / 2;
    int l = mid;
    while (l > 0 && l % (k + 1) == k && (a + b - l) % (k + 1) == 0 &&
               (a + b - l) > 0 ||
           l % (k + 1) == 0 && l > 0 && (a + b - l) % (k + 1) == k)
      l--;
    if (l / (k + 1) * k + l % (k + 1) + (a + b - l) / (k + 1) >= a)
      top = mid;
    else
      bottom = mid;
  }
  int l = top;
  if (l % (k + 1) == k && (a + b - l) % (k + 1) == 0 && (a + b - l) > 0)
    l--;
  else if (l % (k + 1) == 0 && l > 0 && (a + b - l) % (k + 1) == k)
    l--;
  //  cout << l << endl;
  for (int i = c; i <= d; i++) {
    if (i <= l) {
      if (i % (k + 1) == 0)
        cout << 'B';
      else
        cout << 'A';
    } else {
      if ((a + b - i + 1) % (k + 1) == 0)
        cout << 'A';
      else
        cout << 'B';
    }
  }
  cout << endl;
}

int main() {
  Int q;
  cin >> q;
  while (q--)
    solve();
  return 0;
}
Problem p03466 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define int long long
#define LL long long
using namespace std;
template <typename T> void read(T &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-')
      f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
inline void write(int x) {
  if (x > 9)
    write(x / 10);
  putchar(x % 10 + '0');
}

int n, a, b, c, d, k;
inline bool check(int l) {
  LL cntl = l / (k + 1), r = l % (k + 1);
  LL cnta = a - (cntl * k + r), cntb = b - (cntl);
  return cntb <= cnta * k;
}
inline void solve() {
  read(a), read(b), read(c), read(d),
      k = max(ceil(1.0 * a / (b + 1)), ceil(1.0 * b / (a + 1)));
  n = a + b;
  int L = 0, R = n, Mid, Ans = 0;
  while (L <= R) {
    Mid = L + R >> 1;
    if (check(Mid))
      Ans = Mid + 1, L = Mid + 1;
    else
      R = Mid;
  }
  int l = Ans;
  LL cntl = l / (k + 1), r = l % (k + 1);
  int cnta = a - (cntl * k + r), cntb = b - (cntl);
  int w = l + 1 + (cntb - (cnta)*k);
  for (int i = c; i <= d; ++i) {
    if (i <= l) {
      putchar(i % (k + 1) == 0 ? 'B' : 'A');
    } else {
      int j = i - w;
      putchar(j % (k + 1) == 0 ? 'A' : 'B');
    }
  }
  putchar('\n');
}

signed main() {
  int T;
  read(T);
  while (T--)
    solve();
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define int long long
#define LL long long
using namespace std;
template <typename T> void read(T &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-')
      f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
inline void write(int x) {
  if (x > 9)
    write(x / 10);
  putchar(x % 10 + '0');
}

int n, a, b, c, d, k;
inline bool check(int l) {
  LL cntl = l / (k + 1), r = l % (k + 1);
  LL cnta = a - (cntl * k + r), cntb = b - (cntl);
  return cntb <= cnta * k;
}
inline void solve() {
  read(a), read(b), read(c), read(d),
      k = max(ceil(1.0 * a / (b + 1)), ceil(1.0 * b / (a + 1)));
  n = a + b;
  int L = 0, R = n, Mid, Ans = 0;
  while (L < R) {
    Mid = L + R >> 1;
    if (check(Mid))
      Ans = Mid + 1, L = Mid + 1;
    else
      R = Mid;
  }
  int l = Ans;
  LL cntl = l / (k + 1), r = l % (k + 1);
  int cnta = a - (cntl * k + r), cntb = b - (cntl);
  int w = l + 1 + (cntb - (cnta)*k);
  for (int i = c; i <= d; ++i) {
    if (i <= l) {
      putchar(i % (k + 1) == 0 ? 'B' : 'A');
    } else {
      int j = i - w;
      putchar(j % (k + 1) == 0 ? 'A' : 'B');
    }
  }
  putchar('\n');
}

signed main() {
  int T;
  read(T);
  while (T--)
    solve();
  return 0;
}
Problem p03466 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed << setprecision(x)
#define pii pair<ll, ll>
#define vint vector<ll>
#define pb push_back
using namespace std;
void Freopen() {
  freopen(title ".in", "r", stdin);
  freopen(title ".out", "w", stdout);
}
ll read() {
  ll g = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || '9' < ch) {
    if (ch == '-')
      f = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    g = g * 10 + ch - '0';
    ch = getchar();
  }
  return g * f;
}
ll a, b, A, B, C, D, re, tag;
void get(ll mid) {
  a = A - mid / (re + 1) * re - mid % (re + 1);
  b = B - mid / (re + 1);
}
signed main() {
  for (ll T = read(); T--;) {
    A = read(), B = read(), C = read(), D = read();
    re = max((ll)ceil((double)A / (B + 1)), (ll)ceil((double)B / (A + 1)));
    ll l = 0, r = A + B;
    while (l <= r) {
      ll mid = l + r >> 1;
      get(mid);
      if (b <= a * re)
        l = mid + 1;
      else
        r = mid;
    }
    ll pos = l;
    get(pos);
    tag = pos + 1 + b - a * re;
    for (ll i = C; i <= D; i++) {
      if (i <= pos) {
        if (i % (re + 1))
          cout << 'A';
        else
          cout << 'B';
      } else {
        if ((i - tag) % (re + 1))
          cout << 'B';
        else
          cout << 'A';
      }
    }
    cout << '\n';
  }
  return signed();
}

Fixed submission:
#include <bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed << setprecision(x)
#define pii pair<ll, ll>
#define vint vector<ll>
#define pb push_back
using namespace std;
void Freopen() {
  freopen(title ".in", "r", stdin);
  freopen(title ".out", "w", stdout);
}
ll read() {
  ll g = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || '9' < ch) {
    if (ch == '-')
      f = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    g = g * 10 + ch - '0';
    ch = getchar();
  }
  return g * f;
}
ll a, b, A, B, C, D, re, tag;
void get(ll mid) {
  a = A - mid / (re + 1) * re - mid % (re + 1);
  b = B - mid / (re + 1);
}
signed main() {
  for (ll T = read(); T--;) {
    A = read(), B = read(), C = read(), D = read();
    re = max((ll)ceil((double)A / (B + 1)), (ll)ceil((double)B / (A + 1)));
    ll l = 0, r = A + B;
    while (l < r) {
      ll mid = l + r >> 1;
      get(mid);
      if (b <= a * re)
        l = mid + 1;
      else
        r = mid;
    }
    ll pos = l;
    get(pos);
    tag = pos + 1 + b - a * re;
    for (ll i = C; i <= D; i++) {
      if (i <= pos) {
        if (i % (re + 1))
          cout << 'A';
        else
          cout << 'B';
      } else {
        if ((i - tag) % (re + 1))
          cout << 'B';
        else
          cout << 'A';
      }
    }
    cout << '\n';
  }
  return signed();
}
Problem p03467 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <string>

#define P 998244353

using namespace std;

typedef long long ll;

map<ll, ll> F[2];

string operator&(string X, string Y) {
  string Z;
  for (int i = 0; i < X.size(); i++)
    Z += char('0' + ((X[i] - '0') & (Y[i] - '0')));
  return Z;
}

ll gethsh(string A) {
  ll ans = 0;
  for (int i = 0; i < A.size(); i++)
    ans = (ans * 131 + A[i]);
  return ans;
}

ll Solve(string A, int op) {
  if (A.size() == 0)
    return op;
  if (F[op].count(gethsh(A)))
    return F[op][gethsh(A)];
  if (A.size() == 1) {
    if (!op)
      return 0;
    if (A[0] == '1')
      return 2;
    return 1;
  }
  if (op == 1) {
    ll ans = 0, nw = 1;
    for (int i = 0; i < A.size(); i++) {
      for (int j = i + 1; j <= A.size(); j++)
        ans = (ans + nw * Solve(A.substr(i, j - i), 0) % P *
                         Solve(A.substr(j, A.size() - j), 1)) %
              P;
      nw = nw * (A[i] - '0' + 1) % P;
    }
    return F[op][gethsh(A)] = (ans + nw) % P;
  }
  ll ans = 0;
  for (int i = 1; i < A.size(); i++)
    if (A.size() % i == 0) {
      string X = A.substr(0, i);
      for (int j = i; j < A.size(); j += i)
        X = X & A.substr(j, i);
      ans = (ans + Solve(X, 1)) % P;
    }
  return F[op][gethsh(A)] = ans;
}

int main() {
  string A;
  cin >> A;
  printf("%lld\n", Solve(A, 1));
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <string>

#define P 998244353

using namespace std;

typedef long long ll;

map<ll, ll> F[2];

string operator&(string X, string Y) {
  string Z;
  for (int i = 0; i < X.size(); i++)
    Z += char('0' + ((X[i] - '0') & (Y[i] - '0')));
  return Z;
}

ll gethsh(string A) {
  ll ans = 0;
  for (int i = 0; i < A.size(); i++)
    ans = (ans * 131 + A[i]);
  return ans;
}

ll Solve(string A, int op) {
  if (A.size() == 0)
    return op;
  ll tmp;
  if (tmp = F[op][gethsh(A)])
    return tmp;
  if (A.size() == 1) {
    if (!op)
      return 0;
    if (A[0] == '1')
      return 2;
    return 1;
  }
  if (op == 1) {
    ll ans = 0, nw = 1;
    for (int i = 0; i < A.size(); i++) {
      for (int j = i + 1; j <= A.size(); j++)
        ans = (ans + nw * Solve(A.substr(i, j - i), 0) % P *
                         Solve(A.substr(j, A.size() - j), 1)) %
              P;
      nw = nw * (A[i] - '0' + 1) % P;
    }
    return F[op][gethsh(A)] = (ans + nw) % P;
  }
  ll ans = 0;
  for (int i = 1; i < A.size(); i++)
    if (A.size() % i == 0) {
      string X = A.substr(0, i);
      for (int j = i; j < A.size(); j += i)
        X = X & A.substr(j, i);
      ans = (ans + Solve(X, 1)) % P;
    }
  return F[op][gethsh(A)] = ans;
}

int main() {
  string A;
  cin >> A;
  printf("%lld\n", Solve(A, 1));
  return 0;
}
Problem p03467 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod = 998244353, MAX = 105, INF = 1 << 30;
map<string, ll> MA;

ll solve(string &S) {
  if (MA[S])
    return MA[S];
  int N = si(S);
  if (N == 1)
    return (S[0] - '0' + 1);
  vector<ll> dp(N + 1, 0);
  dp[0] = 1;

  for (int i = 0; i < N; i++) {
    dp[i + 1] += dp[i] * (S[i] - '0' + 1);
    dp[i + 1] %= mod;

    for (int plus = 2; i + plus <= N; plus++) {
      for (int x = 1; x < plus; x++) {
        if (plus % x)
          continue;
        string T = S.substr(i, x);
        for (int y = i; y + x - 1 < i + plus; y += x) {
          string U = S.substr(y, x);
          for (int z = 0; z < x; z++) {
            if (T[z] == '0' || U[z] == '0')
              T[z] = '0';
          }
        }

        dp[i + plus] += dp[i] * solve(T);
        dp[i + plus] %= mod;
      }
    }
  }

  return dp[N];
}

int main() {

  std::ifstream in("text.txt");
  std::cin.rdbuf(in.rdbuf());
  cin.tie(0);
  ios::sync_with_stdio(false);

  string S;
  cin >> S;

  cout << solve(S) << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod = 998244353, MAX = 105, INF = 1 << 30;
map<string, ll> MA;

ll solve(string &S) {
  if (MA[S])
    return MA[S];
  int N = si(S);
  if (N == 1)
    return (S[0] - '0' + 1);
  vector<ll> dp(N + 1, 0);
  dp[0] = 1;

  for (int i = 0; i < N; i++) {
    dp[i + 1] += dp[i] * (S[i] - '0' + 1);
    dp[i + 1] %= mod;

    for (int plus = 2; i + plus <= N; plus++) {
      for (int x = 1; x < plus; x++) {
        if (plus % x)
          continue;
        string T = S.substr(i, x);
        for (int y = i; y + x - 1 < i + plus; y += x) {
          string U = S.substr(y, x);
          for (int z = 0; z < x; z++) {
            if (T[z] == '0' || U[z] == '0')
              T[z] = '0';
          }
        }

        dp[i + plus] += dp[i] * solve(T);
        dp[i + plus] %= mod;
      }
    }
  }

  return MA[S] = dp[N];
}

int main() {

  std::ifstream in("text.txt");
  std::cin.rdbuf(in.rdbuf());
  cin.tie(0);
  ios::sync_with_stdio(false);

  string S;
  cin >> S;

  cout << solve(S) << endl;
}
Problem p03468 (C++)

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

using namespace std;

const int N = 6;
const int C = 50;

int n, c;
int l[N];
long long f[N * C][1 << (N - 1)][N * C + 1];

void solve() {
  cin >> n >> c;
  for (int i = 0; i < n; ++i) {
    cin >> l[i];
  }
  sort(l, l + n);
  reverse(l, l + n);

  long long ret = 0;
  vector<int> order_b;
  for (int i = 1; i < n; ++i) {
    order_b.push_back(i);
  }

  do {
    memset(f, 0, sizeof f);
    f[0][0][l[0] * n] = 1;
    for (int i = 0; i < n * c; ++i) {
      for (int s = 0; s < (1 << (n - 1)); ++s) {
        for (int j = i + 1; j <= n * c; ++j) {
          if (f[i][s][j] == 0)
            continue;
          f[i + 1][s][j] += f[i][s][j];
          if ((i + 1) % n == 0)
            continue;

          int id = order_b[(i + 1) % n - 1];
          if (s >> (id - 1) & 1)
            continue;
          f[i + 1][s + (1 << (id - 1))]
           [min(n * c, max(j, i + 1 + l[id] * n))] += f[i][s][j];
        }
      }
    }
    ret += f[n * c][(1 << (n - 1)) - 1][n * c];
  } while (next_permutation(order_b.begin(), order_b.end()));

  long long over = 1;
  for (int i = 1; i < n; ++i) {
    over *= i;
    over *= c;
  }
  printf("%.20f\n", (double)((long double)ret / (long double)over));
}

int main() {
  solve();
  return 0;
}


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

using namespace std;

const int N = 6;
const int C = 50;

int n, c;
int l[N];
long long f[N * C + 1][1 << (N - 1)][N * C + 1];

void solve() {
  cin >> n >> c;
  for (int i = 0; i < n; ++i) {
    cin >> l[i];
  }
  sort(l, l + n);
  reverse(l, l + n);

  long long ret = 0;
  vector<int> order_b;
  for (int i = 1; i < n; ++i) {
    order_b.push_back(i);
  }

  do {
    memset(f, 0, sizeof f);
    f[0][0][l[0] * n] = 1;
    for (int i = 0; i < n * c; ++i) {
      for (int s = 0; s < (1 << (n - 1)); ++s) {
        for (int j = i + 1; j <= n * c; ++j) {
          if (f[i][s][j] == 0)
            continue;
          f[i + 1][s][j] += f[i][s][j];
          if ((i + 1) % n == 0)
            continue;

          int id = order_b[(i + 1) % n - 1];
          if (s >> (id - 1) & 1)
            continue;
          f[i + 1][s + (1 << (id - 1))]
           [min(n * c, max(j, i + 1 + l[id] * n))] += f[i][s][j];
        }
      }
    }
    ret += f[n * c][(1 << (n - 1)) - 1][n * c];
  } while (next_permutation(order_b.begin(), order_b.end()));

  long long over = 1;
  for (int i = 1; i < n; ++i) {
    over *= i;
    over *= c;
  }
  printf("%.20f\n", (double)((long double)ret / (long double)over));
}

int main() {
  solve();
  return 0;
}
Problem p03469 (Python)

Buggy submission (status: Runtime Error):
a = input()
a[3] = "8"
print(a)


Fixed submission:
a = input()
print("2018" + a[4:])
Problem p03469 (C++)

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

int main() {
  string s;
  cout << "2017" + s.substr(4, 6) << endl;
}


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

int main() {
  string s;
  cin >> s;
  cout << "2018" << s.substr(4, s.size() - 4) << endl;
}
Problem p03469 (C++)

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

int main() {
  // input
  string str;
  str.at(3) = '8';
  cout << str << endl;

  return 0;
}

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

int main() {
  // input
  string str;
  cin >> str;
  str.at(3) = '8';
  cout << str << endl;

  return 0;
}
Problem p03469 (C++)

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

using namespace std;

int main() {
  int numbers[10];

  cin >> numbers[10];
  numbers[3] = 8;
  cout << numbers[10] << endl;
  return 0;
}


Fixed submission:
#include <iostream>

using namespace std;

int main() {
  char num1[20];
  cin >> num1;
  num1[3] = '8';
  cout << num1;
  return 0;
}
Problem p03469 (C++)

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

int main() {
  string s;
  s.at(4) = 8;
  cout << s << endl;
}

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

int main() {
  string s;
  cin >> s;
  s.at(3) = '8';
  cout << s << endl;
}
Problem p03469 (C++)

Buggy submission (status: Runtime Error):
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
  ll x, a, b;
  cin >> x >> a >> b;
  ll y = x - a;
  cout << y % b << endl;
}

Fixed submission:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
  str s;
  cin >> s;
  s[3] = '8';
  cout << s << endl;
}
Problem p03469 (C++)

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

#define ft first
#define sd second
#define get(t, x) get<x>(t)
#define pb push_back
#define len length
#define dbgn(x) cerr << #x << ": " << x << '\n'
#define dbg(x) cerr << #x << ": " << x << ' '
#define MAX 1100000

using namespace std;
using namespace __gnu_pbds;

using lli = long long int;
using pll = pair<lli, lli>;
using pii = pair<int, int>;
using mii = map<int, int>;
using ti3 = tuple<int, int, int>;
using pqpi_min = priority_queue<pii, vector<pii>, greater<pii>>;
using ost = tree<int, null_type, less<int>, rb_tree_tag,
                 tree_order_statistics_node_update>;
template <class T> void print(T *a, int sz) {
  for (int i = 0; i < sz; ++i)
    cerr << a[i] << ' ';
  cerr << endl;
}
istream &operator>>(istream &is, pii &p) {
  is >> p.ft >> p.sd;
  return is;
}
ostream &operator<<(ostream &os, const pii &p) {
  os << "[" << p.ft << ", " << p.sd << ']';
  return os;
}
// int+string
// cin.ignore();

constexpr int M = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;

void solve() {
  string s;
  cin >> s;
  s[3] = '8';
  cout << s;
}
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
  freopen("inp.txt", "r", stdin);
#endif
  solve();
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define ft first
#define sd second
#define get(t, x) get<x>(t)
#define pb push_back
#define len length
#define dbgn(x) cerr << #x << ": " << x << '\n'
#define dbg(x) cerr << #x << ": " << x << ' '
#define MAX 1100000

using namespace std;
using namespace __gnu_pbds;

using lli = long long int;
using pll = pair<lli, lli>;
using pii = pair<int, int>;
using mii = map<int, int>;
using ti3 = tuple<int, int, int>;
using pqpi_min = priority_queue<pii, vector<pii>, greater<pii>>;
using ost = tree<int, null_type, less<int>, rb_tree_tag,
                 tree_order_statistics_node_update>;
template <class T> void print(T *a, int sz) {
  for (int i = 0; i < sz; ++i)
    cerr << a[i] << ' ';
  cerr << endl;
}
istream &operator>>(istream &is, pii &p) {
  is >> p.ft >> p.sd;
  return is;
}
ostream &operator<<(ostream &os, const pii &p) {
  os << "[" << p.ft << ", " << p.sd << ']';
  return os;
}
// int+string
// cin.ignore();

constexpr int M = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;

void solve() {
  string s;
  cin >> s;
  s[3] = '8';
  cout << s;
}
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
Problem p03469 (Python)

Buggy submission (status: Runtime Error):
s = str(input())
s[3] = "7"
print(s)


Fixed submission:
s = str(input())
s = "2018/01" + s[7:10]
print(s)
Problem p03469 (Python)

Buggy submission (status: Runtime Error):
S = input()
S[:4] = "2018"
print(S)


Fixed submission:
S = input()
S = S.replace("2017", "2018")
print(S)
Problem p03469 (Python)

Buggy submission (status: Runtime Error):
S = input()

S[3] = 8
print(S)


Fixed submission:
S = input()

S = S.replace("7", "8", 1)
print(S)
Problem p03469 (Python)

Buggy submission (status: Runtime Error):
s = input().rstrip()

s1 = "2018" + s[4:] if s.startwith("2017") else s


Fixed submission:
s = input().rstrip()

s1 = "2018" + s[4:] if s.startswith("2017") else s
print(s1)
Problem p03469 (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++)
#define all(x) (x).begin(), (x).end()

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

  // start
  string s;
  cout << "2018/01/" << s.at(8) << s.at(9) << endl;
  // end

  return 0;
}


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

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

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

  // start
  string s;
  cin >> s;
  cout << "2018/01/" << s.at(8) << s.at(9) << endl;
  // end

  return 0;
}
Problem p03469 (Python)

Buggy submission (status: Runtime Error):
n, y = map(int, input().split())

a = 0
b = 0
c = n
ans = c * 1000

while ans < y:
    if y - ans >= 9000:
        tmp = (y - ans) // 9000
        a += tmp
        c -= tmp
    elif y - ans >= 4000:
        tmp = (y - ans) // 4000
        b += tmp
        c -= tmp
    ans = a * 10000 + b * 5000 + c * 1000

if ans != y:
    a = b = c = -1

print(a, b, c)


Fixed submission:
print(input().replace("2017", "2018"))
Problem p03469 (Python)

Buggy submission (status: Runtime Error):
S = input()

print(S.replace(2017, 2018))


Fixed submission:
S = input()
print(S.replace("2017", "2018"))
Problem p03469 (Python)

Buggy submission (status: Runtime Error):
S = input()
S[3] = 8
print(S)


Fixed submission:
S = input()
S = S[:3] + "8" + S[4:]
print(S)
Problem p03469 (Python)

Buggy submission (status: Runtime Error):
S = input().split("/")
S[0] = "2018"
print(S.join("/"))


Fixed submission:
S = input().split("/")
S[0] = "2018"
print("/".join(S))
Problem p03469 (Python)

Buggy submission (status: Runtime Error):
s = input()
s[3] = "8"
print(s)


Fixed submission:
s = input()
s = s[0:3] + "8" + s[4:]
print(s)
Problem p03469 (Python)

Buggy submission (status: Runtime Error):
S = str(input())
S = S.replace(2017, 2018, 1)
print(S)


Fixed submission:
S = str(input())
S = S.replace("2017", "2018", 1)
print(S)
Problem p03469 (Python)

Buggy submission (status: Runtime Error):
S = list(input())
S[3] = 8
print("".join(S))


Fixed submission:
S = list(input())
S[3] = "8"
a = "".join(S)
print(a)
Problem p03469 (C++)

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

int main() {
  string s;
  cin >> s;
  cout << "2018";
  for (int i = 4; s.length(); ++i)
    cout << s[i];
}

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

int main() {
  string s;
  cin >> s;
  cout << "2018";
  for (int i = 4; i < s.length(); ++i)
    cout << s[i];
}
Problem p03469 (Python)

Buggy submission (status: Runtime Error):
s = input()
s[:4] = "2018"
print(s)


Fixed submission:
s = input()
print(s.replace("2017", "2018"))
Problem p03470 (C++)

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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i = 0; i < n; i++)
    cin >> d.at(i);

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

  int cnt = 1;

  for (int i = 0; i < n; i++)
    if (d.at(i) != d.at(i + 1))
      cnt++;

  cout << cnt << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i = 0; i < n; i++)
    cin >> d.at(i);

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

  int cnt = 1;

  for (int i = 0; i < n - 1; i++)
    if (d.at(i) != d.at(i + 1))
      cnt++;

  cout << cnt << endl;
}
Problem p03470 (C++)

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

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

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

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

  cout << count << endl;
}


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

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

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

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

  cout << count << endl;
}
Problem p03470 (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++)
#define rep2(i, n) for (int i = 0; i < (int)(n); i += 2)
using vi = vector<int>;
using vs = vector<string>;
using gi = greater<int>;
#define soao(c) sort((c).begin(), (c).end())       // 昇順
#define sodo(c) sort((c).begin(), (c).end(), gi()) // 降順

int main() {
  int n, c = 1;
  cin >> n;
  vi d(n);
  rep(i, n) cin >> d.at(i);
  soao(d);

  rep(i, n) {
    if (d.at(i) < d.at(i + 1))
      c++;
  }
  cout << c << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 0; i < (int)(n); i += 2)
using vi = vector<int>;
using vs = vector<string>;
using gi = greater<int>;
#define soao(c) sort((c).begin(), (c).end())       // 昇順
#define sodo(c) sort((c).begin(), (c).end(), gi()) // 降順

int main() {
  int n, c = 1;
  cin >> n;
  vi d(n);
  rep(i, n) cin >> d.at(i);
  soao(d);

  rep(i, n - 1) {
    if (d.at(i) < d.at(i + 1))
      c++;
  }
  cout << c << endl;
}
Problem p03470 (C++)

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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++)
    cin >> d.at(i);
  sort(d.begin(), d.end());
  int x = 1;
  for (int i = 0; i < N; i++) {
    if (i = N - 1)
      break;
    if (d.at(i) != d.at(i + 1))
      x++;
  }
  cout << x << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++)
    cin >> d.at(i);
  sort(d.begin(), d.end());
  int x = 1;
  for (int i = 0; i < N - 1; i++) {
    if (d.at(i) != d.at(i + 1))
      x++;
  }
  cout << x << endl;
}
Problem p03470 (C++)

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

int main() {
  int N, answer = 1;
  cin >> N;

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

  sort(mochi.begin(), mochi.end());
  reverse(mochi.begin(), mochi.end());

  for (int i = 0; i < N; i++) {
    if (mochi.at(i) == mochi.at(i + 1)) {
      continue;
    } else {
      answer++;
    }
  }
  cout << answer << endl;
}

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

int main() {
  int N, answer = 1;
  cin >> N;

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

  sort(mochi.begin(), mochi.end());
  reverse(mochi.begin(), mochi.end());

  for (int i = 0; i < N - 1; i++) {
    if (mochi.at(i) == mochi.at(i + 1)) {
      continue;
    } else {
      answer++;
    }
  }
  cout << answer << endl;
}
Problem p03470 (C++)

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

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

  sort(s.begin(), s.end());
  reverse(s.begin(), s.end());
  int x = 1;
  int f = s.at(N);
  for (int i = 0; i < N; i++) {
    if (f > s.at(i)) {
      f = s.at(i);
      x += 1;
    }
  }
  cout << x << endl;
}


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

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

  sort(s.begin(), s.end());
  reverse(s.begin(), s.end());
  int x = 1;
  int f = s.at(0);
  for (int i = 0; i < N; i++) {
    if (f > s.at(i)) {
      f = s.at(i);
      x += 1;
    }
  }
  cout << x << endl;
}
Problem p03470 (C++)

Buggy submission (status: Time Limit Exceeded):
#include "bits/stdc++.h"
using namespace std;
int main() {
  int n, total = 1;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a.begin(), a.end());
  for (int i = n - 2; i >= 0; i++) {
    total += a[i + 1] != a[i];
  }
  printf("%d\n", total);
}

Fixed submission:
#include "bits/stdc++.h"
using namespace std;
int main() {
  int n, total = 1;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a.begin(), a.end());
  for (int i = n - 2; i >= 0; i--) {
    total += a[i + 1] != a[i];
  }
  printf("%d\n", total);
}
Problem p03470 (C++)

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

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

  std::vector<int> vec(N);
  for (size_t i = 0; i < N; i++) {
    std::cin >> vec.at(i); /* code */
  }

  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int ans = 0;
  for (size_t i = 0; i < N; i++) {
    if (vec.at(i) > vec.at(i + 1)) {
      ans += 1; /* code */
    }           /* ode */
    else {
      ans += 0;
    }
  }
  std::cout << ans << '\n';
}


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

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

  std::vector<int> vec(N);
  for (size_t i = 0; i < N; i++) {
    std::cin >> vec.at(i); /* code */
  }

  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int ans = 1;
  for (size_t i = 0; i < N - 1; i++) {
    if (vec.at(i) > vec.at(i + 1)) {
      ans += 1; /* code */
    }           /* ode */
    else {
      ans += 0;
    }
  }
  std::cout << ans << '\n';
}
Problem p03470 (C++)

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

int main() {
  int N, c;
  c = 0;
  cin >> N;
  vector<int> mochi(N);
  for (int i = 0; i < N; i++) {
    cin >> mochi.at(i);
  }
  sort(mochi.begin(), mochi.end());
  for (int i = 0; i < N - 1; i++) {
    if (mochi.at(i) == mochi.at(i + 1)) {
      continue;
    }
    c++;
  }
  if (mochi.at(N - 2) = mochi.at(N - 1)) {
    c++;
  }
  cout << c + 1 << endl;
}

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

int main() {
  int N, c;
  c = 0;
  cin >> N;
  vector<int> mochi(N);
  for (int i = 0; i < N; i++) {
    cin >> mochi.at(i);
  }
  sort(mochi.begin(), mochi.end());
  for (int i = 0; i < N - 1; i++) {
    if (mochi.at(i) == mochi.at(i + 1)) {
      continue;
    }
    c++;
  }
  cout << c + 1 << endl;
}
Problem p03470 (C++)

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

int main() {
  int N, i, l, d[i];
  int a = 0;
  int b = 0;

  cin >> N;
  for (i = 0; i < N; i++) {
    cin >> d[i];
  }
  for (i = 1; i < N; i++) {
    a = 0;
    for (l = 0; l < i; l++) {
      if (d[i] == d[l]) {
        a += 1;
      }
    }
    if (a == 0) {
      b += 1;
    }
  }

  cout << b + 1 << endl;

  return 0;
}

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

int main() {
  int N, i, l, d[100];
  int a = 0;
  int b = 0;

  cin >> N;
  for (i = 0; i < N; i++) {
    cin >> d[i];
  }
  for (i = 1; i < N; i++) {
    a = 0;
    for (l = 0; l < i; l++) {
      if (d[i] == d[l]) {
        a += 1;
      }
    }
    if (a == 0) {
      b += 1;
    }
  }

  cout << b + 1 << endl;

  return 0;
}
Problem p03470 (C++)

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

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

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

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

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

  cout << dan << endl;
}


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

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

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

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

  int dan = 1; // 何段か
  for (int i = 0; i + 1 < N; i++) {
    if (vec.at(i) > vec.at(i + 1)) {
      dan++;
    }
  }

  cout << dan << endl;
}
Problem p03470 (C++)

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

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

  sort(vec.begin(), vec.end());
  int count = 0;

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

  cout << count + 1 << endl;
}


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

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

  sort(vec.begin(), vec.end());
  int count = 0;

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

  cout << count + 1 << endl;
}
Problem p03470 (C++)

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

#define ft first
#define sd second
#define get(t, x) get<x>(t)
#define pb push_back
#define len length
#define dbgn(x) cerr << #x << ": " << x << '\n'
#define dbg(x) cerr << #x << ": " << x << ' '
#define MAX 1100000

using namespace std;
using namespace __gnu_pbds;

using lli = long long int;
using pll = pair<lli, lli>;
using pii = pair<int, int>;
using mii = map<int, int>;
using ti3 = tuple<int, int, int>;
using pqpi_min = priority_queue<pii, vector<pii>, greater<pii>>;
using ost = tree<int, null_type, less<int>, rb_tree_tag,
                 tree_order_statistics_node_update>;
template <class T> void print(T *a, int sz) {
  for (int i = 0; i < sz; ++i)
    cerr << a[i] << ' ';
  cerr << endl;
}
istream &operator>>(istream &is, pii &p) {
  is >> p.ft >> p.sd;
  return is;
}
ostream &operator<<(ostream &os, const pii &p) {
  os << "[" << p.ft << ", " << p.sd << ']';
  return os;
}
// int+string
// cin.ignore();

constexpr int M = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;

void solve() {
  int x, n, i;
  set<int> v;
  cin >> n;
  for (i = 0; i < n; ++i)
    cin >> x, v.insert(x);
  cout << v.size();
}
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
  freopen("inp.txt", "r", stdin);
#endif
  solve();
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define ft first
#define sd second
#define get(t, x) get<x>(t)
#define pb push_back
#define len length
#define dbgn(x) cerr << #x << ": " << x << '\n'
#define dbg(x) cerr << #x << ": " << x << ' '
#define MAX 1100000

using namespace std;
using namespace __gnu_pbds;

using lli = long long int;
using pll = pair<lli, lli>;
using pii = pair<int, int>;
using mii = map<int, int>;
using ti3 = tuple<int, int, int>;
using pqpi_min = priority_queue<pii, vector<pii>, greater<pii>>;
using ost = tree<int, null_type, less<int>, rb_tree_tag,
                 tree_order_statistics_node_update>;
template <class T> void print(T *a, int sz) {
  for (int i = 0; i < sz; ++i)
    cerr << a[i] << ' ';
  cerr << endl;
}
istream &operator>>(istream &is, pii &p) {
  is >> p.ft >> p.sd;
  return is;
}
ostream &operator<<(ostream &os, const pii &p) {
  os << "[" << p.ft << ", " << p.sd << ']';
  return os;
}
// int+string
// cin.ignore();

constexpr int M = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;

void solve() {
  int x, n, i;
  set<int> v;
  cin >> n;
  for (i = 0; i < n; ++i)
    cin >> x, v.insert(x);
  cout << v.size();
}
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
Problem p03470 (C++)

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

int main() {
  int n, a;
  a = 1;
  cin >> n;

  vector<int> vect(n);
  for (int i = 0; i < n; i++) {
    cin >> vect.at(i);
  }

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

  for (int i = 0; i < n; i++) {
    if (vect.at(i) < vect.at(i + 1)) {
      a++;
    }
  }
  cout << a << endl;
}


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

int main() {
  int n, a;
  a = 1;
  cin >> n;

  vector<int> vect(n);
  for (int i = 0; i < n; i++) {
    cin >> vect.at(i);
  }

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

  for (int i = 1; i < n; i++) {
    if (vect.at(i - 1) < vect.at(i)) {
      a++;
    }
  }
  cout << a << endl;
}
Problem p03470 (C++)

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

using namespace std;

int main() {
  int N, d[10];

  cin >> N;
  for (int i = 0; i < N; i++)
    cin >> d[i];

  set<int> values;

  for (int i = 0; i < N; i++) {
    values.insert(d[i]);
  }

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

  return 0;
}

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

using namespace std;

int main() {
  int N, d[110];

  cin >> N;
  for (int i = 0; i < N; i++)
    cin >> d[i];

  set<int> values;

  for (int i = 0; i < N; i++) {
    values.insert(d[i]);
  }

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

  return 0;
}
Problem p03470 (Python)

Buggy submission (status: Runtime Error):
N = int(input())

List = sorted(list(set(list(int(input()) for i in range(N)))))

print(len(List()))


Fixed submission:
N = int(input())

List = sorted(list(set(list(int(input()) for i in range(N)))))

print(len(List))
Problem p03470 (Python)

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


Fixed submission:
n = int(input())
d = list(int(input()) for i in range(n))
print(len(set(d)))
Problem p03470 (Python)

Buggy submission (status: Runtime Error):
N = int(input())
d = [int(input()) for i in range(N)]

print(list(set(d)))
e = list(set(d))
print(len(e))
N = int(input())
d = [int(input()) for i in range(N)]

# print(list(set(d)))
e = list(set(d))
print(len(e))


Fixed submission:
N = int(input())
d = [int(input()) for i in range(N)]

# print(list(set(d)))
e = list(set(d))
print(len(e))
Problem p03470 (Python)

Buggy submission (status: Runtime Error):
n = int(input())
list = [int(input()) for i in range(n)]
check = 101
count = 0

list.sorted(reverse=True)

for k in list:
    if k < check:
        count += 1
        check = k

print(count)


Fixed submission:
n = int(input())
list = [int(input()) for i in range(n)]
check = 101
count = 0

list.sort(reverse=True)

for k in list:
    if k < check:
        count += 1
        check = k

print(count)
Problem p03470 (Python)

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


Fixed submission:
nums = [int(input()) for _ in range(int(input()))]
print(len(set(nums)))
Problem p03470 (C++)

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

int main() {
  int N, ans;
  ans = 0;
  cin >> N;
  vector<int> mochi(110);
  for (int i = 0; i < N; i++) {
    cin >> mochi.at(i);
  }
  vector<int> backets(110);
  for (int i = 0; i < N; i++) {
    backets.at(mochi.at(i))++;
  }
  for (int i = 0; i < 111; i++) {
    if (backets.at(i) > 0) {
      ans++;
    }
  }
  cout << ans << endl;
}


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

int main() {
  int N, ans;
  ans = 0;
  cin >> N;
  vector<int> mochi(110);
  for (int i = 0; i < N; i++) {
    cin >> mochi.at(i);
  }
  vector<int> backets(110);
  for (int i = 0; i < N; i++) {
    backets.at(mochi.at(i))++;
  }
  for (int i = 0; i < 110; i++) {
    if (backets.at(i) > 0) {
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p03470 (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++)
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  vector<int> num(100, 0); // 1から100の要素ででそれぞれ何個あるかを保持
  rep(i, n) {
    cin >> d.at(i);
    num.at(d.at(i))++;
  }

  int ans = 0;
  rep(i, 101) {
    if (num.at(i) > 0)
      ans++;
  }
  cout << ans << endl;

  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  vector<int> num(101, 0); // 0から100の要素ででそれぞれ何個あるかを保持
  rep(i, n) {
    cin >> d.at(i);
    num.at(d.at(i))++;
  }

  int ans = 0;
  rep(i, 101) {
    if (num.at(i) > 0)
      ans++;
  }
  cout << ans << endl;

  return 0;
}