ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


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

using namespace std;



#define zedanov                   \

ios_base::sync_with_stdio(0); \

cin.tie(0);                   \

cout.tie(0);

#define int long long

#define el "\n"

const int N = 2e5 + 5, md = 1e9 + 7, inf = 1e9;

// Verify Logic, Check Constrains

// Overflow, Fits in Time/Memory ?



void doWork()

{

int n;

cin >> n;

int a[n];

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

cin >> a[i];

if (a[0] > a[1])

{

cout << "NO\n";

return;

}



bool good = 1;

for (int i = 2; i < n; i++)

{

if (a[i] < a[i - 1])

{

a[i - 1] -= a[i - 2];

a[i - 2] -= a[i - 2];

if (a[i] < a[i - 1])

{

good = 0;

break;

}

}

}



if (good)

cout << "YES\n";

else

cout << "NO\n";

}



signed main()

{

zedanov int t = 1;

cin >> t;

while (t--)

doWork();



return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

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

using namespace std;



#define zedanov                   \

ios_base::sync_with_stdio(0); \

cin.tie(0);                   \

cout.tie(0);

#define int long long

#define el "\n"

const int N = 2e5 + 5, md = 1e9 + 7, inf = 1e9;

// Verify Logic, Check Constrains

// Overflow, Fits in Time/Memory ?



void doWork()

{

int n;

cin >> n;

int a[n];

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

cin >> a[i];

if (a[0] > a[1])

{

cout << "NO\n";

return;

}



a[1] %= a[0];

a[0] = 0;



bool good = 1;

for (int i = 2; i < n; i++)

{

if (a[i] < a[i - 1])

{

good = 0;

break;

}



if (a[i - 1])

{

if (a[i] % a[i - 1] == 0)

a[i] = a[i - 1];

else

a[i] = (a[i] % a[i - 1]) + a[i - 1];

}

}



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

//     cout << a[i] << " ";

// cout << el;



if (good)

cout << "YES\n";

else

cout << "NO\n";

}



signed main()

{

zedanov int t = 1;

cin >> t;

while (t--)

doWork();



return 0;

}

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

using namespace std;



#define zedanov                   \

ios_base::sync_with_stdio(0); \

cin.tie(0);                   \

cout.tie(0);

#define int long long

#define el "\n"

const int N = 2e5 + 5, md = 1e9 + 7, inf = 1e9;

// Verify Logic, Check Constrains

// Overflow, Fits in Time/Memory ?



void doWork()

{

int n;

cin >> n;

int a[n];

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

cin >> a[i];



bool good = 1;

for (int i = 1; i < n; i++)

{

int mini = min(a[i], a[i - 1]);

a[i] -= mini;

a[i - 1] -= mini;



good &= (a[i] >= a[i - 1]);

}

if (good)

cout << "YES\n";

else

cout << "NO\n";

}



signed main()

{

zedanov int t = 1;

cin >> t;

while (t--)

doWork();



return 0;

}
Problem: 2062C - Cirno and Operations
Language: PyPy 3-64


Submission (verdict: Wrong answer on test 1):
from collections import Counter

t = int(input())


def solve():
    n = input()
    a = list(map(int, input().split()))
    if n == 1:
        print(a[0])
        return
    ans = abs(sum(a))
    while len(a) > 1:
        b = [0] * (len(a) - 1)
        for i in range(len(a) - 1, 0, -1):
            b[i - 1] = a[i] - a[i - 1]
        a = b.copy()
        ans = max(ans, abs(sum(a)))
    print(ans)


for _ in range(t):
    solve()
Problem: 2062C - Cirno and Operations
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 1):
from collections import Counter

t = int(input())


def solve():
    n = input()
    a = list(map(int, input().split()))
    if n == 1:
        print(a[0])
        return
    ans = abs(sum(a))
    while len(a) > 1:
        b = [0] * (len(a) - 1)
        for i in range(len(a) - 1, 0, -1):
            b[i - 1] = a[i] - a[i - 1]
        a = b.copy()
        ans = max(ans, abs(sum(a)))
    print(ans)


for _ in range(t):
    solve()


Submission (verdict: Wrong answer on test 2):
from collections import Counter

t = int(input())


def solve():
    n = int(input())
    a = list(map(int, input().split()))
    if n == 1:
        print(a[0])
        return
    ans = abs(sum(a))
    while len(a) > 1:
        b = [0] * (len(a) - 1)
        for i in range(len(a) - 1, 0, -1):
            b[i - 1] = a[i] - a[i - 1]
        a = b.copy()
        ans = max(ans, abs(sum(a)))
    print(ans)


for _ in range(t):
    solve()
Problem: 2062C - Cirno and Operations
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 2):
from collections import Counter

t = int(input())


def solve():
    n = int(input())
    a = list(map(int, input().split()))
    if n == 1:
        print(a[0])
        return
    ans = abs(sum(a))
    while len(a) > 1:
        b = [0] * (len(a) - 1)
        for i in range(len(a) - 1, 0, -1):
            b[i - 1] = a[i] - a[i - 1]
        a = b.copy()
        ans = max(ans, abs(sum(a)))
    print(ans)


for _ in range(t):
    solve()


Submission (verdict: Accepted):
from collections import Counter

t = int(input())


def solve():
    n = int(input())
    a = list(map(int, input().split()))
    if n == 1:
        print(a[0])
        return
    ans = sum(a)
    while len(a) > 1:
        b = [0] * (len(a) - 1)
        for i in range(len(a) - 1, 0, -1):
            b[i - 1] = a[i] - a[i - 1]
        a = b.copy()
        ans = max(ans, abs(sum(a)))
    print(ans)


for _ in range(t):
    solve()
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

using namespace std;



// Fast I/O

#define FAST_IO                       \

    ios_base::sync_with_stdio(false); \

    cin.tie(nullptr);                 \

    cout.tie(nullptr);



// Aliases for convenience

using ll = long long;

using vi = vector<int>;

using vll = vector<long long>;

using pii = pair<int, int>;



// Constants

const int MOD = 1e9 + 7;

const int INF = INT_MAX;



// Solve function

void solve()

{

    int n , l ,r ; 

    cin >> n >> l >> r ; 

    vector<int> v(n);

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

        cin >> v[i];

    }

    int len = r-l+1 ; 

    int ans = 0 ; 

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

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

        ans += v[i];

    }

    cout << ans << "\n";

}



int main()

{

    FAST_IO;



    int t; // Number of test cases

    cin >> t;

    while (t--)

    {

        solve();

    }



    return 0;

}

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

// Fast I/O
#define FAST_IO                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr);                 \
    cout.tie(nullptr);

// Aliases for convenience
using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;
using pii = pair<int, int>;

// Constants
const int MOD = 1e9 + 7;
const int INF = INT_MAX;

// Solve function
void solve()
{
    int n, l, r;
    cin >> n >> l >> r;
    vector<int> v(n);
    for (int i = 0; i < n; i++){
        cin >> v[i];
    }
    vector<int> left;
    vector<int> right;
    vector<int> mid;
    for (int i = 0; i<n ; i++){
        if(i<l-1){
            left.push_back(v[i]);
        }else if(i>r-1){
            right.push_back(v[i]);
        }else{
            mid.push_back(v[i]);
        }
    }
    sort(left.begin(), left.end());
    sort(right.begin(), right.end());
    sort(mid.begin(), mid.end());
    int mergeWithLeft = 0 ;
    int mergeWithRight = 0;
    int L_idx = 0 ; 
    int R_idx = 0;
    for (int i = mid.size()-1; i>= 0 ; i--){
        if(R_idx<right.size()){
            mergeWithRight +=  min(mid[i],right[R_idx]);
            R_idx++;
        }else{
            mergeWithRight += mid[i];
        }
        if(L_idx<left.size()){
            mergeWithLeft +=  min(mid[i],left[L_idx]);
            L_idx++;
        }else{
            mergeWithLeft += mid[i];
        }
    }
    cout << min(mergeWithLeft, mergeWithRight) << "\n";
}

int main()
{
    FAST_IO;

    int t; // Number of test cases
    cin >> t;
    while (t--)
    {
        solve();
    }

    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


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

using namespace std;



// Fast I/O

#define FAST_IO                       \

    ios_base::sync_with_stdio(false); \

    cin.tie(nullptr);                 \

    cout.tie(nullptr);



// Aliases for convenience

using ll = long long;

using vi = vector<int>;

using vll = vector<long long>;

using pii = pair<int, int>;



// Constants

const int MOD = 1e9 + 7;

const int INF = INT_MAX;



// Solve function

void solve()

{

    int n , l ,r ; 

    cin >> n >> l >> r ; 

    vector<int> v(n);

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

        cin >> v[i];

    }

    int len = r-l+1 ; 

    int ans = 0 ; 

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

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

        ans += v[i];

    }

    cout << ans << "\n";

}



int main()

{

    FAST_IO;



    int t; // Number of test cases

    cin >> t;

    while (t--)

    {

        solve();

    }



    return 0;

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

Previous submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int N = 2e5+1;
ll mod = 1e9+7;


int main(){
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int T;
  cin>>T;
  while(T--){ 
    int n;
    cin>>n;
    vector<vector<int>>adj(n+1);
    vector<int>deg(n+1);
    for(int i=1;i<n;i++){
      int a,b;
      cin>>a>>b;
      deg[a]++;
      deg[b]++;
      adj[a].pb(b);
      adj[b].pb(a);
    }
    set<pair<int,int>>st;
    for(int i=1;i<=n;i++){
      st.insert({deg[i],i});
    }
    int ans  =1;
    pair<int,int> node1 = *st.rbegin();
    
    ans+=node1.first-1;
    st.erase(node1);
    for(int adn : adj[node1.second]){
      st.erase({deg[adn],adn});
      deg[adn]--;
      st.insert({deg[adn],adn});
    }
    pair<int,int> node2 = *st.rbegin();
    ans+=node2.first-1;
    cout<<ans<<endl;


  }
    return 0;
}





  
  

Submission (verdict: Time limit exceeded on test 9):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int N = 2e5+1;
ll mod = 1e9+7;

int help(int node,vector<int>&deg,int n,vector<set<int>>&adj){
    int ans =0;
    for(int i=1;i<=n;i++){
      if(i!=node){
        if(adj[node].find(i)==adj[node].end()){
          ans = max(ans,deg[i]);
        }else{
          ans = max(ans,deg[i]-1);
        }
      }
    }
    return ans-1;
}

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int T;
  cin>>T;
  while(T--){ 
    int n;
    cin>>n;
    vector<set<int>>adj(n+1);
    vector<int>deg(n+1);
    for(int i=1;i<n;i++){
      int a,b;
      cin>>a>>b;
      deg[a]++;
      deg[b]++;
      adj[a].insert(b);
      adj[b].insert(a);
    }
    int ans=1;
    int maxi =0;
    for(int i=1;i<=n;i++){
      maxi = max(maxi,deg[i]);
    }
    ans+=maxi-1;
    int com =0;
    for(int i=1;i<=n;i++){
      if(maxi==deg[i]){
        int pos = ans +help(i,deg,n,adj);
        com = max(com,pos);
        //cout<<i<<" "<<pos<<endl;
      }
    }
    cout<<com<<endl;

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

Previous submission (verdict: Time limit exceeded on test 9):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int N = 2e5+1;
ll mod = 1e9+7;

int help(int node,vector<int>&deg,int n,vector<set<int>>&adj){
    int ans =0;
    for(int i=1;i<=n;i++){
      if(i!=node){
        if(adj[node].find(i)==adj[node].end()){
          ans = max(ans,deg[i]);
        }else{
          ans = max(ans,deg[i]-1);
        }
      }
    }
    return ans-1;
}

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int T;
  cin>>T;
  while(T--){ 
    int n;
    cin>>n;
    vector<set<int>>adj(n+1);
    vector<int>deg(n+1);
    for(int i=1;i<n;i++){
      int a,b;
      cin>>a>>b;
      deg[a]++;
      deg[b]++;
      adj[a].insert(b);
      adj[b].insert(a);
    }
    int ans=1;
    int maxi =0;
    for(int i=1;i<=n;i++){
      maxi = max(maxi,deg[i]);
    }
    ans+=maxi-1;
    int com =0;
    for(int i=1;i<=n;i++){
      if(maxi==deg[i]){
        int pos = ans +help(i,deg,n,adj);
        com = max(com,pos);
        //cout<<i<<" "<<pos<<endl;
      }
    }
    cout<<com<<endl;

  }
    return 0;
}





  
  

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int N = 2e5+1;
ll mod = 1e9+7;


int main(){
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int T;
  cin>>T;
  while(T--){ 
    int n;
    cin>>n;
    vector<vector<int>>adj(n+1);
    vector<int>deg(n+1);
    for(int i=1;i<n;i++){
      int a,b;
      cin>>a>>b;
      deg[a]++;
      deg[b]++;
      adj[a].pb(b);
      adj[b].pb(a);
    }
    multiset<pair<int,int>>st;
    for(int i=1;i<=n;i++){
      st.insert({deg[i],i});
    }
    int com = 0;
  vector<int>vis(n+1);

   while(!st.empty()){
    int ans  =1;
    pair<int,int> node1 = *st.rbegin();
    
    vis[node1.second]=1;
    ans+=node1.first-1;
    st.erase(node1);

    for(int adn : adj[node1.second]){
      if(!vis[adn]){
      st.erase({deg[adn],adn});
      st.insert({deg[adn]-1,adn});
      }
    }

    if(st.empty()) break;
    pair<int,int> node2 = *st.rbegin();
    ans+=node2.first-1;
    com =max(com,ans);

    for(int adn : adj[node1.second]){
      if(!vis[adn]){
      st.erase({deg[adn]-1,adn});
      st.insert({deg[adn],adn});
      }
    }

    //cout<<node1.second<<" "<<ans<<endl;;
   }
    cout<<com<<endl;
  }
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int N = 2e5+1;
ll mod = 1e9+7;


int main(){
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int T;
  cin>>T;
  while(T--){ 
    int n;
    cin>>n;
    vector<vector<int>>adj(n+1);
    vector<int>deg(n+1);
    for(int i=1;i<n;i++){
      int a,b;
      cin>>a>>b;
      deg[a]++;
      deg[b]++;
      adj[a].pb(b);
      adj[b].pb(a);
    }
    set<pair<int,int>>st;
    for(int i=1;i<=n;i++){
      st.insert({deg[i],i});
    }
    int ans  =1;
    pair<int,int> node1 = *st.rbegin();
    
    ans+=node1.first-1;
    st.erase(node1);
    for(int adn : adj[node1.second]){
      st.erase({deg[adn],adn});
      deg[adn]--;
      st.insert({deg[adn],adn});
    }
    pair<int,int> node2 = *st.rbegin();
    ans+=node2.first-1;
    cout<<ans<<endl;


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

Previous submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MAX_MOD 998244353
int arr[1010];
signed main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> arr[i];
	vector<pair<int, int>> ans;
	int sum = 0;
	vector<int> dp(n + 1, 0);
	for (int i = 1; i <= n; i++)dp[i] = i;
	for (int i = n; i >= 1; i--)
	{
		if (dp[i] != arr[i])
		{
			int sta;
			for (int j = 1; j <= i; j++)
				if (dp[j] == arr[i])
					sta = j;
			for (int j = sta; j < i; j++)
			{
				sum++;
				ans.push_back({dp[j+1],dp[j]});
				swap(dp[j], dp[j+1]);
			}
		}
		else
		{
			if (i != 1)
			{
				sum += 2;
				ans.push_back({dp[i],dp[i-1]});
				ans.push_back({dp[i-1],dp[i]});
			}
		}
	}
	cout<<sum<<endl;
	for (auto x : ans)
		cout << x.first << " " << x.second << endl;
}

Submission (verdict: Wrong answer on test 7):
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MAX_MOD 998244353
int arr[1010];
signed main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> arr[i];
	vector<pair<int, int>> ans;
	int sum = 0;
	vector<int> dp(n + 1, 0);
	for (int i = 1; i <= n; i++)dp[i] = i;
	for (int i = n; i >= 1; i--)
	{
		if (dp[i] != arr[i])
		{
			int sta;
			for (int j = 1; j <= i; j++)
				if (dp[j] == arr[i])
					sta = j;
			for (int j = sta; j < i; j++)
			{
				sum++;
				ans.push_back({dp[j+1],dp[j]});
				swap(dp[j], dp[j+1]);
			}
		}
		else
		{
			if (i != 1)
			{
				for (int j = i; j >= 2; j--)
				{
					sum++;
					ans.push_back({dp[j],dp[j-1]});
					swap(dp[j], dp[j-1]);
				}
				for (int j = 2; j <= i; j++)
				{
					sum++;
					ans.push_back({dp[j],dp[j-1]});
					swap(dp[j], dp[j-1]);
				}
			}
		}
	}
	cout<<sum<<endl;
	for (auto x : ans)
		cout << x.first << " " << x.second << endl;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MAX_MOD 998244353
int arr[1010];
signed main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> arr[i];
	vector<pair<int, int>> ans;
	int sum = 0;
	vector<int> dp(n + 1, 0);
	for (int i = 1; i <= n; i++)dp[i] = i;
	for (int i = n; i >= 1; i--)
	{
		if (dp[i] != arr[i])
		{
			int sta;
			for (int j = 1; j <= i; j++)
				if (dp[j] == arr[i])
					sta = j;
			for (int j = sta; j < i; j++)
			{
				sum++;
				ans.push_back({dp[j+1],dp[j]});
				swap(dp[j], dp[j+1]);
			}
		}
		else
		{
			if (i != 1)
			{
				sum += 2;
				ans.push_back({dp[i],dp[i-1]});
				ans.push_back({dp[i-1],dp[i]});
			}
		}
	}
	cout<<sum<<endl;
	for (auto x : ans)
		cout << x.first << " " << x.second << endl;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 7):
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MAX_MOD 998244353
int arr[1010];
signed main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> arr[i];
	vector<pair<int, int>> ans;
	int sum = 0;
	vector<int> dp(n + 1, 0);
	for (int i = 1; i <= n; i++)dp[i] = i;
	for (int i = n; i >= 1; i--)
	{
		if (dp[i] != arr[i])
		{
			int sta;
			for (int j = 1; j <= i; j++)
				if (dp[j] == arr[i])
					sta = j;
			for (int j = sta; j < i; j++)
			{
				sum++;
				ans.push_back({dp[j+1],dp[j]});
				swap(dp[j], dp[j+1]);
			}
		}
		else
		{
			if (i != 1)
			{
				for (int j = i; j >= 2; j--)
				{
					sum++;
					ans.push_back({dp[j],dp[j-1]});
					swap(dp[j], dp[j-1]);
				}
				for (int j = 2; j <= i; j++)
				{
					sum++;
					ans.push_back({dp[j],dp[j-1]});
					swap(dp[j], dp[j-1]);
				}
			}
		}
	}
	cout<<sum<<endl;
	for (auto x : ans)
		cout << x.first << " " << x.second << endl;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MAX_MOD 998244353
int arr[1010];
signed main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> arr[i];
	vector<pair<int, int>> ans;
	int sum = 0;
	vector<int> dp(n + 1, 0);
	for (int i = 1; i <= n; i++)dp[i] = i;
	for (int i = n; i >= 1; i--)
	{
		if (dp[i] != arr[i])
		{
			int sta;
			for (int j = 1; j <= i; j++)
				if (dp[j] == arr[i])
					sta = j;
			if (sta != 1)
			{
				for (int j = sta; j >= 2; j--)
				{
					sum++;
					ans.push_back({ dp[j],dp[j - 1] });
					swap(dp[j], dp[j - 1]);
				}
				for (int j = 2; j <= sta; j++)
				{
					sum++;
					ans.push_back({ dp[j],dp[j - 1] });
					swap(dp[j], dp[j - 1]);
				}
			}
			for (int j = sta; j < i; j++)
			{
				sum++;
				ans.push_back({dp[j+1],dp[j]});
				swap(dp[j], dp[j+1]);
			}
		}
		else
		{
			if (i != 1)
			{
				for (int j = i; j >= 2; j--)
				{
					sum++;
					ans.push_back({dp[j],dp[j-1]});
					swap(dp[j], dp[j-1]);
				}
				for (int j = 2; j <= i; j++)
				{
					sum++;
					ans.push_back({dp[j],dp[j-1]});
					swap(dp[j], dp[j-1]);
				}
			}
		}
	}
	cout<<sum<<endl;
	for (auto x : ans)
		cout << x.first << " " << x.second << endl;
}
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)

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



using namespace std;



void dbg_out() { cerr << endl; }

template <typename Head, typename... Tail>

void dbg_out(Head H, Tail... T) {

    cerr << ' ' << H;

    dbg_out(T...);

}

#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

#define FAST ios::sync_with_stdio(0), cin.tie(0)

#define pb push_back

#define mp make_pair

#define f first

#define s second

#define endl '\n'



typedef long long int  ll;

typedef unsigned long long int ull;

const int inf = (int)1e9;

const ll mod = 1e9 + 7;

const int MAXN = 200007;

//const double eps=numeric_limits<double>::epsilon();



void solve() {

    int n, x, y; cin >> n >> x >> y;

    --x; --y;

    int a[n];

    int f = 0;

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

        a[i] = f;

        f ^= 1;

    }

    if (a[n - 1] == 0) a[n - 1] = 2;



    auto print = [&]() -> void {

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

            cout << a[i] << ' ';

        }

        cout << endl;

        };



    if (a[x] != a[y]) {

        print();

        return;

    }



    a[x] = 2;

    print();

}



int main(void) {

    FAST;

    int t = 1;

    cin >> t;

    while (t--) {

        solve();

    }

    return 0;

}

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



using namespace std;



void dbg_out() { cerr << endl; }

template <typename Head, typename... Tail>

void dbg_out(Head H, Tail... T) {

    cerr << ' ' << H;

    dbg_out(T...);

}

#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

#define FAST ios::sync_with_stdio(0), cin.tie(0)

#define pb push_back

#define mp make_pair

#define f first

#define s second

#define endl '\n'



typedef long long int  ll;

typedef unsigned long long int ull;

const int inf = (int)1e9;

const ll mod = 1e9 + 7;

const int MAXN = 200007;

//const double eps=numeric_limits<double>::epsilon();



void solve() {

    int n, x, y; cin >> n >> x >> y;

    --x; --y;

    int a[n];

    int f = 0;

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

        a[i] = f;

        f ^= 1;

    }

    if (a[n - 1] == 0) a[n - 1] = 2;



    auto print = [&]() -> void {

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

            cout << a[i] << ' ';

        }

        cout << endl;

        };



    if (a[x] != a[y]) {

        print();

        return;

    }



    if (x == 0) {

        a[x] = 2;

        if (a[n - 1] == 2) a[n - 1] = 0;

    }

    else {

        a[x] = 2;

    }



    print();

}



int main(void) {

    FAST;

    int t = 1;

    cin >> t;

    while (t--) {

        solve();

    }

    return 0;

}
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)


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



using namespace std;



void dbg_out() { cerr << endl; }

template <typename Head, typename... Tail>

void dbg_out(Head H, Tail... T) {

    cerr << ' ' << H;

    dbg_out(T...);

}

#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

#define FAST ios::sync_with_stdio(0), cin.tie(0)

#define pb push_back

#define mp make_pair

#define f first

#define s second

#define endl '\n'



typedef long long int  ll;

typedef unsigned long long int ull;

const int inf = (int)1e9;

const ll mod = 1e9 + 7;

const int MAXN = 200007;

//const double eps=numeric_limits<double>::epsilon();



void solve() {

    int n, x, y; cin >> n >> x >> y;

    --x; --y;

    int a[n];

    int f = 0;

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

        a[i] = f;

        f ^= 1;

    }

    if (a[n - 1] == 0) a[n - 1] = 2;



    auto print = [&]() -> void {

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

            cout << a[i] << ' ';

        }

        cout << endl;

        };



    if (a[x] != a[y]) {

        print();

        return;

    }



    a[y - 1] = 2;

    f = a[x] ^ 1;

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

        a[i] = f;

        f ^= 1;

    }

    if (a[n - 1] == 0) a[n - 1] = 2;

    print();

}



int main(void) {

    FAST;

    int t = 1;

    cin >> t;

    while (t--) {

        solve();

    }

    return 0;

}