Language: C++

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <random>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
#include <limits>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

using ulong = unsigned long long;

const ulong MASK30 = (1ull << 30) - 1;
const ulong MASK31 = (1ull << 31) - 1;
const ulong MOD = (1ull << 61) - 1;
const ulong POSITIVIZER = MOD * 3;

ulong mul(ulong a, ulong b) {
    ulong au = a >> 31;
    ulong ad = a & MASK31;
    ulong bu = b >> 31;
    ulong bd = b & MASK31;
    ulong mid = ad * bu + au * bd;
    ulong midu = mid >> 30;
    ulong midd = mid & MASK30;
    return au * bu * 2 + midu + (midd << 31) + ad * bd;
}

ulong calc_mod(ulong val) {
    val = (val & MOD) + (val >> 61);
    if (val > MOD) val -= MOD;
    return val;
}

ulong power(ulong base, int N) {
  ulong res = 1;
  for (int i = 0; i < N; i++) res = calc_mod(mul(res, base));
  return res;
}

ulong calc_hash(const vector<int>& a, ulong base) {
  ulong hash = 0;
  for (int x : a) {
    hash = calc_mod(mul(hash, base) + x);
  }
  return hash;
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    vector<int> a(N), b(N);
    for (int& x : a) cin >> x;
    for (int& x : b) cin >> x;
    vector<int> a2(N), b2(N);
    for (int i = 0; i < N; i++) a2[i] = (a[i] ^ a[(i + 1) % N]) + 1;
    for (int i = 0; i < N; i++) b2[i] = (b[i] ^ b[(i + 1) % N]) + 1;
    ulong base = 1e9 + 7;
    ulong pw = power(base, N);
    ulong hash = calc_hash(a2, base), target = calc_hash(b2, base);
    for (int k = 0; k < N; k++) {
      if (hash == target) {
        cout << k << " " << (a[k] ^ b[0]) << endl;
      }
      hash = calc_mod(mul(hash, base));
      hash = calc_mod(hash + POSITIVIZER - mul(pw, a2[k]));
      hash = calc_mod(hash + a2[k]);
    }
  }
  return 0;
}


Compiler output:
a.cc:36:7: error: conflicting declaration 'using ulong = long long unsigned int'
   36 | using ulong = unsigned long long;
      |       ^~~~~
In file included from /usr/include/stdlib.h:514,
                 from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/bits/stl_algo.h:71,
                 from /usr/include/c++/14/algorithm:61,
                 from a.cc:1:
/usr/include/x86_64-linux-gnu/sys/types.h:148:27: note: previous declaration as 'typedef long unsigned int ulong'
  148 | typedef unsigned long int ulong;
      |                           ^~~~~