Problem: 2063B - Subsequence Update
Language: c++17 

Solution 1 (runtime: 93 ms):
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define co cout
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"
#define ci cin
#define ins insert
#define pb push_back
#define intl int
#define fi first
#define sc second
#define RODI ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define beg begin()
#define ed end()
using namespace std;
int a[1000009];
int b[1000009];
int ac[100];
const int mod = 1e9+7;
const int siz=1e5;
bool ch=false;
string s,s1,s2,s3,s4,s5;
int t=0,sum=0,i,w,m=0,n=0,n2,n3,n4,x,y=0,k=-1,st=0,cc=0,q,sb,sa,zero=0,rodi,idx,cost,l,d,mode=1,N=1e5+1,mx=-1,z,r,cnt,mid,r2,l2,mid2,sum2,mi,j=0,r1,l1,f,x1,x2,y2;
bool check;
int ar[4009][4009];
int inf=1e9;
string arr[1009];
int p[10000009];
set<int>Se;
vector<int>vec;
map<int,multiset<int>>sm;
vector<int>vec1,vec2,vec3;
stack<int>stk;
vector<int>dpi(2e5,0);
vector<int>adj[200009];
map<int,int>freq,fr1,fr2;
map<int,set<int> >ind;
ll power(ll x , ll y)
{

ll res = 1;
//x %= mod;
while(y > 0)
{
if (y%2)res = (res*x);//%mod;
y /= 2;
x = (x*x);//%mod;
}
return res;
}
deque<int>deq;
vector<int>vis(2e5+9,0);
vector<int>dis(2e5+9,0);
string solver(string s1,string s2)
{
string   s3="";
for(int i=0;i<s1.size();i++)
{
if(s1[i]==s2[i])
s3+='0';
else
s3+='1';
}
return s3;
}
map<int,set<int>>fse;
void solve()
{

    freq.clear();
    Se.clear();
    vec1.clear();
    vec2.clear();
    vec3.clear();
        ci>>n>>l>>r;
        sum=0;
        sum2=0;
        for(i=1;i<=n;i++)
        {
            ci>>a[i];
            if(i<l)
                vec1.pb(a[i]);
            else if(i>r)
                vec3.pb(a[i]);
            else{
                vec1.pb(a[i]);
                vec3.pb(a[i]);
        }
        }
        sort(vec1.rbegin(),vec1.rend());
        sort(vec3.rbegin(),vec3.rend());
        x=r-l+1;
        y=x;
       while(x--)
       {
           sum+=vec1.back();
           vec1.pop_back();
       }
       while(y--)
       {
           sum2+=vec3.back();
           vec3.pop_back();
       }
       co<<min(sum,sum2)<<endl;




}
/*


*/


int32_t main()
{
RODI;
t=1;
ci>>t;

while(t--){
solve();

}
return 0;
}


Solution 2 (runtime: 93 ms):
#include <bits/stdc++.h>
using namespace std;

/* ----- Macros ----- */
#define int long long
#define endl '\n'
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)x.size()
#define read(v)\
for (int i = 0; i < v.size(); ++i)\
    cin >> v[i]

/* ----- Typedefs ----- */
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;

/* ----- Constants ----- */
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const int dx[4] = {-1, 1, 0, 0}, dy[4] = {0, 0, -1, 1}; // Directions (4-way)

/* ----- Fast Input/Output ----- */
void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

/* ----- Debugging Tools ----- */
#define debug(x) cerr << #x << " = " << (x) << endl;
#define debug_vec(v) cerr << #v << " = "; for (auto val : v) cerr << val << " "; cerr << endl;

/* ----- Power Function (Binary Exponentiation) ----- */
int power(int base, int exp, int mod = MOD) {
    int res = 1;
    while (exp > 0) {
        if (exp % 2) res = res * base % mod;
        base = base * base % mod;
        exp /= 2;
    }
    return res;
}

/* ----- GCD & LCM ----- */
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return (a / gcd(a, b)) * b; }

/* ----- Sieve of Eratosthenes (Prime Numbers) ----- */
vector<int> sieve(int n) {
    vector<int> primes(n + 1, 1), prime_list;
    primes[0] = primes[1] = 0;
    for (int i = 2; i * i <= n; i++) {
        if (primes[i]) {
            for (int j = i * i; j <= n; j += i)
                primes[j] = 0;
        }
    }
    for (int i = 2; i <= n; i++) if (primes[i]) prime_list.pb(i);
    return prime_list;
}

/* ----- Solve Function (Per Test Case) ----- */
void solve() {
    int n, l, r; cin>>n>>l>>r;
    vi arr(n), prefix_arr, suffix_arr;
    read(arr);
    int len = r - l + 1;

    l--; r--;
    int pas = 0, sas = 0, range_sum = 0;

    for(int i = 0; i < n; i++){
        if(i >= l){
            suffix_arr.pb(arr[i]);
        }
        if(i <= r){
            prefix_arr.pb(arr[i]);
        }
        if(i >= l and i <= r){
            range_sum += arr[i];
        }
    }
    
    sort(all(prefix_arr));
    sort(all(suffix_arr));

    for(int i = 0; i < len; i++){
        pas += prefix_arr[i];
        sas += suffix_arr[i];  
    }
    

    cout << min({pas, range_sum, sas}) << endl;
}

/* ----- Main Function ----- */
int32_t main() {
    fast_io();
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}