Problem p02631 (C++) — buggy submission, verdict: Runtime Error

//  Author : Amit Kumar

#include <algorithm>
#include <chrono>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <utility>

#include <array>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace std::chrono;
//  using namespace placeholders;
using namespace __gnu_pbds;
template <typename TypeInfo>
using new_set = tree<
    /* ob.order_of_key(element) -> number of element strictly less than element
     * *ob.find_by_order(n) ->  nth element in increasing order
     */
    TypeInfo, null_type, less<TypeInfo>, rb_tree_tag,
    tree_order_statistics_node_update>;

void show_me() { cerr << endl; }

template <typename HEAD, typename... TAIL> void show_me(HEAD H, TAIL... T) {
  cerr << " " << (H);
  show_me(T...);
}

#ifdef HELL_JUDGE
#define show(...) cerr << "[" << #__VA_ARGS__ << "]:", show_me(__VA_ARGS__)
#else
#define show(...) 0
#endif

template <typename A, typename B>
ostream &operator<<(ostream &out, const pair<A, B> &p) {
  out << p.first << ' ' << p.second;
  return out;
}

template <typename A, typename B>
istream &operator>>(istream &in, pair<A, B> &p) {
  in >> p.first >> p.second;
  return in;
}

template <typename A> istream &operator>>(istream &in, vector<A> &vec) {
  for (auto &itr : vec) {
    in >> itr;
  }
  return in;
}

template <typename A> ostream &operator<<(ostream &out, const vector<A> &vec) {
  for (auto &itr : vec) {
    out << itr << ' '; // VVV
  }
  return out;
}

const int MAXM = (int)1e5 + 100;
const int MAXN = (int)1e5 + 100;
const int MOD = (int)1e9 + 7;

signed main(void) {
#ifdef HELL_JUDGE
  freopen("input", "r", stdin);
  freopen("output", "w", stdout);
  freopen("error", "w", stderr);
#endif
  ios::sync_with_stdio(
      false);        // FLUSH THE STREAM IF USING puts / printf / scanf/
  cin.tie(nullptr);  //
  cout.tie(nullptr); //
#ifdef HELL_JUDGE
  auto INITIAL_TIME = high_resolution_clock::now();
#endif
  int64_t n;
  cin >> n;
  vector<int64_t> v(n);
  cin >> v;
  vector<int64_t> xr;
  int64_t total = 0;
  for (int i = 0; i < n; ++i) {
    xr.emplace_back(v[i] ^ v[i + 1]);
    ++i;
  }
  for (auto &itr : xr) {
    total ^= itr;
  }
  for (int i = 0; i < n; i += 2) {
    int x = (total ^ xr[i / 2]);
    cout << (v[i + 1] ^ x) << ' ';
    cout << (v[i] ^ x) << ' ';
  }
  cout << '\\n';
#ifdef HELL_JUDGE
  auto FINAL_TIME = high_resolution_clock::now();
  cout << "Time : "
       << duration_cast<milliseconds>(FINAL_TIME - INITIAL_TIME).count()
       << " ms" << '\\n';
#endif
  return 0;
}


Error: WA

Fixed submission:

//  Author : Amit Kumar

#include <algorithm>
#include <chrono>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <utility>

#include <array>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace std::chrono;
//  using namespace placeholders;
using namespace __gnu_pbds;
template <typename TypeInfo>
using new_set = tree<
    /* ob.order_of_key(element) -> number of element strictly less than element
     * *ob.find_by_order(n) ->  nth element in increasing order
     */
    TypeInfo, null_type, less<TypeInfo>, rb_tree_tag,
    tree_order_statistics_node_update>;

void show_me() { cerr << endl; }

template <typename HEAD, typename... TAIL> void show_me(HEAD H, TAIL... T) {
  cerr << " " << (H);
  show_me(T...);
}

#ifdef HELL_JUDGE
#define show(...) cerr << "[" << #__VA_ARGS__ << "]:", show_me(__VA_ARGS__)
#else
#define show(...) 0
#endif

template <typename A, typename B>
ostream &operator<<(ostream &out, const pair<A, B> &p) {
  out << p.first << ' ' << p.second;
  return out;
}

template <typename A, typename B>
istream &operator>>(istream &in, pair<A, B> &p) {
  in >> p.first >> p.second;
  return in;
}

template <typename A> istream &operator>>(istream &in, vector<A> &vec) {
  for (auto &itr : vec) {
    in >> itr;
  }
  return in;
}

template <typename A> ostream &operator<<(ostream &out, const vector<A> &vec) {
  for (auto &itr : vec) {
    out << itr << ' '; // VVV
  }
  return out;
}

const int MAXM = (int)1e5 + 100;
const int MAXN = (int)1e5 + 100;
const int MOD = (int)1e9 + 7;

signed main(void) {
#ifdef HELL_JUDGE
  freopen("input", "r", stdin);
  freopen("output", "w", stdout);
  freopen("error", "w", stderr);
#endif
  ios::sync_with_stdio(
      false);        // FLUSH THE STREAM IF USING puts / printf / scanf/
  cin.tie(nullptr);  //
  cout.tie(nullptr); //
#ifdef HELL_JUDGE
  auto INITIAL_TIME = high_resolution_clock::now();
#endif
  int n;
  cin >> n;
  vector<int> v(n);
  cin >> v;
  vector<int> xr;
  int64_t total = 0;
  for (int i = 0; i < n; ++i) {
    xr.emplace_back(v[i] ^ v[i + 1]);
    ++i;
  }
  for (auto &itr : xr) {
    total ^= itr;
  }
  for (int i = 0; i < n; ++i) {
    int x = (total ^ xr[i]);
    cout << (v[i] ^ x) << ' ';
    cout << (v[i + 1] ^ x) << ' ';
    ++i;
  }
  cout << '\\n';
#ifdef HELL_JUDGE
  auto FINAL_TIME = high_resolution_clock::now();
  cout << "Time : "
       << duration_cast<milliseconds>(FINAL_TIME - INITIAL_TIME).count()
       << " ms" << '\\n';
#endif
  return 0;
}