ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063B - Subsequence Update
Language: c++17 

Solution 1 (runtime: 93 ms):
#include<bits/stdc++.h>
#include<unordered_map>	
using namespace std;
#define ll long long int
#define vi vector<ll> 
#define all(v) v.begin() , v.end()
#define srt(v) sort(v.begin(), v.end())
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"
#define co(c) cout<<c<<"\n"
#define rn return 
#define acc(v) accumulate(v.begin() , v.end() , 0)


template<class T, class U> istream& operator>>(istream &is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T> istream& operator>>(istream& is, vector<T>& vec) { for(auto &x : vec) cin >> x; return is; }
template<class T, class U> ostream& operator<<(ostream &os, const pair<T, U>& p) { os << "<" << p.first << "," << p.second << ">"; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for(auto x : vec) os << x << " "; return os; }

  void solve(){
        ll n, l, r;
        cin >> n >> l >> r;
        l--;
        
        vi arr(n);
        for (int i = 0; i < n; i++) {
            cin >> arr[i];
        }
        
        vi brr = arr;
        sort(brr.begin() + l, brr.end());
        
        vi crr = arr;
        sort(crr.begin(), crr.begin() + r, greater<int>());
        
        ll sum_brr = 0, sum_crr = 0;
        for (int i = l; i < r; i++) {
            sum_brr += brr[i];
            sum_crr += crr[i];
        }
        
        cout << min(sum_brr, sum_crr) << "\n";
  }

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    int testcases;
    cin >> testcases;

    //testcases = 1;
    while (testcases--) {
       solve();
    }
    
    return 0;
}

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

#include <vector>

#include <algorithm>



int main() {

    int t;

    std::cin >> t; // ��ȡ������������



    while (t--) {

        int n, l, r;

        std::cin >> n >> l >> r;

        l--; // ����������ƥ��Python��0-based����



        std::vector<int> arr(n);

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

            std::cin >> arr[i];

        }



        std::vector<int> brr(arr.begin(), arr.begin() + l);

        std::vector<int> temp(arr.begin() + l, arr.end());

        std::sort(temp.begin(), temp.end());

        brr.insert(brr.end(), temp.begin(), temp.end());



        std::vector<int> crr(arr.begin(), arr.begin() + r);

        std::sort(crr.begin(), crr.end(), std::greater<int>());

        temp = std::vector<int>(arr.begin() + r, arr.end());

        crr.insert(crr.end(), temp.begin(), temp.end());



        // ��������������ָ����Χ�ڵ�Ԫ��֮��

        long long sum_brr = 0, sum_crr = 0;

        for (int i = l; i < r; ++i) {

            sum_brr += brr[i];

            sum_crr += crr[i];

        }



        // ����������е���Сֵ

        std::cout << std::min(sum_brr, sum_crr) << std::endl;

    }



    return 0;

}
Problem: 2050E - Three Strings
Language: c++17 

Solution 1 (runtime: 2031 ms):
#include<bits/stdc++.h>
using namespace std;
int dp[2005][2005];
void solve(){
    string a,b;
    cin >> a >> b ;
    string c;
    cin >> c; 
    memset(dp,0,sizeof dp);


    int lena = a.size();
    int lenb = b.size() ;
    int lenc = c.size();
    a = '3' + a;
    b = '2' + b;
    c = '1' + c;
    for(int i = 1 ; i <= lena ; i ++ )
    {
        if(c[i] == a[i])dp[i][0] = dp[i-1][0] + 1;
        else dp[i][0] = dp[i-1][0];
    }
    for(int i = 1 ; i <= lenb ; i ++ )
    {
        if(c[i] == b[i])dp[0][i] = dp[0][i-1] + 1;
        else dp[0][i] = dp[0][i-1];
    }

    for(int i = 1 ; i <= lena ; i ++ )
    {
        for(int j = 1 ; j <= lenb ; j ++ )
        {
            if(i == 0 && j == 0 )continue ;
            if(c[i + j] == a[i] && i > 0){
                dp[i][j] = max(dp[i][j],dp[i-1][j] + 1);
                dp[i][j] = max(dp[i-1][j],dp[i][j]);
                dp[i][j] = max(dp[i][j],dp[i][j-1]);
            }
            if(c[i + j] == b[j] && j > 0){
                dp[i][j] = max(dp[i][j],dp[i][j-1] + 1);
                dp[i][j] = max(dp[i-1][j],dp[i][j]);
                dp[i][j] = max(dp[i][j],dp[i][j-1]);
            }
            if(c[i+j]!=b[j] && c[i+j] != a[i]){
                dp[i][j] = max(dp[i-1][j],dp[i][j]);
                dp[i][j] = max(dp[i][j],dp[i][j-1]);
            }
           
        }
    }
    
    cout << lenc - dp[lena][lenb] << endl; 
}


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

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

    using namespace std;



    string c;



    int solve(string a, string b){

        int arr[a.length()+1][b.length()+1];

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

            for(int j=0; j<=b.length(); j++){

                if(i == 0 && j == 0) arr[i][j] = 0;

                else if (i == 0 && j != 0){

                    if(b[j-1] == c[j-1]) arr[i][j] = arr[i][j-1];

                    else arr[i][j] = arr[i][j-1]+1;

                } else if(i != 0 && j == 0){

                    if(a[i-1] == c[i-1]) arr[i][j] = arr[i-1][j];

                    else arr[i][j] = arr[i-1][j]+1;

                } else{

                    int ans_1, ans_2;

                    if(a[i-1] == c[i+j-1]) ans_1 = arr[i-1][j];

                    else ans_1 = arr[i-1][j]+1;

                    if(b[j-1] == c[i+j-1]) ans_2 = arr[i][j-1];

                    else ans_2 = arr[i][j-1]+1;

                    arr[i][j] = min(ans_1,ans_2);

                }

            }

        }



        return arr[a.length()][b.length()];

    }



    int main(){



        int t; cin >> t;

        while(t--){

            string a,b; cin >> a >> b >> c;

            cout << solve(a,b) << endl;

        }



        return 0;

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

Solution 1 (runtime: 406 ms):
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <list>
using namespace std;

int n;
int cnt;
const int N = 20005;

void solve()
{
	cin >> n;
	vector<int> deg(n, 0);
	vector<vector<int>> adj(n);
	int u, v;
	for (int i = 1; i < n; i++)
	{
		cin >> u >> v;
		u--, v--;
		deg[u]++, deg[v]++;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	int ans = 1;
	int mans = 0;
	vector<int> sdeg = deg;
	sort(sdeg.begin(), sdeg.end());
	
	for (int i = 0; i < n; i++)
	{
		ans = deg[i];
		vector<int> ideg;
		for (int j : adj[i])
		{
			ideg.push_back(deg[j]);
		}
		ideg.push_back(deg[i]);
		sort(ideg.rbegin(), ideg.rend()); //降序排序
		vector<int> rem;
		for (int j : ideg)
		{
			if (j == sdeg.back())
			{
				sdeg.pop_back();
				rem.push_back(j);
			}
		}
		reverse(rem.begin(), rem.end());
		
		int mx = -1;
		if (!sdeg.empty())
		{
			mx = sdeg.back();
		}
		for (int j : adj[i])
		{
			mx = max(mx, deg[j] - 1);
		}
		mans = max(mans, ans + mx - 1);
		for (int j : rem)
		{
			sdeg.push_back(j);
		}
	}
	cout << mans << endl;
}

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



Solution 2 (runtime: 311 ms):
/*
*      Author: raj_adi
*      HAPPY CODING!!!!!!!
*/
#include<bits/stdc++.h>
using namespace std;
#define pll pair<long,long>
#define ll long long
#define int long long
#define ld long long double
#define pii pair<int, int>
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define limit 100005
#define fixed(n)  << setprecision(n)
template <typename T> ostream &operator<<(ostream &out, const vector<T> &v) { for (const auto &x : v) out << x << ' '; return out; }
template <typename T> istream &operator>>(istream &in, vector<T> &v) { for (auto &x : v) in >> x; return in; }
void solve()
{
for(int i=0;i<1;i++);
int n;cin>>n;
vector<int> degree(n+1,0);
vector<set<int>> adj(n+1);
for(int i=0;i<n-1;i++){
    int u,v;cin>>u>>v;
    adj[u].insert(v);
    adj[v].insert(u);
    degree[u]++,degree[v]++;
}
int ans=0;
vector<pii> v;
for(int i=1;i<=n;i++){
    v.push_back({degree[i],i});
}
sort(all(v),greater<pii>());
int l=v.size();
// for(auto x:v)cout<<x.first<<" "<<x.second<<endl;
    int deg=v[0].first;
    for(int j=1;j<l;j++){
        if(adj[v[0].second].find(v[j].second)!=adj[v[0].second].end())ans=max(ans,deg+v[j].first-2);
        else
        ans=max(ans,deg+v[j].first-1);
    }
    if(v[0].first==v[1].first){
        deg=v[1].first;
        for(int j=2;j<l;j++){
            if(adj[v[1].second].find(v[j].second)!=adj[v[1].second].end())ans=max(ans,deg+v[j].first-2);
            else
            ans=max(ans,deg+v[j].first-1);
        }
    }
cout<<ans<<endl;
}
signed main()
{
 ios_base::sync_with_stdio(0), cin.tie(0);
int t;
cin>>t;
while(t--)
{
solve();
}
}
Problem: 2060D - Subtract Min Sort
Language: c++17 

Solution 1 (runtime: 93 ms):
#include <bits/stdc++.h>
#define int long long
#define vin(a)                  \
    for (int i = 0; i < n; ++i) \
        cin >> a[i];
#define vout(a)                 \
    for (int i = 0; i < n; ++i) \
        cout << a[i] << ' ';
#define pb push_back
#define ff first
#define ss second
#define viv vector<vector<int>>
#define nah cout << "No" << endl;
#define yah cout << "Yes" << endl;
#define be begin()
#define en end()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vi vector<int>
#define vpi vector<pair<int, int>>
#define up upper_bound
#define low lower_bound
#define mod 998244353
using namespace std;
 

int32_t main(){
    fast;
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vi a(n);
        vin(a);

            for(int i=0;i<n-1;i++){
                // /t oko=max(a[i],a[i+1])-min(a[i],a[i+1]);
                int val = min(a[i],a[i+1]);
                a[i]=a[i]-val;
                a[i+1]=a[i+1]-val;

            }
            if(is_sorted(all(a))){
                cout<<"YES"<<endl;
            }
            else{
                cout<<"NO"<<endl;
            }
        }
    }


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

using namespace std;



typedef long long ll;



void solve(){

    int n;

    cin >> n;

    vector<ll> arr;

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

        ll x;

        cin >> x;

        arr.push_back(x);

    }

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

        if(arr[i] <= arr[i + 1]){

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

            arr[i] = 0;

        }else{

            cout << "NO\n";

            return;

        }

    }

    cout << "YES\n";

}



int main(){

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int t = 1;

    cin >> t;

    while(t--){

        solve();

    }

    return 0;

}
Problem: 2063B - Subsequence Update
Language: c++17 

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

using namespace std;

void solve(){
    int n,l,r; cin>>n>>l>>r;
    vector<long long int> a(n),b,c;
    for(int i = 0 ; i < n ; i++) cin>>a[i];
    for(int i = 0 ; i < r ; i++) b.push_back(a[i]);
    for(int i = l-1 ; i < n ; i++) c.push_back(a[i]);

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

    long long int size = r-l+1;
    long long int ans = 0, temp = 0;
    for(int i = 0 ; i < size ; i++) ans += b[i];
    for(int i = 0 ; i < size ; i++) temp += c[i];

    ans = min(ans, temp);
    cout<<ans<<endl;
}

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

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

#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vin(v) for(auto &i : v) cin >> i
#define vout(v) for(auto &i : v) cout << i << ' '; cout<<endl
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define fr(x,y) for(ll i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define pb push_back
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pll pair<ll, ll>
#define endl '\n'
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
const ll mod = 1e9 + 7;
// vector<bool> isPrime(N + 1, true);
// void sieve() {
//     isPrime[0] = isPrime[1] = false;
//     for (ll i = 2; i * i <= N; i++) {
//         if (isPrime[i]) {
//             for (ll j = i * i; j <= N; j += i)
//                 isPrime[j] = false;
//         }
//     }
// }

void solve () {
    ll n,l,r;   
    cin >>n>>l>>r;
    vll v(n);
    vin(v);
    ll ans=0;
    vll v1;
    for(int i=l-1;i<n;i++) {
        v1.pb(v[i]);
    }
    vll v2;
    for(int i=0;i<r;i++) {
        v2.pb(v[i]);
    }
    sort(all(v1));
    sort(all(v2));
    ll ans1=0;
    for(int i=0;i<(r-l+1);i++) {
        ans1+=v2[i];
    }
    ll ans2=0;
    for(int i=0;i<(r-l+1);i++) {
        ans2+=v1[i];
    }
    ans=min(ans1,ans2);
    cout<<ans<<endl;
}

int main() {
    fastio();
    int t;
    cin >>t;
    while(t--) {
        solve();
    }
}
Problem: 2060D - Subtract Min Sort
Language: c++17 

Solution 1 (runtime: 327 ms):
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++)
        cin>>a[i];
        bool yes=true;
        for(int i=0;i<n-1;i++)
        {
            int mini=min(a[i],a[i+1]);
            a[i]-=mini;
            a[i+1]-=mini;
        }
        for(int i=0;i<n-1;i++)
        {
            if(a[i]>a[i+1])
            yes=false;
        }
        if(yes)
        cout<<"YES"<<endl;
        else
        cout<<"NO"<<endl;
    }
}

Solution 2 (runtime: 78 ms):
#include<bits/stdc++.h>
using namespace std;
int t;
int n,a[200005];
int main(){
	ios::sync_with_stdio(0),cin.tie(0);
	cin>>t;
	while(t--){
		cin>>n;
		int flag=0;
		for(int i=1;i<=n;i++){
			cin>>a[i];
			if(i>=2){
				int p=min(a[i],a[i-1]);
				a[i]-=p;
				a[i-1]-=p;
			}
		}
		for(int i=2;i<=n;i++){
			if(a[i]<a[i-1]) flag=1;
		}
		if(!flag) cout<<"YES\n";
		else cout<<"NO\n";
	}
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: c++17 

Solution 1 (runtime: 46 ms):
#include <iostream>
#include <vector>
#define ai_jiang signed main()
#define rep(a, b, c) for (int a = b; a <= c; a++)
#define drep(a, b, c) for (int a = b; a >= c; a--)
#define all(a) a.begin(), a.end()
#define ll long long
#define int long long
using namespace std;
using poly = vector<ll>;
namespace ai
{
    constexpr int N = 60;
    int t, n, a[N];
}
using namespace ai;
ai_jiang
{
    cin.tie(0);
    cout.tie(0);
    cin >> t;
    while (t--)
    {
        cin >> n;
        int ans = 0;
        rep(i, 1, n) cin >> a[i], ans += a[i];
        rep(i, 1, n - 1)
        {
            int sum = 0;
            rep(j, 1, n - i) a[j] -= a[j + 1], sum += a[j];
            ans = max(ans, max(sum, -sum));
        }
        if (n == 1)
            ans = a[1];
        cout << ans << '\n';
    }
    return 0;
}

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

const int N = 55;
long long a[N];

void solve() {
	int n;
	cin >> n;
	
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	} 
	
	int an = n;
	for (int i = 0; i < n - 1; i++) {
		sum = max(sum, abs(a[0] - a[an - 1]));
		for (int j = 0; j < an - 1; j++) {
			a[j] = a[j + 1] - a[j];
		}
		an--;
	}
	
	cout << sum << "\n";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int tt;
	cin >> tt;
	
	while (tt--) {
		solve();
	}
	
	return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: c++17 

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll t;
    cin >> t;

    while (t--) {
        ll n, k;
        cin >> n >> k;

        vector<ll> a(n);
        map<ll, ll> compress;
        vector<ll> freq;

        for (ll i = 0; i < n; i++) {
            cin >> a[i];
            compress[a[i]]++;
        }
        // Chuyển giá trị tần suất từ map vào vector
        for (auto& [value, count] : compress) {
            freq.push_back(count);
        }

        // Sắp xếp tần suất tăng dần
        sort(freq.begin(), freq.end());

        ll distinct = freq.size(); // Ban đầu là số giá trị khác nhau
        for (ll count : freq) {
            if (k >= count) {
                k -= count; // Dùng k để xóa các giá trị ít xuất hiện
                distinct--; // Giảm số lượng giá trị khác biệt
            } else {
                break; // Không còn k đủ để giảm tiếp
            }
        }

        // In kết quả
        cout << max(1LL, distinct) << "\n";
    }

    return 0;
}


Solution 2 (runtime: 218 ms):
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll solve(ll n, ll k, vector<ll>inp){
    map<ll,ll>mpp;
    for(ll i=0;i<inp.size();i++){
        mpp[inp[i]]++;
    }
    vector<ll>freq;
    for(auto it : mpp){
        freq.push_back(it.second);
    }
    sort(begin(freq), end(freq));
    ll p = 0;
    while(k>0 && p<freq.size()-1){
        if(k>=freq[p]){
            k-=freq[p];
            p++;
        }
        else{
            break;
        }
    }
    
    return freq.size()-p;

}

int main() {
    int t;
    cin >> t;
    while(t--) {
        ll n, k;
        cin>>n>>k;
        vector<ll>inp(n);
        for(auto &it : inp) cin>>it;
        cout<<solve(n, k,inp)<<endl;
    }
    
    return 0;
}
Problem: 2050E - Three Strings
Language: c++17 

Solution 1 (runtime: 2390 ms):
#include<bits/stdc++.h>
using namespace std;
int dp[2001][2001];
int f(string &a,string &b,string &c,int i,int j){
    if(dp[i][j]!=-1)
    return dp[i][j];
    if(i==a.length()&&j==b.length())
    return dp[i][j]=0;
    if(i>a.length()||j>b.length())
    return 1e5;
    int min_one=INT_MAX;
    if(i!=a.length()&&a[i]==c[i+j])
    min_one=min(min_one,f(a,b,c,i+1,j));
    if(j!=b.length()&&b[j]==c[i+j])
    min_one=min(min_one,f(a,b,c,i,j+1));
    min_one=min(min_one,1+min(f(a,b,c,i+1,j),f(a,b,c,i,j+1)));
    return dp[i][j]=min_one;
}
int main(){
    int t;
    cin>>t;
    while(t--){
        string a,b,c;
        cin>>a>>b>>c;
        for(int i=0;i<2001;i++){
            for(int j=0;j<2001;j++){
                dp[i][j]=-1;
            }
        }
        cout<<f(a,b,c,0,0)<<endl;
    }
}

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

using namespace std;

#define ll long long

#define int long long

const ll N=1e9+7;



void solve(){

    string a,b,c;

    cin>>a>>b>>c;

    int n=a.size(),m= b.size();

    vector<vector<int>> v(n+1, vector<int> (m+1));

    for(int i=0;i<=n;i++) fill(v[i].begin(),v[i].end(),INT_MAX); 

    v[0][0]=0;

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

        v[i+1][0]=v[i][0]+(a[i]!=c[i]);

    }

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

        v[0][i+1]=v[0][i]+(b[i]!=c[i]);

    }

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

        for(int j=1;j<=m;j++){

            v[i][j]=min(v[i-1][j]+(a[i-1]!=c[i+j-1]),v[i][j-1]+(b[j-1]!=c[i+j-1]));

        }

    }

    cout<<v[n][m]<<"\n";

}



int32_t main() {

    ios::sync_with_stdio(0); 

    cin.tie(0);

    ll t;

    cin>>t;

    while(t--){

        solve();

    }

    return 0;

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

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

#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast,unroll-loops")

using namespace std;

#define all(a) a.begin(), a.end()
#define rsort(c) sort(all(c)); reverse(all(c))
#define print(a) for(auto x : a) cout << x << " "; cout << endl
#define printall(a) for(auto x:a){ print(x); } cout<<endl
#define input(a) for(auto &x:a) cin>>x
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pair<int,int>>
#define vvi vector<vector<int>>


#define int long long

void solve(int tc){
    int l,r;
    cin>>l>>r;
    int a=0, b =l,c=l;
    for(int i = 31;i>=0;i--){
        if(((r>>i)&1)==1){
            a |= (1<<i);
            if(((l>>i)&1)==0) break;
        }
    }
    int bb = (1 + log2(r));
    for(int i = 30;i>=0;i--){
        if(((a>>i)&1)==0) {
            // cout<<i<<endl;
            int nb = b | (1<<i);
            // cout<<nb<<endl;
            if(nb<=r) b = nb;
        }
    }
    if(b==c){
        for(int i =0;i<=30;i++){
            if(((c>>i)&1)==0) {
                int nb = b | (1<<i);
            // cout<<nb<<endl;
                if(nb<=r) b = nb;
                else{
                    b = a + 1;
                }
                break;
            }
        }
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
    // cout<<"xor: "<<endl;
    // cout<<(a^b) + (b^c) + (a^c)<<endl;
    // cout<<(134 ^ 132) + (132 ^ 137) + (134 ^ 137)<<endl;
}


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

    int t=1;
    int tt=1;
    cin>>t;

    while(t--){
        // cout<<"Case #"<<tt<<": ";
        // tt++;
        solve(tt++);
    }
}



















Solution 2 (runtime: 78 ms):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool compareByFirst(const pair<int, int>& a, const pair<int, int>& b) {
    return a.first < b.first;
}

void solve(){
	ll l,r;
	cin>>l>>r;
	int a=-1,b=-1,c=-1;
	ll cur=0;
	for(int k=31;k>=0;k--){
		if((r & (1 << k)) != 0){
			cur= cur | (1 << k);
			}
		if(cur-1>=l){
			a=cur-1;
			b=cur;
			c=cur+1;
			if(c>r){c=cur-2;}
			break;
			}
		}
	cout<<a<<" "<<b<<" "<<c;
	cout<<endl;
	}

int main(){
	int t;
	cin>>t;
	while(t--){
		solve();
		}
	}
Problem: 2060D - Subtract Min Sort
Language: c++17 

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

using namespace std;

void solve(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int &x: a) cin >> x;
  for(int i = 0; i < n-1; i++){
    if(a[i] <= a[i+1]){
      a[i+1] -= a[i];
    }
    else if(a[i] > a[i+1]){
      cout << "NO\n";
      break;
    }
    if(i==n-2){
      cout << "YES\n";
      break;
    }
  }
}

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


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

#define all(a) (a).begin(),(a).end()

#define pb push_back

#define optimize ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

typedef long long ll;

void solve()

{

    int n;

    cin>>n;

    vector<ll> a(n);

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

    bool ok=true;

    ll last=0;

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

    {

        ll f=a[i], sec=a[i+1];

        f-=min(a[i],a[i+1]);

        sec-=min(a[i],a[i+1]);

        if(f>=last)

        {

            a[i]=f;

            a[i+1]=sec;

        }

        last=a[i];

    }

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

    {

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

        {

            cout<<"NO\n"; return;

        }

    }

    cout<<"YES\n";

}

int main()

{

    optimize;

    int t;

    cin>>t;

    while(t--)

    {

        solve();

    }

    return 0;

}