func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 300000 + 100;   int n, m, sz, l, r;   int head[maxn], Next[maxn], to[maxn], in[maxn], out[maxn], deg[maxn], q[maxn];   void init() {     sz = 0;     memset(deg, 0, sizeof(deg));     memset(head, -1, sizeof(head));   }   void add_edge(int a, int b) {     ++sz;     to[sz] = b;     Next[sz] = head[a];     head[a] = sz;   }   struct Edge {     int from, to;   } edges[maxn];   int main() {     init();     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       int a, b;       scanf( %d%d , &a, &b);       edges[i].from = a;       edges[i].to = b;       add_edge(a, b);       deg[b]++;     }     l = r = 0;     for (int i = 1; i <= n; i++) {       if (!deg[i]) {         q[r++] = i;       }     }     while (l < r) {       int u = q[l++];       if (l == r) {         out[u] = n - r;       } else if (l + 1 == r) {         int v = q[l];         int flag = 1;         for (int i = head[v]; i != -1; i = Next[i]) {           int vv = to[i];           if (deg[vv] == 1) {             flag = 0;             break;           }         }         if (!flag)           out[u] = -n;         else           out[u] = n - r;       } else         out[u] = -n;       for (int i = head[u]; i != -1; i = Next[i]) {         int v = to[i];         deg[v]--;         if (!deg[v]) q[r++] = v;       }     }     init();     for (int i = 1; i <= m; i++) {       add_edge(edges[i].to, edges[i].from);       deg[edges[i].from]++;     }     l = r = 0;     for (int i = 1; i <= n; i++) {       if (!deg[i]) {         q[r++] = i;       }     }     while (l < r) {       int u = q[l++];       if (l == r) {         in[u] = n - r;       } else if (l + 1 == r) {         int v = q[l];         int flag = 1;         for (int i = head[v]; i != -1; i = Next[i]) {           int vv = to[i];           if (deg[vv] == 1) {             flag = 0;             break;           }         }         if (!flag)           in[u] = -n;         else           in[u] = n - r;       } else         in[u] = -n;       for (int i = head[u]; i != -1; i = Next[i]) {         int vv = to[i];         deg[vv]--;         if (!deg[vv]) q[r++] = vv;       }     }     int ans = 0;     for (int i = 1; i <= n; i++) {       if (in[i] + out[i] >= n - 2) {         ans++;       }     }     printf( %d n , ans);     return 0;   }   