ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
// LOCKED IN!
#include <bits/stdc++.h>
using namespace std;
#define int long long
// const int MXV = (1LL << 58) - 1;
const int INF = (1LL << 56);
const int MXQ = (1LL << 32) - 1;
void dbg(vector<int> &v) { for(int k: v) cout << k << " "; }
void dbg(map<int, int> &v) { for(auto [a, b]: v) cout << a << " " << b << '\n'; }
void dbg(set<int> &v) { for(int k: v) cout << k << " "; }

// O(n) ~ O(1)
struct DSU {
  vector<int> par, sz;
  DSU(int n) {
    par.resize(n+1);
    sz.resize(n+1, 1);
    for(int i = 0 ; i <= n ; i++) par[i] = i;
  }

  int pfind(int v) {
    if(v == par[v]) return v;
    else return par[v] = pfind(par[v]);
  }

  void sunion(int a, int b) {
    a = pfind(a);
    b = pfind(b);
    if(a == b) return;
    if(sz[a] > sz[b]) swap(a, b);
    par[b] = a;
    sz[a] += sz[b];
  }
};

void solve() {
  int n; cin >> n;
  vector<int> v(n);
  for(int i = 0 ; i < n ; i++) cin >> v[i];
  if(n == 1) {
    cout << v[0] << '\n';
    return;
  }
  
  int r = 0;
  for(int i = 0 ; i < n-1 ; i++) {
    // yapping fr fr
    int k = 0;
    for(int j: v) k += j;
    if(k < 0) reverse(v.begin(), v.end());
    r = max(r, abs(k));
    vector<int> nv;
    for(int j = 0 ; j < v.size()-1 ; j++) nv.push_back(v[j+1] - v[j]);
    v = nv;
    // for(int j: v) cout << j << " ";
    // cout << endl;
  }

  cout << max(r, abs(v[0])) << '\n';
}

signed main() {
  int t; cin >> t;
  // int t = 1;
  while(t--) solve();
}

// think greedy first, Div2AB usually are some sort of greedy, super simple usually
// C on Div2 or E on Div3/4 require more thinking but still not too hard
// for later problems, think about data structures like segment tree and ordered set
// do smth instead of nothing and stay organized
// WRITE STUFF DOWN
// DON'T GET STUCK ON ONE APPROACH
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'
#define pb push_back
#define int long long int
#define deb(x) cerr << x << endl;
#define deb2(x, y) cerr << x << " " << y << endl;
#define deb3(x, y, z) cerr << x << " " << y << " " << z << endl;
#define f_(i, j, k) for (ll i = j; i < k; i++)
#define f__(i, j, k) for (ll i = j; i >= k; i--)

// order_of_key(k)   --> count of elements smaller than k (0 based index)
// find_by_order(k)  --> iterator to the kth element (k=0 for first element)
template <typename T> using maxpq = priority_queue<T, vector<T>>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T> istream &operator>>(istream &in, vector<T> &v) { for (auto &x: v) cin >> x; return in; }
template <typename T> ostream &operator<<(ostream &out, vector<T> &v) { for (auto &x: v) cout << x << " "; return out; }
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pp;
typedef pair<int, pp> ppp;
const int INF = 1e18+5, MOD = 1e9+7;  // 998244353;
const int MAXN = 2e5+5;

int exp(int a, int b, int m) {
    if (!b) return 1LL;
    if (b%2 == 0) return exp((a*a)%m, b/2, m);
    else return (a * exp((a*a)%m, b/2, m)) % m;
}
 
int moiv(int n, int m) {
    return exp(n, m-2, m);
}

bool fun(int x, map<int, int> &mp) {
    if (x==1) {
        if (!mp[x]) return false;
        mp[x]--;
        return true;
    }
    bool flag = true;
    int a = x/2, b = x/2;
    if (x%2) a++;
    if (mp[a]) mp[a]--;
    else flag &= fun(a, mp);
    if (mp[b]) mp[b]--;
    else flag &= fun(b, mp);
    return flag;
}

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

    vector<int> a(n), b(m);
    cin >> a >> b;

    int sa = accumulate(a.begin(), a.end(), 0LL);
    int sb = accumulate(b.begin(), b.end(), 0LL);
    if (sa != sb) {
        cout << "No" << endl;
        return;
    }

    map<int, int> mp;
    f_(i, 0, n) mp[a[i]]++;

    bool flag = true;
    f_(i, 0, m) {
        if (mp[b[i]]) mp[b[i]]--;
        else flag &= fun(b[i], mp);
    }

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int t = 1;
    cin >> t;

    while (t--)
        solve();

    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
 
ll t;
 
void printArr(vector<int> &a){
    for(int i=0; i<a.size(); i++){
        cout<<a[i]<<" ";
    }
    cout<<'\n';
}


void solve(){

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

    bool flag = false;

    int a=0, b=0, c=1;

    int bit = -1;

    if(r-l+1 == 3){
        cout<<l<<" "<<l+1<<" "<<r<<"\n";
        return;
    }

    for(int i=31; i>=0; i--){
        
        int lbit = (( 1 << i ) & l);
        int rbit = ((1 << i) & r);

        // cout<<"i th bit: " << i << "  " << "Lbit -> "<<lbit<<"  "<<"Rbit "<<rbit<<'\n';

        if(!(lbit ^ rbit)){
            if(rbit != 0){
                a |= (1 << i);
                b |= (1 << i);
                c |= (1 << i);
            }
        }else{
            bit = i;
            break;
        }
    }

    // cout<<a<<" "<<b<<" "<<c<<endl;
    // cout<<"First bit: "<<bit<<endl;

    while(bit >= 0){
        int rbit = (1 << bit) & r;
        int lbit = (1 << bit) & l;

        if(rbit && !lbit){
            a |= (1 << bit);
        }else {
            break;
        } 
        bit--;
    }

    // cout<<"Second bit: "<<bit<<endl;


    while(bit >= 0){
        int rbit = (1 << bit) & r;
        int lbit = (1 << bit) & l;

        if(lbit){
            b |= (1 << bit);
        }else{
            break;
        }
        bit--;
    }

    while(bit > 0){
        c |= (1<<bit);
        bit--;
    }

    if(b==l){
        c = b+1;
    }



    // cout<<"Third bit: "<<bit<<endl;


    

    cout<<a<<" "<<b<< " "<<c<<endl;

    // R  1 0 1 1 1 0 0 => 
    // L  1 0 1 0 0 1 1

    // 1 0 1 1 0
    // 0 0 1 1 0

    // 1 0
    // 0 0

    // 0 1 1 1 1 1 1 1
    // 0 1 1 1 0 0 1 1
}
 
int main() {
 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    cin>>t;
    while(t--){
        solve();
    }
 
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define endl "\n"
const int N = 3e5 + 10, M = 110, mod = 998244353;
const long long INF = 2e18;
typedef pair<int, int> pt;
typedef long long ll;



void solve() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n + 1), b(m + 1);
	map<int, int> cnt, cnt2;
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
		if (cnt[a[i]] == 1) sum++;
	}
	map<int, int> mp;
	for (int i = 1; i <= m; i++) {
		cin >> b[i];
		mp[b[i]]++;
	}
	while (!mp.empty()) {
		auto [x, t] = *mp.rbegin();
		mp.erase(mp.rbegin()->first);
		if (cnt[x] >= t) {
			cnt[x] -= t;
			if (cnt[x] == 0) sum--;
			continue;
		}
		else if (cnt[x] > 0) {
			t -= cnt[x];
			cnt[x] = 0;
			sum--;
		}
		if (x == 1) {
			cout << "No" << endl;
			return;
		}
		if (x & 1) {
			mp[x / 2] += t, mp[x / 2 + 1] += t;
		}
		else {
			mp[x / 2] += 2 * t;
		}
	}
	if (sum == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

signed main() {
    //freopen("data.in", "r", stdin);
    //freopen("std.txt", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Submission (verdict: Wrong answer on test 23):
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define endl "\n"
const int N = 3e5 + 10, M = 110, mod = 998244353;
const long long INF = 2e18;
typedef pair<int, int> pt;
typedef long long ll;



void solve() {
	int n, m;
	cin >> n >> m;
	map<int, int> cnt;
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		cnt[x]++;
	}
	map<int, int> mp;
	for (int i = 1; i <= m; i++) {
		int x;
		cin >> x;
		mp[x]++;
	}
	while (!mp.empty()) {
		auto [x, t] = *mp.rbegin();
		mp.erase(mp.rbegin()->first);
		if (cnt[x] >= t) {
			cnt[x] -= t;
			if (cnt[x] == 0) cnt.erase(x);
			continue;
		}
		else {
			t -= cnt[x];
			cnt[x] = 0;
			cnt.erase(x);
		}
		if (x == 1) {
			cout << "No" << endl;
			return;
		}
		if (x & 1) {
			mp[x / 2] += t, mp[x / 2 + 1] += t;
		}
		else {
			mp[x / 2] += 2 * t;
		}
	}
	if (cnt.empty()) cout << "Yes" << endl;
	else cout << "No" << endl;
}

signed main() {
    //freopen("data.in", "r", stdin);
    //freopen("std.txt", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define endl "\n"
const int N = 3e5 + 10, M = 110, mod = 998244353;
const long long INF = 2e18;
typedef pair<int, int> pt;
typedef long long ll;



void solve() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n + 1), b(m + 1);
	map<int, int> cnt;
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
		if (cnt[a[i]] == 1) sum++;
	}
	priority_queue<pt> pq;
	for (int i = 1; i <= m; i++) {
		cin >> b[i];
		pq.push({b[i], 1});
	}
	while (!pq.empty()) {
		auto [x, t] = pq.top();
		pq.pop();
		if (cnt[x] >= t) {
			cnt[x] -= t;
			if (cnt[x] == 0) sum--;
			continue;
		}
		else if (cnt[x] > 0) {
			t -= cnt[x];
			cnt[x] = 0;
			sum--;
		}
		if (x == 1) {
			cout << "No" << endl;
			return;
		}
		if (x & 1) {
			pq.push({x / 2, t}), pq.push({x / 2 + 1, t});
		}
		else {
			pq.push({x / 2, t * 2});
		}
	}
	if (sum == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

signed main() {
    //freopen("data.in", "r", stdin);
    //freopen("std.txt", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define endl "\n"
const int N = 3e5 + 10, M = 110, mod = 998244353;
const long long INF = 2e18;
typedef pair<int, int> pt;
typedef long long ll;



void solve() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n + 1), b(m + 1);
	map<int, int> cnt, cnt2;
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
		if (cnt[a[i]] == 1) sum++;
	}
	map<int, int> mp;
	for (int i = 1; i <= m; i++) {
		cin >> b[i];
		mp[b[i]]++;
	}
	while (!mp.empty()) {
		auto [x, t] = *mp.rbegin();
		mp.erase(mp.rbegin()->first);
		if (cnt[x] >= t) {
			cnt[x] -= t;
			if (cnt[x] == 0) sum--;
			continue;
		}
		else if (cnt[x] > 0) {
			t -= cnt[x];
			cnt[x] = 0;
			sum--;
		}
		if (x == 1) {
			cout << "No" << endl;
			return;
		}
		if (x & 1) {
			mp[x / 2] += t, mp[x / 2 + 1] += t;
		}
		else {
			mp[x / 2] += 2 * t;
		}
	}
	if (sum == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

signed main() {
    //freopen("data.in", "r", stdin);
    //freopen("std.txt", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define endl "\n"
const int N = 3e5 + 10, M = 110, mod = 998244353;
const long long INF = 2e18;
typedef pair<int, int> pt;
typedef long long ll;



void solve() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n + 1), b(m + 1);
	map<int, int> cnt;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	priority_queue<pt> pq;
	
	auto dfs = [&](auto self, int x, int t) -> bool {
		if (cnt[x] >= t) {
			cnt[x] -= t;
			if (cnt[x] == 0) cnt.erase(x);
			return 1;
		}
		else {
			t -= cnt[x];
			cnt[x] = 0;
			cnt.erase(x);
		}
		if (x == 1) return 0;
		if (x & 1) return (self(self, x / 2, t) & self(self, x / 2 + 1, t));
		return(self(self, x / 2, t * 2));
	};
	for (int i = 1; i <= m; i++) {
		cin >> b[i];
		pq.push({b[i], 1});
	}
	while (!pq.empty()) {
		auto [x, t] = pq.top();
		pq.pop();
		if (cnt[x] >= t) {
			cnt[x] -= t;
			if (cnt[x] == 0) cnt.erase(x);
			continue;
		}
		else {
			t -= cnt[x];
			cnt[x] = 0;
			cnt.erase(x);
		}
		if (x == 1) {
			cout << "No" << endl;
			return;
		}
		if (x & 1) {
			pq.push({x / 2, t}), pq.push({x / 2 + 1, t});
		}
		else {
			pq.push({x / 2, t * 2});
		}
	}
	if (cnt.empty()) cout << "Yes" << endl;
	else cout << "No" << endl;
}

signed main() {
    //freopen("data.in", "r", stdin);
    //freopen("std.txt", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 23):
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define endl "\n"
const int N = 3e5 + 10, M = 110, mod = 998244353;
const long long INF = 2e18;
typedef pair<int, int> pt;
typedef long long ll;



void solve() {
	int n, m;
	cin >> n >> m;
	map<int, int> cnt;
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		cnt[x]++;
	}
	map<int, int> mp;
	for (int i = 1; i <= m; i++) {
		int x;
		cin >> x;
		mp[x]++;
	}
	while (!mp.empty()) {
		auto [x, t] = *mp.rbegin();
		mp.erase(mp.rbegin()->first);
		if (cnt[x] >= t) {
			cnt[x] -= t;
			if (cnt[x] == 0) cnt.erase(x);
			continue;
		}
		else {
			t -= cnt[x];
			cnt[x] = 0;
			cnt.erase(x);
		}
		if (x == 1) {
			cout << "No" << endl;
			return;
		}
		if (x & 1) {
			mp[x / 2] += t, mp[x / 2 + 1] += t;
		}
		else {
			mp[x / 2] += 2 * t;
		}
	}
	if (cnt.empty()) cout << "Yes" << endl;
	else cout << "No" << endl;
}

signed main() {
    //freopen("data.in", "r", stdin);
    //freopen("std.txt", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

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

void solve () {
  int n, m;
  cin >> n >> m;
  multiset<int> a, b;
  for (int i = 0; i < n; i++) {
     int x;
     cin >> x;
     a.insert(x); 
   } 
  for (int i = 0; i < m; i++) {
      int x;
      cin >> x;
      b.insert(x);
   } 
  for (int i = 0; i < n; i++) {
    if (a.size() <= b.size()) {
      // cout << "No\n";
      break;
    }     
    int x , y;
    x = *a.begin();  a.erase(a.find(x));
    if (a.size() > 0) y = *a.begin(), a.erase(a.find(y));
   
    if (x == *b.begin()) {
      a.insert(y);
      b.erase(b.find(x));
    } else {
      if (abs(x - y) <= 1) a.insert(x + y);
      else break;
    }
  } 
  if (a.size() == 0 || b.size() == 0 || a.size() < b.size()) {
    cout << "No\n";
  } else {
    while (1) {
     if (a.size() == 0 || b.size() == 0) break; 
     int x = *a.begin(), y = *b.begin();
      if (x != y) {
        cout <<"No\n";
        return;
      } else {
        a.erase(a.find(x));
        b.erase(b.find(y));
      }
    }
    cout << "Yes\n";
  }
}

int main() {
  auto begin = std::chrono::high_resolution_clock::now();
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  //freopen("in",  "r", stdin);
  //freopen("out", "w", stdout);
  int T = 1;
  cin >> T;
  for(int i = 1; i <= T; i++) {
     // cout << "Case #" << i << ": ";
      solve();
  }
  auto end = std::chrono::high_resolution_clock::now();
  auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
  cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; 
  return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define endl "\n"
const int N = 3e5 + 10, M = 110, mod = 998244353;
const long long INF = 2e18;
typedef pair<int, int> pt;
typedef long long ll;



void solve() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n + 1), b(m + 1);
	map<int, int> cnt;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	priority_queue<pt> pq;
	
	auto dfs = [&](auto self, int x, int t) -> bool {
		if (cnt[x] >= t) {
			cnt[x] -= t;
			if (cnt[x] == 0) cnt.erase(x);
			return 1;
		}
		else {
			t -= cnt[x];
			cnt[x] = 0;
			cnt.erase(x);
		}
		if (x == 1) return 0;
		if (x & 1) return (self(self, x / 2, t) & self(self, x / 2 + 1, t));
		return(self(self, x / 2, t * 2));
	};
	for (int i = 1; i <= m; i++) {
		cin >> b[i];
		pq.push({b[i], 1});
	}
	while (!pq.empty()) {
		auto [x, t] = pq.top();
		pq.pop();
		if (cnt[x] >= t) {
			cnt[x] -= t;
			if (cnt[x] == 0) cnt.erase(x);
			continue;
		}
		else {
			t -= cnt[x];
			cnt[x] = 0;
			cnt.erase(x);
		}
		if (x == 1) {
			cout << "No" << endl;
			return;
		}
		if (x & 1) {
			pq.push({x / 2, t}), pq.push({x / 2 + 1, t});
		}
		else {
			pq.push({x / 2, t * 2});
		}
	}
	if (cnt.empty()) cout << "Yes" << endl;
	else cout << "No" << endl;
}

signed main() {
    //freopen("data.in", "r", stdin);
    //freopen("std.txt", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define endl "\n"
const int N = 3e5 + 10, M = 110, mod = 998244353;
const long long INF = 2e18;
typedef pair<int, int> pt;
typedef long long ll;



void solve() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n + 1), b(m + 1);
	map<int, int> cnt;
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
		if (cnt[a[i]] == 1) sum++;
	}
	priority_queue<pt> pq;
	for (int i = 1; i <= m; i++) {
		cin >> b[i];
		pq.push({b[i], 1});
	}
	while (!pq.empty()) {
		auto [x, t] = pq.top();
		pq.pop();
		if (cnt[x] >= t) {
			cnt[x] -= t;
			if (cnt[x] == 0) sum--;
			continue;
		}
		else if (cnt[x] > 0) {
			t -= cnt[x];
			cnt[x] = 0;
			sum--;
		}
		if (x == 1) {
			cout << "No" << endl;
			return;
		}
		if (x & 1) {
			pq.push({x / 2, t}), pq.push({x / 2 + 1, t});
		}
		else {
			pq.push({x / 2, t * 2});
		}
	}
	if (sum == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

signed main() {
    //freopen("data.in", "r", stdin);
    //freopen("std.txt", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int t = 1;
	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>

#include <iostream>

#include <set>

#include <unordered_map>

#include <vector>

#include <algorithm>

#include <string>

#include <map>

#include <cmath>

#include <iomanip>

#include <optional>





using namespace std;



typedef long long int ll;

typedef long double ld;



#define f(i, a, b) for (int i=a; i<b; i++)

#define IOS                                                                  \

    ios_base::sync_with_stdio(false);                                            \

    cin.tie(0);                                                                  \

    cout.tie(0);cout<<fixed<<setprecision(16);

#define pb push_back

#define mp make_pair





void solve() {



    ll n,x,y;

    cin>>n>>x>>y;



    vector<ll> v(n+1);

    ll counter = x, flip = 0;



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



        if(i == n && i%2 != 0) v[counter] = 2;

        else {

            v[counter] = flip;

            flip = !flip;

        }

        counter = (counter%n) + 1;

    }



    if(v[y] == 0) v[y] = 2;



    for(ll i=1; i<n+1; i++) cout<<v[i]<<" ";

    cout<<endl;



}







int main() {

    IOS

    int t;

    cin >> t;



    while(t--) solve();



    return 0;

}



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

#include <iostream>

#include <set>

#include <unordered_map>

#include <vector>

#include <algorithm>

#include <string>

#include <map>

#include <cmath>

#include <iomanip>

#include <optional>





using namespace std;



typedef long long int ll;

typedef long double ld;



#define f(i, a, b) for (int i=a; i<b; i++)

#define IOS                                                                  \

    ios_base::sync_with_stdio(false);                                            \

    cin.tie(0);                                                                  \

    cout.tie(0);cout<<fixed<<setprecision(16);

#define pb push_back

#define mp make_pair





void solve() {



    ll n,x,y;

    cin>>n>>x>>y;



    vector<ll> v(n+1);

    ll counter = x, flip = 0;



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



        if(i==1 && n%2==1) v[counter] = 2;

        else {

            v[counter] = flip;

            flip = !flip;

        }

        counter = (counter%n) + 1;

    }



    if(v[y] == 0 && n%2 == 0) v[y] = 2;



    for(ll i=1; i<n+1; i++) cout<<v[i]<<" ";

    cout<<endl;



}







int main() {

    IOS

    int t;

    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>

#include <iostream>

#include <set>

#include <unordered_map>

#include <vector>

#include <algorithm>

#include <string>

#include <map>

#include <cmath>

#include <iomanip>

#include <optional>





using namespace std;



typedef long long int ll;

typedef long double ld;



#define f(i, a, b) for (int i=a; i<b; i++)

#define IOS                                                                  \

    ios_base::sync_with_stdio(false);                                            \

    cin.tie(0);                                                                  \

    cout.tie(0);cout<<fixed<<setprecision(16);

#define pb push_back

#define mp make_pair





void solve() {



    ll n,x,y;

    cin>>n>>x>>y;



    vector<ll> v(n+1);

    ll counter = x, flip = 0;



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



        if(i == n && i%2 != 0) v[counter] = 2;

        else {

            v[counter] = flip;

            flip = !flip;

        }

        counter = (counter%n) + 1;

    }



    if(v[0] == 0) v[y] = 2;



    for(ll i=1; i<n+1; i++) cout<<v[i]<<" ";

    cout<<endl;



}







int main() {

    IOS

    int t;

    cin >> t;



    while(t--) solve();



    return 0;

}