func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, q, a[200010];   struct node {     int l, r, color;     node(int ll = 0, int rr = 0, int cc = 0) : l(ll), r(rr), color(cc) {}   };   node p[200010];   vector<int> vec[200010];   bool cmp(node a, node b) {     if (a.l != b.l) return a.l < b.l;     return a.r > b.r;   }   int main() {     cin >> n >> q;     for (int i = 1; i <= n; ++i) {       scanf( %d , &a[i]);       vec[a[i]].push_back(i);     }     int cnt = 0;     for (int i = 1; i <= 200000; ++i) {       if (!vec[i].size()) continue;       int l = vec[i][0], r = vec[i][vec[i].size() - 1];       p[++cnt] = node(l, r, i);     }     sort(p + 1, p + 1 + cnt, cmp);     p[cnt + 1].l = 1e9 + 10;     int ans = 0, l = 1e9 + 10, r = 0, tmp = 0;     for (int i = 1; i <= cnt + 1; ++i) {       if (i == 1 || p[i].l < r) {         l = min(l, p[i].l);         r = max(r, p[i].r);         tmp = max(tmp, (int)vec[p[i].color].size());       } else {         ans += r - l + 1 - tmp;         l = p[i].l;         r = p[i].r;         tmp = vec[p[i].color].size();       }     }     printf( %d n , ans);   }   