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;
namespace MySpace{
    #define max(...) MyDearmax(__VA_ARGS__)
    template <typename T>
    T MyDearmax(T a, T b) {return a > b ? a : b;}
    template <typename F, typename... R>
    F MyDearmax(F f,R... r){return MyDearmax(f,MyDearmax(r...));}
    #define min(...) MyDearmin(__VA_ARGS__)
    template <typename T>
    T MyDearmin(T a, T b) {return a < b ? a : b;}
    template <typename F, typename... R>
    F MyDearmin(F f,R... r){return MyDearmin(f,MyDearmin(r...));}
    #define lowbit(x) (x&(-x))
//    #define sqrt __builtin_sqrtf //浣跨敤纭欢鍔犻€熺殑寮€鏂?
//    #ifdef ONLINE_JUDGE
//    #define getchar getchar_unlocked
//    #endif
    inline void read() {}
    template <typename T, typename... R>
    inline void read(T &x,R &... oth){
        x=0;T f=1;
        char c=getchar();
        while(c<'0' || c>'9') {
            if(c=='-') f=-1;
            c=getchar();
        }
        while(c>='0' && c<='9') x=(x<<1)+(x<<3)+(c&15),c=getchar();
        x*=f;
        read(oth...);
        return;
    }
    template<typename T>
    T qpow(T a,T n,T p){
        T res=1;
        while (n){
            if (n&1) res=1ll*res*a%p;
            a=1ll*a*a%p;
            n>>=1;
        }
        return res;
    }
    template<typename T>
    T gcd(T a,T b){return (b>0?gcd(b,a%b):a);}
    template<typename T>
    T exgcd(T a,T b,T& x,T& y){
    	if (b<=0ll){
    		x=1ll,y=0ll;
    		return a;
		}
		T t=x;
		T d=exgcd(b,a%b,y,x);
		y-=(a/b)*x;
		return d;
	}
	template<typename T>
	T inv(T a,T p){
		if (a==1) return 1ll;
		T x,y;
		if (exgcd(a,p,x,y)!=1ll) return -1ll;
		else return (x+p)%p;
	}
}
using namespace MySpace;
//const int INF=0x66CCFF66;
#define int long long
const int maxn=1e5+5;
int n,l,r;
int T;
int a[maxn];
signed main(){
	read(T);
	while (T--){
		read(n,l,r);
		for (int i=1;i<=n;i++) read(a[i]);
		sort(a+1,a+1+n);
		int ans=0;
		for (int i=l;i<=r;i++) ans+=a[i-l+1];
		printf("%lld\n",ans);
	}

	return 0;
}


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

using namespace std;

namespace MySpace{

    #define max(...) MyDearmax(__VA_ARGS__)

    template <typename T>

    T MyDearmax(T a, T b) {return a > b ? a : b;}

    template <typename F, typename... R>

    F MyDearmax(F f,R... r){return MyDearmax(f,MyDearmax(r...));}

    #define min(...) MyDearmin(__VA_ARGS__)

    template <typename T>

    T MyDearmin(T a, T b) {return a < b ? a : b;}

    template <typename F, typename... R>

    F MyDearmin(F f,R... r){return MyDearmin(f,MyDearmin(r...));}

    #define lowbit(x) (x&(-x))

//    #define sqrt __builtin_sqrtf //浣跨敤纭欢鍔犻€熺殑寮€鏂?

//    #ifdef ONLINE_JUDGE

//    #define getchar getchar_unlocked

//    #endif

    inline void read() {}

    template <typename T, typename... R>

    inline void read(T &x,R &... oth){

        x=0;T f=1;

        char c=getchar();

        while(c<'0' || c>'9') {

            if(c=='-') f=-1;

            c=getchar();

        }

        while(c>='0' && c<='9') x=(x<<1)+(x<<3)+(c&15),c=getchar();

        x*=f;

        read(oth...);

        return;

    }

    template<typename T>

    T qpow(T a,T n,T p){

        T res=1;

        while (n){

            if (n&1) res=1ll*res*a%p;

            a=1ll*a*a%p;

            n>>=1;

        }

        return res;

    }

    template<typename T>

    T gcd(T a,T b){return (b>0?gcd(b,a%b):a);}

    template<typename T>

    T exgcd(T a,T b,T& x,T& y){

    	if (b<=0ll){

    		x=1ll,y=0ll;

    		return a;

		}

		T t=x;

		T d=exgcd(b,a%b,y,x);

		y-=(a/b)*x;

		return d;

	}

	template<typename T>

	T inv(T a,T p){

		if (a==1) return 1ll;

		T x,y;

		if (exgcd(a,p,x,y)!=1ll) return -1ll;

		else return (x+p)%p;

	}

}

using namespace MySpace;

//const int INF=0x66CCFF66;

#define int long long

const int maxn=1e5+5;

int n,l,r;

int T;

int a[maxn];

signed main(){

	read(T);

	while (T--){

		read(n,l,r);

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

		if (l!=1) sort(a+1,a+1+l-1);

		if (r!=n) sort(a+1+r+1,a+1+n);

		sort(a+l,a+1+r,greater<int>());

		int delta=INT_MAX;

		int sb=0;

		for (int i=1,j=l,sa=0;i<l && j<=r;i++,j++) {

			sa+=a[i];sb+=a[j];

			//cout<<a[i]<<' '<<a[j]<<endl;

			delta=min(delta,sa-sb);

		}

		sb=0;

		for (int i=r+1,j=l,sa=0;i<=n && j<=r;i++,j++) {

			sa+=a[i];sb+=a[j];

			delta=min(delta,sa-sb);

		}

		//cout<<delta;

		sb=0;

		for (int i=l;i<=r;i++) sb+=a[i];

		printf("%lld\n",sb+min(delta,0ll));

	}



	return 0;

}