Language: C++

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

int bsearch(int x,vector<int> c){
	int min=0;
	int max=c.size()-1;
	int mid;
	while(true){
		mid=(max+min)/2;
		if(c[mid]>=x) max=mid;
		else min=mid+1;
		if(max<=min) break;
	}
	if(max==c.size()-1 && c[max]<x) max++;
	return max;
}

int main(){
	int n; cin >> n;
	vector<int> a(n),b(n);
	for(int i=0;i<n;i++) cin >> a[i];
	for(int i=0;i<n;i++) cin >> b[i];
	vector<vector<int>> c;
	c=vector<vector<int>>(29,vector<int>(b.size()));
	for(int k=0;k<29;k++){
		for(int i=0;i<b.size();i++)	c[k][i]=b[i]%(1<<k+1);
		sort(c[k].begin(),c[k].end());
	}
	vector<int> bits(29,0);
	for(int i=0;i<n;i++){
		for(int k=0;k<29;k++){
			int l=0,r=0;
			int T=1<<k;
			/*
			int ll=bsearch(T-a[i]%(T*2),c[k]);
			int lr=bsearch(2*T-a[i]%(T*2),c[k]);
			if(ll>c[k].size()) l=0;
			else if(ll==lr) l=0;
			else l=lr-ll;
			int rl=bsearch(3*T-a[i]%(T*2),c[k]);
			int rr=bsearch(4*T-a[i]%(T*2),c[k]);
			if(rl>c[k].size()) r=0;
			else if(rl==rr) r=0;
			else r=rr-rl;
			bits[k]+=l+r;
			*/
			auto it1=lower_bound(c.begin(),c.end(),T-a[i]%(T*2));
			auto it2=lower_bound(c.begin(),c.end(),2*T-a[i]%(T*2));
			auto it3=lower_bound(c.begin(),c.end(),3*T-a[i]%(T*2));
			auto it4=lower_bound(c.begin(),c.end(),4*T-a[i]%(T*2));
			bits[k]+=(it2-it1)+(it4-it3);
		}
	}
	int ans=0;
	for(int k=0;k<29;k++){
		ans+=((bits[k]%2)<<k);
	}
	cout << ans << endl;
}


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::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int> > >; _Value = const int]':
/usr/include/c++/14/bits/stl_algobase.h:1504:14:   required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = __gnu_cxx::__normal_iterator<vector<int>*, vector<vector<int> > >; _Tp = int; _Compare = __gnu_cxx::__ops::_Iter_less_val]'
 1504 |           if (__comp(__middle, __val))
      |               ~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1539:32:   required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = __gnu_cxx::__normal_iterator<vector<int>*, vector<vector<int> > >; _Tp = int]'
 1539 |       return std::__lower_bound(__first, __last, __val,
      |              ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
 1540 |                                 __gnu_cxx::__ops::__iter_less_val());
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:50:24:   required from here
   50 |                         auto it1=lower_bound(c.begin(),c.end(),T-a[i]%(T*2));
      |                                  ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:69:22: error: no match for 'operator<' (operand types are 'std::vector<int>' and 'const int')
   69 |       { return *__it < __val; }
      |                ~~~~~~^~~~~~~
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:69:22: note:   'std::vector<int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>'
   69 |       { return *__it < __val; }
      |                ~~~~~~^~~~~~~
/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:69:22: note:   'std::vector<int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>'
   69 |       { return *__it < __val; }
      |                ~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
  448 |     operator<(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note:   'std::vector<int>' is not derived from 'const std::reverse_iterator<_Iterator>'
   69 |       { return *__it < __val; }
      |                ~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  493 |     operator<(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note:   'std::vector<int>' is not derived from 'const std::reverse_iterator<_Iterator>'
   69 |       { return *__it < __val; }
      |                ~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1694 |     operator<(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note:   'std::vector<int>' is not derived from 'const std::move_iterator<_IteratorL>'
   69 |       { return *__it < __val; }
      |                ~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
 1760 |     operator<(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note:   'std::vector<int>' is not derived from 'const std::move_iterator<_IteratorL>'
   69 |       { return *__it < __val; }
      |                ~~~~~~^~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
 1045 |     operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1045:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note:   'std::vector<int>' is not derived from 'const std::pair<_T1, _T2>'
   69 |       { return *__it < __val; }
      |                ~~~~~~^~~~~~~
In file included from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
  673 |     operator< (basic_string_view<_CharT, _Traits> __x,
      |     ^~~~~~~~
/usr/include/c++/14/string_view:673:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note:   'std::vector<int>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
   69 |       { return *__it < __val; }
      |                ~~~~~~^~~~~~~
/usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
  680 |     operator< (basic_string_view<_CharT, _Traits> __x,
      |     ^~~~~~~~
/usr/include/c++/14/string_view:680:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note:   'std::vector<int>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
   69 |       { return *__it < __val; }
      |                ~~~~~~^~~~~~~
/usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
  688 |     operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
      |     ^~~~~~~~
/usr/include/c++/14/string_view:688:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note:   mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int'
   69 |       { return *__it < __val; }
      |                ~~~~~~^~~~~~~
/usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3874 |     operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3874:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note:   'std::vector<int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   69 |       { return *__it < __val; }
      |                ~~~~~~^~~~~~~
/usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
 3888 |     operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3888:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note:   'std::vector<int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   69 |       { return *__it < __val; }
      |                ~~~~~~^~~~~~~
/usr/include/c++/14/bits/basic_string.h:3901:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3901 |     operator<(const _CharT* __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3901:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note: