func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6 + 10, N = 2000;   long long m, n, shroo, I[maxn], tmm, id[maxn], J[maxn], W[maxn], Su[maxn],       dp1[maxn], dp2[maxn];   vector<pair<long long, long long> > hel1;   vector<int> tmp, in[maxn], out[maxn];   bool amx(int i, int j) { return id[I[i]] > id[I[j]]; }   void dfs_1(int i) {     id[i] = 1;     for (auto A : out[i])       if (!id[A]) dfs_1(A);     tmp.push_back(i);   }   void dfs_2(int i) {     id[i] = tmm;     for (auto A : in[i])       if (!id[A]) dfs_2(A);   }   void scc() {     for (int y = 1; y <= n; y++)       if (!id[y]) dfs_1(y);     memset(id, 0, sizeof id);     reverse(tmp.begin(), tmp.end());     for (auto A : tmp)       if (!id[A]) tmm++, dfs_2(A);   }   long long gett(long long x) {     int st = 0, en = 2e4 + 5, md, i;     while (st <= en) {       md = st + ((en - st) >> 1);       if (2 * x >= md * (md + 1))         st = md + 1, i = md;       else         en = md - 1;     }     return (i + 1) * x - 1LL * i * (i + 1) * (i + 2) / 6;   }   int main() {     scanf( %d%d , &n, &m);     for (int y = 1; y <= m; y++) {       scanf( %d%d%d , &I[y], &J[y], &W[y]);       in[J[y]].push_back(I[y]);       out[I[y]].push_back(J[y]);       Su[y] = gett(W[y]);     }     scc();     tmp.clear();     cin >> shroo;     for (int y = 1; y <= m; y++)       if (id[I[y]] == id[J[y]]) dp2[id[I[y]]] += Su[y];     for (int y = 1; y <= m; y++)       if (id[I[y]] != id[J[y]]) tmp.push_back(y);     sort(tmp.begin(), tmp.end(), amx);     for (int y = 1; y <= n; y++) dp1[y] = dp2[y];     for (auto A : tmp)       dp1[id[I[A]]] = max(dp1[id[I[A]]], dp2[id[I[A]]] + W[A] + dp1[id[J[A]]]);     printf( %lld , dp1[id[shroo]]);     return 0;   }   