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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reprep(i, j, h, w) rep(i, h) rep(j, w)
#define rrep(i, m, n) for (int i = m; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define aall(x, n) (x).begin(), (x).begin() + (n)
#define VEC(type, name, n)                                                     \
  std::vector<type> name(n);                                                   \
  rep(i, n) std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed << setprecision
#define vvector(name, typ, m, n, a)                                            \
  vector<vector<typ>> name(m, vector<typ>(n, a))
#define vvvector(name, t, l, m, n, a)                                          \
  vector<vector<vector<t>>> name(l, vector<vector<t>>(m, vector<t>(n, a)));
#define vvvvector(name, t, k, l, m, n, a)                                      \
  vector<vector<vector<vector<t>>>> name(                                      \
      k, vector<vector<vector<t>>>(l, vector<vector<t>>(m, vector<t>(n, a))));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main() {
  int n, k;
  std::cin >> n >> k;
  VEC(ll, a, n);
  int ans = 0;
  sort(all(a), greater<ll>());
  rep(i, k) a[i] = 0ll;
  std::cout << sum(all(a), 0ll) << std::endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reprep(i, j, h, w) rep(i, h) rep(j, w)
#define rrep(i, m, n) for (int i = m; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define aall(x, n) (x).begin(), (x).begin() + (n)
#define VEC(type, name, n)                                                     \
  std::vector<type> name(n);                                                   \
  rep(i, n) std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed << setprecision
#define vvector(name, typ, m, n, a)                                            \
  vector<vector<typ>> name(m, vector<typ>(n, a))
#define vvvector(name, t, l, m, n, a)                                          \
  vector<vector<vector<t>>> name(l, vector<vector<t>>(m, vector<t>(n, a)));
#define vvvvector(name, t, k, l, m, n, a)                                      \
  vector<vector<vector<vector<t>>>> name(                                      \
      k, vector<vector<vector<t>>>(l, vector<vector<t>>(m, vector<t>(n, a))));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main() {
  int n, k;
  std::cin >> n >> k;
  VEC(ll, a, n);
  int ans = 0;
  sort(all(a), greater<ll>());
  rep(i, min(k, n)) a[i] = 0ll;
  std::cout << sum(all(a), 0ll) << std::endl;
}
Problem p02785 (C++)

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

int main() {
  int N, K, hp;
  long long ans = 0;
  cin >> N >> K;

  vector<int> v;
  for (int i = 0; i < N; i++) {
    cin >> hp;
    v.push_back(hp);
  }

  // 降順ソート
  sort(v.begin(), v.end());

  // 必殺技でHPが多い順に倒していく
  for (int j = 0; j < K; j++) {
    v.erase(v.end());
    if (v.empty()) {
      cout << ans << endl;
      return 0;
    }
  }

  // 残りの敵のHP=攻撃回数
  ans = accumulate(v.begin(), v.end(), 0LL);
  cout << ans << endl;

  return 0;
}

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

int main() {
  int N, K, hp;
  long long ans = 0;
  cin >> N >> K;

  vector<int> v;
  for (int i = 0; i < N; i++) {
    cin >> hp;
    v.push_back(hp);
  }

  // 降順ソート
  sort(v.begin(), v.end());

  // 必殺技でHPが多い順に倒していく
  for (int j = 0; j < K; j++) {
    v.pop_back();
    if (v.empty()) {
      cout << ans << endl;
      return 0;
    }
  }

  // 残りの敵のHP=攻撃回数
  ans = accumulate(v.begin(), v.end(), 0LL);
  cout << ans << endl;

  return 0;
}
Problem p02785 (C++)

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

int main() {

  int long long N, K, t = 0, i, j = 0, a;
  int long long ans = 0;

  cin >> N >> K;
  std::vector<int long long> H(N);
  for (i = 0; i < N; i++) {
    cin >> a;
    H[i] = a;
    ans += a;
  }
  sort(H.begin(), H.end(), greater<>());
  for (i = 0; i < K; i++) {
    ans -= H[i];
  }

  printf("%lld\n", ans);
  return 0;
}

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

int main() {

  int long long N, K, t = 0, i, j = 0, a;
  int long long ans = 0;

  cin >> N >> K;
  if (N <= K) {
    ans = 0;
  } else {

    std::vector<int long long> H(N);
    for (i = 0; i < N; i++) {
      cin >> a;
      H[i] = a;
      ans += a;
    }
    sort(H.begin(), H.end(), greater<>());
    for (i = 0; i < K; i++) {
      ans -= H[i];
    }
  }

  printf("%lld\n", ans);
  return 0;
}
Problem p02785 (C++)

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

void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a.rbegin(), a.rend());
  for (int i = 0; i < k; i++) {
    sum -= a[i];
  }
  cout << sum;
}

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


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

void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (k >= n) {
    cout << 0;
    return;
  }
  sort(a.rbegin(), a.rend());
  for (int i = 0; i < k; i++) {
    sum -= a[i];
  }
  cout << sum;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits //stdc++.h>

using namespace std;

long long h[100001];

int main() {
  long long n, k;
  long long a;
  cin >> n >> k;
  a = 0;

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

    cin >> h[i];
  }

  sort(h, h + n);

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

    a = a + h[i];
  }

  cout << a;

  return 0;
}


Fixed submission:
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits //stdc++.h>

using namespace std;

long long h[1000001];

int main() {
  long long n, k;
  long long a;
  cin >> n >> k;
  a = 0;

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

    cin >> h[i];
  }

  sort(h, h + n);

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

    a = a + h[i];
  }

  cout << a;

  return 0;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, k) for (int i = 0; i < k; i++)
ll n, m[22][22] = {}, i, j, k, h, o, l = 0, z, sam = 0, p, q;
ll a[100005] = {}, inf = 1000000000000;
ll b[100005] = {};

string s[22];
ll t[100005], xx[100005];
char ss, st;
const int MAX = 100005;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  cin >> n >> k;
  rep(i, n) cin >> a[i];
  sort(a, a + n);
  z = n - k;
  if (z <= 0) {
    cout << 0;
    return 0;
  }
  rep(i, z) sam += a[i];

  cout << sam;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, k) for (int i = 0; i < k; i++)
ll n, m[22][22] = {}, i, j, k, h, o, l = 0, z, sam = 0, p, q;
ll a[200005] = {}, inf = 1000000000000;
ll b[100005] = {};

string s[22];
ll t[100005], xx[100005];
char ss, st;
const int MAX = 100005;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  cin >> n >> k;
  rep(i, n) cin >> a[i];
  sort(a, a + n);
  z = n - k;
  if (z <= 0) {
    cout << 0;
    return 0;
  }
  rep(i, z) sam += a[i];

  cout << sam;
  return 0;
}
Problem p02785 (C++)

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

#define ll long long
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set                                                            \
  tree<int, null_type, less<int>, rb_tree_tag,                                 \
       tree_order_statistics_node_update>

using namespace std;
const int N = 2e5 + 5;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  ll ans = 0;
  for (int i = 0; i < v.size() - k; i++)
    ans += v[i];
  cout << ans;
  return 0;
}


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

#define ll long long
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set                                                            \
  tree<int, null_type, less<int>, rb_tree_tag,                                 \
       tree_order_statistics_node_update>

using namespace std;
const int N = 2e5 + 5;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  ll ans = 0;
  for (int i = 0; i < int(v.size()) - k; i++)
    ans += v[i];
  cout << ans;
  return 0;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <math.h>
using namespace std;
int h;
int n;
int k;
int a[20009];
int main() {
  while (cin >> n >> k) {
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    long long sum = 0;
    sort(a, a + n);
    for (int i = n - 1; i >= 0; i--) {
      if (k > 0) {
        k--;
        continue;
      } else {
        sum += a[i];
      }
    }
    cout << sum << endl;
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <math.h>
using namespace std;
int h;
int n;
int k;
long long a[200009];
int main() {
  while (cin >> n >> k) {
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    long long sum = 0;
    sort(a, a + n);
    for (int i = n - 1; i >= 0; i--) {
      if (k > 0) {
        k--;
        continue;
      } else {
        sum += a[i];
      }
    }
    cout << sum << endl;
  }
  return 0;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int h[N];
typedef long long ll;

int main() {
  ll n, k;
  cin >> n >> k;
  for (int i = 0; i < n; ++i)
    cin >> h[i];
  sort(h, h + n, greater<int>());
  ll ans = 0;
  for (int i = k; i < n; ++i)
    ans += h[i];
  cout << ans;
  return 0;
}
/*

*/

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int h[N];
typedef long long ll;

int main() {
  ll n, k;
  cin >> n >> k;
  for (int i = 0; i < n; ++i)
    cin >> h[i];
  sort(h, h + n, greater<int>());
  ll ans = 0;
  for (int i = k; i < n; ++i)
    ans += h[i];
  cout << ans;
  return 0;
}
/*

*/
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100010];
int main() {
  int n, k;
  ll ans = 0;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    ans += a[i];
  }
  sort(a + 1, a + 1 + n);
  for (int i = n; i > n - k && i >= 0; i--) {
    ans -= a[i];
  }
  printf("%lld\n", ans);
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200010];
int main() {
  int n, k;
  ll ans = 0;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    ans += a[i];
  }
  sort(a + 1, a + 1 + n);
  for (int i = n; i > n - k && i >= 0; i--) {
    ans -= a[i];
  }
  printf("%lld\n", ans);
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int Max = 0x3f3f3f3f;
int a[100005];
int main() {
  int n, k;
  while (~scanf("%d%d", &n, &k)) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
    }
    sort(a + 1, a + 1 + n);
    if (k >= n)
      printf("0\n");
    else {
      ll sum = 0;
      for (int i = n - k; i >= 1; i--) {
        sum += a[i];
      }
      printf("%lld\n", sum);
    }
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int Max = 0x3f3f3f3f;
int a[200005];
int main() {
  int n, k;
  while (~scanf("%d%d", &n, &k)) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
    }
    sort(a + 1, a + 1 + n);
    if (k >= n)
      printf("0\n");
    else {
      ll sum = 0;
      for (int i = n - k; i >= 1; i--) {
        sum += a[i];
      }
      printf("%lld\n", sum);
    }
  }
}
Problem p02785 (C++)

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

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

  long a, b, c, i, j;
  vector<long> v;
  cin >> a >> b;
  for (i = 0; i < a; i++) {
    cin >> c;
    v.push_back(c);
  }
  std::sort(v.begin(), v.end(), std::greater<int>()); // 降順ソー
  for (i = 0; i < b; i++) {
    v[i] = 0;
  }
  c = 0;
  for (j = i; j < v.size(); j++) {
    c += v[j];
  }
  cout << c;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;

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

  long a, b, c, i, j;
  vector<long> v;
  cin >> a >> b;
  for (i = 0; i < a; i++) {
    cin >> c;
    v.push_back(c);
  }
  std::sort(v.begin(), v.end(), std::greater<int>()); // 降順ソー
  for (i = 0; i < b; i++) {
    if (i >= v.size())
      break;
    v[i] = 0;
  }
  c = 0;
  for (j = i; j < v.size(); j++) {
    c += v[j];
  }
  cout << c;

  return 0;
}
Problem p02785 (C++)

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


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

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

// マクロ
// forループ関係
// 引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (lol i = 0; i < lol(n); i++)
#define REPD(i, n) for (lol i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (lol i = a; i <= lol(b); i++)
#define FORD(i, a, b) for (lol i = a; i >= lol(b); i--)
#define VL vector<lol>
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end() // sortなどの引数を省略したい
#define SIZE(x) lol(x.size())     // sizeをsize_tからllに直しておく
// 定数
#define PI 3.1415926535897932385 // pi
#define INF 1000000000000        // 10^12:極めて大きい値,∞
#define MOD 1000000007           // 10^9+7:合同式の法
#define MAXR 100000 // 10^5:配列の最大のrange(素数列挙などで使用)
// 最大値最小値
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main() {
  lol result{0};
  lol n, k;
  cin >> n >> k;
  VL a(n);
  REP(i, n) {
    cin >> a[i];
    result += a[i];
  }
  sort(ALL(a));
  FORD(i, n - 1, n - k) { result -= a[i]; }

  cout << result << endl;
  return 0;
}

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

// マクロ
// forループ関係
// 引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (lol i = 0; i < lol(n); i++)
#define REPD(i, n) for (lol i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (lol i = a; i <= lol(b); i++)
#define FORD(i, a, b) for (lol i = a; i >= lol(b); i--)
#define VL vector<lol>
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end() // sortなどの引数を省略したい
#define SIZE(x) lol(x.size())     // sizeをsize_tからllに直しておく
// 定数
#define PI 3.1415926535897932385 // pi
#define INF 1000000000000        // 10^12:極めて大きい値,∞
#define MOD 1000000007           // 10^9+7:合同式の法
#define MAXR 100000 // 10^5:配列の最大のrange(素数列挙などで使用)
// 最大値最小値
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main() {
  lol result{0};
  lol n, k;
  cin >> n >> k;
  VL a(n);
  REP(i, n) {
    cin >> a[i];
    result += a[i];
  }
  if (k > n)
    k = n;
  sort(ALL(a));
  FORD(i, n - 1, n - k) { result -= a[i]; }

  cout << result << endl;
  return 0;
}
Problem p02785 (C++)

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

using namespace std;

typedef long long ll;

ifstream fin("hps.in");
ofstream fout("hps.out");

#define f first
#define s second
#define pb push_back

int n, k, h[100002];
ll ans;

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


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

using namespace std;

typedef long long ll;

ifstream fin("hps.in");
ofstream fout("hps.out");

#define f first
#define s second
#define pb push_back

int n, k, h[200002];
ll ans;

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

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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

  return 0;
}

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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

  return 0;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  // モンスターの数, 必殺技の回数
  int N, K;
  cin >> N >> K;

  // N体のモンスターの体力
  vector<long long> HP(N);
  for (long long &x : HP)
    cin >> x;

  sort(HP.begin(), HP.end(), greater<long long>());

  // HPが高い敵をK体倒す
  for (auto itr = HP.begin(); itr < HP.begin() + K; ++itr) {
    *itr = 0;
  }

  // 何回攻撃すれば勝てるか
  long long cnt = 0;
  for (long long x : HP)
    cnt += x;

  cout << cnt << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  // モンスターの数, 必殺技の回数
  int N, K;
  cin >> N >> K;

  // N体のモンスターの体力
  vector<long long> HP(N);
  for (long long &x : HP)
    cin >> x;

  sort(HP.begin(), HP.end(), greater<long long>());

  // HPが高い敵をK体倒す
  for (auto itr = HP.begin(); (itr < (HP.begin() + min(K, N))); ++itr) {
    *itr = 0;
  }

  // 何回攻撃すれば勝てるか
  long long cnt = 0;
  for (long long x : HP)
    cnt += x;

  cout << cnt << 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;
using ll = long long;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  sort(h.begin(), h.end());
  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++)
using namespace std;
using ll = long long;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  sort(h.begin(), h.end());
  k = min(n, k);
  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: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {

  long long n, k;
  cin >> n >> k;
  vector<int> h(n);
  long long tmp = 0;
  long long lol = 0;
  long long ans = 0;

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

  if (k == 0) {
    cout << lol << endl;
    return 0;
  } else if (k >= n) {
    cout << "0" << endl;
  } else {

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

    for (int i = 0; i < k; i++) {
      h.at(i) = 0;
    }
    for (int i = 0; i < n; i++) {
      tmp = tmp + h.at(i);
    }
    for (int i = 0; i < 1000000000 * n; i++) {
      if (tmp <= 0) {
        cout << ans << endl;
        return 0;
      } else {
        tmp--;
        ans++;
      }
    }
  }
}


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

int main() {

  long long n, k;
  cin >> n >> k;
  vector<int> h(n);
  long long tmp = 0;
  long long lol = 0;
  long long ans = 0;

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

  if (k == 0) {
    cout << lol << endl;
    return 0;
  } else if (k >= n) {
    cout << "0" << endl;
  } else {

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

    for (int i = 0; i < k; i++) {
      h.at(i) = 0;
    }
    for (int i = 0; i < n; i++) {
      tmp = tmp + h.at(i);
    }
    cout << tmp << 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 pb push_back
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;

int main() {
  ll n, k, sum = 0;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i, n) {
    cin >> h.at(i);
    sum += h.at(i);
  }
  sort(h.begin(), h.end(), greater<ll>());
  rep(i, k) { sum -= h.at(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 pb push_back
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;

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

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

int main(void) {
  int N, K;
  cin >> N >> K;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  long long count = 0;
  sort(A.begin(), A.end(), greater<>());
  for (int i = 0; i < K; i++) {
    A[i] = 0;
  }
  for (int i = 0; i < N; i++) {
    count += A[i];
  }
  cout << count << endl;
  return 0;
}


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

int main(void) {
  int N, K;
  cin >> N >> K;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  long long count = 0;
  sort(A.begin(), A.end());
  for (int i = 0; i < N - K; i++) {
    count += A[i];
  }
  cout << count << endl;
  return 0;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
/*
 author : arush gupta
 date :26.01.2020
 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll n, k, x;
  vector<ll> v;
  cin >> n >> k;
  for (ll i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  for (ll i = 0; i < k; i++) {
    v.pop_back();
  }
  ll sum = 0;
  for (ll i = 0; i < v.size(); i++) {
    sum += v[i];
  }
  cout << sum << endl;
  return 0;
}


Fixed submission:
/*
 author : arush gupta
 date :26.01.2020
 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll n, k, x;
  vector<ll> v;
  cin >> n >> k;
  for (ll i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
  }
  if (k >= n) {
    cout << 0;
    return 0;
  }
  sort(v.begin(), v.end());
  for (ll i = 0; i < k; i++) {
    v.pop_back();
  }
  ll sum = 0;
  for (ll i = 0; i < v.size(); i++) {
    sum += v[i];
  }
  cout << sum << endl;
  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(x) (x).begin(), (x).end()
#define INF 10000000
using ll = long long;
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
template <int id> struct CompTupleBy {
  template <class T> bool operator()(const T &a, const T &b) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

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

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define INF 10000000
using ll = long long;
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
template <int id> struct CompTupleBy {
  template <class T> bool operator()(const T &a, const T &b) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> vec(n);
  rep(i, n) { cin >> vec[i]; }
  sort(vec.begin(), vec.end(), greater<ll>());
  if (k > n) {
    k = n;
  }
  rep(i, k) { vec[i] = 0; }
  ll ans = 0;
  rep(i, n) { ans += vec[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 REPR(i, n) for (int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, n, m, M, K, a;

vector<ll> v, w;
int main() {
  cin >> N >> K;
  v.resize(0);
  for (int i = 0; i < N; ++i) {
    cin >> n;
    v.push_back(n);
  }
  sort(v.begin(), v.end());
  while (K) {
    v.pop_back();
    --K;
  }
  if (v.size() == 0)
    cout << 0;
  else
    cout << accumulate(v.begin(), v.end(), 0LL);
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for (int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, n, m, M, K, a;

vector<ll> v, w;
int main() {
  cin >> N >> K;
  v.resize(0);
  for (int i = 0; i < N; ++i) {
    cin >> n;
    v.push_back(n);
  }
  sort(v.begin(), v.end());
  while (K and v.size() > 0) {
    v.pop_back();
    --K;
  }
  if (v.size() == 0)
    cout << 0;
  else
    cout << accumulate(v.begin(), v.end(), 0LL);
  return 0;
}
Problem p02785 (C++)

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

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

  vector<ll> h(n);

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

  sort(h.rbegin(), h.rend());

  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;
}

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

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

  vector<ll> h(n);

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

  sort(h.rbegin(), h.rend());

  for (ll i = 0; i < min(n, k); ++i) {
    h[i] = 0;
  }

  ll sum = 0;

  for (ll i = 0; i < n; ++i) {
    sum += h[i];
  }

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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

using namespace std;

void solve() {
  int n, k;
  cin >> n >> k;
  vector<long long> h(n);
  for (int i = 0; i < n; i++)
    cin >> h[i];
  sort(h.begin(), h.end(), greater<int>());
  for (int i = 0; i < k; i++)
    h[i] = 0;
  cout << accumulate(h.begin(), h.end(), 0LL) << endl;
}

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(16);

  solve();

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

using namespace std;

void solve() {
  int n, k;
  cin >> n >> k;
  vector<long long> h(n);
  for (int i = 0; i < n; i++)
    cin >> h[i];
  sort(h.begin(), h.end(), greater<int>());
  for (int i = 0; i < min(n, k); i++)
    h[i] = 0;
  cout << accumulate(h.begin(), h.end(), 0LL) << endl;
}

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(16);

  solve();

  return 0;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  long long n, a[100005], k, s = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a, a + n);
  for (int i = 0; i < n - k; i++)
    s += a[i];
  cout << s;
}

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

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> HP(n);
  for (int i = 0; i < n; i++) {
    cin >> HP.at(i);
  }
  sort(HP.begin(), HP.end());
  for (int i = 0; i < k; i++) {
    HP.pop_back();
  }
  long long sum = 0;
  for (int i = 0; i < HP.size(); i++) {
    sum += HP.at(i);
  }
  cout << sum << endl;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  if (n <= k) {
    cout << "0" << endl;
    return 0;
  }
  vector<int> HP(n);
  for (int i = 0; i < n; i++) {
    cin >> HP.at(i);
  }
  sort(HP.begin(), HP.end());
  for (int i = 0; i < k; i++) {
    HP.pop_back();
  }
  long long sum = 0;
  for (int i = 0; i < HP.size(); i++) {
    sum += HP.at(i);
  }
  cout << sum << endl;
}
Problem p02785 (C++)

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

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, h[200100], i, ans = 0;
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> h[i];
  }
  sort(h, h + n);
  for (i = 0; i < n - k; i++) {
    ans += h[i];
  }
  cout << ans << endl;

  return 0;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  // vector<unsigned int> h(n);
  unsigned int h[20000];
  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;
  }
  unsigned long long int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += h[i];
  }
  cout << ans << "\n";
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  // vector<unsigned int> h(n);
  unsigned int h[200005];
  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;
  }
  unsigned long long int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += h[i];
  }
  cout << ans << "\n";
  return 0;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define End return 0

int main() {
  ll n, a;
  cin >> n >> a;

  ll aa[a];
  ll s = 0;
  for (ll i = 0; i < n; i++) {
    cin >> aa[i];
    s += aa[i];
  }
  if (n <= a)
    cout << "0" << endl;
  else {
    sort(aa, aa + n);
    ll p = 0;
    for (ll i = 0; i < a; i++) {
      p += (aa[n - i - 1]);
    }
    cout << s - p << endl;
  }
}
/* pray for me
All is well
*/


Fixed submission:
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define End return 0

int main() {
  ll n, a;
  cin >> n >> a;

  ll aa[n];
  ll s = 0;
  for (ll i = 0; i < n; i++) {
    cin >> aa[i];
    s += aa[i];
  }
  if (n <= a)
    cout << "0" << endl;
  else {
    sort(aa, aa + n);
    ll p = 0;
    for (ll i = 0; i < a; i++) {
      p += (aa[n - i - 1]);
    }
    cout << s - p << endl;
  }
}
/* pray for me
All is well
*/
Problem p02785 (C++)

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

int main() {
  int n, m;
  int aa[100005];
  long long int ans = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &aa[i]);
  }
  sort(aa + 1, aa + 1 + n);
  if (m >= n)
    cout << "0";
  else {
    for (int i = 1; i <= n - m; i++) {
      ans = ans + aa[i];
    }
    cout << ans;
  }
  return 0;
}


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

int main() {
  int n, m;
  int aa[200005];
  long long int ans = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &aa[i]);
  }
  sort(aa + 1, aa + 1 + n);
  if (m >= n)
    cout << "0";
  else {
    for (int i = 1; i <= n - m; i++) {
      ans = ans + aa[i];
    }
    cout << ans;
  }
  return 0;
}
Problem p02785 (C++)

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


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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n", __LINE__)
#define file(a)                                                                \
  freopen(#a ".in", "r", stdin);                                               \
  freopen(#a ".out", "w", stdout)
#define int long long
#define D double
#define inf 123456789
#define mod 1000000007
il int read() {
  re int x = 0, f = 1;
  re char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-')
      f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = x * 10 + c - 48, c = getchar();
  return x * f;
}
#define rep(i, a, b) for (int i = (a), i##Limit = (b); i <= i##Limit; ++i)
#define drep(i, b, a) for (int i = (a), i##Limit = (b); i >= i##Limit; --i)
#define Next(i, u) for (re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define lb(x) (x) & (-(x))
#define ls k * 2
#define rs k * 2 + 1
#define maxn 100005
il int Mul(int a, int b) { return 1ll * a * b % mod; }
il int Inc(int a, int b) { return (a += b) >= mod ? a - mod : a; }
il int Dec(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
il int qpow(int a, int b) {
  int r = 1;
  while (b) {
    if (b & 1)
      r = Mul(r, a);
    a = Mul(a, a), b >>= 1;
  }
  return r;
}
int n, m, a[maxn], sum;
il bool cmp(int a, int v) { return a > v; }
signed main() {
  n = read(), m = read();
  rep(i, 1, n) a[i] = read();
  sort(a + 1, a + n + 1, cmp);
  rep(i, m + 1, n) sum += a[i];
  cout << sum;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n", __LINE__)
#define file(a)                                                                \
  freopen(#a ".in", "r", stdin);                                               \
  freopen(#a ".out", "w", stdout)
#define int long long
#define D double
#define inf 123456789
#define mod 1000000007
il int read() {
  re int x = 0, f = 1;
  re char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-')
      f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = x * 10 + c - 48, c = getchar();
  return x * f;
}
#define rep(i, a, b) for (int i = (a), i##Limit = (b); i <= i##Limit; ++i)
#define drep(i, b, a) for (int i = (a), i##Limit = (b); i >= i##Limit; --i)
#define Next(i, u) for (re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define lb(x) (x) & (-(x))
#define ls k * 2
#define rs k * 2 + 1
#define maxn 500005
il int Mul(int a, int b) { return 1ll * a * b % mod; }
il int Inc(int a, int b) { return (a += b) >= mod ? a - mod : a; }
il int Dec(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
il int qpow(int a, int b) {
  int r = 1;
  while (b) {
    if (b & 1)
      r = Mul(r, a);
    a = Mul(a, a), b >>= 1;
  }
  return r;
}
int n, m, a[maxn], sum;
il bool cmp(int a, int v) { return a > v; }
signed main() {
  n = read(), m = read();
  rep(i, 1, n) a[i] = read();
  sort(a + 1, a + n + 1, cmp);
  rep(i, m + 1, n) sum += a[i];
  cout << sum;
  return 0;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

#define pb emplace_back
#define re return
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using namespace std;
using namespace __gnu_cxx;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265359;

int n, k;
int main() {
  // freopen("distance.in", "r", stdin);
  // freopen("distance.out", "w", stdout);
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  vector<ll> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(all(a));
  reverse(all(a));
  for (int i = 0; i < k; i++)
    a[i] = 0;
  cout << accumulate(all(a), 0ll);
}
/// ACTUAL CODE STARTS HERE:
//  I'm red in soul
/*
     ▄▀▀▀▄
▄███▀░◐░░░▌
    ▌░░░░░▐
    ▐░░░░░▐
    ▌░░░░░▐▄▄
    ▌░░░░▄▀▒▒▀▀▀▀▄
   ▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
   ▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
    ▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
      ▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
           ▌▌░▌▌
           ▌▌░▌▌
         ▄▄▌▌▄▌▌        */


Fixed submission:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

#define pb emplace_back
#define re return
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using namespace std;
using namespace __gnu_cxx;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265359;

int n, k;
int main() {
  // freopen("distance.in", "r", stdin);
  // freopen("distance.out", "w", stdout);
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  vector<ll> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(all(a));
  reverse(all(a));
  for (int i = 0; i < min(n, k); i++)
    a[i] = 0;
  cout << accumulate(all(a), 0ll);
}
/// ACTUAL CODE STARTS HERE:
//  I'm red in soul
/*
     ▄▀▀▀▄
▄███▀░◐░░░▌
    ▌░░░░░▐
    ▐░░░░░▐
    ▌░░░░░▐▄▄
    ▌░░░░▄▀▒▒▀▀▀▀▄
   ▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
   ▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
    ▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
      ▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
           ▌▌░▌▌
           ▌▌░▌▌
         ▄▄▌▌▄▌▌        */
Problem p02785 (C++)

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

int main() {
  int n, k;
  cin >> n >> k;
  vi h(n);
  rep(i, 0, n) cin >> h[i];

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

  ll ans = 0;

  rep(i, k - 1, n) { ans += h[i]; }

  cout << ans << endl;

  return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

int main() {
  int n, k;
  cin >> n >> k;
  vi h(n);
  rep(i, 0, n) cin >> h[i];

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

  ll ans = 0;

  rep(i, k, n) { ans += h[i]; }

  cout << ans << endl;

  return 0;
}
Problem p02785 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

const int MAX = 100000;

int main() {
  int N, K;
  int H[MAX];
  long long ans = 0;

  cin >> N >> K;

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

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

  sort(H, H + N);

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

  cout << ans << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

const int MAX = 200000;

int main() {
  int N, K;
  int H[MAX];
  long long ans = 0;

  cin >> N >> K;

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

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

  sort(H, H + N);

  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;

#define FAST                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);

#define MAXX 500005

#define PI 3.14159265358979323846264338327950

#define PB push_back
#define PF push_front
#define F first
#define S second

#define fixx(n) fixed << setprecision(n)

#define ll long long

#define mod 1000000007

int main() {
  FAST;
  int n, k;
  cin >> n >> k;
  int a[n + 6];
  ll int x = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    x += a[i];
  }
  sort(a, a + n);
  reverse(a, a + n);
  for (int i = 0; i < k; i++) {
    x -= a[i];
  }
  if (k >= n) {
    x = 0;
  }
  cout << x;
  return 0;
}

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

#define FAST                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);

#define MAXX 500005

#define PI 3.14159265358979323846264338327950

#define PB push_back
#define PF push_front
#define F first
#define S second

#define fixx(n) fixed << setprecision(n)

#define ll long long

#define mod 1000000007

int main() {
  FAST;
  int n, k;
  cin >> n >> k;
  int a[max(n, k) + 6] = {0};
  ll int x = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    x += a[i];
  }
  sort(a, a + n);
  reverse(a, a + n);
  for (int i = 0; i < k; i++) {
    x -= a[i];
  }
  if (k >= n) {
    x = 0;
  }
  cout << x;
  return 0;
}