func_code_string: #include <bits/stdc++.h>   using namespace std;   const int INF = 1e9 + 7;   const int mod = 1e9 + 7;   long long int powmod(long long int a, long long int b) {     long long int res = 1;     a %= mod;     assert(b >= 0);     for (; b; b >>= 1) {       if (b & 1) res = res * a % mod;       a = a * a % mod;     }     return res;   }   int nxt() {     int x;     scanf( %d , &x);     return x;   }   class FenwickTree {    public:     vector<int> ft;     FenwickTree(int n) { ft.assign(n + 1, 0); }     int rsq(int b) {       int sum = 0;       for (; b; b -= (b & (-b))) sum += ft[b];       return sum;     }     int rsq(int a, int b) { return rsq(b) - (a == 1 ? 0 : rsq(a - 1)); }     void adjust(int k, int v) {       for (; k < (int)ft.size(); k += (k & (-k))) ft[k] += v;     }   };   void cnt(int l, int r) {}   void add(int l) {}   void rmv(int l) {}   int main() {     long long int n, k;     cin >> n >> k;     vector<int> a(n), b(n);     for (int i = 0; i < n; i++) {       a[i] = nxt();       b[i] = a[i];     }     sort((b).begin(), (b).end());     for (int i = 0; i < n; i++) {       a[i] = lower_bound((b).begin(), (b).end(), a[i]) - b.begin() + 1;     }     FenwickTree ft(n), ft2(n);     long long int cnt = 0;     for (int i = 0; i < n; i++) {       cnt += (long long int)ft2.rsq(a[i] + 1, n);       ft2.adjust(a[i], 1);     }     if (cnt <= k) {       printf( %lld n , n * (n - 1) / 2);       return 0;     }     int pr = 0;     long long int tmp = cnt;     cnt = 0;     for (int i = 0; i < n; i++) {       tmp += ft.rsq(a[i] + 1, n);       tmp += ft2.rsq(a[i] - 1);       ft.adjust(a[i], 1);       while (tmp > k && pr <= n - 1) {         tmp -= ft.rsq(a[pr] + 1, n);         tmp -= ft2.rsq(a[pr] - 1);         ft2.adjust(a[pr], -1);         pr++;       }       cnt += max(0LL, n - pr);     }     printf( %lld n , cnt);     return 0;   }   