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

/*Author : Hrishi*/

/*When I wrote this, only God and I understood what I was doing.
Now, only God knows.*/

#include <bits/stdc++.h>

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define PB push_back
#define F(i,L,R) for(auto i=L; i<R ;i++)
#define FR(i,L,R) for(auto i=R-1;i>=L;i--)
#define show(x) cout<<(#x)<<" is "<<(x)<<"\n";
#define BOOST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define M 1000000007

using namespace std;

vi graph[100001];
int ans[100001];
vi vis(100001,0);

int main() 
{
    int n,m,a,b;
    cin>>n>>m;
    F(i,0,m)
    {
        cin>>a>>b;
        a--;b--;
        graph[a].PB(b);
    }
	int ans=0;
	
	F(i,0,n)
	{
	    if(vis[i]==1)
	        continue;
	        
	    vi level(n,0);
	    queue<int> q;
	    q.push(i);
	    while(!q.empty())
	    {
	        int s = q.front();
	        vis[s]=1;
	        q.pop();
	        for(auto it=graph[s].begin();it!=graph[s].end();it++)
	        {
	            if(level[*it]<level[s]+1)
	            {
	                level[*it] = level[s] + 1;
	                q.push(*it);
	            }
	        }
	    }
	//    ans = max(ans, ));
	}
	cout<<(*max_element(level.begin(),level.end())<<"\n";
}




Compiler output:
a.cc: In function 'int main()':
a.cc:62:29: error: 'level' was not declared in this scope
   62 |         cout<<(*max_element(level.begin(),level.end())<<"\n";
      |                             ^~~~~
a.cc:62:61: error: expected ')' before ';' token
   62 |         cout<<(*max_element(level.begin(),level.end())<<"\n";
      |               ~                                             ^
      |                                                             )
Language: C++

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

#define mod (int) 998244353
#define MOD (int) 1e9+7
// Big two primes
#define X 1001100011100001111ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int long long
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int>
#define fi first
#define se second
#define endl "\n"
#define ii pair<int, int>
#define vii vector<ii>
#define sz(s) s.size()



int lv=0;
void dfs(int i,int level[],vector<int> adj[]){
    lv=max(lv,level[i]);
    for(auto j=adj[i].begin();j!=adj[i].end();j++){
        level[*j]=level[i]+1;
        dfs(*j,level,adj);
    }
}

int main(){
    fio;
    int n,m,i;
    cin>>n>>m;
    vector<int> adj[n+1];
    for(i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
    }
    int ans=0;
    for(i=1;i<=n;i++){
        int level[n+1];
        level[i]=0;
        dfs(i,level,adj);
        ans=max(lv,ans);
        lv=0;
    }
    cout<<ans<<endl;
    return 0;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n,k;
    cin>>n>>k;
    ll a[n+1];
    for(ll i=0;i<=n;i++)a[i]=0;
    ll mi = ll_MIN;
    while(k--)
    {
        ll x,y;
        cin>>x>>y;
        a[y]=max(a[y],a[x]+1);
        mi=max(mi,a[y]);
    }
    cout<<mi;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:13: error: 'll_MIN' was not declared in this scope
   10 |     ll mi = ll_MIN;
      |             ^~~~~~
Language: C

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

template<class T> inline bool chmax(T& a, T b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T> inline bool chmin(T& a, T b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}

int n,m;
vector<vector<int>> G;
vector<int> deg;

int dp[100100];
int main(){
  cin >> n >> m;
  G.assign(n,vector<int>());
  deg.assign(n,0);
  rep(i,m){
    int x,y;
    cin >> x >> y;
    x--;y--;
    G[x].push_back(y);
    deg[y]++;
  }

  queue<int> que;
  rep(i,n) if(deg[i]==0)que.push(i);

  while(!que.empty()){
    int v = que.front();
    que.pop();
    for(auto nv : G[v]){
      deg[nv]--;
      if(deg[nv]==0){
        que.push(nv);
        chmax(dp[nv],dp[v]+1);
      }
    }
  }

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

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

https://atcoder.jp/contests/dp/standings#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int M=1e5+10;
int n,m,deg_in[M],ans;
vector<int> G[M];
int dfs(int u)
{
    int re=0;
    for(int v: G[u])
        re=max(re,dfs(v));
    return re+1;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0,u,v;i<m;i++)
        scanf("%d%d",&u,&v),G[u].push_back(v),deg_in[v]++;
    for(int i=1;i<=n;i++)
        if(!deg_in[i])
            ans=max(ans,dfs(i));
    printf("%d\n",ans-1);
    return 0;
}


Compiler output:
a.cc:1:1: error: 'https' does not name a type
    1 | https://atcoder.jp/contests/dp/standings#include <bits/stdc++.h>
      | ^~~~~
a.cc:6:1: error: 'vector' does not name a type
    6 | vector<int> G[M];
      | ^~~~~~
a.cc: In function 'int dfs(int)':
a.cc:10:16: error: 'G' was not declared in this scope
   10 |     for(int v: G[u])
      |                ^
a.cc:11:12: error: 'max' was not declared in this scope
   11 |         re=max(re,dfs(v));
      |            ^~~
a.cc: In function 'int main()':
a.cc:16:5: error: 'scanf' was not declared in this scope
   16 |     scanf("%d%d",&n,&m);
      |     ^~~~~
a.cc:18:29: error: 'G' was not declared in this scope
   18 |         scanf("%d%d",&u,&v),G[u].push_back(v),deg_in[v]++;
      |                             ^
a.cc:21:17: error: 'max' was not declared in this scope
   21 |             ans=max(ans,dfs(i));
      |                 ^~~
a.cc:22:5: error: 'printf' was not declared in this scope
   22 |     printf("%d\n",ans-1);
      |     ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | https://atcoder.jp/contests/dp/standings#include <bits/stdc++.h>
Language: C++

unordered_map<int, vector<int>> edges;
unordered_map<int, int> dp;
bool visited[10000] = {false};

int helper(int i) {
    if (visited[i]) return dp[i]; // 访问过的节点，直接返回i节点的Longest Path
    else {
        dp[i] = 0;
        visited[i] = true; // 访问过当前这个节点
        auto next = edges[i];
        for (auto j : next) {
            dp[i] = max(dp[i], helper(j) + 1);
        }
    }
    return dp[i];
}

int main(int argc, char *argv[]) {
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        edges[a].push_back(b);
    }
    int res = 0;
    for (int i = 1; i <= N; i++) {
        res = max(res, helper(i));
    }
    cout << res;
    return 0;
}

Compiler output:
a.cc:1:1: error: 'unordered_map' does not name a type
    1 | unordered_map<int, vector<int>> edges;
      | ^~~~~~~~~~~~~
a.cc:2:1: error: 'unordered_map' does not name a type
    2 | unordered_map<int, int> dp;
      | ^~~~~~~~~~~~~
a.cc: In function 'int helper(int)':
a.cc:6:28: error: 'dp' was not declared in this scope
    6 |     if (visited[i]) return dp[i]; // 访问过的节点，直接返回i节点的Longest Path
      |                            ^~
a.cc:8:9: error: 'dp' was not declared in this scope
    8 |         dp[i] = 0;
      |         ^~
a.cc:10:21: error: 'edges' was not declared in this scope
   10 |         auto next = edges[i];
      |                     ^~~~~
a.cc:12:21: error: 'max' was not declared in this scope
   12 |             dp[i] = max(dp[i], helper(j) + 1);
      |                     ^~~
a.cc:15:12: error: 'dp' was not declared in this scope
   15 |     return dp[i];
      |            ^~
a.cc: In function 'int main(int, char**)':
a.cc:20:5: error: 'cin' was not declared in this scope
   20 |     cin >> N >> M;
      |     ^~~
a.cc:24:9: error: 'edges' was not declared in this scope
   24 |         edges[a].push_back(b);
      |         ^~~~~
a.cc:28:15: error: 'max' was not declared in this scope
   28 |         res = max(res, helper(i));
      |               ^~~
a.cc:30:5: error: 'cout' was not declared in this scope
   30 |     cout << res;
      |     ^~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

queue<long long int>q;

void solve(vector<long long int>v[],long long int ind[],long long int dist[]){
     int x=q.front();
     q.pop();
     for(auto i=v[x].begin();i!=v[x].end();i++){
        ind[*i]--;
        if(ind[*i]==0){
                dist[*i]=dist[x]+1;
            solve(v,ind,dist);}
     }
}

int main()
{
    long long int n,e;
    cin>>n>>e;
    if(e==1){ cout<<1;
    return 0;}
    long long int ind[n+1]={0};
    long long int outd[n+1]={0};
    vector<int>v[n+1];
    long long int dist[n+1]={0};
    for(long long int i=0;i<e;i++){
        long long int x,y;
        cin>>x>>y;
        v[x].push_back(y);
        ind[y]++;
        outd[x]++;
    }
    for(long long int i=1;i<=n;i++){
        if(ind[i]==0)
            q.push(i);
    }
    while(!q.empty()){
        solve(v,ind,dist);
    } long long int ans=0;
    for(long long int i=1;i<=n;i++)
        ans=max(ans,dist[i]);
    cout<<ans;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:15: error: cannot convert 'std::vector<int>*' to 'std::vector<long long int>*'
   40 |         solve(v,ind,dist);
      |               ^
      |               |
      |               std::vector<int>*
a.cc:7:33: note:   initializing argument 1 of 'void solve(std::vector<long long int>*, long long int*, long long int*)'
    7 | void solve(vector<long long int>v[],long long int ind[],long long int dist[]){
      |            ~~~~~~~~~~~~~~~~~~~~~^~~
Language: Java

import com.sun.javaws.IconUtil;

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

public class Main {

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    private ArrayList<Integer>[] adj;


    private void addEdge(int u, int v) {
        adj[u].add(v);
    }

    public static void main(String[] args) {
        Main main = new Main();
        FastReader scanner = new FastReader();
        int N = scanner.nextInt();

        main.adj = new ArrayList[N];
        for (int i = 0; i < N; i++) {
            main.adj[i] = new ArrayList<>();
        }

        int M = scanner.nextInt();
        for (int i = 0; i < M; i++) {
            main.addEdge(scanner.nextInt() - 1, scanner.nextInt() - 1);
        }

        int max = 0;
        for (int i = 0; i < N; i++) {
            //System.out.println("Root = " + i);
            main.DFS(new boolean[N], i);
            //System.out.println("count = " + main.maximum);
            max = Math.max(max, main.maximum);
            main.count = 0;
            main.maximum = 0;
        }
        System.out.println(max - 1);

    }

    private int count = 0;
    private int maximum = 0;

    private void DFS(boolean[] visited, int n) {
        //System.out.println(" n = " + n);
        visited[n] = true;
        count++;
        for (Integer ix : adj[n]) {
            int temp = count;
            if (!visited[ix]) {
                DFS(visited, ix);
            }
            visited[ix] = false;
            count = temp;
        }
        maximum = Math.max(count, maximum);
    }

}

Compiler output:
Main.java:1: error: package com.sun.javaws does not exist
import com.sun.javaws.IconUtil;
                     ^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
Language: Java

	import java.util.*;
	import java.io.*;
import java.lang.reflect.Array;
	public class Main {
		static int n,m;
		static ArrayList<ArrayList<Integer>> g;
		static int dp[],l1,l2;
		static boolean cj;
		public static void main(String[] args) throws IOException{
			BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
			int t=1;
	//		Integer.parseInt(br.readLine().trim());
			StringBuilder printans=new StringBuilder();
			while(t-->0)
			{
				StringTokenizer tok=new StringTokenizer(br.readLine()," ");
				n=Integer.parseInt(tok.nextToken());
				m=Integer.parseInt(tok.nextToken());
				g=new ArrayList<>();
				for(int i=0;i<=n;i++) {
					g.add(new ArrayList<>());
				}
				while(m-->0) {
					tok=new StringTokenizer(br.readLine()," ");
					int a=Integer.parseInt(tok.nextToken());
					int b=Integer.parseInt(tok.nextToken());
					addedge(a,b);
					
				}
				dp=new int[n+1];
				boolean vis[]=new boolean[n+1];
				int ans=0;
				for(int i=0;i<=n;i++) {
					cj=false;
						if(!vis[i]) {
							findans(i,0,vis);
						}
						
				}
				int ans2=0;
				for(int i:dp) {
					ans2=Math.max(ans2, i);
//					System.out.print(i+" ");
				}
				System.out.println(ans2);

			}
			
			
		}
		static void addedge(int a,int b) {
			g.get(a).add(b);
			
		}
		static void findans(int curr,int j,boolean vis[]) {
			vis[curr]=true;
			int ans=0;
			for(int i=0;i<g.get(curr).size();i++) {
				if(!vis[g.get(curr).get(i)]) {
//					
					findans(g.get(curr).get(i),j+1,vis);
					
				}
				dp[curr]=Math.max(dp[curr],dp[g.get(curr).get(i)]+1);
			}
			
				
				
			
			
		
		
		
		}
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		static void memset() {
			for(int a[]:dp) {
				Arrays.fill(a,-1);
			}
		}
		
			
	}


Compiler output:
Main.java:91: error: incompatible types: int cannot be converted to int[]
			for(int a[]:dp) {
			            ^
1 error
Language: C++

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

#define endl '\n'
#define ll long long
#define LSB __builtin_ctzll
#define sc(a) scanf("%d",&a)
#define MSB 63-__builtin_clzll
#define scl(a) scanf("%lld",&a)
#define BITS __builtin_popcountll
#define mem(a , v)  memset(a , v , sizeof(a))
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1e9+7;
const int MAX = 1e5+55;
const int INF = 1e9+77;
const ll INFINF = 1e18+1e17;
const double PI = acos(-1.0);
vector<int> months = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

ll power(ll x,ll y){
         if(y==0)
         return 1;
         ll s=power(x,y/2);
         s*=s;
         if(y&1)
         s*=x;
         return s;
}

int n;
int m;
int dp[MAX];
vector<int> adj[MAX];

int solve(int u){
        vis[u]=1;
        if(!adj[u].size()){
            return 0;
        }

        int &res=dp[u];
        if(res!=-1){
            return res;
        }

        res=0;
        for(auto &v:adj[u]){
            res=max(res,solve(v)+1 );
        }

        return res;
}



int main(){

ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//freopen("input.txt" , "r" , stdin);
//freopen("output.txt" , "w" , stdout);



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


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

    cout<<ans;






     return 0;

}


Compiler output:
a.cc: In function 'int solve(int)':
a.cc:37:9: error: 'vis' was not declared in this scope
   37 |         vis[u]=1;
      |         ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define MAXN 1e5+10
vector<int> adj[MAXN];
int dp[MAXN],vis[MAXN];
int solve(int vertex){
if(vis[vertex])
  return dp[vertex];
  vis[vertex]=1;
  int maxl=0;
  for(int u:adj[vertex])
  {
    maxl=max(maxl,solve(u)+1);
  }
  dp[vertex]=maxl;
  return dp[vertex];
}
int main(){
int N,M;
  cin>>N>>M;
  for(int edges=0;edges<M;edges++){
  int a,b;
    cin>>a>>b;
    adj[a].push_back(b);
  }
  int maxans=0;
  for(int i=1;i<=N;i++){
  maxans=max(maxans,solve(i));
  }
  cout<<maxans;
  return 0;
}

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

#include<bits/stdc++.h>
using namespace std;
int dfs(int vertex,vector<vector<int>> adj,vector<bool> &visited,vector<int> &dp){
visited[vertex]=true;
  if(adj[vertex].size()==0)
  {
    dp[vertex]=0;
    return 0;
  }
  int maxl=0;
      for(int i=0;i<adj[vertex].size();i++){
  if(!visited[adj[vertex][i]])
  {dp[adj[vertex][i]]=dfs(adj[vertex][i],adj,visited,dp);
        maxl=max(dp[adj[vertex][i]]+1,maxl);}
  }
  for(int i=0;i<adj[vertex].size();i++){
  if(visited[adj[vertex][i]])
    maxl=max(dp[adj[vertex][i]]+1,maxl);
  }
    
  dp[vertex]=maxl;
  return dp[vertex];
}
int main(){
int V,E;
  cin>>V>>E;
  vector<vector<int>> adj;
  for(int i=0;i<=V;i++){
  vector<int> l;
    adj.push_back(l);
  }
  for(int edges=0;edges<E;edges++){
  int a,b;
    cin>>a>>b;
    adj[a].push_back(b);
  }
  vector<bool> visited(V+1,false);
  vector<int> dp(V+1,-1);
  int maxans=0;
  for(int i=1;i<=V;i++){
  if(!visited[i])
    dp[i]=dfs(i,adj,visited,dp);
    maxans=max(dp[i],maxans);
  }
  cout<<maxans;
  return 0;


Compiler output:
a.cc: In function 'int main()':
a.cc:46:12: error: expected '}' at end of input
   46 |   return 0;
      |            ^
a.cc:24:11: note: to match this '{'
   24 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
#define fio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
// #define double long double
// #define mp make_pair
// #define pb push_back
// Upper case English alphabet to lower case ch |= ' ';
// Lower case English alphabet to upper case ch &= '_’ ;
//__builtin_popcount(x)

int INF=(int)1e18+1,t=-1,till=0;
int gcd(int a, int b) { return b!=0 ? gcd(b, a % b) : a; }
// int digits(int n){return floor(log10(n))+1 ;}
// bool ispoweroftwo (int x) { return x && (!(x&(x-1))); }
//vector<int> vis,parent,ti,tout,dis;
// vector<vector<int> > adj;
// map<pair<int,int>,int> vis;
// vector<int> row={-1,1,0,0};
// vector<int> col={0,0,-1,1};
// //map<pair<int,int>,int> dp;
// int n=1;
// int th=0;

// int dfs(int r,int c,vector<vector<int> > board,vector<vector<int> > &dp){
//     vis[{r,c}]=1;
//     if(dp[r][c]!=-1){
//         return dp[r][c];
//     }
//     int t=1;
//     for(int i=0;i<4;i++){
//         int r1=r+row[i],c1=c+col[i];
//         if(r1>=0 && r1<n && c1>=0 && c1<n && 
//           !vis[{r1,c1}] && board[r][c]<board[r1][c1]){
//           t=max(t,1LL + dfs(r1,c1,board,dp));
//         }
//     }
//     vis[{r,c}]=0;
//     return dp[r][c]=max(t,dp[r][c]);
    
    
// }




signed main(){
    fio;
    int n,m;
    cin>>n>>m;
    vector<vector<int> > adj(n);
    vector<pair<int,int> >  deg(n);
    for(int i=0;i<n;i++) deg[i]={0,i};
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        x--;y--;
        adj[y].push_back(x);
        deg[y].first++;
    }
    sort(deg.begin(),deg.end());
    int dp[n],ans=-1;
    for(int i=0;i<n;i++) dp[v]=0;
    for(int i=0;i<n;i++){
        int v=deg[i].second,cnt=deg[i].first;
        for(int ad:adj[v]){
            dp[v]=max(dp[v],dp[ad]+1);
        }
        ans=max(dp[v],ans);
    }
    cout<<ans<<endl;


}


Compiler output:
a.cc: In function 'int main()':
a.cc:64:29: error: 'v' was not declared in this scope
   64 |     for(int i=0;i<n;i++) dp[v]=0;
      |                             ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int dp[100005];
bool vis[v+1];
int dfs(int src , bool vis[], list<int> adj[]){
  if(vis[src]==true) return dp[src];
	vis[src]=true;
  int len=0;
  for (auto u=adj[src].begin();u!=adj[src].end();u++){
  	len=max(1+dfs(*u,vis,adj),len);
  }
  dp[src]=len;
    return dp[src];

}
int main(){
  int v,e;
  cin>>v>>e;
  int x,y;
  list< int> adj[v+1];
  for(int i=0;i<e;i++){
  	cin>>x>>y;
    adj[x].push_back(y);
  }
  
 // memset(vis, false, sizeof vis);
  int len=0;
  for(int i=1;i<=v;i++){
  	len=max(len,dfs(i,vis,adj));
  //  memset(vis,false, sizeof vis);
  }
  
  cout<<len<<endl;
}


Compiler output:
a.cc:4:10: error: 'v' was not declared in this scope
    4 | bool vis[v+1];
      |          ^
a.cc: In function 'int main()':
a.cc:29:27: error: 'vis' was not declared in this scope
   29 |         len=max(len,dfs(i,vis,adj));
      |                           ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int dp[100005];
bool vis[v+1];
int dfs(int src , bool vis[], list<int> adj[]){
  if(vis[src]==true) return dp[src];
	vis[src]=true;
  int len=0;
  for (auto u=adj[src].begin();u!=adj[src].end();u++){
  	len=max(1+dfs(*u,vis,adj),len);
  }
  dp[src]=len;
    return dp[src];

}
int main(){
  int v,e;
  cin>>v>>e;
  int x,y;
  list< int> adj[v+1];
  for(int i=0;i<e;i++){
  	cin>>x>>y;
    adj[x].push_back(y);
  }
  
  memset(vis, false, sizeof vis);
  int len=0;
  for(int i=1;i<=v;i++){
  	len=max(len,dfs(i,vis,adj));
  //  memset(vis,false, sizeof vis);
  }
  
  cout<<len<<endl;
}


Compiler output:
a.cc:4:10: error: 'v' was not declared in this scope
    4 | bool vis[v+1];
      |          ^
a.cc: In function 'int main()':
a.cc:26:10: error: 'vis' was not declared in this scope
   26 |   memset(vis, false, sizeof vis);
      |          ^~~
Language: C++

#include<bits/stdc++.h>
#include<queue>
using namespace std;
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: In function 'int path(int)':
a.cc:17:10: error: 'y' was not declared in this scope
   17 |   return y;
      |          ^
Language: C++


#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>
#include <climits>
using namespace std; 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<pii> 
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define f(i,x,n)        for(int i=x;i<n;i++)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count()); 

// unordered_map<int,list<int>> m ;
// unordered_map<int,int> dist; 
// unordered_map<int,bool> visited ;
// int c_sons[100000],lvl[100000],father[100000],subtree[100000] ;  
// priority_queue<pair<int,int> > q;
// int dp[100000] ; 
// void dfs(int src,int fth){
//       father[src] = fth ; 
//       for(auto x:m[src]){

//       	   if(x==fth) continue ; 
//       	   c_sons[src] ++ ;
//       	   lvl[x] = lvl[src] + 1  ;
//       	   dfs(x,src) ;
//       }
//     if(!c_sons[src]){

//     	 q.push(mp(lvl[src],src)) ;
//     }
//  } 
 unordered_map<int,list<int> > m ;
 unordered_set<int> s ; 
 unordered_map<int,int> dist ; 
 int ans=INT_MIN; 
// int calculated[100000] ; 
 void dfs(int src,int fth){ 
       if(dist[src] == dist[fth] + 1 ) return ;
       if(fth==-1) dist[src] = 0 ;
       else
       dist[src] = max(dist[src] , dist[fth] + 1 ) ;
       calculated[src] = dist[src] ;
       ans=max(ans,dist[src]) ; 
       //cout<<src<<" "<<dist[src]<<"\n";
       for(auto x:m[src] ) {
       	    dfs(x,src) ; 
       }
       return ;                         

 }
int32_t main(){

     
	   ios::sync_with_stdio(0);
       cin.tie(0);

      int n ;
      cin>>n ; 
      int v[n+1]={0}; 
       f(i,0,n) { 
         dist[i+1] = 0 ;
         //calculated[i+1] = -1 ; 
    } 
      int src = 0 ;
      vi s_point ; 
      w(edge){

      	 int a,b ;
      	 cin>>a>>b ; 
      	 m[a].pb(b) ;  
         v[b] = true ;
     }

     for(int i=1;i<=n;i++){
     	 if(!v[i]) {
     	 	dfs(i,-1) ;
     	 }
     }
     
     cout<<ans ;
}





 
 
 
        

Compiler output:
a.cc: In function 'void dfs(long long int, long long int)':
a.cc:78:8: error: 'calculated' was not declared in this scope
   78 |        calculated[src] = dist[src] ;
      |        ^~~~~~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
const int MAX=110000;
using namespace std;
int cntc[MAX],longest[MAX];
vector <vector<int>> a;
int n,m,tmp1,tmp2,ans=0;

bool compare(vector<int> x,vector<int> y){
  return x[0]<=y[0];
}


int fmax(int i){
  if (longest[i]){
  } else if (!cntc[i]){
    longest[i]=1;
  } else {
    int maxv=0;
    for (int j=0;j<m;j++){
      if (i==a[j][0])
        maxv=max(maxv,fmax(a[j][1]));
    }
    longest[i]=maxv+1;
  }
  return longest[i];
}

int main(){
  cin >>n>>m;
  for (int i=0;i<m;i++){
    cin >>a1>>a2;
    vector<int> tmp={a1,a2};
    a.push_back(tmp);
    cntc[a1]++;
  }
//sort(a.begin(),a.end(),compare);

  for (int i=1;i<=n;i++){
    ans=max(fmax(i),ans);
  }
cout << ans-1<<endl;
return 0;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:11: error: 'a1' was not declared in this scope; did you mean 'a'?
   33 |     cin >>a1>>a2;
      |           ^~
      |           a
a.cc:33:15: error: 'a2' was not declared in this scope; did you mean 'a'?
   33 |     cin >>a1>>a2;
      |               ^~
      |               a
a.cc:34:27: error: could not convert '{a1, a2}' from '<brace-enclosed initializer list>' to 'std::vector<int>'
   34 |     vector<int> tmp={a1,a2};
      |                           ^
      |                           |
      |                           <brace-enclosed initializer list>
Language: C++

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int dp[100001];
vector<int> adj[100001];

ll dfs(int s)
{
    if (s < 1)
        return 0;
    if (dp[s] != -1)
        return dp[s];
    if (adj[s].size() == 0)
    {
        dp[s] = 0;
    }
    else
    {
        for (auto it = adj[s].begin(); it != adj[s].end(); it++)
        {
            dp[s] = max((ll)dp[s], 1 + dfs(*it));
        }
    }

    return dp[s];
}
int main()
{

    int v;
    int e;
    cin >> v;
    cin >> e;
    for (int i = 0; i <= v; i++)
    {
        dp[i] = -1;
        
    }
    // vector<int> adj[v+1];
    for (int i = 1; i <= e; i++)
    {
        int a;
        int b;
        cin >> a;
        cin >> b;
        adj[a].push_back(b);
    }

    for (int i = 1; i <= v; i++)
    {
        if (!visited[i])
        {
            dfs(i);
        }
    }

    int *ma;
    ma = max_element(dp, dp + (v + 1));
    cout << *ma << "\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:14: error: 'visited' was not declared in this scope
   51 |         if (!visited[i])
      |              ^~~~~~~
Language: Java

import java.io.*;
import java.util.*;
public class Sol1{
	public static int n, m;
	public static List<Integer> adj[];
	public static int dist[];
    public static void main(String[] args) throws IOException{
    	FastScanner sc = new FastScanner();
    	PrintWriter out = new PrintWriter(System.out);
    	n = sc.nextInt();
    	m = sc.nextInt();
    	dist = new int[n];
    	adj = new ArrayList[n];
    	for(int i=0; i<n; i++) {
    		adj[i] = new ArrayList<>();
    	}
    	for(int i=0; i<m; i++) {
    		int a = sc.nextInt()-1;
    		int b = sc.nextInt()-1;
    		adj[a].add(b);
    	}
    	for(int i=0; i<n; i++) {
    		if(dist[i]!=0) continue;
    		dfs(i, 0);
    	}
    	int max = 0;
    	for(int i=0; i<n; i++) {
    		max = Math.max(max, dist[i]);
    	}
    	out.println(max);
    	out.close();
    }
    public static void dfs(int start, int cnt) {
    	dist[start] = cnt;
    	for(int i:adj[start]) {
    		if(dist[i]>cnt+1) continue;
    		dfs(i, cnt+1);
    	}
    }
    public static class FastScanner {
    	BufferedReader br;
    	StringTokenizer st;

    	public FastScanner(String s) {
    		try {
    			br = new BufferedReader(new FileReader(s));
    		} catch (FileNotFoundException e) {
    			e.printStackTrace();
    		}
    	}

    	public FastScanner() {
    		br = new BufferedReader(new InputStreamReader(System.in));
    	}
    	
    	String nextToken() {
    		while (st == null || !st.hasMoreElements()) {
    			try {
    				st = new StringTokenizer(br.readLine());
    			} catch (IOException e) {
    				e.printStackTrace();
    			}
    		}
    		return st.nextToken();
    	}

    	String nextLine() {
    		st = null;
    		try {
    			return br.readLine();
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
    		return null;
    	}

    	int nextInt() {
    		return Integer.parseInt(nextToken());
    	}

    	long nextLong() {
    		return Long.parseLong(nextToken());
    	}

    	double nextDouble() {
    		return Double.parseDouble(nextToken());
    	}
    }
}


Compiler output:
Main.java:3: error: class Sol1 is public, should be declared in a file named Sol1.java
public class Sol1{
       ^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
Language: C++

#include <iostream>
#include <vector>
#include <queue>

using namespace std;


void make_graph(vector<pair<int, int> >& edgeList, vector<vector<int> >& graph, vector<int>& indegree){

    for(int i = 0; i < edgeList.size(); i++){
      graph[edgeList[i].first].push_back(edgeList[i].second);
      indegree[edgeList[i].second]++;
    }
}

void topologicalSortLongestDistance(vector<vector<int> >& graph, vector<int>& indegree, vector<int>& dist){

    queue<int> zeros;
    int count = 0;
    for(int i = 0; i < indegree.size(); i++){
        if(indegree[i] == 0)zeros.push(i);
    }

    while(!zeros.empty()){
        auto node = zeros.front();
        zeros.pop();
        cout << node << " ";
        for(auto ng : graph[node]){
            dist[ng] = max(dist[ng], dist[node] + 1);
            indegree[ng]--;
            if(indegree[ng] == 0)zeros.push(ng);
        }
    }

}


int main(){

  int n,m;
  cin >> n >> m
  vector<pair<int, int>> edgeList;
  int a, b;
  for(int i = 0; i < m; i++){
  	cin >> a >> b;
    edgeList.push_back(make_pair(a, b));
  }
 
  vector<vector<int> > graph(n+1);
  vector<int> indegree(n+1, 0);

  make_graph(edgeList, graph, indegree);

 

  vector<int> dist(n+1, 0);
  topologicalSortLongestDistance(graph, indegree, dist);
  int res = 0;
  for(int i = 0; i <= n; i++){
      res = max(res, dist[i]);
  }
  cout << res << endl;



  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:16: error: expected ';' before 'vector'
   41 |   cin >> n >> m
      |                ^
      |                ;
   42 |   vector<pair<int, int>> edgeList;
      |   ~~~~~~        
a.cc:46:5: error: 'edgeList' was not declared in this scope
   46 |     edgeList.push_back(make_pair(a, b));
      |     ^~~~~~~~
a.cc:52:14: error: 'edgeList' was not declared in this scope
   52 |   make_graph(edgeList, graph, indegree);
      |              ^~~~~~~~
Language: C++

#include<bits/stdc++.h>
#define ll long long 
#define P pair<int,int>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
const ll INF = 100100100100;
/*
dp[i]
iから始まる最長経路
*/
vector<int> memo(101010,-1);
vector<int> xy(101010);
int dp(int i){
    if(memo[i]!=-1) return memo[i];
    int ans = 0;
    for(int to: xy[i]){
        ans = max(ans, dp(to) + 1);
    }
    memo[i] = ans;
    return ans;
}

int main(){
    int n,m;
    cin >> n >> m;
    rep(i,m) {
        int u;
        cin >> u; 
        cin >> xy[u];
    }
    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 'int dp(int)':
a.cc:16:21: error: 'begin' was not declared in this scope
   16 |     for(int to: xy[i]){
      |                     ^
a.cc:16:21: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
                 from a.cc:1:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:16:21: error: 'end' was not declared in this scope
   16 |     for(int to: xy[i]){
      |                     ^
a.cc:16:21: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const long N = 1e5+7;
vector<long> v[N];
long fun(vector<long> k,long i,long ans)
{
	if(k[i]!=0)
	{
		return 0;
	}
	else 
	{
		k[i]=1;ans=0;
		for(long j=0;j<v[i].size();j++)
		{
			ans=max(ans,1+fun(k,v[i][j],ans));
			//cout<<ans<<endl;
		}
	}
	return ans;
}
int main()
{
  		IOS;
		long n,m;
		cin>>n>>m;
		for(long i=0;i<m;i++)
		{
			long u,t;
			cin>>u>>t;
			v[u].push_back(t);
		}
		/*for(long i=0;i<n;i++)
		{
			for(long j=0;j<v[i].size();j++)
			{
				cout<<v[i][j]<<" ";
			}
			cout<<"\n";
		}*/
		/*long k=0;
		vector<long> g(n+1,0);
		k=fun(g,4,0);*/
		long fans=0;
		for(long i=0;i<n+1;i++)
		{
			if(v[i].size()!=0)
			{
				vector<long> g(n+1,0);
				ans[i]=max(fans,fun(g,i,0));
				g.clear();
			}
		}
		//cout<<k<<"\n";
		cout<<fans<<"\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:51:33: error: 'ans' was not declared in this scope; did you mean 'fans'?
   51 |                                 ans[i]=max(fans,fun(g,i,0));
      |                                 ^~~
      |                                 fans
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const long N = 1e5+7;
vector<long> v[N];
long fun(vector<long> k,long i,long ans)
{
	if(k[i]!=0)
	{
		return 0;
	}
	else 
	{
		k[i]=1;ans=0;
		for(long j=0;j<v[i].size();j++)
		{
			ans=max(ans,1+fun(k,v[i][j],ans));
			//cout<<ans<<endl;
		}
	}
	return ans;
}
int main()
{
  		IOS
		long n,m;
		cin>>n>>m;
		for(long i=0;i<m;i++)
		{
			long u,t;
			cin>>u>>t;
			v[u].push_back(t);
		}
		/*for(long i=0;i<n;i++)
		{
			for(long j=0;j<v[i].size();j++)
			{
				cout<<v[i][j]<<" ";
			}
			cout<<"\n";
		}*/
		/*long k=0;
		vector<long> g(n+1,0);
		k=fun(g,4,0);*/
		vector<long> ans(n+1,0);
		for(long i=0;i<n+1;i++)
		{
			if(v[i].size()!=0)
			{
				vector<long> g(n+1,0);
				ans[i]=max(ans[i],fun(g,i,0));
				g.clear();
			}
		}
		//cout<<k<<"\n";
		cout<<*max_element(ans.begin(),ans.end())<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:17: error: expected ';' before 'long'
   26 |                 long n,m;
      |                 ^~~~
a.cc:27:22: error: 'n' was not declared in this scope
   27 |                 cin>>n>>m;
      |                      ^
a.cc:27:25: error: 'm' was not declared in this scope
   27 |                 cin>>n>>m;
      |                         ^
Language: C++

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

const int NAX = 1e5+5;
vector<int> edges[NAX];
int in_degree[NAX];
int dis[NAX];
bool visited[NAX];

void dfs(int a){
    visited[a] = true;
    for(int b: edges[a]){
        dist[b] = max(dist[b], dist[a]+1);
        --indegree[b];
        if(indegree[b] == 0)
            dfs(b);
    }
}
int main()
{
    int n,m;
    cin>>n>>m;
    while(m--){
        int a,b;
        cin>>a>>b;
        edges[a].push_back(b);
        indegree[b]++;
    }
    for(int i=1;i<=n;i++){
        if(!visited[i]&&in_degree[i]==0)
            dfs[i];
    }
    int answer = 0;
    for(int i=1;i<=n;i++){
        answer = max(answer,dist[i]);
    }
    cout<<answer;

    return 0;
}


Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:13:9: error: 'dist' was not declared in this scope; did you mean 'dis'?
   13 |         dist[b] = max(dist[b], dist[a]+1);
      |         ^~~~
      |         dis
a.cc:14:11: error: 'indegree' was not declared in this scope; did you mean 'in_degree'?
   14 |         --indegree[b];
      |           ^~~~~~~~
      |           in_degree
a.cc: In function 'int main()':
a.cc:27:9: error: 'indegree' was not declared in this scope; did you mean 'in_degree'?
   27 |         indegree[b]++;
      |         ^~~~~~~~
      |         in_degree
a.cc:31:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   31 |             dfs[i];
      |                  ^
a.cc:35:29: error: 'dist' was not declared in this scope; did you mean 'dis'?
   35 |         answer = max(answer,dist[i]);
      |                             ^~~~
      |                             dis
Language: Java

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

 class Main{

    static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    static StringBuilder sb = new StringBuilder("");
    static StringTokenizer stk = new StringTokenizer("");
    // static long[][] dp ;
    static Map<Integer,ArrayList<Integer>> adjList = new HashMap<>();
    static int N = 0;
    static int M = 0;
    static long maxValue = 0;

    public static  void main(String args[]){
        try{
            stk = new StringTokenizer(bf.readLine());
             N = Integer.parseInt(stk.nextToken());
             M = Integer.parseInt(stk.nextToken());
            //  dp =  new long[N+1][N+1];

            for(int i=0;i<M;i++){
                stk = new StringTokenizer(bf.readLine());
                int from = Integer.parseInt(stk.nextToken());
                int to = Integer.parseInt(stk.nextToken());

                if(adjList.containsKey(from)){
                    adjList.get(from).add(to);
                }else{
                    ArrayList<Integer> al = new ArrayList<>();
                    al.add(to);
                    adjList.put(from,al);
                }
            }

            solver();

        }catch(Exception e){
            e.printStackTrace();
        }
    }

    public static void solver(){
        for(int i=1;i<=N;i++){
            dfs(i,i,1);
            // System.out.println("doing dfs from "+i+" value "+maxValue);
            // printMatrix()
        }
        System.out.println(maxValue);
    }

    public static void printMatrix(){
        for(int k=1;k<=N;k++){
                for(int j=1;j<=N;j++){
                    System.out.print(dp[k][j]+" ");                
                }
                System.out.println("");
            }
    }

    public static void dfs(int src, int origin ,long length){
        if(adjList.get(src) == null || adjList.get(src).size() == 0){
            return ;
        }

        //check where things are starting 
        for(int i=0;i < adjList.get(src).size();i++){
            // dp[src][adjList.get(src).get(i)] = Math.max(dp[src][adjList.get(src).get(i)],1);
            // dp[origin][adjList.get(src).get(i)] = Math.max(dp[origin][adjList.get(src).get(i)] , length );
            maxValue = Math.max(maxValue , length]);
            dfs(adjList.get(src).get(i),origin,length+1);
        }   
    }

}

Compiler output:
Main.java:71: error: ')' or ',' expected
            maxValue = Math.max(maxValue , length]);
                                                 ^
1 error
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define print(i) std::cout << (i) << '\n'
inline long long ceildiv(long long a, long long  b) { return (a+b-1)/b; }
typedef pair<long long,long long> P;
const long long inf = 10e7;
//int |x|<=2*10**9     long |x|<= 9*10**18
typedef pair<int,string> PP;
#define ll long long

int dp(int x,vector<int> &memo,vector<vector<int>> const &edges){
if (memo[x]=!-1)return memo[x];
int ret=0;
for (int y:edges[x]){ret=max(ret,dp(y,memo,edges)+1); }
return memo[x]=ret;}
int main(){
int n,m ;cin>>n>>m;
vector<int> memo(n,-1);vector<vector<int>> edges(n,vector<int>());
rep(i,m){int a,s;cin>>a>>s;edges[--a].emplace_back(--s);}
int ans=0;
rep(j,n){ans=max(ans,dp(j));}
print(ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:24: error: too few arguments to function 'int dp(int, std::vector<int>&, const std::vector<std::vector<int> >&)'
   23 | rep(j,n){ans=max(ans,dp(j));}
      |                      ~~^~~
a.cc:13:5: note: declared here
   13 | int dp(int x,vector<int> &memo,vector<vector<int>> const &edges){
      |     ^~
Language: C++

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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
#define endl "\n"
#define all(v) v.begin(), v.end()
#define UNIQUE(v) sort(all(v)),v.erase(unique(all(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 1e5 + 5;

struct directed_graph {
  static const int N = 1e5 + 5;
  struct data {
    int node; int val;
    data() : node(-1), val(-1) {}
    data(int node, int val) : node(node), val(val){}
  };
  int n; int ind[ N ]; vector <data> g[ N ];
  init(int _n){
    n = _n;
    for (int i = 0; i <= n; i++) ind[i] = 0, g[i].clear();
  }
  void add_edge(int u, int v, int val = 0) {
    g[u].push_back(data(v, val)); ind[v]++;
  }
  vector <int> topological_order() {
    queue <int> q;
    for (int i = 1; i <= n; i++) if (ind[i] == 0) q.push(i);
    vector <int> ans;
    while (!q.empty()) {
      int to = q.front(); q.pop(); ans.push_back(to);
      for (auto x : g[to]) {
        ind[x.node]--;
        if (ind[x.node] == 0) q.push(x.node);
      }
    }
    if ((int)ans.size() != n) return vector <int> {}; return ans;
  }
} g;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("input.txt", "r", stdin);
  #endif // LOCAL
  int n, e;
  cin >> n >> e;
  g.init(n);
  for (int i = 1; i <= e; i++) {
    int u, v;
    cin >> u >> v;
    g.add_edge(u, v, 1);
  }
  vector <int> t = g.topological_order();
  vector <int> path(n + 1, 0);
  for (auto x: t) {
    for (auto val: g.g[x]) {
      path[val.node] = path[x] + 1;
    }
  }
  int mx = 0;
  for (auto x: t) mx = max(mx, path[x]);
  cout << mx << endl;
  return 0;
}


Compiler output:
a.cc:35:3: error: ISO C++ forbids declaration of 'init' with no type [-fpermissive]
   35 |   init(int _n){
      |   ^~~~
a.cc: In member function 'int directed_graph::init(int)':
a.cc:38:3: warning: no return statement in function returning non-void [-Wreturn-type]
   38 |   }
      |   ^