Language: C++

#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
#define ll long long

int main () {
  ll n, K;
  cin >> n >> K;
  ll a[n];
  ll sum[n + 1];
  sum[0] = 0;
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    sum[i + 1] = sum[i] + a[i];
  }
  vector<ll> ans;
  for (ll i = 0; i < n + 1; i++) {
    for (ll j = i + 1; j < n + 1; j++) {
      ans.push_back(sum[j] - sum[i]);  
    }  
  }
  ll sub = 1;
  ll itr = 0;
  ll dp[40];
  for (int i = 0; i < 40; i++) {
    dp[i] = 0;  
  }
  vector<unordered map<ll, ll> > box;
  box.resize(40);
  for (ll i = 0; i < ans.size(); i++) {
    if (ans[i] == 0) {
      // 何もしない  
    }  
    itr = 0;
    while (ans[i] != 0) {
      if ((ans[i] & 1) == 1) {
        box[itr][i] = 1;
      }    
      ans[i] >>= 1;  
      itr++;
    }
  }
  /*
  while (itr < 41) {
    for (ll i = 0; i < ans.size(); i++) {
      if ((sub & ans[i]) != 0) {
        dp[itr]++;
        box[itr][i] = 1;  
      }    
    }  
    sub = sub * 2;
    itr++;  
  }
  */
  sub = 1;
  for (int i = 0; i < 40; i++) {
    /*
    cout << sub << " " << dp[i] << endl;
    for (auto x = box[i].begin(); x != box[i].end(); ++x) {
      cout << *x << " ";  
    }
    cout << endl;
    */
    sub = sub * 2;  
  }
  ll answer = 0;
  ll ssss = 0;
  bool ok = false;
  unordered map<ll, ll> finish;
  for (ll i = 0; i < 40; i++) {
    sub = sub / 2;
    if (ok == false) {
      if (box[39 - i].size() >= K) {
        answer = answer + sub;
        ok = true;
        itr = 39 - i;
      }
    }
    else {
      ssss = 0;
      if (box[39 - i].size() >= K) {
        for (auto j = box[39 - i].begin(); j != box[39 - i].end(); ++j) {
          if (box[itr][j->first] == 1) {
              ssss++;      
          } 
          else {
            box[39 - i][j->first] = 0;    
          }
        }  
        if (ssss >= K) {
          answer = answer + sub;  
          itr = 39 - i;
        }
        else {
          // 何もしない.    
        }
      }     
    }
  }
  cout << answer << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:10: error: 'unordered' was not declared in this scope
   31 |   vector<unordered map<ll, ll> > box;
      |          ^~~~~~~~~
a.cc:31:32: error: template argument 1 is invalid
   31 |   vector<unordered map<ll, ll> > box;
      |                                ^
a.cc:31:32: error: template argument 2 is invalid
a.cc:32:7: error: request for member 'resize' in 'box', which is of non-class type 'int'
   32 |   box.resize(40);
      |       ^~~~~~
a.cc:40:12: error: invalid types 'int[long long int]' for array subscript
   40 |         box[itr][i] = 1;
      |            ^
a.cc:72:12: error: expected ';' before 'map'
   72 |   unordered map<ll, ll> finish;
      |            ^~~~
      |            ;
a.cc:76:14: error: invalid types 'int[long long int]' for array subscript
   76 |       if (box[39 - i].size() >= K) {
      |              ^
a.cc:84:14: error: invalid types 'int[long long int]' for array subscript
   84 |       if (box[39 - i].size() >= K) {
      |              ^
a.cc:85:26: error: invalid types 'int[long long int]' for array subscript
   85 |         for (auto j = box[39 - i].begin(); j != box[39 - i].end(); ++j) {
      |                          ^
a.cc:85:52: error: invalid types 'int[long long int]' for array subscript
   85 |         for (auto j = box[39 - i].begin(); j != box[39 - i].end(); ++j) {
      |                                                    ^
a.cc:86:18: error: invalid types 'int[long long int]' for array subscript
   86 |           if (box[itr][j->first] == 1) {
      |                  ^
a.cc:90:16: error: invalid types 'int[long long int]' for array subscript
   90 |             box[39 - i][j->first] = 0;
      |                ^