func_code_string: #include <bits/stdc++.h>   using namespace std;   int high[500005], ata[500005], cost[500005], par[500005], der[500005];   long long ans;   vector<int> v[500005];   int n, k, m, x, y, z;   vector<pair<int, pair<int, int> > > e;   int bul(int node, int ar[]) {     if (node == ar[node]) return node;     return ar[node] = bul(ar[node], ar);   }   void update(int a, int b, int cst) {     a = bul(a, high);     b = bul(b, high);     while (a != b) {       if (der[a] < der[b]) swap(a, b);       cost[a] = cst;       a = high[a] = bul(par[a], high);     }   }   void dfs(int node, int ata) {     par[node] = ata;     der[node] = der[ata] + 1;     for (int i : v[node])       if (i != ata) dfs(i, node);   }   int main() {     scanf( %d %d %d , &n, &k, &m);     for (int i = 1; i <= n; i++) ata[i] = i;     for (int i = 1; i <= k; i++) {       scanf( %d %d , &x, &y);       ata[bul(x, ata)] = bul(y, ata);       v[x].push_back(y);       v[y].push_back(x);     }     for (int i = 1; i <= m; i++) {       scanf( %d %d %d , &x, &y, &z);       e.push_back({z, {x, y}});     }     sort(e.begin(), e.end());     for (int i = 0; i < m; i++) {       pair<int, pair<int, int> > edge = e[i];       if (bul(edge.second.first, ata) != bul(edge.second.second, ata)) {         v[edge.second.first].push_back(edge.second.second);         v[edge.second.second].push_back(edge.second.first);         ata[ata[edge.second.first]] = ata[edge.second.second];         ans -= edge.first;       }     }     dfs(1, 0);     for (int i = 1; i <= n; i++) {       high[i] = i;       cost[i] = 2000000000;     }     for (int i = 0; i < m; i++) {       pair<int, pair<int, int> > edge = e[i];       update(edge.second.first, edge.second.second, edge.first);     }     for (int i = 2; i <= n; i++) {       if (cost[i] == 2000000000) {         printf( -1 );         return 0;       }       ans += cost[i];     }     printf( %lld , ans);   }   