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

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int, int>
#define vi vector<int>
#define pb emplace_back
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define x first
#define y second
#define rep(i, j, k) for(i=j; i<k; i++)
#define sep(i, j, k) for(i=j; i>k; i--)
const int N = 2e5+5, inf = 1e9+7;
int n, k, i, j;
int A[N];

int dfs(int id){
    if(dp[id]!=-1) return dp[id];
    dp[id]=0;
    for(auto i:adj[id]) dp[id] = max(dp[id], 1+dfs(i));
    return dp[id];
}

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int i, j, a, b, ans = 0;
    cin>>n>>k;
    rep(i, 0, k){
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    memset(dp, -1, sizeof dp);
    rep(i, 1, n+1) if(dp[i]==-1) dfs(i);
    cout<<*max_element(dp, dp+n+1);
}

Compiler output:
a.cc: In function 'long long int dfs(long long int)':
a.cc:18:8: error: 'dp' was not declared in this scope; did you mean 'dup'?
   18 |     if(dp[id]!=-1) return dp[id];
      |        ^~
      |        dup
a.cc:19:5: error: 'dp' was not declared in this scope; did you mean 'dup'?
   19 |     dp[id]=0;
      |     ^~
      |     dup
a.cc:20:16: error: 'adj' was not declared in this scope
   20 |     for(auto i:adj[id]) dp[id] = max(dp[id], 1+dfs(i));
      |                ^~~
a.cc: In function 'int main()':
a.cc:31:9: error: 'adj' was not declared in this scope
   31 |         adj[a].pb(b);
      |         ^~~
a.cc:34:12: error: 'dp' was not declared in this scope; did you mean 'dup'?
   34 |     memset(dp, -1, sizeof dp);
      |            ^~
      |            dup
Language: Java

import java.util.*;

public class DPG {
    static int n, m;
    static List<Integer>[] graph;
    static int[] distance;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        graph = new ArrayList[n+1];
        distance = new int[n+1];
        Arrays.setAll(graph, i -> new ArrayList<>());
        Arrays.fill(distance, -1);
        for (int i=0; i<m; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            graph[a].add(b);
        }
        for (int i=1; i<=n; i++) {
            if (distance[i] == -1) {
                dfs(i, 0);
            }
        }
        int maxDist = 0;
        for (int i : distance) maxDist = Math.max(maxDist, i);
        System.out.println(maxDist);
    }
    static void dfs(int u, int dist) {
        distance[u] = Math.max(distance[u], dist);
        for (int v : graph[u]) {
            if (distance[v] < 1 + dist) {
                dfs(v, dist+1);
            }
        }
    }
}

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

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    static class Node{
        List<Node> next=new ArrayList<>();
    }

    public static void main(String[] args) {
        Scanner sc  = new Scanner(System.in);
        int N = sc.nextInt();// vertex
        int M = sc.nextInt(); // edges
        Node[] nodes = new Node[N];
        for (int i = 0; i < M ; i++) {
            int x  = sc.nextInt();
            int y  = sc.nextInt();
            if(nodes[x-1]==null){
                nodes[x-1]= new Node();
            }
            if(nodes[y-1]==null){
                nodes[y-1]= new Node();
            }
            Node node = nodes[x-1];
            node.next.add(nodes[y-1]);
        }


        int max =0;
        for (int i = 0; i < N  ; i++) {
//            System.out.println(nodes[i]);
            if(nodes[i] != null ){
                int res = longest(nodes[i],0);
//                System.out.println("i="+i+"  path="+res);
                if(res>max) max = res;
            }
        }

        System.out.println(max);
    }
	static Map<Node,Integer> map = new HashMap<>();
    static int longest(Node root ,int  path){
          
        List<Node> list = root.next;
        if(list.size()==0) return path;
        if(map.containsKey(root)){
          return map.get(root);
        }

        int max =0;
        for(Node node: list){
            int pth = longest( node , path +1);
            if(pth>max) max = pth;
        }
        map.put(root,max);
        return max;
    }
}


Compiler output:
Main.java:42: error: cannot find symbol
	static Map<Node,Integer> map = new HashMap<>();
	       ^
  symbol:   class Map
  location: class Main
Main.java:42: error: cannot find symbol
	static Map<Node,Integer> map = new HashMap<>();
	                                   ^
  symbol:   class HashMap
  location: class Main
2 errors
Language: Java

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class AtCoder {

    static class Node{
        List<Node> next=new ArrayList<>();
    }

    public static void main(String[] args) {
        Scanner sc  = new Scanner(System.in);
        int N = sc.nextInt();// vertex
        int M = sc.nextInt(); // edges
        Node[] nodes = new Node[N];
        for (int i = 0; i < M ; i++) {
            int x  = sc.nextInt();
            int y  = sc.nextInt();
            if(nodes[x-1]==null){
                nodes[x-1]= new Node();
            }
            if(nodes[y-1]==null){
                nodes[y-1]= new Node();
            }
            Node node = nodes[x-1];
            node.next.add(nodes[y-1]);
        }


        int max =0;
        for (int i = 0; i < N  ; i++) {
//            System.out.println(nodes[i]);
            if(nodes[i] != null ){
                int res = longest(nodes[i],0);
//                System.out.println("i="+i+"  path="+res);
                if(res>max) max = res;
            }
        }

        System.out.println(max);
    }

    static int longest(Node root ,int  path){

        List<Node> list = root.next;
        if(list.size()==0) return path;
        int max =0;
        for(Node node: list){
            int pth = longest( node , path +1);
            if(pth>max) max = pth;
        }
        return max;
    }
}

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

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <string>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;
int n, m;
int maxN = 1e3 + 5;
int MOD = 1e9 + 7;
int dp[maxN][maxN];

void add_self(int & a, int b) {
    a += b;
    if (a >= MOD)
        a -= MOD;
}

int main(int argc, char *argv[]) {
    cin >> n >> m;
    vector<string> g(n, string(m, '.'));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> g[i][j];
        }
    }
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            for (int ni: {i, i + 1}) {
                int nj = j;
                if (k == i)
                    nj++;
                if (ni < n && nj < m && g[ni][nj] == '.') {
                    add_self(dp[ni][nj], dp[i][j]);
                }
            }
        }
    }
    cout << dp[n-1][m-1] << endl;
    return 0;
}

Compiler output:
a.cc:18:14: error: size of array 'dp' is not an integral constant-expression
   18 | int dp[maxN][maxN];
      |              ^~~~
a.cc:18:8: error: size of array 'dp' is not an integral constant-expression
   18 | int dp[maxN][maxN];
      |        ^~~~
a.cc: In function 'int main(int, char**)':
a.cc:39:21: error: 'k' was not declared in this scope
   39 |                 if (k == i)
      |                     ^
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
#define long int ll
ll n,m;
ll arr[100000],x[100000],y[100000];
ll dp(ll i);
int main()
{ll i;
 cin>>n>>m;
 for(i=0;i<m;i++)
 {
  cin>>x[i]>>y[i];
 }
  for(i=0;i<=n;i++)
 {
    arr[i]=-1;
 }   
 ll a=0;
 for(i=0;i<m;i++)
 {
  
   a=max(a,dp(x[i]));
 }
  cout<<a;
  
 return 0;
}

ll dp(ll i)
{
  if(arr[i]!=-1)return arr[i];
  
  ll mx=0;
  for(ll j=0;j<m;j++)
  {
    if(x[j]==i)mx=max(mx,dp(y[j])+1);
  }
  arr[i]=mx;
  return mx;
}  


Compiler output:
a.cc:5:1: error: 'll' does not name a type
    5 | ll n,m;
      | ^~
a.cc:6:1: error: 'll' does not name a type
    6 | ll arr[100000],x[100000],y[100000];
      | ^~
a.cc:7:1: error: 'll' does not name a type
    7 | ll dp(ll i);
      | ^~
a.cc: In function 'int main()':
a.cc:9:2: error: 'll' was not declared in this scope
    9 | {ll i;
      |  ^~
a.cc:10:7: error: 'n' was not declared in this scope
   10 |  cin>>n>>m;
      |       ^
a.cc:10:10: error: 'm' was not declared in this scope; did you mean 'tm'?
   10 |  cin>>n>>m;
      |          ^
      |          tm
a.cc:11:6: error: 'i' was not declared in this scope
   11 |  for(i=0;i<m;i++)
      |      ^
a.cc:13:8: error: 'x' was not declared in this scope
   13 |   cin>>x[i]>>y[i];
      |        ^
a.cc:13:14: error: 'y' was not declared in this scope
   13 |   cin>>x[i]>>y[i];
      |              ^
a.cc:15:7: error: 'i' was not declared in this scope
   15 |   for(i=0;i<=n;i++)
      |       ^
a.cc:17:5: error: 'arr' was not declared in this scope
   17 |     arr[i]=-1;
      |     ^~~
a.cc:19:4: error: expected ';' before 'a'
   19 |  ll a=0;
      |    ^~
      |    ;
a.cc:20:6: error: 'i' was not declared in this scope
   20 |  for(i=0;i<m;i++)
      |      ^
a.cc:23:4: error: 'a' was not declared in this scope
   23 |    a=max(a,dp(x[i]));
      |    ^
a.cc:23:15: error: 'x' was not declared in this scope
   23 |    a=max(a,dp(x[i]));
      |               ^
a.cc:23:12: error: 'dp' was not declared in this scope
   23 |    a=max(a,dp(x[i]));
      |            ^~
a.cc:25:9: error: 'a' was not declared in this scope
   25 |   cout<<a;
      |         ^
a.cc: At global scope:
a.cc:30:1: error: 'll' does not name a type
   30 | ll dp(ll i)
      | ^~
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
#define long int ll;
ll n,m;
ll arr[100000],x[100000],y[100000];
ll dp(ll i);
int main()
{ll i;
 cin>>n>>m;
 for(i=0;i<m;i++)
 {
  cin>>x[i]>>y[i];
 }
  for(i=0;i<=n;i++)
 {
    arr[i]=-1;
 }   
 ll a=0;
 for(i=0;i<m;i++)
 {
  
   a=max(a,dp(x[i]));
 }
  cout<<a;
  
 return 0;
}

ll dp(ll i)
{
  if(arr[i]!=-1)return arr[i];
  
  ll mx=0;
  for(ll j=0;j<m;j++)
  {
    if(x[j]==i)mx=max(mx,dp(y[j])+1);
  }
  arr[i]=mx;
  return mx;
}  


Compiler output:
a.cc:5:1: error: 'll' does not name a type
    5 | ll n,m;
      | ^~
a.cc:6:1: error: 'll' does not name a type
    6 | ll arr[100000],x[100000],y[100000];
      | ^~
a.cc:7:1: error: 'll' does not name a type
    7 | ll dp(ll i);
      | ^~
a.cc: In function 'int main()':
a.cc:9:2: error: 'll' was not declared in this scope
    9 | {ll i;
      |  ^~
a.cc:10:7: error: 'n' was not declared in this scope
   10 |  cin>>n>>m;
      |       ^
a.cc:10:10: error: 'm' was not declared in this scope; did you mean 'tm'?
   10 |  cin>>n>>m;
      |          ^
      |          tm
a.cc:11:6: error: 'i' was not declared in this scope
   11 |  for(i=0;i<m;i++)
      |      ^
a.cc:13:8: error: 'x' was not declared in this scope
   13 |   cin>>x[i]>>y[i];
      |        ^
a.cc:13:14: error: 'y' was not declared in this scope
   13 |   cin>>x[i]>>y[i];
      |              ^
a.cc:15:7: error: 'i' was not declared in this scope
   15 |   for(i=0;i<=n;i++)
      |       ^
a.cc:17:5: error: 'arr' was not declared in this scope
   17 |     arr[i]=-1;
      |     ^~~
a.cc:19:4: error: expected ';' before 'a'
   19 |  ll a=0;
      |    ^~
      |    ;
a.cc:20:6: error: 'i' was not declared in this scope
   20 |  for(i=0;i<m;i++)
      |      ^
a.cc:23:4: error: 'a' was not declared in this scope
   23 |    a=max(a,dp(x[i]));
      |    ^
a.cc:23:15: error: 'x' was not declared in this scope
   23 |    a=max(a,dp(x[i]));
      |               ^
a.cc:23:12: error: 'dp' was not declared in this scope
   23 |    a=max(a,dp(x[i]));
      |            ^~
a.cc:25:9: error: 'a' was not declared in this scope
   25 |   cout<<a;
      |         ^
a.cc: At global scope:
a.cc:30:1: error: 'll' does not name a type
   30 | ll dp(ll i)
      | ^~
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int n,m;
int arr[100000],x[100000],y[100000];
int dp(int i);
int main()
{
 cin>>n>>m;
 for(int i=0;i<m;i++)
 {
  cin>>x[i]>>y[i];
 }
  for(int i=0;i<=n;i++)
 {
    arr[i]=-1;
 }   
 int x=0;
 for(int i=0;i<m;i++)
 {
  
   x=max(x,dp(x[i]));
 }
  cout<<x;
  
 return 0;
}

int dp(int i)
{
  if(arr[i]!=-1)return arr[i];
  
  int mx=0;
  for(int j=0;j<m;j++)
  {
    if(x[j]==i)mx=max(mx,dp(y[j])+1);
  }
  arr[i]=mx;
  return mx;
}  


Compiler output:
a.cc: In function 'int main()':
a.cc:22:16: error: invalid types 'int[int]' for array subscript
   22 |    x=max(x,dp(x[i]));
      |                ^
Language: C++

#include <iostream>
#include <vector>
using namespace std;
int n,m;
vector<int>dp;
vector<vector<int>> edge2;
int dfs(int n)
{
  if(dp[n]>-1)return dp[n];
  int res=0;
  for(int ne:edge2[n])
  {
    res=max(dfs(ne)+1,res);
  }
  dp[n]=res;
  return res;
}
int main()
{
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  dp=vector<int>(n+1,-1);
  edge2=vector<vector<int>>(n+1) ;
  for(int i=0;i<m;i++)
  {
    int a,b;
    cin>>a>>b;
    edge2[b].push_back(a);
  }
  for(int i=1;i<=n;i++)
  {
    if(dp[i]==-1)dfs(i);
  }
  cout<<*max_element(dp.begin(), dp.end());
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:10: error: 'max_element' was not declared in this scope
   35 |   cout<<*max_element(dp.begin(), dp.end());
      |          ^~~~~~~~~~~
Language: C++

#include"bits/stdc++.h"
using namespace std;
int head[100001],to[100001],next[100001];
int n,m;
int tot=0;
int maxn=0;
int f[100001];
void addedge(int u,int v)
{
	tot++;
	next[tot]=head[u];
	to[tot]=v;
	head[u]=tot; 
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		addedge(v,u);
	}
	for(int i=1;i<=n;i++)
	{
		int tmp=0;
		for(int j=head[i];j;j=next[j])
		{
			int v=to[j];
			tmp=max(tmp,f[v]);
		}
		f[i]=tmp+1;
		maxn=max(maxn,f[i]);
	}
	printf("%d",maxn);
	return 0;
}


Compiler output:
a.cc: In function 'void addedge(int, int)':
a.cc:11:9: error: reference to 'next' is ambiguous
   11 |         next[tot]=head[u];
      |         ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 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_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:3:29: note:                 'int next [100001]'
    3 | int head[100001],to[100001],next[100001];
      |                             ^~~~
a.cc: In function 'int main()':
a.cc:27:39: error: reference to 'next' is ambiguous
   27 |                 for(int j=head[i];j;j=next[j])
      |                                       ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:3:29: note:                 'int next [100001]'
    3 | int head[100001],to[100001],next[100001];
      |                             ^~~~
Language: C++

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

signed main(){
  int N,M;cin>>N>>M;
  std::vector<int> v[N];
  for(int i=0;i<M;i++){
    int a,b;cin>>a>>b;a--;b--;
    v[a].push_back(b);
  }
  std::vector<int> dp(N);
  for(int i=0;i<N;i++)dp[i]=0;
  std::vector<int> w(N,0);
  for(int i=0;i<N;i++){
    for(int j=0;j<v[i].size();j++){
      w[v[i][j]]++;
    }
  }
  queue<int> que;
  for(int i=0;i<N;i++)if(w[i]==0)que.push(i)
  while(que.size()){
    int a=que.front();que.pop();
    for(int i=0;i<v[a].size();i++){
      dp[v[a][i]]=max(dp[v[a][i]],dp[a]+1);
      w[v[a][i]]--;
      if(w[v[a][i]]==0)que.push(v[a][i]);
    }
  }
  int ans=0;
  for(int i=0;i<N;i++)ans=max(ans,dp[i]);
  cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:45: error: expected ';' before 'while'
   21 |   for(int i=0;i<N;i++)if(w[i]==0)que.push(i)
      |                                             ^
      |                                             ;
   22 |   while(que.size()){
      |   ~~~~~
Language: C++

#include<bits/stdc++.h>
using namespce std;
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n,m;
  cin>>n>>m;
  vector<int> edges[n];
  for(int i=0;i<n;i++){int a,b;
                      cin>>a>>b;
                      edges[a].push_back(b);}
  queue<int> pro;
  pro.push(1);
  vector<int> ans(n);
  while(!(pro.empty()))
  {
    
  }
return 0;
}

Compiler output:
a.cc:2:7: error: expected nested-name-specifier before 'namespce'
    2 | using namespce std;
      |       ^~~~~~~~
a.cc: In function 'int main()':
a.cc:4:3: error: 'ios_base' has not been declared
    4 |   ios_base::sync_with_stdio(false);
      |   ^~~~~~~~
a.cc:5:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    5 |   cin.tie(NULL);
      |   ^~~
      |   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:6:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
    6 |   cout.tie(NULL);
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:9:3: error: 'vector' was not declared in this scope
    9 |   vector<int> edges[n];
      |   ^~~~~~
a.cc:9:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:9:10: error: expected primary-expression before 'int'
    9 |   vector<int> edges[n];
      |          ^~~
a.cc:12:23: error: 'edges' was not declared in this scope
   12 |                       edges[a].push_back(b);}
      |                       ^~~~~
a.cc:13:3: error: 'queue' was not declared in this scope; did you mean 'std::queue'?
   13 |   queue<int> pro;
      |   ^~~~~
      |   std::queue
In file included from /usr/include/c++/14/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157:
/usr/include/c++/14/bits/stl_queue.h:96:11: note: 'std::queue' declared here
   96 |     class queue
      |           ^~~~~
a.cc:13:9: error: expected primary-expression before 'int'
   13 |   queue<int> pro;
      |         ^~~
a.cc:14:3: error: 'pro' was not declared in this scope
   14 |   pro.push(1);
      |   ^~~
a.cc:15:10: error: expected primary-expression before 'int'
   15 |   vector<int> ans(n);
      |          ^~~
Language: C++

#include<bits/stdc++.h>
#define pb push_back
#define int long long int 
using namespace std;
vector<int>v[100005];
bool vis[100005];
int dis[100005];
bool vis1[100005];
stack<int>propagate;
void dfs(int s,int par)
{
    if(par==0)
        if(dis[s]==-1)
                dis[s]=0;
    else
    dis[s]=dis[par]+1;
    vis[s]=true;
    for(auto it:v[s])
    {
         if(dis[it]<dis[s]+1)
            {
                dis[it]=dis[s]+1;
                if(vis[it]==true)
                propagate.push(it);// if node(it) is already visited just propage change later
            }
        if(vis[it]==true)
        {
           
        }
        else
        {
            dfs(it,s);
        }

    }

}
void dfs1(int s)
{
    vis1[s]=true;
    for(auto it:v[s])     // propogate the change
    {
        if(dis[it]<dis[s]+1)
            {
                dis[it]=dis[s]+1;
                if(vis1[it]==true)
                propagate.push(it);
        }
        if(!vis1[it])
            dfs1(it); 
    }
}
void correctit()
{
    while(!propogate.empty())
    {
        int u = propagate.top();
        propogate.pop();
        dfs1(u);
    }

    memset(vis1,false,sizeof vis1);
}
signed main()
{
  

    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
    }
    memset(dis,-1,sizeof dis);
    for(int i=1;i<=n;i++)
    {
        if(!vis[i]){
            dfs(i,0);
        correctit();
        //init();
        }
    }
    int maxi=0;
    for(int i=1;i<=n;i++)
        maxi = max(maxi,dis[i]);
    cout<<maxi<<"\n";
}

Compiler output:
a.cc: In function 'void correctit()':
a.cc:55:12: error: 'propogate' was not declared in this scope; did you mean 'propagate'?
   55 |     while(!propogate.empty())
      |            ^~~~~~~~~
      |            propagate
Language: C++

#include<bits/stdc++.h>
#define pb push_back
#define int long long int 
using namespace std;
vector<int>v[100005];
bool vis[100005];
int dis[100005];
bool vis1[100005];
stack<int>propagate;
void dfs(int s,int par)
{
    if(par==0)
        if(dis[s]==-1)
                dis[s]=0;
    else
    dis[s]=dis[par]+1;
    vis[s]=true;
    for(auto it:v[s])
    {
         if(dis[it]<dis[s]+1)
            {
                dis[it]=dis[s]+1;
                if(vis[it]==true)
                propagate.push(it);// if node(it) is already visited just propage change later
            }
        if(vis[it]==true)
        {
           
        }
        else
        {
            dfs(it,s);
        }

    }

}
void dfs1(int s)
{
    vis1[s]=true;
    for(auto it:v[s])     // propogate the change
    {
        if(dis[it]<dis[s]+1)
            {
                dis[it]=dis[s]+1;
                if(vis1[it]==true)
                propagate.push(it);
        }
        if(!vis1[it])
            dfs1(it); 
    }
}
void correctit()
{
    while(!propogate.empty())
    {
        int u = propagate.top();
        propogate.pop();
        dfs1(u);
    }

    memset(vis1,false,sizeof vis1);
}
signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif

    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
    }
    memset(dis,-1,sizeof dis);
    for(int i=1;i<=n;i++)
    {
        if(!vis[i]){
            dfs(i,0);
        correctit();
        //init();
        }
    }
    int maxi=0;
    for(int i=1;i<=n;i++)
        maxi = max(maxi,dis[i]);
    cout<<maxi<<"\n";
}

Compiler output:
a.cc: In function 'void correctit()':
a.cc:55:12: error: 'propogate' was not declared in this scope; did you mean 'propagate'?
   55 |     while(!propogate.empty())
      |            ^~~~~~~~~
      |            propagate
Language: C++

#include <cstdio>
#include <cstring>
#define Maxn 100000
int f[Maxn+5];
int head[Maxn+5],arrive[Maxn+5],nxt[Maxn+5],tot;
void add_edge(int from,int to){
	arrive[++tot]=to;
	nxt[tot]=head[from];
	head[from]=tot;
}
int mx(int a,int b){
	return a>b?a:b;
}
int dfs(int x){
	if(f[x]!=-1){
		return f[x];
	}
	f[i]=0;
	for(int i=head[x];i;i=nxt[i]){
		f[i]=mx(f[i],dfs(arrive[i])+1);
	}
	return f[i];
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int u,v;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&u,&v);
		add_edge(u,v);
	}
	memset(f,-1,sizeof f);
	int ans=0;
	for(int i=1;i<=n;i++){
		ans=mx(ans,dfs(i));
	}
	printf("%d\n",ans);
	return 0;
}


Compiler output:
a.cc: In function 'int dfs(int)':
a.cc:18:11: error: 'i' was not declared in this scope
   18 |         f[i]=0;
      |           ^
Language: C++

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
int dist[100004],n,m;
set <int> g[100004];
vector <int> t[100004];
bool cmp(int x,int y){
	return !g[y].find(x)!=g[y].end(); 
}
int main(){
	for (int i=0;i<m;i++){
	cin>>n>>m;
		int x,y; 
		cin>>x>>y;
		g[x].insert(y);
		t[x].push_back(y); 
	}
	vector <int> vis;
	for (int i=1;i<=n;i++) vis.push_back(i); 
	sort (vis.begin(),vis.end(),cmp); 
	memset (dist,0,sizeof(dist));
	for (int i=0;i<n;i++){
		for (int j=0;j<t[vis[i]].size();j++){
			dist[t[vis[i]][j]]=max(dist[t[vis[i]][j]],dist[vis[i]]+1);
		}
	}
	int ans=0;
	for (int i=1;i<=n;i++)
		ans=max(ans,dist[i]);
	cout<<ans;
}

Compiler output:
a.cc: In function 'bool cmp(int, int)':
a.cc:33:16: error: no match for 'operator!' (operand type is 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'})
   33 |         return !g[y].find(x)!=g[y].end();
      |                ^~~~~~~~~~~~~
a.cc:33:16: note: candidate: 'operator!(bool)' (built-in)
a.cc:33:16: note:   no known conversion for argument 1 from 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} to 'bool'
Language: C++

#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,m,ai,bi,dp[N],a[N];
vector<int> v[N];
stack<int> q;
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		cin>>ai>>bi;++
		v[ai].push_back(bi);
		a[bi]++;
	}
	memset(dp,-1,sizeof(dp));
	for(int i=1;i<=n;i++)
		if(!a[i])
			q.push(i);
	while(!q.empty())
	{
		int x=q.top();
		q.pop();
		for(int i=0;i<v[x].size();i++)
		{
			int y=v[x][i];
			if(dp[x]+1>dp[y])
				dp[y]=dp[x]+1;
			a[y]--;
			if(!a[y])
				q.push(y); 
		}
	}
	cout<<(*max_element(dp+1,dp+1+n));
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:32: error: no pre-increment operator for type
   24 |                 v[ai].push_back(bi);
      |                 ~~~~~~~~~~~~~~~^~~~
Language: C++

#include <bits/stdc++.h>
#define SPEED ios::sync_with_stdio(false); cin.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define INF 1e18
#define eps 0.00001
#define stp setprecision(20)
#define endl '\n'
using namespace std;
vector < int > adj[100005] ;
bool vis[100005] ={0} ;

 void dfs(int u , int )
   { 
    
       vis[u] =1;
        
        loop(i,0,adj[u].size())
         {
         	 if(!vis[adj[u][i]])
         	   dfs(adj[u][i]) ;
		 }
		 
		 
		 
   }
int main()
{    SPEED;

     int n,m;cin>>n>>m;
     
     loop(i,0,m)
      {
      	  int x,y;cin>>x>>y;
      	  
      	  adj[x].pb(y);
      	 
      	  
	  }
	  
	  loop(i,1,n+1)
	   {
	   	 if(!vis[i])dfs(i) ;
	   }
	   
	   
	   
}



Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:28:23: error: too few arguments to function 'void dfs(int, int)'
   28 |                    dfs(adj[u][i]) ;
      |                    ~~~^~~~~~~~~~~
a.cc:20:7: note: declared here
   20 |  void dfs(int u , int )
      |       ^~~
a.cc: In function 'int main()':
a.cc:50:32: error: too few arguments to function 'void dfs(int, int)'
   50 |                  if(!vis[i])dfs(i) ;
      |                             ~~~^~~
a.cc:20:7: note: declared here
   20 |  void dfs(int u , int )
      |       ^~~
Language: Java


import java.util.Scanner;
import java.util.Vector;

public class AtCoderDB_G {
	static Vector<Integer> [] link;
	static int dp[];
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		link = new Vector[n+1];
		for (int i=1;i<=n;i++)
			link[i] = new Vector();
		dp = new int[n+1];
		
		for (int i=0;i<m;i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			link[a].add(b);
		}
		int ans = 0;
		for (int i=1;i<=n;i++) {
			int l = f(i);
			if (ans<l) ans = l;
		}
		System.out.println(ans);
		
	}
	private static int f(int i) {
		if (dp[i]>0) return dp[i];
		int ans = 0;
		for (int j : link[i]) {
			int l = f(j) + 1;
			if (ans<l) ans = l;
		}
		dp[i] = ans;
		return ans;
	}
}


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

#include <bits/stdc++.h>
using namespace std;
int head[100001],to[100001],nxt[100001],tot;
int degree[100001],f[100001];
void addedge(int u,int v)
{
	tot++;
	nxt[tot]=head[u];
	to[tot]=v;
	head[u]=tot;
}
int dfs(int index)
{
	if(f[u]>=0)
		return f[u];
	if(head[u]==0)
		return f[u]=0;	
	int i,v;
	for(i=head[index];i;i=nxt[i])
	{
		v=to[i];
		f[u]=max(f[u],dfs(v)+1);
	}
}
int main()
{
	int n,m,i,j,v,u,max_v=0;
	scanf("%d %d",&n,&m);
	memoset(f,0xff,sizeof(f));
	for(i=1;i<=m;i++)
	{
		scanf("%d %d",&u,&v);
		addedge(u,v);
		degree[v]++;
	}
	for(i=1;i<=n;i++)
	{
		if(degree[i]==0)
		{
			dfs(i);
		}
	}
	for(i=1;i<=n;i++)
		max_v=max(f[i],max_v);
	printf("%d",max_v);
	return 0;
}

Compiler output:
a.cc: In function 'int dfs(int)':
a.cc:14:14: error: 'u' was not declared in this scope
   14 |         if(f[u]>=0)
      |              ^
a.cc:16:17: error: 'u' was not declared in this scope
   16 |         if(head[u]==0)
      |                 ^
a.cc:22:19: error: 'u' was not declared in this scope
   22 |                 f[u]=max(f[u],dfs(v)+1);
      |                   ^
a.cc: In function 'int main()':
a.cc:29:9: error: 'memoset' was not declared in this scope; did you mean 'memset'?
   29 |         memoset(f,0xff,sizeof(f));
      |         ^~~~~~~
      |         memset
Language: C++

#include<bits/stdc++.h>
using namespace std;
int tot=0;
int nxt[100001];
int to[100001];
int head[100001];
int degree[100001];
int f[100001];
void addedge(int u,int v)
{
	tot++;
	nxt[tot]=head[u];
	to[tot]=v;
	head[u]=tot;
}
int dfs(int ind)
{
	int i,v;
	if(head[ind]==0)
		f[ind]=0;
	if(f[ind]>=0)
		return f[ind];
	for(i=head[ind];i;i=nxt[i])
	{
		v=to[i];
		f[u]=max(f[u],dfs(v)+1);
	}
}
int main()
{
	memset(f,0xff,sizeof(f));
	int u,v,n,m,i,maxn;
	scanf("%d %d",&n,&m);
	for(i=1;i<=m;i++)
	{
		scanf("%d %d",&u,&v);
		addedge(u,v);
		degree[v]++;
	}
	for(i=1;i<=n;i++)
	{
		//if(degree[i]==0)
			dfs(i);
	}
	maxn=0;
	for(i=1;i<=n;i++)
		maxn=max(maxn,f[i]);
	printf("%d",maxn);
	return 0;
}

Compiler output:
a.cc: In function 'int dfs(int)':
a.cc:26:19: error: 'u' was not declared in this scope
   26 |                 f[u]=max(f[u],dfs(v)+1);
      |                   ^
a.cc:28:1: warning: control reaches end of non-void function [-Wreturn-type]
   28 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int tot=0;
int nxt[100001];
int to[100001];
int head[100001];
int degree[100001];
int f[100001];
void addedge(int u,int v)
{
	tot++;
	nxt[tot]=head[u];
	to[tot]=v;
	head[u]=tot;
}
int dfs(int ind)
{
	int i,v;
	if(head[ind]==0)
		f[ind]=0;
	if(f[ind]>=0)
		return f[ind];
	for(i=head[ind];i;i=nxt[i])
	{
		v=to[i];
		f[u]=max(f[u],dfs(v)+1
	}
}
int main()
{
	memset(f,0xff,sizeof(f));
	int u,v,n,m,i,maxn;
	scanf("%d %d",&n,&m);
	for(i=1;i<=m;i++)
	{
		scanf("%d %d",&u,&v);
		addedge(u,v);
		degree[v]++;
	}
	for(i=1;i<=n;i++)
	{
		//if(degree[i]==0)
			dfs(i);
	}
	maxn=0;
	for(i=1;i<=n;i++)
		maxn=max(maxn,f[i]);
	printf("%d",maxn);
	return 0;
}

Compiler output:
a.cc: In function 'int dfs(int)':
a.cc:26:19: error: 'u' was not declared in this scope
   26 |                 f[u]=max(f[u],dfs(v)+1
      |                   ^
a.cc:26:39: error: expected ')' before '}' token
   26 |                 f[u]=max(f[u],dfs(v)+1
      |                         ~             ^
      |                                       )
   27 |         }
      |         ~                              
a.cc:28:1: warning: control reaches end of non-void function [-Wreturn-type]
   28 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int tot=0;
int next[100001];
int to[100001];
int head[100001];
int degree[100001];
int f[100001];
void addedge(int u,int v)
{
	tot++;
	next[tot]=head[u];
	to[u]=v;
	head[u]=tot;
}
void dfs(int ind)
{
	int i,v;
	for(i=head[ind];i;i=next[i])
	{
		v=to[i];
		if(f[v]<f[ind]+1)
		{
			f[v]=f[ind]+1;
			dfs(v);
		}
	}
}
int main()
{
	int u,v,n,m,i,maxn;
	scanf("%d %d",&n,&m);
	for(i=1;i<=m;i++)
	{
		scanf("%d %d",&u,&v);
		addedge(u,v);
		degree[v]++;
	}
	for(i=1;i<=n;i++)
	{
		if(degree[i]==0)
			dfs(i);
	}
	maxn=0;
	for(i=1;i<=n;i++)
		maxn=max(maxn,f[i]);
	printf("%d",maxn);
	return 0;
}

Compiler output:
a.cc: In function 'void addedge(int, int)':
a.cc:12:9: error: reference to 'next' is ambiguous
   12 |         next[tot]=head[u];
      |         ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 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_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:4:5: note:                 'int next [100001]'
    4 | int next[100001];
      |     ^~~~
a.cc: In function 'void dfs(int)':
a.cc:19:29: error: reference to 'next' is ambiguous
   19 |         for(i=head[ind];i;i=next[i])
      |                             ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:4:5: note:                 'int next [100001]'
    4 | int next[100001];
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int head[100001],to[100001],next[100001],tot;
int degree[100001],f[100001];
void addedge(int u,int v)
{
	tot++;
	next[tot]=head[u];
	to[u]=v;
	head[u]=tot;
}
void dfs(int index)
{
	int i,v;
	for(i=head[index];i;i=next[i])
	{
		v=to[i];
		if(f[index]+1>=f[v])
		{
			f[v]=f[index]+1;
			dfs(v);
		}
	}
}
int main()
{
	int n,m,i,j,v,u,max_v=0;
	scanf("%d %d",&n,&m);
	for(i=1;i<=m;i++)
	{
		scanf("%d %d",&u,&v);
		addedge(u,v);
		degree[v]++;
	}
	for(i=1;i<=n;i++)
	{
		if(degree[i]==0)
		{
			dfs(i);
		}
	}
	for(i=1;i<=n;i++)
		max_v=max(f[i],max_v);
	printf("%d",max_v);
	return 0;
}

Compiler output:
a.cc: In function 'void addedge(int, int)':
a.cc:8:9: error: reference to 'next' is ambiguous
    8 |         next[tot]=head[u];
      |         ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 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_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:3:29: note:                 'int next [100001]'
    3 | int head[100001],to[100001],next[100001],tot;
      |                             ^~~~
a.cc: In function 'void dfs(int)':
a.cc:15:31: error: reference to 'next' is ambiguous
   15 |         for(i=head[index];i;i=next[i])
      |                               ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:3:29: note:                 'int next [100001]'
    3 | int head[100001],to[100001],next[100001],tot;
      |                             ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int tot=0;
int next[100001];
int to[100001];
int head[100001];
int degree[100001];
int f[100001];
void addedge(int u,int v)
{
	tot++;
	next[tot]=head[u];
	to[u]=v;
	head[u]=tot;
}
void dfs(int ind)
{
	int i,v;
	for(i=head[ind];i;i=next[i])
	{
		v=to[i];
		if(f[v]<f[ind]+1)
		{
			f[v]=f[ind]+1;
			dfs(v);
		}
	}
}
int main()
{
	int u,v,n,m,i,maxn;
	scanf("%d %d",&n,&m);
	for(i=1;i<=m;i++)
	{
		scanf("%d",&u,&v);
		addedge(u,v);
		degree[v]++;
	}
	for(i=1;i<=n;i++)
	{
		if(degree[i]==0)
			dfs(i);
	}
	maxn=0;
	for(i=1;i<=n;i++)
		maxn=max(maxn,f[i]);
	printf("%d",maxn);
	return 0;
}

Compiler output:
a.cc: In function 'void addedge(int, int)':
a.cc:12:9: error: reference to 'next' is ambiguous
   12 |         next[tot]=head[u];
      |         ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 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_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:4:5: note:                 'int next [100001]'
    4 | int next[100001];
      |     ^~~~
a.cc: In function 'void dfs(int)':
a.cc:19:29: error: reference to 'next' is ambiguous
   19 |         for(i=head[ind];i;i=next[i])
      |                             ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:4:5: note:                 'int next [100001]'
    4 | int next[100001];
      |     ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int head[100001],to[100001],next[100001],f[100001]={0},degree[100001]={0},tot=0,n,m;
void addedge(int u,int v)
{
        tot++;
        next[tot]=head[u];
        to[u]=v;
        head[u]=tot;
}
void dfs(int i,int j)
{
        if(!(f[j]+1<=f[i]))
                return;
        f[i]=f[j]+1;
        int k,v;
        for(k=head[i];k;k=next[k])
        {
                v=to[k];
                dfs(v,i);
        }
}
int main()
{
        int i,u,v,maxv=0;
        scanf("%d %d",&n,&m);
        for(i=1;i<=m;i++)
        {
                scanf("%d %d",&u,&v);
                addedge(u,v);
                degree[v]++;
        }
        for(i=1;i<=n;i++)
                if(degree[i]==0)
                        dfs(i,0);
        for(i=1;i<=n;i++)
                maxv=max(maxv,f[i]);
        printf("%d",maxv);
        return 0;
}

Compiler output:
a.cc: In function 'void addedge(int, int)':
a.cc:7:9: error: reference to 'next' is ambiguous
    7 |         next[tot]=head[u];
      |         ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 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_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:3:29: note:                 'int next [100001]'
    3 | int head[100001],to[100001],next[100001],f[100001]={0},degree[100001]={0},tot=0,n,m;
      |                             ^~~~
a.cc: In function 'void dfs(int, int)':
a.cc:17:27: error: reference to 'next' is ambiguous
   17 |         for(k=head[i];k;k=next[k])
      |                           ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:3:29: note:                 'int next [100001]'
    3 | int head[100001],to[100001],next[100001],f[100001]={0},degree[100001]={0},tot=0,n,m;
      |                             ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int head[100001],to[100001],next[100001],f[100001]={0},degree[100001]={0},tot=0,n,m;
void addedge(int u,int v)
{
	tot++;
	next[tot]=head[u];
	to[u]=v;
	head[u]=tot;
}
void dfs(int i,int j)
{
	if(f[j]+1<=f[i])
		return;
	f[i]=f[j]+1;
	int k,v;
	for(k=head[i];k;k=next[k])
	{
		v=to[k];
		dfs(v,i);
	}
}
int main()
{
	int i,u,v,maxv=0;
	scanf("%d %d",&n,&m);
	for(i=1;i<=m;i++)
	{
		scanf("%d %d",&u,&v);
		addedge(u,v);
		degree[v]++;
	}
	for(i=1;i<=n;i++)
		if(degree[i]==0)
			dfs(i,0);
	for(i=1;i<=n;i++)
		maxv=max(maxv,f[i]);
	printf("%d",maxv);
	return 0;
}

Compiler output:
a.cc: In function 'void addedge(int, int)':
a.cc:7:9: error: reference to 'next' is ambiguous
    7 |         next[tot]=head[u];
      |         ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 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_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:3:29: note:                 'int next [100001]'
    3 | int head[100001],to[100001],next[100001],f[100001]={0},degree[100001]={0},tot=0,n,m;
      |                             ^~~~
a.cc: In function 'void dfs(int, int)':
a.cc:17:27: error: reference to 'next' is ambiguous
   17 |         for(k=head[i];k;k=next[k])
      |                           ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:3:29: note:                 'int next [100001]'
    3 | int head[100001],to[100001],next[100001],f[100001]={0},degree[100001]={0},tot=0,n,m;
      |                             ^~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

vector< vector<int> >g;

int dp[100005];

void init(int n){
	g.clear();
    for(int i = 0; i<n+4; ++i){
     vector<int>ll;
      g.push_back(ll);
    }
    memset(dp,-1,sizeof(dp));
}

int dfs(int n){
  if(dp[n]!=-1)return dp[n];
  dp[n] = 0;
  for(int i = 0; i<(int)g[n].size(); ++i){
     int nxt = g[n][i];
     int ret = dfs(nxt);
     dp[n] = max(dp[n],1+ret);
  }
  return dp[n];
}

int main(){
	int n,m;
  	cin>>n>>m;
  	init(n);
  	for(int i = 0; i<m; ++i){
    		cin>>x>>y;
      g[x].push_back(y);
    }
  	int mxx = 0;
  	for(int i = 1; i<=n; ++i){
    	mxx = max(mxx,dfs(i));
    }
  cout<<mxx<<"\n";
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:22: error: 'x' was not declared in this scope
   34 |                 cin>>x>>y;
      |                      ^
a.cc:34:25: error: 'y' was not declared in this scope
   34 |                 cin>>x>>y;
      |                         ^
Language: C++

#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<utility>
#include <cmath>
#include <math.h> 


#define For(i,begin,end) for(int i=(begin);i<(end);i++)
#define FORD(i,begin,end) for(int i=(begin);i>(end);i--)
#define FOR(l) for(auto p = l.begin(); p != l.end(); p++)
#define ALL(k) (k).begin(),(k).end()
#define e1 first
#define e2 second
#define mp make_pair
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef unsigned long long LLU;
typedef long double LD;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> Vl;


ll dp[100000];
ll n,m;
VI adj[100005];
ll dfs_fun(ll x)
{
	if(dp[x] != -1)
		return dp[x];
	ll ret = 0; //max length keeps getting updated
	For(i,0,adj[x].size())
	{
		ret = max(ret, 1 + dfs_fun(adj[x][i]));
	}
	return dp[x] = ret;
}

int main()
{	
	memset(dp, -1, sizeof dp);
	cin>>n>>m;
	ll u,v;
	For(i,0,m)
	{
		cin>>u>>v;
		adj[u-1].push_back(v-1);
	}

	ll ans = 0;

	For(i,0,n)
		ans = max(ans,dfs_fun(i));

	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:9: error: 'memset' was not declared in this scope
   47 |         memset(dp, -1, sizeof dp);
      |         ^~~~~~
a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    7 | #include <math.h>
  +++ |+#include <cstring>
    8 |
Language: Java

import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    Map<Integer, ArrayList<Integer>> map = new HashMap<>();
    for(int i = 0; i < M; i++){
      int x = sc.nextInt();
      int y = sc.nextInt();
      if(!map.containsKey(x)){
        map.put(x, new ArrayList<Integer>());
      }
      List<Integer> list = map.get(x);
      list.add(y);
    }
    int[] memo = new int[N+1];
    Arrays.fill(memo, -1);
    System.out.println(solve(map, memo));
  }
  
  public static long solve(Map<Integer, ArrayList<Integer>> map, int[] memo){
    long max = -1L;
    for(int i = 1; i <=memo.length; i++){
      max = Math.max(max, saiki(map, i, memo));
    }
    return max;
  }
  
  public static long saiki(Map<Integer, ArrayList<Integer>> map, int n, int[] memo){
    if(!map.containsKey(n)){
      return 0;
    }
    if(memo[n] != -1){
      return memo[n];
    }
    List<Integer> list = map.get(n);
    long max = -1L;
    for(int i : list){
      max = Math.max(max, saiki(map, i, memo));
    }
    memo[n] = max+1;
    return max+1;
  }
}

Compiler output:
Main.java:42: error: incompatible types: possible lossy conversion from long to int
    memo[n] = max+1;
                 ^
1 error