Language: C++

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

   typedef unsinged long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};
const ll MAX_N = 1e5, MAX_K = 50;
ll N, K;
ll A[MAX_N] = {};
ll B[MAX_K][MAX_N] = {};
ll C[MAX_K] = {};
ll s = 0;
ll log2(ll x){
   if(x == 1) return 0;
   return log2(x / 2) + 1;
}
ll f_max(ll x){
   //x以下のfの最大値
   if (x == 0) return s;
   if(x + 1 == pow(2, log2(x + 1))){
      //xが2べき - 1のとき
      ll ans = 0;
      REP(j, log2(x) + 1){
         ans += (1ull << j) * max(C[j], N - C[j]);
      }
      FOR(j, log2(x) + 1, 50){
         ans += (1ull << j) * C[j];
      }
      return ans;
   }
   else{
      ll fmax1 = f_max(pow(2, log2(x)) - 1); // 0 - 2^k - 1でのmax
      ll fmax2 = pow(2, log2(x)) * (N - 2 * C[log2(x)]) + f_max(x - pow(2, log2(x))); // x - 2^kでのmax
      //printf("fmax1 = %lld, fmax2 = %lld\n", fmax1, fmax2);
      return max(fmax1, fmax2);   
   }   
}
int main(){
   cin >> N >> K;
   REP(i, N) {
      cin >> A[i];
      s += A[i];
   }
   REP(j, 50){
      REP(i, N){
         B[j][i] = (A[i] >> j) & 1;
         C[j] += B[j][i];
      }
   }
   cout << f_max(K) << endl;
}


Compiler output:
a.cc:4:12: error: 'unsinged' does not name a type; did you mean 'unsigned'?
    4 |    typedef unsinged long long ll;
      |            ^~~~~~~~
      |            unsigned
a.cc:5:17: error: 'll' was not declared in this scope
    5 |    typedef pair<ll, ll> Pii;
      |                 ^~
a.cc:5:21: error: 'll' was not declared in this scope
    5 |    typedef pair<ll, ll> Pii;
      |                     ^~
a.cc:5:23: error: template argument 1 is invalid
    5 |    typedef pair<ll, ll> Pii;
      |                       ^
a.cc:5:23: error: template argument 2 is invalid
a.cc:6:19: error: 'll' was not declared in this scope
    6 |    typedef vector<ll> Vi;
      |                   ^~
a.cc:6:21: error: template argument 1 is invalid
    6 |    typedef vector<ll> Vi;
      |                     ^
a.cc:6:21: error: template argument 2 is invalid
a.cc:10:10: error: 'll' does not name a type
   10 |    const ll INF =(1e13);
      |          ^~
a.cc:12:10: error: 'll' does not name a type
   12 |    const ll MOD = ll(1e9) + 7;
      |          ^~
a.cc:32:4: error: 'll' does not name a type
   32 |    ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
      |    ^~
a.cc:33:4: error: 'll' does not name a type
   33 |    ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
      |    ^~
a.cc:34:4: error: 'll' does not name a type
   34 |    ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
      |    ^~
a.cc:35:4: error: 'll' does not name a type
   35 |    ll residue(ll a, ll m){return ((a % m) + m) % m;};
      |    ^~
a.cc:37:4: error: 'll' does not name a type
   37 |    ll dx[4]={1,0,-1,0};
      |    ^~
a.cc:38:4: error: 'll' does not name a type
   38 |    ll dy[4]={0,1,0,-1};
      |    ^~
a.cc:39:7: error: 'll' does not name a type
   39 | const ll MAX_N = 1e5, MAX_K = 50;
      |       ^~
a.cc:40:1: error: 'll' does not name a type
   40 | ll N, K;
      | ^~
a.cc:41:1: error: 'll' does not name a type
   41 | ll A[MAX_N] = {};
      | ^~
a.cc:42:1: error: 'll' does not name a type
   42 | ll B[MAX_K][MAX_N] = {};
      | ^~
a.cc:43:1: error: 'll' does not name a type
   43 | ll C[MAX_K] = {};
      | ^~
a.cc:44:1: error: 'll' does not name a type
   44 | ll s = 0;
      | ^~
a.cc:45:1: error: 'll' does not name a type
   45 | ll log2(ll x){
      | ^~
a.cc:49:1: error: 'll' does not name a type
   49 | ll f_max(ll x){
      | ^~
a.cc: In function 'int main()':
a.cc:71:11: error: 'N' was not declared in this scope
   71 |    cin >> N >> K;
      |           ^
a.cc:71:16: error: 'K' was not declared in this scope
   71 |    cin >> N >> K;
      |                ^
a.cc:14:26: error: 'll' was not declared in this scope
   14 |    #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
      |                          ^~
a.cc:72:4: note: in expansion of macro 'REP'
   72 |    REP(i, N) {
      |    ^~~
a.cc:72:8: error: 'i' was not declared in this scope; did you mean 'Vi'?
   72 |    REP(i, N) {
      |        ^
a.cc:14:36: note: in definition of macro 'REP'
   14 |    #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
      |                                    ^
a.cc:73:14: error: 'A' was not declared in this scope
   73 |       cin >> A[i];
      |              ^
a.cc:74:7: error: 's' was not declared in this scope
   74 |       s += A[i];
      |       ^
a.cc:14:26: error: 'll' was not declared in this scope
   14 |    #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
      |                          ^~
a.cc:76:4: note: in expansion of macro 'REP'
   76 |    REP(j, 50){
      |    ^~~
a.cc:76:8: error: 'j' was not declared in this scope; did you mean 'jn'?
   76 |    REP(j, 50){
      |        ^
a.cc:14:36: note: in definition of macro 'REP'
   14 |    #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
      |                                    ^
a.cc:77:11: error: expected ';' before 'i'
   77 |       REP(i, N){
      |           ^
a.cc:14:29: note: in definition of macro 'REP'
   14 |    #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
      |                             ^
a.cc:77:11: error: 'i' was not declared in this scope; did you mean 'Vi'?
   77 |       REP(i, N){
      |           ^
a.cc:14:36: note: in definition of macro 'REP'
   14 |    #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
      |                                    ^
a.cc:78:10: error: 'B' was not declared in this scope
   78 |          B[j][i] = (A[i] >> j) & 1;
      |          ^
a.cc:78:21: error: 'A' was not declared in this scope
   78 |          B[j][i] = (A[i] >> j) & 1;
      |                     ^
a.cc:79:10: error: 'C' was not declared in this scope
   79 |          C[j] += B[j][i];
      |          ^
a.cc:82:12: error: 'f_max' was not declared in this scope; did you mean 'fmax'?
   82 |    cout << f_max(K) << endl;
      |            ^~~~~
      |            fmax