Language: C++

#include<bits/stdc++.h>
#include<queue>
vector<queue<int>>gra;
vector<int>dp;
vector<int>si;
int path(int x) {
  int &ret = dp[x];
  if (ret != -1) return ret;
  ret = 1;
  for (int i = 0; i < si[x]; i ++) {
    int y = gra[x].front();
    gra[x].pop();
    if (ret < path(y)) ret = path(y);
    gra[x].push(y);
  }
  return y;
}
int main () {
  int N;
  cin >> N;
  gra.resize(N + 1);
  dp.assign(N + 1, -1);
  si.assign(N + 1, 0);
  int M;
  cin >> M;
  for (int i = 0; i < M; i ++) {
    int x, y;
    cin >> x >> y;
    gra[x].push(y);
    si[x] ++;
  }
  int ans = 0;
  for (int i = 1; i <= N; i ++) {
    if (ans < path(i)) ans = path(i);
  }
  cout << ans << endl;
}

Compiler output:
a.cc:3:1: error: 'vector' does not name a type
    3 | vector<queue<int>>gra;
      | ^~~~~~
a.cc:4:1: error: 'vector' does not name a type
    4 | vector<int>dp;
      | ^~~~~~
a.cc:5:1: error: 'vector' does not name a type
    5 | vector<int>si;
      | ^~~~~~
a.cc: In function 'int path(int)':
a.cc:7:14: error: 'dp' was not declared in this scope; did you mean 'dup'?
    7 |   int &ret = dp[x];
      |              ^~
      |              dup
a.cc:10:23: error: 'si' was not declared in this scope; did you mean 'i'?
   10 |   for (int i = 0; i < si[x]; i ++) {
      |                       ^~
      |                       i
a.cc:11:13: error: 'gra' was not declared in this scope
   11 |     int y = gra[x].front();
      |             ^~~
a.cc:16:10: error: 'y' was not declared in this scope
   16 |   return y;
      |          ^
a.cc: In function 'int main()':
a.cc:20:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   20 |   cin >> N;
      |   ^~~
      |   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:21:3: error: 'gra' was not declared in this scope
   21 |   gra.resize(N + 1);
      |   ^~~
a.cc:22:3: error: 'dp' was not declared in this scope; did you mean 'dup'?
   22 |   dp.assign(N + 1, -1);
      |   ^~
      |   dup
a.cc:23:3: error: 'si' was not declared in this scope; did you mean 'sin'?
   23 |   si.assign(N + 1, 0);
      |   ^~
      |   sin
a.cc:36:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   36 |   cout << ans << endl;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:36:18: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   36 |   cout << ans << endl;
      |                  ^~~~
      |                  std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~