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

Buggy submission (status: Time Limit Exceeded):
// ConsoleApplication15.cpp : 此文件包含 "main"
// 函数。程序执行将在此处开始并结束。
//
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
using namespace std;
int hn[200500];
int main() {
  double n, k, ci;
  int i;
  while (cin >> n >> k) {
    ci = 0;
    for (i = 0; i < n; i++) {
      cin >> hn[i];
    }
    sort(hn, hn + i, [](double a, double b) { return a > b; });
    for (int p = k; p < n; p++) {
      while (hn[p]) {
        hn[p]--;
        ci++;
      }
    }
    cout << fixed << setprecision(0) << ci << "\n";
  }
}

Fixed submission:
// ConsoleApplication15.cpp : 此文件包含 "main"
// 函数。程序执行将在此处开始并结束。
//
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
using namespace std;
int hn[200500];
int main() {
  double n, k, ci;
  int i;
  while (cin >> n >> k) {
    ci = 0;
    for (i = 0; i < n; i++) {
      cin >> hn[i];
    }
    sort(hn, hn + i, [](double a, double b) { return a > b; });
    for (int p = k; p < n; p++) {
      ci += hn[p];
    }
    cout << fixed << setprecision(0) << ci << "\n";
  }
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int a[100001];
int n, k;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  sort(a + 1, a + n + 1);
  long long sum = 0;
  for (int i = 1; i <= n - k; i++)
    sum += a[i];
  cout << sum << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int a[200001];
int n, k;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  sort(a + 1, a + n + 1);
  long long sum = 0;
  for (int i = 1; i <= n - k; i++)
    sum += a[i];
  cout << sum << endl;
  return 0;
}
Problem p02785 (C++)

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

int n[maxn];

int main() {
  int a, b;
  cin >> a >> b;
  for (int i = 0; i < a; ++i) {
    cin >> n[i];
  }
  sort(n, n + a);
  LL ans = 0;
  for (int i = 0; i < a - b; ++i) {
    ans = ans + n[i];
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define LL long long
#define maxn 200010
using namespace std;

int n[maxn];

int main() {
  int a, b;
  cin >> a >> b;
  for (int i = 0; i < a; ++i) {
    cin >> n[i];
  }
  sort(n, n + a);
  LL ans = 0;
  for (int i = 0; i < a - b; ++i) {
    ans = ans + n[i];
  }
  cout << ans << endl;
  return 0;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long N, K;
  cin >> N >> K;
  vector<long long> H(N);
  for (long long i = 0; i < N; i++) {
    cin >> H[i];
  }
  sort(H.begin(), H.end());
  reverse(H.begin(), H.end());

  for (long long i = 0; i < K; i++) {
    H[i] = 0;
  }

  long long S = 0;
  for (long long i = 0; i < N; i++) {
    S += H[i];
  }
  cout << S << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long N, K;
  cin >> N >> K;
  vector<long long> H(N);
  for (long long i = 0; i < N; i++) {
    cin >> H[i];
  }
  sort(H.begin(), H.end());
  reverse(H.begin(), H.end());

  for (long long i = 0; i < K; i++) {
    H[i] = 0;
    if (i == N) {
      break;
    }
  }

  long long S = 0;
  for (long long i = 0; i < N; i++) {
    S += H[i];
  }
  cout << S << endl;
}
Problem p02785 (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() {
  int n, k;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  sort(h.begin(), h.end());
  rep(i, k) h[n - 1 - i] = 0;
  ll ans = 0;
  rep(i, n) ans += h[i];
  cout << ans << endl;
}

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() {
  int n, k;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  sort(h.begin(), h.end());
  rep(i, min(k, n)) h[n - 1 - i] = 0;
  ll ans = 0;
  rep(i, n) ans += h[i];
  cout << ans << endl;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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;
}
// 自作関数
template <class T> ll llpow(T x, T n) {
  ll ans = 1;
  while (n--) {
    ans *= x;
  }
  return ans;
}

#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL << 60;
int n;
int main() {
  int k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  sort(h.begin(), h.end(), greater<int>());
  rep(i, k) h[i] = 0;
  ll ans = 0;
  rep(i, n) ans += h[i];
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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;
}
// 自作関数
template <class T> ll llpow(T x, T n) {
  ll ans = 1;
  while (n--) {
    ans *= x;
  }
  return ans;
}

#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL << 60;
int n;
int main() {
  int k;
  cin >> n >> k;
  if (n < k) {
    cout << 0 << endl;
    return 0;
  }
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  sort(h.begin(), h.end(), greater<int>());
  rep(i, k) h[i] = 0;
  ll ans = 0;
  rep(i, n) ans += h[i];
  cout << ans << endl;
  return 0;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < n; i++)
#define Rep(i, n) for (long long i = 1; i < n; i++)
#define ll long long
#include <cmath>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;
#define PI acos(-1)
using P = pair<int, int>;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  sort(h.begin(), h.end());
  reverse(h.begin(), h.end());
  rep(i, k) h[i] = 0;
  ll sum = 0;
  rep(i, n) sum += h[i];
  cout << sum << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < n; i++)
#define Rep(i, n) for (long long i = 1; i < n; i++)
#define ll long long
#include <cmath>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;
#define PI acos(-1)
using P = pair<int, int>;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  sort(h.begin(), h.end());
  reverse(h.begin(), h.end());
  k = min(n, k);
  rep(i, k) h[i] = 0;
  ll sum = 0;
  rep(i, n) sum += h[i];
  cout << sum << endl;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> h(n);
  for (ll i = 0; i < n; ++i)
    cin >> h[i];
  sort(h.begin(), h.end(), greater<ll>());
  for (ll i = 0; i < k; ++i)
    h[i] = 0;
  ll sum = 0;
  for (ll i = 0; i < n; ++i)
    sum += h[i];
  cout << sum << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> h(n);
  for (ll i = 0; i < n; ++i)
    cin >> h[i];
  sort(h.begin(), h.end(), greater<ll>());
  if (n >= k) {
    for (ll i = 0; i < k; ++i)
      h[i] = 0;
  } else {
    for (ll i = 0; i < n; ++i)
      h[i] = 0;
  }
  ll sum = 0;
  for (ll i = 0; i < n; ++i)
    sum += h[i];
  cout << sum << endl;
  return 0;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
long long a[N], ans;
int n, k;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  sort(a + 1, a + n + 1);
  reverse(a + 1, a + n + 1);
  for (int i = k + 1; i <= n; i++)
    ans += a[i];
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
long long a[N], ans;
int n, k;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  sort(a + 1, a + n + 1);
  reverse(a + 1, a + n + 1);
  for (int i = k + 1; i <= n; i++)
    ans += a[i];
  cout << ans << endl;
  return 0;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
// 競技プログラミング用のテンプレート
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <vector>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)

using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

int main() {
  int n, k;
  cin >> n >> k;
  vl h(n, 0);
  rep(i, n) { cin >> h[i]; }
  sort(h.begin(), h.end());
  reverse(h.begin(), h.end());
  rep(i, k) { h[i] = 0; }
  ll c = 0;
  rep(i, n) { c += h[i]; }
  cout << c << endl;
}


Fixed submission:
// 競技プログラミング用のテンプレート
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <vector>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)

using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

int main() {
  int n, k;
  cin >> n >> k;
  vl h(n, 0);
  rep(i, n) { cin >> h[i]; }
  sort(h.begin(), h.end());
  reverse(h.begin(), h.end());
  rep(i, k) {
    if (i >= n)
      break;
    h[i] = 0;
  }
  ll c = 0;
  rep(i, n) { c += h[i]; }
  cout << c << endl;
}
Problem p02785 (C++)

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for (int64 i = 0; i < (n); i++)
#define FOR(i, a, b) for (int64 i = (a); i < (b); i++)
#define all(x) x.begin(), x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template <typename A, typename B> inline void chmin(A &a, B b) {
  if (a > b)
    a = b;
}
template <typename A, typename B> inline void chmax(A &a, B b) {
  if (a < b)
    a = b;
}

template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type fill_v(U &u, const V... v) {
  u = U(v...);
}

template <typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type fill_v(U &u, const V... v) {
  for (auto &e : u)
    fill_v<T>(e, v...);
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 N, K;
  cin >> N >> K;
  vector<int64> H(N);
  REP(i, N) cin >> H[i];
  sort(all(H), greater<int64>());
  int64 sum = accumulate(all(H), 0);
  REP(i, K) { sum -= H[i]; }
  cout << sum << endl;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for (int64 i = 0; i < (n); i++)
#define FOR(i, a, b) for (int64 i = (a); i < (b); i++)
#define all(x) x.begin(), x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template <typename A, typename B> inline void chmin(A &a, B b) {
  if (a > b)
    a = b;
}
template <typename A, typename B> inline void chmax(A &a, B b) {
  if (a < b)
    a = b;
}

template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type fill_v(U &u, const V... v) {
  u = U(v...);
}

template <typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type fill_v(U &u, const V... v) {
  for (auto &e : u)
    fill_v<T>(e, v...);
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 N, K;
  cin >> N >> K;
  vector<int64> H(N);
  REP(i, N) cin >> H[i];
  sort(all(H), greater<int64>());
  int64 sum = accumulate(all(H), 0LL);
  REP(i, min(K, N)) { sum -= H[i]; }
  cout << sum << endl;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
// define
typedef pair<int, int> pi;
#define int long long
#define elif else if
#define rep(x, y) for (int i = x; i < y; i++)
#define REP(x, y) for (int j = x; j < y; j++)
#define Rep(x, y) for (int k = x; k < y; k++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define vint vector<int>
#define vvint vector<vector<int>>
#define vtr vector<string>
#define vvtr vector<vector<string>>
#define vhar vector<char>
#define vvhar vector<vector<char>>
#define mod 100000007
#define elif else if
#define str string
int digitsum(int a) {
  int b = 0;
  while (a) {
    b += a % 10;
    a /= 10;
  }
  return b;
}
signed main() {
  int N, M, O, P = 0, c = 0, co = 0, cou = 0, minN = mod;
  double D, Do;
  char C, Ca;
  str S, T;
  cin >> N >> M;
  vint A(N);
  rep(0, N) {
    cin >> A[i];
    c += A[i];
  }
  sort(all(A));
  rep(0, M - 1) { c -= A[A.size() - 1 - i]; }
  cout << c << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
// define
typedef pair<int, int> pi;
#define int long long
#define elif else if
#define rep(x, y) for (int i = x; i < y; i++)
#define REP(x, y) for (int j = x; j < y; j++)
#define Rep(x, y) for (int k = x; k < y; k++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define vint vector<int>
#define vvint vector<vector<int>>
#define vtr vector<string>
#define vvtr vector<vector<string>>
#define vhar vector<char>
#define vvhar vector<vector<char>>
#define mod 100000007
#define elif else if
#define str string
int digitsum(int a) {
  int b = 0;
  while (a) {
    b += a % 10;
    a /= 10;
  }
  return b;
}
signed main() {
  int N, M, O, P = 0, c = 0, co = 0, cou = 0, minN = mod;
  double D, Do;
  char C, Ca;
  str S, T;
  cin >> N >> M;
  vint A(N);
  rep(0, N) {
    cin >> A[i];
    c += A[i];
  }
  sort(all(A));
  if (N >= M)
    rep(0, M) { c -= A[A.size() - 1 - i]; }
  else
    c = 0;
  cout << c << endl;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v;
  int move = 0;
  long long s[100001];
  for (int i = 0; i < n; i++)
    cin >> s[i];
  for (int i = 0; i < n; i++)
    v.push_back(s[i]);
  sort(v.begin(), v.end());
  for (int i = 0; i < n - m; i++)
    move += v[i];
  cout << move << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<long long> v;
  long long move = 0;
  long long s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    v.push_back(s);
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n - m; i++)
    move += v[i];
  cout << move << endl;
  return 0;
}
Problem p02785 (C++)

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

int main() {
  long long N, K;
  long long H[20000];
  long long sum = 0;

  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }

  sort(H, H + N, greater<long long int>());

  for (int i = K; i < N; i++) {
    sum += H[i];
  }

  cout << sum << endl;

  return 0;
}

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

int main() {
  long long N, K;
  long long H[200000];
  long long sum = 0;

  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }

  sort(H, H + N, greater<long long int>());

  for (int i = K; i < N; i++) {
    sum += H[i];
  }

  cout << sum << endl;

  return 0;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N, K;
  cin >> N >> K;
  ll H[N];
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  sort(H, H + N);
  reverse(H, H + N);
  for (int i = 0; i < K; i++) {
    H[i] = 0;
  }
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ans += H[i];
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N, K;
  cin >> N >> K;
  ll H[N];
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  sort(H, H + N);
  reverse(H, H + N);
  for (int i = 0; i < min(K, N); i++) {
    H[i] = 0;
  }
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ans += H[i];
  }
  cout << ans << endl;
  return 0;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b;
  cin >> a >> b;
  long long aa[b];
  long long sum = 0;
  for (long long i = 0; i < a; i++) {
    cin >> aa[i];
  }
  sort(aa, aa + a);

  if (b >= a)
    cout << "0" << endl;
  else {
    for (long long i = 0; i < a - b; i++) {
      sum += aa[i];
    }
    cout << sum << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b;
  cin >> a >> b;
  long long aa[a];
  long long sum = 0;
  for (long long i = 0; i < a; i++) {
    cin >> aa[i];
  }
  sort(aa, aa + a);

  if (b >= a)
    cout << "0" << endl;
  else {
    for (long long i = 0; i < a - b; i++) {
      sum += aa[i];
    }
    cout << sum << endl;
  }
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <cstdlib>
#include <iostream>
using namespace std;
int comp(const void *a, const void *b) {
  if ((*(unsigned long *)(a)) < (*(unsigned long *)(b))) {
    return -1;
  }
  if ((*(unsigned long *)(a)) > (*(unsigned long *)(b))) {
    return 1;
  }
  return 0;
}
int main() {
  unsigned long N, K;
  cin >> N >> K;
  unsigned long *H;
  H = (unsigned long *)malloc(N * sizeof(unsigned long));
  for (unsigned long i = 0; i < N; i++) {
    cin >> H[i];
  }
  qsort(H, N, sizeof(unsigned long), comp);
  unsigned long total = 0;
  for (unsigned long i = 0; i < N - K; i++) {
    total += H[i];
  }
  cout << total << endl;
  return 0;
}


Fixed submission:
#include <cstdlib>
#include <iostream>
using namespace std;
int comp(const void *a, const void *b) {
  if ((*(unsigned long *)(a)) < (*(unsigned long *)(b))) {
    return -1;
  }
  if ((*(unsigned long *)(a)) > (*(unsigned long *)(b))) {
    return 1;
  }
  return 0;
}
int main() {
  unsigned long N, K;
  cin >> N >> K;
  if (N < K) {
    cout << "0" << endl;
    return 0;
  }
  unsigned long *H;
  H = (unsigned long *)malloc(N * sizeof(unsigned long));
  for (unsigned long i = 0; i < N; i++) {
    cin >> H[i];
  }
  qsort(H, N, sizeof(unsigned long), comp);
  unsigned long total = 0;
  for (unsigned long i = 0; i < N - K; i++) {
    total += H[i];
  }
  cout << total << endl;
  return 0;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define INF 10000000001
#define DIM 200001
#define mod 1000000007
#define PI 3.1415926535897932384626433
#define se second
#define fi first
#define pb push_back
#define T true
#define F false
#define endl "\n"
typedef char ch;
typedef bool boll;
typedef string st;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef set<string> sst;
typedef set<long long> sl;
typedef queue<long long> que;
typedef vector<long long> vec;
typedef map<long long, long long> mll;
typedef pair<long long, long long> pll;
typedef vector<pair<long long, long long>> vpl;
typedef pair<long long, unsigned long long> pul;
ll a[100001], b, n, z, x, c, s, t;
int main() {
  fast;
  ll k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++)
    cin >> a[i], s += a[i];
  sort(a + 1, a + 1 + n);
  reverse(a + 1, a + 1 + n);
  for (int i = 1; i <= k; i++)
    s -= a[i];
  cout << s << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define INF 10000000001
#define DIM 200001
#define mod 1000000007
#define PI 3.1415926535897932384626433
#define se second
#define fi first
#define pb push_back
#define T true
#define F false
#define endl "\n"
typedef char ch;
typedef bool boll;
typedef string st;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef set<string> sst;
typedef set<long long> sl;
typedef queue<long long> que;
typedef vector<long long> vec;
typedef map<long long, long long> mll;
typedef pair<long long, long long> pll;
typedef vector<pair<long long, long long>> vpl;
typedef pair<long long, unsigned long long> pul;
ll a[200001], b, n, z, x, c, s, t;
int main() {
  fast;
  ll k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++)
    cin >> a[i], s += a[i];
  sort(a + 1, a + 1 + n);
  reverse(a + 1, a + 1 + n);
  for (int i = 1; i <= k; i++)
    s -= a[i];
  cout << s << endl;
}
Problem p02785 (C++)

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

int main() {
  long long int N, K;
  cin >> N >> K;

  vector<long long int> H(N);

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

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

  for (int i = 0; i < K; i++) {
    H[i] = 0;
  }

  long long int ans = 0;

  for (int i = 0; i < N; i++) {
    ans += H[i];
  }
  cout << ans << endl;
}


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

int main() {
  long long int N, K;
  cin >> N >> K;

  vector<long long int> H(N);

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

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

  if (N <= K) {
    for (int i = 0; i < N; i++) {
      H[i] = 0;
    }
  }

  else {
    for (int i = 0; i < K; i++) {
      H[i] = 0;
    }
  }

  long long int ans = 0;

  for (int i = 0; i < N; i++) {
    ans += H[i];
  }
  cout << ans << endl;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

using ll = long long;
template <class T> using V = vector<T>;
template <class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i = k; i < (ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(), v.end()
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
#define DEBUG_VLL(vec)                                                         \
  REP(sz, vec.size())                                                          \
      std::cerr << vec[sz] << (sz == vec.size() - 1 ? '\n' : ' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, k;
  cin >> n >> k;
  vll h(n);
  REP(i, n) cin >> h[i];
  sort(ALL(h));
  reverse(ALL(h));
  for (int i = 0; i < k; i++)
    h[i] = 0;
  cout << accumulate(ALL(h), 0LL) << '\n';
  return 0;
}


Fixed submission:
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

using ll = long long;
template <class T> using V = vector<T>;
template <class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i = k; i < (ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(), v.end()
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
#define DEBUG_VLL(vec)                                                         \
  REP(sz, vec.size())                                                          \
      std::cerr << vec[sz] << (sz == vec.size() - 1 ? '\n' : ' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, k;
  cin >> n >> k;
  vll h(n);
  REP(i, n) cin >> h[i];
  sort(ALL(h));
  reverse(ALL(h));
  for (int i = 0; i < min(k, n); i++)
    h[i] = 0;
  cout << accumulate(ALL(h), 0LL) << '\n';
  return 0;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
template <class T> inline bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
typedef long long ll;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  sort(all(h));
  for (int i = n - 1; i > n - 1 - k; i--) {
    h[i] = 0;
  }
  ll ans = 0;
  rep(i, n) ans += h[i];

  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
template <class T> inline bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
typedef long long ll;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  sort(all(h));
  for (int i = n - 1; i > n - 1 - k; i--) {
    h[i] = 0;
    if (i == 0)
      break;
  }
  ll ans = 0;
  rep(i, n) ans += h[i];

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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

typedef long long ll;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};
const int INF = 1e9;
#define FOR(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
int guki(int a) {
  if (a % 2 == 0)
    return 0;
  else
    return 1;
}
int gcd(int a, int b) {
  if (a % b == 0) {
    return b;
  } else {
    return (gcd(b, a % b));
  }
}
int lcm(int a, int b) {
  int x = gcd(a, b);
  return (a * b / x);
}

using namespace std;
ll k(ll a) {
  a--;
  ll ans = 0;
  while (a != 0) {
    ans += a;
    a--;
  }
  return ans;
}

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

  vector<int> vec(n);
  REP(i, n) { cin >> vec[i]; }
  SORT(vec);

  REP(i, k) { vec[n - 1 - i] = 0; }
  ll ans = 0;
  REP(i, n) { ans += vec[i]; }
  cout << ans << endl;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

typedef long long ll;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};
const int INF = 1e9;
#define FOR(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
int guki(int a) {
  if (a % 2 == 0)
    return 0;
  else
    return 1;
}
int gcd(int a, int b) {
  if (a % b == 0) {
    return b;
  } else {
    return (gcd(b, a % b));
  }
}
int lcm(int a, int b) {
  int x = gcd(a, b);
  return (a * b / x);
}

using namespace std;
ll k(ll a) {
  a--;
  ll ans = 0;
  while (a != 0) {
    ans += a;
    a--;
  }
  return ans;
}

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

  vector<int> vec(n);
  REP(i, n) { cin >> vec[i]; }
  SORT(vec);

  REP(i, k) {
    if (i >= n) {
      break;
    }
    vec[n - 1 - i] = 0;
  }
  ll ans = 0;
  REP(i, n) { ans += vec[i]; }
  cout << ans << endl;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int n, k, h[1000000005], i, ans;
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> h[i];
  }
  sort(h, h + n, greater<int>());
  for (i = k; i < n; i++) {
    ans = ans + h[i];
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  long long int n, k, h[200005], i, ans;
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> h[i];
  }
  sort(h, h + n, greater<int>());
  for (i = k; i < n; i++) {
    ans = ans + h[i];
  }
  cout << ans << endl;
  return 0;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
#include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main() {

  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> h[i];
    ans += h[i];
  }
  sort(h.rbegin(), h.rend());

  for (int i = 0; i < k; i++) {
    ans -= h[i];
  }
  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
#include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main() {

  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> h[i];
    ans += h[i];
  }
  sort(h.rbegin(), h.rend());

  for (int i = 0; i < min(n, k); i++) {
    ans -= h[i];
  }
  cout << ans << endl;

  return 0;
}
Problem p02785 (C++)

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

#define fori(x) for (int i = 0; i < x; ++i)

// cout << fixed << setprecision(10) << num << endl;

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  int h[110000];
  fori(n) cin >> h[i];

  sort(h, h + n, greater<int>());

  long long i = 0, s = 0, t = 0;
  for (i = 0; i < n; ++i) {
    if (k > 0) {
      --k;
      ++t;
      continue;
    } else {
      s += h[i];
      ++t;
    }
  }
  cout << i + s - t;
  return 0;
}

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

#define fori(x) for (int i = 0; i < x; ++i)

// cout << fixed << setprecision(10) << num << endl;

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  int h[220000];
  fori(n) cin >> h[i];

  sort(h, h + n, greater<int>());

  long long i = 0, s = 0, t = 0;
  for (i = 0; i < n; ++i) {
    if (k > 0) {
      --k;
      ++t;
      continue;
    } else {
      s += h[i];
      ++t;
    }
  }
  cout << i + s - t;
  return 0;
}
Problem p02785 (C++)

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

int n, k, h[100010];

int main() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }
  sort(h, h + n);
  long long ans = 0;
  for (int i = 0; i < n - k; ++i) {
    ans += h[i];
  }
  cout << ans << endl;
  return 0;
}

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

int n, k;
long long h[200010];

int main() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }
  sort(h, h + n);
  long long ans = 0;
  for (int i = 0; i < n - k; ++i) {
    ans += h[i];
  }
  cout << ans << endl;
  return 0;
}
Problem p02785 (C++)

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

int main() {
  int h, n;
  cin >> h >> n;
  long long a[n + 1], sum = 0;
  for (int i = 0; i < h; i++)
    cin >> a[i];
  sort(a, a + h);
  for (int i = 0; i < h - n; i++)
    sum += a[i];
  cout << sum;
  return 0;
}


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

int main() {
  int h, n;
  cin >> h >> n;
  long long a[h + 1], sum = 0;
  for (int i = 0; i < h; i++)
    cin >> a[i];
  sort(a, a + h);
  for (int i = 0; i < h - n; i++)
    sum += a[i];
  cout << sum;
  return 0;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void) {
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  rep(i, N) cin >> H[i];
  sort(all(H));
  rep(i, K) H.pop_back();
  ll ans = 0;
  rep(i, H.size()) ans += H[i];
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void) {
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  rep(i, N) cin >> H[i];
  sort(all(H));
  K = min(K, N);
  rep(i, K) H.pop_back();
  ll ans = 0;
  rep(i, H.size()) ans += H[i];
  cout << ans << endl;
  return 0;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;
int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  vector<ll> h(n);

  rep(i, n) {
    cin >> h.at(i);
    ans += h.at(i);
  }

  sort(all(h));
  reverse(all(h));

  rep(i, k) { ans -= h.at(i); }

  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;
int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  vector<ll> h(n);

  rep(i, n) {
    cin >> h.at(i);
    ans += h.at(i);
  }

  sort(all(h));
  reverse(all(h));

  rep(i, min(k, n)) { ans -= h.at(i); }

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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long ll;
ll a[100010];
int main() {
  int i, j, k;
  ll H, N;
  ll ans = 0;
  cin >> N >> k;
  for (i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a, a + N);
  for (i = 0; i < N - k; i++) {
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long ll;
ll a[200010];
int main() {
  int i, j, k;
  ll H, N;
  ll ans = 0;
  cin >> N >> k;
  for (i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a, a + N);
  for (i = 0; i < N - k; i++) {
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}
Problem p02785 (C++)

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

int main() {
  long long int n, k, c = 0;
  cin >> n >> k;
  vector<int> a(100000);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end(), std::greater<>());
  for (int i = k; i < n; i++) {
    c += a[i];
  }
  cout << c << endl;
  return 0;
}

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

int main() {
  long long int n, k, c = 0;
  cin >> n >> k;
  vector<long long int> a(10000000);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end(), std::greater<>());
  for (int i = k; i < n; i++) {
    c += a[i];
  }
  cout << c << endl;
  return 0;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> H;
  for (int i = 0; i < N; i++) {
    ll a;
    cin >> a;
    H.push_back(a);
  }
  sort(H.begin(), H.end());
  cout << accumulate(H.begin(), H.end() - K, 0) << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> H;
  for (int i = 0; i < N; i++) {
    ll a;
    cin >> a;
    H.push_back(a);
  }
  if (N < K) {
    cout << 0 << endl;
  } else {
    sort(H.begin(), H.end());
    cout << accumulate(H.begin(), H.end() - K, 0LL) << endl;
  }

  return 0;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k, i;
  cin >> n >> k;
  long long int arr[100005];
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  if (k >= n) {
    printf("0\n");
  } else {
    long long int sum = 0;
    for (i = 0; i < n - k; i++) {
      sum = sum + arr[i];
    }
    cout << sum << endl;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k, i;
  cin >> n >> k;
  long long int arr[200005];
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  if (k >= n) {
    printf("0\n");
  } else {
    long long int sum = 0;
    for (i = 0; i < n - k; i++) {
      sum = sum + arr[i];
    }
    cout << sum << endl;
  }
  return 0;
}
Problem p02785 (C++)

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

long long chose2(long long x) { return x * (x - 1) / 2; }

int main() {
  long long N, K;
  cin >> N >> K;
  vector<long long> H(N, 0);
  for (long long i = 0; i < N; i++) {
    cin >> H[i];
  }

  sort(H.begin(), H.end(), greater<int>());
  for (long long i = 0; i < K; i++) {
    H[i] = 0;
  }

  long long ans = 0;
  for (long long i = 0; i < N; i++) {
    ans += H[i];
  }

  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define INF 1LL << 60

long long chose2(long long x) { return x * (x - 1) / 2; }

int main() {
  long long N, K;
  cin >> N >> K;
  vector<long long> H(N, 0);
  for (long long i = 0; i < N; i++) {
    cin >> H[i];
  }

  sort(H.begin(), H.end(), greater<int>());
  K = min(K, N);
  for (long long i = 0; i < K; i++) {
    H[i] = 0;
  }

  long long ans = 0;
  for (long long i = 0; i < N; i++) {
    ans += H[i];
  }

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

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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
#define INF 1e8
typedef long long ll;
typedef long double ld;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  sort(h.begin(), h.end(), greater<int>());

  rep(i, k) h[i] = 0;
  ll sum = 0;
  rep(i, n) sum += h[i];

  cout << sum << endl;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
#define INF 1e8
typedef long long ll;
typedef long double ld;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  sort(h.begin(), h.end(), greater<int>());
  if (k > n)
    k = n;
  rep(i, k) h[i] = 0;
  ll sum = 0;
  rep(i, n) sum += h[i];

  cout << sum << endl;
}
Problem p02785 (C++)

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

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> H(N);
  for (ll i = 0; i < N; i++) {
    cin >> H[i];
  }
  sort(H.begin(), H.end());
  reverse(H.begin(), H.end());
  for (ll i = 0; i < K; i++) {
    H[i] = 0;
  }
  ll ans = 0;
  for (ll i = 0; i < N; i++) {
    ans += H[i];
  }
  cout << ans << endl;
}

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

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> H(N);
  for (ll i = 0; i < N; i++) {
    cin >> H[i];
  }
  sort(H.begin(), H.end());
  reverse(H.begin(), H.end());
  if (N <= K) {
    cout << 0 << endl;
    exit(0);
  }
  for (ll i = 0; i < K; i++) {
    H[i] = 0;
  }
  ll ans = 0;
  for (ll i = 0; i < N; i++) {
    ans += H[i];
  }
  cout << ans << endl;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#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++)
using namespace std;
using P = pair<int, int>;
using ll = long long;

int main() {
  int n;
  cin >> n;
  int k;
  cin >> k;
  int a[n];
  ll sum = 0;
  rep(i, n) {
    cin >> a[i];
    sum += a[i];
  }
  int ans = 0;
  sort(a, a + n, greater<>());
  rep(i, k) sum -= a[i];
  if (sum < 0)
    sum = 0;
  cout << sum << endl;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#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++)
using namespace std;
using P = pair<int, int>;
using ll = long long;

int main() {
  int n;
  cin >> n;
  int k;
  cin >> k;
  int a[n];
  ll sum = 0;
  rep(i, n) {
    cin >> a[i];
    sum += a[i];
  }
  int ans = 0;
  sort(a, a + n, greater<>());
  rep(i, k) {
    sum -= a[i];
    if (i + 1 == n)
      break;
  }
  if (sum < 0)
    sum = 0;
  cout << sum << endl;

  return 0;
}
Problem p02785 (C++)

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

int32_t main() {

  int n, k;
  cin >> n >> k;
  int array[n];
  REP(i, n) cin >> array[i];
  sort(array, array + n, greater<int>());
  REP(i, k) array[i] = 0;
  int ans = 0;
  REP(i, n) ans += array[i];
  cout << ans;

  return 0;
}

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

int32_t main() {

  int n, k;
  cin >> n >> k;
  int array[n];
  REP(i, n) cin >> array[i];
  sort(array, array + n, greater<int>());
  if (k >= n)
    cout << 0;
  else {
    REP(i, k) array[i] = 0;
    int ans = 0;
    REP(i, n) ans += array[i];
    cout << ans;
  }

  return 0;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int _I() {
  int x;
  scanf("%d", &x);
  return x;
}
int mp[10005];
int ar[100005];
void solve() {
  int n = _I();
  int k = _I();
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    ar[i] = _I();
  }
  sort(ar, ar + n);
  for (int i = 0; i < max(0, n - k); i++) {
    sum += ar[i];
  }
  cout << sum << "\n";
}
int main() {
  solve();
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int _I() {
  int x;
  scanf("%d", &x);
  return x;
}
int mp[10005];
int ar[200005];
void solve() {
  int n = _I();
  int k = _I();
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    ar[i] = _I();
  }
  sort(ar, ar + n);
  for (int i = 0; i < max(0, n - k); i++) {
    sum += ar[i];
  }
  cout << sum << "\n";
}
int main() {
  solve();
  return 0;
}
Problem p02785 (C++)

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

using namespace std;

typedef long long int LL;
typedef unsigned long long int ULL;
typedef pair<int, int> PII;
typedef map<int, int> MII;

const int SZ = 112345;
const int MOD = 1e9 + 7;

int n, k, a[SZ];

int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  int m = n - k;
  LL s = 0;
  for (int i = 0; i < m; i++) {
    s += a[i];
  }
  cout << s << endl;
  return 0;
}


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

using namespace std;

typedef long long int LL;
typedef unsigned long long int ULL;
typedef pair<int, int> PII;
typedef map<int, int> MII;

const int SZ = 212345;
const int MOD = 1e9 + 7;

int n, k, a[SZ];

int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  int m = n - k;
  LL s = 0;
  for (int i = 0; i < m; i++) {
    s += a[i];
  }
  cout << s << endl;
  return 0;
}
Problem p02785 (C++)

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> H(n);
  rep(i, n) cin >> H[i];
  sort(H.begin(), H.end());
  reverse(H.begin(), H.end());
  rep(i, k) H[i] = 0;
  ull cnt = 0;
  rep(i, n) cnt += H[i];
  cout << cnt << endl;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> H(n);
  rep(i, n) cin >> H[i];
  sort(H.begin(), H.end());
  ll cnt = 0;
  rep(i, n - k) cnt += H[i];
  cout << cnt << endl;
}