func_code_string: #include <bits/stdc++.h>   using namespace std;   const int M = 2e5 + 10;   struct Edge {     int u, v, cap, flow = 0;     Edge(int u, int v, int cap) : u(u), v(v), cap(cap) {}   };   class Dinic {    public:     vector<Edge> edges;     vector<vector<int>> G;     int n, m = 0, s, t;     vector<int> H, ptr;     queue<int> q;     Dinic(int n, int s, int t) : n(n), s(s), t(t) {       G.resize(n + 1);       H = ptr = vector<int>(n + 1);     }     void add(int u, int v, int cap) {       edges.emplace_back(u, v, cap);       edges.emplace_back(v, u, 0);       G[u].push_back(m++);       G[v].push_back(m++);     }     bool bfs() {       while (!q.empty()) {         int u = q.front();         q.pop();         for (int v : G[u]) {           int to = edges[v].v;           int gap = edges[v].cap - edges[v].flow;           if (H[to] != -1 or gap < 1) continue;           H[to] = H[u] + 1, q.push(to);         }       }       return H[t] != -1;     }     int dfs(int u, int X) {       if (!X) return 0;       if (u == t) return X;       for (int &i = ptr[u]; i < (int)(G[u]).size(); ++i) {         int v = G[u][i], to = edges[v].v;         int gap = edges[v].cap - edges[v].flow;         if (H[to] != (H[u] + 1) or gap < 1) continue;         int Y = dfs(to, min(X, gap));         if (!Y) continue;         edges[v].flow += Y;         edges[v ^ 1].flow -= Y;         return Y;       }       return 0;     }     int flow() {       int ans = 0;       while (true) {         fill(H.begin(), H.end(), -1);         H[s] = 0, q.push(s);         if (!bfs()) break;         fill(ptr.begin(), ptr.end(), 0);         while (int X = dfs(s, (int)(1e18))) ans += X;       }       return ans;     }   };   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n, m;     cin >> n >> m;     vector<pair<int, pair<int, int>>> edges;     vector<int> cand;     for (int i = 0; i < m; ++i) {       int u, v, w;       cin >> u >> v >> w;       edges.push_back({w, {u, v}});       cand.push_back(w);     }     sort((cand).begin(), (cand).end());     cand.erase(unique((cand).begin(), (cand).end()), cand.end());     int lo = 0, hi = (int)(cand).size() - 1, mid, ans = -1;     int s = 0, t = 2 * n + 1;     while (lo <= hi) {       mid = (lo + hi) >> 1;       Dinic dinic(2 * n + 2, s, t);       for (int i = 1; i <= n; ++i) {         dinic.add(s, i, 1);         dinic.add(i + n, t, 1);       }       for (auto [w, p] : edges)         if (w <= cand[mid]) dinic.add(p.first, p.second + n, 1);       int x = dinic.flow();       if (x == n)         hi = mid - 1, ans = cand[mid];       else         lo = mid + 1;     }     cout << ans;     return 0;   }   