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


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

#include<iostream>

#include<unordered_set>

#include<map>

#include<set>

using namespace std;

#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)



// Macros for quick typing

#define int long long

#define pb push_back

#define all(x) x.begin(), x.end()

#define rall(x) x.rbegin(), x.rend()

#define sz(x) (int)x.size()

#define endl '\n'

#define fi first

#define se second

#define pii pair<int, int>



#define int long long

#define INT_MAX LLONG_MAX

#define INT_MIN LLONG_MIN

//#define input(v,n) for(int i=0;i<n;i++)cin>>v[i]

#define ultasort(v) sort((v).begin(),(v).end(),greater<int>())

#define endl "\n"

#define all(x) (x).begin(),(x).end()

#define disp(v) for(int i=0;i<v.size();i++)cout<<v[i]<<" "; cout<<endl

using namespace std;

typedef unsigned char byte;

bool is_sorted(vector<int>& arr) {

    for (int i = 1; i < arr.size(); ++i) {

        if (arr[i - 1] > arr[i]) {

            return false;

        }

    }

    return true;

}

void input(vector<int>& v, int n) {

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

        cin >> v[i];

    }

}

void setIO(string name = "") {

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    if (name.size()) {

        freopen((name + ".in").c_str(), "r", stdin);

        freopen((name + ".out").c_str(), "w", stdout);

    }

}

string decimalToBinary(int n) {

    if (n == 0) return "0";

    string binary = "";

    while (n > 0) {

        binary = (n % 2 == 0 ? "0" : "1") + binary;

        n /= 2;

    }

    return binary;

}

vector<long long> getDivisors(long long k) {

    vector<long long> divisors;

    for (long long i = 1; i * i <= k; ++i) {

        if (k % i == 0) {

            divisors.push_back(i);

            if (i != k / i) {

                divisors.push_back(k / i);

            }

        }

    }

    return divisors;

}

int mod_exp(int base, int exp, int modulus=1e9+7) {

    int result = 1;

    while (exp > 0) {

        if (exp % 2 == 1) {

            result = (result * base) % modulus;

        }

        base = (base * base) % modulus;

        exp /= 2;

    }

    return result;

}

bool isPrime(int num) {

    if (num <= 1) return false;

    if (num == 2 || num == 3) return true;

    if (num % 2 == 0 || num % 3 == 0) return false;

    for (int i = 5; i * i <= num; i += 6) {

        if (num % i == 0 || num % (i + 2) == 0) return false;

    }

    return true;

}

long long power2(int n) {

    const int MOD = 1e9 + 7; // Modulo value

    long long result = 1;    // Result initialized to 1

    long long base = 2;      // Base is 2 (we are calculating 2^n)



    while (n > 0) {

        // If n is odd, multiply the current base with the result

        if (n % 2 == 1) {

            result = (result * base) % MOD;

        }

        // Square the base and reduce n by half

        base = (base * base) % MOD;

        n /= 2;

    }



    return result;

}

const int mod=1e9+7;

int trailing_zeros(int n){// calculate 0s at end of a number

    int ans=0;

    vector<int>v;

    for(int i=5;i<=n;i*=5){

        int p=n/i;

        v.push_back(p);

    }

    int x=v.size();

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

        v[i]-=v[i+1];

    }





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

        ans+=v[i]*(i+1);

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

    }

    //cout<<endl;

    return ans;



}

long long modAdd(long long a, long long b, long long m) {

    return ((a % m) + (b % m)) % m;

}



// Function to compute modular multiplication

long long modMul(long long a, long long b, long long m=mod) {

    return ((a % m) * (b % m)) % m;

}



// Function to compute modular exponentiation

long long modExp(long long base, long long exp, long long m) {

    long long result = 1;

    base = base % m;

    while (exp > 0) {

        if (exp % 2 == 1) {

            result = (result * base) % m; // Multiply base with result if exp is odd

        }

        base = (base * base) % m;       // Square the base

        exp /= 2;

    }

    return result;

}



// Function to compute modular division

long long modDiv(long long a, long long b, long long m=1e9+7) {

    // Compute the modular inverse of b mod m

    long long b_inv = modExp(b, m - 2, m); // Fermat's Little Theorem

    return modMul(a, b_inv, m);           // Modular division is a * b^-1 mod m

}

long long modFactorial(long long n, long long m) {

    long long result = 1;

    for (long long i = 1; i <= n; i++) {

        result = modMul(result, i, m);

    }

    return result;

}

long long modNCR(long long n, long long r, long long m) {

    if (r > n) return 0;

    long long num = modFactorial(n, m);

    long long denom = modMul(modFactorial(r, m), modFactorial(n - r, m), m);

    return modDiv(num, denom, m);

}

vector<pair<int, int>> primeFactorization(int n) {

    vector<pair<int, int>> factors;



    // Check for divisibility by numbers from 2 to sqrt(n)

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

        if (n % i == 0) {

            int count = 0; // Power of the current prime factor

            while (n % i == 0) {

                n /= i;

                count++;

            }

            factors.emplace_back(i, count);

        }

    }



    // If n is still greater than 1, it is a prime number

    if (n > 1) {

        factors.emplace_back(n, 1);

    }



    return factors;

}

vector<int> sieve(int n) {

    vector<bool> isPrime(n + 1, true); // Boolean array to mark primes

    vector<int> primes;



    isPrime[0] = isPrime[1] = false; // 0 and 1 are not prime



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

        if (isPrime[i]) { // If i is prime

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

                isPrime[j] = false; // Mark all multiples of i as non-prime

            }

        }

    }



    // Collect all prime numbers

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

        if (isPrime[i]) {

            primes.push_back(i);

        }

    }



    return primes;

}

class FactorizationUtils {

private:

    static const int MAXN = 100100;

    vector<int> spf; // Smallest Prime Factor

    bool precomputed = false;

public:

    FactorizationUtils() {

        spf.resize(MAXN);

    }



    void precomputeSPF(int limit = 100000) {

        if (precomputed) return;

        for (int i = 1; i <= limit; ++i) spf[i] = i;



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

            if (spf[i] == i) { // Prime number found

                for (int j = i * i; j <= limit; j += i) {

                    if (spf[j] == j) spf[j] = i; // Mark with smallest prime

                }

            }

        }

        precomputed = true;

    }



    // Prime factorization using precomputed SPF

    vector<pair<int, int>> factorize(int num) {

        vector<pair<int, int>> factors;

        if (num <= 1) return factors; // Ignore 1



        while (num > 1) {

            int prime = spf[num], exponent = 0;

            while (num % prime == 0) {

                num /= prime;

                exponent++;

            }

            factors.pb({prime, exponent});

        }

        return factors;

    }



    // Factorize multiple numbers

    vector<vector<pair<int, int>>> factorizeElements(const vector<int>& elements) {

        vector<vector<pair<int, int>>> result;

        for (int num : elements) {

            result.pb(factorize(num));

        }

        return result;

    }

};



// Global instance for contests

FactorizationUtils factorUtils;



class Disjointset{

    vector<int>size,parent;

public:

    Disjointset (int n){

        size.resize(n+1);

        parent.resize(n+1);

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

            parent[i]=i;

            size[i]=1;

        }

    }

    int findParent(int u){

        if(u==parent[u])

            return u;

        return parent[u]=findParent(parent[u]);

    }

    void unite(int u, int v){

        int par_u=findParent(u);

        int par_v=findParent(v);

        if(par_u==par_v)

            return;

        if(size[par_u]<size[par_v]){

            size[par_v]+=size[par_u];

            parent[par_u]=par_v;

        }

        else{

            size[par_u]+=size[par_v];

            parent[par_v]=par_u;

        }

    }

    int get_size(int u){

        return size[findParent(u)];

    }

};

vector<int> binomialCoefficients(int n) {

    vector<int> coefficients(n + 1);

    

    coefficients[0] = 1; 

    for (int k = 1; k <= n; ++k) {

       

        coefficients[k] = abs(coefficients[k - 1]) * (n - k + 1) / k;

        

        if (k % 2 == 1) {

            coefficients[k] *= -1;

        }

    }

    

    return coefficients;

}



vector<int> lds(vector<int>& nums) {

    int n = nums.size();

    if (n == 0) return {};



    vector<int> dp, indices, parent(n, -1), pos(n, -1);



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

        auto it = upper_bound(dp.begin(), dp.end(), nums[i], greater<int>());

        int idx = distance(dp.begin(), it);



        if (it == dp.end()) {

            dp.push_back(nums[i]);

            indices.push_back(i);

        } else {

            *it = nums[i];

            indices[idx] = i;

        }



        pos[i] = idx;

        if (idx > 0) parent[i] = indices[idx - 1];

    }



    vector<int> result;

    int last_index = indices.back();

    while (last_index != -1) {

        result.push_back(last_index);

        last_index = parent[last_index];

    }



    reverse(result.begin(), result.end()); 

    for(int i:result)cout<<nums[i]<<" ";cout<<endl;

    return result;

}





    

int query(int l, int r,vector<int>&tree,int n) {

        l += n; r += n;  // Shift indices to leaf nodes

        int result = 1;  // Identity element for multiplication



        while (l <= r) {

            if (l % 2 == 1) result += tree[l++];  // If l is right child, use it

            if (r % 2 == 0) result += tree[r--];  // If r is left child, use it

            l /= 2; r /= 2;

        }

        return result;

    }

// Function to build the segment tree

void buildSegment(vector<int>& tree, vector<int>& v, int n) {

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

        tree[n + i] = v[i];

    }

    for (int i = n - 1; i >= 1; i--) {

        tree[i] = tree[2 * i] * tree[2 * i + 1];

    }

}

// Function to update the segment tree

void update(int ind, int value, vector<int>& tree, int n) {

    ind += n; // Move to leaf node

    tree[ind] = value;

    int flag=0;

    while (ind > 1) {

        if(flag==0){

            tree[ind/2] = tree[ind/2*2] | tree[ind/2*2+1];

            flag=1;

        }

        else{

            tree[ind/2] = tree[ind/2*2] ^ tree[ind/2*2+1];

            flag=0;

        }

        ind/=2;

    }

}









int subtree(int node, int par, vector<vector<vector<int>>>&adj, vector<int>&sz){

    int ans=0;

    for(auto &i:adj[node]){

        if(i[0]==par)continue;

        ans+=1+subtree(i[0],node,adj,sz);

    }

    sz[node]=ans+1;

    return ans;

}









int kadane(vector<int>& arr) {

    int max_sum = arr[0], current_sum = arr[0];

    for (int i = 1; i < arr.size(); i++) {

        current_sum = max(arr[i], current_sum + arr[i]);

        max_sum = max(max_sum, current_sum);

    }

    return max_sum;

}





int rec(int i, vector<int>& v, int tgt, vector<vector<int>>& dp) {

    int n = v.size();

    if (tgt == 0) return 0;

    if (i >= n) return 1e9;

    if (dp[i][tgt] != -1) return dp[i][tgt];



    int np = rec(i + 1, v, tgt, dp);

    int pick = 1e9;

    if (v[i] <= tgt) {

        pick = 1 + rec(i, v, tgt - v[i], dp);

    }



    return dp[i][tgt] = min(pick, np);

}

long long f(long long p, long long q) {

    long long count = 0;

    while (q > 0) {

        count += p / q;

        p %= q;

        swap(p, q);

    }

    return count;

}







long long eulerTotient(long long n) {

    long long result = n;

    for (long long p = 2; p * p <= n; p++) {

        if (n % p == 0) {

            while (n % p == 0) {

                n /= p;

            }

            result -= result / p;

        }

    }

    if (n > 1) { 

        result -= result / n;

    }

    return result;

}





const int MASK = 9223372036854775807;

void maximize_or(vector<int>& a) {

    int n=a.size();

    sort(all(a));

    disp(a);

    int f=-1;

    int c=0;

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

        if(a[i]<(1LL <<62)){

            f=i;

            c++;

            a[i]^=MASK;

        }

    }

    if(c%2){

        a[f]^=MASK;

    }

}



template <typename T>

long double sqrt_large(T num, long double precision = 1e-9) {

    if (num == 0 || num == 1) return num;

    

    T left = 1, right = num;

    long double mid;

    

    // Binary search for integer part

    while (left <= right) {

        mid = left + (right - left) / 2;

        if (mid * mid == num) return mid;

        if (mid * mid < num)

            left = mid + 1;

        else

            right = mid - 1;

    }

    

    // Refine using Newton's method

    long double res = right; // Right is the best lower bound

    while (true) {

        long double new_res = 0.5 * (res + num / res);

        if (abs(new_res - res) < precision) break;

        res = new_res;

    }

    return res;

}







int count(const vector<int>& arr) {

    int invCount = 0;

    int n = arr.size();

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

        for (int j = i + 1; j < n; j++) {

            if (arr[i] > arr[j]) invCount++;

        }

    }

    return invCount;

}



bool helper(vector<int>&v, string &s,int x,int k){

    int n=v.size();

    char lst_vis='R';

    int c=0;

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

        if(v[i]>x){

            if(s[i]=='B' && lst_vis=='R')c++;

            lst_vis=s[i];

        }

    }

    return c<=k;

}



void code() {

   int n,l,r;

   cin>>n>>l>>r;

   vector<int>v(n);input(v,n);

   sort(all(v));int ans=0;

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

        ans+=v[i];

   }

   cout<<ans<<endl;

}













signed main() {

    //setIO("notlast");

   // factorUtils.precomputeSPF();

    fastio();

    int t=1;

   cin>>t;

    while(t--){

        code();

    }

}