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

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

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


Error: WA

Fixed submission:

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

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    num ^= a[i];
  }
  for (int i = 0; i < n; i++) {
    cout << (num ^ a[i]) << " ";
  }
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {

  int n;
  cin >> n;
  vector<ll> a(n);
  ll xo = 0;
  for (ll &i : a) {
    cin >> i;
    xo ^= i;
  }

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

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {

  int n;
  cin >> n;
  vector<ll> a(n);
  for (ll &i : a)
    cin >> i;

  for (int i = 0; i < n; i++) {
    ll x = 0;
    for (int j = 0; j < n; j++) {
      if (j == i)
        continue;
      x ^= a[j];
    }
    cout << x << ' ';
  }
  cout << endl;
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define endl '\\n';
#define ll long long
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define IOS                                                                    \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define pb push_back

int main() {

  // IOS;
  /*ll n;
   cin>>n;
   string s;
  while(n>0){
    int x=(n%26);
    cout<<(char)(x+97);
    n/=2;
  }
  */
  int n;
  cin >> n;
  int a[n];
  int d = 0;
  rep(i, 0, n) {
    cin >> a[i];
    d = d ^ a[i];
  }
  rep(i, 0, n) {
    int c = a[i] ^ d;
    cout << c << " ";
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define endl '\\n';
#define ll long long
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define IOS                                                                    \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define pb push_back

int main() {

  // IOS;
  /*ll n;
   cin>>n;
   string s;
  while(n>0){
    int x=(n%26);
    cout<<(char)(x+97);
    n/=2;
  }
  */
  int n;
  cin >> n;
  int a[n];
  rep(i, 0, n) cin >> a[i];
  rep(i, 0, n) {
    int c = 0;
    rep(j, 0, n) {
      if (i == j)
        continue;
      c = c ^ a[j];
    }
    cout << c << " ";
  }

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

#include <bits/stdc++.h>
using namespace std;
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <math.h>
#include <numeric>
#include <sstream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
using pint = pair<int, int>;
using vec = vector<int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

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

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

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <math.h>
#include <numeric>
#include <sstream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
using pint = pair<int, int>;
using vec = vector<int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

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

  int n;
  cin >> n;
  vec a(SIZE);
  rep(i, n) cin >> a[i];

  int s = 0;
  rep(i, n) s ^= a[i];
  rep(i, n) a[i] ^= s;
  rep(i, n) cout << a[i] << endl;
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (i = 0; i < n; ++i)
using namespace std;
int main(void) {
  int b = 0, i, N;
  cin >> N;
  vector<int> a(N);
  rep(i, N) {
    cin >> a[i];
    b ^= a[i];
  }
  rep(i, N) cout << (a[i] ^ b) << ' ';
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (i = 0; i < n; ++i)
using namespace std;
int main(void) {
  int i, j, N;
  cin >> N;
  vector<int> a(N), b(N, 0);
  rep(i, N) cin >> a[i];
  rep(i, N) rep(j, N) if (i != j) b[i] ^= a[j];
  rep(i, N) cout << b[i] << " ";
  cout << endl;
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;
using namespace __gnu_pbds;

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

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

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

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


Error: TLE

Fixed submission:

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

using namespace std;
using namespace __gnu_pbds;

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

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

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

  /* ll t;
  cin>>t;
  while(t--){ */
  solve();
  /* } */
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <map>
using namespace std;
int main(void) {

  int n;
  cin >> n;

  long long arr[n];

  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  long long ans = arr[0];
  for (int i = 1; i < n; i++) {
    ans ^= arr[i];
  }
  for (int i = 0; i < n; i++) {
    cout << (ans ^ arr[i]) << " ";
  }
}


Error: TLE

Fixed submission:

#include <iostream>
#include <map>
using namespace std;
int main(void) {

  int n;
  cin >> n;

  long long arr[n];

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

  for (int i = 0; i < n; i++) {
    int ans = 0;
    for (int j = 0; j < n; j++) {
      if (i != j)
        ans ^= arr[j];
    }
    cout << ans << " ";
  }
}
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);
  int Max = 0;
  for (int n = 0; n < N; ++n) {
    cin >> A[n];
    Max = max(Max, A[n]);
  }
  // 桁数求めて
  int l = 0;
  while (true) {
    int q = 1 << l;
    q--;
    if (q >= Max) {
      break;
    }
    l++;
  }
  int x = 0;
  for (int m = 0; m < N; ++m) {
    x = x xor A[m];
  }
  // 偶数奇数場合分け必要。
  for (int n = 0; n < N; ++n) {
    int y;
    y = x xor A[n];

    if (0 == N % 2) {
      cout << y << endl;
    } else {
      int n = 1 << l;
      n--;
      y = n xor y;
      cout << y << endl;
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int Max = 0;
  for (int n = 0; n < N; ++n) {
    cin >> A[n];
    Max = max(Max, A[n]);
  }
  // 偶数奇数場合分け必要。
  for (int n = 0; n < N; ++n) {
    int x = A[n];
    for (int m = 0; m < N; ++m) {
      x = x xor A[m];
    }
    if (0 == N % 2) {
      cout << x << endl;
    } else {
      // 桁数求めて
      int l = 0;
      while (true) {
        int q = 1 << l;
        q--;
        if (q >= Max) {
          break;
        }
        l++;
      }
      int n = 1 << l;
      x = 31 xor x;
      cout << x << endl;
    }
  }

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

#include <iostream>
#include <vector>

void stupid() {
  int N;
  std::cin >> N;
  std::vector<unsigned long long> A(N);
  unsigned long long totalXOR = 0x0000;
  for (auto &a : A) {
    std::cin >> a;
  }
  for (int i = 0; i < N; ++i) {
    totalXOR ^= A[i];
  }
  for (int i = 0; i < N; ++i) {
    unsigned long long buf = totalXOR ^ A[i];
    std::cout << buf << " ";
  }
}
int main() {
  stupid();
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>

void stupid() {
  int N;
  std::cin >> N;
  std::vector<unsigned long long> A(N);
  for (auto &a : A) {
    std::cin >> a;
  }
  for (int i = 0; i < N; ++i) {
    unsigned long long buf = 0x0000;
    for (int j = 0; j < N; ++j) {
      if (i == j) {
        continue;
      }
      buf = buf ^ A[j];
    }
    std::cout << buf << " ";
  }
}
int main() {
  stupid();
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded


#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define ll long long
const int maxi = 2000000000;
const int maxq = 1000000000;
const ll mod = 1000000007LL;
#define f(i, a, b) for (ll i = (a); i < (b); ++i)
/*
unsigned int countSetBits(unsigned int n)
{
    unsigned int count = 0;
    while (n) {
        count += n & 1;
        n >>= 1;
    }
    return count;
}
*/

/*
const int maxx=9000000;
void SieveOfEratosthenes(vector<int> &primes){
    bool IsPrime[maxx+1];
    memset(IsPrime, true, sizeof(IsPrime));
    for(int p=2;p*p<=maxx ;p++){
        if(IsPrime[p]){
            for(int i=p*p;i<maxx ;i+=p) IsPrime[i]=false;
        }
    }
    f(p,2,maxx +1){
        if(IsPrime[p]) primes.push_back(p);
    }
    }
*/
int aa[1000001];
ll func(ll a[], ll n) {
  ll xor_ = 0;
  f(i, 0, n) { xor_ = xor_ ^ a[i]; }
  return xor_;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /*ll n,sum=0;
  cin>>n;
  ll a[n];
  f(i,0,n){
      cin>>a[i];
      sum+=a[i];
  }
  ll x;
  cin>>x;
  while(x--){
      ll c,d;
      cin>>c>>d;
      f(i,0,n){
      if(a[i]==c){
          a[i]=d;
          sum=sum+d-c;
      }

      } cout<<sum<<endl;
  } */
  ll n;
  cin >> n;
  ll a[n];
  f(i, 0, n) cin >> a[i];
  ll xor_ = func(a, n);
  f(i, 0, n) {
    ll x = xor_ ^ a[i];
    cout << x << ' ';
  }
  return 0;
}


Error: TLE

Fixed submission:


#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define ll long long
const int maxi = 2000000000;
const int maxq = 1000000000;
const ll mod = 1000000007LL;
#define f(i, a, b) for (ll i = (a); i < (b); ++i)
/*
unsigned int countSetBits(unsigned int n)
{
    unsigned int count = 0;
    while (n) {
        count += n & 1;
        n >>= 1;
    }
    return count;
}
*/

/*
const int maxx=9000000;
void SieveOfEratosthenes(vector<int> &primes){
    bool IsPrime[maxx+1];
    memset(IsPrime, true, sizeof(IsPrime));
    for(int p=2;p*p<=maxx ;p++){
        if(IsPrime[p]){
            for(int i=p*p;i<maxx ;i+=p) IsPrime[i]=false;
        }
    }
    f(p,2,maxx +1){
        if(IsPrime[p]) primes.push_back(p);
    }
    }
*/
int aa[1000001];
ll func(ll a[], ll n, ll x) {
  ll xor_ = 0;
  f(i, 0, n) {
    if (a[i] != x)
      xor_ = xor_ ^ a[i];
  }
  return xor_;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /*ll n,sum=0;
  cin>>n;
  ll a[n];
  f(i,0,n){
      cin>>a[i];
      sum+=a[i];
  }
  ll x;
  cin>>x;
  while(x--){
      ll c,d;
      cin>>c>>d;
      f(i,0,n){
      if(a[i]==c){
          a[i]=d;
          sum=sum+d-c;
      }

      } cout<<sum<<endl;
  } */
  ll n;
  cin >> n;
  ll a[n];
  f(i, 0, n) cin >> a[i];
  f(i, 0, n) cout << func(a, n, a[i]) << ' ';
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>

#define pii pair<int, int>
#define pll pair<ll, ll>

#define pb push_back

#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL)

using namespace std;

int main() {
  fast;

  int n;

  cin >> n;

  int a[n + 5], xr = 0;

  for (int i = 0; i < n; i++)
    cin >> a[i], xr ^= a[i];

  for (int i = 0; i < n; i++)
    cout << (xr ^ a[i]) << ' ';

  cout << endl;

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  // your code goes here
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++)
    cin >> arr[i];
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    int a = 0;
    for (int j = 0; j < n; j++) {
      if (i == j)
        continue;
      else
        a ^= arr[j];
    }
    ans.push_back(a);
  }
  for (auto it : ans)
    cout << it << ' ';
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Runtime Error

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

int main(void) {
  int N;
  cin >> N;

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

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

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

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


Error: 0

Fixed submission:

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

int main(void) {
  int N;
  cin >> N;

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

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

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

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

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

int main() {
  int N, S = 0;
  cin >> N;
  vector<int> a(N);
  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
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc


Fixed submission:

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

int main() {
  int N, S = 0;
  vector<int> a(N);
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    S ^= a[i];
  }
  for (int i = 0; i < N; i++) {
    cout << (S ^ a[i]) << " ";
  }
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

#define PI 3.1415926535897932384626433
#define _DBG_

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

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

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

  cout << endl;

  return 0;
}

Error: TLE

Fixed submission:

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

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

#define PI 3.1415926535897932384626433
#define _DBG_

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

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

  cout << endl;

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

vector<ll> fact, invfact;
ll modpower(ll x, ll n, ll mod) {
  ll res = 1;
  while (n) {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}
ll inv(ll n) { return modpower(n, MOD - 2, MOD); }
void COMinit(ll k) { // 空っぽの配列を二つ
  k++;
  fact.resize(k, 0);
  invfact.resize(k, 0);
  fact[0] = 1;
  repi(i, k, 1) { fact[i] = fact[i - 1] * i % MOD; }
  invfact[k - 1] = inv(fact[k - 1]);
  repd(i, k - 2, 0) { invfact[i] = invfact[i + 1] * (i + 1) % MOD; }
  return;
}
ll nCk(vector<ll> &fact, vector<ll> &invfact, ll n,
       ll k) { // この関数を使う前にCOMinit
  if (k < 0 || n < k)
    return 0LL;
  return fact[n] * invfact[k] % MOD * invfact[n - k] % MOD;
}
ll com(ll n, ll k) {
  ll iv = 1;
  ll fa = 1;
  repi(i, k, 0) {
    fa *= (n - i);
    fa %= MOD;
  }
  repi(i, k + 1, 1) {
    iv *= inv(i);
    iv %= MOD;
  }
  return fa * iv % MOD;
}

//---------main function----------

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

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

vector<ll> fact, invfact;
ll modpower(ll x, ll n, ll mod) {
  ll res = 1;
  while (n) {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}
ll inv(ll n) { return modpower(n, MOD - 2, MOD); }
void COMinit(ll k) { // 空っぽの配列を二つ
  k++;
  fact.resize(k, 0);
  invfact.resize(k, 0);
  fact[0] = 1;
  repi(i, k, 1) { fact[i] = fact[i - 1] * i % MOD; }
  invfact[k - 1] = inv(fact[k - 1]);
  repd(i, k - 2, 0) { invfact[i] = invfact[i + 1] * (i + 1) % MOD; }
  return;
}
ll nCk(vector<ll> &fact, vector<ll> &invfact, ll n,
       ll k) { // この関数を使う前にCOMinit
  if (k < 0 || n < k)
    return 0LL;
  return fact[n] * invfact[k] % MOD * invfact[n - k] % MOD;
}
ll com(ll n, ll k) {
  ll iv = 1;
  ll fa = 1;
  repi(i, k, 0) {
    fa *= (n - i);
    fa %= MOD;
  }
  repi(i, k + 1, 1) {
    iv *= inv(i);
    iv %= MOD;
  }
  return fa * iv % MOD;
}

//---------main function----------

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  repi(i, n, 0) { cin >> a[i]; }
  repi(i, n, 0) {
    ll ans = 0;
    repi(j, n, 0) {
      if (i == j)
        continue;
      ans ^= a[j];
    }
    cout << ans << 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 all(x) begin(x), end(x)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
  int n;
  cin >> n;
  int a[200005];
  rep(i, n) cin >> a[i];
  int keta = 0;
  while (1) {
    int cnt1 = 0;
    int end = 0;
    rep(i, n) {
      if (a[i] >= (1 << keta))
        cnt1 += (a[i] >> keta) & 1;
      if (a[i] <= (1 << (keta + 1)) - 1)
        end++;
    }
    if (cnt1 % 2 == 1) {
      rep(i, n) { a[i] ^= 1 << keta; }
    }
    keta++;
    if (end == n)
      break;
    // printf("%d %d\\n",cnt1,keta);
  }
  rep(i, n) cout << 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 all(x) begin(x), end(x)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
  int n;
  cin >> n;
  int a[100005];
  rep(i, n) cin >> a[i];
  rep(i, n) cout << a[i] << ' ';
  cout << endl;
  return 0;
}