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

Solution 1 (runtime: 77 ms):
//Hara Hara Mahadev
#include<bits/stdc++.h>
using namespace std;
 
#define int 	long long
#define pi      3.1415926535897932384626433832795028841971693993751058
#define YES     cout<<"YES"<<"\n"
#define NO      cout<<"NO"<<"\n"
#define m1      cout<<-1<<"\n"
#define ssort(S)  sort((S).begin(),(S).end())
#define srev(S)   reverse((S).begin(),(S).end())
#define ll      long long
#define pb      push_back
#define vi      vector<int>
#define vvi 	vector<vector<int>>
#define vll      vector<long long>
#define vc      vector<char>
#define pii     pair<int,int>
#define vpii    vector<pair<int,int>>
#define vs	 vector<string>
#define all(arr)  (arr).begin(), (arr).end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define inp(v) for (auto & a : (v)) cin >> a;
#define endl "\n"
#define speed (ios_base:: sync_with_stdio(false),cin.tie(NULL))
#define mod 1000000007
 
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}  

int ceil_div(int a, int b) {
   return a / b + ((a ^ b) > 0 && a % b != 0);
}

int calcSum(vi &a, vi &b, int sz) {
    int i=0, j=0;
    int n = a.size(), m = b.size();
    int sum = 0;

    while(i<n && j<m && sz>0) {
        if(a[i] <= b[j]) {
            sum += a[i];    i++;
            sz--;
        }
        else {
            sum += b[j]; j++;
            sz--;
        }
    }

    while(j<m && sz--) {
        sum += b[j];
        j++;
    }

    return sum;
}
void solve()
{
   int n,l,r;
   cin >> n >> l >> r;
    
    vi left, mid, right;
    for(int i=1; i<=n; i++) {
        int x; cin >> x;
        if(i<l) left.pb(x);
        else if(i>r) right.pb(x);
        else    mid.pb(x);
    }
    ssort(left); ssort(mid); ssort(right);
    
   int mini = calcSum(left, mid, r-l+1);
   mini = min(mini, calcSum(right, mid, r-l+1));

   cout << mini << endl;
}

int t = 1;
int32_t main() {
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0),cin>>t;
    //cin >> t;
    while(t--){solve();}
    return 0;
}

Solution 2 (runtime: 171 ms):
#include <bits/stdc++.h>

#include <algorithm>

using namespace std;

typedef long long ll;

long long mod = 2 * 1000000 + 1;

long long prme[2 * 1000000 + 1] = {0};

void checkprime()

{

    while (mod--)

    {

        ll cnt = 0;

        if (mod <= 1)

            prme[mod] = 1;

        else

        {



            // Check how many numbers divide n in

            // range 2 to sqrt(n)

            for (int i = 2; i * i <= mod; i++)

            {

                if (mod % i == 0)

                    cnt++;

            }



            // if cnt is greater than 0 then n is

            // not prime

            if (cnt > 0)

                continue;



            // else n is prime

            else

                prme[mod] = 1;

        }

    }

}



bool exists(string aa)

{

    string bb = "1100";

    ll i = 0, j = 0, m = aa.size(), n = bb.size();

    while (i < m && j < n)

    {

        if (aa[i] == bb[j])

        {

            i++;

            j++;

            if (j == n)

            {

                return true;

            }

        }

        else

        {

            i = i - j + 1;

            j = 0;

        }

    }

    return false;

}

ll cnt = 0;

ll recursion(vector<ll> &v, ll r, ll l, ll sum)

{



    if (r == l)

    {

        return sum;

    }

    sum += v[r];

    // cout << sum << endl;

    return recursion(v, r + 1, l, sum);

}

ll ans = INT_MIN;



int main()

{

    ll a, b, c, d, e = 0, f, g, sum = 0, dum = 0, m, mn, t, mnt = 0, o, j, k, n, q, pt;

    char ch;

    vector<ll> v, v1;

    cin >> t;

    while (t--)

    {

        vector<ll> v, v1, v2;

        map<ll, ll> mp;

        bool flag = true;

        vector<pair<int, int>> pr;

        ll cnt = 0, sum = 0, dum = 0, mnt = 0, l = 0, r = 0, ans;

        ll mx = INT_MIN, mn = INT_MAX;

        char ch;

        string aa;

        cin >> a >> b >> c;

        for (int i = 0; i < a; i++)

        {

            cin >> d;

            v.push_back(d);

        }

        for (int i = 0; i < c; i++)

        {

            v1.push_back(v[i]);

        }

        for (int i = b - 1; i < a; i++)

        {

            v2.push_back(v[i]);

        }

        sort(v1.begin(), v1.end());

        sort(v2.begin(), v2.end());

        sum = accumulate(v1.begin(), v1.begin() + (c - b + 1), (long long)0);

        dum = accumulate(v2.begin(), v2.begin() + (c - b + 1),(long long) 0);

        cout << min(sum, dum) << endl;

    }

}