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

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

#define ll long long

void solve(){
	ll n,l,r;
	cin>>n>>l>>r;
	ll one=l-1,two=r-l+1,three=n-r;
	vector<ll>a(one),b(two),c(three);
	for(ll i=0;i<one;i++){
		cin>>a[i];
	}
	for(ll i=0;i<two;i++){
		cin>>b[i];
	}
	for(ll i=0;i<three;i++){
		cin>>c[i];
	}
	// cout<<one<<' '<<two<<' '<<three<<endl;
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());
	ll sum=0;
	for(auto i:b){
		sum+=i;
	}
	ll ans=sum;
	ll temp=sum;
	// r--,l--;
	ll i=0,j=two-1;
	while(i<one && j>=0){
		if(a[i]<b[j]){
			temp-=b[j];
			temp+=a[i];
			i++;
			j--;
		}
		else{
			break;
		}
	}
	// cout<<temp<<'$'<<endl;
	ans=min(ans,temp);
	temp=sum;
	i=0,j=two-1;
	while(i<three && j>=0){
		if(c[i]<b[j]){
			temp-=b[j];
			temp+=c[i];
			i++;j--;
		}
		else{
			break;
		}
	}
	cout<<min(ans,temp)<<endl;
}

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

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

//
//bool check(ll k, ll mid, ll n, vector<ll>& a, vector<ll>& b){
//    ll counter = 0;
//    bool f = false;
//    for (int i = 0; i < n; ++i){
//        if (mid <= b[i] && mid > a[i]) {
//            counter++;
//            f = true;
//        }
//        else if (mid <= a[i]) {
//            f = true;
//        }
//    }
//    return (counter <= k && f);
//}

void solve() {
    ll n, l, r, x = 0, y = 0, counter = 0;
    cin >> n >> l >> r;
    vector<int>a(n);
    vector<pair<int, int>>v;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        v.emplace_back(a[i], i);
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < n; ++i){
        if (counter >= (r - l + 1))
            break;
        if (v[i].second <= r - 1) {
            x += v[i].first;
            counter++;
        }
    }
    counter = 0;
    for (int i = 0; i < n; ++i){
        if (counter >= (r - l + 1))
            break;
        if (v[i].second >= l - 1) {
            y += v[i].first;
            counter++;
        }

    }
    if (x == 0)
        cout << y << el;
    else if (y == 0)
        cout << x << el;
    else
        cout << min(x, y) << el;

}

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

Solution 1 (runtime: 312 ms):
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void sol()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<int> b(n);
    b[0] = a[0] - min(a[0], a[1]);
    b[1] = a[1] - min(a[1], a[0]);
    bool fa, fb;
    fa = true;
    fb = true;
    for (int i = 1; i < n - 1; i++)
    {
        int x = min(b[i], a[i + 1]);
        b[i] = b[i] - x;
        b[i + 1] = a[i + 1] - x;
        fa = fa && (a[i] >= a[i - 1]);
        fb = fb && (b[i] >= b[i - 1]);
        fa = fa || (fb && b[i - 1] <= a[i]);
    }
    fa = fa && (a[n - 1] >= a[n - 2]);
    fb = fb && (b[n - 1] >= b[n - 2]);
    fa = fa || (fb && b[n - 2] <= a[n - 1]);
    if (!fa && !fb)
    {
        cout << "NO\n";
        return;
    }
    cout << "YES\n";
}
void bedo()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 1; i < n; i++)
    {
        if (a[i] < a[i - 1])
        {
            cout << "NO\n";
            return;
        }
        a[i] -= a[i - 1];
        a[i - 1] = 0;
    }
    cout << "YES\n";
    return;
}
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        bedo();
    }

    return 0;
}

Solution 2 (runtime: 93 ms):
//refer jay's solution

#include<bits/stdc++.h>

using namespace std;

#define int long long



void solve()

{

    int n;

    cin>>n;

    vector<int>arr;

    arr.resize(n);

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

    cin>>arr[i];

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

    {

        int mn=min(arr[i],arr[i+1]);

        arr[i]-=mn;

        arr[i+1]-=mn;

    }

    if(is_sorted(arr.begin(),arr.end()))

    cout<<"YES\n";

    else

    cout<<"NO\n";

}



signed main()

{

    ios_base::sync_with_stdio(0);

    cin.tie(0);cout.tie(0);

    int t;

    cin>>t;

    while(t--)

    {

        solve();

    }

}
Problem: 2050D - Digital string maximization
Language: c++17 

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

void solve()
{
 string s;
 cin>>s;
 ll n=s.size();
 for(ll i=0;i<n;i++){
 	ll j=i;
 	while(s[j+1]-s[j]>=2&&j>=0){
 		s[j+1]-=1;
 		swap(s[j+1],s[j]);
 		j--;
	 }
 }
 cout<<s<<endl;
}

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

	ll t; cin >> t;
	while(t--) solve();

	return 0;
}



Solution 2 (runtime: 62 ms):
// Problem: D. Digital string maximization
// Contest: Codeforces - Codeforces Round 991 (Div. 3)
// URL: https://codeforces.com/contest/2050/problem/D
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

//                                               وقل ربي زدني علما
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define s second
#define f first
#define all(x) x.begin(),x.end()
#define yes cout<< "YES\n";
#define no cout << "NO\n";
#define el cout << "\n";
#define c1 cout << 1 << "\n";
#define c0 cout << 0 << "\n";
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define T int ttcc; cin >> ttcc; while(ttcc--)
const int N=200100;
const int mod = 1e9 + 7;

int a[N],n,m;

ll gcd(ll x,ll y)
{
    while(y)
    {
        ll r=x%y;
        x=y;
        y=r;
    }
    return x;
}

void mo(ll &x) { x=((x%mod)+mod)%mod; } 
 
ll add(ll a, ll b) { return ((a % mod) + (b % mod)) % mod; }
 
ll sub(ll a, ll b) { return ((a % mod - b % mod) % mod + mod) % mod; }
 
int mul(int a, int b)
{
    return (long long)a * b % mod;
}
 
int fpow(int a, int b)
{
    if (b == 0)
        return 1;
    int ret = fpow(a, b / 2);
    ret = mul(ret, ret);
    if (b % 2 == 1)
        ret = mul(ret, a);
    return ret;
}
 
int divi(int a, int b)
{
    return mul(a, fpow(b, mod - 2));
}
 
int ceil(int a, int b)
{
    return (a + b - 1) / b;
}

/*
void nx_pr(){
  do
    {
      for (auto x : v)
        {
          cout << x << ' ';
        }
      cout << endl;
    }
  while (next_permutation (v.begin (), v.end ()));
}
*/
string s;
void solve(){
	cin >> s;
	for(int i=1;i<s.size();i++){
		for(int j=i-1;j>=0;j--){
			if(s[j+1]-1=='0')break;
			if((s[j+1]-1)>s[j]){
				s[j+1]--;
				swap(s[j],s[j+1]);
			}
			else break;
		}
	}
	cout << s;el
}


int main(){
    fast
    T solve();
}
Problem: 2050E - Three Strings
Language: c++17 

Solution 1 (runtime: 77 ms):
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007 
using namespace std;
int solve(int i,int j,string& s,string &n,string& m,vector<vector<int>>&dp){
    if(i==n.size() && j==m.size())return 0;
    if(dp[i][j]!=-1)return dp[i][j];
    int ans=INT_MAX;
    if(i<n.size())ans=min(ans,solve(i+1,j,s,n,m,dp)+(n[i]!=s[i+j]));
    if(j<m.size())ans=min(ans,solve(i,j+1,s,n,m,dp)+(m[j]!=s[i+j]));
    return dp[i][j]=ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    cin >> t;
    while (t--) {
 long long a,b,c=0,k,d=0,cnt=0,sum=0,ans=0,e=1;
 string s,m,n;
 cin>>n>>m>>s;
 vector<vector<int>>dp(n.size()+1,vector<int>(m.size()+1,-1));
 cout<< solve(0,0,s,n,m,dp)<<endl;
 
    }
    return 0;
}

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

typedef long long ll;
#define ios 
const int N = 300010;

void solve();

int main () {
	cin.tie(0) -> sync_with_stdio();
	int T = 1;
	cin >> T;
	while( T -- ) solve();
	return 0;
}


void solve() {
	string a, b, c;
	cin >> a >> b >> c;
	int n = a.size(), m = b.size();
	a = ' ' + a;
	b = ' ' + b;
	c = ' ' + c;
	vector<vector<int>> dp(n + 1, vector<int>(m + 1));
	dp[0][0] = 0;
	for(int i = 0; i <= n; i++) {
		for(int j = 0; j <= m; j++) {
			if(j != 0 || i != 0) {
				if(i != 0) dp[i][j] = dp[i - 1][j] + (c[i + j] != a[i]);
				if(j != 0) {
					if(i != 0) dp[i][j] = min(dp[i][j], dp[i][j - 1] + (c[i + j] != b[j]));
					else dp[i][j] = dp[i][j - 1] + (c[i + j] != b[j]);
				}
			}
		}
	}
	printf("%d\n", dp[n][m]);
}
Problem: 2057C - Trip to the Olympiad
Language: c++17 

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

//JAY SHREE KRISHNA
// --------------------------------------
#define ll long long
#define ld long double
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define pb push_back
#define pp pop_back
#define endl "\n"
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
// -------------------------------------

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t;		cin>>t;
    while(t--){
        long long l,r,req1=0,req2=0;
        cin>>l>>r;
        bool flag=true;
        for(int i=30;i>=0;i--){
            if(((l>>i)&1)==((r>>i)&1)&&flag){
                req1=req1|((((r>>i)&1))<<i);
            }
            else if(((l>>i)&1)!=((r>>i)&1)&&!flag){
                req1=req1|(1<<i);
            }
            else{
                flag=false;
                req1=req1|((!(((r>>i)&1)))<<i);
            }
        }
        flag=true;
        for(int i=30;i>=0;i--){
            if(((l>>i)&1)==((r>>i)&1)&&flag){
                req2=req2|((((r>>i)&1))<<i);
            }
            else if(((l>>i)&1)!=((r>>i)&1)&&!flag){
                req2=req2|(0<<i);
            }
            else{
                flag=false;
                req2=req2|((!(((l>>i)&1)))<<i);
            }
        }
        if(req1<=l){
            cout<<l<<" "<<req2<<" "<<r<<endl;
        }
        else{
            cout<<l<<" "<<req1<<" "<<r<<endl;
        }
    }
    return 0;
}

Solution 2 (runtime: 77 ms):
#include<bits/stdc++.h>
using namespace std;
#define fr(ii,ss,tt) for(int ii=ss;ii<=tt;ii++)
#define rf(ii,ss,tt) for(int ii=ss;ii>=tt;ii--)
#define pii pair<int,int>
#define pt printf
#define x first
#define y second
#define all(a) begin(a),end(a)
#define pb push_back
#define eb emplace_back
#define siz(x) ((int)size(x))
#ifdef UFILE
#define file(f1,f2) (f1!=""&&freopen(f1,"r",stdin),f2!=""&&freopen(f2,"w",stdout))
#else
#define file(...) 0
#endif
#ifdef DEBUG
#include DEBUG
#else
#define assert(...) 0
#define Z(...) 0
#define ZZ(...) 0
#endif
typedef long long LL;
template<typename T>bool tomax(T&x,const T&y){if(x<y)return x=y,true;return false;}
template<typename T>bool tomin(T&x,const T&y){if(x>y)return x=y,true;return false;}
inline void rd(auto&x,auto&...y){char ch;bool f=0;while(!isdigit(ch=getchar()))if(ch=='-')f=1;x=0;do{x=(x<<1)+(x<<3)+(ch^48);}while(isdigit(ch=getchar()));if(f)x=-x;if constexpr(sizeof...(y))rd(y...);}
inline void wtl(auto&x,auto&...y){cout<<x;if constexpr(sizeof...(y))cout<<' ',wt(y...);else cout<<'\n';}

const int L=29,N=1e6+33;

signed main(){
	ios::sync_with_stdio(0);
	int T;
	rd(T);
	while(T--){
		int l,r;
		rd(l,r);
		int t=-1;
		int bs=0;
		rf(b,L,0){
			if((l>>b&1)==(r>>b&1)){
				if(l>>b&1)bs|=(1<<b);
			}else{t=b; break;}
		}

		int ans=-1,an=-1;
		auto upd=[&](int x){
			if(!(l<=x&&x+2<=r)){
				return;
			}
			tomax(ans,(x^(x+1))+((x+1)^(x+2))+((x+2)^x))&&(an=x);
			
		};
		fr(x,(1<<t)-5,(1<<t)+5){
			upd(bs+x);
		}
		//cout<<ans<<endl;
		cout<<an<<" "<<an+1<<" "<<an+2<<endl;
	}
	return 0;
}
Problem: 2060D - Subtract Min Sort
Language: c++17 

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

typedef long long ll;

#define INF 0x3f3f3f

void solve()
{
    int n, j = 0;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n - 1; i++)
    {
        if (a[i] > a[i + 1])
        {
            j = i + 1;
        }
    }
    if (j == 0)
    {
        cout << "YES\n";
        return;
    }
    for (int i = 0; i < j; i++)
    {
        int minA = min(a[i], a[i + 1]);
        a[i] -= minA, a[i + 1] -= minA;
    }
    cout << (is_sorted(a.begin(), a.end()) ? "YES\n" : "NO\n");
}

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

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

Solution 2 (runtime: 358 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=0; i<n-1; i++){
        if(a[i]>a[i+1]) {
            cout << "no\n";
            return;
        }
        else {
            a[i+1] -= a[i];
            a[i] = 0;
              
        }
    }
    cout << "YES\n";
    return;
}
int main(){
    int t;
    cin >> t;
    while(t--){
        solve();
    }
}
Problem: 2063B - Subsequence Update
Language: c++17 

Solution 1 (runtime: 93 ms):
//mamadam
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
const int N = 200010, inf = 1000000000;
vector <long long> adj[N];
long long n, m = 1000000007, k, kk, e, a[N], vis[N];
int main(){
    long long f, q = 0, t = 1, w = 1e14, l = 0, r = 0;
    string s;
    ios_base::sync_with_stdio(false);
    cin >> t;
    for(long long te = 0;te < t;te++){
    	cin >> n >> l >> r;
    	for(int i = 1 ;i <= n;i++){
    		cin >> a[i];
    		vis[i] = a[i];
		}
		sort(vis + l, vis + n + 1);
		sort(a + 1, a + r + 1);
		w = 0;
		for(int i = 1;i <= r - l + 1;i++){
			w+= a[i];
		}
		q = 0;
		for(int i = l;i <= r;i++){
			q += vis[i];
		}
		cout << min(q, w) << endl;
	}
}
//69.

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

#include<ext/pb_ds/assoc_container.hpp>

#define ENDL '\n'

#define MAXN 100001

#define mod 998244353

#define ft first

#define sd second

using namespace std;

using namespace __gnu_pbds;



typedef long long ll;

typedef pair<int, int> pii;

typedef vector<int> vi;

typedef vector<ll> vll;

typedef vector<vector<int>> vvi;

typedef long double ld;

typedef tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update>ordered_set;



ll n, m, k;



ll binpow(ll a, ll b){

	if(b==0)return 1;

	if(b==1)return a;

	ll num=binpow(a,b>>1)%mod, p=1;

	if(b%2)p=a;

	ll part=(num*num)%mod;

	return (part*p)%mod;

}



const int mov_f[]={-1,0,1, 0};

const int mov_c[]={0,-1,0, 1};



void solve(){

  cin>>n;

  int l, r; cin>>l>>r;

  vll v(n+1);

  for(int i=1; i<=n; i++)cin>>v[i];





  vll left, right, left2;

  ll sum=0;

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

    left.push_back(v[i]);

    sum+=v[i];

  }



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

    left2.push_back(v[i]);

  }



  sort(left.rbegin(), left.rend());

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



  ll sum2=sum;

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

    right.push_back(v[i]);

  }

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



  for(int i=0; i<min(right.size(), left.size()); i++){

    if(left[i]<right[i])break;

    sum+=right[i]-left[i];

  }



  for(int i=0; i<min(left2.size(), left.size()); i++){

    if(left[i]<left2[i])break;

    sum2+=left2[i]-left[i];

  }



  cout<<min(sum, sum2)<<ENDL;



}



int32_t main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0); cout.tie(0);

    cout.precision(0);

    cout<<fixed;

	//freopen("fencedin.in", "r", stdin);

	//freopen("fencedin.out", "w", stdout);



	int t=1;

    cin>>t;

	while(t--)solve();



	return 0;

}
Problem: 2057B - Gorilla and the Exam
Language: c++17 

Solution 1 (runtime: 78 ms):
#include<bits/stdc++.h>
#define ll long long
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define fastread() (ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL))
#define sp(x, y) fixed << setprecision(x) << y
#define mod (int)(1e9 + 7)
#define nl endl
using namespace std;
void print(vector<int>arr)
{
    int n=(int)(arr.size());
    for(int i=0;i<n;i++)
    {
        cout<<arr[i]<<" ";
    }
    cout<<endl;
}
void accepted()
{
    int n,k;
    cin>>n>>k;
    vector<int>arr(n);
    for(int i=0;i<n;i++) cin>>arr[i];
    if(k>=n)
    {
        cout<<1<<endl;
        return;
    }
    sort(all(arr));
    std::vector<int> cnt = {1};
    for (int i = 1; i < n; i++) {
        if (arr[i] == arr[i - 1]) {
            cnt.back()++;
        } else {
            cnt.emplace_back(1);
        }
    }
    sort(allr(cnt));
    //print(cnt);
    while(k>0)
    {
        int mini=min(k,cnt.back());
        k-=mini;
        cnt.back()-=mini;
        if(cnt.back()==0) cnt.pop_back();
    }
    cout<<(int)cnt.size()<<endl;
}
int main()
{
    fastread();
    int t=1;
    cin>>t;
    while(t--)
    {
        accepted();
    }
    return 0;
}

Solution 2 (runtime: 186 ms):
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
typedef long long ll;
using namespace std;
inline int calc(vector<int>& arr) {
    if (arr.empty()) return 0;
    vector<int> temp = arr;
    int ops = 0;
    while (!temp.empty()) {
        int mv = *min_element(temp.begin(), temp.end());
        vector<int> a;
        for (int x:temp) if (x!=mv) a.push_back(x);
        temp = a;
        ops++;
    }
    return ops;
}
inline void solve() {
    int n, k; cin>>n>>k;
    map<int, int> freq;
    set<int> unique;
    for (int i=0; i<n; i++) {
        int x; cin>>x;
        freq[x]++;
        unique.insert(x);
    }
    vector<pair<int, int>> freqp;
    for (auto [num, c]:freq) freqp.push_back({c, num});
    sort(freqp.begin(), freqp.end());
    int d = unique.size();
    int usedK = 0;
    for (auto [c, num]:freqp) {
        if (usedK+c<=k) {
            d--;
            usedK+=c;
        }
    }
    cout<<max(1, d)<<'\n';
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int t; cin>>t;
    while (t--) solve();
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: c++17 

Solution 1 (runtime: 93 ms):
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;

#define ll long long
#define forn(i, s, n) for (int i = s; i < n; i++)
#define bforn(i, s) for (int i = s; i >= 0; i--)
// for pairs
#define s second
#define f first 
const int M = 2e5 + 1;
const char nl = '\n';

void solve(){
    ll l, r; cin >> l >> r;
    int k = 0;
    int at = 0;
    while (true) {
        if (r / (1 << at) == 0) {
            break;
        }
        if ((l >> at) % 2 != (r >> at) % 2) {
            k = at;
        }
        at++;
    }
    ll a = (l | ((1 << k) - 1));
    ll b = a + 1, c = (b == r) ? l : r;
    cout << a << ' ' << b << ' ' << c << nl;;
}
// if you are unsure of how to do a problem by hand
// the solution is most likely somewhat brute force (i.e binsearch)
// if input is limited to 0-9 or a-z, usually you will loop through all combinations
// of letters or numbers
// constructive problems : start with 1 when constructing
// :%y+ to copy all lines
// rearrange math expressions
// difference array? (a[i] - b[i])
// debugging : reread the problem statement-every word is important!
// debugging : print important variables!
// think brute force sol first
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t; cin >> t;
    for (int tt = 0; tt < t; tt++) solve();
}




Solution 2 (runtime: 62 ms):
#include <limits.h>
#include <math.h>
#include <stdio.h>

#include <algorithm>
#include <complex>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
typedef long long int lld;
typedef long double llf;
typedef pair<int, int> pii;

int lsb(int x) { return x & (-x); }

int msb(int x) {
  if (x == 0) {
    return 0;
  }
  while (lsb(x) < x) {
    x -= lsb(x);
  }
  return x;
}

// a ^ c = x, b ^ c = y
// => (a ^ b) + (a ^ c) + (b ^ c)
//    = (x ^ y) + x + y
// Note: if x = 1111111111, then y is irrelevant
void find_answer(int l, int r, int &a, int &b, int &c) {
  if (r == 0) {
    return;
  }
  int msbr = msb(r);

  if (msbr == msb(l)) {
    // All of them are going to have the msbr
    a += msbr;
    b += msbr;
    c += msbr;
    find_answer(l - msbr, r - msbr, a, b, c);
  } else {
    // a = 1000..., c = 01111..., b irrelevant
    a += msbr;
    c += msbr - 1;

    // b irrelevant but want to be different from a, c
    b += (msbr == r ? l : r);
  }
}

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

  int T;
  for (cin >> T; T; --T) {
    int l, r;
    cin >> l >> r;
    int a = 0, b = 0, c = 0;
    find_answer(l, r, a, b, c);

    cout << a << " " << b << " " << c << endl;
  }

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

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

#define ll long long

using namespace std;

int main()

{

    int t;

    cin>>t;

    while(t--){

        string s;

        cin>>s;

        ll sum=0;

        map<ll,ll>mp;

        for(auto i:s){

            sum+=(i-'0');

            if(i-'0'==2)mp[2]++;

            if(i-'0'==3)mp[3]++;

        }

        if(sum%9==0){

            cout<<"YES\n";

            continue;

        }

        int p=0;

       for(int i=0;i<=min(mp[2],8ll);i++){

           for(int j=0;j<=min(mp[3],20ll);j++){

              ll ans=0;

              ans=sum+(i*2+j*6);

              if(ans%9==0){

                  p=1;

                  break;

              }

           }

       }

        cout<<(p?"YES":"NO")<<"\n";

    }

    return 0;

}

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

using namespace std;



typedef long long ll;



#define what_is(x) cerr << "LOG: " << #x << " is " << x << endl;

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

#define ssort(v) sort(v.begin(), v.end())

#define rsort(v) sort(v.rbegin(), v.rend())



// const ll mod = 1000000007;

// const ll mod = 998244353;



void solve() {

    string s; cin >> s;



    int two = 0, three = 0;

    int sum = 0;



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

        if (s[i] == '2') two++;

        else if (s[i] == '3') three++;



        sum += (s[i] - '0');

    }



    bool gud = false;



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

        int temp = sum + i * 2;



        int res = temp % 9;



        if (res == 0){

            gud = true;

            break;

        }else if (res == 3){

            if (three > 0){

                gud = true;

                break;

            }

        }else if (res == 6){

            if (three > 1){

                gud = true;

                break;

            }

        }

    }



    cout << (gud ? "YES" : "NO") << endl;

}



int main() {

    //auto begin = std::chrono::high_resolution_clock::now();

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int t;

    cin >> t;

    while (t--) {

        solve();

    }

    //auto end = std::chrono::high_resolution_clock::now();

    //cerr << "\nTime taken: " << chrono::duration_cast<chrono::milliseconds>(end - begin).count() << "ms" << endl;

    return 0;

}