ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#define ll long long int
#define fr(i,j,n) for(i=j;i<n;i++)
#define srt(a) sort(a.begin(),a.end())
#define srtr(a) sort(a.begin(),a.end(),greater<ll>())
#define rvr(a) reverse(a.begin(),a.end())
#define rdp(a) a.resize(unique(a.begin(),a.end())-a.begin())
#define mxel(a) *max_element(a.begin(),a.end())
#define mnel(a) *min_element(a.begin(),a.end())
#define ve vector<ll>
#define vep vector<pair<ll,ll>>
#define vee vector<vector<ll>>
using namespace std;
template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (auto &i : v)
        is >> i;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v)
{
    for (auto &i : v)
        os << i << ' ';
    return os;
}
const ll M=998244353;
const ll N=4e5+2;
void solve()
{
    ll n;cin >> n;ve a(n);cin >> a;ll i,ans,an=-N;if(n==1) {cout << a[0] << endl;return;}
    while(n){
        ans=0;fr(i,0,n) ans+=a[i];an=max(an,ans);
        fr(i,0,n)a[i]=a[i+1]-a[i];
        if(n==1) if(ans<0) an=max(an,-ans);
        n--;
    }
    cout << an << endl;
}
int main()
{
    ll testcase=1;
    cin >> testcase;
    while(testcase--) solve();
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#define ll long long int
#define fr(i,j,n) for(i=j;i<n;i++)
#define srt(a) sort(a.begin(),a.end())
#define srtr(a) sort(a.begin(),a.end(),greater<ll>())
#define rvr(a) reverse(a.begin(),a.end())
#define rdp(a) a.resize(unique(a.begin(),a.end())-a.begin())
#define mxel(a) *max_element(a.begin(),a.end())
#define mnel(a) *min_element(a.begin(),a.end())
#define ve vector<ll>
#define vep vector<pair<ll,ll>>
#define vee vector<vector<ll>>
using namespace std;
template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (auto &i : v)
        is >> i;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v)
{
    for (auto &i : v)
        os << i << ' ';
    return os;
}
const ll M=998244353;
const ll N=4e5+2;
void solve()
{
    ll n;cin >> n;ve a(n);cin >> a;ll i,ans,an=-N;if(n==1) {cout << a[0] << endl;return;}
    while(n){
        ans=0;fr(i,0,n) ans+=a[i];
        if(n==1)an=max(an,ans);
        else an=max(an,max(ans,(-ans)));
        fr(i,0,n)a[i]=(a[i+1]-a[i]);
        //if(n==1) if(ans<0) an=max(an,-ans);
        n--;
    }
    cout << an << endl;
}
int main()
{
    ll testcase=1;
    cin >> testcase;
    while(testcase--) solve();
    return 0;
}


Submission (verdict: Accepted):
#include<bits/stdc++.h>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#define ll long long int
#define fr(i,j,n) for(i=j;i<n;i++)
#define srt(a) sort(a.begin(),a.end())
#define srtr(a) sort(a.begin(),a.end(),greater<ll>())
#define rvr(a) reverse(a.begin(),a.end())
#define rdp(a) a.resize(unique(a.begin(),a.end())-a.begin())
#define mxel(a) *max_element(a.begin(),a.end())
#define mnel(a) *min_element(a.begin(),a.end())
#define ve vector<ll>
#define vep vector<pair<ll,ll>>
#define vee vector<vector<ll>>
using namespace std;
template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (auto &i : v)
        is >> i;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v)
{
    for (auto &i : v)
        os << i << ' ';
    return os;
}
const ll M=998244353;
const ll N=4e5+2;
ll a[1010];
void solve()
{
    ll n,i;cin >> n;fr(i,1,n+1)cin >> a[i];ll j,k=n,ans,an=-N;//if(n==1) {cout << a[1] << endl;return;}
    fr(i,1,n+1){
        ans=0;fr(j,1,k+1) ans+=a[j];
        if(i==1)an=max(an,ans);
        else an=max(an,max(ans,(-ans)));
        fr(j,1,k)a[j]=(a[j+1]-a[j]);
        //if(n==1) if(ans<0) an=max(an,-ans);
        k--;
    }
    cout << an << endl;
}
int main()
{
    ll testcase=1;
    cin >> testcase;
    while(testcase--) solve();
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

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

#include<numeric>

#include<algorithm>

#include<cmath>

#include<iostream>

#include<string>

#include<vector>

#include<math.h>

#define ll long long int

#define fr(i,j,n) for(i=j;i<n;i++)

#define srt(a) sort(a.begin(),a.end())

#define srtr(a) sort(a.begin(),a.end(),greater<ll>())

#define rvr(a) reverse(a.begin(),a.end())

#define rdp(a) a.resize(unique(a.begin(),a.end())-a.begin())

#define mxel(a) *max_element(a.begin(),a.end())

#define mnel(a) *min_element(a.begin(),a.end())

#define ve vector<ll>

#define vep vector<pair<ll,ll>>

#define vee vector<vector<ll>>

using namespace std;

const ll M=998244353;

const ll N=4e5+2;

void solve()

{

    ll n,l,r,i;cin >> n >> l >> r;ve a(n),b,c;fr(i,0,n) cin >> a[i];b=a;

    sort(b.begin(),b.begin()+r);ll a1=accumulate(b.begin(),b.begin()+r-l+1,0);b=a;

    sort(b.begin()+l-1,b.end());ll a2=accumulate(b.begin()+l-1,b.begin()+r,0);

    //ll a1,a2;fr(i,0,r) b.push_back(a[i]);fr(i,l-1,n) c.push_back(a[i]);srt(b);srt(c);

    //a1=accumulate(b.begin(),b.begin()+r-l+1,0);a2=accumulate(c.begin(),c.begin()+r-l+1,0);

    cout << (a1<a2?a1:a2) << endl;

}

int main()

{

    ll testcase=1;

    cin >> testcase;

    while(testcase--) solve();

    return 0;

}



Submission (verdict: Accepted):
#include<bits/stdc++.h>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#define ll long long int
#define fr(i,j,n) for(i=j;i<n;i++)
#define srt(a) sort(a.begin(),a.end())
#define srtr(a) sort(a.begin(),a.end(),greater<ll>())
#define rvr(a) reverse(a.begin(),a.end())
#define rdp(a) a.resize(unique(a.begin(),a.end())-a.begin())
#define mxel(a) *max_element(a.begin(),a.end())
#define mnel(a) *min_element(a.begin(),a.end())
#define ve vector<ll>
#define vep vector<pair<ll,ll>>
#define vee vector<vector<ll>>
using namespace std;
const ll M=998244353;
const ll N=4e5+2;
void solve()
{
    ll n,l,r,i;cin >> n >> l >> r;ll a[n],b[n],c;fr(i,0,n) {cin >> a[i];b[i]=a[i];}
    sort(b,b+r);ll a1=0;fr(i,0,r-l+1) a1+=b[i];
    sort(a+l-1,a+n);ll a2=0;fr(i,l-1,r) a2+=a[i];
    cout << min(a1,a2) << endl;
}
int main()
{
    ll testcase=1;
    cin >> testcase;
    while(testcase--) solve();
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

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

#include<numeric>

#include<algorithm>

#include<cmath>

#include<iostream>

#include<string>

#include<vector>

#include<math.h>

#define ll long long int

#define fr(i,j,n) for(i=j;i<n;i++)

#define srt(a) sort(a.begin(),a.end())

#define srtr(a) sort(a.begin(),a.end(),greater<ll>())

#define rvr(a) reverse(a.begin(),a.end())

#define rdp(a) a.resize(unique(a.begin(),a.end())-a.begin())

#define mxel(a) *max_element(a.begin(),a.end())

#define mnel(a) *min_element(a.begin(),a.end())

#define ve vector<ll>

#define vep vector<pair<ll,ll>>

#define vee vector<vector<ll>>

using namespace std;

const ll M=998244353;

const ll N=4e5+2;

void solve()

{

    ll n,l,r,i;cin >> n >> l >> r;ve a(n),b,c;fr(i,0,n) cin >> a[i];

    ll ans=0,a1=0,a2=0;fr(i,0,r) b.push_back(a[i]);fr(i,l-1,n) c.push_back(a[i]);srt(b);srt(c);

    a1=accumulate(b.begin(),b.begin()+r-l+1,0);a2=accumulate(c.begin(),c.begin()+r-l+1,0);

    cout << (a1<a2?a1:a2) << endl;

}

int main()

{

    ll testcase=1;

    cin >> testcase;

    while(testcase--) solve();

    return 0;

}



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

#include<numeric>

#include<algorithm>

#include<cmath>

#include<iostream>

#include<string>

#include<vector>

#include<math.h>

#define ll long long int

#define fr(i,j,n) for(i=j;i<n;i++)

#define srt(a) sort(a.begin(),a.end())

#define srtr(a) sort(a.begin(),a.end(),greater<ll>())

#define rvr(a) reverse(a.begin(),a.end())

#define rdp(a) a.resize(unique(a.begin(),a.end())-a.begin())

#define mxel(a) *max_element(a.begin(),a.end())

#define mnel(a) *min_element(a.begin(),a.end())

#define ve vector<ll>

#define vep vector<pair<ll,ll>>

#define vee vector<vector<ll>>

using namespace std;

const ll M=998244353;

const ll N=4e5+2;

void solve()

{

    ll n,l,r,i;cin >> n >> l >> r;ve a(n),b,c;fr(i,0,n) cin >> a[i];b=a;

    sort(b.begin(),b.begin()+r);ll a1=accumulate(b.begin(),b.begin()+r-l+1,0);b=a;

    sort(b.begin()+l-1,b.end());ll a2=accumulate(b.begin()+l-1,b.begin()+r,0);

    //ll a1,a2;fr(i,0,r) b.push_back(a[i]);fr(i,l-1,n) c.push_back(a[i]);srt(b);srt(c);

    //a1=accumulate(b.begin(),b.begin()+r-l+1,0);a2=accumulate(c.begin(),c.begin()+r-l+1,0);

    cout << (a1<a2?a1:a2) << endl;

}

int main()

{

    ll testcase=1;

    cin >> testcase;

    while(testcase--) solve();

    return 0;

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


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#define ll long long int
#define fr(i,j,n) for(i=j;i<n;i++)
#define srt(a) sort(a.begin(),a.end())
#define srtr(a) sort(a.begin(),a.end(),greater<ll>())
#define rvr(a) reverse(a.begin(),a.end())
#define rdp(a) a.resize(unique(a.begin(),a.end())-a.begin())
#define mxel(a) *max_element(a.begin(),a.end())
#define mnel(a) *min_element(a.begin(),a.end())
#define ve vector<ll>
#define vep vector<pair<ll,ll>>
#define vee vector<vector<ll>>
using namespace std;
const ll M=998244353;
const ll N=4e5+2;
void solve()
{
    ll n,l,r,i;cin >> n >> l >> r;ve a(n);fr(i,0,n) cin >> a[i];srt(a);ll ans=0;
    fr(i,0,r-l+1) ans+=a[i];cout << ans << endl;
}
int main()
{
    ll testcase=1;
    cin >> testcase;
    while(testcase--) solve();
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#define ll long long int
#define fr(i,j,n) for(i=j;i<n;i++)
#define srt(a) sort(a.begin(),a.end())
#define srtr(a) sort(a.begin(),a.end(),greater<ll>())
#define rvr(a) reverse(a.begin(),a.end())
#define rdp(a) a.resize(unique(a.begin(),a.end())-a.begin())
#define mxel(a) *max_element(a.begin(),a.end())
#define mnel(a) *min_element(a.begin(),a.end())
#define ve vector<ll>
#define vep vector<pair<ll,ll>>
#define vee vector<vector<ll>>
using namespace std;
const ll M=998244353;
const ll N=4e5+2;
void solve()
{
    ll n,l,r,i;cin >> n >> l >> r;ve a(n);fr(i,0,n) cin >> a[i];srt(a);ll ans=0;
    fr(i,0,r-l+1) ans+=a[i];cout << ans << endl;
}
int main()
{
    ll testcase=1;
    cin >> testcase;
    while(testcase--) solve();
    return 0;
}


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

#include<numeric>

#include<algorithm>

#include<cmath>

#include<iostream>

#include<string>

#include<vector>

#include<math.h>

#define ll long long int

#define fr(i,j,n) for(i=j;i<n;i++)

#define srt(a) sort(a.begin(),a.end())

#define srtr(a) sort(a.begin(),a.end(),greater<ll>())

#define rvr(a) reverse(a.begin(),a.end())

#define rdp(a) a.resize(unique(a.begin(),a.end())-a.begin())

#define mxel(a) *max_element(a.begin(),a.end())

#define mnel(a) *min_element(a.begin(),a.end())

#define ve vector<ll>

#define vep vector<pair<ll,ll>>

#define vee vector<vector<ll>>

using namespace std;

const ll M=998244353;

const ll N=4e5+2;

void solve()

{

    ll n,l,r,i;cin >> n >> l >> r;ve a(n),b,c;fr(i,0,n) cin >> a[i];

    ll ans=0,a1=0,a2=0;fr(i,0,r) b.push_back(a[i]);fr(i,l-1,n) c.push_back(a[i]);srt(b);srt(c);

    a1=accumulate(b.begin(),b.begin()+r-l+1,0);a2=accumulate(c.begin(),c.begin()+r-l+1,0);

    cout << (a1<a2?a1:a2) << endl;

}

int main()

{

    ll testcase=1;

    cin >> testcase;

    while(testcase--) solve();

    return 0;

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

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#define getbit(x,y) ((x>>y)&1)
using namespace std;
int main(){ 
	int t;
	cin>>t;
	while(t--){
		int l,r;
		cin>>l>>r;
		int now = 0;
		for(int i=30;i>=0;i--){
			if(getbit(l,i)!=getbit(r,i)){
				int x,y;
				x = 1<<i; 
				y = x-1;
				cout<<x+now<<' '<<y+now<<' ';
				if(x==r) cout<<x-2+now<<'\n';
				else cout<<x+1+now<<'\n';
				break;
			}
			if(getbit(l,i)) now += 1<<i; 
		}
	}
}

Submission (verdict: Wrong answer on test 2):
#include<iostream>
#define getbit(x,y) ((x>>y)&1)
using namespace std;
int main(){ 
	int t;
	cin>>t;
	while(t--){
		long long l,r;
		cin>>l>>r;
		long long now = 0;
		for(int i=30;i>=0;i--){
			if(getbit(l,i)!=getbit(r,i)){
				long long x,y;
				x = 1<<i; 
				y = x-1;
				cout<<x+now<<' '<<y+now<<' ';
				if(x==r) cout<<x-2+now<<'\n';
				else cout<<x+1+now<<'\n';
				break;
			}
			if(getbit(l,i)) now += 1<<i; 
		}
	}
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#define getbit(x,y) ((x>>y)&1)
using namespace std;
int main(){ 
	int t;
	cin>>t;
	while(t--){
		int l,r;
		cin>>l>>r;
		for(int i=30;i>=0;i--){
			if(getbit(l,i)!=getbit(r,i)){
				int x,y;
				x = 1<<i; 
				y = x-1;
				cout<<x<<' '<<y<<' ';
				if(x==r) cout<<x-2<<'\n';
				else cout<<x+1<<'\n';
				break;
			}
		}
	}
}

Submission (verdict: Wrong answer on test 2):
#include<iostream>
#define getbit(x,y) ((x>>y)&1)
using namespace std;
int main(){ 
	int t;
	cin>>t;
	while(t--){
		int l,r;
		cin>>l>>r;
		int now = 0;
		for(int i=30;i>=0;i--){
			if(getbit(l,i)!=getbit(r,i)){
				int x,y;
				x = 1<<i; 
				y = x-1;
				cout<<x+now<<' '<<y+now<<' ';
				if(x==r) cout<<x-2+now<<'\n';
				else cout<<x+1+now<<'\n';
				break;
			}
			if(getbit(l,i)) now += 1<<i; 
		}
	}
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#define getbit(x,y) ((x>>y)&1)
using namespace std;
int main(){ 
	int t;
	cin>>t;
	while(t--){
		int l,r;
		cin>>l>>r;
		for(int i=30;i>=0;i--){
			if(getbit(l,i)!=getbit(r,i)){
				int x,y;
				x = 1<<i; 
				y = x-1;
				cout<<x<<' '<<y<<' ';
				if(x==r) cout<<r-2<<'\n';
				else cout<<r+1<<'\n';
				break;
			}
		}
	}
}

Submission (verdict: Wrong answer on test 1):
#include<iostream>
#define getbit(x,y) ((x>>y)&1)
using namespace std;
int main(){ 
	int t;
	cin>>t;
	while(t--){
		int l,r;
		cin>>l>>r;
		for(int i=30;i>=0;i--){
			if(getbit(l,i)!=getbit(r,i)){
				int x,y;
				x = 1<<i; 
				y = x-1;
				cout<<x<<' '<<y<<' ';
				if(x==r) cout<<x-2<<'\n';
				else cout<<x+1<<'\n';
				break;
			}
		}
	}
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#define getbit(x,y) ((x>>y)&1)
using namespace std;
int main(){ 
	int t;
	cin>>t;
	while(t--){
		long long l,r;
		cin>>l>>r;
		long long now = 0;
		for(int i=30;i>=0;i--){
			if(getbit(l,i)!=getbit(r,i)){
				long long x,y;
				x = 1<<i; 
				y = x-1;
				cout<<x+now<<' '<<y+now<<' ';
				if(x==r) cout<<x-2+now<<'\n';
				else cout<<x+1+now<<'\n';
				break;
			}
			if(getbit(l,i)) now += 1<<i; 
		}
	}
}

Submission (verdict: Accepted):
#include<iostream>
#define ll long long
#define getbit(x,y) ((x>>y)&1)
using namespace std;
int main() {
	int t;
	cin>>t;
	while(t--){
		ll l,r,now=0;
		cin>>l>>r;
		for(ll i=30;i>=0;i--) {
			if(getbit(l,i)!=getbit(r,i)) {
				ll x=(1ll<<i)-1,y=0;
				x+=now,y+=now+(1ll<<i);
				printf("%lld %lld ",x,y);
				if(x!=l&&y!=l) printf("%lld\n",l);
				else printf("%lld\n",r);
				break; 
			}
		now+=getbit(l,i)?(1ll<<i):0;
		}
	}
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include<iostream>
#define getbit(x,y) ((x>>y)&1)
using namespace std;
int main(){ 
	int t;
	cin>>t;
	while(t--){
		int l,r;
		cin>>l>>r;
		for(int i=30;i>=0;i--){
			if(getbit(l,i)!=getbit(r,i)){
				int x,y;
				x = 1<<i; 
				y = x-1;
				cout<<x<<' '<<y<<' ';
				if(x==r) cout<<r-2<<'\n';
				else cout<<r+1<<'\n';
				break;
			}
		}
	}
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<queue>
using namespace std;
int main(){
	int t;
	cin>>t;
	while(t--){
		priority_queue<int> q;
		priority_queue<int> Q;	
		int n,m;
		cin>>n>>m;
		for(int i=0;i<n;i++){
			int a;
			cin>>a;
			q.push(a);	
		}
		for(int i=0;i<m;i++){
			int b;
			cin>>b;
			Q.push(b);
		}
		while(1){
			if(m>n){
				cout<<"No"<<'\n';
				break;
			}
			if(Q.empty() and !q.empty()){
				cout<<"No"<<'\n';
				break;
			}
			if(q.empty() and Q.empty()){
				cout<<"Yes"<<'\n';
				break;
			}
			int a = q.top();
			int b = Q.top();
			cout<<a<<' '<<b<<'\n';
			if(a==b){
				q.pop();
				Q.pop();
				n--;
				m--;
			}
			if(b>a){
				Q.pop();
				Q.push(b/2);
				Q.push((b+1)/2);
				m--;
				m+=2;
			}
			if(b<a){
				cout<<"No"<<'\n';
				break;
			}
		}
	}
} 

Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<queue>
using namespace std;
int main(){
	int t;
	cin>>t;
	while(t--){
		priority_queue<int> q;
		priority_queue<int> Q;	
		int n,m;
		cin>>n>>m;
		for(int i=0;i<n;i++){
			int a;
			cin>>a;
			q.push(a);	
		}
		for(int i=0;i<m;i++){
			int b;
			cin>>b;
			Q.push(b);
		}
		while(1){
			if(m>n){
				cout<<"No"<<'\n';
				break;
			}
			if(Q.empty() and !q.empty()){
				cout<<"No"<<'\n';
				break;
			}
			if(q.empty() and Q.empty()){
				cout<<"Yes"<<'\n';
				break;
			}
			int a = q.top();
			int b = Q.top();
			cout<<a<<' '<<b<<'\n';
			if(a==b){
				q.pop();
				Q.pop();
				n--;
				m--;
			}
			if(b>a){
				Q.pop();
				Q.push(b/2);
				Q.push(b-b/2);
				m--;
				m+=2;
			}
			if(b<a){
				cout<<"No"<<'\n';
				break;
			}
		}
	}
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<queue>
using namespace std;
int main(){
	int t;
	cin>>t;
	while(t--){
		priority_queue<int> q;
		priority_queue<int> Q;	
		int n,m;
		cin>>n>>m;
		for(int i=0;i<n;i++){
			int a;
			cin>>a;
			q.push(a);	
		}
		for(int i=0;i<m;i++){
			int b;
			cin>>b;
			Q.push(b);
		}
		while(1){
			if(m>n){
				cout<<"No"<<'\n';
				break;
			}
			if(Q.empty() and !q.empty()){
				cout<<"No"<<'\n';
				break;
			}
			if(q.empty() and Q.empty()){
				cout<<"Yes"<<'\n';
				break;
			}
			int a = q.top();
			int b = Q.top();
			cout<<a<<' '<<b<<'\n';
			if(a==b){
				q.pop();
				Q.pop();
				n--;
				m--;
			}
			if(b>a){
				Q.pop();
				Q.push(b/2);
				Q.push((b+1)/2);
				m--;
				m+=2;
			}
			if(b<a){
				cout<<"No"<<'\n';
				break;
			}
		}
	}
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<queue>
using namespace std;
int main(){
	int t;
	cin>>t;
	while(t--){
		priority_queue<int> q;
		priority_queue<int> Q;	
		int n,m;
		cin>>n>>m;
		for(int i=0;i<n;i++){
			int a;
			cin>>a;
			q.push(a);	
		}
		for(int i=0;i<m;i++){
			int b;
			cin>>b;
			Q.push(b);
		}
		while(1){
			if(m>n){
				cout<<"No"<<'\n';
				break;
			}
			if(Q.empty() and !q.empty()){
				cout<<"No"<<'\n';
				break;
			}
			if(q.empty() and Q.empty()){
				cout<<"Yes"<<'\n';
				break;
			}
			int a = q.top();
			int b = Q.top();
			cout<<a<<' '<<b<<'\n';
			if(a==b){
				q.pop();
				Q.pop();
				n--;
				m--;
			}
			if(b>a){
				Q.pop();
				Q.push(b/2);
				Q.push(b-b/2);
				m--;
				m+=2;
			}
			if(b<a){
				cout<<"No"<<'\n';
				break;
			}
		}
	}
} 

Submission (verdict: Accepted):
#include<iostream>
#include<queue>
using namespace std;
int main(){
	int t;
	cin>>t;
	while(t--){
		priority_queue<int> q;
		priority_queue<int> Q;	
		int n,m;
		cin>>n>>m;
		for(int i=0;i<n;i++){
			int a;
			cin>>a;
			q.push(a);	
		}
		for(int i=0;i<m;i++){
			int b;
			cin>>b;
			Q.push(b);
		}
		while(1){
			if(m>n){
				cout<<"No"<<'\n';
				break;
			}
			if(Q.empty() and !q.empty()){
				cout<<"No"<<'\n';
				break;
			}
			if(q.empty() and Q.empty()){
				cout<<"Yes"<<'\n';
				break;
			}
			int a = q.top();
			int b = Q.top();
			//cout<<a<<' '<<b<<'\n';
			if(a==b){
				q.pop();
				Q.pop();
				n--;
				m--;
			}
			if(b>a){
				Q.pop();
				Q.push(b/2);
				Q.push(b-b/2);
				m--;
				m+=2;
			}
			if(b<a){
				cout<<"No"<<'\n';
				break;
			}
		}
	}
}
Problem: 2050D - Digital string maximization
Language: Java 21

Previous submission (verdict: Time limit exceeded on test 7):
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc=new Scanner(System.in);

        int t=sc.nextInt();

        while(t-- >0){

          String str=sc.next();

          int n=str.length(); 

          int arr[]=new int[n];

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

              arr[i]=str.charAt(i)-'0';

          }

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

              int idx=i;

              while(arr[idx]>0 && arr[idx]>arr[idx-1]+1){

                  int temp=arr[idx];

                  arr[idx]=arr[idx-1];

                  arr[idx-1]=temp-1;

                  if(idx>1){

                      idx--;

                  }else{

                      break;

                  }

              }

          }

          String s="";

          for(int a: arr){

              s+=a;

          }

          System.out.println(s);

        }

    }

}

Submission (verdict: Time limit exceeded on test 7):
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc=new Scanner(System.in);

        int t=sc.nextInt();

        while(t-- >0){

          String str=sc.next();

          int n=str.length(); 

          int arr[]=new int[n];

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

              arr[i]=str.charAt(i)-'0';

          }

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

              int idx=i;

              while(idx>=1&&arr[idx]>0&&arr[idx]>arr[idx-1]+1){

                  int temp=arr[idx];

                  arr[idx]=arr[idx-1];

                  arr[idx-1]=temp-1;

                  if(idx>1){

                      idx--;

                  }else{

                      break;

                  }

              }

          }

          String s="";

          for(int a: arr){

              s+=a;

          }

          System.out.println(s);

        }

    }

}