This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
// 0 <= x, y <= 2^(k+1)
// (x+y) & (2^k) > 0
// 2^k <= x+y < 2^(k+1)
// 2^(k+1) <= x+y < 2^(k+2)
int main()
{
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	vector<int> v(n);
	for (int &x : v)
		cin >> x;
	int res = 0;
	for (int k = 0; k < 30; ++k)
	{
		// radix sort
		{
			vector<int> a, b;
			for (int &x : v)
			{
				if (x >> k & 1) b.pb(x);
				else a.pb(x);
			}
			v.clear();
			for (int x : a)
				v.pb(x);
			for (int x : b)
				v.pb(x);
		}
		int C = 0, R = (1 << (k+1)) - 1;
		int l = n-1, r = n-1;
		for (int x : v)
		{
			while (l >= 0 && (x&R) + (v[l]&R) >= (1 << k)) l--;
			while (r >= 0 && (x&R) + (v[r]&R) >= (1 << (k+1))) r--;
			C += r-l;
		}
		l = r = n-1;
		for (int x : v)
		{
			while (l >= 0 && (x&R) + (v[l]&R) >= (1 << (k+1)) + (1 << k)) l--;
			while (r >= 0 && (x&R) + (v[r]&R) >= (1 << (k+1)) + (1 << (k+1))) r--;
			C += r-l;
		}
		
		if (C & 1) res ^= (1 << k);
	}
	cout << res << '\n';
	return 0;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |