ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)


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

using namespace std;
using pii=pair<int,int>;

signed main(){
    cin.tie(nullptr)->sync_with_stdio(0);
    cout.tie(nullptr)->sync_with_stdio(0);
    int n;
    cin>>n;
    vector<int> lst(n+1);
    vector<int> now(n+1);
    for(int i=1; i<=n ; i++){
        cin>>lst[i];
        now[i]=i;
    }
    vector<pii> ans;
    vector<vector<bool>> vis(n+1,vector<bool>(n+1,true));
    for(int i=1; i<=n  ; i++){
        if(now[i]!=lst[i]){
            int p=0;
            int tar=lst[i];
            for(int j=1; j<=n; j++){
                if(now[j]==tar){
                    p=j; 
                    break;
                }
            }
            ans.push_back({now[i],now[p]});
            swap(now[i],now[p]);
            //cout<<now[i]<<' '<<now[p]<<'\n';
            vis[now[i]][now[p]]=vis[now[p]][now[i]]=false;
        }
    }
    for(int i=1,u; i<=n; i++){
        u=now[i];
        for(int j=1,v; j<=n; j++){
            v=now[j];
            if(i==j) continue;
            if(vis[u][v]&&i<j){
                vis[u][v]=vis[v][u]=false;
                ans.push_back({v,u});
                ans.push_back({u,v});
            }
        }
    }
    cout<<ans.size()<<'\n';
    for(auto x :ans ){
        cout<<x.first<<' '<<x.second<<'\n';
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

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

using namespace std;
using pii=pair<int,int>;

signed main(){
    cin.tie(nullptr)->sync_with_stdio(0);
    cout.tie(nullptr)->sync_with_stdio(0);
    int n;
    cin>>n;
    vector<int> lst(n+1);
    vector<int> now(n+1);
    for(int i=1; i<=n ; i++){
        cin>>lst[i];
        now[i]=i;
    }
    vector<pii> ans;
    vector<vector<bool>> vis(n+1,vector<bool>(n+1,true));
    for(int i=1; i<=n  ; i++){
        if(now[i]!=lst[i]){
            int p=0;
            int tar=lst[i];
            for(int j=1; j<=n; j++){
                if(now[j]==tar){
                    p=j; 
                    break;
                }
            }
            ans.push_back({now[p],now[i]});
            swap(now[i],now[p]);
            //cout<<now[i]<<' '<<now[p]<<'\n';
            vis[now[i]][now[p]]=vis[now[p]][now[i]]=false;
        }
    }
    for(int i=1,u; i<=n; i++){
        u=now[i];
        for(int j=1,v; j<=n; j++){
            v=now[j];
            if(i==j) continue;
            if(vis[u][v]&&i<j){
                vis[u][v]=vis[v][u]=false;
                ans.push_back({v,u});
                ans.push_back({u,v});
            }
        }
    }
    cout<<ans.size()<<'\n';
    for(auto x :ans ){
        cout<<x.first<<' '<<x.second<<'\n';
    }
}

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

using namespace std;
using pii=pair<int,int>;

signed main(){
    cin.tie(nullptr)->sync_with_stdio(0);
    cout.tie(nullptr)->sync_with_stdio(0);
    int n;
    cin>>n;
    vector<int> lst(n+1);
    vector<int> now(n+1);
    for(int i=1; i<=n ; i++){
        cin>>lst[i];
        now[i]=i;
    }
    vector<pii> ans;
    vector<vector<bool>> vis(n+1,vector<bool>(n+1,true));
    for(int i=1; i<=n ; i++){
        if(now[i]!=lst[i]){
            int p=0;
            int tar=lst[i];
            for(int j=i+1; j<=n ; j++){
                if(now[j]==tar){
                    p=j; break;
                }
            }
            for(int j=p ; j>i ; j--){
                ans.push_back({now[j],now[j-1]});
                swap(now[j],now[j-1]);
                vis[now[j]][now[j-1]]=vis[now[j-1]][now[j]]=false;
            }
        }
    }
    //cout<<"!!"<<' '<<ans.size()<<'\n';
    //for(auto it: now) cout<<it<<' ';
    //cout<<'\n';
    for(int i=1; i<n ; i++){
        int j=i+1;
        for(int v ; j<=n; j++){
            v=now[j];
            if(vis[now[j-1]][v]){
                //cout<<"??"<<u<<' '<<v<<'\n';
                ans.push_back({v,now[j-1]});
                swap(now[j],now[j-1]);
                vis[now[j-1]][v]=vis[v][now[j-1]]=false;
            }
            else{
                break;
            }
        }
        j--;
        for(int v; j>i ; j--){
            //cout<<"NMSL "<<i<<' '<<j<<'\n';
            v=now[j];
            ans.push_back({now[j],now[j-1]});
            swap(now[j],now[j-1]);
        }
    }
    cout<<ans.size()<<'\n';
    for(auto x :ans ){
        cout<<x.first<<' '<<x.second<<'\n';
    }
}
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;
using ll=long long;

void solve(){
    int l,r;
    cin>>l>>r;
    int p=-1;
    vector<int> ans[3];
    for(int i=30 ; i>=0; i--){
        if((r&(1<<i))!=(l&(1<<i))){
            p=i;
            ans[0].push_back(0);
            ans[1].push_back(0);
            ans[2].push_back(1);
            break;
        }
        else{
            ans[0].push_back(r&(1<<i));
            ans[1].push_back(r&(1<<i));
            ans[2].push_back(r&(1<<i));
        }
    }
    for(int i=p-1 ; i>=0; i--){
        ans[0].push_back(1) ; ans[1].push_back(1);
        ans[2].push_back(0);
    }
    vector<ll> res(3);
    for(int i=0,j=30 ; i<=30; i++,j--){
        for(int k=0; k<3 ; k++){
            res[k]+=(ans[k][i]<<j);
        }
    }
    for(int i=0; i<3 ; i++) cout<<res[i]<<' ';
    cout<<'\n';
}

signed main(){
    cin.tie(nullptr)->sync_with_stdio(0);
    cout.tie(nullptr)->sync_with_stdio(0);
    int t;
    cin>>t;
    while(t--) solve();
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define int long long

using namespace std;
using ll=long long;

void solve(){
    int l,r;
    cin>>l>>r;
    int p=-1;
    vector<int> ans[3];
    for(int i=30 ; i>=0; i--){
        if((r&(1<<i))!=(l&(1<<i))){
            p=i;
            ans[0].push_back(0);
            ans[1].push_back(0);
            ans[2].push_back(1);
            break;
        }
        else{
            ans[0].push_back(r&(1<<i));
            ans[1].push_back(r&(1<<i));
            ans[2].push_back(r&(1<<i));
        }
    }
    for(int i=p-1 ; i>=0; i--){
        ans[0].push_back(1) ; ans[1].push_back(1);
        ans[2].push_back(0);
    }
    vector<ll> res(3);
    for(int i=0,j=30 ; i<=30; i++,j--){
        for(int k=0; k<3 ; k++){
            res[k]+=(ll)(ans[k][i]<<j);
        }
    }
    for(int i=0; i<3 ; i++) cout<<res[i]<<' ';
    cout<<'\n';
}

signed main(){
    cin.tie(nullptr)->sync_with_stdio(0);
    cout.tie(nullptr)->sync_with_stdio(0);
    int t;
    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>
#define int long long

using namespace std;
using ll=long long;

void solve(){
    int l,r;
    cin>>l>>r;
    int p=-1;
    vector<int> ans[3];
    for(int i=30 ; i>=0; i--){
        if((r&(1<<i))!=(l&(1<<i))){
            p=i;
            ans[0].push_back(0);
            ans[1].push_back(0);
            ans[2].push_back(1);
            break;
        }
        else{
            ans[0].push_back(r&(1<<i));
            ans[1].push_back(r&(1<<i));
            ans[2].push_back(r&(1<<i));
        }
    }
    bool flag=true;
    for(int i=p-1 ; i>=0; i--){
        if((l&(1<<i))==0){
            flag=false; ans[0].push_back(1); ans[1].push_back(0);
            ans[2].push_back(0);
        }
        else{
            ans[0].push_back(1); ans[1].push_back(1); ans[2].push_back(0);
        }
    }
    if(flag){
        for(int i=30,j=0; j<p ; j++,i--){
            ans[1][i]=0;
        }
        ans[1][30-p]=1;
    }
    vector<ll> res(3);
    for(int i=0,j=30 ; i<=30; i++,j--){
        for(int k=0; k<3 ; k++){
            res[k]+=(ll)(ans[k][i]<<j);
        }
    }
    for(int i=0; i<3 ; i++) cout<<res[i]<<' ';
    cout<<'\n';
}

signed main(){
    cin.tie(nullptr)->sync_with_stdio(0);
    cout.tie(nullptr)->sync_with_stdio(0);
    int t;
    cin>>t;
    while(t--) solve();
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define int long long

using namespace std;
using ll=long long;

void solve(){
    int l,r;
    cin>>l>>r;
    if(r-l+1==3){
        cout<<l<<' '<<l+1<<' '<<l+2<<'\n';
        return ;
    }
    int p=-1;
    vector<int> ans[3];
    for(int i=30 ; i>=0; i--){
        if((r&(1<<i))!=(l&(1<<i))){
            p=i;
            ans[0].push_back(0);
            ans[1].push_back(0);
            ans[2].push_back(1);
            break;
        }
        else{
            ans[0].push_back(r&(1<<i));
            ans[1].push_back(r&(1<<i));
            ans[2].push_back(r&(1<<i));
        }
    }
    bool flag=true;
    for(int i=p-1 ; i>=0; i--){
        if((l&(1<<i))==0){
            flag=false; ans[0].push_back(1); ans[1].push_back(0);
            ans[2].push_back(0);
        }
        else{
            ans[0].push_back(1); ans[1].push_back(1); ans[2].push_back(0);
        }
    }
    if(flag){
        for(int i=30,j=0; j<p ; j++,i--){
            ans[1][i]=0;
        }
        ans[1][30-p]=1;
    }
    vector<ll> res(3);
    for(int i=0,j=30 ; i<=30; i++,j--){
        for(int k=0; k<3 ; k++){
            res[k]+=(ll)(ans[k][i]<<j);
        }
    }
    for(int i=0; i<3 ; i++) cout<<res[i]<<' ';
    cout<<'\n';
}

signed main(){
    cin.tie(nullptr)->sync_with_stdio(0);
    cout.tie(nullptr)->sync_with_stdio(0);
    int t;
    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>
#define int long long

using namespace std;
using ll=long long;

void solve(){
    int l,r;
    cin>>l>>r;
    if(r-l+1==3){
        cout<<l<<' '<<l+1<<' '<<l+2<<'\n';
        return ;
    }
    int p=-1;
    vector<int> ans[3];
    for(int i=30 ; i>=0; i--){
        if((r&(1<<i))!=(l&(1<<i))){
            p=i;
            ans[0].push_back(0);
            ans[1].push_back(0);
            ans[2].push_back(1);
            break;
        }
        else{
            ans[0].push_back(r&(1<<i));
            ans[1].push_back(r&(1<<i));
            ans[2].push_back(r&(1<<i));
        }
    }
    bool flag=true;
    for(int i=p-1 ; i>=0; i--){
        if((l&(1<<i))==0){
            flag=false; ans[0].push_back(1); ans[1].push_back(0);
            ans[2].push_back(0);
        }
        else{
            ans[0].push_back(1); ans[1].push_back(1); ans[2].push_back(0);
        }
    }
    if(flag){
        for(int i=30,j=0; j<p ; j++,i--){
            ans[1][i]=0;
        }
        ans[1][30-p]=1;
    }
    vector<ll> res(3);
    for(int i=0,j=30 ; i<=30; i++,j--){
        for(int k=0; k<3 ; k++){
            res[k]+=(ll)(ans[k][i]<<j);
        }
    }
    for(int i=0; i<3 ; i++) cout<<res[i]<<' ';
    cout<<'\n';
}

signed main(){
    cin.tie(nullptr)->sync_with_stdio(0);
    cout.tie(nullptr)->sync_with_stdio(0);
    int t;
    cin>>t;
    while(t--) solve();
}

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

using namespace std;
using ll=long long;

void solve(){
    int l,r;
    cin>>l>>r;
    if(r-l+1==3){
        cout<<l<<' '<<l+1<<' '<<l+2<<'\n';
        return ;
    }
    int p=-1;
    vector<int> ans[3];
    for(int i=30 ; i>=0; i--){
        if((r&(1<<i))!=(l&(1<<i))){
            p=i;
            ans[0].push_back(0);
            ans[1].push_back(0);
            ans[2].push_back(1);
            break;
        }
        else{
            ans[0].push_back((r>>i)&1);
            ans[1].push_back((r>>i)&1);
            ans[2].push_back((r>>i)&1);
        }
    }
    bool flag=true;
    for(int i=p-1 ; i>=0; i--){
        if((l&(1<<i))==0){
            flag=false; ans[0].push_back(1); ans[1].push_back(0);
            ans[2].push_back(0);
        }
        else{
            ans[0].push_back(1); ans[1].push_back(1); ans[2].push_back(0);
        }
    }
    if(flag){
        for(int i=30,j=0; j<p ; j++,i--){
            ans[1][i]=0;
        }
        ans[1][30-p]=1;
        ans[2][30]=1;
    }
    vector<ll> res(3);
    for(int i=0,j=30 ; i<=30; i++,j--){
        for(int k=0; k<3 ; k++){
            res[k]+=(ll)(ans[k][i]<<j);
        }
    }
    for(int i=0; i<3 ; i++) cout<<res[i]<<' ';
    cout<<'\n';
}

signed main(){
    cin.tie(nullptr)->sync_with_stdio(0);
    cout.tie(nullptr)->sync_with_stdio(0);
    int t;
    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<bits/stdc++.h>

using namespace std;
using ll=long long;

void solve(){
    int l,r;
    cin>>l>>r;
    int p=-1;
    vector<int> ans[3];
    for(int i=30 ; i>=0; i--){
        if((r&(1<<i))!=(l&(1<<i))){
            p=i;
            ans[0].push_back(0);
            ans[1].push_back(0);
            ans[2].push_back(1);
            break;
        }
        else{
            ans[0].push_back(r&(1<<i));
            ans[1].push_back(r&(1<<i));
            ans[2].push_back(r&(1<<i));
        }
    }
    for(int i=p-1 ; i>=0; i--){
        ans[0].push_back(1) ; ans[1].push_back(1);
        ans[2].push_back(0);
    }
    vector<ll> res(3);
    for(int i=0,j=30 ; i<=30; i++,j--){
        for(int k=0; k<3 ; k++){
            res[k]+=(ans[k][i]<<j);
        }
    }
    for(int i=0; i<3 ; i++) cout<<res[i]<<' ';
    cout<<'\n';
}

signed main(){
    cin.tie(nullptr)->sync_with_stdio(0);
    cout.tie(nullptr)->sync_with_stdio(0);
    int t;
    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>
#define int long long

using namespace std;
using ll=long long;

void solve(){
    int l,r;
    cin>>l>>r;
    int p=-1;
    vector<int> ans[3];
    for(int i=30 ; i>=0; i--){
        if((r&(1<<i))!=(l&(1<<i))){
            p=i;
            ans[0].push_back(0);
            ans[1].push_back(0);
            ans[2].push_back(1);
            break;
        }
        else{
            ans[0].push_back(r&(1<<i));
            ans[1].push_back(r&(1<<i));
            ans[2].push_back(r&(1<<i));
        }
    }
    for(int i=p-1 ; i>=0; i--){
        ans[0].push_back(1) ; ans[1].push_back(1);
        ans[2].push_back(0);
    }
    vector<ll> res(3);
    for(int i=0,j=30 ; i<=30; i++,j--){
        for(int k=0; k<3 ; k++){
            res[k]+=(ll)(ans[k][i]<<j);
        }
    }
    for(int i=0; i<3 ; i++) cout<<res[i]<<' ';
    cout<<'\n';
}

signed main(){
    cin.tie(nullptr)->sync_with_stdio(0);
    cout.tie(nullptr)->sync_with_stdio(0);
    int t;
    cin>>t;
    while(t--) solve();
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define int long long

using namespace std;
using ll=long long;

void solve(){
    int l,r;
    cin>>l>>r;
    int p=-1;
    vector<int> ans[3];
    for(int i=30 ; i>=0; i--){
        if((r&(1<<i))!=(l&(1<<i))){
            p=i;
            ans[0].push_back(0);
            ans[1].push_back(0);
            ans[2].push_back(1);
            break;
        }
        else{
            ans[0].push_back(r&(1<<i));
            ans[1].push_back(r&(1<<i));
            ans[2].push_back(r&(1<<i));
        }
    }
    bool flag=true;
    for(int i=p-1 ; i>=0; i--){
        if((l&(1<<i))==0){
            flag=false; ans[0].push_back(1); ans[1].push_back(0);
            ans[2].push_back(0);
        }
        else{
            ans[0].push_back(1); ans[1].push_back(1); ans[2].push_back(0);
        }
    }
    if(flag){
        for(int i=30,j=0; j<p ; j++,i--){
            ans[1][i]=0;
        }
        ans[1][30-p]=1;
    }
    vector<ll> res(3);
    for(int i=0,j=30 ; i<=30; i++,j--){
        for(int k=0; k<3 ; k++){
            res[k]+=(ll)(ans[k][i]<<j);
        }
    }
    for(int i=0; i<3 ; i++) cout<<res[i]<<' ';
    cout<<'\n';
}

signed main(){
    cin.tie(nullptr)->sync_with_stdio(0);
    cout.tie(nullptr)->sync_with_stdio(0);
    int t;
    cin>>t;
    while(t--) solve();
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#include<deque> 
#include<vector>
#include<cmath> 
#include<set> 
using namespace std;
const int N = 2e5 + 10;
#define int long long 
int head[N], nex[N << 1], to[N << 1], tot;
int d[N];
inline void init(int n)
{
	tot = 0;
	for(int i = 1; i <= n; ++i) head[i] = d[i] = 0;
}
inline void add(int x, int y)
{
	nex[++tot] = head[x];
	to[tot] = y;
	head[x] = tot;
}

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T;
	cin >> T;
	while(T--)
	{
		int n;
		cin >> n;
		init(n);
		int u, v;
		multiset<int> s;
		for(int i = 1; i < n; ++i) 
		{
			cin >> u >> v;
			add(u, v);
			add(v, u); 
			++d[u];
			++d[v];
		}
		for(int i = 1; i <= n; ++i) s.insert(d[i]); 
		int ans = 0;
		for(int i = 1; i <= n; ++i)
		{
			s.erase(d[i]);
			for(int j = head[i]; j; j = nex[j])
			{
				int v = to[j];
				s.erase(d[v]);
				s.insert(d[v] - 1);
			}
			ans = max(ans, d[i] + (*--s.end()) - 1);
			for(int j = head[i]; j; j = nex[j])
			{
				int v = to[j];
				s.insert(d[v]);
				s.erase(d[v] - 1);
			}
			s.insert(d[i]);
		}
		cout << ans << endl;
	}
	return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#include<deque> 
#include<vector>
#include<cmath> 
#include<set> 
using namespace std;
const int N = 2e5 + 10;
#define int long long 
int head[N], nex[N << 1], to[N << 1], tot;
int d[N];
inline void init(int n)
{
	tot = 0;
	for(int i = 1; i <= n; ++i) head[i] = d[i] = 0;
}
inline void add(int x, int y)
{
	nex[++tot] = head[x];
	to[tot] = y;
	head[x] = tot;
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T;
	cin >> T;
	while(T--)
	{
		int n;
		cin >> n;
		init(n);
		int u, v;
		multiset<int, greater<int>> s;
		for(int i = 1; i < n; ++i) 
		{
			cin >> u >> v;
			add(u, v);
			add(v, u); 
			++d[u];
			++d[v];
		}
		for(int i = 1; i <= n; ++i) s.insert(d[i]); 
		int ans = 0;
		for(int i = 1; i <= n; ++i)
		{
			s.erase(d[i]);
			for(int j = head[i]; j; j = nex[j])
			{
				int v = to[j];
				s.erase(d[v]);
				s.insert(d[v] - 1);
			}
			ans = max(ans, d[i] + (*s.begin()) - 1);
			for(int j = head[i]; j; j = nex[j])
			{
				int v = to[j];
				s.insert(d[v]);
				s.erase(d[v] - 1);
			}
			s.insert(d[i]);
		}
		cout << ans << endl;
	}
	return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#include<deque> 
#include<vector>
#include<cmath> 
#include<set> 
using namespace std;
const int N = 2e5 + 10;
#define int long long 
int head[N], nex[N << 1], to[N << 1], tot;
int d[N];
inline void init(int n)
{
	tot = 0;
	for(int i = 1; i <= n; ++i) head[i] = d[i] = 0;
}
inline void add(int x, int y)
{
	nex[++tot] = head[x];
	to[tot] = y;
	head[x] = tot;
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T;
	cin >> T;
	while(T--)
	{
		int n;
		cin >> n;
		init(n);
		int u, v;
		multiset<int, greater<int>> s;
		for(int i = 1; i < n; ++i) 
		{
			cin >> u >> v;
			add(u, v);
			add(v, u); 
			++d[u];
			++d[v];
		}
		for(int i = 1; i <= n; ++i) s.insert(d[i]); 
		int ans = 0;
		for(int i = 1; i <= n; ++i)
		{
			s.erase(d[i]);
			for(int j = head[i]; j; j = nex[j])
			{
				int v = to[j];
				s.erase(d[v]);
				s.insert(d[v] - 1);
			}
			ans = max(ans, d[i] + (*s.begin()) - 1);
			for(int j = head[i]; j; j = nex[j])
			{
				int v = to[j];
				s.insert(d[v]);
				s.erase(d[v] - 1);
			}
			s.insert(d[i]);
		}
		cout << ans << endl;
	}
	return 0;
}

Submission (verdict: Accepted):
#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#include<deque> 
#include<vector>
#include<cmath> 
#include<set> 
using namespace std;
const int N = 2e5 + 10;
#define int long long 
int head[N], nex[N << 1], to[N << 1], tot;
int d[N];
inline void init(int n)
{
	tot = 0;
	for(int i = 1; i <= n; ++i) head[i] = d[i] = 0;
}
inline void add(int x, int y)
{
	nex[++tot] = head[x];
	to[tot] = y;
	head[x] = tot;
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T;
	cin >> T;
	while(T--)
	{
		int n;
		cin >> n;
		init(n);
		int u, v;
		multiset<int, greater<int>> s;
		//cout << "s.size() = " << s.size() << endl;
		for(int i = 1; i < n; ++i) 
		{
			cin >> u >> v;
			add(u, v);
			add(v, u); 
			++d[u];
			++d[v];
		}
		for(int i = 1; i <= n; ++i) s.insert(d[i]); 
		
		int ans = 0;
		for(int i = 1; i <= n; ++i)
		{
			auto it = s.find(d[i]);
			s.erase(it);
			for(int j = head[i]; j; j = nex[j])
			{
				int v = to[j];
				auto it = s.find(d[v]);
				s.erase(it);
				s.insert(d[v] - 1);
			}
			ans = max(ans, d[i] + (*s.begin()) - 1);
			for(int j = head[i]; j; j = nex[j])
			{
				int v = to[j];
				auto it = s.find(d[v] - 1);
				s.erase(it);
				s.insert(d[v]);
			}
			s.insert(d[i]);
		}
		cout << ans << endl;
	}
	return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#include<deque> 
#include<vector>
#include<cmath> 
#include<set> 
using namespace std;
const int N = 2e5 + 10;
#define int long long 
int head[N], nex[N << 1], to[N << 1], tot;
int d[N];
inline void init(int n)
{
	tot = 0;
	for(int i = 1; i <= n; ++i) head[i] = d[i] = 0;
}
inline void add(int x, int y)
{
	nex[++tot] = head[x];
	to[tot] = y;
	head[x] = tot;
}

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T;
	cin >> T;
	while(T--)
	{
		int n;
		cin >> n;
		init(n);
		int u, v;
		multiset<int> s;
		for(int i = 1; i < n; ++i) 
		{
			cin >> u >> v;
			add(u, v);
			add(v, u); 
			++d[u];
			++d[v];
		}
		for(int i = 1; i <= n; ++i) s.insert(d[i]); 
		int ans = 0;
		for(int i = 1; i <= n; ++i)
		{
			s.erase(d[i]);
			for(int j = head[i]; j; j = nex[j])
			{
				int v = to[j];
				s.erase(d[v]);
				s.insert(d[v] - 1);
			}
			ans = max(ans, d[i] + (*--s.end()) - 1);
			for(int j = head[i]; j; j = nex[j])
			{
				int v = to[j];
				s.insert(d[v]);
				s.erase(d[v] - 1);
			}
			s.insert(d[i]);
		}
		cout << ans << endl;
	}
	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)


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

#include <bits/stdc++.h>

#include <map>

#include <cctype>

using namespace std;

#define endl "\n"

#define Yahia cin.tie(0), cout.tie(0), cin.sync_with_stdio(0), cout.sync_with_stdio(0);

#define INF INT64_MAX

#define int long long int

const int sz=1e5+5;

const int OO=0x3f3f3f3f;

#include <unordered_set>



int find_mex(const set<int>& arr) {

    unordered_set<int> present_elements;

    for (int num : arr) {

        present_elements.insert(num);

    }

    int mex = 0;

    while (present_elements.find(mex) != present_elements.end()) {

        mex++;

    }

    return mex;

}





void execute_case(int tc) {

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

    vector<int>v(n);

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

    int s=accumulate(v.begin(),v.end(),0);

    if(l==1 and r==n) {

        return void(cout<<s);

    }

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

    int range=r-l+1;

    int ans{};

    for(int i=0;i<range;++i)ans+=v[i];

    cout<<ans;

}

signed main(){

    Yahia

    int t;

    cin>>t;

    for(int tc=1;tc<=t;++tc)

    {

        execute_case(tc);

        cout<<endl;

    }

    return 0;

}