Language: C++

using namespace std;

//from https://misora192.hatenablog.com/entry/2019/01/09/074031
int n,m;
const int max_n=1e5+10;
vector<int> g[max_n];
bool used[max_n];
vector<int> v;

void dfs(int u) {
    if (used[u]) return;
    used[u]=true;
    for (int i: g[u]) dfs(i);
    v.push_back(u);
}

void tsort() {
    for (int i=0;i<n;i++) dfs(i);
    reverse(v.begin(), v.end());
}

int main(){
    int mod=1000000007;
    scanf("%d %d",&n,&m);
    for (int i=0;i<n;i++) {
        int x,y;
        scanf("%d %d",&x,&y);
        x--;
        y--;
        g[x].push_back(y);
    }
    tsort();
    reverse(v.begin(), v.end());
    vector<int> dp(n,0);
    int ans=0;
    for (int i: v) {
        for (int u: g[i]) {
            dp[i]=max(dp[i],dp[u]+1);
        }
        ans=max(ans,dp[i]);
    }
    printf("%d\n",ans);
    return 0;
}

Compiler output:
a.cc:6:1: error: 'vector' does not name a type
    6 | vector<int> g[max_n];
      | ^~~~~~
a.cc:8:1: error: 'vector' does not name a type
    8 | vector<int> v;
      | ^~~~~~
a.cc: In function 'void dfs(int)':
a.cc:13:17: error: 'g' was not declared in this scope
   13 |     for (int i: g[u]) dfs(i);
      |                 ^
a.cc:14:5: error: 'v' was not declared in this scope
   14 |     v.push_back(u);
      |     ^
a.cc: In function 'void tsort()':
a.cc:19:13: error: 'v' was not declared in this scope
   19 |     reverse(v.begin(), v.end());
      |             ^
a.cc:19:5: error: 'reverse' was not declared in this scope
   19 |     reverse(v.begin(), v.end());
      |     ^~~~~~~
a.cc: In function 'int main()':
a.cc:24:5: error: 'scanf' was not declared in this scope
   24 |     scanf("%d %d",&n,&m);
      |     ^~~~~
a.cc:30:9: error: 'g' was not declared in this scope
   30 |         g[x].push_back(y);
      |         ^
a.cc:33:13: error: 'v' was not declared in this scope
   33 |     reverse(v.begin(), v.end());
      |             ^
a.cc:33:5: error: 'reverse' was not declared in this scope
   33 |     reverse(v.begin(), v.end());
      |     ^~~~~~~
a.cc:34:5: error: 'vector' was not declared in this scope
   34 |     vector<int> dp(n,0);
      |     ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | using namespace std;
a.cc:34:12: error: expected primary-expression before 'int'
   34 |     vector<int> dp(n,0);
      |            ^~~
a.cc:37:21: error: 'g' was not declared in this scope
   37 |         for (int u: g[i]) {
      |                     ^
a.cc:38:13: error: 'dp' was not declared in this scope
   38 |             dp[i]=max(dp[i],dp[u]+1);
      |             ^~
a.cc:38:19: error: 'max' was not declared in this scope
   38 |             dp[i]=max(dp[i],dp[u]+1);
      |                   ^~~
a.cc:40:21: error: 'dp' was not declared in this scope
   40 |         ans=max(ans,dp[i]);
      |                     ^~
a.cc:40:13: error: 'max' was not declared in this scope
   40 |         ans=max(ans,dp[i]);
      |             ^~~
a.cc:42:5: error: 'printf' was not declared in this scope
   42 |     printf("%d\n",ans);
      |     ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | using namespace std;