func_code_string: #include <bits/stdc++.h>   using namespace std;   const int max_N = 2e5 + 10;   const int l_N = 20;   int st[l_N][max_N];   int lg[max_N];   int inp[max_N];   vector<int> bits[30];   int query_max(int i, int j);   int main() {     {       int j = 0;       for (int i = 0; i < max_N; ++i) {         while ((1 << j) <= i) {           ++j;         }         lg[i] = j - 1;       }     }     int N;     scanf( %d , &N);     for (int i = 1; i <= N; ++i) {       scanf( %d , &inp[i]);       st[0][i] = inp[i];     }     for (int j = 1; j < l_N; ++j) {       for (int i = 1; i + (1 << j) - 1 <= N; ++i) {         st[j][i] = max(st[j - 1][i], st[j - 1][i + (1 << (j - 1))]);       }     }     for (int i = 1; i <= N; ++i) {       for (int j = 0; j < 30; ++j) {         if ((inp[i] >> j) & 1) {           bits[j].push_back(i);         }       }     }     long long ans = 0;     for (int i = 1; i <= N; ++i) {       vector<int> or_changes;       for (int j = 0; j < 30; ++j) {         auto it = lower_bound(bits[j].begin(), bits[j].end(), i);         if (it != bits[j].end()) {           or_changes.push_back(*it);         }       }       sort(or_changes.begin(), or_changes.end());       or_changes.push_back(N + 1);       int cid = *or_changes.begin();       int cor = inp[cid];       for (int j = 1; j < or_changes.size(); ++j) {         int L = cid, R = or_changes[j];         int low = L, high = R - 1, mid, best = R;         while (low <= high) {           mid = (low + high) >> 1;           if (query_max(L, mid) >= cor) {             best = mid;             high = mid - 1;           } else {             low = mid + 1;           }         }         ans += best - L;         cid = R;         cor |= inp[R];       }     }     cout << ans << endl;   }   int query_max(int i, int j) {     int d = lg[j - i + 1];     return max(st[d][i], st[d][j - (1 << d) + 1]);   }   