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

Previous submission (verdict: Wrong answer on test 2):
#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{
                vec2.pb(a[i]);
                sum+=a[i];
                sum2+=a[i];
        }
        }
        sort(vec1.begin(),vec1.begin());
        sort(vec2.begin(),vec2.begin());
        sort(vec3.begin(),vec3.begin());
        for(i=vec2.size()-1;i>=0&&vec1.size();i--)
        {
                    if(vec2[i]<vec1.back())
                        break;
                    sum-=vec2[i];
                    sum+=vec1.back();
                    vec1.pop_back();
        }


  for(i=vec2.size()-1;i>=0&&vec3.size();i--)
        {
                    if(vec2[i]<vec3.back())
                        break;
                    sum2-=vec2[i];
                    sum2+=vec3.back();
                    vec3.pop_back();
        }
        co<<min(sum,sum2)<<endl;




}
/*


*/


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

while(t--){
solve();

}
return 0;
}


Submission (verdict: Wrong answer on test 2):
#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{
                vec2.pb(a[i]);
                sum+=a[i];
                sum2+=a[i];
        }
        }
        sort(vec1.rbegin(),vec1.rbegin());
        sort(vec2.begin(),vec2.begin());
        sort(vec3.rbegin(),vec3.rbegin());
        for(i=vec2.size()-1;i>=0&&vec1.size();i--)
        {
                    if(vec2[i]<vec1.back())
                        break;
                        if(vec2[i]>vec1.back()){
                    sum-=vec2[i];
                    sum+=vec1.back();
                    vec1.pop_back();
                        }
        }


  for(i=vec2.size()-1;i>=0&&vec3.size();i--)
        {
                    if(vec2[i]<vec3.back())
                        break;
                        if(vec2[i]>vec3.back()){
                    sum2-=vec2[i];
                    sum2+=vec3.back();
                    vec3.pop_back();
                        }
        }
        co<<min(sum,sum2)<<endl;




}
/*


*/


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

while(t--){
solve();

}
return 0;
}