ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2060D - Subtract Min Sort
Language: c++17 

Solution 1 (runtime: 343 ms):
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include <set>
#include <string>
#include <map>
#include <deque>
#include <queue>
#include <iomanip>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

//#pragma GCC optimize ("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

typedef long long ll;

using namespace std;

const long long MOD = 1e9 + 7, BASE = 31;
const int size = 2 * 1e5 + 1;
const ll mod = 998244353;
const int MAXN = 100100;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0);

	int t;
	cin >> t;
	while (t--) {

		int n;
		cin >> n;
		vector<int>a(n);

		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		if (n % 2 != 0) {
			a.push_back(0);
		}
		if (n == 2) {
			if (a[1] > a[0]) {
				cout << "YES\n";
				continue;
			}
			else {
				cout << "NO\n";
				continue;
			}
		}
		bool f = false;
		for (int i = 1; i < n-2; i+=2) {
			if (max(a[i] - a[i - 1],0) < a[i + 1] - a[i + 2]) {
				f = true;
				break;
			}
		}

		if (f) {
			cout << "NO\n";
		}
		else {
			cout << "YES\n";
		}
	}

}

Solution 2 (runtime: 343 ms):
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,p,i,t;
    vector<int>v1;
    cin>>t;while(t--){
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>m;
        v1.push_back(m);
    }
    p=0;
    if(v1.size()<=2)
    {
        if(v1[0]<=v1[1]){p=0;}else{p=1;}
    }

    if(v1.size()>=3){

    for(i=0;i<=n-2;i++)
    {
      int d=min(v1[i],v1[i+1]);
      v1[i]=v1[i]-d;
      v1[i+1]=v1[i+1]-d;
    }

    for(int k=0;k<v1.size()-1;k++)
    {
      if(v1[k]>v1[k+1])
      {
          p=1;k=v1.size();
      }
    }

    }

    if(p>=1)
    {
        cout<<"NO";
    }
    else{cout<<"YES";}
    v1.clear();cout<<"\n";
}

    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: c++17 

Solution 1 (runtime: 546 ms):
// Away... beyond all concepts of wrong-doing and right-doing
// There is a field, I will meet you there.


#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
 
typedef long long ll;
#define pb push_back
#define endl '\n'
#define rev(v) reverse(v.begin(), v.end())
#define srt(v) sort(v.begin(), v.end())
#define minv(v) *min_element(v.begin(), v.end())
#define maxv(v) *max_element(v.begin(), v.end())
#define vll vector<ll>
#define pll = pair<ll, ll>;

const ll mod = 1000000007;
const ll MOD = 998244353;

void vin(vector<ll> &a, int n)
{
    for (int i = 0; i < n; i++)
    {
        ll x;
        cin >> x;
        a.push_back(x);
    }
}

ll modPow(ll base, ll exp, ll mod) {
    ll result = 1;
    base %= mod;
    while (exp > 0) {
        if (exp & 1) result = (result * base) % mod;
        base = (base * base) % mod;
        exp >>= 1;
    }
    return result;
}

ll modInverse(ll x, ll mod) {
    return modPow(x, mod - 2, mod);
}

void solve() {
    int n; cin>>n;
    vector<vector<int>>adj(n+1);
    for (int i = 0; i<n-1; i++){
        int x, y; cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    int ans = 0;
    for (int i = 1; i<=n; i++){
        for (int j: adj[i]){
            ans = max(ans, (int)(adj[i].size() + adj[j].size())-2);
        }
    }
    multiset<int>ms;
    for (int i = 1; i<=n; i++){
        ms.insert(adj[i].size());
    }
    for (int i = 1; i<=n; i++){
        ms.erase(ms.find(adj[i].size()));
        for (int j: adj[i]){
            ms.erase(ms.find(adj[j].size()));
        }
        if (!ms.empty()){
            ans = max(ans, (int)(adj[i].size()) + *ms.rbegin() - 1);
        }
        ms.insert(adj[i].size());
        for (int j: adj[i]) ms.insert(adj[j].size());
    }
    cout<<ans<<endl;

}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll t=1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Solution 2 (runtime: 624 ms):
#include<bits/stdc++.h>
using namespace std;

#define ll long long int

void solve(){
    ll n;cin>>n;
    vector<ll> g[n+1];

    for(ll i=0;i<n-1;i++) {
        ll x,y;
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    multiset<ll> st;
    for(ll i=1;i<=n;i++) st.insert(g[i].size());
    ll ans=0;
    for(ll i=1;i<=n;i++){
        for(auto ng:g[i]){
            ans = max(ans,(ll)g[i].size()+(ll)g[ng].size()-2);
        }
    }
    for(ll i=1;i<=n;i++){
        st.erase(st.find(g[i].size()));
        for(auto ng:g[i]){
            st.erase(st.find(g[ng].size()));
        }
        if(!st.empty())ans = max(ans,g[i].size() + *st.rbegin()-1);
        st.insert(g[i].size());
        for(auto ng:g[i]){
            st.insert(g[ng].size());
        }
    }

    cout<<ans<<endl;
   
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    
    int t;
    cin>>t;
    while(t--){
        solve();    
    }
    
}
Problem: 2060D - Subtract Min Sort
Language: c++17 

Solution 1 (runtime: 343 ms):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin >> n;
        vector<int> a;
        int flag=0;
        for(int i=0;i<n;++i){
            int x;
            cin >> x;
            a.push_back(x);
        }
        if(a[0]>a[1]) {
            cout<<"NO"<<endl;
            flag=1;
        }
        else{
            for(int i=0;i<n-1;++i){
                int x = min(a[i],a[i+1]);
                a[i]-=x;
                a[i+1]-=x;  
                if(a[i]>a[i+1]){
                    cout<<"NO"<<endl;
                    flag=1;
                    break;
                }
            }
        }
        if(flag==0)cout<<"YES"<<endl;
    }
}

Solution 2 (runtime: 328 ms):
#include<bits/stdc++.h>

#include <iostream>

#define ll long long

using namespace std;

void solve(){

    ll n;

    cin >> n;

    vector<ll> ans(n);

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

        cin >> ans[i];

    }

    for(ll i=0;i<n-1;i++){

        ll res=min(ans[i],ans[i+1]);

        ans[i]=ans[i]-res;

        ans[i+1]=ans[i+1]-res;

    }

    if(is_sorted(ans.begin(),ans.end())){

        cout << "YES" <<endl;

    }else{

         cout << "NO" <<endl;

    }

 

}

int main()

{

    ll t;

    cin >> t;

    while(t--){

        solve();

    }

 

    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: c++17 

Solution 1 (runtime: 359 ms):
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+4;
#define int long long
int a[N];
int vis[N];
void solv(){
	int flag = 0;
	int n;cin >> n;
	for(int i = 1;i <= n ;i++)	cin >> a[i];
	for(int i = 1;i < n ;i++){
		if(a[i] == a[i+1]){
			i++;
		}
		else if(a[i] > a[i+1]){
			flag = 1;
			break;
		}
		else{
			a[i+1] -= a[i];
		}
	}
	if(flag) cout << "NO"<<endl;
	else cout << "YES"<<endl;
}
signed main(){
	int t;cin >> t;
	while(t--){
		solv();
	}
	return 0;
}




Solution 2 (runtime: 109 ms):
#include <bits/stdc++.h>
using namespace std;

#define ar array
#define ll long long
#define ld long double
#define sza(x) ((int)x.size())
#define all(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)

const int MAX_N = 1e5 + 5;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ld EPS = 1e-9;

void solve()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    forn(i, n) cin >> a[i];

    for (int i = 1; i < n; i++)
    {
        if (a[i - 1] <= a[i])
        {
            a[i] -= min(a[i - 1], a[i]);
        }
        else
        {
            cout << "NO\n";
            return;
        }
    }

    cout << "YES\n";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc = 1;
    cin >> tc;
    for (int t = 1; t <= tc; t++)
    {
        // cout << "Case #" << t << ": ";
        solve();
    }
}
Problem: 2063B - Subsequence Update
Language: c++17 

Solution 1 (runtime: 77 ms):
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double


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

	vector<int> v(n);
	for(int i = 0; i < n; i++){
		cin >> v[i];
	}

	vector<int> prev, next;
	int sum = 0;
	for(int i = 0; i < l - 1; i++){
		prev.push_back(v[i]);
	}
	sort(prev.begin(), prev.end());
	vector<int> sub;
	for(int i = l - 1; i < r; i++){
		sum += v[i];
		sub.push_back(v[i]);
	}
	sort(sub.begin(), sub.end());

	for(int i = r; i < n; i++){
		next.push_back(v[i]);
	}

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

	int temp1 = sum, temp2 = sum, j = sub.size() - 1, sz = sub.size();

	for(int i = 0; i < prev.size(); i++){
		if(prev[i] < sub[j] && sz > 0){
			temp1 -= sub[j];
			temp1 += prev[i];
			j--;
			sz--;
		}
		else break;
		if(sz <= 0)break;
	}

	j = sub.size() - 1, sz = sub.size();
	for(int i = 0; i < next.size(); i++){
		if(next[i] < sub[j]){
			temp2 -= sub[j];
			temp2 += next[i];
			j--;
			sz--;
		}
		else break;
		if(sz <= 0)break;
	}

	cout << min(temp1, temp2) << endl;

	
}

signed main() {

#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif

	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int t;
	cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Solution 2 (runtime: 78 ms):
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef long double doo;



typedef vector<pair<ll,ll>> vp;

typedef pair<ll,ll> pl;

typedef vector<ll> vl;

typedef set<ll> sl;

typedef map<ll, ll> ml;

typedef map<string, ll> ms;



#define gett(s) string s; cin>>s;

#define ll_max INT64_MAX

#define ll_min INT64_MIN



#define mp make_pair

#define pb push_back

#define f first

#define se second



#define yes cout<<"YES"<<endl;

#define no cout<<"NO"<<endl;

#define cn continue;

#define nl cout << "\n";



signed main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    

    ll t;

    cin >> t;

    

    while(t--){

        ll n, l, r;

        cin >> n >> l >> r;

        vector<ll> a(n), b(n);

        

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

            cin >> a[i];

            b[i] = a[i];

        }



        sort(a.begin(), a.begin() + r);

        sort(b.begin() + (l - 1), b.end());

        

        ll sum1 = 0, sum2 = 0;

        ll length = r - l + 1;

        for(ll j = 0; j < length; j++){

            sum1 += a[j];

        }

        for(ll k = l-1; k < r; k++){

            sum2 += b[k];

        }

        

        cout << min(sum1, sum2);

        nl;

    }

    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: c++17 

Solution 1 (runtime: 140 ms):
//signed by xy

#include <bits/stdc++.h>

using namespace std;

#define ios ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define int long long

#define double long double

#define ull unsigned long long

#define endl '\n'

#define x first

#define y second

#define rep(i,a,b) for(int i = a;i<=b;i++)

#define PII pair<int,int>

#define TUP tuple<int,int,int>

#define  M_PI 3.14159265358979323846

#define cmin(a,b) a = min(a,b)

#define cmax(a,b) a = max(a,b)

#define begin(a) a.begin()

#define end(a) a.end()



template <typename Tp>

void read(Tp &x){

char c=getchar();x=0;int f=1;

while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}

while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}x*=f;

}



const int inf = LONG_LONG_MAX;

const int N = 1e6+10,mod = 1e9+7,P = 19270821;





int n,m;



void solve()

{

cin >> n ;

vector<int>a(n+1);

rep(i,1,n) cin >> a[i];

rep(i,1,n)

{

if(a[i] < a[i-1])

{

cout << "NO" << endl;

return;

}

a[i] -= a[i-1];

}

cout << "YES" << endl;

}



signed main() {

ios;

int t = 1;

cin >> t;

while(t--)

solve();

return 0;

}



Solution 2 (runtime: 374 ms):
#include<bits/stdc++.h>

#define ll long long

using namespace std;



void solve(){

int n;

cin>>n;



vector<int>temp(n);

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



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

temp[i+1] -= temp[i];

if(temp[i+1]<0){

cout<<"NO"<<endl;

return;

}

}



cout<<"YES"<<endl;

return;

}



int main(){

int t;

cin >> t;



while(t--)

solve();



return 0;

}
Problem: 2060D - Subtract Min Sort
Language: c++17 

Solution 1 (runtime: 108 ms):
#include <bits/stdc++.h>
using namespace std;
template <typename _Tp> bool minimize(_Tp &__a, const _Tp &__b) { if (__a > __b) { __a = __b; return true; } return false; }
template <typename _Tp> bool maximize(_Tp &__a, const _Tp &__b) { if (__a < __b) { __a = __b; return true; } return false; }
#define int long long
#define pb push_back
#define fi first
#define vi vector<int>
#define se second
#define pii pair<int,int>
#define mp make_pair
#define all(a) a.begin(), a.end()
#define allof(a,n) a + 1, a + 1 + n
#define fo(i,a,b) for(int i = a; i <= b; i++)
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define file "ship"
#define I ios_base :: sync_with_stdio(0);
#define wish cin.tie(0);
#define have cout.tie(0);
#define tomorrow if(fopen(file".inp","r")) {freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);}
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
const int single_test = 1;
const int base = 31;
namespace memaybeobachlong
{
    void solve()
    {
        int n;
        cin >> n;
        int a[n + 1];
        a[0] = 0;
        fo(i, 1, n) cin >> a[i];
        int id = 0;
        for(int i = n - 1; i >= 1; i--)
            if(a[i] > a[i + 1])
            {
                id = i;
                break;
            }
        if(!id) return cout << "YES\n", void();
        fo(i, 2, id - 1)
        {
            if(a[i - 1] > a[i])
                return cout << "NO\n", void();
            a[i] -= a[i - 1];
        }
        if(a[id - 1] <= a[id] && a[id] - a[id - 1] <= a[id + 1])
            cout << "YES\n";
        else cout << "NO\n";
    }
}
int32_t main()
{
    I wish have tomorrow
    int t = 1;
    if(single_test)
        cin >> t;
    while(t--)
        memaybeobachlong :: solve();
}


Solution 2 (runtime: 374 ms):
#include<bits/stdc++.h>
using namespace std;
int n,a[200005];
bool b[200005];
int main(){
	int t;cin>>t;
	while(t--){
		cin>>n;
		for(int i=1;i<=n;i++)cin>>a[i];
		if(a[1]>a[2]){cout<<"NO\n";continue;}
		for(int i=1;i<=n;i++)b[i]=0;b[n]=1;
		for(int i=n-1;i>=1;i--){
			if(a[i]<=a[i+1])b[i]=1;else break;}
		bool ok=0;
		if(b[1])ok=1;
		for(int i=2;i<n;i++){
			int now=min(a[i],a[i-1]);
			a[i]-=now;a[i-1]-=now;
			if(a[i]<=a[i+1]&&b[i+1]){ok=1;break;}
			if(a[i]>a[i+1])break;}
		if(ok)cout<<"YES"<<endl;
		else cout<<"No"<<endl;
	
	
	}
	return 0;
}
Problem: 2050E - Three Strings
Language: c++17 

Solution 1 (runtime: 61 ms):
#include <iostream>
#include <vector>
#include <string>

#define ll long long

using namespace std;

// dp[i][2][n] = dp[i][j - 1][n + 1]
// dp[i][
void solve() {
    string a, b, c;
    cin >> a >> b >> c;

    int m = a.size();
    int n = b.size();
    vector<vector<int>> dp(m + 1, vector<int>(n + 1, 1e9));
    dp[0][0] = 0;

    for (int i = 1; i <= m; i++) {
        dp[i][0] = dp[i - 1][0] + (a[i - 1] != c[i - 1]);
    }

    for (int i = 1; i <= n; i++) {
        dp[0][i] = dp[0][i - 1] + (b[i - 1] != c[i - 1]);
    }

    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            dp[i][j] = min(dp[i - 1][j] + (a[i - 1] != c[i + j - 1]),
                dp[i][j - 1] + (b[j - 1] != c[i + j - 1]));
        }
    }

    cout << dp[m][n] << endl;
}

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


Solution 2 (runtime: 62 ms):
#include <bits/stdc++.h>

#define ll long long
#define mod 1000000007
#define INF 1e9

using namespace std;

void input1(vector<ll>& num, ll n){
	for(int i = 0 ; i < n ; ++i) cin >> num[i];
}

void input2(vector<vector<ll> >& num, int n, int m) {
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> num[i][j];
        }
    }
}

void solve() {
	string a,b,c;
	cin >> a >> b >> c;
	int n = a.size();
	int m = b.size();
	vector<vector<int>> dp(n+1,vector<int> (m+1));
	dp[0][0] = 0;
	for(int i=1;i<=n;++i){
		if(a[i-1]==c[i-1]){
			dp[i][0] = 0;
		}else{
			dp[i][0] = 1;
		}
		dp[i][0]+=dp[i-1][0];
	}
	for(int i=1;i<=m;++i){
		if(b[i-1]==c[i-1]){
			dp[0][i] = 0;
		}else{
			dp[0][i] = 1;
		}
		dp[0][i]+=dp[0][i-1];
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			int con1 = dp[i-1][j] + (a[i-1]!=c[i+j-1]);
			int con2 = dp[i][j-1] + (b[j-1]!=c[i+j-1]);
			dp[i][j] = min(con1,con2);
		}
	}
	cout << dp[n][m] << endl;
}

int main() {
	ios::sync_with_stdio(false);
	int tt; cin >> tt; for (int i = 0; i < tt; i++) {solve();}
	//solve();
}
Problem: 2060D - Subtract Min Sort
Language: c++17 

Solution 1 (runtime: 108 ms):

#include <bits/stdc++.h>
using namespace std;
#define forn(i,a,n) for(long long i = a; i < n; i++)
#define endl "\n"
#define int long long
const int MAXN = 200100;
const int MOD = 1000000007;

void solve() 
{
   int i=0,n,z=-1,v,p,f=-1;
   cin>>n;
   vector<int> arr(n);
   while (i<n)
   {
     cin>>arr[i];
     i++;
   }
   i=0;
   while (i<n-1)
   {
    if (arr[i]>arr[i+1])
    {
      v=arr[i],p=i-1,f=-1;
      while (p>z)
      {
        v=v+f*arr[p];
        f=-f;
        p--;
      }
      arr[i]=v;
      z=i-1;
    }
    if (arr[i]>arr[i+1])
    {
      cout<<"NO"<<endl;
      return;
    }
    i++;
   }
   cout<<"YES"<<endl;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int T = 1;
    cin >> T;//Comment this out in case number of test cases are not to be taken as input.
    for(int I = 1; I <= T; I++) {
        solve();
    }
    return 0;
}

Solution 2 (runtime: 93 ms):
#include <iostream>

#include <algorithm>

#include <cstring>



using namespace std;

const int N = 2e5 + 10;

int n, a[N];



bool satisfied(int u){

if(u >= n)return true;

if(a[u] == a[u + 1]){

return satisfied(u + 2);

}

else if(a[u] <= a[u + 1]){

a[u + 1] -= a[u];

return satisfied(u + 1);

}

else{

return false;

}

}



void solve(){

scanf("%d", &n);

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

scanf("%d", &a[i]);

}

if(satisfied(1))puts("yes");

else puts("no");

}



int main()

{

int T;

scanf("%d", &T);

while(T -- ){

solve();

}

return 0;

}
Problem: 2062C - Cirno and Operations
Language: c++17 

Solution 1 (runtime: 62 ms):
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  ll t;
  cin>>t;
  while(t--){
      ll n;
      cin>>n;
      vector<ll> a(n);
      for(ll i=0;i<n; i++){
          cin>>a[i];
      }
      ll ans = -1e18;
      ll last = n;
      for(int i=0; i<n; i++){
          ll sum = 0;
          for(ll k=0; k<last; k++){
              sum+=a[k];
          }
          if(i==0) ans = max(ans, sum);
          else ans = max(ans, max(sum, (-sum)));
          for(ll j=0; j<last-1; j++){
              a[j]=a[j+1]-a[j];
          }
          last--;

      }
      cout<<ans<<endl;
  }

}


Solution 2 (runtime: 61 ms):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=70;
int n;ll a[N];
int main(){
	int t;scanf("%d",&t);
	while(t--){
		scanf("%d",&n);
		ll res=0;
		for(int i=1;i <= n;i++) scanf("%lld",&a[i]),res += a[i];
		for(int i=1;i<n;i++){
			ll ans=0;
			for(int j=1;j+i <= n;j++) a[j] -= a[j+1],ans += a[j];
			res=max(res,abs(ans));
		}
		printf("%lld\n",res);
	}
	return 0;
}
/*
sasakure.UK is the only god.
*/
Problem: 2057C - Trip to the Olympiad
Language: c++17 

Solution 1 (runtime: 93 ms):
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
#define int long long
typedef pair<int, int> PII;
typedef long long LL;
const int N = 5e5+10;
const int mod = 998244353;


void solve() {   
    int l, r;
    cin >> l>> r;
    int ll = l;
    int L[35], R[35];
    memset(L, 0, sizeof L);
    memset(R, 0, sizeof R);
    int w = 0;
    while(l){
        if(l&1)L[w] = 1;
        else L[w] = 0;
        w++;
        l/=2; 
    }
    w = 0;
    while(r){
        if(r&1)R[w] = 1;
        else R[w] = 0;
        w++;
        r/=2;
    }
    int idx = 0;
    for(int i = 30; i >= 0; i --){
        if(L[i] != R[i]){
            idx = i;
            break;
        }
    }
    int t = 0;
    for(int i = idx; i < 30; i ++){
        if(R[i] == 1)t += pow(2, i); 
    }
    int a = t, b = t - 1;
    if(b > ll)cout << b-1 << " "<< a <<" " <<b <<endl;
    else cout << a + 1 << " " << a <<" " <<b <<endl;

} 

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while(t--){
        solve();
    }
    
    return 0;
}

Solution 2 (runtime: 93 ms):
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t--) {
        ll l, r;
        cin>>l>>r;
        ll ans = 0;
        for(int i = 30; i >= 0; i--) {
            ll b1 = l & (1ll << i);
            ll b2 = r & (1ll << i);
            if(b1 == b2) {
                ans += b1;
            } else {
                ans += 1ll << i;
                break;
            }
        }
        ll ans2 = ans-1;
        ll ans3;
        for(int i = l; i <= r; i++) {
            if(i != ans && i != ans2) {
                ans3 = i;
                break;
            }
        }
        cout<<ans<<" "<<ans2<<" "<<ans3<<endl;
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: c++17 

Solution 1 (runtime: 61 ms):
#include<bits/stdc++.h>
using namespace std;

#define add emplace_back
#define FOR(i, a, b) for(int i = a;i < (b); ++i)
#define FORD(i , a, b) for(int i = a;i >= (b);i--)
#define all(v) v.begin(), v.end()
#define len(x) (x).size();

using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
using vll = vector<ll>;

const int mod = 1e9+7;

void Main(){
	string s;
	cin >> s;
	int sum = 0, two = 0, three = 0;
	
	for(int i = 0;i < s.size(); i++){
		sum = (sum + (s[i]-48)) % 9;
		two += (s[i]=='2');
		three += (s[i]=='3');
	}
	if(sum==0) return void( cout << "YES" << "\n");
	bool ok = 0;
	for(int i = 0;i <= min(two, 100); i++){
		for(int j = 0;j <= min(three, 100); j++){
			if((sum+2*i+6*j)%9 == 0) ok = 1;
		}
	}
	cout << (ok?"YES":"NO") << "\n";
}

int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.tie(NULL);

	int t;
	for(cin>>t; t; t--) Main();

	return 0;
}



Solution 2 (runtime: 46 ms):
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
void solve()
{
    std::string s;
    int cnt_2 = 0, cnt_6 = 0, sum = 0;
    std::cin >> s;
    cnt_2 = std::count(s.begin(), s.end(), '2');
    cnt_6 = std::count(s.begin(), s.end(), '3');
    for (int i = 0; i < s.size(); i++)
        sum += s[i] - '0';
    if (sum % 9 == 0)
    {
        std::cout << "YES" << endl;
        return;
    }
    int mod = sum % 9, flag = 1;
    if (cnt_2 > 9)
        cnt_2 = 9;
    if (cnt_6 > 9)
        cnt_6 = 9;
    for (int i = 0; i <= cnt_2; i++)
    {
        for (int j = 0; j <= cnt_6; j++)
        {
            int temp = mod + 2 * i + 6 * j;
            if (temp % 9 == 0)
            {
                std::cout << "YES" << endl;
                return;
            }
        }
    }
    std::cout << "NO" << endl;
}
signed main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    int T = 1;
    std::cin >> T;
    while (T--)
        solve();
    return 0;
}