func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     cerr << name <<  :   << arg1 << endl;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cerr.write(names, comma - names) <<  :   << arg1 <<   | ;     __f(comma + 1, args...);   }   const int INF = 1 << 29;   const int MOD = 1e9 + 7;   struct Node {     Node *pre, *nxt;     int val, pos, len;     bool operator<(const Node& rhs) const {       if (len != rhs.len) return len > rhs.len;       return pos < rhs.pos;     }   };   const int N = 2e5 + 10;   Node pool[N << 1], *last;   struct cmp {     bool operator()(int u, int v) const { return pool[u] < pool[v]; }   };   int main() {     int n;     scanf( %d , &n);     vector<int> a(n);     for (int i = 0; i < n; ++i) {       scanf( %d , &a[i]);     }     set<int, cmp> A;     last = pool;     for (int i = 0, j; i < n; i = j) {       for (j = i + 1; j < n && a[j] == a[i]; ++j)         ;       Node* cur = last++;       cur->val = a[i];       cur->pos = i;       cur->len = j - i;       cur->pre = cur->nxt = nullptr;       if (i > 0) {         auto pre = last - 2;         pre->nxt = cur;         cur->pre = pre;       }     }     for (auto it = pool; it != last; ++it) {       A.insert(it - pool);     }     int ret = 0;     while (A.size()) {       auto it = A.begin();       auto cur = &pool[*it];       auto pre = cur->pre;       auto nxt = cur->nxt;       if (pre && nxt && pre->val == nxt->val) {         cur = last++;         cur->val = pre->val;         cur->pos = pre->pos;         cur->len = pre->len + nxt->len;         cur->pre = pre->pre;         cur->nxt = nxt->nxt;         if (cur->pre) cur->pre->nxt = cur;         if (cur->nxt) cur->nxt->pre = cur;         A.erase(pre - pool);         A.erase(nxt - pool);         A.insert(cur - pool);       } else {         if (pre) pre->nxt = nxt;         if (nxt) nxt->pre = pre;       }       A.erase(it);       ++ret;     }     printf( %d n , ret);     return 0;   }   