ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063C - Remove Exactly Two
Language: c++17 

Solution 1 (runtime: 749 ms):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
 
    ll t;
    cin >> t;
 
    while (t--) {
        ll n;
        cin >> n ;
        vector<ll> a(n);
        vector<vector<ll>> adj(n);
        map<pair<ll,ll>, ll>st;
        vector<pair<ll,ll>>sz;
        for (ll i = 0; i < n - 1; i++) {
            ll x, y;
            cin >> x >> y;
            x--; y--;
            adj[y].push_back(x);
            adj[x].push_back(y);
            st[{x,y}]++;
            st[{y,x}]++;
        }
        for (ll i = 0; i < n ; i++) {
            sort(adj[i].begin(), adj[i].end());
            sz.push_back({adj[i].size(), i});
        }
        sort(sz.rbegin(),sz.rend());
        
        ll ans=0;
        for(ll i=0; i<n; i++){
            ll node=sz[i].second;
            ll ans2=sz[i].first;
            ll mx=0;
            ll f=0;
            for(ll j=0; j<n; j++){
                ll nd=sz[j].second;
                ll len=sz[j].first;
                if(node==nd){
                    continue;
                }
                if(st[{node,nd}]==0 || st[{nd,node}]==0){
                    mx=max(len,mx);
                    f=1;
                    break;
                }
                else{
                    mx=max(len-1,mx);
                }
            }
            ans=max(ans,mx+ans2-1);
            
        }
        cout<<ans<<endl;
    }
 
 
    return 0;
}

Solution 2 (runtime: 765 ms):
#include <bits/stdc++.h>
#define ull unsigned long long
#define ul unsigned long
#define l long
#define ll long long
using namespace std;
struct vertex{
	vector<int> v;
	int degree;
};
vertex graph[200010];
int main()
{
	ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
	int t;
	cin>>t;
	while(t--)
	{
		multiset<int> dg;
		dg.clear();
		int n;
		cin>>n;
		int maxdegree=0;
		for(int i=1;i<=n;i++)
		{
			graph[i].v.clear();
			graph[i].degree=0;
		}
		for(int i=1;i<n;i++)
		{
			int u,v;
			cin>>u>>v;
			graph[u].v.push_back(v);
			graph[u].degree++;
			graph[v].v.push_back(u);
			graph[v].degree++;
			if(graph[u].degree>maxdegree)
				maxdegree=graph[u].degree;
			if(graph[v].degree>maxdegree)
				maxdegree=graph[v].degree;
		}
		for(int i=1;i<=n;i++)dg.insert(graph[i].degree);
		int ans=0;
		for(int i=1;i<=n;i++)
		{
			dg.erase(dg.find(graph[i].degree));
			for(auto it=graph[i].v.begin();it!=graph[i].v.end();it++)
			{
				int vv=*it;
				dg.erase(dg.find(graph[vv].degree));
				dg.insert(graph[vv].degree-1);
			}
			ans=max(ans,graph[i].degree+*dg.rbegin()-1);
			for(auto it=graph[i].v.begin();it!=graph[i].v.end();it++)
			{
				int vv=*it;
				dg.erase(dg.find(graph[vv].degree-1));
				dg.insert(graph[vv].degree);
			}
			dg.insert(graph[i].degree);
		}
 		cout<<ans<<endl;
	}
	return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: c++17 

Solution 1 (runtime: 77 ms):
#include <bits/stdc++.h>
using namespace std;

#define dbg(x) cout << (#x) << ": " << x << "\n";
#define be(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repm(i, m, n) for(int i = (m); i < (n); i++)
#define rev(i, n) for(int i = (n)-1; i >= 0; i--)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> 
ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }

void test_case() {
    int l, r;
    cin >> l >> r;

    int n = 0, off = 0;
    for(int i = 31; i >= 0; i--) {
        int lx = l & (1 << i), rx = r & (1 << i);
        if(lx != rx) {
            n = i;
            break;
        } else if(lx && rx) off += 1 << i;
    }

    int a, b, c;
    a = 1 << n, b = a - 1;
    a += off, b += off;
    c = l > a-2 ? a+1 : a-2;

    cout << a << " " << b << " " << c << "\n";
}

int32_t main() {    
    ios::sync_with_stdio(0);
    cin.tie(0);

    int t = 1;
    cin >> t;
    rep(i, t) {
        test_case();
    }

    return 0;
}

Solution 2 (runtime: 62 ms):
//जय सिया राम
// Author : **Aditya Raj**

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define int long long int
#define ll  long long int
#define ld long double
#define endl '\n'
#define loopi(n) for(int i=0;i<n;i++)


void solve(){
    int l,r;
    cin>>l>>r;
    int a,b,c;
    int ans = 0;
    a = 0;
    b = 0;
    c = 0;
    for(int i=30;i>=0;i--){
        int b1 = 0;
        int 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(int i = l;i<=r;i++){
        if(i != a && i != b){
            c = i;
            break;
        }
    }

    cout<<a<<" "<<b<<" "<<c<<" "<<endl;


}



signed main() {    
    //fast input output
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    int t = 1;
    cin>>t;

    while(t--){

        solve();

    }
    return 0;
}
Problem: 2050E - Three Strings
Language: c++17 

Solution 1 (runtime: 687 ms):
#include<bits/stdc++.h>
#define int long long
using namespace std;
int dp[1005][1005];
string a,b,c;
int solve(int i,int j)
{
    int k=i+j;
    if(dp[i][j]==-1)
    {
        dp[i][j]=1e18;
        if(i<a.size())dp[i][j]=solve(i+1,j)+(a[i]!=c[k]);
        if(j<b.size())dp[i][j]=min(dp[i][j],solve(i,j+1)+(b[j]!=c[k]));
        if(dp[i][j]==1e18)dp[i][j]=0;
    }

    return dp[i][j];
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   int t;
   cin>>t;
   while(t--)
   {
       memset(dp,-1,sizeof(dp));
       cin>>a>>b>>c;
       cout<<solve(0,0)<<'\n';
   }
}


Solution 2 (runtime: 686 ms):
#include <bits/stdc++.h>
using namespace std;
 
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define int long long
#define PI pair<int,int>
#define pb push_back
#define f first
#define s second
#define endl '\n'
#define dbgl(x) cout << #x << " = " << x << "####" << endl;
#define dbg(x) cout << #x << " = " << x << " ";

const int INF = 1e16;
const int MAX = 1e3+100;

int memo[MAX][MAX];

string a, b, c;

int dp(int ia, int ib){
	if(ia == a.size() and ib == b.size()) return 0;
	if(memo[ia][ib] != -1) return memo[ia][ib];

	if(ia == a.size()){
		if(b[ib] == c[ia+ib]) return memo[ia][ib] = dp(ia, ib+1);
		return memo[ia][ib] = dp(ia, ib+1) + 1;
	}

	if(ib == b.size()){
		if(a[ia] == c[ia+ib]) return memo[ia][ib] = dp(ia+1, ib);
		return memo[ia][ib] = dp(ia+1, ib) + 1;
	}

	if(a[ia] == c[ia+ib] and b[ib] == c[ia+ib]) return memo[ia][ib] = min(dp(ia+1, ib), dp(ia, ib+1));
	if(a[ia] == c[ia+ib]) return memo[ia][ib] = min(dp(ia+1, ib), dp(ia, ib+1) + 1);
	if(b[ib] == c[ia+ib]) return memo[ia][ib] = min(dp(ia+1, ib) + 1, dp(ia, ib+1));
	return memo[ia][ib] = min(dp(ia+1, ib) + 1, dp(ia, ib+1) + 1);
}

int32_t main(){ _
    int t; cin >> t;
	while(t--){
		cin >> a >> b >> c;
		memset(memo, -1, sizeof(memo));
		int ans = dp(0, 0);
		cout << ans << endl;
	}
    
}   

/* makefile
CXX = g++
CPXXFLAGS = -fsanitize=address,undefined -fno-omit-frame-pointer -g -Wall -Wshadow -std=c++17 -Wno-unused-result -Wno-sign-compare -Wno-char-subscripts #-fuse-ld=gold

q:	
		cp makefiletemp.cpp $(f).cpp
		touch $(f).txt
		code $(f).txt        
		code $(f).cpp
		clear
compile: 
		g++ -g $(f).cpp $(CXXFLAGS) -o $(f)
exe:
		./$(f) < $(f).txt

runc: compile
comp: compile exe

clearexe:
		find . -maxdepth 1 -type f -executable -exec rm {} +
cleartxt:
		find . -type f -name "*.txt" -exec rm -f {} \; 
clear: clearexe cleartxt
		clear
*/
Problem: 2050C - Uninteresting Number
Language: c++17 

Solution 1 (runtime: 77 ms):
#include <bits/stdc++.h>
using namespace std;

int main() {
    int t;
    cin >> t;
    while(t--) {
        string s;
        cin >> s;
        int sum=0;int c3=0,c2=0;
        for(int i=0; i<s.size(); i++) {
            sum += s[i] - '0';
            if(s[i] == '2') c2++;// increases 2
            if(s[i] == '3') c3++;// increases 6
        }
        if(sum%9 == 0) cout << "YES" << endl;
        else{
            if(sum>9)
            sum =9-(sum%9);
            else 
            sum = 9-sum;
            int temp=sum,tc3=c3,tc2=c2;

            while(sum%9!=0 && (c2>0 || c3>0)){
                // cout << sum << " "<< c2 << " " << c3 << endl;
                if(c3>0 && sum>=6){
                    sum-=6;
                    c3--;
                }
                else if(c2>0 && sum>=2){
                    sum-=2;
                    c2--;
                }
                else break;
            }
            if(sum%9==0) {cout << "YES" << endl;continue;}
            sum=temp+9;
            c3=tc3;c2=tc2;
            while(sum%9!=0 && (c2>0 || c3>0)){
                // cout << sum << " "<< c2 << " " << c3 << endl;
                if(c3>0 && sum>=6){
                    sum-=6;
                    c3--;
                }
                else if(c2>0 && sum>=2){
                    sum-=2;
                    c2--;
                }
                else break;
            }
            if(sum%9==0) cout << "YES" << endl;
            else cout << "NO" << endl;
        }
    }
    return 0;
}


Solution 2 (runtime: 77 ms):
#include <bits/stdc++.h>
#define ll long long 
#define pii pair<int,int>
#define tii tuple<int, int, int>
#define pll pair<ll,ll>
#define mp make_pair
#define all(x) x.begin(), x.end()
using namespace std;
const int maxn = 2e6 + 10;
const int INF = 1e8;
const ll mod = 998244353;
 
void solve() {
	map<int, int> cnt;
	int r = 0;
	string s; cin >> s;
	for (auto &c: s) {
		r += c - '0';
		cnt[c - '0']++;
	}
	r %= 9;
	vector<int> dp(9);
	dp[r] = 1;
	for (int choice: {2, 3}) {
		int add = (choice == 2 ? 2 : 6);
		for (int i = 0; i < min(cnt[choice], 10); i++) {
			auto ndp = dp;
			for (int j = 0; j < 9; j++) if (dp[j]) {
				ndp[(j + add) % 9] = 1;
			}
			dp = ndp;
		}
	}
	cout << (dp[0] ? "YES\n" : "NO\n");
} 
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll TestCases = 1;
   	cin >> TestCases;
	while (TestCases--) {
		solve();
	}
}
Problem: 2050E - Three Strings
Language: c++17 

Solution 1 (runtime: 218 ms):
#include<bits/stdc++.h>
using namespace std;
int t;

int dp[1006][1006];
void solve(){
	memset(dp,0,sizeof(dp));
	string a,b;
	string s;
	cin>>a>>b>>s;
	for(int i=0;i<=a.size();i++){
		for(int j=0;j<=b.size();j++){
			if(i){
				dp[i][j]=max(dp[i][j],dp[i-1][j]+(s[i+j-1]==a[i-1]?1:0));
			}
			if(j){
				dp[i][j]=max(dp[i][j],dp[i][j-1]+(s[i+j-1]==b[j-1]?1:0));
			}
		}
	}
	cout<<s.size()-dp[a.size()][b.size()]<<endl;
}
int main(){
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
} 

Solution 2 (runtime: 93 ms):
#include <bits/stdc++.h>
using namespace std;
int printans(string &a,string &b,string &c,int i,int j, vector<vector<int>>&dp){
    // cout<<i<<" "<<j<<endl;
    if((i+j)==c.length()){
        return 0;
    }
    if(dp[i][j]!=-1){
        return dp[i][j];
    }
    int l=0,r=0;
    if(i<a.length() and j<b.length()){
        l=printans(a,b,c,i+1,j,dp)+1;
        if(a[i]==c[i+j]){
            l=(printans(a,b,c,i+1,j,dp));
        }
        r=printans(a,b,c,i,j+1,dp)+1;
        if(b[j]==c[i+j]){
            r=(printans(a,b,c,i,j+1,dp));
        }
        return dp[i][j]=min(l,r);
        
    }
    else if(i<a.length()){
        l=printans(a,b,c,i+1,j,dp)+1;
        if(a[i]==c[i+j]){
            l=(printans(a,b,c,i+1,j,dp));
        }
        return dp[i][j]=l;
        
    }
    else if(j<b.length()){
        r=printans(a,b,c,i,j+1,dp)+1;
        if(b[j]==c[i+j]){
            r=min(printans(a,b,c,i,j+1,dp),r);
        }
        return dp[i][j]=r;
    }
    return dp[i][j]=min(l,r);
}
void solve(){
    string a,b,c;
    cin>>a>>b>>c;
    vector<vector<int>>dp(a.length()+1,vector<int>(b.length()+1,-1));
    cout<<printans(a,b,c,0,0,dp)<<endl;
}

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--){
	    solve();
	}

}
Problem: 2057C - Trip to the Olympiad
Language: c++17 

Solution 1 (runtime: 108 ms):
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define umap unordered_map
#define fl(type,symbol,start,end) for(type symbol=start;symbol<end;symbol++)
#define pb(x) push_back(x)
int gcd( int a,  int b)
{
    if (b == 0)
    return a;
    return gcd(b, a % b);
}
int lcm(int a, int b)
{
    return (a / gcd(a, b)) * b;
}
vector<string> split(string s, string delimiter) {
    size_t pos_start = 0, pos_end, delim_len = delimiter.length();
    string token;
    vector<string> res;
    while ((pos_end = s.find(delimiter, pos_start)) != string::npos) {
        token = s.substr (pos_start, pos_end - pos_start);
        pos_start = pos_end + delim_len;
        res.push_back (token);
    }
    res.push_back (s.substr (pos_start));
    return res;
}
int32_t main()
{
    int t;
    cin>>t;
    // 7 6 5 4 3 2 1 0
    // | | | | | | | | 
    for(int ii=0;ii<t;ii++){
        int  l,r;
        cin>>l>>r;
        int a,b,c;
        // int aa, bb,cc;
        // cin>>aa>>bb>>cc;

        // lets get the most significant bit differing in l and r;;
        int diff = l xor r;
        int k = 31- __builtin_clz(diff);// count the leading zeros of the integer
        a = 1<<k;
        b= (l | (a-1));
        a=b+1;
        c= b==l?r:l;


        cout<<a<<" "<<b<<" "<<c<<endl;
        // cout<<((aa xor bb)+(aa xor cc) + (bb xor cc))<<endl;
        // cout<<((a xor b)+(a xor c) + (b xor c))<<endl;

    }
    return 0;
}

Solution 2 (runtime: 62 ms):
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=100010;
int l,r;
int a[3];
void solve(){
	memset(a,0,sizeof(a));
	cin>>l>>r;
	int res=0;
	while(1){
		if(r-l==2){
			cout<<l+res<<" "<<l+res+1<<" "<<l+res+2<<"\n";
			return;
		}
		int x=1;
		while(x*2<=r)x<<=1;
		if(x<=l){
			res+=x;
			l-=x;
			r-=x;
			continue;
		}
		cout<<x+res<<" "<<x+res-1<<" "<<(x==r?l:r)+res<<"\n";
		break;
	}
	return;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T=1;
	cin>>T;
	while(T--)solve();
	return 0;
}
Problem: 2063C - Remove Exactly Two
Language: c++17 

Solution 1 (runtime: 249 ms):
//#pragma GCC optimize("inline,Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,popcnt,avx,abm")
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF 101010101010101010
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long mod = 998244353;
#define int ll

int n;
vector<int> g[201010];
int flag[201010];

void solve() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        g[i].clear();
    }
    for (int i = 1; i < n; i++) {
        int A, B;
        cin >> A >> B;
        g[A].push_back(B);
        g[B].push_back(A);
    }
//    if (n == 2) {cout << "0\n";return;}

    vector<pair<int, int> > hv;
    for (int i = 1; i <= n; i++)
        hv.push_back({g[i].size(), i});
    sort(hv.begin(), hv.end(), [](pair<int, int> q, pair<int, int> w) {
         return q.first > w.first;
    });

    int ans = 0;
    for (int v = 1; v <= n; v++) {
        for (int to : g[v]) {
            flag[to] = v;
        }
        int upTo = min(n, (int)g[v].size() + 1);
        for (int i = 0; i < upTo; i++) {
            int to = hv[i].second;
            if (v == to) continue;
            if (flag[to] == v) {
                ans = max(ans, (int)g[v].size() + (int)g[to].size() - 2);
            } else {
                ans = max(ans, (int)g[v].size() + (int)g[to].size() - 1);
            }

//            cout << v << " " << to << " << " << ans << endl;
        }
    }
    cout << ans << '\n';
}

signed main() {
    fast
    int t = 1;
    cin >> t;
    for (int i = 1; i <= t; i++) {
        solve();
    }
    return 0;
}

/**

*/



Solution 2 (runtime: 733 ms):
#include<bits/stdc++.h>
#define endl '\n' 
using i64 = long long;
using namespace std;
signed main(){
    std::ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int T, n, u, v;
    cin >> T;
    while(T--){
        cin >> n;
        vector<int> deg(n + 1);
        vector<vector<int>> e(n + 1);
        for (int i = 1; i < n;i++){
            cin >> u >> v;
            e[u].push_back(v);
            e[v].push_back(u);
            deg[u]++, deg[v]++;
        }
        i64 ans = 0, res = 0;
        multiset<int> se;
        for (int i = 1; i <= n;i++)
            se.insert(deg[i]);
        for (int i = 1; i <= n; i++){
            res = deg[i];
            se.extract(deg[i]);
            for (auto x : e[i]){
                se.extract(deg[x]);
                se.insert(deg[x] - 1);
            }
            res += *se.rbegin() - 1;
            for (auto x : e[i]){
                se.extract(deg[x] - 1);
                se.insert(deg[x]);
            }
            se.insert(deg[i]);
            ans = max(ans, res);
        }
        cout << ans << endl;
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: c++17 

Solution 1 (runtime: 62 ms):
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <climits>
using namespace std;

int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<long long> v;
        for(int i=0;i<n;i++){
            long long a;
            cin >> a;
            v.push_back(a);
        }
        long long ans = accumulate(v.begin(),v.end(),0LL);
        while(n > 1){
            vector<long long> v1;
            for(int i = 1;i<n;i++){
                v1.push_back(v[i] - v[i-1]);
            }
            ans = max(ans,abs(accumulate(v1.begin(),v1.end(),0LL)));
            for(int i = 0;i<n-1;i++){
                v[i] = v1[i];
            }
            n--;
        }
        cout << ans << endl;
    }
}

Solution 2 (runtime: 46 ms):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef vector<long long> vc;
#define fol(i,a,b) for(ll i = a; i < b; i++)
const ll mod = 1e9+7;
int main(){
    int t;
    cin>>t;
    while(t--){
        ll n;
        cin>>n;
        vector<ll> a(n);
        ll sum = 0;
        fol(i,0,n) {cin>>a[i];}
        //vector<ll> prev;
        if (n == 1) cout<<a[0]<<endl;
        else{
        ll ans = -1e18;
        ll lim = n;
        for(ll i = 0;i<n;i++){
            ll sum2 = 0;
            for(ll j = 0;j<lim;j++) sum2 += a[j];
            if (i == 0) ans=max(ans,sum2);
            else ans=max(ans,max(sum2,-(sum2)));
            //cout<<sum2<<endl;
            for(ll j = 0;j<lim-1;j++){
                a[j] = a[j+1] - a[j];
            }
            lim--;
        }
        //ll si = 0;
        cout<<ans<<endl;
    }
}
}
Problem: 2063B - Subsequence Update
Language: c++17 

Solution 1 (runtime: 202 ms):
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+4;
#define int long long
int a[N];
int b[N];
int c[N];
int d[N];
int vis[N];
void solv(){
	int n,x,y,num = 0,sum1 = 0,sum2 = 0;
	cin >> n >> x >> y;
	for(int i = 1;i <= n ;i++) cin >> a[i];
	for(int i = 1;i <= x-1;i++) c[i] = a[i];
	sort(c+1,c+x);
	for(int i = x;i <= y;i++) d[i] = a[i];
	sort(d+x,d+1+y);
	for(int i = y+1;i <= n;i++) b[i] = a[i];
	sort(b+y+1,b+n+1);
	int i = 1;
	for(i= 1; i< x;i++){
		if((y-i+1) < x) break;
		if(c[i] >= d[y-i+1]) break;
		sum1 += c[i];
	}
	for(i = y- i +1;i >= x;i--){
		sum1 += d[i];
	}
	i = y+1;
	for(i= y+1;i <= n;i++){
		if((2 * y - i+1) < x) break;
		if(b[i] >= d[2 * y - i+1])break;
		sum2 += b[i];
	}
	for(i = 2*y-i+1;i>=x;i--) sum2 += d[i];
	cout << min(sum1,sum2) << endl;
}
signed main(){
	int t;cin >> t;
	while(t--){
		solv();
	}
	return 0;
}




Solution 2 (runtime: 93 ms):
#include <bits/stdc++.h>

#include <chrono>

using namespace std;

using namespace chrono;



// Aliases

using ll = long long;

using ull = unsigned long long;

using ld = long double;



// Constants

constexpr ll INF = 4e18;

constexpr ld EPS = 1e-9;

constexpr ll MOD = 998244353;



// Macros

#define F first

#define S second

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

#define allr(x) rbegin(x), rend(x)

#define pb push_back

#define MP make_pair

#define endl '\n'

#define rep(i, a, b) for (int i = a; i < b; i++)



// Modular arithmetic functions

ll inv(ll i) {

    if (i == 1) return 1;

    return (MOD - (MOD / i) * inv(MOD % i) % MOD) % MOD;

}



ll mod_mul(ll a, ll b) {

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

}



ll mod_add(ll a, ll b) {

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

}



ll mod_sub(ll a, ll b) {

    return (a % MOD - b % MOD + MOD) % MOD;

}



ll pwr(ll a, ll b) {

    ll res = 1;

    a %= MOD;

    while (b > 0) {

        if (b & 1) res = res * a % MOD;

        a = a * a % MOD;

        b >>= 1;

    }

    return res;

}



// Fast I/O

istream& operator>>(istream &is, vector<ll> &v) {

    for (auto &x : v) is >> x;

    return is;

}



ostream& operator<<(ostream &os, const vector<ll> &v) {

    for (auto &x : v) os << x << " ";

    return os;

}



// Main logic

void solve() {

 int n, l, r;

    cin >> n >> l >> r;

    vector<ll> a(n);

    cin >> a;

    vector<ll> b(n);

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

        b[i] = a[i];

    l--;

    r--;

    sort(a.begin(), a.begin() + r + 1);

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

    ll temp1 = 0;

    ll temp2 = 0;

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

    {

        temp1 += b[i];

    }

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

    {

        temp2 += a[i];

    }

    cout << min(temp1, temp2) << endl;

}



int main() {

    ios::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);



    int T;

    cin >> T;



    auto start = high_resolution_clock::now();

    while (T--) {

        solve();

    }

    auto stop = high_resolution_clock::now();

    auto duration = duration_cast<microseconds>(stop - start);

    cerr << "Time: " << duration.count() / 1000 << " ms" << endl;



    return 0;

}