prithivMLmods/Coder-Stat huggingface dataset:
Problem p02631 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD 998244353
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double, ll> &firstElof,
                 const pair<double, ll> &secondElof) {
  return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double, ll> &firstElof,
                       const pair<double, ll> &secondElof) {
  return firstElof.second < secondElof.second;
}
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge { // グラフに使うヤツ
  ll from, to, cost;
};

typedef vector<vector<edge>> G;
ll gcd(ll a, ll b) {
  if (a % b == 0)
    return (b);
  else
    return (gcd(b, a % b));
}
int main() {
  ll n;
  cin >> n;
  ll a[n];
  for (ll i = 0; i < n; i++)
    cin >> a[i];
  for (ll i = 0; i < n; i++) {
    ll x = 0;
    for (ll j = 0; j < n; j++) {
      if (i == j)
        continue;
      x ^= a[j];
    }
    cout << x << " ";
  }
  cout << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD 998244353
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double, ll> &firstElof,
                 const pair<double, ll> &secondElof) {
  return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double, ll> &firstElof,
                       const pair<double, ll> &secondElof) {
  return firstElof.second < secondElof.second;
}
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge { // グラフに使うヤツ
  ll from, to, cost;
};

typedef vector<vector<edge>> G;
ll gcd(ll a, ll b) {
  if (a % b == 0)
    return (b);
  else
    return (gcd(b, a % b));
}
int main() {
  ll n;
  cin >> n;
  ll a[n];
  for (ll i = 0; i < n; i++)
    cin >> a[i];
  ll x = 0;
  for (ll i = 1; i < n; i++) {
    x = x ^ a[i];
  }
  cout << x << " ";
  for (ll i = 1; i < n; i++) {
    x ^= a[i - 1];
    x ^= a[i];
    cout << x << " ";
  }
  cout << endl;
  return 0;
}
Problem p02631 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define vint vector<int>

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];

  int mx = 0;
  REP(i, n) { mx = max(mx, a[i]); }
  int digit = (int)log2(mx) + 1;

  vint sum(digit, 0);
  REP(i, n) {
    REP(j, digit) {
      if (a[i] & (1 << j))
        sum[j]++;
    }
  }

  vector<int> ans(n, 0);
  REP(i, n) {
    REP(j, digit) {
      if (sum[j] % 2 == 0) {
        if (a[i] & (1 << j)) {
          ans[i] |= (1 << j);
        }
      } else {
        if (!(a[i] & (1 << j))) {
          ans[i] |= (1 << j);
        }
      }
    }
  }

  REP(i, n) cout << ans[i] << " ";
  cout << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define vint vector<int>

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];

  int mx = 0;
  REP(i, n) { mx = max(mx, a[i]); }
  int digit = 32;

  vint sum(digit, 0);
  REP(i, n) {
    REP(j, digit) {
      if (a[i] & (1 << j))
        sum[j]++;
    }
  }

  vector<int> ans(n, 0);
  REP(i, n) {
    REP(j, digit) {
      if (sum[j] % 2 == 0) {
        if (a[i] & (1 << j)) {
          ans[i] |= (1 << j);
        }
      } else {
        if (!(a[i] & (1 << j))) {
          ans[i] |= (1 << j);
        }
      }
    }
  }

  REP(i, n) cout << ans[i] << " ";
  cout << endl;

  return 0;
}
Problem p02631 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
#define LL long long
#define li i << 1
#define ri i << 1 | 1
using namespace std;
inline LL read() {
  char c = getchar();
  LL x = 0, f = 1;
  while (c < '0' || c > '9') {
    if (c == '-')
      f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
const int maxn = 200005;
LL n, a[maxn], ans[maxn];
int main() {
  n = read();
  for (int i = 1; i <= n; ++i)
    a[i] = read();
  for (int p = 0;; ++p) {
    ans[1] = p;
    for (int i = 2; i <= n; ++i) {
      ans[i] = (a[i - 1] ^ a[i] ^ ans[i - 1]);
    }
    if ((a[1] ^ a[n]) != (ans[1] ^ ans[n]))
      continue;
    LL num = 0;
    for (int i = 2; i <= n; ++i)
      num ^= ans[i];
    if (num == a[1])
      break;
  }
  for (int i = 1; i <= n; ++i) {
    if (i != 1)
      printf(" ");
    printf("%lld", ans[i]);
  }
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
#define LL long long
#define li i << 1
#define ri i << 1 | 1
using namespace std;
inline LL read() {
  char c = getchar();
  LL x = 0, f = 1;
  while (c < '0' || c > '9') {
    if (c == '-')
      f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
const int maxn = 200005;
LL n, a[maxn], ans[maxn];
int main() {
  n = read();
  for (int i = 1; i <= n; ++i)
    a[i] = read();
  for (int i = 2; i <= n; ++i)
    ans[1] ^= a[i];
  for (int i = 2; i <= n; ++i)
    ans[i] = (a[i - 1] ^ a[i] ^ ans[i - 1]);
  for (int i = 1; i <= n; ++i) {
    if (i != 1)
      printf(" ");
    printf("%lld", ans[i]);
  }
  return 0;
}
Problem p02631 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<ll, ll>
#define vi vector<ll>
#define vii vector<pii>
#define mi map<ll, ll>
#define mii map<pii, ll>
#define all(a) (a).begin(), (a).end()
#define fi first
#define si second
#define sz(x) (ll) x.size()
#define endl '\n'
#define mod 1000000007
#define mset(m, v) memset(m, v, sizeof(m))
using namespace std;
ll power(ll a, ll b, ll modi) {
  a %= modi;
  ll res = 1;
  while (b) {
    if (b % 2) {
      res = (res * a) % modi;
    }
    b /= 2;
    a = (a * a) % modi;
  }
  return res;
}
// ll a[100001];
ll a[100001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  // cin>>t;
  while (t--) {
    ll n;
    cin >> n;
    for (ll i = 0; i < n; i++)
      cin >> a[i];
    ll x = 0;
    for (ll i = 0; i < n; i++)
      x ^= a[i];
    for (ll i = 0; i < n; i++)
      a[i] = a[i] ^ x;
    for (ll i = 0; i < n; i++)
      cout << a[i] << " ";
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<ll, ll>
#define vi vector<ll>
#define vii vector<pii>
#define mi map<ll, ll>
#define mii map<pii, ll>
#define all(a) (a).begin(), (a).end()
#define fi first
#define si second
#define sz(x) (ll) x.size()
#define endl '\n'
#define mod 1000000007
#define mset(m, v) memset(m, v, sizeof(m))
using namespace std;
ll power(ll a, ll b, ll modi) {
  a %= modi;
  ll res = 1;
  while (b) {
    if (b % 2) {
      res = (res * a) % modi;
    }
    b /= 2;
    a = (a * a) % modi;
  }
  return res;
}
// ll a[100001];
ll a[200001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  // cin>>t;
  while (t--) {
    ll n;
    cin >> n;
    for (ll i = 0; i < n; i++)
      cin >> a[i];
    ll x = 0;
    for (ll i = 0; i < n; i++)
      x ^= a[i];
    for (ll i = 0; i < n; i++)
      a[i] = a[i] ^ x;
    for (ll i = 0; i < n; i++)
      cout << a[i] << " ";
  }
  return 0;
}
Problem p02631 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <iostream>  // cout, endl, cin
#include <math.h>    // sqrt
#include <string>    // string, to_string, stoi
#include <vector>    // vector
using namespace std;

long long ruijo(int n) {
  long long ans = 1;
  for (int i = 0; i < n; i++) {
    ans *= 2;
  }
  return ans;
}

int main() {
  int N;
  cin >> N;
  vector<long long> data(N);
  for (int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  vector<int> two(31, 0);
  long long num;
  int j;
  for (int i = 0; i < N; i++) {
    num = data.at(i);
    j = 0;
    while (true) {
      if (num % 2 == 1) {
        two.at(j)++;
      }
      if (num < 2) {
        break;
      }
      num = floor(num / 2);
      j++;
    }
  }
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    if (two.at(i) % 2 == 1) {
      ans += ruijo(i);
    }
  }
  long long ansa;
  for (int i = 0; i < N; i++) {
    ansa = ans;
    num = data.at(i);
    j = 0;
    while (true) {
      if (num % 2 == 1) {
        if (two.at(j) % 2 == 0) {
          ansa += ruijo(j);
        } else {
          ansa -= ruijo(j);
        }
      }
      if (num < 2) {
        break;
      }
      num = floor(num / 2);
      j++;
    }
    cout << ansa << ' ';
  }
  cout << endl;
}

Fixed submission:
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <iostream>  // cout, endl, cin
#include <math.h>    // sqrt
#include <string>    // string, to_string, stoi
#include <vector>    // vector
using namespace std;

long long ruijo(int n) {
  long long ans = 1;
  for (int i = 0; i < n; i++) {
    ans *= 2;
  }
  return ans;
}

int main() {
  int N;
  cin >> N;
  vector<long long> data(N);
  for (int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  vector<int> two(31, 0);
  long long num;
  int j;
  for (int i = 0; i < N; i++) {
    num = data.at(i);
    j = 0;
    while (true) {
      if (num % 2 == 1) {
        two.at(j)++;
      }
      if (num < 2) {
        break;
      }
      num = floor(num / 2);
      j++;
    }
  }
  long long ans = 0;
  for (int i = 0; i < 31; i++) {
    if (two.at(i) % 2 == 1) {
      ans += ruijo(i);
    }
  }
  long long ansa;
  for (int i = 0; i < N; i++) {
    ansa = ans;
    num = data.at(i);
    j = 0;
    while (true) {
      if (num % 2 == 1) {
        if (two.at(j) % 2 == 0) {
          ansa += ruijo(j);
        } else {
          ansa -= ruijo(j);
        }
      }
      if (num < 2) {
        break;
      }
      num = floor(num / 2);
      j++;
    }
    cout << ansa << ' ';
  }
  cout << endl;
}
Problem p02631 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  ll i, j, k, l, m, n, o, p, q, r, t, a[100001] = {0};
  cin >> n;
  m = 0;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    m ^= a[i];
  }
  for (i = 0; i < n; i++) {
    cout << (m ^ a[i]) << " ";
  }
  cout << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  ll i, j, k, l, m, n, o, p, q, r, t, a[300001] = {0};
  cin >> n;
  m = 0;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    m ^= a[i];
  }
  for (i = 0; i < n; i++) {
    cout << (m ^ a[i]) << " ";
  }
  cout << endl;
  return 0;
}
Problem p02631 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                 \
  sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(    \
            c i) {
sim > struct rge {
  c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
  ~debug() { cerr << endl; }
  eni(!=) cerr << boolalpha << i;
  ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
  sim dor(const c &) { ris; }
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
using ull = unsigned long long;
const int nax = 1e9;
int ff(int xorr, int num) {
  for (int i = 1; i < nax; i++) {
    if ((xorr ^ i) == num) {
      return i;
    }
  }
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int xorr = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    xorr ^= a[i];
  }
  debug() << imie(xorr);
  vector<int> ans(n);
  for (int i = 0; i < n; i++) {
    ans[i] = ff(xorr, a[i]);
    assert((xorr ^ a[i]) == ans[i]);
  }
  for (auto it : ans) {
    cout << it << " ";
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                 \
  sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(    \
            c i) {
sim > struct rge {
  c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
  ~debug() { cerr << endl; }
  eni(!=) cerr << boolalpha << i;
  ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
  sim dor(const c &) { ris; }
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
using ull = unsigned long long;
const int nax = 1e9;
int ff(int xorr, int num) { return (xorr ^ num); }
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int xorr = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    xorr ^= a[i];
  }
  debug() << imie(xorr);
  vector<int> ans(n);
  for (int i = 0; i < n; i++) {
    ans[i] = ff(xorr, a[i]);
    assert((xorr ^ a[i]) == ans[i]);
  }
  for (auto it : ans) {
    cout << it << " ";
  }
}
Problem p02631 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX = 1e5 + 5;

int vt[MX];

int main() {
  int i, j, k;
  int n;
  cin >> n;
  for (i = 0; i < n; ++i)
    cin >> vt[i];
  int sm = 0;
  for (i = 0; i < n; ++i)
    sm ^= vt[i];
  for (i = 0; i < n; ++i) {
    cout << (sm ^ vt[i]) << " ";
  }
  cout << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX = 2e5 + 5;

int vt[MX];

int main() {
  int i, j, k;
  int n;
  cin >> n;
  for (i = 0; i < n; ++i)
    cin >> vt[i];
  int sm = 0;
  for (i = 0; i < n; ++i)
    sm ^= vt[i];
  for (i = 0; i < n; ++i) {
    cout << (sm ^ vt[i]) << " ";
  }
  cout << endl;
}
Problem p02631 (C++)

Buggy submission (status: Runtime Error):
// #pragma GCC optimize (2)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(v) v.begin(), v.end()
ll quick_pow(ll base, ll n) {
  ll ans = 1;
  while (n) {
    if (n & 1)
      ans *= base;
    base *= base;
    n >>= 1;
  }
  return ans;
}
void solve();
int main() {
  int T = 1;
  // cin>>T;
  while (T--) {
    solve();
  }
  return 0;
}

int a[100050];
void solve() {
  int n;
  cin >> n;
  int t = 1;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    t ^= a[i];
  }
  t ^= 1;
  for (int i = 0; i < n; ++i) {
    t ^= a[i];
    cout << t << ' ';
    t ^= a[i];
  }
}

Fixed submission:
// #pragma GCC optimize (2)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(v) v.begin(), v.end()
ll quick_pow(ll base, ll n) {
  ll ans = 1;
  while (n) {
    if (n & 1)
      ans *= base;
    base *= base;
    n >>= 1;
  }
  return ans;
}
void solve();
int main() {
  int T = 1;
  // cin>>T;
  while (T--) {
    solve();
  }
  return 0;
}

int a[200050];
void solve() {
  int n;
  cin >> n;
  int t = 1;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    t ^= a[i];
  }
  t ^= 1;
  for (int i = 0; i < n; ++i) {
    t ^= a[i];
    cout << t << ' ';
    t ^= a[i];
  }
}
Problem p02631 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;

LL bin(LL a, LL b, LL p) {
  LL res = 1;
  for (; b; b >>= 1, a = a * a % p)
    if (b & 1)
      res = res * a % p;
  return res;
}
const int N = 1e5 + 50;
int a[N];
int n;

int main(int argc, char const *argv[]) {
  scanf("%d", &n);
  int s = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    s ^= a[i];
  }

  for (int i = 0; i < n; ++i) {
    printf("%d%c", s ^ a[i], i == n - 1 ? '\n' : ' ');
  }

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;

LL bin(LL a, LL b, LL p) {
  LL res = 1;
  for (; b; b >>= 1, a = a * a % p)
    if (b & 1)
      res = res * a % p;
  return res;
}
const int N = 3e5 + 50;
int a[N];
int n;

int main(int argc, char const *argv[]) {
  scanf("%d", &n);
  int s = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    s ^= a[i];
  }

  for (int i = 0; i < n; ++i) {
    printf("%d%c", s ^ a[i], i == n - 1 ? '\n' : ' ');
  }

  return 0;
}
Problem p02631 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main() {
  // int t;cin>>t;while(t--)
  {
    ll a, b, c, d, i, j, k, l, m, n, cnt = 0, sum = 0;
    ll arr[1000];
    cin >> n;
    for (i = 0; i < n; i++) {
      cin >> arr[i];
    }
    k = arr[0];
    for (i = 1; i < n; i++) {
      k ^= arr[i];
    }
    for (i = 0; i < n; i++) {
      l = arr[i] ^ k;
      cout << l << " ";
    }
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main() {
  // int t;cin>>t;while(t--)
  {
    ll a, b, c, d, i, j, k, l, m, n, cnt = 0, sum = 0;
    ll arr[300000];
    cin >> n;
    for (i = 0; i < n; i++) {
      cin >> arr[i];
    }
    k = arr[0];
    for (i = 1; i < n; i++) {
      k ^= arr[i];
    }
    for (i = 0; i < n; i++) {
      l = arr[i] ^ k;
      cout << l << " ";
    }
  }
}
Problem p02631 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>
using namespace std;

#include <climits>
#include <iomanip>
#include <math.h>
#include <queue>
#include <vector>
using Graph = vector<vector<int>>;
const double PI = 3.14159265358979323846;

long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

// 約数をベクトル形式で返す
vector<int> vect_yakusuu(int n) {
  vector<int> ret;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

int main() {

  long long ans;
  int N;
  int a[20002];

  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  int sum = 0;

  for (int i = 0; i < N; i++) {
    sum = sum ^ a[i];
  }

  for (int i = 0; i < N; i++) {
    ans = sum ^ a[i];
    cout << ans << " ";
  }

  cin >> ans;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>
using namespace std;

#include <climits>
#include <iomanip>
#include <math.h>
#include <queue>
#include <vector>
using Graph = vector<vector<int>>;
const double PI = 3.14159265358979323846;

long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

// 約数をベクトル形式で返す
vector<int> vect_yakusuu(int n) {
  vector<int> ret;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

int main() {

  long long ans;
  int N;
  int a[200020];

  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  int sum = 0;

  for (int i = 0; i < N; i++) {
    sum = sum ^ a[i];
  }

  for (int i = 0; i < N; i++) {
    ans = sum ^ a[i];
    cout << ans << " ";
  }

  cin >> ans;

  return 0;
}
Problem p02631 (C++)

Buggy submission (status: Runtime Error):
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimze("02")
using namespace std;
using ll = long long;
const ll maxn = 1e5 + 5, inf = 1e18 + 18;
ll n, ans, a[maxn];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    ans = ans ^ a[i];
  }
  for (int i = 0; i < n; i++) {
    ans = ans ^ a[i];
    cout << ans << endl;
    ans = ans ^ a[i];
  }
}


Fixed submission:
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimze("02")
using namespace std;
using ll = long long;
const ll maxn = 2e5 + 5, inf = 1e18 + 18;
ll n, ans, a[maxn];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    ans = ans ^ a[i];
  }
  for (int i = 0; i < n; i++) {
    ans = ans ^ a[i];
    cout << ans << endl;
    ans = ans ^ a[i];
  }
}
Problem p02631 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1 << 30) - 1)
#define LINF (1LL << 60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll a[100010];

int main() {
  int n;
  cin >> n;
  rep(i, n) cin >> a[i];

  ll b = a[0];
  rep(i, n - 1) { b ^= a[i + 1]; }
  rep(i, n) cout << (b ^ a[i]) << " ";
  cout << endl;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1 << 30) - 1)
#define LINF (1LL << 60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll a[200010];

int main() {
  int n;
  cin >> n;
  rep(i, n) cin >> a[i];

  ll b = a[0];
  rep(i, n - 1) { b ^= a[i + 1]; }
  rep(i, n) cout << (b ^ a[i]) << " ";
  cout << endl;

  return 0;
}
Problem p02631 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h> //toINFandByd
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define endl "\n"
using namespace std;
typedef long long ll;

void solve() {
  int n;
  cin >> n;
  vector<ll> a(n);
  forn(i, n) cin >> a[i];
  vector<ll> ans(n);
  int i, j;
  for (i = 0; i < n; i++) {
    ans[i] = 0;
    for (j = 0; j < n; j++) {
      if (i == j)
        continue;
      ans[i] = ans[i] ^ a[j];
    }
  }
  for (auto x : ans) {
    cout << x << " ";
  }
  cout << endl;
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
//     freopen("output.txt","w",stdout);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
}

Fixed submission:
#include <bits/stdc++.h> //toINFandByd
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define endl "\n"
using namespace std;
typedef long long ll;

void solve() {
  int n;
  cin >> n;
  vector<ll> a(n);
  forn(i, n) cin >> a[i];
  vector<ll> ans(n);
  int i, j;
  ans[0] = 0;
  for (i = 1; i < n; i++) {
    ans[0] = ans[0] ^ a[i];
  }
  ll temp = ans[0];
  for (i = 1; i < n; i++) {
    temp = temp ^ a[i];
    temp = temp ^ a[i - 1];
    ans[i] = temp;
  }
  for (auto x : ans) {
    cout << x << " ";
  }
  cout << endl;
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
//     freopen("output.txt","w",stdout);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
}
Problem p02631 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned long long ull;
#define st first
#define sd second
#define mkp make_pair
#define pb push_back
void wenjian() {
  freopen("concatenation.in", "r", stdin);
  freopen("concatenation.out", "w", stdout);
}
void tempwj() {
  freopen("hash.in", "r", stdin);
  freopen("hash.out", "w", stdout);
}
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll a, ll b, ll mod) {
  a %= mod;
  ll ans = 1;
  while (b) {
    if (b & 1)
      ans = ans * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ans;
}
struct cmp {
  bool operator()(const pii &a, const pii &b) { return a.second > b.second; }
};
int lb(int x) { return x & -x; }

const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
const int maxn = 1e5 + 5;
int a[maxn];

int main() {
  int n;
  scanf("%d", &n);
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum ^= a[i];
  }
  for (int i = 1; i <= n; i++) {
    a[i] = a[i] ^ sum;
    printf("%d ", a[i]);
  }
  printf("\n");
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned long long ull;
#define st first
#define sd second
#define mkp make_pair
#define pb push_back
void wenjian() {
  freopen("concatenation.in", "r", stdin);
  freopen("concatenation.out", "w", stdout);
}
void tempwj() {
  freopen("hash.in", "r", stdin);
  freopen("hash.out", "w", stdout);
}
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll a, ll b, ll mod) {
  a %= mod;
  ll ans = 1;
  while (b) {
    if (b & 1)
      ans = ans * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ans;
}
struct cmp {
  bool operator()(const pii &a, const pii &b) { return a.second > b.second; }
};
int lb(int x) { return x & -x; }

const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
const int maxn = 3e5 + 5;
int a[maxn];

int main() {
  int n;
  scanf("%d", &n);
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum ^= a[i];
  }
  for (int i = 1; i <= n; i++) {
    a[i] = a[i] ^ sum;
    printf("%d ", a[i]);
  }
  printf("\n");
}
Problem p02631 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>

typedef unsigned long long ULONG;
typedef long long LONG;
using namespace std;

#define PI 3.1415926535897932384626433
#define _DBG_

int main(void) {
  ULONG N;
  cin >> N;
  vector<ULONG> a(N);
  for (ULONG i = 0; i < N; i++) {
    cin >> a[i];
  }

  for (ULONG i = 0; i < N; i++) {
    ULONG xor_ = 0;
    for (ULONG j = 0; j < N; j++) {
      if (i == j)
        continue;
      xor_ = xor_ ^ a[j];
    }
    cout << xor_;
    if (i != N - 1) {
      cout << " ";
    }
  }

  cout << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>

typedef unsigned long long ULONG;
typedef long long LONG;
using namespace std;

#define PI 3.1415926535897932384626433
#define _DBG_

int main(void) {
  ULONG N;
  cin >> N;
  vector<ULONG> a(N);
  for (ULONG i = 0; i < N; i++) {
    cin >> a[i];
  }

  ULONG xor_ = 0;
  for (ULONG j = 1; j < N; j++) {
    xor_ = xor_ ^ a[j];
  }
  cout << xor_ << " ";

  for (ULONG i = 1; i < N; i++) {
    xor_ = xor_ ^ a[i - 1];
    xor_ = xor_ ^ a[i];
    cout << xor_;
    if (i != N - 1) {
      cout << " ";
    }
  }

  cout << endl;

  return 0;
}
Problem p02631 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using namespace __gnu_pbds;

#define f(i, a, b) for (i = a; i < b; i++)
#define rep(i, n) f(i, 0, n)
#define fd(i, a, b) for (i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vector<ll>
#define ss second
#define ff first
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sz(a) a.size()
#define inf (1000 * 1000 * 1000 + 5)
#define all(a) a.begin(), a.end()
#define rev(a) a.rbegin(), a.rend()
#define tri pair<int, pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000 * 1000 * 1000 + 7)
#define pqueue priority_queue<int>
#define pdqueue priority_queue<int, vi, greater<int>>

void solve() {
  ll m = 0, n = 0, i = 0, j = 0, k = 0, ma = -1e9, mi = 1e9, ans = 0, cnt = 0;
  cin >> n;
  vl v(n);
  for (auto &i : v)
    cin >> i;
  rep(i, n) {
    ans = 0;
    rep(j, n) {
      if (i == j)
        continue;
      ans ^= v[j];
    }
    cout << ans << " ";
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  /* ll t;
  cin>>t;
  while(t--){ */
  solve();
  /* } */
}


Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using namespace __gnu_pbds;

#define f(i, a, b) for (i = a; i < b; i++)
#define rep(i, n) f(i, 0, n)
#define fd(i, a, b) for (i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vector<ll>
#define ss second
#define ff first
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sz(a) a.size()
#define inf (1000 * 1000 * 1000 + 5)
#define all(a) a.begin(), a.end()
#define rev(a) a.rbegin(), a.rend()
#define tri pair<int, pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000 * 1000 * 1000 + 7)
#define pqueue priority_queue<int>
#define pdqueue priority_queue<int, vi, greater<int>>

void solve() {
  ll m = 0, n = 0, i = 0, j = 0, k = 0, ma = -1e9, mi = 1e9, ans = 0, cnt = 0;
  cin >> n;
  vl v(n);
  for (auto &i : v)
    cin >> i;
  rep(i, n) { ans ^= v[i]; }
  rep(i, n) { cout << (ans ^ v[i]) << " "; }
  cout << "\n";
}

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  /* ll t;
  cin>>t;
  while(t--){ */
  solve();
  /* } */
}
Problem p02631 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int N = 100005;
#define ll long long
int cmp(int a, int b) { return a > b; }
int gcd(int x, int y) {
  while (y ^= x ^= y ^= x %= y)
    ;
  return x;
}
int a[100005];
int n, num = 0;

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    num ^= a[i];
  }
  for (int i = 0; i < n; i++) {
    cout << (num ^ a[i]) << " ";
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int N = 100005;
#define ll long long
int cmp(int a, int b) { return a > b; }
int gcd(int x, int y) {
  while (y ^= x ^= y ^= x %= y)
    ;
  return x;
}
int a[200004];
int n, num = 0;

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    num ^= a[i];
  }
  for (int i = 0; i < n; i++) {
    cout << (num ^ a[i]) << " ";
  }
  return 0;
}
Problem p02631 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define sz(a) ((int)a.size())
#define mp make_pair
#define fi first
#define se second

const int maxn = 1e5 + 5;

const int maxv = 1e9;

int T, tc;
int n;
int a[maxn];

int main() {
  //	freopen("inp.txt", "r", stdin);

  cin >> n;

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

  for (int i = 0; i < n; i++) {
    printf("%d ", x ^ a[i]);
  }

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define sz(a) ((int)a.size())
#define mp make_pair
#define fi first
#define se second

const int maxn = 2e5 + 5;

const int maxv = 1e9;

int T, tc;
int n;
int a[maxn];

int main() {
  //	freopen("inp.txt", "r", stdin);

  cin >> n;

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

  for (int i = 0; i < n; i++) {
    printf("%d ", x ^ a[i]);
  }

  return 0;
}
Problem p02631 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e5 + 5;
const long long inf = 0x3f3f3f3f;
long long a[maxn], num;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  // freopen(".in","r",stdin);
  // freopen(".out","w",stdout);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    num ^= a[i];
  }
  for (long long i = 1; i <= n; i++)
    cout << (num ^ a[i]) << " ";
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 5;
const long long inf = 0x3f3f3f3f;
long long a[maxn], num;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  // freopen(".in","r",stdin);
  // freopen(".out","w",stdout);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    num ^= a[i];
  }
  for (long long i = 1; i <= n; i++)
    cout << (num ^ a[i]) << " ";
  return 0;
}
Problem p02631 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>

#define int long long
#define rr register

#define inf 1e9
#define MAXN 1010

using namespace std;

inline int read() {
  int s = 0, f = 0;
  char ch = getchar();
  while (!isdigit(ch))
    f |= ch == '-', ch = getchar();
  while (isdigit(ch))
    s = s * 10 + (ch ^ 48), ch = getchar();
  return f ? -s : s;
}

void print(int x) {
  if (x < 0)
    putchar('-'), x = -x;
  if (x > 9)
    print(x / 10);
  putchar(x % 10 + 48);
}

int n, ans;

int a[MAXN];

signed main() {
  n = read();
  for (int i = 1; i <= n; i++)
    a[i] = read(), ans ^= a[i];
  for (int i = 1; i <= n; i++)
    cout << (ans ^ a[i]) << " ";
  puts("");
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>

#define int long long
#define rr register

#define inf 1e9
#define MAXN 200010

using namespace std;

inline int read() {
  int s = 0, f = 0;
  char ch = getchar();
  while (!isdigit(ch))
    f |= ch == '-', ch = getchar();
  while (isdigit(ch))
    s = s * 10 + (ch ^ 48), ch = getchar();
  return f ? -s : s;
}

void print(int x) {
  if (x < 0)
    putchar('-'), x = -x;
  if (x > 9)
    print(x / 10);
  putchar(x % 10 + 48);
}

int n, ans;

int a[MAXN];

signed main() {
  n = read();
  for (int i = 1; i <= n; i++)
    a[i] = read(), ans ^= a[i];
  for (int i = 1; i <= n; i++)
    cout << (ans ^ a[i]) << " ";
  puts("");
}
Problem p02631 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;
int mas[100000], input[100000];
int main() {
  int n, p, in, pans = 0;
  cin >> n >> p;
  input[0] = p;
  mas[0] = 0;
  for (int i = 1; i < n; i++) {
    cin >> input[i];
    in = input[i];
    int k = pans ^ in ^ p;
    mas[i] = k;
    pans = k;
    p = in;
  }
  int test = 0;
  for (int i = 1; i < n; i++) {
    test ^= mas[i];
  }
  pans = test ^ input[0];
  p = input[0];
  cout << pans << " ";
  for (int i = 1; i < n; i++) {
    in = input[i];
    int k = pans ^ in ^ p;
    cout << k << " ";
    pans = k;
    p = in;
  }
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;
int mas[200005], input[200005];
int main() {
  int n, p, in, pans = 0;
  cin >> n >> p;
  input[0] = p;
  mas[0] = 0;
  for (int i = 1; i < n; i++) {
    cin >> input[i];
    in = input[i];
    int k = pans ^ in ^ p;
    mas[i] = k;
    pans = k;
    p = in;
  }
  int test = 0;
  for (int i = 1; i < n; i++) {
    test ^= mas[i];
  }
  pans = test ^ input[0];
  p = input[0];
  cout << pans << " ";
  for (int i = 1; i < n; i++) {
    in = input[i];
    int k = pans ^ in ^ p;
    cout << k << " ";
    pans = k;
    p = in;
  }
}
Problem p02631 (C++)

Buggy submission (status: Time Limit Exceeded):
#include "bits/stdc++.h"
#define DEBUG(x) cout << #x << ": " << x << endl;
#define DEBUG_VEC(v)                                                           \
  cout << #v << ":";                                                           \
  for (int i = 0; i < v.size(); i++)                                           \
    cout << " " << v[i];                                                       \
  cout << endl
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vs vector<string>
#define pii pair<int, int>
#define pis pair<int, string>
#define psi pair<string, int>
#define pll pair<ll, ll>
#define rep(i, begin, end)                                                     \
  for (__typeof(end) i = (begin) - ((begin) > (end));                          \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout << setprecision(15) << fixed << p << endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1};
typedef long long ll;
typedef unsigned long long ull;
const ull INF = 1e18;
using namespace std;

int main() {
  int n;
  cin >> n;
  int lst[n];
  rep(i, 0, n) { cin >> lst[i]; }
  rep(i, 0, n) {
    int tmp = 0;
    rep(j, 0, n) {
      if (i == j)
        continue;
      tmp ^= lst[j];
    }
    cout << tmp << endl;
  }
  return 0;
}


Fixed submission:
#include "bits/stdc++.h"
#define DEBUG(x) cout << #x << ": " << x << endl;
#define DEBUG_VEC(v)                                                           \
  cout << #v << ":";                                                           \
  for (int i = 0; i < v.size(); i++)                                           \
    cout << " " << v[i];                                                       \
  cout << endl
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vs vector<string>
#define pii pair<int, int>
#define pis pair<int, string>
#define psi pair<string, int>
#define pll pair<ll, ll>
#define rep(i, begin, end)                                                     \
  for (__typeof(end) i = (begin) - ((begin) > (end));                          \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout << setprecision(15) << fixed << p << endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1};
typedef long long ll;
typedef unsigned long long ull;
const ull INF = 1e18;
using namespace std;

int main() {
  int n;
  cin >> n;
  int lst[n];
  rep(i, 0, n) { cin >> lst[i]; }
  int tmp = 0;
  rep(i, 1, n) { tmp ^= lst[i]; }
  cout << tmp << endl;
  lst[0] ^= tmp;
  rep(i, 1, n) {
    lst[i] ^= lst[0];
    cout << lst[i] << endl;
  }
  return 0;
}
Problem p02631 (C++)

Buggy submission (status: Runtime Error):
// BISMILLAHIR RAHMANIR RAHIM
#include <bits/stdc++.h>
#define mem(a, b) (memset(a, b, sizeof(a)))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define INF 2147483647
#define MOD 1000000007
#define MAX 100005
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;
typedef vector<ii> vii;
typedef priority_queue<int, vector<int>, greater<int>> PQ;

int Set(int mask, int pos) { return mask = mask | (1 << pos); }
bool check(int mask, int pos) { return (bool)(mask & (1 << pos)); }

int arr[MAX], cnt[32];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

  int n;

  cin >> n;
  vector<int> ans(n);

  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    for (int j = 0; j < 31; j++) {
      if (check(arr[i], j))
        cnt[j]++;
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 31; j++) {
      if (check(arr[i], j))
        cnt[j]--;
    }

    int res = 0;
    for (int j = 0; j < 31; j++) {
      if (cnt[j] & 1) {
        res += (1 << j);
      }
    }
    ans[i] = res;
    for (int j = 0; j < 31; j++) {
      if (check(arr[i], j))
        cnt[j]--;
    }
  }

  for (int i = 0; i < n - 1; i++)
    cout << ans[i] << " ";
  cout << ans[n - 1] << endl;

  return 0;
}


Fixed submission:
// BISMILLAHIR RAHMANIR RAHIM
#include <bits/stdc++.h>
#define mem(a, b) (memset(a, b, sizeof(a)))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define INF 2147483647
#define MOD 1000000007
#define MAX 200005
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;
typedef vector<ii> vii;
typedef priority_queue<int, vector<int>, greater<int>> PQ;

int Set(int mask, int pos) { return mask = mask | (1 << pos); }
bool check(int mask, int pos) { return (bool)(mask & (1 << pos)); }

int arr[MAX], cnt[32];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

  int n;

  cin >> n;
  vector<int> ans(n);

  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    for (int j = 0; j < 31; j++) {
      if (check(arr[i], j))
        cnt[j]++;
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 31; j++) {
      if (check(arr[i], j))
        cnt[j]--;
    }

    int res = 0;
    for (int j = 0; j < 31; j++) {
      if (cnt[j] & 1) {
        res += (1 << j);
      }
    }
    ans[i] = res;
    for (int j = 0; j < 31; j++) {
      if (check(arr[i], j))
        cnt[j]--;
    }
  }

  for (int i = 0; i < n - 1; i++)
    cout << ans[i] << " ";
  cout << ans[n - 1] << endl;

  return 0;
}
Problem p02631 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
#define ll long long
map<int, int> mo;
const int maxn = 1e5 + 5;
int a[maxn], b[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int xsum = a[0];
  for (int i = 1; i < n; i++) {
    xsum ^= a[i];
  }
  for (int i = 0; i < n; i++) {
    cout << (a[i] ^ xsum) << " ";
  }
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
#define ll long long
map<int, int> mo;
const int maxn = 2e5 + 5;
int a[maxn], b[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int xsum = a[0];
  for (int i = 1; i < n; i++) {
    xsum ^= a[i];
  }
  for (int i = 0; i < n; i++) {
    cout << (a[i] ^ xsum) << " ";
  }
}
Problem p02631 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define INF 0x3f3f3f3f
typedef vector<int> VI;
typedef long long ll;
typedef pair<int, int> PII;
typedef double db;
const ll mod = 1000000007;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0; // 角度转弧度
ll powmod(ll a, ll b) {
  ll res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1)
      res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
const int N = 1e5 + 10;
int a[N];
int main() {
  int n;
  cin >> n;
  int sum = 0;
  rep(i, 1, n + 1) scanf("%d", &a[i]), sum ^= a[i];
  rep(i, 1, n + 1) cout << (sum ^ a[i]) << " ";
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define INF 0x3f3f3f3f
typedef vector<int> VI;
typedef long long ll;
typedef pair<int, int> PII;
typedef double db;
const ll mod = 1000000007;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0; // 角度转弧度
ll powmod(ll a, ll b) {
  ll res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1)
      res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
const int N = 2e5 + 10;
int a[N];
int main() {
  int n;
  cin >> n;
  int sum = 0;
  rep(i, 1, n + 1) scanf("%d", &a[i]), sum ^= a[i];
  rep(i, 1, n + 1) cout << (sum ^ a[i]) << " ";
  return 0;
}
Problem p02631 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
template <typename T> inline void read(T &x) {
  x = 0;
  T f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-')
      f = -1;
  for (; isdigit(c); c = getchar())
    x = (x << 1) + (x << 3) + (c ^ 48);
  x *= f;
}
template <typename T> inline void w(T x) {
  if (x > 9)
    w(x / 10);
  putchar(x % 10 + 48);
}
template <typename T> inline void write(T x, char c) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  w(x);
  putchar(c);
}
int a[100005];
int main() {
  int n;
  int s = 0;
  read(n);
  for (int i = 1; i <= n; i++) {
    read(a[i]);
    s ^= a[i];
  }
  for (int i = 1; i < n; i++) {
    write(s ^ a[i], ' ');
  }
  write(s ^ a[n], '\n');
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
template <typename T> inline void read(T &x) {
  x = 0;
  T f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-')
      f = -1;
  for (; isdigit(c); c = getchar())
    x = (x << 1) + (x << 3) + (c ^ 48);
  x *= f;
}
template <typename T> inline void w(T x) {
  if (x > 9)
    w(x / 10);
  putchar(x % 10 + 48);
}
template <typename T> inline void write(T x, char c) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  w(x);
  putchar(c);
}
int a[200005];
int main() {
  int n;
  int s = 0;
  read(n);
  for (int i = 1; i <= n; i++) {
    read(a[i]);
    s ^= a[i];
  }
  for (int i = 1; i < n; i++) {
    write(s ^ a[i], ' ');
  }
  write(s ^ a[n], '\n');
  return 0;
}