ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: c++17 

Solution 1 (runtime: 46 ms):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T>
using orderedSet = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order, order_of_key
// order_of_key(k) - number of element strictly less than k
// find_by_order(k) - k'th element in set.(0 indexed)(iterator)
#define optimize()              \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define endl '\n'
#define int long long int
#define ll long long unsigned
#define float long double
#define mod (1000000007)
int ceil2(int a, int b)
{
  return (a + b - 1) / b;
}
bool cmp(pair<int, int> &x, pair<int, int> &y)
{
  return x.second > y.second;
}

int32_t main()
{
  optimize();
  int t;
  cin >> t;
  //t = 1;
  while (t--)
  {
    int n;
    cin>>n;
    vector<int>v(n);
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>v[i];
        sum+=v[i];
    }
    while(v.size()>1){
        for(int i=1;i<v.size();i++){
            v[i-1]=v[i]-v[i-1];
        }
        v.pop_back();
        int cur_sum_pos=accumulate(v.begin(),v.end(),0LL);
        int cur_sum_neg=-1LL*cur_sum_pos;
        sum=max(sum,max(cur_sum_pos,cur_sum_neg));
        if(cur_sum_neg>cur_sum_pos){
            for(auto &it:v)it*=-1LL;
        }
    }
    cout<<sum<<endl;

  }
}


Solution 2 (runtime: 46 ms):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll counter(vector<int> v,map<vector<int>,ll> mp={},ll howme=0 ) {
    if(v.size()==1)return v[0];
    if(v.size()==2)return max(v[0]+v[1],abs(v[1]-v[0]));
    if(mp[v]!=0) {
        ll sum=0;
        for(int i=0;i<v.size();i++) {
            sum+=v[i];

        }
        return sum;
    }
    mp[v]++;
    vector<int> v1,v2;
    for(int i=0;i<v.size();i++) {
        if(i<v.size()-1) {
            v1.push_back(v[i+1]-v[i]);
        }
        v2.push_back(v[v.size()-i-1]);
    }
    return max(counter(v1,mp,howme),counter(v2,mp,howme));
}
int main() {
    int t;
    cin>>t;
    while(t--) {
        int n;
        cin>>n;
        vector<ll> v;
        ll sum=0;
        for(int i=0;i<n;i++) {
            int a;
            cin>>a;
            sum+=a;
            v.push_back(a);
        }
        //ll count=counter(v);
        //cout<<count<<endl;

        for(int i=n;i>1;i--) {
            vector<ll> v1;
            ll sum2=0;
            for(int i=0;i<v.size();i++) {
                if(i<v.size()-1) {
                    v1.push_back(v[i+1]-v[i]);
                    sum2+=v[i+1]-v[i];
                }

            }
            sum=max(sum,abs(sum2));
            v=v1;
        }
        cout<<sum<<endl;

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

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

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long
#define vi vector<int>

void solve() {
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    if(v[0] > v[1]){
        cout<<"NO"<<endl;
        return;
    }
    for(int i=0;i<n-1;i++){
        if(v[i] <= v[i+1]){
            v[i+1]-=v[i];
            v[i]=0;
        }
        else{
            cout<<"NO"<<endl;
            return;
        }
    }
    cout<<"YES"<<endl;
}

int32_t main() {
    fastio;
    int tc;
    cin >> tc;
    while (tc--) {
        solve();
    }
    return 0;
}

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

using namespace std;



void solve()

{

    int n; cin >> n;

    vector<int> a(n);

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

    for(int i = n-2; i >= 1; i--) {

        if(a[i] > a[i+1]) {

            int jar = a[i] - a[i+1];

            a[i] -= jar;

            if(a[i-1] - jar < 0) {

                cout << "no\n"; return;

            } 

            a[i-1] -= jar;

        }

    }

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

        if(a[i] > a[i+1]) {

            cout << "no\n"; return;

        }

    }

    cout << "yes\n";

}



int main()

{

    ios::sync_with_stdio(false); cin.tie(0);

    int t; cin >> t;

    while(t--) solve();

    return 0;

}
Problem: 2057C - Trip to the Olympiad
Language: c++17 

Solution 1 (runtime: 62 ms):
#include <bits/stdc++.h>
#define st first
#define nd second
typedef long long ll;
using namespace std;

void solve() {
    int l, r; cin >> l >> r;
    int x = 0;
    int i;
    for (i = (1<<30); i > 0; i>>=1) {
        // cout << i << ' ' << (r^l) << '\n';
        if (i > (r^l)) x += l&i;
        else break;
    }
    // cout << x << ' ' << i << '\n';
    int a = x+i, b = x+i-1, c;
    assert(a >= l && a <= r);
    assert(b >= l && b <= r);
    if (a+1<=r) c = a+1;
    else c = b-1;
    cout << a << ' ' << b << ' ' << c << '\n';
    // cout << (a^b) + (b^c) + (c^a) << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1; 
    cin >> t;
    while (t--) {
        solve();
    }
    // int a, b, c;
    // cin >> a >> b >> c;
    // cout << (a^b) + (b^c) + (c^a) << '\n';
    
    
}

Solution 2 (runtime: 62 ms):
#include <cstdio>
#include <algorithm>


void solve() {
	int l, r; scanf("%d%d", &l, &r);
	int eq=1; int ans1=0, ans2=0;
	for(int i = 29;i >= 0;i--) {
		if(eq&&(l&(1<<i))!=(r&(1<<i))) {
			eq=0; ans1^=(1<<i);
		} else if(eq) {
			ans1^=(l&(1<<i)); ans2^=(l&(1<<i));
		} else {
			ans2^=(1<<i);
		}
	}
	if(ans2==l) {
		printf("%d %d %d\n", ans1+1, ans1, ans2);
	} else {
		printf("%d %d %d\n", ans1, ans2, ans2-1);
	}
	
}


int main() {
//	freopen("in.txt", "r", stdin);
	int T; scanf("%d", &T);
	while(T--) {
		solve();
	}
	return 0;
}
Problem: 2050B - Transfusion
Language: c++17 

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

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

    int n;
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        int seq_len; cin >> seq_len;
        long long odd_sum = 0;
        long long even_sum = 0;
        int odd_seq_len = (seq_len / 2) + (seq_len % 2);
        int even_seq_len = (seq_len / 2);
        for (int j = 0; j < seq_len; j++) {
            int val;
            cin >> val;
            if (j % 2 == 0) {
                odd_sum += val;
            }
            else even_sum += val;
        }
        long long desired = (odd_sum + even_sum) / seq_len;
        if (odd_sum / odd_seq_len == desired && even_sum / even_seq_len == desired && odd_sum % odd_seq_len == 0 && even_sum % even_seq_len == 0) {
            cout << "YES\n";
        }
        else cout << "NO\n";
    }
}



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

#define ll long long
#define ld long double
#define endl '\n'
#define CLS system("cls");
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define uni(a) a.erase(unique(all(a)), a.end())
#define input(a)    \
  for (auto &i : a) \
    cin >> i;
#define output(a)   \
  for (auto &i : a) \
    cout << i << ' ';

bool CheakBit(int n, int id)
{
  return (n >> id & 1);
}

ll SetBit(ll n, int id)
{
  return (n | (1LL << id));
}

ll ClearBit(ll n, int id)
{
  return (n & (~(1LL << id)));
}

int FilbBit(int n, int id)
{
  return (n ^ (1 << id));
}

ll convertToDec(string n, int b)
{
  ll j = 0, num = 0;
  for (int i = n.size() - 1; i >= 0; i--)
  {
    num += (n[i] - '0') * pow(b, j);
    j++;
  }
  return num;
}

string ConvertToBase(ll n, int b)
{
  string ans = "";
  while (n > 0)
  {
    ans += (n % b) + '0';
    n /= b;
  }
  while (ans.size() < 4)
  {
    ans.push_back('0');
  }
  reverse(all(ans));

  return ans;
}
void fast()
{
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
const ll N = 1e4 + 5, mod = 1e9 + 7;

void solve()
{
  int n;
  cin >> n;
  vector<ll> v(n);
  input(v);
  ll sODD = 0, cODD = 0, sEVEN = 0, cEVEN = 0;
  for (int i = 0; i < n; i++)
  {
    if (i & 1)
      cODD++, sODD += v[i];
    else
      cEVEN++, sEVEN += v[i];
  }

  if (((sODD / cODD) == (sEVEN / cEVEN)) && (sEVEN % cEVEN == 0) && (sODD % cODD == 0))
    YES else NO
}

int main()
{
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  fast();

  int t = 1;
   cin >> t;
  while (t--)
  {
    solve();
    // cout << '\n';
  }
  return 0;
}
Problem: 2050D - Digital string maximization
Language: c++17 

Solution 1 (runtime: 62 ms):
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define vl vector<ll> 
#define pb push_back
#define loop(n,i) for(ll i = 0; i < n; i++)
#define fa(i,v) for(auto &i:v)
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define print(x) cout << x << "\n";
#define cl(v) v.clear()
#define all(v) v.begin(),v.end()
#define inf (ll)1e18
#define mod (ll)(1e9+7)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

template <typename T> T input(int n = 1){T tmp;cin >> tmp;return tmp;  }

string op(string s, ll n){
    
    return s;
}

int main() {
	fastio
	int T = input<int>();
	loop(T,_){
        string s = input<string>();
        int p = 0;
        fa(x,s){
            int i = 1;
            ll best = s[p],pn = 0;
            while(i < 10 and p+i < s.length()){
                if(s[p+i]-i > best) {
                    best = s[p+i]-i;
                    pn = i;
                }
                i++;
            }
            //if(T == 1) cout << s.length() << " " << pn << "\n";
            loop(pn,j){
                int N=p+(pn-j);
                char tmp1;
                tmp1 = s[N];
                s[N] = s[N-1];
                s[N-1] = (char)(tmp1-1);
            }
            p++;
        }
        cout << s << "\n";
	}
	return 0;
}

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



using namespace std;



void solve() {

string s; cin >> s;

for (int i = 0; i < s.size(); i++) {

int best = s[i] - '0', pos = i;

for (int j = i; j < min(i + 10, (int) s.size()); j++) {

if (s[j] - '0' - (j - i) > best) {

best = s[j] - '0' - (j - i);

pos = j;

}

}

while (pos > i) {

swap(s[pos], s[pos - 1]);

pos--;

}

s[i] = char(best + '0');

}

cout << s;

}



int main() {

int TESTS = 1; cin >> TESTS;

while (TESTS --> 0) {

solve();

cout << '\n';

}

return 0;

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

Solution 1 (runtime: 359 ms):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<int> v(n);
        for(int i=0;i<n;i++){
            cin>>v[i];
        }
        bool b = true;
        for(int i=1;i<n-1;i++){
            if(v[i]-v[i-1]>=0 && v[i]-v[i-1]<=v[i+1]){
                v[i] = v[i]-v[i-1];
                v[i-1] = 0;
            }
            else{
                b = false;
                break;
            }
        }
        if(n==2){
            if(v[1]<v[0]){
                b = false;
            }
        }
        if(b){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }
    }
}

Solution 2 (runtime: 108 ms):
#include <bits/stdc++.h>
using namespace std;
void solve(){
    int n;
    cin>>n;
    vector<int>vec(n);
    for(auto &i:vec){
        cin>>i;
    }
    for(int i=0;i<n-1;++i){
        int k=min(vec[i],vec[i+1]);
        
            vec[i]-=k;
            vec[i+1]-=k;
       
    }
    for(int i=0;i<n-1;++i){
        if(vec[i+1]<vec[i]){
            cout<<"NO"<<'\n';
            return ;
        }
    }
    cout<<"YES"<<"\n";
    return ;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: c++17 

Solution 1 (runtime: 124 ms):
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
int read()
{
    int x = 0, f = 1;
    char ch = getchar();
    while (!isdigit(ch))
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (isdigit(ch))
    {
        x = (x << 1) + (x << 3) + ch - '0';
        ch = getchar();
    }
    return x * f;
}

void solve()
{
    int n,k;cin>>n>>k;
    map<int,int>mp;
    for (int i=0,t;i<n;i++)
    {
        cin>>t;
        mp[t]++;
    }
    vector<int>a;
    for (auto [x,y]:mp)
    {
        a.push_back(y);
    }
    sort(a.begin(),a.end());
    int ans=a.size();
  
    for (int i=0;i<a.size();i++)
    {
       
        if (k>=a[i])
        {
            ans--;
            k-=a[i];
        }
        else 
        {
            break;
        }
    }
    cout<<(ans==0?1:ans)<<"\n";
}
int main()
{
    std::cin.tie(nullptr)->sync_with_stdio(false);
    int t = 1;
     cin>>t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Solution 2 (runtime: 265 ms):
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        map<int,int>mp;
        set<int>st;
        int a[n];
        for(int i=0; i<n; i++)
        {
            cin>>a[i];
            st.insert(a[i]);
            mp[a[i]]++;
        }
        vector<pair<int,int>>v(mp.begin(),mp.end());
        sort(v.begin(), v.end(), [](const pair<int, int> &a, const pair<int, int> &b)
        {
            return a.second < b.second;
        });
        int ans=st.size();
        for(auto & it:v)
        {
            if(it.second<=k)
            {
                ans--;
                k-=it.second;
            }
        }
        cout<<max(1,ans)<<endl;

    }
}
Problem: 2050C - Uninteresting Number
Language: c++17 

Solution 1 (runtime: 77 ms):
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
void solve()
{
	string s;
	getline(cin, s);
	ll ssum = 0;
	int the_2 = 0, the_3 = 0;
	for (char& ch : s)
	{
		ssum += ch - '0';
		if (ch - '0' == 2)
		{
			the_2++;
		}
		else if (ch - '0' == 3)
		{
			the_3++;
		}
	}
	ll sheng = ssum % 9;
	for (int i = 0; i <= the_2; i++)
	{
		for (int j = 0; j <= the_3; j++)
		{
			if ((sheng + i * 2 + j * 6) % 9 == 0)
			{
				cout << "YES" << endl;
				return;
			}
		}
	}
	cout << "NO" << endl;
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll t;
	cin >> t;
	//getchar();
    string s;
    getline(cin,s);
	while (t--)
	{
		solve();
	}
	return 0;
}

Solution 2 (runtime: 62 ms):
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

void solve() {
    string input;
    cin >> input;

    vector<int> s;
    int sm = 0, twos = 0, threes = 0;
    for (char c : input) {
        int digit = c - '0';
        s.push_back(digit);
        sm += digit;
        if (digit == 2) twos++;
        if (digit == 3) threes++;
    }

    for (int i = 0; i < min(10, twos + 1); i++) {
        for (int j = 0; j < min(10, threes + 1); j++) {
            if ((sm + i * 2 + j * 6) % 9 == 0) {
                cout << "YES" << endl;
                return;
            }
        }
    }
    cout << "NO" << endl;
}

int main() {
    int t;
    cin >> t;

    while (t--) {
        solve();
    }

    return 0;
}
Problem: 2049C - MEX Cycle
Language: c++17 

Solution 1 (runtime: 77 ms):
// #include </Users/LucasZ/Library/CloudStorage/GoogleDrive-lucas.zichen.zhang@gmail.com/My Drive/desktop/coding/vscode/bits/stdc++.h>

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;



int main() {

    int t; cin >> t;

    while (t--) {

        int n, x, y; cin >> n >> x >> y;

        x--;

        y--;

        vector<int> ans(n);

        for (int i = 0; i < n; i++) ans[(x + i) % n] = i % 2;

        if (n % 2 || (x - y) % 2 == 0) ans[x] = 2;

        for (auto it: ans) cout << it << ' ';

        cout << endl;

    }

}

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

using namespace std;

#define int long long

int n, x, y;

int nums[200009];

void run_case()

{

    cin >> n >> x >> y;

    if (x+1 == y || x == 1 && y == n)

    {

        if (n & 1)

        {

            nums[1] = 2;

            for (int i = 2; i <= n; i++)

            {

                nums[i] = (i % 2 == 0);

            }

        }

        else

        {

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

            {

                nums[i] = (i % 2 == 0);

            }

        }

    }

    else

    {

        int block1 = y - x + 1;

        int block2 = n - block1 + 2;

        if (block1 & 1 || block2 & 1)

        {

            nums[x] = 2;

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

            {

                if (i > n) nums[i - n] = (i % 2 == 0);

                else nums[i] = (i % 2 == 0);

            }

        }

        else

        {

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

            {

                nums[i] = (i % 2 == 0);

            }

        }

    }

    for (int i = 1; i <= n; i++) cout << nums[i] << " ";

}







signed main()

{

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

    int t;

    cin >> t;

    while (t--) {

        run_case();

        cout << '\n';

    }

    return 0;

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

Solution 1 (runtime: 124 ms):
#include<iostream>
#include<utility>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<iomanip>
typedef long long ll;
using namespace std;
#define inf 0x7f7f7f
#define rpup(i,a,b) for(int i=a;i<=b;i++)
#define rpdo(i,a,b) for(int i=a;i>=b;i--)
#define vc vector

const int Mod4 = 10000;

void solve()
{
	int n;
	cin >> n;
	vc<ll> a(n);
	ll sum = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n - 1; i++)
	{
		if (a[i] <= a[i + 1])
		{
			a[i + 1] = a[i + 1] - min(a[i + 1], a[i]);
		}
		else
		{
			cout << "NO" << endl;
			return;
		}
	}
	cout << "YES" << endl;
	return;
}

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

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

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

using namespace std;

int main(){

long long t; cin>>t;

while(t--){

long long n; cin>>n;

vector<long long> v(n);

for(auto &i: v) cin>>i;

long long j = 0;

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

if(v[i-1]>v[i]) j = i;

}

if(j == 0) cout<<"YES"<<endl;

else{

for(long long i = 0; i<j; i++){

long long temp = min(v[i], v[i+1]);

v[i] -= temp;

v[i+1] -= temp;

}

if(is_sorted(v.begin(), v.end())) cout<<"YES"<<endl;

else cout<<"NO"<<endl;

}

}

}
Problem: 2050C - Uninteresting Number
Language: c++17 

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

#define int long long

void solve() {
    string s;
    cin >> s;
    int sum = 0;
    map<int, int> cnt;
    for(auto c:s) {
        int x = c-'0';
        sum += x;
        if(x>1 && x<4) {
            cnt[x]++;
        }
        // for(int i=0;i<10;i++) {
        //     cout << b[i];
        // }
        // cout << "\n";
    }
    for(int i=0;i<=min(9LL, cnt[2]);i++) {
        for(int j=0;j<=min(9LL, cnt[3]);j++) {
            int sum2 = sum + i*(4-2) + j*(9-3);
            if(sum2 % 9 == 0) {
                cout << "YES\n";
                return;
            }
        }
    }
    cout << "NO\n";
}

signed main() {
    ios::sync_with_stdio(0),cin.tie(0);
    int t=1;
    cin >> t;
    while(t--) solve();
}

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

using namespace std;

int main(){

    int t;

    cin>>t;

    while(t--){

        string s;

        cin>>s;

        int rem=0;

        long long two=0,three=0;

        for(int i=0;i<s.length();i++){

            rem=rem+s[i]-48;

            if(s[i]=='2')

            two++;

            else if(s[i]=='3')

            three++;

        }

        rem=rem%9;

        if(rem==0){

        cout<<"YES"<<endl;

        continue;

        }

        rem=9-rem;

        if(rem%2){

            rem+=9;

        }

        while(three&&rem-6>=0){

            rem-=6;

            three--;

        }

        if(rem==0)

        cout<<"YES"<<endl;

        else{

            while(two>0&&rem-2>=0){

                rem-=2;

                two--;

            }

            if(rem==0)

            cout<<"YES"<<endl;

            else

            cout<<"NO"<<endl;

        }



    }

}
Problem: 2057C - Trip to the Olympiad
Language: c++17 

Solution 1 (runtime: 78 ms):
#include<bits/stdc++.h>
#define ll long long
using namespace std;
string bin(ll x){
	string ans = "";
	while(x){
		ans += char(x % 2 + '0');
		x /= 2;
	}
	 reverse(ans.begin(), ans.end());
	return ans;
}
ll num(string x){
	ll ans = 0;
	for(int i = 0; i < x.size(); i++) {
		if(x[i] == '1') ans += (ll)powl(2, x.size() - i - 1);
	}
	return ans;
}
int main(){
    ll t, n, l, r;
	cin >> t;
	while(t--){
		cin >> l >> r; ll ans = 0, a, b, c;
    for (int i = 30; i >= 0; i--) {
        ll b1 = 0;
        ll b2 = 0;
        if (l & (1ll << i))
        {
            b1 = 1;
        }
        if (r & (1ll << i))
        {
            b2 = 1;
        }
        if (b1 == b2)
        {
            ans += b1 * (1ll << i);
        }
        else
        {
            a = ans + (1ll << i);
            b = a - 1;
            break;
        }
    }
    for (ll i = l; i <= r; i++)
    {
        if (i != a && i != b)
        {
            c = i;
            break;
        }
    }
    cout << a << " " << b << " " << c << endl;
	}
}


Solution 2 (runtime: 77 ms):
#include <bits/stdc++.h>
 
using i64 = long long;
 
void solve() {
    int l, r;
    std::cin >> l >> r;
    int k = 31 - __builtin_clz(l ^ r);
    int a = l | ((1 << k) - 1), b = a + 1, c = (a == l ? r : l);
    std::cout << a << " " << b << " " << c << "\n";
}
 
signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
 
    int t = 1;
    std::cin >> t;
 
    while (t--) {
        solve();
    }
}
Problem: 2062C - Cirno and Operations
Language: c++17 

Solution 1 (runtime: 62 ms):
#include<iostream>
#include<algorithm>
using namespace std;
bool descending(long long a, long long b) {
    return a > b;  // 返回true表示a排在b前面（降序）
}
long long a[55];
long long  sum = 0;
long long ans = 0;
int main()
{
    int t;cin>>t;
    while(t--)
    {
        sum = 0,ans = 0;
        int n;cin>>n;
        for(int i=0;i<n;i++) 
        {
            cin>>a[i];
            sum += a[i];
        }
        if(n == 1)
        {
            cout<<a[0]<<endl;
        }
        else 
        {
            while(n--)
            {
                for(int i=0;i<n;i++)//2
                {
                    a[i] = a[i+1] - a[i];       
                    ans += a[i];
                } 
                sum = max(sum,abs(ans));
                ans = 0 ;
            }
           cout<<sum<<endl;
        }
    }
    return 0;
}

Solution 2 (runtime: 62 ms):
#include <stdio.h>
using namespace std;
typedef long long ll;

int n; ll a[64];

ll max(ll x,ll y){
	return x > y ? x : y;
}
ll abs(ll x){
	return x > 0 ? x : -x;
}

void solve(){
	scanf("%d",&n);
	ll ans = 0;
	for(int i = 1;i <= n;i++)
		scanf("%lld",&a[i]), ans += a[i];
	while(n > 1){
		n--; ll sum = 0;
		for(int i = 1;i <= n;i++)
			a[i] = a[i + 1] - a[i], sum += a[i];
		ans = max(ans,abs(sum));
	}
	printf("%lld\n",ans);
}

int main(){
	int t; scanf("%d",&t);
	while(t--) solve();
}