func_code_string: #include <bits/stdc++.h>   using namespace std;   struct interval {     int l, r;     bool operator<(const interval &t) const { return r < t.r; }   };   set<interval> itree[20];   set<interval>::iterator l, r;   long long ans;   long long f(int type, int num) {     return (1LL << type) * ((num + 1LL) * num) / 2;   }   void add(int type, int pos, int val) {     interval unit = {pos, pos};     l = r = itree[type].lower_bound(unit);     if (val == 0) {       if (r->l <= pos && pos <= r->r) {         interval new_left = {r->l, pos - 1}, new_right = {pos + 1, r->r};         ans -= f(type, (r->r) - (r->l) + 1);         ans += f(type, new_left.r - new_left.l + 1);         ans += f(type, new_right.r - new_right.l + 1);         itree[type].erase(r);         if (new_left.l <= new_left.r) itree[type].insert(new_left);         if (new_right.l <= new_right.r) itree[type].insert(new_right);       }     } else {       if (r->l <= pos && pos <= r->r) {         return;       }       if (!itree[type].empty()) {         if (l != itree[type].begin() && (--l)->r == pos - 1) {           unit.l = l->l;           ans -= f(type, l->r - l->l + 1);           itree[type].erase(l);         }         if (r != itree[type].end() && r->l == pos + 1) {           unit.r = r->r;           ans -= f(type, r->r - r->l + 1);           itree[type].erase(r);         }       }       itree[type].insert(unit);       ans += f(type, unit.r - unit.l + 1);     }   }   int main() {     int n, m;     cin >> n >> m;     for (int i = 1; i <= n; ++i) {       int a;       cin >> a;       for (int j = 0; j < 20; ++j) {         if (a % 2 != 0) add(j, i, a % 2);         a /= 2;       }     }     for (int i = 0; i < m; ++i) {       int pos, val;       cin >> pos >> val;       for (int j = 0; j < 20; ++j) {         add(j, pos, val % 2);         val /= 2;       }       cout << ans <<   n ;     }   }   