criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include<bits/stdc++.h>
using namespace std;
void dfs(vector<int> g, bool vis[], int s, int dp[]){
  vis[s]=true;
  for(auto i::g[s]){
    if(!vis[i]){
      dfs(g, vis, i, dp);
    }
    dp[s]=max(dp[s], ++dp[i]);
  }
}
int main(){
  int n, m, x, y;
  cin>>n>>m;
  vector<int> g[n+1];
  int dp[n+1];
  memset(dp, 0, sizeof(dp));
  for(int i=0;i<m;i++){
    cin>>x>>y;
    g[x].push_back(y);
  }
  bool vis[n+1];
  memset(vis, false, sizeof(vis));
  for(int i=1;i<=n;i++){
    if(!vis[i])
      dfs(g,vis,i,dp);
  }
  int ans=0;
  for(int i=1;i<=n;i++){
    ans=max(ans, dp[i]);
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'void dfs(std::vector<int>, bool*, int, int*)':
a.cc:5:12: error: 'i' has not been declared
    5 |   for(auto i::g[s]){
      |            ^
a.cc:5:16: error: qualified-id in declaration before '[' token
    5 |   for(auto i::g[s]){
      |                ^
a.cc:5:16: error: expected ';' before '[' token
    5 |   for(auto i::g[s]){
      |                ^
      |                ;
a.cc: In lambda function:
a.cc:5:19: error: expected '{' before ')' token
    5 |   for(auto i::g[s]){
      |                   ^
a.cc: In function 'void dfs(std::vector<int>, bool*, int, int*)':
a.cc:5:16: error: could not convert '<lambda closure object>dfs(std::vector<int>, bool*, int, int*)::<lambda()>{s}' from 'dfs(std::vector<int>, bool*, int, int*)::<lambda()>' to 'bool'
    5 |   for(auto i::g[s]){
      |                ^~~
      |                |
      |                dfs(std::vector<int>, bool*, int, int*)::<lambda()>
a.cc:5:19: error: expected ';' before ')' token
    5 |   for(auto i::g[s]){
      |                   ^
      |                   ;
a.cc:6:13: error: 'i' was not declared in this scope
    6 |     if(!vis[i]){
      |             ^
a.cc:9:27: error: 'i' was not declared in this scope
    9 |     dp[s]=max(dp[s], ++dp[i]);
      |                           ^
a.cc: In function 'int main()':
a.cc:26:11: error: could not convert '(std::vector<int>*)(& g)' from 'std::vector<int>*' to 'std::vector<int>'
   26 |       dfs(g,vis,i,dp);
      |           ^
      |           |
      |           std::vector<int>*
a.cc:33:2: error: expected '}' at end of input
   33 | }
      |  ^
a.cc:12:11: note: to match this '{'
   12 | int main(){
      |           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
void dfs(vector<int> g, bool vis[], int s, int dp[]){
  vis[s]=true;
  for(auto it::g[s]){
    if(!vis[it]){
      dfs(g, vis, it, dp);
    }
    dp[s]=max(dp[s], ++dp[it]);
  }
}
int main(){
  int n, m, x, y;
  cin>>n>>m;
  vector<int> g[n+1];
  int dp[n+1];
  memset(dp, 0, sizeof(dp));
  for(int i=0;i<m;i++){
    cin>>x>>y;
    g[x].push_back(y);
  }
  bool vis[n+1];
  memset(vis, false, sizeof(vis));
  for(int i=1;i<=n;i++){
    if(!vis[i])
      dfs(g,vis,i,dp);
  }
  int ans=0;
  for(int i=1;i<=n;i++){
    ans=max(ans, dp[i]);
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'void dfs(std::vector<int>, bool*, int, int*)':
a.cc:5:12: error: 'it' has not been declared
    5 |   for(auto it::g[s]){
      |            ^~
a.cc:5:17: error: qualified-id in declaration before '[' token
    5 |   for(auto it::g[s]){
      |                 ^
a.cc:5:17: error: expected ';' before '[' token
    5 |   for(auto it::g[s]){
      |                 ^
      |                 ;
a.cc: In lambda function:
a.cc:5:20: error: expected '{' before ')' token
    5 |   for(auto it::g[s]){
      |                    ^
a.cc: In function 'void dfs(std::vector<int>, bool*, int, int*)':
a.cc:5:17: error: could not convert '<lambda closure object>dfs(std::vector<int>, bool*, int, int*)::<lambda()>{s}' from 'dfs(std::vector<int>, bool*, int, int*)::<lambda()>' to 'bool'
    5 |   for(auto it::g[s]){
      |                 ^~~
      |                 |
      |                 dfs(std::vector<int>, bool*, int, int*)::<lambda()>
a.cc:5:20: error: expected ';' before ')' token
    5 |   for(auto it::g[s]){
      |                    ^
      |                    ;
a.cc:6:13: error: 'it' was not declared in this scope; did you mean 'int'?
    6 |     if(!vis[it]){
      |             ^~
      |             int
a.cc:9:27: error: 'it' was not declared in this scope; did you mean 'int'?
    9 |     dp[s]=max(dp[s], ++dp[it]);
      |                           ^~
      |                           int
a.cc: In function 'int main()':
a.cc:26:11: error: could not convert '(std::vector<int>*)(& g)' from 'std::vector<int>*' to 'std::vector<int>'
   26 |       dfs(g,vis,i,dp);
      |           ^
      |           |
      |           std::vector<int>*
a.cc:33:2: error: expected '}' at end of input
   33 | }
      |  ^
a.cc:12:11: note: to match this '{'
   12 | int main(){
      |           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
void dfs(vector<int> g, bool vis[], int s, int dp[]){
  vis[s]=true;
  for(auto it=g[s].begin();it!=g[s].end();++it){
    if(!vis[it]){
      dfs(g, vis, s]it, dp);
    }
    dp[s]=max(dp[s], ++dp[it]);
  }
}
int main(){
  int n, m, x, y;
  cin>>n>>m;
  vector<int> g[n+1];
  int dp[n+1];
  memset(dp, 0, sizeof(dp));
  for(int i=0;i<m;i++){
    cin>>x>>y;
    g[x].push_back(y);
  }
  bool vis[n+1];
  memset(vis, false, sizeof(vis));
  for(int i=1;i<=v;i++){
    if(!vis[i])
      dfs(g,vis,i,dp);
  }
  int ans=0;
  for(int i=1;i<=v;i++){
    ans=max(ans, dp[i]);
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'void dfs(std::vector<int>, bool*, int, int*)':
a.cc:5:20: error: request for member 'begin' in 'g.std::vector<int>::operator[](((std::vector<int>::size_type)s))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
    5 |   for(auto it=g[s].begin();it!=g[s].end();++it){
      |                    ^~~~~
a.cc:5:37: error: request for member 'end' in 'g.std::vector<int>::operator[](((std::vector<int>::size_type)s))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
    5 |   for(auto it=g[s].begin();it!=g[s].end();++it){
      |                                     ^~~
a.cc:7:20: error: expected ')' before ']' token
    7 |       dfs(g, vis, s]it, dp);
      |          ~         ^
      |                    )
a.cc: In function 'int main()':
a.cc:24:18: error: 'v' was not declared in this scope
   24 |   for(int i=1;i<=v;i++){
      |                  ^
a.cc:26:11: error: could not convert '(std::vector<int>*)(& g)' from 'std::vector<int>*' to 'std::vector<int>'
   26 |       dfs(g,vis,i,dp);
      |           ^
      |           |
      |           std::vector<int>*
a.cc:29:18: error: 'v' was not declared in this scope
   29 |   for(int i=1;i<=v;i++){
      |                  ^
a.cc:33:2: error: expected '}' at end of input
   33 | }
      |  ^
a.cc:12:11: note: to match this '{'
   12 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int dp[100005];
void dfs(vector<int> adj[],bool vis[],int src)
{
    vis[src]=true;
    for(auto x:adj[src])
    {
        if(!vis[x])
        {
            dfs(adj,vis,src);
        }
        dp[src]=max(dp[src],1+dp[x]);
    }
}
int main()
{
    int v,e;
    cin>>v>>e;
    vector<int>adj[v];
    int i,j,k;
    for(i=0;i<e;i++)
    {
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
    }
    bool vis[v+1];
    memset(vis,false,sizeof(vis));
    for(i=1;i<=n;i++)
    {
        if(!vis[i])
        dfs(adj,vis,i)
    }
    int ans=0;
    for(i=1;i<=n;i++)
    ans=max(ans,dp[i]);
    cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:16: error: 'n' was not declared in this scope
   30 |     for(i=1;i<=n;i++)
      |                ^
a.cc:33:23: error: expected ';' before '}' token
   33 |         dfs(adj,vis,i)
      |                       ^
      |                       ;
   34 |     }
      |     ~                  
a.cc:36:16: error: 'n' was not declared in this scope
   36 |     for(i=1;i<=n;i++)
      |                ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
vector<int> ar[100001];
vector<int> dp(100001,-1);
void solve(int n)
{
  int i,j;
  if(ar[n].empty())
  {
    dp[n]=0;
    return;
  }
  for(i=0;i<ar[n].size();i++)
  {
    if(dp[ar[n][i]]==-1)
      solve(dp[ar[n][i]]);
    dp[n]=max(dp[n],dp[ar[n][i]]+1);
  }
  return;
}

int main()
{
  int i,n,m,x,y,ans=0;
  cin>>n>>m;
  vector<int> ar[n+1];
  for(i=0;i<n;i++)
  {
    cin>>x>>y;
    ar[x].push_back(y);
  }
  for(i=1;i<=n;i++)
  {
    if(dp[i]!=-1)
      continue;
    k=solve(i);
   ans=max(k,ans);
  }
  cout<<ans<<endl;
  return 0;
}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:36:5: error: 'k' was not declared in this scope
   36 |     k=solve(i);
      |     ^
Language: C++

dp[vertex]=max(dp[vertex],1+dp[child]);#include "bits/stdc++.h"
using namespace std;
#define ll long long
vector<int>dp(100001);
int n ,m,x,y;
int vis[100001]={0};
vector<int>g[100001];
void solve(int vertex)
{
    vis[vertex]=1;
    dp[vertex]=0;
    for(int child:g[vertex])
    {
        if(!vis[child])
        {
            solve(child);
        }
       dp[vertex]=max(dp[vertex],1+dp[child]);
    }

}
int main()
{
    cin>>n>>m;
    for(ll i=0;i<m;i++)
    {
        cin>>x>>y;
        g[x].push_back(y);
    }
    for(ll i=1;i<=n;i++)
    {
        if(!vis[i])
        {
          solve(i);
        }
    }
    int ans=0;
   for(int i=1;i<=n;i++)
   {
       ans=max(ans,dp[i]);
   }
   cout<<ans;
}


Compiler output:
a.cc:1:40: error: stray '#' in program
    1 | dp[vertex]=max(dp[vertex],1+dp[child]);#include "bits/stdc++.h"
      |                                        ^
a.cc:1:1: error: 'dp' does not name a type
    1 | dp[vertex]=max(dp[vertex],1+dp[child]);#include "bits/stdc++.h"
      | ^~
a.cc:1:41: error: 'include' does not name a type
    1 | dp[vertex]=max(dp[vertex],1+dp[child]);#include "bits/stdc++.h"
      |                                         ^~~~~~~
a.cc:4:1: error: 'vector' does not name a type
    4 | vector<int>dp(100001);
      | ^~~~~~
a.cc:7:1: error: 'vector' does not name a type
    7 | vector<int>g[100001];
      | ^~~~~~
a.cc: In function 'void solve(int)':
a.cc:11:5: error: 'dp' was not declared in this scope
   11 |     dp[vertex]=0;
      |     ^~
a.cc:12:19: error: 'g' was not declared in this scope
   12 |     for(int child:g[vertex])
      |                   ^
a.cc:18:19: error: 'max' was not declared in this scope
   18 |        dp[vertex]=max(dp[vertex],1+dp[child]);
      |                   ^~~
a.cc: In function 'int main()':
a.cc:24:5: error: 'cin' was not declared in this scope
   24 |     cin>>n>>m;
      |     ^~~
a.cc:28:9: error: 'g' was not declared in this scope
   28 |         g[x].push_back(y);
      |         ^
a.cc:40:20: error: 'dp' was not declared in this scope
   40 |        ans=max(ans,dp[i]);
      |                    ^~
a.cc:40:12: error: 'max' was not declared in this scope
   40 |        ans=max(ans,dp[i]);
      |            ^~~
a.cc:42:4: error: 'cout' was not declared in this scope
   42 |    cout<<ans;
      |    ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long	
const int maxi=1e5+5;

vector<int> adj[maxi];
int n,m;
vector<int> dist(maxi,-1);

void dfs(int s, int d)
{
	dist[s]=max(dist[s],d);
	
	for(auto u:adj[s])
	{
		dfs(u,d+1);
	}
}

int main()
{
	cin>>n>>m;
	int x,y;
	for(int i=0;i<m;i++)
	{
		cin>>x>>y;
		adj[x].push_back(y);
	}
	
	for(int i=1;i<=n;i++)
	{
		if(adj[i].size()>0&&dist[s]==-1)
		dfs(i,0);
	}
	int ans=-1;
	for(int i=1;i<=n;i++)
	ans=max(ans,dist[i]);
	
	cout<<ans;
		
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:42: error: 's' was not declared in this scope
   32 |                 if(adj[i].size()>0&&dist[s]==-1)
      |                                          ^
Language: C++

#include <iostream>
#include <vector>
using namespace std;

vector<int> graph[100001];
int dp[100001];

int solve(int src){
    if(dp[src]!=-1)
        return dp[src];

    if(graph[src].size()==0){
        return 0;
    }

    bool leaf = true;
    int best = 0;
    for(int child:graph[src]){
        leaf = false;
        best = max(best, solve(child));
    }

    return leaf ? 0 : 1+ best;
}

int main() {
    memset(dp, -1, sizeof dp);
    int n, m;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >>b;
        graph[a].push_back(b);
    }

    int ans = 0;
    for(int i=1;i<=n;i++){
        int res = solve(i);
        ans = max(ans, res);
    }

    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:5: error: 'memset' was not declared in this scope
   27 |     memset(dp, -1, sizeof dp);
      |     ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <vector>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: C++

#include<bits/stdc++.h>
#define ll long long
using namespace std;

vector<int> V[200005];
int indegree[200005];
int bio[200005];
int dp[200005];

void dfs(int a) {
    bio[a]=1;
    for (b : V[a]) {
        dp[b]=max(dp[b],dp[a]+1);
        indegree[b]--;
        if (!indegree[b]) {dfs(b);}
    }
}

int main() {
    int n,m,sol,a,b;
    cin >> n >> m;
    for (int i=0;i<m;i++) {
        cin >> a >> b;
        V[a].push_back(b);
        indegree[b]++;
    }

    for (int i=1;i<=n;i++) {
        if (indegree[i]==0 && bio[i]==0) {
            dfs(i);
        }
    }

    for (int i=1;i<=n;i++) {sol=max(sol,dp[i]);}

    cout << sol << endl;
}


Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:12:12: error: found ':' in nested-name-specifier, expected '::'
   12 |     for (b : V[a]) {
      |            ^
      |            ::
a.cc:12:10: error: 'b' has not been declared
   12 |     for (b : V[a]) {
      |          ^
a.cc:17:1: error: expected primary-expression before '}' token
   17 | }
      | ^
a.cc:16:6: error: expected ';' before '}' token
   16 |     }
      |      ^
      |      ;
   17 | }
      | ~     
a.cc:17:1: error: expected primary-expression before '}' token
   17 | }
      | ^
a.cc:16:6: error: expected ')' before '}' token
   16 |     }
      |      ^
      |      )
   17 | }
      | ~     
a.cc:12:9: note: to match this '('
   12 |     for (b : V[a]) {
      |         ^
a.cc:17:1: error: expected primary-expression before '}' token
   17 | }
      | ^
Language: C++

#include "bits/stdc++.h"
#define ll long long int
#define mp(a, b) make_pair(a, b)
using namespace std;
typedef pair<ll, ll> pairs;
typedef pair<ll, pairs> tpl;
vector<ll> v[100001];
bool visit[100001];
ll dp[100001];
void dfs(ll node)
{
	visit[node] = 1;
	for (auto i : v[node])
	{
		if (!visit[i])
			dfs(i);
		dp[node] = max(dp[node], 1 + dp[i]);
	}
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll n, m;
	cin >> n >> m;
	while (m--)
	{
		ll x, y;
		cin >> x >> y;
		v[x].push_back(y);
	}
	for (ll i = 1; i <= n; i++)
		if (!visit[i])
			dfs(i);
	ll ans = 0;
	for (ll i = 1; i <= n; i++)
		ans = max(ans, dp[i]);
	cout << ans;
}


Compiler output:
a.cc: In function 'void dfs(long long int)':
a.cc:12:9: error: reference to 'visit' is ambiguous
   12 |         visit[node] = 1;
      |         ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:8:6: note:                 'bool visit [100001]'
    8 | bool visit[100001];
      |      ^~~~~
a.cc:15:22: error: reference to 'visit' is ambiguous
   15 |                 if (!visit[i])
      |                      ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:8:6: note:                 'bool visit [100001]'
    8 | bool visit[100001];
      |      ^~~~~
a.cc: In function 'int main()':
a.cc:33:22: error: reference to 'visit' is ambiguous
   33 |                 if (!visit[i])
      |                      ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:8:6: note:                 'bool visit [100001]'
    8 | bool visit[100001];
      |      ^~~~~
Language: C++

#include "bits/stdc++.h"
using namespace std;

int dp[100005];
bool visited[100005];
vector<int> adj[100005];

void visit(int vertex){
	visited[vertex] = 1;
	dp[vertex] = 0;
	for(int child:adj[vertex]){
		if(!visited[child]){
			visit(child);
		}
		dp[vertex] = max(dp[vertex] , 1 + dp[child]);
	}
}

int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		adj[x].push_back(y);
	}
	
  int ans = 0;
	for(int i = 1; i <= n; i++){
		if(!visited[i]){
			visit(i);
          ans = max(ans, dp[i]);
		}
	}
	
	
	
	}
	
	cout<<ans;
	
}


Compiler output:
a.cc:40:9: error: 'cout' does not name a type
   40 |         cout<<ans;
      |         ^~~~
a.cc:42:1: error: expected declaration before '}' token
   42 | }
      | ^
Language: C++

#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <array>
#define ll long long
#define ar array
using namespace std;
const int N = 1e5;
string a, b;
int dp[N];
vector<ar<int, 2>> adj;

int main(){
    ios_base::sync_with_stdio(0);
    int n, m;
    cin>>n>>m;
    adj.reserve(m);

    for(int i=0; i<m; i++){
        int u, v;
        cin>>u>>v;
        adj.push_back({u,v});
    }

    int result = 0;

    for(int j=0; j<n-1; j++){
        for(auto p : adj){
            int u = p[0], v = p[1]
            if(dp[v] < dp[u]+1){
                dp[v] = dp[u]+1;
                result = max(result, dp[v]);
            }
        }
    }
    cout<<result<<endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:13: error: expected ',' or ';' before 'if'
   31 |             if(dp[v] < dp[u]+1){
      |             ^~
Language: C++

#include <bits/stdc++.h>

#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

//#define max(a,b) a>b?a:b
//#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int sum() { return 0; }

template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }



vector<vector<int> > gr[100005;
int dp[100005];
int n,m;
ll cnt =0;
ll dfs(int i){
	if(dp[i] != -1) return dp[i];
	cnt = 0;
	for (int j = 0; j < gr[i].size(); ++j)
	{	int f = gr[i][j];
		//if(vis[f] != true){
			//cnt++;
			cnt =  max(cnt ,  dfs(f) + 1);
		//}
	}
	return dp[i] = cnt;



}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cin>>n>>m;
	//vis.assign(n ,false);
	//gr.assign( n , vector<int>());
	int a,b;
	for (int i = 0; i < m; ++i)
	{
		cin>>a>>b;
		a--;b--;
		gr[a].push_back(b);
	}
	ll ans = -1;
	REP(i,n)dp[i] = -1;
	for (int i = 0; i < n; ++i)
	{	cnt = 0;
	     //vis.clear();
	     //vis.assign(n , false);

		 ans = max(ans , (ll)dfs(i));
	}
	cout<<ans<<"\n"; 
	return 0;
}


Compiler output:
a.cc:38:31: error: expected ']' before ';' token
   38 | vector<vector<int> > gr[100005;
      |                               ^
      |                               ]
a.cc: In function 'long long int dfs(int)':
a.cc:45:29: error: 'gr' was not declared in this scope
   45 |         for (int j = 0; j < gr[i].size(); ++j)
      |                             ^~
a.cc: In function 'int main()':
a.cc:68:17: error: 'gr' was not declared in this scope
   68 |                 gr[a].push_back(b);
      |                 ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define MAX 100005

vector<int>adj[MAX];

int dp[MAX];
bool visit[MAX];

void dfs(int a)
{
    dp[a]=0;

   visit[a]=true;

   for(auto x:adj[a])
   {
       if(!visit[x])
       dfs(x);

       dp[a]=max(dp[a],1+dp[x]);
   }

}

int main() {
    int n,e;
    cin>>n>>e;

    int i,a,b;
    for(i=0;i<e;i++)
    {
     cin>>a>>b;
     adj[a].push_back(b);
    }
for(i=1;i<=n;i++)
{
    if(!visit[i])
    dfs(i);
}
int ans=0;
for(i=1;i<=n;i++)
{
    ans=max(ans,dp[i]);
}
cout<<ans<<endl;
 
         
    


 


}


Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:14:4: error: reference to 'visit' is ambiguous
   14 |    visit[a]=true;
      |    ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:8:6: note:                 'bool visit [100005]'
    8 | bool visit[MAX];
      |      ^~~~~
a.cc:18:12: error: reference to 'visit' is ambiguous
   18 |        if(!visit[x])
      |            ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:8:6: note:                 'bool visit [100005]'
    8 | bool visit[MAX];
      |      ^~~~~
a.cc: In function 'int main()':
a.cc:38:9: error: reference to 'visit' is ambiguous
   38 |     if(!visit[i])
      |         ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:8:6: note:                 'bool visit [100005]'
    8 | bool visit[MAX];
      |      ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
vector<bool> in, visit;
vector<int> adj[100009], go;
int mx = -1;

void dfs(int u){
	int i;

	for(i=0; i< adj[u].size(); i++){
		if (visit[adj[u][i]] == false)
			dfs(adj[u][i]);
		go[u] = max(go[adj[u][i]] + 1, go[u]);
	}

	mx = max(go[u], mx);
	visit[u] = true;
}

int main()
{
	int n, m, i, x, y, cnt=0;
	cin >> n >> m;
	in.resize(n+1, false);
	go.resize(n+1, 0);
	visit.resize(n+1, false);
	for(i=0; i<m; i++){
		cin >> x >> y;
		adj[x].push_back(y);
		in[y] = true;
	}

	for(i=1; i<=n; i++){
		
		if(in[i] == false)
			dfs(i);
	}

	cout << mx << endl;
	return 0;
}


Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:11:21: error: reference to 'visit' is ambiguous
   11 |                 if (visit[adj[u][i]] == false)
      |                     ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:3:18: note:                 'std::vector<bool> visit'
    3 | vector<bool> in, visit;
      |                  ^~~~~
a.cc:17:9: error: reference to 'visit' is ambiguous
   17 |         visit[u] = true;
      |         ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:3:18: note:                 'std::vector<bool> visit'
    3 | vector<bool> in, visit;
      |                  ^~~~~
a.cc: In function 'int main()':
a.cc:26:9: error: reference to 'visit' is ambiguous
   26 |         visit.resize(n+1, false);
      |         ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:3:18: note:                 'std::vector<bool> visit'
    3 | vector<bool> in, visit;
      |                  ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
vector<bool> in, visit;
vector<int> adj[100009], go;
int mx = -1;

void dfs(int u){
	int i, j;

	for(i=0; i< adj[u].size(); i++){
		if (!visit[adj[u][i]])
			dfs(adj[u][i]);
		go[u] = max(go[adj[u][i]] + 1, go[u]);
	}

	mx = max(go[u], mx);
	visit[u] = true;
}

int main()
{
	int n, m, i, j, x, y, cnt=0;
	cin >> n >> m;
	in.resize(n+1, false);
	go.resize(n+1, 0);
	visit.resize(n+1, false);
	for(i=0; i<m; i++){
		cin >> x >> y;
		adj[x].push_back(y);
		in[y] = true;
	}

	for(i=1; i<=n; i++){
		
		if(in[i] == false)
			dfs(i);
	}

	cout << mx << endl;
	return 0;
}


Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:11:22: error: reference to 'visit' is ambiguous
   11 |                 if (!visit[adj[u][i]])
      |                      ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:3:18: note:                 'std::vector<bool> visit'
    3 | vector<bool> in, visit;
      |                  ^~~~~
a.cc:17:9: error: reference to 'visit' is ambiguous
   17 |         visit[u] = true;
      |         ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:3:18: note:                 'std::vector<bool> visit'
    3 | vector<bool> in, visit;
      |                  ^~~~~
a.cc: In function 'int main()':
a.cc:26:9: error: reference to 'visit' is ambiguous
   26 |         visit.resize(n+1, false);
      |         ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:3:18: note:                 'std::vector<bool> visit'
    3 | vector<bool> in, visit;
      |                  ^~~~~
Language: C++

#include<bits/stdc++.h>
#define lli long long int
const long int M = 1000000007;
using namespace std;

printg(vector<vector<int> > v, int n)
{
    for(int i=1;i<=n;i++)
    {
        cout << i << ": ";
        for(int j=0;j<v[i].size();j++)
        {
            cout << v[i][j] << "->";
        }
        cout << endl;
    }
}
int solve(vector<vector<int> > v,int dp[],int n,int s)
{
    if(!v[s].size())
    {
        dp[s] = 0;
        return 0;
    }
    for(int j=0;j<v[s].size();j++)
    {
        if(!dp[v[s][j]]) solve(v,dp,n,v[s][j]);
        dp[s] = max(dp[s],dp[v[s][j]] + 1);
    }
    return dp[s];
}
int main()
{
    int n,m;
    cin >> n >> m;
    int i,j;
    vector<vector<int> > v(n+1);
    for(i=0;i<m;i++)
    {
        int a,b;
        cin >> a >> b;
        v[a].push_back(b);
    }
    //printg(v,n);
    int dp[n+1] = {0};
    for(i=1;i<=n;i++) solve(v,dp,n,i);
    //for(i=1;i<=n;i++) cout << dp[i] << " ";
    cout << *max_element(dp,dp+n+1);
}



Compiler output:
a.cc:6:1: error: ISO C++ forbids declaration of 'printg' with no type [-fpermissive]
    6 | printg(vector<vector<int> > v, int n)
      | ^~~~~~
a.cc: In function 'int printg(std::vector<std::vector<int> >, int)':
a.cc:17:1: warning: no return statement in function returning non-void [-Wreturn-type]
   17 | }
      | ^
Language: Java

import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] s = br.readLine().split(" ");
    int n = Integer.parseInt(s[0]);
    int m = Integer.parseInt(s[1]);
    HashMap<Integer, ArrayList<Integer>> hm = new HashMap<>();
    for(int i=0;i<m;i++){
      String[] str = br.readLine().split(" ");
      int u = Integer.parseInt(str[0]);
      int v = Integer.parseInt(str[1]);
      if(hm.containsKey(u)){
        ArrayList<Integer> al = hm.get(u);
        al.add(v);
        hm.put(u,al);
      }
      else{
        ArrayList<Integer> al = new ArrayList<>();
        al.add(v);
        hm.put(u,al);
      }
    }
    long ans = 0;
    long[] dp = new long[1000005];
    Arrays.fill(dp,-1);
    for(int i=1;i<=n;i++){
      ans = Math.max(ans,getBestLength(i,dp,hm));
    }
    System.out.println(ans);
  }
  
  public int getBestLength(int u,long[] dp,Map<Integer,ArrayList<Integer>> hm){
    if(dp[u]!=-1) return dp[u];
    else if(!hm.containsKey(u)){
      dp[u] = 0;
      return dp[u];
    }
      else{
        long bestLen = 0;
        for(int child : hm.get(u)){
          long currLen = getBestLength(child,dp,hm);
          bestLen = Math.max(bestLen,currLen);
        }
        dp[u] = bestLen+1;
        return dp[u];
      }
      
  }
}
      


Compiler output:
Main.java:30: error: non-static method getBestLength(int,long[],Map<Integer,ArrayList<Integer>>) cannot be referenced from a static context
      ans = Math.max(ans,getBestLength(i,dp,hm));
                         ^
Main.java:36: error: incompatible types: possible lossy conversion from long to int
    if(dp[u]!=-1) return dp[u];
                           ^
Main.java:39: error: incompatible types: possible lossy conversion from long to int
      return dp[u];
               ^
Main.java:48: error: incompatible types: possible lossy conversion from long to int
        return dp[u];
                 ^
4 errors
Language: Java

import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] s = br.readLine().split(" ");
    int n = Integer.parseInt(s[0]);
    int m = Integer.parseInt(s[1]);
    HashMap<Integer, ArrayList<Integer>> hm = new HashMap<>();
    for(int i=0;i<m;i++){
      String[] str = br.readLine().split(" ");
      int u = Integer.parseInt(str[0]);
      int v = Integer.parseInt(str[1]);
      if(hm.containsKey(u)){
        ArrayList<Integer> al = hm.get(u);
        al.add(v);
        hm.put(u,al);
      }
      else{
        ArrayList<Integer> al = new ArrayList<>();
        al.add(v);
        hm.put(u,al);
      }
    }
    long ans = 0;
    long[] dp = new long[1000005];
    Arrays.fill(dp,-1);
    for(int i=1;i<=n;i++){
      ans = Math.max(ans,getBestLength(i,dp,hm));
    }
    System.out.println(ans);
  }
  
  public int getBestLength(int u,int[] dp,Map<Integer,ArrayList<Integer>> hm){
    if(dp[u]!=-1) return dp[u];
    else if(!hm.containsKey(u)){
      dp[u] = 0;
      return dp[u];
    }
      else{
        long bestLen = 0;
        for(int child : hm.get(u)){
          long currLen = getBestLength(child,dp,hm);
          bestLen = Math.max(bestLen,currLen);
        }
        dp[u] = bestLen+1;
        return dp[u];
      }
      
  }
}
      

Compiler output:
Main.java:30: error: incompatible types: long[] cannot be converted to int[]
      ans = Math.max(ans,getBestLength(i,dp,hm));
                                         ^
Main.java:47: error: incompatible types: possible lossy conversion from long to int
        dp[u] = bestLen+1;
                       ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
2 errors
Language: C++

#include <bits/stdc++.h>
#include <bits/extc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace std;
#define FOR(i, N)         for(int i = 0; i < (N); i++)
using vi = vector<int> ;
const int MAX_N = 1e5;

int N, M;
int in[MAX_N];
vi adj[MAX_N];

int len[MAX_N];

void dfs(int u, int l){
  for(int v : adj[u]){
    len[v] = max(len[v], l+1);
    dfs(v, l+1);
  } 
}

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  memset(in, 0, sizeof(in));
  memset(len, 0, sizeof(len));
  cin >> N >> M;
  while(M--){
    int u,v; cin >>u>>v; u--;v--;
    in[v]++;
    adj[u].pb(v);
  }
  FOR(i, N) if(!in[i]) dfs(i,0);
  int ans = 0;
  FOR(i, N) ans = max(ans, len[i]);
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:12: error: 'using vi = class std::vector<int>' {aka 'class std::vector<int>'} has no member named 'pb'
   31 |     adj[u].pb(v);
      |            ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define f(a) for (ll i = 0; i < a; i++)
#define fio                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);

ll findno(ll a[],ll b[],ll c[],ll n,ll arr[],vector<ll>x[])
{
    ll mx=0;
    if(arr[n-1]!=(-1)){return arr[n-1];}
    ll i;
    for(auto it = x[n-1].begin(); it != x[n-1].end(); ++it)
    {   i=*it;
        if(arr[a[i]-1]==(-1))
        {mx=max(mx,findno(a,b,c,a[i],arr,x));}
        else{mx=max(mx,arr[a[i]-1]);}

    }
    arr[n-1]=mx+1;
    return mx+1;

}


int main()
{
    fio;
    ll n,m;
    ll i,j;
    cin>>n>>m;
    ll a[m],b[m];
    ll c[n];
    ll arr[n];
    vector<ll>x[n];
    f(n){c[i]=0;e[i]=0;f[i]=0;arr[i]=-1;}
    f(m){cin>>a[i]>>b[i];c[b[i]-1]++;x[b[i]-1].push_back(i);}
    f(n){if(c[i]==0){arr[i]=0;}}
    ll ans=0;
    f(n){if(arr[i]==(-1)){arr[i]=findno(a,b,c,i+1,arr,x);}}
	f(n){ans=max(ans,arr[i]);}
	cout<<ans;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:17: error: 'e' was not declared in this scope
   38 |     f(n){c[i]=0;e[i]=0;f[i]=0;arr[i]=-1;}
      |                 ^
a.cc:38:24: error: 'f' was not declared in this scope
   38 |     f(n){c[i]=0;e[i]=0;f[i]=0;arr[i]=-1;}
      |                        ^
Language: C++

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define has(c,i) 		((c).find(i) != end(c))
#define has_str(s, c)	((s).find(c) != string::npos)
typedef long long ll;
const int N = 1e5+5;
vector<int> edges[N];
int in_degree[N]; // the number of edges going to b
int dist[N];
bool visited[N];
void dfs (int a) {
    visited[a] = true;
    for(int b : edges[a]) {
        dist[b] = max(dist[b], dist[a]+1);
        --in_degree[b];
        if(in_degree[b] == 0)
            dfs(b);
    }
}

int main() {
#ifdef LOCAL
    freopen("input.in.txt", "rt", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, m;
    cin >> n >> m;
    while (m--) {
        int a, b;
        cin >> a >> b;
        edges[a].push_back(b);
        ++in_degree[b];
    }
    for(int i = 1; i <= n; ++i) {
        if(!visted[i] && in_degree[i] == 0)
            dfs(i);
    }
    int ans = 0;
    for(int i = 1; i <= n; ++i) {
        ans = max(ans, dist[i]);
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:13: error: 'visted' was not declared in this scope; did you mean 'visited'?
   48 |         if(!visted[i] && in_degree[i] == 0)
      |             ^~~~~~
      |             visited
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define N 100000
bool ch[N+5];
int dp[N+5];
vector<int>v[N+5];
void dfs(int x) {
	ch[x]=true;
  	for(int t:v[x]) {
    	if(!ch[t]) {dfs(t);}
      	dp[x]=max(dp[x],1+dp[t]);
    }
}
int main() {
  	int n,m,x,y;
  	cin>>n>>m;
  	for(int i=0;i<m;i++) {
    	cin>>x>>y;
      	v[x].push_back(y);
    }
  	memset(ch,false,n+1);
  	memset(dp,0,n+1);
  	for(int i=1;i<=n;i++) {
    	if(!ch[i]) {dfs(i);}
    }
  	x=INT_MIN;
  	for(int i=1;i<=n;++) {x=max(x,dp[i]);}
  	cout<<x<<endl;
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:28: error: expected primary-expression before ')' token
   27 |         for(int i=1;i<=n;++) {x=max(x,dp[i]);}
      |                            ^
Language: Java

public class Main {
  
  public static void main(String[] abc) {
     Main answer = new Main();
     long solution = answer.solve();
     System.out.println(solution);
  }
  
  private int[] dp;
  
  private long solve() {
     Scanner sc = new Scanner();     
     int N = sc.nextInt();
     int M = sc.nextInt();
     Map<Integer, List<Integer>> graph = new HashMap<>();
     for(int i=0;i<M;i++) {
        int u = sc.nextInt();
        int v = sc.nextInt();
        List<Integer> children = graph.getOrDefault(u, new ArrayList<>());        
        children.add(v);
        graph.put(u, children);
     }
     int bestLen =0;
     dp = new int[N];
     Arrays.fill(dp, -1);
     for(int i=1;i<=N;i++) {
       bestLen = Math.max(bestLen, getBestLen(i, graph));
     }
     return bestLen;
  }
	  
  private int getBestLen(int u, Map<Integer, List<Integer>> graph) {
	 if (dp[u]!=-1) return dp[u];
     if (!graph.containsKey(u)){
        dp[u]=0;
        return dp[u];
     } else {
        int bestChildLen=0;
        for(int child: graph.get(u)){
         	 int currChildLen = getBestLen(child, graph);
             bestChildLen = Math.max(bestChildLen, currChildLen);
        }
		dp[u] = bestChildLen+1;
        return dp[u];
     }
  }
}

Compiler output:
Main.java:32: error: cannot find symbol
  private int getBestLen(int u, Map<Integer, List<Integer>> graph) {
                                ^
  symbol:   class Map
  location: class Main
Main.java:32: error: cannot find symbol
  private int getBestLen(int u, Map<Integer, List<Integer>> graph) {
                                             ^
  symbol:   class List
  location: class Main
Main.java:12: error: cannot find symbol
     Scanner sc = new Scanner();     
     ^
  symbol:   class Scanner
  location: class Main
Main.java:12: error: cannot find symbol
     Scanner sc = new Scanner();     
                      ^
  symbol:   class Scanner
  location: class Main
Main.java:15: error: cannot find symbol
     Map<Integer, List<Integer>> graph = new HashMap<>();
     ^
  symbol:   class Map
  location: class Main
Main.java:15: error: cannot find symbol
     Map<Integer, List<Integer>> graph = new HashMap<>();
                  ^
  symbol:   class List
  location: class Main
Main.java:15: error: cannot find symbol
     Map<Integer, List<Integer>> graph = new HashMap<>();
                                             ^
  symbol:   class HashMap
  location: class Main
Main.java:19: error: cannot find symbol
        List<Integer> children = graph.getOrDefault(u, new ArrayList<>());        
        ^
  symbol:   class List
  location: class Main
Main.java:19: error: cannot find symbol
        List<Integer> children = graph.getOrDefault(u, new ArrayList<>());        
                                                           ^
  symbol:   class ArrayList
  location: class Main
Main.java:25: error: cannot find symbol
     Arrays.fill(dp, -1);
     ^
  symbol:   variable Arrays
  location: class Main
10 errors
Language: Java

import java.util.*;
import java.io.*;

public class Main {
  
   public static void main(String []abc) {
      Main answer = new Main();
      long solution = answer.solve();
   }
   long [] dp = new long[1000000];	
   private long solve() {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int E = sc.nextInt();
      Map<Integer, List<Integer>> graph = new HashMap<>();
      for(int i=0;i<E;i++){
         int u = sc.nextInt();
         int v = sc.nextInt();
         List<Integer> children = map.getOrDefault(u, new ArrayList<>());
         children.add(v);
         map.put(u, children);          
      }
      Arrays.fill(dp, -1);
      long bestLength=0;
      for(int i=1;i<=N;i++){
        bestLength = Math.max(bestLength, solve(graph, i));
      }
      return bestLength;     
   }

   private long solve(Map<Integer, List<Integer>> graph, int u) {
     if (dp[u]!=-1) return dp[u];
     if (!graph.containsKey(u)) {
        dp[u]=0;
        return dp[u];
     }
     long bestChild=0;
     for(int child: graph.get(u)){
        bestChild = Math.max(bestChild, solve(graph, child));
     }
     dp[u]= 1+bestChild;
     return dp[u];
   }
}


Compiler output:
Main.java:19: error: cannot find symbol
         List<Integer> children = map.getOrDefault(u, new ArrayList<>());
                                  ^
  symbol:   variable map
  location: class Main
Main.java:21: error: cannot find symbol
         map.put(u, children);          
         ^
  symbol:   variable map
  location: class Main
2 errors
Language: Java

import java.util.*;
import java.io.*;

public class Main {
  
   public static void main(String []abc) {
      Main answer = new Main();
      long solution = answer.solve();
   }
   long [] dp = new long[1000000];	
   private long solve() {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int E = sc.nextInt();
      Map<Integer, List<Integer>> graph = new HashMap<>();
      for(int i=0;i<E;i++){
         int u = sc.nextInt();
         int v = sc.nextInt();
         List<Integer> children = map.getOrDefault(u, new ArrayList<>());
         children.add(v);
         map.put(u, children);          
      }
      Arrays.fill(dp, -1);
      long bestLength=0;
      for(int i=1;i<=N;i++){
        bestLength = Math.max(bestLength, solve(graph, i));
      }
      return bestLength;     
   }

   private long solve(Map<Integer, List<Integer>> graph, int u) {
     if (dp[u]!=-1) return dp[u];
     if (!graph.containsKey(u)) {
        dp[u]=0;
        return dp[u];
     }
     long bestChild=0;
     for(int child: map.get(u)){
        bestChild = Math.max(bestChild, solve(graph, child));
     }
     dp[u]= 1+bestChild;
     return dp[u];
   }
}

Compiler output:
Main.java:19: error: cannot find symbol
         List<Integer> children = map.getOrDefault(u, new ArrayList<>());
                                  ^
  symbol:   variable map
  location: class Main
Main.java:21: error: cannot find symbol
         map.put(u, children);          
         ^
  symbol:   variable map
  location: class Main
Main.java:38: error: cannot find symbol
     for(int child: map.get(u)){
                    ^
  symbol:   variable map
  location: class Main
3 errors
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int N, M, dp[100100], in[100100];
vector<int> G[100100];

int main() {
    cin >> n >> m;
    rep(i,n){
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        G[x].push_back(y);
        in[y]++;
    }

    queue<int> que;
    rep(i,n) if(in[i] == 0) que.push(i);
    while(!que.empty()) {
        int v = que.front(); que.pop();
        for(int nv : G[v]){
          	in[nv]--;
      		dp[nv] =  max(dp[nv], dp[v]+1);
            if(in[nv] == 0) que.push(nv);
        }
    }

    int ans = 0;
    rep(i,n) ans = max(res, dp[i]);
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:12: error: 'n' was not declared in this scope
    9 |     cin >> n >> m;
      |            ^
a.cc:9:17: error: 'm' was not declared in this scope
    9 |     cin >> n >> m;
      |                 ^
a.cc:31:24: error: 'res' was not declared in this scope; did you mean 'rep'?
   31 |     rep(i,n) ans = max(res, dp[i]);
      |                        ^~~
      |                        rep
Language: C++

#include <iostream>
#include <queue>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;

#define Max 1e5+10
int dp[Max],in[Max];
vector<int > G[Max];
int main()
{
    queue<int> q;
    int n,m,a,b,ans = 0;
	scanf("%d%d",&n,&m);
    for(int i = 1;i<=m;++i)
		scanf("%d%d",&a,&b),in[b]++,G[a].push_back(b);
    for(int i = 1;i<=n;++i)
		if(!in[i]) q.push(i);
    while(!q.empty())
    {
        int now = q.front();
        q.pop();
        int sz = G[now].size();
        for(int i = 0;i<sz;++i)
        {
            dp[G[now][i]] = max(dp[G[now][i]],dp[now]+1);
            in[G[now][i]]--;
            if(in[G[now][i]]==0) q.push(G[now][i]);
        }
    }
    for(int i=1;i<=n;++i)
		ans = max(ans,dp[i]);
    printf("%d\n",ans);
    return 0;
}

Compiler output:
a.cc:8:16: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    8 | #define Max 1e5+10
      |             ~~~^~~
a.cc:9:8: note: in expansion of macro 'Max'
    9 | int dp[Max],in[Max];
      |        ^~~
a.cc:8:16: error: could not convert '(1.0e+5 + (double)10)' from 'double' to 'long unsigned int'
    8 | #define Max 1e5+10
      |             ~~~^~~
      |                |
      |                double
a.cc:9:8: note: in expansion of macro 'Max'
    9 | int dp[Max],in[Max];
      |        ^~~
a.cc:8:16: error: size of array 'dp' has non-integral type 'double'
    8 | #define Max 1e5+10
      |             ~~~^~~
a.cc:9:8: note: in expansion of macro 'Max'
    9 | int dp[Max],in[Max];
      |        ^~~
a.cc:8:16: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    8 | #define Max 1e5+10
      |             ~~~^~~
a.cc:9:16: note: in expansion of macro 'Max'
    9 | int dp[Max],in[Max];
      |                ^~~
a.cc:8:16: error: could not convert '(1.0e+5 + (double)10)' from 'double' to 'long unsigned int'
    8 | #define Max 1e5+10
      |             ~~~^~~
      |                |
      |                double
a.cc:9:16: note: in expansion of macro 'Max'
    9 | int dp[Max],in[Max];
      |                ^~~
a.cc:8:16: error: size of array 'in' has non-integral type 'double'
    8 | #define Max 1e5+10
      |             ~~~^~~
a.cc:9:16: note: in expansion of macro 'Max'
    9 | int dp[Max],in[Max];
      |                ^~~
a.cc:8:16: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    8 | #define Max 1e5+10
      |             ~~~^~~
a.cc:10:16: note: in expansion of macro 'Max'
   10 | vector<int > G[Max];
      |                ^~~
a.cc:8:16: error: could not convert '(1.0e+5 + (double)10)' from 'double' to 'long unsigned int'
    8 | #define Max 1e5+10
      |             ~~~^~~
      |                |
      |                double
a.cc:10:16: note: in expansion of macro 'Max'
   10 | vector<int > G[Max];
      |                ^~~
a.cc:8:16: error: size of array 'G' has non-integral type 'double'
    8 | #define Max 1e5+10
      |             ~~~^~~
a.cc:10:16: note: in expansion of macro 'Max'
   10 | vector<int > G[Max];
      |                ^~~