Language: C++

/* ----------------------------
 * ABC 91 D カンニングして解答
 * ---------------------------- */
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

// digit は0始まり.
bool isBitOn(int target, int digit);
// digit 以下のビットを取得する
int getUnderBits(int target, int digit);
// digit だけ bit が立ったマスクを取得する
int getOnMask(int digit);
int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	// ソート
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	// 回答編
	int ans = 0;
	
	// c を n の4倍の大きさで用意する
	vector<int> c(4*n);
	// 0 <= (a, b) < pow(2, 28)
	for(int i = 0; i < 29; i++){
		for(int j = 0; j < n; j++){
			c[j] = getUnderBits(b[j], i);
		}
		sort(c.begin(), c.end);
		for(int j = 0; j < 2*n; j++){
			c[n+j] = c[j] + getOnMask(i + 1);
		}
		long long total = 0;
		for(int j = 0; j < n; j++){
			int y = getUnderBits(a[j], i);
			total += lower_bound(c.begin(), c.begin() + 3 * n, (4<<i)-y)
					- lower_bound(c.begin(), c.begin() + 3 * n, (3<<i)-y);
		}
		if(total%2) ans += getOnMask(i);
	}
	
	cout << ans << endl;
	return 0;
}
// digit は0始まり.
bool isBitOn(int target, int digit){
	return target & (1 << digit);
}
// digit 以下のビットを取得する
int getUnderBits(int target, int digit){
	// i.e.
	// getUnderBits(0b11111111, 3)
	// returns     0b00001111
	return target & ((1 << (digit + 1)) - 1);
}
// digit だけ bit が立ったマスクを取得する
int getOnMask(int digit){
	return 1 << digit;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:21: error: no matching function for call to 'sort(std::vector<int>::iterator, <unresolved overloaded function type>)'
   39 |                 sort(c.begin(), c.end);
      |                 ~~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:6:
/usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate: 'void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<int*, vector<int> >]'
 4762 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4762:63: note:   no known conversion for argument 2 from '<unresolved overloaded function type>' to '__gnu_cxx::__normal_iterator<int*, std::vector<int> >'
 4762 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |                                         ~~~~~~~~~~~~~~~~~~~~~~^~~~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
 4793 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)'
  292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)'
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note:   candidate expects 3 arguments, 2 provided