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

#include "bits/stdc++.h"
#define DEBUG(x) cout << #x << ": " << x << endl;
#define DEBUG_VEC(v)                                                           \\
  cout << #v << ":";                                                           \\
  for (int i = 0; i < v.size(); i++)                                           \\
    cout << " " << v[i];                                                       \\
  cout << endl
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vs vector<string>
#define pii pair<int, int>
#define pis pair<int, string>
#define psi pair<string, int>
#define pll pair<ll, ll>
#define rep(i, begin, end)                                                     \\
  for (__typeof(end) i = (begin) - ((begin) > (end));                          \\
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout << setprecision(15) << fixed << p << endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1};
typedef long long ll;
typedef unsigned long long ull;
const ull INF = 1e18;
using namespace std;

int main() {
  int n;
  cin >> n;
  int lst[n];
  rep(i, 0, n) { cin >> lst[i]; }
  int tmp = 0;
  rep(i, 1, n) { tmp ^= lst[i]; }
  cout << tmp << endl;
  lst[0] ^= tmp;
  rep(i, 1, n) {
    lst[i] ^= lst[0];
    cout << lst[i] << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include "bits/stdc++.h"
#define DEBUG(x) cout << #x << ": " << x << endl;
#define DEBUG_VEC(v)                                                           \\
  cout << #v << ":";                                                           \\
  for (int i = 0; i < v.size(); i++)                                           \\
    cout << " " << v[i];                                                       \\
  cout << endl
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vs vector<string>
#define pii pair<int, int>
#define pis pair<int, string>
#define psi pair<string, int>
#define pll pair<ll, ll>
#define rep(i, begin, end)                                                     \\
  for (__typeof(end) i = (begin) - ((begin) > (end));                          \\
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout << setprecision(15) << fixed << p << endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1};
typedef long long ll;
typedef unsigned long long ull;
const ull INF = 1e18;
using namespace std;

int main() {
  int n;
  cin >> n;
  int lst[n];
  rep(i, 0, n) { cin >> lst[i]; }
  rep(i, 0, n) {
    int tmp = 0;
    rep(j, 0, n) {
      if (i == j)
        continue;
      tmp ^= lst[j];
    }
    cout << tmp << endl;
  }
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;
int mas[200005], input[200005];
int main() {
  int n, p, in, pans = 0;
  cin >> n >> p;
  input[0] = p;
  mas[0] = 0;
  for (int i = 1; i < n; i++) {
    cin >> input[i];
    in = input[i];
    int k = pans ^ in ^ p;
    mas[i] = k;
    pans = k;
    p = in;
  }
  int test = 0;
  for (int i = 1; i < n; i++) {
    test ^= mas[i];
  }
  pans = test ^ input[0];
  p = input[0];
  cout << pans << " ";
  for (int i = 1; i < n; i++) {
    in = input[i];
    int k = pans ^ in ^ p;
    cout << k << " ";
    pans = k;
    p = in;
  }
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
int mas[100000], input[100000];
int main() {
  int n, p, in, pans = 0;
  cin >> n >> p;
  input[0] = p;
  mas[0] = 0;
  for (int i = 1; i < n; i++) {
    cin >> input[i];
    in = input[i];
    int k = pans ^ in ^ p;
    mas[i] = k;
    pans = k;
    p = in;
  }
  int test = 0;
  for (int i = 1; i < n; i++) {
    test ^= mas[i];
  }
  pans = test ^ input[0];
  p = input[0];
  cout << pans << " ";
  for (int i = 1; i < n; i++) {
    in = input[i];
    int k = pans ^ in ^ p;
    cout << k << " ";
    pans = k;
    p = in;
  }
}
Problem p02631 (C++) — buggy submission, verdict: Runtime Error

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

const int N = 2e5 + 100;
int mod = 1e9 + 7;
typedef long long ll;
int a[N];
map<int, int> mp;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int s = 0;
  for (int i = 1; i <= n; i++)
    cin >> a[i], s ^= a[i];
  for (int i = 1; i <= n; i++) {
    cout << (s ^ a[i]) << " ";
  }
  return 0;
}
/*
1e15
*/


Error: WA

Fixed submission:

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

const int N = 1e5 + 100;
int mod = 1e9 + 7;
typedef long long ll;
int a[N];
map<int, int> mp;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  for (int i = 1; i <= n; i++)
    cout << a[i];
  return 0;
}
/*
1e15
*/
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<int> pref(n);
  vector<int> suf(n);
  for (int i = 0; i < n; ++i) {
    pref[i] ^= a[i];
    if (i) {
      pref[i] ^= pref[i - 1];
    }
  }
  for (int i = 0; i < n; ++i) {
    suf[n - i - 1] ^= a[n - i - 1];
    if (i) {
      suf[n - i - 1] ^= suf[n - i];
    }
  }
  for (int i = 0; i < n; ++i) {
    if (i && i + 1 < n) {
      cout << (pref[i - 1] ^ suf[i + 1]);
    } else if (i && i == n - 1) {
      cout << pref[i - 1];
    } else {
      cout << suf[i + 1];
    }
    cout << " \\n"[i == n - 1];
  }
  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    int x = 0;
    for (int j = 0; j < n; ++j) {
      if (i != j) {
        x ^= a[j];
      }
    }
    cout << x << " \\n"[i == n - 1];
  }
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using std::bitset;
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reps(i, s, e) for (int i = s; i < (int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template <class T> using Set = std::set<T>;
template <class T, class U> using Map = std::map<T, U>;

template <class T> using Graph = vector<vector<T>>;

const int INT_BIG = 1 << 28;

int main() {
  int N;
  cin >> N;
  vll cats(N);
  vll catxor(N);
  ll maxxor = 0;
  rep(i, N) {
    cin >> catxor[i];
    if (maxxor < catxor[i]) {
      maxxor = catxor[i];
    }
  }

  // int now = catxor[0];
  ll sumxor = 0;
  reps(i, 1, N) {
    ll nextxor = catxor[i - 1] ^ catxor[i];
    cats[i] = nextxor ^ cats[i - 1];
    sumxor ^= cats[i];
  }
  rep(i, N) {
    // cout << cats[i]
    cout << (cats[i] ^ sumxor ^ catxor[0]);
    if (i != N - 1) {
      cout << " ";
    }
  }
  cout << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using std::bitset;
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reps(i, s, e) for (int i = s; i < (int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template <class T> using Set = std::set<T>;
template <class T, class U> using Map = std::map<T, U>;

template <class T> using Graph = vector<vector<T>>;

const int INT_BIG = 1 << 28;

int main() {
  int N;
  cin >> N;
  vll cats(N);
  vll catxor(N);
  ll maxxor = 0;
  rep(i, N) {
    cin >> catxor[i];
    if (maxxor < catxor[i]) {
      maxxor = catxor[i];
    }
  }
  int bit = (int)(std::log2(maxxor) + 0.01) + 1;

  // int now = catxor[0];
  vint counter(bit, 0);
  ll sumxor = 0;
  reps(i, 1, N) {
    ll nextxor = catxor[i - 1] ^ catxor[i];
    cats[i] = nextxor ^ cats[i - 1];
    sumxor ^= cats[i];
  }
  rep(i, N) {
    // cout << cats[i]
    cout << (cats[i] ^ sumxor ^ catxor[0]);
    if (i != N - 1) {
      cout << " ";
    }
  }
  cout << endl;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  ll N;
  cin >> N;
  vector<ll> a(N, 0);
  ll base = 0;
  rep(i, N) {
    cin >> a[i];
    base = base ^ a[i];
  }
  vector<ll> b(N, 0);
  rep(i, N) { b[i] = base ^ a[i]; }
  rep(i, N) { cout << b[i] << " "; }
  cout << endl;
}


Error: TLE

Fixed submission:

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

int main() {
  ll N;
  cin >> N;
  vector<ll> a(N, 0);
  rep(i, N) { cin >> a[i]; }
  vector<ll> b(N, 0);
  rep(i, N) {
    ll ans = 0;
    rep(j, N) {
      if (i == j)
        continue;
      ans = ans ^ a[j];
    }
    b[i] = ans;
  }
  rep(i, N) { cout << b[i] << " "; }
  cout << endl;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

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

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

  vector<ll> cats(N + 1);
  for (ll i = 1; i <= N; i++) {
    cats[i] = acc ^ a[i];
  }

  for (ll i = 1; i <= N; i++) {
    cout << cats[i] << " ";
  }
  cout << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

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

  vector<ll> cats(N + 1);
  cats[1] = a[2];
  for (ll i = 3; i <= N; i++) {
    cats[1] ^= a[i];
  }
  for (ll i = 2; i <= N; i++) {
    cats[i] = a[1];
    for (ll j = 2; j <= N; j++) {
      if (i != j) {
        cats[i] ^= a[j];
      }
    }
  }
  for (ll i = 1; i <= N; i++) {
    cout << cats[i] << " ";
  }
  cout << endl;
}
Problem p02631 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
template <typename T> inline void read(T &x) {
  x = 0;
  T f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-')
      f = -1;
  for (; isdigit(c); c = getchar())
    x = (x << 1) + (x << 3) + (c ^ 48);
  x *= f;
}
template <typename T> inline void w(T x) {
  if (x > 9)
    w(x / 10);
  putchar(x % 10 + 48);
}
template <typename T> inline void write(T x, char c) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  w(x);
  putchar(c);
}
int a[200005];
int main() {
  int n;
  int s = 0;
  read(n);
  for (int i = 1; i <= n; i++) {
    read(a[i]);
    s ^= a[i];
  }
  for (int i = 1; i < n; i++) {
    write(s ^ a[i], ' ');
  }
  write(s ^ a[n], '\\n');
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
template <typename T> inline void read(T &x) {
  x = 0;
  T f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-')
      f = -1;
  for (; isdigit(c); c = getchar())
    x = (x << 1) + (x << 3) + (c ^ 48);
  x *= f;
}
template <typename T> inline void w(T x) {
  if (x > 9)
    w(x / 10);
  putchar(x % 10 + 48);
}
template <typename T> inline void write(T x, char c) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  w(x);
  putchar(c);
}
int a[100005];
int main() {
  int n;
  int s = 0;
  read(n);
  for (int i = 1; i <= n; i++) {
    read(a[i]);
    s ^= a[i];
  }
  for (int i = 1; i < n; i++) {
    write(s ^ a[i], ' ');
  }
  write(s ^ a[n], '\\n');
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n, m, t, a[200005];
vector<ll> adj[100005];
#define ari                                                                    \\
  for (int i = 0; i < n; i++)                                                  \\
    cin >> a[i];
#define ginp                                                                   \\
  for (int i = 0; i < m; i++) {                                                \\
    int u, v;                                                                  \\
    cin >> u >> v;                                                             \\
    adj[u].push_back(v);                                                       \\
    adj[v].push_back(u);                                                       \\
  }

int main() {
  // cin >> t;
  // t = 1;
  // while( t-- ){
  cin >> n;
  ari;
  ll u = 0;
  for (int i = 0; i < n; i++)
    u = u ^ a[i];
  for (int i = 0; i < n; i++)
    cout << (u ^ a[i]) << " ";
  cout << endl;
  // }
  return (0);
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n, m, t, a[100005];
vector<ll> adj[100005];
#define ari                                                                    \\
  for (int i = 0; i < n; i++)                                                  \\
    cin >> a[i];
#define ginp                                                                   \\
  for (int i = 0; i < m; i++) {                                                \\
    int u, v;                                                                  \\
    cin >> u >> v;                                                             \\
    adj[u].push_back(v);                                                       \\
    adj[v].push_back(u);                                                       \\
  }

int main() {
  // cin >> t;
  t = 1;
  while (t--) {
    cin >> n;
    ari;
    ll u = 0;
    for (int i = 0; i < n; i++)
      u = u ^ a[i];
    for (int i = 0; i < n; i++)
      cout << (u ^ a[i]) << " ";
    cout << endl;
  }
  return (0);
}
Problem p02631 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
const int N = 200000;
int n, q;
ll a[N];
ll k;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%lld", a + i);
    k ^= a[i];
  }
  for (int i = 0; i < n; i++)
    cout << (a[i] ^ k) << " ";
}


Error: WA

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
const int N = 100005;
int n, q;
int a[N];
int k;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    k ^= a[i];
  }
  for (int i = 0; i < n; i++)
    cout << (a[i] ^ k) << " ";
}
Problem p02631 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
vector<ll> v;
ll arr[200001];
int main() {
  ll n, k, a, b, c, ans = 0;
  cin >> n;
  for (ll i = 0; i < n; i++) {
    cin >> arr[i];
    ans ^= arr[i];
  }
  //   cout<<arr[1]<<endl;
  for (ll i = 0; i < n; i++) {
    b = ans ^ arr[i];
    cout << b << " ";
  }
  cout << endl;
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
vector<ll> v;
ll arr[100001] = {0};
int main() {
  ll n, k, a, b, c, ans = 0;
  cin >> n;
  for (ll i = 0; i < n; i++) {
    cin >> arr[i];
    ans ^= arr[i];
  }
  //   cout<<arr[1]<<endl;
  for (ll i = 0; i < n; i++) {
    b = ans ^ arr[i];
    cout << b << " ";
  }
  cout << endl;
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define INF 1e9
using ll = long long;
using namespace std;
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;
}

int main() {
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  int x = 0;
  rep(j, n) x ^= a[j];
  rep(i, n) {
    int ans = x;
    ans ^= a[i];
    cout << ans << " ";
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define INF 1e9
using ll = long long;
using namespace std;
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;
}

int main() {
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  rep(i, n) {
    int x = 0;
    rep(j, n) if (i != j) x ^= a[j];
    cout << x << " ";
  }
  return 0;
}
Problem p02631 (C++) — buggy submission, verdict: Runtime Error

// Apparat : drobucs, aleonov, vit_72
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

// #pragma warning(disable : 4996)
// #pragma GCC optimize("O3")

using namespace std;

#define nptr nullptr
#define all(x) (x).begin(), (x).end()
#define drobucs                                                                \\
  ios_base::sync_with_stdio(0);                                                \\
  cout.tie(0);                                                                 \\
  cin.tie(0);
#define ff first
#define ss second
#define pb push_back
#define sz(x) (int)(x).size()

typedef long long ll;

const int maxn = (int)2e5 + 13;
const ll INFL = 9223372036854775807;
const ll INF = 2147483647;
const ll MOD = (int)1e9 + 7,
         MOD2 = 998244353; // 1e9 + 21, 1e9 + 33, 1e9 + 87, 1e9 + 93
const ll base = 101, base2 = 37;

int a[maxn];
int main() {
  drobucs;

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

Error: WA

Fixed submission:

// Apparat : drobucs, aleonov, vit_72
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

// #pragma warning(disable : 4996)
// #pragma GCC optimize("O3")

using namespace std;

#define nptr nullptr
#define all(x) (x).begin(), (x).end()
#define drobucs                                                                \\
  ios_base::sync_with_stdio(0);                                                \\
  cout.tie(0);                                                                 \\
  cin.tie(0);
#define ff first
#define ss second
#define pb push_back
#define sz(x) (int)(x).size()

typedef long long ll;

const int maxn = (int)1e5 + 13;
const ll INFL = 9223372036854775807;
const ll INF = 2147483647;
const ll MOD = (int)1e9 + 7,
         MOD2 = 998244353; // 1e9 + 21, 1e9 + 33, 1e9 + 87, 1e9 + 93
const ll base = 101, base2 = 37;

int a[maxn];
int main() {
  drobucs;

  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i)
    cin >> a[i];
  int xr = 0;
  for (int i = 1; i <= n; ++i)
    xr ^= a[i];
  for (int i = 1; i <= n; ++i)
    cout << (xr ^ a[i]) << " ";
  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++)
#define rng(a) a.begin(), a.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

Error: TLE

Fixed submission:

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n), b(n);
  rep(i, n) { cin >> a[i]; }
  rep(i, n) {
    rep(j, n) {
      if (i == j)
        continue;
      b[i] ^= a[j];
    }
  }
  rep(i, n) cout << b[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() {
  ios_base::sync_with_stdio(0);
  ll n;
  cin >> n;
  vector<ll> v(n);
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    ans ^= v[i];
  }

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

Error: TLE

Fixed submission:


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main() {
  ios_base::sync_with_stdio(0);
  ll n;
  cin >> n;
  vector<ll> v(n), res(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  ll ans;
  for (int i = 0; i < n; i++) {
    ans = 0;
    for (int j = 0; j < n; j++) {
      if (i != j) {
        ans ^= v[j];
      }
    }
    cout << ans << " ";
  }
}
Problem p02631 (C++) — buggy submission, verdict: Runtime Error

#include "bits/stdc++.h"
using namespace std;
#define ll long long
// function to construct new array
void constructXOR(int A[], int n) {
  // calculate xor of array
  int XOR = 0;
  for (int i = 0; i < n; i++)
    XOR ^= A[i];

  // update array
  for (int i = 0; i < n; i++)
    A[i] = XOR ^ A[i];
}
int main() {
  int n;
  cin >> n;
  int A[n + 1];
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  constructXOR(A, n);
  for (int i = 0; i < n; i++) {
    cout << A[i] << ' ';
  }

  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll n, m, a[200000], b[200000], f1[10000] = {0}, f2[10000] = {0};
  vector<ll> v;
  cin >> n;
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    f1[a[i]]++;
  }
  cin >> m;
  for (ll i = 0; i < m; i++) {
    cin >> b[i];
    f2[b[i]]++;
  }
  for (ll i = 1; i <= 10000; i++) {
    if ((f2[i] - f1[i]) > 0)
      v.push_back(i);
  }
  for (auto i : v)
    cout << i << " ";
  return 0;
}