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

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

using namespace std;
#define ll long long
#define rep(i, m, n) for (ll i = m; i <= n; i++)
#define reb(i, m, n) for (ll i = m; i >= n; i--)
#define rv(i, vt) for (auto i : vt)
#define pb push_back
#define ii pair<ll, ll>
#define F first
#define S second
#define task "task"

//Consts
const ll N = 3e5 + 5, mod = 1e9 + 7;

//Global variables
ll n, a[N], pos[N];

//Preparations
void PrepBeforeTest()
{

}

void AfterTestReset()
{
    
}

//Functions

//Main
void solve()
{
    cin >> n;
    rep(i, 1, n) cin >> a[i], pos[a[i]] = i;
    ll res = 0;
    rep(i, 1, n)
    rep(j, i + 1, n) if (pos[i] < pos[j]) res += 2;
    else res++;
    cout << res << "\n";
    rep(i, 1, n)
    rep(j, i + 1, n) if (pos[i] < pos[j]) cout << j << " " << i << "\n" << i << " " << j << "\n";
    else cout << j << " " << i << "\n";
}

//Finalize
int main()
{
    if (fopen(task".inp", "r"))
    {
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll tests = 1;
    //cin >> tests;
    PrepBeforeTest();
    while (tests--)
    {
        solve();
        cout << endl;
        AfterTestReset();
    }
}


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

using namespace std;
#define ll long long
#define rep(i, m, n) for (ll i = m; i <= n; i++)
#define reb(i, m, n) for (ll i = m; i >= n; i--)
#define rv(i, vt) for (auto i : vt)
#define pb push_back
#define ii pair<ll, ll>
#define F first
#define S second
#define task "task"

//Consts
const ll N = 3e5 + 5, mod = 1e9 + 7;

//Global variables
ll n, a[N], pos[N];

//Preparations
void PrepBeforeTest()
{

}

void AfterTestReset()
{
    
}

//Functions

//Main
void solve()
{
    cin >> n;
    rep(i, 1, n) cin >> a[i], pos[a[i]] = i;
    ll res = 0;
    rep(i, 1, n)
    rep(j, i + 1, n) if (pos[i] < pos[j]) res += 2;
    else res++;
    cout << res << "\n";
    rep(i, 1, n)
    rep(j, i + 1, n) cout << j << " " << i << "\n";
    reb(i, n, 1)
    rep(j, i + 1, n) if (pos[i] < pos[j]) cout << i << " " << j << "\n";
}

//Finalize
int main()
{
    if (fopen(task".inp", "r"))
    {
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll tests = 1;
    //cin >> tests;
    PrepBeforeTest();
    while (tests--)
    {
        solve();
        cout << endl;
        AfterTestReset();
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

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

void solve()
{
    int n, k; cin >> n >> k;
    vector<int>a(n + 1);
    map<int, int>q;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        q[a[i]]++;
    }
    if (n == k)
    {
        cout << 1 << endl;
        return;
    }
    vector<int>b;
    for (auto x : q)
        b.push_back(x.second);
    sort(b.begin(), b.end());
    int ans = 0;
    for (int i = 0; i < b.size(); i++)
    {
        if (b[i] <= k)
        {
            k--; b[b.size() - 1] += b[i];
        }
        else
        {
            ans++;
        }
    }
    cout << ans << endl;
}

int main()
{
    int t; cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

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

void solve()
{
    int n, k; cin >> n >> k;
    vector<int>a(n + 1);
    map<int, int>q;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        q[a[i]]++;
    }
    if (n <= k)
    {
        cout << 1 << endl;
        return;
    }
    vector<int>b;
    for (auto x : q)
        b.push_back(x.second);
    sort(b.begin(), b.end());
    int ans = 0;
    for (int i = 0; i < b.size(); i++)
    {
        if (b[i] <= k)
        {
            b[b.size() - 1] += b[i];
            k -= b[i];
        }
        else
            ans++;
    }
    cout << ans << endl;
}

int main()
{
    int t; cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

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

void solve()
{
    int n, k; cin >> n >> k;
    vector<int>a(n + 1);
    map<int, int>q;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        q[a[i]]++;
    }
    vector<int>b;
    for (auto x : q)
        b.push_back(x.second);
    sort(b.begin(), b.end());
    int ans = 0;
    for (int i = 0; i < b.size(); i++)
    {
        if (b[i] <= k)
        {
            k--; b[b.size() - 1] += b[i];
        }
        else
        {
            ans++;
        }
    }
    cout << ans << endl;
}

int main()
{
    int t; cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

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

void solve()
{
    int n, k; cin >> n >> k;
    vector<int>a(n + 1);
    map<int, int>q;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        q[a[i]]++;
    }
    if (n == k)
    {
        cout << 1 << endl;
        return;
    }
    vector<int>b;
    for (auto x : q)
        b.push_back(x.second);
    sort(b.begin(), b.end());
    int ans = 0;
    for (int i = 0; i < b.size(); i++)
    {
        if (b[i] <= k)
        {
            k--; b[b.size() - 1] += b[i];
        }
        else
        {
            ans++;
        }
    }
    cout << ans << endl;
}

int main()
{
    int t; cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)


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

void solve()
{
    int n, k; cin >> n >> k;
    vector<int>a(n + 1);
    map<int, int>q;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        q[a[i]]++;
    }
    vector<int>b;
    for (auto x : q)
        b.push_back(x.second);
    sort(b.begin(), b.end());
    int ans = 0;
    for (int i = 0; i < b.size(); i++)
    {
        if (b[i] <= k)
        {
            k--; b[b.size() - 1] += b[i];
        }
        else
        {
            ans++;
        }
    }
    cout << ans << endl;
}

int main()
{
    int t; cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2049C - MEX Cycle
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;

const ll inf = 4e18;

const int N = 2e5 + 5;

int n, x, y;

int a[N];

void solve(){

	cin >> n >> x >> y;

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

		a[i] = (i - 1) % 2;

	}

	if(n % 2 == 1)a[1] = 2;



	if(a[x] == a[y]){

		if(n % 2 == 0)a[x] = 2;

		else{

			if(x == 2 || y == n)swap(a[x], a[1]);

			else a[x] = 2;

		}

	}

	for(int i = 1;i <= n; ++ i)cout << a[i] << ' ';

		cout << '\n';



}



int 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;

using ll = long long;

const ll inf = 4e18;

const int N = 2e5 + 5;

int n, x, y;

int a[N];

void solve(){

	cin >> n >> x >> y;

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

		a[i] = (i - 1) % 2;

	}

	if(n % 2 == 1)a[1] = 2;



	if(a[x] == a[y]){

		if(n % 2 == 0)a[x] = 2;

		else{

			if(x == 2)swap(a[x], a[1]);

			else if(y == n)swap(a[y], a[1]);

			else a[x] = 2;

		}

	}

	for(int i = 1;i <= n; ++ i)cout << a[i] << ' ';

		cout << '\n';



}



int main(){

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

	int _ = 1;cin >> _;

	while(_ --){

		solve();

	}

	return 0;

}

/*



*/
Problem: 2049C - MEX Cycle
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;

const ll inf = 4e18;

const int N = 2e5 + 5;

int n, x, y;

int a[N];

void solve(){

	cin >> n >> x >> y;

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

		a[i] = (i - 1) % 2;

	}

	if(n % 2 == 1)a[1] = 2;



	if(a[x] == a[y]){

		if(n % 2 == 0)a[x] = 2;

		else{

			if(x == 2)swap(a[x], a[1]);

			else if(y == n)swap(a[y], a[1]);

			else a[x] = 2;

		}

	}

	for(int i = 1;i <= n; ++ i)cout << a[i] << ' ';

		cout << '\n';



}



int 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;

using ll = long long;

const ll inf = 4e18;

const int N = 2e5 + 5;

int n, x, y;

int a[N];

void solve(){

	cin >> n >> x >> y;

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

		a[i] = (i - 1) % 2;

	}

	if(n % 2 == 1)a[1] = 2;



	if(a[x] == a[y]){

		if(n % 2 == 0)a[x] = 2;

		else{

			if(x == 2)swap(a[x], a[1]);

			else if(y == n)swap(a[y], a[1]);

			else a[y] = 2;

		}

	}

	for(int i = 1;i <= n; ++ i)cout << a[i] << ' ';

		cout << '\n';



}



int main(){

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

	int _ = 1;cin >> _;

	while(_ --){

		solve();

	}

	return 0;

}

/*



*/
Problem: 2049C - MEX Cycle
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;

const ll inf = 4e18;

const int N = 2e5 + 5;

int n, x, y;

int a[N];

void solve(){

	cin >> n >> x >> y;

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

		a[i] = (i - 1) % 2;

	}

	if(n % 2 == 1)a[1] = 2;



	if(a[x] == a[y]){

		if(n % 2 == 0)a[x] = 2;

		else{

			if(x == 2 || y == n)swap(a[x], a[n]);

			else a[x] = 2;

		}

	}

	for(int i = 1;i <= n; ++ i)cout << a[i] << ' ';

		cout << '\n';



}



int 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;

using ll = long long;

const ll inf = 4e18;

const int N = 2e5 + 5;

int n, x, y;

int a[N];

void solve(){

	cin >> n >> x >> y;

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

		a[i] = (i - 1) % 2;

	}

	if(n % 2 == 1)a[1] = 2;



	if(a[x] == a[y]){

		if(n % 2 == 0)a[x] = 2;

		else{

			if(x == 2 || y == n)swap(a[x], a[1]);

			else a[x] = 2;

		}

	}

	for(int i = 1;i <= n; ++ i)cout << a[i] << ' ';

		cout << '\n';



}



int main(){

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

	int _ = 1;cin >> _;

	while(_ --){

		solve();

	}

	return 0;

}

/*



*/
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)


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

using namespace std;

using ll = long long;

const ll inf = 4e18;

const int N = 2e5 + 5;

int n, x, y;

int a[N];

void solve(){

	cin >> n >> x >> y;

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

		a[i] = (i - 1) % 2;

	}

	if(n % 2 == 1)a[1] = 2;



	if(a[x] == a[y]){

		if(n % 2 == 0)a[x] = 2;

		else{

			if(x == 2 || y == n)swap(a[x], a[n]);

			else a[x] = 2;

		}

	}

	for(int i = 1;i <= n; ++ i)cout << a[i] << ' ';

		cout << '\n';



}



int main(){

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

	int _ = 1;cin >> _;

	while(_ --){

		solve();

	}

	return 0;

}

/*





*/
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 4e18;
const int N = 1e3 + 5;
int n, a[N], b[N], c[N];
void solve(){
	cin >> n;
	for(int i = 1;i <= n; ++ i)cin >> a[i];
	vector<pair<int, int> > ans;
	for(int i = n;i > 1; -- i){
		for(int j = i - 1;j >= 1; -- j)ans.push_back({i, j});
	}
	for(int i = 1;i <= n; ++ i)b[i] = n - i + 1;

	for(int i = 1;i <= n; ++ i){
		int x = a[i];
		int p = n - x + 1;
		c[p] = p - i;
	}

	for(int i = 1;i <= n; ++ i){
		if(c[i] > 0){
			int x = c[i];
			for(int j = i;x >= 1; -- j, -- x){
				ans.push_back({b[i], b[i - 1]});
				swap(b[i], b[i - 1]);
			}
		}
	}

	cout << ans.size() << '\n';
	for(const auto [x, y] : ans)cout << x << ' ' << y << '\n';

}

int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int _ = 1;
	while(_ --){
		solve();
	}
	return 0;
}
/*


*/
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 4e18;
const int N = 1e3 + 5;
int n, a[N], b[N], c[N];
void solve(){
	cin >> n;
	for(int i = 1;i <= n; ++ i)cin >> a[i];
	vector<pair<int, int> > ans;
	for(int i = n;i > 1; -- i){
		for(int j = i - 1;j >= 1; -- j)ans.push_back({i, j});
	}
	for(int i = 1;i <= n; ++ i)b[i] = n - i + 1;

	for(int i = 1;i <= n; ++ i){
		int x = a[i];
		int p = n - x + 1;
		c[p] = p - i;
	}

	for(int i = 1;i <= n; ++ i){
		if(c[i] > 0){
			int x = c[i];
			for(int j = i;x >= 1; -- j, -- x){
				ans.push_back({b[i], b[i - 1]});
				swap(b[i], b[i - 1]);
			}
		}
	}

	cout << ans.size() << '\n';
	for(const auto [x, y] : ans)cout << x << ' ' << y << '\n';

}

int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int _ = 1;
	while(_ --){
		solve();
	}
	return 0;
}
/*


*/

Submission (verdict: Wrong answer on test 6):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 4e18;
const int N = 1e3 + 5;
int n, a[N], b[N], c[N];
void solve(){
	cin >> n;
	for(int i = 1;i <= n; ++ i)cin >> a[i];
	vector<pair<int, int> > ans;
	for(int i = n;i > 1; -- i){
		for(int j = i - 1;j >= 1; -- j)ans.push_back({i, j});
	}
	for(int i = 1;i <= n; ++ i)b[i] = n - i + 1;

	for(int i = 1;i <= n; ++ i){
		int x = a[i];
		int p = n - x + 1;
		c[p] = p - i;
	}

	for(int i = 1;i <= n; ++ i){
		if(c[i] > 0){
			int x = c[i];
			for(int j = i;x >= 1; -- j, -- x){
				ans.push_back({b[j], b[j - 1]});
				c[j] --, c[j - 1] ++;
				swap(c[j], c[j - 1]);
				swap(b[j], b[j - 1]);
			}
			-- i;
		}
	}

	cout << ans.size() << '\n';
	for(const auto [x, y] : ans)cout << x << ' ' << y << '\n';

}

int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int _ = 1;
	while(_ --){
		solve();
	}
	return 0;
}
/*


*/
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 6):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 4e18;
const int N = 1e3 + 5;
int n, a[N], b[N], c[N];
void solve(){
	cin >> n;
	for(int i = 1;i <= n; ++ i)cin >> a[i];
	vector<pair<int, int> > ans;
	for(int i = n;i > 1; -- i){
		for(int j = i - 1;j >= 1; -- j)ans.push_back({i, j});
	}
	for(int i = 1;i <= n; ++ i)b[i] = n - i + 1;

	for(int i = 1;i <= n; ++ i){
		int x = a[i];
		int p = n - x + 1;
		c[p] = p - i;
	}

	for(int i = 1;i <= n; ++ i){
		if(c[i] > 0){
			int x = c[i];
			for(int j = i;x >= 1; -- j, -- x){
				ans.push_back({b[j], b[j - 1]});
				c[j] --, c[j - 1] ++;
				swap(c[j], c[j - 1]);
				swap(b[j], b[j - 1]);
			}
			-- i;
		}
	}

	cout << ans.size() << '\n';
	for(const auto [x, y] : ans)cout << x << ' ' << y << '\n';

}

int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int _ = 1;
	while(_ --){
		solve();
	}
	return 0;
}
/*


*/

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 4e18;
const int N = 1e3 + 5;
int n, a[N], b[N];
void solve(){
	cin >> n;
	for(int i = 1;i <= n; ++ i){
		int x;cin >> x;
		a[x] = i;
	}
	vector<pair<int, int> > ans;
	for(int i = 1;i <= n; ++ i)b[i] = i;

	for(int i = 1;i <= n; ++ i){
		for(int j = n;j > i; -- j){
			if(b[j] > b[j - 1]){
				ans.push_back({b[j], b[j - 1]});
				swap(b[j], b[j - 1]);
			}
		}
	}

	for(int i = 1;i <= n; ++ i){
		for(int j = 1;j < n; ++ j){
			if(b[j] > b[j + 1] && a[b[j]] > a[b[j + 1]]){
				ans.push_back({b[j + 1], b[j]});
				swap(b[j + 1], b[j]);
			}
		}
	}
	cout << ans.size() << '\n';
	for(const auto [x, y] : ans)cout << x << ' ' << y << '\n';

}

int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int _ = 1;
	while(_ --){
		solve();
	}
	return 0;
}
/*


*/
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

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

void solve(){
    int l; int r;
    cin >> l;
    cin >> r;
    int len = floor(log2(r)) + 1;
    string a;
    if (r > 0){
        a = bitset<32>(r).to_string().substr(32-len, len);
    }
    else{
        a = "0";
    }
    
    string c = bitset<32>(l).to_string().substr(32-len, len);
    //string c = "00";
    string b = "";
    int bval = 0;
    for (int i = 0; i < len; i++){
        if ((bval + (pow(2, (len-i-1)))-1)<l){
            b+="1";
            bval += pow(2, (len-i-1));
            continue;
        }
        else if ((bval + (pow(2, (len-i-1)))-1)==l){
            b += "0";
            for (int j = i+1; j < len; j++){
                b+="1";
                bval += pow(2, (len-j-1));
            }
            break;
        }
        else{
            if (c[i] == '1' && a[i] == '1'){
                b+="0";
                continue;
            }
            else if ((c[i] == '0' && a[i] == '0')&&(bval + pow(2, (len-i-1))<=r)){
                b+="1";
                bval += pow(2, (len-i-1));
                continue;
            }
            else {
                b+="0";
                continue;
            }
        }
    }
    cout << l << " " << bval << " " << r << endl;
}

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

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

void solve(){
    int l; int r;
    cin >> l;
    cin >> r;
    int len = floor(log2(r)) + 1;
    string a;
    if (r > 0){
        a = bitset<32>(r).to_string().substr(32-len, len);
    }
    else{
        a = "0";
    }
    
    string c = bitset<32>(l).to_string().substr(32-len, len);
    //string c = "00";
    string b = "";
    int bval = 0;
    for (int i = 0; i < len; i++){
        if ((bval + (pow(2, (len-i-1)))-1)<l){
            b+="1";
            bval += pow(2, (len-i-1));
            continue;
        }
        /*
        else if ((bval + (pow(2, (len-i-1)))-1)==l){
            b += "0";
            for (int j = i+1; j < len; j++){
                b+="1";
                bval += pow(2, (len-j-1));
            }
            break;
        }
        */
        else{
            if (c[i] == '1' && a[i] == '1'){
                b+="0";
                continue;
            }
            else if ((c[i] == '0' && a[i] == '0')&&(bval + pow(2, (len-i-1))<r)){
                b+="1";
                bval += pow(2, (len-i-1));
                continue;
            }
            else {
                if ((c[i] == '0' && a[i] == '1')&&(bval + pow(2, (len-i-1))<r)){
                    b+="1";
                    bval += pow(2, (len-i-1));
                    continue;
                }
                b+="0";
                continue;
            }
        }
    }
    cout << l << " " << bval << " " << r << endl;
}

int main(){
    int t;
    cin >> t;
    for (int i = 0; i < t; i++){
        solve();
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)


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

void solve(){
    int l; int r;
    cin >> l;
    cin >> r;
    int len = floor(log2(r)) + 1;
    string a;
    if (r > 0){
        a = bitset<32>(r).to_string().substr(32-len, len);
    }
    else{
        a = "0";
    }
    
    string c = bitset<32>(l).to_string().substr(32-len, len);
    //string c = "00";
    string b = "";
    int bval = 0;
    for (int i = 0; i < len; i++){
        if ((bval + (pow(2, (len-i-1)))-1)<l){
            b+="1";
            bval += pow(2, (len-i-1));
            continue;
        }
        else if ((bval + (pow(2, (len-i-1)))-1)==l){
            b += "0";
            for (int j = i+1; j < len; j++){
                b+="1";
                bval += pow(2, (len-j-1));
            }
            break;
        }
        else{
            if (c[i] == '1' && a[i] == '1'){
                b+="0";
                continue;
            }
            else if ((c[i] == '0' && a[i] == '0')&&(bval + pow(2, (len-i-1))<=r)){
                b+="1";
                bval += pow(2, (len-i-1));
                continue;
            }
            else {
                b+="0";
                continue;
            }
        }
    }
    cout << l << " " << bval << " " << r << endl;
}

int main(){
    int t;
    cin >> t;
    for (int i = 0; i < t; i++){
        solve();
    }
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

using namespace std;

void solve(){
    int n; cin >> n;
    vector<ll> a(n);
    for(auto &e:a) cin >> e;
    if(n==1){
        cout << a[0] << "\n";
        return;
    }
    ll ans = accumulate(a.begin(), a.end(), 0);
    for(int c=0;c<n && (int)a.size()>1;c++){
        vector<ll> nv;
        ll ns = 0;
        for(int i=(int)a.size()-1;i;--i){
            nv.emplace_back(a[i-1]-a[i]);
            ns += a[i-1]-a[i];
        }
        swap(nv, a);
        ans = max(ans, ns);
    }
    cout << ans << "\n";
}
int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    int tc; cin >> tc;
    while(tc--) solve();

    return 0;
}


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

using namespace std;

void solve(){
    int n; cin >> n;
    vector<ll> a(n);
    for(auto &e:a) cin >> e;
    if(n==1){
        cout << a[0] << "\n";
        return;
    }
    ll ans = accumulate(a.begin(), a.end(), 0);
    while((int)a.size()>1){
        vector<ll> nv;
        ll ns = 0;
        for(int i=(int)a.size()-1;i;--i){
            nv.emplace_back(a[i-1]-a[i]);
            ns += a[i-1]-a[i];
        }
        swap(nv, a);
        ans = max(ans, ns);
    }
    cout << ans << "\n";
}
int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    int tc; cin >> tc;
    while(tc--) solve();

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

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

using namespace std;

void solve(){
    int n; cin >> n;
    vector<ll> a(n);
    for(auto &e:a) cin >> e;
    if(n==1){
        cout << a[0] << "\n";
        return;
    }
    ll ans = accumulate(a.begin(), a.end(), 0);
    while((int)a.size()>1){
        vector<ll> nv;
        ll ns = 0;
        for(int i=(int)a.size()-1;i;--i){
            nv.emplace_back(a[i-1]-a[i]);
            ns += a[i-1]-a[i];
        }
        swap(nv, a);
        ans = max(ans, ns);
    }
    cout << ans << "\n";
}
int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    int tc; cin >> tc;
    while(tc--) solve();

    return 0;
}


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

using namespace std;

void solve(){
    int n; cin >> n;
    vector<ll> a(n);
    for(auto &e:a) cin >> e;
    if(n==1){
        cout << a[0] << "\n";
        return;
    }
    ll ans = accumulate(a.begin(), a.end(), 0);
    while((int)a.size()>1){
        vector<ll> nv;
        ll ns = 0;
        int sz = a.size();
        for(int i=sz-1;i;--i){
            nv.emplace_back(a[i-1]-a[i]);
            ns += a[i-1]-a[i];
        }
        ans = max({ans, ns, -ns});
        swap(nv, a);
    }
    cout << ans << "\n";
}
int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    int tc; cin >> tc;
    while(tc--) solve();

    return 0;
}