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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

vector<ll> num;

struct Nbase {
    int n;
    int sz = 1;
    long long max = 1e18;

    Nbase(int k = 2){
        n = k;
        while(max != 0){
            max /= n;
            sz++;
        }
        num.resize(sz);
    };

    //繰り返し二乗法
    ll EX(ll x,ll n){
        if(n == 0) return 1;
        else if(n%2 == 1) return EX(x,n-1)*x;
        else return EX(x*x,n/2);
    }

    vector<int> to_n(int num){
        vector<int> ret(sz);
        for(int i = sz-1; i >= 0; i--){
            long long subtraction = EX(n,i);
            if(subtraction <= num){
                for(int j = 1; j <= n; j++){
                    if(num < j*subtraction){
                        ret[i] = j-1;
                        num -= ret[i]*subtraction;
                    } 
                }
            } else ret[i] = 0;
        }
        return ret;
    }

    long long re_n(vector<int>& vec){
        long long ret = 0;
        vec.resize(sz);
        for(int i = 0; i < sz; i++){
            ret += vec[i]*EX(n,i);
        }
        return ret;
    }

    void supress(const vector<int>& lim,vector<int>& at){
        bool upper = true;
        for(int i = sz; i >= 0; i--){
            if(upper && lim[i] > 0) upper = false;
            if(lim[i] > at[i]) break;
            else if(upper || lim[i] < at[i]) at[i] = lim[i];
        }
    }
};

int main(){
    Nbase base = 2;
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    /*for(ll i = 0; i < n; i++){
        cin >> a[i];
        vector<int> sam = base.to_n(a[i]);
        for(int j = 0; j < base.sz; j++){
            if(sam[j] == 1) num[j]++;
        }
    }
    vector<int> x(base.sz);
    for(int i = 0; i < n; i++){
        if(num[i] <= n/2) x[i] = 1;
        else x[i] = 0;
    }*/
    vector<int> kd = base.to_n(k);
    base.supress(kd,x);
    int X = base.re_n(x);
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += X^a[i];
    }
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:82:21: error: 'x' was not declared in this scope
   82 |     base.supress(kd,x);
      |                     ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

vector<ll> num;

struct Nbase {
    int n;
    int sz = 1;
    long long max = 1e18;

    Nbase(int k = 2){
        n = k;
        while(max != 0){
            max /= n;
            sz++;
        }
        num.resize(sz);
    };

    //繰り返し二乗法
    ll EX(ll x,ll n){
        if(n == 0) return 1;
        else if(n%2 == 1) return EX(x,n-1)*x;
        else return EX(x*x,n/2);
    }

    vector<int> to_n(int num){
        vector<int> ret(sz);
        for(int i = sz-1; i >= 0; i--){
            long long subtraction = EX(n,i);
            if(subtraction <= num){
                for(int j = 1; j <= n; j++){
                    if(num < j*subtraction){
                        ret[i] = j-1;
                        num -= ret[i]*subtraction;
                    } 
                }
            } else ret[i] = 0;
        }
        return ret;
    }

    long long re_n(vector<int>& vec){
        long long ret = 0;
        vec.resize(sz);
        for(int i = 0; i < sz; i++){
            ret += vec[i]*EX(n,i);
        }
        return ret;
    }

    void supress(const vector<int>& lim,vector<int>& at){
        bool upper = true;
        for(int i = sz; i >= 0; i--){
            if(upper && lim[i] > 0) upper = false;
            if(lim[i] > at[i]) break;
            else if(upper || lim[i] < at[i]) at[i] = lim[i];
        }
    }
};

int main(){
    Nbase base = 2;
    cout << base.n << " " << base.sz << endl;
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        //vector<int> sam = base.to_n(a[i]);
        for(int j = 0; j < base.sz; j++){
            if(sam[j] == 1) num[j]++;
        }
    }
    vector<int> x(base.sz);
    for(int i = 0; i < n; i++){
        if(num[i] <= n/2) x[i] = 1;
        else x[i] = 0;
    }
    vector<int> kd = base.to_n(k);
    base.supress(kd,x);
    int X = base.re_n(x);
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += X^a[i];
    }
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:74:16: error: 'sam' was not declared in this scope
   74 |             if(sam[j] == 1) num[j]++;
      |                ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

vector<ll> num(45,0);

//繰り返し二乗法
ll EX(ll x,ll n){
    if(n == 0) return 1;
    else if(n%2 == 1) return EX(x,n-1)*x;
    else return EX(x*x,n/2);
};

vector<ll> to_k (ll n,ll k){
    vector<ll> memo(45);
    for(ll i = 44; i >= 0; i--){
        ll e = EX(k,i);
        if(e <= n){
            memo[i] = 1;
            n -= e;
        } else memo[i] = 0;
    }
    return memo;
}
vector<ll> x(45);
ll re_k (ll k){
    ll res = 0;
    for(ll i = 0; i < 45; i++){
        res += x[i]*EX(k,i);
    }
    return res;
}

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        vector<ll> vlu = to_k(a[i],2);
        for(ll j = 0; j < 45; j++){
            if(vlu[i]%2 == 1) //num[i]++;
        }
    }
    
    for(ll i = 0; i < 45; i++){
        if(num[i] <= n/2) x[i] = 1;
        else x[i] = 0;
    }
    vector<ll> kd = to_k(k,2);
    for(ll i = 44; i >= 0; i--){
        if(kd[i] == 0) x[i] = 0;
        else break;
    }
    ll hoge = re_k(2);
    ll ans = 0;
    for(ll i = 0; i < n; i++){
        ans += hoge^a[i];
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:9: error: expected primary-expression before '}' token
   44 |         }
      |         ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

vector<ll> num(45,0);

//繰り返し二乗法
ll EX(ll x,ll n){
    if(n == 0) return 1;
    else if(n%2 == 1) return EX(x,n-1)*x;
    else return EX(x*x,n/2);
};

vector<ll> to_k (ll n,ll k){
    vector<ll> memo(45,0);
    for(ll i = 44; i >= 0; i--){
        ll e = EX(k,i);
        if(e <= n){
            memo[i]++;
            n -= e;
        }
    }
    return memo;
}
vector<ll> x(45);
ll re_k (ll k){
    ll res = 0;
    for(ll i = 0; i < 45; i++){
        res += x[i]*EX(k,i);
    }
    return res;
}

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        vector<ll> memo = to_k(a[i],2);
        for(ll j = 0; j < 45; j++){
            if(memo[i]%2 == 1) num[i]++;
        }
    }
    
    for(ll i = 0; i < 45; i++){
        if(num[i] <= n/2) x[i] = 1;
        else x[i] = 0;
    }
    /*vector<ll> kd = to_k(k,2);
    for(ll i = 44; i >= 0; i--){
        if(kd[i] == 0) x[i] = 0;
        else break;
    }
    ll hoge = re_k(2);
    ll ans = 0;
    for(ll i = 0; i < n; i++){
        ans += hoge^a[i];
    }*/
    cout << ans << endl;
    return 0;
}

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

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    long long N, K;
    cin >> N >> K;
    long long k = K;
    vector<long long> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    string s;
    if(K == 0){
        long long ans = 0;
        for(int i = 0; i < N; i++){
            ans += A[i];
        }
        cout << ans << endl;
        return 0;
    }
    while(k > 0){
        int i = k % 2;
        k >>= 1;
        s += '0' + i;
    }
    int size = s.size();
    vector<long long> bi(size, 0);
    for(int i = 0; i < N; i++){
        long long temp = A[i];
        int cnt = 0;
        while(temp > 0){
            if(temp % 2 == 1) bi[cnt]++;
            temp >>= 1;
            cnt++;
        }
    }
    long long t = 0;
    vector<long long> su(size, 1e18);
    for(int i = 0; i < size; i++){
        if(bi[i] < (N + 1) / 2) {
            t += (1LL << i);
            su[i] = (N - bi[i]) * (1LL << i);
        }
    }
    while(t > K){
        int ind = 0;
        long long temp = 1e18 - 1;
        for(int i = 0; i < size; i++){
            if(temp > bi[i]) {
                temp = bi[i];
                ind = i;
                b[i] = 1e18;
            }
        }
        t -= (1LL << ind);
    }
    long long ans = 0;
    for(int i = 0; i < N; i++){
        ans += t^A[i];
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:17: error: 'b' was not declared in this scope
   51 |                 b[i] = 1e18;
      |                 ^
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; }

long long dp[100][2];
const int MAX_DIGIT = 50;


// dp[ i ][ smaller ] := X
// X を上から i 桁目まで決めたとき、それを K
// K の上から i 桁目までと比較したときに、
// smaller = 0 のとき、K とちょうど一致する場合
// smaller = 1 のとき、K よりも小さくなっている場合についての、スコアの最大値

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

    memset(dp, -1, sizeof(dp)); // -1に初期化
    dp[0][0] = 0;
    for(int d= 0; d < MAX_DIGIT; ++d){
        long long mask = 1LL << (MAX_DIGIT - d - 1);

        // A で元々 d 桁目にビットが立っているものの個数
        int num = 0;

        for(int i=0; i < N; ++i){
            if(A[i] & mask ) ++ num;
        }

        // X の d 桁目を 0, 1 にしたときのコスト
        long long cost0 = mask * num;
        long long cost1 = mask * (N - num);

        //smaller --> smaller 
        if(dp[d][1] != -1 ){
            chmax(dp[d+1][1], dp[d][1] + max(cost0, cost1)); // 0でも1でも可能
        }

        //exat --> smaller
        if(dp[d][0] != -1){
            // K の d 桁目が 1 だったら、X の d 桁目は 0 にする
            if(K & mask){
            chmax(dp[d+1][1], dp[d][0] + cost0);                
            }
        }

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:25:5: error: 'memset' was not declared in this scope
   25 |     memset(dp, -1, sizeof(dp)); // -1に初期化
      |     ^~~~~~
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 |
Language: C++

#pragma GCC optimize("O3")
#pragma GCC optimize("O1")
#pragma GCC optimize("O2")
#pragma GCC optimize("Os")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    // #endif
}
int main()
{
    vok();
    int n;
    unsigned ll k;
    IN n>>k;
    vll a(n);
    loop(i,0,n)
    {
        IN a[i];
    }
  	ll haha=0LL;
    rloop(i,49,0)
    {
        int countt=0;
      	ll temp=P(2,i,4e18);
        loop(j,0,n)
        {
            if((temp&b[j])==temp)
            {
                countt++;
            }
        }
        haha+=temp;
        if((countt*2)<n && haha<=k)
        {
            //Do Nothing
        }
        else
        {
            haha-=temp;
        }
    }
    ll fans=0LL;
    loop(i,0,n)
    {
     	ll add=haha^a[i];
      	fans+=add;
        //fans+=((ll)X^a[i]);
    }
    OUT fans<<endl
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:96:22: error: 'b' was not declared in this scope
   96 |             if((temp&b[j])==temp)
      |                      ^
Language: C++

#pragma GCC optimize("O3")
#pragma GCC optimize("O1")
#pragma GCC optimize("O2")
#pragma GCC optimize("Os")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}
int main()
{
    vok();
    ll n,k;
    IN n>>k;
    vll a(n);
    bitset<50> b[n];
    loop(i,0,n)
    {
        IN a[i];
        bitset<50> temp(a[i]);
        b[i]=temp;
    }
    bitset<50> ans(0);
    loop(i,0,50)
    {
        int countt=0;
        loop(j,0,n)
        {
            if(b[j][i])
            {
                countt++;
            }
        }
        ans[i]=1;
        if((countt*2)<n && ans.to_ullong()<=k)
        {
            //Do Nothing
        }
        else
        {
            ans[i]=0;
        }
    }
    ll fans=0LL;
    ll X=ans.to_ullong();
    loop(i,0,n)
    {
        fans+=(X^a[i]);
    }
    OUT fans<<endl
    return 0;
}

Compiler output:
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:8:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::_Vector_base<long long int, std::allocator<long long int> >::_Vector_impl::~_Vector_impl()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = long long int]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:132:14: note: called from here
  132 |       struct _Vector_impl
      |              ^~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

ll pow2(ll b) {ll ret=1;rep(i,b) ret*=2;return ret;}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k,a;cin>>n>>k;
  lvector digit(40,0),take_zero(40,0),max_(40,0),k_(40,0);
  rep(i,n) {
    cin>>a;
    rep(j,40) {
      if((a>>j)&1) digit[j]++;
    }
  }
  rep(i,40) {
    a=pow2(i);
    k_[i]+=((k>>i)&1)?(n-digit[i])*a:digit[i]*a;
    take_zero[i]+=digit[i]*a;
    max_[i]+=max(digit[i],n-digit[i])*a;
  }
  ll ans=accumulate(ALL(k_),0),s,t;
  rep(i,40) {
    if((k>>1)&1) {
      s=accumulate(k_.begin()+i+1,k_.end(),0);
      t=accumulate(max_.begin().max_.begin()+i,0);
      ans=max(ans,s+take_zero[i]+t);
    }
  }
  print(ans);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:33: error: 'std::vector<long long int>::iterator' has no member named 'max_'
   39 |       t=accumulate(max_.begin().max_.begin()+i,0);
      |                                 ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define mp make_pair
#define _GLIBCXX_DEBUG
const int INF=1e15;
template<class T> inline bool chmax(T& A,T b){if(A<B){A=B;return 1;}return 0;}
const int MAX_DIGIT=50;
vector<vector<int>>dp(100,vector<int>(2,-1));

signed main(){
    int N,K;cin>>N>>K;
    int A[N];
    REP(i,N)cin>>A[i];
    dp[0][0]=0;
    REP(d,MAX_DIGIT){
        int mask=1<<(MAX_DIGIT-d-1);
        int num=0;
        for(int i=0;i<N;i++){
            if(A[i]&mask)num++;
        }
        int cost0=mask*num;
        int cost1=mask*(N-num);
        if(dp[d][1]!=-1){
            chmax(dp[d+1][1],dp[d][1]+max(cost0,cost1));
        }
        if(dp[d][0]!=-1){
            if(K&mask){
                chmax(dp[d+1][1],dp[d][0]+cost0);
            }
        }
        if(dp[d][0]!=-1){
            if(K&mask) chmax(dp[d+1][0],dp[d][0]+cost1);
            else chmax(dp[d+1][0],dp[d][0]+cost0);

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


Compiler output:
a.cc: In function 'bool chmax(T&, T)':
a.cc:9:52: error: 'B' was not declared in this scope
    9 | template<class T> inline bool chmax(T& A,T b){if(A<B){A=B;return 1;}return 0;}
      |                                                    ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define mp make_pair
#define _GLIBCXX_DEBUG
const int INF=1e15;
template<class T> inline bool chmax(T& A,T b){if(a<b){a=b;return 1;}return 0;}
const int MAX_DIGIT=50;
vector<vector<int>>dp(100,vector<int>(2,-1));

signed main(){
    int N,K;cin>>N>>K;
    int A[N];
    REP(i,N)cin>>A[i];
    dp[0][0]=0;
    REP(d,MAX_DIGIT){
        int mask=1<<(MAX_DIGIT-d-1);
        int num=0;
        for(int i=0;i<N;i++){
            if(A[i]&mask)num++;
        }
        int cost0=mask*num;
        int cost1=mask*(N-num);
        if(dp[d][1]!=-1){
            chmax(dp[d+1][1],dp[d][1]+max(cost0,cost1));
        }
        if(dp[d][0]!=-1){
            if(K&mask){
                chmax(dp[d+1][1],dp[d][0]+cost0);
            }
        }
        if(dp[d][0]!=-1){
            if(K&mask) chmax(dp[d+1][0],dp[d][0]+cost1);
            else chmax(dp[d+1][0],dp[d][0]+cost0));

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


Compiler output:
a.cc: In function 'bool chmax(T&, T)':
a.cc:9:50: error: 'a' was not declared in this scope
    9 | template<class T> inline bool chmax(T& A,T b){if(a<b){a=b;return 1;}return 0;}
      |                                                  ^
a.cc: In function 'int main()':
a.cc:36:50: error: expected ';' before ')' token
   36 |             else chmax(dp[d+1][0],dp[d][0]+cost0));
      |                                                  ^
      |                                                  ;
Language: C++

#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>

//#define _USE_MATH_DEFINES
#include <math.h>  /* M_PI */



int main(){
    
    int x = 1000000000;
    bitset<1000000> bit1;
    bit1 = x;

    int N,K;
    cin >> N >> K;

    vector<ll> A(N);

    for(int i=0;i < N;i++) cin >> A[i];
    vector<ll> sum(K + 1,0);
    for(int i = 0;i <= K;i++){
        bitset<10000000> bit1 = i;
        for(int j = 0;j < N;j++){
            bitset<10000000> bit2 = A[j];
            sum[i] += (bit1 ^ bit2).to_ullong();       

        }
    
    }
    ll max = 0LL;
    for(int i=0;i <= K;i++){
        if(max < sum[i]) max = sum[i];
    }
    cout << max << endl;
    return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:5: error: 'bitset' was not declared in this scope
   27 |     bitset<1000000> bit1;
      |     ^~~~~~
a.cc:21:1: note: 'std::bitset' is defined in header '<bitset>'; this is probably fixable by adding '#include <bitset>'
   20 | #include <math.h>  /* M_PI */
  +++ |+#include <bitset>
   21 | 
a.cc:27:21: error: 'bit1' was not declared in this scope
   27 |     bitset<1000000> bit1;
      |                     ^~~~
a.cc:40:30: error: 'bit2' was not declared in this scope
   40 |             bitset<10000000> bit2 = A[j];
      |                              ^~~~
Language: C++

#include<bits/stdc++.h>
#define int long long
#define for1(i, n) for(int i = 1; i <= (n);i++)\
#define puts(x) cout << x << endl
using namespace std;
int input() {
	int r;
	scanf("%lld", &r);
	return r;
}
int n, k, a[123456], sum, p = 1099511627776, ans;
signed main() {
	cin >> n >> k; for1(i, n)a[i] = input();
	while (p) {
		if (sum + p <= k) {
			int cnt = 0;
			for1(i, n)cnt += a[i] / p % 2;
			if (cnt < n - cnt)sum += p;
		}
		p /= 2;
	}
	for1(i, n)ans += a[i] ^ sum;
	puts(ans);
}

Compiler output:
a.cc:3:18: error: '#' is not followed by a macro parameter
    3 | #define for1(i, n) for(int i = 1; i <= (n);i++)\
      |                  ^
a.cc: In function 'int main()':
a.cc:13:29: error: 'i' was not declared in this scope
   13 |         cin >> n >> k; for1(i, n)a[i] = input();
      |                             ^
a.cc:13:24: error: 'for1' was not declared in this scope; did you mean 'fork'?
   13 |         cin >> n >> k; for1(i, n)a[i] = input();
      |                        ^~~~
      |                        fork
a.cc:23:14: error: invalid conversion from 'long long int' to 'const char*' [-fpermissive]
   23 |         puts(ans);
      |              ^~~
      |              |
      |              long long int
In file included from /usr/include/c++/14/cstdio:42,
                 from /usr/include/c++/14/ext/string_conversions.h:45,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/stdio.h:714:30: note:   initializing argument 1 of 'int puts(const char*)'
  714 | extern int puts (const char *__s);
      |                  ~~~~~~~~~~~~^~~
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
ll dp[60][2];
int main(){
  memset(dp,-1,sizeof(dp));
  ll n,k;
  cin>>n>>k;
  vll a(n);
  rep(i,n) cin>>a[i];
  
  dp[0][0]=0;
  rep(i,50)rep(j,2){
    if(dp[i][j]==-1) continue;
    ll num=0;
    ll mask=1<<(50-i-1);
    rep(i,n){
      if(a[i]&mask) num++;
    }
    ll cost0=mask*num;
    ll cost1=mask(n-num);
    if(j==0){
      if(k&(1<<i)){
        dp[i+1][0]=max(dp[i+1][0],dp[i][j]+cost1);
        dp[i+1][1]=max(dp[i+1][1],dp[i][j]+cost0);
      }
      else{
        dp[i+1][0]=max(dp[i+1][0],dp[i][j]+cost0);
      }
    }
    if(j==1){
      dp[i+1][j]=dp[i][j]+max(cost1,cost0);
    }
  }
  COUT(max(dp[n][0],dp[n][1]));
}

Compiler output:
a.cc: In function 'int main()':
a.cc:66:18: error: 'mask' cannot be used as a function
   66 |     ll cost1=mask(n-num);
      |              ~~~~^~~~~~~
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll>a(n);
    REP(i,n)cin >> a[i];

    const int MAX_DIGIT = 50;
    ll dp[MAX_DIGIT+1][2];
    memset(dp,-1,sizeof(dp));
    dp[0][0]=0;

    REP(i,MAX_DIGIT){
        ll mask = (ll)1 << (MAX_DIGIT-1-i);
        ll num = 0;
        REP(j,n)if(a[j]&mask)num++;
        ll cost0 = num*mask;
        ll cost1 = (n-num)*mask;

        if(dp[i][1]!=-1){
            chmax(dp[i+1][1],dp[i][1]+max(cost0,cost1));
        }
        if(dp[i][0]!=-1){
            if(mask&k)chmax(dp[i+1][1],dp[i][0]+cost0);
        }
        if(dp[i][0]!=-1){
            if(mask&k)chmax(dp[i+1][0],dp[i][0]+cost1);
            else chmax(dp[i+1][0],dp[i][0]+cost0);
        }
    }
    cout << max(dp[MAX_DIGIT][0],dp[MAX_DIGIT][1]) << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:5: error: 'memset' was not declared in this scope
   25 |     memset(dp,-1,sizeof(dp));
      |     ^~~~~~
a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    7 | #include<queue>
  +++ |+#include <cstring>
    8 | #define REP(i,a) for (int i = 0;i < (a);++i)
Language: C++

#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

struct UnionFind{
    vector<int>par;

    UnionFind(int n) : par(n){
        rep(i,n)par[i] = i;
    }

    int root(int x){
        if(par[x]==x)return x;
        return par[x] = root(par[x]);
    }

    void unite(int x,int y){
        if(root(x)==root(y))return;
        par[root(x)] = root(y);
    }

    bool same(int x,int y){
        return root(x)==root(y);
    }
};


int main(){
   int n;
   ll k;cin>>n>>k;
   vector<ll>a(n);
   ll sum = 0;
   rep(i,n){
       cin>>a[i];
       sum += a[i];
   }
   ll res = 0;
   int bit = 0;
   if(k==0){
       cout<<sum<<endl;
       return 0;
   }
   while(pow(2,bit)=<k){
       ll cnt_1 = 0,cnt_0 = 0;
       rep(i,n){
            if(a[i]&(1<<bit))cnt_1++;
            else cnt_0++;
       }
       if(cnt_1>cnt_0)res += pow(2,bit)*cnt_1;
       else res += pow(2,bit)*cnt_0;
       bit++;
   }
   cout<<res<<endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:77:21: error: expected primary-expression before '<' token
   77 |    while(pow(2,bit)=<k){
      |                     ^
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
 }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,k;
  cin>>n>>k;
  vll a(n);
  rep(i,n) cin>>a[i];
  vvll dp(60,vll(2,-1));
  dp[0][0]=0;
  rep(i,60){
    ll mask=1LL<<(60-i-1);
    ll cu1=0;
    rep(j,n)if(a[i]&mask) cu1++;
    ll cost0=mask*cu1;
    ll cost1=mask*(n-cu1);
    if(dp[i][0]!=-1){
      if(k&mask){
        dp[i+1][0]=max(dp[i+1][0],dp[i][0]+cost1);
      }
      else{
        dp[i+1][0]=max(dp[i+1][0],dp[i][0]+cost0);
      }
    }
    if(dp[i][0]!=-1){
      if(k&mask){
        dp[i+1][1]=max(dp[i+1][1],dp[i][0]+cost1);
      }
    }
    if(dp[i][1]!=-1){
      dp[i+1][1]=max(dp[i+1][1],dp[i][1]+max(cost1,cost));
    }
  }
  COUT(max(dp[59][0],dp[59][1]));
}

Compiler output:
a.cc: In function 'int main()':
a.cc:76:52: error: 'cost' was not declared in this scope; did you mean 'cost1'?
   76 |       dp[i+1][1]=max(dp[i+1][1],dp[i][1]+max(cost1,cost));
      |                                                    ^~~~
      |                                                    cost1
Language: C++

#include <bits/stdc++.h>
typedef long long ll;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define All(x) (x).begin(),(x).end()
using namespace std;

signed main() {
	ll N,K;
	cin >> N >> K;
	vector<ll> A(N);

	vector<ll> bitnum(63, 0);
	for(auto &a : A) {
		cin >> a;
		for(ll j=0;j<63;j++) {
			if(a & (1LL << j)) bitnum[j]++;
		}
	}

	vector<ll> one;
	ll cnt = 0;
	while((cnt < 63) {
		if(K & (1LL << cnt)) {
			one.push_back(cnt); 
		}
		cnt++;
	}

	ll ans = 0;
	// 0で合成したとき
	for(ll i=0;i<N;i++)
		ans += A[i];

	for(ll j=one.size()-1;j>=0;j--) {
		ll tmp_ans = 0;
		ll key = one[j];
		for(ll i=62;i>=key+1;i--) {
			// if(K & (1LL<<i)) { // 1LLとしてLLONG型の整数をbitshiftしないといけない
			if(K & (1LL << i)) {
				tmp_ans += ((1LL<<i) * max(bitnum[i], N - bitnum[i]));
			} else {
				tmp_ans += ((1LL<<i) * bitnum[i]);
			}
		}
		tmp_ans += ((1LL<<key) * bitnum[key]);
		for(ll i=key-1;i>=0;i--) {
			tmp_ans += ((1LL<<i) * max(N - bitnum[i], bitnum[i]));
		}
		ans = max(ans, tmp_ans);
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:25: error: expected ')' before '{' token
   23 |         while((cnt < 63) {
      |              ~          ^~
      |                         )
Language: C++

#include <bits/stdc++.h>

#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

const int MAX_DIGIT = 50;

int main(){
    ll n, k;
    cin >> n >> k;

    vector<ll> a(n);
    rep(i, n)cin >> a[i];

    ll dp[100][2];
    rep(i, 100)dp[i][0] = -1, dp[i][1] = -1;
    dp[0][0] = 0;

    rep(i, MAX_DIGIT){
        //上からi桁目を立てた数値
        ll base = 1LL<<(MAX_DIGIT -1 - i);

        //数列Aの中でi桁目を立てている値の数
        ll cnt = 0;
        rep(j, n)if(a[j]&base)cnt++;

        ll cost0 = base * cnt;//xにおいて桁を立てなかった場合に得られるf(x)の値
        ll cost1 = base * (n-cnt);//xにおいて桁を立てた場合に得られるf(x)の値

        //すでに制約Kよりもxが小さいことが確定している場合、桁を立てるか立てないかは自由
        if(dp[i][1] != -1){
            dp[i+1][1] = max(dp[i+1][1], dp[i][1] + max(cost0, cost1));
        }
        
        //すでに制約Kギリギリの際に、Kのi桁めを下げ、制約よりxを小さくする
        if(dp[i][0] != -1)if(k&base){
            dp[i+1][1] = max(dp[i+1][1], dp[i][0] + cost0);
        
        //制約Kギリギリを攻める
        if(dp[i][0] != -1){
            if(k&base)dp[i+1][0] = max(dp[i+1][0], dp[i][0] + cost1);
            else dp[i+1][0] = max(dp[i+1][0], dp[i][0] + cost0);
        }
    }

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

Compiler output:
a.cc: In function 'int main()':
a.cc:56:2: error: expected '}' at end of input
   56 | }
      |  ^
a.cc:17:11: note: to match this '{'
   17 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
vector <ll> binary(ll bina){
    vector <ll> ans;
    for (ll i = 0; bina>0;i++)
    {
        ans.push_back((bina%2));
        bina = bina/2;
    }
    return ans;
}


int main(){
  ll N,K:
  cin>>N>>K;
  ll a[N];
  for(ll i = 0;i<N;i++){
    cin>>a[i];
  }
  ll b[50] = {0};
  for(ll i = 0;i<N;i++){
    vector <ll> ppp = binary(a[i]);
    for(ll k = 0;k<ppp.size();k++){
      if(ppp[k] == 1){
        b[k]++;
      }
    }
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:18:9: error: found ':' in nested-name-specifier, expected '::'
   18 |   ll N,K:
      |         ^
      |         ::
a.cc:18:8: error: 'K' has not been declared
   18 |   ll N,K:
      |        ^
a.cc:19:6: error: qualified-id in declaration before '>>' token
   19 |   cin>>N>>K;
      |      ^~
a.cc:32:4: error: expected '}' at end of input
   32 |   }
      |    ^
a.cc:17:11: note: to match this '{'
   17 | int main(){
      |           ^
Language: Java

import java.util.*;
import java.math.*;
// testing something
public class ABC117D {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long k = in.nextLong();
        long[] ary = new long[n];
        // number of 0s have to be greater
        int MAX_BIT_LENGTH = (new BigInteger(k+"")).bitLength();
        for( int i = 0; i < n; i++ ) ary[i] = in.nextLong();
        long xor = 0L;
        for( int i = MAX_BIT_LENGTH; i >= 0; i-- ) {
            int ones = 0;
            for( int j = 0; j < n; j++ ) {
                if((ary[j]&(1L<<i)) > 0 ) ones++;
            }
            if( ones < n-ones && xor+(1L<<i) <= k) xor += (long) (1L<<(long)i); // if 1 is less than 0s, and adding it to xor will keep it less than k
        }

        long ans = 0L;
        for( long i : ary ) ans += (long) (i^xor);
        System.out.println(ans);
    }
}

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

import java.util.*;
import java.math.*;
// im giving up 
public class ABC117D {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long k = in.nextLong();
        long[] ary = new long[n];
        // number of 0s have to be greater
        for( int i = 0; i < n; i++ ) ary[i] = in.nextLong();
        long xor = 0L;
        for( int i = 0; i <= 41; i++ ) {
            int ones = 0;
            for( int j = 0; j < n; j++ ) {
                if((ary[j]&(1L<<i)) > 0 ) ones++;
            }
            if( ones < n-ones && xor+(1L<<i) <= k) xor += (long) (1L<<(long)i); // if 1 is less than 0s, and adding it to xor will keep it less than k
        }

        long ans = 0L;
        for( long i : ary ) ans += (long) (i^xor);
        System.out.println(ans);
    }
}

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

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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 100000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

ll N;

ll dfs(ll n,vector<ll> cnt,bitset<50> k,bool frag){
  if(n == 0){
    if(frag){
      return max(cnt[n],N-cnt[n]);
    }else{
      if(k.test(n)){
        return max(cnt[n],N-cnt[n]);
      }else{
        return cnt[n];
      }
    }
  }else{
    if(frag){
      return max(cnt[n],N-cnt[n]) * pow(2,n) + dfs(n-1,cnt,k,true);
    }else{
      if(k.test(n)){
        return max(cnt[n] * pow(2,n) + dfs(n-1,cnt,k,true),(N-cnt[n]) * pow(2,n) + dfs(n-1,cnt,k,false));
      }else{
        return cnt[n] * pow(2,n) + dfs(n-1,cnt,k,false);
      }
    }
  }
}

int main(){
 ll K;cin >> N >> K;
 vector<ll> A(N),cnt(50);
 for(int i = 0;i < N;i++){
   cin >> A[i];
   bitset<50> S(A[i]);
   for(int j = 0;j < 50;j++){
     if(S.test(j)){
       cnt[j]++;
     }
   }
 }
 bitset<42> k(K);
 ll ans = dfs(49,cnt,k,false);
 cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:57:22: error: could not convert 'k' from 'bitset<42>' to 'bitset<50>'
   57 |  ll ans = dfs(49,cnt,k,false);
      |                      ^
      |                      |
      |                      bitset<42>
Language: C++

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

int main() {
    int N;
    long long K;
    cin >> N >> K;
  
   long long int a[100010];
  
    for (int i = 0; i < N; ++i) cin >> A[i];
        
    long long ans = 0;
  
    for (int d = 60; d >= -1; d--) { 
        if (d != -1 && !(K & (1LL<<d))) continue;
        
        long long tmp = 0;
        for (int e = 60; e >= 0; e--) {
            long long x = 1LL<<e;
            int num = 0;
            for (int i = 0; i < N; ++i) if (A[i] & x) ++num;
            
            if (e > d) {
                if (K & x) tmp += x* (N - num);
                else tmp += x * num;
            }
            else if (e == d) {
                tmp += x * num;
            }
            else {
                tmp += x * max(num, N - num);
            }
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:40: error: 'A' was not declared in this scope
   12 |     for (int i = 0; i < N; ++i) cin >> A[i];
      |                                        ^
a.cc:23:45: error: 'A' was not declared in this scope
   23 |             for (int i = 0; i < N; ++i) if (A[i] & x) ++num;
      |                                             ^
Language: C++

#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>


#define rep(i, a, b) for ( ll i = (a); i < (b); i++ )
#define per(i, a, b) for ( ll i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()
#define DEBUG_INT(var) printf("the value of "#var" is %lld\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) rep(i, begin, end) PRINT_ARRAY(name, i)


using namespace std;

typedef long long ll;


ll N, K;
ll c[65];
ll A[100005];
ll dp[65][2];

int main(void) {
    scanf("%lld %lld", &N, &K);
    for (ll i = 0; i < N; i++) scanf("%lld", &A[i]);

    per(i, 0, 46) {
      ll t = 1LL<<i;
      ll D = K & t;
      ll c = 0;
      rep(j, 0, N) if (t&A[j]) c++;

      if (t >= k) {dp[i][0] = dp[i+1][0]+t*c; continue;}
      if (!D) {
        for (int j = 0; j <= 1; j++) dp[i][j] = dp[i+1][j]+t*c;
      } else {
        dp[i][0] = dp[i+1][0]+t*(N-c);
        dp[i][1] = max(dp[i+1][0]+t*(N-c), dp[i+1][1]+t*max(c, N-c));
      
      }
    }
    printf("%lld\n", max(dp[0][0], dp[0][1]));
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:16: error: 'k' was not declared in this scope
   38 |       if (t >= k) {dp[i][0] = dp[i+1][0]+t*c; continue;}
      |                ^
Language: C++

#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>


#define rep(i, a, b) for ( ll i = (a); i < (b); i++ )
#define per(i, a, b) for ( ll i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()
#define DEBUG_INT(var) printf("the value of "#var" is %lld\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) rep(i, begin, end) PRINT_ARRAY(name, i)


using namespace std;

typedef long long ll;


ll N, K;
ll c[65];
ll A[100005];
ll dp[65][2];

int main(void) {
    scanf("%lld %lld", &N, &K);
    for (ll i = 0; i < N; i++) scanf("%lld", &A[i]);

    per(i, 0, 46) {
      ll t = 1LL<<i;
      ll D = K & t;
      ll c = 0;
      rep(j, 0, N) if (t&A[j]) c++;

      if (t >= k) {dp[i][0] = dp[i+1]+t*c; continue;}
      if (!D) {
        for (int j = 0; j <= 1; j++) dp[i][j] = dp[i+1][j]+t*c;
      } else {
        dp[i][0] = dp[i+1][0]+t*(N-c);
        dp[i][1] = max(dp[i+1][0]+t*(N-c), dp[i+1][1]+t*max(c, N-c));
      
      }
    }
    printf("%lld\n", max(dp[0][0], dp[0][1]));
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:16: error: 'k' was not declared in this scope
   38 |       if (t >= k) {dp[i][0] = dp[i+1]+t*c; continue;}
      |                ^
a.cc:38:38: error: invalid conversion from 'll*' {aka 'long long int*'} to 'll' {aka 'long long int'} [-fpermissive]
   38 |       if (t >= k) {dp[i][0] = dp[i+1]+t*c; continue;}
      |                               ~~~~~~~^~~~
      |                                      |
      |                                      ll* {aka long long int*}
Language: Java


	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();
		}
		sc.close();
		// Aを二進数に直した時の、2^kがでる回数をk番目の要素に格納した配列
		int bi_A[] = new int[40];
		// 初期化
		for (int i = 0; i < bi_A.length; i++) {
			bi_A[i] = 0;
		}

		int cnt;
		for (long tmp : A) {
			while (tmp != 0) {
				cnt = -1;
				while (tmp >= Math.pow(2, cnt+1)) {
					cnt++;
				}
				if(cnt >= 0) {
				bi_A[cnt]++;
				tmp -= Math.pow(2, cnt);
				}
			}
		}
		// bi_Aが完成
		// 各要素は最高でN回現れる。
		// ある桁がk回現れている時、その桁の要素をXが持つ時、現れた回数が、N-k回に変換される。
		// よって、bi_Aの要素が、N/2より大きいかいなかで判断する。

		long sumX=0;
			for (int i=bi_A.length;i>0;i--) {
				if(bi_A[i-1]>N-bi_A[i-1]) {
					//何もしない
				}else {				
					if(K>sumX + Math.pow(2, i-1)) {
						bi_A[i-1]=N-bi_A[i-1];
						sumX+=Math.pow(2, i-1);
					}else {
					}
				}
			}
			
		

		long ans = 0;
		for (int i = 0; i < bi_A.length; i++) {
			ans += bi_A[i] * (long) Math.pow(2, i);
		}

		System.out.println(ans);

	}
}

Compiler output:
Main.java:2: 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)
Main.java:59: error: class, interface, enum, or record expected
}
^
2 errors
Language: C++

#include <bits/stdc++.h>

#define fastio1 ios_base::sync_with_stdio(false)
#define fastio2 cin.tie(NUll)
#define ll long long
#define MOD 1000000007
using namespace std;

int main(){
    fastio1; fastio2;
	ll n, k; cin >> n >> k;
	vector<ll> a(n);
	int maxBits = 45;
	ll tracker[maxBits];
	for (int i = 0; i < maxBits; i++){
		tracker[i] = 0;
	}
	
	for (int i = 0; i < n; i++){
		cin >> a[i];
		ll temp = a[i];
		int b = 1;
		while(temp > 0){
			tracker[maxBits-b] += temp % 2;
			temp /= 2LL;
			b++;
		}
	}
	
	
	ll x = 0;
	for (int i = 0; i < maxBits; i++){
		if (tracker[i] < n-tracker[i]){
			if (x + 1LL<<(maxBits-1-i) <= k){
				x += 1LL<<(maxBits-1-i);
			}
		}
	} 
	
	ll total = 0;
	for (int i = 0; i < n; i++){
		total += x^a[i];
	}
	cout << total << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:25: error: 'NUll' was not declared in this scope; did you mean 'NULL'?
    4 | #define fastio2 cin.tie(NUll)
      |                         ^~~~
a.cc:10:14: note: in expansion of macro 'fastio2'
   10 |     fastio1; fastio2;
      |              ^~~~~~~
Language: Java

import java.util.*;
import java.math.*;
// im sorry
public class XXOR {
	static BigInteger ZERO = new BigInteger("0");
	static BigInteger ONE = new BigInteger("1");
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt(); in.nextLine();
		BigInteger[] nums = new BigInteger[n];
		BigInteger max = new BigInteger("-1");
		String[] nums_str = in.nextLine().split(" ");
		for( int i = 0; i < n; i++ ) {
			nums[i] = new BigInteger(nums_str[i]);
			max = max.max(msb(nums[i]));
		}
		max = incr(max);
		while( ONE.shiftLeft(max.intValue()).compareTo(new BigInteger(Integer.toString(k))) > 0){
			max = decr(max);
		}
		BigInteger xor = ONE.shiftLeft(max.intValue());
		BigInteger sum = ZERO;
		for( BigInteger q : nums )
			sum = sum.add(xor.xor(q));
		System.out.println(sum);
	}
	public static BigInteger msb(BigInteger n) {
		BigInteger ct = ZERO;
		while( n.compareTo(ZERO) == 1 ) {
			ct = incr(ct);
			n = n.shiftRight(1);
		}
		return ct;
	}

	public static BigInteger incr(BigInteger b) {
		return b.add(ONE);
	}

	public static BigInteger decr(BigInteger b) {
		return b.subtract(ONE);
	}
}

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