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

Code 1:
#include <bits/stdc++.h>

using namespace std;



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

#define vi vector<int>

#define ln long long int

#define test int t; cin >> t; while (t--)

#define ll long long



#ifndef ONLINE_JUDGE

#define debug(x) cerr << #x << " -> "; _print(x); cerr << endl

#else

#define debug(x)

#endif



void _print(int a) { cerr << a << " "; }

void _print(long long a) { cerr << a << " "; }

void _print(char a) { cerr << a << " "; }

void _print(string a) { cerr << a << " "; }

void _print(bool a) { cerr << a << " "; }

template <class T, class V> void _print(pair<T, V> p) { cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}"; }

template <class T> void _print(vector<T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }

template <class T> void _print(set<T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }

template <class T> void _print(multiset<T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }

template <class T, class V> void _print(map<T, V> v) { cerr << "[ "; for (auto i : v) { _print(i); cerr << " "; } cerr << "]"; }

template <class T> void _print(pair<T, T> p) { cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}"; }

template <class T, class V> void _print(multimap<T, V> v) { cerr << "[ "; for (auto i : v) { _print(i); cerr << " "; } cerr << "]"; }

template <class T> void _print(unordered_set<T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }

template <class T> void _print(unordered_multiset<T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }

template <class T, class V> void _print(unordered_map<T, V> v) { cerr << "[ "; for (auto i : v) { _print(i); cerr << " "; } cerr << "]"; }



void solve(){

  int n,l,r; cin >> n >> l >> r;

  vector<int>v(n);

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



  l--,r--;

  vector<int>left;

  vector<int>right;

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

    left.push_back(v[i]);

  }

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

    right.push_back(v[i]);

  }



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

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



  // int sum1 = accumulate(left.begin(),left.begin()+ (int)(r-l+1),0LL);

  // int sum2 = accumulate(right.begin(),right.begin()+ (int)(r-l+1),0LL);

  int sum1 = 0;

  int sum2 = 0;



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

    sum1+=left[i];

  }

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

    sum2+=right[i];

  }

  cout << min(sum1,sum2) << endl;



}

int main() {

#ifndef ONLINE_JUDGE

    freopen("input.txt","r",stdin);

    freopen("output.txt","w",stdout);

    freopen("Error.txt", "w", stderr);

#endif



test{

   solve();

}



    return 0;

}



Code 2:
#include <bits/stdc++.h>

using namespace std;



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

#define vi vector<int>

#define ln long long int

#define test int t; cin >> t; while (t--)

#define ll long long



#ifndef ONLINE_JUDGE

#define debug(x) cerr << #x << " -> "; _print(x); cerr << endl

#else

#define debug(x)

#endif



void _print(int a) { cerr << a << " "; }

void _print(long long a) { cerr << a << " "; }

void _print(char a) { cerr << a << " "; }

void _print(string a) { cerr << a << " "; }

void _print(bool a) { cerr << a << " "; }

template <class T, class V> void _print(pair<T, V> p) { cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}"; }

template <class T> void _print(vector<T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }

template <class T> void _print(set<T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }

template <class T> void _print(multiset<T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }

template <class T, class V> void _print(map<T, V> v) { cerr << "[ "; for (auto i : v) { _print(i); cerr << " "; } cerr << "]"; }

template <class T> void _print(pair<T, T> p) { cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}"; }

template <class T, class V> void _print(multimap<T, V> v) { cerr << "[ "; for (auto i : v) { _print(i); cerr << " "; } cerr << "]"; }

template <class T> void _print(unordered_set<T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }

template <class T> void _print(unordered_multiset<T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }

template <class T, class V> void _print(unordered_map<T, V> v) { cerr << "[ "; for (auto i : v) { _print(i); cerr << " "; } cerr << "]"; }



void solve(){

  int n,l,r; cin >> n >> l >> r;

  vector<int>v(n);

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



  l--,r--;

  vector<int>left;

  vector<int>right;

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

    left.push_back(v[i]);

  }

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

    right.push_back(v[i]);

  }



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

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



  // int sum1 = accumulate(left.begin(),left.begin()+ (int)(r-l+1),0LL);

  // int sum2 = accumulate(right.begin(),right.begin()+ (int)(r-l+1),0LL);

  ll sum1 = 0;

  ll sum2 = 0;



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

    sum1+=left[i];

  }

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

    sum2+=right[i];

  }

  cout << min(sum1,sum2) << endl;



}

int main() {

#ifndef ONLINE_JUDGE

    freopen("input.txt","r",stdin);

    freopen("output.txt","w",stdout);

    freopen("Error.txt", "w", stderr);

#endif



test{

   solve();

}



    return 0;

}



Answer: 2