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

Previous submission (verdict: Wrong answer on test 2):
/*

    author : abhishrestha

*/

#include <bits/stdc++.h>

using namespace std;



#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

const long long MOD = 1e9 + 7;

const long long N = 1e7;

#define no cout << "NO" << endl

#define yes cout << "YES" << endl

#define int long long

#define endl "\n"



int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }

int lcm(int a, int b) { return a / gcd(a, b) * b; }

#define maxx(vector) (*max_element((vector).begin(), (vector).end()))

#define minn(vector) (*min_element((vector).begin(), (vector).end()))



#ifndef abhishrestha

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

#else 

#define debug(x)

#endif



void _print(int t) {cerr << t;}

void _print(string t) {cerr << t;}

void _print(char t) {cerr << t;}

void _print(double t) {cerr << t;}



template <class T, class V> void _print(pair <T, V> p);

template <class T> void _print(vector <T> v);

template <class T> void _print(set <T> v);

template <class T, class V> void _print(map <T, V> v);

template <class T> void _print(multiset <T> v);

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 << "]";}







/*





<------------------------------MAIN CODE STARTS HERE-------------------------------->





*/ 



void solve() {

    int n , l , r;

    cin >> n >> l >> r;



    vector<int> arr(n);

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

        cin >> arr[i];

    }

    vector<int> arr2 = arr;

    int cnt = r - l + 1;

    l--;

    r--;

    int cnt2 = cnt, sum = 0;

    sort(arr.begin() , arr.begin() + r);

    int i = 0;

    while(cnt--) {

        sum = sum + arr[i];

        i++;

    }

    i = l;

    int ans = sum;

    sum = 0;

    cnt = cnt2;



    sort(arr2.begin() + l , arr2.end());

    while (cnt--) {

        sum = sum + arr2[i];

        i++;

    }

    ans = min (ans , sum);

    cout << ans << endl;

}



int32_t main() {

#ifndef abhishrestha

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

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

#endif

    FAST_IO;

    int tt = 1;

    cin >> tt;

    for( int tc = 1; tc <= tt; tc++ ) {

        solve();

    }

    return 0;

}

Submission (verdict: Wrong answer on test 2):
/*
    author : abhishrestha
*/
#include <bits/stdc++.h>
using namespace std;

#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
const long long MOD = 1e9 + 7;
const long long N = 1e7;
#define no cout << "NO" << endl
#define yes cout << "YES" << endl
#define int long long
#define endl "\n"

int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
#define maxx(vector) (*max_element((vector).begin(), (vector).end()))
#define minn(vector) (*min_element((vector).begin(), (vector).end()))

#ifndef abhishrestha
#define debug(x) cerr << #x << " "; _print(x); cerr << endl;
#else 
#define debug(x)
#endif

void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(double t) {cerr << t;}

template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
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 << "]";}



/*


<------------------------------MAIN CODE STARTS HERE-------------------------------->


*/ 

void solve() {
    int n , l , r;
    cin >> n >> l >> r;
    l--,r--;
    vector<int> arr(n);
    for (int i = 0; i < n; i++ ) {
        cin >> arr[i];
    }
    vector<int> arr2 = arr;
    sort(arr.begin() , arr.begin() + r);
    sort(arr2.begin() + l , arr2.end());
    int sum = 0;
    for (int i = 0; i < r - l + 1; i++ ) {
        sum += arr[i];
    }
    int ans = sum;
    sum = 0;
    for (int i = 0; i < r - l + 1; i++ ) {
        sum += arr2[i];
    }
    cout << min (ans , sum) << endl;
}

int32_t main() {
#ifndef abhishrestha
    freopen("Error.txt", "w", stderr);
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
#endif
    FAST_IO;
    int tt = 1;
    cin >> tt;
    for( int tc = 1; tc <= tt; tc++ ) {
        solve();
    }
    return 0;
}