stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#pragma GCC optimize("O3")

#include<bits/stdc++.h> 

using namespace std;

using ll=long long;

typedef  unsigned long long int ull;

typedef pair<ll,ll> P;

template<class T> using V=vector<T>; 

#define fi first

#define se second

#define all(v) (v).begin(),(v).end()

const ll inf=(1e18);

//const ll mod=998244353;

const ll mod=1000000007;

//ios_base::sync_with_stdio(false);

//cin.tie(NULL);

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

ll lcm(ll c,ll d){return c/gcd(c,d)*d;}

struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

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 (a>b) { a=b; return 1; } return 0; }

int main(){

ll n,a,b,c,d;

cin>>n>>a>>b>>c>>d;

if(a>b)swap(a,b);

V<ll> suml1(n+1,0),suml2(n+1,0);

suml1[0]=a,suml2[0]=a;

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

    suml1[i+1]+=suml1[i]+d;

    suml2[i+1]+=suml2[i]-d;

}

V<ll> sumr1(n+1,0),sumr2(n+1,0);

sumr1[n-1]=b;sumr2[n-1]=b;

for(int i=n-1;i>0;i--){

    sumr1[i-1]+=sumr1[i]+d;

    sumr2[i-1]+=sumr2[i]-d;

}

bool ch=false;

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

    if(!(suml1[i]<sumr1[i]-(n-1-i)*(d-c)||suml1[i]-i*(d-c)>sumr1[i]))ch=true;

    if(!(suml1[i]<sumr2[i]||suml1[i]-i*(d-c)>sumr2[i]+(n-1-i)*(d-c)))ch=true;

}

if(ch)cout<<"YES"<<"\n";

else cout<<"NO"<<"\n";

}




// Optimized solution to the same problem (faster):
#pragma GCC optimize("O3")

#include<bits/stdc++.h> 

using namespace std;

using ll=long long;

using P=pair<ll,ll>;

template<class T> using V=vector<T>; 

#define fi first

#define se second

#define all(v) (v).begin(),(v).end()

const ll inf=(1e18);

//const ll mod=998244353;

const ll mod=1000000007;

ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}

ll LCM(ll c,ll d){return c/GCD(c,d)*d;}

struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

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 (a>b) { a=b; return 1; } return 0; }

int main(){

    ll n,a,b,c,d;

    cin>>n>>a>>b>>c>>d;

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

        ll acu=a+i*d,acd=a+i*c;

        if(!(acu<b+c*(n-i-1)||acd>b+d*(n-i-1))||!(acu<b-d*(n-i-1)||acd>b-c*(n-i-1))){

            cout<<"YES"<<"\n";

            return 0;

        }

        acu=a-i*c,acd=a-i*d;

        if(!(acu<b+c*(n-i-1)||acd>b+d*(n-i-1))||!(acu<b-d*(n-i-1)||acd>b-c*(n-i-1))){

            cout<<"YES"<<"\n";

            return 0;

        }

    }

    cout<<"NO"<<"\n";

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



#define FOR(i,a,b) for(int i = (a); i < (b); i++)

#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)

#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define FILL(a, value) memset(a, value, sizeof(a))



#define SZ(a) (int) a.size()

#define ALL(a) a.begin(),a.end()

#define PB push_back

#define MP make_pair



typedef long long LL;

typedef vector<int> VI;

typedef pair<int, int> PII;



const double PI = acos(-1.0);

const LL INF = 1000 * 1000 * 1000 + 7;

const LL LINF = INF * (LL)INF;



const int MAX = 500500;



LL L[MAX], R[MAX];

LL U[MAX], D[MAX];



bool intersect(LL x1, LL y1, LL x2, LL y2)

{

	if (y1 < x2) return false;

	if (y2 < x1) return false;

	return true;

}



int main()

{

	//freopen("in.txt", "r", stdin);

	//ios::sync_with_stdio(false); cin.tie(0);



	LL n, a, b, c, d;

	cin>>n>>a>>b>>c>>d;



	L[0] = R[0] = a;

	FOR (i, 1, n)

	{

		L[i] = L[i-1] + c;

		R[i] = R[i-1] + d;

	}



	U[n-1] = D[n-1] = b;

	RFOR(i, n-1, 0)

	{

		D[i] = D[i+1] + c;

		U[i] = U[i+1] + d;

	}



	FOR (i, 0, n)

	{

		if (intersect(L[i], R[i], D[i], U[i]))

		{

			cout<<"YES"<<endl;

			return 0;

		}

	}



	cout<<"NO"<<endl;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#define ll long long

using namespace std;

inline ll in(){

    ll x=0;bool f=0; char c;

    for (;(c=getchar())<'0'||c>'9';f=c=='-');

    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');

    return f?-x:x;

}

ll n,a,b,c,d,mxp,mnp,mxn,mnn;

int main()

{

	n=in();a=in();b=in();c=in();d=in();

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

		mnp=c*i;mxp=d*i;

		mxn=-c*(n-1ll-i);mnn=-d*(n-1ll-i);

		if (mnp+mnn<=b-a&&mxp+mxn>=b-a) {printf("YES");return 0;}

	}printf("NO");return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;



//#define _FILES

#define PB push_back

#define MP make_pair

#define X first

#define Y second



int main()

{

    ios_base::sync_with_stdio(false);



    #ifdef _FILES

        freopen("","r",stdin);

        freopen("","w",stdout);

    #endif // _FILES



    long long n, a, b, c, d;

    cin >> n >> a >> b >> c >> d;



    if (a > b) swap(a, b);

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

    {

        if ((b - a >= c *(n - 1 - i) - i * d) && (b - a <= -c * i + (n - 1 - i) * d))

        {

            cout << "YES" << endl;

            return 0;

        }

    }

    cout << "NO" << endl;

    return 0;

}




// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#define ll long long

using namespace std;

inline ll in(){

    ll x=0;bool f=0; char c;

    for (;(c=getchar())<'0'||c>'9';f=c=='-');

    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');

    return f?-x:x;

}

ll n,a,b,c,d,mxp,mnp,mxn,mnn;

int main()

{

	n=in();a=in();b=in();c=in();d=in();

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

		mnp=c*i;mxp=d*i;

		mxn=-c*(n-1ll-i);mnn=-d*(n-1ll-i);

		if (mnp+mnn<=b-a&&mxp+mxn>=b-a) {printf("YES");return 0;}

	}printf("NO");return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
/* ***********************************************

Author        :ACagain

Created Time  :2018/4/21 11:50:24

File Name     :dong.cpp

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



#include <iostream>

#include <cstdio>

#include <cstring>

#include <algorithm>

#include <string>

#include <stack>

#include <cmath>

#include <cstdlib>

#include <vector>

#include <queue>

#include <set>

#include <map>

using namespace std;



#define lson o<<1,l,m

#define rson o<<1|1,m+1,r

#define pii pair<int,int>

#define mp make_pair

#define ll long long

#define INF 0x3f3f3f3f

const int maxn=55;



int main()

{

    std::ios::sync_with_stdio(false);

    std::cin.tie(0);

    //freopen("in.txt","r",stdin);

    //freopen("out.txt","w",stdout);

	ll n,a,b,c,d;

	cin>>n>>a>>b>>c>>d;

	if(a>b)

	  swap(a,b);

	ll dis=b-a,num=n-1;

	ll r=num*d,l=num*c;

	int flag=0;

	int tt=c+d;

	if(dis>=l&&dis<=r)

	  flag=1;

	else

	for(int i=1;i<=num;i++)

	{

		l-=tt;

		r-=tt;

		if(dis>=l&&dis<=r)

		{

			flag=1;

			break;

		}

	}

	if(flag)

	  cout<<"YES"<<endl;

	else

	  cout<<"NO"<<endl;

	return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#define ll long long

using namespace std;

inline ll in(){

    ll x=0;bool f=0; char c;

    for (;(c=getchar())<'0'||c>'9';f=c=='-');

    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');

    return f?-x:x;

}

ll n,a,b,c,d,mxp,mnp,mxn,mnn;

int main()

{

	n=in();a=in();b=in();c=in();d=in();

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

		mnp=c*i;mxp=d*i;

		mxn=-c*(n-1ll-i);mnn=-d*(n-1ll-i);

		if (mnp+mnn<=b-a&&mxp+mxn>=b-a) {printf("YES");return 0;}

	}printf("NO");return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

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

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please





int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);





	int N;

	cin >> N;



	int P[100001];

	rep1(i, N) {

		int p;

		cin >> p;

		P[p] = i;

	}

	set<int> ST;

	ST.insert(N + 1);

	ST.insert(0);

	ll kotae = 0;

	for (int i = N; i >= 1; i--) {

		int p = P[i];



		auto itr1 = ST.lower_bound(p);

		auto itr2 = itr1--;



		int l = *itr1;

		int r = *itr2;



		int kari = 0;

		if (r != N + 1) {

			int r2 = *(++itr2);

			kari += (ll)(p - l) * (r2 - r);

		}

		if (l != 0) {

			int l2 = *(--itr1);

			kari += (ll)(r - p) * (l - l2);

		}

		kotae += (ll)kari * i;

		ST.insert(p);

	}



	co(kotae);



	Would you please return 0;

}

// Optimized solution to the same problem (faster):
//#include<bits/stdc++.h>

#include<cstdio>

using namespace std;

typedef long long ll;

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

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please



const int cm = 1 << 17;

char cn[cm], * ci = cn + cm, ct;

inline char getcha() {

	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }

	return *ci++;

}

inline int getint() {

	int A = 0;

	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';

	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';

	return A;

}



int main() {

	//cin.tie(0);

	//ios::sync_with_stdio(false);





	int N = getint();

	int A[100001];

	rep1(i, N) A[getint()] = i + 1;

	int daishou[100004] = {};

	daishou[0] = 2;

	daishou[N + 3] = N + 1;



	ll kotae = 0;

	rep1(i, N) {

		int a = A[i];

		int l = daishou[a - 1];

		if (!l) l = a;

		int r = daishou[a + 1];

		if (!r) r = a;

		int l2 = daishou[l - 2];

		if (!l2) l2 = l - 1;

		int r2 = daishou[r + 2];

		if (!r2) r2 = r + 1;



		kotae += ((ll)(r2 - r) * (a - l + 1) + (ll)(l - l2) * (r - a + 1)) * i;



		daishou[l] = r;

		daishou[r] = l;

	}



	printf("%lld", kotae);



	Would you please return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

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

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please



int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);





	int N;

	cin >> N;

	int A[100001];

	rep1(i, N) {

		int a;

		cin >> a;

		A[a] = i + 1;

	}

	int daishou[100004] = {};

	daishou[0] = 2;

	daishou[N + 3] = N + 1;



	ll kotae = 0;

	rep1(i, N) {

		int a = A[i];

		int l = daishou[a - 1];

		if (!l) l = a;

		int r = daishou[a + 1];

		if (!r) r = a;

		int l2 = daishou[l - 2];

		if (!l2) l2 = l - 1;

		int r2 = daishou[r + 2];

		if (!r2) r2 = r + 1;



		kotae += ((ll)(r2 - r) * (a - l + 1) + (ll)(l - l2) * (r - a + 1)) * i;



		daishou[l] = r;

		daishou[r] = l;

	}



	co(kotae);



	Would you please return 0;

}

// Optimized solution to the same problem (faster):
//#include<bits/stdc++.h>

#include<cstdio>

using namespace std;

typedef long long ll;

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

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please



const int cm = 1 << 17;

char cn[cm], * ci = cn + cm, ct;

inline char getcha() {

	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }

	return *ci++;

}

inline int getint() {

	int A = 0;

	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';

	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';

	return A;

}



int main() {

	//cin.tie(0);

	//ios::sync_with_stdio(false);





	int N = getint();

	int A[100001];

	rep1(i, N) A[getint()] = i + 1;

	int daishou[100004] = {};

	daishou[0] = 2;

	daishou[N + 3] = N + 1;



	ll kotae = 0;

	rep1(i, N) {

		int a = A[i];

		int l = daishou[a - 1];

		if (!l) l = a;

		int r = daishou[a + 1];

		if (!r) r = a;

		int l2 = daishou[l - 2];

		if (!l2) l2 = l - 1;

		int r2 = daishou[r + 2];

		if (!r2) r2 = r + 1;



		kotae += ((ll)(r2 - r) * (a - l + 1) + (ll)(l - l2) * (r - a + 1)) * i;



		daishou[l] = r;

		daishou[r] = l;

	}



	printf("%lld", kotae);



	Would you please return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
/*** author: yuji9511 ***/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<ll, ll> lpair;

const ll MOD = 1e9 + 7;

const ll INF = 1e18;

#define rep(i,m,n) for(ll i = (m); i < (n); i++)

#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)

#define print(x) cout << (x) << endl;

#define print2(x,y) cout << (x) << " " << (y) << endl;

#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};

typedef struct {

    ll idx;

    ll num;

    ll lv;

    ll rv;

} Q;

int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);

    ll N;

    cin >> N;

    ll P[100010];

    rep(i,0,N) cin >> P[i];

    vector<Q> arr(100010);

    arr[0] = (Q){0, -1, -1, 1};

    arr[1] = (Q){1, -1, 0, 2};

    rep(i,0,N){

        arr[i+2] = (Q){i+2, P[i], i+1, i+3};

    }

    arr[N+2] = (Q){N+2, -1, N+1, N+3};

    arr[N+3] = (Q){N+3, -1, N+2, N+4};

    ll pos[100010] = {};

    rep(i,0,N) pos[P[i]] = i+2;



    ll ans = 0;

    rep(n,1,N){

        ll p = pos[n];

        ll lv = arr[p].lv;

        ll lv2 = arr[lv].lv;

        ll rv = arr[p].rv;

        ll rv2 = arr[rv].rv;

        if(lv == 1){

            ans += n * (rv2 - rv) * (p - lv);

        }else if(rv == N+2){

            ans += n * (lv - lv2) * (rv - p);

        }else{

            ans += n * (lv - lv2) * (rv - p);

            ans += n * (rv2 - rv) * (p - lv);

        }

        arr[lv].rv = arr[p].rv;

        arr[rv].lv = arr[p].lv;

    }

    print(ans);







    

}

// Optimized solution to the same problem (faster):
/*** author: yuji9511 ***/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<ll, ll> lpair;

const ll MOD = 1e9 + 7;

const ll INF = 1e18;

#define rep(i,m,n) for(ll i = (m); i < (n); i++)

#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)

#define print(x) cout << (x) << endl;

#define print2(x,y) cout << (x) << " " << (y) << endl;

#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};

typedef struct {

    ll lv;

    ll rv;

} Q;

int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);

    ll N;

    cin >> N;

    ll P[100010];

    rep(i,0,N) cin >> P[i];

    vector<Q> arr(100010);

    arr[0] = (Q){-1, 1};

    arr[1] = (Q){0, 2};

    rep(i,0,N){

        arr[i+2] = (Q){i+1, i+3};

    }

    arr[N+2] = (Q){N+1, N+3};

    arr[N+3] = (Q){N+2, N+4};

    ll pos[100010] = {};

    rep(i,0,N) pos[P[i]] = i+2;



    ll ans = 0;

    rep(n,1,N){

        ll p = pos[n];

        ll lv = arr[p].lv;

        ll lv2 = arr[lv].lv;

        ll rv = arr[p].rv;

        ll rv2 = arr[rv].rv;

        if(lv != 1){

            ans += n * (lv - lv2) * (rv - p);

        }

        if(rv != N+2){

            ans += n * (rv2 - rv) * (p - lv);

        }



        arr[lv].rv = arr[p].rv;

        arr[rv].lv = arr[p].lv;

    }

    print(ans);







    

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <string>

#include <deque>

#include <queue>

#include <vector>

#include <algorithm>

using namespace std;

int main() {

	long long N, K;

	cin >> N >> K;

	priority_queue<long long,vector <long long>,greater<long long>> p;

	int tmp;

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

		cin >> tmp;

		p.push(tmp);

	}

	long long sum = 0;

	for (int j = 0; j < (N - K); j++) {

		sum +=  p.top() ;

		p.pop();

	}

	cout << sum;

		//system("pause");

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<algorithm>



#define ll long long



class FIO

{

public:

    template<typename T>FIO& operator >>(T& x){ _R(x);return *this; }

    template<typename T>FIO& operator <<(T x){ _W(x);return *this; }

private:

    char f,c,a[25],i;

    template<typename T>inline void _R(T& x)

    {

        for(f=0;(c=getchar())<48;c==45&&(f=1));

        for(x=c^48;(c=getchar())>47;x=(x<<3)+(x<<1)+(c^48));

        if(f)x=-x;

    }

    template<typename T>inline void _W(T x)

    {

        if(sizeof(x)==1){ putchar(x);return; }

        if(x<0)putchar(45),x=-x;

        if(x>99) {

            for(i=0;x;x/=10)a[i++]=x%10;

            while(i--)putchar(a[i]+48);

        } else if(x>9) putchar(x/10+48),putchar(x%10+48);

        else putchar(x+48);

    }

}io;





ll a[200005];



int main()

{

    ll n,k;

    io>>n>>k;

    for(int i=0;i<n;++i)io>>a[i];

    std::sort(a,a+n);

    ll ans=0;

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

        ans+=a[i];

    io<<ans;

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <vector>

#include <map>

#include <algorithm>

using namespace std;

typedef long long ll;

// using dfs or inorder traverse and savee them then iterate over them to ckeck they are sorted



// Complete the breakingRecords function below.

void minn(int a, int b)

{

    a > b ? cout << b : cout << a;

}



void solve(string s)

{

    

}



int main()

{

    int n, m , k;

    cin >> n >> k;

    vector <ll> v(n,0);

    vector <bool> b(150001,0);

    ll sum = 0;

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

        cin >> v[i];

    }

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

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

        sum += v[i];

    }

    cout << sum;

    



}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<algorithm>



#define ll long long



class FIO

{

public:

    template<typename T>FIO& operator >>(T& x){ _R(x);return *this; }

    template<typename T>FIO& operator <<(T x){ _W(x);return *this; }

private:

    char f,c,a[25],i;

    template<typename T>inline void _R(T& x)

    {

        for(f=0;(c=getchar())<48;c==45&&(f=1));

        for(x=c^48;(c=getchar())>47;x=(x<<3)+(x<<1)+(c^48));

        if(f)x=-x;

    }

    template<typename T>inline void _W(T x)

    {

        if(sizeof(x)==1){ putchar(x);return; }

        if(x<0)putchar(45),x=-x;

        if(x>99) {

            for(i=0;x;x/=10)a[i++]=x%10;

            while(i--)putchar(a[i]+48);

        } else if(x>9) putchar(x/10+48),putchar(x%10+48);

        else putchar(x+48);

    }

}io;





ll a[200005];



int main()

{

    ll n,k;

    io>>n>>k;

    for(int i=0;i<n;++i)io>>a[i];

    std::sort(a,a+n);

    ll ans=0;

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

        ans+=a[i];

    io<<ans;

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<math.h>

#include<algorithm>

#include<deque>

#include<vector>

#include <iostream>

#include<map>

#include<stack>

#include <string>

using namespace std;

int main()

{

    long long n;

        cin >> n;

        long long k, a=0;

        long long* m = new long long[n];

        long long i = 0;

        cin >> k;

        i = n-1;

        while (i>=0) {

            cin >> m[i];

            i--;

            

        }

        sort(m, m + n);

        for (long long i = n-k-1; i >=0 ; i--) {

            a += m[i];





        }

        cout << a << endl;





    return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<algorithm>



#define ll long long



class FIO

{

public:

    template<typename T>FIO& operator >>(T& x){ _R(x);return *this; }

    template<typename T>FIO& operator <<(T x){ _W(x);return *this; }

private:

    char f,c,a[25],i;

    template<typename T>inline void _R(T& x)

    {

        for(f=0;(c=getchar())<48;c==45&&(f=1));

        for(x=c^48;(c=getchar())>47;x=(x<<3)+(x<<1)+(c^48));

        if(f)x=-x;

    }

    template<typename T>inline void _W(T x)

    {

        if(sizeof(x)==1){ putchar(x);return; }

        if(x<0)putchar(45),x=-x;

        if(x>99) {

            for(i=0;x;x/=10)a[i++]=x%10;

            while(i--)putchar(a[i]+48);

        } else if(x>9) putchar(x/10+48),putchar(x%10+48);

        else putchar(x+48);

    }

}io;





ll a[200005];



int main()

{

    ll n,k;

    io>>n>>k;

    for(int i=0;i<n;++i)io>>a[i];

    std::sort(a,a+n);

    ll ans=0;

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

        ans+=a[i];

    io<<ans;

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;



int main()

{

ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);



long long n,k; cin>>n>>k;

long long arr[n];

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

    cin>>arr[i];



    sort(arr,arr+n,greater<>());

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

{

    arr[i]=0;

}

long long sum=0;

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

{

    sum+=arr[i];

}

cout<<sum<<endl;





return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<algorithm>



#define ll long long



class FIO

{

public:

    template<typename T>FIO& operator >>(T& x){ _R(x);return *this; }

    template<typename T>FIO& operator <<(T x){ _W(x);return *this; }

private:

    char f,c,a[25],i;

    template<typename T>inline void _R(T& x)

    {

        for(f=0;(c=getchar())<48;c==45&&(f=1));

        for(x=c^48;(c=getchar())>47;x=(x<<3)+(x<<1)+(c^48));

        if(f)x=-x;

    }

    template<typename T>inline void _W(T x)

    {

        if(sizeof(x)==1){ putchar(x);return; }

        if(x<0)putchar(45),x=-x;

        if(x>99) {

            for(i=0;x;x/=10)a[i++]=x%10;

            while(i--)putchar(a[i]+48);

        } else if(x>9) putchar(x/10+48),putchar(x%10+48);

        else putchar(x+48);

    }

}io;





ll a[200005];



int main()

{

    ll n,k;

    io>>n>>k;

    for(int i=0;i<n;++i)io>>a[i];

    std::sort(a,a+n);

    ll ans=0;

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

        ans+=a[i];

    io<<ans;

    return 0;

}

// Fastest known solution for this problem: