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

Previous submission (verdict: Wrong answer on test 1):
/*

░░░░█▐▄▒▒▒▌▌▒▒▌░▌▒▐▐▐▒▒▐▒▒▌▒▀▄▀▄░
░░░█▐▒▒▀▀▌░▀▀▀░░▀▀▀░░▀▀▄▌▌▐▒▒▒▌▐░
░░▐▒▒▀▀▄▐░▀▀▄▄░░░░░░░░░░░▐▒▌▒▒▐░▌
░░▐▒▌▒▒▒▌░▄▄▄▄█▄░░░░░░░▄▄▄▐▐▄▄▀░░
░░▌▐▒▒▒▐░░░░░░░░░░░░░▀█▄░░░░▌▌░░░
▄▀▒▒▌▒▒▐░░░░░░░▄░░▄░░░░░▀▀░░▌▌░░░
▄▄▀▒▐▒▒▐░░░░░░░▐▀▀▀▄▄▀░░░░░░▌▌░░░
░░░░█▌▒▒▌░░░░░▐▒▒▒▒▒▌░░░░░░▐▐▒▀▀▄
░░▄▀▒▒▒▒▐░░░░░▐▒▒▒▒▐░░░░░▄█▄▒▐▒▒▒
▄▀▒▒▒▒▒▄██▀▄▄░░▀▄▄▀░░▄▄▀█▄░█▀▒▒▒▒

*/
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;

template <class T> using ordered_set = tree<T, null_type,less<T>, rb_tree_tag, tree_order_statistics_node_update>; // use pair to implement multiordset

#define ll long long
#define vi vector<ll>
#define vll vector<long long>
#define vp vector<pair<ll,ll>>
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define vvi vector<vector<ll>>
#define prll(a) for(auto x:a){cout<<x<<" ";}cout<<endl;
#define pref(a) vll pref(a.size());pref[0]=a[0]; for(ll i=1;i<a.size();i++){pref[i]=pref[i-1]+a[i];} 
#define preff(a) vll preff(a.size());preff[0]=a[0]; for(ll i=1;i<a.size();i++){preff[i]=preff[i-1]+a[i];}
#define all(s) s.begin(), s.end()

long long binpow(long long a, long long b) {
if (b == 0)
 return 1;
 long long res = binpow(a, b / 2);
if (b % 2)
return res * res * a;
else
return res * res;
}

long long modbinpow(long long a, long long b, long long m) {
a %= m;
long long res = 1;
 while (b > 0) {
if (b & 1)
res = res * a % m;
a = a * a % m;
b >>= 1;
}
return res;
}

long long modbinmultiply(long long a, long long b, long long m) {
a %= m;
long long res = 0;
 while (b > 0) {
if (b & 1)
res = (res+a) % m; 
a = (a + a) % m;
b >>= 1;
}
return res;
}

vector<bool> sieve(ll n) {
    vector<bool> prime(n + 1, true);
    prime[0] = prime[1] = false;
    for (ll i = 2; i * i <= n; i++) {
        if (prime[i]) {
            for (ll j = i * i; j <= n; j += i)
                prime[j] = false;
        }
    }
   return prime;
}

vector<ll> lp(ll n){
   vector<bool> prime(n + 1, true);
   vi lp(n+1,0);
    prime[0] = prime[1] = false;
    for (ll i = 2; i < n; i++) {
        if (prime[i]) {
         lp[i]=i;
            for (ll j = 2*i; j < n; j += i){
              prime[j] = false;
            if(lp[j]==0){
               lp[j]=i;
            }
         }
        }
    }
   return lp;
}

vector<ll> hp(ll n){
   vector<bool> prime(n + 1, true);
   vi hp(n+1,0);
    prime[0] = prime[1] = false;
    for (ll i = 2; i < n; i++) {
        if (prime[i]) {
         hp[i]=i;
            for (ll j = 2*i; j < n; j += i){
               prime[j] = false;
               hp[j]=i;   
         }    
        }
    }
   return hp;
}

vector<vi> edges;
vector<vp> edgesw;
vi visited;
void dfs(ll n){
visited[n]=1;
for(ll i:edges[n]){
  if(!visited[i]){
     dfs(i);
  }
 }
}

vi level;
void bfs(ll source){
  queue<ll> q;
  q.push(source);
  visited[source]=1;
  while(!q.empty()){
    ll cur_v=q.front();
    q.pop();
    for(ll child:edges[cur_v]){
      if(!visited[child]){
        q.push(child);
        visited[child]=1;
        level[child]=level[cur_v]+1;
      }
    }
  }
}

int main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);

  ll t;
  cin>>t;
  while(t--)
  {
     ll n,l,r;
     cin>>n>>l>>r;
     l--;
     r--;
     vi v;
     vi bl;
     vi ar;
     for(ll i=0;i<n;i++){
        ll x;
        cin>>x;
        if(i<l){
            bl.push_back(x);
        }
        if(i>r){
            ar.push_back(x);
        }
        if(i>=l && i<=r){
             v.push_back(x);
        }
     }
     sort(all(bl));
     sort(all(ar));
     sort(all(v));
     ll a=accumulate(all(v),0ll);
     ll b=accumulate(all(v),0ll);
     cout<<a<<"\n";
     ll i=0;
     ll j=v.size()-1;
     while(i<bl.size() && bl[i]<v[j] && j>=0){
         a+=bl[i]-v[j];
         i++;
         j--;
     }
     i=0;
     j=v.size()-1;
     while(i<ar.size() && ar[i]<v[j] && j>=0){
         b+=ar[i]-v[j];
         i++;
         j--;
     }
     cout<<a<<" "<<b<<"\n";
     cout<<min(a,b)<<"\n";
  }

    return 0;
}

Submission (verdict: Accepted):
/*

░░░░█▐▄▒▒▒▌▌▒▒▌░▌▒▐▐▐▒▒▐▒▒▌▒▀▄▀▄░
░░░█▐▒▒▀▀▌░▀▀▀░░▀▀▀░░▀▀▄▌▌▐▒▒▒▌▐░
░░▐▒▒▀▀▄▐░▀▀▄▄░░░░░░░░░░░▐▒▌▒▒▐░▌
░░▐▒▌▒▒▒▌░▄▄▄▄█▄░░░░░░░▄▄▄▐▐▄▄▀░░
░░▌▐▒▒▒▐░░░░░░░░░░░░░▀█▄░░░░▌▌░░░
▄▀▒▒▌▒▒▐░░░░░░░▄░░▄░░░░░▀▀░░▌▌░░░
▄▄▀▒▐▒▒▐░░░░░░░▐▀▀▀▄▄▀░░░░░░▌▌░░░
░░░░█▌▒▒▌░░░░░▐▒▒▒▒▒▌░░░░░░▐▐▒▀▀▄
░░▄▀▒▒▒▒▐░░░░░▐▒▒▒▒▐░░░░░▄█▄▒▐▒▒▒
▄▀▒▒▒▒▒▄██▀▄▄░░▀▄▄▀░░▄▄▀█▄░█▀▒▒▒▒

*/
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;

template <class T> using ordered_set = tree<T, null_type,less<T>, rb_tree_tag, tree_order_statistics_node_update>; // use pair to implement multiordset

#define ll long long
#define vi vector<ll>
#define vll vector<long long>
#define vp vector<pair<ll,ll>>
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define vvi vector<vector<ll>>
#define prll(a) for(auto x:a){cout<<x<<" ";}cout<<endl;
#define pref(a) vll pref(a.size());pref[0]=a[0]; for(ll i=1;i<a.size();i++){pref[i]=pref[i-1]+a[i];} 
#define preff(a) vll preff(a.size());preff[0]=a[0]; for(ll i=1;i<a.size();i++){preff[i]=preff[i-1]+a[i];}
#define all(s) s.begin(), s.end()

long long binpow(long long a, long long b) {
if (b == 0)
 return 1;
 long long res = binpow(a, b / 2);
if (b % 2)
return res * res * a;
else
return res * res;
}

long long modbinpow(long long a, long long b, long long m) {
a %= m;
long long res = 1;
 while (b > 0) {
if (b & 1)
res = res * a % m;
a = a * a % m;
b >>= 1;
}
return res;
}

long long modbinmultiply(long long a, long long b, long long m) {
a %= m;
long long res = 0;
 while (b > 0) {
if (b & 1)
res = (res+a) % m; 
a = (a + a) % m;
b >>= 1;
}
return res;
}

vector<bool> sieve(ll n) {
    vector<bool> prime(n + 1, true);
    prime[0] = prime[1] = false;
    for (ll i = 2; i * i <= n; i++) {
        if (prime[i]) {
            for (ll j = i * i; j <= n; j += i)
                prime[j] = false;
        }
    }
   return prime;
}

vector<ll> lp(ll n){
   vector<bool> prime(n + 1, true);
   vi lp(n+1,0);
    prime[0] = prime[1] = false;
    for (ll i = 2; i < n; i++) {
        if (prime[i]) {
         lp[i]=i;
            for (ll j = 2*i; j < n; j += i){
              prime[j] = false;
            if(lp[j]==0){
               lp[j]=i;
            }
         }
        }
    }
   return lp;
}

vector<ll> hp(ll n){
   vector<bool> prime(n + 1, true);
   vi hp(n+1,0);
    prime[0] = prime[1] = false;
    for (ll i = 2; i < n; i++) {
        if (prime[i]) {
         hp[i]=i;
            for (ll j = 2*i; j < n; j += i){
               prime[j] = false;
               hp[j]=i;   
         }    
        }
    }
   return hp;
}

vector<vi> edges;
vector<vp> edgesw;
vi visited;
void dfs(ll n){
visited[n]=1;
for(ll i:edges[n]){
  if(!visited[i]){
     dfs(i);
  }
 }
}

vi level;
void bfs(ll source){
  queue<ll> q;
  q.push(source);
  visited[source]=1;
  while(!q.empty()){
    ll cur_v=q.front();
    q.pop();
    for(ll child:edges[cur_v]){
      if(!visited[child]){
        q.push(child);
        visited[child]=1;
        level[child]=level[cur_v]+1;
      }
    }
  }
}

int main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);

  ll t;
  cin>>t;
  while(t--)
  {
     ll n,l,r;
     cin>>n>>l>>r;
     l--;
     r--;
     vi v;
     vi bl;
     vi ar;
     for(ll i=0;i<n;i++){
        ll x;
        cin>>x;
        if(i<l){
            bl.push_back(x);
        }
        if(i>r){
            ar.push_back(x);
        }
        if(i>=l && i<=r){
             v.push_back(x);
        }
     }
     sort(all(bl));
     sort(all(ar));
     sort(all(v));
     ll a=accumulate(all(v),0ll);
     ll b=accumulate(all(v),0ll);
   
     ll i=0;
     ll j=v.size()-1;
     while(i<bl.size() && bl[i]<v[j] && j>=0){
         a+=bl[i]-v[j];
         i++;
         j--;
     }
     i=0;
     j=v.size()-1;
     while(i<ar.size() && ar[i]<v[j] && j>=0){
         b+=ar[i]-v[j];
         i++;
         j--;
     }
     cout<<min(a,b)<<"\n";
  }

    return 0;
}