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

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

#define ll long long

#define ld long double

#define vi vector<int>

#define t(ok) ok?cout<< YES<<endl:cout<<NO<<endl;

#define vll vector<long long>

#define vpll vector <pair<ll,ll>>

#define mll map<long long, long long>

#define all(x) x.begin(), x.end()

#define forn(i,n) for(int i = 0; i < n; i++)

#define mii map<int, int>

#define f(i,a,b) for(ll i = a;i<b;i++)

#define vc vector<char>

#define py cout << "YES" << endl

#define pn cout << "NO" << endl

#define vb vector<bool>

#define invec for (int i=0;i<n;i++) {cin>>v[i];} 

#define print_arr(vec, sz) for(int zwzq = 0; zwzq < sz ; zwzq++){cout << vec[zwzq] << ' ';}cout << endl;

#define fori(i, a, c) for(int i = a ; i < c ; i++)

#define ford(i, n, a) for (int i = n ; i >= a ; i--)

#define print(vec) for(int zwzq = 0; zwzq < vec.size() ; zwzq++){cout << vec[zwzq] << ' ';}cout << endl;

#define print_pair(vec) for(int zwzq = 0; zwzq < vec.size() ; zwzq++){cout << '[' <<vec[zwzq].first << ',' << vec[zwzq].second << ']' << ' ';}cout << endl;

const ll mod = 998244353;

using namespace std;

long long mod_sub(long long a, long long b, long long m){a = a % m; b = b % m;return (((a - b) % m) + m) % m;}

long long powermod(long long x, long long y, long long p){

    long long res = 1;

    x = x % p;

    if (x == 0){return 0;}

    while (y > 0){

        if (y & 1)

            res = (res * x) % p;

        y = y >> 1;

        x = (x * x) % p;

    }

   return res;

}





//for first see soln,for second try reverse or smaller optimal method, BIT question write one or two example in bit then solve

// FIND BRUTE FORCE FIRST 

int main(){



    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);



    ll t;

    cin >> t;

    while (t--){

ll n,l,r;

    cin  >> n >> l>> r;

    vll v(n);

     for (int i=0;i<n;i++) {cin>>v[i];}

    if (r-l+1 == n){

        cout<<accumulate(all(v),0LL)<<endl;

    }

    else {

    

    multiset<int>a,b,c;

    for (int i=0;i<l;i++){

        a.insert(v[i]);

    }

    for(int i=l-1;i<r;i++){

        c.insert(v[i]);

    }

    for (int i=r;i<n;i++){

        b.insert(v[i]);

    }

    int size = r-l+1;

    auto it = c.begin();

    while (size--){

        a.insert(*it);

        it++;

    }

    auto kt = a.begin();

    int rr = r-l+1;

    while (rr--){

        b.insert(*kt);

        kt++;

    }

    ll a1 =0LL,a2 =0LL;

    int t = r-l+1;

    auto aaa = a.begin();

    auto bbb = b.begin();

    while (t--){

        a1 += *aaa;

        aaa++;

        a2 += *bbb;

        bbb++;

    }

    // cout<<a1<<" "<<a2<<endl;

    cout<<min(a1,a2)<<endl;

}



    }

    return 0;

}

Submission (verdict: Wrong answer on test 8):
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define vi vector<int>
#define t(ok) ok?cout<< YES<<endl:cout<<NO<<endl;
#define vll vector<long long>
#define vpll vector <pair<ll,ll>>
#define mll map<long long, long long>
#define all(x) x.begin(), x.end()
#define forn(i,n) for(int i = 0; i < n; i++)
#define mii map<int, int>
#define f(i,a,b) for(ll i = a;i<b;i++)
#define vc vector<char>
#define py cout << "YES" << endl
#define pn cout << "NO" << endl
#define vb vector<bool>
#define invec for (int i=0;i<n;i++) {cin>>v[i];} 
#define print_arr(vec, sz) for(int zwzq = 0; zwzq < sz ; zwzq++){cout << vec[zwzq] << ' ';}cout << endl;
#define fori(i, a, c) for(int i = a ; i < c ; i++)
#define ford(i, n, a) for (int i = n ; i >= a ; i--)
#define print(vec) for(int zwzq = 0; zwzq < vec.size() ; zwzq++){cout << vec[zwzq] << ' ';}cout << endl;
#define print_pair(vec) for(int zwzq = 0; zwzq < vec.size() ; zwzq++){cout << '[' <<vec[zwzq].first << ',' << vec[zwzq].second << ']' << ' ';}cout << endl;
const ll mod = 998244353;
using namespace std;
long long mod_sub(long long a, long long b, long long m){a = a % m; b = b % m;return (((a - b) % m) + m) % m;}
long long powermod(long long x, long long y, long long p){
    long long res = 1;
    x = x % p;
    if (x == 0){return 0;}
    while (y > 0){
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
   return res;
}


//for first see soln,for second try reverse or smaller optimal method, BIT question write one or two example in bit then solve
// FIND BRUTE FORCE FIRST 
int main(){

    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

    ll t;
    cin >> t;
    while (t--){


ll n,r,l;
    cin  >> n >>l>>r;
    l--;r--;
    vll v(n);
     for (int i=0;i<n;i++) {cin>>v[i];}
        multiset<int>a,b;
        for (int i = 0;i<=r;i++){
            a.insert(v[i]);
        }
        for (int i = l;i<n;i++){
            b.insert(v[i]);
        }
        int a1=0,a2=0;
        auto it = a.begin();
        auto jt = b.begin();
        int k = r-l+1;
        while (k--){
            a1 += *it;
            it++;
            a2 += *jt;
            jt++;
        }
        cout<<min(a1,a2)<<endl;

    }
    return 0;
}