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

Previous submission (verdict: Wrong answer on test 8):
#include<bits/stdc++.h>
#include<unordered_map>	
using namespace std;
#define ll long long int
#define vi vector<ll> 
#define all(v) v.begin() , v.end()
#define srt(v) sort(v.begin(), v.end())
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"
#define co(c) cout<<c<<"\n"
#define rn return 
#define acc(v) accumulate(v.begin() , v.end() , 0)


template<class T, class U> istream& operator>>(istream &is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T> istream& operator>>(istream& is, vector<T>& vec) { for(auto &x : vec) cin >> x; return is; }
template<class T, class U> ostream& operator<<(ostream &os, const pair<T, U>& p) { os << "<" << p.first << "," << p.second << ">"; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for(auto x : vec) os << x << " "; return os; }

  void solve(){
        int n, l, r;
        cin >> n >> l >> r;
        l--;
        
        vector<int> arr(n);
        for (int i = 0; i < n; i++) {
            cin >> arr[i];
        }
        
        vector<int> brr = arr;
        sort(brr.begin() + l, brr.end());
        
        vector<int> crr = arr;
        sort(crr.begin(), crr.begin() + r, greater<int>());
        
        int sum_brr = 0, sum_crr = 0;
        for (int i = l; i < r; i++) {
            sum_brr += brr[i];
            sum_crr += crr[i];
        }
        
        cout << min(sum_brr, sum_crr) << "\n";
  }

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

   #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int testcases;
    cin >> testcases;

    //testcases = 1;
    while (testcases--) {
       solve();
    }
    
    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
#include<unordered_map>	
using namespace std;
#define ll long long int
#define vi vector<ll> 
#define all(v) v.begin() , v.end()
#define srt(v) sort(v.begin(), v.end())
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"
#define co(c) cout<<c<<"\n"
#define rn return 
#define acc(v) accumulate(v.begin() , v.end() , 0)


template<class T, class U> istream& operator>>(istream &is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T> istream& operator>>(istream& is, vector<T>& vec) { for(auto &x : vec) cin >> x; return is; }
template<class T, class U> ostream& operator<<(ostream &os, const pair<T, U>& p) { os << "<" << p.first << "," << p.second << ">"; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for(auto x : vec) os << x << " "; return os; }

  void solve(){
        ll n, l, r;
        cin >> n >> l >> r;
        l--;
        
        vi arr(n);
        for (int i = 0; i < n; i++) {
            cin >> arr[i];
        }
        
        vi brr = arr;
        sort(brr.begin() + l, brr.end());
        
        vi crr = arr;
        sort(crr.begin(), crr.begin() + r, greater<int>());
        
        ll sum_brr = 0, sum_crr = 0;
        for (int i = l; i < r; i++) {
            sum_brr += brr[i];
            sum_crr += crr[i];
        }
        
        cout << min(sum_brr, sum_crr) << "\n";
  }

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

   #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int testcases;
    cin >> testcases;

    //testcases = 1;
    while (testcases--) {
       solve();
    }
    
    return 0;
}