prithivMLmods/Coder-Stat huggingface dataset:
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);
  }
  int count = 0;
  sort(d.begin(), d.end());
  for (int i = 0; i < n - 1; i++) {
    if (d.at(i) == d.at(i - 1)) {
      count++;
    }
  }

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

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

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

int main() {
  int N;
  int ans = 1;
  cin >> N;
  vector<int> moti(N);
  for (int n = 0; n < N; n++) {
    cin >> moti.at(n);
  }
  sort(moti.begin(), moti.end(), greater<int>());
  for (int n = 0; n < N; n++) {
    if (moti.at(n) != moti.at(n + 1)) {
      ans++;
    }
  }
  cout << ans << endl;
}


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

int main() {
  int N;
  int ans = 1;
  cin >> N;
  vector<int> moti(N);
  for (int n = 0; n < N; n++) {
    cin >> moti.at(n);
  }
  sort(moti.begin(), moti.end(), greater<int>());
  for (int n = 0; n < N; n++) {
    if (n == N - 1) {
    } else {
      if (moti.at(n) != moti.at(n + 1)) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}
Problem p03470 (C++)

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

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

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

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

  for (int i = 0; i < N; i++) {
    if (data.at(i) != data.at(i + 1)) {
      cnt++;
    }
    if (i == N - 2) {
      break;
    }
  }

  cout << cnt << endl;
}

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

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

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

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

  if (N != 1) {
    for (int i = 0; i < N; i++) {
      if (data.at(i) != data.at(i + 1)) {
        cnt++;
      }
      if (i == N - 2) {
        break;
      }
    }
  }

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

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

int main() {
  vector<int> vec(101);
  int i, j;
  int t;
  // int min;
  int N;
  cin >> N;
  for (i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  //   min=vec.at(0);
  for (i = 0; i < N - 1; i++) {
    for (j = N - 1; j >= i; j--) {
      if (vec.at(j - 1) > vec.at(j)) {
        t = vec.at(j - 1);
        vec.at(j - 1) = vec.at(j);
        vec.at(j) = t;
        // min=vec.at(j+1);
      }
    }
  }
  /*  for(i=0;i<N;i++){
    cout << vec.at(i) <<" ";
    }
    cout << endl;*/
  int count = 0;
  for (i = 0; i < N; i++) {
    if (vec.at(i) == vec.at(i + 1)) {
      count++;
    }
  }
  // cout << count <<endl;
  cout << N - count << endl;
}

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

int main() {
  vector<int> vec(101);
  int i, j;
  int t;
  // int min;
  int N;
  cin >> N;
  for (i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  //   min=vec.at(0);
  for (i = 0; i < N - 1; i++) {
    for (j = N - 1; j > i; j--) {
      if (vec.at(j - 1) > vec.at(j)) {
        t = vec.at(j - 1);
        vec.at(j - 1) = vec.at(j);
        vec.at(j) = t;
        // min=vec.at(j+1);
      }
    }
  }
  /*  for(i=0;i<N;i++){
    cout << vec.at(i) <<" ";
    }
    cout << endl;*/
  int count = 0;
  for (i = 0; i < N; i++) {
    if (vec.at(i) == vec.at(i + 1)) {
      count++;
    }
  }
  // cout << count <<endl;
  cout << N - count << endl;
}
Problem p03470 (C++)

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

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

  int dan = 1;

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

    if (mochi.at(i + 1) < mochi.at(i)) {
      dan++;
    }

    else if (mochi.at(i + 1) == mochi.at(i)) {
      continue;
    }
  }

  cout << dan << endl;
}


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

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

  int dan = 1;

  for (int i = 0; i < N - 1; i++) {

    if (mochi.at(i + 1) < mochi.at(i)) {
      dan++;
    }

    else if (mochi.at(i + 1) == mochi.at(i)) {
      continue;
    }
  }

  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> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  int count = 0;
  for (int i = 0; i < N; i++) {
    if (d.at(i) == d.at(i + 1)) {
      count++;
    }
  }
  cout << N - count << 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 count = 0;
  for (int i = 0; i < N; i++) {
    if (i + 1 < N && d.at(i) == d.at(i + 1)) {
      count++;
    }
  }
  cout << N - count << endl;
}
Problem p03470 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(), (a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int, int> P;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<int> d;
  int ans = n;

  rep(i, n) cin >> d[i];

  sort(all(d));

  rep(i, n - 1) if (d[i] == d[i + 1]) ans--;

  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(), (a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int, int> P;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  int ans = n;

  rep(i, n) cin >> d[i];

  sort(all(d));

  rep(i, n - 1) if (d[i] == d[i + 1]) ans--;

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

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

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


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

int main() {
  int N;
  cin >> N;
  vector<int> diameter(N);
  for (int i = 0; i < N; i++) {
    cin >> diameter.at(i);
  }
  sort(diameter.begin(), diameter.end());
  int x = 0;
  for (int i = 0; i < N; i++) {
    if (i > 0 && diameter.at(i - 1) == diameter.at(i)) {
      continue;
    }
    x += 1;
  }
  cout << x << 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;
  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 - 1; 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 < N - 1; i++) {
    if (vec.at(i) > vec.at(i + 1))
      count++;
  }
  cout << count << endl;
}
Problem p03470 (Python)

Buggy submission (status: Runtime Error):
n = int(input())
d = sorted([int(input()) for _ in range(n)])
cnt = 1
for a, b in zip(cnt[1:], cnt):
    if a > b:
        cnt += 1
print(cnt)


Fixed submission:
n = int(input())
d = sorted([int(input()) for _ in range(n)])
cnt = 1
for a, b in zip(d[1:], d):
    if a > b:
        cnt += 1
print(cnt)
Problem p03470 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  set<int> S;
  for (int i = 0; i < N; i++) {
    S.insert(a.at(N));
  }
  cout << S.size() << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  set<int> S;
  for (int i = 0; i < N; i++) {
    S.insert(a.at(i));
  }
  cout << S.size() << 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 sum = vec.size();

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


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 sum = vec.size();

  for (int i = 0; i < N - 1; i++) {
    if (vec.at(i) == vec.at(i + 1))
      sum -= 1;
  }
  cout << sum;
}
Problem p03470 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iostream>
#include <memory>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

#define Get(ty, ...)                                                           \
  ty __VA_ARGS__;                                                              \
  cins(__VA_ARGS__);
#define GetArray(ty, v, n)                                                     \
  vector<ty> v(n);                                                             \
  cin_arr(v, n);
#define ci cin
#define co cout
#define en endl;
#define Arr(f, arr, pred) f(arr.begin(), arr.end(), pred)
#define Arr2(f, arr) f(arr.begin(), arr.end())
#define ArrExpr(f, arr, expr)                                                  \
  f(arr.begin(), arr.end(), [](auto x) { return expr; })
#define Acc(init, arr, pred) accumulate(arr.begin(), arr.end(), init, pred)

void cins() {}

template <class Head, class... Tail> void cins(Head &head, Tail &...tail) {
  cin >> head;
  cins(tail...);
}

template <class Arr> void cin_arr(Arr &v, int n) {
  for (int i = 0; i < n; i++)
    cin >> v[i];
}

int main() {
  Get(int, n);
  GetArray(int, v, n);
  Arr2(sort, v);
  auto itr = Arr2(unique, v);
  v.erase(itr);
  co << v.size() << en
}


Fixed submission:
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iostream>
#include <memory>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

#define Get(ty, ...)                                                           \
  ty __VA_ARGS__;                                                              \
  cins(__VA_ARGS__);
#define GetArray(ty, v, n)                                                     \
  vector<ty> v(n);                                                             \
  cin_arr(v, n);
#define ci cin
#define co cout
#define en endl;
#define Arr(f, arr, pred) f(arr.begin(), arr.end(), pred)
#define Arr2(f, arr) f(arr.begin(), arr.end())
#define ArrExpr(f, arr, expr)                                                  \
  f(arr.begin(), arr.end(), [](auto x) { return expr; })
#define Acc(init, arr, pred) accumulate(arr.begin(), arr.end(), init, pred)

void cins() {}

template <class Head, class... Tail> void cins(Head &head, Tail &...tail) {
  cin >> head;
  cins(tail...);
}

template <class Arr> void cin_arr(Arr &v, int n) {
  for (int i = 0; i < n; i++)
    cin >> v[i];
}

int main() {
  Get(int, n);
  GetArray(int, v, n);
  Arr2(sort, v);
  auto itr = Arr2(unique, v);
  v.erase(itr, v.end());
  co << max({v.size(), (size_t)1}) << en
}
Problem p03470 (C++)

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

int main() {
  int N;
  cin >> N;
  vector<int> mochi(N);
  rep(i, N) cin >> mochi.at(i);
  sort(mochi.begin(), mochi.end());

  int count = 1, i = 0;
  while (mochi.at(i) < mochi.at(i + 1)) {
    count++;
    i++;
  }

  cout << count << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> mochi(N);
  rep(i, N) cin >> mochi.at(i);
  sort(mochi.begin(), mochi.end());

  int count = 1;
  rep(i, N - 1) {
    if (mochi.at(i) < mochi.at(i + 1))
      count++;
  }

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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  std::vector<int> v;
  for (int i = 0; i < N; ++i) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  int count = N;
  for (int i = 0; i < N - 1; ++i) {
    if (v[i] == v[i + 1])
      count--;
  }
  cout << count << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  std::vector<int> v(N);
  for (int i = 0; i < N; ++i) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  int count = N;
  for (int i = 0; i < N - 1; ++i) {
    if (v[i] == v[i + 1])
      count--;
  }
  cout << count << endl;
}
Problem p03470 (C++)

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

int main() {
  int N;
  cin >> N;
  int ans = 1;
  vector<int> D(N);
  for (int i = 0; i < N; i++) {
    cin >> D.at(i);
  }
  sort(D.begin(), D.end());

  for (int i = 0; i < N; i++) {
    if (D.at(i) < D.at(i + 1)) {
      ans++;
    }
  }
  cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  int ans = 1;
  vector<int> D(N);
  for (int i = 0; i < N; i++) {
    cin >> D.at(i);
  }
  sort(D.begin(), D.end());

  for (int i = 0; i < N - 1; i++) {
    if (D.at(i) < D.at(i + 1)) {
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p03470 (C++)

Buggy submission (status: Runtime Error):
#include <bits //stdc++.h>
using namespace std;
int in(void) {
  int x;
  cin >> x;
  return x;
}
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define ll long long int
long long int dx[4] = {1, 0, -1, 0};
long long int dy[4] = {0, 1, 0, -1};
int D[2] = {1, -1};
int main() {
  int x;
  cin >> x;
  int num[120000000];
  int check;
  int main = 0;
  rep(i, 0, x) {
    cin >> check;
    if (num[check] == 1)
      main++;
    num[check] = 1;
  }
  cout << x - main;
  return 0;
}


Fixed submission:
#include <bits //stdc++.h>
using namespace std;
int in(void) {
  int x;
  cin >> x;
  return x;
}
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define ll long long int
long long int dx[4] = {1, 0, -1, 0};
long long int dy[4] = {0, 1, 0, -1};
int D[2] = {1, -1};
int main() {
  int x;
  cin >> x;
  int num[10000000];
  int check;
  int main = 0;
  rep(i, 0, x) {
    cin >> check;
    if (num[check] == 1)
      main++;
    num[check] = 1;
  }
  cout << x - main;
  return 0;
}
Problem p03470 (C++)

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

int main() {
  int N;
  cin >> N;
  int Asum = 0;
  int Bsum = 0;
  int count = 0;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }

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

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

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

int main() {
  int N;
  cin >> N;
  int Asum = 0;
  int Bsum = 0;
  int count = 0;
  vector<int> a(N + 1);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }

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

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

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

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

  int res = 0;
  sort(S, S + N);
  for (int i = 0; i < N; ++i) {
    if (S[i] == S[i + 1])
      res += 1;
  }
  cout << N - res << endl;
}

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

int main() {
  int N;
  int S[100];
  cin >> N;
  for (int i = 0; i < N; ++i)
    cin >> S[i];

  int res = 0;
  sort(S, S + N);
  for (int i = 0; i < N; ++i) {
    if (S[i] == S[i + 1])
      res += 1;
  }
  cout << N - res << 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++)

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  rep(i, N) { cin >> d.at(i); }
  sort(d.begin(), d.end());
  reverse(d.begin(), d.end());
  int dansuu = 0;
  rep(i, N) {
    dansuu++;
    if (d.at(i) == d.at(i + 1)) {
      dansuu--;
    }
  }
  cout << dansuu << 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<int> d(N);
  rep(i, N) { cin >> d.at(i); }
  sort(d.begin(), d.end());
  reverse(d.begin(), d.end());
  int dansuu = 0;
  rep(i, N) {
    dansuu++;
    if (i == N - 1) {
      break;
    }
    if (d.at(i) == d.at(i + 1)) {
      dansuu--;
    }
  }
  cout << dansuu << endl;
}
Problem p03470 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> Mo(N);
  for (int i = 0; i < N; i++) {
    cin >> Mo.at(i);
  }
  sort(Mo.begin(), Mo.end());
  int i = 0;
  int x = 0;
  while (i < N) {
    if (Mo.at(i) < Mo.at(i + 1)) {
      x++;
    }
    i++;
  }
  cout << x << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> Mo(N);
  for (int i = 0; i < N; i++) {
    cin >> Mo.at(i);
  }
  sort(Mo.begin(), Mo.end());
  int i = 0;
  int x = 1;
  while (i < N - 1) {
    if (Mo.at(i) < Mo.at(i + 1)) {
      x++;
    }
    i++;
  }
  cout << x << endl;
}
Problem p03470 (C++)

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

using namespace std;

using ll = long long;

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

  int n, d, ans = 0;
  vector<int> flag(d + 1, false);

  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> d;
    if (!flag[d])
      ++ans;
    flag[d] = true;
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

using ll = long long;

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

  int n, d, ans = 0;
  array<bool, 101> flag;
  fill(flag.begin(), flag.end(), false);

  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> d;
    if (!flag[d])
      ++ans;
    flag[d] = true;
  }

  cout << ans << 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> d;
  for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  }

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

  int num = 1;
  for (int i = 1; i < N; i++) {
    if (d.at(i) == d.at(i - 1)) {
      continue;
    }
    num++;
  }
  cout << num << 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());
  reverse(d.begin(), d.end());

  int num = 1;
  for (int i = 1; i < N; i++) {
    if (d.at(i) == d.at(i - 1)) {
      continue;
    }
    num++;
  }
  cout << num << 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);
  }
  int k = 0;
  vector<int> t(n, 0);
  t.at(0) = d.at(0);
  for (int j = 0; j < n; j++) {
    if (t.at(0) < d.at(j)) {
      t.at(0) = d.at(j);
    }
  }
  for (;;) {
    k++;
    for (int j = 0; j < n; j++) {
      if (t.at(k) < d.at(j) && d.at(j) < t.at(k - 1)) {
        t.at(k) = d.at(j);
      }
    }
    if (t.at(k) == 0) {
      break;
    }
  }
  cout << k << 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);
  }
  int k = 0;
  vector<int> t(n + 1, 0);
  t.at(0) = d.at(0);
  for (int j = 0; j < n; j++) {
    if (t.at(0) < d.at(j)) {
      t.at(0) = d.at(j);
    }
  }
  for (;;) {
    k++;
    for (int j = 0; j < n; j++) {
      if (t.at(k) < d.at(j) && d.at(j) < t.at(k - 1)) {
        t.at(k) = d.at(j);
      }
    }
    if (t.at(k) == 0) {
      break;
    }
  }
  cout << k << endl;
}
Problem p03470 (Python)

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


Fixed submission:
N = int(input())
d = []
for i in range(N):
    d.append(int(input()))
print(len(set(d)))
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 count = 1, same = 0;
  for (int i = 0; i < N - 1; i++) {
    if (d.at(i) <= d.at(i + 1))
      count++;
    if (d.at(i) == d.at(i + 1))
      same++;
  }
  if (d.at(N - 2) <= d.at(N - 1))
    count++;
  if (d.at(N - 2) == d.at(N - 1))
    same++;
  cout << count - same << 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 count = 1, same = 0;
  for (int i = 0; i < N - 1; i++) {
    if (d.at(i) <= d.at(i + 1))
      count++;
    if (d.at(i) == d.at(i + 1))
      same++;
  }
  cout << count - same << endl;
}
Problem p03470 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#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() {
  int N;
  cin >> N;
  vector<int> vec;
  rep(i, N) { cin >> vec.at(i); }
  sort(vec.begin(), vec.end());
  int c = 1;
  rep(i, N - 1) {
    if (vec.at(i) < vec.at(i + 1)) {
      c++;
    }
  }
  cout << c << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#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() {
  int N;
  cin >> N;
  vector<int> vec(N);
  rep(i, N) { cin >> vec.at(i); }
  sort(vec.begin(), vec.end());
  int c = 1;
  rep(i, N - 1) {
    if (vec.at(i) < vec.at(i + 1)) {
      c++;
    }
  }
  cout << c << endl;
}
Problem p03471 (C++)

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

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

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

  for (int i = 0; i < N + 1; i++) {
    for (int j = 0; j < N + 1; j++) {
      for (int k = 0; k < N + 1; k++) {
        if (i + j + k == N && i * 10000 + j * 5000 + k * 1000 == Y) {
          cout << i << " " << j << " " << k << endl;
          return 0;
        }
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
}


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

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

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

  for (int i = 0; i < N + 1; i++) {
    for (int j = 0; j < N + 1 - i; j++) {
      if (i * 10000 + j * 5000 + (N - i - j) * 1000 == Y) {
        cout << i << " " << j << " " << N - i - j << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
}
Problem p03471 (C++)

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

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

  int a, b, c;
  int num10000 = y / 10000, num5000 = y / 5000;
  rep(i, y / num10000 + 1) {
    rep(j, num5000 + 1) {
      int num = y / 1000 - 10 * i - 5 * j;
      if (0 <= num && num <= y / 1000 && i + j + num == n) {
        printf("%d %d %d\n", i, j, num);
        return 0;
      }
    }
  }

  printf("-1 -1 -1\n");
  return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

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

  int a, b, c;
  int num10000 = y / 10000, num5000 = y / 5000;
  rep(i, num10000 + 1) {
    rep(j, num5000 + 1) {
      int num = y / 1000 - 10 * i - 5 * j;
      if (0 <= num && num <= y / 1000 && i + j + num == n) {
        printf("%d %d %d\n", i, j, num);
        return 0;
      }
    }
  }

  printf("-1 -1 -1\n");
  return 0;
}
Problem p03471 (C++)

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

int main() {
  int n, y;
  cin >> n >> y;
  vector<int> result(3, -1);
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= n; k++) {
        // cout << i << ':' << j << ':' << k << ':' << endl;
        if (i + j + k == n) {
          int sum = i * 10000 + j * 5000 + k * 1000;
          // cout << i << ':' << j << ':' << k << ':' << sum << endl;
          if (sum == y) {
            result.at(0) = i;
            result.at(1) = j;
            result.at(2) = k;
          }
        }
      }
    }
  }
  for (int i = 0; i < 3; i++) {
    cout << result.at(i);
    if (i != 2) {
      cout << ' ';
    }
  }
}

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

int main() {
  int n, y;
  cin >> n >> y;
  vector<int> result(3, -1);
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      int c = n - i - j;
      int sum = i * 10000 + j * 5000 + c * 1000;
      if (sum == y && c >= 0 && c <= n) {
        result.at(0) = i;
        result.at(1) = j;
        result.at(2) = c;
      }
    }
  }
  for (int i = 0; i < 3; i++) {
    cout << result.at(i);
    if (i != 2) {
      cout << ' ';
    }
  }
}
Problem p03471 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repl(i, 0, n)
#define sort(a) sort((a).begin(), (a).end())
#define rev(a) reverse((a).begin(), (a).end())
using db = double;
using namespace std;
typedef long long ll;

int main() {
  int n, y;
  cin >> n >> y;
  rep(i, 2000) {
    rep(j, 2000) {
      rep(k, 2000) {
        if (10000 * i + 5000 * j + 1000 * k == y && i + j + k == n) {
          cout << i << " " << j << " " << k << endl;
          return 0;
        }
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repl(i, 0, n)
#define sort(a) sort((a).begin(), (a).end())
#define rev(a) reverse((a).begin(), (a).end())
using db = double;
using namespace std;
typedef long long ll;

int main() {
  int n, y;
  cin >> n >> y;
  rep(i, 2001) {
    rep(j, 2001) {
      if (10000 * i + 5000 * j + 1000 * (n - i - j) == y && n - i - j >= 0) {
        cout << i << " " << j << " " << n - i - j << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}
Problem p03471 (C++)

Buggy submission (status: Runtime Error):
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repr(i, n) for (int i = n; i > (int)(n); --i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ALL(a) a.begin(), a.end()
#define RSORT(a) sort(ALL(a), greater<>())
#define SORT(a) sort(ALL(a))
#define bit_check(bit, i) ((bit >> (i)) & 1)
#define PRINT(x) cout << (x) << endl;
#define ENDL cout << endl;
using namespace std;
typedef long long int i64;
typedef unsigned long long u64;
template <class T> using V = vector<T>;
using VI = V<int>;
const int INF = 2e9;
const i64 MOD = 1e9 + 7;

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
struct Init_On {
  Init_On() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(16);
  }
};

int n, y;

signed main() {
  Init_On start;
  cin >> n >> y;
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) {
      if (i * 10000 + j * 5000 + (n - i - j) * 1000 == y) {
        assert(n - i - j >= 0);
        cout << n - i - j << " " << j << " " << i << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
}

Fixed submission:
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repr(i, n) for (int i = n; i > (int)(n); --i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ALL(a) a.begin(), a.end()
#define RSORT(a) sort(ALL(a), greater<>())
#define SORT(a) sort(ALL(a))
#define bit_check(bit, i) ((bit >> (i)) & 1)
#define PRINT(x) cout << (x) << endl;
#define ENDL cout << endl;
using namespace std;
typedef long long int i64;
typedef unsigned long long u64;
template <class T> using V = vector<T>;
using VI = V<int>;
const int INF = 2e9;
const i64 MOD = 1e9 + 7;

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
struct Init_On {
  Init_On() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(16);
  }
};

int n, y;

signed main() {
  Init_On start;
  cin >> n >> y;
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) {
      if (i * 10000 + j * 5000 + (n - i - j) * 1000 == y && n - i - j >= 0) {
        cout << i << " " << j << " " << n - i - j << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
}
Problem p03471 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

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

  // 答えを格納するための変数
  int ares = -1, bres = -1, cres = -1;

  // 全探索
  for (int a = 0; a <= N; ++a) {
    for (int b = 0; b <= N; ++b) {
      for (int c = 0; c <= N; ++c) {
        if (a + b + c == N && 10000 * a + 5000 * b + 1000 * c == Y) {
          ares = a;
          bres = b;
          cres = c;
        }
      }
    }
  }
  cout << ares << " " << bres << " " << cres << endl;
}

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

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

  // 答えを格納するための変数
  int ares = -1, bres = -1, cres = -1;

  // 全探索
  for (int a = 0; a <= N; ++a) {
    // a + b が N 以下の範囲で
    for (int b = 0; a + b <= N; ++b) {
      int c = N - a - b;
      if (10000 * a + 5000 * b + 1000 * c == Y) {
        ares = a;
        bres = b;
        cres = c;
      }
    }
  }
  cout << ares << " " << bres << " " << cres << endl;
}
Problem p03471 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <stdio.h>
#include <string.h>

int main() {
  int N;
  long long int Y, i, j, k;
  scanf("%d%lld", &N, &Y);
  for (i = 0; i <= N; i++) {
    for (j = 0; j <= N; j++) {
      for (k = 0; k <= N; k++) {
        if (i + j + k == N) {
          if (i * 1000 + j * 5000 + k * 10000 == Y) {
            printf("%d %d %d\n", k, j, i);
            return 0;
          }
        }
      }
    }
  }
  printf("-1 -1 -1\n");
  return 0;
}

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

int main() {
  int N;
  long long int Y, i, j, k;
  scanf("%d%lld", &N, &Y);
  for (i = 0; i <= N; i++) {
    for (j = i; j <= N; j++) {
      if (i * 1000 + (j - i) * 5000 + (N - j) * 10000 == Y) {
        printf("%d %d %d\n", (N - j), (j - i), i);
        return 0;
      }
    }
  }
  printf("-1 -1 -1\n");
  return 0;
}
Problem p03471 (C++)

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

int main() {
  int n, Y, x = 0, y = 0, z = 0;
  cin >> n >> Y;
  while (Y >= 10000) {
    Y -= 10000;
    x++;
  }
  while (Y >= 5000) {
    Y -= 5000;
    y++;
  }
  while (Y >= 1000) {
    Y -= 1000;
    z++;
  }
  int diff = n - (x + y + z);
  // cout<<diff<<endl;
  while (diff > 0) {
    if (x > 0 && diff >= 9) {
      diff -= 9;
      x--;
      z += 10;
    } else if (y > 0 && diff >= 4) {
      diff -= 4;
      y--;
      z += 5;
    } else if (x > 0 && diff >= 1) {
      diff -= 1;
      x--;
      y += 2;
    } else if (diff <= 0) {
      cout << "-1 -1 -1";
      return 0;
    }
  }
  if (x + y + z == n)
    cout << x << " " << y << " " << z;
  else
    cout << "-1 -1 -1";
  return 0;
}


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

int main() {
  int n, Y, x = 0, y = 0, z = 0;
  cin >> n >> Y;
  while (Y >= 10000) {
    Y -= 10000;
    x++;
  }
  while (Y >= 5000) {
    Y -= 5000;
    y++;
  }
  while (Y >= 1000) {
    Y -= 1000;
    z++;
  }
  int diff = n - (x + y + z);
  // cout<<diff<<endl;
  while (diff > 0) {
    if (x > 0 && diff >= 9) {
      diff -= 9;
      x--;
      z += 10;
    } else if (y > 0 && diff >= 4) {
      diff -= 4;
      y--;
      z += 5;
    } else if (x > 0 && diff >= 1) {
      diff -= 1;
      x--;
      y += 2;
    } else if (diff > 0) {
      cout << "-1 -1 -1";
      return 0;
    }
  }
  if (x + y + z == n)
    cout << x << " " << y << " " << z;
  else
    cout << "-1 -1 -1";
  return 0;
}
Problem p03471 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
// vector<> vec(n);

int main() {
  int n = 0;
  long long y = 0, ans = 0;

  cin >> n >> y;

  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= n; k++) {
        if (y == 10000 * i + 5000 * j + 1000 * k && n == i + j + k) {
          cout << i << " " << j << " " << k << endl;
          return 0;
        }
      }
    }
  }

  cout << "-1 -1 -1" << 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;
using P = pair<int, int>;
// vector<> vec(n);

int main() {
  int n = 0;
  long long y = 0, ans = 0;

  cin >> n >> y;

  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      int z = n - i - j;
      if (y == 10000 * i + 5000 * j + 1000 * z && z >= 0) {
        cout << i << " " << j << " " << z << endl;
        return 0;
      }
    }
  }

  cout << "-1 -1 -1" << endl;
  return 0;
}
Problem p03471 (C++)

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

int main() {
  int n, y;
  cin >> n >> y;
  bool a = false;
  int no, hi, yu;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= n; k++) {
        if ((1000 * i + 5000 * (j) + 10000 * (k) == y) && (i + j + k <= n)) {
          a = true;
          no = i;
          hi = j;
          yu = k;
          break;
        }
      }
    }
  }
  if (a) {
    cout << yu << ' ' << hi << ' ' << no << endl;
  } else {
    cout << "-1 -1 -1" << endl;
  }
}

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

int main() {
  int n, y;
  cin >> n >> y;
  bool a = false;
  int no, hi, yu;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n - i; j++) {
      for (int k = 0; k <= n - i - j; k++) {
        if ((1000 * i + 5000 * (j) + 10000 * (k) == y) && (i + j + k == n)) {
          a = true;
          no = i;
          hi = j;
          yu = k;
          break;
        }
      }
    }
  }
  if (a) {
    cout << yu << ' ' << hi << ' ' << no << endl;
  } else {
    cout << "-1 -1 -1" << endl;
  }
}
Problem p03471 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>

using namespace std;

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

  int a10 = -1, a5 = -1, a1 = -1;
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N; j++) {
      for (int k = 0; k <= N; k++) {
        if (i + j + k == N && i * 10000 + j * 5000 + k * 1000 == Y) {
          a10 = i;
          a5 = j;
          a1 = k;
          break;
        }
      }
    }
  }
  cout << a10 << " " << a5 << " " << a1 << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>

using namespace std;

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

  int a10 = -1, a5 = -1, a1 = -1;
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N; j++) {
      int k = N - i - j;
      if (k >= 0 && i * 10000 + j * 5000 + k * 1000 == Y) {
        a10 = i;
        a5 = j;
        a1 = k;
        break;
      }
    }
  }
  cout << a10 << " " << a5 << " " << a1 << endl;

  return 0;
}
Problem p03471 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

int main() {
  int n, a;
  int x = -1, y = -1, z = -1;
  cin >> n >> a;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= n; k++) {
        if ((10000 * i + 5000 * j + 1000 * k == a) && (i + j + k == n)) {
          x = i;
          y = j;
          z = k;
          cout << x << " " << y << " " << z << endl;
          return 0;
        }
      }
    }
  }
  cout << x << " " << y << " " << z << endl;
}

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

int main() {
  int n, a;
  int x = -1, y = -1, z = -1;
  cin >> n >> a;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n - i; j++) {
      for (int k = 0; k <= n - i - j; k++) {
        if (i + j + k == n) {
          if (10000 * i + 5000 * j + 1000 * k == a) {
            x = i;
            y = j;
            z = k;
            cout << x << " " << y << " " << z << endl;
            return 0;
          }
        }
      }
    }
  }
  cout << x << " " << y << " " << z << endl;
}
Problem p03471 (C++)

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

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

  for (int x = 0; x <= N; x++) {
    for (int y = 0; y <= N; y++) {
      if (N - x - y < 0)
        break;
      int total = 10000 * x + 5000 * y + 1000 * (N - x - y);

      if (total == Y) {
        cout << x << ' ' << y << ' ' << (N - x - y) << endl;
        return 1;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}

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

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

  for (int x = 0; x <= N; x++) {
    for (int y = 0; y <= N; y++) {
      if (N - x - y < 0)
        break;
      int total = 10000 * x + 5000 * y + 1000 * (N - x - y);

      if (total == Y) {
        cout << x << " " << y << " " << (N - x - y) << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}
Problem p03471 (Python)

Buggy submission (status: Time Limit Exceeded):
n, y = map(int, input().split())
max_x = y // 10000
max_y = y // 5000
max_z = y // 1000

for i in range(max_x + 1):
    for j in range(max_y + 1):
        remain = y - 10000 * i - 5000 * j
        if remain < 0:
            continue
        if remain // 1000 == n - (i + j):
            print(i, j, (n - i - j))
            exit()
print(-1, -1, -1)


Fixed submission:
N, Y = list(map(int, input().split()))
ans = [-1, -1, -1]
flag = False
for x in range(N, -1, -1):
    for y in range(N - x, -1, -1):
        if 10000 * x + 5000 * y + 1000 * (N - x - y) == Y:
            ans = [x, y, N - x - y]
            flag = True
            break
        if flag == True:
            break
    if flag == True:
        break
print(ans[0], ans[1], ans[2])
Problem p03471 (Python)

Buggy submission (status: Time Limit Exceeded):
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:
n, y = map(int, input().split())

a, b, c = (-1, -1, -1)
for i in range(n + 1):
    for j in range(n + 1 - i):
        k = n - (i + j)
        if 10000 * i + 5000 * j + 1000 * k == y:
            a, b, c = (i, j, k)
            break
print(a, b, c)
Problem p03471 (Python)

Buggy submission (status: Time Limit Exceeded):
n, y = [int(x) for x in input().split()]

for m in list(range(min(n + 1, y // 10000 + 1)))[::-1]:
    for g in list(range(min(n - m + 1, (y - 10000 * m) // 5000 + 1)))[::-1]:
        for s in list(
            range(min(n - m - g + 1, (y - 10000 * m - 5000 * g) // 1000 + 1))
        )[::-1]:
            # print("{} {} {}".format(m, g, s))
            if n == m + g + s and y == 10000 * m + 5000 * g + 1000 * s:
                print("{} {} {}".format(m, g, s))
                exit()

print("-1 -1 -1 ")


Fixed submission:
n, y = [int(x) for x in input().split()]

for i in range(n + 1):
    for j in range(i, n + 1):
        m = i
        g = j - i
        s = n - j
        if y == m * 10000 + g * 5000 + s * 1000:
            print("{} {} {}".format(m, g, s))
            exit()

print("-1 -1 -1 ")
Problem p03471 (Python)

Buggy submission (status: Runtime Error):
N, Y = list(map(int, input().split()))
ans = []
for i_yukichi in range(N + 1):
    for j_higuchi in range(N + 1 - i_yukichi):
        k_noguchi = N - i_yukichi - j_higuchi
        if 10000 * i_yukichi + 5000 * j_higuchi + 1000 * k_noguchi == Y:
            ans.append(i_yukichi)
            ans.append(j_higuchi)
            ans.append(k_noguchi)
            break
if len(ans) != 0:
    print(ans[0], ans[1], ans[3])
else:
    print("-1 -1 -1")


Fixed submission:
N, Y = list(map(int, input().split()))
ans = []
for i_yukichi in range(N + 1):
    for j_higuchi in range(N + 1 - i_yukichi):
        k_noguchi = N - i_yukichi - j_higuchi
        if 10000 * i_yukichi + 5000 * j_higuchi + 1000 * k_noguchi == Y:
            ans.append(i_yukichi)
            ans.append(j_higuchi)
            ans.append(k_noguchi)
            break
if len(ans) != 0:
    print(ans[0], ans[1], ans[2])
else:
    print("-1 -1 -1")
Problem p03471 (C++)

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

using namespace std;

int main(void) {

  long n, sum;
  cin >> n >> sum;
  sum /= 1000;

  if (sum > n * 10) {
    cout << "-1 -1 -1" << endl;
    return 0;
  }

  for (long x = 0; x <= n; x++) {
    for (long y = 0; y <= n; y++) {
      for (long z = 0; z <= n; z++) {
        if (sum == x * 10 + y * 5 + z * 1) {
          if (x + y + z > n)
            break;

          if (x + y + z == n) {
            printf("%d %d %d\n", x, y, z);
            return 0;
          }
        }
      }
    }
  }

  cout << "-1 -1 -1" << endl;
  return 0;
}

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

using namespace std;

int main(void) {

  long n, sum;
  cin >> n >> sum;
  sum /= 1000;

  if (sum > n * 10) {
    cout << "-1 -1 -1" << endl;
    return 0;
  }

  for (long x = 0; x <= n; x++) {
    for (long y = 0; y <= n; y++) {
      for (long z = 0; z <= (n - x - y); z++) {
        if (sum == x * 10 + y * 5 + z * 1) {
          if (x + y + z > n)
            break;

          if (x + y + z == n) {
            printf("%d %d %d\n", x, y, z);
            return 0;
          }
        }
      }
    }
  }

  cout << "-1 -1 -1" << endl;
  return 0;
}
Problem p03471 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <string>
int main() {
  int maisuu = 0, kingaku = 0;
  std::cin >> maisuu >> kingaku;

  for (int x = 0; x <= maisuu; x++) {
    for (int y = 0; y <= maisuu; y++) {
      for (int z = 0; z <= maisuu; z++) {
        if (kingaku == 10000 * x + 5000 * y + 1000 * z && maisuu == x + y + z) {
          std::cout << x << " " << y << " " << z << std::endl;
          return 0;
        }
      }
    }
  }
  std::cout << "-1 -1 -1" << std::endl;
}

Fixed submission:
#include <iostream>
#include <string>
int main() {
  int maisuu = 0, kingaku = 0;
  std::cin >> maisuu >> kingaku;

  for (int x = 0; x <= maisuu; x++) {
    for (int y = 0; y <= maisuu; y++) {
      if (kingaku == 10000 * x + 5000 * y + 1000 * (maisuu - x - y) &&
          maisuu >= x + y) {
        std::cout << x << " " << y << " " << maisuu - x - y << std::endl;
        return 0;
      }
    }
  }
  std::cout << "-1 -1 -1" << std::endl;
}
Problem p03471 (C++)

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

int main() {
  int n, y;
  cin >> n >> y;
  rep(i, n + 1) rep(j, n + 1) rep(k, n + 1) {
    int sum = 0;
    sum = k * 10000 + j * 5000 + i * 1000;
    if (sum == y && i + j + k == n) {
      cout << k << " " << j << " " << i << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
}

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

int main() {
  int n, y;
  cin >> n >> y;
  rep(i, n + 1) rep(j, n + 1 - i) rep(k, n + 1 - i) {
    int sum = 0;
    sum = k * 10000 + j * 5000 + i * 1000;
    if (sum == y && i + j + k == n) {
      cout << k << " " << j << " " << i << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
}