ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

using namespace std;
/*
8
4 5 4 5 4 5 4 5
0 1 1 1
*/
int T, a[200001], n;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> T;
    while(T--)
    {
        int i;
        cin >> n;
        for(i = 1; i <= n; i++)
            cin >> a[i];
        if(a[1] > a[2])
            cout << "NO\n";
        else
        {
            a[2] -= a[1];
            a[1] = 0;
            for(i = 3; i <= n; i++)
            {
                if(a[i - 1] != 0)
                {
                    while(a[i] - a[i - 1] >= a[i - 1])
                        a[i] -= a[i - 1];
                }
            }
            bool ok = true;
            for(i = 1; i < n and ok == true; i++)
                if(a[i] > a[i + 1])
                    ok = false;
            if(ok == false)
                cout << "NO\n";
            else cout << "Yes\n";
        }
    }
    return 0;
}


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

using namespace std;
/*
8
4 5 4 5 4 5 4 5
0 1 1 1
*/
int T, a[200001], n;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> T;
    while(T--)
    {
        int i;
        cin >> n;
        for(i = 1; i <= n; i++)
            cin >> a[i];
        int x = min(a[1], a[2]);
        a[2] -= x;
        a[1] -= x;
        for(i = 3; i <= n; i++)
        {
            if(a[i - 1] != 0)
            {
                while(a[i] - a[i - 1] >= a[i - 1])
                    a[i] -= a[i - 1];
            }
        }
        bool ok = true;
        for(i = 1; i < n and ok == true; i++)
            if(a[i] > a[i + 1])
                ok = false;
        if(ok == false)
            cout << "NO\n";
        else cout << "Yes\n";
    }
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


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

#define pb push_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll INF = (ll)1<<62;
const ll MOD = 1e9+7;
const int iINF = 1<<30;
const double PI = 3.14159265359;

void solve(){
	int m, n;
	cin >> m >> n;
	
	vector<int> a(m);
	vector<int> b(n);
	for(int& x : a) cin >> x;
	for(int& x : b) cin >> x;

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

	int i = 0, j = 0;
	while(i < m && j < n){
		//cout << a[i] << " " << b[j] << ",";
		if(a[i] == b[j]){
			i++;
			j++;
		} else if(a[i] < b[j]){
			if(i+1 < m && a[i+1]-a[i] <= 1){
				a[i+1] += a[i];
				
				for(int k=i+1;k+1<m;k++){
					if(a[k] < a[k+1]) swap(a[k], a[k+1]);
					else break;
				}

				i++;
			}
			else break;
		} else break;
	}

	//cout << "\n";
	if(i == m && j == n) cout << "Yes\n";
	else cout << "No\n";
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	#ifdef ONLINEJUDGE
       clock_t tStart = clock();
       freopen("input.txt","r",stdin); //can need to change file . this one for taking input
       freopen("output.txt","w",stdout); // this one for output
  	#endif

       //Your Code
       int t; cin >> t;
       while(t--){
       	solve();
       }

  	#ifdef ONLINEJUDGE
     	fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC); // this line gives your code runtime
  	#endif

    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

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

#define pb push_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll INF = (ll)1<<62;
const ll MOD = 1e9+7;
const int iINF = 1<<30;
const double PI = 3.14159265359;

void solve(){
	int m, n;
	cin >> m >> n;
	
	vector<int> a(m);
	vector<int> b(n);
	for(int& x : a) cin >> x;
	for(int& x : b) cin >> x;

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

	int i = 0, j = 0;
	while(i < m && j < n){
		//cout << a[i] << " " << b[j] << ",";
		if(a[i] == b[j]){
			i++;
			j++;
		} else if(a[i] < b[j]){
			if(i+1 < m && a[i+1]-a[i] <= 1){
				a[i+1] += a[i];
				
				for(int k=i+1;k+1<m;k++){
					if(a[k] < a[k+1]) swap(a[k], a[k+1]);
					else break;
				}

				i++;
			}
			else break;
		} else break;
	}

	//cout << "\n";
	if(i == m && j == n) cout << "Yes\n";
	else cout << "No\n";
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	#ifdef ONLINEJUDGE
       clock_t tStart = clock();
       freopen("input.txt","r",stdin); //can need to change file . this one for taking input
       freopen("output.txt","w",stdout); // this one for output
  	#endif

       //Your Code
       int t; cin >> t;
       while(t--){
       	solve();
       }

  	#ifdef ONLINEJUDGE
     	fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC); // this line gives your code runtime
  	#endif

    return 0;
}

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

#define pb push_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll INF = (ll)1<<62;
const ll MOD = 1e9+7;
const int iINF = 1<<30;
const double PI = 3.14159265359;

void solve(){
	int m, n;
	cin >> m >> n;
	
	vector<int> a(m);
	vector<int> b(n);
	for(int& x : a) cin >> x;
	for(int& x : b) cin >> x;

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

	int i = 0, j = 0;
	while(i < m && j < n){
		//cout << a[i] << " " << b[j] << ",";
		if(a[i] == b[j]){
			i++;
			j++;
		} else if(a[i] < b[j]){
			if(i+1 < m && a[i+1]-a[i] <= 1){
				a[i+1] += a[i];
				
				for(int k=i+1;k+1<m;k++){
					if(a[k] > a[k+1]) swap(a[k], a[k+1]);
					else break;
				}

				i++;
			}
			else break;
		} else break;
	}

	//cout << "\n";
	if(i == m && j == n) cout << "Yes\n";
	else cout << "No\n";
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	#ifdef ONLINEJUDGE
       clock_t tStart = clock();
       freopen("input.txt","r",stdin); //can need to change file . this one for taking input
       freopen("output.txt","w",stdout); // this one for output
  	#endif

       //Your Code
       int t; cin >> t;
       while(t--){
       	solve();
       }

  	#ifdef ONLINEJUDGE
     	fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC); // this line gives your code runtime
  	#endif

    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

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

#define pb push_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll INF = (ll)1<<62;
const ll MOD = 1e9+7;
const int iINF = 1<<30;
const double PI = 3.14159265359;

void solve(){
	int m, n;
	cin >> m >> n;
	
	vector<int> a(m);
	vector<int> b(n);
	for(int& x : a) cin >> x;
	for(int& x : b) cin >> x;

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

	int i = 0, j = 0;
	while(i < m && j < n){
		//cout << a[i] << " " << b[j] << ",";
		if(a[i] == b[j]){
			i++;
			j++;
		} else if(a[i] < b[j]){
			if(i+1 < m && a[i+1]-a[i] <= 1){
				a[i+1] += a[i];
				
				for(int k=i+1;k+1<m;k++){
					if(a[k] > a[k+1]) swap(a[k], a[k+1]);
					else break;
				}

				i++;
			}
			else break;
		} else break;
	}

	//cout << "\n";
	if(i == m && j == n) cout << "Yes\n";
	else cout << "No\n";
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	#ifdef ONLINEJUDGE
       clock_t tStart = clock();
       freopen("input.txt","r",stdin); //can need to change file . this one for taking input
       freopen("output.txt","w",stdout); // this one for output
  	#endif

       //Your Code
       int t; cin >> t;
       while(t--){
       	solve();
       }

  	#ifdef ONLINEJUDGE
     	fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC); // this line gives your code runtime
  	#endif

    return 0;
}

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

#define pb push_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll INF = (ll)1<<62;
const ll MOD = 1e9+7;
const int iINF = 1<<30;
const double PI = 3.14159265359;

void solve(){
	int m, n;
	cin >> m >> n;
	
	multiset<int> a;
	multiset<int> b;

	int tmp;
	for(int i=0;i<m;i++){
		cin >> tmp;
		a.insert(tmp);
	}
	for(int i=0;i<n;i++){
		cin >> tmp;
		b.insert(tmp);
	}

	while(!a.empty() && !b.empty()){
		int x = *b.begin();
		if(x < *a.begin()) break;
		
		b.erase(b.begin());

		multiset<int>::iterator it = a.find(x);
		if(it == a.end()){
			int y = x/2;
			int z = (x+1)/2;

			b.insert(y);
			b.insert(z);
		} else {
			a.erase(it);
		}
	}

	if(a.empty() && b.empty()) cout << "Yes\n";
	else cout << "No\n";
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	#ifdef ONLINEJUDGE
       clock_t tStart = clock();
       freopen("input.txt","r",stdin); //can need to change file . this one for taking input
       freopen("output.txt","w",stdout); // this one for output
  	#endif

       //Your Code
       int t; cin >> t;
       while(t--){
       	solve();
       }

  	#ifdef ONLINEJUDGE
     	fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC); // this line gives your code runtime
  	#endif

    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 8):
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;
const int N=200010;
int a[N],b[N],c[N];
void solve(){
	int n,l,r;
	cin>>n>>l>>r;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<r;i++) b[i]=a[i];
	int k=0;
	for(int i=l-1;i<n;i++) c[k++]=a[i];
	sort(b,b+r);
	sort(c,c+k);
	int t=r-l+1;
	int minv=0;
	int cnt=1e9;
	for(int i=0;i<t;i++) minv+=b[i];
	cnt=min(cnt,minv);
	minv=0;
	for(int i=0;i<t;i++) minv+=c[i];
	cnt=min(cnt,minv);
	cout << cnt << endl;
}
int main(){
	int t;
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
} 

Submission (verdict: Wrong answer on test 8):
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;
const int N=200010;
long long a[N],b[N],c[N];
void solve(){
	int n,l,r;
	cin>>n>>l>>r;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<r;i++) b[i]=a[i];
	int k=0;
	for(int i=l-1;i<n;i++) c[k++]=a[i];
	sort(b,b+r);
	sort(c,c+k);
	int t=r-l+1;
	long long minv=0;
	long long cnt=1e9+900;
	for(int i=0;i<t;i++) minv+=b[i];
	cnt=min(cnt,minv);
	minv=0;
	for(int i=0;i<t;i++) minv+=c[i];
	cnt=min(cnt,minv);
	cout << cnt << endl;
}
int main(){
	int t;
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

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

#include<algorithm>

#include<cstring>

using namespace std;

const int N=100010;

int a[N];

void solve(){

	int n,l,r;

	cin>>n>>l>>r;

	for(int i=0;i<n;i++) cin>>a[i];

	sort(a,a+n);

	long long cnt=0;

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

	{

		cnt+=a[i];

	}

	cout << cnt << endl;

}

int main(){

	int T=1;

	cin>>T;

	while(T--)

	{

		solve();

	}

	return 0;

}

Submission (verdict: Wrong answer on test 8):
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;
const int N=200010;
int a[N],b[N],c[N];
void solve(){
	int n,l,r;
	cin>>n>>l>>r;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<r;i++) b[i]=a[i];
	int k=0;
	for(int i=l-1;i<n;i++) c[k++]=a[i];
	sort(b,b+r);
	sort(c,c+k);
	int t=r-l+1;
	int minv=0;
	int cnt=1e9;
	for(int i=0;i<t;i++) minv+=b[i];
	cnt=min(cnt,minv);
	minv=0;
	for(int i=0;i<t;i++) minv+=c[i];
	cnt=min(cnt,minv);
	cout << cnt << endl;
}
int main(){
	int t;
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)


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

#include<algorithm>

#include<cstring>

using namespace std;

const int N=100010;

int a[N];

void solve(){

	int n,l,r;

	cin>>n>>l>>r;

	for(int i=0;i<n;i++) cin>>a[i];

	sort(a,a+n);

	long long cnt=0;

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

	{

		cnt+=a[i];

	}

	cout << cnt << endl;

}

int main(){

	int T=1;

	cin>>T;

	while(T--)

	{

		solve();

	}

	return 0;

}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

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

#include<algorithm>

#include<cstring>

#include<cmath>

#include<vector>

#include<queue>

using namespace std;

const int N=200010;

long long a[N],b[N],c[N];

void solve(){

	int n,l,r;

	cin>>n>>l>>r;

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

		cin>>a[i];

	}

	for(int i=0;i<r;i++) b[i]=a[i];

	int k=0;

	for(int i=l-1;i<n;i++) c[k++]=a[i];

	sort(b,b+r);

	sort(c,c+k);

	int t=r-l+1;

	long long minv=0;

	long long cnt=1e13;

	for(int i=0;i<t;i++) minv+=b[i];

	cnt=min(cnt,minv);

	minv=0;

	for(int i=0;i<t;i++) minv+=c[i];

	cnt=min(cnt,minv);

	cout << cnt << endl;

}

int main(){

	int t;

	cin>>t;

	while(t--){

		solve();

	}

	return 0;

} 

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

#include<algorithm>

#include<cstring>

#include<cmath>

#include<vector>

#include<queue>

using namespace std;

const int N=200010;

long long a[N],b[N],c[N];

void solve(){

	int n,l,r;

	cin>>n>>l>>r;

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

		cin>>a[i];

	}

	for(int i=0;i<r;i++) b[i]=a[i];

	int k=0;

	for(int i=l-1;i<n;i++) c[k++]=a[i];

	sort(b,b+r);

	sort(c,c+k);

	int t=r-l+1;

	long long minv=0;

	long long cnt=1e17;

	for(int i=0;i<t;i++) minv+=b[i];

	cnt=min(cnt,minv);

	minv=0;

	for(int i=0;i<t;i++) minv+=c[i];

	cnt=min(cnt,minv);

	cout << cnt << endl;

}

int main(){

	int t;

	cin>>t;

	while(t--){

		solve();

	}

	return 0;

}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 8):
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;
const int N=200010;
long long a[N],b[N],c[N];
void solve(){
	int n,l,r;
	cin>>n>>l>>r;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<r;i++) b[i]=a[i];
	int k=0;
	for(int i=l-1;i<n;i++) c[k++]=a[i];
	sort(b,b+r);
	sort(c,c+k);
	int t=r-l+1;
	long long minv=0;
	long long cnt=1e9+900;
	for(int i=0;i<t;i++) minv+=b[i];
	cnt=min(cnt,minv);
	minv=0;
	for(int i=0;i<t;i++) minv+=c[i];
	cnt=min(cnt,minv);
	cout << cnt << endl;
}
int main(){
	int t;
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
} 

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

#include<algorithm>

#include<cstring>

#include<cmath>

#include<vector>

#include<queue>

using namespace std;

const int N=200010;

long long a[N],b[N],c[N];

void solve(){

	int n,l,r;

	cin>>n>>l>>r;

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

		cin>>a[i];

	}

	for(int i=0;i<r;i++) b[i]=a[i];

	int k=0;

	for(int i=l-1;i<n;i++) c[k++]=a[i];

	sort(b,b+r);

	sort(c,c+k);

	int t=r-l+1;

	long long minv=0;

	long long cnt=1e13;

	for(int i=0;i<t;i++) minv+=b[i];

	cnt=min(cnt,minv);

	minv=0;

	for(int i=0;i<t;i++) minv+=c[i];

	cnt=min(cnt,minv);

	cout << cnt << endl;

}

int main(){

	int t;

	cin>>t;

	while(t--){

		solve();

	}

	return 0;

}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

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

#define int long long
// #define mkp make_pair
#define txt freopen("kout.in", "r", stdin), freopen("kout.out", "w", stdout);
const int N = 200100, K = 20;

void solve() 
{   
    int l, r;
    cin >> l >> r;

    vector<int> vec;
    for(int i = 1; i <= r; i *= 2)
    {
        if(i >= l) 
            vec.push_back(i);
    }
    int a, b, c;
    if(vec.empty())
    {
        int x = 0;
        for(int k = 30; k >= 0; k--)
        {
            if(r < (1ll << k))
                continue;
            else if(l >= (1ll << k))
            {
                x |= (1ll << k);
                l -= (1ll << k);
                r -= (1ll << k);
                continue;
            }
            int bt = 1;
            while(bt * 2 <= r)
                bt *= 2;
            a = bt, b = a - 1, c = a - 2;
            if(c < l)
                c = a + 1;
            break;
        }
        a |= x;
        b |= x;
        c |= x;
    }
    else
    {
        if(l < vec.back())
        {
            a = vec.back(), b = a - 1, c = a - 2;
            if(c < l)
                c = a + 1;
        }
        else
            a = vec.back(), b = r, c = r - 1;
        
    }

    cout << a << ' ' << b << ' ' << c << '\n';


    

}   

signed main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int T = 1;
    for (cin >> T; T--; solve());
}
/*

*/


Submission (verdict: Accepted):
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define int long long
// #define mkp make_pair
#define txt freopen("kout.in", "r", stdin), freopen("kout.out", "w", stdout);
const int N = 200100, K = 20;

void solve() 
{   
    int l, r;
    cin >> l >> r;

    int x = 0;
    for(int i = 30; i >= 0; i--)
    {
        if(r < (1ll << i))
            continue;
        else if(l >= (1ll << i))
        {
            l -= (1ll << i);
            r -= (1ll << i);
            x |= (1ll << i);
            continue;
        }
        
        int a = (1ll << i), b = a - 1, c = a - 2;
        if(c < l)
            c = a + 1;
        cout << (a | x) << ' ' << (b | x) << ' ' << (c | x) << '\n';
        return;    
    }


    

}   

signed main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int T = 1;
    for (cin >> T; T--; solve());
}
/*

*/
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

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

#define int long long
// #define mkp make_pair
#define txt freopen("kout.in", "r", stdin), freopen("kout.out", "w", stdout);
const int N = 200100, K = 20;

void solve() 
{   
    int l, r;
    cin >> l >> r;

    vector<int> vec;
    for(int i = 1; i <= r; i *= 2)
    {
        if(i >= l) 
            vec.push_back(i);
    }
    int a, b, c;
    if(vec.empty())
    {
        int x = 0;
        for(int k = 30; k >= 0; k--)
        {
            if(r < (1ll << k))
                continue;
            else if(l >= (1ll << k))
            {
                x |= (1ll << k);
                l -= (1ll << k);
                r -= (1ll << k);
                continue;
            }
            int bt = 1;
            while(bt * 2 <= r)
                bt *= 2;
            a = bt, b = a - 1, c = a - 2;
            if(c < l)
                c = a + 1;
            break;
        }
        a |= x;
        b |= x;
        c |= x;
    }
    else
    {
        if(l < vec.back())
        {
            a = vec.back(), b = a - 1, c = a - 2;
            if(c < l)
                c = a + 1;
        }
        else
        {
            a = vec.back(), b = a + 1, c = r;
            if(c % 2 && c - 1 != b)
                c--;
        }
    }

    cout << a << ' ' << b << ' ' << c << '\n';


    

}   

signed main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int T = 1;
    for (cin >> T; T--; solve());
}
/*

*/


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

#define int long long
// #define mkp make_pair
#define txt freopen("kout.in", "r", stdin), freopen("kout.out", "w", stdout);
const int N = 200100, K = 20;

void solve() 
{   
    int l, r;
    cin >> l >> r;

    vector<int> vec;
    for(int i = 1; i <= r; i *= 2)
    {
        if(i >= l) 
            vec.push_back(i);
    }
    int a, b, c;
    if(vec.empty())
    {
        int x = 0;
        for(int k = 30; k >= 0; k--)
        {
            if(r < (1ll << k))
                continue;
            else if(l >= (1ll << k))
            {
                x |= (1ll << k);
                l -= (1ll << k);
                r -= (1ll << k);
                continue;
            }
            int bt = 1;
            while(bt * 2 <= r)
                bt *= 2;
            a = bt, b = a - 1, c = a - 2;
            if(c < l)
                c = a + 1;
            break;
        }
        a |= x;
        b |= x;
        c |= x;
    }
    else
    {
        if(l < vec.back())
        {
            a = vec.back(), b = a - 1, c = a - 2;
            if(c < l)
                c = a + 1;
        }
        else
            a = vec.back(), b = r, c = r - 1;
        
    }

    cout << a << ' ' << b << ' ' << c << '\n';


    

}   

signed main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int T = 1;
    for (cin >> T; T--; solve());
}
/*

*/
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


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

#define int long long
// #define mkp make_pair
#define txt freopen("kout.in", "r", stdin), freopen("kout.out", "w", stdout);
const int N = 200100, K = 20;

void solve() 
{   
    int l, r;
    cin >> l >> r;

    vector<int> vec;
    for(int i = 1; i <= r; i *= 2)
    {
        if(i >= l) 
            vec.push_back(i);
    }
    int a, b, c;
    if(vec.empty())
    {
        int x = 0;
        for(int k = 30; k >= 0; k--)
        {
            if(r < (1ll << k))
                continue;
            else if(l >= (1ll << k))
            {
                x |= (1ll << k);
                l -= (1ll << k);
                r -= (1ll << k);
                continue;
            }
            int bt = 1;
            while(bt * 2 <= r)
                bt *= 2;
            a = bt, b = a - 1, c = a - 2;
            if(c < l)
                c = a + 1;
            break;
        }
        a |= x;
        b |= x;
        c |= x;
    }
    else
    {
        if(l < vec.back())
        {
            a = vec.back(), b = a - 1, c = a - 2;
            if(c < l)
                c = a + 1;
        }
        else
        {
            a = vec.back(), b = a + 1, c = r;
            if(c % 2 && c - 1 != b)
                c--;
        }
    }

    cout << a << ' ' << b << ' ' << c << '\n';


    

}   

signed main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int T = 1;
    for (cin >> T; T--; solve());
}
/*

*/
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define up(i,x,y) for (int i=x;i<=y;i++)
#define down(i,x,y) for (int i=x;i>=y;i--)
#define ll long long
#define elif else if
using namespace std;

int dp[2010][1010];

void solve(){
	string a,b,c;
	cin>>a>>b>>c;
	int la=a.size(),lb=b.size();
	a="^"+a;
	b="^"+b;
	c="^"+c;
	up(i,0,la+lb) up(j,0,la) dp[i][j]=10000;
	dp[0][0]=0;
	up(i,1,la+lb){
		int mn=max(0,i-lb),mx=min(la,i);
		up(j,mn,mx){
			dp[i][j]=min(
				dp[i-1][j]+(b[i-j]!=c[i]),
				dp[i-1][j-1]+(a[j]!=c[i])
			);
		}
	}
	int res=10000;
	cout<<dp[la+lb][la]<<"\n";
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T;
	cin>>T;
	while(T--) solve();
} 

Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define up(i,x,y) for (int i=x;i<=y;i++)
#define down(i,x,y) for (int i=x;i>=y;i--)
#define ll long long
#define elif else if
using namespace std;

int dp[2010][1010];

void solve(){
	string a,b,c;
	cin>>a>>b>>c;
	int la=a.size(),lb=b.size();
	a="^"+a;
	b="^"+b;
	c="^"+c;
	up(i,0,la+lb) up(j,0,la) dp[i][j]=10000;
	dp[0][0]=0;
	up(i,1,la+lb){
		int mn=max(0,i-lb),mx=min(la,i);
		up(j,mn,mx){
			dp[i][j]=min(
				dp[i-1][j]+(b[i-j]!=c[i]),
				(j>0?dp[i-1][j-1]+(a[j]!=c[i]):10000)
			);
		}
	}
	int res=10000;
	cout<<dp[la+lb][la]<<"\n";
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T;
	cin>>T;
	while(T--) solve();
}