ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ull = unsigned long long;
using i128 = __int128;

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll ans = accumulate(a.begin(), a.end(), 0);
    for (int i = 1; i < n; i++) {
        vector<ll> b(a.size() - 1);
        for (int j = 0; j < b.size(); j++) {
            b[j] = a[j + 1] - a[j];
        }

        ll sum = accumulate(b.begin(), b.end(), 0);
        ans = max(ans, abs(sum));
        a = b;
    }
    cout << ans << '\n';
}

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

    int t;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ull = unsigned long long;
using i128 = __int128;

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll ans = accumulate(a.begin(), a.end(), 0LL);
    for (int i = 1; i < n; i++) {
        vector<ll> b(a.size() - 1);
        for (int j = 0; j < b.size(); j++) {
            b[j] = a[j + 1] - a[j];
        }

        ll sum = accumulate(b.begin(), b.end(), 0LL);
        ans = max(ans, abs(sum));
        a = b;
    }
    cout << ans << '\n';
}

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

    int t;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ull = unsigned long long;
using i128 = __int128;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans = accumulate(a.begin(), a.end(), 0);
    for (int i = 1; i < n; i++) {
        vector<int> b(a.size() - 1);
        for (int j = 0; j < b.size(); j++) {
            b[j] = a[j + 1] - a[j];
        }
        int sum = accumulate(b.begin(), b.end(), 0);
        ans = max(ans, abs(sum));
        a = b;
    }
    cout << ans << "\n\n";
}

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

    int t;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ull = unsigned long long;
using i128 = __int128;

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll ans = accumulate(a.begin(), a.end(), 0);
    for (int i = 1; i < n; i++) {
        vector<ll> b(a.size() - 1);
        for (int j = 0; j < b.size(); j++) {
            b[j] = a[j + 1] - a[j];
        }

        ll sum = accumulate(b.begin(), b.end(), 0);
        ans = max(ans, abs(sum));
        a = b;
    }
    cout << ans << '\n';
}

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

    int t;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)


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

using namespace std;

#define int long long

const int N = 1e5 + 10;

void solve()

{

	int n, l, r;

	int a[N];

	cin >> n >> l >> r;

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

	sort(a + 1, a + n + 1);

	int k = r - l + 1;

	int sum = 0;

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

	{

		sum += a[i];

	}

	cout << sum << endl;

}

signed main() 

{

 	int t;

 	cin >> t;

 	while(t --)

 	{

 		solve();

 	}

    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

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

using namespace std;

#define int long long

const int N = 1e5 + 10;

void solve()

{

	int n, l, r;

	int a[N];

	cin >> n >> l >> r;

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

	sort(a + 1, a + n + 1);

	int k = r - l + 1;

	int sum1 = 0, sum2 = 0;

	for(int i = 1; i <= k; i ++) sum1 += a[i];

	for(int i = l; i < l + k; i ++) sum2 += a[i];

	int sum = min(sum1, sum2);

	cout << sum << endl;

}

signed main() 

{

 	int t;

 	cin >> t;

 	while(t --)

 	{

 		solve();

 	}

    return 0;

}

 

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 10;
void solve()
{
	int n, l, r;
	int a[N], b[N];
	cin >> n >> l >> r;
	for(int i = 1; i <= n; i ++)
	{
		cin >> a[i];
		b[i] = a[i];
	}
	  
	sort(a + 1, a + r + 1);
	sort(b + l, b + n + 1);
	int k = r - l + 1;
	int sum1 = 0, sum2 = 0;
	for(int i = 1; i <= k; i ++) sum1 += a[i];
	for(int i = l; i <= r; i ++) sum2 += b[i];
	int sum = min(sum1, sum2);
	cout << sum << endl;
}
signed main() 
{
 	int t;
 	cin >> t;
 	while(t --)
 	{
 		solve();
 	}
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

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

using namespace std;

#define int long long

const int N = 1e5 + 10;

void solve()

{

	int n, l, r;

	int a[N];

	cin >> n >> l >> r;

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

	sort(a + 1, a + n + 1);

	int k = r - l + 1;

	int sum = 0;

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

	{

		sum += a[i];

	}

	cout << sum << endl;

}

signed main() 

{

 	int t;

 	cin >> t;

 	while(t --)

 	{

 		solve();

 	}

    return 0;

}

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

using namespace std;

#define int long long

const int N = 1e5 + 10;

void solve()

{

	int n, l, r;

	int a[N];

	cin >> n >> l >> r;

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

	sort(a + 1, a + n + 1);

	int k = r - l + 1;

	int sum1 = 0, sum2 = 0;

	for(int i = 1; i <= k; i ++) sum1 += a[i];

	for(int i = l; i < l + k; i ++) sum2 += a[i];

	int sum = min(sum1, sum2);

	cout << sum << endl;

}

signed main() 

{

 	int t;

 	cin >> t;

 	while(t --)

 	{

 		solve();

 	}

    return 0;

}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Memory limit exceeded on test 6):
#include <bits/stdc++.h>



using i32 = int32_t;

using i64 = int64_t;



void solve() {

    i32 n, m;

    std::cin >> n >> m;

    i64 suma = 0, sumb = 0;

    std::multiset<i32> a;

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

        i32 x;

        std::cin >> x;

        a.insert(x);

        suma += x;

    }

    std::queue<i32> q;

    for (i32 i = 0; i < m; ++i) {

        i32 x;

        std::cin >> x;

        q.push(x);

        sumb += x;

    }

    if (suma != sumb) {

        std::cout << "No\n";

        return;

    }

    while (!q.empty()) {

        i32 x = q.front();

        q.pop();

        if (a.contains(x)) {

            a.extract(x);

        } else if (x > 1) {

            i32 down = x / 2;

            i32 up = (x + 1) / 2;

            q.push(down);

            q.push(up);

        } else {

            std::cout << "No\n";

            return;

        }

    }

    std::cout << "Yes\n";

}



signed main() {

    std::ios::sync_with_stdio(false);

    std::cin.tie(nullptr);



    i32 t = 1;

    std::cin >> t;

    std::cin.get();

    while (t--) {

        solve();

    }



    return 0;

}

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



using i32 = int32_t;

using i64 = int64_t;



void solve() {

    i32 n, m;

    std::cin >> n >> m;

    i64 suma = 0, sumb = 0;

    std::multiset<i32> a;

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

        i32 x;

        std::cin >> x;

        a.insert(x);

        suma += x;

    }

    std::vector<i32> b(m);

    for (i32 i = 0; i < m; ++i) {

        std::cin >> b[i];

        sumb += b[i];

    }

    if (suma != sumb) {

        std::cout << "No\n";

        return;

    }

    for (i32 i = 0; i < m; ++i) {

        std::stack<i32> stk;

        stk.push(b[i]);

        while (!stk.empty()) {

            i32 x = stk.top();

            stk.pop();

            if (a.contains(x)) {

                a.extract(x);

            } else if (x > 1) {

                i32 down = x / 2;

                i32 up = (x + 1) / 2;

                if ((a.size() < stk.size() + 2) || (!a.empty() && *a.begin() > down)) {

                    std::cout << "No\n";

                    return;

                }

                stk.push(down);

                stk.push(up);

            } else {

                std::cout << "No\n";

            }

        }

    }

    std::cout << "Yes\n";

}



signed main() {

    std::ios::sync_with_stdio(false);

    std::cin.tie(nullptr);



    i32 t = 1;

    std::cin >> t;

    std::cin.get();

    while (t--) {

        solve();

    }



    return 0;

}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

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



using i32 = int32_t;

using i64 = int64_t;



void solve() {

    i32 n, m;

    std::cin >> n >> m;

    i64 suma = 0, sumb = 0;

    std::multiset<i32> a;

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

        i32 x;

        std::cin >> x;

        a.insert(x);

        suma += x;

    }

    std::vector<i32> b(m);

    for (i32 i = 0; i < m; ++i) {

        std::cin >> b[i];

        sumb += b[i];

    }

    if (suma != sumb) {

        std::cout << "No\n";

        return;

    }

    for (i32 i = 0; i < m; ++i) {

        std::stack<i32> stk;

        stk.push(b[i]);

        while (!stk.empty()) {

            i32 x = stk.top();

            stk.pop();

            if (a.contains(x)) {

                a.extract(x);

            } else if (x > 1) {

                i32 down = x / 2;

                i32 up = (x + 1) / 2;

                if ((a.size() < stk.size() + 2) || (!a.empty() && *a.begin() > down)) {

                    std::cout << "No\n";

                    return;

                }

                stk.push(down);

                stk.push(up);

            } else {

                std::cout << "No\n";

            }

        }

    }

    std::cout << "Yes\n";

}



signed main() {

    std::ios::sync_with_stdio(false);

    std::cin.tie(nullptr);



    i32 t = 1;

    std::cin >> t;

    std::cin.get();

    while (t--) {

        solve();

    }



    return 0;

}

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



using i32 = int32_t;

using i64 = int64_t;



void solve() {

    i32 n, m;

    std::cin >> n >> m;

    i64 suma = 0, sumb = 0;

    std::multiset<i32> a;

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

        i32 x;

        std::cin >> x;

        a.insert(x);

        suma += x;

    }

    std::vector<i32> b(m);

    for (i32 i = 0; i < m; ++i) {

        std::cin >> b[i];

        sumb += b[i];

    }

    if (suma != sumb) {

        std::cout << "No\n";

        return;

    }

    for (i32 i = 0; i < m; ++i) {

        std::stack<i32> stk;

        stk.push(b[i]);

        while (!stk.empty()) {

            i32 x = stk.top();

            stk.pop();

            if (a.contains(x)) {

                a.extract(x);

            } else if (x > 1) {

                i32 down = x / 2;

                i32 up = (x + 1) / 2;

                if ((a.size() < stk.size() + 2) || (!a.empty() && *a.begin() > down)) {

                    std::cout << "No\n";

                    return;

                }

                stk.push(down);

                stk.push(up);

            } else {

                std::cout << "No\n";

                return;

            }

        }

    }

    std::cout << "Yes\n";

}



signed main() {

    std::ios::sync_with_stdio(false);

    std::cin.tie(nullptr);



    i32 t = 1;

    std::cin >> t;

    std::cin.get();

    while (t--) {

        solve();

    }



    return 0;

}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Memory limit exceeded on test 6):
#include <bits/stdc++.h>



using i32 = int32_t;

using i64 = int64_t;



void solve() {

    i32 n, m;

    std::cin >> n >> m;

    i64 suma = 0, sumb = 0;

    std::multiset<i32> a;

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

        i32 x;

        std::cin >> x;

        a.insert(x);

        suma += x;

    }

    std::queue<i32> q;

    for (i32 i = 0; i < m; ++i) {

        i32 x;

        std::cin >> x;

        q.push(x);

        sumb += x;

    }

    if (suma != sumb) {

        std::cout << "No\n";

        return;

    }

    while (!q.empty()) {

        i32 x = q.front();

        q.pop();

        if (a.contains(x)) {

            a.extract(x);

        } else if (x > 1) {

            i32 down = x / 2;

            i32 up = (x + 1) / 2;

            q.push(down);

            q.push(up);

        } else {

            std::cout << "No\n";

            return;

        }

    }

    std::cout << "Yes\n";

}



signed main() {

    std::ios::sync_with_stdio(false);

    std::cin.tie(nullptr);



    i32 t = 1;

    std::cin >> t;

    std::cin.get();

    while (t--) {

        solve();

    }



    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;
int n,m;
main(void){
	cin>>m;
	while(m--){
		cin>>n;
		int a[n+2],flag=0;
		for(int i=1;i<=n;i++){
			cin>>a[i];	
		}
		for(int i=2;i<=n-1;i++){
			int q=min(a[i-1],a[i]);
			a[i-1]-=q;
			a[i]-=q;
			if(a[i-1]>a[i]||a[i]>a[i+1]){
				flag=1;break;
			}
		}if(flag){cout<<"No";}
		else{cout<<"Yes";}
		cout<<endl;
	}
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int n,m;
main(void){
	cin>>m;
	while(m--){
		cin>>n;
		int a[n+2],flag=0;
		for(int i=1;i<=n;i++){
			cin>>a[i];	
		}
		if(n==2){
			if(a[0]<a[1]){cout<<"YES"<<endl;}
			else{cout<<"NO"<<endl;}
			continue;
		}
		for(int i=2;i<=n-1;i++){
			int q=min(a[i-1],a[i]);
			a[i-1]-=q;
			a[i]-=q;
			//cout<<a[i]<<a[i-1]<<endl;
			if(a[i-1]>a[i]||a[i]>a[i+1]){
				flag=1;break;
			}
		}if(flag){cout<<"NO";}
		else{cout<<"YES";}
		cout<<endl;
	}
}
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;
int n,m;
main(void){
	cin>>m;
	while(m--){
		cin>>n;
		int a[n+2],flag=0;
		for(int i=1;i<=n;i++){
			cin>>a[i];	
		}
		for(int i=2;i<=n-1;i++){
			int q=min(a[i-1],a[i]);
			a[i-1]-=q;
			a[i]-=q;
			if(a[i-1]>a[i]||a[i]>a[i+1]){
				flag=1;break;
			}
		}if(flag){cout<<"No";}
		else{cout<<"Yes";}
		cout<<endl;
	}
}
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;
int n,m;
main(void){
	cin>>m;
	while(m--){
		cin>>n;
		int a[n+2],flag=0;
		for(int i=1;i<=n;i++){
			cin>>a[i];	
		}
		if(n==2){
			if(a[0]<a[1]){cout<<"YES"<<endl;}
			else{cout<<"NO"<<endl;}
			continue;
		}
		for(int i=2;i<=n-1;i++){
			int q=min(a[i-1],a[i]);
			a[i-1]-=q;
			a[i]-=q;
			//cout<<a[i]<<a[i-1]<<endl;
			if(a[i-1]>a[i]||a[i]>a[i+1]){
				flag=1;break;
			}
		}if(flag){cout<<"NO";}
		else{cout<<"YES";}
		cout<<endl;
	}
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
int n,m;
main(void){
	cin>>m;
	while(m--){
		cin>>n;
		int a[n+2],flag=0;
		for(int i=1;i<=n;i++){
			cin>>a[i];	
		}
		if(n==2){
			if(a[1]<a[2]){cout<<"Yes"<<endl;}
			else{cout<<"NO"<<endl;}
			continue;
		}
		for(int i=2;i<=n-1;i++){
			int q=min(a[i-1],a[i]);
			a[i-1]-=q;
			a[i]-=q;
		//	cout<<a[i]<<a[i-1]<<endl;
			if(a[i-1]>a[i]||a[i]>a[i+1]){
				flag=1;break;
			}
		}if(flag){cout<<"NO";}
		else{cout<<"YES";}
		cout<<endl;
	}
}
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)

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

#define u32 unsigned int

#define ll long long

#define ull unsigned ll



const int N = 2e5+5, mod = 998244353;

int ans[N];

void solve() {

    

    int n,x,y;

    std::cin>>n>>x>>y;

    if(x>y) std::swap(x,y);

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

        ans[i]=(i+1)%2;

    }

    ans[n]=ans[n-1]&1^1;

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

        //nothing happened nya~

    } else {

        ans[x]=ans[y];

        if(x==1||x==n-1) std::swap(ans[x],ans[n]);

        else ans[x]=2;

    }

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

        std::cout<<ans[i]<<" ";

    }

    std::cout<<"\n";



    return;

}



int main() {

    std::ios::sync_with_stdio(false);

    std::cin.tie(nullptr);

    std::cout.tie(nullptr);

    int t = 1;

    std::cin >> t;

    while(t--) {

        solve();

    }

    return 0;

}

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

#define u32 unsigned int

#define ll long long

#define ull unsigned ll



const int N = 2e5+5, mod = 998244353;

int ans[N];

void solve() {

    

    int n,x,y;

    std::cin>>n>>x>>y;

    if(x>y) std::swap(x,y);

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

        ans[i]=(i+1)%2;

    }

    ans[n]=n&1+1;

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

        //nothing happened nya~

    } else {

        //ans[x]=ans[y];

        if(x==1&&n&1) std::swap(ans[x],ans[n]);

        else ans[x]=2;

    }

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

        std::cout<<ans[i]<<" ";

    }

    std::cout<<"\n";



    return;

}



int main() {

    std::ios::sync_with_stdio(false);

    std::cin.tie(nullptr);

    std::cout.tie(nullptr);

    int t = 1;

    std::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>

#define u32 unsigned int

#define ll long long

#define ull unsigned ll



const int N = 2e5+5, mod = 998244353;

int ans[N];

void solve() {

    

    int n,x,y;

    std::cin>>n>>x>>y;

    if(x>y) std::swap(x,y);

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

        ans[i]=i%2;

    }

    ans[n-1]=0;

    if(n&1) ans[n]=2;

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

        //nothing happened nya~

    } else {

        ans[x]=ans[y];

        if(x==1||x==n-1) std::swap(ans[x],ans[n]);

        else ans[x]=2;

    }

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

        std::cout<<ans[i]<<" ";

    }

    std::cout<<"\n";



    return;

}



int main() {

    std::ios::sync_with_stdio(false);

    std::cin.tie(nullptr);

    std::cout.tie(nullptr);

    int t = 1;

    std::cin >> t;

    while(t--) {

        solve();

    }

    return 0;

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

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

#define u32 unsigned int

#define ll long long

#define ull unsigned ll



const int N = 2e5+5, mod = 998244353;

int ans[N];

void solve() {

    

    int n,x,y;

    std::cin>>n>>x>>y;

    if(x>y) std::swap(x,y);

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

        ans[i]=i%2;

    }

    ans[n-1]=0;

    if(n&1) ans[n]=2;

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

        //nothing happened nya~

    } else {

        ans[x]=ans[y];

        if(x==1||x==n-1) std::swap(ans[x],ans[n]);

        else ans[x]=2;

    }

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

        std::cout<<ans[i]<<" ";

    }

    std::cout<<"\n";



    return;

}



int main() {

    std::ios::sync_with_stdio(false);

    std::cin.tie(nullptr);

    std::cout.tie(nullptr);

    int t = 1;

    std::cin >> t;

    while(t--) {

        solve();

    }

    return 0;

}

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

#define u32 unsigned int

#define ll long long

#define ull unsigned ll



const int N = 2e5+5, mod = 998244353;

int ans[N];

void solve() {

    

    int n,x,y;

    std::cin>>n>>x>>y;

    if(x>y) std::swap(x,y);

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

        ans[i]=(i+1)%2;

    }

    ans[n]=ans[n-1]&1^1;

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

        //nothing happened nya~

    } else {

        ans[x]=ans[y];

        if(x==1||x==n-1) std::swap(ans[x],ans[n]);

        else ans[x]=2;

    }

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

        std::cout<<ans[i]<<" ";

    }

    std::cout<<"\n";



    return;

}



int main() {

    std::ios::sync_with_stdio(false);

    std::cin.tie(nullptr);

    std::cout.tie(nullptr);

    int t = 1;

    std::cin >> t;

    while(t--) {

        solve();

    }

    return 0;

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

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

#define u32 unsigned int

#define ll long long

#define ull unsigned ll



const int N = 2e5+5, mod = 998244353;

int ans[N];

void solve() {

    

    int n,x,y;

    std::cin>>n>>x>>y;

    if(x>y) std::swap(x,y);

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

        ans[i]=(i+1)%2;

    }

    ans[n]=n&1+1;

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

        //nothing happened nya~

    } else {

        //ans[x]=ans[y];

        if(x==1&&n&1) std::swap(ans[x],ans[n]);

        else ans[x]=2;

    }

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

        std::cout<<ans[i]<<" ";

    }

    std::cout<<"\n";



    return;

}



int main() {

    std::ios::sync_with_stdio(false);

    std::cin.tie(nullptr);

    std::cout.tie(nullptr);

    int t = 1;

    std::cin >> t;

    while(t--) {

        solve();

    }

    return 0;

}

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

#define u32 unsigned int

#define ll long long

#define ull unsigned ll



const int N = 2e5+5, mod = 998244353;

int ans[N];

void solve() {

    

    int n,x,y;

    std::cin>>n>>x>>y;

    if(x>y) std::swap(x,y);

    ans[1]=0;

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

        ans[i]=ans[i-1]^1;

    }

    ans[n]=(n&1)+1;

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

        //nothing happened nya~

    } else {

        //ans[x]=ans[y];

        if(x==1&&n&1) std::swap(ans[x],ans[n]);

        else ans[x]=2;

    }

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

        std::cout<<ans[i]<<" ";

    }

    std::cout<<"\n";



    return;

}



int main() {

    std::ios::sync_with_stdio(false);

    std::cin.tie(nullptr);

    std::cout.tie(nullptr);

    int t = 1;

    std::cin >> t;

    while(t--) {

        solve();

    }

    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;

int main()

{

 ios::sync_with_stdio(false);

cin.tie(NULL);

long long int t;

cin>>t;

while(t--){

int n;

cin>>n;

vector<int>a(n);

vector<int>p(n);

//bool m=true;

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

    cin>>a[i];

    p[i]=a[i];

}

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

int mi=0;

bool m=true;

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

   

        if(abs(a[i]-a[i+1])<=mi){

            m=false;

            break;

        }

        else {

            mi=a[i]-min(a[i],a[i+1]);

            i++;}

    }

  

if(a[n-1]<mi) m=false;



if(m) cout<<"YES"<<endl;

else cout<<"NO"<<endl;

}

 return 0;

}

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

using namespace std;

int main()

{

 ios::sync_with_stdio(false);

cin.tie(NULL);

long long int t;

cin>>t;

while(t--){

int n;

cin>>n;

vector<int>a(n);

vector<int>p(n);

//bool m=true;

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

    cin>>a[i];

    p[i]=a[i];

}

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

int mi=0;

bool m=true;

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

   

        if(abs(a[i]-a[i+1])<mi){

            m=false;

                                                  

            break;

        }

        else {

            mi=a[i]-min(a[i],a[i+1]);

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

            }

    }

if(a[n-1]<mi){

  //cout<<a[n-1]<<" "<<mi<<endl;

    m=false;

} 



if(m) cout<<"YES"<<endl;

else cout<<"NO"<<endl;

}

 return 0;

}