ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()
const int mod = 1e9 + 10;
int n, m, q, k,d;
void solve() {
    cin>>n;
    vector<int>c(n+1),id(n+1);
    for (int i =1;i<=n;i++) {
        cin>>c[i];
        id[c[i]]=i;
    }
    set<int>st;
    for (int i =1;i<=n;i++) st.insert(i);
    int ans = 0;
    vector<pair<int,int> >v;
    for (int i =1;i<n;i++) {
        if (id[i+1]>id[i]&&id[i+1]!=id[i]+1) {
            v.push_back({i+1,i});
            v.push_back({i,i+1});
        }
    }
    for (int i =1;i<=n;i++) {
        int x = c[i];
        vector<int>a;
        for (auto j:st) {
            if (j<x) {
                ans++;
                a.push_back(j);
            }
            else break;
        }
        for (int k =a.size()-1;k>=0;k--) {
            v.push_back({x,a[k]});
        }
        st.erase(x);
    }
    for (int i =1;i<n;i++) {
        if (c[i]<c[i+1]) {
            ans+=2;
            v.push_back({c[i]+1,c[i]});
            v.push_back({c[i],c[i]+1});
        }
    }
    cout<<v.size()<<endl;
    for (int i =0;i<v.size();i++) {
        cout<<v[i].first<<" "<<v[i].second<<endl;
    }
}

signed main() {
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()
const int mod = 1e9 + 10;
int n, m, q, k,d;
void solve() {
    cin>>n;
    vector<int>c(n+1),id(n+1);
    for (int i =1;i<=n;i++) {
        cin>>c[i];
    }
    vector<pair<int,int>>ans;
    for (int i =1;i<=n;i++) {
        for (int j = 1;j<n;j++) {
            if (c[j]<c[j+1]) {
                swap(c[j],c[j+1]);
                ans.push_back({c[j],c[j+1]});
            }
        }
    }
    for (int i =1;i<=n;i++) {
        for (int j = 1;j<n;j++) {
            if (c[j]>c[j+1]) {
                swap(c[j],c[j+1]);
                ans.push_back({c[j],c[j+1]});
            }
        }
    }
    reverse(all(ans));
    cout<<ans.size()<<endl;
    for (auto i:ans) {
        cout<<i.first<<" "<<i.second<<endl;
    }
    cout<<endl;
}

signed main() {
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()
const int mod = 1e9 + 10;
int n, m, q, k,d;
void solve() {
    cin>>n;
    vector<int>c(n+1),id(n+1);
    for (int i =1;i<=n;i++) {
        cin>>c[i];
    }
    vector<pair<int,int>>ans;
    for (int i =1;i<=n;i++) {
        for (int j = 1;j<n;j++) {
            if (c[j]<c[j+1]) {
                swap(c[j],c[j+1]);
                ans.push_back({c[j],c[j+1]});
            }
        }
    }
    for (int i =1;i<=n;i++) {
        for (int j = 1;j<n;j++) {
            if (c[j]>c[j+1]) {
                swap(c[j],c[j+1]);
                ans.push_back({c[j],c[j+1]});
            }
        }
    }
    reverse(all(ans));
    cout<<ans.size()<<endl;
    for (auto i:ans) {
        cout<<i.first<<" "<<i.second<<endl;
    }
    cout<<endl;
}

signed main() {
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()
const int mod = 1e9 + 10;
int n, m, q, k,d;
void solve() {
    cin>>n;
    vector<int>c(n+1);
    for (int i =1;i<=n;i++) cin>>c[i];
    vector<pair<int ,int>>ans;
    for (int i =1;i<=n;i++) {
        for (int j =1;j<n;j++) {
            if (c[j]<c[j+1]) {
                swap(c[j],c[j+1]),
                ans.push_back({c[j],c[j+1]});
            }
        }
    }
    for (int i =1;i<=n;i++) {
        for (int j =1;j<n;j++) {
            if (c[j]>c[j+1]) {
                swap(c[j],c[j+1]),
                ans.push_back({c[j],c[j+1]});
            }
        }
    }
    cout<<ans.size()<<endl;
    reverse(all(ans));
    for (int i =0;i<ans.size();i++) {
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }
}

signed main() {
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()
const int mod = 1e9 + 10;
int n, m, q, k,d;
void solve() {
    cin>>n;
    vector<int>c(n+1);
    for (int i =1;i<=n;i++) cin>>c[i];
    set<int>st;
    for (int i =1;i<=n;i++) st.insert(i);
    int ans = 0;
    vector<pair<int,int> >v;
    for (int i =1;i<=n;i++) {
        int x = c[i];
        vector<int>a;
        for (auto j:st) {
            if (j<x) {
                ans++;
                a.push_back(j);
            }
            else break;
        }
        for (int k =a.size()-1;k>=0;k--) {
            v.push_back({x,a[k]});
        }
        st.erase(x);
    }
    for (int i =1;i<n;i++) {
        if (c[i]<c[i+1]) {
            ans+=2;
            v.push_back({c[i]+1,c[i]});
            v.push_back({c[i],c[i]+1});
        }
    }
    cout<<v.size()<<endl;
    for (int i =0;i<v.size();i++) {
        cout<<v[i].first<<" "<<v[i].second<<endl;
    }
}

signed main() {
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}


Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()
const int mod = 1e9 + 10;
int n, m, q, k,d;
void solve() {
    cin>>n;
    vector<int>c(n+1),id(n+1);
    for (int i =1;i<=n;i++) {
        cin>>c[i];
        id[c[i]]=i;
    }
    set<int>st;
    for (int i =1;i<=n;i++) st.insert(i);
    int ans = 0;
    vector<pair<int,int> >v;
    for (int i =1;i<n;i++) {
        if (id[i+1]>id[i]&&id[i+1]!=id[i]+1) {
            v.push_back({i+1,i});
            v.push_back({i,i+1});
        }
    }
    for (int i =1;i<=n;i++) {
        int x = c[i];
        vector<int>a;
        for (auto j:st) {
            if (j<x) {
                ans++;
                a.push_back(j);
            }
            else break;
        }
        for (int k =a.size()-1;k>=0;k--) {
            v.push_back({x,a[k]});
        }
        st.erase(x);
    }
    for (int i =1;i<n;i++) {
        if (c[i]<c[i+1]) {
            ans+=2;
            v.push_back({c[i]+1,c[i]});
            v.push_back({c[i],c[i]+1});
        }
    }
    cout<<v.size()<<endl;
    for (int i =0;i<v.size();i++) {
        cout<<v[i].first<<" "<<v[i].second<<endl;
    }
}

signed main() {
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()
const int mod = 1e9 + 10;
int n, m, q, k,d;
void solve() {
    cin>>n;
    vector<int>c(n+1);
    for (int i =1;i<=n;i++) cin>>c[i];
    vector<pair<int ,int>>ans;
    for (int i =1;i<=n;i++) {
        for (int j =1;j<n;j++) {
            if (c[j]<c[j+1]) {
                swap(c[j],c[j+1]),
                ans.push_back({c[j],c[j+1]});
            }
        }
    }
    for (int i =1;i<=n;i++) {
        for (int j =1;j<n;j++) {
            if (c[j]>c[j+1]) {
                swap(c[j],c[j+1]),
                ans.push_back({c[j],c[j+1]});
            }
        }
    }
    cout<<ans.size()<<endl;
    reverse(all(ans));
    for (int i =0;i<ans.size();i++) {
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }
}

signed main() {
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()
const int mod = 1e9 + 10;
int n, m, q, k,d;
void solve() {
    cin>>n;
    vector<int>c(n+1);
    for (int i =1;i<=n;i++) cin>>c[i];
    vector<pair<int ,int>>ans;
    for (int i =1;i<=n;i++) {
        for (int j =1;j<n;j++) {
            if (c[j]<c[j+1]) {
                swap(c[j],c[j+1]),
                ans.push_back({c[j],c[j+1]});
            }
        }
    }
    for (int i =1;i<=n;i++) {
        for (int j =1;j<n;j++) {
            if (c[j]>c[j+1]) {
                swap(c[j],c[j+1]),
                ans.push_back({c[j],c[j+1]});
            }
        }
    }
    cout<<ans.size()<<endl;
    reverse(all(ans));
    for (int i =0;i<ans.size();i++) {
        cout<<ans[i].second<<" "<<ans[i].first<<endl;
    }
}

signed main() {
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()
const int mod = 1e9 + 10;
int n, m, q, k,d;
void solve() {
    cin>>n;
    vector<int>c(n+1);
    for (int i =1;i<=n;i++) cin>>c[i];
    set<int>st;
    for (int i =1;i<=n;i++) st.insert(i);
    int ans = 0;
    vector<pair<int,int> >v;
    for (int i =1;i<=n;i++) {
        int x = c[i];
        vector<int>a;
        for (auto j:st) {
            if (j<x) {
                ans++;
                a.push_back(j);
            }
            else break;
        }
        for (int k =a.size()-1;k>=0;k--) {
            v.push_back({x,a[k]});
        }
        st.erase(x);
    }
    for (int i =1;i<n;i++) {
        if (c[i]<c[i+1]) {
            ans+=2;
            v.push_back({c[i]+1,c[i]});
            v.push_back({c[i],c[i]+1});
        }
    }
    cout<<v.size()<<endl;
    for (int i =0;i<v.size();i++) {
        cout<<v[i].first<<" "<<v[i].second<<endl;
    }
}

signed main() {
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define i64 long long
#define all(x) x.begin(), x.end()
using namespace std;
const i64 mod = 1000000007;

i64 n,m,k;

void solve()
{
    cin>>n;
    vector<int>a(n+1);
    for (int i =0;i<n;i++) cin>>a[i];
    i64 ans = -1e18,res = n;
    for (int i =0;i<n;i++) {
        i64 sum = 0;
        for (int i =0;i<res;i++) sum+=a[i];
        if (i==0) ans = max(ans,sum);
        else ans = max(ans,max(sum,-sum));
        for (int i =0;i<res;i++) a[i] = a[i+1]-a[i];
        res--;
    }
    cout<<ans<<endl;
}
int main()
{
    int t = 1;
    cin>>t;
    while (t--)
    {
        solve();
    }
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define i64 long long
#define all(x) x.begin(), x.end()
using namespace std;
const i64 mod = 1000000007;

i64 n,m,k;

void solve()
{
    cin>>n;
    vector<int>a(n+1);
    for (int i =0;i<n;i++) cin>>a[i];
    i64 ans = -1e18,res = n;
    for (int i =0;i<n;i++) {
        i64 sum = 0;
        for (int i =0;i<res;i++) sum+=a[i];
        if (i==0) ans = max(ans,sum);
        else ans = max(ans,max(sum,-sum));
        for (int i =0;i<res-1;i++) a[i] = a[i+1]-a[i];
        res--;
    }
    cout<<ans<<endl;
}
int main()
{
    int t = 1;
    cin>>t;
    while (t--)
    {
        solve();
    }
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define i64 long long
#define all(x) x.begin(), x.end()
using namespace std;
const i64 mod = 1000000007;

i64 n,m,k;

void solve()
{
    cin>>n;
    vector<int>a(n+1);
    for (int i =0;i<n;i++) cin>>a[i];
    i64 ans = -1e18,res = n;
    for (int i =0;i<n;i++) {
        i64 sum = 0;
        for (int i =0;i<res;i++) sum+=a[i];
        if (i==0) ans = max(ans,sum);
        else ans = max(ans,max(sum,-sum));
        for (int i =0;i<res-1;i++) a[i] = a[i+1]-a[i];
        res--;
    }
    cout<<ans<<endl;
}
int main()
{
    int t = 1;
    cin>>t;
    while (t--)
    {
        solve();
    }
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define i64 long long
#define all(x) x.begin(), x.end()
using namespace std;
const i64 mod = 1000000007;

i64 n,m,k;

void solve()
{
    cin>>n;
    vector<int>a(n+1);
    for (int i =1;i<=n;i++) cin>>a[i];
    i64 ans = -1e18,res = n;
    for (int i =1;i<=n;i++) {
        i64 sum = 0;
        for (int i =1;i<=res;i++) sum+=a[i];
        if (i==1) ans = max(ans,sum);
        else ans = max(ans,max(sum,-sum));
        for (int i =1;i<res;i++) a[i] = a[i+1]-a[i];
        res--;
    }
    cout<<ans<<endl;
}
int main()
{
    int t = 1;
    cin>>t;
    while (t--)
    {
        solve();
    }
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define i64 long long
#define all(x) x.begin(), x.end()
using namespace std;
const i64 mod = 1000000007;

i64 n,m,k;

void solve()
{
    cin>>n;
    vector<int>a(n+1);
    for (int i =1;i<=n;i++) cin>>a[i];
    i64 ans = -1e18,res = n;
    for (int i =1;i<=n;i++) {
        i64 sum = 0;
        for (int i =1;i<=res;i++) sum+=a[i];
        if (i==1) ans = max(ans,sum);
        else ans = max(ans,max(sum,-sum));
        for (int i =1;i<res;i++) a[i] = a[i+1]-a[i];
        res--;
    }
    cout<<ans<<endl;
}
int main()
{
    int t = 1;
    cin>>t;
    while (t--)
    {
        solve();
    }
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define i64 long long
#define all(x) x.begin(), x.end()
using namespace std;
const i64 mod = 1000000007;

i64 n,m,k;

void solve()
{
    cin>>n;
    vector<i64>a(n+1);
    for (int i =1;i<=n;i++) cin>>a[i];
    m = n;
    i64 ans = -1e18;
    for (int i =1;i<=n;i++) {
        i64 sum  =0;
        for (int i =1;i<=m;i++) sum = sum+a[i];
        if (i==1)ans = max(ans,sum);
        else {
            ans = max(ans,max(sum,-sum));
        }
        for (int i =1;i<m;i++) a[i] = a[i+1]-a[i];
        m--;
    }
    cout<<ans<<endl;
}
int main()
{
    int t = 1;
    cin>>t;
    while (t--)
    {
        solve();
    }
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define i64 long long
#define all(x) x.begin(), x.end()
using namespace std;
const i64 mod = 1000000007;

i64 n,m,k;

void solve()
{
    cin>>n;
    vector<int>a(n+1);
    for (int i =0;i<n;i++) cin>>a[i];
    i64 ans = -1e18,res = n;
    for (int i =0;i<n;i++) {
        i64 sum = 0;
        for (int i =0;i<res;i++) sum+=a[i];
        if (i==0) ans = max(ans,sum);
        else ans = max(ans,max(sum,-sum));
        for (int i =0;i<res;i++) a[i] = a[i+1]-a[i];
        res--;
    }
    cout<<ans<<endl;
}
int main()
{
    int t = 1;
    cin>>t;
    while (t--)
    {
        solve();
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


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

using namespace std;



int main() {

    int t;

    cin >> t;

    while (t--) {

        int n;

        cin >> n;

        int a[n];

        vector<vector<int>> v(n);   

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

            cin >> a[i];

        }

        if(is_sorted(a, a + n)) {

            cout << "YES" << endl;

            continue;

        }

        if (n > 1 && a[0] > a[1]) {

            cout << "NO" << endl;

            continue;

        }

        bool b = false;

        int c = 0;

        v[0].push_back(a[0]);

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

            if (a[i - 1] <= a[i] && b == false) {

                v[c].push_back(a[i]);

                b = true;

            }

            else if (b == true) {

                if (a[i] >= a[i - 1])

                    v[c].push_back(a[i]);

                else {

                    b = false;

                    c++;

                    v[c].push_back(a[i]);

                }

            }

            else {

                c++;

                v[c].push_back(a[i]);

            }

        }

        int sum = 0;

        bool poss = false;

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

            for (int j = 0; j < v[i].size(); j++) {

                if (j % 2 == 0)

                    sum += v[i][j];

                else

                    sum -= v[i][j];

            }

.

            if (!v[i + 1].empty() && sum <= v[i + 1][0]) {

                poss = true;

                v[i + 1][0] = v[i + 1][0] - sum;

            }

            else {

                poss = false;

                break;

            }

        }

        cout << (poss ? "YES" : "NO") << endl;

    }

    return 0;

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


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
#define ll long long
vector<int> v;
int a[N];
void solve(){
	int n,l,r;cin>>n>>l>>r;

	for(int i=1;i<=n;i++)cin>>a[i];
	//cout<<"test"<<endl;
	sort(a+1,a+l);sort(a+l,a+r+1);sort(a+r+1,a+n+1);
	
	ll res=0;
	int i=1;
	for(i=1;i<=n-r;i++){
		if(a[r+i]<a[r-i+1])res+=a[r+i];
		else break;
	}
	while(r-i+1>=l){
		res+=a[r-i+1];
		i++;
	}
	ll res2=0;

	 i=1;
	for(i=1;i<l;i++){
		if(a[i]<a[r+1-i])res2+=a[i];
		else break;
	}
	while(i<=r-l+1){
		res2+=a[r+1-i];
		i++;
	}
	res=min(res,res2);
	cout<<res<<endl;
}

int main(){
	int t;
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
#define ll long long
vector<int> v;
int a[N];
void solve(){
	int n,l,r;cin>>n>>l>>r;

	for(int i=1;i<=n;i++)cin>>a[i];
	//cout<<"test"<<endl;
	sort(a+1,a+l);sort(a+l,a+r+1);sort(a+r+1,a+n+1);
	
	ll res=0;
	int i=1;
	for(i=1;i<=n-r;i++){
		if(a[r+i]<a[r-i+1])res+=a[r+i];
		else break;
	}
	while(r-i+1>=l){
		res+=a[r-i+1];
		i++;
	}
	ll res2=0;

	 i=1;
	for(i=1;i<l;i++){
		if(a[i]<a[r+1-i])res2+=a[i];
		else break;
	}
	while(i<=r-l+1){
		res2+=a[r+1-i];
		i++;
	}
	res=min(res,res2);
	cout<<res<<endl;
}

int main(){
	int t;
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

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

using namespace std;

const int N=2e5+10;

#define ll long long

vector<int> v;

int a[N];

void solve(){

	int n,l,r;cin>>n>>l>>r;



	for(int i=1;i<=n;i++)cin>>a[i];

	//cout<<"test"<<endl;

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

	

	//for(int i=1;i<=n;i++)cout<<a[i]<<" ";

		//cout<<endl;



	ll res=0;

	int i=1;

	for(i=1;i<=n-r,r-i+1>=l;i++){

		cout<<"i="<<i<<endl;

		if(a[r+i]<a[r-i+1])res+=a[r+i];

		else break;

	}

	while(r-i+1>=l){

		res+=a[r-i+1];

		i++;

	}

	ll res2=0;



	 i=1;

	for(i=1;i<l,r+1-i>=l;i++){

		if(a[i]<a[r+1-i])res2+=a[i];

		else break;

	}

	while(i<=r-l+1){

		res2+=a[r+1-i];

		i++;

	}

	res=min(res,res2);

	cout<<res<<endl;

}



int main(){

	int t;

	cin>>t;

	while(t--){

		solve();

	}

	return 0;

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

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

using namespace std;

const int N=2e5+10;

#define ll long long

vector<int> v;

int a[N];

void solve(){

	int n,l,r;cin>>n>>l>>r;



	for(int i=1;i<=n;i++)cin>>a[i];

	//cout<<"test"<<endl;

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

	

	//for(int i=1;i<=n;i++)cout<<a[i]<<" ";

		//cout<<endl;



	ll res=0;

	int i=1;

	for(i=1;i<=n-r,r-i+1>=l;i++){

		cout<<"i="<<i<<endl;

		if(a[r+i]<a[r-i+1])res+=a[r+i];

		else break;

	}

	while(r-i+1>=l){

		res+=a[r-i+1];

		i++;

	}

	ll res2=0;



	 i=1;

	for(i=1;i<l,r+1-i>=l;i++){

		if(a[i]<a[r+1-i])res2+=a[i];

		else break;

	}

	while(i<=r-l+1){

		res2+=a[r+1-i];

		i++;

	}

	res=min(res,res2);

	cout<<res<<endl;

}



int main(){

	int t;

	cin>>t;

	while(t--){

		solve();

	}

	return 0;

}

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

using namespace std;

const int N=2e5+10;

#define ll long long

vector<int> v;

int a[N];

void solve(){

	int n,l,r;cin>>n>>l>>r;



	for(int i=1;i<=n;i++)cin>>a[i];

	//cout<<"test"<<endl;

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

	

	//for(int i=1;i<=n;i++)cout<<a[i]<<" ";

		//cout<<endl;



	ll res=0;

	int i=1;

	for(i=1;i<=n-r&&r-i+1>=l;i++){//????????????

		//cout<<"i="<<i<<" res="<<res<<endl;

		if(a[r+i]<a[r-i+1])res+=a[r+i];

		else break;

	}

	while(r-i+1>=l){

		//cout<<"i="<<i<<" res="<<res<<endl;

		res+=a[r-i+1];

		i++;

	}

	ll res2=0;



	 i=1;

	for(i=1;i<l&&r+1-i>=l;i++){

		if(a[i]<a[r+1-i])res2+=a[i];

		else break;

	}

	while(i<=r-l+1){

		res2+=a[r+1-i];

		i++;

	}

	//cout<<"res="<<res<<" res2="<<res2<<endl;

	res=min(res,res2);

	cout<<res<<endl;

}



int main(){

	int t;

	cin>>t;

	while(t--){

		solve();

	}

	return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


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

using namespace std;



#define ll long long int





ll mod_expo(ll a, ll b)

{

    if (b == 0)

        return 1;

    ll res = mod_expo(a, b / 2);

    res = res * res;

    if (b % 2 == 1)

        res = res * a;

    return res;

}



bool isPalindrome(vector<ll> &vec)

{

    // cout<<"hello"<<endl;

    int i = 0;

    int j = vec.size() - 1;

    while (i < j)

    {

        if (vec[i] != vec[j])

            return false;

        i++;

        j--;

    }

    return true;

}

vector<bool> SieveOfEratosthenes()

{

    vector<bool> prime(10000000 + 1, true);

    int n = 10000000;

    for (int p = 2; p * p <= n; p++)

    {

        if (prime[p] == true)

        {

            for (int i = p * p; i <= n; i += p)

                prime[i] = false;

        }

    }

    return prime;

}









int main()

{

    ll mod = 1e9 + 7;



    // question pdh lo sir

    // constraints bhi dhk lo sir

    // have trust on yourself ki jo tu kr rha hai best approach hai

    // dimag me test case lao aur ek baar uspr run krke dhklo sir



    // gcd of an array a[]={a,b,c,d} === gcd(a,b-a,c-a,d-a)

    // logic is simple and similar to gcd() of two no; i.e. gcd(a,b)=gcd(a,b-a);

    ll _;

    cin >> _;

    // vector<bool> prime=SieveOfEratosthenes();

    while (_--)

    {

        ll n;

        cin>>n;



        vector<ll> vec(n);

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

            cin>>vec[i];

        }

        bool isPossibel=true;



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

            if(vec[i]<vec[i-1] && vec[i]>vec[i+1]){

                isPossibel=false;

                break;

            }

            if(vec[i]>vec[i-1] && vec[i]>vec[i+1]){

                ll mini=min(vec[i],vec[i-1]);

                ll temp=vec[i]-mini;

                ll temp2=vec[i-1]-mini;



                if(temp<vec[i+1] && temp>temp2){

                    vec[i]=temp;

                    vec[i-1]=temp2;

                }

                else {

                    isPossibel=false;

                    break;

                }

            }

            else if(vec[i]<vec[i-1] && vec[i]<vec[i+1]){

                isPossibel=false;

                break;

            }

            else if(vec[i]>vec[i-1] && vec[i]<vec[i+1]){

                    vec[i+1]=vec[i+1]+vec[i-1] - vec[i];

                    vec[i]=0;

                    vec[i-1]=0;

            }

        }



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

            if(vec[i]>vec[i+1]){

                isPossibel=false;

                break;

            }

        }



        if(isPossibel){

            cout<<"YES"<<endl;

        }

        else {

            cout<<"NO"<<endl;

        }



        

    }



    return 0;



};