Problem p02631 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vll vector<ll>
#define print(x)                                                               \
  for (auto it = x.begin(); it != x.end(); it++)                               \
    cout << *it << ' ';                                                        \
  cout << '\n';
#define debug(a, b, c) cout << a << " " << b << " " << c << endl;
#define in(x, n)                                                               \
  for (int e = 0; e < n; e++) {                                                \
    int y;                                                                     \
    cin >> y;                                                                  \
    x.pb(y);                                                                   \
  }
#define inl(x, n)                                                              \
  for (int e = 0; e < n; e++) {                                                \
    ll y;                                                                      \
    cin >> y;                                                                  \
    x.pb(y);                                                                   \
  }
#define lower(sl) transform(sl.begin(), sl.end(), sl.begin(), ::tolower);

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vll a;
  inl(a, n);
  vll res;
  int i = 1;
  while (res.size() != n) {
    int k = 0;
    int c = 0;
    while (k < n - 1) {
      int pos = (i + k) % n;
      c = c ^ a[pos];
      k++;
    }
    i += 1;
    res.pb(c);
  }
  print(res);
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vll vector<ll>
#define print(x)                                                               \
  for (auto it = x.begin(); it != x.end(); it++)                               \
    cout << *it << ' ';                                                        \
  cout << '\n';
#define debug(a, b, c) cout << a << " " << b << " " << c << endl;
#define in(x, n)                                                               \
  for (int e = 0; e < n; e++) {                                                \
    int y;                                                                     \
    cin >> y;                                                                  \
    x.pb(y);                                                                   \
  }
#define inl(x, n)                                                              \
  for (int e = 0; e < n; e++) {                                                \
    ll y;                                                                      \
    cin >> y;                                                                  \
    x.pb(y);                                                                   \
  }
#define lower(sl) transform(sl.begin(), sl.end(), sl.begin(), ::tolower);

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vll a;
  inl(a, n);
  vll res;
  int x = 0;
  for (int i = 0; i < n; i++) {
    x ^= a[i];
  }

  int s = 0;
  for (int i = 0; i < n; i++) {
    s = x ^ a[i];
    res.pb(s);
  }
  print(res);
}