Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

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

#ifdef TEPAMID
#define debug(x) cerr << #x << " = " << x << endl;
#define debug_v(v)            \
    {                         \
        cerr << #v << " = ";  \
        for (auto x : v)      \
            cerr << x << " "; \
        cerr << endl;         \
    }
#define debug_vp(v)                       \
    {                                     \
        cerr << #v << " = ";              \
        for (auto [x, y] : v)             \
            cerr << x << "," << y << " "; \
        cerr << endl;                     \
    }
#else
#define debug(x) 0;
#define debug_v(x) 0;
#define debug_vp(x) 0;
#endif // HOME

using namespace std;

// mt19937 rng(5);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define fo(i, n) for (int i = 0; i < n; ++i)
#define foback(i, n) for (int i = n - 1; i >= 0; --i)
#define fo1(i, n) for (int i = 1; i <= n; ++i)

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())

typedef long long ll;

void fastio()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

void one();


int main() {
    fastio();

    int t = 1;
// #ifdef TEPAMID
    cin >> t;
// #endif

    fo(TEST, t)
    {
        debug(TEST)
        one();
    }

    return 0;
}

ll solve(vector<ll>& a){ 

    sort(all(a));

   ll ans=accumulate(all(a), 0LL);
// for(int i=0; i<a.size(); i++) ans += a[i];
return ans;
}


void one () {
    int n;   cin >> n;
    int l,r; cin >> l >> r; l--;
vector<ll> a(n);
vector<ll> b,c;
    
    for(int i=0; i<n; i++) {
        cin >> a[i];
    }

for(int i=0; i<r; i++) {
b.push_back(a[i]);
}
for(int i=l; i<r; i++) {
c.push_back(a[i]);
}
    auto ans = min(solve(b), solve(c));
cout << ans <<endl;

}



Submission (verdict: Accepted):
#include <bits/stdc++.h>

#ifdef TEPAMID
#define debug(x) cerr << #x << " = " << x << endl;
#define debug_v(v)            \
    {                         \
        cerr << #v << " = ";  \
        for (auto x : v)      \
            cerr << x << " "; \
        cerr << endl;         \
    }
#define debug_vp(v)                       \
    {                                     \
        cerr << #v << " = ";              \
        for (auto [x, y] : v)             \
            cerr << x << "," << y << " "; \
        cerr << endl;                     \
    }
#else
#define debug(x) 0;
#define debug_v(x) 0;
#define debug_vp(x) 0;
#endif // HOME

using namespace std;

// mt19937 rng(5);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define fo(i, n) for (int i = 0; i < n; ++i)
#define foback(i, n) for (int i = n - 1; i >= 0; --i)
#define fo1(i, n) for (int i = 1; i <= n; ++i)

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())

typedef long long ll;

void fastio()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

void one();


int main() {
    fastio();

    int t = 1;
// #ifdef TEPAMID
    cin >> t;
// #endif

    fo(TEST, t)
    {
        debug(TEST)
        one();
    }

    return 0;
}

ll solve(vector<ll>& a, int m){ 

    sort(all(a));

    while(a.size() > m) a.pop_back();

   ll ans=accumulate(all(a), 0LL);
// for(int i=0; i<a.size(); i++) ans += a[i];
return ans;
}


void one () {
    int n;   cin >> n;
    int l,r; cin >> l >> r; l--;
    vector<ll> a(n);
    vector<ll> b,c;
        
    for(int i=0; i<n; i++) {
        cin >> a[i];
    }

    for(int i=0; i<r; i++) {
        b.push_back(a[i]);
    }
    for(int i=l; i<n; i++) {
        c.push_back(a[i]);
    }

    auto ans = min(solve(b, r-l), solve(c, r-l));
    cout << ans <<endl;
}