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

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<pi> vpi;
typedef vector<vector<pi>> vvpi;
typedef vector<vector<vector<pi>>> vvvpi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef vector<long double> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int T;
    cin >> T;
    while (T--)
    {
        int N, l, r;
        cin >> N >> l >> r;
        vi v(N);
        for (auto& i : v) cin >> i;

        vi mid = vi(v.begin() + l - 1, v.begin() + r);

        sort(mid.begin(), mid.end(), greater<int>());


        int sum1 = 0;
        if (l != 0)
        {
            vi bg = vi(v.begin(), v.begin() + l - 1);
            sort(bg.begin(), bg.end());
            int idx = 0;
            
            for (auto i : mid)
            {
                int temp = i;
                if (idx < bg.size())
                {
                    temp = min(temp, bg[idx]);
                }
                sum1 += temp;
                idx++;
            }
        }
        
        int sum2 = 0;
        vi ng = vi(v.begin() + r, v.end());
        sort(ng.begin(), ng.end());
        int idx = 0;
        for (auto i : mid)
        {
            int temp = i;
            if (idx < ng.size())
            {
                temp = min(temp, ng[idx]);
            }
            sum2 += temp;
            idx++;
        }
        cout << min(sum1, sum2) << '\n';
    }
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<pi> vpi;
typedef vector<vector<pi>> vvpi;
typedef vector<vector<vector<pi>>> vvvpi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef vector<long double> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int T;
    cin >> T;
    while (T--)
    {
        int N, l, r;
        cin >> N >> l >> r;
        vi v(N);
        for (auto& i : v) cin >> i;

        vi s1 = vi(v.begin(), v.begin() + r);
        vi s2 = vi(v.begin() + l - 1, v.end());
        sort(s1.begin(), s1.end());
        sort(s2.begin(), s2.end());

        int sum1 = 0, sum2 = 0;

        for (int i = 0; i < r - l + 1; i++)
        {
            sum1 += s1[i];
            sum2 += s2[i];
        }
        
        cout << min(sum1, sum2) << '\n';
    }
}