func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long N = 3e5 + 10;   const long long M = 3e5 + 1;   const long long oo = 1e9;   long long n, minn, ans;   long long bit[N], deg[N];   pair<long long, long long> nex[N];   vector<long long> vi[N];   void upd(long long pos, long long val) {     for (long long i = pos; i < N; i += (i & -i)) bit[i] += val;   }   long long get(long long pos) {     long long res = 0;     for (long long i = pos; i >= 1; i -= (i & -i)) res += bit[i];     return res;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> minn;     for (long long i = 1; i <= n; ++i) {       long long x, y;       cin >> x >> y;       nex[i] = pair<long long, long long>(x, y);       vi[x].push_back(i);       vi[y].push_back(i);       deg[x]++;       deg[y]++;     }     for (long long i = 1; i <= n; ++i) upd(M - vi[i].size(), 1);     for (long long i = 1; i <= n; ++i) {       long long cur = vi[i].size();       for (long long v : vi[i]) {         long long die = (nex[v].first == i) ? nex[v].second : nex[v].first;         upd(M - deg[die], -1);         deg[die]--;         upd(M - deg[die], 1);       }       upd(M - deg[i], -1);       long long rem = max(0ll, minn - cur);       ans += get(M - rem);       upd(M - deg[i], 1);       for (long long v : vi[i]) {         long long die = (nex[v].first == i) ? nex[v].second : nex[v].first;         upd(M - deg[die], -1);         deg[die]++;         upd(M - deg[die], 1);       }     }     cout << ans / 2;   }   