ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <fstream>
#include <iostream>
using namespace std;



int main() {
    istream& fin = cin;
    ostream& fout = cout;

    int t;
    fin >> t;
    int n, a1, a2;
    int temp;
    for (int i=0; i<t; i++) {
        fin >> n;
        a1 = 0; a2 = 0;
        for (int j=0; j<n; j++) {
            fin >> temp;
            if (j % 2 == 0) a1 += temp;
            else a2 += temp;
        }
        bool possible = (a2 % (n / 2) == 0 && a1 % (n - n/2) == 0 && (a2 / (n/2) == a1 / (n - n/2)));
        fout << (possible ? "YES" : "END") << "\n";
    }
}

Submission (verdict: Wrong answer on test 3):
#include <fstream>
#include <iostream>
using namespace std;



int main() {
    istream& fin = cin;
    ostream& fout = cout;

    int t;
    fin >> t;
    int n, a1, a2;
    int temp;
    for (int i=0; i<t; i++) {
        fin >> n;
        a1 = 0; a2 = 0;
        for (int j=0; j<n; j++) {
            fin >> temp;
            if (j % 2 == 0) a1 += temp;
            else a2 += temp;
        }
        bool possible = (a2 % (n / 2) == 0 && a1 % (n - n/2) == 0 && (a2 / (n/2) == a1 / (n - n/2)));
        fout << (possible ? "YES" : "NO") << "\n";
    }
}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include <fstream>
#include <iostream>
using namespace std;



int main() {
    istream& fin = cin;
    ostream& fout = cout;

    int t;
    fin >> t;
    int n, a1, a2;
    int temp;
    for (int i=0; i<t; i++) {
        fin >> n;
        a1 = 0; a2 = 0;
        for (int j=0; j<n; j++) {
            fin >> temp;
            if (j % 2 == 0) a1 += temp;
            else a2 += temp;
        }
        bool possible = (a2 % (n / 2) == 0 && a1 % (n - n/2) == 0 && (a2 / (n/2) == a1 / (n - n/2)));
        fout << (possible ? "YES" : "END") << "\n";
    }
}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include <fstream>
#include <iostream>
using namespace std;



int main() {
    istream& fin = cin;
    ostream& fout = cout;

    int t;
    fin >> t;
    int n, a1, a2;
    int temp;
    for (int i=0; i<t; i++) {
        fin >> n;
        a1 = 0; a2 = 0;
        for (int j=0; j<n; j++) {
            fin >> temp;
            if (j % 2 == 0) a1 += temp;
            else a2 += temp;
        }
        bool possible = (a2 % (n / 2) == 0 && a1 % (n - n/2) == 0 && (a2 / (n/2) == a1 / (n - n/2)));
        fout << (possible ? "YES" : "NO") << "\n";
    }
}

Submission (verdict: Accepted):
#include <fstream>
#include <iostream>
using namespace std;



int main() {
    istream& fin = cin;
    ostream& fout = cout;

    int t;
    fin >> t;
    int n;
    long long a1, a2;
    int temp;
    for (int i=0; i<t; i++) {
        fin >> n;
        a1 = 0; a2 = 0;
        for (int j=0; j<n; j++) {
            fin >> temp;
            if (j % 2 == 0) a1 += temp;
            else a2 += temp;
        }
        bool possible = (a2 % (n / 2) == 0 && a1 % (n - n/2) == 0 && (a2 / (n/2) == a1 / (n - n/2)));
        fout << (possible ? "YES" : "NO") << "\n";
    }
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pp pair<int,int> 
const int N = 2e5 + 9;
const int inf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;


void solve() {
    int n, m;cin >> n >> m;
    map<int, int> mp;
    priority_queue<int, vector<int>, greater<int>> pq;
    for (int i = 0;i < n;i++) {
        int a;cin >> a;pq.push(a);
    }
    for (int i = 0;i < m;i++) {
        int a;cin >> a;
        mp[a]++;
    }

    while (pq.size()>=2) {
        while (pq.size()) {
            int a = pq.top();
            if (mp[a] > 0) {
                mp[a]--;pq.pop();
            }
            else break;
        }
        if (pq.size() >= 2) {
            int a = pq.top();pq.pop();
            int b = pq.top();pq.pop();
            if (b - a <= 1) {
                pq.push(b + a);
            }
            else {
                cout << "No\n";return;
            }
        }
    }
    if (pq.size() == 1) {
        if(mp[pq.top()] > 0){mp[pq.top()]--;pq.pop();}
    }
    if(pq.size() > 0){
        cout << "No\n";return;
    }
    for (auto [x, y] : mp) {
        if(y > 0){
            cout << "No\n";return;
        }
    }
    cout << "Yes\n";
}
signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--)solve();
    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pp pair<int,int> 
const int N = 2e5 + 9;
const int inf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;


void solve() {
    int n, m;cin >> n >> m;
    map<int, int> mp;
    for (int i = 0;i < n;i++) {
        int x;cin >> x;
        mp[x]++;
    }
    priority_queue<int, vector<int>, greater<int>> pq;
    for (int i = 0;i < m;i++) {
        int x;cin >> x;
        pq.push(x);
    }
    while (pq.size()) {
        int x = pq.top();pq.pop();
        if (mp[x])mp[x]--;
        else {
            if (x == 1) {
                cout << "No\n";return;
            }
            else if (x % 2) {
                pq.push(x / 2);pq.push(x / 2+1);
            }
            else {
                pq.push(x / 2);pq.push(x / 2);
            }
        }
    }
    for(auto[x,y]:mp){
        if(y){
            cout << "No\n";return;
        }
    }
    cout << "Yes\n";
}
signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--)solve();
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pp pair<int,int> 
const int N = 2e5 + 9;
const int inf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;


void solve() {
    int n;cin >> n;
    vector<int> a(n), dp(n);
    for (int i = 0;i < n;i++)cin >> a[i];
    if (n == 1) {
        if (a[0] == 0)cout << 2 << endl;
        else cout << 1 << endl;
        return;
    }
    if (a[0] == 0) {
        dp[0] = 1;
        if (a[1] > 1)dp[1] = 0;
        else if (a[1] == 1)dp[1] = 1;
        else dp[1] = 1;
    }
    else {
        dp[0] = 0;
        if (a[1] == 1)dp[1] = 1;
        else dp[1] = 0;
    }
    for (int i = 2;i < n;i++) {
        if (a[i] == a[i - 1])dp[i] += dp[i - 1];dp[i] %= mod;
        if (a[i] == a[i - 2] + 1)dp[i] += dp[i - 2];
        dp[i] %= mod;
    }

    cout << dp[n - 1] + dp[n - 2] << endl;
}
signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--)solve();
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pp pair<int,int> 
const int N = 2e5 + 9;
const int inf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;


void solve() {
    int n, m;cin >> n >> m;
    map<int, int> mp;
    priority_queue<int, vector<int>, greater<int>> pq;
    for (int i = 0;i < n;i++) {
        int a;cin >> a;pq.push(a);
    }
    for (int i = 0;i < m;i++) {
        int a;cin >> a;
        mp[a]++;
    }

    while (pq.size()) {
        while (pq.size()) {
            int a = pq.top();
            if (mp[a] > 0) {
                mp[a]--;pq.pop();
            }
            else break;
        }
        if (pq.size() >= 2) {
            int a = pq.top();pq.pop();
            int b = pq.top();pq.pop();
            if (b - a <= 1) {
                pq.push(b + a);
            }
            else {
                cout << "No\n";return;
            }
        }
        else break;
    }
    if (pq.size() == 1) {
        if (mp[pq.top()] == 1) {
            cout << "Yes\n";return;
        }
        else {
            cout << "No\n";return;
        }
    }
    else cout << "Yes\n";
}
signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--)solve();
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pp pair<int,int> 
const int N = 2e5 + 9;
const int inf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;


void solve() {
    int n, m;cin >> n >> m;
    map<int, int> mp;
    priority_queue<int, vector<int>, greater<int>> pq;
    for (int i = 0;i < n;i++) {
        int a;cin >> a;pq.push(a);
    }
    for (int i = 0;i < m;i++) {
        int a;cin >> a;
        mp[a]++;
    }

    while (pq.size()) {
        while (pq.size()) {
            int a = pq.top();
            if (mp[a] > 0) {
                mp[a]--;pq.pop();
            }
            else break;
        }
        if (pq.size() >= 2) {
            int a = pq.top();pq.pop();
            int b = pq.top();pq.pop();
            if (b - a <= 1) {
                pq.push(b + a);
            }
            else {
                cout << "No\n";return;
            }
        }
        else break;
    }
    if (pq.size() == 1) {
        if (mp[pq.top()] == 1) {
            cout << "Yes\n";return;
        }
        else {
            cout << "No\n";return;
        }
    }
    else cout << "Yes\n";
}
signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--)solve();
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pp pair<int,int> 
const int N = 2e5 + 9;
const int inf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;


void solve() {
    int n, m;cin >> n >> m;
    map<int, int> mp;
    priority_queue<int, vector<int>, greater<int>> pq;
    for (int i = 0;i < n;i++) {
        int a;cin >> a;pq.push(a);
    }
    for (int i = 0;i < m;i++) {
        int a;cin >> a;
        mp[a]++;
    }

    while (pq.size()) {
        while (pq.size()) {
            int a = pq.top();
            if (mp[a] > 0) {
                mp[a]--;pq.pop();
            }
            else break;
        }
        if (pq.size() >= 2) {
            int a = pq.top();pq.pop();
            int b = pq.top();pq.pop();
            if (b - a <= 1) {
                pq.push(b + a);
            }
            else {
                cout << "No\n";return;
            }
        }
        else break;
    }
    if (pq.size() == 1) {
        if(mp[pq.top()] > 0)mp[pq.top()]--;
    }
    for (auto [x, y] : mp) {
        if(y > 0){
            cout << "No\n";return;
        }
    }
    cout << "Yes\n";
}
signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--)solve();
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pp pair<int,int> 
const int N = 2e5 + 9;
const int inf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;


void solve() {
    int n, m;cin >> n >> m;
    map<int, int> mp;
    priority_queue<int, vector<int>, greater<int>> pq;
    for (int i = 0;i < n;i++) {
        int a;cin >> a;pq.push(a);
    }
    for (int i = 0;i < m;i++) {
        int a;cin >> a;
        mp[a]++;
    }

    while (pq.size()) {
        while (pq.size()) {
            int a = pq.top();
            if (mp[a] > 0) {
                mp[a]--;pq.pop();
            }
            else break;
        }
        if (pq.size() >= 2) {
            int a = pq.top();pq.pop();
            int b = pq.top();pq.pop();
            if (b - a <= 1) {
                pq.push(b + a);
            }
            else {
                cout << "No\n";return;
            }
        }
        else break;
    }
    if (pq.size() == 1) {
        if(mp[pq.top()] > 0)mp[pq.top()]--;
    }
    for (auto [x, y] : mp) {
        if(y > 0){
            cout << "No\n";return;
        }
    }
    cout << "Yes\n";
}
signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--)solve();
    return 0;
}

Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pp pair<int,int> 
const int N = 2e5 + 9;
const int inf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;


void solve() {
    int n, m;cin >> n >> m;
    map<int, int> mp;
    priority_queue<int, vector<int>, greater<int>> pq;
    for (int i = 0;i < n;i++) {
        int a;cin >> a;pq.push(a);
    }
    for (int i = 0;i < m;i++) {
        int a;cin >> a;
        mp[a]++;
    }

    while (pq.size()>=2) {
        while (pq.size()) {
            int a = pq.top();
            if (mp[a] > 0) {
                mp[a]--;pq.pop();
            }
            else break;
        }
        if (pq.size() >= 2) {
            int a = pq.top();pq.pop();
            int b = pq.top();pq.pop();
            if (b - a <= 1) {
                pq.push(b + a);
            }
            else {
                cout << "No\n";return;
            }
        }
    }
    if (pq.size() == 1) {
        if(mp[pq.top()] > 0){mp[pq.top()]--;pq.pop();}
    }
    if(pq.size() > 0){
        cout << "No\n";return;
    }
    for (auto [x, y] : mp) {
        if(y > 0){
            cout << "No\n";return;
        }
    }
    cout << "Yes\n";
}
signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--)solve();
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pp pair<int,int> 
const int N = 2e5 + 9;
const int inf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;


void solve() {
    int n;cin >> n;
    vector<int> a(n), dp(n);
    for (int i = 0;i < n;i++)cin >> a[i];
    if (n == 1) {
        if (a[0] == 0)cout << 2 << endl;
        else cout << 1 << endl;
        return;
    }
    if (a[0] == 0) {
        dp[0] = 1;
        if (a[1] > 1)dp[1] = 0;
        else if (a[1] == 1)dp[1] = 1;
        else dp[1] = 1;
    }
    else {
        dp[0] = 0;
        if (a[1] == 1)dp[1] = 1;
        else dp[1] = 0;
    }
    for (int i = 2;i < n;i++) {
        if (a[i] == a[i - 1])dp[i] += dp[i - 1];dp[i] %= mod;
        if (a[i] == a[i - 2] + 1)dp[i] += dp[i - 2];
        dp[i] %= mod;
    }

    cout << dp[n - 1] + dp[n - 2] << endl;
}
signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--)solve();
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

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

using namespace std;

const int N = 55;

int T, n;
vector<int> a;

void Solve(){
	cin >> n;
	a.clear();
	for(int i = 1, x; i <= n; i++){
		cin >> x;
		a.push_back(x);
	}
	if(n == 1){
		cout << a.back() << '\n';
		return ;
	}
	long long sum = 0;
	long long ans = LLONG_MIN;
	for(int i = 0; i < n; i++){
		sum += a[i];
	}
	ans = sum;
	while(a.size() > 1){
		vector<int> v;
		sum = 0;
		for(int i = 1; i < a.size(); i++){
			v.push_back(a[i] - a[i - 1]);
			sum += v.back();
		}		
		ans = max({ans, sum, -sum});
		swap(a, v);
	}
	cout << ans << '\n';
}

int main(){
	for(cin >> T; T--; Solve()){
	}
	return 0;
}


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

using namespace std;

const int N = 55;

int T, n;
vector<long long> a;

void Solve(){
	cin >> n;
	a.clear();
	for(int i = 1, x; i <= n; i++){
		cin >> x;
		a.push_back(x);
	}
	if(n == 1){
		cout << a.back() << '\n';
		return ;
	}
	long long sum = 0;
	long long ans = LLONG_MIN;
	for(int i = 0; i < n; i++){
		sum += a[i];
	}
	ans = sum;
	while(a.size() > 1){
		vector<long long> v;
		sum = 0;
		for(int i = 1; i < a.size(); i++){
			v.push_back(a[i] - a[i - 1]);
			sum += v.back();
		}		
		ans = max({ans, sum, -sum});
		swap(a, v);
	}
	cout << ans << '\n';
}

int main(){
	for(cin >> T; T--; Solve()){
	}
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

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

using namespace std;

const int N = 55;

int T, n;
vector<int> a;

void Solve(){
	cin >> n;
	a.clear();
	for(int i = 1, x; i <= n; i++){
		cin >> x;
		a.push_back(x);
	}
	long long ans = LLONG_MIN;
	while(a.size() > 1){
		vector<int> v;
		long long sum = 0;
		for(int i = 1; i < a.size(); i++){
			v.push_back(a[i] - a[i - 1]);
			sum += v.back();
		}		
		ans = max(sum, -sum);
		swap(a, v);
	}
	cout << ans << '\n';
}

int main(){
	for(cin >> T; T--; Solve()){
	}
	return 0;
}


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

using namespace std;

const int N = 55;

int T, n;
vector<int> a;

void Solve(){
	cin >> n;
	a.clear();
	for(int i = 1, x; i <= n; i++){
		cin >> x;
		a.push_back(x);
	}
	if(n == 1){
		cout << a.back() << '\n';
		return ;
	}
	long long ans = LLONG_MIN;
	while(a.size() > 1){
		vector<int> v;
		long long sum = 0;
		for(int i = 1; i < a.size(); i++){
			v.push_back(a[i] - a[i - 1]);
			sum += v.back();
		}		
		ans = max(sum, -sum);
		swap(a, v);
	}
	cout << ans << '\n';
}

int main(){
	for(cin >> T; T--; Solve()){
	}
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

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

using namespace std;

const int N = 55;

int T, n;
vector<int> a;

void Solve(){
	cin >> n;
	a.clear();
	for(int i = 1, x; i <= n; i++){
		cin >> x;
		a.push_back(x);
	}
	long long ans = 0;
	while(a.size() > 1){
		vector<int> v;
		long long sum = 0;
		for(int i = 1; i < a.size(); i++){
			v.push_back(a[i] - a[i - 1]);
			sum += v.back();
		}		
		ans = max(sum, -sum);
		swap(a, v);
	}
	cout << ans << '\n';
}

int main(){
	for(cin >> T; T--; Solve()){
	}
	return 0;
}


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

using namespace std;

const int N = 55;

int T, n;
vector<int> a;

void Solve(){
	cin >> n;
	a.clear();
	for(int i = 1, x; i <= n; i++){
		cin >> x;
		a.push_back(x);
	}
	long long ans = LLONG_MIN;
	while(a.size() > 1){
		vector<int> v;
		long long sum = 0;
		for(int i = 1; i < a.size(); i++){
			v.push_back(a[i] - a[i - 1]);
			sum += v.back();
		}		
		ans = max(sum, -sum);
		swap(a, v);
	}
	cout << ans << '\n';
}

int main(){
	for(cin >> T; T--; Solve()){
	}
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


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

using namespace std;

const int N = 55;

int T, n;
vector<int> a;

void Solve(){
	cin >> n;
	a.clear();
	for(int i = 1, x; i <= n; i++){
		cin >> x;
		a.push_back(x);
	}
	long long ans = 0;
	while(a.size() > 1){
		vector<int> v;
		long long sum = 0;
		for(int i = 1; i < a.size(); i++){
			v.push_back(a[i] - a[i - 1]);
			sum += v.back();
		}		
		ans = max(sum, -sum);
		swap(a, v);
	}
	cout << ans << '\n';
}

int main(){
	for(cin >> T; T--; Solve()){
	}
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

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

using namespace std;

const int N = 55;

int T, n;
vector<int> a;

void Solve(){
	cin >> n;
	a.clear();
	for(int i = 1, x; i <= n; i++){
		cin >> x;
		a.push_back(x);
	}
	if(n == 1){
		cout << a.back() << '\n';
		return ;
	}
	long long ans = LLONG_MIN;
	while(a.size() > 1){
		vector<int> v;
		long long sum = 0;
		for(int i = 1; i < a.size(); i++){
			v.push_back(a[i] - a[i - 1]);
			sum += v.back();
		}		
		ans = max(sum, -sum);
		swap(a, v);
	}
	cout << ans << '\n';
}

int main(){
	for(cin >> T; T--; Solve()){
	}
	return 0;
}


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

using namespace std;

const int N = 55;

int T, n;
vector<int> a;

void Solve(){
	cin >> n;
	a.clear();
	for(int i = 1, x; i <= n; i++){
		cin >> x;
		a.push_back(x);
	}
	if(n == 1){
		cout << a.back() << '\n';
		return ;
	}
	long long sum = 0;
	long long ans = LLONG_MIN;
	for(int i = 0; i < n; i++){
		sum += a[i];
	}
	ans = sum;
	while(a.size() > 1){
		vector<int> v;
		sum = 0;
		for(int i = 1; i < a.size(); i++){
			v.push_back(a[i] - a[i - 1]);
			sum += v.back();
		}		
		ans = max({ans, sum, -sum});
		swap(a, v);
	}
	cout << ans << '\n';
}

int main(){
	for(cin >> T; T--; Solve()){
	}
	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

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

using namespace std;



#ifdef APPLE

#include <competitive/debug>

#else

#define debug(...) void()

#endif



template<typename T> bool chmax(T &a, const T &b) { return (b > a ? a = b, true : false); }

template<typename T> bool chmin(T &a, const T &b) { return (b < a ? a = b, true : false); }



using i64 = int64_t;



int main() {

  ios::sync_with_stdio(false);

  cin.tie(nullptr);



  int tt;

  cin >> tt;

  

  while (tt--) {

    int n, l, r;

    cin >> n >> l >> r;



    l--; r--;



    vector<int> in, out;

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

      int x;

      cin >> x;

      if (l <= i && i <= r) {

        in.push_back(x);

      }

      else {

        out.push_back(x);

      }

    }



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

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



    for (int i = 0, j = in.size()-1; i < (int)out.size() && j >= 0; i++) {

      if (out[i] < in[j]) {

        swap(out[i], in[j]);

        j--;

      }

    }



    cout << accumulate(in.begin(), in.end(), 0LL) << '\n';

  }

}

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

#ifdef APPLE
#include <competitive/debug>
#else
#define debug(...) void()
#endif

template<typename T> bool chmax(T &a, const T &b) { return (b > a ? a = b, true : false); }
template<typename T> bool chmin(T &a, const T &b) { return (b < a ? a = b, true : false); }

using i64 = int64_t;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int tt;
  cin >> tt;
  
  while (tt--) {
    int n, l, r;
    cin >> n >> l >> r;

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

    sort(b.begin(), b.end());
    
    map<int, int> rank;
    for (int i = 0; i < n; i++) {
      rank[b[i].second] = i;
    }

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

    vector<int> la, ra;
    for (int i = 0, j = r; i < l && j >= l; i++) {
      if (a[i] < a[j]) {
        la.push_back(a[i]);
        j--;
      }
    }

    for (int i = r+1, j = r; i < n && j >= l; i++) {
      if (a[i] < a[j]) {
        ra.push_back(a[i]);
        j--;
      }
    }

    if (la.size() > ra.size() || accumulate(la.begin(), la.end(), 0LL) < accumulate(ra.begin(), ra.end(), 0LL)) {
      cout << accumulate(la.begin(), la.end(), 0LL) + (r + 1 - la.size() >= l ? accumulate(a.begin() + l, a.begin() + r + 1 - la.size(), 0LL) : 0) << '\n';
    }
    else {
      cout << accumulate(ra.begin(), ra.end(), 0LL) + (r + 1 - ra.size() >= l ? accumulate(a.begin() + l, a.begin() + r + 1 - ra.size(), 0LL) : 0) << '\n';
    }
  }
}