ShaysXIA/CodeInsightBench huggingface dataset:
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
#define double long double
#define endl '\n'
using namespace std;
typedef pair<int,int>PII;
const int mod=1e9+7;
const int N=2e5+10;

void solve(){
	int l,r;
	cin>>l>>r;
	int a=l,c=r,b=r-1;
	bool flag=false;
	for(int i=30;i>=0;i--){
		int tep1=(l>>i)&1;
		int tep2=(r>>i)&1;
	//	cout<<tep1<<" "<<tep2<<endl;
		if(tep1!=tep2){
			flag=true;
			continue;
		}else if(tep1==tep2&&flag){
			int tep3=b^(1<<i);
			//cerr<<tep3<<endl;
			if(tep3>l&&tep3<r){
				b=tep3;
			}
		}
	}
	cout<<a<<" "<<b<<" "<<c<<endl;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int tt=1;
	cin>>tt;
	while(tt--){
		solve();
	}
	return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define int long long
#define double long double
#define endl '\n'
using namespace std;
typedef pair<int,int>PII;
const int mod=1e9+7;
const int N=2e5+10;

void solve(){
	int l,r;
	cin>>l>>r;
	int a=l,c=r,b1=a,b2=c;
	bool flag=false;
	for(int i=30;i>=0;i--){
		int tep1=(l>>i)&1;
		int tep2=(r>>i)&1;
		if(tep1!=tep2){
			flag=true;
			continue;
		}else if(tep1==tep2&&flag){
			b1=b1^(1<<i);
			b2=b2^(1<<i);
		}
	}
	int b=c-1;
	if(b1>l&&b1<r){
		b=b1;
	}else if(b2>l&&b2<r){
		b=b2;
	}
	cout<<a<<" "<<b<<" "<<c<<endl;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int tt=1;
	cin>>tt;
	while(tt--){
		solve();
	}
	return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
void solve(){
	int l,r;
	cin>>l>>r;
	int c=r,a=r-1,b;
	int Max=0;
	for(int i=l;i<=r;i++){
		int temp=a^i+i^c+c^a;
		if(temp>Max&&i!=a&&i!=c){
			Max=temp;
			b=i;
		}
	}
	cout<<a<<" "<<b<<" "<<c<<endl;

}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int tt=1;
	cin>>tt;
	while(tt--){
		solve();
	}
	return 0;
}
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 endl '\n'
#define int long long
using namespace std;
void solve(){
	int l,r;
	cin>>l>>r;
	int c=r,a=r-1,b;
	int Max=0;
	for(int i=l;i<=r;i++){
		int temp=a^i+i^c+c^a;
		if(temp>Max&&i!=a&&i!=c){
			Max=temp;
			b=i;
		}
	}
	cout<<a<<" "<<b<<" "<<c<<endl;

}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int tt=1;
	cin>>tt;
	while(tt--){
		solve();
	}
	return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define int long long
#define double long double
#define endl '\n'
using namespace std;
typedef pair<int,int>PII;
const int mod=1e9+7;
const int N=2e5+10;

void solve(){
	int l,r;
	cin>>l>>r;
	int a=l,c=r,b=r-1;
	bool flag=false;
	for(int i=30;i>=0;i--){
		int tep1=(l>>i)&1;
		int tep2=(r>>i)&1;
	//	cout<<tep1<<" "<<tep2<<endl;
		if(tep1!=tep2){
			flag=true;
			continue;
		}else if(tep1==tep2&&flag){
			int tep3=b^(1<<i);
			//cerr<<tep3<<endl;
			if(tep3>l&&tep3<r){
				b=tep3;
			}
		}
	}
	cout<<a<<" "<<b<<" "<<c<<endl;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int tt=1;
	cin>>tt;
	while(tt--){
		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>
using namespace std;

#define ll long long

void solve(){
    int n, l, r; cin>>n>>l>>r;
    vector<int> a(n);
    for (int i=0; i<n; i++){cin>>a[i];}
    sort(a.begin(), a.end());
    int ans=0;
    for (int i=0; i<r-l+1; i++){
        ans+=a[i];
    }
    cout<<ans<<endl;
    return;
}

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

    //write your program here
    int t;
    cin>>t;
    while (t--){
        solve();
    }

}

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

using namespace std;



#define ll long long



void solve(){

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

    vector<int> a1(n);

    vector<int> a2(n);

    for (int i=0; i<n; i++){cin>>a1[i]; a2[i]=a1[i];}

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

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

    int ans1=0, ans2=0;

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

        if (i<r-l+1){ans1+=a1[i];}

        if (i>=l-1 && i<r){ans2+=a2[i];}

    }

    cout<<min(ans1, ans2)<<endl;

    return;

}



int main(){

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);



    //write your program here

    int t;

    cin>>t;

    while (t--){

        solve();

    }



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

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

using namespace std;



#define ll long long



void solve(){

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

    vector<int> a1(n);

    vector<int> a2(n);

    for (int i=0; i<n; i++){cin>>a1[i]; a2[i]=a1[i];}

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

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

    int ans1=0, ans2=0;

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

        if (i<r-l+1){ans1+=a1[i];}

        if (i>=l-1 && i<r){ans2+=a2[i];}

    }

    cout<<min(ans1, ans2)<<endl;

    return;

}



int main(){

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);



    //write your program here

    int t;

    cin>>t;

    while (t--){

        solve();

    }



}

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

#define ll long long

void solve(){
    int n, l, r; cin>>n>>l>>r;
    vector<int> a1(n);
    vector<int> a2(n);
    for (int i=0; i<n; i++){cin>>a1[i]; a2[i]=a1[i];}
    sort(a1.begin(), a1.begin()+r);
    sort(a2.begin()+l-1, a2.end());
    ll ans1=0, ans2=0;
    for (int i=0; i<n; i++){
        if (i<r-l+1){ans1+=a1[i];}
        if (i>=l-1 && i<r){ans2+=a2[i];}
    }
    cout<<min(ans1, ans2)<<endl;
    return;
}

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

    //write your program here
    int t;
    cin>>t;
    while (t--){
        solve();
    }

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


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

#define ll long long

void solve(){
    int n, l, r; cin>>n>>l>>r;
    vector<int> a(n);
    for (int i=0; i<n; i++){cin>>a[i];}
    sort(a.begin(), a.end());
    int ans=0;
    for (int i=0; i<r-l+1; i++){
        ans+=a[i];
    }
    cout<<ans<<endl;
    return;
}

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

    //write your program here
    int t;
    cin>>t;
    while (t--){
        solve();
    }

}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
//RADHE RADHE

#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long

int32_t main() {
    IOS
    int n;
    cin>>n;

    vector<int>v1(n);
    for(int i=0;i<n;i++)cin>>v1[i];
    if(n==1){
        cout<<0<<endl;
    }
    for(int i=n-1;i>=0;i--){

        for(int j=0;j<i;j++){
            if(v1[j]>v1[i])cout<<v1[j]<<" "<<v1[i]<<endl;
        }
        for(int j=0;j<i;j++){
            if(v1[j]<v1[i])cout<<v1[i]<<" "<<v1[j]<<endl;
        }
        for(int j=0;j<i;j++){
            if(v1[j]<v1[i])cout<<v1[j]<<" "<<v1[i]<<endl;
        }
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 5):
//RADHE RADHE

#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long

int32_t main() {
    IOS
    int n;
    cin>>n;

    vector<int>v1(n);
    for(int i=0;i<n;i++)cin>>v1[i];
    vector<array<int,2>>v;
    for(int i=n-1;i>=0;i--){

        for(int j=0;j<i;j++){
            if(v1[j]>v1[i])v.push_back({v1[j],v1[i]});
        }
        for(int j=i-1;j>=0;j--){
            if(v1[j]<v1[i])v.push_back({v1[i],v1[j]});
        }
        for(int j=0;j<i;j++){
            if(v1[j]<v1[i])v.push_back({v1[j],v1[i]});
        }
    }
    cout<<v.size()<<endl;
    for(auto x:v)cout<<x[0]<<" "<<x[1]<<endl;
}



Submission (verdict: Runtime error on test 1):
//RADHE RADHE

#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long

int32_t main() {
    IOS
    int n;
    cin>>n;

    vector<int>v1(n);
    for(int i=0;i<n;i++)cin>>v1[i];
    vector<array<int,2>>v;
    for(int i=n-1;i>=0;i--){
        vector<int>v2;
        for(int j=0;j<i;j++){
            if(v1[j]>v1[i])v2.push_back(v1[j]);
        }
        sort(v2.begin(),v2.end());

        for(int j=0;j<v2.size();j++){
            v.push_back({v2[j],v1[i]});
        }
        v2.clear();
        for(int j=i-1;j>=0;j--){
            if(v1[j]<v1[i])v2.push_back(v1[j]);
        }
        sort(v2.begin(),v2.end());
        for(int j=v2.size()-1;j>=0;j--){
            v.push_back({v1[i],v2[j]});
        }
        for(int j=0;j<v2.size();j++){
            v.push_back({v2[j],v1[i]});
        }
    }
    cout<<v.size()<<endl;
    for(auto x:v)cout<<x[0]<<" "<<x[1]<<endl;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 1):
//RADHE RADHE

#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long

int32_t main() {
    IOS
    int n;
    cin>>n;

    vector<int>v1(n);
    for(int i=0;i<n;i++)cin>>v1[i];
    vector<array<int,2>>v;
    for(int i=n-1;i>=0;i--){
        vector<int>v2;
        for(int j=0;j<i;j++){
            if(v1[j]>v1[i])v2.push_back(v1[j]);
        }
        sort(v2.begin(),v2.end());

        for(int j=0;j<v2.size();j++){
            v.push_back({v2[j],v1[i]});
        }
        v2.clear();
        for(int j=i-1;j>=0;j--){
            if(v1[j]<v1[i])v2.push_back(v1[j]);
        }
        sort(v2.begin(),v2.end());
        for(int j=v2.size()-1;j>=0;j--){
            v.push_back({v1[i],v2[j]});
        }
        for(int j=0;j<v2.size();j++){
            v.push_back({v2[j],v1[i]});
        }
    }
    cout<<v.size()<<endl;
    for(auto x:v)cout<<x[0]<<" "<<x[1]<<endl;
}



Submission (verdict: Accepted):
//RADHE RADHE

#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long

int32_t main() {
    IOS
    int n;
    cin>>n;

    vector<int>v1(n);
    for(int i=0;i<n;i++)cin>>v1[i];
    vector<array<int,2>>v;
    for(int i=n-1;i>=0;i--){
        vector<int>v2;
        for(int j=i-1;j>=0;j--){
            if(v1[j]<v1[i])v2.push_back(v1[j]);
        }
        sort(v2.begin(),v2.end());
        for(int j=(int)v2.size()-1;j>=0;j--){
            v.push_back({v1[i],v2[j]});
        }
        for(int j=0;j<v2.size();j++){
            v.push_back({v2[j],v1[i]});
        }
        v2.clear();
        for(int j=0;j<i;j++){
            if(v1[j]>v1[i])v2.push_back(v1[j]);
        }
        sort(v2.begin(),v2.end());

        for(int j=0;j<v2.size();j++){
            v.push_back({v2[j],v1[i]});
        }

    }
    cout<<v.size()<<endl;
    for(auto x:v)cout<<x[0]<<" "<<x[1]<<endl;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
//RADHE RADHE

#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long

int32_t main() {
    IOS
    int n;
    cin>>n;

    vector<int>v1(n);
    for(int i=0;i<n;i++)cin>>v1[i];
    if(n==1){
        cout<<0<<endl;
    }
    for(int i=n-1;i>=0;i--){

        for(int j=0;j<i;j++){
            if(v1[j]>v1[i])cout<<v1[j]<<" "<<v1[i]<<endl;
        }
        for(int j=0;j<i;j++){
            if(v1[j]<v1[i])cout<<v1[i]<<" "<<v1[j]<<endl;
        }
        for(int j=0;j<i;j++){
            if(v1[j]<v1[i])cout<<v1[j]<<" "<<v1[i]<<endl;
        }
    }
}



Submission (verdict: Wrong answer on test 4):
//RADHE RADHE

#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long

int32_t main() {
    IOS
    int n;
    cin>>n;

    vector<int>v1(n);
    for(int i=0;i<n;i++)cin>>v1[i];
    vector<array<int,2>>v;
    for(int i=n-1;i>=0;i--){

        for(int j=0;j<i;j++){
            if(v1[j]>v1[i])v.push_back({v1[j],v1[i]});
        }
        for(int j=0;j<i;j++){
            if(v1[j]<v1[i])v.push_back({v1[i],v1[j]});
        }
        for(int j=0;j<i;j++){
            if(v1[j]<v1[i])v.push_back({v1[j],v1[i]});
        }
    }
    cout<<v.size()<<endl;
    for(auto x:v)cout<<x[0]<<" "<<x[1]<<endl;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 4):
//RADHE RADHE

#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long

int32_t main() {
    IOS
    int n;
    cin>>n;

    vector<int>v1(n);
    for(int i=0;i<n;i++)cin>>v1[i];
    vector<array<int,2>>v;
    for(int i=n-1;i>=0;i--){

        for(int j=0;j<i;j++){
            if(v1[j]>v1[i])v.push_back({v1[j],v1[i]});
        }
        for(int j=0;j<i;j++){
            if(v1[j]<v1[i])v.push_back({v1[i],v1[j]});
        }
        for(int j=0;j<i;j++){
            if(v1[j]<v1[i])v.push_back({v1[j],v1[i]});
        }
    }
    cout<<v.size()<<endl;
    for(auto x:v)cout<<x[0]<<" "<<x[1]<<endl;
}



Submission (verdict: Wrong answer on test 5):
//RADHE RADHE

#include <bits/stdc++.h>

using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long

int32_t main() {
    IOS
    int n;
    cin>>n;

    vector<int>v1(n);
    for(int i=0;i<n;i++)cin>>v1[i];
    vector<array<int,2>>v;
    for(int i=n-1;i>=0;i--){

        for(int j=0;j<i;j++){
            if(v1[j]>v1[i])v.push_back({v1[j],v1[i]});
        }
        for(int j=i-1;j>=0;j--){
            if(v1[j]<v1[i])v.push_back({v1[i],v1[j]});
        }
        for(int j=0;j<i;j++){
            if(v1[j]<v1[i])v.push_back({v1[j],v1[i]});
        }
    }
    cout<<v.size()<<endl;
    for(auto x:v)cout<<x[0]<<" "<<x[1]<<endl;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

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

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
	cin.tie(0);
	// freopen("outofplace.in", "r", stdin);
    // freopen("outofplace.out", "w", stdout);

	int n; cin >> n;
	vector<int> goal(n);
	for (int i = 0; i < n; i++) {
		cin >> goal[i];
	}
	vector<pair<int, int>> moves;

	vector<int> arr(n);
	for(int i = 0; i < n; i++) {
		arr[i] = i + 1;
	}
	for (int pos = n - 1; pos >= 0; pos--) {
		for (int i = 0; i < pos; i++) {
			if (arr[i] == goal[pos]) {
				moves.emplace_back(arr[i + 1], arr[i]);
				swap(arr[i], arr[i + 1]);
			}
		}
	}
	for (int i = 0; i < n; i++) {
		int j = i;
		while (0 < j and arr[j - 1] < arr[j]) {
			moves.emplace_back(arr[j], arr[j - 1]);
			swap(arr[j - 1], arr[j]);
			j--;
		}
		while (j != i) {
			moves.emplace_back(arr[j + 1], arr[j]);
			swap(arr[j + 1], arr[j]);
			j++;
		}
	}

	cout << moves.size() << endl;
	for (int i = 0; i < moves.size(); i++) {
		cout << moves[i].first << " " << moves[i].second << endl;
	}
	// dbg(arr);
    return 0;
}

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


typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
	cin.tie(0);
	// freopen("outofplace.in", "r", stdin);
    // freopen("outofplace.out", "w", stdout);

	int n; cin >> n;
	vector<int> goal(n);
	for (int i = 0; i < n; i++) {
		cin >> goal[i];
	}
	vector<pair<int, int>> moves;

	vector<int> arr(n);
	map<int, int> positions;
	for(int i = 0; i < n; i++) {
		arr[i] = i + 1;
		positions[i + 1] = i;
	}
	int pos = n -1;
	for (int pos = n - 1; pos >= 0; pos--) {
		for (int i = positions[goal[pos]]; i > 0; i--) {
			moves.emplace_back(arr[i], arr[i - 1]);
			positions[arr[i]] = i - 1;
			positions[arr[i - 1]] = i;
			swap(arr[i], arr[i - 1]);
		}
		for (int i = 0; i < pos; i++) {
			moves.emplace_back(arr[i + 1], arr[i]);
			positions[arr[i]] = i + 1;
			positions[arr[i + 1]] = i;
			swap(arr[i], arr[i + 1]);
		}
	}
	cout << moves.size() << endl;
	for (int i = 0; i < moves.size(); i++) {
		cout << moves[i].first << " " << moves[i].second << endl;
	}
	// dbg(arr);
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

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

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
	cin.tie(0);
	// freopen("outofplace.in", "r", stdin);
    // freopen("outofplace.out", "w", stdout);

	int n; cin >> n;
	vector<int> goal(n);
	for (int i = 0; i < n; i++) {
		cin >> goal[i];
	}
	cout << 2 * (n - 1) << endl;

	vector<int> arr(n);
	for(int i = 0; i < n; i++) {
		arr[i] = i + 1;
	}
	for (int pos = n - 1; pos >= 0; pos--) {
		for (int i = 0; i < pos; i++) {
			if (arr[i] == goal[pos]) {
				cout << arr[i + 1] << " " << arr[i] << endl;
				swap(arr[i], arr[i + 1]);
			}
		}
	}
	for (int i = 0; i < n - 1; i++) {
		if (arr[i] < arr[i + 1]) {
			cout << arr[i + 1] << " " << arr[i] << endl;
			cout << arr[i] << " " << arr[i + 1] << endl;
		}
	}
	// dbg(arr);
    return 0;
}

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

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
	cin.tie(0);
	// freopen("outofplace.in", "r", stdin);
    // freopen("outofplace.out", "w", stdout);

	int n; cin >> n;
	vector<int> goal(n);
	for (int i = 0; i < n; i++) {
		cin >> goal[i];
	}
	vector<pair<int, int>> moves;

	vector<int> arr(n);
	for(int i = 0; i < n; i++) {
		arr[i] = i + 1;
	}
	for (int pos = n - 1; pos >= 0; pos--) {
		for (int i = 0; i < pos; i++) {
			if (arr[i] == goal[pos]) {
				moves.emplace_back(arr[i + 1], arr[i]);
				swap(arr[i], arr[i + 1]);
			}
		}
	}
	for (int i = 0; i < n; i++) {
		int j = i;
		while (0 < j and arr[j - 1] < arr[j]) {
			moves.emplace_back(arr[j], arr[j - 1]);
			swap(arr[j - 1], arr[j]);
			j--;
		}
		while (j != i) {
			moves.emplace_back(arr[j + 1], arr[j]);
			swap(arr[j + 1], arr[j]);
			j++;
		}
	}

	cout << moves.size() << endl;
	for (int i = 0; i < moves.size(); i++) {
		cout << moves[i].first << " " << moves[i].second << endl;
	}
	// dbg(arr);
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


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

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
	cin.tie(0);
	// freopen("outofplace.in", "r", stdin);
    // freopen("outofplace.out", "w", stdout);

	int n; cin >> n;
	vector<int> goal(n);
	for (int i = 0; i < n; i++) {
		cin >> goal[i];
	}
	cout << 2 * (n - 1) << endl;

	vector<int> arr(n);
	for(int i = 0; i < n; i++) {
		arr[i] = i + 1;
	}
	for (int pos = n - 1; pos >= 0; pos--) {
		for (int i = 0; i < pos; i++) {
			if (arr[i] == goal[pos]) {
				cout << arr[i + 1] << " " << arr[i] << endl;
				swap(arr[i], arr[i + 1]);
			}
		}
	}
	for (int i = 0; i < n - 1; i++) {
		if (arr[i] < arr[i + 1]) {
			cout << arr[i + 1] << " " << arr[i] << endl;
			cout << arr[i] << " " << arr[i + 1] << endl;
		}
	}
	// dbg(arr);
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 1):
#include<iostream>
#include<vector>
#include<set>
#define add(a,b) e[a].push_back(b)
#define rep for(int v:e[i])
using namespace std;

const int N=1e6+5;

int t;

static vector<int>e[N];
static multiset<int>s;

inline void work(){
	int n,ans=0;
	cin>>n;
	for(int i=1;i<n;++i){
		int u,v;
		cin>>u>>v;
		add(u,v),add(v,u);
	}
	for(int i=1;i<=n;++i){
		s.insert(e[i].size());
	}
	for(int i=1;i<=n;++i){
		s.erase(s.find(e[i].size()));
		rep{
//			puts("work");
			s.erase(s.find(e[v].size()));
			s.insert(e[v].size()-1);
		}
		ans=max(ans,(int)e[i].size()+*s.rbegin()-1);
		s.insert(e[i].size());
		rep{
			s.erase(s.find(e[v].size()-1));
			s.insert(e[v].size());
		}
	}
	cout<<ans<<"\n";
	return ;
}

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

Previous submission (verdict: Time limit exceeded on test 1):
#include<iostream>
#include<vector>
#include<set>
#define add(a,b) e[a].push_back(b)
#define rep for(int v:e[i])
using namespace std;

const int N=1e6+5;

int t;

static vector<int>e[N];
static multiset<int>s;

inline void work(){
	int n,ans=0;
	cin>>n;
	for(int i=1;i<n;++i){
		int u,v;
		cin>>u>>v;
		add(u,v),add(v,u);
	}
	for(int i=1;i<=n;++i){
		s.insert(e[i].size());
	}
	for(int i=1;i<=n;++i){
		s.erase(s.find(e[i].size()));
		rep{
//			puts("work");
			s.erase(s.find(e[v].size()));
			s.insert(e[v].size()-1);
		}
		ans=max(ans,(int)e[i].size()+*s.rbegin()-1);
		s.insert(e[i].size());
		rep{
			s.erase(s.find(e[v].size()-1));
			s.insert(e[v].size());
		}
	}
	cout<<ans<<"\n";
	return ;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>t;
	while(t--)work();
	return 0;
}

Submission (verdict: Runtime error on test 6):
#include<iostream>
#include<vector>
#include<set>
#define add(a,b) e[a].push_back(b)
#define rep for(int v:e[i])
#define siz(a) e[a].size()
using namespace std;

const int N=5e4+5;

int t;

inline void work(){
	int n,ans=0;
	cin>>n;
	vector<int>e[N];
	multiset<int>s;
	for(int i=1;i<n;++i){
		int u,v;
		cin>>u>>v;
		add(u,v),add(v,u);
	}
	for(int i=1;i<=n;++i){
		s.insert(siz(i));
	}
	for(int i=1;i<=n;++i){
		s.erase(s.find(siz(i)));
		rep{
			s.erase(s.find(siz(v)));
			s.insert(siz(v)-1);
		}
		ans=max(ans,(int)siz(i)+*s.rbegin()-1);
		s.insert(siz(i));
		rep{
			s.erase(s.find(siz(v)-1));
			s.insert(e[v].size());
		}
	}
	cout<<ans<<"\n";
	return ;
}

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

Previous submission (verdict: Time limit exceeded on test 2):
#include<iostream>
#include<vector>
#include<set>
#define add(a,b) e[a].push_back(b)
#define rep for(int v:e[i])
#define siz(a) e[a].size()
using namespace std;

const int N=1e6+5;

int t;

vector<int>e[N];
multiset<int>s;


inline void work(){
	s.clear();
	for(int i=0;i<N;++i)e[i].clear();
	int n,ans=0;
	cin>>n;
	for(int i=1;i<n;++i){
		int u,v;
		cin>>u>>v;
		add(u,v),add(v,u);
	}
	for(int i=1;i<=n;++i){
		s.insert(siz(i));
	}
	for(int i=1;i<=n;++i){
		s.erase(s.find(siz(i)));
		rep{
			s.erase(s.find(siz(v)));
			s.insert(siz(v)-1);
		}
		ans=max(ans,(int)siz(i)+*s.rbegin()-1);
		s.insert(siz(i));
		rep{
			s.erase(s.find(siz(v)-1));
			s.insert(siz(v));
		}
	}
	cout<<ans<<"\n";
	return ;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>t;
	while(t--)work();
	return 0;
}

Submission (verdict: Accepted):
#include<iostream>
#include<vector>
#include<set>
#define add(a,b) e[a].push_back(b)
#define rep for(int v:e[i])
#define siz(a) e[a].size()
using namespace std;

const int N=1e6+5;

int t;

vector<int>e[N];
multiset<int>s;


inline void work(){
	s.clear();
	int n,ans=0;
	cin>>n;
	for(int i=0;i<=n;++i)e[i].clear();
	for(int i=1;i<n;++i){
		int u,v;
		cin>>u>>v;
		add(u,v),add(v,u);
	}
	for(int i=1;i<=n;++i){
		s.insert(siz(i));
	}
	for(int i=1;i<=n;++i){
		s.erase(s.find(siz(i)));
		rep{
			s.erase(s.find(siz(v)));
			s.insert(siz(v)-1);
		}
		ans=max(ans,(int)siz(i)+*s.rbegin()-1);
		s.insert(siz(i));
		rep{
			s.erase(s.find(siz(v)-1));
			s.insert(siz(v));
		}
	}
	cout<<ans<<"\n";
	return ;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>t;
	while(t--)work();
	return 0;
}