ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 7):
#include<iostream>
#include<vector>
#include<set>
#define add(a,b) e[a].push_back(b)
#define rep for(int v:e[i])
#define siz(a) e[a].size()
using namespace std;

const int N=1e5+5;

int t;

vector<int>e[N];
multiset<int>s;


inline void work(){
	s.clear();
	for(int i=0;i<N;++i)e[i].clear();
	int n,ans=0;
	cin>>n;
	for(int i=1;i<n;++i){
		int u,v;
		cin>>u>>v;
		add(u,v),add(v,u);
	}
	for(int i=1;i<=n;++i){
		s.insert(siz(i));
	}
	for(int i=1;i<=n;++i){
		s.erase(s.find(siz(i)));
		rep{
			s.erase(s.find(siz(v)));
			s.insert(siz(v)-1);
		}
		ans=max(ans,(int)siz(i)+*s.rbegin()-1);
		s.insert(siz(i));
		rep{
			s.erase(s.find(siz(v)-1));
			s.insert(e[v].size());
		}
	}
	cout<<ans<<"\n";
	return ;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>t;
	while(t--)work();
	return 0;
}

Submission (verdict: Time limit exceeded on test 2):
#include<iostream>
#include<vector>
#include<set>
#define add(a,b) e[a].push_back(b)
#define rep for(int v:e[i])
#define siz(a) e[a].size()
using namespace std;

const int N=1e6+5;

int t;

vector<int>e[N];
multiset<int>s;


inline void work(){
	s.clear();
	for(int i=0;i<N;++i)e[i].clear();
	int n,ans=0;
	cin>>n;
	for(int i=1;i<n;++i){
		int u,v;
		cin>>u>>v;
		add(u,v),add(v,u);
	}
	for(int i=1;i<=n;++i){
		s.insert(siz(i));
	}
	for(int i=1;i<=n;++i){
		s.erase(s.find(siz(i)));
		rep{
			s.erase(s.find(siz(v)));
			s.insert(siz(v)-1);
		}
		ans=max(ans,(int)siz(i)+*s.rbegin()-1);
		s.insert(siz(i));
		rep{
			s.erase(s.find(siz(v)-1));
			s.insert(siz(v));
		}
	}
	cout<<ans<<"\n";
	return ;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>t;
	while(t--)work();
	return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 6):
#include<iostream>
#include<vector>
#include<set>
#define add(a,b) e[a].push_back(b)
#define rep for(int v:e[i])
#define siz(a) e[a].size()
using namespace std;

const int N=5e4+5;

int t;

inline void work(){
	int n,ans=0;
	cin>>n;
	vector<int>e[N];
	multiset<int>s;
	for(int i=1;i<n;++i){
		int u,v;
		cin>>u>>v;
		add(u,v),add(v,u);
	}
	for(int i=1;i<=n;++i){
		s.insert(siz(i));
	}
	for(int i=1;i<=n;++i){
		s.erase(s.find(siz(i)));
		rep{
			s.erase(s.find(siz(v)));
			s.insert(siz(v)-1);
		}
		ans=max(ans,(int)siz(i)+*s.rbegin()-1);
		s.insert(siz(i));
		rep{
			s.erase(s.find(siz(v)-1));
			s.insert(e[v].size());
		}
	}
	cout<<ans<<"\n";
	return ;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>t;
	while(t--)work();
	return 0;
}

Submission (verdict: Runtime error on test 7):
#include<iostream>
#include<vector>
#include<set>
#define add(a,b) e[a].push_back(b)
#define rep for(int v:e[i])
#define siz(a) e[a].size()
using namespace std;

const int N=1e5+5;

int t;

vector<int>e[N];
multiset<int>s;


inline void work(){
	s.clear();
	for(int i=0;i<N;++i)e[i].clear();
	int n,ans=0;
	cin>>n;
	for(int i=1;i<n;++i){
		int u,v;
		cin>>u>>v;
		add(u,v),add(v,u);
	}
	for(int i=1;i<=n;++i){
		s.insert(siz(i));
	}
	for(int i=1;i<=n;++i){
		s.erase(s.find(siz(i)));
		rep{
			s.erase(s.find(siz(v)));
			s.insert(siz(v)-1);
		}
		ans=max(ans,(int)siz(i)+*s.rbegin()-1);
		s.insert(siz(i));
		rep{
			s.erase(s.find(siz(v)-1));
			s.insert(e[v].size());
		}
	}
	cout<<ans<<"\n";
	return ;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>t;
	while(t--)work();
	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>

#include<algorithm>

#define int long long

using namespace std;



const int N=1e5+5;



int t;

int a[N],b[N];



inline bool cmp(int a,int b){

	return a<b;

}



inline void work(){

	int n,l,r;

	int a_=0,b_=0;

	cin>>n>>l>>r;

	for(int i=1;i<=n;++i)cin>>a[i],b[i]=a[i];

	sort(a+1,a+r+1,cmp);

	sort(b+1,b+n+1,cmp);

	for(int i=1;i<=r-l+1;++i)a_+=a[i];

	for(int i=l;i<=r;++i)b_+=b[i];

	cout<<min(a_,b_)<<"\n";

	return ;

}



signed main(){

	ios::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);

	cin>>t;

	while(t--)work();

	return 0;

}

Submission (verdict: Accepted):
#include<iostream>

#include<algorithm>

#define int long long

using namespace std;



const int N=1e5+5;



int t;

int a[N],b[N];



inline bool cmp(int a,int b){

	return a<b;

}



inline void work(){

	int n,l,r;

	int a_=0,b_=0;

	cin>>n>>l>>r;

	for(int i=1;i<=n;++i)cin>>a[i],b[i]=a[i];

	sort(a+1,a+r+1,cmp);

	sort(b+l,b+n+1,cmp);

	for(int i=1;i<=r-l+1;++i)a_+=a[i];

	for(int i=l;i<=r;++i)b_+=b[i];

	cout<<min(a_,b_)<<"\n";

	return ;

}



signed main(){

	ios::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);

	cin>>t;

	while(t--)work();

	return 0;

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


Submission (verdict: Wrong answer on test 1):
#include<iostream>

#include<algorithm>

#define int long long

using namespace std;



const int N=1e5+5;



int t;

int a[N],b[N];



inline bool cmp(int a,int b){

	return a<b;

}



inline void work(){

	int n,l,r;

	static int a_,b_;

	cin>>n>>l>>r;

	for(int i=1;i<=n;++i)cin>>a[i],b[i]=a[i];

	sort(a+1,a+r+1,cmp);

	sort(b+1,b+n+1,cmp);

	for(int i=l;i<=r;++i)a_+=a[i];

	for(int i=l;i<=r;++i)b_+=b[i];

	cout<<min(a_,b_)<<"\n";

	return ;

}



signed main(){

	ios::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);

	cin>>t;

	while(t--)work();

	return 0;

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

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>

#include<algorithm>

#define int long long

using namespace std;



const int N=1e5+5;



int t;

int a[N],b[N];



inline bool cmp(int a,int b){

	return a<b;

}



inline void work(){

	int n,l,r;

	static int a_,b_;

	cin>>n>>l>>r;

	for(int i=1;i<=n;++i)cin>>a[i],b[i]=a[i];

	sort(a+1,a+r+1,cmp);

	sort(b+1,b+n+1,cmp);

	for(int i=l;i<=r;++i)a_+=a[i];

	for(int i=l;i<=r;++i)b_+=b[i];

	cout<<min(a_,b_)<<"\n";

	return ;

}



signed main(){

	ios::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);

	cin>>t;

	while(t--)work();

	return 0;

}

Submission (verdict: Wrong answer on test 2):
#include<iostream>

#include<algorithm>

#define int long long

using namespace std;



const int N=1e5+5;



int t;

int a[N],b[N];



inline bool cmp(int a,int b){

	return a<b;

}



inline void work(){

	int n,l,r;

	int a_=0,b_=0;

	cin>>n>>l>>r;

	for(int i=1;i<=n;++i)cin>>a[i],b[i]=a[i];

	sort(a+1,a+r+1,cmp);

	sort(b+1,b+n+1,cmp);

	for(int i=1;i<=r-l+1;++i)a_+=a[i];

	for(int i=l;i<=r;++i)b_+=b[i];

	cout<<min(a_,b_)<<"\n";

	return ;

}



signed main(){

	ios::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);

	cin>>t;

	while(t--)work();

	return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

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

void SetFastIO() {
    std::cin.tie(nullptr)->sync_with_stdio(false);
}

#define For(index,start,end) for(LI index {start} ; index < end ; ++index)
#define Loop(end)            for(LI i {0} ; i < end ; ++i)
#define CFor(i,container)    for(const auto& i : container)
#define RFor(i,container)    for(auto& i : container)
#define F first
#define S second

#define print(container)     for(const auto& x : container)cout << x << ' ';cout << '\n';

using namespace std;
typedef unsigned long long int ULLI;
typedef unsigned long int ULI;
typedef long long int LLI;
typedef long int LI;

void solve(){
    string str;
    cin >> str;
    int cnt2 {};
    int cnt3 {};
    int sum  {};
    
    for(int i {} ; i < str.size() ; i++){
        cnt2 += str.at(i) == '2';
        cnt3 += str.at(i) == '3';
        sum  += str.at(i) - '0';
    }

    sum %= 9;
    vector<int> vec;
    for(int i {} ; i <= min(2,cnt3) ; i++){
        vec.push_back((sum + i * 6) % 9);
    }

    RFor(c,vec){
        for(int i {0} ; i <= min(cnt2,5) ; i++){
            if(c % 9 == 0){
                cout << "YES";
                return;
            }
            c += 2;
        }
        //cout << '\n';
    }
    cout << "NO";
}

int main() {
    int t {1};
    cin >> t;
    for(;t--;cout << '\n')solve();

    return 0;
}

/*   /\_/\
*   (= ._.)
*   / >  \>
*/

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

void SetFastIO() {
    std::cin.tie(nullptr)->sync_with_stdio(false);
}

#define For(index,start,end) for(LI index {start} ; index < end ; ++index)
#define Loop(end)            for(LI i {0} ; i < end ; ++i)
#define CFor(i,container)    for(const auto& i : container)
#define RFor(i,container)    for(auto& i : container)
#define F first
#define S second

#define print(container)     for(const auto& x : container)cout << x << ' ';cout << '\n';

using namespace std;
typedef unsigned long long int ULLI;
typedef unsigned long int ULI;
typedef long long int LLI;
typedef long int LI;

void solve(){
    string str;
    cin >> str;
    int cnt2 {};
    int cnt3 {};
    int sum  {};
    
    for(int i {} ; i < str.size() ; i++){
        cnt2 += str.at(i) == '2';
        cnt3 += str.at(i) == '3';
        sum  += str.at(i) - '0';
    }

    sum %= 9;
    vector<int> vec;
    for(int i {} ; i <= min(3,cnt3) ; i++){
        vec.push_back((sum + i * 6) % 9);
    }

    RFor(c,vec){
        for(int i {0} ; i <= min(cnt2,8) ; i++){
            if(c % 9 == 0){
                cout << "YES";
                return;
            }
            c += 2;
        }
        //cout << '\n';
    }
    cout << "NO";
}

int main() {
    int t {1};
    cin >> t;
    for(;t--;cout << '\n')solve();

    return 0;
}

/*   /\_/\
*   (= ._.)
*   / >  \>
*/
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


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

void SetFastIO() {
    std::cin.tie(nullptr)->sync_with_stdio(false);
}

#define For(index,start,end) for(LI index {start} ; index < end ; ++index)
#define Loop(end)            for(LI i {0} ; i < end ; ++i)
#define CFor(i,container)    for(const auto& i : container)
#define RFor(i,container)    for(auto& i : container)
#define F first
#define S second

#define print(container)     for(const auto& x : container)cout << x << ' ';cout << '\n';

using namespace std;
typedef unsigned long long int ULLI;
typedef unsigned long int ULI;
typedef long long int LLI;
typedef long int LI;

void solve(){
    string str;
    cin >> str;
    long cnt2 {};
    long cnt3 {};
    long sum  {};
    
    for(long i {} ; i < str.size() ; i++){
        cnt2 += str.at(i) == '2';
        cnt3 += str.at(i) == '3';
        sum  += str.at(i) - '0';
    }

    sum = sum % 9;

    while((cnt2 && cnt3) && (sum % 9 != 0)){

        if(cnt3 && (sum % 2 == 0 || sum <= 3)){
            sum += 6;
            cnt3--;
            continue;
        }

        if(cnt2){
            sum += 2;
            cnt2--;
        }   

        sum = sum % 9;
    }

    while((cnt2) && (sum % 9 != 0)){
        sum += 2;
        cnt2--;
    }
    while((cnt3) && (sum % 9 != 0)){
        sum += 6;
        cnt3--;
    }

    cout << (sum % 9 == 0 ? "YES" : "NO");
}

int main() {
    int t {1};
    cin >> t;
    for(;t--;cout << '\n')solve();

    return 0;
}

/*   /\_/\
*   (= ._.)
*   / >  \>
*/
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

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

void SetFastIO() {
    std::cin.tie(nullptr)->sync_with_stdio(false);
}

#define For(index,start,end) for(LI index {start} ; index < end ; ++index)
#define Loop(end)            for(LI i {0} ; i < end ; ++i)
#define CFor(i,container)    for(const auto& i : container)
#define RFor(i,container)    for(auto& i : container)
#define F first
#define S second

#define print(container)     for(const auto& x : container)cout << x << ' ';cout << '\n';

using namespace std;
typedef unsigned long long int ULLI;
typedef unsigned long int ULI;
typedef long long int LLI;
typedef long int LI;

void solve(){
    string str;
    cin >> str;
    long cnt2 {};
    long cnt3 {};
    long sum  {};
    
    for(long i {} ; i < str.size() ; i++){
        cnt2 += str.at(i) == '2';
        cnt3 += str.at(i) == '3';
        sum  += str.at(i) - '0';
    }

    sum = sum % 9;

    while((cnt2 && cnt3) && (sum % 9 != 0)){

        if(cnt3 && (sum % 2 == 0 || sum <= 3)){
            sum += 6;
            cnt3--;
            continue;
        }

        if(cnt2){
            sum += 2;
            cnt2--;
        }   

        sum = sum % 9;
    }

    while((cnt2) && (sum % 9 != 0)){
        sum += 2;
        cnt2--;
    }
    while((cnt3) && (sum % 9 != 0)){
        sum += 6;
        cnt3--;
    }

    cout << (sum % 9 == 0 ? "YES" : "NO");
}

int main() {
    int t {1};
    cin >> t;
    for(;t--;cout << '\n')solve();

    return 0;
}

/*   /\_/\
*   (= ._.)
*   / >  \>
*/

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

void SetFastIO() {
    std::cin.tie(nullptr)->sync_with_stdio(false);
}

#define For(index,start,end) for(LI index {start} ; index < end ; ++index)
#define Loop(end)            for(LI i {0} ; i < end ; ++i)
#define CFor(i,container)    for(const auto& i : container)
#define RFor(i,container)    for(auto& i : container)
#define F first
#define S second

#define print(container)     for(const auto& x : container)cout << x << ' ';cout << '\n';

using namespace std;
typedef unsigned long long int ULLI;
typedef unsigned long int ULI;
typedef long long int LLI;
typedef long int LI;

void solve(){
    string str;
    cin >> str;
    int cnt2 {};
    int cnt3 {};
    int sum  {};
    
    for(int i {} ; i < str.size() ; i++){
        cnt2 += str.at(i) == '2';
        cnt3 += str.at(i) == '3';
        sum  += str.at(i) - '0';
    }

    sum %= 9;
    vector<int> vec;
    for(int i {} ; i <= min(2,cnt3) ; i++){
        vec.push_back((sum + i * 6) % 9);
    }

    RFor(c,vec){
        for(int i {0} ; i <= min(cnt2,5) ; i++){
            if(c % 9 == 0){
                cout << "YES";
                return;
            }
            c += 2;
        }
        //cout << '\n';
    }
    cout << "NO";
}

int main() {
    int t {1};
    cin >> t;
    for(;t--;cout << '\n')solve();

    return 0;
}

/*   /\_/\
*   (= ._.)
*   / >  \>
*/
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)


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

#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define en '\n'
#define sp ' '
#define tb '\t'
#define ri(n) int n; cin >> n
#define rl(n) ll n; cin >> n
#define rs(s) string s; cin >> s
#define rc(c) char c; cin >> c
#define rv(v) for (auto &x : v) cin >> x
#define pven(v) for (auto x : v) cout << x << en
#define pv(v) for (auto x : v) cout << x << sp; cout << en
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yes cout << "YES" << en
#define no cout << "NO" << en
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define ssort(a, b) if (a < b) swap(a, b)
#define bitcnt(a) (__builtin_popcountll(a))
#define bithigh(a) (63-__builtin_clzll(a))
#define lg bithigh
#define highpow(a) (1LL << (ll)lg(a))

using namespace std;

const ll LINF = 4e18;
const int mxN = 1e6+10, INF = 2e9;
ll n, m, a[mxN];

void Solve(){

    cin >> n; ri(l); ri(r);
    m = r-l+1;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a+n);
    ll ans = 0;
    for (int i = 0; i < m; i++)
        ans += a[i];
    cout << ans << en;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0); cerr.tie(0);
    cout << setprecision(12) << fixed;
    cerr << setprecision(12) << fixed;

    int t = 1;
    cin >> t;
    while (t--)
        Solve();

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

Previous submission (verdict: Wrong answer on test 2):
/******************************************************************************



                              Online C++ Compiler.

               Code, Compile, Run and Debug C++ program online.

Write your code in this editor and press "Run" button to compile and execute it.



*******************************************************************************/



#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;

int main()

{

    int t;

    cin>>t;

    

    while(t--){

        int n,l,r;

        cin>>n>>l>>r;

        vector<int>v(n);

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

            cin >> v[i];

        }

        

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

        int total = r-l+1;

        long long answer = 0;

        int i = 0;

        while(total--){

            answer += v[i++];

        }

        cout<<answer<<endl;

    }



    return 0;

}

Submission (verdict: Wrong answer on test 8):
/******************************************************************************



                              Online C++ Compiler.

               Code, Compile, Run and Debug C++ program online.

Write your code in this editor and press "Run" button to compile and execute it.



*******************************************************************************/



#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;

int main()

{

    int t;

    cin>>t;

    

    while(t--){

        int n,l,r;

        cin>>n>>l>>r;

        vector<int>v(n);

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

            cin >> v[i];

        }

        

        int leftSum = 0;

        int rightSum = 0;

        vector<int>left;

        vector<int>right;

        

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

            left.push_back(v[i]);

        }

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

            right.push_back(v[i]);

        }

    

        

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

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

        

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

            leftSum += left[i];

            rightSum += right[i];

        }

        

        cout<<min(leftSum,rightSum)<<endl;

        

    }



    return 0;

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


Submission (verdict: Wrong answer on test 2):
/******************************************************************************



                              Online C++ Compiler.

               Code, Compile, Run and Debug C++ program online.

Write your code in this editor and press "Run" button to compile and execute it.



*******************************************************************************/



#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;

int main()

{

    int t;

    cin>>t;

    

    while(t--){

        int n,l,r;

        cin>>n>>l>>r;

        vector<int>v(n);

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

            cin >> v[i];

        }

        

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

        int total = r-l+1;

        int answer = 0;

        int i = 0;

        while(total--){

            answer += v[i++];

        }

        cout<<answer<<endl;

    }



    return 0;

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

Previous submission (verdict: Wrong answer on test 8):
/******************************************************************************



                              Online C++ Compiler.

               Code, Compile, Run and Debug C++ program online.

Write your code in this editor and press "Run" button to compile and execute it.



*******************************************************************************/



#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;

int main()

{

    int t;

    cin>>t;

    

    while(t--){

        int n,l,r;

        cin>>n>>l>>r;

        vector<int>v(n);

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

            cin >> v[i];

        }

        

        int leftSum = 0;

        int rightSum = 0;

        vector<int>left;

        vector<int>right;

        

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

            left.push_back(v[i]);

        }

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

            right.push_back(v[i]);

        }

    

        

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

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

        

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

            leftSum += left[i];

            rightSum += right[i];

        }

        

        cout<<min(leftSum,rightSum)<<endl;

        

    }



    return 0;

}

Submission (verdict: Accepted):
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int t;
    cin>>t;
    
    while(t--){
        int n,l,r;
        cin>>n>>l>>r;
        vector<int>v(n);
        for(int i = 0;i<n;i++){
            cin >> v[i];
        }
        
        long long leftSum = 0;
        long long rightSum = 0;
        vector<int>left;
        vector<int>right;
        
        for(int i = 0;i<r;i++){
            left.push_back(v[i]);
        }
        for(int i = l-1;i<n;i++){
            right.push_back(v[i]);
        }
    
        
        sort(left.begin(),left.end());
        sort(right.begin(),right.end());
        
        for(int i = 0;i<r-l+1;i++){
            leftSum += left[i];
            rightSum += right[i];
        }
        
        cout<<min(leftSum,rightSum)<<endl;
        
    }

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

Previous submission (verdict: Wrong answer on test 2):
/******************************************************************************



                              Online C++ Compiler.

               Code, Compile, Run and Debug C++ program online.

Write your code in this editor and press "Run" button to compile and execute it.



*******************************************************************************/



#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;

int main()

{

    int t;

    cin>>t;

    

    while(t--){

        int n,l,r;

        cin>>n>>l>>r;

        vector<int>v(n);

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

            cin >> v[i];

        }

        

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

        int total = r-l+1;

        int answer = 0;

        int i = 0;

        while(total--){

            answer += v[i++];

        }

        cout<<answer<<endl;

    }



    return 0;

}

Submission (verdict: Wrong answer on test 2):
/******************************************************************************



                              Online C++ Compiler.

               Code, Compile, Run and Debug C++ program online.

Write your code in this editor and press "Run" button to compile and execute it.



*******************************************************************************/



#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;

int main()

{

    int t;

    cin>>t;

    

    while(t--){

        int n,l,r;

        cin>>n>>l>>r;

        vector<int>v(n);

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

            cin >> v[i];

        }

        

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

        int total = r-l+1;

        long long answer = 0;

        int i = 0;

        while(total--){

            answer += v[i++];

        }

        cout<<answer<<endl;

    }



    return 0;

}