criyle/codenet-compile-errors huggingface dataset:
Language: Java

package practice;

import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class LongestPathDp {

	static List<List<Integer>> graph = new LinkedList<List<Integer>>();
 	static int dp[];
 	static int answer = 0;
 	
	public static void addEdge(int u , int v) {
		graph.get(u).add(v);
	}
	
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int vertices = sc.nextInt();
	    int edge = sc.nextInt();
	    dp = new int[vertices + 1];
	    for(int i = 0 ; i <= vertices ; i++) {
	    	List<Integer> list = new LinkedList<Integer>();
	    	graph.add(list);
	    }
	    
	    for(int i = 1 ; i <= edge ; i++) {
	    	int u = sc.nextInt();
	    	int v = sc.nextInt();
	    	addEdge(u, v);
	    }
	    
	    boolean visited[] = new boolean[vertices + 1];
	    for(int i = 1 ; i <= vertices ; i++) {
	    	dfs(visited , i);
	    }
	    System.out.println(answer);
	}
	
	public static int dfs(boolean[] visited , int curr) {
		List<Integer> list = graph.get(curr);
		if(visited[curr]) {
			return dp[curr];
		}
		for(int i = 0 ; i < list.size() ; i++) {
			dp[curr] = Math.max(dp[curr] , 1 + dfs(visited , list.get(i)));
		}
		visited[curr] = true;
		answer = Math.max(answer, dp[curr]);
		return dp[curr];
	}
}


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

#include <bits/stdc++.h>

using namespace std;
int dp[100001];
vector <int> v[100001];
int viz[100001];
int maxim;
void dfs(int nod){
    viz[nod] = 1;
    for(auto x : v[nod]){
            dp[x] = max(dp[x],dp[nod] + 1);
            maxim = max(maxim,dp[x]);
            dfs(x);

    }
}
int main()
{
    int n,m,x,y,i;
    cin >> n >> m;
    for(i = 1;i <= m;i++){
        cin >> x >> y;
        v[x].push_back(y);
    }
   dfs(1)
    cout << maxim;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:10: error: expected ';' before 'cout'
   25 |    dfs(1)
      |          ^
      |          ;
   26 |     cout << maxim;
      |     ~~~~
Language: C++

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;

int graph[100002][100002], dp[100002];
int N, M;

int q(int k) {
    int i, j;
    if (dp[k] != -1) return dp[k];

    int max = 0;
    for (i = 1; i <= N; i++) {
        if (graph[k][i] == 1) {
            int temp = q(i) + 1;
            if (temp > max) max = temp;
        }
    }
    dp[k] = max;

    return dp[k];
}

int main() {
    int i;
    cin >> N >> M;

    for (i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        graph[x][y] = 1;
    }
    for (i = 1; i <= N; i++) {
        dp[i] = -1;
    }

    int max = 0;
    for (i = 1; i <= N; i++) {
        int temp = q(i);
        if (temp > max) max = temp;
    }
    cout << max << endl;
}

Compiler output:
/tmp/ccSZGmrt.o: in function `q(int)':
a.cc:(.text+0x1b): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccSZGmrt.o
a.cc:(.text+0x37): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccSZGmrt.o
a.cc:(.text+0xa3): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccSZGmrt.o
a.cc:(.text+0xbc): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccSZGmrt.o
a.cc:(.text+0xd6): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccSZGmrt.o
/tmp/ccSZGmrt.o: in function `main':
a.cc:(.text+0xea): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccSZGmrt.o
a.cc:(.text+0x106): relocation truncated to fit: R_X86_64_PC32 against symbol `M' defined in .bss section in /tmp/ccSZGmrt.o
a.cc:(.text+0x177): relocation truncated to fit: R_X86_64_PC32 against symbol `M' defined in .bss section in /tmp/ccSZGmrt.o
a.cc:(.text+0x199): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccSZGmrt.o
a.cc:(.text+0x1aa): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccSZGmrt.o
a.cc:(.text+0x1e4): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

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

char path[100001][100001];
int dp[100001][100001];

int grid(int h, int w, int hmax, int wmax)
{
	if(path[h][w] == '#' || h == hmax || w == wmax) return 0;
	if(dp[h][w]>0) return dp[h][w];
	if(h == hmax - 1 && w == wmax - 1) return 1;

	dp[h][w] = grid(h,w+1,hmax,wmax) + grid(h+1,w,hmax,wmax);
	return dp[h][w];
}

int main()
{
	int h, w;
	cin >> h >> w;

	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j++)
			cin >> path[i][j];

	int m = grid(0, 0, h, w);

	cout << m << endl;
	return 0;
}


Compiler output:
/tmp/ccNQKuwx.o: in function `grid(int, int, int, int)':
a.cc:(.text+0x75): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccNQKuwx.o
a.cc:(.text+0xa0): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccNQKuwx.o
a.cc:(.text+0x11a): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccNQKuwx.o
a.cc:(.text+0x141): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccNQKuwx.o
collect2: error: ld returned 1 exit status
Language: Java

import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class template {
	public static void main(String[] args) throws Exception {
		FastScanner sc = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		int l = sc.nextInt();
		int t = sc.nextInt();
		Node[] n = new Node[l];
		for(int i=0;i<l;i++)n[i]=new Node(i+1);
		int out =0;
		for(int i=0;i<t;i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			n[x-1].addc(n[y-1]);
		}
		for(int i=0;i<l;i++) {
			out=Math.max(out, getLayer(n[i]));
		}
		pw.println(out);
		pw.close();
	}
	public static int getLayer(Node n) {
		if(n.layer>-1)return n.layer;
		else if(n.c.isEmpty())return 0;
		else {
			int temp =0;
			for(Node x : n.c) {	
				temp=Math.max(temp, getLayer(x)+1);
			}
			n.layer=temp;
			return temp;
		}
	}
	static class Node{
		int layer;
		int val;
		ArrayList<Node> c;
		public Node(int v) {
			val=v;
			layer=-1;
			c=new ArrayList<Node>();
		}
		public void addc(Node n) {
			c.add(n);
		}
	}
}
@SuppressWarnings("all")
class FastScanner {
    BufferedReader br;
    StringTokenizer st;
 
    public FastScanner(String s) {
        try {
            br = new BufferedReader(new FileReader(s));
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
 
    public FastScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }
 
    String nextToken() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
 
    int nextInt() {
        return Integer.parseInt(nextToken());
    }
 
    long nextLong() {
        return Long.parseLong(nextToken());
    }
 
    double nextDouble() {
        return Double.parseDouble(nextToken());
    }
}

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


// Target Expert 

/*
 * Author    : raj1307 - Raj Singh
 * Institute : Jalpaiguri Government Engineering College
 * Date      : 3.08.19
 */

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <iomanip>
#include <memory.h>
#include <assert.h>
using namespace std;


//#define DEBUG
#ifdef DEBUG
#define deb(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
#define debarr(a,n) cerr<<#a<<" : ";for(int i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define debmat(mat,row,col) cerr<<#mat<<" :\n";for(int i=0;i<row;i++) {for(int j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cerr<<name<<" : "<<arg1<<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 deb(...) {}
#define debarr(a,n) {}
#define debmat(mat,row,col) {}
#define endl "\n"
#endif

#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fr(i, a, b) for(int i = (a); i < (b); ++i)
#define fb(i, b, a) for(int i = (b); i > (a); --i)
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define rr return 
#define int long long
#define pb push_back
#define sz(x) ((int)x.size())
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a>b) return b; else return a;}

const int mod = 1000*1000*1000+7;
const int INF = 1e18 +5;

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}


const int N = 1e5 + 5;
int n,m;
int x[N],y[N];
 
int mm[N]; 

vector<int>graph[N];
bitset<500005> vis;


void dfs(int v,int c){
	vis[v] = 1;

	mm[v]=max(mm[v],c);
	//deb(v,c,graph[v].size());
	for(auto i:graph[v]){
		//deb(*i,c+1);
		dfs(i,c+1);
	}
}

 






 
 
 
 
void solve(){
 
 
	cin>>n>>m;
	int u,v;
	for(int i=1;i<=m;++i){
        
        cin>>u>>v;
        //deb(u,v);
        graph[u].pb(v);
    }
    int c=0;
	//memset(cache,-1,sizeof(cache));
 	int ma=0;
	//deb(mm);
	fr(i,1,n+1){
		if(!vis[i]){
			c=0;

			dfs(i,c);
		}
	}
	//debarr(mm,10);
	fr(i,1,n+1){
		if(mm[i]>ma)
			ma=mm[i];
	}
	cout<<ma;


	
 
}
 



signed main() {
	fio;
	
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	while(t--) {
		solve();
	}

	
	return 0;
}


Compiler output:
a.cc:89:1: error: 'bitset' does not name a type
   89 | bitset<500005> vis;
      | ^~~~~~
a.cc: In function 'void dfs(long long int, long long int)':
a.cc:93:9: error: 'vis' was not declared in this scope
   93 |         vis[v] = 1;
      |         ^~~
a.cc: In function 'void solve()':
a.cc:130:21: error: 'vis' was not declared in this scope
  130 |                 if(!vis[i]){
      |                     ^~~
Language: C++


// Target Expert 

/*
 * Author    : raj1307 - Raj Singh
 * Institute : Jalpaiguri Government Engineering College
 * Date      : 3.08.19
 */

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <iomanip>
#include <memory.h>
#include <assert.h>
using namespace std;


//#define DEBUG
#ifdef DEBUG
#define deb(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
#define debarr(a,n) cerr<<#a<<" : ";for(int i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define debmat(mat,row,col) cerr<<#mat<<" :\n";for(int i=0;i<row;i++) {for(int j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cerr<<name<<" : "<<arg1<<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 deb(...) {}
#define debarr(a,n) {}
#define debmat(mat,row,col) {}
#define endl "\n"
#endif

#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fr(i, a, b) for(int i = (a); i < (b); ++i)
#define fb(i, b, a) for(int i = (b); i > (a); --i)
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define rr return 
#define int long long
#define pb push_back
#define sz(x) ((int)x.size())
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a>b) return b; else return a;}

const int mod = 1000*1000*1000+7;
const int INF = 1e18 +5;

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}


const int N = 1e5 + 5;
int n,m;
int x[N],y[N];
 
int mm[N]; 

vector<int>graph[N];
bitset<500005> vis;


void dfs(int v,int c){
	vis[v] = 1;

	mm[v]=max(mm[v],c);
	//deb(v,c,graph[v].size());
	for(auto i=graph[v].begin();i<graph[v].end();++i){
		//deb(*i,c+1);
		dfs(*i,c+1);
	}
}

 






 
 
 
 
void solve(){
 
 
	cin>>n>>m;
	int u,v;
	for(int i=1;i<=m;++i){
        
        cin>>u>>v;
        //deb(u,v);
        graph[u].pb(v);
    }
    int c=0;
	//memset(cache,-1,sizeof(cache));
 	int ma=0;
	//deb(mm);
	fr(i,1,n+1){
		if(!vis[i]){
			c=0;

			dfs(i,c);
		}
	}
	//debarr(mm,10);
	fr(i,1,n+1){
		if(mm[i]>ma)
			ma=mm[i];
	}
	cout<<ma;


	
 
}
 



signed main() {
	fio;

	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	while(t--) {
		solve();
	}

	
	return 0;
}


Compiler output:
a.cc:89:1: error: 'bitset' does not name a type
   89 | bitset<500005> vis;
      | ^~~~~~
a.cc: In function 'void dfs(long long int, long long int)':
a.cc:93:9: error: 'vis' was not declared in this scope
   93 |         vis[v] = 1;
      |         ^~~
a.cc: In function 'void solve()':
a.cc:130:21: error: 'vis' was not declared in this scope
  130 |                 if(!vis[i]){
      |                     ^~~
Language: C++


// Target Expert 

/*
 * Author    : raj1307 - Raj Singh
 * Institute : Jalpaiguri Government Engineering College
 * Date      : 3.08.19
 */

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <iomanip>
#include <memory.h>
#include <assert.h>
using namespace std;


#define DEBUG
#ifdef DEBUG
#define deb(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
#define debarr(a,n) cerr<<#a<<" : ";for(int i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define debmat(mat,row,col) cerr<<#mat<<" :\n";for(int i=0;i<row;i++) {for(int j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cerr<<name<<" : "<<arg1<<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 deb(...) {}
#define debarr(a,n) {}
#define debmat(mat,row,col) {}
#define endl "\n"
#endif

#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fr(i, a, b) for(int i = (a); i < (b); ++i)
#define fb(i, b, a) for(int i = (b); i > (a); --i)
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define rr return 
#define int long long
#define pb push_back
#define sz(x) ((int)x.size())
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a>b) return b; else return a;}

const int mod = 1000*1000*1000+7;
const int INF = 1e18 +5;

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}


const int N = 1e5 + 5;
int n,m;
int x[N],y[N];
 
int mm[N]; 

vector<int>graph[N];
bitset<500005> vis;


void dfs(int v,int c){
	vis[v] = 1;

	mm[v]=max(mm[v],c);
	//deb(v,c,graph[v].size());
	for(auto i=graph[v].begin();i<graph[v].end();++i){
		//deb(*i,c+1);
		dfs(*i,c+1);
	}
}

 






 
 
 
 
void solve(){
 
 
	cin>>n>>m;
	int u,v;
	for(int i=1;i<=m;++i){
        
        cin>>u>>v;
        //deb(u,v);
        graph[u].pb(v);
    }
    int c=0;
	//memset(cache,-1,sizeof(cache));
 	int ma=0;
	//deb(mm);
	fr(i,1,n+1){
		if(!vis[i]){
			c=0;

			dfs(i,c);
		}
	}
	//debarr(mm,10);
	fr(i,1,n+1){
		if(mm[i]>ma)
			ma=mm[i];
	}
	cout<<ma;


	
 
}
 



signed main() {
	fio;
	
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	while(t--) {
		solve();
	}

	
	return 0;
}


Compiler output:
a.cc:89:1: error: 'bitset' does not name a type
   89 | bitset<500005> vis;
      | ^~~~~~
a.cc: In function 'void dfs(long long int, long long int)':
a.cc:93:9: error: 'vis' was not declared in this scope
   93 |         vis[v] = 1;
      |         ^~~
a.cc: In function 'void solve()':
a.cc:130:21: error: 'vis' was not declared in this scope
  130 |                 if(!vis[i]){
      |                     ^~~
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include "math.h"
using namespace std;

#define BUFF ios::sync_with_stdio(false)
#define rep(i,a,b) for (int i=a; i<b; i++)
#define pb push_back
#define vvi vector<vector<int>> 
#define vi vector<int>
#define vb vector<bool>
#define vvb vector<vector<bool>> 

vi visit, pos;
int nxt = 1;
void dfs_visit(vvi & adj, int i) {
	visit[i] = 1;
	for (int j : adj[i]) {
		if (!visit[j]) {
			dfs_visit(adj, j);
		}
	}
	pos[i] = nxt++;
}

void dfs(vvi & adj, int n) {
		visit.assign(n+1, 0);
		pos.assign(n+1, 0);
		for(int i=1; i<=n; i++) {
			if (!visit[i]) {
				dfs_visit(adj, i);
			}
		}
}

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

	vvi adj;
	vi lista;
	lista.clear();
	adj.assign(n+1, lista);
	for (int i=1; i<=m; i++) { 
		int x, y;
		cin >> x >> y;
		adj[x].push_back(y);
	}

	dfs(adj, n);

	vector<pair<int, int>> v(n+1);
	for(int i=1; i<=n; i++) {
		v[i].first = pos[i];
		v[i].second = i;
	}
	sort(v.rbegin(), v.rend());
	vector<int> path(n+1, 0);
	for(int i=0; i<n; i++) {
		int node = v[i].second;
		for(auto j : adj[node]) path[j] = max(path[j], path[node]+1);
	}
	int ans = 0;
	for(int i=1; i<=n; i++) {
		ans = max(ans, path[i]);	
	}

	cout << ans << endl;
   return 0;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:59:9: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   59 |         sort(v.rbegin(), v.rend());
      |         ^~~~
      |         sqrt
Language: C++

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// DON'T USE THESE MACROS DURING ICPC PRACTICE
#define For(i,n) for (int i=0; i<n; i++)
#define FOR(i,a,b) for (int i=a; i<=b; i++)
#define Down(i,n) for (int i=n-1; i>=0; i--)
#define DOWN(i,a,b) for (int i=b; i>=a; i--)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef complex<ld> pt;
typedef vector<pt> pol;
typedef vector<int> vi;

const char nl = '\n';
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9+7;
const ld EPS = 1e-10;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());



int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(10);

	int n, m;
	cin >> n >> m;

	int indeg[n+1];
	memset(indeg, 0, sizeof indeg);
	For(i,m) {
		int a, b;
		cin >> a >> b;
		adj[a].push_back(b);
		indeg[b]++;
	}

	queue<int> bfs;
	FOR(i,1,n) {
		if (indeg[i] == 0) {
			bfs.push(i);
		}
	}

	int len[n+1];
	memset(len, 0, sizeof len);
	while (!bfs.empty()) {
		int u = bfs.front();
		bfs.pop();
		for (int v : adj[u]) {
			len[v] = max(len[v], len[u] + 1);
			if (--indeg[v] == 0) {
				bfs.push(v);
			}
		}
	}

	int ans = 0;
	FOR(i,1,n) {
		ans = max(ans, len[i]);
	}
	cout << ans << nl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:48:17: error: 'adj' was not declared in this scope
   48 |                 adj[a].push_back(b);
      |                 ^~~
a.cc:64:30: error: 'adj' was not declared in this scope
   64 |                 for (int v : adj[u]) {
      |                              ^~~
Language: C++

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

const int INF= 1e9 +5;
typedef std::vector<lli> vi;
typedef pair<int,int> ii;


void max_self(int& a,int b)
{
    a=max(a,b);
}


int main() {

    int n,m;
    scanf("%d%d",&n,&m);
    
    vi edges[n+1];
    
    for(int i=0;i<m;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        edges[x].pb(y);
    }
    for(int i=1;i<=n;i++)
    {
        edges[0].pb(i);
    }
    
    vi dist(n+1,0);
    
    queue<int>q;
    q.push(0);
    while(!q.empty())
    {
        int t=q.front();
        q.pop();
        
        for(auto x:edges[t])
        {
            if(dist[x]<dist[t]+1)
            {
                dist[x]=dist[t]+1;
                q.push(x);
            }
        }
        
    }
    
    lli ans=0;
    for(auto x:dist)
    {
        max_self(ans,x);
    }
    
    cout<<ans-1<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:58:18: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'long long int'
   58 |         max_self(ans,x);
      |                  ^~~
a.cc:11:20: note:   initializing argument 1 of 'void max_self(int&, int)'
   11 | void max_self(int& a,int b)
      |               ~~~~~^
Language: C++

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

const int MaxNoeuds=10*10*10*10*10;
const int MaxArretes=10*10*10*10*10;
const int MoinsInf=-100000*10000;
vector<pair<int,bool>> ListeAdj[MaxNoeuds+5];
int DP[MaxNoeuds+5];
int NbNoeuds,NbArretes;

void LitGraphe()
{
   scanf("%d%d", &NbNoeuds, &NbArretes);
   for(int iArrete=1;iArrete<=NbArretes;iArrete++)
   {
      int Noeud1,Noeud2;
      scanf("%d%d",&Noeud1,&Noeud2);
      ListeAdj[Noeud1].push_back({Noeud2,false});
   }
   for(int iNoeud=1;iNoeud<=NbNoeuds;iNoeud++)
   {
      if(ListeAdj[iNoeud].size()==0)
         DP[iNoeud]=0;
      else
         DP[iNoeud]=MoinsInf;
   }
}
bool ArreteToutes(int iNoeud)
{
   for(int iFils=0;iFils<(int)ListeAdj[iNoeud].size();iFils++)
       if(!ListeAdj[iNoeud][iFils].second)
          return false;
   return true;
}
           
int plusLong(int iNoeud)
{

   if(DP[iNoeud]!=MoinsInf||ArreteToute(iNoeud))
      return DP[iNoeud];
      
   else
   {
      for(int iFils=0;iFils<(int)ListeAdj[iNoeud].size();iFils++)
      {       
        int Fils=ListeAdj[iNoeud][iFils].first;
        if(!ListeAdj[iNoeud][iFils].second)
        {
            
            DP[iNoeud]=max(DP[iNoeud],plusLong(Fils)+1); 
            ListeAdj[iNoeud][iFils].second=true;                 
        }                 
      }
      return DP[iNoeud]; 
   }
}

int main()
{
   LitGraphe();
   int CheminPL=MoinsInf;
   
     for(int iNoeud=1;iNoeud<=NbNoeuds;iNoeud++)
        plusLong(iNoeud);
      
   
   for(int iNoeud=1;iNoeud<=NbNoeuds;iNoeud++)
   {
         CheminPL=max(CheminPL,DP[iNoeud]);
         
   }
   printf("%d",CheminPL);
}




Compiler output:
a.cc: In function 'int plusLong(int)':
a.cc:40:29: error: 'ArreteToute' was not declared in this scope; did you mean 'ArreteToutes'?
   40 |    if(DP[iNoeud]!=MoinsInf||ArreteToute(iNoeud))
      |                             ^~~~~~~~~~~
      |                             ArreteToutes
a.cc:57:1: warning: control reaches end of non-void function [-Wreturn-type]
   57 | }
      | ^
Language: C++

#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>

#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,n) for(int i=0;i<(n); ++i)
#define rep2(i,n) for(int i=1;i<=(n);++i)

using namespace std;
typedef long long ll;
typedef vector<int> vi;
const int NMAX = 100000;
const int MMAX = 100000;
const int k = 200000;
static const int INF = 1<<21;
static const int NIL = -1;

int dp[3001][3001];
ll gcd(ll a, ll b){
if(a<b) swap(a,b);
    if(b==0) return a;
    return gcd(b, a%b);
}
vector<vi> pre(NMAX+1);
vi dist(NMAX+1);
vector<bool> visited(NMAX+1);

void dfs(int v){
    visited[v]=true; //bool値　訪れたらtrue
  	rep(vp,pre[v].size(){
        if(!visited[pre[vp]){
            dfs(pre[vp);
        }
        dist[v] = max(dist[v],dist[pre[vp]+1);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0); //この2行はより速度を向上させる


    int n,m,s,t,q;
    cin >> n >> m;
    int u,v;
    rep(i,m){
        cin >> u >> v;
        pre[v].push_back(u);
    }
    int ans=0;
    rep2(i,n){
        if(!visited[i]){
            dfs(i);
            ans=max(ans,dist[i]);
        }
    }
    cout << ans << endl;

return 0;
}

Compiler output:
a.cc:104:2: error: unterminated argument list invoking macro "rep"
  104 | }
      |  ^
a.cc: In function 'void dfs(int)':
a.cc:74:9: error: 'rep' was not declared in this scope
   74 |         rep(vp,pre[v].size(){
      |         ^~~
a.cc:74:12: error: expected '}' at end of input
   74 |         rep(vp,pre[v].size(){
      |            ^
a.cc:72:16: note: to match this '{'
   72 | void dfs(int v){
      |                ^
Language: C++

#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>

#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,n) for(int i=0;i<(n); ++i)
#define rep2(i,n) for(int i=1;i<=(n);++i)

using namespace std;
typedef long long ll;
typedef vector<int> vi;
const int NMAX = 100000;
const int MMAX = 100000;
const int k = 200000;
static const int INF = 1<<21;
static const int NIL = -1;

int dp[3001][3001];
ll gcd(ll a, ll b){
if(a<b) swap(a,b);
    if(b==0) return a;
    return gcd(b, a%b);
}

vector<vi> pre(NMAX+1);
vi dist(NMAX+1);
vector<bool> visited(NMAX+1);

void dfs(int v){
    visited[v]=true; //bool値　訪れたらtrue
    rep(int vp:pre[v]){
        if(!visited[vp]){
            dfs(vp);
        }
        dist[v] = max(dist[v],dist[vp]+1);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0); //この2行はより速度を向上させる


    int n,m,s,t,q;
    cin >> n >> m;
    int u,v;
    rep(i,m){
        cin >> u >> v;
        pre[v].push_back(u);
    }
    int ans=0;
    rep2(i,n){
        if(!visited[i]){
            dfs(i);
            ans=max(ans,dist[i]);
        }
    }
    cout << ans << endl;

return 0;
}

Compiler output:
a.cc:75:22: error: macro "rep" requires 2 arguments, but only 1 given
   75 |     rep(int vp:pre[v]){
      |                      ^
a.cc:50:9: note: macro "rep" defined here
   50 | #define rep(i,n) for(int i=0;i<(n); ++i)
      |         ^~~
a.cc: In function 'void dfs(int)':
a.cc:75:5: error: 'rep' was not declared in this scope
   75 |     rep(int vp:pre[v]){
      |     ^~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <math.h>
#include <climits>
#include <stack>

using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

#define MOD (1000000000+7)

bool _less(pair<int, int> a, pair<int, int> b) {
    return a.second < b.second;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int> > E;
    vector<int> inedges(N), outedges(N);
    vector<vector<int> > nextnodes(N);
    REP(i, M) {
        int x, y;
        cin >> x >> y;
        E.push_back(make_pair(x-1, y-1));
        inedges[y-1]++;
        outedges[x-1]++;
        nextnodes[x-1].push_back(y-1);
    }
    
    vector<int> dp(N);
    REP(i, N) {
        if (outedges[i] == 0) dp[i] = 1;
    }
    

    auto rec = [&](int n) mutable -> int {
        if (dp[n] > 0) return dp[n];
        int m = 0;
        REP(i, nextnodes[n].size()) {
            int nn = nextnodes[n][i];
            m = max(m, rec(nn)+1);
        }
        return m;
    };
    
    int cnt = 0;
    REP(i, N) {
        if (inedges[i] == 0) {
            cnt = max(cnt, rec(i));
        }
    }
    

    cout << cnt-1 << endl;
}


Compiler output:
a.cc: In lambda function:
a.cc:63:24: error: use of 'rec' before deduction of 'auto'
   63 |             m = max(m, rec(nn)+1);
      |                        ^~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <math.h>
#include <climits>
#include <stack>

using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

#define MOD (1000000000+7)

bool _less(pair<int, int> a, pair<int, int> b) {
    return a.second < b.second;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int> > E;
    vector<int> inedges(N), outedges(N);
    vector<vector<int> > nextnodes(N);
    REP(i, M) {
        int x, y;
        cin >> x >> y;
        E.push_back(make_pair(x-1, y-1));
        inedges[y-1]++;
        outedges[x-1]++;
        nextnodes[x-1].push_back(y-1);
    }
    
    vector<int> dp(N);
    REP(i, N) {
        if (outedges[i] == 0) dp[i] = 1;
    }
    

    function<int(int)> rec = [&](int n) mutable -> int {
        if (dp[n] > 0) return dp[n];
        int m = 0;
        REP(i, nextnodes[n].size()) {
            int nn = nextnodes[n][i];
            m = max(m, rec(nn)+1);
        }
        return m;
    };
    
    int cnt = 0;
    REP(i, N) {
        if (inedges[i] == 0) {
            cnt = max(cnt, rec(i));
        }
    }
    

    cout << cnt-1 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:58:5: error: 'function' was not declared in this scope
   58 |     function<int(int)> rec = [&](int n) mutable -> int {
      |     ^~~~~~~~
a.cc:12:1: note: 'std::function' is defined in header '<functional>'; this is probably fixable by adding '#include <functional>'
   11 | #include <stack>
  +++ |+#include <functional>
   12 | 
a.cc:58:14: error: expected primary-expression before 'int'
   58 |     function<int(int)> rec = [&](int n) mutable -> int {
      |              ^~~
a.cc:71:28: error: 'rec' was not declared in this scope
   71 |             cnt = max(cnt, rec(i));
      |                            ^~~
Language: Java

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class dpdfs {
    static void dfsutil(Graph g,int s,boolean[] visited,int dp[]){
//        visited[s]=true;
//        System.out.print(s+1+" ");
        for(int i=0;i<g.arr[s].size();i++){
            dp[g.arr[s].get(i)]=Math.max(dp[g.arr[s].get(i)],dp[s]+1);
//                visited[g.arr[s].get(i)]=true;
            dfsutil(g,g.arr[s].get(i),visited,dp);

        }

    }
    static int dfs(Graph g){
        boolean visited[]=new boolean[g.v];
        int dp[]=new int[g.v];
        for(int i=0;i<g.v;i++){
            if(visited[i]==false){
                dfsutil(g,i,visited,dp);
            }
        }
//        System.out.println(Arrays.toString(dp));
        int max=0;
        for(int i=0;i<g.v;i++){
            max=Math.max(max,dp[i]);
        }
        return max;
    }
    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        int v=s.nextInt();
        int e=s.nextInt();
        Graph g=new Graph(v);
        for(int i=0;i<e;i++){
            g.addEdge(s.nextInt()-1,s.nextInt()-1);

        }
        System.out.println(dfs(g));

    }
}

class Graph{
    int v;//no of vertices
    ArrayList<Integer> arr[];
    Graph(int v){
        this.v=v;
        this.arr=new ArrayList[v];
        for(int i=0;i<v;i++){
            this.arr[i]=new ArrayList<Integer>();
        }


    }
    void addEdge(int a,int b){
        this.arr[a].add(b);
    }
}




Compiler output:
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Language: Java

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;



class Graph{
    int v;//no of vertices
    ArrayList<Integer> arr[];
    Graph(int v){
        this.v=v;
        this.arr=new ArrayList[v];
        for(int i=0;i<v;i++){
            this.arr[i]=new ArrayList<Integer>();
        }


    }
    void addEdge(int a,int b){
        this.arr[a].add(b);
    }
}

class dpdfs {
    static void dfsutil(Graph g,int s,boolean[] visited,int dp[]){
//        visited[s]=true;
//        System.out.print(s+1+" ");
        for(int i=0;i<g.arr[s].size();i++){
                dp[g.arr[s].get(i)]=Math.max(dp[g.arr[s].get(i)],dp[s]+1);
//                visited[g.arr[s].get(i)]=true;
                dfsutil(g,g.arr[s].get(i),visited,dp);

        }

    }
    static int dfs(Graph g){
        boolean visited[]=new boolean[g.v];
        int dp[]=new int[g.v];
        for(int i=0;i<g.v;i++){
            if(visited[i]==false){
                dfsutil(g,i,visited,dp);
            }
        }
//        System.out.println(Arrays.toString(dp));
        int max=0;
        for(int i=0;i<g.v;i++){
            max=Math.max(max,dp[i]);
        }
        return max;
    }
    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        int v=s.nextInt();
        int e=s.nextInt();
        Graph g=new Graph(v);
        for(int i=0;i<e;i++){
            g.addEdge(s.nextInt()-1,s.nextInt()-1);

        }
        System.out.println(dfs(g));

    }
}


Compiler output:
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Language: Java

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;



class Graph{
    int v;//no of vertices
    ArrayList<Integer> arr[];
    Graph(int v){
        this.v=v;
        this.arr=new ArrayList[v];
        for(int i=0;i<v;i++){
            this.arr[i]=new ArrayList<Integer>();
        }


    }
    void addEdge(int a,int b){
        this.arr[a].add(b);
    }
}

public class dpdfs {
    static void dfsutil(Graph g,int s,boolean[] visited,int dp[]){
//        visited[s]=true;
//        System.out.print(s+1+" ");
        for(int i=0;i<g.arr[s].size();i++){
                dp[g.arr[s].get(i)]=Math.max(dp[g.arr[s].get(i)],dp[s]+1);
//                visited[g.arr[s].get(i)]=true;
                dfsutil(g,g.arr[s].get(i),visited,dp);

        }

    }
    static int dfs(Graph g){
        boolean visited[]=new boolean[g.v];
        int dp[]=new int[g.v];
        for(int i=0;i<g.v;i++){
            if(visited[i]==false){
                dfsutil(g,i,visited,dp);
            }
        }
//        System.out.println(Arrays.toString(dp));
        int max=0;
        for(int i=0;i<g.v;i++){
            max=Math.max(max,dp[i]);
        }
        return max;
    }
    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        int v=s.nextInt();
        int e=s.nextInt();
        Graph g=new Graph(v);
        for(int i=0;i<e;i++){
            g.addEdge(s.nextInt()-1,s.nextInt()-1);

        }
        System.out.println(dfs(g));

    }
}


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

#include<bits/stdc++.h>
#include<math.h>
//#include<vector>
//#include <iostream>
//#include <algorithm>
#include <limits>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
vector<int> G[intMAX];
int dp[intMAX];
int max(int a,int b){
	if(a>b){
		return a;

	}else{
		return b;
	}
}
/*void printdp(int N,ll Vmax){
	rep(i,N+1){
		for(ll j=0;j<Vmax+1;j++){
			if(dp[i][j]==llMAX)continue;
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}
	cout << endl;
	return;
}*/
int rec(int v){
	if(dp[v] != -1){
		return dp[v];
	}
	int res = 0;
	for(auto to :G[v]){
		res = max(res,rec(to)+1);
	}
}
int main(void){
	int N;
	int m=0;
	int M;
	int i,k;
	int j;
	int x,y;
	cin >> N>>M;
	rep(i,N)dp[i]=-1;
	rep(i,M){
		cin >> x >> y;
		x--;
		y--;
		G[x].push_back(y);
	}
	int ans = 0;
	for(i=0;i<N;i++){
		ans=max(ans,rec(i));
	}
	return 0;
}

Compiler output:
a.cc: In function 'int rec(int)':
a.cc:41:1: warning: control reaches end of non-void function [-Wreturn-type]
   41 | }
      | ^
/tmp/cc8w5phS.o: in function `rec(int)':
a.cc:(.text+0x37): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cc8w5phS.o
a.cc:(.text+0x53): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cc8w5phS.o
/tmp/cc8w5phS.o: in function `main':
a.cc:(.text+0x14d): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cc8w5phS.o
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
#include<math.h>
//#include<vector>
//#include <iostream>
//#include <algorithm>
#include <limits>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
vector<int> G[intMAX];
int dp[intMAX];
int max(int a,int b){
	if(a>b){
		return a;

	}else{
		return b;
	}
}
/*void printdp(int N,ll Vmax){
	rep(i,N+1){
		for(ll j=0;j<Vmax+1;j++){
			if(dp[i][j]==llMAX)continue;
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}
	cout << endl;
	return;
}*/
int rec(int v){
	if(dp[v] != -1){
		return dp[v];

	int res = 0;
	for(auto to :G[v]){
		res = max(res,rec(to)+1);
	}
}
int main(void){
	int N;
	int m=0;
	int M;
	int i,k;
	int j;
	int x,y;
	cin >> N>>M;
	rep(i,N)dp[i]=-1;
	rep(i,M){
		cin >> x >> y;
		x--;
		y--;
		G[x].push_back(y);
	}
	int ans = 0;
	for(i=0;i<N;i++){
		ans=max(ans,rec(i));
	}
	return 0;
}

Compiler output:
a.cc: In function 'int rec(int)':
a.cc:42:15: error: a function-definition is not allowed here before '{' token
   42 | int main(void){
      |               ^
a.cc:62:2: error: expected '}' at end of input
   62 | }
      |  ^
a.cc:33:15: note: to match this '{'
   33 | int rec(int v){
      |               ^
a.cc:62:2: warning: control reaches end of non-void function [-Wreturn-type]
   62 | }
      |  ^
Language: C++

#include<bits/stdc++.h>
#include<math.h>
//#include<vector>
//#include <iostream>
//#include <algorithm>
#include <limits>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
vector<int> G[intMAX];
int dp[intMAX];
int max(int a,int b){
	if(a>b){
		return a;

	}else{
		return b;
	}
}
void printdp(int N,ll Vmax){
	rep(i,N+1){
		for(ll j=0;j<Vmax+1;j++){
			if(dp[i][j]==llMAX)continue;
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}
	cout << endl;
	return;
}
int rec(int v){
	if(dp[v] != -1){
		return dp[v];

	int res = 0;
	for(auto to :G[v]){
		res = max(res,rec(to)+1);
	}
}
int main(void){
	int N;
	int m=0;
	int M;
	int i,k;
	int j;
	int x,y;
	cin >> N>>M;
	rep(i,N)dp[i]=-1;
	rep(i,M){
		cin >> x >> y;
		x--;
		y--;
		G[x].push_back(y);
	}
	int ans = 0;
	for(i=0;i<N;i++){
		ans=max(ans,rec(i));
	}
	return 0;
}

Compiler output:
a.cc: In function 'void printdp(int, ll)':
a.cc:25:33: error: invalid types 'int[ll {aka long long int}]' for array subscript
   25 |                         if(dp[i][j]==llMAX)continue;
      |                                 ^
a.cc:26:38: error: invalid types 'int[ll {aka long long int}]' for array subscript
   26 |                         cout << dp[i][j] << " ";
      |                                      ^
a.cc: In function 'int rec(int)':
a.cc:42:15: error: a function-definition is not allowed here before '{' token
   42 | int main(void){
      |               ^
a.cc:62:2: error: expected '}' at end of input
   62 | }
      |  ^
a.cc:33:15: note: to match this '{'
   33 | int rec(int v){
      |               ^
a.cc:62:2: warning: control reaches end of non-void function [-Wreturn-type]
   62 | }
      |  ^
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

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

int solve(int v){
	if(dp[v] != -1) return dp[v];
	int res = 0;
	for(int i=0; i<G[v].size(); i++){
		res = max(res, solve(G[v][i])+1)
	}

	return dp[v] = res;
}

int main(void){
	cin >> N >> M;
	G.assign(N, vector<int>());
	for(int i=0; i<M; i++){
		int x, y; cin >> x >> y;
		x--; y--;
		G[x].push_back(y);
	}

	fill(dp, dp+100001, -1);

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

	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int solve(int)':
a.cc:15:49: error: expected ';' before '}' token
   15 |                 res = max(res, solve(G[v][i])+1)
      |                                                 ^
      |                                                 ;
   16 |         }
      |         ~
Language: C++

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef long long int llint;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int,int>
#define pl pair<ll,ll>
const long double PI = acos(-1);
const long long INF = 1e15;
const ll DEP = (1LL << 50);
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
template<class T> inline chmax(T& a,T b){ if(a < b) {a = b; return true;} return false;}
template<class T> inline chmin(T& a,T b){ if(a > b) {a = b; return true;} return false;}
template<typename T>
T GCD(T x,T y){
    return y ? GCD(y,x%y) : x;
}
template<typename T>
string toString( const T &a ){
    ostringstream oss;
    oss << a;
    return oss.str();
};

int M_MAX = 100010;
int N,M,x,y;
int dp[100010];
vector<vector<int>> G;

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


/* 
void toporogical_sort(){
    for(int i = 0; i < v; i++){
        if(!In[i].size()) Q.push(i);
    }
    while(!Q.empty()){
        int t = Q.front(); 
        Q.pop();
        ans.push_back(t);
        for(int i = 0; i < Out[t].size(); i++){
            int nx = Out[t][i];
            int size = In[nx].size();
            for(int j = 0; j < size; j++){
                if(In[nx][j] == t){
                    In[nx].erase(In[nx].begin()+j);
                    break;
                }
            }
            if(!In[nx].size()) Q.push(nx);
        }
    }
}
*/


int main(){
    cin >> N >> M;
    G.assign(N,vector<int>());
    for(int i = 0; i < M; i++){
        cin >> x >> y;
        x--; y--;
        G[x].push_back(y);
    }
    for(int i = 0; i < N; i++) dp[i] = -1;
    int res = 0;
    for(int i = 0; i < N; i++) chmax(res,rec(i));
    cout << res << endl;
}

Compiler output:
a.cc:33:26: error: ISO C++ forbids declaration of 'chmax' with no type [-fpermissive]
   33 | template<class T> inline chmax(T& a,T b){ if(a < b) {a = b; return true;} return false;}
      |                          ^~~~~
a.cc:34:26: error: ISO C++ forbids declaration of 'chmin' with no type [-fpermissive]
   34 | template<class T> inline chmin(T& a,T b){ if(a > b) {a = b; return true;} return false;}
      |                          ^~~~~
Language: C++

//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <cmath>
#include <map>
 
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> da(n,vector<int>(0));
    vector<int> dp(n,0);
    vector<int> ju(n,0);
    for(int i=0;i<m;i++){
        int x,y;
        cin >> x >> y;
        ju[y-1]+=1;
        da[x-1].push_back(y-1);
    }
    queue<int> q;
    for(int i=0;i<n;i++){
        if(ju[i]==0){
            q.push(i);
        }
    }
    int ans=0;
    while(!q.empty()){
        int x=q.front();
        q.pop();
        for(int i=0;i<da[x].size();i++){
            ju[da[x][i]]--;
            if(dp[da[x][i]]<=dp[x]){
                ans=max(ans,dp[x]+1);
                dp[da[x][i]]=dp[x]+1;
            }
            if(ju[da[x][i]]==0){
                q.push(da[x][i]);
            }
        }
    }
    cout << ans << endl;
}//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <cmath>
#include <map>
 
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> da(n,vector<int>(0));
    vector<int> dp(n,0);
    vector<int> ju(n,0);
    for(int i=0;i<m;i++){
        int x,y;
        cin >> x >> y;
        ju[y-1]+=1;
        da[x-1].push_back(y-1);
    }
    queue<int> q;
    for(int i=0;i<n;i++){
        if(ju[i]==0){
            q.push(i);
        }
    }
    int ans=0;
    while(!q.empty()){
        int x=q.front();
        q.pop();
        for(int i=0;i<da[x].size();i++){
            ju[da[x][i]]--;
            if(dp[da[x][i]]<=dp[x]){
                ans=max(ans,dp[x]+1);
                dp[da[x][i]]=dp[x]+1;
            }
            if(ju[da[x][i]]==0){
                q.push(da[x][i]);
            }
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc:57:5: error: redefinition of 'int main()'
   57 | int main(){
      |     ^~~~
a.cc:12:5: note: 'int main()' previously defined here
   12 | int main(){
      |     ^~~~