func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxN = 3e5 + 5;   map<pair<int, int>, int> mp;   int counts[maxN];   set<int> s[maxN];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int N, P;     cin >> N >> P;     for (int i = 0; i < N; i++) {       pair<int, int> xy;       cin >> xy.first >> xy.second;       xy = {min(xy.first, xy.second), max(xy.first, xy.second)};       if (mp.count(xy) > 0)         mp[xy]++;       else         mp[xy] = 1;       counts[xy.first]++;       counts[xy.second]++;       s[xy.first].insert(xy.second);       s[xy.second].insert(xy.first);     }     vector<int> ordered;     for (int i = 1; i <= N; i++) {       ordered.push_back(counts[i]);     }     sort(ordered.begin(), ordered.end());     long long ans = 0;     for (int i = 1; i <= N; i++) {       int rem = P - counts[i];       int k = lower_bound(ordered.begin(), ordered.end(), rem) - ordered.begin();       int tot = N - k;       if (counts[i] >= rem) tot--;       for (auto it = s[i].begin(); it != s[i].end(); it++) {         pair<int, int> ordp = {min(i, *it), max(i, *it)};         if (counts[i] + counts[*it] >= P &&             counts[i] + counts[*it] - mp[ordp] < P) {           tot--;         }       }       ans += tot;     }     cout << ans / 2;     return 0;   }   