ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define ENDL '\n'
#define MAXN 100001
#define mod 998244353
#define ft first
#define sc second
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef long double ld;
typedef tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update>ordered_set;

ll n, m, k;

ll binpow(ll a, ll b){
	if(b==0)return 1;
	if(b==1)return a;
	ll num=binpow(a,b>>1)%mod, p=1;
	if(b%2)p=a;
	ll part=(num*num)%mod;
	return (part*p)%mod;
}

const int mov_f[]={-1,0,1, 0};
const int mov_c[]={0,-1,0, 1};

bool rec(multiset<ll>&sa, ll x){
    ll a=x/2, b=(x+1)/2;
    if(x==1 || x==0)return 0;
    bool flag1=0, flag2=0;
    if(sa.find(a)!=sa.end()){
        sa.erase(sa.find(a));
        flag1=1;
    }
    else flag1=rec(sa, a);

    if(sa.find(b)!=sa.end()){
        sa.erase(sa.find(b));
        flag2=1;
    }
    else flag2=rec(sa, b);

    return flag1 && flag2;

}

void solve(){
  cin>>n;
  /*vll v(n);

  ll a=0, b=0;
  map<ll, ll>mp;
  for(int i=0; i<n; i++){
     cin>>v[i];
     mp[v[i]]++;
  }

  vll fact(n+1);
  fact[0]=1;
  for(int i=1; i<=n; i++)fact[i]=(fact[i-1]*i)%mod;

  ll dp[n][2];
  for(int i=0; i<n; i++)dp[i][0]=dp[i][1]=0;
  dp[0][0]=1;
  ll c=0;

  set<ll>s1, s0;
  if(v[0]!=0){
    dp[0][1]=-1; c++;
    s0.insert(0);
    s1.insert(1);
    }
  dp[0][1]++;


  for(int i=1; i<n; i++){
    dp[i][0]=dp[i-1][1];


    //cout<<i<<" "<<dp[i][0]<<" "<<dp[i][1]<<ENDL;
  }

  cout<<(dp[n-1][0]+dp[n-1][1])%mod<<ENDL;*/

  cin>>m;
  vll a(n), b(m);
  map<ll, ll>ca, cb;
  for(int i=0; i<n; i++){
    cin>>a[i];
    ca[a[i]]++;
  }

  for(int i=0; i<m; i++){
    cin>>b[i];
    cb[b[i]]++;
  }

  if(m>n){
    cout<<"NO"<<ENDL;
    return;
  }

  multiset<ll>sa, sb;
  for(int i:a)sa.insert(i);
  for(int i: b)sb.insert(i);

  vll del;
  for(auto i=sb.begin(); i!=sb.end(); i++){
    if(sa.find(*i)!=sa.end()){
        sa.erase(sa.find(*i));
        del.push_back(*i);
    }
  }

  for(ll i: del)sb.erase(sb.find(i));

  while(sa.size()){
    if(sa.size()==1){
        if(sb.size()==1 && *sa.begin() == *sb.begin())cout<<"YES"<<ENDL;
        else cout<<"NO"<<ENDL;
        return;
    }

    ll x=*sa.begin();
    sa.erase(sa.begin());

    if(sb.find(x)!=sb.end()){
        sb.erase(sb.find(x));
        continue;
    }

    ll y=*sa.begin();
    sa.erase(sa.begin());

    if(sb.find(y)!=sb.end()){
        sa.insert(x);
        sb.erase(sb.find(y));
        continue;
    }

    if(abs(x-y)<=1)sa.insert(x+y);
    else{
        cout<<"NO"<<ENDL;
        return;
    }
  }

   cout<<"YES"<<ENDL;



}

int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cout.precision(0);
    cout<<fixed;
	//freopen("fencedin.in", "r", stdin);
	//freopen("fencedin.out", "w", stdout);

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

	return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with_stdio(0);    cin.tie(0);
#define ff first
#define ss second
using namespace std;
const ll MOD=998244353;
const int MAX=2e6+5;

int T[MAX];
vector<int>v[MAX];

void go(){
    int n;  cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b;    cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
        T[a]++;
        T[b]++;
    }
    int a=0;
    int maxi=0;
    for(int i=1;i<=n;i++){
        if(T[i]>maxi){
            a=i;
            maxi=T[i];
        }
    }
    int ans=1;
    ans+=T[a];
    for(auto it:v[a]){
        T[it]--;
    }
    //cout<<T[a]<<endl;
    T[a]=0;
    a=0;
    maxi=0;
    for(int i=1;i<=n;i++){
        if(T[i]>maxi){
            a=i;
            maxi=T[i];
        }
    }
    ans+=T[a];
    cout<<ans-2<<endl;
    for(int i=1;i<=n;i++){
        v[i].clear();
        T[i]=0;
    }
}

int main(){
    fastio;
    int t;  cin>>t;
    while(t--)
        go();
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with_stdio(0);    cin.tie(0);
#define ff first
#define ss second
using namespace std;
const ll MOD=998244353;
const int MAX=2e6+5;

int T[MAX];
vector<int>v[MAX];

void go(){
    int n;  cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b;    cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
        T[a]++;
        T[b]++;
    }
    int a=0;
    int maxi=0;
    int cant=0;
    for(int i=1;i<=n;i++){
        if(T[i]>maxi){
            a=i;
            cant=1;
            maxi=T[i];
        }
        else    if(T[i]==maxi)  cant++;
    }
    if(cant>2){
        cout<<2*maxi-1<<endl;
        return;
    }
    else{
        int ans=1;
        ans+=T[a];
        for(auto it:v[a]){
            T[it]--;
        }
        //cout<<T[a]<<endl;
        T[a]=0;
        a=0;
        maxi=0;
        for(int i=1;i<=n;i++){
            if(T[i]>=maxi){
                a=i;
                maxi=T[i];
            }
        }
        ans+=T[a];
        cout<<ans-2<<endl;
    }
    
    for(int i=1;i<=n;i++){
        v[i].clear();
        T[i]=0;
    }
}

int main(){
    fastio;
    int t;  cin>>t;
    while(t--)
        go();
    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with_stdio(0);    cin.tie(0);
#define ff first
#define ss second
using namespace std;
const ll MOD=998244353;
const int MAX=2e6+5;

int T[MAX];
vector<int>v[MAX];

void go(){
    int n;  cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b;    cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
        T[a]++;
        T[b]++;
    }
    int a=0;
    int maxi=0;
    int cant=0;
    for(int i=1;i<=n;i++){
        if(T[i]>maxi){
            a=i;
            cant=1;
            maxi=T[i];
        }
        else    if(T[i]==maxi)  cant++;
    }
    if(cant>2){
        cout<<2*maxi-1<<endl;
    }
    else{
        int ans=1;
        ans+=T[a];
        for(auto it:v[a]){
            T[it]--;
        }
        //cout<<T[a]<<endl;
        T[a]=0;
        a=0;
        maxi=0;
        for(int i=1;i<=n;i++){
            if(T[i]>=maxi){
                a=i;
                maxi=T[i];
            }
        }
        ans+=T[a];
        cout<<ans-2<<endl;
    }
    
    for(int i=1;i<=n;i++){
        v[i].clear();
        T[i]=0;
    }
}

int main(){
    fastio;
    int t;  cin>>t;
    while(t--)
        go();
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with_stdio(0);    cin.tie(0);
#define ff first
#define ss second
using namespace std;
const ll MOD=998244353;
const int MAX=2e6+5;

int T[MAX];
vector<int>v[MAX];

void go(){
    int n;  cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b;    cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
        T[a]++;
        T[b]++;
    }
    int a=0;
    int maxi=0;
    for(int i=1;i<=n;i++){
        if(T[i]>maxi){
            a=i;
            maxi=T[i];
        }
    }
    int ans=1;
    ans+=T[a];
    for(auto it:v[a]){
        T[it]--;
    }
    //cout<<T[a]<<endl;
    T[a]=0;
    a=0;
    maxi=0;
    for(int i=1;i<=n;i++){
        if(T[i]>maxi){
            a=i;
            maxi=T[i];
        }
    }
    ans+=T[a];
    cout<<ans-2<<endl;
    for(int i=1;i<=n;i++){
        v[i].clear();
        T[i]=0;
    }
}

int main(){
    fastio;
    int t;  cin>>t;
    while(t--)
        go();
    return 0;
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with_stdio(0);    cin.tie(0);
#define ff first
#define ss second
using namespace std;
const ll MOD=998244353;
const int MAX=2e6+5;

int T[MAX];
vector<int>v[MAX];

void go(){
    int n;  cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b;    cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
        T[a]++;
        T[b]++;
    }
    int a=0;
    int maxi=0;
    int cant=0;
    for(int i=1;i<=n;i++){
        if(T[i]>maxi){
            a=i;
            cant=1;
            maxi=T[i];
        }
        else    if(T[i]==maxi)  cant++;
    }
    if(cant>2){
        cout<<2*maxi-1<<endl;
        return;
    }
    int ans=1;
    ans+=T[a];
    for(auto it:v[a]){
        T[it]--;
    }
    //cout<<T[a]<<endl;
    T[a]=0;
    a=0;
    maxi=0;
    for(int i=1;i<=n;i++){
        if(T[i]>=maxi){
            a=i;
            maxi=T[i];
        }
    }
    ans+=T[a];
    cout<<ans-2<<endl;
    for(int i=1;i<=n;i++){
        v[i].clear();
        T[i]=0;
    }
}

int main(){
    fastio;
    int t;  cin>>t;
    while(t--)
        go();
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with_stdio(0);    cin.tie(0);
#define ff first
#define ss second
using namespace std;
const ll MOD=998244353;
const int MAX=2e6+5;

int T[MAX];
vector<int>v[MAX];

void go(){
    int n;  cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b;    cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
        T[a]++;
        T[b]++;
    }
    int a=0;
    int maxi=0;
    int cant=0;
    for(int i=1;i<=n;i++){
        if(T[i]>maxi){
            a=i;
            cant=1;
            maxi=T[i];
        }
        else    if(T[i]==maxi)  cant++;
    }
    if(cant>2){
        cout<<2*maxi-1<<endl;
        return;
    }
    int ans=1;
    ans+=T[a];
    for(auto it:v[a]){
        T[it]--;
    }
    //cout<<T[a]<<endl;
    T[a]=0;
    a=0;
    maxi=0;
    for(int i=1;i<=n;i++){
        if(T[i]>=maxi){
            a=i;
            maxi=T[i];
        }
    }
    ans+=T[a];
    cout<<ans-2<<endl;
    for(int i=1;i<=n;i++){
        v[i].clear();
        T[i]=0;
    }
}

int main(){
    fastio;
    int t;  cin>>t;
    while(t--)
        go();
    return 0;
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with_stdio(0);    cin.tie(0);
#define ff first
#define ss second
using namespace std;
const ll MOD=998244353;
const int MAX=2e6+5;

int T[MAX];
vector<int>v[MAX];

void go(){
    int n;  cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b;    cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
        T[a]++;
        T[b]++;
    }
    int a=0;
    int maxi=0;
    int cant=0;
    for(int i=1;i<=n;i++){
        if(T[i]>maxi){
            a=i;
            cant=1;
            maxi=T[i];
        }
        else    if(T[i]==maxi)  cant++;
    }
    if(cant>2){
        cout<<2*maxi-1<<endl;
        return;
    }
    else{
        int ans=1;
        ans+=T[a];
        for(auto it:v[a]){
            T[it]--;
        }
        //cout<<T[a]<<endl;
        T[a]=0;
        a=0;
        maxi=0;
        for(int i=1;i<=n;i++){
            if(T[i]>=maxi){
                a=i;
                maxi=T[i];
            }
        }
        ans+=T[a];
        cout<<ans-2<<endl;
    }
    
    for(int i=1;i<=n;i++){
        v[i].clear();
        T[i]=0;
    }
}

int main(){
    fastio;
    int t;  cin>>t;
    while(t--)
        go();
    return 0;
}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
using namespace std;

int main(){
  int t;
  cin>>t;
  while (t--)
  {
    int n;
    cin>>n;
    vector<int>v;
    for (int i = 0; i <n; i++)
    {
      int k;
      cin>>k;
      v.push_back(k);
    }
    int sum=0;
    int check=0;
    for (auto i:v)
    {
        sum+=i;
    }

    if (n==1)
    {
      cout<<"YES"<<endl;
    }
    else if (sum%n!=0)
    {
      cout<<"NO"<<endl;
    }
    else{
      for (int i = 0; i <2; i++)
      {
        int avg=0;
        int num=0;
         while (i<n)
         {
          avg+=v[i];
          i+=2; 
          num++;
         }
         if (avg%num!=0)
         {
           check++;
         }
         
      }

       if (check)
       {
       cout<<"NO"<<endl;
       }
        else{cout<<"YES"<<endl;}
    
  }
    }
   
  
}

Submission (verdict: Wrong answer on test 3):
#include<iostream>
#include<vector>
using namespace std;

int main(){
  int t;
  cin>>t;
  while (t--)
  {
    int n;
    cin>>n;
    vector<int>v(n);
    for (int i = 0; i <n; i++)
    {
      
      cin>>v[i];
    }
   
   int evensum=0;
   int even=0,oddsum=0,odd=0;
   for (int i = 0; i <n; i++)
   {
      if (i%2==0)
       {
          evensum+=v[i];
          even++;
       }
       else{
         oddsum+=v[i];
         odd++;
       }   
   }

   if (evensum%even==0 && oddsum%odd==0)
   {
       if (evensum/even==oddsum/odd)
       {
          cout<<"YES"<<endl;
       }
       else{cout<<"NO"<<endl;}
       
   }
   else{cout<<"NO"<<endl;}
   
  }
}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include<iostream>
#include<vector>
using namespace std;

int main(){
  int t;
  cin>>t;
  while (t--)
  {
    int n;
    cin>>n;
    vector<int>v(n);
    for (int i = 0; i <n; i++)
    {
      
      cin>>v[i];
    }
   
   int evensum=0;
   int even=0,oddsum=0,odd=0;
   for (int i = 0; i <n; i++)
   {
      if (i%2==0)
       {
          evensum+=v[i];
          even++;
       }
       else{
         oddsum+=v[i];
         odd++;
       }   
   }

   if (evensum%even==0 && oddsum%odd==0)
   {
       if (evensum/even==oddsum/odd)
       {
          cout<<"YES"<<endl;
       }
       else{cout<<"NO"<<endl;}
       
   }
   else{cout<<"NO"<<endl;}
   
  }
}

Submission (verdict: Accepted):
#include<iostream>
#include<vector>
using namespace std;

int main(){
  int t;
  cin>>t;
  while (t--)
  {
    int n;
    cin>>n;
    vector<int>v(n);
    for (int i = 0; i <n; i++)
    {
      
      cin>>v[i];
    }
   
   long long evensum=0;
   long long even=0,oddsum=0,odd=0;
   for (int i = 0; i <n; i++)
   {
      if (i%2==0)
       {
          evensum+=v[i];
          even++;
       }
       else{
         oddsum+=v[i];
         odd++;
       }   
   }

   if (evensum%even==0 && oddsum%odd==0)
   {
       if (evensum/even==oddsum/odd)
       {
          cout<<"YES"<<endl;
       }
       else{cout<<"NO"<<endl;}
       
   }
   else{cout<<"NO"<<endl;}
   
  }
}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
using namespace std;

int main(){
  int t;
  cin>>t;
  while (t--)
  {
    int n;
    cin>>n;
    vector<int>v;
    for (int i = 0; i <n; i++)
    {
      int k;
      cin>>k;
      v.push_back(k);
    }
    int sum=0;
    int check=0;
    for (auto i:v)
    {
        sum+=i;
    }

    if (n==1)
    {
      cout<<"YES"<<endl;
    }
    else if (sum%n!=0)
    {
      cout<<"NO"<<endl;
    }
    else{
      for (int i = 0; i <2; i++)
      {
        int avg=0;
        int num=0;
         while (i<n)
         {
          avg+=v[i];
          i+=2; 
          num++;
         }
         if (avg%num!=0)
         {
           check++;
         }
         
      }

       if (check)
       {
       cout<<"NO"<<endl;
       }
        else{cout<<"YES"<<endl;}
    
  }
    }
   
  
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 4):
#include <iostream>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>
#include <iomanip>
#include <ctype.h>
using namespace std;
// #define int long long
#define fo(i, n) for (int i = 0; i < n; ++i)
#define print(v) for(auto it:v)cout<<it<<" "; cout<<endl;
#define vvi vector<vector<int>>
#define vi vector<int>
#define vll vector<long long>
#define ll long long
#define pb push_back
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define sortit(v) sort(v.begin(),v.end())
const ll mod = 998244353;

void solve() 
{
	int n;
	cin>>n;

	vi v;
	set<int> st;
	fo(i, n)
	{
		int x;
		cin>>x;
		v.pb(x);
		st.insert(x);
	}


	map<pair<int, int>, int> mp;
	vvi ans;

	fo(i, n)
	{
		st.erase(v[i]);
		for(int ii = v[i] - 1;ii>=1;ii--)
		{
			if(st.find(ii) != st.end())
			{
				mp[{ii, v[i]}] = 1;
				ans.pb({v[i], ii});	
			}
		}
	}

	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			if(mp.find({v[i], v[j]}) == mp.end() && mp.find({v[j], v[i]}) == mp.end())
			{
				ans.pb({v[j], v[i]});
				ans.pb({v[i], v[j]});
			}
		}
	}

	cout<<ans.size()<<endl;
	for(auto it : ans)
	{
		print(it);
	}
}


 
int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    cout<<setprecision(12);
    // cin >> t;
    int i = 1;
    while (t--) {
    	i++;
        solve();
    }
}

Submission (verdict: Accepted):
#include <iostream>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>
#include <iomanip>
#include <ctype.h>
using namespace std;
// #define int long long
#define fo(i, n) for (int i = 0; i < n; ++i)
#define print(v) for(auto it:v)cout<<it<<" "; cout<<endl;
#define vvi vector<vector<int>>
#define vi vector<int>
#define vll vector<long long>
#define ll long long
#define pb push_back
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define sortit(v) sort(v.begin(),v.end())
const ll mod = 998244353;

void solve() 
{
	int n;
	cin>>n;

	vi v;
	set<int> st;
	fo(i, n)
	{
		int x;
		cin>>x;
		v.pb(x);
		st.insert(x);
	}


	map<pair<int, int>, int> mp;
	vvi ans;

	vi vv;
	for(int i=n;i>=1;i--)
	{
		vv.pb(i);
	}

	fo(i, n)
	{
		st.erase(vv[i]);
		for(int ii = vv[i] - 1;ii>=1;ii--)
		{
			if(st.find(ii) != st.end())
			{
				// mp[{ii, vv[i]}] = 1;
				ans.pb({vv[i], ii});	
			}
		}
	}
	for(int i=1;i<=n;i++)
		st.insert(i);

	fo(i, n)
	{
		st.erase(v[i]);
		for(int ii = v[i] + 1;ii <= n;ii++)
		{
			if(st.find(ii) != st.end())
			{
				// mp[{ii, vv[i]}] = 1;
				ans.pb({v[i], ii});	
			}
		}
	}

	

	cout<<ans.size()<<endl;
	for(auto it : ans)
	{
		print(it);
	}
}


 
int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    cout<<setprecision(12);
    // cin >> t;
    int i = 1;
    while (t--) {
    	i++;
        solve();
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 4):
#include <iostream>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>
#include <iomanip>
#include <ctype.h>
using namespace std;
// #define int long long
#define fo(i, n) for (int i = 0; i < n; ++i)
#define print(v) for(auto it:v)cout<<it<<" "; cout<<endl;
#define vvi vector<vector<int>>
#define vi vector<int>
#define vll vector<long long>
#define ll long long
#define pb push_back
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define sortit(v) sort(v.begin(),v.end())
const ll mod = 998244353;

void solve() 
{
	int n;
	cin>>n;

	vi v;
	set<int> st;
	fo(i, n)
	{
		int x;
		cin>>x;
		v.pb(x);
		st.insert(x);
	}


	map<pair<int, int>, int> mp;
	vvi ans;

	fo(i, n)
	{
		st.erase(v[i]);
		for(int ii = v[i] - 1;ii>=1;ii--)
		{
			if(st.find(ii) != st.end())
			{
				mp[{ii, v[i]}] = 1;
				ans.pb({v[i], ii});	
			}
		}
	}

	for(int i=0;i<n-1;i++)
	{
		if(mp.find({v[i], v[i+1]}) == mp.end() 
			&& mp.find({v[i+1], v[i]}) == mp.end())
		{
			ans.pb({v[i+1], v[i]});
			ans.pb({v[i], v[i+1]});
		}
	}

	cout<<ans.size()<<endl;
	for(auto it : ans)
	{
		print(it);
	}
}


 
int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    cout<<setprecision(12);
    // cin >> t;
    int i = 1;
    while (t--) {
    	i++;
        solve();
    }
}

Submission (verdict: Wrong answer on test 4):
#include <iostream>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>
#include <iomanip>
#include <ctype.h>
using namespace std;
// #define int long long
#define fo(i, n) for (int i = 0; i < n; ++i)
#define print(v) for(auto it:v)cout<<it<<" "; cout<<endl;
#define vvi vector<vector<int>>
#define vi vector<int>
#define vll vector<long long>
#define ll long long
#define pb push_back
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define sortit(v) sort(v.begin(),v.end())
const ll mod = 998244353;

void solve() 
{
	int n;
	cin>>n;

	vi v;
	set<int> st;
	fo(i, n)
	{
		int x;
		cin>>x;
		v.pb(x);
		st.insert(x);
	}


	map<pair<int, int>, int> mp;
	vvi ans;

	fo(i, n)
	{
		st.erase(v[i]);
		for(int ii = v[i] - 1;ii>=1;ii--)
		{
			if(st.find(ii) != st.end())
			{
				mp[{ii, v[i]}] = 1;
				ans.pb({v[i], ii});	
			}
		}
	}

	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			if(mp.find({v[i], v[j]}) == mp.end() && mp.find({v[j], v[i]}) == mp.end())
			{
				ans.pb({v[j], v[i]});
				ans.pb({v[i], v[j]});
			}
		}
	}

	cout<<ans.size()<<endl;
	for(auto it : ans)
	{
		print(it);
	}
}


 
int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    cout<<setprecision(12);
    // cin >> t;
    int i = 1;
    while (t--) {
    	i++;
        solve();
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 4):
#include <iostream>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>
#include <iomanip>
#include <ctype.h>
using namespace std;
// #define int long long
#define fo(i, n) for (int i = 0; i < n; ++i)
#define print(v) for(auto it:v)cout<<it<<" "; cout<<endl;
#define vvi vector<vector<int>>
#define vi vector<int>
#define vll vector<long long>
#define ll long long
#define pb push_back
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define sortit(v) sort(v.begin(),v.end())
const ll mod = 998244353;

void solve() 
{
	int n;
	cin>>n;

	vi v;
	set<int> st;
	fo(i, n)
	{
		int x;
		cin>>x;
		v.pb(x);
		st.insert(x);
	}


	map<pair<int, int>, int> mp;
	vvi ans;

	fo(i, n)
	{
		st.erase(v[i]);
		for(int ii = v[i] - 1;ii>=1;ii--)
		{
			if(st.find(ii) != st.end())
			{
				mp[{ii, v[i]}] = 1;
				ans.pb({v[i], ii});	
			}
		}
	}

	for(int i=0;i<n-1;i++)
	{
		if(mp.find({v[i], v[i+1]}) == mp.end() 
			&& mp.find({v[i+1], v[i]}) == mp.end())
		{
			ans.pb({v[i+1], v[i]});
			ans.pb({v[i], v[i+1]});
		}
	}

	cout<<ans.size()<<endl;
	for(auto it : ans)
	{
		print(it);
	}
}


 
int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    cout<<setprecision(12);
    // cin >> t;
    int i = 1;
    while (t--) {
    	i++;
        solve();
    }
}
Problem: 2049B - pspspsps
Language: C++20 (GCC 13-64)

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

void solve() {
	int n; cin >> n;
	string s; cin >> s;
	int mx = -1, cnt = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'p') {
			int x = 1, y = i + 1;
			cnt++;
			if (mx > y) {
				cout << "NO\n";
				return;
			}
			mx = max(mx, y);
		}
		else if (s[i] == 's') {
			int x = n - i, y = n;
			if (mx > y or cnt) {
				cout << "NO\n";
				return;
			}
			mx = n;
		}
	}
	cout << "YES\n";
}

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

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

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

void solve() {
	int n; cin >> n;
	string s; cin >> s;
	int mx = -1, cnt = 0, mn = n;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'p') {
			int x = 1, y = i + 1;
			cnt++;
			if (mx > y or x > mn) {
				cout << "NO\n";
				return;
			}
			mn = min(mn, x);
			mx = max(mx, y);
		}
		else if (s[i] == 's') {
			int x = n - i, y = n;
			if (mx > y or cnt or x > mn) {
				cout << "NO\n";
				return;
			}
			mn = min(mn, x);
			mx = n;
		}
	}
	cout << "YES\n";
}

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

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