ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<int> a;
        for (int i = 0; i < n; i++)
        {
            int x;
            cin >> x;
            a.push_back(x);
        }
        ll maxi=0;
        for(int i=0;i<n;i++)
        maxi+=a[i];
        vector<int>v;
        while(n>1)
        {
            ll sum=0;
            for(int i=0;i<n-1;i++)
            {
                v.push_back(a[i+1]-a[i]);
            }
            for(int i=0;i<n-1;i++)
            sum+=v[i];
            maxi=max(abs(sum),maxi);
            for(int i=0;i<n-1;i++)
            a[i]=v[i];
            v.clear();
            n--;
        }
        cout<<maxi<<endl;

    }
    return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<ll> a;
        for (int i = 0; i < n; i++)
        {
            int x;
            cin >> x;
            a.push_back(x);
        }
        ll maxi=0;
        for(int i=0;i<n;i++)
        maxi+=a[i];
        vector<ll>v;
        while(n>1)
        {
            ll sum=0;
            for(int i=0;i<n-1;i++)
            {
                v.push_back(a[i+1]-a[i]);
            }
            for(int i=0;i<n-1;i++)
            sum+=v[i];
            maxi=max(abs(sum),maxi);
            for(int i=0;i<n-1;i++)
            a[i]=v[i];
            v.clear();
            n--;
        }
        cout<<maxi<<endl;

    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int a[n];
        for (int i = 0; i < n; i++)
            cin >> a[i];
        // n=n+1;
        int p = n, maxi = 0;
        if (n == 1)
        {
            cout << a[0] << endl;
            continue;
        }
        while (n--)
        {
            int s = 0;
            for (int i = 0; i < p; i++)
                s += a[i];
            if (s < 0)
                maxi = max(maxi, -s);
            else
                maxi = max(maxi, s);
            for (int i = 0; i < p - 1; i++)
            {
                a[i] = a[i + 1] - a[i];
            }
            p--;
        }
        cout << maxi << endl;
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--)
    {
        ll n;
        cin >> n;
        ll a[n];
        for (ll i = 0; i < n; i++)
            cin >> a[i];
        // n=n+1;
        ll p = n, maxi = 0;
        if (n == 1)
        {
            cout << a[0] << endl;
            continue;
        }
        while (n--)
        {
            ll s = 0;
            for (int i = 0; i < p; i++)
                s += a[i];
            if (s < 0)
                maxi = max(maxi, -s);
            else
                maxi = max(maxi, s);
            for (int i = 0; i < p - 1; i++)
            {
                a[i] = a[i + 1] - a[i];
            }
            p--;
        }
        cout << maxi << endl;
    }
    return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<int> a;
        for (int i = 0; i < n; i++)
        {
            int x;
            cin >> x;
            a.push_back(x);
        }
        ll maxi=0;
        for(int i=0;i<n;i++)
        maxi+=a[i];
        vector<int>v;
        while(n>1)
        {
            ll sum=0;
            for(int i=0;i<n-1;i++)
            {
                v.push_back(a[i+1]-a[i]);
            }
            for(int i=0;i<n-1;i++)
            sum+=v[i];
            maxi=max(abs(sum),maxi);
            for(int i=0;i<n-1;i++)
            a[i]=v[i];
            v.clear();
            n--;
        }
        cout<<maxi<<endl;

    }
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
#define int long long
#define float long double
#define pp pair<int, int>
#define tp tuple<int, int, int>
#define mtp make_tuple
#define mp make_pair
using namespace std;
// using lf = __float128;
// using ld = __int128;
// float pi = 3.141592653589793238462643383279502884197169399375105Q;
int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
int ddx[8] = {0, 0, 1, -1, 1, 1, -1, 1}, ddy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

map<int, int> adict, bdict;
int go(int bi)
{
    if (adict[bi] != 0)
    {
        adict[bi]--;
        return 0;
    }
    if (bi == 1)
        return 1;
    if (bi % 2 == 0)
    {
        int x = bi >> 1;

        if (adict[x] >= 2)
        {
            adict[x] -= 2;
            return 0;
        }
        go(x);
        return go(x);
    }
    else
    {
        int hol = bi + 1 >> 1, jjak = bi + 1 >> 1;
        if (hol % 2 == 0)
            hol--;
        else
            jjak--;

        int ret = 0;
        if (adict[jjak] == 0)
        {
            ret = go(jjak);
        }
        else
            adict[jjak]--;
        if (ret)
            return 1;
        return go(hol);
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int tt;
    cin >> tt;
    while (tt--)
    {
        adict.clear();
        bdict.clear();
        int n, m;
        cin >> n >> m;
        vector<int> arr(n), brr(m);
        for (int i = 0; i < n; i++)
        {
            cin >> arr[i];
            adict[arr[i]]++;
        }
        for (int i = 0; i < m; i++)
        {
            cin >> brr[i];
            bdict[brr[i]]++;
        }

        int flag = 0;
        for (int i = 0; i < m; i++)
        {
            flag = max(flag, go(brr[i]));
            bdict[brr[i]]--;
        }
        // for (int i = 0; i <= 5; i++)
        // {
        //     cout << adict[i] << ' ';
        // }
        // return 0;

        if (flag)
        {
            cout << "No";
            cout << '\n';
            continue;
        }
        for (auto p : bdict)
        {
            auto [x, counter] = p;
            if (adict[x] != counter)
            {
                flag = 1;
                break;
            }
        }
        for (auto p : adict)
        {
            auto [x, counter] = p;
            if (counter == 0)
                continue;
            if (bdict[x] != counter)
            {
                flag = 1;
                break;
            }
        }
        if (flag)
        {
            cout << "No";
            cout << '\n';
            continue;
        }
        cout << "Yes\n";
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;

int main(){

	int t;

	cin>>t;

	while(t--){

	char s[200005];

	int a[200005];

	cin>>s;

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

		a[i]=s[i]-'0';

	}

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

		int j=i;

		while(a[j]-1>a[j-1]&&a[j]>0&&j>0){

			int t=a[j]-1;

			a[j]=a[j-1];

			a[j-1]=t;

			j--;

		}

	}

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

		cout<<a[i];

	}

	cout<<endl;

	return 0;

}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Compilation error):
#include<bits/stdc++.h>

using namespace std;

int main(){

	int t;

	cin>>t;

	while(t--){

	char s[200005];

	int a[200005];

	cin>>s;

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

		a[i]=s[i]-'0';

	}

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

		int j=i;

		while(a[j]-1>a[j-1]&&a[j]>0&&j>0){

			int t=a[j]-1;

			a[j]=a[j-1];

			a[j-1]=t;

			j--;

		}

	}

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

		cout<<a[i];

	}

	cout<<endl;

	return 0;

} 

Submission (verdict: Time limit exceeded on test 7):
#include<bits/stdc++.h>

using namespace std;

int main(){

	int t;

	cin>>t;

	while(t--){

	char s[200005];

	int a[200005];

	cin>>s;

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

		a[i]=s[i]-'0';

	}

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

		int j=i;

		while(a[j]-1>a[j-1]&&a[j]>0&&j>0){

			int t=a[j]-1;

			a[j]=a[j-1];

			a[j-1]=t;

			j--;

		}

	}

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

		cout<<a[i];

	}

	cout<<endl;}

	return 0;

}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 7):
#include<bits/stdc++.h>

using namespace std;

int main(){

	int t;

	cin>>t;

	while(t--){

	char a[200005];

	cin>>a;

	for(int i=1;i<strlen(a);i++){

		int j=i;

		while(a[j]-1>a[j-1]&&j>0){

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

			a[j-1]--;

			j--;

		}

	}

	for(int i=0;i<strlen(a);i++){

		cout<<a[i];

	}

	cout<<endl;}

	return 0;

} 

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

using namespace std;

int main(){

	int t;

	cin>>t;

	while(t--){

	string a;

	cin>>a;

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

		int j=i;

		while(a[j]-1>a[j-1]&&j>0){

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

			a[j-1]--;

			j--;

		}

	}

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

		cout<<a[i];

	}

	cout<<endl;}

	return 0;

}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 7):
#include<bits/stdc++.h>

using namespace std;

int main(){

	int t;

	cin>>t;

	while(t--){

	char s[200005];

	int a[200005];

	cin>>s;

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

		a[i]=s[i]-'0';

	}

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

		int j=i;

		while(a[j]-1>a[j-1]&&a[j]>0&&j>0){

			int t=a[j]-1;

			a[j]=a[j-1];

			a[j-1]=t;

			j--;

		}

	}

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

		cout<<a[i];

	}

	cout<<endl;}

	return 0;

} 

Submission (verdict: Time limit exceeded on test 7):
#include<bits/stdc++.h>

using namespace std;

int main(){

	int t;

	cin>>t;

	while(t--){

	char a[200005];

	cin>>a;

	for(int i=1;i<strlen(a);i++){

		int j=i;

		while(a[j]-1>a[j-1]&&j>0){

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

			a[j-1]--;

			j--;

		}

	}

	for(int i=0;i<strlen(a);i++){

		cout<<a[i];

	}

	cout<<endl;}

	return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Time limit exceeded on test 6):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll t;
    cin >> t;
    while(t--){
        string s;
        cin >> s;
        ll sum=0;
        ll f2=0,f3=0;
        for(int i=0;i<s.size();i++){
            sum+=(ll)s[i]-'0';
            if(s[i]=='2'){
                f2++;
            }
            else if(s[i]=='3'){
                f3++;
            }
        }
        if(sum%9==0){
            cout << "YES" << "\n";
            continue;
        }
        else{
            if(f2==0 && f3==0){
                cout << "NO" << "\n";
                continue;
            }
            ll minc=(ll)2*f2 + (ll)6*f3;
            ll p=(ll)((sum/9)+1)*9;
            vector<ll> req;
            while((p-sum)<=minc){
                if(sum%2==0 && p%2==0){
                    req.push_back(p-sum);
                }
                else if(sum%2!=0 && p%2!=0){
                    req.push_back(p-sum);
                }
                p+=(ll)9;
            }
            if(req.size()==0){
                cout << "NO" << "\n";
                continue;
            }
            ll gh=0;
            for(int i=0;i<req.size();i++){
                for(int j=0;j<=f3;j++){
                    if((req[i]-(ll)j*6)%2==0 && (req[i]-(ll)j*6)/2>=0 && (req[i]-(ll)j*6)/2<=f2){
                        gh++;
                        break;
                    }
                }
                if(gh>0){
                    break;
                }
            }
            if(gh>0){
                cout << "YES" << "\n";
            }     
            else{
                cout << "NO" << "\n";
            }
        }
    }
    return 0;
}
Problem: 2049B - pspspsps
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;



#define fastIO()                              \

    do {                                      \

        ios::sync_with_stdio(false);         \

        cin.tie(NULL);                        \

        cout.tie(NULL);                       \

    } while (0)



void solve() {

    int n;

    cin >> n;

    string s;

    cin >> s;

    if(s[0]=='s' || s[n-1]=='p'){

        cout << "YES" << endl;

        return;

    }

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

        if(s[i]!='.'){

            cout << "NO" << endl;

            return;

        }

    }

    cout << "YES" << endl;

}



int main() {

    fastIO();

    int tc;

    cin >> tc;

    while (tc--) {

        solve();

    }

    return 0;

}
Problem: 2049B - pspspsps
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;



#define fastIO()                              \

    do {                                      \

        ios::sync_with_stdio(false);         \

        cin.tie(NULL);                        \

        cout.tie(NULL);                       \

    } while (0)



void solve() {

    int n;

    cin >> n;

    string s;

    cin >> s;

    if(s[0]=='s' || s[n-1]=='p'){

        cout << "YES" << endl;

        return;

    }

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

        if(s[i]!='.'){

            cout << "NO" << endl;

            return;

        }

    }

    cout << "YES" << endl;

}



int main() {

    fastIO();

    int tc;

    cin >> tc;

    while (tc--) {

        solve();

    }

    return 0;

}



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

using namespace std;



#define fastIO()                              \

    do {                                      \

        ios::sync_with_stdio(false);         \

        cin.tie(NULL);                        \

        cout.tie(NULL);                       \

    } while (0)



void solve() {

    int n;

    cin >> n;

    string s;

    cin >> s;

    map<char,int> m;

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

        m[s[i]]++;

    }



    if(s[0]=='s' || s[n-1]=='p'){

        cout << "YES" << endl;

        return;

    }

    if((m['p']==1 && m['s']==0)  ||  (m['p']==0 && m['s']==1)  ){

        cout << "YES" << endl;

        return;

    }



    if(m['.']==n){

        cout << "YES" << endl;

        return;

    }

    cout << "NO" << endl;

    return;

}



int main() {

    fastIO();

    int tc;

    cin >> tc;

    while (tc--) {

        solve();

    }

    return 0;

}
Problem: 2049B - pspspsps
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;



#define fastIO()                              \

    do {                                      \

        ios::sync_with_stdio(false);         \

        cin.tie(NULL);                        \

        cout.tie(NULL);                       \

    } while (0)



void solve() {

    int n;

    cin >> n;

    string s;

    cin >> s;

    map<char,int> m;

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

        m[s[i]]++;

    }



    if(s[0]=='s' || s[n-1]=='p'){

        cout << "YES" << endl;

        return;

    }

    if(( m['s']==0)  ||  (m['p']==0)  ){

        cout << "YES" << endl;

        return;

    }



    if(m['.']==n){

        cout << "YES" << endl;

        return;

    }

    cout << "NO" << endl;

    return;

}



int main() {

    fastIO();

    int tc;

    cin >> tc;

    while (tc--) {

        solve();

    }

    return 0;

}



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

using namespace std;



#define fastIO()                              \

    do {                                      \

        ios::sync_with_stdio(false);         \

        cin.tie(NULL);                        \

        cout.tie(NULL);                       \

    } while (0)



void solve() {

    int n;

    cin >> n;

    string s;

    cin >> s;

    map<char,int> m;

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

        m[s[i]]++;

    }

    if(s[0]=='s'){

        m['s']--;

        m['.']++;

    }



    if(s[n-1]=='p'){

        m['p']--;

        m['.']++;

    }



    if(m['s']+m['.']==n || m['p']+m['.']==n ) cout << "YES" << endl;

    else cout << "NO" << endl;



}



int main() {

    fastIO();

    int tc;

    cin >> tc;

    while (tc--) {

        solve();

    }

    return 0;

}
Problem: 2049B - pspspsps
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;



#define fastIO()                              \

    do {                                      \

        ios::sync_with_stdio(false);         \

        cin.tie(NULL);                        \

        cout.tie(NULL);                       \

    } while (0)



void solve() {

    int n;

    cin >> n;

    string s;

    cin >> s;

    map<char,int> m;

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

        m[s[i]]++;

    }



    if(s[0]=='s' || s[n-1]=='p'){

        cout << "YES" << endl;

        return;

    }

    if((m['p']==1 && m['s']==0)  ||  (m['p']==0 && m['s']==1)  ){

        cout << "YES" << endl;

        return;

    }



    if(m['.']==n){

        cout << "YES" << endl;

        return;

    }

    cout << "NO" << endl;

    return;

}



int main() {

    fastIO();

    int tc;

    cin >> tc;

    while (tc--) {

        solve();

    }

    return 0;

}



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

using namespace std;



#define fastIO()                              \

    do {                                      \

        ios::sync_with_stdio(false);         \

        cin.tie(NULL);                        \

        cout.tie(NULL);                       \

    } while (0)



void solve() {

    int n;

    cin >> n;

    string s;

    cin >> s;

    map<char,int> m;

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

        m[s[i]]++;

    }



    if(s[0]=='s' || s[n-1]=='p'){

        cout << "YES" << endl;

        return;

    }

    if(( m['s']==0)  ||  (m['p']==0)  ){

        cout << "YES" << endl;

        return;

    }



    if(m['.']==n){

        cout << "YES" << endl;

        return;

    }

    cout << "NO" << endl;

    return;

}



int main() {

    fastIO();

    int tc;

    cin >> tc;

    while (tc--) {

        solve();

    }

    return 0;

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


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




void Solve()
{

    int n, l , r;
    cin >> n >> l >> r ;
    vector<int>a(n,0);
    for(int i = 0 ; i < n ; i++){
        cin >> a[i];
    }
    l--;
    vector<int>b = a;
    reverse(b.begin(),b.end());
    sort(a.begin() + l , a.end());
    sort(b.begin() + l , b.end());

    int sum = 0;
    int sum1 = 0;
    for(int i = l  ; i < r ; i++){
        sum += a[i];
        sum1 += b[i];
    }
    cout<<min(sum,sum1)<<endl;
}


int32_t main(){

   int t;
   cin >> t;
   for(int i = 0 ; i <t ; i++){
    Solve();
   }
}

//6
//17
//22
//
//
//00110
//01001
//10110
//
//32 + 16 + 8 + 4 + 2
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

#define int long long

using namespace std;









void Solve()

{



    int n, l , r;

    cin >> n >> l >> r ;

    vector<int>a(n,0);

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

        cin >> a[i];

    }

    l--;

    vector<int>b = a;

    reverse(b.begin(),b.end());



    multiset<int>sA;

    multiset<int>sB;

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

        sA.insert(a[i]);

        sB.insert(b[i]);

    }

    int sum0 = 0;

    int sum1 = 0;

    int cnt = 0;

    for(auto i : sA){

        cnt++;

        sum0 += i;

        if(cnt == r - l){

            break;

        }

    }

    cnt = 0;

    for(auto i : sB){

        cnt++;

        sum1 += i;

        if(cnt == r - l){

            break;

        }

    }

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



}





int32_t main(){



   int t;

   cin >> t;

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

    Solve();

   }

}



//6

//17

//22

//

//

//00110

//01001

//10110

//

//32 + 16 + 8 + 4 + 2



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

#define int long long

using namespace std;









void Solve()

{



    int n, l , r;

    cin >> n >> l >> r ;

    vector<int>a(n,0);

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

        cin >> a[i];

    }

    l--;

    vector<int>b = a;

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

    sort(b.begin() , b.begin() + r);



    int sum = 0;

    int sum1 = 0;

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

        sum += a[i];

    }



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

        sum1 += b[i];

    }



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

}





int32_t main(){



   int t;

   cin >> t;

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

    Solve();

   }

}



//6

//17

//22

//

//

//00110

//01001

//10110

//

//32 + 16 + 8 + 4 + 2
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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




void Solve()
{

    int n, l , r;
    cin >> n >> l >> r ;
    vector<int>a(n,0);
    for(int i = 0 ; i < n ; i++){
        cin >> a[i];
    }
    l--;
    vector<int>b = a;
    reverse(b.begin(),b.end());
    sort(a.begin() + l , a.end());
    sort(b.begin() + l , b.end());

    int sum = 0;
    int sum1 = 0;
    for(int i = l  ; i < r ; i++){
        sum += a[i];
        sum1 += b[i];
    }
    cout<<min(sum,sum1)<<endl;
}


int32_t main(){

   int t;
   cin >> t;
   for(int i = 0 ; i <t ; i++){
    Solve();
   }
}

//6
//17
//22
//
//
//00110
//01001
//10110
//
//32 + 16 + 8 + 4 + 2


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

#define int long long

using namespace std;









void Solve()

{



    int n, l , r;

    cin >> n >> l >> r ;

    vector<int>a(n,0);

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

        cin >> a[i];

    }

    l--;

    vector<int>b = a;

    reverse(b.begin(),b.end());



    multiset<int>sA;

    multiset<int>sB;

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

        sA.insert(a[i]);

        sB.insert(b[i]);

    }

    int sum0 = 0;

    int sum1 = 0;

    int cnt = 0;

    for(auto i : sA){

        cnt++;

        sum0 += i;

        if(cnt == r - l){

            break;

        }

    }

    cnt = 0;

    for(auto i : sB){

        cnt++;

        sum1 += i;

        if(cnt == r - l){

            break;

        }

    }

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



}





int32_t main(){



   int t;

   cin >> t;

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

    Solve();

   }

}



//6

//17

//22

//

//

//00110

//01001

//10110

//

//32 + 16 + 8 + 4 + 2
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 int long long

void solve(){
	int n,l,r;
	cin>>n>>l>>r;
	l--,r--;
	int a[n+1];
	for(int i=0;i<n;++i){
		cin>>a[i];
	}
	int z=r-l+1;
	sort(a,a+r+1);
	/**for(int i=0;i<n;++i){
		cout<<a[i]<<" ";
	}
	cout<<endl;**/
	int sum=accumulate(a,a+z,0);
	sort(a+l,a+n);
	int s=0;
	for(int i=l;i<l+z;++i){
		s+=a[i];
	}
	sum=min(sum,s);
	cout<<sum<<endl;
   
   }

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}