func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename T>   inline void read(T &x) {     int f = 0, c = getchar();     x = 0;     while (!isdigit(c)) f |= c == 45, c = getchar();     while (isdigit(c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();     if (f) x = -x;   }   template <typename T, typename... Args>   inline void read(T &x, Args &...args) {     read(x);     read(args...);   }   const int maxn = 2e5 + 50;   int fa[maxn], bj[maxn], n, m, ans;   struct node {     int x, y, z;   } e[maxn];   bool cmp(node a, node b) { return a.z > b.z; }   inline int find(int x) {     if (fa[x] == x) return x;     return fa[x] = find(fa[x]);   }   signed main() {     read(n, m);     for (int i = 1; i <= n; i++) fa[i] = i;     for (int i = 1; i <= m; i++) read(e[i].x, e[i].y, e[i].z);     stable_sort(e + 1, e + 1 + m, cmp);     for (int i = 1; i <= m; i++) {       int f1 = find(e[i].x), f2 = find(e[i].y);       if (f1 == f2) {         if (bj[f1] == 0)           bj[f1] = 1, ans += e[i].z;         else           continue;       } else {         if (bj[f1] + bj[f2] == 0) fa[f1] = f2, ans += e[i].z;         if (bj[f1] == 1 && bj[f2] == 0) fa[f2] = f1, ans += e[i].z;         if (bj[f1] == 0 && bj[f2] == 1) fa[f1] = f2, ans += e[i].z;       }     }     cout << ans;     return 0;   }   