Language: C++

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second


signed main(){
	
	ll cnt[51] = {},type[51] = {},n,k,memo = 0,ans = 0;
	scanf("%llu %llu",&n,&k);
	
	ll a[n] = {};
	
	rep(i,0,n){
		scanf("%llu",&a[i]);
		ll temp = a[i];
		
		rep(j,0,51){
			cnt[j] += ((a[i] >> j) & 1);
		}
	}
	
	rep(i,0,51){
		if(n % 2){
			if(cnt[i] > n/2) type[i] = 0;
			else type[i] = 1;
		}
		else{
			if(cnt[i] > n/2) type[i] = 0;
			else if(cnt[i] == n/2) type[i] = 2;
			else type[i] = 1;
		}
		
		//cout << type[i] ;
	}
	cout << endl;
	rep(i,0,51){
		//cout <<memo + pow(2,i)*min(1,type[i]) << "  " << k << endl;
		if(memo + pow(2,i)*min(1,type[i]) > k){
			if(memo != 0) break;
			rep(j,0,i){
				if(type[i-j] == 2){
					memo = pow(2,i-j);
					break;
				}
			}
		}
		
		memo += pow(2,i)*min(1,type[i]);
	}
	
	rep(i,0,n){
		ans += (memo ^ a[i]);
	}
	
	printf("%llu\n",ans);
	
	return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:39: error: no matching function for call to 'min(int, ll&)'
   48 |                 if(memo + pow(2,i)*min(1,type[i]) > k){
      |                                    ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:48:39: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   48 |                 if(memo + pow(2,i)*min(1,type[i]) > k){
      |                                    ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:48:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   48 |                 if(memo + pow(2,i)*min(1,type[i]) > k){
      |                                    ~~~^~~~~~~~~~~
a.cc:58:37: error: no matching function for call to 'min(int, ll&)'
   58 |                 memo += pow(2,i)*min(1,type[i]);
      |                                  ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:58:37: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   58 |                 memo += pow(2,i)*min(1,type[i]);
      |                                  ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:58:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   58 |                 memo += pow(2,i)*min(1,type[i]);
      |                                  ~~~^~~~~~~~~~~