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

Previous submission (verdict: Wrong answer on test 2):
using namespace std;

#include <iostream>

#include <string>

#include <bits/stdc++.h>

#include <algorithm>

#include <cctype>

#define ll long long

const ll N=2e5+10;

bool prime[N];

ll factor(ll n) {

    ll ans=n;

    for (int i = 2; i * i <= n; ++i) {

        if(n%i==0) {

            while (n % i == 0) {

                n /= i;

            }

            ans -= ans / i;

        }

    }

    if (n > 1) { ans-=ans/n; }

    return ans;

}

vector<ll> prime_divisors(int n){

    vector<ll>ret;

    if(prime[n])ret.push_back(n);

    for(int i=2;i*i<=n;i++){

        if(n%i==0&&prime[i]){

            ret.push_back(i);

            if((n/i!=i)&&prime[n/i])ret.push_back(n/i);

        }

    }

    return ret;

}

void Sieve(ll n)

{

    memset(prime,true,sizeof(prime));

    for(ll p=2; p*p<=n; p++)

    {

        if(prime[p])

        {

            for(ll i=p*p; i<=n; i+=p)

            {

                prime[i]=false;

            }

        }

    }

}

ll FastExpo (ll base, ll power) {

    ll result = 1;

    while (power) {

        if (power%2) {

            result *= base;

        }

        base *= base;

        power /= 2;

    }

    return result;

}

ll OddSum(ll n){

    if(n%2){

        ll k=(n+1)/2;

        return (k*k);

    }

    else{

        ll k=(n)/2;

        return (k*k);

    }

}

ll CeilDivision(ll a,ll b){

    return (a+b-1) / b;

}

int dx[]={-1, 0, 1, 0};

int dy[]= {0, -1, 0, 1};

void fast()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

}

bool comp(const pair<ll,ll>&a , const pair<ll,ll>&b){

    return b.second>a.second;

}

vector<bool>visited(N,false);

vector<int>AdjList[N];

void dfs(int node){

    if(visited[node]){

        return;

    }

    visited[node]=true;

    for(int n: AdjList[node]){

        dfs(n);

    }

}

queue<int>qu;

vector<int>dis(N,0);

void bfs(int node){



    if (!visited[node]) {

        queue<int> q;

        q.push(node);

        visited[node] = true;

        while (!q.empty()) {

            int current_node = q.front();

            q.pop();

            for (int neighbor : AdjList[current_node]) {

                if (!visited[neighbor]) {

                    visited[neighbor] = true;

                    q.push(neighbor);

                }

            }

        }

    }

}

void solve() {

    ll n,l,r;cin>>n>>l>>r;

    ll a[n];

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

        cin>>a[i];

    }

    sort(a,a+n);

    ll ans=0;

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

        ans+=a[i];

    }

    cout<<ans<<endl;

}

int main() {

/*

#ifndef ONLINE_JUDGE

    freopen("art.in", "r", stdin);

    freopen("art.out", "w", stdout);

#endif

*/

    fast();

    int t=1;cin>>t;

    while(t--){

        solve();

    }

    return 0;

}

Submission (verdict: Wrong answer on test 2):
using namespace std;

#include <iostream>

#include <string>

#include <bits/stdc++.h>

#include <algorithm>

#include <cctype>

#define ll long long

const ll N=2e5+10;

bool prime[N];

ll factor(ll n) {

    ll ans=n;

    for (int i = 2; i * i <= n; ++i) {

        if(n%i==0) {

            while (n % i == 0) {

                n /= i;

            }

            ans -= ans / i;

        }

    }

    if (n > 1) { ans-=ans/n; }

    return ans;

}

vector<ll> prime_divisors(int n){

    vector<ll>ret;

    if(prime[n])ret.push_back(n);

    for(int i=2;i*i<=n;i++){

        if(n%i==0&&prime[i]){

            ret.push_back(i);

            if((n/i!=i)&&prime[n/i])ret.push_back(n/i);

        }

    }

    return ret;

}

void Sieve(ll n)

{

    memset(prime,true,sizeof(prime));

    for(ll p=2; p*p<=n; p++)

    {

        if(prime[p])

        {

            for(ll i=p*p; i<=n; i+=p)

            {

                prime[i]=false;

            }

        }

    }

}

ll FastExpo (ll base, ll power) {

    ll result = 1;

    while (power) {

        if (power%2) {

            result *= base;

        }

        base *= base;

        power /= 2;

    }

    return result;

}

ll OddSum(ll n){

    if(n%2){

        ll k=(n+1)/2;

        return (k*k);

    }

    else{

        ll k=(n)/2;

        return (k*k);

    }

}

ll CeilDivision(ll a,ll b){

    return (a+b-1) / b;

}

int dx[]={-1, 0, 1, 0};

int dy[]= {0, -1, 0, 1};

void fast()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

}

bool comp(const pair<ll,ll>&a , const pair<ll,ll>&b){

    return b.second>a.second;

}

vector<bool>visited(N,false);

vector<int>AdjList[N];

void dfs(int node){

    if(visited[node]){

        return;

    }

    visited[node]=true;

    for(int n: AdjList[node]){

        dfs(n);

    }

}

queue<int>qu;

vector<int>dis(N,0);

void bfs(int node){



    if (!visited[node]) {

        queue<int> q;

        q.push(node);

        visited[node] = true;

        while (!q.empty()) {

            int current_node = q.front();

            q.pop();

            for (int neighbor : AdjList[current_node]) {

                if (!visited[neighbor]) {

                    visited[neighbor] = true;

                    q.push(neighbor);

                }

            }

        }

    }

}

void solve() {

    ll n,l,r;cin>>n>>l>>r;

    l--;

    r--;

    vector<ll>segment;

    vector<ll>v;

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

        ll x;cin>>x;

        if(i>=l && i<=r){

            segment.push_back(x);

        }

        else{

            v.push_back(x);

        }

    }

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

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

    int temp=0;

    ll ans=0;

    if(v.size())

    for(int i=segment.size()-1;i>=0;i--){

        if(v[temp]<segment[i]){

            segment[i]=v[temp];

            temp++;

        }

        if(temp==v.size()){

            break;

        }

    }

    for(int i=0;i<segment.size();i++){

        ans+=segment[i];

    }

    cout<<ans<<endl;

}

int main() {

/*

#ifndef ONLINE_JUDGE

    freopen("art.in", "r", stdin);

    freopen("art.out", "w", stdout);

#endif

*/

    fast();

    int t=1;cin>>t;

    while(t--){

        solve();

    }

    return 0;

}