func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d n , &n);     set<int> in, x;     long totalCost(0), cost(0);     while (n--) {       int a, b, c;       scanf( %d %d %d n , &a, &b, &c);       totalCost += c;       if (in.count(a) || x.count(b)) {         cost += c;         x.insert(a);         in.insert(b);       } else {         in.insert(a);         x.insert(b);       }     }     if (totalCost - cost < cost) {       cost = totalCost - cost;     }     printf( %ld n , cost);     return 0;   }   