Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define fastread() (ios_base::sync_with_stdio(false),cin.tie(NULL))
#define ll long long
#define sp " "
#define nl "\n"
 

#define ON(n,k)         ((n)| (1<<(k)))
#define OFF(n,k)        ((n)& (~(1<<(k))))
#define GetBit(n,k)     (((n)>> (k)) & 1 )
#define flibBit(n,k)    ((n)^(1<<(k)))
#define IsPowerOfTwo(n) (((n)&(n-1))==0)
#define IsOdd(n)        ((n) & 1 )


#define ONll(n,k)         ((n)| (1LL<<(k)))
#define OFFll(n,k)        ((n)& (~(1LL<<(k))))
#define GetBitll(n,k)     (((n)>> (k)) & 1LL )
#define flibBitll(n,k)    ((n)^(1LL<<(k)))
#define IsPowerOfTwoll(n) (((n)&(n-1))==0)
#define IsOddll(n)        ((n) & 1LL )


ll fast_power(ll base , ll pwr)
{
    if(pwr==0) return 1;
    ll p= fast_power(base, pwr/2);
    
    if(pwr%2 == 0) return p*p;

    return p*p*base;
}
ll sumtoN(ll n)
{
    return n*(n+1)/2;
}



const int N=1e5+5;

int n,m,u,v;
vector<int> adj[N];    
bool vis[N]; 
int depth[N];
int freq[N];



void DFS(int u,int dep)   
{
    vis[u]= true;
    depth[u]=dep;
    freq[dep]++;
    freq[dep]=freq[dep]%2;
    for(int v: adj[u])
    {
        if (!vis[v])
        {
            DFS(v,dep+1);
        }
    }

    
}

void solution()
{
    ll n,l,r;
    cin>>n>>l>>r;
    vector<int>v(n);
    for(int i=0; i<n; i++)
    {
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    ll res=0;
    for(int i=0; i<r-l+1; i++ )
    {
        res+=v[i];
    }
    cout<<res<<nl;

}


int main() {
    fastread();
 
    int t=1;
    cin>>t;
    while(t--) {
        solution();
    }
    
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define fastread() (ios_base::sync_with_stdio(false),cin.tie(NULL))
#define ll long long
#define sp " "
#define nl "\n"
 

#define ON(n,k)         ((n)| (1<<(k)))
#define OFF(n,k)        ((n)& (~(1<<(k))))
#define GetBit(n,k)     (((n)>> (k)) & 1 )
#define flibBit(n,k)    ((n)^(1<<(k)))
#define IsPowerOfTwo(n) (((n)&(n-1))==0)
#define IsOdd(n)        ((n) & 1 )


#define ONll(n,k)         ((n)| (1LL<<(k)))
#define OFFll(n,k)        ((n)& (~(1LL<<(k))))
#define GetBitll(n,k)     (((n)>> (k)) & 1LL )
#define flibBitll(n,k)    ((n)^(1LL<<(k)))
#define IsPowerOfTwoll(n) (((n)&(n-1))==0)
#define IsOddll(n)        ((n) & 1LL )


ll fast_power(ll base , ll pwr)
{
    if(pwr==0) return 1;
    ll p= fast_power(base, pwr/2);
    
    if(pwr%2 == 0) return p*p;

    return p*p*base;
}
ll sumtoN(ll n)
{
    return n*(n+1)/2;
}



const int N=1e5+5;

int n,m,u,v;
vector<int> adj[N];    
bool vis[N]; 
int depth[N];
int freq[N];



void DFS(int u,int dep)   
{
    vis[u]= true;
    depth[u]=dep;
    freq[dep]++;
    freq[dep]=freq[dep]%2;
    for(int v: adj[u])
    {
        if (!vis[v])
        {
            DFS(v,dep+1);
        }
    }

    
}

void solution()
{
    ll n,l,r;
    cin>>n>>l>>r;
    vector<int>v(n), seg , lp, rp;
    ll sumg=0;
    l--,r--;
    for(int i=0; i<n; i++)
    {
        cin>>v[i];
        if(i>=l && i<=r)
        {
            seg.push_back(v[i]);
            sumg+=v[i];
        }
        if(i<l)
        {
            lp.push_back(v[i]);
        }
        if(i>r) rp.push_back(v[i]);
    }
    sort(seg.begin(),seg.end(),greater<int>());
    sort(lp.begin(),lp.end());
    sort(rp.begin(),rp.end());

    ll lft=0,rght=0,currl=0,currr=0;
    for(int i=0; i<lp.size(); i++)
    {
        if(lp[i]<seg[currl])
        {
            lft+= (seg[currl]-lp[i]);
            currl++;
        }
        if(currl==seg.size()-1) break;
    }
    
    for(int i=0; i<rp.size(); i++)
    {
        if(rp[i]<seg[currr])
        {
            rght+=(seg[currr]-rp[i]);
            currr++;
        }
        if(currr==seg.size()) break;

    }
    ll ans=sumg-max(lft,rght);
   
    cout<<ans<<nl;

}


int main() {
    fastread();
 
    int t=1;
    cin>>t;
    while(t--) {
        solution();
    }
    
    return 0;
}