ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)


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

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;

        vector<int>arr;
        for(int i=0; i<n; i++)
        {
            int num;
            cin>>num;
            arr.push_back(num);
        }
        sort(arr.begin(), arr.end());

        int uniqueCount=1;

        for(int i=1; i<n; i++)
        {
            if(arr[i]!=arr[i-1])
            {
                uniqueCount++;
            }
        }
        int ans=uniqueCount-k;

        if(ans!=0)
        {
            cout<<ans<<endl;
        }
        else
        {
            cout<<"1"<<endl;
        }
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)


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

void quantas_permutacoes(int numero_carros)
{
    vector<int> posicao_final;
    posicao_final.push_back(0);
    int x;
    for (int i = 1; i <= numero_carros; i++)
    {
        cin >> x;
        posicao_final.push_back(x); 
    }

    vector<vector<int>> todas_ultrapassagens;
    vector<int> posicao_atual;
    vector <int> indices_carros_na_pos_atual;
    for (int i = 0; i <= numero_carros; i++)
    {
        posicao_atual.push_back(i);
        indices_carros_na_pos_atual.push_back(i);
    }
    vector< vector<bool> > ultrapassagens;
    for (int i = 0; i <= numero_carros; i++)
    {
        ultrapassagens.push_back({});
        for (int j = 0; j <= numero_carros; j++)
        {
            ultrapassagens[i].push_back(false);
        }
    }

    for (int i = 1; i <= numero_carros; i++)
    {
        int carro_atual = posicao_final[i];
        int indice_carro_atual_na_pos_atual = indices_carros_na_pos_atual[carro_atual];
        for (int j = indice_carro_atual_na_pos_atual; j >= i+1; j--)
        {
            int carro1 = posicao_atual[j-1];
            int carro2 = posicao_atual[j];
            ultrapassagens[carro1][carro2] = true;
            ultrapassagens[carro2][carro1] = true;
            posicao_atual[j - 1] = posicao_atual[j];
            posicao_atual[j] = carro1;
            int auxiliar = indices_carros_na_pos_atual[carro1];
            indices_carros_na_pos_atual[carro1] = indices_carros_na_pos_atual[carro2];
            indices_carros_na_pos_atual[carro2] = auxiliar;
            todas_ultrapassagens.push_back({carro2,carro1});
        }
    }
    
    for (int j = 1; j <= posicao_atual.size() - 2; j++)
    {
        if (!ultrapassagens[j][j+1])
        {
            todas_ultrapassagens.push_back({j+1,j});
            todas_ultrapassagens.push_back({j,j+1});
        }
    }
    
    cout << todas_ultrapassagens.size() << endl;
    for (int i = 0; i < static_cast<int>(todas_ultrapassagens.size());i++)
    {
        cout << todas_ultrapassagens[i][0] << " " <<  todas_ultrapassagens[i][1] << endl;
    }

}




int main()
{
    int numero_carros;
    cin >> numero_carros;
    quantas_permutacoes(numero_carros);
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)


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



#include<ext/pb_ds/assoc_container.hpp>

#include<ext/pb_ds/tree_policy.hpp>



using namespace std;

using namespace __gnu_pbds;



typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key



#define ll long long

#define gap " "

#define nline "\n"

#define pi 2 * acos(0.0)

#define yes cout<<"YES\n"

#define no cout<<"NO\n"

#define bigger greater<int>()



const int inf = INT_MAX;

const int mod = 1e9 + 7;



#ifndef ONLINE_JUDGE

#include "template.cpp"

#else

#define debug(...)

#define debugArr(...)

#endif









signed main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);



#ifndef ONLINE_JUDGE

    freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);

#endif



    int testCases;

    cin >> testCases;

    while (testCases--){

        string s;

        cin>>s;



        vector<int> v;



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

            v.push_back(s[i]-'0');

        }



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

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

            priority_queue<pair<int, int>> pq;

            pq.push({v[i], i});



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

                if(v[j]<v[i]){

                    continue;

                }else{

                    pq.push({v[j]-j+i, j});

                }

            }

            debug(pq);

            int val = pq.top().first;

            int pos = pq.top().second;



            while(!pq.empty()){

                if(pq.top().first==val){

                    pos = pq.top().second;

                    pq.pop();

                }else{

                    break;

                }

            }

            

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

                v[j] = v[j-1];

            }

            v[i] = val;

        }



        for(int i: v){

            cout<<i;

        }

        cout<<nline;

    }

}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

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

int main(void)
{   
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int32_t l, r; 
    std::cin>>l>>r; 
    int32_t num1 = l, num2 = r, pos = -1; 

    for(int32_t i = 0; i <= 29; ++i)
    {
        if((l & (1 << i)) != (r & (1 << i)))
        {
            pos = i;
        }
    }

    if(pos != -1)
    {
        num1 = l | ((1 << pos) - 1);
        num2 = num1 + 1; 
        int32_t num3 = r; 

        while(num3 == num1 || num3 == num2)
        {
            --num3; 
        }

        std::cout << num1 << " " << num2 << " " << num3 << "\n";
    }
    else
    {
        std::cout << "No valid position found\n";
    }
}


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

int main(void)
{   
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int32_t t; std::cin>>t; 
while(t--)
{
    int32_t l, r; 
    std::cin>>l>>r; 
    int32_t num1 = l, num2 = r, pos = -1; 

    for(int32_t i = 0; i <= 29; ++i)
    {
        if((l & (1 << i)) != (r & (1 << i)))
        {
            pos = i;
        }
    }

    if(pos != -1)
    {
        num1 = l | ((1 << pos) - 1);
        num2 = num1 + 1; 
        int32_t num3 = r; 

        while(num3 == num1 || num3 == num2)
        {
            --num3; 
        }

        std::cout << num1 << " " << num2 << " " << num3 << "\n";
    }
    else
    {
        std::cout << "No valid position found\n";
    }
}
    
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef __gnu_pbds::tree<int, __gnu_pbds::null_type, less<int>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> ordered_set;

#define ll  long long
#define ull unsigned long long
#define lld long double
#define pb push_back
const int INF_INT= std::numeric_limits<int32_t>::max();
const ull INF_ULL= std::numeric_limits<ull>::max();

int main(void)
{   
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int32_t t; cin>>t;
    while(t--)
    {
        /*nt32_t n,k; std::cin>>n>>k; 
        std::vector<ll>vec(n);
        unordered_map<ll, int> map_count;

        for(int32_t i=0; i<n; ++i)
        {
            std::cin>>vec[i]; 
            map_count[vec[i]]++; 
        }

	std::vector<int32_t>vec_count; 
       

       // int32_t freq_count= INT_MIN; 
	//ll freq_num;    

        for(const auto& it : map_count)
		vec_count.pb(it.second); 
            //if(it.second > freq_count)
            {
                freq_count = it.second; 
                freq_num = it.first;
            }
        }
            
	sort(vec_count.begin(), vec_count.end());
	int32_t ans= vec_count.size(); //pop_back(); 
	vec_count.pop_back();  

        //int32_t same_count=0; 
        for(const auto& it : vec_count)
            if(it <= k)
	    {
		    --ans; 
		    k-=it; 

	    }
                //++same_count; 

        std::cout<<ans<<"\n"; //-same_count<<"\n";
    }*/
		
    	int32_t l,r; std::cin>>l>>r; 
	int32_t num1= l, num2=r, pos; 
	//int32_t maxi=0; 
	for(int32_t i=0; i<=29; ++i)
	{
		if((l&(1<<i)) != (r&(1<<i)))
		{
			pos=i;
			break; 
		}
	}
			
	num1= l|((1<<pos)-1);
	num2= num1+1; 
	int32_t num3=r; 

	while(num3==num1 || num3==num2)
	{
		--num3; 
	}

	std::cout<<num1<<" "<<num2<<" "<<num3<<"\n";
	
	

	//std::cout<<maxi<<"\n";

    }
    
    
}


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

int main(void)
{   
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int32_t l, r; 
    std::cin>>l>>r; 
    int32_t num1 = l, num2 = r, pos = -1; 

    for(int32_t i = 0; i <= 29; ++i)
    {
        if((l & (1 << i)) != (r & (1 << i)))
        {
            pos = i;
        }
    }

    if(pos != -1)
    {
        num1 = l | ((1 << pos) - 1);
        num2 = num1 + 1; 
        int32_t num3 = r; 

        while(num3 == num1 || num3 == num2)
        {
            --num3; 
        }

        std::cout << num1 << " " << num2 << " " << num3 << "\n";
    }
    else
    {
        std::cout << "No valid position found\n";
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef __gnu_pbds::tree<int, __gnu_pbds::null_type, less<int>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> ordered_set;

#define ll  long long
#define ull unsigned long long
#define lld long double
#define pb push_back
const int INF_INT= std::numeric_limits<int32_t>::max();
const ull INF_ULL= std::numeric_limits<ull>::max();

int main(void)
{   
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int32_t t; cin>>t;
    while(t--)
    {
        /*nt32_t n,k; std::cin>>n>>k; 
        std::vector<ll>vec(n);
        unordered_map<ll, int> map_count;

        for(int32_t i=0; i<n; ++i)
        {
            std::cin>>vec[i]; 
            map_count[vec[i]]++; 
        }

	std::vector<int32_t>vec_count; 
       

       // int32_t freq_count= INT_MIN; 
	//ll freq_num;    

        for(const auto& it : map_count)
		vec_count.pb(it.second); 
            //if(it.second > freq_count)
            {
                freq_count = it.second; 
                freq_num = it.first;
            }
        }
            
	sort(vec_count.begin(), vec_count.end());
	int32_t ans= vec_count.size(); //pop_back(); 
	vec_count.pop_back();  

        //int32_t same_count=0; 
        for(const auto& it : vec_count)
            if(it <= k)
	    {
		    --ans; 
		    k-=it; 

	    }
                //++same_count; 

        std::cout<<ans<<"\n"; //-same_count<<"\n";
    }*/
		
    	int32_t l,r; std::cin>>l>>r; 
	int32_t num1= l, num2=r, pos; 
	//int32_t maxi=0; 
	for(int32_t i=29; i>=0; --i)
	{
		if((l&(1<<i)) != (r&(1<<i)))
		{
			pos=i;
			break; 
		}
	}
			
	num1= l|(1<<pos);
	num2= num1+1; 
	int32_t num3=r; 

	while(num3==num1 || num3==num2)
	{
		--num3; 
	}

	std::cout<<num1<<" "<<num2<<" "<<num3<<"\n";
	
	

	//std::cout<<maxi<<"\n";

    }
    
    
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int main(){
    int t ; cin>>t;
    while(t--){
        int n , k ; cin>>n>>k ;
        vector<int> a ;
        map<int,int> m ; 
        for(int i = 0 ; i< n ; i++) {
            int x ; cin>>x ;
            a.push_back(x);
            m[x]++ ;
        }
        vector<int> x ; 
        for(auto i : m){
            x.push_back(i.second);
        }
        sort(x.begin() , x.end());
        int ans = x.size();
        for(auto i : x){
            if(k > i){
                ans--;
                k-=i;
            }
        }
        cout<<ans<<endl;

    }
    return 0 ;
}

Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int main(){
    int t ; cin>>t;
    while(t--){
        int n , k ; cin>>n>>k ;
        vector<int> a ;
        map<int,int> m ; 
        for(int i = 0 ; i< n ; i++) {
            int x ; cin>>x ;
            a.push_back(x);
            m[x]++ ;
        }
        vector<int> x ; 
        for(auto i : m){
            x.push_back(i.second);
        }
        sort(x.begin() , x.end());
        int ans = x.size();
        for(auto i : x){
            if(k >= i){
                ans--;
                k-=i;
            }
        }
        cout<<ans<<endl;

    }
    return 0 ;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int main(){
    int t ; cin>>t;
    while(t--){
        int n , k ; cin>>n>>k ;
        vector<int> a ;
        map<int,int> m ; 
        for(int i = 0 ; i< n ; i++) {
            int x ; cin>>x ;
            a.push_back(x);
            m[x]++ ;
        }
        vector<int> x ; 
        for(auto i : m){
            x.push_back(i.second);
        }
        sort(x.begin() , x.end());
        int ans = x.size();
        for(auto i : x){
            if(k >= i){
                ans--;
                k-=i;
            }
        }
        cout<<ans<<endl;

    }
    return 0 ;
}

Submission (verdict: Accepted):
#include<iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int main(){
    int t ; cin>>t;
    while(t--){
        int n , k ; cin>>n>>k ;
        vector<int> a ;
        map<int,int> m ; 
        for(int i = 0 ; i< n ; i++) {
            int x ; cin>>x ;
            a.push_back(x);
            m[x]++ ;
        }
        vector<int> x ; 
        for(auto i : m){
            x.push_back(i.second);
        }
        sort(x.begin() , x.end());
        int ans = x.size();
        for(auto i : x){
            if(k >= i){
                ans--;
                k-=i;
            }
        }
        cout<<max(ans,1)<<endl;

    }
    return 0 ;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int main(){
    int t ; cin>>t;
    while(t--){
        int n , k ; cin>>n>>k ;
        vector<int> a ;
        map<int,int> m ; 
        for(int i = 0 ; i< n ; i++) {
            int x ; cin>>x ;
            a.push_back(x);
            m[x]++ ;
        }
        vector<int> x ; 
        for(auto i : m){
            x.push_back(i.second);
        }
        sort(x.begin() , x.end());
        int ans = x.size();
        for(auto i : x){
            if(k > i){
                ans--;
                k-=i;
            }
        }
        cout<<ans<<endl;

    }
    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;
#define ll long long
#define double long double
#define endl '\n'
#define JAYSHRIRAM ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(NULL);
int lcm2(int a,int b){return (a*b)/ __gcd(a,b);}
int lcm3(int a, int b, int c){ return lcm2(a,lcm2(b,c));}
int lcm4(int a,int b, int c, int d){ return lcm2(lcm2(a,b), lcm2(c,d));}


const long long MOD=1e9+7;
const long long inf=1e9+8;







void solve(){
    ll n,l,r;
    cin>>n>>l>>r;
    vector<ll> arr(n),arr1(n);
    ll length=r-l+1;
    for(ll i=0;i<n;i++){
        cin>>arr[i];
    }
    arr1=arr;
    sort(arr.begin(),arr.begin()+r);
    ll sum1=0;
    for(ll i=0;i<length;i++){
        sum1+=arr[i];
    }
    sort(arr.begin()+l-1,arr.end());
    ll sum2=0;
    for(ll i=l-1;i<length+l-1;i++){
        sum2+=arr[i];
    }
    // cout<<sum1<<" "<<sum2<<endl;
    cout<<min(sum1,sum2)<<endl;


}           




signed main () {
    JAYSHRIRAM  
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }    
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define double long double
#define endl '\n'
#define JAYSHRIRAM ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(NULL);
int lcm2(int a,int b){return (a*b)/ __gcd(a,b);}
int lcm3(int a, int b, int c){ return lcm2(a,lcm2(b,c));}
int lcm4(int a,int b, int c, int d){ return lcm2(lcm2(a,b), lcm2(c,d));}


const long long MOD=1e9+7;
const long long inf=1e9+8;







void solve(){
    ll n,l,r;
    cin>>n>>l>>r;
    vector<ll> arr(n),arr1(n);
    ll length=r-l+1;
    for(ll i=0;i<n;i++){
        cin>>arr[i];
    }
    arr1=arr;
    sort(arr.begin(),arr.begin()+r);
    ll sum1=0;
    for(ll i=0;i<length;i++){
        sum1+=arr[i];
    }
    sort(arr1.begin()+l-1,arr1.end());
    ll sum2=0;
    for(ll i=l-1;i<length+l-1;i++){
        sum2+=arr1[i];
    }
    // cout<<sum1<<" "<<sum2<<endl;
    cout<<min(sum1,sum2)<<endl;


}           




signed main () {
    JAYSHRIRAM  
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }    
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)


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

using namespace std;

#define ll long long

#define double long double

#define endl '\n'

#define JAYSHRIRAM ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(NULL);

int lcm2(int a,int b){return (a*b)/ __gcd(a,b);}

int lcm3(int a, int b, int c){ return lcm2(a,lcm2(b,c));}

int lcm4(int a,int b, int c, int d){ return lcm2(lcm2(a,b), lcm2(c,d));}





const long long MOD=1e9+7;

const long long inf=1e9+8;















void solve(){

    ll n,l,r;

    cin>>n>>l>>r;

    vector<ll> arr(n),arr1(n);

    ll length=r-l+1;

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

        cin>>arr[i];

    }

    arr1=arr;

    sort(arr.begin(),arr.begin()+r-1);

    ll sum1=0;

    for(ll i=0;i<length;i++){

        sum1+=arr[i];

    }

    sort(arr.begin()+l-1,arr.end());

    ll sum2=0;

    for(ll i=0;i<length;i++){

        sum2+=arr[i];

    }



    cout<<min(sum1,sum2)<<endl;





}           









signed main () {

    JAYSHRIRAM  

    int t=1;

    cin>>t;

    while(t--){

        solve();

    }    

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

#define ll long long

#define double long double

#define endl '\n'

#define JAYSHRIRAM ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(NULL);

int lcm2(int a,int b){return (a*b)/ __gcd(a,b);}

int lcm3(int a, int b, int c){ return lcm2(a,lcm2(b,c));}

int lcm4(int a,int b, int c, int d){ return lcm2(lcm2(a,b), lcm2(c,d));}





const long long MOD=1e9+7;

const long long inf=1e9+8;















void solve(){

    ll n,l,r;

    cin>>n>>l>>r;

    vector<ll> arr(n),arr1(n);

    ll length=r-l+1;

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

        cin>>arr[i];

    }

    arr1=arr;

    sort(arr.begin(),arr.begin()+r-1);

    ll sum1=0;

    for(ll i=0;i<length;i++){

        sum1+=arr[i];

    }

    sort(arr.begin()+l-1,arr.end());

    ll sum2=0;

    for(ll i=l-1;i<length+l-1;i++){

        sum2+=arr[i];

    }

    // cout<<sum1<<" "<<sum2<<endl;

    cout<<min(sum1,sum2)<<endl;





}           









signed main () {

    JAYSHRIRAM  

    int t=1;

    cin>>t;

    while(t--){

        solve();

    }    

}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define double long double
#define endl '\n'
#define JAYSHRIRAM ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(NULL);
int lcm2(int a,int b){return (a*b)/ __gcd(a,b);}
int lcm3(int a, int b, int c){ return lcm2(a,lcm2(b,c));}
int lcm4(int a,int b, int c, int d){ return lcm2(lcm2(a,b), lcm2(c,d));}


const long long MOD=1e9+7;
const long long inf=1e9+8;







void solve(){
    ll n,l,r;
    cin>>n>>l>>r;
    vector<ll> arr(n),arr1(n);
    ll length=r-l+1;
    for(ll i=0;i<n;i++){
        cin>>arr[i];
    }
    arr1=arr;
    sort(arr.begin(),arr.begin()+r);
    ll sum1=0;
    for(ll i=0;i<length;i++){
        sum1+=arr[i];
    }
    sort(arr.begin()+l-1,arr.end());
    ll sum2=0;
    for(ll i=l-1;i<length+l-1;i++){
        sum2+=arr[i];
    }
    // cout<<sum1<<" "<<sum2<<endl;
    cout<<min(sum1,sum2)<<endl;


}           




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

#define ll long long

#define double long double

#define endl '\n'

#define JAYSHRIRAM ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(NULL);

int lcm2(int a,int b){return (a*b)/ __gcd(a,b);}

int lcm3(int a, int b, int c){ return lcm2(a,lcm2(b,c));}

int lcm4(int a,int b, int c, int d){ return lcm2(lcm2(a,b), lcm2(c,d));}





const long long MOD=1e9+7;

const long long inf=1e9+8;















void solve(){

    ll n,l,r;

    cin>>n>>l>>r;

    vector<ll> arr(n),arr1(n);

    ll length=r-l+1;

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

        cin>>arr[i];

    }

    arr1=arr;

    sort(arr.begin(),arr.begin()+r-1);

    ll sum1=0;

    for(ll i=0;i<length;i++){

        sum1+=arr[i];

    }

    sort(arr.begin()+l-1,arr.end());

    ll sum2=0;

    for(ll i=0;i<length;i++){

        sum2+=arr[i];

    }



    cout<<min(sum1,sum2)<<endl;





}           









signed main () {

    JAYSHRIRAM  

    int t=1;

    cin>>t;

    while(t--){

        solve();

    }    

}

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

using namespace std;

#define ll long long

#define double long double

#define endl '\n'

#define JAYSHRIRAM ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(NULL);

int lcm2(int a,int b){return (a*b)/ __gcd(a,b);}

int lcm3(int a, int b, int c){ return lcm2(a,lcm2(b,c));}

int lcm4(int a,int b, int c, int d){ return lcm2(lcm2(a,b), lcm2(c,d));}





const long long MOD=1e9+7;

const long long inf=1e9+8;















void solve(){

    ll n,l,r;

    cin>>n>>l>>r;

    vector<ll> arr(n),arr1(n);

    ll length=r-l+1;

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

        cin>>arr[i];

    }

    arr1=arr;

    sort(arr.begin(),arr.begin()+r-1);

    ll sum1=0;

    for(ll i=0;i<length;i++){

        sum1+=arr[i];

    }

    sort(arr.begin()+l-1,arr.end());

    ll sum2=0;

    for(ll i=l-1;i<length+l-1;i++){

        sum2+=arr[i];

    }

    // cout<<sum1<<" "<<sum2<<endl;

    cout<<min(sum1,sum2)<<endl;





}           









signed main () {

    JAYSHRIRAM  

    int t=1;

    cin>>t;

    while(t--){

        solve();

    }    

}