ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

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

#include<vector>

#include<unordered_set>

#include<unordered_map>

#include<algorithm>

#include<cmath>

#include<set>

#include<map>

#include<iomanip>

#include<string>

#include<numeric>

#include<queue>

#include<stdlib.h>

#include<cstring>

#include<climits>

using namespace std;

long long x;

void solve()

{

	long long n, m; cin >> n >> m;

	multiset<long long>st1;

	multiset<long long>st2;

	for (long long i = 1; i <= n; i++)cin >> x, st1.insert(x);

	for (long long i = 1; i <= m; i++)cin >> x, st2.insert(x);

	auto pos1 = st1.begin();

	auto pos2 = st2.begin();

	while (pos1 != st1.end() && pos2 != st2.end())

	{

		if ((*pos1) == (*pos2))

		{

			st1.erase(st1.begin());

			st2.erase(st2.begin());

			pos1 = st1.begin();

			pos2 = st2.begin();

		}

		else if ((*pos1) > (*pos2))

		{

			cout << "NO" << endl;

			return;

		}

		else

		{

			auto temp = pos1;

			pos1++;

			if (pos1 == st1.end() || *temp + 1 < *pos1)

			{

				cout << "NO" << endl;

				return;

			}

			st1.insert(*temp + *pos1);

			st1.erase(st1.begin());

			st1.erase(st1.begin());

			pos1 = st1.begin();

		}

	}

	if (st1.size() == 0 && st2.size() == 0)cout << "YES" << endl;

	else cout << "NO" << endl;

}

int main()

{

	ios::sync_with_stdio(0), cout.tie(0), cin.tie(0);

	int tt = 1;

	cin >> tt;

	while (tt--)

	{

		solve();

	}

	return 0;

}

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

#include<vector>

#include<unordered_set>

#include<unordered_map>

#include<algorithm>

#include<cmath>

#include<set>

#include<map>

#include<iomanip>

#include<string>

#include<numeric>

#include<queue>

#include<stdlib.h>

#include<cstring>

#include<climits>

using namespace std;

long long x;

void solve()

{

	long long n, m; cin >> n >> m;

	multiset<long long>st1;

	multiset<long long>st2;

	for (long long i = 1; i <= n; i++)cin >> x, st1.insert(x);

	for (long long i = 1; i <= m; i++)cin >> x, st2.insert(x);



	while (st1.size() != 0 && st2.size() != 0)

	{

		//for (auto it = st1.begin(); it != st1.end(); it++)cout << *it << " "; cout << endl;

		//for (auto it = st2.begin(); it != st2.end(); it++)cout << *it << " "; cout << endl;

		auto pos = st1.find(*st2.begin());

		if (pos != st1.end())

		{

			st2.erase(st2.begin());

			st1.erase(pos);

		}

		else

		{

			auto temp = st2.begin();

			long long num1 = *temp / 2;

			long long num2 = (*temp + 1) / 2;

			st2.erase(temp);

			if (num1 == 0 || num2 == 0)

			{

				cout << "NO" << endl;

				return;

			}

			st2.insert(num1);

			st2.insert(num2);

		}

	}

	if (st1.size() == 0 && st2.size() == 0)cout << "YES" << endl;

	else cout << "NO" << endl;

}

int main()

{

	ios::sync_with_stdio(0), cout.tie(0), cin.tie(0);

	int tt = 1;

	cin >> tt;

	while (tt--)

	{

		solve();

	}

	return 0;

}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>
#include<string>
using namespace std;
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios::sync_with_stdio(false);

    int t;
    cin >> t;
    while (t--)
    {
        long long n;
        cin >> n;
        vector<pair<long long, long long>>path(n - 1);
        vector<long long>num(n + 1, 0);
        for (long long i = 0; i < n - 1; i++)
        {
            long long u, v;
            cin >> u >> v;
            path[i] = { u,v };
            num[u]++;
            num[v]++;
        }
        long long max_num = 0;
        long long max_num_index = 0;
        for (long long i = 1; i <= n; i++)
        {
            if (max_num < num[i])
            {
                max_num = num[i];
                max_num_index = i;
            }
        }
        long long ans = max_num;
        long long m = 0;
        vector<long long>nums(n + 1, 0);
        for (long long i = 0; i < n - 1; i++)
        {
            long long u = path[i].first;
            long long v = path[i].second;
            if (u == max_num_index || v == max_num_index)
            {
                continue;
            }
            else
            {
                nums[u]++;
                nums[v]++;
                m = max(m, max(nums[u], nums[v]));
            }
        }
        cout << ans + m - 1 << endl;
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)


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

int main(){
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        vector<int> arr(n);
        unordered_map<int, int> freq;
        vector<pair<int, int>> revfreq;
        for(int i=0; i<n; i++){
            cin>>arr[i];
            freq[arr[i]]++;
        }
        for(auto i:freq){
            revfreq.push_back(MP(i.second, i.first));
        }
        sort(revfreq.begin(), revfreq.end());
        for(auto i:revfreq){
            if(k<i.first){
                break;
            }else{
                k-=freq[i.second];
                freq.erase(i.second);
            }
        }
        if(freq.empty()){
            cout<<"1\n";
        }else{
            cout<<freq.size()<<'\n';
        }
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 11):
#include<bits/stdc++.h>
using namespace std;
#define MP make_pair

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        vector<int> arr(n);
        unordered_map<int, int> freq;
        vector<pair<int, int>> revfreq;
        for(int i=0; i<n; i++){
            cin>>arr[i];
            freq[arr[i]]++;
        }
        for(auto i:freq){
            revfreq.push_back(MP(i.second, i.first));
        }
        sort(revfreq.begin(), revfreq.end());
        for(auto i:revfreq){
            if(k<i.first){
                break;
            }else{
                k-=freq[i.second];
                freq.erase(i.second);
            }
        }
        if(freq.empty()){
            cout<<"1\n";
        }else{
            cout<<freq.size()<<'\n';
        }
    }
}

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

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        vector<int> arr(n);
        map<int, int> freq;
        vector<pair<int, int>> revfreq;
        for(int i=0; i<n; i++){
            cin>>arr[i];
            freq[arr[i]]++;
        }
        for(auto i:freq){
            revfreq.push_back(MP(i.second, i.first));
        }
        sort(revfreq.begin(), revfreq.end());
        for(auto i:revfreq){
            if(k<i.first){
                break;
            }else{
                k-=freq[i.second];
                freq.erase(i.second);
            }
        }
        if(freq.empty()){
            cout<<"1\n";
        }else{
            cout<<freq.size()<<'\n';
        }
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 11):
#include<bits/stdc++.h>
using namespace std;
#define MP make_pair

int main(){
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        vector<int> arr(n);
        unordered_map<int, int> freq;
        vector<pair<int, int>> revfreq;
        for(int i=0; i<n; i++){
            cin>>arr[i];
            freq[arr[i]]++;
        }
        for(auto i:freq){
            revfreq.push_back(MP(i.second, i.first));
        }
        sort(revfreq.begin(), revfreq.end());
        for(auto i:revfreq){
            if(k<i.first){
                break;
            }else{
                k-=freq[i.second];
                freq.erase(i.second);
            }
        }
        if(freq.empty()){
            cout<<"1\n";
        }else{
            cout<<freq.size()<<'\n';
        }
    }
}

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

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        vector<int> arr(n);
        unordered_map<int, int> freq;
        vector<pair<int, int>> revfreq;
        for(int i=0; i<n; i++){
            cin>>arr[i];
            freq[arr[i]]++;
        }
        for(auto i:freq){
            revfreq.push_back(MP(i.second, i.first));
        }
        sort(revfreq.begin(), revfreq.end());
        for(auto i:revfreq){
            if(k<i.first){
                break;
            }else{
                k-=freq[i.second];
                freq.erase(i.second);
            }
        }
        if(freq.empty()){
            cout<<"1\n";
        }else{
            cout<<freq.size()<<'\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>
using namespace std;
int main()
{
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(0);
    int t;
    cin >> t;
    while(t--)
    {
        int l, r;
        cin >> l >> r;
        int a = l;
        for(int i = 31; i >= 0; i--)
        {
            if(((1 << i)&l) != ((1 << i)&r)) {
                a = (1 << i);
                break;
            }
        }
        int b = a - 1;
        int c = r;
        if(a == l + 1)
        {
            c = r;
        }
        if(a == r)
        {
            c = l;
        }
        cout << a << " " << b << " " << c << endl;
    }
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
int main()
{
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(0);
    int t;
    cin >> t;
    while(t--)
    {
        int l, r;
        cin >> l >> r;
        int a = l;
        for(int i = 31; i >= 0; i--)
        {
            if(((1 << i)&l) != ((1 << i)&r)) {
                a = a | (1 << i);
                a--;
                break;
            }
        }
        int b = a + 1;
        int c = (a == l ? r : l);
        cout << a << " " << b << " " << c << endl;
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
int main()
{
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(0);
    int t;
    cin >> t;
    while(t--)
    {
        int l, r;
        cin >> l >> r;
        int a = l;
        for(int i = 31; i >= 0; i--)
        {
            if(((1 << i)&l) != ((1 << i)&r)) {
                a = (1 << i);
                break;
            }
        }
        int b = a - 1;
        int c = r;
        if(a == l + 1)
        {
            c = r;
        }
        if(a == r)
        {
            c = l;
        }
        cout << a << " " << b << " " << c << endl;
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
int main()
{
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(0);
    int t;
    cin >> t;
    while(t--)
    {
        int l, r;
        cin >> l >> r;
        int a = l;
        for(int i = 31; i >= 0; i--)
        {
            if(((1 << i)&l) != ((1 << i)&r)) {
                a = a | (1 << i);
                a--;
                break;
            }
        }
        int b = a + 1;
        int c = (a == l ? r : l);
        cout << a << " " << b << " " << c << endl;
    }
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
int main()
{
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(0);
    int t;
    cin >> t;
    while(t--)
    {
        int l, r;
        cin >> l >> r;
        int a = l;
        int k = l ^ r;
        for(int i = 31; i >= 0; i--)
        {
            if((1 << i) & k)
            {
                a = a | ((1 << i) - 1);
            }
        }
        int b = a + 1;
        int c = (a == l ? r : l);
        cout << a << " " << b << " " << c << endl;
    }
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 5):
#include <vector>

#include <bits/stdc++.h>

using namespace std;



#define endl '\n'

typedef long long ll;





int main(){



	ios_base::sync_with_stdio(false);

	cin.tie(NULL);







	ll t; cin>>t;

	while(t--> 0){

		

		string str; 

		ll sum=0;

		cin>>str;

		int freq[10]{};

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

			int curr = str[i]-'0';

			sum+=(curr);

			if(str[i]=='2'){

				freq[2]++;

			}

			if(str[i]=='3'){

				freq[3]++;

			}





		}

		

		if(!(sum%9)){

			cout<<"YES"<<endl;

		}else{

			string ans="NO";

			for(int i = 0;i<=freq[2];i++){

				for(int j = 0;j<=freq[3];j++){

					if(((sum+(i*2)+(j*6))%9==0)){

						ans="YES";

						break;

						i=freq[2];

					}



				}

			}

			cout<<ans<<endl;



		}









		}	





 

 

 

	return 0;

}



Submission (verdict: Time limit exceeded on test 5):
#include <vector>

#include <bits/stdc++.h>

using namespace std;



#define endl '\n'

typedef long long ll;





int main(){



	ios_base::sync_with_stdio(false);

	cin.tie(NULL);







	ll t; cin>>t;

	while(t--> 0){

		

		string str; 

		ll sum=0;

		cin>>str;

		int freq[10]{};

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

			int curr = str[i]-'0';

			sum+=(curr);

			if(str[i]=='2'){

				freq[2]++;

			}

			if(str[i]=='3'){

				freq[3]++;

			}





		}

		

		if(!(sum%9)){

			cout<<"YES"<<endl;

		}else{

			string ans="NO";

			for(int i = 0;i<=freq[2];i++){

				for(int j = 0;j<=freq[3];j++){

					if(((sum+(i*2)+(j*6))%9==0)){

						ans="YES";

						break;

						i = freq[2]+1;

					}



				}

			}

			cout<<ans<<endl;



		}









		}	





 

 

 

	return 0;

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

Previous submission (verdict: Wrong answer on test 3):
#include <vector>

#include <bits/stdc++.h>

using namespace std;



#define endl '\n'

typedef long long ll;





int main(){



	ios_base::sync_with_stdio(false);

	cin.tie(NULL);







	ll t; cin>>t;

	while(t--> 0){

		ll x;cin>>x;

		

		string str; 

		str=to_string(x);

		ll sum=0;

		int freq[10]{};

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

			int curr = str[i]-'0';

			sum+=(curr);

			if(str[i]=='2'){

				freq[2]++;

			}

			if(str[i]=='3'){

				freq[3]++;

			}





		}

		

		if(!(sum%9)){

			cout<<"YES"<<endl;

		}else{

			string ans="NO";

			for(int i = 0;i<=freq[2];i++){

				for(int j = 0;j<=freq[3];j++){

					if(((sum+(i*2)+(j*6))%9==0)){

						ans="YES";

						break;

						i=freq[2];

					}



				}

			}

			cout<<ans<<endl;



		}









		}	





 

 

 

	return 0;

}



Submission (verdict: Time limit exceeded on test 5):
#include <vector>

#include <bits/stdc++.h>

using namespace std;



#define endl '\n'

typedef long long ll;





int main(){



	ios_base::sync_with_stdio(false);

	cin.tie(NULL);







	ll t; cin>>t;

	while(t--> 0){

		

		string str; 

		ll sum=0;

		cin>>str;

		int freq[10]{};

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

			int curr = str[i]-'0';

			sum+=(curr);

			if(str[i]=='2'){

				freq[2]++;

			}

			if(str[i]=='3'){

				freq[3]++;

			}





		}

		

		if(!(sum%9)){

			cout<<"YES"<<endl;

		}else{

			string ans="NO";

			for(int i = 0;i<=freq[2];i++){

				for(int j = 0;j<=freq[3];j++){

					if(((sum+(i*2)+(j*6))%9==0)){

						ans="YES";

						break;

						i=freq[2];

					}



				}

			}

			cout<<ans<<endl;



		}









		}	





 

 

 

	return 0;

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


Submission (verdict: Wrong answer on test 3):
#include <vector>

#include <bits/stdc++.h>

using namespace std;



#define endl '\n'

typedef long long ll;





int main(){



	ios_base::sync_with_stdio(false);

	cin.tie(NULL);







	ll t; cin>>t;

	while(t--> 0){

		ll x;cin>>x;

		

		string str; 

		str=to_string(x);

		ll sum=0;

		int freq[10]{};

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

			int curr = str[i]-'0';

			sum+=(curr);

			if(str[i]=='2'){

				freq[2]++;

			}

			if(str[i]=='3'){

				freq[3]++;

			}





		}

		

		if(!(sum%9)){

			cout<<"YES"<<endl;

		}else{

			string ans="NO";

			for(int i = 0;i<=freq[2];i++){

				for(int j = 0;j<=freq[3];j++){

					if(((sum+(i*2)+(j*6))%9==0)){

						ans="YES";

						break;

						i=freq[2];

					}



				}

			}

			cout<<ans<<endl;



		}









		}	





 

 

 

	return 0;

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

Previous submission (verdict: Time limit exceeded on test 5):
#include <vector>

#include <bits/stdc++.h>

using namespace std;



#define endl '\n'

typedef long long ll;





int main(){



	ios_base::sync_with_stdio(false);

	cin.tie(NULL);







	ll t; cin>>t;

	while(t--> 0){

		

		string str; 

		ll sum=0;

		cin>>str;

		int freq[10]{};

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

			int curr = str[i]-'0';

			sum+=(curr);

			if(str[i]=='2'){

				freq[2]++;

			}

			if(str[i]=='3'){

				freq[3]++;

			}





		}

		

		if(!(sum%9)){

			cout<<"YES"<<endl;

		}else{

			string ans="NO";

			for(int i = 0;i<=freq[2];i++){

				for(int j = 0;j<=freq[3];j++){

					if(((sum+(i*2)+(j*6))%9==0)){

						ans="YES";

						break;

						i = freq[2]+1;

					}



				}

			}

			cout<<ans<<endl;



		}









		}	





 

 

 

	return 0;

}



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

#include <bits/stdc++.h>

using namespace std;



#define endl '\n'

typedef long long ll;





int main(){



	ios_base::sync_with_stdio(false);

	cin.tie(NULL);







	ll t; cin>>t;

	while(t--> 0){

		

		string str; 

		ll sum=0;

		cin>>str;

		int freq[10]{};

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

			int curr = str[i]-'0';

			sum+=(curr);

			if(str[i]=='2'){

				freq[2]++;

			}

			if(str[i]=='3'){

				freq[3]++;

			}





		}

		

		if(!(sum%9)){

			cout<<"YES"<<endl;

		}else{

			string ans="NO";

			for(int i = 0;i<=min(freq[2],9);i++){

				for(int j = 0;j<=min(freq[3],9);j++){

					if(((sum+(i*2)+(j*6))%9==0)){

						ans="YES";

						break;

						i = freq[2]+1;

					}



				}

			}

			cout<<ans<<endl;



		}









		}	





 

 

 

	return 0;

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

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


#define endl '\n'
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	cin>>t;

	while(t-- >0){
	

		ll s,l,r;
		cin>>s>>l>>r;
		vector<ll> vec(s);
		for(auto &x: vec){cin>>x;}	
		vector<ll> pref = vec;
		int prefix=0;
		sort(pref.begin(),pref.begin()+r);

		reverse(pref.begin(),pref.begin()+r);
		prefix+= accumulate(pref.begin()+l-1,pref.begin()+r,0);
		
		vector<ll> suffix = vec;
		int suff=0;
		sort(suffix.begin()+l-1,suffix.end());

		suff=accumulate(suffix.begin()+l-1,suffix.begin()+r,0);
		cout<<min(prefix,suff)<<endl;

	}


// 9 2 3 4 5 2 5 1 5









	return 0;
}


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


#define endl '\n'
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	cin>>t;

	while(t-- >0){
	

		ll s,l,r;
		cin>>s>>l>>r;
		vector<ll> vec(s);
		for(auto &x: vec){cin>>x;}	
		vector<ll> pref = vec;
		ll prefix=0;
		sort(pref.begin(),pref.begin()+r);

		reverse(pref.begin(),pref.begin()+r);
		prefix+= accumulate(pref.begin()+l-1,pref.begin()+r,0);
		
		vector<ll> suffix = vec;
		ll suff=0;
		sort(suffix.begin()+l-1,suffix.end());

		suff=accumulate(suffix.begin()+l-1,suffix.begin()+r,0);
		cout<<min(prefix,suff)<<endl;

	}


// 9 2 3 4 5 2 5 1 5









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

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


#define endl '\n'
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	cin>>t;

	while(t-- >0){
	

		int s,l,r;
		cin>>s>>l>>r;
		vector<int> vec(s);
		for(auto &x: vec){cin>>x;}	
		vector<int> pref = vec;
		int prefix=0;
		sort(pref.begin(),pref.begin()+r);

		reverse(pref.begin(),pref.begin()+r);
		prefix+= accumulate(pref.begin()+l-1,pref.begin()+r,0);
		
		vector<int> suffix = vec;
		int suff=0;
		sort(suffix.begin()+l-1,suffix.end());

		suff=accumulate(suffix.begin()+l-1,suffix.begin()+r,0);
		cout<<min(prefix,suff)<<endl;

	}


// 9 2 3 4 5 2 5 1 5









	return 0;
}


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


#define endl '\n'
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	cin>>t;

	while(t-- >0){
	

		ll s,l,r;
		cin>>s>>l>>r;
		vector<ll> vec(s);
		for(auto &x: vec){cin>>x;}	
		vector<ll> pref = vec;
		int prefix=0;
		sort(pref.begin(),pref.begin()+r);

		reverse(pref.begin(),pref.begin()+r);
		prefix+= accumulate(pref.begin()+l-1,pref.begin()+r,0);
		
		vector<ll> suffix = vec;
		int suff=0;
		sort(suffix.begin()+l-1,suffix.end());

		suff=accumulate(suffix.begin()+l-1,suffix.begin()+r,0);
		cout<<min(prefix,suff)<<endl;

	}


// 9 2 3 4 5 2 5 1 5









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

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


#define endl '\n'
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	cin>>t;

	while(t-- >0){
	

		ll s,l,r;
		cin>>s>>l>>r;
		vector<ll> vec(s);
		for(auto &x: vec){cin>>x;}	
		vector<ll> pref = vec;
		ll prefix=0;
		sort(pref.begin(),pref.begin()+r);

		reverse(pref.begin(),pref.begin()+r);
		prefix+= accumulate(pref.begin()+l-1,pref.begin()+r,0);
		
		vector<ll> suffix = vec;
		ll suff=0;
		sort(suffix.begin()+l-1,suffix.end());

		suff=accumulate(suffix.begin()+l-1,suffix.begin()+r,0);
		cout<<min(prefix,suff)<<endl;

	}


// 9 2 3 4 5 2 5 1 5









	return 0;
}


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


#define endl '\n'
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	cin>>t;

	while(t-- >0){
	

		ll s,l,r;
		cin>>s>>l>>r;
		vector<ll> vec(s);
		for(auto &x: vec){cin>>x;}	
		vector<ll> pref = vec;
		ll prefix=0;
		sort(pref.begin(),pref.begin()+r);

		reverse(pref.begin(),pref.begin()+r);
		prefix= accumulate(pref.begin()+l-1,pref.begin()+r,0);
		
		vector<ll> suffix = vec;
		ll suff=0;
		sort(suffix.begin()+l-1,suffix.end());

		suff=accumulate(suffix.begin()+l-1,suffix.begin()+r,0);
		cout<<min(prefix,suff)<<endl;

	}


// 9 2 3 4 5 2 5 1 5









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


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


#define endl '\n'
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	cin>>t;

	while(t-- >0){
	

		int s,l,r;
		cin>>s>>l>>r;
		vector<int> vec(s);
		for(auto &x: vec){cin>>x;}	
		vector<int> pref = vec;
		int prefix=0;
		sort(pref.begin(),pref.begin()+r);

		reverse(pref.begin(),pref.begin()+r);
		prefix+= accumulate(pref.begin()+l-1,pref.begin()+r,0);
		
		vector<int> suffix = vec;
		int suff=0;
		sort(suffix.begin()+l-1,suffix.end());

		suff=accumulate(suffix.begin()+l-1,suffix.begin()+r,0);
		cout<<min(prefix,suff)<<endl;

	}


// 9 2 3 4 5 2 5 1 5









	return 0;
}