Language: C++

#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/
 
const ll max_n = 100005;
ll N,M;
vector<ll> A,B;
set<pii> st[4];
vector<vector<ll>> g;
set<ll> d[max_n][4];
 
int main(){
    cin >> N >> M;
    g.resize(N);
    A.resize(M);
    B.resize(M);
    rep(i,M){
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
        g[A[i]].pb(B[i]);
        g[B[i]].pb(A[i]);
    }
 
    rep(i,N){
        queue<pii> que;
        que.push(pii(0,i));
        set<pii> poi;
        //cerr << i << endl;
        while(!que.empty()){
            int dis = que.front().fi;
            int u = que.front().se;
            que.pop();
            if(i!=u and dis<=3){
                st[dis].insert(pii(min(i,u),max(i,u)));
            }
            if(dis == 3) continue;
            for(int v : g[u]){
                int nd = dis+1;
                if(poi.count(nd,v)) continue;
            poi.insert(pii(nd,v));
                que.push(pii(nd,v));
            }
        }
    }
 
    for(auto p : st[1]){
        if(st[3].count(p)){
            st[3].erase(p);
        }
    }
 
    rep(i,4){
        for(pii p : st[i]){
            int u=p.fi,v=p.se;
            d[u][i].insert(v);
            d[v][i].insert(u);
        }
    }
 
    //rep(i,4) cerr << st[i] << endl;
 
    while(1){
        set<pii> st2;
        for(pii p : st[3]){
            if(st[1].count(p)){
                continue;
            }
            ll u = p.fi,v=p.se;
            d[u][1].insert(v);
            d[v][1].insert(u);
            st[1].insert(pii(min(u,v),max(u,v)));
            for(ll nv : d[v][2]){
                if(u==nv) continue;
                if(st[1].count(pii(min(u,nv),max(u,nv)))) continue;
                d[u][3].insert(nv);
                st2.insert(pii(min(u,nv),max(u,nv)));
            }
            for(ll nu : d[u][2]){
                if(v==nu) continue;
                if(st[1].count(pii(min(v,nu),max(v,nu)))) continue;
                d[v][3].insert(nu);
                st2.insert(pii(min(v,nu),max(v,nu)));
            }
        }
        swap(st2,st[3]);
        //cerr << st2 << endl;
        if(st[3].empty()) break;
    }
 
    //cout << st[1] << endl;
    cout << st[1].size() - M << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:71:29: error: no matching function for call to 'std::set<std::pair<long long int, long long int> >::count(int&, int&)'
   71 |                 if(poi.count(nd,v)) continue;
      |                    ~~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/set:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:158,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_set.h:756:9: note: candidate: 'template<class _Kt> decltype (((const std::set<_Key, _Compare, _Alloc>*)this)->std::set<_Key, _Compare, _Alloc>::_M_t._M_count_tr(__x)) std::set<_Key, _Compare, _Alloc>::count(const _Kt&) const [with _Key = std::pair<long long int, long long int>; _Compare = std::less<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<long long int, long long int> >]'
  756 |         count(const _Kt& __x) const
      |         ^~~~~
/usr/include/c++/14/bits/stl_set.h:756:9: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_set.h:750:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::count(const key_type&) const [with _Key = std::pair<long long int, long long int>; _Compare = std::less<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<long long int, long long int> >; size_type = long unsigned int; key_type = std::pair<long long int, long long int>]'
  750 |       count(const key_type& __x) const
      |       ^~~~~
/usr/include/c++/14/bits/stl_set.h:750:7: note:   candidate expects 1 argument, 2 provided