Segmentation fault while applying Kruskal's algorithm

I saw the Kruskal’s code from the videos and implemented it on my system. The code gave the following error: “Segmentation fault (core dumped)”, when I ran it on a custom input. The input is as follows:
5 5
1 2 5
1 3 2
3 4 1
1 4 6
3 5 5

Link for the code: https://ide.codingblocks.com/s/107290