alexjercan/bugnet huggingface dataset:
Problem p02631 (C++) — buggy submission, verdict: 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 = 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;
}

Error: WA

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 = (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;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

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

void Main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    if (i == 0)
      b[i] = a[i];
    else
      b[i] = b[i - 1] ^ a[i];
  }
  vector<int> c(n);
  for (int i = 0; i < n; i++) {
    c[i] = b[n - 1] ^ b[i];
    if (i != 0)
      c[i] = c[i] ^ b[i - 1];
  }
  for (int i = 0; i < n; i++) {
    if (i != 0)
      cout << " ";
    cout << c[i];
  }
  cout << endl;
}

int main(int argc, char **argv) {
  Main();
  return 0;
}


Error: TLE

Fixed submission:

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

long f(vector<int> a, int e) {
  int n = a.size();
  a[e] = 0;
  while (n > 1) {
    for (int i = 0; i < n; i += 2) {
      if (i + 1 < n)
        a[i / 2] = a[i] ^ a[i + 1];
      else
        a[i / 2] = a[i];
    }
    n = (n + 1) / 2;
  }
  return a[0];
}

void Main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    // for (int j = 0; j < n; j++)
    // {
    //     if(i != j)
    //         b[i] = b[i] ^ a[j];
    // }
    b[i] = f(a, i);
    if (i != 0)
      cout << " ";
    cout << b[i];
  }
  cout << endl;
}

int main(int argc, char **argv) {
  Main();
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

#define eps 10e-9
#define pi 2 * acos(0)
#define P1 1e9 + 7
#define P2 1e9 + 9
#define lli long long int

using namespace std;

/// ISNNJB
int ara[200010], brr[100010];

void constructXOR(int n) {
  lli XOR = 0;
  for (int i = 0; i < n; i++)
    XOR ^= ara[i];
  /// cout<<XOR<<endl;

  for (int i = 0; i < n; i++)
    ara[i] = XOR ^ ara[i];
}

/**int fx[]={+1,-1,+0,+0};
int fy[]={+0,+0,+1,-1};
int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};*/

int main() {
  /***freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);*/

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  lli n;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> ara[i];
  constructXOR(n);

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

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

#define eps 10e-9
#define pi 2 * acos(0)
#define P1 1e9 + 7
#define P2 1e9 + 9
#define lli long long int

using namespace std;

/// ISNNJB
int ara[100010], brr[100010];

void constructXOR(int n) {
  int XOR = 0;
  for (int i = 0; i < n; i++)
    XOR ^= ara[i];

  for (int i = 0; i < n; i++)
    ara[i] = XOR ^ ara[i];
}

/**int fx[]={+1,-1,+0,+0};
int fy[]={+0,+0,+1,-1};
int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};*/

int main() {
  /***freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);*/

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  lli a, b, c, d, t, n, m, x, y, q, ctn, l1, l2, total = 0;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> ara[i];
  constructXOR(n);

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

  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Runtime Error

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

#define froop1(a, n) for (long long i = a; i < n; i++)
#define froop2(a, n) for (long long i = a; i > n; i--)
int main() {
  long long N;
  cin >> N;
  vector<long long> a(N);
  vector<long long> bit(200, 0);
  vector<vector<long long>> e(N);
  froop1(0, N) { cin >> a.at(i); }
  long long d = a.at(0);
  long long k = 0;
  while (d > 0) {
    bit.at(k) += d % 2;
    e.at(0).push_back(d % 2);
    d /= 2;
    k++;
  }
  froop1(1, N) {
    d = a.at(i);
    long long kd = 0;
    while (d > 0) {
      bit.at(kd) += (d % 2);
      e.at(i).push_back(d % 2);
      d /= 2;
      kd++;
    }
  }
  froop1(0, bit.size()) { bit.at(i) %= 2; }
  froop1(0, N) {
    long long sum = 0;
    long long b = 1;
    for (int j = 0; j < bit.size(); j++) {
      if (j < e.at(i).size()) {
        sum += (bit.at(j) + e.at(i).at(j)) % 2 * b;
      } else {
        sum += bit.at(j) * b;
      }
      b *= 2;
    }
    cout << sum;
    if (i != N - 1)
      cout << ' ';
    else
      cout << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

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

#define froop1(a, n) for (long long i = a; i < n; i++)
#define froop2(a, n) for (long long i = a; i > n; i--)
int main() {
  long long N;
  cin >> N;
  vector<long long> a(N);
  vector<long long> bit;
  vector<vector<long long>> e(N);
  froop1(0, N) { cin >> a.at(i); }
  long long d = a.at(0);
  long long k = 0;
  while (d > 0) {
    bit.push_back(d % 2);
    e.at(0).push_back(d % 2);
    d /= 2;
    k++;
  }
  froop1(1, N) {
    d = a.at(i);
    long long kd = 0;
    while (d > 0) {
      bit.at(kd) += (d % 2);
      e.at(i).push_back(d % 2);
      d /= 2;
      kd++;
    }
  }
  froop1(0, bit.size()) { bit.at(i) %= 2; }
  froop1(0, N) {
    long long sum = 0;
    long long b = 1;
    for (int j = 0; j < bit.size(); j++) {
      if (j < e.at(i).size()) {
        sum += (bit.at(j) + e.at(i).at(j)) % 2 * b;
      } else {
        sum += bit.at(j) * b;
      }
      b *= 2;
    }
    cout << sum;
    if (i != N - 1)
      cout << ' ';
    else
      cout << endl;
  }
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using ll = long long;

#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \\
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \\
       << endl
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N, std::vector<ll> a) {
  vector<ll> s(N, -1);

  ll v = a.at(0);

  FOR(i, 1, N) { v = v ^ a.at(i); }

  rep(i, N) { s.at(i) = v ^ a.at(i); }

  rep(i, N) {
    if (i == N - 1) {
      cout << s.at(i);
    } else {
      cout << s.at(i) << " ";
    }
  }
  cout << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  std::vector<ll> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  solve(N, std::move(a));
  return 0;
}


Error: TLE

Fixed submission:

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

using ll = long long;

#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \\
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \\
       << endl
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N, std::vector<ll> a) {
  int v = 11 ^ 9 ^ 24;
  vector<ll> s(N, -1);

  rep(i, N) {
    rep(j, N) {
      if (i == j)
        continue;
      if (s.at(j) == -1) {
        s.at(j) = a.at(i);
      } else {
        s.at(j) = s.at(j) ^ a.at(i);
      }
    }
  }

  rep(i, N) {
    if (i == N - 1) {
      cout << s.at(i);
    } else {
      cout << s.at(i) << " ";
    }
  }
  cout << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  std::vector<ll> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  solve(N, std::move(a));
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i = 0; i < int(N); ++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;

int main() {
  // int a = 3^0;
  // cout << a << endl;
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll all = 0;
  rep(i, n) { all = all ^ a[i]; }
  // cout << all << endl;
  rep(i, n) {
    int now = all ^ a[i];
    cout << now << ' ';
    // cout << all^a[i];
  }
  cout << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i = 0; i < int(N); ++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;

int main() {
  // int a = 3^0;
  // cout << a << endl;
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  vector<ll> ans_t;
  rep(i, n) {
    int ans = 0;
    rep(j, n) {
      if (i == j)
        ;
      else
        ans = ans ^ a[j];
    }
    ans_t.push_back(ans);
  }
  rep(i, ans_t.size()) cout << ans_t[i] << ' ';
  cout << endl;
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: 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[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;
}


Error: WA

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[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;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define tcase                                                                  \\
  int _;                                                                       \\
  cin >> _;                                                                    \\
  while (_--)
const int MAX = 1e6;

int n;
int v[MAX];

void solve() {
  cin >> n;
  int x = 0;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    x ^= v[i];
  }
  for (int i = 0; i < n; i++) {
    cout << (x ^ v[i]) << " ";
  }
  cout << "\\n";
}

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

  solve();

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define tcase                                                                  \\
  int _;                                                                       \\
  cin >> _;                                                                    \\
  while (_--)
const int MAX = 1e6;

int n;
int v[MAX];

void solve() {
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> v[i];
  for (int i = 0; i < n; i++) {
    int ans = 0;
    for (int j = 0; j < n; j++) {
      if (i != j)
        ans ^= v[j];
    }
    cout << ans << " ";
  }
  cout << "\\n";
}

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

  solve();

  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
using graph = vector<vector<int>>;

const double pi = 3.14159265358979323846;
const ll mod = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> A(n);
  rep(i, n) cin >> A.at(i);
  int x = 0;
  for (int i = 0; i < n; i++) {
    x ^= A.at(i);
  }
  for (int i = 0; i < n; i++) {
    int ans = x;
    ans ^= A.at(i);
    cout << ans << " ";
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
using graph = vector<vector<int>>;

const double pi = 3.14159265358979323846;
const ll mod = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> A(n);
  rep(i, n) cin >> A.at(i);
  vector<int> xr(n / 2);
  for (int i = 0; i < n / 2; i++) {
    xr.at(i) = (A.at(2 * i) ^ A.at(2 * i + 1));
  }
  for (int i = 0; i < n; i++) {
    int x = A.at(i);
    for (int j = 0; j < xr.size(); j++) {
      x ^= xr.at(j);
    }
    cout << x << " ";
  }
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {

  cin.tie(0);
  ios_base::sync_with_stdio(0);

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

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

  for (int i = 2; i <= N; i++) {
    int c = (ans ^ a[i]) ^ a[1];
    ;
    cout << c << " ";
  }
  cout << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

  for (int i = 1; i <= N; i++) {
    int ans = 0;
    for (int j = 1; j <= N; j++) {
      if (j != i) {
        ans ^= a[j];
      }
    }
    cout << ans << " ";
  }
  cout << endl;
}
Problem p02631 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int, int>;
ll mod = 1000000007, mod2 = 998244353;

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

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;
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

bool is_prime[1000010];

int main() {
  int n, ans = 0;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    ans ^= a[i];
  }
  for (int i = 0; i < n; ++i) {
    cout << (ans ^ a[i]) << endl;
  }
  return 0;
}

Error: -6
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc


Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int, int>;
ll mod = 1000000007, mod2 = 998244353;

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

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;
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

bool is_prime[1000010];

int main() {
  ll n, ans = 0;
  vector<ll> a(n);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    ans ^= a[i];
  }
  for (int i = 0; i < n; ++i) {
    cout << (ans ^ a[i]) << endl;
  }
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Runtime Error

#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;
}


Error: WA

Fixed submission:

#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;
}
Problem p02631 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
typedef long long int ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < signed(n); i++)
#define EREP(i, n) for (int i = 1; i <= signed(n); i++)
#define ALL(a) (a).begin(), (a).end()
using namespace std;
// #define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" << X << " ";
#define TF(f) f ? cout << "true  " : cout << "false ";
#define END cout << "\\n";
#else
#define DEB(X)                                                                 \\
  {}
#define TF(f)                                                                  \\
  {}
#define END                                                                    \\
  {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e14;
typedef std::pair<ll, ll> P;
struct edge {
  int to, cost;
};
#define VMAX 100000

ll K, N, X, A[200010];
ll ans = 0;
ll S[3][5000];
map<int64_t, int> ret;
int main() {
  cin >> N;
  REP(i, N) { cin >> A[i]; }
  REP(i, N) {
    if (i == 0)
      X = A[i];
    else
      X = (X ^ A[i]);
  }
  REP(i, N) {
    cout << (X ^ A[i]);
    if (i != N - 1)
      cout << " ";
  }

  // std::cout<<ans<<endl;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
typedef long long int ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < signed(n); i++)
#define EREP(i, n) for (int i = 1; i <= signed(n); i++)
#define ALL(a) (a).begin(), (a).end()
using namespace std;
// #define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" << X << " ";
#define TF(f) f ? cout << "true  " : cout << "false ";
#define END cout << "\\n";
#else
#define DEB(X)                                                                 \\
  {}
#define TF(f)                                                                  \\
  {}
#define END                                                                    \\
  {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e14;
typedef std::pair<ll, ll> P;
struct edge {
  int to, cost;
};
#define VMAX 100000

ll N, M, K;
ll A[100010], B, C, D, X, Y;
ll ans = 0;
string S, T, U;
ll F[100010];
bool ok = true;
ll Q;
ll G[50];
ll ga[200010][20];
ll Z[] = {1, 2, 3, 6, 7, 8, 9, 0};

int main() {
  cin >> N;
  REP(i, N) {
    cin >> A[i];
    ll a = A[i];
    REP(k, 20) {
      G[k] += a % 2;
      ga[i][k] += a % 2;
      a /= 2;
    }
  }
  REP(i, N) {
    ans = 0;
    ll b = 1;
    REP(k, 20) {
      ans += b * ((G[k] - ga[i][k]) % 2);
      b *= 2;
    }
    cout << ans << endl;
  }
}
Problem p02631 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define D(x) cout << #x << "=" << x << endl;
#define De(...)
#define hrp(i, l, r) for (register int i = l; i <= r; i++)
using namespace std;

int _;

int n, a[200500], ans;

int main() {
  // for(scanf("%d",&_);_;_--)
  scanf("%lld", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    ans ^= a[i];
  }
  for (int i = 0; i < n; i++)
    printf("%d ", ans ^ a[i]);
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define D(x) cout << #x << "=" << x << endl;
#define De(...)
#define hrp(i, l, r) for (register int i = l; i <= r; i++)
using namespace std;

int _;

long long n, a[200500], ans[20000];
int maxn = 0;
string s[200500];

inline int dectobin(int nn) {
  int result = 0, k = 1, i, temp;
  temp = nn;
  while (temp) {
    i = temp % 2;
    result = k * i + result;
    k = k * 10;
    temp = temp / 2;
  }
  return result;
}

int Atoi(string s, int radix) // s是给定的radix进制字符串
{
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    char t = s[i];
    if (t >= '0' && t <= '9')
      ans = ans * radix + t - '0';
    else
      ans = ans * radix + t - 'a' + 10;
  }
  return ans;
}

int main() {
  // for(scanf("%d",&_);_;_--)
  scanf("%lld", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", a + i);
  for (int i = 0; i < n; i++) {
    int x = dectobin(a[i]), cnt = 0;
    while (x) {
      ans[cnt] += x % 10;
      x /= 10;
      maxn = max(maxn, cnt);
      cnt++;
    }
  }
  for (int i = maxn; i >= 0; i--) {
    for (int j = 0; j < n - ans[i]; j++)
      s[j] += '1';
    for (int j = n - ans[i]; j < n; j++)
      s[j] += '0';
  }
  for (int i = 0; i < n; i++) {
    //	printf("%d ",dectobin(Atoi(s[i],2)));
    printf("%d ", Atoi(s[i], 2));
  }
  return 0;
}