alexjercan/bugnet huggingface dataset:
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

int main() {
  int N;
  std::cin >> N;
  std::vector<long long int> a(N);
  long long int ans = 0;
  for (int i = 0; i < N; i++) {
    std::cin >> a[i];
  }
  for (int i = 0; i < N; i++) {
    ans = a[i] ^ ans;
  }
  for (int i = 0; i < N; i++) {
    if (i == N - 1)
      std::cout << (a[i] ^ ans) << std::endl;
    else
      std::cout << (a[i] ^ ans) << " ";
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

int main() {
  int N;
  std::cin >> N;
  std::vector<long long int> a(N);
  std::vector<long long int> ans(N, 0);
  for (int i = 0; i < N; i++) {
    std::cin >> a[i];
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j)
        continue;
      ans[i] = a[j] ^ ans[i];
    }
  }
  for (int i = 0; i < N; i++) {
    if (i == N - 1)
      std::cout << ans[i] << std::endl;
    else
      std::cout << ans[i] << " ";
  }
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: 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[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;
}

Error: WA

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

#include <bits/stdc++.h>
#define int long long
#define for0(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i <= (n); i++)
#define mp make_pair
#define all(x) x.begin(), x.end()
#define puts(x) cout << x << "\\n"
#define endwith return
constexpr int mod = 1000000007;
using namespace std;
int input() {
  int t;
  cin >> t;
  return t;
}
int n, a[234567], k;
signed main() {
  cin >> n;
  for0(i, n) {
    cin >> a[i];
    k ^= a[i];
  }
  for0(i, n) {
    if (i)
      cout << ' ';
    cout << (a[i] ^ k);
  }
  cout << endl;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
// #include<bits/stdc++.h>
#define int long long
#define for0(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i <= (n); i++)
#define mp make_pair
#define all(x) x.begin(), x.end()
#define puts(x) cout << x << "\\n"
#define endwith return
constexpr int mod = 1000000007;
using namespace std;
int input() {
  int t;
  cin >> t;
  return t;
}
int n, a[123456], k;
signed main() {
  cin >> n;
  for0(i, n) {
    cin >> a[i];
    k ^= a[i];
  }
  for0(i, n) {
    if (i)
      cout << ' ';
    cout << (a[i] ^ k);
  }
  cout << endl;
}
Problem p02631 (C++) — buggy submission, verdict: 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[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 << " ";
    }
  }
}


Error: WA

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

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MX = 1000;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int s = 0;
  rep(i, n) s ^= a[i];
  rep(i, n) {
    a[i] ^= s;
    cout << a[i] << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MX = 1000;

int main() {
  int n;
  cin >> n;
  vector<bitset<MX>> a(n);
  rep(i, n) {
    int ai;
    cin >> ai;
    a[i] = (ai);
  }
  rep(i, n) {
    bitset<MX> ans;
    rep(j, n) {
      if (j != i) {
        ans = ans ^ a[j];
      }
    }
    cout << ans.to_ullong();
    if (i < n - 1)
      cout << " ";
  }
  cout << endl;
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using ll = long long;
#define fast_io()                                                              \\
  ;                                                                            \\
  std::ios_base::sync_with_stdio(0);                                           \\
  std::cin.tie(0);                                                             \\
  std::cout.tie(0);

int main() {
  fast_io();

  ll n;
  std::cin >> n;
  std::vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
  }

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

  for (int i = 0; i < n; i++) {
    std::cout << (axor ^ a[i]) << " ";
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using ll = long long;
#define fast_io()                                                              \\
  ;                                                                            \\
  std::ios_base::sync_with_stdio(0);                                           \\
  std::cin.tie(0);                                                             \\
  std::cout.tie(0);

int main() {
  ll n;
  std::cin >> n;
  std::vector<ll> a(n), v(n, 0);
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i != j)
        v[i] = v[i] ^ a[j];
    }
  }

  for (int i = 0; i < n; i++) {
    std::cout << v[i] << " ";
  }

  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: 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[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];
  }
}

Error: WA

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

#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
using Graph = vector<vector<int>>;
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;
}

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

  for (int i = 0; i < n; ++i) {
    long long temp2 = temp;
    ans[i] = temp ^ a[i];
  }

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

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
using Graph = vector<vector<int>>;
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;
}

int main() {
  long long n;
  cin >> n;
  vector<long long> a(n), ans(n);
  for (int i = 0; i < n; ++i)
    cin >> a[i];
  for (int i = 0; i < n; ++i) {
    long long temp = 0;
    for (int j = 0; j < n; ++j) {
      if (i == j)
        continue;
      temp ^= a[j];
    }
    ans[i] = temp;
  }

  for (int i = 0; i < n; ++i)
    cout << ans[i] << " ";
  cout << endl;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> a(n), ans(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  ans[0] = 0;
  for (int i = 1; i < n; i++) {
    ans[0] ^= a[i];
  }
  for (int i = 1; i < n; i++) {
    ans[i] = ans[i - 1] ^ a[i - 1] ^ a[i];
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> a(n), ans(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    ans[i] = 0;
    for (int j = 0; j < n; j++) {
      if (i != j) {
        ans[i] ^= a[j];
      }
    }
    cout << ans[i] << " ";
  }
  cout << endl;
}
Problem p02631 (C++) — buggy submission, verdict: Runtime Error

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


Error: WA

Fixed submission:

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

#include <bits/stdc++.h>
using namespace std;
int n, a[200005];
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int x = a[0];
  for (int i = 1; i < n; ++i) {
    x ^= a[i];
  }
  for (int i = 0; i < n; ++i) {
    int v = x ^ a[i];
    cout << v << ' ';
  }
  cout << '\\n';
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int n, a[200005];
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    int id = (i + 1) % n;
    int ans = a[id];
    for (int j = 2; j < n; ++j) {
      int ind = (i + j) % n;
      ans ^= a[ind];
    }
    cout << ans << ' ';
  }
  cout << '\\n';
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdint>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define INF 1000000000
#define LLINF 2000000000000000
#define MOD 1000000007
using namespace std;
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define LOOP(i, N) for (int i = 0; i < N; i++)
#define LOOP1(i, N) for (int i = 1; i <= N; i++)
typedef pair<int, int> P;
typedef pair<int, pair<int, int>> PP;
#define int long long

signed main() {
  int n;
  cin >> n;
  bool bit[200000][30] = {};
  int sum[30] = {};
  LOOP(i, n) {
    int a;
    cin >> a;
    int cnt = 0;
    while (true) {
      bit[i][cnt] = a % 2;
      sum[cnt] += a % 2;
      // cout << bit[i][cnt];

      a /= 2;
      cnt++;
      if (a == 0)
        break;
    }
    // cout << endl;
  }
  // LOOP(i,19){
  //   cerr << sum[i] << endl;
  // }

  LOOP(i, n) {
    int ans = 0;
    int k = 1;
    LOOP(j, 30) {
      int sc = sum[j] - bit[i][j];
      ans += (sc % 2) * k;
      // ans += ((sum[j]%2) ^ bit[i][j])*k;
      k *= 2;
    }
    cout << ans << endl;
  }
  return 0;
}


Error: WA

Fixed submission:

#include <algorithm>
#include <cstdint>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define INF 1000000000
#define LLINF 2000000000000000
#define MOD 1000000007
using namespace std;
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define LOOP(i, N) for (int i = 0; i < N; i++)
#define LOOP1(i, N) for (int i = 1; i <= N; i++)
typedef pair<int, int> P;
typedef pair<int, pair<int, int>> PP;
#define int long long

signed main() {
  int n;
  cin >> n;
  bool bit[200000][19] = {};
  int sum[19] = {};
  LOOP(i, n) {
    int a;
    cin >> a;
    int cnt = 0;
    while (true) {
      bit[i][cnt] = a % 2;
      sum[cnt] += a % 2;
      // cout << bit[i][cnt];

      a /= 2;
      cnt++;
      if (a == 0)
        break;
    }
    // cout << endl;
  }
  // LOOP(i,19){
  //   cerr << sum[i] << endl;
  // }

  LOOP(i, n) {
    int ans = 0;
    int k = 1;
    LOOP(j, 19) {
      // int sc = sum[j] - bit[i][j];
      ans += ((sum[j] % 2) ^ bit[i][j]) * k;
      k *= 2;
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: 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) { 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 << " ";
  }
}


Error: TLE

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

Error: WA

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

Error: WA

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

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007

int main() {

  int n;
  cin >> n;
  vector<int> k(n);
  vector<int> s(31, 0);
  rep(i, n) {
    cin >> k[i];
    int x = k[i];
    rep(j, 31) {
      s[j] += x % 2;
      x /= 2;
    }
  }
  vector<ll> res(n, 0);
  rep(j, 31) {
    if (s[j] & 1) {
      rep(i, n) {
        if (k[i] >> j & 1)
          k[i] -= 1 << j;
        else
          k[i] += 1 << j;
      }
    }
  }
  rep(i, n) cout << k[i] << " ";
  cout << endl;

  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007

int main() {

  int n;
  cin >> n;
  vector<vector<int>> k(n, vector<int>(31, 0));
  vector<int> s(31, 0);
  rep(i, n) {
    int x;
    cin >> x;
    rep(j, 31) {
      k[i][j] += x % 2;
      s[i] += x % 2;
      x /= 2;
    }
  }
  rep(i, n) {
    ll res = 0;
    rep(j, 31) {
      int l = s[j] - k[i][j];
      if (l % 2 == k[i][j] % 2) {
        if (k[i][j] & 1)
          res += 1 << j;
      } else {
        res += 1 << j;
      }
    }
    cout << res << " ";
  }
  cout << endl;

  return 0;
}