alexjercan/bugnet huggingface dataset:
Problem p02631 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read() {
  ll a = 0, b = getchar(), c = 1;
  while (!isdigit(b))
    c = b == '-' ? -1 : 1, b = getchar();
  while (isdigit(b))
    a = a * 10 + b - '0', b = getchar();
  return a * c;
}
ll n, ans, a[200005];
int main() {
  n = read();
  for (int i = 0; i < n; i++)
    a[i] = read(), ans ^= a[i];
  for (int i = 0; i < n; i++)
    printf("%lld ", ans ^ a[i]);
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read() {
  ll a = 0, b = getchar(), c = 1;
  while (!isdigit(b))
    c = b == '-' ? -1 : 1, b = getchar();
  while (isdigit(b))
    a = a * 10 + b - '0', b = getchar();
  return a * c;
}
ll n, ans, a[100005];
int main() {
  n = read();
  for (int i = 0; i < n; i++)
    a[i] = read(), ans ^= a[i];
  for (int i = 0; i < n; i++)
    printf("%lld ", ans ^ a[i]);
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define endl "\\n"
#define int unsigned long long
#define debug(x) cout << #x << " is " << x << endl;
using namespace std;
int fastpow(int a, int b) {
  if (!b)
    return 1ll;
  if (b % 2 == 1)
    return fastpow(a, b - 1) * a;
  int t = fastpow(a, b / 2);
  return t * t;
}
void solve() {
  int n, ans = 0;
  cin >> n;
  vector<int> a(n);
  for (auto &x : a)
    cin >> x;
  for (int i = 0; i < n; ++i) {
    ans ^= a[i];
  }
  for (int i = 0; i < n; ++i) {
    int cur = ans ^ a[i];
    cout << cur << " ";
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(15);
  int t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define endl "\\n"
#define int unsigned long long
#define debug(x) cout << #x << " is " << x << endl;
using namespace std;
int fastpow(int a, int b) {
  if (!b)
    return 1ll;
  if (b % 2 == 1)
    return fastpow(a, b - 1) * a;
  int t = fastpow(a, b / 2);
  return t * t;
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &x : a)
    cin >> x;
  for (int i = 0; i < n; ++i) {
    int ans = 0;
    for (int j = 0; j < n; ++j) {
      if (j == i)
        continue;
      ans ^= a[j];
    }
    cout << ans << " ";
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(15);
  int t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: 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 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;
}


Error: TLE

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


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

#include <bits/stdc++.h>

using namespace std;

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

  for (int i = 0; i < n; i++) {
    cout << (a[i] ^ x) << ' ';
  }
  cout << endl;
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second

#ifdef OJ
#define debug(x)                                                               \\
  do {                                                                         \\
    cerr << #x << ": " << x << "\\n";                                           \\
  } while (0)
#define debugv(x)                                                              \\
  do {                                                                         \\
    cerr << #x << ": ";                                                        \\
    for (auto &e : (x))                                                        \\
      cerr << e << " ";                                                        \\
    cerr << "\\n";                                                              \\
  } while (0)
#else
#define debug(x)
#define debugv(x)
#endif

#define all(x) (x).begin(), (x).end()
#define rsort(x) sort((x).rbegin(), (x).rend())
#define sz(x) ((int)x.size())
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n, e) for (int i = (int)(n); i >= (int)(e); --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template <typename T> bool mmax(T &m, const T q) {
  if (m < q) {
    m = q;
    return true;
  } else
    return false;
}
template <typename T> bool mmin(T &m, const T q) {
  if (m > q) {
    m = q;
    return true;
  } else
    return false;
}
#define RETURN(x)                                                              \\
  do {                                                                         \\
    cout << (x) << '\\n';                                                       \\
    return 0;                                                                  \\
  } while (0)

const int MOD = 1e9 + 7;
const int MAXN = 2e5 + 3;
const int INF = 1e9;

int a[10];
int solve() {
  // int n; cin >> n;
  // vector<int> a(n);
  // fori(i,n) cin >> a[i];
  // int x = 0;
  // fori(i,n) x ^= a[i];
  // debug(x);
  // fori(i,n) {
  // cout << a[i] << ' ';
  // int b = x^a[i];
  // cout << b << ' ';
  //}
  // cout << endl;
}

int main(int argc, char **argv) {
#ifdef OJ
  freopen("input.txt", "rt", stdin);
  // freopen("output.txt", "wt", stdout);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);

  solve();
  // int ntest = 1;
  // cin >> ntest;
  // while(ntest--) solve();

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


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

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {

  ll n;
  cin >> n;

  vector<ll> a(n);
  ll b = 0;
  REP(i, n) {
    cin >> a[i];
    b = b ^ a[i];
  }

  ll c = 0;
  REP(i, n) {
    c = b ^ a[i];
    cout << c << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {

  ll n;
  cin >> n;

  vector<ll> a(n);
  REP(i, n) cin >> a[i];

  vector<ll> b(n);
  REP(i, n) {
    REP(j, n) {
      if (i != j) {
        b[i] = b[i] ^ a[j];
      }
    }
  }

  REP(i, n) cout << b[i] << endl;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using ll = long long;
int main() {
  int n, res = 0;
  std::cin >> n;
  std::vector<int> x(n, 0), a(n, 0);
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
    res ^= a[i];
  }
  for (int i = 0; i < n; i++)
    std::cout << (res ^ a[i]) << ' ';
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using ll = long long;
int main() {
  int n;
  std::cin >> n;
  std::vector<int> x(n, 0), a(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++)
      x[i] ^= a[j];
    x[i] ^= a[i];
  }
  for (int y : x)
    std::cout << y << ' ';
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[1212030], v[1000005];
int main() {
  ll i, ans = 0, ans2, w, t, flag = 0, n, k, N, x, q, c, b, j;
  scanf("%lld", &n);
  for (i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  ans2 = a[1];
  for (i = 2; i <= n; i++) {
    ans2 ^= a[i];
    // swap(a[i],a[i+1]);
  }
  for (i = 1; i <= n; i++) {
    ans = ans2;
    ans ^= a[i];
    printf("%lld\\n", ans);
  }
  // printf("%c",N+'a'-1);
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[1212030], v[1000005];
int main() {
  ll i, ans = 0, ans2, w, t, flag = 0, n, k, N, x, q, c, b, j;
  scanf("%lld", &n);
  for (i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  for (i = 1; i <= n / 2; i++) {
    // swap(a[i],a[i+1]);
  }
  for (i = 1; i <= n; i++) {
    if (i != n) {
      ans = a[i + 1];
      for (j = 1; j <= n; j++) {
        if (j != i && j != i + 1)
          ans ^= a[j];
      }
    } else {
      ans = a[1];
      for (j = 1; j <= n; j++) {
        if (j != i && j != 1)
          ans ^= a[j];
      }
    }
    printf("%lld\\n", ans);
  }
  // printf("%c",N+'a'-1);
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int &ai : a) {
    cin >> ai;
  }

  int all = 0;
  for (int ai : a) {
    all ^= ai;
  }

  for (int i = 0; i < N; ++i) {
    int ret = a[i] ^ all;
    cout << ret;
    if (i != N - 1)
      cout << " ";
    else
      cout << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int &ai : a) {
    cin >> ai;
  }
  for (int i = 0; i < N; ++i) {
    int ret = 0;
    for (int j = 0; j < N; ++j) {
      if (i == j)
        continue;
      ret ^= a[j];
    }
    cout << ret;
    if (i != N - 1)
      cout << " ";
    else
      cout << endl;
  }

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

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

#define FAST                                                                   \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie();                                                                   \\
  cout.tie();

#define MAXX 200020

#define PI 3.14159265358979323846264338327950

#define ll long long int
ll mod = 1000000007;
ll a[MAXX], b[MAXX];
char str[MAXX];

int main() {
  FAST;
  ll n, k, ans = 0;
  cin >> n;
  cin >> a[0];
  k = a[0];
  for (ll i = 1; i < n; i++) {
    cin >> a[i];
    k ^= a[i];
  }
  for (ll i = 0; i < n; i++) {
    ll t = k;
    t ^= a[i];
    cout << t << " ";
  }
}

Error: WA

Fixed submission:

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

#define FAST                                                                   \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie();                                                                   \\
  cout.tie();

#define MAXX 100005

#define PI 3.14159265358979323846264338327950

#define ll long long int
ll mod = 1000000007;
ll a[MAXX], b[MAXX];
char str[MAXX];

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

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

int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  long long s = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s ^= a[i];
  }
  for (int i = 0; i < n; i++)
    cout << (s ^ a[i]) << ' ';
}

Error: -6
Fatal glibc error: malloc assertion failure in sysmalloc: (old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)


Fixed submission:

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

int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  vector<long long> b(n);
  long long index = 1;
  for (int i = 0; i < 31; i++) {
    long long even = 0;
    for (int j = 0; j < n; j++) {
      if (a[i] % 2 == 0) {
        b[i] += index;
        even++;
      }
      a[i] /= 2;
    }
    if (even == n) {
      for (int j = 0; j < n; j++)
        b[i] -= index;
    }
    index *= 2;
  }
  for (int i = 0; i < n; i++)
    cout << b[i] << " ";
}
Problem p02631 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define endl "\\n"
#define int long long int
#define mod 1000000007

void solve(int A[], int n) {
  int i;
  int B[n];
  int x = 0;
  for (i = 0; i < n; i++)
    x = x ^ A[i];

  for (i = 0; i < n; i++) {
    B[i] = x ^ A[i];
  }

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

int32_t main() {
  // code
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int t, n, w, k, x, i;
  // cin>>t;
  t = 1;
  while (t--) {
    cin >> n;
    int A[n];

    for (i = 0; i < n; i++)
      cin >> A[i];

    solve(A, n);
  }

  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define endl "\\n"
#define int long long int
#define mod 1000000007

int solve(int A[], int n) {
  int i;
  int B[n];
  int x = 0;
  for (i = 0; i < n; i++)
    x = x ^ A[i];

  for (i = 0; i < n; i++) {
    B[i] = x ^ A[i];
  }

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

int32_t main() {
  // code
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int t, n, w, k, x, i;
  // cin>>t;
  t = 1;
  while (t--) {
    cin >> n;
    int A[n];

    for (i = 0; i < n; i++)
      cin >> A[i];

    solve(A, n);
  }

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


Error: TLE

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

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {

  // make input and output more efficient
  ios::sync_with_stdio(0);
  cin.tie(0);

  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);

  // to read whole line
  // string s;
  // getline(cin, s);

  int N;

  cin >> N;

  int a[N];

  int x = 0;

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

  for (int i = 0; i < N; i++) {
    a[i] ^= x;
    cout << a[i] << (i == N - 1 ? "\\n" : " ");
  }
  return 0;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {

  // make input and output more efficient
  ios::sync_with_stdio(0);
  cin.tie(0);

  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);

  // to read whole line
  // string s;
  // getline(cin, s);

  int N;
  int a[N];

  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++) {
    a[i] ^= x;
    cout << a[i] << (i == N - 1 ? "\\n" : " ");
  }
  return 0;
}
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);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  long long x = 0;
  for (int i = 0; i < N; i++) {
    x = x ^ a[i];
  }
  for (int i = 0; i < N; i++) {
    long long y = x ^ a[i];
    cout << y << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

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

  for (int i = 0; i < N; i++) {
    long long x = 0;
    for (int j = 0; j < N; j++) {
      if (i == j)
        continue;
      x ^= a[j];
    }
    cout << x << endl;
  }

  return 0;
}