ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long 
#define nah_id_win ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define pll pair<ll, ll>
using namespace std;
const ll MAXN=1e5+5;
vector<ll> edge[MAXN];

void solve(){
    ll n; cin >> n;
    ll u, v;
    map<pll,bool> ril;
    for(int i=0; i<n-1; i++){
        cin >> u >> v;
        edge[u].push_back(v);
        edge[v].push_back(u);
        ril[{u,v}]=1;
        ril[{v,u}]=1;
    }

    vector<pll> degree(n+1);
    for(int i=1; i<=n; i++){
        ril[{i,i}]=1;
        degree[i].fi=edge[i].size();
        degree[i].se=i;
    }
    sort(degree.begin(), degree.end(), greater<pll>());
    
    ll ans=0, temp, mx;
    for(int i=1; i<=n; i++){
        temp=edge[i].size();
        // cout << temp << endl;
        mx=0;
        for(int j=0; j<n; j++){
            if(!ril[{i, degree[j].se}]){
                // cout << "AWI" << endl;
                temp+=degree[j].fi-1;
                break;
            }else if(i!=degree[j].se && degree[j].fi-1==0){
                // cout << "WOK" << endl;
                temp--;
                break;
            }
        }
        // cout << temp << endl;
        ans=max(ans, temp);
    }
    cout << ans << endl;

    for(int i=1; i<=n; i++)
        edge[i].clear();
}
 
int main(){
    nah_id_win;
    // pre();
    ll t=1;
    cin >> t;
    while(t--) 
        solve();
}

Submission (verdict: Runtime error on test 7):
#include <bits/stdc++.h>
#define ll long long 
#define nah_id_win ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define pll pair<ll, ll>
using namespace std;
const ll MAXN=1e5+5;
vector<ll> edge[MAXN];

void solve(){
    ll n; cin >> n;
    ll u, v;
    map<pll,bool> ril;
    for(int i=0; i<n-1; i++){
        cin >> u >> v;
        edge[u].push_back(v);
        edge[v].push_back(u);
        ril[{u,v}]=1;
        ril[{v,u}]=1;
    }

    vector<pll> degree(n+1);
    for(int i=1; i<=n; i++){
        ril[{i,i}]=1;
        degree[i].fi=edge[i].size();
        degree[i].se=i;
    }
    sort(degree.begin(), degree.end(), greater<pll>());
    
    ll ans=0, temp, mx;
    for(int i=1; i<=n; i++){
        temp=edge[i].size();
        // cout << temp << endl;
        mx=-1;
        for(int j=0; j<n; j++){
            if(!ril[{i, degree[j].se}]){
                // cout << "AWI" << endl;
                mx=max(mx, degree[j].fi-1);
                break;
            }else if(i!=degree[j].se){
                // tru=1;
                // cout << "FR" << endl;
                mx=max(mx, max(-1LL, degree[j].fi-2));
            }
        }
        // cout << mx << endl;
        ans=max(ans, temp+mx);
    }
    cout << ans << endl;

    for(int i=1; i<=n; i++)
        edge[i].clear();
}
 
int main(){
    nah_id_win;
    // pre();
    ll t=1;
    cin >> t;
    while(t--) 
        solve();
}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Runtime error on test 7):
#include <bits/stdc++.h>
#define ll long long 
#define nah_id_win ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define pll pair<ll, ll>
using namespace std;
const ll MAXN=1e5+5;
vector<ll> edge[MAXN];

void solve(){
    ll n; cin >> n;
    ll u, v;
    map<pll,bool> ril;
    for(int i=0; i<n-1; i++){
        cin >> u >> v;
        edge[u].push_back(v);
        edge[v].push_back(u);
        ril[{u,v}]=1;
        ril[{v,u}]=1;
    }

    vector<pll> degree(n+1);
    for(int i=1; i<=n; i++){
        ril[{i,i}]=1;
        degree[i].fi=edge[i].size();
        degree[i].se=i;
    }
    sort(degree.begin(), degree.end(), greater<pll>());
    
    ll ans=0, temp, mx;
    for(int i=1; i<=n; i++){
        temp=edge[i].size();
        // cout << temp << endl;
        mx=-1;
        for(int j=0; j<n; j++){
            if(!ril[{i, degree[j].se}]){
                // cout << "AWI" << endl;
                mx=max(mx, degree[j].fi-1);
                break;
            }else if(i!=degree[j].se){
                // tru=1;
                // cout << "FR" << endl;
                mx=max(mx, max(-1LL, degree[j].fi-2));
            }
        }
        // cout << mx << endl;
        ans=max(ans, temp+mx);
    }
    cout << ans << endl;

    for(int i=1; i<=n; i++)
        edge[i].clear();
}
 
int main(){
    nah_id_win;
    // pre();
    ll t=1;
    cin >> t;
    while(t--) 
        solve();
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define ll long long 
#define nah_id_win ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define pll pair<ll, ll>
using namespace std;
const ll MAXN=2e5+5;
vector<ll> edge[MAXN];

void solve(){
    ll n; cin >> n;
    ll u, v;
    map<pll,bool> ril;
    for(int i=0; i<n-1; i++){
        cin >> u >> v;
        edge[u].push_back(v);
        edge[v].push_back(u);
        ril[{u,v}]=1;
        ril[{v,u}]=1;
    }

    vector<pll> degree(n+1);
    for(int i=1; i<=n; i++){
        ril[{i,i}]=1;
        degree[i].fi=edge[i].size();
        degree[i].se=i;
    }
    sort(degree.begin(), degree.end(), greater<pll>());
    
    ll ans=0, temp, mx;
    for(int i=1; i<=n; i++){
        temp=edge[i].size();
        // cout << temp << endl;
        mx=-1;
        for(int j=0; j<n; j++){
            if(!ril[{i, degree[j].se}]){
                // cout << "AWI" << endl;
                mx=max(mx, degree[j].fi-1);
                break;
            }else if(i!=degree[j].se){
                // tru=1;
                // cout << "FR" << endl;
                mx=max(mx, max(-1LL, degree[j].fi-2));
            }
        }
        // cout << mx << endl;
        ans=max(ans, temp+mx);
    }
    cout << ans << endl;

    for(int i=1; i<=n; i++)
        edge[i].clear();
}
 
int main(){
    nah_id_win;
    // pre();
    ll t=1;
    cin >> t;
    while(t--) 
        solve();
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;

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

    int t;
    cin >> t;
    while (t--) {
        long long l, r;
        cin >> l >> r;

        long long m = 0;
        if (r > 0) {
            m = 31 - __builtin_clzll(r^l);
        }
        long long a = (1LL << m);
        if (a > r || a < l) {
            a = r;
        }
        long long b = (a - 1);
        if (b < l) {
            b = r - 1;
        }
        if (b == a) {
            b = a - 1;
        }
        long long c = l;
        if (c == a || c == b) {
            c = l + 1;
            if (c == a || c == b) c++;
        }

        cout << a << " " << b << " " << c << "\n";
    }
    return 0;
}

Submission (verdict: Accepted):
#include <iostream>

using namespace std;
using ll = long long;

void solve(){
    ll a=0,b=0,c=0;
    ll l,r;
    ll ans = 0;
    cin >> l >> r;
    for(int i=31;i>=0;i--){
        int b1 = 0, 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;
}

int main(){
    int t = 1;
    cin >> t;
    while(t--) solve();
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <math.h>
#define endl '\n'
using namespace std;
using ll = long long;
void solve(){
    ll l,r;
    cin >> l  >> r;
    int k = (int)log2(r);
    cout << (1<<k) << " " << (1<<k)-1 << " " << l << endl;
}

int main(){
    int t = 1;
    cin >> t;
    while(t--) solve();
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;

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

    int t;
    cin >> t;
    while (t--) {
        long long l, r;
        cin >> l >> r;

        long long m = 0;
        if (r > 0) {
            m = 63 - __builtin_clzll(r);
        }
        long long a = (1LL << m);
        if (a > r || a < l) {
            a = r;
        }
        long long b = (a - 1);
        if (b < l) {
            b = r - 1;
        }
        if (b == a) {
            b = a - 1;
        }
        long long c = l;
        if (c == a || c == b) {
            c = l + 1;
            if (c == a || c == b) c++;
        }

        cout << a << " " << b << " " << c << "\n";
    }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;

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

    int t;
    cin >> t;
    while (t--) {
        long long l, r;
        cin >> l >> r;

        long long m = 0;
        if (r > 0) {
            m = 31 - __builtin_clzll(r^l);
        }
        long long a = (1LL << m);
        if (a > r || a < l) {
            a = r;
        }
        long long b = (a - 1);
        if (b < l) {
            b = r - 1;
        }
        if (b == a) {
            b = a - 1;
        }
        long long c = l;
        if (c == a || c == b) {
            c = l + 1;
            if (c == a || c == b) c++;
        }

        cout << a << " " << b << " " << c << "\n";
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <math.h>
#define endl '\n'
using namespace std;
using ll = long long;
void solve(){
    ll l,r;
    cin >> l  >> r;
    int k = (int)log2(r);
    cout << (1<<k) << " " << (1<<k)-1 << " " << l << endl;
}

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

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;

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

    int t;
    cin >> t;
    while (t--) {
        long long l, r;
        cin >> l >> r;

        long long m = 0;
        if (r > 0) {
            m = 63 - __builtin_clzll(r);
        }
        long long a = (1LL << m);
        if (a > r || a < l) {
            a = r;
        }
        long long b = (a - 1);
        if (b < l) {
            b = r - 1;
        }
        if (b == a) {
            b = a - 1;
        }
        long long c = l;
        if (c == a || c == b) {
            c = l + 1;
            if (c == a || c == b) c++;
        }

        cout << a << " " << b << " " << c << "\n";
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=100010;
void solve()
{
    int flag=1;
    int n;cin>>n;
    int ans=INT_MIN;
    int sum=0;
    vector<vector<int>> a(2);
    for (int i=0;i<n;i++) 
    {
        int x;cin>>x;
        sum+=x;
        a[0].push_back(x);
    }
    if (n==1)
    {
        cout<<sum<<endl;
        return;
    }
    ans=max(ans,abs(sum));
    for (int i=0;i<n-1;i++)
    {
        int sum=0;
        flag++;
        int x=flag%2;
        for (int i=1;i<a[x].size();i++)
        {
            // cout<<a[x][i]<<endl<<a[x][i-1];
            a[1-x].push_back(a[x][i]-a[x][i-1]);
            sum+=a[x][i]-a[x][i-1];
        }
        // cout<<a[x][i]<<endl<<a[x][i-1];
        ans=max(ans,abs(sum));
        a[x].clear();
    }
    flag++;
    int x=flag%2;
    cout<<ans<<endl;
}

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

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=100010;
void solve()
{
    int flag=1;
    int n;cin>>n;
    int ans=INT_MIN;
    int sum=0;
    vector<vector<int>> a(2);
    for (int i=0;i<n;i++) 
    {
        int x;cin>>x;
        sum+=x;
        a[0].push_back(x);
    }
    if (n==1)
    {
        cout<<sum<<endl;
        return;
    }
    ans=max(ans,sum);
    for (int i=0;i<n-1;i++)
    {
        int sum=0;
        flag++;
        int x=flag%2;
        for (int i=1;i<a[x].size();i++)
        {
            // cout<<a[x][i]<<endl<<a[x][i-1];
            a[1-x].push_back(a[x][i]-a[x][i-1]);
            sum+=a[x][i]-a[x][i-1];
        }
        // cout<<a[x][i]<<endl<<a[x][i-1];
        ans=max(ans,abs(sum));
        a[x].clear();
    }
    cout<<ans<<endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    cin>>t;
    while (t--)
    {
        solve();
    }
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=100010;
void solve()
{
    int flag=1;
    int n;cin>>n;
    int ans=INT_MIN;
    int sum=0;
    vector<vector<int>> a(2);
    for (int i=0;i<n;i++) 
    {
        int x;cin>>x;
        sum+=x;
        a[0].push_back(x);
    }
    ans=max(ans,abs(sum));
    for (int i=0;i<n-1;i++)
    {
        int sum=0;
        flag++;
        int x=flag%2;
        for (int i=1;i<a[x].size();i++)
        {
            // cout<<a[x][i]<<endl<<a[x][i-1];
            a[1-x].push_back(a[x][i]-a[x][i-1]);
            sum+=a[x][i]-a[x][i-1];
        }
        // cout<<a[x][i]<<endl<<a[x][i-1];
        ans=max(ans,abs(sum));
        a[x].clear();
    }
    flag++;
    int x=flag%2;
    cout<<ans<<endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    cin>>t;
    while (t--)
    {
        solve();
    }
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=100010;
void solve()
{
    int flag=1;
    int n;cin>>n;
    int ans=INT_MIN;
    int sum=0;
    vector<vector<int>> a(2);
    for (int i=0;i<n;i++) 
    {
        int x;cin>>x;
        sum+=x;
        a[0].push_back(x);
    }
    ans=max(ans,abs(sum));
    for (int i=0;i<n-1;i++)
    {
        int sum=0;
        flag++;
        int x=flag%2;
        for (int i=1;i<a[x].size();i++)
        {
            // cout<<a[x][i]<<endl<<a[x][i-1];
            a[1-x].push_back(a[x][i]-a[x][i-1]);
            sum+=a[x][i]-a[x][i-1];
        }
        // cout<<a[x][i]<<endl<<a[x][i-1];
        ans=max(ans,abs(sum));
        a[x].clear();
    }
    flag++;
    int x=flag%2;
    cout<<ans<<endl;
}

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

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=100010;
void solve()
{
    int flag=1;
    int n;cin>>n;
    int ans=INT_MIN;
    int sum=0;
    vector<vector<int>> a(2);
    for (int i=0;i<n;i++) 
    {
        int x;cin>>x;
        sum+=x;
        a[0].push_back(x);
    }
    if (n==1)
    {
        cout<<sum<<endl;
        return;
    }
    ans=max(ans,abs(sum));
    for (int i=0;i<n-1;i++)
    {
        int sum=0;
        flag++;
        int x=flag%2;
        for (int i=1;i<a[x].size();i++)
        {
            // cout<<a[x][i]<<endl<<a[x][i-1];
            a[1-x].push_back(a[x][i]-a[x][i-1]);
            sum+=a[x][i]-a[x][i-1];
        }
        // cout<<a[x][i]<<endl<<a[x][i-1];
        ans=max(ans,abs(sum));
        a[x].clear();
    }
    flag++;
    int x=flag%2;
    cout<<ans<<endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    cin>>t;
    while (t--)
    {
        solve();
    }
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 7):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void solve() {
    int n, m;
    multiset<int> a, b;

    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a.insert(x);
    }
    for (int i = 0; i < m; i++) {
        int x;
        cin >> x;
        if (a.count(x)) a.extract(x);
        else b.insert(x);
    }

    int loop = (int) a.size() - (int) b.size();
    for (int i = 0; i < loop; i++) {
        if (b.empty() || a.empty()) {
            cout << "No\n";
            return;
        }

        int B = *b.rbegin();
        int A = *a.rbegin();

        if (A > B) {
            cout << "No\n";
            return;
        }

        b.extract(B);

        int b1 = B / 2;
        if (a.count(b1)) a.extract(b1);
        else b.insert(b1);

        b1 = B + 1 >> 1;
        if (a.count(b1)) a.extract(b1);
        else b.insert(b1);
    }

    while (!a.empty() && !b.empty()) {
        if (*a.rbegin() == *b.rbegin()) {
            a.extract(*a.rbegin());
            b.extract(*b.rbegin());
        } else {
            break;
        }
    }

    if (!a.empty() || !b.empty()) cout << "No\n";
    else cout << "Yes\n";
}

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

    int tc = 1;
    cin >> tc;

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

    return 0;
}



Submission (verdict: Time limit exceeded on test 7):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void solve() {
    int n, m;
    multiset<int> a;
    priority_queue<int> b;

    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a.insert(x);
    }
    for (int i = 0; i < m; i++) {
        int x;
        cin >> x;
        if (a.count(x)) a.extract(x);
        else b.push(x);
    }

    int loop = (int) a.size() - (int) b.size();
    for (int i = 0; i < loop; i++) {
        if (b.empty() || a.empty()) {
            cout << "No\n";
            return;
        }

        int B = b.top();
        b.pop();

        int b1 = B / 2;
        if (a.count(b1)) a.extract(b1);
        else b.push(b1);

        b1 = B + 1 >> 1;
        if (a.count(b1)) a.extract(b1);
        else b.push(b1);
    }

    if (!a.empty() || !b.empty()) cout << "No\n";
    else cout << "Yes\n";
}

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

    int tc = 1;
    cin >> tc;

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

    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Time limit exceeded on test 7):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void solve() {
    int n, m;
    multiset<int> a, b;

    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a.insert(x);
    }
    for (int i = 0; i < m; i++) {
        int x;
        cin >> x;
        if (a.count(x)) a.extract(x);
        else b.insert(x);
    }

    int loop = (int) a.size() - (int) b.size();
    for (int i = 0; i < loop; i++) {
        if (b.empty() || a.empty()) {
            cout << "No\n";
            return;
        }

        int B = *b.rbegin();
        int A = *a.rbegin();

        if (A > B) {
            cout << "No\n";
            return;
        }

        b.extract(B);

        int b1 = B / 2;
        if (a.count(b1)) a.extract(b1);
        else b.insert(b1);

        b1 = B + 1 >> 1;
        if (a.count(b1)) a.extract(b1);
        else b.insert(b1);
    }

    while (!a.empty() && !b.empty()) {
        if (*a.rbegin() == *b.rbegin()) {
            a.extract(*a.rbegin());
            b.extract(*b.rbegin());
        } else {
            break;
        }
    }

    if (!a.empty() || !b.empty()) cout << "No\n";
    else cout << "Yes\n";
}

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

    int tc = 1;
    cin >> tc;

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

    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 7):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void solve() {
    int n, m;
    multiset<int> a;
    priority_queue<int> b;

    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a.insert(x);
    }
    for (int i = 0; i < m; i++) {
        int x;
        cin >> x;
        if (a.count(x)) a.extract(x);
        else b.push(x);
    }

    int loop = (int) a.size() - (int) b.size();
    for (int i = 0; i < loop; i++) {
        if (b.empty() || a.empty()) {
            cout << "No\n";
            return;
        }

        int B = b.top();
        b.pop();

        int b1 = B / 2;
        if (a.count(b1)) a.extract(b1);
        else b.push(b1);

        b1 = B + 1 >> 1;
        if (a.count(b1)) a.extract(b1);
        else b.push(b1);
    }

    if (!a.empty() || !b.empty()) cout << "No\n";
    else cout << "Yes\n";
}

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

    int tc = 1;
    cin >> tc;

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

    return 0;
}



Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void solve() {
    int n, m;
    map<int,int> a;
    priority_queue<int> b;

    cin >> n >> m;
    int sza = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a[x]++;
        sza++;
    }
    for (int i = 0; i < m; i++) {
        int x;
        cin >> x;
        if (a.count(x)) {
            a[x]--;
            if (a[x] == 0) a.erase(x);
            sza--;
        }
        else b.push(x);
    }

    int loop = sza - (int) b.size();
    for (int i = 0; i < loop; i++) {
        if (b.empty() || a.empty()) {
            cout << "No\n";
            return;
        }

        int B = b.top();
        b.pop();

        int b1 = B / 2;
        if (a.count(b1)) {
            a[b1]--;
            if (a[b1] == 0) a.erase(b1);
            sza--;
        }
        else b.push(b1);

        b1 = B + 1 >> 1;
        if (a.count(b1)) {
            a[b1]--;
            if (a[b1] == 0) a.erase(b1);
            sza--;
        }
        else b.push(b1);
    }

    if (sza > 0 || !b.empty()) cout << "No\n";
    else cout << "Yes\n";
}

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

    int tc = 1;
    cin >> tc;

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

    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ull = unsigned long long;
using i128 = __int128;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans = accumulate(a.begin(), a.end(), 0);
    for (int i = 1; i < n; i++) {
        vector<int> b(a.size() - 1);
        for (int j = 0; j < b.size(); j++) {
            b[j] = a[j + 1] - a[j];
        }
        int sum = accumulate(b.begin(), b.end(), 0);
        ans = max(ans, abs(sum));
        a = b;
    }
    cout << ans << "\n\n";
}

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

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

    return 0;
}