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

//#include"stdc++.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define cases ll t;cin>>t;while(t--)
#define f1(a,n) for(int i=a;i<n;i++)
#define f2(b,n) for(int j=b;j<n;j++)
#define INF 1000000000000009
#define pb push_back
ll ar[100005];
#define MAX 1000005
vector<vector<ll> > g(MAX);
ll dp[MAX];
ll dfs(ll i)
{
    if(dp[i]!=-1)
        return dp[i];
    int temp=0;
    for(auto &j:g[i])
        temp=max(dfs(j)+1,temp);
    dp[i]=temp;
    return temp;
}
int main() {
    fast
    ll n,m;
    cin>>n>>m;
    
    memset(dp,-1,sizeof(dp));
    f1(0,m)
    {
        ll u,v;
        cin>>u>>v;
        u-=1;
        v-=1;
        g[u].pb(v);
    }
    ll res=0;
    f1(0,n)
        res=max(res,dfs(i));
    
    cout<<res;
    
    return 0;
}




Compiler output:
a.cc: In function 'long long int dfs(long long int)':
a.cc:21:17: error: no matching function for call to 'max(long long int, int&)'
   21 |         temp=max(dfs(j)+1,temp);
      |              ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:21:17: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   21 |         temp=max(dfs(j)+1,temp);
      |              ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:21:17: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   21 |         temp=max(dfs(j)+1,temp);
      |              ~~~^~~~~~~~~~~~~~~
Language: C++

//#include"stdc++.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define cases ll t;cin>>t;while(t--)
#define f1(a,n) for(int i=a;i<n;i++)
#define f2(b,n) for(int j=b;j<n;j++)
#define INF 1000000000000009
#define pb push_back
ll ar[100005];
#define MAX 1000005
vector<vector<ll> > g(MAX);
ll dp[MAX];
int dfs(int i)
{
    if(dp[i]!=-1)
        return dp[i];
    dp[i]=0;
    for(auto &j:g[i])
        dp[j]=max(dfs(j),dp[i]);
  dp[i]+=1;
    return dp[i];
}
int main() {
    fast
    ll n,m;
    cin>>n>>m;
    
    memset(dp,-1,sizeof(dp));
    f1(0,m)
    {
        ll u,v;
        cin>>u>>v;
        u-=1;
        v-=1;
        g[u].pb(v);
    }
    int res=0;
    f1(0,n)
        res=max(res,dfs(i));
    
    cout<<res;
    
    return 0;
}



Compiler output:
a.cc: In function 'int dfs(int)':
a.cc:21:18: error: no matching function for call to 'max(int, long long int&)'
   21 |         dp[j]=max(dfs(j),dp[i]);
      |               ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:21:18: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   21 |         dp[j]=max(dfs(j),dp[i]);
      |               ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:21:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   21 |         dp[j]=max(dfs(j),dp[i]);
      |               ~~~^~~~~~~~~~~~~~
Language: C++

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

#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ldb long double 
#define db double
#define str string
#define int long long

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >

#define mi map<int,int>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const int INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

int power(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a*=a;
  n/=2;
}
return res;
}

int abst(int a)
{
 return ((a<0)?(-1*a):(a));
}
vector<int> v[100005];
int n,m;
int dp[100005];
bool vis[100005];

int fun(int s)
{
    vis[s]=true;
    if(dp[s]!=-1)
     return dp[s];
     int res=0;
    for(int j=0;j<v[i].size();j++)
    {
        res=max(res,fun(v[i][j])+1);
    }
    return dp[i]=res;
}
int32_t main()
{
    memset(dp,-1,sizeof(dp));
     cin>>n>>m;
     for(int i=0;i<m;i++)
     {
        int x,y;
        cin>>x>>y;
        v[x].pb(y);
     }
     for(int i=0;i<100005;i++)
      vis[i]=false;
     for(int i=1;i<=n;i++)
     {
        if(!vis[i])
        {
            int z=fun(i);
        }
     }
     int res=0;
     for(int i=1;i<=n;i++)
      res=max(res,dp[i]);
      cout<<res<<"\n";
      return 0;
}

Compiler output:
a.cc: In function 'long long int fun(long long int)':
a.cc:70:21: error: 'i' was not declared in this scope
   70 |     for(int j=0;j<v[i].size();j++)
      |                     ^
a.cc:74:15: error: 'i' was not declared in this scope
   74 |     return dp[i]=res;
      |               ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define vi vector<int>
const ll INF=1e9+5;
typedef struct node
{
    int av;
    node *next;
} *LPTR;
void add(LPTR &L,int x)
{
    if(!L)
    {
        LPTR l=new node;
        l->av=x;
        l->next=NULL;
        L=l;
        return ;
    }
    add(L->next,x);
}
void dfs(LPTR edg[],int v,map<int,bool> vis,int v1,int cnt,map<int,int> &path,map<int,int> &dp)
{
    vis[v1]=true;
    if(dp[v1]!=-1) return dp[v1];
    if(path[v1]==-1) path[v1]=cnt;
    else
    {
        if(path[v1]<cnt) path[v1]=cnt;
    }
    LPTR l=edg[v1];
    while(l)
    {
        if(vis[l->av]==false)
        {
            dfs(edg,v,vis,l->av,cnt+1,path);
        }
        l=l->next;
    }
}
int main()
{
    int n,m;
    cin>>n>>m;
    int p,q;
    LPTR edg[n+1]={ };
    int indegree[n+1]={ };
    int indeg[n+1]={ };
    while(m--)
    {
        cin>>p>>q;
        add(edg[p],q);
        indegree[q]++;
        indeg[q]++;
    }
    map <int,int> path;
    map <int,int> dp;
    for(int i=1;i<=n;i++) {path[i]=-1;dp[i]=-1;}
    vector<int> pi,tsort;int cnt=0;
    map<int,bool> vis;
    for (int i = 1; i <= n; ++i)
    {
        int cnt=0;
        map<int,bool> vis;
        dfs(edg,n,vis,i,cnt,path,dp);
        dp[i]=cnt;
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(ans<path[i]) ans=path[i];
    }
    cout<<ans<<endl;
    return 0;
}





Compiler output:
a.cc: In function 'void dfs(node**, int, std::map<int, bool>, int, int, std::map<int, int>&, std::map<int, int>&)':
a.cc:27:32: error: return-statement with a value, in function returning 'void' [-fpermissive]
   27 |     if(dp[v1]!=-1) return dp[v1];
      |                                ^
a.cc:38:16: error: too few arguments to function 'void dfs(node**, int, std::map<int, bool>, int, int, std::map<int, int>&, std::map<int, int>&)'
   38 |             dfs(edg,v,vis,l->av,cnt+1,path);
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:24:6: note: declared here
   24 | void dfs(LPTR edg[],int v,map<int,bool> vis,int v1,int cnt,map<int,int> &path,map<int,int> &dp)
      |      ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define vi vector<int>
const ll INF=1e9+5;
typedef struct node
{
    int av;
    node *next;
} *LPTR;
void add(LPTR &L,int x)
{
    if(!L)
    {
        LPTR l=new node;
        l->av=x;
        l->next=NULL;
        L=l;
        return ;
    }
    add(L->next,x);
}
void topsort(LPTR edg[],vector <int> p,int indegree[],int v,int &m,map<int,bool> &visited,vector<int> &ans)
{
    bool flag=false;
    for(int i=1;i<v+1;i++)
    {
        if(indegree[i]==0&&visited[i]==false)
        {
            p.push_back(i);
            LPTR l=edg[i];
            while(l!=NULL)
            {
                indegree[l->av]--;
                l=l->next;
            }
            visited[i]=true;
            topsort(edg,p,indegree,v,m,visited,ans);/*
            visited[i]=false;
            LPTR t=edg[i];
            while(t!=NULL)
            {
                indegree[t->av]++;
                t=t->next;
            }
            p.erase(p.end()-1);
            flag=true;*/
        }
    }
    if(flag==false)
    {/*
        for(int i=0;i<p.size();i++)
        {
            cout<<p[i]<<" ";
        }
        cout<<endl;*/
        if(m==0) ans=p;
        m++;
        return;
    }
}
void dfs(LPTR edg[],int v,map<int,bool> vis,int v1,int cnt,map<int,int> &dp)
{
    vis[v1]=true;
    if(dp[v1]==-1) dp[v1]=cnt;
    else
    {
        if(dp[v1]<cnt) dp[v1]=cnt;
    }
    LPTR l=edg[v1];
    while(l)
    {
        if(vis[l->av]==false)
        {
            dfs(edg,v,vis,l->av,cnt+1,dp);
        }
        l=l->next;
    }
}
int main()
{
    int n,m;
    cin>>n>>m;
    int p,q;
    LPTR edg[n+1]={ };
    int indegree[n+1]={ };
    int indeg[n+1]={ }
    while(m--)
    {
        cin>>p>>q;
        add(edg[p],q);
        indegree[q]++;
        indeg[q]++;
    }
    map <int,int> dp;
    for(int i=1;i<=n;i++) dp[i]=-1;
    vector<int> pi,tsort;int cnt=0;
    map<int,bool> vis;
    topsort(edg,pi,indegree,n,cnt,vis,tsort);
    for (int i = 0; i < tsort.size(); ++i)
    {
        if(indeg[tsort[i]]==0){
        int cnt=0;
        map<int,bool> vis;
        dfs(edg,n,vis,tsort[i],cnt,dp);}
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(ans<dp[i]) ans=dp[i];
    }
    cout<<ans<<endl;
    return 0;
}





Compiler output:
a.cc: In function 'int main()':
a.cc:89:5: error: expected ',' or ';' before 'while'
   89 |     while(m--)
      |     ^~~~~
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class LongestPath {
    public static int path(Edge[] edges, Vertex[] vertices){
        int sum = 0;
        int[] in_degree = new int[vertices.length];
        boolean[] visited = new boolean[vertices.length];
        Arrays.fill(in_degree, 0);
        Arrays.fill(visited, false);
        for (Edge e : edges){
            in_degree[e.dst-1]++;
        }
        Queue<Integer> queue = new LinkedList<>();
        for (int i = 0; i < vertices.length; i++) {
            if (!visited[i] && in_degree[i] == 0){
                queue.add(i);
            }
        }
        int[] path = new int[vertices.length];
        Arrays.fill(path, 0);
        while (!queue.isEmpty()){
            int v = queue.poll();
            visited[v] = true;
            for (Edge e: vertices[v].edges){
                in_degree[e.dst-1]--;
                if (path[e.src-1] + 1 > path[e.dst - 1]){
                    path[e.dst-1] = path[e.src-1] + 1;
                }
                if (in_degree[e.dst-1] == 0){
                    queue.add(e.dst-1);
                }
            }
        }
        for (int i = 0; i < vertices.length; i++) {
            if (path[i] > sum){
                sum = path[i];
            }
        }
        return sum;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(reader.readLine());
        int N = Integer.parseInt(st.nextToken());
        int M = Integer.parseInt(st.nextToken());
        Edge[] edges = new Edge[M];
        Vertex[] vertices = new Vertex[N];
        for (int i = 0; i < N; i++) {
            vertices[i] = new Vertex();
            vertices[i].edges = new Vector<>();
        }

        for (int i = 0; i < M; i++) {
            st = new StringTokenizer(reader.readLine());
            edges[i] = new Edge();
            edges[i].src = Integer.parseInt(st.nextToken());
            edges[i].dst = Integer.parseInt(st.nextToken());
            vertices[edges[i].src-1].edges.add(edges[i]);
        }
        System.out.println(path(edges, vertices));
    }

    private static class Edge{
        int src;
        int dst;
    }

    private static class Vertex{
        Vector<Edge> edges;
    }
}


Compiler output:
Main.java:6: error: class LongestPath is public, should be declared in a file named LongestPath.java
public class LongestPath {
       ^
1 error
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n,m;
	cin>>n>>m;
	vector<ll>arr[n+1];
	
for(int i=0;i<m;i++){
	int x,y;
	cin>>x>>y;
	
	arr[x].push_back(y);
}
ll dp[n+1];
ll vis[n+1];
memset(dp,0,sizeof(dp));
memset(vis,0,sizeof(vis));
for(int i=1;i<=n;i++){
	if(vis[i]==0){
		queue<ll>q;
		q.push(i);
		while(!q.empty()){
			ll temp=q.front();
			q.pop();
			vis[temp]=1;
			for(int k=0;k<arr[temp].size();k++){
				if(!vis[temp][k]){
				dp[arr[temp][k]]=dp[temp]+1;
				q.push(arr[temp][k]);
				}
				
			}
		}
	}
}
	cout<<*max_element(dp,dp+n+1);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:46: error: invalid types 'long long int[int]' for array subscript
   28 |                                 if(!vis[temp][k]){
      |                                              ^
Language: C++


#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;

ll n,m;

vector<vector<ll>> G;
ll dp[100100];

ll rec(ll v){
    if(dp[v]!=-1){
        return dp[v];
    }
    int res;
    for(auto x:G[v]){
        chmax(res,rec(v)+1LL);
    }
    return dp[v]=res;
}

int main()
{
    cin >> n >> m;
    G.assign(n,vector<ll>());
    rep(i,m){
        ll x,y;
        cin >> x >> y;
        x--;
        y--;
        G[x].push_back(y);
    }
    rep(v,n){
        dp[v]=-1;
        
    }
    ll res=0;
    rep(v,n){
        chmax(res,rec(v));
    }
    cout << res << endl;
    return 0;
} 

Compiler output:
a.cc: In function 'long long int rec(long long int)':
a.cc:54:14: error: no matching function for call to 'chmax(int&, long long int)'
   54 |         chmax(res,rec(v)+1LL);
      |         ~~~~~^~~~~~~~~~~~~~~~
a.cc:31:31: note: candidate: 'template<class T> bool chmax(T&, T)'
   31 | template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
      |                               ^~~~~
a.cc:31:31: note:   template argument deduction/substitution failed:
a.cc:54:14: note:   deduced conflicting types for parameter 'T' ('int' and 'long long int')
   54 |         chmax(res,rec(v)+1LL);
      |         ~~~~~^~~~~~~~~~~~~~~~
Language: C++


#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;

ll n,m;

vector<vector<ll>> G;
ll dp[100100];

ll rec(ll v){
    if(dp[v]!=-1){
        return dp[v];
    }
    int res;
    for(auto x:G[v]){
        chmax(res,rec(v)+1);
    }
    return dp[v]=res;
}

int main()
{
    cin >> n >> m;
    G.assign(n,vector<ll>());
    rep(i,m){
        ll x,y;
        cin >> x >> y;
        x--;
        y--;
        G[x].push_back(y);{
    }
    rep(v,n){
        dp[v]=-1;
        
    }
    ll res=0;
    rep(v,n){
        chmax(res,rec(v));
    }
    cout << res << endl;
    return 0;
} 

Compiler output:
a.cc: In function 'long long int rec(long long int)':
a.cc:54:14: error: no matching function for call to 'chmax(int&, long long int)'
   54 |         chmax(res,rec(v)+1);
      |         ~~~~~^~~~~~~~~~~~~~
a.cc:31:31: note: candidate: 'template<class T> bool chmax(T&, T)'
   31 | template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
      |                               ^~~~~
a.cc:31:31: note:   template argument deduction/substitution failed:
a.cc:54:14: note:   deduced conflicting types for parameter 'T' ('int' and 'long long int')
   54 |         chmax(res,rec(v)+1);
      |         ~~~~~^~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:80:2: error: expected '}' at end of input
   80 | }
      |  ^
a.cc:60:1: note: to match this '{'
   60 | {
      | ^
Language: Java


import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Graph {
    ArrayList<Integer>[] graph;

    @SuppressWarnings("unchecked")
    Graph(int n) {
        graph = new ArrayList[n];
        for(int i = 0; i < n; i++) {
            graph[i] = new ArrayList<>();
        }
    }
    public void addEdge(int u, int v) {
        graph[u].add(v);
    }
    public ArrayList<Integer> neighbors(int u) {
        return graph[u];
    }
}

public class Main {
    static Graph g;
    static boolean[] visited;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), m = in.nextInt();

        g = new Graph(n);
        visited = new boolean[n];

        for(int i = 0; i < m; i++) {
            int u = in.nextInt(), v = in.nextInt();
            u--; v--;
            g.addEdge(u, v);
        }
        int mx = 0;
        for(int i = 0; i < n; i++) {
            if(!visited[i]) {
                mx = Math.max(mx, go(i));
                visited[i] = true;
            }
        }

        System.out.println(mx - 1);
    }

    private static int go(int u) {
        int ans = 0;
        if(visited[u]) return 0; 
        visited[u] = true;
        for (int v : g.neighbors(u)) {
            ans = Math.max(ans, go(v));
        }
        return ans + 1;
    }

Compiler output:
Main.java:60: error: reached end of file while parsing
    }
     ^
1 error
Language: Java

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Graph {
    ArrayList<Integer>[] graph;

    @SuppressWarnings("unchecked")
    Graph(int n) {
        graph = new ArrayList[n];
        for(int i = 0; i < n; i++) {
            graph[i] = new ArrayList<>();
        }
    }
    public void addEdge(int u, int v) {
        graph[u].add(v);
    }
    public ArrayList<Integer> neighbors(int u) {
        return graph[u];
    }
}

public class G {
    static Graph g;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), m = in.nextInt();
        g = new Graph(n);
        for(int i = 0; i < m; i++) {
            int u = in.nextInt(), v = in.nextInt();
            u--; v--;
            g.addEdge(u, v);
        }
        boolean[] visited = new boolean[n];
        int mx = 0;
        for(int i = 0; i < n; i++) {
            if(!visited[i]) {
                mx = Math.max(mx, go(i));
                visited[i] = true;
            }
        }

        System.out.println(mx - 1);
    }

    private static int go(int u) {
        int ans = 0;
        for (int v : g.neighbors(u)) {
            ans = Math.max(ans, go(v));
        }
        return ans + 1;
    }

}


Compiler output:
Main.java:24: error: class G is public, should be declared in a file named G.java
public class G {
       ^
1 error
Language: C++

#include <iostream>
#include <vector>
#include <queue>
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; }
const long long INF = 1LL<<60;

// 入力
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);
    for (int i = 0; i < M; ++i) {
        int x, y; cin >> x >> y;
        --x, --y; // 0-indexed にする
        G[x].push_back(y);
        deg[y]++;
    }

    // source をキューに突っ込む
    queue<int> que;
    for (int v = 0; v < N; ++v) if (deg[v] == 0) que.push(v);

    // BFS
  long long step = 0;
    while (!que.empty()) {
        int v = que.front(); que.pop();
        for (auto nv : G[v]) {
            deg[nv]--; // エッジ (v, nv) を破壊する
            if (deg[nv] == 0) {
                que.push(nv); // それによって入次数が 0 にあったならキューに突っ込む
                chmax(dp[nv], step + 1); // さらにソースから nv までの再長距離が確定する
            }
        }
      step++;
    }

    // 答え
    int res = 0;
    for (int v = 0; v < N; ++v) chmax(res, dp[v]);
    cout << res << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:22: error: no matching function for call to 'chmax(int&, long long int)'
   39 |                 chmax(dp[nv], step + 1); // さらにソースから nv までの再長距離が確定する
      |                 ~~~~~^~~~~~~~~~~~~~~~~~
a.cc:5:31: note: candidate: 'template<class T> bool chmax(T&, T)'
    5 | template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
      |                               ^~~~~
a.cc:5:31: note:   template argument deduction/substitution failed:
a.cc:39:22: note:   deduced conflicting types for parameter 'T' ('int' and 'long long int')
   39 |                 chmax(dp[nv], step + 1); // さらにソースから nv までの再長距離が確定する
      |                 ~~~~~^~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;
int n,m;
vector<vector<int>> g;
vector<int> dp;

int func(int idx) {
	if(idx>=n && idx<0)
		return INT_MIN;
	
	if(dp[idx]!=-1)
		return dp[idx];
	
	int maxm = -1;
	for(int i=0; i<g[idx].size(); i++) {
		maxm = max(maxm, func(g[i])) + 1;
	}

	return dp[idx] = maxm;
}

int main() {
	cin>>n>>m;

	g.clear();
	g.resize(n+1);
	dp.resize(n+1,-1);

	int x,y;
	for(int i=0; i<m; i++) {
		cin>>x>>y;
		g[y].push_back(x);
	}

	maxm = -1;
	for(int i=0; i<=n;i++) {
		if(dp[i]==-1) {
			func(idx);
		}
		maxm = max(dp[i], maxm);
	}

	cout<<maxm<<endl;
}

Compiler output:
a.cc: In function 'int func(int)':
a.cc:17:38: error: cannot convert '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to 'int'
   17 |                 maxm = max(maxm, func(g[i])) + 1;
      |                                  ~~~~^~~~~~
      |                                      |
      |                                      __gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type {aka std::vector<int>}
a.cc:8:14: note:   initializing argument 1 of 'int func(int)'
    8 | int func(int idx) {
      |          ~~~~^~~
a.cc: In function 'int main()':
a.cc:36:9: error: 'maxm' was not declared in this scope
   36 |         maxm = -1;
      |         ^~~~
a.cc:39:30: error: 'idx' was not declared in this scope
   39 |                         func(idx);
      |                              ^~~
Language: C++

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;
#define TENS(n) int(1e##n + n)

int A[TENS(5)][TENS(5)];
// i 番目から出発したときの最長経路
int dp[TENS(5)];
int deg_o[TENS(5)];
int N, M;

void solve()
{
    cin >> N;
    cin >> M;
    REP0(i, M)
    {
        int x, y;
        cin >> x >> y;
        A[x][y] = 1;
        deg_o[x]++;
    }

    REP1(i, N)
    {
        if (deg_o[i] == 0) // 終点
        {
            queue<int> S;
            S.push(i);
            while (S.size())
            {
                int v = S.front();
                S.pop();
                REP1(j, N)
                {
                    if (A[j][v])
                    {
                        S.push(j);
                        dp[j] = max(dp[j], dp[v] + 1);
                    }
                }
            }
        }
    }

    int ans = 0;
    REP1(i, N)
    {
        ans = max(ans, dp[i]);
    }

    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Compiler output:
/tmp/ccidM2UW.o: in function `solve()':
a.cc:(.text+0xf): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccidM2UW.o
a.cc:(.text+0x28): relocation truncated to fit: R_X86_64_PC32 against symbol `M' defined in .bss section in /tmp/ccidM2UW.o
a.cc:(.text+0x47): relocation truncated to fit: R_X86_64_PC32 against symbol `M' defined in .bss section in /tmp/ccidM2UW.o
a.cc:(.text+0xb7): relocation truncated to fit: R_X86_64_PC32 against symbol `deg_o' defined in .bss section in /tmp/ccidM2UW.o
a.cc:(.text+0xce): relocation truncated to fit: R_X86_64_PC32 against symbol `deg_o' defined in .bss section in /tmp/ccidM2UW.o
a.cc:(.text+0xee): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccidM2UW.o
a.cc:(.text+0x10a): relocation truncated to fit: R_X86_64_PC32 against symbol `deg_o' defined in .bss section in /tmp/ccidM2UW.o
a.cc:(.text+0x16f): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccidM2UW.o
a.cc:(.text+0x1cc): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccidM2UW.o
a.cc:(.text+0x1e9): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccidM2UW.o
a.cc:(.text+0x212): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;
#define TENS(n) int(1e##n + n)

int A[TENS(5)][TENS(5)];
int N, M, ans;

void dfs(int v, int depth)
{
    bool isStop = true;
    REP1(i, N)
    {
        if (A[v][i])
        {
            isStop = false;
            dfs(i, depth + 1);
        }
    }
    if (isStop)
    {
        ans = max(ans, depth);
        return;
    }
}

void solve()
{
    cin >> N;
    cin >> M;
    REP0(i, M)
    {
        int x, y;
        cin >> x >> y;
        A[x][y] = 1;
    }

    REP1(i, N)
    {
        dfs(i, 0);
    }

    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Compiler output:
/tmp/ccSIHUKF.o: in function `dfs(int, int)':
a.cc:(.text+0x1b): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccSIHUKF.o
a.cc:(.text+0x81): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccSIHUKF.o
a.cc:(.text+0x91): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccSIHUKF.o
/tmp/ccSIHUKF.o: in function `solve()':
a.cc:(.text+0xa3): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccSIHUKF.o
a.cc:(.text+0xbc): relocation truncated to fit: R_X86_64_PC32 against symbol `M' defined in .bss section in /tmp/ccSIHUKF.o
a.cc:(.text+0xdb): relocation truncated to fit: R_X86_64_PC32 against symbol `M' defined in .bss section in /tmp/ccSIHUKF.o
a.cc:(.text+0x14c): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccSIHUKF.o
a.cc:(.text+0x172): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccSIHUKF.o
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int dp[100001];
int dfs(vector<int> v[],int idx)
{
  if(dp[idx]!=-1) return dp[idx];
  int max_=0;
  //visited[idx]=true;
  for(auto a:v[idx])
  {
    max_=max(max_,1+dfs(v,a));
  }
  return dp[idx]=max_;
  
}

int main()
{
    int n,m,a,b; cin>>n>>m;
    vector<int> v[n+1];
  //memset(visited,false,sizeof(visited));
  memset(dp,-1,sizeof(dp));
  while(m--)
  {
    cin>>a>>b; v[a].push_back(b);
  }
  int max_=0;
  
  for(int i=1;i<=n;i++)
  {
    if(!visited[i]) dfs(v,i);
  }
  for(int i=1;i<=n;i++) {max_=max(max_,dp[i]);}
  cout<<max_;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:9: error: 'visited' was not declared in this scope
   32 |     if(!visited[i]) dfs(v,i);
      |         ^~~~~~~
Language: C++

#include<bits/stdc++.h>
#define ld  double
#define ll long long 
#define pp push
#define pb push_back
#define pf push_front
#define mp make_pair
#define inf 1e9
#define f first
#define s second
#define pll pair<ll,ll>
#define vll vector<ll>
#define vi vector<int>
#define mod 1000000007
using namespace std; 
vector<int> grafo[MAXN];
int dp[MAXN],vis[MAXN],N,M;

int solve(int v){

	if(vis[v]) return dp[v];

	vis[v] = 1;
	int best = 0;

	for(int u : grafo[v]){
		best = max(best, solve(u) + 1 );
	}

	return dp[v] = best;

}

int main(){

	scanf("%d %d",&N,&M);
	for(int i = 1;i<=M;i++){
		int u,v;
		scanf("%d %d",&u,&v);
		grafo[u].push_back(v);
	}

	int best = 0;
	for(int i = 1;i<=N;i++) best = max(best, solve(i) );
	printf("%d\n",best);

	return 0;

}

Compiler output:
a.cc:16:19: error: 'MAXN' was not declared in this scope
   16 | vector<int> grafo[MAXN];
      |                   ^~~~
a.cc:17:8: error: 'MAXN' was not declared in this scope
   17 | int dp[MAXN],vis[MAXN],N,M;
      |        ^~~~
a.cc:17:18: error: 'MAXN' was not declared in this scope
   17 | int dp[MAXN],vis[MAXN],N,M;
      |                  ^~~~
a.cc: In function 'int solve(int)':
a.cc:21:12: error: 'vis' was not declared in this scope; did you mean 'vi'?
   21 |         if(vis[v]) return dp[v];
      |            ^~~
      |            vi
a.cc:21:27: error: 'dp' was not declared in this scope; did you mean 'dup'?
   21 |         if(vis[v]) return dp[v];
      |                           ^~
      |                           dup
a.cc:23:9: error: 'vis' was not declared in this scope; did you mean 'vi'?
   23 |         vis[v] = 1;
      |         ^~~
      |         vi
a.cc:26:21: error: 'grafo' was not declared in this scope
   26 |         for(int u : grafo[v]){
      |                     ^~~~~
a.cc:30:16: error: 'dp' was not declared in this scope; did you mean 'dup'?
   30 |         return dp[v] = best;
      |                ^~
      |                dup
a.cc: In function 'int main()':
a.cc:40:17: error: 'grafo' was not declared in this scope
   40 |                 grafo[u].push_back(v);
      |                 ^~~~~
Language: Java

import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class Graph {
    private int v;
    private LinkedList<Integer>[] adj_lists;
    private int[] maxLens;
    //node starts from 1;
    Graph (int v){
        this.v = v;
        adj_lists = new LinkedList[v + 1];
        maxLens = new int[v + 1];
        for (int i = 1; i < v + 1; i++){
            adj_lists[i] = new LinkedList<Integer>();
            maxLens[i] = -1;
        }
    }

    public void addEdge(int source, int dest){
        adj_lists[source].add(dest);
        //adj_lists[dest].add(source);
    }

    public LinkedList<Integer> getAdjs(int node){
        return adj_lists[node];
    }

//    public boolean isEnd(int node){
//        return adj_lists[node].isEmpty();
//    }

    public int DFS(int node){

        if (maxLens[node] != -1){
            return maxLens[node];
        }else{
            int maxlen = 0;
            for (int child : getAdjs(node)){
              maxlen = Math.max(maxlen, 1 + DFS(child));
              maxLens[node] = maxlen;
            }
            return maxlen;
        }
    }

    public int findLongestPath(){
        int maxLen = 0;
        for (int i = 1; i < adj_lists.length; i++ ){

            maxLen = Math.max(DFS(i),maxLen);
        }
        return maxLen;
    }

}

public class Main{




 public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        PrintWriter pw = new PrintWriter(System.out);
 
        st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        int m = Integer.parseInt(st.nextToken());
 
        Graph g = new Graph(n);
 
        for(int i=0 ; i<m ; i++) {
            st = new StringTokenizer(br.readLine());
            int u = Integer.parseInt(st.nextToken());
            int v = Integer.parseInt(st.nextToken());
            g.addEdge(u, v);
        }
 
        int ans = g.findLongestPath();
        pw.print(ans);
        
        
        
        
        
        
        
        pw.flush();
        pw.close();
    }

}

Compiler output:
Main.java:8: error: class Graph is public, should be declared in a file named Graph.java
public class Graph {
       ^
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.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class Graph {
    private int v;
    private LinkedList<Integer>[] adj_lists;
    private int[] maxLens;
    //node starts from 1;
    Graph (int v){
        this.v = v;
        adj_lists = new LinkedList[v + 1];
        maxLens = new int[v + 1];
        for (int i = 1; i < v + 1; i++){
            adj_lists[i] = new LinkedList<Integer>();
            maxLens[i] = -1;
        }
    }

    public void addEdge(int source, int dest){
        adj_lists[source].add(dest);
        //adj_lists[dest].add(source);
    }

    public LinkedList<Integer> getAdjs(int node){
        return adj_lists[node];
    }

//    public boolean isEnd(int node){
//        return adj_lists[node].isEmpty();
//    }

    public int DFS(int node){

        if (maxLens[node] != -1){
            return maxLens[node];
        }else{
            int maxlen = 0;
            for (int child : getAdjs(node)){
              maxlen = Math.max(maxlen, 1 + DFS(child));
              maxLens[node] = maxlen;
            }
            return maxlen;
        }
    }

    public int findLongestPath(){
        int maxLen = 0;
        for (int i = 1; i < adj_lists.length; i++ ){

            maxLen = Math.max(DFS(i),maxLen);
        }
        return maxLen;
    }



    public String toString(){
        StringBuilder ans = new StringBuilder();
        int node = 1;

        for (LinkedList<Integer> adjs : Arrays.copyOfRange(adj_lists,1,adj_lists.length)){
            ans.append(node);
              for (int adj : adjs) {
              ans.append(" -> ");
              ans.append(adj);
             }
          ans.append("\n");
          node++;
      }
        return ans.toString();
    }

    public static void main (String[] args){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        PrintWriter pw = new PrintWriter(System.out);
 
        st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        int m = Integer.parseInt(st.nextToken());
 
        Graph g = new Graph(n);
 
        for(int i=0 ; i<m ; i++) {
            st = new StringTokenizer(br.readLine());
            int u = Integer.parseInt(st.nextToken());
            int v = Integer.parseInt(st.nextToken());
            g.addEdge(u, v);
        }
 
        int ans = g.findLongestPath();
        pw.print(ans);

        
        pw.flush();
        pw.close();



    }
}

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

import java.util.*;
public class Main{
  ArrayList<Integer> adj[];
public static void main(String args[]){  
  Scanner sc=new Scanner(System.in);
  int ver=sc.nextInt();
  int edg=sc.nextInt();
  adj=new ArrayList<Integer>[ver];
  for(int i=0;i<ver;i++){
  adj[i]=new ArrayList<Integer>();
  }
  for(int i=0;i<edg;i++){
    int a=sc.nextInt();
    int b=sc.nextInt();
    arr[a-1].add(b-1);
   }
  int visited[]=new int[ver];
  int dp[]=new int[ver];
  for(int i=0;i<ver;i++){
  if(!visited[i])
    dfs(dp,visited,adj)
  }
  
  int max=0;
  for(int i=0;i<dp.length;i++){
    if(dp[i]>max)
      max=dp[i];
  }
  System.out.println(max);
}
        public static void dfs(int dp[],int visited[],int node,ArrayList<Integer> adj){
        visited[node]=true;
          for(int i=0;i<adj[node].size();i++){
              if(!visited[adj[node].get(i))
                          dfs(dp,visited,adj[node].get(i),adj)
                          
               dp[node]=Math.max(dp[node],1+dp[adj[node].get(i)]);           
          }
          
        }
}

Compiler output:
Main.java:21: error: ';' expected
    dfs(dp,visited,adj)
                       ^
Main.java:34: error: ']' expected
              if(!visited[adj[node].get(i))
                                          ^
Main.java:35: error: ';' expected
                          dfs(dp,visited,adj[node].get(i),adj)
                                                              ^
3 errors
Language: C++

        #include<bits/stdc++.h>
        using namespace std;
        #define itn int
        #define int long long 
        int dp[1000005];
        int nx;

        bool h[1000005];
        vector<itn> e[1000005];
          int a,b,c,d;
        int f(int g){
          if(h[g]) return dp[g];
          int nx=0;
     
          for(int j=0;j<e[g].size();j++){
            nx=max(nx,f(e[g][j])+1);
          }
          dp[g]=nx;
          h[g]=true;
          return nx;
        }
        signed main(){
          cin>>a>>b;
          for(int i=0;i<b;i++){
            cin>>c>>d;
            e[c].push_back(d);
          }
          for(int i=1;i<=a;i++){
            n=max(n,f(i));
          }
          cout<<n<<"\n";
          return 0;
        }

Compiler output:
a.cc: In function 'int main()':
a.cc:29:13: error: 'n' was not declared in this scope
   29 |             n=max(n,f(i));
      |             ^
a.cc:31:17: error: 'n' was not declared in this scope; did you mean 'yn'?
   31 |           cout<<n<<"\n";
      |                 ^
      |                 yn
Language: C++

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

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<typename T> void view(T cont) {std::cout << cont << std::endl;}
template<typename T> void view(T* cont, ll sz) {rep(i, sz) std::cout << cont[i] << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<T>& v) {for (const auto& f: v) std::cout << f << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v: vv) {view(v);}}
const long long INF = 1LL<<60;

ll N, M;
vector<vector<ll> > G;
int count_max = 0;
int temp_count = 0;
vector<bool> visited;

void dfs(ll pos) {
    // cout << pos << endl;
    count_max++;
    if (G[pos].empty()) {
        // cout << pos << endl;
        if (count_max > temp_count) temp_count = count_max;
        return;
    }
    for (int i = 0; i < G[pos].size(); i++) {
        // if (!visited[G[pos][i]]) {
            // cout << G[pos][i] << endl;
            dfs(G[pos][i]);
            count_max--;
            // visited[G[pos][i]] = true;
        // }
    }
    return;
}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

//@author :  |< U $ |-|
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#define ll long long
#define vi vector<long long>
#define pb push_back
#define po pop_back
#define pi pair<long long ,long long>
#define vp vector<pair<long long,long long> >
#define mkp make_pair
#define in(i,n) for(i=0;i<n;i++)
#define fon(i,n,m) for(i=n;i<m;i++)
#define rfon(i,n,m) for(i=n;i>=m;i--)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);
#define map map<long long,long long>
#define inm1(b)  memset(b,1,sizeof(b))
#define in0(b) memset(b,0,sizeof(b))
#define ininf(b) memset(b,1000000001,sizeof(b))
#define M  1000000007
#define I 10000000001
#define TakeInput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
using namespace std;
ll gcd(ll a, ll b) {  if (a == 0)  return b; return gcd(b % a, a); }
ll f(ll n,ll m,ll d){
    if(n>m){
        return I;
    }
    if(n==m){
        return d;
    }
    ll d1=f(n*2,m,d+1);
    ll d2=f(n*3,m,d+1);
    return min(d1,d2);
}
ll ma=0;
ll dis[100001]={0};
vector<ll> v[100001];
ll dfs(ll i){
    if(v[i].size()==0){
        dis[i]=1;
        return dis[i];
    }
    ll ma=0;
    for(auto& ver : v[i]){
        
        ma=max(dfs(ver)+1,ma);
    }
    dis[i]=ma;
    return dis[i];

}
int main()
{
    jaldi
    #ifndef ONLINE_JUDGE 
    //TakeInput
    #endif
        
    ll n,m,i,j,k;
    cin>>n>>m;
    in(i,m){
        ll src,des;
        cin>>src>>des;
        v[src].pb(des);
    }
    fon(i,1,n+1){
        dfs(i,vis);
    }
    fon(i,1,n+1){
        ma=max(ma,dis[i]);
    }
    cout<<ma-1;

}
 
 








 



Compiler output:
a.cc: In function 'int main()':
a.cc:79:15: error: 'vis' was not declared in this scope; did you mean 'dis'?
   79 |         dfs(i,vis);
      |               ^~~
      |               dis
Language: C++

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

vector<int> g[100005];
bool used[100005];
int dist[100005];
int in_degree[100005];
void dfs(int a) {
    used[a] = 1;
    for(int b : g[a]) {
            dist[b] = max(dist[b], dist[a] + 1);
            in_degree[b]--;
            if(in_degree[b] == 0) dfs(b);
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    while(m--) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        in_degree[b]++;
    }
    for(int i = 1; i <= n; i++) dist[i] = 0;
    for(int i = 1;  i <= n; i++) {
        if(!used[i] && in_degree[b]== 0) {
            dfs(i);
        }
    }
    int ans = 0;
    for(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:28:34: error: 'b' was not declared in this scope
   28 |         if(!used[i] && in_degree[b]== 0) {
      |                                  ^