ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

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

typedef long long ll;

using namespace std;

int main() {

	ll t;

	cin >> t;

	while (t--) {

		int n,count=0,i;

		cin >> n;

		string s;

		cin >> s;

		if (n == 1) {

			cout << "Yes" << endl;

			continue;

		}

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

			if (s[i] == '.')count++;

		if(count==n){

			cout << "Yes" << endl;

			continue;

		}

		if(s[n-1]=='p'){

			cout << "Yes" << endl;

			continue;

		}

		if(s[0]=='s'){

			cout << "Yes" << endl;

			continue;

		}

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

			if (s[i] == 'p')

				break;

		count = 0;

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

			if (s[j] == '.')count++;

		if (count >= n - i - 1){

			cout << "Yes" << endl;

			continue;

		}

		count = 0;

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

			if (s[i] == 's')break;

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

			if (s[j] == '.')count++;

		if (count >= i) {

			cout << "Yes" << endl;

			continue;

		}

		cout << "No" << endl;

	}

	return 0;

}

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

typedef long long ll;

using namespace std;

int main() {

	ll t;

	cin >> t;

	while (t--) {

		int n,count=0,i,j;

		cin >> n;

		string s;

		cin >> s;

		if (n == 1) {

			cout << "Yes" << endl;

			continue;

		}

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

			if (s[i] == '.')count++;

		if(count==n){

			cout << "Yes" << endl;

			continue;

		}

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

			if (s[i] == 's')break;

		if (i == n ) {

			cout << "Yes" << endl;

			continue;

		}

		for (j = n - 1; j >= 0; j--)

			if (s[j] == 'p')	break;

		if (j == -1) {

			cout << "Yes" << endl;

			continue;

		}

		if (i < j) {

			if (-i + j + 1 < j + 1 && -i + j + 1 < n - i) {

				cout << "No" << endl;

					continue;

			}

			count = 0;

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

				if (s[k] == 'p') count++;

			if(count){

					cout << "No" << endl;

					continue;

			}

			count = 0;

			for (int k = j + 1; k < n; k++)

				if (s[k] == 's')count++;

			if(count){

					cout << "No" << endl;

					continue;

			}

			cout << "Yes" << endl;

			continue;

		}

		

		else

		  cout << "No" << endl;

	}

	return 0;

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


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

#include <vector>

#include <iomanip>

#include <cstring>

#include <string>

#include <array>

#include <sstream>

#include <algorithm>

#include <cmath>

#include <climits>

#include<bitset>

#include <tuple>

#include<unordered_set>

#include<map>

#include<set>

#include <stack>

#include <queue>

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

FILE* stream;

#define ll long long



int d(char c)

{

	return c - '0';

}



void solve()

{

	string s;

	cin >> s;



	int n = (int)s.size();

	string out;

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

	{



		for (int j = n - 1; j>0 ; --j)

		{



			if (d(s[j]) - d(s[j - 1]) > 1)

			{

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

				s[j - 1]--;

			}

		}

	}



	cout << s << endl;

}



signed main()

{

	FastIO

#ifndef ONLINE_JUDGE



		//For getting input from input.txt file

		freopen_s(&stream, "input.txt", "r", stdin);



	//Prlong longing the Output to output.txt file

	freopen_s(&stream, "output.txt", "w", stdout);



#endif



	ll tc = 1;

	cin >> tc;

	while (tc--) {

		solve();

	}



	return 0;

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

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

#include <vector>

#include <iomanip>

#include <cstring>

#include <string>

#include <array>

#include <sstream>

#include <algorithm>

#include <cmath>

#include <climits>

#include<bitset>

#include <tuple>

#include<unordered_set>

#include<map>

#include<set>

#include <stack>

#include <queue>

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

FILE* stream;

#define ll long long



int d(char c)

{

	return c - '0';

}



void solve()

{

	string s;

	cin >> s;



	int n = (int)s.size();

	string out;

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

	{



		for (int j = n - 1; j>0 ; --j)

		{



			if (d(s[j]) - d(s[j - 1]) > 1)

			{

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

				s[j - 1]--;

			}

		}

	}



	cout << s << endl;

}



signed main()

{

	FastIO

#ifndef ONLINE_JUDGE



		//For getting input from input.txt file

		freopen_s(&stream, "input.txt", "r", stdin);



	//Prlong longing the Output to output.txt file

	freopen_s(&stream, "output.txt", "w", stdout);



#endif



	ll tc = 1;

	cin >> tc;

	while (tc--) {

		solve();

	}



	return 0;

}

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

#include <vector>

#include <iomanip>

#include <cstring>

#include <string>

#include <array>

#include <sstream>

#include <algorithm>

#include <cmath>

#include <climits>

#include<bitset>

#include <tuple>

#include<unordered_set>

#include<map>

#include<set>

#include <stack>

#include <queue>

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

FILE* stream;

#define ll long long



int d(char c)

{

	return c - '0';

}



void solve()

{

	string s;

	cin >> s;



	int n = (int)s.size();

	string out;

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

	{



		for (int j = n - 1; j>0 ; --j)

		{



			if (d(s[j]) - d(s[j - 1]) > 1)

			{

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

				s[j - 1]--;

			}

		}

	}



	cout << s << endl;

}



signed main()

{

	FastIO

#ifndef ONLINE_JUDGE



		//For getting input from input.txt file

		freopen_s(&stream, "input.txt", "r", stdin);



	//Prlong longing the Output to output.txt file

	freopen_s(&stream, "output.txt", "w", stdout);



#endif



	ll tc = 1;

	cin >> tc;

	while (tc--) {

		solve();

	}



	return 0;

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

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

#include <vector>

#include <iomanip>

#include <cstring>

#include <string>

#include <array>

#include <sstream>

#include <algorithm>

#include <cmath>

#include <climits>

#include<bitset>

#include <tuple>

#include<unordered_set>

#include<map>

#include<set>

#include <stack>

#include <queue>

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

FILE* stream;

#define ll long long



int d(char c)

{

	return (c - '0');

}



void solve()

{

	string s;

	cin >> s;



	int n = (int)s.size();



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

	{

		int best = d(s[i]);

		int pos = i;

		for (int j = i+1; j < min(i+10, n); ++j)

		{

			if( d(s[j])-(j-i)>best)

			{

				pos = j;

				best = d(s[j])-(j-i);







			}





			while (pos > i)

			{

				swap(s[pos], s[pos - 1]);

				--pos;

			}

		}



		s[i] = best + '0';

	}





	cout << s << endl;

}



signed main()

{

	FastIO

#ifndef ONLINE_JUDGE



		//For getting input from input.txt file

		freopen_s(&stream, "input.txt", "r", stdin);



	//Prlong longing the Output to output.txt file

	freopen_s(&stream, "output.txt", "w", stdout);



#endif



	ll tc = 1;

	cin >> tc;

	while (tc--) {

		solve();

	}



	return 0;

}

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

#include <vector>

#include <iomanip>

#include <cstring>

#include <string>

#include <array>

#include <sstream>

#include <algorithm>

#include <cmath>

#include <climits>

#include<bitset>

#include <tuple>

#include<unordered_set>

#include<map>

#include<set>

#include <stack>

#include <queue>

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

FILE* stream;

#define ll long long



int d(char c)

{

	return (c - '0');

}



void solve()

{

	string s;

	cin >> s;



	int n = (int)s.size();



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

	{

		int best = d(s[i]);



		int pos = i;



		for (int j = i; j < min(i+10, n); ++j)

		{

			if( d(s[j])-(j-i)>best)

			{

				pos = j;

				best = d(s[j])-(j-i);







			}





		

		}

		while (pos > i)

		{

			swap(s[pos], s[pos - 1]);

			--pos;

		}



		s[i] = char(best + '0');

	}





	cout << s << endl;

}



signed main()

{

	FastIO

#ifndef ONLINE_JUDGE



		//For getting input from input.txt file

		freopen_s(&stream, "input.txt", "r", stdin);



	//Prlong longing the Output to output.txt file

	freopen_s(&stream, "output.txt", "w", stdout);



#endif



	ll tc = 1;

	cin >> tc;

	while (tc--) {

		solve();

	}



	return 0;

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

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

#include <vector>

#include <iomanip>

#include <cstring>

#include <string>

#include <array>

#include <sstream>

#include <algorithm>

#include <cmath>

#include <climits>

#include<bitset>

#include <tuple>

#include<unordered_set>

#include<map>

#include<set>

#include <stack>

#include <queue>

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

FILE* stream;

#define ll long long



int d(char c)

{

	return (c - '0');

}



void solve()

{

	string s;

	cin >> s;



	int n = (int)s.size();



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

	{

		int best = d(s[i]);

		int pos = i;

		for (int j = i+1; j < min(i+10, n); ++j)

		{

			if( d(s[j])-(j-i)>best)

			{

				pos = j;

				best = d(s[j])-(j-i);







			}





			while (pos > i)

			{

				swap(s[pos], s[pos - 1]);

				--pos;

			}

		}

	}





	cout << s << endl;

}



signed main()

{

	FastIO

#ifndef ONLINE_JUDGE



		//For getting input from input.txt file

		freopen_s(&stream, "input.txt", "r", stdin);



	//Prlong longing the Output to output.txt file

	freopen_s(&stream, "output.txt", "w", stdout);



#endif



	ll tc = 1;

	cin >> tc;

	while (tc--) {

		solve();

	}



	return 0;

}

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

#include <vector>

#include <iomanip>

#include <cstring>

#include <string>

#include <array>

#include <sstream>

#include <algorithm>

#include <cmath>

#include <climits>

#include<bitset>

#include <tuple>

#include<unordered_set>

#include<map>

#include<set>

#include <stack>

#include <queue>

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

FILE* stream;

#define ll long long



int d(char c)

{

	return (c - '0');

}



void solve()

{

	string s;

	cin >> s;



	int n = (int)s.size();



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

	{

		int best = d(s[i]);

		int pos = i;

		for (int j = i+1; j < min(i+10, n); ++j)

		{

			if( d(s[j])-(j-i)>best)

			{

				pos = j;

				best = d(s[j])-(j-i);







			}





			while (pos > i)

			{

				swap(s[pos], s[pos - 1]);

				--pos;

			}

		}



		s[i] = best + '0';

	}





	cout << s << endl;

}



signed main()

{

	FastIO

#ifndef ONLINE_JUDGE



		//For getting input from input.txt file

		freopen_s(&stream, "input.txt", "r", stdin);



	//Prlong longing the Output to output.txt file

	freopen_s(&stream, "output.txt", "w", stdout);



#endif



	ll tc = 1;

	cin >> tc;

	while (tc--) {

		solve();

	}



	return 0;

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

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

#include <vector>

#include <iomanip>

#include <cstring>

#include <string>

#include <array>

#include <sstream>

#include <algorithm>

#include <cmath>

#include <climits>

#include<bitset>

#include <tuple>

#include<unordered_set>

#include<map>

#include<set>

#include <stack>

#include <queue>

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

FILE* stream;

#define ll long long



int d(char c)

{

	return c - '0';

}



void solve()

{

	string s;

	cin >> s;



	int n = (int)s.size();

	string out;

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

	{



		for (int j = n - 1; j>0 ; --j)

		{



			if (d(s[j]) - d(s[j - 1]) > 1)

			{

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

				s[j - 1]--;

			}

		}

	}



	cout << s << endl;

}



signed main()

{

	FastIO

#ifndef ONLINE_JUDGE



		//For getting input from input.txt file

		freopen_s(&stream, "input.txt", "r", stdin);



	//Prlong longing the Output to output.txt file

	freopen_s(&stream, "output.txt", "w", stdout);



#endif



	ll tc = 1;

	cin >> tc;

	while (tc--) {

		solve();

	}



	return 0;

}

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

#include <vector>

#include <iomanip>

#include <cstring>

#include <string>

#include <array>

#include <sstream>

#include <algorithm>

#include <cmath>

#include <climits>

#include<bitset>

#include <tuple>

#include<unordered_set>

#include<map>

#include<set>

#include <stack>

#include <queue>

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

FILE* stream;

#define ll long long



int d(char c)

{

	return (c - '0');

}



void solve()

{

	string s;

	cin >> s;



	int n = (int)s.size();



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

	{

		int best = d(s[i]);

		int pos = i;

		for (int j = i+1; j < min(i+10, n); ++j)

		{

			if( d(s[j])-(j-i)>best)

			{

				pos = j;

				best = d(s[j])-(j-i);







			}





			while (pos > i)

			{

				swap(s[pos], s[pos - 1]);

				--pos;

			}

		}

	}





	cout << s << endl;

}



signed main()

{

	FastIO

#ifndef ONLINE_JUDGE



		//For getting input from input.txt file

		freopen_s(&stream, "input.txt", "r", stdin);



	//Prlong longing the Output to output.txt file

	freopen_s(&stream, "output.txt", "w", stdout);



#endif



	ll tc = 1;

	cin >> tc;

	while (tc--) {

		solve();

	}



	return 0;

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

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

#include <algorithm>

#include <cstring>

#define ll long long

const int N = 1e5 + 8;



using namespace std;



int a[N];



void solve() {

    memset(a , sizeof a, 0);

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

    

    for (int i = 0 ; i < n ; i ++) cin >> a[i];

    

    auto b = a;

    

    ll sum1 = 0, sum2 = 0;

    

    sort(a , a + r);

    

    for (int i = 0 ; i < r - l + 1; i ++) sum1 += a[i];

    

    sort(b + l - 1 , b + n );

    

    for (int i = l - 1 ; i < l - 1 + r - l + 1; i ++) sum2 +=a[i];

    

    ll ans = min(sum1, sum2);

    

    cout << ans << endl;

    

    

}





int main(void) {

    ios::sync_with_stdio(false);cin.tie(nullptr);

    int t ; cin >> t;

    while (t--)solve();

    

}

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

#include <algorithm>

#include <cstring>

#define ll long long

const int N = 1e5 + 8;



using namespace std;



int a[N];



void solve() {

    memset(a , sizeof a, 0);

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

    

    for (int i = 0 ; i < n ; i ++) cin >> a[i];

    

    auto b = a;

    

    ll sum1 = 0, sum2 = 0;

    

    sort(a , a + r);

    

    for (int i = 0 ; i < r - l + 1; i ++) sum1 += a[i];

    

    sort(b + l - 1 , b + n );

    

    for (int i = l - 1 ; i < l - 1 + r - l + 1; i ++) sum2 +=b[i];

    

    ll ans = min(sum1, sum2);

    

    cout << ans << endl;

    

    

}





int main(void) {

    ios::sync_with_stdio(false);cin.tie(nullptr);

    int t ; cin >> t;

    while (t--)solve();

    

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

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
const int N = 1e5 + 8;

using namespace std;

int a[N];

void solve() {
    int n , l , r ; cin >> n >> l >> r;
    
    for (int i = 0 ; i < n ; i ++) cin >> a[i];
    
    auto b = a;
    
    ll sum1 = 0, sum2 = 0;
    
    sort(a , a + r);
    
    for (int i = 0 ; i < r - l + 1; i ++) sum1 += a[i];
    
    sort(b + l - 1 , b + n );
    
    for (int i = l - 1 ; i < l - 1 + r - l + 1; i ++) sum2 +=a[i];
    
    ll ans = min(sum1, sum2);
    
    cout << ans << endl;
    
    
}


int main(void) {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int t ; cin >> t;
    while (t--)solve();
    
}

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

#include <algorithm>

#include <cstring>

#define ll long long

const int N = 1e5 + 8;



using namespace std;



int a[N];



void solve() {

    memset(a , sizeof a, 0);

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

    

    for (int i = 0 ; i < n ; i ++) cin >> a[i];

    

    auto b = a;

    

    ll sum1 = 0, sum2 = 0;

    

    sort(a , a + r);

    

    for (int i = 0 ; i < r - l + 1; i ++) sum1 += a[i];

    

    sort(b + l - 1 , b + n );

    

    for (int i = l - 1 ; i < l - 1 + r - l + 1; i ++) sum2 +=a[i];

    

    ll ans = min(sum1, sum2);

    

    cout << ans << endl;

    

    

}





int main(void) {

    ios::sync_with_stdio(false);cin.tie(nullptr);

    int t ; cin >> t;

    while (t--)solve();

    

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

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

#include <algorithm>

#include <cstring>

#define ll long long

const int N = 1e5 + 8;



using namespace std;



int a[N];



void solve() {

    memset(a , sizeof a, 0);

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

    

    for (int i = 0 ; i < n ; i ++) cin >> a[i];

    

    auto b = a;

    

    ll sum1 = 0, sum2 = 0;

    

    sort(a , a + r);

    

    for (int i = 0 ; i < r - l + 1; i ++) sum1 += a[i];

    

    sort(b + l - 1 , b + n );

    

    for (int i = l - 1 ; i < l - 1 + r - l + 1; i ++) sum2 +=b[i];

    

    ll ans = min(sum1, sum2);

    

    cout << ans << endl;

    

    

}





int main(void) {

    ios::sync_with_stdio(false);cin.tie(nullptr);

    int t ; cin >> t;

    while (t--)solve();

    

}

Submission (verdict: Accepted):
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#define ll long long
const int N = 1e5 + 8;

using namespace std;



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


int main(void) {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int t ; cin >> t;
    while (t--)solve();
    
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
const int N = 1e5 + 8;

using namespace std;

int a[N];

void solve() {
    int n , l , r ; cin >> n >> l >> r;
    
    for (int i = 0 ; i < n ; i ++) cin >> a[i];
    
    auto b = a;
    
    ll sum1 = 0, sum2 = 0;
    
    sort(a , a + r);
    
    for (int i = 0 ; i < r - l + 1; i ++) sum1 += a[i];
    
    sort(b + l - 1 , b + n );
    
    for (int i = l - 1 ; i < l - 1 + r - l + 1; i ++) sum2 +=a[i];
    
    ll ans = min(sum1, sum2);
    
    cout << ans << endl;
    
    
}


int main(void) {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int t ; cin >> t;
    while (t--)solve();
    
}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)

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

using namespace std;

#define LL long long

#define PII pair<int, int>

#define PLL pair<LL, LL>

#define endl '\n'

const int N = 2e5 + 10;

void solve(){

    int n, x, y;

    cin >> n >> x >> y;

    vector<int> a(n + 1);

    if(x == (y + 1) % n || y == (x + 1) % n){

        if(n % 2){

            for(int i = 1;i <= n - 1;i++)a[i] = i % 2;

            a[n] = 2;

        }

        else {

            for(int i = 1;i <= n;i++)a[i] = i % 2;

        }

    }

    else{

        a[x] = 0, a[y] = 1;

        for(int i = x + 1;i <= y;i++){

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

        }

        if(a[y] != 1)a[y] = 1, a[y - 1] = 2;

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

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

        }

        a[0] = (a[n] + 1) % 2;

        for(int i = 1;i <= x;i++){

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

        }

        if(a[x] != 0)a[x] = 0, a[x - 1] = 2;

    }

    for(int i = 1;i <= n;i++)cout << a[i] << ' ';

    cout << endl;

}

int main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr), cout.tie(nullptr);

    int T = 1;

    cin >> T;

    while(T--){

        solve();

    }

}

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

using namespace std;

#define LL long long

#define PII pair<int, int>

#define PLL pair<LL, LL>

#define endl '\n'

const int N = 2e5 + 10;

void solve(){

    int n, x, y;

    cin >> n >> x >> y;

    vector<int> a(n + 1);

    if(x == (y + 1) % n || y == (x + 1) % n){

        if(n % 2){

            for(int i = 1;i <= n - 1;i++)a[i] = i % 2;

            a[n - 1] = 2;

        }

        else {

            for(int i = 1;i <= n;i++)a[i] = i % 2;

        }

    }

    else{

        a[x] = 0, a[y] = 1;

        for(int i = x + 1;i <= y;i++){

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

        }

        if(a[y] != 1)a[y] = 1, a[y - 1] = 2;

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

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

        }

        a[0] = a[n];

        for(int i = 1;i <= x;i++){

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

        }

        if(a[x] != 0)a[x] = 0, a[x - 1] = 2;

    }

    for(int i = 1;i <= n;i++)cout << a[i] << ' ';

    cout << endl;

}

int main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr), cout.tie(nullptr);

    int T = 1;

    cin >> T;

    while(T--){

        solve();

    }

}
Problem: 2049C - MEX Cycle
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

#define PII pair<int, int>

#define PLL pair<LL, LL>

#define endl '\n'

const int N = 2e5 + 10;

void solve(){

    int n, x, y;

    cin >> n >> x >> y;

    vector<int> a(n + 1);

    if(x == (y + 1) % n || y == (x + 1) % n){

        if(n % 2){

            for(int i = 1;i <= n - 1;i++)a[i] = i % 2;

            a[n - 1] = 2;

        }

        else {

            for(int i = 1;i <= n;i++)a[i] = i % 2;

        }

    }

    else{

        a[x] = 0, a[y] = 1;

        for(int i = x + 1;i <= y;i++){

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

        }

        if(a[y] != 1)a[y] = 1, a[y - 1] = 2;

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

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

        }

        a[0] = a[n];

        for(int i = 1;i <= x;i++){

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

        }

        if(a[x] != 0)a[x] = 0, a[x - 1] = 2;

    }

    for(int i = 1;i <= n;i++)cout << a[i] << ' ';

    cout << endl;

}

int main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr), cout.tie(nullptr);

    int T = 1;

    cin >> T;

    while(T--){

        solve();

    }

}

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

using namespace std;

#define LL long long

#define PII pair<int, int>

#define PLL pair<LL, LL>

#define endl '\n'

const int N = 2e5 + 10;

void solve(){

    int n, x, y;

    cin >> n >> x >> y;

    vector<int> a(n + 1);

    if(x == (y + 1) % n || y == (x + 1) % n){

        if(n % 2){

            for(int i = 1;i <= n - 1;i++)a[i] = i % 2;

            a[n - 1] = 2;

        }

        else {

            for(int i = 1;i <= n;i++)a[i] = i % 2;

        }

    }

    else{

        a[x] = 0, a[y] = 1;

        for(int i = x + 1;i <= y;i++){

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

        }

        if(a[y] != 1)a[y] = 1, a[y - 1] = 2;

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

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

        }

        a[0] = a[n];

        for(int i = 1;i <= x;i++){

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

        }

        if(a[x] != 0){

            a[x] = 0;

            if(x == 1)a[n] = 2;

            else a[x - 1] = 2;

        }

    }

    for(int i = 1;i <= n;i++)cout << a[i] << ' ';

    cout << endl;

}

int main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr), cout.tie(nullptr);

    int T = 1;

    cin >> T;

    while(T--){

        solve();

    }

}