func_code_string: #include <bits/stdc++.h>   using namespace std;   set<pair<long long, long long> > s[17];   long long a[100002];   long long g[100002];   signed main() {     ios ::sync_with_stdio(0), cin.tie(0), cout.tie(0);     long long n, m;     cin >> n >> m;     for (long long i = 0; i <= n; i++) g[i] = (i * (i + 1)) / 2LL;     long long ans = 0;     for (long long i = 0; i <= n - 1; i++) cin >> a[i];     for (long long j = 0; j <= 16; j++) {       for (long long i = 0; i <= n - 1; i++) {         if (a[i] & (1LL << j)) {           long long len = 1;           long long st = i;           i++;           while (1) {             if (i == n or !(a[i] & (1LL << j))) {               s[j].insert({st, len});               ans += (g[len] * (1LL << j));               break;             }             len++;             i++;           }         }       }     }     while (m--) {       long long idx, val, pval;       cin >> idx >> val;       idx--;       pval = a[idx];       for (long long j = 0; j <= 16; j++) {         if (val & (1LL << j) and !(pval & (1LL << j))) {           auto it = s[j].lower_bound({idx, 1e9});           if (it == s[j].end() or (*it).first != idx + 1)             s[j].insert({idx, 1}), ans += (1LL << j);           else             ans += (1LL << j) * ((*it).second + 1),                 s[j].insert({idx, (*it).second + 1}), s[j].erase(it);           it = s[j].lower_bound({idx, -1});           if (it != s[j].begin()) {             auto pt = prev(it);             if ((*pt).second + (*pt).first - 1 == idx - 1) {               ans -= (1LL << j) * (g[(*pt).second] + g[(*it).second]),                   ans += (1LL << j) * g[(*it).second + (*pt).second],                   s[j].insert({(*pt).first, (*pt).second + (*it).second}),                   s[j].erase(it), s[j].erase(pt);             }           }         } else if (pval & (1LL << j) and !(val & (1LL << j))) {           auto it = s[j].lower_bound({idx, -1});           if (it != s[j].end() and (*it).first == idx) {             if ((*it).second == 1)               ans -= (1LL << j), s[j].erase({idx, 1});             else               ans -= (1LL << j) * ((*it).second),                   s[j].insert({idx + 1, (*it).second - 1}), s[j].erase(it);           } else {             it = prev(it);             if ((*it).first + (*it).second - 1 == idx)               ans -= (1LL << j) * ((*it).second),                   s[j].insert({(*it).first, (*it).second - 1}), s[j].erase(it);             else {               ans -= (1LL << j) * g[(*it).second],                   ans += (1LL << j) * g[idx - 1 - (*it).first + 1],                   ans +=                   (1LL << j) * g[(*it).first + (*it).second - 1 - idx - 1 + 1];               s[j].insert({(*it).first, idx - 1 - (*it).first + 1}),                   s[j].insert(                       {idx + 1, (*it).first + (*it).second - 1 - idx - 1 + 1}),                   s[j].erase(it);             }           }         }       }       a[idx] = val;       cout << ans <<   n ;     }   }   