criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;

int a[40];

int main(){
	int n,m;
	cin >> n >> m;
	long long now,maxx = 0;
	long long own = 1;
	for(int i = 1 ; i <= n ; i++){
		scanf("%lld",&now);
		if(now > maxx)maxx = now;
		for(int i = 0 ; i < 40 ; i++)
			if(((own << i) & now) != 0)a[i]++;
	}

	long long ans = 0;
	for(int i = p ; i >= 0 ; i--){
		if(m - (own << i) >= 0 && 2 * a[i] <= n){//第i位取1
			ans += (n - a[i]) * (own << i);
			m -= (own << i);
		}
		else{
			ans += a[i] * (own << i);
		}
	}
	
	cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:21: error: 'p' was not declared in this scope
   20 |         for(int i = p ; i >= 0 ; i--){
      |                     ^
Language: C++

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<int> ans(n);
    for (int j = 0; j < k; i++) {
        for (int i = 0; i < n; i++) {
            ans[i] += i ^ a[i];
        }
    }
    sort(ans.begin(), ans.end(), greater<int>());
    
    cout << ans[0] << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:28: error: 'i' was not declared in this scope
   14 |     for (int j = 0; j < k; i++) {
      |                            ^
Language: C++

#include <vector>
#include <cmath>
#include <iostream>
 
void makeBinary(int t, std::vector<int>& bin, int length){
	if(length == 1){
    	t == 1 ? bin[0] = 1 : bin[0] = 0;
      	return;
    }
  	
  	for(int i = length-1; i > 0; i--){
      	bin[i] = t%2;
      	if(i == 1){
        	bin[i-1] = t/2; 
        }
      	t = t/2;
    }
}
 
int GetbinaryLength(int a){
	if(a < 0) return -1;
  
  	int length = 1;
  	while(a >= 2){
		a = a/2;
      	length++;
    }
  
  	return length;
}
 
int main(void){
	int N, K;
    size_t N_length = GetbinaryLength(N);
  	std::vector<int> countOne;
  	std::vector<int> countZero;
    countOne.resize(N_length);
  	countZero.resize(N_length);
  	for(int i = 0; i < N_length; i++){
    	countOne[i] = couneZero[i] = 0;
    }
  
  	for(int i = 0; i < N; i++){
      	int tmp;
    	std::cin >> tmp;
      	std::vector<int> bin;
      	bin.resize(N_length);
      	makeBinary(tmp, bin, N_length);
      	for(int j = 0; j < N_length; j++){
        	if(bin[j] == 0){
            	countZero[j]++;
            }
          	else{
            	countOne[j]++;
            }
        }
    }
  
  	int result = 0;
  	int K_limit = 0;
  	for(int i = N_length-1; i >= 0; i--){
      	int plus = std::pow(2,i);
    	if(countZero[i] > countOne[i]){
          	if(plus + K_limit <= K){
            	K_limit += plus;
              	result += countZero[i] * plus;
            }
          	else{
            	result += countOne[i] * plus;
            }
        }
      	else{
            result += countOne[i] * plus;
        }
    }
 
	std::cout << result;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:23: error: 'couneZero' was not declared in this scope; did you mean 'countZero'?
   40 |         countOne[i] = couneZero[i] = 0;
      |                       ^~~~~~~~~
      |                       countZero
Language: C++

#include <vector>
#include <cmath>
#include <iostream>

void makeBinary(int t, std::vector<int>& bin, int length){
	if(length == 1){
    	t == 1 ? bin[0] = 1 : bin[0] = 0;
      	return;
    }
  	
  	for(int i = length-1; i > 0; i--){
      	bin[i] = t%2;
      	if(i == 1){
        	bin[i-1] = t/2; 
        }
      	t = t/2;
    }
}

int GetbinaryLength(int a){
	if(a < 0) return -1;
  
  	int length = 1;
  	while(a >= 2){
		a = a/2;
      	length++;
    }
  
  	return length;
}
 
int main(void){
	int N, K;
    size_t N_length = GetbinaryLength(N);
  	std::vector<int> countOne;
  	std::vector<int> countZero;
    countOne.resize(N_length);
  	countZero.resize(N_length);
  	for(int i = 0; i < N_length; i++){
    	countOne[i] = couneZero[i] = 0;
    }
  
  	for(int i = 0; i < N; i++){
      	int tmp;
    	std::cin >> tmp;
      	std::vector<int> bin;
      	bin.resize(N_length);
      	makeBinary(tmp, bin, N_length);
      	for(int j = 0; j < N_length; j++){
        	if(bits[j] == 0){
            	countZero[j]++;
            }
          	else{
            	countOne[j]++;
            }
        }
    }
  
  	int result = 0;
  	int K_limit = 0;
  	for(int i = N_length-1; i >= 0; i--){
      	int plus = std::pow(2,i);
    	if(countZero[i] > countOne[i]){
        	result.set(i+1);
          	if(plus + K_limit <= K){
            	K_limit += plus;
              	result += countZero[i] * plus;
            }
          	else{
            	result += countOne[i] * plus;
            }
        }
      	else{
        	result.reset(i+1);
            result += countOne[i] * plus;
        }
    }
 
	std::cout << result;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:23: error: 'couneZero' was not declared in this scope; did you mean 'countZero'?
   40 |         countOne[i] = couneZero[i] = 0;
      |                       ^~~~~~~~~
      |                       countZero
a.cc:50:20: error: 'bits' was not declared in this scope
   50 |                 if(bits[j] == 0){
      |                    ^~~~
a.cc:64:24: error: request for member 'set' in 'result', which is of non-class type 'int'
   64 |                 result.set(i+1);
      |                        ^~~
a.cc:74:24: error: request for member 'reset' in 'result', which is of non-class type 'int'
   74 |                 result.reset(i+1);
      |                        ^~~~~
Language: C++

#include <bitset>
#include <vector>
#include <cmath>
#include <iostream>

int GetbinaryLength(int a){
	if(a < 0) return -1;
  
  	int length = 1;
  	while(a >= 2){
		a = a/2;
      	length++;
    }
  
  	return length;
}

int main(void){
	int N, K;
    size_t N_length = GetbinaryLength(N);
  	std::vector<int> countOne;
  	std::vector<int> countZero;
    countOne.resize(N_length);
  	countZero.resize(N_length);
  
  	for(int i = 0; i < N; i++){
      	int tmp;
    	std::cin >> tmp;
      	std::bitset<N_length> bits(tmp);
      	for(int j = 0; j < N_length; j++){
        	if(bits[j] == 0){
            	countZero[j]++;
            }
          	else{
            	countOne[j]++;
            }
        }
    }
  
  	int result = 0;
  	int K_limit = 0;
  	for(int i = N_length-1; i >= 0; i--){
      	int plus = std::pow(2,i);
    	if(countZero[i] > countOne[i]){
        	result.set(i+1);
          	if(plus + K_limit <= K){
            	K_limit += plus;
              	result += countZero[i] * plus;
            }
          	else{
            	result += countOne[i] * plus;
            }
        }
      	else{
        	result.reset(i+1);
            result += countOne[i] * plus;
        }
    }

	std::cout << result;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:29: error: the value of 'N_length' is not usable in a constant expression
   29 |         std::bitset<N_length> bits(tmp);
      |                             ^
a.cc:20:12: note: 'size_t N_length' is not const
   20 |     size_t N_length = GetbinaryLength(N);
      |            ^~~~~~~~
a.cc:29:29: note: in template argument for type 'long unsigned int'
   29 |         std::bitset<N_length> bits(tmp);
      |                             ^
a.cc:31:24: error: invalid types 'int[int]' for array subscript
   31 |                 if(bits[j] == 0){
      |                        ^
a.cc:45:24: error: request for member 'set' in 'result', which is of non-class type 'int'
   45 |                 result.set(i+1);
      |                        ^~~
a.cc:55:24: error: request for member 'reset' in 'result', which is of non-class type 'int'
   55 |                 result.reset(i+1);
      |                        ^~~~~
Language: C++

#include <iostream>
#include <vector>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

#define TEST
int main() {
#ifdef TEST
  freopen("input.txt", "r", stdin);
#endif
  int N;
  long long K;
  cin >> N >> K;
  vector<long long> A;
  for (int i = 0; i < N; i++) {
    long long a;
    cin >> a;
    A.push_back(a);
  }

  // 2^40 > 10^12
  const int MAX_DIGIT = 50;

  // 上からi桁目
  // j=0 => k未満であることが確定 (smaller)
  // j=1 => 今のところKと一致 (exact)
  long long dp[MAX_DIGIT + 1][2];
  memset(dp, -1, sizeof(dp));

  // 上から0桁目がKと一致するのを0に初期化
  dp[0][1] = 0;
  for (int i = 0; i < MAX_DIGIT; i++) {
    long long mask = 1LL << (MAX_DIGIT - i - 1);

    // cout << "start: " << i << endl;

    // i桁目が1の数
    int num = 0;
    for (int j = 0; j < N; j++) {
      if ( (A[j] & mask) != 0) {
        num++;
      }
    }

    // 上からi桁目を0にしたとき
    long long cost0 = num * mask;
    // 上からi桁目を1にしたとき
    long long cost1 = (N - num) * mask;

    // smaller -> smaller
    if (dp[i][0] != -1) {
      chmax(dp[i + 1][0], dp[i][0] + max(cost0, cost1));
    }
    // smaller -> exact (上の桁から決めているのでこの遷移はない)

    // exact -> smaller
    if (dp[i][1] != -1) {
      if ((K & mask) != 0) {
        chmax(dp[i + 1][0], dp[i][1] + cost0);
      }
    }

    // exact -> exact
    if (dp[i][1] != -1) {
      if ((K & mask) != 0) {
        chmax(dp[i + 1][1], dp[i][1] + cost1);
      } else {
        chmax(dp[i + 1][1], dp[i][1] + cost0);
      }
    }
  }

  // for (int i = 0; i < MAX_DIGIT + 1; i++) {
  //   for (int j = 0; j < 2; j++) {
  //     cout << dp[i][j] << " ";
  //   }
  //   cout << endl;
  // }

  cout << max(dp[MAX_DIGIT][0], dp[MAX_DIGIT][1]);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:3: error: 'memset' was not declared in this scope
   28 |   memset(dp, -1, sizeof(dp));
      |   ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <vector>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int S = 60;
int dp[S + 10][2];

signed main(){

    int n, k; cin >> n >> k;
    vector<int> info(S);

    for(int i = 0; i < n; i++){
        int val; cin >> val;
        for(int j = 0; j < S; j++){
            if((1LL << j) & val) info[j]++;
        }
    }

    reverse(info.begin(), info.end());

    //string s = "";
    for(int i = 0; i < S; i++){
        if(k & (1LL << i)) s = "1" + s;
        else s = "0" + s;
    }

    fill(dp[0], dp[S + 1], -1);
    dp[0][0] = 0;
    cout << s << endl;
    for(int i = 0; i < S; i++){
        for(int f = 0; f < 2; f++){
            if(dp[i][f] == -1) continue;

            int lim = f ? 1 : s[i] - '0';
            //cout << lim << endl;
            for(int x = 0; x <= lim; x++){
                int val = (1LL << (S - i - 1));
                int add = (x == 0 ? info[i] : n - info[i]) * val;
                int nf = f || x < lim;
                dp[i + 1][nf] = max(dp[i + 1][nf], dp[i][f] + add);
                //cout << "dp[" << i + 1 << "][" << nf << "] = " << dp[i + 1][nf] << endl;
            }
        }
    }

    cout << max(dp[S][0], dp[S][1]) << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:28: error: 's' was not declared in this scope
   23 |         if(k & (1LL << i)) s = "1" + s;
      |                            ^
a.cc:24:14: error: 's' was not declared in this scope
   24 |         else s = "0" + s;
      |              ^
a.cc:29:13: error: 's' was not declared in this scope
   29 |     cout << s << endl;
      |             ^
Language: C++

#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

ll dp[50][2];
ll N;
ll K;
ll bit_max = 0;
vector<ll> A;
vector<ll> one_num;

ll func(ll target_idx, ll cur_max, bool tight)
{
	if (target_idx == -1)
	{
		return cur_max;
	}

	ll cor_val = (K & (1LL << target_idx)) ? 1 : 0;
	ll one_cnt = one_num[target_idx];

	bool next_tight = false;
	ll add_val = 0;
	ll next_target_idx = target_idx - 1;

	if (tight)
	{
		if (cor_val == 0)
		{
			// sould be zero
			next_tight = true;
			add_val = one_cnt * (1LL << target_idx);

			return func(next_target_idx, cur_max + add_val, true);

		}
		else
		{
			// if select 1
			add_val = one_cnt * (1LL << target_idx);
			ll one_case = func(next_target_idx, cur_max + add_val, true);

			// if select 0
			add_val = (N-one_cnt) * (1LL << target_idx);
			ll zero_case = func(next_target_idx, cur_max + add_val, false);

			return max(one_case, zero_case);
		}
	}
	else
	{
		// if select 1
		add_val = one_cnt * (1LL << target_idx);
		ll one_case = func(next_target_idx, cur_max + add_val, false);

		// if select 0
		add_val = (N - one_cnt) * (1LL << target_idx);
		ll zero_case = func(next_target_idx, cur_max + add_val, false);

		return max(one_case, zero_case);
	}
}


int main()
{
	memset(dp, -1, sizeof(dp));

	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> K;

	if (K != 0)
	{
		bit_max = max(bit_max, (ll)ceil(log2(K)));
	}

	A = vector<ll>(N);
	for (ll i = 0; i < N; ++i)
	{
		cin >> A[i];
		bit_max = max(bit_max, (ll)ceil(log2(A[i])));
	}
	bit_max -= 1;
	
	for (ll bit = 0; bit <= bit_max; ++bit)
	{
		ll one_cnt = 0;
		for (ll i = 0; i < N; ++i)
		{
			if (A[i] & (1LL << bit))
			{
				one_cnt++;
			}
		}

		one_num.push_back(one_cnt);
	}

	cout << func(bit_max, 0, true) << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:84:9: error: 'memset' was not declared in this scope
   84 |         memset(dp, -1, sizeof(dp));
      |         ^~~~~~
a.cc:14:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   13 | #include <cmath>
  +++ |+#include <cstring>
   14 |
Language: C++

#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<bitset>
using namespace std;

int main(void)
{
	long long N, K;
	cin >> N >> K;

	vector<long long> A(N);
	for(int i=0; i<N; i++)
		cin >> A[i];

	const int length = 50;
	vector<long long> cnt(length, 0);
	for(int i=0; i<N; i++){
		bitset<length> bit(A[i]);
		for(int j=0; j<length; j++)
			cnt[j] += bit[j];
	}

	reverse(cnt.begin(), cnt.end());

	long long ans = 0;
	long long k = 0;
	for(int i=0; i<length; i++){
		bool bit;
		int count;
		if(cnt[i] > N-cnt[i]){
			bit = 0;
			count = cnt[i];
		}
		else{
			bit = 1;
			count = N - cnt[i];
		}
		int shift = length - i - 1;
		long long n = (long long)bit << shift;
		long long value = (long long)1 << shift;
		if(k+n <= K)
			k += n;
		else
			count = N - count;

		ans += value * count;
	}

	cout << ans << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:9: error: 'reverse' was not declared in this scope
   25 |         reverse(cnt.begin(), cnt.end());
      |         ^~~~~~~
Language: Java

import java.math.BigInteger;
import java.util.Scanner;

public class Main1 {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long K = sc.nextLong();
        long[] A = new long[N];
        for(int i = 0; i < N; i++) {
            A[i] = sc.nextLong();
        }
        System.out.println(findMaximumValue(A, K));
    }

    static long findMaximumValue(long x[], long k) {
        long max = x[0];
        long check = 0;
        int start = 0;
        while (start < k) {
            for (int i = 0; i < x.length; i++) {
                check = check + ((x[i] | start) & (~x[i] | ~start));

            }
            start++;
            if (check > max) {
                max = check;
            }
            check = 0;
        }
        return max;
    }

}


Compiler output:
Main.java:4: error: class Main1 is public, should be declared in a file named Main1.java
public class Main1 {
       ^
1 error
Language: Java

import java.math.BigInteger;
import java.util.Scanner;

public class Main1 {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        long n = sc.nextInt();
        long k = sc.nextLong();

        long[] numbers = new long[(int)k];

        for (int i = 0; i < numbers.length; i++)
        {
            numbers[i] = sc.nextLong();
        }
        sc.close();
        System.out.println(findMaximumValue(numbers, k));
    }

    static long findMaximumValue(long x[], long k) {
        long max = x[0];
        long check = 0;
        int start = 0;
        while (start < k) {
            for (int i = 0; i < x.length; i++) {
                check = check + ((x[i] | start) & (~x[i] | ~start));

            }
            start++;
            if (check > max) {
                max = check;
            }
            check = 0;
        }
        return max;
    }

}


Compiler output:
Main.java:4: error: class Main1 is public, should be declared in a file named Main1.java
public class Main1 {
       ^
1 error
Language: Java

import java.math.BigInteger;
import java.util.Scanner;

public class Main1 {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // get a integer
        int a = sc.nextInt();
        // get two integers separated with half-width break
        int b = sc.nextInt();

        Scanner input = new Scanner(System.in);
        BigInteger[] numbers = new BigInteger[a];

        for (int i = 0; i < numbers.length; i++)
        {
            numbers[i] = input.nextBigInteger();
        }
        input.close();
        System.out.println(findMaximumValue(numbers, b));
    }

    static BigInteger findMaximumValue(BigInteger x[], int k) {
        BigInteger max = x[0];
        BigInteger check = BigInteger.valueOf(0);
        int start = 0;
        while (start < k) {
            for (int i = 0; i < x.length; i++) {
                check = check.add(BigInteger.valueOf((x[i].intValue() | start) & (~x[i].intValue() | ~start)));

            }
            start++;
            if (check.compareTo(max) > 0) {
                max = check;
            }
            check = BigInteger.ZERO;
        }
        return max;
    }

}

Compiler output:
Main.java:4: error: class Main1 is public, should be declared in a file named Main1.java
public class Main1 {
       ^
1 error
Language: Java

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // get a integer
        int a = sc.nextInt();
        // get two integers separated with half-width break
        int b = sc.nextInt();

        Scanner input = new Scanner(System.in);
        int[] numbers = new int[a];

        for (int i = 0; i < numbers.length; i++)
        {
            System.out.println("Please enter number");
            numbers[i] = input.nextInt();
        }
        System.out.println(findMaximumValue(numbers, b));
    }

    static int findMaximumValue(int x[], int k) {
        int max = 0;
        int check = 0;
        int start = 0;
        while (start < k) {
            for (int i = 0; i < x.length; i++) {
                check = check + ((x[i] | start) & (~x[i] | ~start));

            }
            start++;
            if (check >= max) {
                max = check;
            }
            check = 0;
        }
        return max;
    }

}

Compiler output:
Main.java:4: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:4: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
                         ^
  symbol:   class Scanner
  location: class Main
Main.java:10: error: cannot find symbol
        Scanner input = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:10: error: cannot find symbol
        Scanner input = new Scanner(System.in);
                            ^
  symbol:   class Scanner
  location: class Main
4 errors
Language: Java



    public static void main(String[] args) {
        int[] x = {1, 6, 3};
        System.out.println(findMaximumValue(x, 7));
    }

    static int findMaximumValue(int x[], int k) {
        int max = 0;
        int check = 0;
        int start = 0;
        while (start < k) {
            for (int i = 0; i < x.length; i++) {
                check = check + ((x[i] | start) & (~x[i] | ~start));

            }
            start++;
            if (check >= max) {
                max = check;
            }
            check = 0;
        }
        return max;
    }




Compiler output:
Main.java:3: error: unnamed classes are a preview feature and are disabled by default.
    public static void main(String[] args) {
                  ^
  (use --enable-preview to enable unnamed classes)
1 error
Language: Java

public class Test2 {

    public static void main(String[] args) {
        int[] x = {1, 6, 3};
        System.out.println(findMaximumValue(x, 7));
    }

    static int findMaximumValue(int x[], int k) {
        int max = 0;
        int check = 0;
        int start = 0;
        while (start < k) {
            for (int i = 0; i < x.length; i++) {
                check = check + ((x[i] | start) & (~x[i] | ~start));

            }
            start++;
            if (check >= max) {
                max = check;
            }
            check = 0;
        }
        return max;
    }

}


Compiler output:
Main.java:1: error: class Test2 is public, should be declared in a file named Test2.java
public class Test2 {
       ^
1 error
Language: C++

#include <bits/stdc++.h>
using namespace std;
using int64 = int64_t;
#define int int64

// dp[i][j] := ibit目まで見てそこまでの値がk未満で(0:ない, 1:ある)時の最大値
int dp[60][2];

signed main(){
  int n,k;
  cin >> n >> k;
  vector< int > a(n);
  for(int i=0; i<n; ++i) cin >> a[i];
  memset(dp, -1, sizeof(dp));

  dp[45][0] = 0;
  for(int bi=44; bi>=0; --bi){
    int on_bit_num = 0;
    for(int ai=0; ai<n; ++ai){
      if((a[ai] >> bi) & 1) ++on_bit_num;
    }

    int digit = (1LL << bi);
    if(dp[bi+1][1] >= 0){
      dp[i][1] = max(dp[i][1], dp[i+1][1] + digit * max(on_bit_num, n-on_bit_num));
    }     
    if(dp[bi+1][1] >= 0){
      if (k & (1<<i)){
        dp[i][1] = max(dp[i][1], dp[i+1][0] + digit * on_bit_num);
        dp[i][0] = max(dp[i][0], dp[i+1][0] + digit * (n-on_bit_num));
      } else {
        dp[i][0] = max(dp[i][0], dp[i+1][0] + digit * on_bit_num);
      }     
    }
  }

  int ans = max(dp[0][0], dp[0][1]);
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:10: error: 'i' was not declared in this scope; did you mean 'bi'?
   25 |       dp[i][1] = max(dp[i][1], dp[i+1][1] + digit * max(on_bit_num, n-on_bit_num));
      |          ^
      |          bi
a.cc:28:19: error: 'i' was not declared in this scope; did you mean 'bi'?
   28 |       if (k & (1<<i)){
      |                   ^
      |                   bi
Language: C++

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vv = vector<vector<ll>>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end());
#define MIN(vec) *std::min_element(vec.begin(), vec.end());
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define REV(T) greater<T>()

typedef pair<ll, ll> Pair;
bool pairCompare(const Pair &firstElof, const Pair &secondElof) {
  return firstElof.second > secondElof.second;
}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

ll factorial(int n) {
  ll ans = 1;
  for (int i = 2; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll P(int n, int m) {
  ll ans = 1;
  for (int i = m + 1; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll power(int n, int m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = power(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * power(n, m - 1)) % MOD;
  }
}
ll C(int n, int m) {
  return (P(n, n - m) * power(factorial(m), MOD - 2)) % MOD;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ll N, K;
  ll A = 0, B = 0;
  cin >> N >> K;
  ll one[50];
  REP(i, 50) { one[i] = 0; }
  REP(i, N) {
    ll a;
    cin >> a;
    REP(i, 50) {
      if (a >= (1 << i) && (a >> i) & 1)
        one[i]++;
    }
  }
  ll ans = 0;
  ll mans = 0;
  for (ll j = K != 0 ? (ll)log2(K) + 1 : 0; j >= 0; j--) {
    ans = 0;
    for (ll i = 0; i < 50; i++) {
      if (i < j) {
        if (one[i] > N - one[i]) {
          ans += ((ll)1 << i) * one[i];
        } else {
          ans += ((ll)1 << i) * (N - one[i]);
        }
      } else if (i > j) {
        if ((K >> i) & 1) {
          ans += ((ll)1 << i) * (N - one[i]);
        } else {
          ans += ((ll)1 << i) * one[i];
        }
      } else {
        if ((K >> i) & 1)
          ans += ((ll)1 << i) * one[i];
        else
          ans = -INF;
      }
    }
    mans = max(ans, mans);
  }

  cout << mans << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:132:18: error: 'INF' was not declared in this scope; did you mean 'iINF'?
  132 |           ans = -INF;
      |                  ^~~
      |                  iINF
Language: C++

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

vector<ll> Kbin(55, 0);
vector<ll> num_one(55, 0);
ll dp[55][2];
ll N, K;

ll rec(ll k, bool tight){
	if(k==-1) return 0;
	if(dp[k][tight]>=0) return dp[k][tight];

	ll x = Kbin[k];
	ll r = (tight?x:1);

	ll res = -1;

	if(r==0){
		res = max(res, rec(k-1, tight) + (num_one[k])*(1ll<<k));	
	}else{
		res = max(res , rec(k-1, false) + (num_one[k])*(1ll<<k));
		res = max(res , rec(k-1, tight) + (N-num_one[k])*(1ll<<k));
	}

	dp[k][tight] = res;
	return res;
}

int main(){
	cin >> N >> K;
	vector<ll> A(N);
	REP(i, N) cin >> A[i];

	REP(i, 50){
		Kbin[i] = (K>>i&1);
		REP(j, N){
			num_one[i] += (A[j]>>i&1);
		}
	}

	REP(i, 55)REP(j, 2) dp[i][j] = -1;v

	cout << rec(50, true) << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:61:43: error: 'v' was not declared in this scope
   61 |         REP(i, 55)REP(j, 2) dp[i][j] = -1;v
      |                                           ^
Language: C

#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <vector>
#define   FOR(i,n) for(int i=0;i<n;i++)

using namespace std;
int int_sort(const void*a,const void *b) {
    return *(  int *) b - *(int *) a;
    //qsort(b, a, sizeof(long long int), int_sort);
}

int main() {
    int count=0,N,x[50]={},tmp;
    long k,test=1,out=0,a;
    vector<long> A;


    cin >> N>>k;
    vector< vector<long> > data(N,vector<long>(43,0));
    while(k>test){
        test*=2;
        count+=1;
    }//count-1桁目まで調べる．
    count-=1;
    FOR(i, N) {///ニシン変換

        cin >> tmp;
        A.push_back(tmp);
        a = A[i];
        int  q=0;
        while(a>0) {

            data[i][q] = a % 2;
            a = a / 2;
            q++;
        }
        for(int m=q;m<=42;m++)
               data[i][m] =0;
    }
/*
    FOR(p, N) {//確認
        FOR(i, 43) {
            cout<<data[p][i];
        }
        puts("");
    }
*/
    //////flag 多数決
    for (int i = count; i >= 0; i--) {
        int flag = 0;
        for(int p=0;p<N;p++)
            flag += data[p][i];
        if(flag<=N/2){
            x[i]=1;
            k-=long(pow(2,i));
        }
        else {
            x[i] = 0;
        }
    }

        //cout<<count;

    //puts("");


    for(int p=0;p<N;p++){
        for(int i=10;i>=0;i--){
            if(i>count){
                out+=(2^i)*data[p][i];
                //cout<<(2^i)*data[p][i]<<" ";
            }
            else {//i==2から
                if(x[i]+data[p][i]==1)
                    out+=long(pow(2,i));
                //cout<<long(pow(2,i))<<" ";
            }
        }
        //puts("");
    }


    cout<<out;
    return 0;
}







Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include "bits/stdc++.h"
using namespace std;

int main()
{
	double N, K, sum = 0;
	double f = 0, a;
	cin >> N >> K;
	vector<int> A(N);

	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	for (int i = 0; i < N; i++) {

		a = A[i] ^ K;
		if (a > K) {
			continue;
		}
		f = 0;
		for (int j = 0;j < N;j++) {
			f += a ^ A[j];
		}
		if (sum < f) {
			sum = f;
		}
	}

	cout << sum;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:26: error: invalid operands of types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'double' to binary 'operator^'
   17 |                 a = A[i] ^ K;
a.cc:23:32: error: invalid operands of types 'double' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to binary 'operator^'
   23 |                         f += a ^ A[j];
Language: C++

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(void){
	int n,i,j,c;
	ll k,a[100000],x,sub_k=0,s=0,tmp=0;
	cin >> n >> k; ++k;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	for(j=0; j<40; ++j){
		c = 0;
		for(i=0; i<n; ++i){
			if(a[i]&(1ll<<j)){
				++c;
			}
		}
		if(c*2<n){
			s += (1ll<<j);
		}
	}
	for(j=0; j<40; ++j){
		tmp = 0;
		if(!(k&(1ll<<j))){
			continue;
		}
		x = (k/(1ll<<(j+1)))*(1ll<<(j+1))+s%(1ll<<j);
		for(i=0; i<n; ++i){
			tmp += (a[i]^x);
		}
		sub_k = max(sub_k,tmp);
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   34 |         cout << ans << endl;
      |                 ^~~
      |                 abs
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <gmpxx.h> 


using namespace::std;


int get_X(vector<int> X, vector<mpz_class> A, int N, int K_bit) {

	vector<int> C(K_bit);

	int N_half = 0.5 * N;
	
	for (int k = 0; k < K_bit; k++) {
		for (int n = 0; n < N; n++) {
			if (A[n] % 2 == 1) {
				C[k] += 1;
			}
			A[n] = (int) A[n] * 0.5;
//			cout << A[n];
		}
//		cout << endl;
//		cout << "Ck = " << C[k] << endl;

		if (C[k] <= N_half) {
			X[k] = 1;
		}
		else X[k] = 0;

	}

	int x = 0;
	int multi = 1;
	for (int k = 0; k < K_bit; k++) {
		x += X[k] * multi;
		multi *= 2;
	}

//	cout << "x = " << x << endl;
	return x;

}


int main()
{
	int max_bit = 40;

	double K = 10;
	int N;
	long sum = 0;

	cin >> N;
	//cin >> K;
	
	cout << N << endl;
	int K_bit = (int)(log2(K) + 1);

//	cout << "K_bit = " << K_bit << endl;

	vector<mpz_class> A(N);
	vector<mpz_class> B(N);
	

	for (int i = 0; i < N; i++) {
		cin >> A[i];
		B[i] = A[i];
	}

	vector<int> X(K_bit);

	int x = get_X(X, B, N, K_bit);

	for (int i = 0; i < N; i++) {
		sum += x ^ A[i];
	}

	cout << sum << endl;
	
	return 0;
}



Compiler output:
a.cc: In function 'int get_X(std::vector<int>, std::vector<__gmp_expr<__mpz_struct [1], __mpz_struct [1]> >, int, int)':
a.cc:22:32: error: invalid cast from type '__gnu_cxx::__alloc_traits<std::allocator<__gmp_expr<__mpz_struct [1], __mpz_struct [1]> >, __gmp_expr<__mpz_struct [1], __mpz_struct [1]> >::value_type' {aka 'std::allocator_traits<std::allocator<__gmp_expr<__mpz_struct [1], __mpz_struct [1]> > >::value_type'} to type 'int'
   22 |                         A[n] = (int) A[n] * 0.5;
a.cc: In function 'int main()':
a.cc:78:21: error: no match for 'operator+=' (operand types are 'long int' and '__gmp_expr<__mpz_struct [1], __gmp_binary_expr<long int, __gmp_expr<__mpz_struct [1], __mpz_struct [1]>, __gmp_binary_xor> >')
   78 |                 sum += x ^ A[i];
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>

using namespace std;

int main(){
  unsigned long long n,k,a[100001],cnt=0;
  unsigned long long  x = 0, max=0;
  cin >> n >> k;

  for(int i=0; i < n;i++){
    cin >> a[i];
  }

  for(int i=41; i>=0;i--){
    cnt=0;
    for(int j=0; j < n; j++){
      if((1<<i)&a[j])
        cnt++;
    }
    if((n-cnt>cnt)&&((1<<i)+ans<=k)){
      x|=(1<<i);
    }
  }

  for(int i=0; i<n;i++){
    max+=x^a[i];
  }
  cout << max << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:29: error: 'ans' was not declared in this scope; did you mean 'abs'?
   29 |     if((n-cnt>cnt)&&((1<<i)+ans<=k)){
      |                             ^~~
      |                             abs
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>

using namespace::std;


int get_X(vector<int> X, vector<int> A, int N, int K_bit) {

	vector<int> C(K_bit);

	int N_half = 0.5 * N;
	
	for (int k = 0; k < K_bit; k++) {
		for (int n = 0; n < N; n++) {
			if (A[n] % 2 == 1) {
				C[k] += 1;
			}
			A[n] = (int) A[n] * 0.5;
//			cout << A[n];
		}
//		cout << endl;
//		cout << "Ck = " << C[k] << endl;

		if (C[k] <= N_half) {
			X[k] = 1;
		}
		else X[k] = 0;

	}

	int x = 0;
	int multi = 1;
	for (int k = 0; k < K_bit; k++) {
		x += X[k] * multi;
		multi *= 2;
	}

//	cout << "x = " << x << endl;
	return x;

}


int main()
{
	int max_bit = 40;

	int K;
	int N;
	int sum = 0;

	cin >> N;
	cin >> K;
	
	int K_bit = (int)(log2(K) + 1);

//	cout << "K_bit = " << K_bit << endl;

	vector<int> A(N);
	vector<int> B(N);


	for (int i = 0; i < N; i++) {
		cin >> A[i];
		B[i] = A[i];
	}

	vector<int> X(K_bit);

	int x = get_X(X, B, N, K_bit);

	for (int i = 0; i < N; i++) {
		sum += x ^ A[i];
	}

	cout << sum << endl;
	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:56:27: error: 'log2' was not declared in this scope
   56 |         int K_bit = (int)(log2(K) + 1);
      |                           ^~~~
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
long long int n, k;
long long int a[100000];
int a2[100000][50];
long long int a3[50];
long long int pow(long long int p, int e){
	long long int ans = 1;
	for(long long int i = 0;i < e;i++){
		ans *= p;
	}
	return ans;
}
long long int keta(int w){
	int count = 0;
	while(w){
		w = w / 2;
		count++;
	}
	return count;
}
long long int solve(long long int m, long long int k2){
	long long int k3 = keta(k2) - 1;
	if(m == 0){
		if(k2){
			return max(a3[0], n - a3[0]);
		}else{
			return a3[0];
		}
	}
	if(m > k3){
		return solve(m - 1, k2) + pow(2, m) * a3[m];
	}
	if(a3[m] >= n - a3[m]){
		return solve(m - 1, pow(2, m) - 1) + pow(2, m) * a3[m];
	}
	return max((solve(m - 1, k2 - pow(2, m)) + pow(2, m) * (n - a3[m])), solve(m - 1, pow(2, m) - 1) + pow(2, m) * a3[m]);
}
int main(){
	long long int amax = 0;
	cin >> n >> k;
	for(long long int i = 0;i < n;i++){
		cin >> a[i];
		amax = max(a[i], amax);
	}
	for(int i = 0;i < 50:i++){
		a3[i] = 0;
	}
	long long int count = 0;
	while(amax){
		amax = amax / 2;
		count++;
	}
	long long int count4 = keta(k) - 1;
	if(count4 == -1){
		cout << 0 << endl;
	}
	int count2 = 0;
	for(long long int i = 0;i < count;i++){
		for(long long int j = 0;j < n;j++){
			if((a[j] >> i) % 2){
				//a2[j][i] = 1;
				a3[i]++;
			}//else{
				//a2[j][i] = 0;
			//}
		}
	}
	cout << solve(count4, k) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:23: warning: range-based 'for' loops with initializer only available with '-std=c++20' or '-std=gnu++20' [-Wc++20-extensions]
   47 |         for(int i = 0;i < 50:i++){
      |                       ^
a.cc:47:29: error: expected ';' before ':' token
   47 |         for(int i = 0;i < 50:i++){
      |                             ^
      |                             ;
a.cc:51:9: error: expected primary-expression before 'while'
   51 |         while(amax){
      |         ^~~~~
a.cc:50:33: error: expected ')' before 'while'
   50 |         long long int count = 0;
      |                                 ^
      |                                 )
   51 |         while(amax){
      |         ~~~~~                    
a.cc:47:12: note: to match this '('
   47 |         for(int i = 0;i < 50:i++){
      |            ^
a.cc:60:35: error: invalid operands of types 'long long int' and '<unresolved overloaded function type>' to binary 'operator<'
   60 |         for(long long int i = 0;i < count;i++){
      |                                 ~~^~~~~~~
Language: C++

n,k = map(int,input().split())
a = list(map(int,input().split()))

cnt = [0 for _ in range(40)]
for ak in a:
    i = 0
    while(ak>0):
        cnt[i] = cnt[i] + ak%2
        ak //= 2
        i += 1

q = []
f = 0
for i in range(40):
    f += 2**i * cnt[i]
    if(cnt[i]*2 < n):
        q.append([2**i, 2**i*(n - 2*cnt[i]) ])

def rec(i,j):
    if(i==0):
        return f
    else:
        if(q[i-1][0] <= k):
            return max( rec(i-1,k), q[i-1][1]+rec(i-1,k-q[i-1][0]) )
        else:
            return rec(i-1,k)    

print(rec(len(q)-1,k))

# print(cnt, q, f)

Compiler output:
a.cc:30:3: error: invalid preprocessing directive #print
   30 | # print(cnt, q, f)
      |   ^~~~~
a.cc:1:1: error: 'n' does not name a type
    1 | n,k = map(int,input().split())
      | ^
Language: C++

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	long long N, K;

	cin >> N >> K;

	int d = 0;
	for(long long x = K; x>0; x/=2){
		d++;
	}

	long long c[d], A[N];
	memset(c, 0, sizeof(long long)*d);
	for(long long ll = 0; ll < N; ll++){
		cin >> A[ll];
		for(long long i = 0; i<d; i++){
			if((A[ll] & 1ll << i) != 0){
				c[i]++;
			}
		}
	 }

	long long X = 0;
	for(int i = d-1; i>=0; i--){
		if((c[i] < (N+1)/2) && ((X|1ll<<i) <= K)){
			X |= (1ll<<i);
		}
	}

	long long ans = 0;
	for(long long ll = 0; ll < N; ll++){
		ans += X ^ A[ll];
	}

	cout << ans << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:9: error: 'memset' was not declared in this scope
   38 |         memset(c, 0, sizeof(long long)*d);
      |         ^~~~~~
a.cc:19:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   18 | #include <utility>
  +++ |+#include <cstring>
   19 | #include <vector>
Language: C++

#include<bits/stdc++.h>
using namespace std;

int main(){
  long long n,k,a[1000000],x=-1,maxi=-1000,v,z=0;
  cin >> n >> k;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]%2==1){
      z++;
    }
  }
  
  for(long long i=1;i<k+1;i+=pow(2,x)){
    v=0;
    for(int j=0;j<n;j++){
      v+=(i^a[j]);
    }
    if(maxi<v){
      maxi=v;
    }
    x++;
  }
x=-1;
  
  for(long long i=1;i<k+1;i+=pow(2,x)){
    v=0;
    for(int j=0;j<n;j++){
      v+=(i^a[j]);
    }
    if(maxi<v){
      maxi=v;
    }
    x++;
    if(i=2){
      i--;
    }
  }
  v=0;
  for(int i=0;i<n;i++){
    v+=(0^a[i]);
  }
 if(maxi<v){
   maxi=v;
 } 
v=0;
 for(int i=0;i<n;i++){
    v+=(m^a[i]);
  }
 if(maxi<v){
   maxi=v;
 }

  
  cout << maxi << endl;
  
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:48:9: error: 'm' was not declared in this scope
   48 |     v+=(m^a[i]);
      |         ^
Language: C++

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	long long N, K;

	cin >> N >> K;

	int d = 0;
	for(long long x = K; x>0; x/=2){
		d++;
	}

	long long c[d], A[N];
	memset(c, 0, sizeof(c));
	for(long long ll = 0; ll < N; ll++){
		cin >> A[ll];
		for(long long i = 0; i<d; i++){
			if((A[ll] & 1ll << i) != 0){
				c[i]++;
			}
		}
	 }

	long long X = 0;
	for(int i = d-1; i>=0; i--){
		if((c[i] < (N+1)/2) && ((X|1ll<<i) <= K)){
			X |= (1ll<<i);
		}
	}

	long long ans = 0;
	for(long long ll = 0; ll < N; ll++){
		ans += X ^ A[ll];
	}

	cout << ans << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:9: error: 'memset' was not declared in this scope
   38 |         memset(c, 0, sizeof(c));
      |         ^~~~~~
a.cc:19:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   18 | #include <utility>
  +++ |+#include <cstring>
   19 | #include <vector>
Language: C++

#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int  ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
LL mod = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(n); sll(k);
	LL arr[n], count[40];
	rep(i, 0, n) {
		arr[i] = scanLong();
		rep(j, 40, 0)
			if(arr[i] & (1LL << j))	count[j]++;
	}

	LL x = 0;

	rep(i, 40, 0) {
		if(x + (1LL << i) <= k && 2*count[j] < n)
			x += (1LL << i);
	}

	LL ans = 0;
	rep(i, 0, n)	ans += (x^arr[i]);
	pll(ans); nl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:71:51: error: 'j' was not declared in this scope
   71 |                 if(x + (1LL << i) <= k && 2*count[j] < n)
      |                                                   ^
Language: C++

#include<bits/stdc++.h>
using namespace std;

int main(){
  long long n,k,a[1000000],x=-1,maxi=-1000,v,z=0;
  cin >> n >> k;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]%2==1){
      z++;
    }
  }
  
  for(long long i=1;i<k+1;i+=pow(2,x)){
    v=0;
    for(int j=0;j<n;j++){
      v+=(i^a[j]);
    }
    if(maxi<v){
      maxi=v;
    }
    x++;
  }
x=-1;
  
  for(long long i=1;i<k+1;i+=pow(2,x)){
    v=0;
    for(int j=0;j<n;j++){
      v+=(i^a[j]);
    }
    if(maxi<v){
      maxi=v;
    }
    x++;
    if(i=2){
      i--;
    }
  }
  v=0;
  for(int i=0;i<n;i++){
    v+=(0^a[i]);
  }
 if(maxi<v){
   maxi=v;
 } 
 for(int i=0;
i<n;i++){
    v+=(m^a[i]);
  }
 if(maxi<v){
   maxi=v;
 }

  
  cout << maxi << endl;
  
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:48:9: error: 'm' was not declared in this scope
   48 |     v+=(m^a[i]);
      |         ^
Language: C

#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <string>

using namespace std;
using ll = long long;
using ull = size_t;

ll N, K;
vector<ll> A;

void input() {
    cin >> N >> K;
    A.resize(N);
    for (auto& a : A) cin >> a;
    //    N = 3, K = 7;
    //    A = {1, 6, 3};
}

void solve() {
    ll x = 0;
    for (ll n = 39; n >= 0; n--) {
        ll bitcnt = 0;
        for (auto a : A)
            if (a >> n & 1)
                bitcnt++;
        if (bitcnt < (N+1)/2) {
            if ((x ^ (1ull << n)) <= K) {
                x ^= 1ull << n;
            }
        }
    }
    ll ans = 0;
    for (auto a : A)
        ans += x ^ a;
    cout << ans << endl;
}

int main() {
    input();
    
    solve();
    
    return 0;
}



Compiler output:
main.c:1:10: fatal error: cstdio: No such file or directory
    1 | #include <cstdio>
      |          ^~~~~~~~
compilation terminated.
Language: C++

import numpy as np

def binary_array(x, max_len):
    x = bin(x)[2:]
    x = '0' * (max_len - len(x)) + x
    return [int(a) for a in list(x)]

def main():
    n, k = (int(x) for x in input().split())
    a = [int(x) for x in input().split()]
    if k==0:
        print(sum(a))
        return
    
    max_len = max(len(bin(max(a))), len(bin(k))) - 2
    A = [binary_array(aa, max_len) for aa in a]
    A = np.array(A)
    k_array = np.array(binary_array(k, max_len))

    s = []
    K = 0
    for i in range(len(k_array)):
        K += 2**(max_len-1-i)
        if K<=k:
            tmp = np.sum(A[:,i])
            s.append(max(tmp, n-tmp))
        else:
            s.append(np.sum(A[:,i]))
            K -= 2**(max_len-1-i)
        

    ans = 0
    for i,ss in enumerate(s):
        ans += 2**(max_len-1-i) * ss
    print(ans)



if __name__=='__main__':
    main()

Compiler output:
a.cc:39:14: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   39 | if __name__=='__main__':
      |              ^~~~~~~~~~
a.cc:1:1: error: 'import' does not name a type
    1 | import numpy as np
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'