func_code_string: #include <bits/stdc++.h>   #pragma comment(linker,  /STACK:1024000000,1024000000 )   using namespace std;   const int inf = 0x3f3f3f3f;   const long long INF = 1e18;   template <typename T>   void read(T &x) {     x = 0;     int s = 1, c = getchar();     for (; !isdigit(c); c = getchar())       if (c ==  - ) s = -1;     for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;     x *= s;   }   template <typename T>   void write(T x) {     if (x < 0) x = -x, putchar( - );     if (x > 9) write(x / 10);     putchar(x % 10 +  0 );   }   template <typename T>   void writeln(T x) {     write(x);     puts(  );   }   const int maxn = 1e5 + 5, maxm = 1e6 + 5;   struct Edge {     int u, v, c, id;     bool operator<(const Edge &rhs) const { return c < rhs.c; }   } e[maxm];   int n, m;   int fa[maxn];   vector<pair<int, int> > adj[maxn];   int f[maxn][20], dis[maxn][20], d[maxn];   vector<Edge> v;   int find(int v) { return v == fa[v] ? v : fa[v] = find(fa[v]); }   void dfs(int u, int fa) {     d[u] = d[fa] + 1;     for (pair<int, int> x : adj[u])       if (x.first ^ fa) {         int v = x.first, c = x.second;         f[v][0] = u;         dis[v][0] = c;         dfs(v, u);       }   }   int LCA(int x, int y, int op) {     int res = 0;     if (d[x] > d[y]) swap(x, y);     for (int t = 19; t >= 0; t--)       if (d[x] <= d[f[y][t]]) {         res = max(res, dis[y][t]);         y = f[y][t];       }     if (x == y) return op ? res : x;     for (int t = 19; t >= 0; t--)       if (f[x][t] != f[y][t]) {         res = max(res, max(dis[x][t], dis[y][t]));         x = f[x][t], y = f[y][t];       }     res = max(res, max(dis[x][0], dis[y][0]));     return op ? res : f[x][0];   }   int main() {     read(n), read(m);     for (int i = 1; i <= m; i++) {       read(e[i].u), read(e[i].v), read(e[i].c);       e[i].id = i;     }     sort(e + 1, e + 1 + m);     for (int i = 1; i <= n; i++) fa[i] = i;     for (int i = 1; i <= m; i++) {       int p = find(e[i].u), t = find(e[i].v);       if (p != t) {         adj[e[i].u].emplace_back(e[i].v, e[i].c);         adj[e[i].v].emplace_back(e[i].u, e[i].c);         fa[p] = t;       } else         v.emplace_back(e[i]);     }     dfs(1, 0);     for (int j = 1; j <= 19; j++)       for (int i = 1; i <= n; i++) {         f[i][j] = f[f[i][j - 1]][j - 1];         dis[i][j] = max(dis[i][j - 1], dis[f[i][j - 1]][j - 1]);       }     sort((v.begin()), (v.end()), [&](Edge x, Edge y) { return x.id < y.id; });     for (auto i : v) {       int lca = LCA(i.u, i.v, 0);       printf( %d n , max(LCA(i.u, lca, 1), LCA(i.v, lca, 1)));     }   }   