func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long int lg = 22;   const long long int N = 2e5 + 5;   const long long int INF = 1e18;   const long long int mod = 1e9 + 7;   const double PI = 3.14159265358979323846;   template <typename T>   T power(T x, T y, long long int m) {     T ans = 1;     while (y > 0) {       if (y & 1LL) ans = (ans * x) % m;       y >>= 1LL;       x = (x * x) % m;     }     return ans % m;   }   inline long long int mul(long long int a, long long int b, long long int p) {     return (a * 1ll * b) % p;   }   inline long long int sub(long long int a, long long int b, long long int p) {     long long int c = a - b;     if (c < 0) c += p;     return c;   }   inline long long int add(long long int a, long long int b, long long int p) {     long long int c = a + b;     if (c > p) c -= p;     return c;   }   long long int mark[N];   long long int n, q, a[N], minidx[N], maxidx[N];   int main() {     long long int ans = 0;     cin >> n >> q;     for (long long int i = 1; i <= n; i++) {       cin >> a[i];       if (minidx[a[i]] == 0) {         minidx[a[i]] = i;       }       maxidx[a[i]] = i;     }     for (long long int i = 1; i <= n; i++) {       long long int maxcnt = 0, cnt = 0;       long long int maxi = maxidx[a[i]];       if (mark[i]) {         continue;       }       map<long long int, long long int> xfreq;       for (long long int j = i; j <= maxi; j++) {         cnt++;         mark[j] = 1;         xfreq[a[j]]++;         maxcnt = max(maxcnt, xfreq[a[j]]);         maxi = max(maxi, maxidx[a[j]]);       }       ans += (cnt - maxcnt);     }     cout << ans << endl;   }   