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<int,int> 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};
/*}}}*/

ll n,m;
vector<set<int>> g;

int main(){
    cin >> n >> m;
    g.resize(n);
    rep(i,m){
        ll a,b;cin>>a>>b;a--;b--;
        g[a].insert(b);
        g[b].insert(a);
    }

    set<pii> dis2;
    rep(i,n){
        queue<int> que;
        for(int v : g[i]) que.push(v);

        while(!que.empty()){
            int u = que.front();que.pop();
            for(int v : g[u]){
                if(v == i or g[i].count(v)) continue;
                dis2.insert(pii(min(i,v),max(i,v)));
            }
        }
    }

    while(true){
        set<pii> tmp;
        for(pii p : dis2){
            int u=p.fi,v=p.se;
            for(int nv : g[v]){
                g[u].insert(nv);
            }
            for(int nu : g[u]){
                g[v].insert(nu);
            }
        }
        rep(i,n){
            queue<int> que;
            for(int v : g[i]) que.push(v);

            while(!que.empty()){
                int u = que.front();que.pop();
                for(int v : g[u]){
                    if(v == i or g[i].count(v)) continue;
                    tmp.insert(pii(min(i,v),max(i,v)));
                }
            }
        }

        if(tmp == dis2) break;
        swap(dis2,tmp);
    }

    ll sum = 0;
    rep(i,n)
        sum += g[i].size();
    sum /= 2;
    sum -= m;
    cout << sum << endl;
}


Compiler output:
a.cc:17:8: error: expected identifier before 'double'
   17 | struct double{ double d; explicit double(double x) : d(x){} };
      |        ^~~~~~
a.cc:17:14: error: expected unqualified-id before '{' token
   17 | struct double{ double d; explicit double(double x) : d(x){} };
      |              ^
a.cc: In function 'std::ostream& operator<<(std::ostream&, double)':
a.cc:18:87: error: request for member 'd' in 'x', which is of non-class type 'const double'
   18 | ostream& operator<<(ostream& os,const double x){ os << fixed << setprecision(20) << x.d; return os; }
      |                                                                                       ^