Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

struct cmp {
	int mod;
	cmp(int x) :mod(x) {}
	bool operator()(const int& a, const int& b)const {
		return a % mod < b% mod;
	}
};

int main() {
	int n; cin >> n;
	vector<int>a(n), b(n); for (auto&& x : a)cin >> x;for (auto&& x : b)cin >> x;
	int ans = 0;
	for (int i = 0; i < 30; i++) {
		sort(b.begin(), b.end(), cmp(1 << i));
		bool btg = false;
		for (int j = 0; j < n; j++) {
			btg ^= (b[j] >> i) & 1;
		}
		for (int j = 0; j < n; j++) {
			int v = (1 << i) - (a[j] % (1 << i)) - 1;
			int pos = upper_bound(b.begin(), b.end(), cmp(1 << i)) - b.begin();
			int pv = (a[j] >> i) & 1;
			bool tg = (pv ? pos & 1 : (n - pos) & 1);
			tg ^= btg;
			if (tg)ans ^= (1 << i);
		}
	}
	cout << ans << endl;

	return 0;
}

Compiler output:
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
                 from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_less_iter::operator()(_Value&, _Iterator) const [with _Value = const cmp; _Iterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >]':
/usr/include/c++/14/bits/stl_algo.h:1993:14:   required from '_ForwardIterator std::__upper_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = __gnu_cxx::__normal_iterator<int*, vector<int> >; _Tp = cmp; _Compare = __gnu_cxx::__ops::_Val_less_iter]'
 1993 |           if (__comp(__val, __middle))
      |               ~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2028:32:   required from '_FIter std::upper_bound(_FIter, _FIter, const _Tp&) [with _FIter = __gnu_cxx::__normal_iterator<int*, vector<int> >; _Tp = cmp]'
 2028 |       return std::__upper_bound(__first, __last, __val,
      |              ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
 2029 |                                 __gnu_cxx::__ops::__val_less_iter());
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:26:25:   required from here
   26 |                         int pos = upper_bound(b.begin(), b.end(), cmp(1 << i)) - b.begin();
      |                                   ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:98:22: error: no match for 'operator<' (operand types are 'const cmp' and 'int')
   98 |       { return __val < *__it; }
      |                ~~~~~~^~~~~~~
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)'
 1241 |     operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1241:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:98:22: note:   'const cmp' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>'
   98 |       { return __val < *__it; }
      |                ~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)'
 1249 |     operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1249:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:98:22: note:   'const cmp' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>'
   98 |       { return __val < *__it; }
      |                ~~~~~~^~~~~~~