ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


Submission (verdict: Compilation error):
#include<bits/stdc++.h>
using namespace std;
#define fr(ii,ss,tt) for(int ii=ss;ii<=tt;ii++)
#define rf(ii,ss,tt) for(int ii=ss;ii>=tt;ii--)
#define pii pair<int,int>
#define pt printf
#define x first
#define y second
#define all(a) begin(a),end(a)
#define pb push_back
#define eb emplace_back
#define siz(x) ((int)size(x))
#ifdef UFILE
#define file(f1,f2) (f1!=""&&freopen(f1,"r",stdin),f2!=""&&freopen(f2,"w",stdout))
#else
#define file(...) 0
#endif
#ifdef DEBUG
#include DEBUG
#else
#define assert(...) 0
#define Z(...) 0
#define ZZ(...) 0
#endif
typedef long long LL;
typedef __int128 Int;
template<typename T>bool tomax(T&x,const T&y){if(x<y)return x=y,true;return false;}
template<typename T>bool tomin(T&x,const T&y){if(x>y)return x=y,true;return false;}
inline void rd(auto&x,auto&...y){char ch;bool f=0;while(!isdigit(ch=getchar()))if(ch=='-')f=1;x=0;do{x=(x<<1)+(x<<3)+(ch^48);}while(isdigit(ch=getchar()));if(f)x=-x;if constexpr(sizeof...(y))rd(y...);}
inline void wtl(auto&x,auto&...y){cout<<x;if constexpr(sizeof...(y))cout<<' ',wt(y...);else cout<<'\n';}

const int N=1e6+33;
int n,k,a[N];
signed main(){
	ios::sync_with_stdio(0);
	int T;
	rd(T);
	while(T--){
		rd(n,k);
		if(k==n){
			pt("1\n");continue;
		}
		map<int,int>mp;
		fr(i,1,n){
			rd(a[i]);
			mp[a[i]]++;
		}
		priority_queue<pii,vector<pii>,greater<pii>>q;
		for(auto[v,c]:mp){
			q.push({c,v});
		}
		while(1){
			auto[c,v]=q.top();
			if(c>k)break;
			q.pop();
			k-=c;
		}
		pt("%d\n",q.size());
	}
	return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 2):
#include<bits/stdc++.h>
using namespace std;
#define fr(ii,ss,tt) for(int ii=ss;ii<=tt;ii++)
#define rf(ii,ss,tt) for(int ii=ss;ii>=tt;ii--)
#define pii pair<int,int>
#define pt printf
#define x first
#define y second
#define all(a) begin(a),end(a)
#define pb push_back
#define eb emplace_back
#define siz(x) ((int)size(x))
#ifdef UFILE
#define file(f1,f2) (f1!=""&&freopen(f1,"r",stdin),f2!=""&&freopen(f2,"w",stdout))
#else
#define file(...) 0
#endif
#ifdef DEBUG
#include DEBUG
#else
#define assert(...) 0
#define Z(...) 0
#define ZZ(...) 0
#endif
typedef long long LL;
template<typename T>bool tomax(T&x,const T&y){if(x<y)return x=y,true;return false;}
template<typename T>bool tomin(T&x,const T&y){if(x>y)return x=y,true;return false;}
inline void rd(auto&x,auto&...y){char ch;bool f=0;while(!isdigit(ch=getchar()))if(ch=='-')f=1;x=0;do{x=(x<<1)+(x<<3)+(ch^48);}while(isdigit(ch=getchar()));if(f)x=-x;if constexpr(sizeof...(y))rd(y...);}
inline void wtl(auto&x,auto&...y){cout<<x;if constexpr(sizeof...(y))cout<<' ',wt(y...);else cout<<'\n';}

const int N=1e6+33;
int n,k,a[N];
signed main(){
	ios::sync_with_stdio(0);
	int T;
	rd(T);
	while(T--){
		rd(n,k);
		if(k==n){
			pt("1\n");continue;
		}
		map<int,int>mp;
		fr(i,1,n){
			rd(a[i]);
			mp[a[i]]++;
		}
		priority_queue<pii,vector<pii>,greater<pii>>q;
		for(auto[v,c]:mp){
			q.push({c,v});
		}
		while(1){
			auto[c,v]=q.top();
			if(c>k)break;
			q.pop();
			k-=c;
		}
		pt("%d\n",q.size());
	}
	return 0;
}

Submission (verdict: Compilation error):
#include<bits/stdc++.h>
using namespace std;
#define fr(ii,ss,tt) for(int ii=ss;ii<=tt;ii++)
#define rf(ii,ss,tt) for(int ii=ss;ii>=tt;ii--)
#define pii pair<int,int>
#define pt printf
#define x first
#define y second
#define all(a) begin(a),end(a)
#define pb push_back
#define eb emplace_back
#define siz(x) ((int)size(x))
#ifdef UFILE
#define file(f1,f2) (f1!=""&&freopen(f1,"r",stdin),f2!=""&&freopen(f2,"w",stdout))
#else
#define file(...) 0
#endif
#ifdef DEBUG
#include DEBUG
#else
#define assert(...) 0
#define Z(...) 0
#define ZZ(...) 0
#endif
typedef long long LL;
typedef __int128 Int;
template<typename T>bool tomax(T&x,const T&y){if(x<y)return x=y,true;return false;}
template<typename T>bool tomin(T&x,const T&y){if(x>y)return x=y,true;return false;}
inline void rd(auto&x,auto&...y){char ch;bool f=0;while(!isdigit(ch=getchar()))if(ch=='-')f=1;x=0;do{x=(x<<1)+(x<<3)+(ch^48);}while(isdigit(ch=getchar()));if(f)x=-x;if constexpr(sizeof...(y))rd(y...);}
inline void wtl(auto&x,auto&...y){cout<<x;if constexpr(sizeof...(y))cout<<' ',wt(y...);else cout<<'\n';}

const int N=1e6+33;
int n,k,a[N];
signed main(){
	ios::sync_with_stdio(0);
	int T;
	rd(T);
	while(T--){
		rd(n,k);
		
		map<int,int>mp;
		fr(i,1,n){
			rd(a[i]);
			mp[a[i]]++;
		}if(k==n){
			pt("1\n");continue;
		}
		priority_queue<pii,vector<pii>,greater<pii>>q;
		for(auto[v,c]:mp){
			q.push({c,v});
		}
		while(1){
			auto[c,v]=q.top();
			if(c>k)break;
			q.pop();
			k-=c;
		}
		pt("%d\n",q.size());
	}
	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>



using namespace std;



const int N=100010;



typedef long long ll;



int a[N];

ll sum[N];



int main()

{

    int T;

    cin>>T;

    while(T--)

    {

        memset(a,0,sizeof a);

        memset(sum,0,sizeof sum);

        int n,l,r;

        cin>>n>>l>>r;

        

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

        {

            scanf("%d",&a[i]);

        }

        

        sort(a+1,a+n+1);

        

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

        {

            sum[i]=sum[i-1]+a[i];

        }

        

        printf("%lld\n",sum[r-l+1]);

    }

    

    return 0;

}

Submission (verdict: Accepted):
#include<bits/stdc++.h>



using namespace std;



const int N=100010;



typedef long long ll;



int a[N],b[N];

ll sum1[N],sum2[N];



int main()

{

    int T;

    cin>>T;

    while(T--)

    {

        memset(a,0,sizeof a);

        memset(b,0,sizeof b);

        memset(sum1,0,sizeof sum1);

        memset(sum2,0,sizeof sum2);

        int n,l,r;

        cin>>n>>l>>r;

        

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

        {

            scanf("%d",&a[i]);

        }

        

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

        {

            b[i-l+1]=a[i];

        }

        

        sort(a+1,a+r+1);

        sort(b+1,b+n-l+2);

        

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

        {

            sum1[i]=sum1[i-1]+a[i];

            sum2[i]=sum2[i-1]+b[i];

        }

        

        printf("%lld\n",min(sum1[r-l+1],sum2[r-l+1]));

    }

    

    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>



using namespace std;



const int N=100010;



typedef long long ll;



int a[N];

ll sum[N];



int main()

{

    int T;

    cin>>T;

    while(T--)

    {

        memset(a,0,sizeof a);

        memset(sum,0,sizeof sum);

        int n,l,r;

        cin>>n>>l>>r;

        

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

        {

            scanf("%d",&a[i]);

        }

        

        sort(a+1,a+n+1);

        

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

        {

            sum[i]=sum[i-1]+a[i];

        }

        

        printf("%lld\n",sum[r-l+1]-sum[0]);

    }

    

    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>



using namespace std;



const int N=100010;



typedef long long ll;



int a[N];

ll sum[N];



int main()

{

    int T;

    cin>>T;

    while(T--)

    {

        memset(a,0,sizeof a);

        memset(sum,0,sizeof sum);

        int n,l,r;

        cin>>n>>l>>r;

        

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

        {

            scanf("%d",&a[i]);

        }

        

        sort(a+1,a+n+1);

        

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

        {

            sum[i]=sum[i-1]+a[i];

        }

        

        printf("%lld\n",sum[r-l+1]);

    }

    

    return 0;

}



Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>



using namespace std;



const int N=100010;



typedef long long ll;



int a[N];

ll sum[N];



int main()

{

    int T;

    cin>>T;

    while(T--)

    {

        memset(a,0,sizeof a);

        memset(sum,0,sizeof sum);

        int n,l,r;

        cin>>n>>l>>r;

        

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

        {

            scanf("%d",&a[i]);

        }

        

        sort(a+1,a+n+1);

        

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

        {

            sum[i]=sum[i-1]+a[i];

        }

        

        printf("%lld\n",sum[r-l+1]);

    }

    

    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>



using namespace std;



const int N=100010;



typedef long long ll;



int a[N];

ll sum[N];



int main()

{

    int T;

    cin>>T;

    while(T--)

    {

        memset(a,0,sizeof a);

        memset(sum,0,sizeof sum);

        int n,l,r;

        cin>>n>>l>>r;

        

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

        {

            scanf("%d",&a[i]);

        }

        

        sort(a+1,a+n+1);

        

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

        {

            sum[i]=sum[i-1]+a[i];

        }

        

        printf("%lld\n",sum[r-l+1]-sum[0]);

    }

    

    return 0;

}



Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>



using namespace std;



const int N=100010;



typedef long long ll;



int a[N];

ll sum[N];



int main()

{

    int T;

    cin>>T;

    while(T--)

    {

        memset(a,0,sizeof a);

        memset(sum,0,sizeof sum);

        int n,l,r;

        cin>>n>>l>>r;

        

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

        {

            scanf("%d",&a[i]);

        }

        

        sort(a+1,a+n+1);

        

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

        {

            sum[i]=sum[i-1]+a[i];

        }

        

        printf("%lld\n",sum[r-l+1]);

    }

    

    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 1):
#include<iostream>

#include<vector>



using namespace std;



solve(){

	int n;

	bool out = false;

	cin >> n;

	vector<int> a(n);

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

		cin>>a[i];

	}

	

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

		int mn = min(a[i], a[i-1]);

		a[i] -= mn;

		a[i-1] -= mn;

	}

	

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

		if(a[i+1] < a[i]){

			cout<<"NO"<<endl;

			out = true;

			break;

		}

	}

	

	if(!out) cout<<"YES"<<endl;

}



int main(){

	int t;

	cin >> t;

	

	while(t--){

		solve();

	}

	

	return 0;

} 





Submission (verdict: Accepted):
#include<iostream>

#include<vector>



using namespace std;



void solve(){

	int n;

	bool out = false;

	cin >> n;

	vector<int> a(n);

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

		cin>>a[i];

	}

	

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

		int mn = min(a[i], a[i-1]);

		a[i] -= mn;

		a[i-1] -= mn;

	}

	

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

		if(a[i+1] < a[i]){

			cout<<"NO"<<endl;

			out = true;

			break;

		}

	}

	

	if(!out) cout<<"YES"<<endl;

}



int main(){

	int t;

	cin >> t;

	

	while(t--){

		solve();

	}

	

	return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

Previous submission (verdict: Runtime error on test 1):
#include<iostream>

#include<vector>



using namespace std;



int a[200003];



solve(){

	int n;

	bool out = false;

	cin >> n;

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

		cin>>a[i];

	}

	

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

		int mn = min(a[i], a[i-1]);

		a[i] -= mn;

		a[i-1] -= mn;

	}

	

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

		if(a[i+1] < a[i]){

			cout<<"NO"<<endl;

			out = true;

			break;

		}

	}

	

	if(!out) cout<<"YES"<<endl;

}



int main(){

	int t;

	cin >> t;

	

	while(t--){

		solve();

	}

	

	return 0;

} 







Submission (verdict: Runtime error on test 1):
#include<iostream>

#include<vector>



using namespace std;



int a[200003];



solve(){

	int n;

	bool out = false;

	cin >> n;

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

		cin>>a[i];

	}

	

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

		int mn = min(a[i], a[i-1]);

		a[i] -= mn;

		a[i-1] -= mn;

	}

	

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

		if(a[i+1] < a[i]){

			cout<<"NO"<<endl;

			out = true;

			break;

		}

	}

	

	if(!out) cout<<"YES"<<endl;

}



int main(){

	int t;

	cin >> t;

	

	while(t--){

		solve();

	}

	

	return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


Submission (verdict: Runtime error on test 1):
#include<iostream>

#include<vector>



using namespace std;



int a[200003];



solve(){

	int n;

	bool out = false;

	cin >> n;

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

		cin>>a[i];

	}

	

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

		int mn = min(a[i], a[i-1]);

		a[i] -= mn;

		a[i-1] -= mn;

	}

	

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

		if(a[i+1] < a[i]){

			cout<<"NO"<<endl;

			out = true;

			break;

		}

	}

	

	if(!out) cout<<"YES"<<endl;

}



int main(){

	int t;

	cin >> t;

	

	while(t--){

		solve();

	}

	

	return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

Previous submission (verdict: Runtime error on test 1):
#include<iostream>

#include<vector>



using namespace std;



int a[200003];



solve(){

	int n;

	bool out = false;

	cin >> n;

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

		cin>>a[i];

	}

	

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

		int mn = min(a[i], a[i-1]);

		a[i] -= mn;

		a[i-1] -= mn;

	}

	

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

		if(a[i+1] < a[i]){

			cout<<"NO"<<endl;

			out = true;

			break;

		}

	}

	

	if(!out) cout<<"YES"<<endl;

}



int main(){

	int t;

	cin >> t;

	

	while(t--){

		solve();

	}

	

	return 0;

} 





Submission (verdict: Time limit exceeded on test 1):
#include<iostream>

#include<vector>



using namespace std;



solve(){

	int n;

	bool out = false;

	cin >> n;

	vector<int> a(n);

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

		cin>>a[i];

	}

	

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

		int mn = min(a[i], a[i-1]);

		a[i] -= mn;

		a[i-1] -= mn;

	}

	

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

		if(a[i+1] < a[i]){

			cout<<"NO"<<endl;

			out = true;

			break;

		}

	}

	

	if(!out) cout<<"YES"<<endl;

}



int main(){

	int t;

	cin >> t;

	

	while(t--){

		solve();

	}

	

	return 0;

}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 7):
#include <iostream>
#include <map>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <iomanip>
using namespace std;
int main() {
    int nn;
    cin >> nn;
    while(nn--){
        int sw=1;
        string a;
        cin >> a;
        while(sw){
            sw=0;
            for(int i=a.length()-1;i>=1;i--){
                string tmp1{a[i]};
                string tmp2{a[i-1]};
                int tmp3=stoi(tmp1);
                int tmp4=stoi(tmp2);
                
                if(tmp4!=9 && tmp3>tmp4+1){
                    a[i]=a[i-1];
                    tmp3--;
                    string tmp5=to_string(tmp3);
                    a[i-1]=tmp5[0];
                    sw=1;
                }
            }
        }
        cout << a << endl;
    }
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 8):
#include <iostream>
#include <map>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <iomanip>
using namespace std;
int main() {
    int nn;
    cin >> nn;
    while(nn--){
        int sw=1;
        string a;
        cin >> a;
        while(sw){
            sw=0;
            for(int i=a.length()-1;i>=1;i--){
                int tmp3 = a[i]-'0';
                int tmp4 = a[i-1]-'0';
                if(tmp4!=9 && tmp3>tmp4+1){
                    a[i]=a[i-1];
                    tmp3--;
                    string tmp5=to_string(tmp3);
                    a[i-1]=tmp5[0];
                    sw=1;
                }
            }
        }
        cout << a << endl;
    }
}

Submission (verdict: Accepted):
#include <iostream>
#include <map>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <iomanip>
using namespace std;
int main() {
    int nn;
    cin >> nn;
    while(nn--){
        int sw=1;
        string a;
        cin >> a;
        int tmp=a.length()-1;
        while(sw){
            sw=0;
            for(int i=0;i<a.length()-1;i++){
                int tmp3 = a[i]-'0';
                int tmp4 = a[i+1]-'0';
                if(tmp4!=0 && tmp3!=9 && tmp3<tmp4-1){
                    a[i+1]=a[i];
                    tmp4--;
                    string tmp5=to_string(tmp4);
                    a[i]=tmp5[0];
                    sw=1;
                }
            }
        }
        cout << a << endl;
    }
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 7):
#include <iostream>
#include <map>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <iomanip>
using namespace std;
int main() {
    int nn;
    cin >> nn;
    while(nn--){
        int sw=1;
        string a;
        cin >> a;
        while(sw){
            sw=0;
            for(int i=a.length()-1;i>=1;i--){
                string tmp1{a[i]};
                string tmp2{a[i-1]};
                int tmp3=stoi(tmp1);
                int tmp4=stoi(tmp2);
                
                if(tmp4!=9 && tmp3>tmp4+1){
                    a[i]=a[i-1];
                    tmp3--;
                    string tmp5=to_string(tmp3);
                    a[i-1]=tmp5[0];
                    sw=1;
                }
            }
        }
        cout << a << endl;
    }
}


Submission (verdict: Time limit exceeded on test 8):
#include <iostream>
#include <map>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <iomanip>
using namespace std;
int main() {
    int nn;
    cin >> nn;
    while(nn--){
        int sw=1;
        string a;
        cin >> a;
        while(sw){
            sw=0;
            for(int i=a.length()-1;i>=1;i--){
                int tmp3 = a[i]-'0';
                int tmp4 = a[i-1]-'0';
                if(tmp4!=9 && tmp3>tmp4+1){
                    a[i]=a[i-1];
                    tmp3--;
                    string tmp5=to_string(tmp3);
                    a[i-1]=tmp5[0];
                    sw=1;
                }
            }
        }
        cout << a << endl;
    }
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 8):
#include <iostream>

#include <vector>

#include <algorithm>



using namespace std;



int main() {

    int t; cin >> t;



    for (; t > 0; t--) {

        int n, l, r;

        cin >> n >> l >> r;



        vector<long int> a, left, right;

        long int x;

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

            cin >> x;

            a.push_back(x);

        }



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

            left.push_back(a[i]);

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

            right.push_back(a[i]);



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

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



        long int size = r - l + 1, suml = 0, sumr = 0;

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

            if (left.size() > i)

                suml += left[i];

            if (right.size() > i)

                sumr += right[i];

        }



        cout << min(suml, sumr) << "\n";

    }







    return 0;

}

Submission (verdict: Accepted):
#include <iostream>

#include <vector>

#include <algorithm>



using namespace std;



int main() {

    int t; cin >> t;



    for (; t > 0; t--) {

        int n, l, r;

        cin >> n >> l >> r;



        vector<long long int> a, left, right;

        long long int x;

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

            cin >> x;

            a.push_back(x);

        }



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

            left.push_back(a[i]);

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

            right.push_back(a[i]);



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

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



        long long int size = r - l + 1, suml = 0, sumr = 0;

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

            if (left.size() > i)

                suml += left[i];

            if (right.size() > i)

                sumr += right[i];

        }



        cout << min(suml, sumr) << "\n";

    }







    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 8):
#include <iostream>

#include <vector>

#include <algorithm>



using namespace std;



int main() {

    int t; cin >> t;



    for (; t > 0; t--) {

        int n, l, r;

        cin >> n >> l >> r;



        vector<int> a, left, right;

        int x;

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

            cin >> x;

            a.push_back(x);

        }



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

            left.push_back(a[i]);

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

            right.push_back(a[i]);



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

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



        int size = r - l + 1, suml = 0, sumr = 0;

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

            suml += left[i];

            sumr += right[i];

        }



        cout << min(suml, sumr) << "\n";

    }







    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 8):
#include <iostream>

#include <vector>

#include <algorithm>



using namespace std;



int main() {

    int t; cin >> t;



    for (; t > 0; t--) {

        int n, l, r;

        cin >> n >> l >> r;



        vector<int> a, left, right;

        int x;

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

            cin >> x;

            a.push_back(x);

        }



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

            left.push_back(a[i]);

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

            right.push_back(a[i]);



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

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



        int size = r - l + 1, suml = 0, sumr = 0;

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

            suml += left[i];

            sumr += right[i];

        }



        cout << min(suml, sumr) << "\n";

    }







    return 0;

}

Submission (verdict: Wrong answer on test 8):
#include <iostream>

#include <vector>

#include <algorithm>



using namespace std;



int main() {

    int t; cin >> t;



    for (; t > 0; t--) {

        int n, l, r;

        cin >> n >> l >> r;



        vector<long int> a, left, right;

        long int x;

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

            cin >> x;

            a.push_back(x);

        }



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

            left.push_back(a[i]);

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

            right.push_back(a[i]);



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

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



        long int size = r - l + 1, suml = 0, sumr = 0;

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

            if (left.size() > i)

                suml += left[i];

            if (right.size() > i)

                sumr += right[i];

        }



        cout << min(suml, sumr) << "\n";

    }







    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 7):
#include <bits/stdc++.h>
using namespace std;
bool isIncreasing(int n, vector<int> nums){
    for(int i=0; i<n-1; i++){
        if(nums[i]> nums[i+1]){
            return false;
        }
    }
    return true;
}

int main() {
	int t,n;
	cin>>t;
	while(t--){
	    cin>>n;
	    vector<int> nums(n);
	    for(int i=0; i<n; i++){
	        cin>>nums[i];
	    }
	    for(int i=0; i<n-1; i++){
	        int sub = min(nums[i], nums[i+1]);
	        nums[i] = nums[i]-sub;
	         nums[i+1] = nums[i+1]-sub;
	         if(isIncreasing(n, nums)){
	             cout<<"YES"<<endl;
	             break;
	         }
	         else if(i==n-2){
	             cout<<"NO"<<endl;
	         }
	    }
	    
	    
	    
	    
	}
    
}