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

#include <cstring>
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
const int MAX_N=100005;
int dp[MAX_N],in[MAX_N];//dp[i]表示以i点为终点最多可以经过多少个点(多少次传输),in存每个点的入度 
vector<int> G[MAX_N];//存每个点所连接的点 
int main()
{
    queue<int> q;
    int n,m,a,b,ans=0;
	scanf("%d%d",&n,&m);
    for(int i=1;i<=m;++i)
    {
    	scanf("%d%d",&a,&b);//a到b有一条边 
		in[b]++;//b入度++ 
		G[a].push_back(b);//b加入a所连接的点的集合 
	}
    for(int i = 1;i<=n;++i)
	  if(!in[i])//若入度为0，入队 
	    q.push(i);
    while(!q.empty())
    {
        int now=q.front();
        q.pop();//队首元素出队 
        int sz=G[now].size();//队首元素相连接的点的个数 
        for(int i=0;i<sz;++i)//遍历其连接的点 
        {
            dp[G[now][i]]=max(dp[G[now][i]],dp[now]+1);//用其dp值更新其连接的点的dp值 
            in[G[now][i]]--;//其连接的点的入度-- 
            if(in[G[now][i]]==0)//若入度为0了，则入队 
			  q.push(G[now][i]);
        }
    }
    for(int i=1;i<=n;++i)//遍历所有点 
	  ans=max(ans,dp[i]);//保留dp值最大的(以该点为终点可以传输的次数最多) 
    printf("%d\n",ans);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:5: error: 'queue' was not declared in this scope
   12 |     queue<int> q;
      |     ^~~~~
a.cc:6:1: note: 'std::queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
    5 | #include <algorithm>
  +++ |+#include <queue>
    6 | using namespace std;
a.cc:12:11: error: expected primary-expression before 'int'
   12 |     queue<int> q;
      |           ^~~
a.cc:23:13: error: 'q' was not declared in this scope
   23 |             q.push(i);
      |             ^
a.cc:24:12: error: 'q' was not declared in this scope
   24 |     while(!q.empty())
      |            ^
Language: C++

# include <bits/stdc++.h>
using namespace std; 
const int mod=1e5+1;
long long int visited[mod]={0};
vector < int> adj[mod];
 long long int dfs(int n){
  if(adj[n].size()==0){
    return 1;
    visited[n]=1;
  }
 long long int maxx=0;
  for(auto i:adj[n]){
      maxx=max(maxx,dfs(i));
      
  }
  visited[n]=maxx+1; 
  return visited[n];
}
int main(){
  int n, i, x, y, ans, m; 
  cin>>n>>m; 
  while(m--){
    cin>>x>>y; 
    adj[x].push_back(y);
  }
  ans=0;
  for(i=1;i<=n;i++){
      ans=max(ans,visited[i]);
  }
  cout<<ans-1;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:14: error: no matching function for call to 'max(int&, long long int&)'
   28 |       ans=max(ans,visited[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:1:
/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:28:14: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   28 |       ans=max(ans,visited[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:28:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   28 |       ans=max(ans,visited[i]);
      |           ~~~^~~~~~~~~~~~~~~~
Language: C++

# include <bits/stdc++.h>
using namespace std; 
const int mod=1e5+1;
int visited[mod]={0};
vector < int> adj[mod];
long long int dfs(int n){
  if(adj[n].size()==0){
    return 1;
    visited[n]=1;
  }
 long long int maxx=0;
  for( int i=0;i<adj[n].size();i++){
      maxx=max(maxx,dfs(adj[n][i]));
      
  }
  visited[n]=maxx+1; 
  return maxx+1;
}
int main(){
  int n, i, x, y, ans, m; 
  cin>>n>>m; 
  while(m--){
    cin>>x>>y; 
    adj[x].push_back(y);
  }
  ans=0;
  for(i=1;i<=n;i++){
    if(visited[i]==0){
      ans=max(ans,dfs(i));
    }
    else{
      ans=max(ans,visited[i]);
    }
  }
  cout<<ans-1;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:14: error: no matching function for call to 'max(int&, long long int)'
   29 |       ans=max(ans,dfs(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:1:
/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:29:14: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   29 |       ans=max(ans,dfs(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:29:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   29 |       ans=max(ans,dfs(i));
      |           ~~~^~~~~~~~~~~~
Language: C++

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

int main()
{
   long long  n,m;
   cin>>n>>m;
  if(m==1) 
  {
      cout<<m;
      return 0;
  }
   vector<vector<long long >> adj(n+1);
   long long  a,b;
   vector<long long> vec(n+1,0);
   for(int i=1;i<=m;i++)
   {
       cin>>a>>b;
       adj[a].push_back(b);
       vec[b]++;
   }
    priority_queue<pair<long long ,long long>> q;
    for(long long i=1;i<=n;i++)
    {
        if(vec[i]==0)
           
    }
    long long ans=0;
    while(!q.empty())
    {
        pair<long long,long long> t= q.top();
        q.pop();
       if(t.first>ans)
         ans=t.first;
        for(auto y:adj[t.second])
        {
                if(vec[y]!=0)
                {
                    q.push({t.first+1,y});
                    vec[y]--;
                }
        }
    }
    cout<<ans; 
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:5: error: expected primary-expression before '}' token
   28 |     }
      |     ^
Language: C++

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

int main()
{
   long long  n,m;
   cin>>n>>m;
  if(m==1) 
  {
      cout<<m;
      return 0;
  }
   vector<vector<long long >> adj(n+1);
   long long  a,b;
   vector<long long> vec(n+1,0);
   for(int i=1;i<=m;i++)
   {
       cin>>a>>b;
       adj[a].push_back(b);
       vec[b]++;
   }
    priority_queue<pair<long long ,long long>> q;
    for(long long i=1;i<=n;i++)
    {
        if(vec[i]==0)
           q.push({0,i});
    }
    vector<vector<long long>> vis(n+1,vector<long long>(n+1,0));
    long long ans=0;
    while(!q.empty())
    {
        pair<long long,long long> t= q.front();
        q.pop();
       if(t.first>ans)
         ans=t.first;
        for(auto y:adj[t.second])
        {
            if(vis[t.second][y]==0)
            {
                q.push({t.first+1,y});
                vis[t.second][y]=1;
            }
        }
    }
    cout<<ans; 
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:40: error: 'class std::priority_queue<std::pair<long long int, long long int> >' has no member named 'front'
   33 |         pair<long long,long long> t= q.front();
      |                                        ^~~~~
Language: C

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int dp[maxn],deg[maxn];
vector<int> G[maxn];

int get(int u)
{
	if(dp[u]) return dp[u];
	for(auto it:G[u])
	dp[u]=max(dp[u],get(it)+1);
	return dp[u];
}

int main()
{
	int n,m,x,y;
	cin>>n>>m;
	
	while(m--) 
	{
		 cin>>x>>y;
		 deg[y]++;
		 G[x].push_back(y);
	}
	
	int ans=0;
	for(int i=1;i<=n;i++)
	if(deg[i]==0) ans=max(ans,get(i));
	
	cout<<ans<<endl;
	
	return 0;
 } 

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

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int dp[maxn],deg[maxn];
vector<int> G[maxn];

int get(int u)
{
	if(dp[u]) return dp[u];
	for(auto it:G[u])
	dp[u]=max(dp[u],get(it)+1);
	return dp[u];
}

int main()
{
	int n,m,x,y;
	cin>>n>>m;
	
	while(m--) 
	{
		 cin>>x>>y;
		 deg[y]++;
		 G[x].push_back(y);
	}
	
	int ans=0;
	for(int i=1;i<=n;i++)
	if(deg[i]==0) ans=max(ans,get(i));
	
	
	return 0;
 } 

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

#include<stdio.h>
int mem[10001][10001];
int d[10001];
int n;

int max(int i,int j)
{
    return i>j?i:j;
}
int f(int i)
{
    if(d[i]!=0)
        return d[i];
    int q=0,a=0;
    for(int j=1;j<n+1;j++)
    {
        if(mem[i][j]==1)
        {
            q=1;
            a=max(a,f(j)+1);
        }
    }
    if(q==1)
            {
                d[i]=a;
                return a;
            }
            else
                return 0;


}
int main()
{
    int i,x=0,m,g,h;
    warn_unused_result scanf("%d %d",&n,&m);
    for(i=1;i<n+1;i++)
    {
        for(int j=1;j<n+1;j++)
            mem[i][j]=0;
    }
    for(i=0;i<n+1;i++)
        d[i]=0;
    for(int j=0;j<m;j++)
    {
       warn_unused_result scanf("%d %d",&g,&h);
        mem[g][h]=1;
    }
    for(i=1;i<n+1;i++)
        {
            d[i]=f(i);
            x=x>d[i]?x:d[i];
        }
        printf("%d",x);
        return 0;

}


Compiler output:
main.c: In function 'main':
main.c:36:5: error: unknown type name 'warn_unused_result'
   36 |     warn_unused_result scanf("%d %d",&n,&m);
      |     ^~~~~~~~~~~~~~~~~~
main.c:36:30: error: expected declaration specifiers or '...' before string constant
   36 |     warn_unused_result scanf("%d %d",&n,&m);
      |                              ^~~~~~~
main.c:36:38: error: expected declaration specifiers or '...' before '&' token
   36 |     warn_unused_result scanf("%d %d",&n,&m);
      |                                      ^
main.c:36:41: error: expected declaration specifiers or '...' before '&' token
   36 |     warn_unused_result scanf("%d %d",&n,&m);
      |                                         ^
main.c:46:8: error: unknown type name 'warn_unused_result'
   46 |        warn_unused_result scanf("%d %d",&g,&h);
      |        ^~~~~~~~~~~~~~~~~~
main.c:46:33: error: expected declaration specifiers or '...' before string constant
   46 |        warn_unused_result scanf("%d %d",&g,&h);
      |                                 ^~~~~~~
main.c:46:41: error: expected declaration specifiers or '...' before '&' token
   46 |        warn_unused_result scanf("%d %d",&g,&h);
      |                                         ^
main.c:46:44: error: expected declaration specifiers or '...' before '&' token
   46 |        warn_unused_result scanf("%d %d",&g,&h);
      |                                            ^
Language: C++

#include<bits/stdc++.h>

using namespace std;

long recurse(int i, int &n , vector<vector<long>> &mat , vector<long> &dp)
{

    if(dp[i] != -1) return dp[i];
    else
    {
        long flag = 0;
        long max1 = 0;
        for (long k = 1; k <= n; k++)
        {
            if(mat[k][i] == 1)
            {
                flag = 1;
                max1 = max(recurse(k,n,mat,dp)+1,max1);
            }
        }
        if(flag == 0) return dp[i] = 0;
        else return dp[i] = max1;
    }
}

int main(int argc, char const *argv[])
{
    long n , m;
    cin >>n >> m;
    long t1 ,t2;
    vector<vector<long>> mat(n+1,vector<long>(n+1,0));
    vector<long> dp(n+1,-1); //denotes the max length to this vertex
    for (long i = 0; i < m; i++)
    {
        cin >> t1 >> t2;
        mat[t1][t2] = 1;
    }

    for (long i = 1; i <= n; i++)
    {
        dp[i] = recurse(i,n,mat,dp);
    }
    long ans = 0;
    for (long i = 0; i <= n; i++)
    {
        ans = max(ans,dp[i]);
    }
    cout << ans;
    
    return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:41:27: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'long int'
   41 |         dp[i] = recurse(i,n,mat,dp);
      |                           ^
a.cc:5:26: note:   initializing argument 2 of 'long int recurse(int, int&, std::vector<std::vector<long int> >&, std::vector<long int>&)'
    5 | long recurse(int i, int &n , vector<vector<long>> &mat , vector<long> &dp)
      |                     ~~~~~^
Language: Java


import java.util.*;

public class Pg
{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
	String[] temp = in.nextLine().split(" ");
	int N = Integer.parseInt(temp[0]);
	int M = Integer.parseInt(temp[1]);
	ArrayList<Integer>[] graph = new ArrayList[N+1];
	for (int i = 0; i <= N; i++) graph[i] = new ArrayList<>();
	for (int i = 0; i < M; i++) {
	    temp = in.nextLine().split(" ");
	    int from = Integer.parseInt(temp[0]);
	    int to = Integer.parseInt(temp[1]);
	    graph[to].add(from);
	}
	in.close();
	int[] mem = new int[N+1];
	Arrays.fill(mem, -1);
	int res = 0;
	for (int i = 1; i <= N; i++) {
	    res = Math.max(res, longest(i, mem, graph));
	}
	System.out.println(res);
	
    }

    public static int longest(int i, int[] mem, ArrayList<Integer>[] graph) {
	if (mem[i] == -1) {
	    int res = 0;
	    for (int j : graph[i]) {
		res = Math.max(res, longest(j, mem, graph)+1);
	    }
	    mem[i] = res;
	}
	return mem[i];
    }
}


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

#include <bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")
 
#define int long long 
#define pb push_back
#define all(s) s.begin(),s.end()
#define pii pair<int,int>
#define fr first
#define sc second
#define bst ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define no cout << "NO" << endl;
#define yes cout << "YES" << endl;

using namespace std;

const int N = 5e5 + 10, mod = 1e9 + 7, inf = 1e18 + 7, logn = 23;
const double pi = acos(-1);

int dp[N];
vector<int> gr[N];

void dfs(int v) {
	vis[v] = 1;
	for(auto to: gr[v]) {
		if(!vis[to]) {
			dfs(to);
		}
		if(dp[v] < dp[to] + 1) {
			dp[v] = dp[to] + 1;
		}
	}
}

void solve() {
	//soln
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int l, r;
		cin >> l >> r;
		gr[l].pb(r);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		if(!vis[i]) {
			dfs(i);
		}
		ans = max({ans, dp[i]});		
	}
	cout << ans << endl;
}
main() {
	bst;
	int t = 1;
	//cin >> t;
	while(t--) {
		solve();
	}
}


Compiler output:
a.cc: In function 'void dfs(long long int)':
a.cc:26:9: error: 'vis' was not declared in this scope
   26 |         vis[v] = 1;
      |         ^~~
a.cc: In function 'void solve()':
a.cc:48:21: error: 'vis' was not declared in this scope
   48 |                 if(!vis[i]) {
      |                     ^~~
a.cc: At global scope:
a.cc:55:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   55 | main() {
      | ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
using Graph = vector<vector<int>>;
int n, m;
Graph G;

int dp[1001000];

int dfs(int x) {
  if (dp[x] != 0) return dp[x];
  int mx = 0;
  for (int i = 0; i < G[x].size(); i++) {
    mx = max(mx, dfs(G[x][i]) + 1);
  }
  dp[x] = mx;
  return mx;
}

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

  G.resize(n);

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

  cout << max_element(begin(dp), end(dp), 0) << endl;
}

Compiler output:
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = int*; _Iterator2 = int*; _Compare = int]':
/usr/include/c++/14/bits/stl_algo.h:5626:12:   required from here
 5626 |         if (__comp(__result, __first))
      |             ~~~~~~^~~~~~~~~~~~~~~~~~~
a.cc:35:22:   in 'constexpr' expansion of 'std::max_element<int*, int>(std::begin<int, 1001000>(dp), std::end<int, 1001000>(dp), 0)'
/usr/include/c++/14/bits/stl_algo.h:5677:43:   in 'constexpr' expansion of 'std::__max_element<int*, __gnu_cxx::__ops::_Iter_comp_iter<int> >(__first, __last, __gnu_cxx::__ops::__iter_comp_iter<int>(__comp))'
/usr/include/c++/14/bits/predefined_ops.h:158:30: error: expression cannot be used as a function
  158 |         { return bool(_M_comp(*__it1, *__it2)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~~~
Language: C++

/*       _________
        /|______/ \
        ||  _|_|\  |
        || |_|   | /
        ||    _ / |
        ||  _| \\  \    
        ||_|_|\ || |
        |/_|/ | /|_/
              /__/      Written by: Rishabh Roshan
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int            	long long
#define tree         	ped
#define integer        	int32_t
#define mod         	1000000007
#define vint        	vector<integer>
#define pint        	pair<integer, integer>
#define umint        	unordered_map<integer, integer>
#define mint        	map<integer, integer>
#define in(x)        	int x; cin>>x
#define setbits(x)    	__builtin_popcountll(x)
#define zerobits(x)    	__builtin_ctzll(x)
#define w(x)        	int x; cin>>x; while(x--)
#define sp(x, y)    	fixed<<setprecision(y)<<x
#define poll(x)        	x.front(); x.pop()
#define f(x)        	for(int i=0; i<x; i++)
#define endl         	'\n'
#define inf         	1e9 
#define order_set     	tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

#include "functions.h"

void om_shree_ganeshaya_namah(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

vector<bool> visit;
vint dp;
unordered_map<int, vint> dict;

int dfs(int x){
	if(!dict[x].size())
		return 0;

	if(dp[x])
		return dp[x];

	int max=0;
	vint v = dict[x];
	for(auto i:v){
		int a = dfs(i);
		if(a>max)
			max = a;
	}
	dp[x] = max+1;
	return dp[x];
}

int32_t main(){
    
    om_shree_ganeshaya_namah();

    in(n);
    w(m){
    	in(x); in(y);
    	dict[x].push_back(y);
    }
    dp = vint(n+1);
    visit = vector<bool>(n+1, false);

    for(auto it:dict){

/*    	cout<<it.first<<" -> ";
    	for(auto i:it.second)
    		cout<<i<<" ";
    	cout<<endl;
*/
    	if(!visit[it.first]){
    		visit[it.first] = true;
    		int max=0;
    		for(auto i:it.second){
    			int a = dfs(i);
    			visit[i] = true;
    			if(a>max)
    				max = a;
    		}
    		dp[it.first] = max+1;
    	}
    }

//    f(n) cout<<visit[i+1]<<" ";
  //  cout<<endl;
    // print(dp);
    int ans = *max_element(dp.begin(), dp.end());
    cout<<ans;

}

Compiler output:
a.cc:37:10: fatal error: functions.h: No such file or directory
   37 | #include "functions.h"
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

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

vector<int> adj[1e5 + 1];
vector<int> in(1e5 + 1, 1), d(1e5 + 1, 0);

void dfs(int nd) {
	for (int nb : adj[nd]) {
		d[nb] = max(d[nb], d[nd] + 1);
		if (--in[nb] == 0) dfs(nb);
	}
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n, m;
	cin >> n >> m;
	vector<int> foo(n);
	iota(foo.begin(), foo.end(), 1);
	adj[0] = foo, in[0] = 0;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		adj[a].push_back(b);
		in[b]++;
	}
	
	dfs(0);
	
	int ans{};
	for (int i : d) ans = max(ans, i);
	cout << ans - 1;
}

Compiler output:
a.cc:4:21: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    4 | vector<int> adj[1e5 + 1];
      |                 ~~~~^~~
a.cc:4:21: error: could not convert '(1.0e+5 + (double)1)' from 'double' to 'long unsigned int'
    4 | vector<int> adj[1e5 + 1];
      |                 ~~~~^~~
      |                     |
      |                     double
a.cc:4:21: error: size of array 'adj' has non-integral type 'double'
Language: Java

import java.util.*;
class Main{
  static Map<Integer,List<Integer>> graph=new HashMap<>();
  static Map<Integer,Integer> dist=new HashMap<>();
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int e=sc.nextInt();
    for(int i=0;i<e;i++){
      populate(sc.nextInt(),sc.nextInt());
    }
    Set<Integer> visited=new HashSet<>();
    int ans=0;
    for(int i:graph.keySet()){
      if(!visited[i]) ans=Math.max(ans,dfs(i,visited));
    }
    System.out.println(ans);
  }
  public static int dfs(int src,Set<Integer> visited){
        if(dist.containsKey(src)) return dist.get(src);
        visited.add(src);
        int current=0;
        for(int nei:graph.getOrDefault(src,new ArrayList<>())){
            if(!visited.contains(nei)) current=Math.max(current,dfs(nei,visited));
        }
    	dist.put(src,1+current);
        return 1+current;
    }
    public static void populate(int i,int j){
            graph.putIfAbsent(i,new ArrayList<>());
            graph.get(i).add(j); 
    }
}

Compiler output:
Main.java:15: error: array required, but Set<Integer> found
      if(!visited[i]) ans=Math.max(ans,dfs(i,visited));
                 ^
1 error
Language: Java

import java.util.*;
class Main{
  static Map<Integer,List<Integer>> graph=new HashMap<>();
  static Integer[]cache;
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int m=sc.nextInt();
    for(int i=0;i<e;i++){
      populate(sc.nextInt(),sc.nextInt());
    }
    cache=new Integer[n+1];
    boolean[] visited=new boolean[n+1];
    int ans=0;
    for(int i=1;i<=n;i++){
      if(!visited[i]) ans=Math.max(ans,dfs(i,visited));
    }
    System.out.println(ans);
  }
  public static int dfs(int src,boolean[] visited){
        if(cache[src]!=null) return cache[src];
        visited[src]=true;
        int current=0;
        for(int nei:graph.getOrDefault(src,new ArrayList<>())){
            if(!visited[nei]) current=Math.max(current,dfs(nei,visited));
        }
        return cache[src]=1+current;
    }
    public static void populate(int i,int j){
            graph.putIfAbsent(i,new ArrayList<>());
            graph.get(i).add(j); 
    }
}

Compiler output:
Main.java:9: error: cannot find symbol
    for(int i=0;i<e;i++){
                  ^
  symbol:   variable e
  location: class Main
1 error
Language: C++

// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;
const int maxn = 1E5 + 5;

vector<int> adj[maxn], ans(maxn), degI(maxn), vis(maxn);

void dfs(int now) {
    for (auto x : adj[now]) {
        ans[x] = max(ans[x], ans[now] + 1);
        if (++vis[x] == degI[x]) dfs(x);
    }
}

int32_t main() {
    fastIO();
    
    int n, m, u, v;
    cin >> n >> m;
    
    while (m--) cin >> u >> v, ++degI(v), adj[u].eb(v);
    
    for (int i = 1; i <= n; ++i) {
        if (!degI[i]) dfs(i);
    }
    
    int maxL = 0;
    for (int i = 1; i <= n; ++i) maxL = max(maxL, ans[i]);
    
    cout << maxL << "\n";
    
    return 0;
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:51:38: error: no match for call to '(std::vector<long long int>) (long long int&)'
   51 |     while (m--) cin >> u >> v, ++degI(v), adj[u].eb(v);
      |                                  ~~~~^~~
Language: C++

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define rall(c) c.rbegin(), c.rend()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
#define init(a, x) memset(a,x,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)
const int L=1e6+7;
std::vector<int> v[L];
int visit[L], dp[L];
int dfs(int vertex)
{
	if(visit[vertex])return dp[vertex];
	visit[vertex] = 1;
	trace(v[vertex], x)
	{
		dp[vertex] = max(dp[vertex], 1 + dfs(x));
	}
	return dp[vertex];
}
void fff()
{
	int n, m, x, y;
	cin >> n >> m;
	FOR(i,0,m)
	{
		cin >> x >> y;
		v[x].pb(y);
	}
	int ans = 0;
	FOR(i,1,n+1)
	{
		ans = max(ans, dfs(i));
	}
	cout<<ans<<ln;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//int t;cin >> t;while(t--)
	fff();
	return 0;
}

Compiler output:
a.cc: In function 'int dfs(int)':
a.cc:48:12: error: reference to 'visit' is ambiguous
   48 |         if(visit[vertex])return dp[vertex];
      |            ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:45:5: note:                 'int visit [1000007]'
   45 | int visit[L], dp[L];
      |     ^~~~~
a.cc:49:9: error: reference to 'visit' is ambiguous
   49 |         visit[vertex] = 1;
      |         ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:45:5: note:                 'int visit [1000007]'
   45 | int visit[L], dp[L];
      |     ^~~~~
Language: C++

#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dp[101010];
ll n, m;
vector<vector<ll>>to;

ll rec(ll v) {
	if (dp[v] != -1)return dp[v];
	else {
		ll res = 0;
		for (auto nv : to[v]) {
			res = max(res, rec(nv) + 1);
		}
		return dp[v] = res;
	}
}

//long longしか使わない
//素数は1より大きい
int main() {
	cin >> n >> m;
	rep(i, m) {
		ll x, y;
		cin >> x >> y;
		x--;
		y--;
		to[x].push_back(y);
	}
	for (i, n) {
		dp[i] = -1;
	}
	ll ans = 0;
	rep(i, n) {
		ans = max(ans, rec(i));
	}
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:71:14: error: 'i' was not declared in this scope; did you mean 'pi'?
   71 |         for (i, n) {
      |              ^
      |              pi
a.cc:28:17: error: expected primary-expression before 'for'
   28 | #define rep(i,n)for(ll i=0;i<n;++i)
      |                 ^~~
a.cc:75:9: note: in expansion of macro 'rep'
   75 |         rep(i, n) {
      |         ^~~
a.cc:74:20: error: expected ')' before 'for'
   74 |         ll ans = 0;
      |                    ^
      |                    )
a.cc:71:13: note: to match this '('
   71 |         for (i, n) {
      |             ^
a.cc:78:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   78 |         cout << ans << endl;
      |                 ^~~
      |                 abs
Language: C++

#include <iostream>
#include <unordered_map>
#include <list>
using namespace std;

int longest_path(unordered_map<int, list<int>> graph, int i, unordered_map<int, int> &dp) {
    if (dp.find(i) != dp.end()) {
        return dp[i];
    }
    if (graph[i].empty()) {
        return 0;
    }
    int length = INT_MIN;
    for (int child : graph[i]) {
        length = max(length, 1 + longest_path(graph, child, dp));
    }
    return dp[i] = length;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    unordered_map<int, list<int>> graph;
    int n, m, x, y;
    cin >> n >> m;
    int path = 0;
    while (m--) {
        cin >> x >> y;
        graph[x].push_back(y);
    }
    unordered_map<int, int> dp;
    for (int i = 1; i <= n; ++i) {
        path = max(path, longest_path(graph, i, dp));
    }
    cout << path << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int longest_path(std::unordered_map<int, std::__cxx11::list<int> >, int, std::unordered_map<int, int>&)':
a.cc:13:18: error: 'INT_MIN' was not declared in this scope
   13 |     int length = INT_MIN;
      |                  ^~~~~~~
a.cc:4:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <list>
  +++ |+#include <climits>
    4 | using namespace std;
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define N 100100


vector<int>ad[N];
int ans=0;
int a[N];
bool vis[N];

dfs(int sr)
{
    int sum=0;
    vis[sr]=true;
    for(auto s : ad[sr])
    {
        if(vis[s]==false)dfs(s);
        sum=max(sum,a[s]);
    }
    a[sr]=1+sum;
}


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i = 0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        ad[x].pb(y);
    }
    int u=0;
    for(int i = 1;i<=n;i++)if(!vis[i])dfs(i);
    for(int i = 1;i<=n;i++)u=max(u,a[i]);
    cout<<u-1<<endl;
}


Compiler output:
a.cc:12:1: error: ISO C++ forbids declaration of 'dfs' with no type [-fpermissive]
   12 | dfs(int sr)
      | ^~~
a.cc: In function 'int dfs(int)':
a.cc:22:1: warning: no return statement in function returning non-void [-Wreturn-type]
   22 | }
      | ^
Language: C++

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

vector<int> v[100005];
int vis[100005];
int ans[100005];

void dfs(int node)
{
	if(!ans[node])
	{
		for(int i: v[node])
		{
			ans[node] = max(ans[node] , dfs(i))
			ans[node]++;			
		}
	}
	return ans[node];
}
int main()
{
	int n , m;
	
	cin >> n >> m;
	
	for(int i = 1 ; i<=m ; i++)
	{
		int x , y;
		cin >> x >> y;
		v[x].push_back(y);
	}
	
	int fans = 1;
	
	for(int i = 1 ; i<=n ; i++)
	{
		fans = max(fans , dfs(i));
	}
	
	cout << fans-1;
	
	return 0;
}

Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:14:56: error: invalid use of void expression
   14 |                         ans[node] = max(ans[node] , dfs(i))
      |                                                     ~~~^~~
a.cc:18:24: error: return-statement with a value, in function returning 'void' [-fpermissive]
   18 |         return ans[node];
      |                ~~~~~~~~^
a.cc: In function 'int main()':
a.cc:37:38: error: invalid use of void expression
   37 |                 fans = max(fans , dfs(i));
      |                                   ~~~^~~
Language: C++

#include <bits/stdc++.h>
#define ll long long
using namespace std;
void sho(vector<ll>adj[],ll src,vector<ll>&vis,vector<ll>&dist){
	dist[src]=0;
	queue<ll>q;
	q.push(src);
	int ans=INT_MAX;
	while(!q.empty()){
		ll u=q.front();
		q.pop();
		vis[u]=true;
		for(auto x: adj[u])
		{
			if(dist[x]>dist[u]-1)
			{
				dist[x]=dist[u]-1;
				q.push(x);
				
			}
		}
	}
	
}
int main() {
	ll n,e;
	cin>>n>>e;
	vector<int>adj[n+1];
	for(ll i=0;i<e;i++)
	{
		ll a,b;
		cin>>a>>b;
		adj[a].push_back(b);
	}
	vector<ll>vis(n+1,0);
	vector<ll>dist(n+1,INT_MAX);
	int val=INT_MIN;
	
	for(ll i=1;i<=n;i++)
	{
	  if(!vis[i] && adj[i].size()){
	  	sho(adj,i,vis,dist);
	  
	  }	
	}
	ll ans=INT_MAX;
	for(ll i=1;i<=n;i++)
	ans=min(ans,dist[i]);
	cout<<abs(ans);
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:21: error: cannot convert 'std::vector<int>*' to 'std::vector<long long int>*'
   42 |                 sho(adj,i,vis,dist);
      |                     ^~~
      |                     |
      |                     std::vector<int>*
a.cc:4:20: note:   initializing argument 1 of 'void sho(std::vector<long long int>*, long long int, std::vector<long long int>&, std::vector<long long int>&)'
    4 | void sho(vector<ll>adj[],ll src,vector<ll>&vis,vector<ll>&dist){
      |          ~~~~~~~~~~^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef pair<int,int> PII;
const int mx = 1e5+5;
vector<int>edge[mx];
bool visit[mx];
int dis[mx],node,ed;
void dfs(int u)
{
    visit[u] = true;
    for(auto it:edge[u])
    {
        if(!visit[it])
            dfs(it);
        dis[u] = max(dis[u],1+dis[it]);
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>node>>ed;
    for(int i=1;i<=ed;i++)
    {
        int u,v;
        cin>>u>>v;
        edge[u].push_back(v);
    }
    for(int i=1;i<=node;i++)
        dis[i] = 0;

    for(int i=1;i<=node;i++)
        if(!visit[i])
        dfs(i);
    int ans = 0;
    for(int i=1;i<=node;i++)
        ans = max(ans,dis[i]);
    cout<<ans<<endl;
    return 0;
}


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

#include <stdio.h>
#define MAX_N 100000
typedef struct e{
  int a[MAX_N+1];
  int point;
  int point2;
}el;
int max(int a,int b){
  if(a>b)return a;
  else return b;
}
int s[MAX_N+1];
el edge[MAX_N+1];
int dp[MAX_N];
int main(){
  int n,m;
  int x,y;
  int i,j;
  int idx = 0;

  scanf("%d %d", &n,&m);
  for(int i=0; i<m;i++){
    scanf("%d %d", &x, &y);
    edge[x-1].a[edge[x-1].point] = y-1;
    edge[x-1].point+=1;
    edge[y-1].point2 += 1;
  }


  for(int i=0; i<n; i++){
    if(edge[i].point2==0)s[idx++]=i;
  }
  j = 0;
  while(j<idx){
    for(int k=0; k<edge[s[j]].point; k++){
      edge[edge[s[j]].a[k]].point2 -= 1;
      if(edge[edge[s[j]].a[k]].point2==0){
        s[idx++] = edge[s[j]].a[k];
      }
    }
    j+=1;
  }
  int ans = 0;
  for(i=n-1;i>-1;i--){
    //printf("%d: ", s[i]);
    for(j=0;j<edge[s[i]].point;j++){
      //printf("%d ", edge[s[i]].a[j]);
      dp[s[i]] = max(dp[s[i]], dp[edge[s[i]].a[j]]+1);
    }
    ans = max(ans, dp[s[i]]);
  }

  printf("%d\n", ans);

  return 0;
}


Compiler output:
/tmp/ccQ2l6l5.o: in function `main':
main.c:(.text+0x399): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccQ2l6l5.o
main.c:(.text+0x3c7): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccQ2l6l5.o
main.c:(.text+0x3fd): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccQ2l6l5.o
main.c:(.text+0x45f): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccQ2l6l5.o
collect2: error: ld returned 1 exit status
Language: C

#include <stdio.h>
#define MAX_N 100000
typedef struct e{
  int a[MAX_N+1];
  int point;
  int b[MAX_N+1];
  int point2;
}el;
int max(int a,int b){
  if(a>b)return a;
  else return b;
}
int s[MAX_N+1];
int v[MAX_N+1];
el edge[MAX_N+1];
int l[MAX_N+1];
int dp[MAX_N];
int main(){
  int n,m;
  int x,y;
  int idx = 0;

  scanf("%d %d", &n,&m);
  for(int i=0; i<m;i++){
    scanf("%d %d", &x, &y);
    edge[x-1].a[edge[x-1].point] = y-1;
    edge[x-1].point+=1;
    edge[y-1].b[edge[y-1].point2] = x-1;
    edge[y-1].point2 += 1;
  }


  for(int i=0; i<n; i++){
    if(edge[i].point2==0)s[idx++]=i;
  }

  int j=0;
  int i=0;
  while(j<idx){
    l[i] = s[j++];
    for(int k=0; k<edge[l[i]].point; k++){
      edge[edge[l[i]].a[k]].point2 -= 1;
      if(edge[edge[l[i]].a[k]].point2==0){
        s[idx++] = edge[l[i]].a[k];
      }
    }
    i+=1;
  }
  int ans = 0;
  for(i=n-1;i>-1;i--){
    //printf("%d: ", s[i]);
    for(j=0;j<edge[s[i]].point;j++){
      //printf("%d ", edge[s[i]].a[j]);
      dp[s[i]] = max(dp[s[i]], dp[edge[s[i]].a[j]]+1);
    }
    ans = max(ans, dp[s[i]]);
  }

  printf("%d\n", ans);

  return 0;
}


Compiler output:
/tmp/ccgTexJH.o: in function `main':
main.c:(.text+0x214): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/ccgTexJH.o
main.c:(.text+0x237): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/ccgTexJH.o
main.c:(.text+0x285): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/ccgTexJH.o
main.c:(.text+0x2d6): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/ccgTexJH.o
main.c:(.text+0x328): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/ccgTexJH.o
main.c:(.text+0x385): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/ccgTexJH.o
main.c:(.text+0x421): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccgTexJH.o
main.c:(.text+0x44f): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccgTexJH.o
main.c:(.text+0x485): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccgTexJH.o
main.c:(.text+0x4e7): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccgTexJH.o
collect2: error: ld returned 1 exit status
Language: C

#include <stdio.h>
#define MAX_N 100000
typedef struct e{
  int a[MAX_N+1];
  int point;
  int b[MAX_N+1];
  int point2;
}el;
int max(int a,int b){
  if(a>b)return a;
  else return b;
}
int s[MAX_N+1];
int v[MAX_N+1];
el edge[MAX_N+1];
int l[MAX_N+1];
int dp[MAX_N];
int main(){
  int n,m;
  int x,y;
  int idx = 0;

  scanf("%d %d", &n,&m);
  for(int i=0; i<m;i++){
    scanf("%d %d", &x, &y);
    edge[x-1].a[edge[x-1].point] = y-1;
    edge[x-1].point+=1;
    edge[y-1].b[edge[y-1].point2] = x-1;
    edge[y-1].point2 += 1;
  }


  for(int i=0; i<n; i++){
    if(edge[i].point2==0)s[idx++]=i;
  }

  int j=0;
  int i=0;
  while(j<idx){
    l[i] = s[j++];
    for(int k=0; k<edge[l[i]].point; k++){
      edge[edge[l[i]].a[k]].point2 -= 1;
      if(edge[edge[l[i]].a[k]].point2==0){
        s[idx++] = edge[l[i]].a[k];
      }
    }
    i+=1;
  }
  int ans = 0;
  for(i=n-1;i>-1;i--){
    //printf("%d: ", s[i]);
    for(j=0;j<edge[s[i]].point;j++){
      //printf("%d ", edge[s[i]].a[j]);
      dp[s[i]] = max(dp[s[i]], dp[edge[s[i]].a[j]]+1);
    }
    ans = max(ans, dp[s[i]]);
  }

  printf("%d\n", ans);

  return 0;
}


Compiler output:
/tmp/ccc87h5z.o: in function `main':
main.c:(.text+0x214): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/ccc87h5z.o
main.c:(.text+0x237): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/ccc87h5z.o
main.c:(.text+0x285): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/ccc87h5z.o
main.c:(.text+0x2d6): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/ccc87h5z.o
main.c:(.text+0x328): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/ccc87h5z.o
main.c:(.text+0x385): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/ccc87h5z.o
main.c:(.text+0x421): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccc87h5z.o
main.c:(.text+0x44f): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccc87h5z.o
main.c:(.text+0x485): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccc87h5z.o
main.c:(.text+0x4e7): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccc87h5z.o
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
#pragma GCC optimize ("-O3")
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define int long long
#define double long double
#define pb push_back
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define diff(a,b) (a>b?a-b:b-a)
#define F first
#define S second
const int N=1e6+5;
int mod = 1e9+7;
void pairsort(int a[], int b[], int n){
    pair<int, int> pairt[n];
    for (int i = 0; i < n; i++) 
    {
        pairt[i].first = a[i];
        pairt[i].second = b[i];
    }
    sort(pairt, pairt + n);
    for (int i = 0; i < n; i++) 
    {
        a[i] = pairt[i].first;
        b[i] = pairt[i].second;
    }
}
ll pow1(ll n,ll p)
{
    if(p==0)    return 1;
    ll x=pow1(n, p/2);
    x=(x*x)%mod;
    if(p%2==0)
        return x;
    else
        return (x*n)%mod;
}
ll binarySearch(ll arr[], ll l, ll r,ll x) 
{ 
    if (r >= l) 
    { 
        ll mid = l + (r - l) / 2;  
        if (arr[mid] == x) 
        return mid; 
        if (arr[mid] > x) 
        return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    }
    return -1; 
}
bool compare(const pair<ll, ll>&p1, const pair<ll,ll>&p2)
{
    if(p1.F < p2.F) return true;
        if(p1.F == p2.F) return p1.S < p2.S;
        return false;
}
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b); 
}
int isPrime(int n){
    if(n < 2)
        return 0;
    if(n < 4)
        return 1;
    if(n % 2 == 0 or n % 3 == 0)
        return 0;
    for(int i = 5; i*i <= n; i += 6)
        if(n % i == 0 or n % (i+2) == 0)
            return 0;
    return 1;
}
long long C(int n, int r) {
    if(r>n-r) 
        r=n-r;
    long long ans=1;
    for(int i=1;i<=r;i++){
        ans*=n-r+i;
        ans/=i;
    }
    return ans;
}
int modexpo(int x,int p){
    int res = 1;
    x = x%mod;
    while(p){
        if(p%2)
            res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}
int n,m;
vector<vector<int>>adj;
vector<int>vis;
vector<int>dp;
int longest_path(int v){

	for(auto x:adj[v]){
		if(!vis[x]){
			dp[v] = max(ans, 1+longest_path(x));
		}
	}
	return dp[v];
}

int32_t main()
{
    IOS;
    cin>>n>>m;
    dp.clear();
    dp.resize(n+1);
    adj.clear();
    adj.resize(n+1);
    vis.clear();
    vis.resize(n+1);
    while(m--){
    	int x,y;
    	cin>>x>>y;
    	adj[x].pb(y);
    }
    int ans = 0 ;
    for(int i=1;i<=n;i++){
    	if(!vis[i]){
    		ans = max(ans, longest_path(i));
    	}
    }
    cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'long long int longest_path(long long int)':
a.cc:112:37: error: 'ans' was not declared in this scope; did you mean 'abs'?
  112 |                         dp[v] = max(ans, 1+longest_path(x));
      |                                     ^~~
a.cc:10:19: note: in definition of macro 'max'
   10 | #define max(a,b) (a>b?a:b)
      |                   ^