ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050B - Transfusion
Language: C++23 (GCC 14-64, msys2)

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

int main () {
        ios::sync_with_stdio(0), cin.tie(nullptr);
        int t;
        cin >> t;
        while (t--) {
                int n, sp=0, si=0, qi=0, qp;
                cin >> n;
                for (int i=0; i<n; i++) {
                        int x;
                        cin >> x;
                        if (i % 2 == 1) {
                                qi++;
                                si += x;
                        }
                        else sp += x;
                }
                qp = n - qi;
                if ((sp / qp) == (si / qi) && (si % qi == 0)&& (sp % qp == 0)) cout << "YES\n";
                else cout << "NO\n";
        }
}

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

int main () {
        ios::sync_with_stdio(0), cin.tie(nullptr);
        int t;
        cin >> t;
        while (t--) {
                int n, qi=0, qp;
                long long int si = 0, sp = 0;
                cin >> n;
                for (int i=0; i<n; i++) {
                        int x;
                        cin >> x;
                        if (i % 2 == 1) {
                                qi++;
                                si += x;
                        }
                        else sp += x;
                }
                qp = n - qi;
                if ((sp / qp) == (si / qi) && (si % qi == 0)&& (sp % qp == 0)) cout << "YES\n";
                else cout << "NO\n";
        }
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


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

#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned ll

#define v vector
#define vll vector<ll>
#define vb vector<bool>

#define p pair
#define pll pair<ll, ll>

#define uset unordered_set
#define umap unordered_map
#define sll set<ll>
#define mpll map<ll, ll>

#define dqll deque<ll>
#define stll stack<ll>
#define qll queue<ll>

#define fi first
#define se second

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front

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

using namespace std;

// STRUCTS & CLASSES
///////////////////////////////////////////////////////////////////////////



// GLOBALS
///////////////////////////////////////////////////////////////////////////

ll n, t;
vll arr;

// HELPER FUNCS
///////////////////////////////////////////////////////////////////////////

vll diff(vll& arr)
{
    vll res(arr.size() - 1);
    for (ll i = 0; i < arr.size() - 1; i++)
    {
        res[i] = arr[i + 1] - arr[i];
    }
    return res;
}

ll sum(vll& arr)
{
    ll res = 0;
    for (auto i : arr)
    {
        res += i;
    }
    return res;
}

ll solve(vll& arr)
{
    if (arr.size() == 1)
    {
        return arr[0];
    }

    ll res = LONG_MIN;
    ll s = sum(arr);
    vll d = diff(arr);
    ll s1 = solve(d);
    return max(s, abs(s1));
}

// MAIN
///////////////////////////////////////////////////////////////////////////

int main()
{
    fastio;
//    freopen("test.inp", "r", stdin);
//    freopen("test.out", "w", stdout);

    // input
    cin >> t;

    // solve
    while (t--)
    {
        // test input
        cin >> n;
        arr.resize(n);
        for (ll i = 0; i < n; i++)
            cin >> arr[i];

        // test solve
//        cout << arr << "\n\n";

        cout << solve(arr) << '\n';
    }

    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

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

#include <bits/stdc++.h>

using namespace std;

#define fi first

#define se second

#define ll long long

#define ps push

const ll N=2e5+5;

const ll mod=1e9+7;

const ll INF=1e18;

#define endl '\n'

#define pb push_back

#define th third

#define fo four

ll n,m,k,i,j,x,y,z,a[N];

int main() {

#ifndef ONLINE_JUDGE

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

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

#endif

ll t;

cin >> t;

while (t--){

string s;

cin >> s;

n=s.size();

for (i=0;i<s.size();i++) a[i+1]=s[i]-'0';

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

ll ma=a[i],pos=i;

for (j=i+1;j<=min(n,i+9);j++){

if (a[j]-(j-i)>ma){

pos=j;ma=s[j]-(j-i);

}

}

swap(a[i],a[pos]);

}

for (i=1;i<=n;i++) cout << a[i];

cout << endl;

}

return 0;

}



Submission (verdict: Wrong answer on test 1):
//Lingshaisthebest

#include <bits/stdc++.h>

using namespace std;

#define fi first

#define se second

#define ll long long

#define ps push

const ll N=2e5+5;

const ll mod=1e9+7;

const ll INF=1e18;

#define endl '\n'

#define pb push_back

#define th third

#define fo four

ll n,m,k,i,j,x,y,z,a[N];

int main() {

#ifndef ONLINE_JUDGE

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

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

#endif

ll t;

cin >> t;

while (t--){

string s;

cin >> s;

n=s.size();

for (i=0;i<s.size();i++) a[i+1]=s[i]-'0';

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

ll ma=a[i],pos=i;

for (j=i+1;j<=min(n,i+9);j++){

if (a[j]-(j-i)>ma){

pos=j;ma=a[j]-(j-i);

}

}

a[pos]=ma;

swap(a[i],a[pos]);

}

for (i=1;i<=n;i++) cout << a[i];

cout << endl;

}

return 0;

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

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

#include <bits/stdc++.h>

using namespace std;

#define fi first

#define se second

#define ll long long

#define ps push

const ll N=2e5+5;

const ll mod=1e9+7;

const ll INF=1e18;

#define endl '\n'

#define pb push_back

#define th third

#define fo four

ll n,m,k,i,j,x,y,z,a[N];

int main() {

#ifndef ONLINE_JUDGE

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

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

#endif

ll t;

cin >> t;

while (t--){

string s;

cin >> s;

n=s.size();

for (i=0;i<s.size();i++) a[i+1]=s[i]-'0';

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

ll ma=a[i],pos=i;

for (j=i+1;j<=min(n,i+9);j++){

if (a[j]-(j-i)>ma){

pos=j;ma=a[j]-(j-i);

}

}

a[pos]=ma;

swap(a[i],a[pos]);

}

for (i=1;i<=n;i++) cout << a[i];

cout << endl;

}

return 0;

}



Submission (verdict: Accepted):
//Lingshaisthebest

#include <bits/stdc++.h>

using namespace std;

#define fi first

#define se second

#define ll long long

#define ps push

const ll N=2e5+5;

const ll mod=1e9+7;

const ll INF=1e18;

#define endl '\n'

#define pb push_back

#define th third

#define fo four

ll n,m,k,i,j,x,y,z,a[N];

int main() {

#ifndef ONLINE_JUDGE

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

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

#endif

ll t;

cin >> t;

while (t--){

string s;

cin >> s;

n=s.size();

for (i=0;i<s.size();i++) a[i+1]=s[i]-'0';

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

ll ma=a[i],pos=i;

for (j=i+1;j<=min(n,i+9);j++){

if (a[j]-(j-i)>ma){

pos=j;ma=a[j]-(j-i);

}

}

a[pos]=ma;

while (pos>i){

swap(a[pos],a[pos-1]);

pos--;

}

}

for (i=1;i<=n;i++) cout << a[i];

cout << endl;

}

return 0;

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
//Lingshaisthebest

#include <bits/stdc++.h>

using namespace std;

#define fi first

#define se second

#define ll long long

#define ps push

const ll N=2e5+5;

const ll mod=1e9+7;

const ll INF=1e18;

#define endl '\n'

#define pb push_back

#define th third

#define fo four

ll n,m,k,i,j,x,y,z,a[N];

int main() {

#ifndef ONLINE_JUDGE

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

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

#endif

ll t;

cin >> t;

while (t--){

string s;

cin >> s;

n=s.size();

for (i=0;i<s.size();i++) a[i+1]=s[i]-'0';

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

ll ma=a[i],pos=i;

for (j=i+1;j<=min(n,i+9);j++){

if (a[j]-(j-i)>ma){

pos=j;ma=s[j]-(j-i);

}

}

swap(a[i],a[pos]);

}

for (i=1;i<=n;i++) cout << a[i];

cout << endl;

}

return 0;

}
Problem: 2061D - Kevin and Numbers
Language: Java 21


Submission (verdict: Wrong answer on test 2):
import java.util.*;

public class Picky {
    //public static int mod = 998244353;

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();

        while(t-->0){
            int n=sc.nextInt();
            int m=sc.nextInt();
            int[] a=new int[n];
            int[] b=new int[m];

            HashMap<Integer, Integer> mp1 = new HashMap<>();
            HashMap<Integer, Integer> mp2 = new HashMap<>();

            for(int i=0; i<n; i++){
                a[i]=sc.nextInt();
                mp1.put(a[i], mp1.getOrDefault(a[i], 0)+1);
            }
            for(int i=0; i<m; i++){
                b[i]=sc.nextInt();
                mp2.put(b[i], mp2.getOrDefault(b[i], 0)+1);
            }

            Arrays.sort(a);
            Arrays.sort(b);

            if(n==m){
                if (mp1.equals(mp2)) System.out.println("YES");
                else System.out.println("NO");
            }
            else{
                int i=0, cnt=0;
                while(i<n){
                    int f=0;
                    while(i<n){
                        if(f!=0 && Math.abs(f-a[i])>1) break;
                        f+=a[i];

                        if(mp1.containsKey(a[i])){
                            mp1.put(a[i], mp1.get(a[i])-1);
                            if(mp1.get(a[i])==0) mp1.remove(a[i]);
                        }
                        i++;

                        if(mp2.containsKey(f)) break;
                    }

                    if(mp2.containsKey(f)){
                        cnt++;
                        if(mp2.get(f)>0){
                            mp2.put(f, mp2.get(f)-1);
                            if (mp2.get(f) == 0) mp2.remove(f);
                        }
                    }
                    if(mp2.size()==0) break;
                }

                if(cnt==m && i==n && mp1.size()==0 && mp2.size()==0) System.out.println("YES");
                else System.out.println("NO");
            }
        }
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define ll long long
using namespace std;
string bin(ll x){
	string ans = "";
	while(x){
		ans += char(x % 2 + '0');
		x /= 2;
	}
	 reverse(ans.begin(), ans.end());
	return ans;
}
ll num(string x){
	ll ans = 0;
	for(int i = 0; i < x.size(); i++) {
		if(x[i] == '1') ans += (ll)powl(2, x.size() - i - 1);
	}
	return ans;
}
int main(){
    ll t, n, l, r;
	cin >> t;
	while(t--){
		cin >> l >> r; 
		string x = bin(r), ans = "";
		for(int i = 0; i < x.size(); i++){
			if(x[i] == '0') ans += '1';
			else ans += '0';
		}
		//cout << x << " " << ans << "\n";
		for(int i = ans.size() - 1; i >= 0; i--){
			if(num(ans) < l) ans[i] = '1';
			else break;
			//cout << ans << "y\n";
		}
		cout << r << " " << num(ans) << " ";
		for(int i = l; i <= r; i++) {if(i != r && i != num(ans)) {cout << i; break;}}
		cout << "\n";
	}
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define ll long long
using namespace std;
string bin(ll x){
	string ans = "";
	while(x){
		ans += char(x % 2 + '0');
		x /= 2;
	}
	 reverse(ans.begin(), ans.end());
	return ans;
}
ll num(string x){
	ll ans = 0;
	for(int i = 0; i < x.size(); i++) {
		if(x[i] == '1') ans += (ll)powl(2, x.size() - i - 1);
	}
	return ans;
}
int main(){
    ll t, n, l, r;
	cin >> t;
	while(t--){
		cin >> l >> r; 
		string x = bin(r), ans = "";
		for(int i = 0; i < x.size(); i++){
			if(x[i] == '0') ans += '1';
			else ans += '0';
		}
		//cout << x << " " << ans << "\n";
		for(int i = ans.size() - 1; i >= 0; i--){
			if(num(ans) < l) ans[i] = '1';
			else break;
			//cout << ans << "y\n";
		}
		cout << r << " " << num(ans) << " ";
		for(int i = l; i <= r; i++) {if(i != r && i != num(ans)) {cout << i; break;}}
		cout << "\n";
	}
}


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define ll long long
using namespace std;
string bin(ll x){
	string ans = "";
	while(x){
		ans += char(x % 2 + '0');
		x /= 2;
	}
	 reverse(ans.begin(), ans.end());
	return ans;
}
ll num(string x){
	ll ans = 0;
	for(int i = 0; i < x.size(); i++) {
		if(x[i] == '1') ans += (ll)powl(2, x.size() - i - 1);
	}
	return ans;
}
int main(){
    ll t, n, l, r;
	cin >> t;
	while(t--){
		cin >> l >> r; 
		string x = bin(r), ans = "";
		for(int i = 0; i < x.size(); i++){
			if(x[i] == '0') ans += '1';
			else ans += '0';
		}
		//cout << x << " " << ans << "\n";
		for(int i = ans.size() - 1; i >= 0; i--){
			if(num(ans) < l) ans[i] = '1';
			else break;
			//cout << ans << "y\n";
		}
		for(int i = ans.size() - 1; i >= 0; i--){
			if(num(ans) > r) ans[i] = '0';
			else break;
			//cout << ans << "y\n";
		}
		cout << r << " " << num(ans) << " ";
		for(int i = l; i <= r; i++) {if(i != r && i != num(ans)) {cout << i; break;}}
		cout << "\n";
	}
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define ll long long
using namespace std;
string bin(ll x){
	string ans = "";
	while(x){
		ans += char(x % 2 + '0');
		x /= 2;
	}
	 reverse(ans.begin(), ans.end());
	return ans;
}
ll num(string x){
	ll ans = 0;
	for(int i = 0; i < x.size(); i++) {
		if(x[i] == '1') ans += (ll)powl(2, x.size() - i - 1);
	}
	return ans;
}
int main(){
    ll t, n, l, r;
	cin >> t;
	while(t--){
		cin >> l >> r; 
		string x = bin(r), ans = "";
		for(int i = 0; i < x.size(); i++){
			if(x[i] == '0') ans += '1';
			else ans += '0';
		}
		//cout << x << " " << ans << "\n";
		for(int i = ans.size() - 1; i >= 0; i--){
			if(num(ans) < l) ans[i] = '1';
			else break;
			//cout << ans << "y\n";
		}
		for(int i = ans.size() - 1; i >= 0; i--){
			if(num(ans) > r) ans[i] = '0';
			else break;
			//cout << ans << "y\n";
		}
		cout << r << " " << num(ans) << " ";
		for(int i = l; i <= r; i++) {if(i != r && i != num(ans)) {cout << i; break;}}
		cout << "\n";
	}
}


Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define ll long long
using namespace std;
string bin(ll x){
	string ans = "";
	while(x){
		ans += char(x % 2 + '0');
		x /= 2;
	}
	 reverse(ans.begin(), ans.end());
	return ans;
}
ll num(string x){
	ll ans = 0;
	for(int i = 0; i < x.size(); i++) {
		if(x[i] == '1') ans += (ll)powl(2, x.size() - i - 1);
	}
	return ans;
}
int main(){
    ll t, n, l, r;
	cin >> t;
	while(t--){
		cin >> l >> r; ll ans = 0, a, b, c;
    for (int i = 30; i >= 0; i--) {
        ll b1 = 0;
        ll b2 = 0;
        if (l & (1ll << i))
        {
            b1 = 1;
        }
        if (r & (1ll << i))
        {
            b2 = 1;
        }
        if (b1 == b2)
        {
            ans += b1 * (1ll << i);
        }
        else
        {
            a = ans + (1ll << i);
            b = a - 1;
            break;
        }
    }
    for (ll i = l; i <= r; i++)
    {
        if (i != a && i != b)
        {
            c = i;
            break;
        }
    }
    cout << a << " " << b << " " << c << endl;
	}
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 6):
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define fn for(ll i = 0; i<n; i++)
#define fx(n) for(ll i = 0; i<n; i++)
#define fix(e, n) for(ll i = e; i<n; i++)
#ifndef ONLINE_JUDGE
#define debug(...) cerr<<#__VA_ARGS__<<":";_print(__VA_ARGS__)
#define debug_a(arr, n) cerr<<#arr<<":";_print(arr, n)
#define edl cerr<<endl
#else
#define debug(...)
#define debug_a(arr, n)
#define edl
#endif

template<class T> void _print(T x) {cerr<<x<<" ";}
template<class T, class U> void _print(pair<T, U> p) {cerr<<p.first<<" "<<p.second<<endl;}
template<class T> void _print(vector<T> &v) {cerr<<"[ ";for(auto &e:v)_print(e);cerr<<"]";edl;}
template<class T> void _print(vector<vector<T>> &v) {cerr<<'[';edl;for(auto &e:v)_print(e);cerr<<']';edl;}
template<class T, class U> void _print(T *arr, U n) {cerr<<"[ ";fx(n)_print(arr[i]);cerr<<"]";edl;}
template<class... Args> void _print(Args... args) {cerr<<"{ ";((cerr<<args<<", "), ...);cerr<<"\033[2D }";cerr<<endl;}
//template<class T, class... Args> void _print(T first, Args... args) {cerr<<"{ ";_print(first); cerr<<"a";_print(args...);cerr<<" }";edl;} //alt way to do the same above thing recursively.
int _z = 0;
bool _stop(int x) {return _z++>x;}
ll MOD = 1e9+7;

// _______________________________________________________________________________

void soln() {
	string s; cin>>s;
	int n = s.size();
	for(int i = 1; i<n; i++) {
		for(int j = i; j>0; j--) {
			if(s[j]-s[j-1] > 1) {
				s[j]--;
				swap(s[j], s[j-1]);
			}
		}
	}
	cout<<s;
}

// _______________________________________________________________________________

int main() {

#ifndef ONLINE_JUDGE
	ofstream err("debug.txt");   // Open a file named "debug.txt" for output
  	streambuf* cerrbuf = cerr.rdbuf();   // Save the original cerr buffer
	cerr.rdbuf(err.rdbuf());   // Redirect cerr to write to the "debug.txt" file
	clock_t tstart = clock();
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll t = 1;
	cin>>t; edl;debug(t);edl;
	ll tc = 1;
	while(t--) {
		debug(tc);edl;tc++;
		soln();
		cout<<endl;edl;
	}

#ifndef ONLINE_JUDGE
	cout<<"\n Executed In: "<<double(clock()-tstart)/CLOCKS_PER_SEC<<"ms"<<endl;
#endif
	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include "bits/stdc++.h"

#include <unordered_map>



using namespace std;

#define ll long long

#define limit 200000

#define MOD 998244353

vector<ll> pow2(limit + 1);







void solve()

{

	ll n, l, r;

	cin >> n >> l >> r;



	vector<int> niz1(l - 1);

	vector<int> niz2(r - l + 1);

	vector<int> niz3(n - r);

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

	{

		if (i < l - 1)

			cin >> niz1[i];

		else if (i >= l-1 && i < r)

			cin >> niz2[i - (l-1)];

		else

			cin >> niz3[i - r];

	}

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

	sort(niz2.begin(), niz2.end(), greater<int>());

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



	std::vector<ll> cumsum1(niz1.size());

	std::partial_sum(niz1.begin(), niz1.end(), cumsum1.begin());

	std::vector<ll> cumsum2(niz2.size());

	std::partial_sum(niz2.begin(), niz2.end(), cumsum2.begin());

	std::vector<ll> cumsum3(niz3.size());

	std::partial_sum(niz3.begin(), niz3.end(), cumsum3.begin());



	ll pom = 0;

	for (int i = 0; i < niz1.size() && i < niz2.size(); i++)

	{

		ll x = cumsum2[i] - cumsum1[i];

		if (x > pom)

		{

			pom = x;

		}

		else break;

	}

	for (int i = 0; i < niz3.size() && i < niz2.size(); i++)

	{

		ll x = cumsum2[i] - cumsum3[i];

		if (x > pom)

		{

			pom = x;

		}

		else break;

	}



	cout << cumsum2[r - l] - pom << endl;



}





int main()

{

	cin.tie(nullptr)->sync_with_stdio(false);



	ll n; cin >> n;



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

	{



		solve();



	}

}

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

using namespace std;
#define ll long long
#define limit 200000
#define MOD 998244353
vector<ll> pow2(limit + 1);



void solve()
{
	ll n, l, r;
	cin >> n >> l >> r;

	vector<int> niz1(l - 1);
	vector<int> niz2(r - l + 1);
	vector<int> niz3(n - r);
	for (int i = 0; i < n; i++)
	{
		if (i < l - 1)
			cin >> niz1[i];
		else if (i >= l-1 && i < r)
			cin >> niz2[i - (l-1)];
		else
			cin >> niz3[i - r];
	}
	sort(niz1.begin(), niz1.end());
	sort(niz2.begin(), niz2.end(), greater<int>());
	sort(niz3.begin(), niz3.end());

	std::vector<ll> cumsum1(niz1.size());
	std::partial_sum(niz1.begin(), niz1.end(), cumsum1.begin());
	std::vector<ll> cumsum2(niz2.size());
	std::partial_sum(niz2.begin(), niz2.end(), cumsum2.begin());
	std::vector<ll> cumsum3(niz3.size());
	std::partial_sum(niz3.begin(), niz3.end(), cumsum3.begin());

	ll pom = 0;
	ll pom2 = 0;
	for (int i = 0; i < niz1.size() && i < niz2.size(); i++)
	{
		ll x = cumsum2[i] - cumsum1[i];
		if (x > pom)
		{
			pom = x;
		}
		else break;
	}
	for (int i = 0; i < niz3.size() && i < niz2.size(); i++)
	{
		ll x = cumsum2[i] - cumsum3[i];
		if (x > pom2)
		{
			pom2 = x;
		}
		else break;
	}

	cout << cumsum2[r - l] - max(pom, pom2)<< endl;

}


int main()
{
	cin.tie(nullptr)->sync_with_stdio(false);

	ll n; cin >> n;

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

		solve();

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


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

#include <unordered_map>



using namespace std;

#define ll long long

#define limit 200000

#define MOD 998244353

vector<ll> pow2(limit + 1);







void solve()

{

	ll n, l, r;

	cin >> n >> l >> r;



	vector<int> niz1(l - 1);

	vector<int> niz2(r - l + 1);

	vector<int> niz3(n - r);

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

	{

		if (i < l - 1)

			cin >> niz1[i];

		else if (i >= l-1 && i < r)

			cin >> niz2[i - (l-1)];

		else

			cin >> niz3[i - r];

	}

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

	sort(niz2.begin(), niz2.end(), greater<int>());

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



	std::vector<ll> cumsum1(niz1.size());

	std::partial_sum(niz1.begin(), niz1.end(), cumsum1.begin());

	std::vector<ll> cumsum2(niz2.size());

	std::partial_sum(niz2.begin(), niz2.end(), cumsum2.begin());

	std::vector<ll> cumsum3(niz3.size());

	std::partial_sum(niz3.begin(), niz3.end(), cumsum3.begin());



	ll pom = 0;

	for (int i = 0; i < niz1.size() && i < niz2.size(); i++)

	{

		ll x = cumsum2[i] - cumsum1[i];

		if (x > pom)

		{

			pom = x;

		}

		else break;

	}

	for (int i = 0; i < niz3.size() && i < niz2.size(); i++)

	{

		ll x = cumsum2[i] - cumsum3[i];

		if (x > pom)

		{

			pom = x;

		}

		else break;

	}



	cout << cumsum2[r - l] - pom << endl;



}





int main()

{

	cin.tie(nullptr)->sync_with_stdio(false);



	ll n; cin >> n;



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

	{



		solve();



	}

}