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

Error: WA

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

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
#define PI 3.14159265359

int main() {
  ll N, A;
  cin >> N;
  vector<ll> vec, ret;
  vec.reserve(N);
  ret.reserve(N);
  for (auto i = 0; i < N; i++) {
    cin >> A;
    vec.push_back(A);
    ret.push_back(A);
  }
  bool flag = true;
  ll n = 2;
  ll re = 0;
  while (flag) {
    flag = false;

    ll count = 0;
    for (auto i = 0; i < N; i++) {
      if (vec[i] % 2 == 1) {
        flag = true;
        count++;
      }
      vec[i] /= 2;
    }
    if (count % 2) {
      re += (n / 2);
    }
    n *= 2;
  }
  for (auto i = 0; i < N - 1; i++) {
    ll r = ret[i] ^ re;
    cout << r << " ";
  }
  ll r = ret[N - 1] ^ re;
  cout << r << endl;

  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
#define PI 3.14159265359

int main() {
  ll N, A;
  cin >> N;
  vector<ll> vec, ret;
  vec.reserve(N);
  ret.reserve(N);
  for (auto i = 0; i < N; i++) {
    cin >> A;
    vec.push_back(A);
  }
  bool flag = true;
  ll n = 2;
  ll re = 0;
  while (flag) {
    flag = false;

    ll count = 0;
    for (auto i = 0; i < N; i++) {
      if (vec[i] % n == 1) {
        flag = true;
        count++;
      }
    }
    re += (count % 2) / (n / 2);
    n *= 2;
  }
  for (auto i = 0; i < N - 1; i++) {
    ll r = vec[i] ^ re;
    cout << r << " ";
  }
  ll r = vec[N - 1] ^ re;
  cout << r << endl;

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

#include "bits/stdc++.h"
using namespace std;
typedef long long int lli;
#define pb push_back

int main() {
  int n;
  cin >> n;
  std::vector<int> v(n);

  int val = 0;
  for (int i = 0; i < n; ++i) {
    /* code */
    cin >> v[i];
    val = val ^ v[i];
  }

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

  /*for (int i = 0; i < n; ++i)
  {

          int  val = 0;
          for (int j = 0; j < n; ++j)
          {
                  if(i!=j){
                          val = val ^ v[j];
                  }
          }
          cout << val <<" " << endl;
  }
  */
}


Error: TLE

Fixed submission:

#include "bits/stdc++.h"
using namespace std;
typedef long long int lli;
#define pb push_back

int main() {
  int n;
  cin >> n;
  std::vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    /* code */
    cin >> v[i];
  }

  for (int i = 0; i < n; ++i) {
    /* code */
    int val = 0;
    for (int j = 0; j < n; ++j) {
      if (i != j) {
        val = val ^ v[j];
      }
    }
    cout << val << " " << endl;
  }
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

/* https://codeforces.com/contest/1360/problem/H */
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vs = vector<string>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;
using ld = double;

#define f first
#define s second
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ins insert

const int MAX = 1e5;

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

  vl ans(N);
  for (int i = 0; i < N; ++i) {
    ll temp = 0;
    for (int j = 0; j < N; ++j) {
      if (i == j)
        continue;
      temp ^= a[j];
    }

    ans[i] = temp;
    break;
  }

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

  for (auto const &x : ans) {
    cout << x << " ";
  }

  cout << endl;
  return 0;
}


Error: TLE

Fixed submission:

/* https://codeforces.com/contest/1360/problem/H */
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vs = vector<string>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;
using ld = double;

#define f first
#define s second
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ins insert

const int MAX = 1e5;

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

  vl ans(N);
  for (int i = 0; i < N; ++i) {
    ll temp = 0;
    for (int j = 0; j < N; ++j) {
      if (i == j)
        continue;
      temp ^= a[j];
    }

    ans[i] = temp;
  }

  for (auto const &x : ans) {
    cout << x << " ";
  }

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ar[200000];
  cin >> n;
  long x = 0;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
    x ^= ar[i];
  }
  for (int i = 0; i < n; i++) {
    ar[i] ^= x;
  }
  for (int i = 0; i < n; i++)
    cout << ar[i] << " ";
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ar[100000];
  cin >> n;
  long x = 0;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
    x ^= ar[i];
  }
  for (int i = 0; i < n; i++) {
    ar[i] ^= x;
  }
  for (int i = 0; i < n; i++)
    cout << ar[i] << " ";
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define MEM 200006
#define sanic ios_base::sync_with_stdio(0)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
const ll MOD = 1e9 + 7;
ll n, m, sum;
ll c[MEM];
string s;
int main() {
  sanic;
  cin.tie(0);
  cin >> n;
  ll sxm = 0;
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    sxm ^= c[i];
  }
  for (int i = 0; i < n; i++)
    cout << (sxm ^ c[i]) << ' ';
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define MEM 100006
#define sanic ios_base::sync_with_stdio(0)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
const ll MOD = 1e9 + 7;
ll n, m, sum;
ll c[MEM];
string s;
int main() {
  sanic;
  cin.tie(0);
  cin >> n;
  ll sxm = 0;
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    sxm ^= c[i];
  }
  for (int i = 0; i < n; i++)
    cout << (sxm ^ c[i]) << ' ';
}
Problem p02631 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> x(60, 0);
  ll maxNum = 0;
  rep(i, n) {
    cin >> a[i];
    ll now = a[i];
    ll s = 0;
    while (now) {
      if (now & 1) {
        x[s]++;
        x[s] %= 2;
      }
      now >>= 1;
      s++;
      maxNum = max(maxNum, s);
    }
  }

  rep(i, n) {
    ll ans = 0;
    rep(s, maxNum) {
      if (((x[s] + (a[i] & 1)) % 2 == 1))
        ans += (1LL << s);
      a[i] >>= 1;
    }
    if (i == n - 1)
      cout << ans << endl;
    else
      cout << ans << ' ';
  }

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> x(20, 0);
  ll maxNum = 0;
  rep(i, n) {
    cin >> a[i];
    ll now = a[i];
    ll s = 0;
    while (now) {
      if (now & 1) {
        x[s]++;
        x[s] %= 2;
      }
      now >>= 1;
      s++;
      maxNum = max(maxNum, s);
    }
  }

  rep(i, n) {
    ll ans = 0;
    rep(s, maxNum) {
      if (((x[s] + (a[i] & 1)) % 2 == 1))
        ans += (1LL << s);
      a[i] >>= 1;
    }
    if (i == n - 1)
      cout << ans << endl;
    else
      cout << ans << ' ';
  }

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

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

void solve(long long N, std::vector<long long> a) {
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    ans ^= a[i];
  }

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

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> 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;

void solve(long long N, std::vector<long long> a) {

  for (int i = 0; i < N; i++) {

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

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> 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 <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define ll long long

int main() {

  int n;
  cin >> n;

  vector<int> arr(n);

  for (int i = 0; i < n; i++) {
    int val;
    cin >> val;
    arr[i] = val;
  }
  int totalXor = 0;
  for (int i = 0; i < n; i++)
    totalXor = totalXor ^ arr[i];

  for (int i = 0; i < n; i++) {

    cout << (totalXor ^ arr[i]) << " ";
  }

  cout << endl;
  return 0;
}


Error: TLE

Fixed submission:


#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define ll long long

int main() {

  int n;
  cin >> n;

  vector<int> arr(n);

  for (int i = 0; i < n; i++) {
    int val;
    cin >> val;
    arr[i] = val;
  }

  for (int i = 0; i < n; i++) {

    int res = 0;
    for (int j = 0; j < n; j++) {
      if (j == i)
        continue;
      res = res ^ arr[j];
    }
    cout << res << " ";
  }

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

#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
  ll n, a[200005], q, sum = 0;
  cin >> n;

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

  cout << "\\n";
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
  ll n, a[100005], q, sum = 0;
  cin >> n;

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

  cout << "\\n";
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

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

short bits[200005][34];
int bitSum[34];
short bits2[200005][34];

void fillBits(int pos, int Ai) {
  for (int i = 0; i < 34; i++) {
    int lastBit = Ai & 1;
    bits[pos][i] = lastBit;
    bitSum[i] += lastBit;
    Ai >>= 1;
  }
}

int main() {
  int N;
  scanf("%d", &N);

  for (int i = 0; i < N; i++) {
    int Ai;
    scanf("%d", &Ai);
    fillBits(i, Ai);
  }

  for (int i = 0; i < N; i++) {
    long long int values = 0, power = 1;
    for (int j = 0; j < 34; j++) {
      int numOnes = bitSum[j] - bits[i][j];
      bits2[i][j] = numOnes % 2;

      values += power * bits2[i][j];
      power *= 2;
    }

    printf("%lld ", values);
  }
}


Error: TLE

Fixed submission:

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

int A[200005];
int XORExclude(int pos, int N) {
  int ans = -1;
  for (int i = 0; i < N; i++) {
    if (i == pos)
      continue;

    if (ans == -1)
      ans = A[i];

    else
      ans = ans ^ A[i];
  }

  return ans;
}

int main() {
  int N;
  scanf("%d", &N);

  for (int i = 0; i < N; i++)
    scanf("%d", &A[i]);

  for (int i = 0; i < N; i++) {
    printf("%d ", XORExclude(i, N));
  }
}
Problem p02631 (C++) — buggy submission, verdict: Runtime Error

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

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int n, f, a[10005];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    f ^= a[i];
  }
  for (int i = 1; i <= n; i++)
    cout << (f ^ a[i]) << " ";
  cout << endl;
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long int n;
  cin >> n;
  vector<long int> v;
  int ele;
  for (auto i = 0; i < n; i++) {
    cin >> ele;
    v.push_back(ele);
  }
  int x = 0;
  for (auto i = 0; i < n; i++) {
    x ^= v[i];
  }
  for (auto i = 0; i < n; i++) {
    int sol = x ^ v[i];
    cout << sol << " ";
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long int n;
  cin >> n;
  vector<long int> v;
  int ele;
  for (auto i = 0; i < n; i++) {
    cin >> ele;
    v.push_back(ele);
  }
  for (auto i = 0; i < n; i++) {
    int res = 0;
    for (auto j = 0; j < n; j++) {
      if (j == i)
        continue;
      else {
        res ^= v[j];
      }
    }
    cout << res << " ";
  }
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, n, m) for (int i = (m), i##_len = (n); i < i##_len; ++i)
#define EACH(i, v) for (const auto &i : v)
#define ALL(x) (x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <class Value> using vec = vector<Value>;
using ll = long long;
using P = pair<long long, long long>;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();
void solve(long long N, std::vector<long long> a);

int main() {
  std::cin.tie(nullptr);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

void Main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  solve(N, std::move(a));
}

void solve(long long N, std::vector<long long> a) {
  int lm = 0;
  REP(i, N) { lm ^= a[i]; }
  REP(i, N) {
    if (i != 0) {
      cout << ' ';
    }
    cout << (lm ^ a[i]);
  }
  cout << el;
}


Error: TLE

Fixed submission:

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, n, m) for (int i = (m), i##_len = (n); i < i##_len; ++i)
#define EACH(i, v) for (const auto &i : v)
#define ALL(x) (x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <class Value> using vec = vector<Value>;
using ll = long long;
using P = pair<long long, long long>;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();
void solve(long long N, std::vector<long long> a);

int main() {
  std::cin.tie(nullptr);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

void Main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  solve(N, std::move(a));
}

void solve(long long N, std::vector<long long> a) {
  vec<int> memo(N);
  REP(i, N) {
    REP(j, N) {
      if (i == j)
        continue;
      memo[i] ^= a[j];
    }
  }
  REP(i, N) {
    if (i != 0) {
      cout << ' ';
    }
    cout << memo[i];
  }
  cout << el;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

#define loop(i, n) for (ll i = 0; i < n; i++)
#define loopr(i, x, y) for (ll i = x; i < y; i++)
#define push_back pb;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<string> VS;
typedef vector<P> VP;
typedef vector<V> VV;
typedef map<ll, ll> MP;
typedef set<ll> SET;
typedef multiset<ll> MSET;

int main() {

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

  ll n;

  cin >> n;

  ll arr[n];

  ll val = 0;

  loop(i, n) {
    cin >> arr[i];

    val ^= arr[i];
  }

  for (int i = 0; i < n; i++) {
    cout << (val ^ arr[i]) << " ";
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define loop(i, n) for (ll i = 0; i < n; i++)
#define loopr(i, x, y) for (ll i = x; i < y; i++)
#define push_back pb;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<string> VS;
typedef vector<P> VP;
typedef vector<V> VV;
typedef map<ll, ll> MP;
typedef set<ll> SET;
typedef multiset<ll> MSET;

int main() {

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

  ll n;

  cin >> n;

  ll arr[n];
  ll brr[n];
  loop(i, n) { cin >> arr[i]; }

  for (int i = 0; i < n; i++) {
    ll val = 0;

    for (int j = 0; j < n; j++) {
      if (i != j) {
        val ^= arr[j];
      }
    }
    brr[i] = val;
  }

  for (auto i : brr) {
    cout << i << " ";
  }
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int N;
  int i, j;
  cin >> N;
  vector<int> a(N);
  for (i = 0; i < N; i++)
    cin >> a[i];
  bitset<32> ans;
  for (i = 1; i < N; i++)
    ans ^= a[i];
  cout << ans.to_ullong() << " ";
  for (i = 1; i < N; i++) {
    ans ^= a[i];
    ans ^= a[i - 1];
    cout << ans.to_ullong() << " ";
  }
  cout << endl;
}


Error: TLE

Fixed submission:

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

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

#include <iostream>
using namespace std;

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

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, l;
  cin >> n;
  vector<int> ai;
  for (int i = 0; i < n; i++) {
    cin >> l;
    ai.push_back(l);
  }
  int ans;
  for (int i = 0; i < n; i++) {
    ans = 0;
    for (int j = 0; j < n; j++) {
      if (i == j)
        continue;
      ans ^= ai[j];
    }
    cout << ans << " ";
  }
  cout << endl;
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  // code
  // cout<<"ashish"<<endl;
  long long int n;
  cin >> n;
  long long int a[n];
  long long int x = 0;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    x = x ^ a[i];
  }
  long long int k = 0;
  for (long long int i = 0; i < n; i++) {
    k = x ^ a[i];
    cout << k << " ";
  }
  // cout<<x<<endl;
  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  // code
  // cout<<"ashish"<<endl;
  int n;
  cin >> n;
  long long int a[n];
  long long int sum = 0;
  // map<int,int>m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    long long int x = 0;
    for (int j = 0; j < n; j++) {
      if (i != j)
        x = x ^ a[j];
    }
    cout << x << " ";
  }
  // cout<<x<<endl;
  return 0;
}