ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

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

using namespace std;



#define int long long

#define endl '\n'

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

#define rall(x) (x).rbegin(), (x).rend()

#define pb push_back

#define vi vector<int>

#define mii map<int, int>

#define pii pair<int, int>



void solve(){

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

    vi a(n);

    for(int &x: a)  cin >> x;

    vi b = a;

    sort(a.begin(), a.begin() + r);

    sort(b.begin() + l - 1, b.end());

    cout << min(accumulate(a.begin(), a.begin() + r - l + 1, 0), accumulate(b.begin() + l - 1, b.begin() + r, 0)) << endl;

}



signed main(){

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin >> t;

    while(t--){

        solve();

    }

    return 0;

}

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

using namespace std;



#define int long long

#define endl '\n'

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

#define rall(x) (x).rbegin(), (x).rend()

#define pb push_back

#define vi vector<int>

#define mii map<int, int>

#define pii pair<int, int>



void solve(){

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

    vi a(n);

    for(int &x: a)  cin >> x;

    vi b = a;

    sort(a.begin(), a.begin() + r);

    reverse(a.begin(), a.begin() + r);

    sort(b.begin() + l - 1, b.end());

    cout << min(accumulate(a.begin() + l - 1, a.begin() + r, 0), accumulate(b.begin() + l - 1, b.begin() + r, 0)) << endl;

}



signed main(){

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin >> t;

    while(t--){

        solve();

    }

    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)


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

using namespace std;



#define int long long

#define endl '\n'

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

#define rall(x) (x).rbegin(), (x).rend()

#define pb push_back

#define vi vector<int>

#define mii map<int, int>

#define pii pair<int, int>



void solve(){

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

    vi a(n);

    for(int &x: a)  cin >> x;

    vi b = a;

    sort(a.begin(), a.begin() + r);

    sort(b.begin() + l - 1, b.end());

    cout << min(accumulate(a.begin(), a.begin() + r - l + 1, 0), accumulate(b.begin() + l - 1, b.begin() + r, 0)) << endl;

}



signed main(){

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin >> t;

    while(t--){

        solve();

    }

    return 0;

}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <set>

#include <map>
#include <cctype>
#include <cstdio>
#include <numeric>
#define ll long long
#define LOG2(n) __lg(n)
#define SET_BIT_COUNTLL(x) __builtin_popcountll(x)
#define SET_BIT_COUNT(x) __builtin_popcount(x)
#define FAST ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define lp(var,inti,size) for(int var = inti ; var < size ; var ++)
#define fori(size) for(ll i=0; i < (size); i++)
#define foril(size) for(ll i=(size-1); i >= 0; --i)
#define forj(size) for(ll j=0; j < (size); j++)
#define fork(size) for(ll k=0; k < (size); k+= 1)
#define forl(size) for(ll l=0; l < (size); l+= 1)
const float pi = 3.14;
const long long oo = 9223372036854775807;
using namespace std;
#define oo 1e9
#define pb push_back
#define endll "\n"
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define mp make_pair
#define yes cout<<"YES"<<endll
#define no cout<<"NO"<<endll

const ll MOD = 1e9 + 7, MOD2 = 1e9 + 9;
const ll N = 1e6 + 9;
using namespace std;

typedef pair<ll, ll> pii;
typedef pair<ll, pii> ppi;
typedef vector<ll> vec;
void fast() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }

vector<ll> fibNumbers(1e7, 1);

set<ll> primeo;



ll  dpadep(vec &dpadepo, ll fo) {
    if (fo > 1000)return 0;
    else {
        dpadepo.push_back(fo);
        dpadep(dpadepo, fo * 10 + 7);
        return dpadep(dpadepo, fo * 10 + 4);
    }

}
void TT() {

    long long n, t, m = 0, c = 0, sum = 0, real_sum = 0, c_sofar = 0, sum_sofar = 0; ll a, b = 1, k, r, l, ans = 0;
    string sl,sr;
    cin >>l>>r;
    vec x; t = l;
    map <ll, ll>lolo;
    while (l) {
        if (l % 2)sl = "1" + sl;
        else sl = "0" + sl;
        l = l/ 2;
   }
    while (r) {
        if (r % 2)sr = "1" + sr;
        else sr = "0" + sr;
        r = r / 2;
    }
    if (sr.length() > sl.length())cout<<(1<< sr.length()-1)<<" " << (1 << sr.length() - 1) - 1 << " " << t << endl;
    else {
        c = sr.size()-1;
        while (sr[c] == sl[c])c--;
        cout << (1 << c) << " " << (1 << c) - 1 << " " << t << endl;

    }

}


/* if (b > n) {         QWE
        cout << n << endl;;
    }
    else if (a) {
        ans = n - 1 - b+a;
        ans /= a;
        cout <<n- ans << endl;
    }
    else {
        
        if (n == 1) {
            if (b)cout << 1<<endl;
            else cout << 0 << endl;;
        }
        else if(b) cout << n - 1 << endl;
        else  cout << -1 << endl;;
    }*/




int main() {
    fast();
   
    int n = 1;
    cin >> n;
    ll s = 0;
    while (n--) { TT();  }
}
// Owvx
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)


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

#include<ext/pb_ds/assoc_container.hpp>

#include<ext/pb_ds/tree_policy.hpp>



using namespace std;

using namespace __gnu_pbds;



typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

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

#define ll  long long

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

#define rall(v) v.rbegin(),v.rend()

ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}

ll lcm(ll a, ll b){return ((a/gcd(a,b))*b);}

#define f    first

#define s    second

#define FOR(v) for(auto&i:v) cin>>i;



void gen()

{

    ll n;cin>>n;

    vector<ll>v(n);

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

    vector<pair<ll,ll>>ans;

    vector<ll>v2;

    for(ll i=1;i<=n;i++) v2.push_back(i); 

    ll m=0;

    for(ll i=n-1;i>=0;i--)

    {

        ll val=v[i];

        ll idx=lower_bound(all(v2),val)-v2.begin();

        ll t=idx; 

        while(t>0) 

        {

            swap(v2[t],v2[t-1]);

            ans.push_back({v2[t-1],v2[t]});

            t--;

        }

        for(ll j=1;j<=n-m-1;j++)

        {

            swap(v2[j],v2[j-1]);

            ans.push_back({v2[j-1],v2[j]}); 

        }

        m++;

    }

    cout<<ans.size()<<'\n';

    for(auto ele:ans) cout<<ele.first<<" "<<ele.second<<'\n';

}

signed main()

{

    god_speed

    ll t=1; 

    while(t--) 	gen();

    return 0;

}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

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

#include<ext/pb_ds/assoc_container.hpp>

#include<ext/pb_ds/tree_policy.hpp>



using namespace std;

using namespace __gnu_pbds;



typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

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

#define ll  long long

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

#define rall(v) v.rbegin(),v.rend()

ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}

ll lcm(ll a, ll b){return ((a/gcd(a,b))*b);}

#define f    first

#define s    second

#define FOR(v) for(auto&i:v) cin>>i;



void gen()

{

    ll n;cin>>n;

    vector<ll>v(n);

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

    vector<pair<ll,ll>>ans;

    vector<ll>v2;

    for(ll i=1;i<=n;i++) v2.push_back(i); 

    ll m=0;

    for(ll i=n-1;i>=0;i--)

    {

        ll val=v[i];

        ll idx=lower_bound(all(v2),val)-v2.begin();

        ll t=idx; 

        while(t>0) 

        {

            swap(v2[t],v2[t-1]);

            ans.push_back({v2[t-1],v2[t]});

            t--;

        }

        for(ll j=1;j<=n-m-1;j++)

        {

            swap(v2[j],v2[j-1]);

            ans.push_back({v2[j-1],v2[j]}); 

        }

        m++;

    }

    cout<<ans.size()<<'\n';

    for(auto ele:ans) cout<<ele.first<<" "<<ele.second<<'\n';

}

signed main()

{

    god_speed

    ll t=1; 

    while(t--) 	gen();

    return 0;

}

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

#include<ext/pb_ds/assoc_container.hpp>

#include<ext/pb_ds/tree_policy.hpp>



using namespace std;

using namespace __gnu_pbds;



typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

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

#define ll  long long

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

#define rall(v) v.rbegin(),v.rend()

ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}

ll lcm(ll a, ll b){return ((a/gcd(a,b))*b);}

#define f    first

#define s    second

#define FOR(v) for(auto&i:v) cin>>i;



void gen()

{

    ll n;cin>>n;

    vector<ll>v(n);

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

    vector<pair<ll,ll>>ans;

    vector<ll>v2;

    for(ll i=1;i<=n;i++) v2.push_back(i); 

    ll m=0;

    for(ll i=n-1;i>0;i--)

    {

        ll val=v[i];

        ll idx=lower_bound(all(v2),val)-v2.begin();

        ll t=idx; 

        while(t>0) 

        {

            swap(v2[t],v2[t-1]);

            ans.push_back({v2[t-1],v2[t]});

            t--;

        }

        for(ll j=1;j<=n-m-1;j++)

        {

            swap(v2[j],v2[j-1]);

            ans.push_back({v2[j-1],v2[j]}); 

        }

        m++;

    }

    cout<<ans.size()<<'\n';

    for(auto ele:ans) cout<<ele.first<<" "<<ele.second<<'\n';

}

signed main()

{

    god_speed

    ll t=1; 

    while(t--) 	gen();

    return 0;

}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

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

#include<ext/pb_ds/assoc_container.hpp>

#include<ext/pb_ds/tree_policy.hpp>



using namespace std;

using namespace __gnu_pbds;



typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

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

#define ll  long long

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

#define rall(v) v.rbegin(),v.rend()

ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}

ll lcm(ll a, ll b){return ((a/gcd(a,b))*b);}

#define f    first

#define s    second

#define FOR(v) for(auto&i:v) cin>>i;



void gen()

{

    ll n;cin>>n;

    vector<ll>v(n);

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

    vector<pair<ll,ll>>ans;

    vector<ll>v2;

    for(ll i=1;i<=n;i++) v2.push_back(i); 

    ll m=0;

    for(ll i=n-1;i>0;i--)

    {

        ll val=v[i];

        ll idx=lower_bound(all(v2),val)-v2.begin();

        ll t=idx; 

        while(t>0) 

        {

            swap(v2[t],v2[t-1]);

            ans.push_back({v2[t-1],v2[t]});

            t--;

        }

        for(ll j=1;j<=n-m-1;j++)

        {

            swap(v2[j],v2[j-1]);

            ans.push_back({v2[j-1],v2[j]}); 

        }

        m++;

    }

    cout<<ans.size()<<'\n';

    for(auto ele:ans) cout<<ele.first<<" "<<ele.second<<'\n';

}

signed main()

{

    god_speed

    ll t=1; 

    while(t--) 	gen();

    return 0;

}

Submission (verdict: Accepted):
#include<bits/stdc++.h>

#include<ext/pb_ds/assoc_container.hpp>

#include<ext/pb_ds/tree_policy.hpp>



using namespace std;

using namespace __gnu_pbds;



typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

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

#define ll  long long

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

#define rall(v) v.rbegin(),v.rend()

ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}

ll lcm(ll a, ll b){return ((a/gcd(a,b))*b);}

#define f    first

#define s    second

#define FOR(v) for(auto&i:v) cin>>i;



void gen()

{

    ll n;cin>>n;

    vector<ll>v(n);

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

    vector<pair<ll,ll>>ans;

    vector<ll>v2;

    for(ll i=1;i<=n;i++) v2.push_back(i); 

    ll m=0;

    for(ll i=n-1;i>0;i--)

    {

        ll val=v[i]; 

        ll idx;

        for(ll i=0;i<n;i++) {if(v2[i]==val) {idx=i;break;}}  

        for(ll j=idx;j>0;j--)

        {

            swap(v2[j],v2[j-1]);

            ans.push_back({v2[j-1],v2[j]});

        }

        for(ll j=1;j<=n-m-1;j++)

        {

            swap(v2[j],v2[j-1]);

            ans.push_back({v2[j-1],v2[j]}); 

        } 

        m++; 

    }

    cout<<ans.size()<<'\n';

    for(auto ele:ans) cout<<ele.first<<" "<<ele.second<<'\n';

}

signed main()

{

    god_speed

    ll t=1; 

    while(t--) 	gen();

    return 0;

}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>

using namespace std;

void bin(int bin[],long long int n) {
    for (int i=29;i>=0;i--) {
        bin[i]=n%2;
        n/=2;
    }
    return ;
}

long long int dec(int bin[]) {
    
    long long int num=1,a=1;
    for (int i=29;i>=0;i--) {
        num+=a*bin[i];
        a*=2;
    }
    return num;
}

int main() {
    int t;
    cin >> t;
    for (int i=0;i<t;i++) {
        long long int l,r;
        cin >> l >> r;
        int bin1[30],bin2[30],ans1[30],ans2[30];
        bin(bin1,l);bin(bin2,r);
        int flg=0;
        for (int j=0;j<30;j++) {
            if (flg==0 && bin1[j]==bin2[j]) {
                ans2[j]=ans1[j]=bin1[j];
            }
            else {
                if (flg==0) {ans1[j]=1;ans2[j]=0;}
                else {ans1[j]=0;ans2[j]=1;}
            }
        }
        long long int a1,a2,po;
        a1=dec(bin1);a2=dec(bin2);
        for (long long int k=l;;k++) {
            if (k!=a1 && k!=a2) {po=k;break;}
        }
        cout << a1 << " " << a2 << " " << po << endl;
    }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <iostream>

using namespace std;

void bin(int bin[],long long int n) {
    for (int i=29;i>=0;i--) {
        bin[i]=n%2;
        n/=2;
    }
    return ;
}

long long int dec(int bin[]) {
    
    long long int num=1,a=1;
    for (int i=29;i>=0;i--) {
        num+=a*bin[i];
        a*=2;
    }
    return num;
}

int main() {
    int t;
    cin >> t;
    for (int i=0;i<t;i++) {
        long long int l,r;
        cin >> l >> r;
        int bin1[30],bin2[30],ans1[30],ans2[30];
        bin(bin1,l);bin(bin2,r);
        int flg=0;
        for (int j=0;j<30;j++) {
            if (flg==0 && bin1[j]==bin2[j]) {
                ans2[j]=ans1[j]=bin1[j];
            }
            else {
                if (flg==0) {ans1[j]=1;ans2[j]=0;}
                else {ans1[j]=0;ans2[j]=1;}
                flg=1;
            }
        }
        long long int a1,a2,po;
        a1=dec(bin1);a2=dec(bin2);
        for (long long int k=l;;k++) {
            if (k!=a1 && k!=a2) {po=k;break;}
        }
        cout << a1 << " " << a2 << " " << po << endl;
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include <iostream>

using namespace std;

void bin(int bin[],long long int n) {
    for (int i=29;i>=0;i--) {
        bin[i]=n%2;
        n/=2;
    }
    return ;
}

long long int dec(int bin[]) {
    
    long long int num=1,a=1;
    for (int i=29;i>=0;i--) {
        num+=a*bin[i];
        a*=2;
    }
    return num;
}

int main() {
    int t;
    cin >> t;
    for (int i=0;i<t;i++) {
        long long int l,r;
        cin >> l >> r;
        int bin1[30],bin2[30],ans1[30],ans2[30];
        bin(bin1,l);bin(bin2,r);
        int flg=0;
        for (int j=0;j<30;j++) {
            if (flg==0 && bin1[j]==bin2[j]) {
                ans2[j]=ans1[j]=bin1[j];
            }
            else {
                if (flg==0) {ans1[j]=1;ans2[j]=0;}
                else {ans1[j]=0;ans2[j]=1;}
            }
        }
        long long int a1,a2,po;
        a1=dec(bin1);a2=dec(bin2);
        for (long long int k=l;;k++) {
            if (k!=l && k!=r) {po=k;break;}
        }
        cout << a1 << " " << a2 << " " << po << endl;
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>

using namespace std;

void bin(int bin[],long long int n) {
    for (int i=29;i>=0;i--) {
        bin[i]=n%2;
        n/=2;
    }
    return ;
}

long long int dec(int bin[]) {
    
    long long int num=1,a=1;
    for (int i=29;i>=0;i--) {
        num+=a*bin[i];
        a*=2;
    }
    return num;
}

int main() {
    int t;
    cin >> t;
    for (int i=0;i<t;i++) {
        long long int l,r;
        cin >> l >> r;
        int bin1[30],bin2[30],ans1[30],ans2[30];
        bin(bin1,l);bin(bin2,r);
        int flg=0;
        for (int j=0;j<30;j++) {
            if (flg==0 && bin1[j]==bin2[j]) {
                ans2[j]=ans1[j]=bin1[j];
            }
            else {
                if (flg==0) {ans1[j]=1;ans2[j]=0;}
                else {ans1[j]=0;ans2[j]=1;}
            }
        }
        long long int a1,a2,po;
        a1=dec(bin1);a2=dec(bin2);
        for (long long int k=l;;k++) {
            if (k!=l && k!=r) {po=k;break;}
        }
        cout << a1 << " " << a2 << " " << po << endl;
    }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <iostream>

using namespace std;

void bin(int bin[],long long int n) {
    for (int i=29;i>=0;i--) {
        bin[i]=n%2;
        n/=2;
    }
    return ;
}

long long int dec(int bin[]) {
    
    long long int num=1,a=1;
    for (int i=29;i>=0;i--) {
        num+=a*bin[i];
        a*=2;
    }
    return num;
}

int main() {
    int t;
    cin >> t;
    for (int i=0;i<t;i++) {
        long long int l,r;
        cin >> l >> r;
        int bin1[30],bin2[30],ans1[30],ans2[30];
        bin(bin1,l);bin(bin2,r);
        int flg=0;
        for (int j=0;j<30;j++) {
            if (flg==0 && bin1[j]==bin2[j]) {
                ans2[j]=ans1[j]=bin1[j];
            }
            else {
                if (flg==0) {ans1[j]=1;ans2[j]=0;}
                else {ans1[j]=0;ans2[j]=1;}
            }
        }
        long long int a1,a2,po;
        a1=dec(bin1);a2=dec(bin2);
        for (long long int k=l;;k++) {
            if (k!=a1 && k!=a2) {po=k;break;}
        }
        cout << a1 << " " << a2 << " " << po << endl;
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>

using namespace std;

void bin(int bin[],long long int n) {
    for (int i=29;i>=0;i--) {
        bin[i]=n%2;
        n/=2;
    }
    return ;
}

long long int dec(int bin[]) {
    
    long long int num=1,a=1;
    for (int i=29;i>=0;i--) {
        num+=a*bin[i];
        a*=2;
    }
    return num;
}

int main() {
    int t;
    cin >> t;
    for (int i=0;i<t;i++) {
        long long int l,r;
        cin >> l >> r;
        int bin1[30],bin2[30],ans1[30],ans2[30];
        bin(bin1,l);bin(bin2,r);
        int flg=0;
        for (int j=0;j<30;j++) {
            if (flg==0 && bin1[j]==bin2[j]) {
                ans2[j]=ans1[j]=bin1[j];
            }
            else {
                if (flg==0) {ans1[j]=1;ans2[j]=0;}
                else {ans1[j]=0;ans2[j]=1;}
                flg=1;
            }
        }
        long long int a1,a2,po;
        a1=dec(bin1);a2=dec(bin2);
        for (long long int k=l;;k++) {
            if (k!=a1 && k!=a2) {po=k;break;}
        }
        cout << a1 << " " << a2 << " " << po << endl;
    }
    return 0;
}

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

using namespace std;

void bin(int bin[],long long int n) {
    for (int i=29;i>=0;i--) {
        bin[i]=n%2;
        n/=2;
    }
    return ;
}

long long int dec(int bin[]) {
    
    long long int num=0,a=1;
    for (int i=29;i>=0;i--) {
        num+=a*bin[i];
        a*=2;
    }
    return num;
}

int main() {
    int t;
    cin >> t;
    for (int i=0;i<t;i++) {
        long long int l,r;
        cin >> l >> r;
        int bin1[30],bin2[30],ans1[30],ans2[30];
        bin(bin1,l);bin(bin2,r);
        int flg=0;
        for (int j=0;j<30;j++) {
            if (flg==0 && bin1[j]==bin2[j]) {
                ans2[j]=ans1[j]=bin1[j];
            }
            else {
                if (flg==0) {ans1[j]=1;ans2[j]=0;}
                else {ans1[j]=0;ans2[j]=1;}
                flg=1;
            }
        }
        long long int a1,a2,po;
        a1=dec(ans1);a2=dec(ans2);
        for (long long int k=l;;k++) {
            if (k!=a1 && k!=a2) {po=k;break;}
        }
        cout << a1 << " " << a2 << " " << po << endl;
    }
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: Python 3


Submission (verdict: Wrong answer on test 2):
def solve():
    n = int(input())
    d = [{'id': _ + 1, 'v': []} for _ in range(n)]
    for i in range(n - 1):
        u, v = map(int, input().split())
        d[u - 1]['v'].append(v)
        d[v - 1]['v'].append(u)
    if n == 2:
        print(0)
    else:
        cnt = 1
        d.sort(key=lambda x: len(x['v']), reverse=True)
        cnt += len(d[0]['v']) - 1
        for item in d:
            if d[0]['id'] in item['v']:
                item['v'].remove(d[0]['id'])
        d.remove(d[0])
        # print(d)
        d.sort(key=lambda x: len(x['v']), reverse=True)
        cnt += len(d[0]['v']) - 1
        print(cnt)


for _ in range(int(input())):
    solve()
Problem: 2063C - Remove Exactly Two
Language: Python 3

Previous submission (verdict: Wrong answer on test 2):
def solve():
    n = int(input())
    d = [{'id': _ + 1, 'v': []} for _ in range(n)]
    for i in range(n - 1):
        u, v = map(int, input().split())
        d[u - 1]['v'].append(v)
        d[v - 1]['v'].append(u)
    if n == 2:
        print(0)
    else:
        cnt = 1
        d.sort(key=lambda x: len(x['v']), reverse=True)
        cnt += len(d[0]['v']) - 1
        for item in d:
            if d[0]['id'] in item['v']:
                item['v'].remove(d[0]['id'])
        d.remove(d[0])
        # print(d)
        d.sort(key=lambda x: len(x['v']), reverse=True)
        cnt += len(d[0]['v']) - 1
        print(cnt)


for _ in range(int(input())):
    solve()


Submission (verdict: Runtime error on test 2):
def solve():
    n = int(input())
    d = [{'id': _ + 1, 'v': []} for _ in range(n)]
    for i in range(n - 1):
        u, v = map(int, input().split())
        d[u - 1]['v'].append(v)
        d[v - 1]['v'].append(u)
    if n == 2:
        print(0)
    else:
        for i in range(n):
            s = 0
            for j in d[i]['v']:
                s += len(d[j - 1]['v'])
            d[i]['s'] = s
        d.sort(key=lambda x: (-len(x['v']), x['s']))
        cnt = 1
        cnt += len(d[0]['v']) - 1
        for item in d:
            if d[0]['id'] in item['v']:
                item['v'].remove(d[0]['id'])
        d.remove(d[0])
        for i in range(n - 1):
            s = 0
            for j in d[i]['v']:
                s += len(d[j - 1]['v'])
            d[i]['s'] = s
        d.sort(key=lambda x: (-len(x['v']), x['s']))
        cnt += len(d[0]['v']) - 1
        print(cnt)


for _ in range(int(input())):
    solve()