func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, k, a[400010];   map<int, int> m;   set<pair<int, int> > s;   long long ans = 0;   int main() {     cin >> n >> k;     for (int i = 1; i <= n; ++i) cin >> a[i];     a[0] = 0;     for (int l = 1, r = 0; l <= n; ++l) {       s.erase(make_pair(-m[a[l - 1]], a[l - 1]));       m[a[l - 1]]--;       s.insert(make_pair(-m[a[l - 1]], a[l - 1]));       while (-s.begin()->first < k) {         ++r;         if (r >= n + 1) break;         s.erase(make_pair(-m[a[r]], a[r]));         m[a[r]]++;         s.insert(make_pair(-m[a[r]], a[r]));       }       ans += max(n + 1 - r, 0);     }     cout << ans << endl;     return 0;   }   