ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 7):
//https://codeforces.com/problemset/problem/2052/A
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 10;
int n, m, k;
int a[N];
int b[N];
void solve() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        b[i] = i;
    }
    set<pair<int, int>> s;
    vector<pair<int, int>> ans;
    for (int i = 1; i <= n; ++i) {
        int  p = 0;
        for (int j = i; j <= n; ++j) {
            if (b[j] == a[i]) {
                p = j;
                break;
            }
        }
        for (int j = p; j > i; --j) {
            int jj = j - 1;
            int t1 = b[j], t2 = b[jj];
            ans.push_back({ t1,t2 });
            if (t2 > t1) swap(t1, t2);
            swap(b[j], b[jj]);
            s.insert({ t1,t2 });
        }
    }
    int t = 0;
    vector<int> tt;
    for (int i = 1; i <= n; ++i) {
        if (b[i] > t) {
            t = b[i];
        } else {
            if (tt.size() >= 2) {
                int pp = tt.size();
                while (pp--)
                    for (int j = tt.size() - 1; j >= 1; --j) {
                        ans.push_back({ tt[j],tt[j - 1] });
                        swap(tt[j], tt[j - 1]);
                    }
            }
            t = b[i];
            tt.clear();
        }
        tt.push_back(t);
       
    }
    if (tt.size() >= 2) {
        int pp = tt.size();
        while (pp--)
            for (int j = tt.size() - 1; j >= 1; --j) {
                ans.push_back({ tt[j],tt[j - 1] });
                swap(tt[j], tt[j - 1]);
            }
    }
    cout << ans.size() << "\n";
    for (auto [x, y] : ans) {
        cout << x << ' ' << y << "\n";
    }
}
signed main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int T = 1;
    //cin >> T;
    while (T--) {
        solve();
    }
}

Submission (verdict: Accepted):
//https://codeforces.com/problemset/problem/2052/A
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 10;
int n, m, k;
int a[N];
int b[N];
void solve() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    vector<pair<int,int>> ans;
    for(int i = 1; i < n; ++i) {
        for(int j = 1; j < n; ++j) {
            if(a[j] < a[j+1]) {
                ans.push_back({a[j],a[j+1]});
                swap(a[j],a[j+1]);
            }
        }
    }
    for(int i = 1; i< n; ++i) {
        for(int j = 1; j < n; ++j) {
            if (a[j] > a[j + 1]) {
                ans.push_back({ a[j],a[j + 1] });
                swap(a[j], a[j + 1]);
            }
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans.size()<<"\n";
    for(auto [x,y] : ans) {
        cout<<x<<' '<<y<<endl;
    }
}
signed main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int T = 1;
    //cin >> T;
    while (T--) {
        solve();
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 4):
//https://codeforces.com/problemset/problem/2052/A
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 10;
int n, m, k;
int a[N];
int b[N];
void solve() {
    cin>>n;
    for(int i = 1; i<= n; ++i) {
        cin>>a[i];
        b[i] = i;
    }
    set<pair<int,int>> s;
    vector<pair<int,int>> ans;
    for(int i = 1; i<= n; ++i) {
        int  p = 0;
        for(int j = i; j <= n; ++j) {
            if(b[j] == a[i]) {
                p = j;
                break;
            }
        }
        for(int j = p; j > i; --j) {
            int jj = j - 1;
            int t1 = b[j],t2 = b[jj];
            ans.push_back({t1,t2});
            if(t2 > t1) swap(t1,t2);
            swap(b[j],b[jj]);
            s.insert({t1,t2});
        }
    }
    for(int i = 1; i< n; ++i) {
        int t1 = b[i],t2 = b[i+1];
        if (t2 > t1) swap(t1, t2);
        if(!s.count({t1,t2})) {
            ans.push_back({t1,t2});
            ans.push_back({t2,t1});
        }
    }
    cout<<ans.size()<<"\n";
    for(auto [x,y] : ans) {
        cout<<x <<' '<<y << "\n";
    }
}
signed main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int T = 1;
    //cin >> T;
    while (T--) {
        solve();
    }
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


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

using namespace std;
using ll = long long;

// https://codeforces.com/blog/entry/62393
struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};

void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	if (n == 1) {
		cout << a[0] << endl;
	}
	int ans = INT_MIN;
	for (int len = n; len >= 1; len--) {
		vector<int> b;
		int sum = 0;
		for (int i = 0; i < len; i++) {
			sum += a[i];
			if (i > 0) {
				b.push_back(a[i] - a[i - 1]);
			}
		}
		ans = max(ans, abs(sum));
		a = b;
	}
	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int tt;
	cin >> tt;
	while (tt--) {
		solve();
	}
}
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;
using ll = long long;

// https://codeforces.com/blog/entry/62393
struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};

void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	if (n == 1) {
		cout << a[0] << endl;
		return;
	}
	int ans = INT_MIN;
	for (int len = n; len >= 1; len--) {
		vector<int> b;
		int sum = 0;
		for (int i = 0; i < len; i++) {
			sum += a[i];
			if (i > 0) {
				b.push_back(a[i] - a[i - 1]);
			}
		}
		ans = max(ans, abs(sum));
		a = b;
	}
	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int tt;
	cin >> tt;
	while (tt--) {
		solve();
	}
}



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

using namespace std;
using ll = long long;

// https://codeforces.com/blog/entry/62393
struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};

void solve() {
	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	if (n == 1) {
		cout << a[0] << endl;
		return;
	}
	ll ans = INT_MIN;
	for (int len = n; len >= 1; len--) {
		vector<ll> b;
		ll sum = 0;
		for (int i = 0; i < len; i++) {
			sum += a[i];
			if (i > 0) {
				b.push_back(a[i] - a[i - 1]);
			}
		}
		ans = max(ans, abs(sum));
		a = b;
	}
	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int tt;
	cin >> tt;
	while (tt--) {
		solve();
	}
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

using namespace std;
using ll = long long;

// https://codeforces.com/blog/entry/62393
struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};

void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	if (n == 1) {
		cout << a[0] << endl;
	}
	int ans = INT_MIN;
	for (int len = n; len >= 1; len--) {
		vector<int> b;
		int sum = 0;
		for (int i = 0; i < len; i++) {
			sum += a[i];
			if (i > 0) {
				b.push_back(a[i] - a[i - 1]);
			}
		}
		ans = max(ans, abs(sum));
		a = b;
	}
	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int tt;
	cin >> tt;
	while (tt--) {
		solve();
	}
}



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

using namespace std;
using ll = long long;

// https://codeforces.com/blog/entry/62393
struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};

void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	if (n == 1) {
		cout << a[0] << endl;
		return;
	}
	int ans = INT_MIN;
	for (int len = n; len >= 1; len--) {
		vector<int> b;
		int sum = 0;
		for (int i = 0; i < len; i++) {
			sum += a[i];
			if (i > 0) {
				b.push_back(a[i] - a[i - 1]);
			}
		}
		ans = max(ans, abs(sum));
		a = b;
	}
	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int tt;
	cin >> tt;
	while (tt--) {
		solve();
	}
}
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;
using ll = long long;

// https://codeforces.com/blog/entry/62393
struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};

void solve() {
	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	if (n == 1) {
		cout << a[0] << endl;
		return;
	}
	ll ans = INT_MIN;
	for (int len = n; len >= 1; len--) {
		vector<ll> b;
		ll sum = 0;
		for (int i = 0; i < len; i++) {
			sum += a[i];
			if (i > 0) {
				b.push_back(a[i] - a[i - 1]);
			}
		}
		ans = max(ans, abs(sum));
		a = b;
	}
	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int tt;
	cin >> tt;
	while (tt--) {
		solve();
	}
}



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

using namespace std;
using ll = long long;

// https://codeforces.com/blog/entry/62393
struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};

void solve() {
	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll ans = INT_MIN;
	for (int len = n; len >= 1; len--) {
		vector<ll> b;
		ll sum = 0;
		for (int i = 0; i < len; i++) {
			sum += a[i];
			if (i > 0) {
				b.push_back(a[i] - a[i - 1]);
			}
		}
		if (len != n) {
			sum = abs(sum);
		}
		ans = max(ans, sum);
		a = b;
	}
	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int tt;
	cin >> tt;
	while (tt--) {
		solve();
	}
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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



using namespace std;

using ll = long long;



// https://codeforces.com/blog/entry/62393

struct custom_hash {

	static uint64_t splitmix64(uint64_t x) {

		// http://xorshift.di.unimi.it/splitmix64.c

		x += 0x9e3779b97f4a7c15;

		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;

		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;

		return x ^ (x >> 31);

	}



	size_t operator()(uint64_t x) const {

		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();

		return splitmix64(x + FIXED_RANDOM);

	}

};



void solve() {

	int n, l, r;

	cin >> n >> l >> r;

	vector<int> a, b, c;

	ll ref = 0;

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

		int x;

		cin >> x;

		if (i + 1 < l) {

			a.push_back(x);

		} else if (i + 1 <= r) {

			b.push_back(x);

			ref += x;

		} else {

			c.push_back(x);

		}

	}

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

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

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



	ll ans = ref;

	ll test1 = ref;

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

		if (b[j] < a[i]) {

			break;

		}

		test1 += a[i];

		test1 -= b[j];

		ans = min(ans, test1);

	}

	ll test2 = ref;

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

		if (b[j] < c[i]) {

			break;

		}

		test2 += c[i];

		test2 -= b[j];

		ans = min(ans, test2);

	}

	cout << ans << endl;

}



int main() {

	ios::sync_with_stdio(false);

  cin.tie(nullptr);

  int tt;

	cin >> tt;

	while (tt--) {

		solve();

	}

}





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



using namespace std;

using ll = long long;



// https://codeforces.com/blog/entry/62393

struct custom_hash {

	static uint64_t splitmix64(uint64_t x) {

		// http://xorshift.di.unimi.it/splitmix64.c

		x += 0x9e3779b97f4a7c15;

		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;

		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;

		return x ^ (x >> 31);

	}



	size_t operator()(uint64_t x) const {

		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();

		return splitmix64(x + FIXED_RANDOM);

	}

};



void solve() {

	int n, l, r;

	cin >> n >> l >> r;

	vector<int> a, b, c;

	ll ref = 0;

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

		int x;

		cin >> x;

		if (i + 1 < l) {

			a.push_back(x);

		} else if (i + 1 <= r) {

			b.push_back(x);

			ref += x;

		} else {

			c.push_back(x);

		}

	}

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

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

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



	ll ans = ref;

	ll test1 = ref;

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

		if (b[j] < a[i]) {

			break;

		}

		test1 += a[i];

		test1 -= b[j];

		ans = min(ans, test1);

	}

	ll test2 = ref;

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

		if (b[j] < c[i]) {

			break;

		}

		test2 += c[i];

		test2 -= b[j];

		ans = min(ans, test2);

	}

	cout << ans << endl;

}



int main() {

	ios::sync_with_stdio(false);

  cin.tie(nullptr);

  int tt;

	cin >> tt;

	while (tt--) {

		solve();

	}

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

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

using namespace std;
using ll = long long;

// https://codeforces.com/blog/entry/62393
struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};

void solve() {
	int n, l, r;
	cin >> n >> l >> r;
	vector<int> a, b, c;
	ll ref = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (i + 1 < l) {
			a.push_back(x);
		} else if (i + 1 <= r) {
			b.push_back(x);
			ref += x;
		} else {
			c.push_back(x);
		}
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());

	ll ans = ref;
	ll test1 = ref;
	for (int i = 0, j = b.size() - 1; i < a.size() && j >= 0; i++, j--) {
		if (b[j] < a[i]) {
			break;
		}
		test1 += a[i] - b[j];
		ans = min(ans, test1);
	}
	ll test2 = ref;
	for (int i = 0, j = c.size() - 1; i < c.size() && j >= 0; i++, j--) {
		if (b[j] < c[i]) {
			break;
		}
		test2 += c[i] - b[j];
		ans = min(ans, test2);
	}
	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int tt;
	cin >> tt;
	while (tt--) {
		solve();
	}
}



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



using namespace std;

using ll = long long;



// https://codeforces.com/blog/entry/62393

struct custom_hash {

	static uint64_t splitmix64(uint64_t x) {

		// http://xorshift.di.unimi.it/splitmix64.c

		x += 0x9e3779b97f4a7c15;

		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;

		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;

		return x ^ (x >> 31);

	}



	size_t operator()(uint64_t x) const {

		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();

		return splitmix64(x + FIXED_RANDOM);

	}

};



void solve() {

	int n, l, r;

	cin >> n >> l >> r;

	vector<int> a, b, c;

	ll ref = 0;

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

		int x;

		cin >> x;

		if (i + 1 < l) {

			a.push_back(x);

		} else if (i + 1 <= r) {

			b.push_back(x);

			ref += x;

		} else {

			c.push_back(x);

		}

	}

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

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

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



	ll ans = ref;

	ll test1 = ref;

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

		if (b[j] < a[i]) {

			break;

		}

		test1 += a[i];

		test1 -= b[j];

		ans = min(ans, test1);

	}

	ll test2 = ref;

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

		if (b[j] < c[i]) {

			break;

		}

		test2 += c[i];

		test2 -= b[j];

		ans = min(ans, test2);

	}

	cout << ans << endl;

}



int main() {

	ios::sync_with_stdio(false);

  cin.tie(nullptr);

  int tt;

	cin >> tt;

	while (tt--) {

		solve();

	}

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


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

using namespace std;
using ll = long long;

// https://codeforces.com/blog/entry/62393
struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};

void solve() {
	int n, l, r;
	cin >> n >> l >> r;
	vector<int> a, b, c;
	ll ref = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (i + 1 < l) {
			a.push_back(x);
		} else if (i + 1 <= r) {
			b.push_back(x);
			ref += x;
		} else {
			c.push_back(x);
		}
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());

	ll ans = ref;
	ll test1 = ref;
	for (int i = 0, j = b.size() - 1; i < a.size() && j >= 0; i++, j--) {
		if (b[j] < a[i]) {
			break;
		}
		test1 += a[i] - b[j];
		ans = min(ans, test1);
	}
	ll test2 = ref;
	for (int i = 0, j = c.size() - 1; i < c.size() && j >= 0; i++, j--) {
		if (b[j] < c[i]) {
			break;
		}
		test2 += c[i] - b[j];
		ans = min(ans, test2);
	}
	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int tt;
	cin >> tt;
	while (tt--) {
		solve();
	}
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

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

using namespace std;
using ll = long long;

// https://codeforces.com/blog/entry/62393
struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};

void solve() {
	int n;
	cin >> n;
	vector<vector<int>> adjList(n);
	vector<int> deg(n);
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adjList[u].push_back(v);
		adjList[v].push_back(u);
		deg[u]++;
		deg[v]++;
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		vector<int> cnt(deg);
		for (int x : adjList[i]) {
			cnt[x]--;
		}
		int can = cnt[i];
		cnt[i] = 0;
		can += *max_element(cnt.begin(), cnt.end());
		ans = max(ans, can);
	}
	cout << ans - 1 << endl;
}

int main() {
	ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int tt;
	cin >> tt;
	while (tt--) {
		solve();
	}
}



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

using namespace std;
using ll = long long;

// https://codeforces.com/blog/entry/62393
struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};

void solve() {
	int n;
	cin >> n;
	vector<vector<int>> adjList(n);
	vector<int> deg(n);
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adjList[u].push_back(v);
		adjList[v].push_back(u);
		deg[u]++;
		deg[v]++;
	}
	int ans = 0;
	multiset<int> cnt(deg.begin(), deg.end());
	for (int i = 0; i < n; i++) {
		for (int x : adjList[i]) {
			cnt.erase(cnt.find(deg[x]));
			cnt.insert(deg[x] - 1);
		}
		int can = deg[i];
		cnt.erase(cnt.find(deg[i]));
		can += *cnt.rbegin();
		ans = max(ans, can);
		cnt.insert(deg[i]);
		for (int x : adjList[i]) {
			cnt.erase(cnt.find(deg[x] - 1));
			cnt.insert(deg[x]);
		}
	}
	cout << ans - 1 << endl;
}

int main() {
	ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int tt;
	cin >> tt;
	while (tt--) {
		solve();
	}
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


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

using namespace std;
using ll = long long;

// https://codeforces.com/blog/entry/62393
struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};

void solve() {
	int n;
	cin >> n;
	vector<vector<int>> adjList(n);
	vector<int> deg(n);
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adjList[u].push_back(v);
		adjList[v].push_back(u);
		deg[u]++;
		deg[v]++;
	}
	vector<int> p(n);
	iota(p.begin(), p.end(), 0);
	sort(p.begin(), p.end(), [&](int i, int j) { return deg[i] > deg[j]; });
	int first = p[0], firstCnt = deg[p[0]];
	multiset<int> s;
	for (int x : adjList[first]) {
		deg[x]--;
	}
	for (int i = 0; i < n; i++) {
		if (i != first) {
			s.insert(deg[i]);
		}
	}
	int secondCnt = *s.rbegin();
	cout << firstCnt + secondCnt - 1 << endl;
}

int main() {
	ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int tt;
	cin >> tt;
	while (tt--) {
		solve();
	}
}