ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <cstring>
#include <unordered_map>

using namespace std;
typedef int ll;

int main(){
    ll t;
    cin >> t;
    
    while(t--){
        ll l, r;
        cin >> l >> r;
        
        ll a, b, c;
        ll still = 0;
        
        for(ll i = 30; i >= 0; i--){
            if((l >> i) % 2 == (r >> i) % 2){
                still += (1ll << i) * ((l >> i) & 1);
                continue;
            }
            
            b = (1ll << i);
            a = b - 1;
            c = 0;
            
            if(a - 1 >= l)
                c = a - 1;
            else
                c = b + 1;
            
            break;
        }
        
        cout << a + still << ' ' << b + still << ' ' << c + still << endl;
    }
    
    return 0;
}


Submission (verdict: Accepted):
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <cstring>
#include <unordered_map>

using namespace std;
typedef int ll;

int main(){
    ll t;
    cin >> t;
    
    while(t--){
        ll l, r;
        cin >> l >> r;
        
        ll a, b, c;
        ll still = 0;
        
        for(ll i = 30; i >= 0; i--){
            if((l >> i) % 2 == (r >> i) % 2){
                still += (1ll << i) * ((l >> i) & 1);
                continue;
            }
            
            b = (1ll << i);
            a = b - 1;
            c = 0;
            
            if(a + still - 1 >= l)
                c = a - 1;
            else
                c = b + 1;
            
            break;
        }
        
        cout << a + still << ' ' << b + still << ' ' << c + still << endl;
    }
    
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


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

using namespace std;



void solve() {

    int n, l, r;

    cin >> n >> l >> r;

    l--; 

    

    vector<int> arr(n);

    for (int &x : arr) cin >> x;



    vector<int> brr = arr;

    sort(brr.begin() + l, brr.end());



    vector<int> crr = arr;

    sort(crr.begin(), crr.begin() + r, greater<int>()); 



    int sum1 = accumulate(brr.begin() + l, brr.begin() + r, 0);

    int sum2 = accumulate(crr.begin() + l, crr.begin() + r, 0);

    

    cout << min(sum1, sum2) << '\n';

}



int main() {

    



    int t=1;

    cin >> t;

    while (t--) {

        solve();

    }

    

    return 0;

}
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;

void solve() {
    int n, l, r;
    cin >> n >> l >> r;
    l--; 
    
    vector<int> arr(n);
    for (int &x : arr) cin >> x;

    vector<int> brr = arr;
    sort(brr.begin() + l, brr.end());

    vector<int> crr = arr;
    sort(crr.begin(), crr.begin() + r, greater<int>()); 

    long long sum1 = accumulate(brr.begin() + l, brr.begin() + r, 0);
    long long sum2 = accumulate(crr.begin() + l, crr.begin() + r, 0);
    
    cout << min(sum1, sum2) << '\n';
}

int main() {
    

    int t=1;
    cin >> t;
    while (t--) {
        solve();
    }
    
    return 0;
}


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

void solve() {
    int n, l, r;
    cin >> n >> l >> r;
    l--; 
    
    vector<int> arr(n);
    for (int &x : arr) cin >> x;

    vector<int> brr = arr;
    sort(brr.begin() + l, brr.end());

    vector<int> crr = arr;
    sort(crr.begin(), crr.begin() + r, greater<int>()); 

    long long sum1 = accumulate(brr.begin() + l, brr.begin() + r, 0LL);
    long long sum2 = accumulate(crr.begin() + l, crr.begin() + r, 0LL);
    
    cout << min(sum1, sum2) << '\n';
}

int main() {
    

    int t=1;
    cin >> t;
    while (t--) {
        solve();
    }
    
    return 0;
}
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;



void solve() {

    int n, l, r;

    cin >> n >> l >> r;

    l--; 

    

    vector<int> arr(n);

    for (int &x : arr) cin >> x;



    vector<int> brr = arr;

    sort(brr.begin() + l, brr.end());



    vector<int> crr = arr;

    sort(crr.begin(), crr.begin() + r, greater<int>()); 



    int sum1 = accumulate(brr.begin() + l, brr.begin() + r, 0);

    int sum2 = accumulate(crr.begin() + l, crr.begin() + r, 0);

    

    cout << min(sum1, sum2) << '\n';

}



int main() {

    



    int t=1;

    cin >> t;

    while (t--) {

        solve();

    }

    

    return 0;

}



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

void solve() {
    int n, l, r;
    cin >> n >> l >> r;
    l--; 
    
    vector<int> arr(n);
    for (int &x : arr) cin >> x;

    vector<int> brr = arr;
    sort(brr.begin() + l, brr.end());

    vector<int> crr = arr;
    sort(crr.begin(), crr.begin() + r, greater<int>()); 

    long long sum1 = accumulate(brr.begin() + l, brr.begin() + r, 0);
    long long sum2 = accumulate(crr.begin() + l, crr.begin() + r, 0);
    
    cout << min(sum1, sum2) << '\n';
}

int main() {
    

    int t=1;
    cin >> t;
    while (t--) {
        solve();
    }
    
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
using namespace std;


int main()
{
    
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        
        int two=0,three=0,sum=0;
           bool flag=0;
        for(auto i:s){
            if(i=='2'){
                two++;
            }
            else if(i=='3'){
                three++;
            }
            sum+=(i-'0');
            sum=sum%9;
            
         
            for(int j=0;j<=three;j++){
                for(int i=0;i<=two;i++){
                    long tsum=sum;
                    tsum+=i*2+j*6;
                    
                    if(tsum%9==0){
                        flag=1;
                       break;
                    }
                }
            }
            
        }
        if(flag==1){
                cout<<"YES"<<endl;
            }
            else{
                cout<<"NO"<<endl;
            }
    }
    
}

Submission (verdict: Accepted):
#include <iostream>
using namespace std;

void solve(){
     string s;
        cin>>s;
        
        int two=0,three=0,sum=0;
           bool flag=0;
        for(auto i:s){
            if(i=='2'){
                two++;
            }
            else if(i=='3'){
                three++;
            }
            sum+=(i-'0');
            sum=sum%9;
            
        }
            for(int j=0;j<=three;j++){
                for(int i=0;i<=two;i++){
                    long tsum=sum;
                    tsum+=i*2+j*6;
                    
                    if(tsum%9==0){
                        cout<<"YES"<<endl;
                        return;
                    }
                }
            }
            
        
        
     
                cout<<"NO"<<endl;
            return;
}


int main()
{
    
    
    int t;
    cin>>t;
    while(t--){
        solve();
       
    }
    
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


Submission (verdict: Compilation error):
int main()
{
    
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        
        int two=0,three=0,sum=0;
           bool flag=0;
        for(auto i:s){
            if(i=='2'){
                two++;
            }
            else if(i=='3'){
                three++;
            }
            sum+=(i-'0');
            sum=sum%9;
            
         
            for(int j=0;j<=three;j++){
                for(int i=0;i<=two;i++){
                    long tsum=sum;
                    tsum+=i*2+j*6;
                    
                    if(tsum%9==0){
                        flag=1;
                       break;
                    }
                }
            }
            
        }
        if(flag==1){
                cout<<"YES"<<endl;
            }
            else{
                cout<<"NO"<<endl;
            }
    }
    
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Compilation error):
int main()
{
    
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        
        int two=0,three=0,sum=0;
           bool flag=0;
        for(auto i:s){
            if(i=='2'){
                two++;
            }
            else if(i=='3'){
                three++;
            }
            sum+=(i-'0');
            sum=sum%9;
            
         
            for(int j=0;j<=three;j++){
                for(int i=0;i<=two;i++){
                    long tsum=sum;
                    tsum+=i*2+j*6;
                    
                    if(tsum%9==0){
                        flag=1;
                       break;
                    }
                }
            }
            
        }
        if(flag==1){
                cout<<"YES"<<endl;
            }
            else{
                cout<<"NO"<<endl;
            }
    }
    
}

Submission (verdict: Wrong answer on test 1):
#include <iostream>
using namespace std;


int main()
{
    
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        
        int two=0,three=0,sum=0;
           bool flag=0;
        for(auto i:s){
            if(i=='2'){
                two++;
            }
            else if(i=='3'){
                three++;
            }
            sum+=(i-'0');
            sum=sum%9;
            
         
            for(int j=0;j<=three;j++){
                for(int i=0;i<=two;i++){
                    long tsum=sum;
                    tsum+=i*2+j*6;
                    
                    if(tsum%9==0){
                        flag=1;
                       break;
                    }
                }
            }
            
        }
        if(flag==1){
                cout<<"YES"<<endl;
            }
            else{
                cout<<"NO"<<endl;
            }
    }
    
}
Problem: 2052A - Adrenaline Rush
Language: PyPy 3-64


Submission (verdict: Wrong answer on test 10):
import sys

N = int(sys.stdin.readline())

class Number:
    
    def __init__(self, value, index):
        self.value = value
        self.idx = value-1
        self.final_idx = index
        
    def __repr__(self):
        return str(self.value)
    
    @staticmethod
    def swap(a, b):
        if a == b: return
        a, b = Number.dct[a], Number.dct[b]
        a.idx, b.idx = b.idx, a.idx
        Number.lst[a.idx], Number.lst[b.idx] = a, b
        Number.swaps.append((a.value, b.value))

Number.dct = {int(x): Number(int(x), i) for i, x in enumerate(sys.stdin.readline().split())}
Number.lst = [Number.dct[i] for i in range(1, N + 1)]
Number.swaps = []
            
lst = Number.lst
dct = Number.dct
swaps = Number.swaps

def bring_to_front(n):
    if dct[n].idx == 0: return
    for i in range(n-1, 0, -1):
        Number.swap(n, lst[i-1].value)
        
def bring_to_back(n):
    idx = dct[n].final_idx
    if idx == 0: return
    for i in range(1, idx+1):
        Number.swap(lst[i].value, n)
        
for i in range(1, N + 1):
    bring_to_front(i)
    bring_to_back(i)

sys.stdout.write(str(len(swaps)) + '\n')
for swap in swaps:
    sys.stdout.write(str(swap[0]) + ' ' + str(swap[1]) + '\n')
Problem: 2052A - Adrenaline Rush
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 1):
import sys

N = int(sys.stdin.readline())

class Number:
    
    SWAPS = set()
    
    def __init__(self, value, index):
        self.value = value
        self.idx = value-1
        self.final_idx = index
        
    def __repr__(self):
        return str(self.value)
    
    @staticmethod
    def swap(a, b):
        if a == b: return
        if (a, b) in Number.SWAPS: return
        a, b = Number.dct[a], Number.dct[b]
        if a.idx < b.idx: return
        a.idx, b.idx = b.idx, a.idx
        Number.lst[a.idx], Number.lst[b.idx] = a, b
        Number.swaps.append((a.value, b.value))
        Number.SWAPS.add((a.value, b.value))

Number.dct = {int(x): Number(int(x), i) for i, x in enumerate(sys.stdin.readline().split())}
Number.lst = [Number.dct[i] for i in range(1, N + 1)]
Number.swaps = []
            
lst = Number.lst
dct = Number.dct
swaps = Number.swaps

def bring_to_front(n):
    if dct[n].idx == 0: return
    for i in range(n-1, 0, -1):
        Number.swap(n, lst[i-1].value)
        
def bring_to_back(n):
    idx = dct[n].final_idx
    if idx == 0: return
    for i in range(1, idx+1):
        Number.swap(lst[i].value, n)
        
for i in reversed(dct.keys()):
    bring_to_front(i)
    bring_to_back(i)
    print(i, lst)

sys.stdout.write(str(len(swaps)) + '\n')
for swap in swaps:
    sys.stdout.write(str(swap[0]) + ' ' + str(swap[1]) + '\n')

Submission (verdict: Accepted):
import sys

N = int(sys.stdin.readline())

class Number:
    
    SWAPS = set()
    
    def __init__(self, value, index):
        self.value = value
        self.idx = value-1
        self.final_idx = index
        
    def __repr__(self):
        return str(self.value)
    
    @staticmethod
    def swap(a, b):
        if a == b: return
        if (a, b) in Number.SWAPS: return
        a, b = Number.dct[a], Number.dct[b]
        if a.idx < b.idx: return
        a.idx, b.idx = b.idx, a.idx
        Number.lst[a.idx], Number.lst[b.idx] = a, b
        Number.swaps.append((a.value, b.value))
        Number.SWAPS.add((a.value, b.value))

Number.dct = {int(x): Number(int(x), i) for i, x in enumerate(sys.stdin.readline().split())}
Number.lst = [Number.dct[i] for i in range(1, N + 1)]
Number.swaps = []
            
lst = Number.lst
dct = Number.dct
swaps = Number.swaps

def bring_to_front(n):
    if dct[n].idx == 0: return
    for i in range(n-1, 0, -1):
        Number.swap(n, lst[i-1].value)
        
def bring_to_back(n):
    idx = dct[n].final_idx
    if idx == 0: return
    for i in range(1, idx+1):
        Number.swap(lst[i].value, n)
        
for i in reversed(dct.keys()):
    bring_to_front(i)
    bring_to_back(i)

sys.stdout.write(str(len(swaps)) + '\n')
for swap in swaps:
    sys.stdout.write(str(swap[0]) + ' ' + str(swap[1]) + '\n')
Problem: 2052A - Adrenaline Rush
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 12):
import sys

N = int(sys.stdin.readline())

class Number:
    
    SWAPS = set()
    
    def __init__(self, value, index):
        self.value = value
        self.idx = value-1
        self.final_idx = index
        
    def __repr__(self):
        return str(self.value)
    
    @staticmethod
    def swap(a, b):
        if a == b: return
        if (a, b) in Number.SWAPS: return
        a, b = Number.dct[a], Number.dct[b]
        a.idx, b.idx = b.idx, a.idx
        Number.lst[a.idx], Number.lst[b.idx] = a, b
        Number.swaps.append((a.value, b.value))
        Number.SWAPS.add((a.value, b.value))

Number.dct = {int(x): Number(int(x), i) for i, x in enumerate(sys.stdin.readline().split())}
Number.lst = [Number.dct[i] for i in range(1, N + 1)]
Number.swaps = []
            
lst = Number.lst
dct = Number.dct
swaps = Number.swaps

def bring_to_front(n):
    if dct[n].idx == 0: return
    for i in range(n-1, 0, -1):
        Number.swap(n, lst[i-1].value)
        
def bring_to_back(n):
    idx = dct[n].final_idx
    if idx == 0: return
    for i in range(1, idx+1):
        Number.swap(lst[i].value, n)
        
for i in reversed(dct.keys()):
    bring_to_front(i)
    bring_to_back(i)

sys.stdout.write(str(len(swaps)) + '\n')
for swap in swaps:
    sys.stdout.write(str(swap[0]) + ' ' + str(swap[1]) + '\n')

Submission (verdict: Wrong answer on test 1):
import sys

N = int(sys.stdin.readline())

class Number:
    
    SWAPS = set()
    
    def __init__(self, value, index):
        self.value = value
        self.idx = value-1
        self.final_idx = index
        
    def __repr__(self):
        return str(self.value)
    
    @staticmethod
    def swap(a, b):
        if a == b: return
        if (a, b) in Number.SWAPS: return
        a, b = Number.dct[a], Number.dct[b]
        if a.idx < b.idx: return
        a.idx, b.idx = b.idx, a.idx
        Number.lst[a.idx], Number.lst[b.idx] = a, b
        Number.swaps.append((a.value, b.value))
        Number.SWAPS.add((a.value, b.value))

Number.dct = {int(x): Number(int(x), i) for i, x in enumerate(sys.stdin.readline().split())}
Number.lst = [Number.dct[i] for i in range(1, N + 1)]
Number.swaps = []
            
lst = Number.lst
dct = Number.dct
swaps = Number.swaps

def bring_to_front(n):
    if dct[n].idx == 0: return
    for i in range(n-1, 0, -1):
        Number.swap(n, lst[i-1].value)
        
def bring_to_back(n):
    idx = dct[n].final_idx
    if idx == 0: return
    for i in range(1, idx+1):
        Number.swap(lst[i].value, n)
        
for i in reversed(dct.keys()):
    bring_to_front(i)
    bring_to_back(i)
    print(i, lst)

sys.stdout.write(str(len(swaps)) + '\n')
for swap in swaps:
    sys.stdout.write(str(swap[0]) + ' ' + str(swap[1]) + '\n')
Problem: 2052A - Adrenaline Rush
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 10):
import sys

N = int(sys.stdin.readline())

class Number:
    
    def __init__(self, value, index):
        self.value = value
        self.idx = value-1
        self.final_idx = index
        
    def __repr__(self):
        return str(self.value)
    
    @staticmethod
    def swap(a, b):
        if a == b: return
        a, b = Number.dct[a], Number.dct[b]
        a.idx, b.idx = b.idx, a.idx
        Number.lst[a.idx], Number.lst[b.idx] = a, b
        Number.swaps.append((a.value, b.value))

Number.dct = {int(x): Number(int(x), i) for i, x in enumerate(sys.stdin.readline().split())}
Number.lst = [Number.dct[i] for i in range(1, N + 1)]
Number.swaps = []
            
lst = Number.lst
dct = Number.dct
swaps = Number.swaps

def bring_to_front(n):
    if dct[n].idx == 0: return
    for i in range(n-1, 0, -1):
        Number.swap(n, lst[i-1].value)
        
def bring_to_back(n):
    idx = dct[n].final_idx
    if idx == 0: return
    for i in range(1, idx+1):
        Number.swap(lst[i].value, n)
        
for i in range(1, N + 1):
    bring_to_front(i)
    bring_to_back(i)

sys.stdout.write(str(len(swaps)) + '\n')
for swap in swaps:
    sys.stdout.write(str(swap[0]) + ' ' + str(swap[1]) + '\n')

Submission (verdict: Wrong answer on test 12):
import sys

N = int(sys.stdin.readline())

class Number:
    
    SWAPS = set()
    
    def __init__(self, value, index):
        self.value = value
        self.idx = value-1
        self.final_idx = index
        
    def __repr__(self):
        return str(self.value)
    
    @staticmethod
    def swap(a, b):
        if a == b: return
        if (a, b) in Number.SWAPS: return
        a, b = Number.dct[a], Number.dct[b]
        a.idx, b.idx = b.idx, a.idx
        Number.lst[a.idx], Number.lst[b.idx] = a, b
        Number.swaps.append((a.value, b.value))
        Number.SWAPS.add((a.value, b.value))

Number.dct = {int(x): Number(int(x), i) for i, x in enumerate(sys.stdin.readline().split())}
Number.lst = [Number.dct[i] for i in range(1, N + 1)]
Number.swaps = []
            
lst = Number.lst
dct = Number.dct
swaps = Number.swaps

def bring_to_front(n):
    if dct[n].idx == 0: return
    for i in range(n-1, 0, -1):
        Number.swap(n, lst[i-1].value)
        
def bring_to_back(n):
    idx = dct[n].final_idx
    if idx == 0: return
    for i in range(1, idx+1):
        Number.swap(lst[i].value, n)
        
for i in reversed(dct.keys()):
    bring_to_front(i)
    bring_to_back(i)

sys.stdout.write(str(len(swaps)) + '\n')
for swap in swaps:
    sys.stdout.write(str(swap[0]) + ' ' + str(swap[1]) + '\n')
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


Submission (verdict: Compilation error):
#include <bits/stdc++.h>
using namespace std;


int recursion(string s1, string s2, string c, int index1, int index2, vector<vector<int>> &dp){
    if(index1==0 && index2 == 0) return dp[index1][index2] = 0;
    if(dp[index1][index2] != -1) return dp[index1][index2];

    int a = INT_MAX;
    if(index1 > 0){
        if(s1[index1-1] == c[index1 + index2 -1]){
            a = min(a, recursion(s1, s2, c, index1-1, index2, dp));
        }
        else {
            a = min(a, 1 + recursion(s1, s2, c, index1-1, index2, dp));
        }
    }
    if(index2 > 0){
        if(s2[index2-1] == c[index1+index2-1]){
            a = min(a, recursion(s1, s2, c, index1, index2-1, dp));
        }
        else {
            a = min(a, 1 + recursion(s1, s2, c, index1, index2-1, dp));
        }
    }
    return dp[index1][index2] = a;
    
}
void solve(){
    string s1, s2, c;
    cin>>s1>>s2>>c;

    int n1 = s1.size();
    int n2 = s2.size();

    vector<vector<int>> dp(n1+1, vector<int>(n2+1, -1));
    // for(int i=0; i<=n1; i++){
    //     for(int j=0; j<=n2; j++){
    //         if(i==0 && j==0) continue;

    //         if(i>0 && s1[i-1] == c[i+j-1]){
    //             dp[i][j] = dp[i-1][j];
    //         }
    //         else if (j>0 && s2[j-1] == c[i+j-1]) {
    //             dp[i][j] = dp[i][j-1];
    //         }
    //         else{
    //             dp[i][j] = 1 + min(dp[i][j-1], dp[i-1][j]);
    //         }
    //     }
    // }

    cout<<recursion(s1, s2, c, n1, n2)<<endl;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll solve(int n, int l,int r, vector<int>&a){
   l--; r--;
   vector<int>x,y;
   for(int i=0;i<=r;i++){
     x.push_back(a[i]);
   }
   for(int i=l;i<n;i++){
      y.push_back(a[i]);
   }
   sort(x.begin(),x.end());
   sort(y.begin(),y.end());
   int s1,s2=0;
   for(int i=0;i<(r-l+1);i++){
     s1+=x[i];
     s2+=y[i];
   }
   return min(s1,s2);
}
int main() {
    int t;
    cin >> t;
    while (t--) {
       int n,l,r;
       cin>>n>>l>>r;
       vector<int>a(n);
       for(int i=0;i<n;i++)
          cin>>a[i];
          
      int ans = solve(n,l,r,a);
      cout<<ans<<endl;
    }
    return 0;
}

Submission (verdict: Wrong answer on test 8):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll solve(int n, int l,int r, vector<int>&a){
   l--; r--;
   vector<int>x,y;
   for(int i=0;i<=r;i++){
     x.push_back(a[i]);
   }
   for(int i=l;i<n;i++){
      y.push_back(a[i]);
   }
   sort(x.begin(),x.end());
   sort(y.begin(),y.end());
   int s1=0,s2=0;
   for(int i=0;i<(r-l+1);i++){
     s1+=x[i];
     s2+=y[i];
   }
   return min(s1,s2);
}
int main() {
    int t;
    cin >> t;
    while (t--) {
       int n,l,r;
       cin>>n>>l>>r;
       vector<int>a(n);
       for(int i=0;i<n;i++)
          cin>>a[i];
          
      int ans = solve(n,l,r,a);
      cout<<ans<<endl;
    }
    return 0;
}