func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 10;   map<pair<int, int>, int> weight;   vector<int> edges[MAXN];   bool visited[MAXN];   long long int maximum;   void dfs(int v, long long int sum) {     visited[v] = true;     maximum = max(maximum, sum);     for (int i : edges[v]) {       if (!visited[i]) dfs(i, sum + weight[make_pair(v, i)]);     }     return;   }   int main() {     long long int n, a, b, c, sum_of_edges = 0;     cin >> n;     for (int i = 0; i < n - 1; i++) {       cin >> a >> b >> c;       sum_of_edges += c;       a--;       b--;       edges[a].push_back(b);       edges[b].push_back(a);       weight[make_pair(a, b)] = c;       weight[make_pair(b, a)] = c;     }     dfs(0, 0);     sum_of_edges *= 2;     sum_of_edges -= maximum;     cout << sum_of_edges << endl;     return 0;   }   