func_code_string: #include <bits/stdc++.h>   using namespace std;   struct ed {     int a, b, w;   } p[600010];   int n, m, fa[600010], d[600010], ans;   bool cmp(ed a, ed b) { return (a.w > b.w); }   int gf(int x) { return (fa[x] != x) ? fa[x] = gf(fa[x]) : x; }   int main() {     cin >> n >> m;     for (int i = 1; i <= m; i++) cin >> p[i].a >> p[i].b >> p[i].w;     sort(p + 1, p + m + 1, cmp);     for (int i = 1; i <= n; i++) fa[i] = i, d[i] = 1;     for (int i = 1; i <= m; i++) {       int x = gf(p[i].a), y = gf(p[i].b);       if (x != y && d[x] + d[y] > 0)         fa[y] = x, ans += p[i].w, d[x] = d[x] & d[y];       else if (x == y && d[x]) {         d[x] = 0, ans += p[i].w;       }     }     cout << ans << endl;   }   