func_code_string: #include <bits/stdc++.h>   using namespace std;   string itos(int x) {     stringstream ss;     ss << x;     return ss.str();   }   int n, k, a[400010], nxt[400010], pt[400010], res;   struct Comp {     bool operator()(int l, int r) const { return pt[l] > pt[r]; }   };   set<int, Comp> s1;   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> a[i];     iota(pt, pt + 400010, n);     for (int i = n - 1; i >= 0; i--) {       nxt[i] = pt[a[i]];       pt[a[i]] = i;     }     for (int i = 0; i < n; i++) {       if (s1.count(a[i])) {         s1.erase(a[i]);         pt[a[i]] = nxt[i];         s1.insert(a[i]);       } else         pt[a[i]] = nxt[i];       if (s1.count(a[i])) continue;       if (s1.size() == k) s1.erase(s1.begin());       s1.insert(a[i]);       res++;     }     cout << res << endl;     return 0;   }   