ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	long long t,n,m,i,x,y;
	string res;
	cin>>t;
	while(t--){
		cin>>n>>m;
		priority_queue<long long,vector<long long>,greater<long long>> a;
		vector<long long> b;
		for(i=0;i<n;i++){
			cin>>x;
			a.push(x);
		}
		for(i=0;i<m;i++){
			cin>>x;
			b.push_back(x);
		}
		sort(b.begin(),b.end());
		i=0;
		res="Yes\n";
		while(!a.empty()){
			x=a.top();
			a.pop();
			if(i>=m){
				res="No\n";
				break;
			}
			else if(x==b[i])
				i++;
			else{
				if(a.empty()){
					res="No\n";
					break;
				}
				else{
					y=a.top();
					a.pop();
					if(y-x>1){
						res="No\n";
						break;
					}
					else
						a.push(x+y);
				}
			}
		}
		if(i<m)
			res="No\n";
		cout<<res;
	}
	return 0;
}


Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	long long t,n,m,i,x,y;
	string res;
	cin>>t;
	while(t--){
		cin>>n>>m;
		priority_queue<long long,vector<long long>,greater<long long>> a;
		vector<long long> b;
		for(i=0;i<n;i++){
			cin>>x;
			a.push(x);
		}
		for(i=0;i<m;i++){
			cin>>x;
			b.push_back(x);
		}
		sort(b.begin(),b.end());
		i=0;
		res="Yes\n";
		while(!a.empty()){
			if(i>=m){
				res="No\n";
				break;
			}
			x=a.top();
			a.pop();
			if(x==b[i])
				i++;
			else{
				if(a.empty()){
					res="No\n";
					break;
				}
				else{
					y=a.top();
					a.pop();
					if(y-x>1){
						res="No\n";
						break;
					}
					else
						a.push(x+y);
				}
			}
		}
		if(i<m)
			res="No\n";
		cout<<res;
	}
	return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	long long t,n,m,i,x,y;
	cin>>t;
	while(t--){
		cin>>n>>m;
		priority_queue<long long,vector<long long>,greater<long long>> a;
		vector<long long> b;
		for(i=0;i<n;i++){
			cin>>x;
			a.push(x);
		}
		for(i=0;i<m;i++){
			cin>>x;
			b.push_back(x);
		}
		sort(b.begin(),b.end());
		i=0;
		while(!a.empty()){
			x=a.top();
			a.pop();
			if(i>=m)
				break;
			else if(x==b[i])
				i++;
			else{
				if(a.empty())
					break;
				else{
					y=a.top();
					a.pop();
					if(y-x>1)
						break;
					else
						a.push(x+y);
				}
			}
		}
		if(i==m&&a.empty())
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
	return 0;
}


Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	long long t,n,m,i,x;
	cin>>t;
	while(t--){
		cin>>n>>m;
		multiset<long long> a;
		stack<long long> b;
		for(i=0;i<n;i++){
			cin>>x;
			a.insert(x);
		}
		for(i=0;i<m;i++){
			cin>>x;
			b.push(x);
		}
		while(!b.empty()){
			x=b.top();
			b.pop();
			if(a.find(x)!=a.end())
				a.erase(a.find(x));
			else if(x==1){
				b.push(x);
				break;
			}
			else{
				b.push(x/2);
				b.push((x+1)/2);
			}
		}
		cout<<(b.empty()&&a.empty()?"Yes\n":"No\n");
	}
	return 0;
}
Problem: 2050D - Digital string maximization
Language: Java 21

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


import java.util.*;

import java.io.*;



public class DigitalStringMax {



public static void main(String args[]) throws Exception {

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

PrintWriter pw = new PrintWriter(System.out);



int tt = Integer.parseInt(br.readLine());

while(tt-- > 0) {



char ch[] = br.readLine().toCharArray();



int n = ch.length;

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

int max = -1;

int ind = -1;

for(int j = i;j < Math.min(n,i+8); j++){



if(max <= (ch[j] - (j - i))){

max = (ch[j] - (j - i));

ind = j;

}



}



ch[ind] = (char)(ch[ind]  - (ind - i ));

for(int j = ind; j > i; j--){

char temp = ch[j];



ch[j] = ch[j-1];

ch[j-1] = temp;



}

}



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

pw.print(ch[i]);

}

pw.println();



}

pw.flush();

}

}



Submission (verdict: Accepted):


import java.util.*;

import java.io.*;



public class DigitalStringMax {



public static void main(String args[]) throws Exception {

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

PrintWriter pw = new PrintWriter(System.out);



int tt = Integer.parseInt(br.readLine());

while(tt-- > 0) {



char ch[] = br.readLine().toCharArray();



int n = ch.length;

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

int max = -1;

int ind = -1;

for(int j = i;j < Math.min(n,i+9); j++){



if(max < (ch[j] - (j - i))){

max = (ch[j] - (j - i));

ind = j;

}



}



ch[ind] = (char)(ch[ind]  - (ind - i ));

for(int j = ind; j > i; j--){

char temp = ch[j];



ch[j] = ch[j-1];

ch[j-1] = temp;



}

}



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

pw.print(ch[i]);

}

pw.println();



}

pw.flush();

}

}
Problem: 2050D - Digital string maximization
Language: Java 21

Previous submission (verdict: Wrong answer on test 3):


import java.util.*;

import java.io.*;



public class DigitalStringMax {



public static void main(String args[]) throws Exception {

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

PrintWriter pw = new PrintWriter(System.out);



int tt = Integer.parseInt(br.readLine());

while(tt-- > 0) {



char ch[] = br.readLine().toCharArray();



int n = ch.length;

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

int max = -1;

int ind = -1;

for(int j = i;j < Math.min(n,i+8); j++){



if(max < ch[j] - (j - i)){

max = ch[j] - (j - i);

ind = j;

}



}



ch[ind] = (char)(ch[ind]  - (ind - i ));

for(int j = ind; j > i; j--){

char temp = ch[j];



ch[j] = ch[j-1];

ch[j-1] = temp;



}

}



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

pw.print(ch[i]);

}

pw.println();



}

pw.flush();

}

}



Submission (verdict: Wrong answer on test 1):


import java.util.*;

import java.io.*;



public class DigitalStringMax {



public static void main(String args[]) throws Exception {

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

PrintWriter pw = new PrintWriter(System.out);



int tt = Integer.parseInt(br.readLine());

while(tt-- > 0) {



char ch[] = br.readLine().toCharArray();



int n = ch.length;

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

int max = -1;

int ind = -1;

for(int j = i;j < Math.min(n,i+8); j++){



if(max <= (ch[j] - (j - i))){

max = (ch[j] - (j - i));

ind = j;

}



}



ch[ind] = (char)(ch[ind]  - (ind - i ));

for(int j = ind; j > i; j--){

char temp = ch[j];



ch[j] = ch[j-1];

ch[j-1] = temp;



}

}



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

pw.print(ch[i]);

}

pw.println();



}

pw.flush();

}

}
Problem: 2050D - Digital string maximization
Language: Java 21


Submission (verdict: Wrong answer on test 3):


import java.util.*;

import java.io.*;



public class DigitalStringMax {



public static void main(String args[]) throws Exception {

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

PrintWriter pw = new PrintWriter(System.out);



int tt = Integer.parseInt(br.readLine());

while(tt-- > 0) {



char ch[] = br.readLine().toCharArray();



int n = ch.length;

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

int max = -1;

int ind = -1;

for(int j = i;j < Math.min(n,i+8); j++){



if(max < ch[j] - (j - i)){

max = ch[j] - (j - i);

ind = j;

}



}



ch[ind] = (char)(ch[ind]  - (ind - i ));

for(int j = ind; j > i; j--){

char temp = ch[j];



ch[j] = ch[j-1];

ch[j-1] = temp;



}

}



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

pw.print(ch[i]);

}

pw.println();



}

pw.flush();

}

}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

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

#define fastIO                                                                 \
    ios::sync_with_stdio(false);                                               \
    cin.tie(NULL);                                                             \
    cout.tie(NULL);                                                            \
    cout.precision(numeric_limits<double>::max_digits10);
#define int long long 

void Bankai() {
    int n;
    cin>>n;
    vector<int> v(n);
    for(auto &i:v)cin>>i;
    
    vector<vector<int>> vk(n+1,vector<int>(n+1,0));
    
    vector<int> rank(n+1);
    vector<int> temp(n);
    for(int i=0;i<n;i++){
    	rank[v[i]]=i+1;
    	temp[i]=i+1;
    }
    vector<pair<int,int>> vp;
    for(int i=0;i<n;i++){
    	int yh=rank[i+1];
    	for(int j=yh;j<n;j++){
    		if(v[j]>(i+1)){
    			vp.push_back({v[j],i+1});
    		}
    	}
    	for(int j=n-1;j>=yh;j--){
    		if(v[j]>(i+1)){
    			vp.push_back({i+1,v[j]});
    		}
    	}
    	for(int j=yh-1;j>=0;j--){
    		if(v[j]>(i+1)){
    			vp.push_back({i+1,v[j]});
    		}
    	}
    }

    cout<<vp.size()<<endl;
    if(vp.size())
	for(auto &i:vp){
		cout<<i.first<<" "<<i.second<<endl;
	}
    
}
 
int32_t main() {
    fastIO;
 
    int t = 1;
   // cin >> t;
   // int a=fac(200000);
    while (t--) {
        Bankai();
    }
    return 0;
}

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

#define fastIO                                                                 \
    ios::sync_with_stdio(false);                                               \
    cin.tie(NULL);                                                             \
    cout.tie(NULL);                                                            \
    cout.precision(numeric_limits<double>::max_digits10);
#define int long long 

void Bankai() {
    int n;
    cin>>n;
    vector<int> v(n);
    for(auto &i:v)cin>>i;
    
    vector<vector<int>> vk(n+1,vector<int>(n+1,0));
    
    vector<int> rank(n+1);
    vector<int> temp(n);
    for(int i=0;i<n;i++){
    	rank[v[i]]=i+1;
    	temp[i]=i+1;
    }
    vector<pair<int,int>> vp;
    for(int i=0;i<n;i++){
    	int yh=rank[i+1];
    	for(int j=yh;j<n;j++){
    		if(v[j]>(i+1)){
    			vp.push_back({v[j],i+1});
    		}
    	}
    	for(int j=n-1;j>=yh;j--){
    		if(v[j]>(i+1)){
    			vp.push_back({i+1,v[j]});
    		}
    	}
    	for(int j=0;j<=yh-1;j++){
    		if(v[j]>(i+1)){
    			vp.push_back({v[j],i+1});
    		}
    	}
    }

    cout<<vp.size()<<endl;
    if(vp.size())
	for(auto &i:vp){
		cout<<i.first<<" "<<i.second<<endl;
	}
    
}
 
int32_t main() {
    fastIO;
 
    int t = 1;
   // cin >> t;
   // int a=fac(200000);
    while (t--) {
        Bankai();
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

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

#define fastIO                                                                 \
    ios::sync_with_stdio(false);                                               \
    cin.tie(NULL);                                                             \
    cout.tie(NULL);                                                            \
    cout.precision(numeric_limits<double>::max_digits10);
#define int long long 

void Bankai() {
    int n;
    cin>>n;
    vector<int> v(n);
    for(auto &i:v)cin>>i;
    
    vector<vector<int>> vk(n+1,vector<int>(n+1,0));
    
    vector<int> rank(n+1);
    vector<int> temp(n);
    for(int i=0;i<n;i++){
    	rank[v[i]]=i+1;
    	temp[i]=i+1;
    }
    vector<pair<int,int>> vp;
    for(int i=0;i<n-1;i++){
    	int yh=0;
    	for(int j=0;j<n-1;j++){
    		if(rank[temp[j]]>rank[temp[j+1]]){
    			yh=1;
    			//cout<<temp[j+1]<<" "<<temp[j]<<endl;
    			swap(temp[j],temp[j+1]);
    			vp.push_back({temp[j],temp[j+1]});
    			
    		}else if(vk[temp[j]][temp[j+1]]==0){
    		 vp.push_back({temp[j+1],temp[j]});
    		 vp.push_back({temp[j],temp[j+1]});
    		}
    		vk[temp[j]][temp[j+1]]=1;
    		vk[temp[j+1]][temp[j]]=0;
    	}
    	if(yh==0)break;
    }

    cout<<vp.size()<<endl;
    if(vp.size())
	for(auto &i:vp){
		cout<<i.first<<" "<<i.second<<endl;
	}
    
}
 
int32_t main() {
    fastIO;
 
    int t = 1;
   // cin >> t;
   // int a=fac(200000);
    while (t--) {
        Bankai();
    }
    return 0;
}

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

#define fastIO                                                                 \
    ios::sync_with_stdio(false);                                               \
    cin.tie(NULL);                                                             \
    cout.tie(NULL);                                                            \
    cout.precision(numeric_limits<double>::max_digits10);
#define int long long 

void Bankai() {
    int n;
    cin>>n;
    vector<int> v(n);
    for(auto &i:v)cin>>i;
    
    vector<vector<int>> vk(n+1,vector<int>(n+1,0));
    
    vector<int> rank(n+1);
    vector<int> temp(n);
    for(int i=0;i<n;i++){
    	rank[v[i]]=i+1;
    	temp[i]=i+1;
    }
    vector<pair<int,int>> vp;
    for(int i=0;i<n;i++){
    	int yh=rank[i+1];
    	for(int j=yh;j<n;j++){
    		if(v[j]>(i+1)){
    			vp.push_back({v[j],i+1});
    		}
    	}
    	for(int j=n-1;j>=yh;j--){
    		if(v[j]>(i+1)){
    			vp.push_back({i+1,v[j]});
    		}
    	}
    	for(int j=yh-1;j>=0;j--){
    		if(v[j]>(i+1)){
    			vp.push_back({i+1,v[j]});
    		}
    	}
    }

    cout<<vp.size()<<endl;
    if(vp.size())
	for(auto &i:vp){
		cout<<i.first<<" "<<i.second<<endl;
	}
    
}
 
int32_t main() {
    fastIO;
 
    int t = 1;
   // cin >> t;
   // int a=fac(200000);
    while (t--) {
        Bankai();
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)


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

#define fastIO                                                                 \
    ios::sync_with_stdio(false);                                               \
    cin.tie(NULL);                                                             \
    cout.tie(NULL);                                                            \
    cout.precision(numeric_limits<double>::max_digits10);
#define int long long 

void Bankai() {
    int n;
    cin>>n;
    vector<int> v(n);
    for(auto &i:v)cin>>i;
    
    vector<vector<int>> vk(n+1,vector<int>(n+1,0));
    
    vector<int> rank(n+1);
    vector<int> temp(n);
    for(int i=0;i<n;i++){
    	rank[v[i]]=i+1;
    	temp[i]=i+1;
    }
    vector<pair<int,int>> vp;
    for(int i=0;i<n-1;i++){
    	int yh=0;
    	for(int j=0;j<n-1;j++){
    		if(rank[temp[j]]>rank[temp[j+1]]){
    			yh=1;
    			//cout<<temp[j+1]<<" "<<temp[j]<<endl;
    			swap(temp[j],temp[j+1]);
    			vp.push_back({temp[j],temp[j+1]});
    			
    		}else if(vk[temp[j]][temp[j+1]]==0){
    		 vp.push_back({temp[j+1],temp[j]});
    		 vp.push_back({temp[j],temp[j+1]});
    		}
    		vk[temp[j]][temp[j+1]]=1;
    		vk[temp[j+1]][temp[j]]=0;
    	}
    	if(yh==0)break;
    }

    cout<<vp.size()<<endl;
    if(vp.size())
	for(auto &i:vp){
		cout<<i.first<<" "<<i.second<<endl;
	}
    
}
 
int32_t main() {
    fastIO;
 
    int t = 1;
   // cin >> t;
   // int a=fac(200000);
    while (t--) {
        Bankai();
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

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

#define fastIO                                                                 \
    ios::sync_with_stdio(false);                                               \
    cin.tie(NULL);                                                             \
    cout.tie(NULL);                                                            \
    cout.precision(numeric_limits<double>::max_digits10);
#define int long long 

void Bankai() {
    int n;
    cin>>n;
    vector<int> v(n);
    for(auto &i:v)cin>>i;
    
    vector<vector<int>> vk(n+1,vector<int>(n+1,0));
    
    vector<int> rank(n+1);
    vector<int> temp(n);
    for(int i=0;i<n;i++){
    	rank[v[i]]=i+1;
    	temp[i]=i+1;
    }
    vector<pair<int,int>> vp;
    for(int i=0;i<n;i++){
    	int yh=rank[i+1];
    	for(int j=yh;j<n;j++){
    		if(v[j]>(i+1)){
    			vp.push_back({v[j],i+1});
    		}
    	}
    	for(int j=n-1;j>=yh;j--){
    		if(v[j]>(i+1)){
    			vp.push_back({i+1,v[j]});
    		}
    	}
    	for(int j=0;j<=yh-1;j++){
    		if(v[j]>(i+1)){
    			vp.push_back({v[j],i+1});
    		}
    	}
    }

    cout<<vp.size()<<endl;
    if(vp.size())
	for(auto &i:vp){
		cout<<i.first<<" "<<i.second<<endl;
	}
    
}
 
int32_t main() {
    fastIO;
 
    int t = 1;
   // cin >> t;
   // int a=fac(200000);
    while (t--) {
        Bankai();
    }
    return 0;
}

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

#define fastIO                                                                 \
    ios::sync_with_stdio(false);                                               \
    cin.tie(NULL);                                                             \
    cout.tie(NULL);                                                            \
    cout.precision(numeric_limits<double>::max_digits10);
#define int long long 

void Bankai() {
    int n;
    cin>>n;
    vector<int> v(n);
    for(auto &i:v)cin>>i;
    
    vector<vector<int>> vk(n+1,vector<int>(n+1,0));
    
    vector<int> rank(n+1);
    vector<int> temp(n);
    for(int i=0;i<n;i++){
    	rank[v[i]]=i+1;
    	//temp[i]=i;
    }
    vector<pair<int,int>> vp;
    for(int i=0;i<n;i++){
    	int yh=rank[i+1];
    	for(int j=yh;j<n;j++){
    		if(v[j]>(i+1)){
    			vp.push_back({v[j],i+1});
    		}
    	}
    	for(int j=n-1;j>=yh;j--){
    		if(v[j]>(i+1)){
    			vp.push_back({i+1,v[j]});
    		}
    	}
    	for(int j=yh-2;j>=0;j--){
    		if(v[j]>(i+1)){
    			vp.push_back({i+1,v[j]});
    		}
    	}
    }

    cout<<vp.size()<<endl;
    if(vp.size())
	for (int i = vp.size() - 1; i >= 0; i--) cout << vp[i].second << " " << vp[i].first << endl;
    
}
 
int32_t main() {
    fastIO;
 
    int t = 1;
   // cin >> t;
   // int a=fac(200000);
    while (t--) {
        Bankai();
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define fastread() (ios_base::sync_with_stdio(false),cin.tie(NULL))
#define ll long long
#define sp " "
#define nl "\n"
 

#define ON(n,k)         ((n)| (1<<(k)))
#define OFF(n,k)        ((n)& (~(1<<(k))))
#define GetBit(n,k)     (((n)>> (k)) & 1 )
#define flibBit(n,k)    ((n)^(1<<(k)))
#define IsPowerOfTwo(n) (((n)&(n-1))==0)
#define IsOdd(n)        ((n) & 1 )


#define ONll(n,k)         ((n)| (1LL<<(k)))
#define OFFll(n,k)        ((n)& (~(1LL<<(k))))
#define GetBitll(n,k)     (((n)>> (k)) & 1LL )
#define flibBitll(n,k)    ((n)^(1LL<<(k)))
#define IsPowerOfTwoll(n) (((n)&(n-1))==0)
#define IsOddll(n)        ((n) & 1LL )


ll fast_power(ll base , ll pwr)
{
    if(pwr==0) return 1;
    ll p= fast_power(base, pwr/2);
    
    if(pwr%2 == 0) return p*p;

    return p*p*base;
}
ll sumtoN(ll n)
{
    return n*(n+1)/2;
}



const int N=1e5+5;

int n,m,u,v;
vector<int> adj[N];    
bool vis[N]; 
int depth[N];
int freq[N];



void DFS(int u,int dep)   
{
    vis[u]= true;
    depth[u]=dep;
    freq[dep]++;
    freq[dep]=freq[dep]%2;
    for(int v: adj[u])
    {
        if (!vis[v])
        {
            DFS(v,dep+1);
        }
    }

    
}

void solution()
{
    ll n,l,r;
    cin>>n>>l>>r;
    vector<int>v(n);
    for(int i=0; i<n; i++)
    {
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    ll res=0;
    for(int i=0; i<r-l+1; i++ )
    {
        res+=v[i];
    }
    cout<<res<<nl;

}


int main() {
    fastread();
 
    int t=1;
    cin>>t;
    while(t--) {
        solution();
    }
    
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pp make_pair
#define endl "\n"
#define f first
#define s second
#define TxtIO   freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define int long long
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t ;cin>>t;
    while (t--)
    {
        int n,l,r ; cin>>n>>l>>r;
        l--;r--;
        vector<int> v(n);
        for (int i = 0 ; i<n ; i++) cin>>v[i];
        sort(v.begin(),v.end());
         int ans=0;
        for (int i = 0;i<r-l+1;i++) ans+=v[i];
        cout<<ans<<endl;
    }
}
// store the indexes
// 3  6  6  4  3 2
// 8 11 11  10 - -
//  after sorting  2 3 3 4 6 6


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

using namespace std;

typedef long long ll;

#define pp make_pair

#define endl "\n"

#define f first

#define s second

#define TxtIO   freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

#define int long long



signed main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    int t ;cin>>t;

    while (t--)

    {

        int n,l,r ; cin>>n>>l>>r;

        l--;r--;

        vector<int> v(n); 

        for (int i = 0 ; i<n ; i++) cin>>v[i];



        vector<int> v1;

        vector<int> v2;

        

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

        v1.push_back(v[i]);

        v2.push_back(v[i]);

        }



        for (int i = 0 ;i<l;i++) v1.push_back(v[i]);

        for (int i = r+1 ;i<n;i++) v2.push_back(v[i]);



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

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

        int k= r-l+1;

        int ans=INT_MAX;

        int sum=0;

      //  cout<<v1.size()<<" "<<v2.size();

    //    return 0;

        for (int i = 0 ;i<k;i++) sum+=v1[i];

        ans=min(ans,sum); sum=0;

        for (int i = 0 ; i<k;i++) sum+=v2[i];

        ans=min(ans,sum);

        

        cout<<ans<<endl;



    }

}

// store the indexes

// 3  6  6  4  3 2

// 8 11 11  10 - -

//  after sorting  2 3 3 4 6 6