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: import heapq
def dfs(adjlist,vis,node):
	global temparr
	temparr.append(node)
	vis[node] = True
	for i in adjlist[node]:
		if not vis[i]:
			dfs(adjlist,vis,i)
	
ne=list(map(int,input().rstrip().split()))
n=ne[0]
e=ne[1]

adjlist = [[] for i in range(n+1)]

for i in range(e):
	edge = list(map(int,input().rstrip().split()))
	adjlist[edge[0]].append(edge[1])
	adjlist[edge[1]].append(edge[0])

vis = [False for i in range(n+1)]

temparr=[]

mx = 0
arr=[]
for x in range(1,n+1):
	if vis[x] == False:
		temparr = []
		dfs(adjlist,vis,x)
		arr.append(len(temparr))

heapq.heapify(arr)
while len(arr)>=2:
	a=heapq.heappop(arr)
	b=heapq.heappop(arr)
	mx+=a+b
	heapq.heappush(arr,a+b)
print(mx), In this Programming Language: Python, Now tell me if this Code is compilable or not?