Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

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



#define int long long

#define IOS                           \

    ios_base::sync_with_stdio(false); \

    cin.tie(0);                       \

    cout.tie(0);

#define Max(a, b) (a > b ? a : b)

#define Min(a, b) (a < b ? a : b)

#define isPower2(a) (a == 0 ? false : ((a & (a - 1)) == 0 ? true : false))

#define isEven(a) ((a & 1) == 0 ? true : false)

// Check if the kth bit (from right -> left) is set ( Ex: (8,1) -> false || (7,1) -> true)

#define checkKBit(a, k) ((a & (1 << k)) != 0 ? true : false)

#define setKBit(a, k) (a | (1 << k))

#define unsetKBit(a, k) (a & ~(1 << k))

#define toggleKBit(a, k) (a ^ (1 << k))

#define divideByPower2(a, k) (a >> k)

#define moduloByPower2(a, k) ((a & ((1 << k) - 1)))

#define multiplyByPower2(a, k) (a << k)

#define getNumberOfSetBits(a) (__builtin_popcountll(a))

#define getNumberOfLeadingZeros(a) (__builtin_clzll(a))

#define xorOp(a, b) (a ^ b)

#define swap(a, b) \

    {              \

        a = a ^ b; \

        b = a ^ b; \

        a = a ^ b; \

    }

// if x == a -> x = b else if x == b -> x = a

#define swapConditional(a, b, x) {a ^ b ^ x}

const int maxn = 2e5 + 5;

using namespace std;



const int M = 1e9 + 7;



#define add(a, b, m) ((a + b) % m)

#define sub(a, b, m) ((a - b + m) % m)

/*

3 6 6 4 3 2

1 2 3 4 5 6

0 1 2 3 4 5 

l   r



3 6 6



2 3 3 4 6 6



*/



void solve()

{   

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

    // cout << l << " " << r << endl;

    int ssum = 0;

    l--; r--;n--;

    vector<int> ll, rr, arr;

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

        int aux; cin >> aux;

        arr.push_back(aux);

    }

    for(int i = 0; i <= r; i++) ll.push_back(arr[i]);

    for(int i = l; i <= n; i++) rr.push_back(arr[i]);

    int sum= 0;

    int ans = maxn;

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

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

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

        // cout << ll[i] << " ";

        sum += ll[i];

    }

    // cout << endl;

    ans = min(sum, ans);

    sum= 0;

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

        // cout << rr[i] << " ";

        sum += rr[i];

    }

    // cout << endl;

    ans = min(sum, ans);

    cout << ans << endl;

}



signed main()

{

    IOS;

    int t = 1;

    // int t;

    cin >> t;

    while (t--)

    {

        // cout << "TESTE: " << t << endl;

        solve();

    }

    return 0;

}



Submission (verdict: Wrong answer on test 8):
#include <bits/stdc++.h>

#define int long long
#define IOS                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define Max(a, b) (a > b ? a : b)
#define Min(a, b) (a < b ? a : b)
#define isPower2(a) (a == 0 ? false : ((a & (a - 1)) == 0 ? true : false))
#define isEven(a) ((a & 1) == 0 ? true : false)
// Check if the kth bit (from right -> left) is set ( Ex: (8,1) -> false || (7,1) -> true)
#define checkKBit(a, k) ((a & (1 << k)) != 0 ? true : false)
#define setKBit(a, k) (a | (1 << k))
#define unsetKBit(a, k) (a & ~(1 << k))
#define toggleKBit(a, k) (a ^ (1 << k))
#define divideByPower2(a, k) (a >> k)
#define moduloByPower2(a, k) ((a & ((1 << k) - 1)))
#define multiplyByPower2(a, k) (a << k)
#define getNumberOfSetBits(a) (__builtin_popcountll(a))
#define getNumberOfLeadingZeros(a) (__builtin_clzll(a))
#define xorOp(a, b) (a ^ b)
#define swap(a, b) \
    {              \
        a = a ^ b; \
        b = a ^ b; \
        a = a ^ b; \
    }
// if x == a -> x = b else if x == b -> x = a
#define swapConditional(a, b, x) {a ^ b ^ x}
const int maxn = 2e5 + 5;
using namespace std;

const int M = 1e9 + 7;

#define add(a, b, m) ((a + b) % m)
#define sub(a, b, m) ((a - b + m) % m)
/*
3 6 6 4 3 2
1 2 3 4 5 6
0 1 2 3 4 5 
l   r

3 6 6

2 3 3 4 6 6

*/

void solve()
{   
    int n, l , r; cin >> n >> l >> r;
    // cout << l << " " << r << endl;
    int ssum = 0;
    l--; r--;n--;
    vector<int> ll, rr, arr;
    for(int i = 0; i <= n; i++){
        int aux; cin >> aux;
        arr.push_back(aux);
    }
    for(int i = 0; i <= r; i++) ll.push_back(arr[i]);
    for(int i = l; i <= n; i++) rr.push_back(arr[i]);
    int sum= 0;
    int ans = M;
    sort(ll.begin(), ll.end());
    sort(rr.begin(), rr.end());
    for(int i = 0; i < (r - l + 1) ; i++){
        // cout << ll[i] << " ";
        sum += ll[i];
    }
    // cout << endl;
    ans = min(sum, ans);
    sum= 0;
    for(int i = 0; i < (r - l + 1) ; i++){
        // cout << rr[i] << " ";
        sum += rr[i];
    }
    // cout << endl;
    ans = min(sum, ans);
    cout << ans << endl;
}

signed main()
{
    IOS;
    int t = 1;
    // int t;
    cin >> t;
    while (t--)
    {
        // cout << "TESTE: " << t << endl;
        solve();
    }
    return 0;
}