For this Question: You are given N nodes and M undirected edges. These nodes and edges represent some trees (graphs with no loops). Now, your task is to merge the trees into a single tree. In one operation of merging, two disconnected trees are merged using an edge from one tree to the other tree. The cost of this merging operation is <b>total number of nodes in the final merged tree</b>. Once merged the trees lose their original existence. 
So, if there are T trees in the original state, you'll have to perform the merge operation T-1 times to merge all the trees in a single tree.

All you need to do is find the minimum cost of merging the trees (sum of costs of all T-1 merge operations). See sample for better understanding.The first line of input contains two integers N and M, the total number of nodes and the total number of edges.
The next M lines contain two integers U and V, representing an undirected edge between the two nodes.

Constraints
1 <= N <= 200000
0 <= M < N
1 <= U, V <= N
The given nodes and edges represent some trees (maybe 1)Output a single integer, the cost of merging these trees.Sample Input
7 3
1 2
3 4
4 5

Sample Output
13

Explanation: 
The four trees are as follows:
1 --- 2 ; 3 --- 4 --- 5 ; 6 ; 7
We will first add an edge from 6 to 7. (Cost of merging = 2)
The three remaining trees are as follows:
1 --- 2 ; 3 --- 4 --- 5 ; 6 --- 7
We will add an edge from 2 to 6. (Cost of merging = 4)
The two remaining trees are as follows:
1 --- 2 --- 6 --- 7 ; 3 --- 4 --- 5
We will add an edge from 7 to 3. (Cost of merging = 7)
Total cost of merging = 2 + 4 + 7 = 13.

Sample Input
2 1
1 2

Sample Output
0, I have written this Solution Code: #include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(int i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define ld long double
#define int long long
#define double long double
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pi 3.141592653589793238
const int MOD = 1e9+7;
const int INF = 1LL<<60;


const int N = 2e5+5;

// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

vector<int> adj[N];
priority_queue<int, vector<int>, greater<int> > pq;

int ct = 0;
bool vis[N];

void dfs(int u, int p){
    ct++;
    vis[u]=true;
    for(int v: adj[u]){
        if(v != p){
            dfs(v, u);
        }
    }
}

void solve(){
    int n, m; cin>>n>>m;
    For(i, 0, m){
        int u, v; cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    For(i, 1, n+1){
        if(!vis[i]){
            ct = 0;
            dfs(i, 0);
            pq.push(ct);
        }
    }
    int ans = 0;
    while(sz(pq) > 1){
        int c1 = pq.top();
        pq.pop();
        int c2 = pq.top();
        pq.pop();
        ans += (c1+c2);
        pq.push(c1+c2);
    }
    assert(pq.top() == n);
    cout<<ans;
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}

, In this Programming Language: C++, Now tell me if this Code is compilable or not?