func_code_string: #include <bits/stdc++.h>   using namespace std;   bool f[300010];   map<pair<int, int>, int> mp;   vector<int> g[300010];   long long nm[300010], kk[300010], x, y, p;   long long ans, n, i;   void go(int now) {     f[now] = 1;     for (int i = 0; i < g[now].size(); i++)       if (!f[g[now][i]])         if (nm[now] + nm[g[now][i]] - mp[make_pair(now, g[now][i])] < p &&             p <= nm[now] + nm[g[now][i]])           ans -= 2;     for (int i = 0; i < g[now].size(); i++)       if (!f[g[now][i]]) go(g[now][i]);   }   int main() {     cin >> n >> p;     for (i = 1; i <= n; i++) {       scanf( %d%d , &x, &y);       mp[make_pair(x, y)]++;       mp[make_pair(y, x)]++;       if (mp[make_pair(x, y)] == 1) {         g[x].push_back(y);         g[y].push_back(x);       }       nm[x]++;       nm[y]++;     }     for (i = 1; i <= n; i++)       if (2 * nm[i] >= p) ans--;     for (i = 1; i <= n; i++) kk[nm[i]]++;     for (i = 300000; i >= 0; i--) kk[i] += kk[i + 1];     for (i = 1; i <= n; i++) ans += kk[max(0LL, p - nm[i])];     for (i = 1; i <= n; i++)       if (!f[i]) go(i);     cout << ans / 2 << endl;   }   