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


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

public class Main2 {
    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = in.nextInt();
        int m = in.nextInt();
        Map<Integer, List<Integer>> paths = new HashMap<>();
        int[] dp = new int[n];
        for (int i = 0; i < m; i++) {
            int from = in.nextInt();
            int to = in.nextInt();
            paths.compute(from - 1, (integer, integers) -> {
                if (integers == null) {
                    integers = new ArrayList<>();
                }
                integers.add(to - 1);
                return integers;
            });
        }
        boolean[] visited = new boolean[n];
        for (int i = 0; i < n; i++) {
            if (!visited[i]) {
                dfs(i, visited, paths, dp);
            }
        }

        int result = Integer.MIN_VALUE;
        for (int j = 0; j < n; j++) {
            result = Math.max(result, dp[j]);
        }
        System.out.println(result);
    }

    private static void dfs(int from, boolean[] visited, Map<Integer, List<Integer>> paths, int[] dp) {
        final List<Integer> tos = paths.getOrDefault(from, Collections.emptyList());
        for (Integer to : tos) {
            if (!visited[to]) {
                dfs(to, visited, paths, dp);
            }
        }
        for (Integer to : tos) {
            dp[from] = Math.max(dp[from], dp[to] + 1);
        }
    }
}


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

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

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

		final int max_node = 100005;

		int[] dist = new int[max_node]; 
		ArrayList<Integer>[] edges = new ArrayList[max_node];
		int[] in_degree = new int[max_node];
		boolean[] visited = new boolean[max_node];

		for (int i = 0; i < max_node; i++) { 
			edges[i] = new ArrayList<Integer>(); 
		}

	//	System.out.println("Enter "+m+" edges");
		for(int i = 0; i < m ; ++i){
			int x = in.nextInt();
			int y = in.nextInt();
			in_degree[y]++;

			edges[x].add(y);
		}

		LongestPathDAG graph = new LongestPathDAG();

		for(int i =1; i<n; i++){
			if(visited[i] == false && in_degree[i] == 0){
				graph.dfs(i,edges, visited, in_degree, dist);
			}
		}

		int answer = 0;
		for(int i = 1; i < max_node; ++i){
			if(dist[i] > answer){
				answer = dist[i];
			}
		}
		
		System.out.println(answer);


	}

	private void dfs(int node,ArrayList<Integer>[] edges, boolean[] visited, int[] in_degree, int[] dist){
		if(visited[node] == true){
			return;
		}
		visited[node] = true;
		for(int edge : edges[node]){
			in_degree[edge]--;
			dist[edge] = Math.max(dist[edge], dist[node]+1);
			if(in_degree[edge] == 0){
				dfs(edge, edges, visited, in_degree, dist);
			}
		}
	}

}


Compiler output:
Main.java:30: error: cannot find symbol
		LongestPathDAG graph = new LongestPathDAG();
		^
  symbol:   class LongestPathDAG
  location: class Main
Main.java:30: error: cannot find symbol
		LongestPathDAG graph = new LongestPathDAG();
		                           ^
  symbol:   class LongestPathDAG
  location: class Main
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
Language: Java

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

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

		final int max_node = 100005;

		int[] dist = new int[max_node]; 
		ArrayList<Integer>[] edges = new ArrayList[max_node];
		int[] in_degree = new int[max_node];
		boolean[] visited = new boolean[max_node];

		for (int i = 0; i < max_node; i++) { 
			edges[i] = new ArrayList<Integer>(); 
		}

	//	System.out.println("Enter "+m+" edges");
		for(int i = 0; i < m ; ++i){
			int x = in.nextInt();
			int y = in.nextInt();
			in_degree[y]++;

			edges[x].add(y);
		}

		LongestPathDAG graph = new LongestPathDAG();

		for(int i =1; i<n; i++){
			if(visited[i] == false && in_degree[i] == 0){
				graph.dfs(i,edges, visited, in_degree, dist);
			}
		}

		int answer = 0;
		for(int i = 1; i < max_node; ++i){
			if(dist[i] > answer){
				answer = dist[i];
			}
		}
		
		System.out.println(answer);


	}

	private void dfs(int node,ArrayList<Integer>[] edges, boolean[] visited, int[] in_degree, int[] dist){
		if(visited[node] == true){
			return;
		}
		visited[node] = true;
		for(int edge : edges[node]){
			in_degree[edge]--;
			dist[edge] = Math.max(dist[edge], dist[node]+1);
			if(in_degree[edge] == 0){
				dfs(edge, edges, visited, in_degree, dist);
			}
		}
	}

}


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

#include <bits/stdc++.h>
#include "../cxx-prettyprint/prettyprint.hpp" // vecの内容をきれいに表示

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)

// 今回は関数でdpテーブルをいじるのでグローバル
vector<int> dp(100001,0);
vector<bool> flg(100001, false);
vector< vector<int> > A(100001);

int fans; // 経路の長さ

int f(int x){
	if(A[x].size() == 0) return 0;
	// すでに探索完了ならその値を返す
	if(flg[x]) return dp[x];
	flg[x] = true;
	// 探索
	fans = 0;
	for(const auto& y : A[x]){
		fans = max(fans, f(y)+1);
	}
	return dp[x] = fans;
}

int main(){
// ここに処理を記述

	int N, M;
	cin >> N >> M;

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

	// cout << A << "\n";

	// DAG(閉路なし有向グラフ)はトポロジカルソートでDP可能性あり
	// 今回はそうじゃなくてメモ化再帰で記述
	// f(x) : xを始点とする最長経路
	// f(x) = 0(xの行先なし) or max(f(y)+1|x->yが存在するy)
	// この時答えはmax(f(x))
	int ans = 0;
	FOR(i,1,N+1){
		if(!flg[i]) ans = max(ans,f(i));
	}

	cout << ans << "\n";

return 0;
}

Compiler output:
a.cc:2:10: fatal error: ../cxx-prettyprint/prettyprint.hpp: No such file or directory
    2 | #include "../cxx-prettyprint/prettyprint.hpp" // vecの内容をきれいに表示
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#include "../cxx-prettyprint/prettyprint.hpp" // vecの内容をきれいに表示

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)

// 今回は関数でdpテーブルをいじるのでグローバル
vector<int> dp(100001,0);
vector<bool> flg(100001, false);
vector< vector<int> > A(100001);

int fans; // 経路の長さ

int f(int x){
	// すでに探索完了ならその値を返す
	if(flg[x]) return dp[x];
	flg[x] = true;
	// 探索
	fans = 0;
	for(const auto& y : A[x]){
		fans = max(fans, f(y)+1);
	}
	return dp[x] = fans;
}

int main(){
// ここに処理を記述

	int N, M;
	cin >> N >> M;

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

	// cout << A << "\n";

	// DAG(閉路なし有向グラフ)はトポロジカルソートでDP可能性あり
	// 今回はそうじゃなくてメモ化再帰で記述
	// f(x) : xを始点とする最長経路
	// f(x) = 0(xの行先なし) or max(f(y)+1|x->yが存在するy)
	// この時答えはmax(f(x))
	int ans = 0;
	FOR(i,1,N+1){
		if(!flg[i]) ans = max(ans,f(i));
	}

	cout << ans << "\n";

return 0;
}

Compiler output:
a.cc:2:10: fatal error: ../cxx-prettyprint/prettyprint.hpp: No such file or directory
    2 | #include "../cxx-prettyprint/prettyprint.hpp" // vecの内容をきれいに表示
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <vector>
#include<queue>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;

vector<vector<int>> G;
vector<int> deg;

int dp[100100];

int main() {
	int n, m;
	cin >> n >> m;
	G.assign(n, vector<int>());
	deg.assign(n, 0);
	for (int i = 0;i < m;i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		G[x].push_back(y);
		deg[y]++;
	}
	queue<int> que;
	for (int v = 0;v < n;v++)if (deg[v] == 0)que.push(v);

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

	int res = 0;
	for (int v = 0;v < n;v++)chmax(res, dp[v]);
	cout << res << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:29: error: invalid use of member function 'std::queue<int>::front' (did you forget the '()' ?)
   30 |                 int v = que.front.que.pop();
      |                         ~~~~^~~~~
Language: C++

//#include "pch.h"
#include "stdafx.h"
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstring>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define INF				2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define MIN(a, b)		((a) < (b) ? a : b)
#define MAX(a, b)		((a) > (b) ? a : b)
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)		/* 奇数 */
#define IsEven(x)		(!IsOdd((x)))					/* 偶数 */
#define ArrayLength(x)	(sizeof(x) / sizeof(x[0]))
#define DWORD_MAX		(0xFFFFFFFF)

typedef short SWORD;
typedef unsigned short WORD;
typedef long SDWORD;
typedef unsigned long DWORD;
typedef long long int QWORD;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
#define N_MAX	(1000 * 100 + 1)
#define M_MAX	(1000 * 100 + 1)
int x[N_MAX];
int y[N_MAX];
int dp[N_MAX];
int N, M;

/* メイン */
int main()
{
	cin >> N >> M;
	REP(z, M) cin >> x[z] >> y[z];

	int i;
	for (i = 0; i < M; i++) {
		dp[y[i]] = MAX(dp[x[i]] + 1, dp[y[i]]);
	}

	int maxCnt = 0;
	for (i = 0; i <= N; i++) {
		maxCnt = MAX(maxCnt, dp[i]);
	}
	cout << maxCnt;
	cout << endl;
	return 0;
}



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

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

void dfs(vector<vector<int>> &adj,vector<int> &dp, vector<int> &visit, int u)
{
    visit[u]=1;
    for(int tt : adj[u])
    {
        if(visit[tt]==0)
        {
            dfs(adj,dp,visit,tt);
        }
      	dp[u] = max(dp[u],1+dp[tt]);
    }
}
int main() {
	// your code goes here
	int n;
	int m;
	cin>>n>>m;
	int u,v;
	vector<int> visit(n,0);
	vector<vector<int>> adj(n);
	for(int i=0;i<m;i++)
	{
	    cin>>u>>v;
	    u--,v--;
	    adj[u].push_back(v);
	}
	vector<int> dp(n,0);
	for(int i=0;i<n;i++)
	{
	    if(visit[i]==0)
	    {
	        dfs(adj,dp,visit,i)
	    }
	}
	int ans=INT_MIN;
    for(int i=0;i<n;i++)
	{
	    ans = max(ans,dp[i]);
	}
	cout<<ans;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:36: error: expected ';' before '}' token
   35 |                 dfs(adj,dp,visit,i)
      |                                    ^
      |                                    ;
   36 |             }
      |             ~
Language: C++

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

int main(){
	int n,m;
	cin>>n>>m;
	vector<vector<int>> edges(n+1);
	vector<int> in_degree(n+1);
	vector<int> dist(n+1);
	vector<int> visited(n+1);

	for(int i = 0; i < m; i++){
		int a,b;
		scanf("%d%d",&a,&b);
		edges[a].push_back(b);
		in_degree[b]++;
	}

	for(int iter = 1; iter <= n; iter++){
		bool flag = false;
		int node = 1;
		while(node <= n){
			int l = node;
			if(visited[node] == false && in_degree[node] == 0){
				visited[node] = true;
				in_degree[node]--;
				for(int k = 0; k < edges[node].size(); k++){
					in_degree[edges[node][k]]--;
					dist[edges[node][k]] = max(dist[edges[node][k]], dist[node]+1);
					flag = true;
					if(in_degree[edges[j][k]] == 0)
						node = edges[j][k];
				}
			}
			if(node == l)
				node++;
		}

		if(flag == false)
			break;
	}
	int answer = 0;
	for(int i = 1; i <= n; i++){
		answer = max(answer, dist[i]);
	}
	cout<<answer<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:60: error: 'j' was not declared in this scope
   31 |                                         if(in_degree[edges[j][k]] == 0)
      |                                                            ^
Language: Java

import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class G1 {


    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        int m = std.nextInt();
        int[] from = new int[m];
        int[] to = new int[m];
        long dp[] = new long[n];
        for (int i = 0; i < m; i++) {
            from[i] = std.nextInt() - 1;
            to[i] = std.nextInt() - 1;
        }

        Deque<Integer> deque = new ArrayDeque<>();
        long ans = 0;
        boolean[] visited = new boolean[n];
        for (int k = 0; k < n; k++) {
            if (visited[k]) {
                continue;
            }
            deque.add(k);
            while (!deque.isEmpty()) {
                int v = deque.poll();
                visited[v] = true;
                for (int i = 0; i < m; i++) {
                    int f = from[i];
                    if (f == v) {
                        int t = to[i];
                        long cost = dp[v] + 1;

                        dp[t] = Math.max(dp[t], cost);
                        if (!deque.contains(t)) {
                            deque.add(t);
                        }
                    }
                }
            }
        }

        ans = Math.max(Arrays.stream(dp).max().getAsLong(), ans);
        System.out.println(ans);
    }
}


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

package com.dp_training;

import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class G1 {
    static int dp[] = new int[100000];

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

        for (int i = 0; i < m; i++) {
            from[i] = std.nextInt() - 1;
            to[i] = std.nextInt() - 1;
        }

        PriorityQueue<Integer> deque = new PriorityQueue<>(n);
        long ans = 0;
        boolean[] visited = new boolean[n];
        for (int k = 0; k < n; k++) {
            if (!visited[k]) {
                deque.add(k);
            }
            while (!deque.isEmpty()) {
                int v = deque.poll();
                visited[v] = true;
                for (int i = 0; i < m; i++) {
                    int f = from[i];
                    if (f == v) {
                        int t = to[i];
                        int cost = dp[v] + 1;

                        dp[t] = Math.max(dp[t], cost);
                        if (!deque.contains(t)) {
                            deque.add(t);
                        }
                    }
                }
            }
            ans = Math.max(Arrays.stream(dp).max().getAsInt(), ans);
        }

        System.out.println(ans);
    }
}


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

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

int N, M, a, b, ans;
vector<int> V[100100];
int dp[100100];

int f(int a) {
	if (V[a].size() == 0) return 0;
	if (dp[a] != -1) return dp[a];
	int dp[a] = 0;
	for(int i=0; i<V[a].size(); i++) {
		int b = V[a][i];
		dp[a] = max(dp[a], f(b)+1);
	}
	return dp[a];
}

int main() {
	cin >> N >> M;
	for(int i=0; i<=N; i++) {
		cin >> a >> b;
		V[a].push_back(b);
	}
	memset(dp, -1, sizeof(dp));
	for(int i=1; i<=N; i++) {
		ans = max(ans, f(i));
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int f(int)':
a.cc:11:21: error: array must be initialized with a brace-enclosed initializer
   11 |         int dp[a] = 0;
      |                     ^
Language: C++

#include<chrono>
#include<random>
#include <iostream>
using namespace std;
using namespace chrono;
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef vector<string> vs;
template<class T1, class T2>
istream& operator>>(istream& in, pair<T1, T2>& P) {
	in >> P.first >> P.second;
	return in;
}
template<class T1, class T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& P) {
	out << "(" << P.first << ", " << P.second << ")";
	return out;
}
template<class T>
istream& operator>>(istream& in, vector<T>& arr) {
	for (auto& x : arr) in >> x;
	return in;
}
template<class T>
ostream& operator<<(ostream & out, const vector<T> & arr) {
	for (auto& x : arr) out << x << ' '; cout << "\n";
	return out;
}
mt19937 rnd(time(0));

int n; // number of vertices
vector<vector<int>> adj; // adjacency list of graph
vector<bool> visited;
vector<int> ans;

void dfs(int v) {
	visited[v] = true;
	for (int u : adj[v]) {
		if (!visited[u])
			dfs(u);
	}
	ans.push_back(v);
}

void topological_sort() {
	visited.assign(n, false);
	ans.clear();
	for (int i = 0; i < n; ++i) {
		if (!visited[i])
			dfs(i);
	}
	reverse(ans.begin(), ans.end());
}

int main() {

	int m;

	cin >> n >> m;
	
	int x, y;

	vector<int> d;
	vector<int> p;

	adj.assign(n, vector<int>());
	// dp.assign(n + 1, vector<vector<int>>());

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

	topological_sort();

	vi dp(n);

	for (auto i : ans) {
		for (auto v : adj[i]) {
			dp[v] = max(dp[i] + 1, dp[v]);
		}
	}

	cout << *max_element(dp.begin(), dp.end()) << "\n";


	return 0;

}








Compiler output:
a.cc: In function 'void topological_sort()':
a.cc:58:9: error: 'reverse' was not declared in this scope
   58 |         reverse(ans.begin(), ans.end());
      |         ^~~~~~~
a.cc: In function 'int main()':
a.cc:90:18: error: 'max_element' was not declared in this scope
   90 |         cout << *max_element(dp.begin(), dp.end()) << "\n";
      |                  ^~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

#include "utils.cpp"

vector<int> memo(100001, -1);
using Graph = vector<vector<int>>;

int dp(Graph g, int start_node) {
    if (memo[start_node] != -1) return memo[start_node];
    int longest = 0;
    for(auto node : g[start_node]) {
        longest = max(dp(g, node) + 1, longest);
    }
    memo[start_node] = longest;
    return memo[start_node];
}

int main() {
    int n, m;
    cin >> n >> m;
    Graph g(n);
    for(int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        g[x-1].push_back(y-1);
    }
    int res = 0;
    for(int i = 0; i < n; i++) {
        res = max(dp(g, i), res);
    }
    cout << res << endl;
    return 0;
}

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

#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(false), cin.tie(NULL);
 
using namespace std;
int main(){
  int v, e;
  cin>>v>>e;
  vector<vector<int>> out(v);
  vector<vector<int>> in(v);
  for(int i =0; i<e; i++){
    int a, b;
    cin>>a>>b;
    out[a-1].push_back(b-1);
    in[b-1].push_back(a-1);
    
  }
  vector<int> dp(v,0);
  vector<int> deg(v); //number of edges from vertex i to other
  queue<int> s;
  for(int i =0; i<v; i++){
    deg[i]=out[i].size();
    if(!deg[i]){
      s.push(i);
    }
  }
  int mx = 0;
  while(s.size()){
    int j = s.front();
    s.pop();
    for(int i : in[j]){
      if(deg[i]>0){
        dp[i] = max(1+dp[j], dp[i]);
        deg[i]--;
        if(deg[i]==0) s.push(i);
        mx = max(mx, dp[i]);
      }
    }
    cout<<mx<<endl;
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:2: error: expected '}' at end of input
   40 | }
      |  ^
a.cc:5:11: note: to match this '{'
    5 | int main(){
      |           ^
Language: C

// Author - Sumit

#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define int ll
#define ps push
#define pb push_back
#define INF 1000000005
#define MOD 1000000007
#define mp make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
#define repd(i,a,b) for (int i = a; i >= b; i--)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pair<int,int>>
#define itr :: iterator it
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

const int N=1e5+5;
vi v[N];
bool vis[N];
int dis[N];

void dfs(int p){
    // cout<<p<<" ";
    vis[p]=true;
    for(auto x:v[p]){
        dis[x] = max(dis[x],dis[p]+1);
        if(!vis[x])
            dfs(x);
    }
}


void solve(){
    int n,m;
    cin>>n>>m;
    rep(i,0,m){
        int x,y;
        cin>>x>>y;
        v[x].pb(y);
    }
    rep(i,1,n+1){
        if(!vis[i])
            dfs(i);
    }
    int res=0;
    // rep(i,1,n){
    //     cout<<dis[i]<<" ";
    // }
    rep(i,1,n){
        res = max(res,dis[i]);
    }
    debug(res+1);
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);


    int t=1;
    // cin>>t;
    WL(t){
        solve();
    }    
}

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

#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

vector<int> ed[200000];

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

int main()
{
  int n=0,m=0;scanf("%d%d",&n,&m);for(int i=1,a=0,b=0;i<=m;i++){scanf("%d%d",&a,&b);ed[a].push_back(b);}
  for(int i=1;i<=n;i++)if(!dp[i])dfs(i);
  int maxn=0;for(int i=1;i<=n;i++)maxn=max(maxn,dp[i]);printf("%d,maxn);
  return 0;
}

Compiler output:
a.cc:21:63: warning: missing terminating " character
   21 |   int maxn=0;for(int i=1;i<=n;i++)maxn=max(maxn,dp[i]);printf("%d,maxn);
      |                                                               ^
a.cc:21:63: error: missing terminating " character
   21 |   int maxn=0;for(int i=1;i<=n;i++)maxn=max(maxn,dp[i]);printf("%d,maxn);
      |                                                               ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:22:3: error: expected primary-expression before 'return'
   22 |   return 0;
      |   ^~~~~~
Language: C++

#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>

using namespace std;

void dfs(int i, int n, vector<int> g[n], int dp[n], int vis[n])
{
  vis[i] = 1;
  for (int x: g[i])
  {
    if (!vis[x])
      dfs(x, n, g, dp, vis);
    dp[i] = max(dp[i], 1 + dp[x]);
  }
}

int main()
{
  ios::sync_with_stdio(false);cin.tie(0);
  int n, m, x, y;
  cin >> n >> m;
  vector<int> g[100005];
  for (int i = 0; i < m; i++)
  {
    cin >> x >> y;
    g[x - 1].push_back(y - 1);
  }
  int dp[100005] = {0};
  int vis[100005] = {0};
  for (int i = 0; i < n; i++)
  {
    if (!vis[i])
      dfs(i, n, g, dp, vis);
  }
  cout << *max_element(dp, dp + n) ;
  return 0;
}


Compiler output:
a.cc:34:39: error: use of parameter outside function body before ']' token
   34 | void dfs(int i, int n, vector<int> g[n], int dp[n], int vis[n])
      |                                       ^
a.cc:34:40: error: expected ')' before ',' token
   34 | void dfs(int i, int n, vector<int> g[n], int dp[n], int vis[n])
      |         ~                              ^
      |                                        )
a.cc:34:42: error: expected unqualified-id before 'int'
   34 | void dfs(int i, int n, vector<int> g[n], int dp[n], int vis[n])
      |                                          ^~~
Language: Java

import java.util.*;
public class G_LongestPath{
  static int dp[];
  static List<Integer> list[];
  static int solve(int i){
    int ret = 0;
    if (dp[i] != - 1) return dp[i];
    else{
      for (int j = 0; j < list[i].size(); j++) {
        ret = Math.max(ret, solve(list[i].get(j)) + 1);
//        System.out.println(ret + " ret inside");
      }
    }
    return dp[i] = ret;
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    list = new LinkedList[n + 1];
    for (int i = 0; i <= n; i++)
      list[i] = new LinkedList<>();
    for (int i = 0; i < m; i++) {
      list[sc.nextInt()].add(sc.nextInt());
    }
    int ret = 0;
    dp = new int[n + 1];
    Arrays.fill(dp, -1);
    for (int i = 1; i <= n; i++){
      ret = Math.max(ret, solve(i));
//      System.out.println(ret + " ret");
    }
    System.out.println(ret);
  }
}


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

#include <iostream>
#include <set>
#include <cstring>
#include <vector>
using namespace std;

// dp[i]: 根からの最長距離

int dp[100010];
vector<int> path[100010];
set<int> sx, sy, end_nodes;

int dfs(int cur) {
    if(dp[cur] >= 0) return dp[cur];
    if(path[cur].size() == 0) {
        return dp[cur] = 0;
    }

    int ret = 0;
    for(int next: path[cur]) {
        ret = max(ret, 1 + dfs(next));
    }

    return dp[cur] = ret;
}

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

    for(int i = 0; i < M; ++i) {
        int x, y;
        scanf("%d%d", &x, &y);
        x--, y--;
        path[y].push_back(x);
        sx.insert(x);
        sy.insert(y);
    }

    memset(dp, -1, sizeof dp);

    std::set_difference(sy.begin(), sy.end(), sx.begin(), sx.end(), std::inserter(end_nodes, end_nodes.end()));

    int ret = 0;
    for(auto end: end_nodes) {
        ret = max(ret, dfs(end));
    }

    cout << ret << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:10: error: 'set_difference' is not a member of 'std'
   42 |     std::set_difference(sy.begin(), sy.end(), sx.begin(), sx.end(), std::inserter(end_nodes, end_nodes.end()));
      |          ^~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>


using namespace std;
#define max 999999
vector<int>edges[max];
int in_Degree[max];
int dist[max];
bool vis[max];
void dfs(int a){
assert(!vis[a]);
vis[a]=1;
for(auto b:edges[a]){
	dist[b]=max(dist[b],dist[a]+1);
	--in_Degree[b];
	if(in_Degree[b]==0)
		dfs(b);
}
}





int main()
{
int n,m;
cin>>n>>m;
while(m--)
{int a,b;
	cin>>a>>b;
	edges[a].push_back(b);
	++in_Degree[b];
} 
for(int i=1;i<=n;i++)
	if(!vis[i] && in_Degree[i]==0)
	dfs(i);

int an=0;
for(int i=1;i<=n;i++)
	an=max(an,dist[i]);

cout<<an;
return 0;
}

Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:14:20: error: expression cannot be used as a function
   14 |         dist[b]=max(dist[b],dist[a]+1);
      |                    ^
a.cc: In function 'int main()':
a.cc:41:15: error: expression cannot be used as a function
   41 |         an=max(an,dist[i]);
      |               ^
Language: C++

#include <bits/stdc++.h>


using namespace std;
#define max 999999
vector<int>edges(max);
int in_Degree[max];
int dist[max];
bool vis[max];
void dfs(int a){
assert(!vis[a]);
vis[a]=1;
for(auto b:edges[a]){
	dist[b]=max(dist[b],dist[a]+1);
	--in_Degree[b];
	if(in_Degree[b]==0)
		dfs(b);
}
}





int main()
{
int n,m;
cin>>n>>m;
while(m--)
{int a,b;
	cin>>a>>b;
	edges[a].push_back(b);
	++in_Degree[b];
} 
for(int i=1;i<=n;i++)
	if(!vis[i] && in_Degree[i]==0)
	dfs(i);

int an=0;
for(int i=1;i<=n;i++)
	an=max(an,dist[i]);

cout<<an;
return 0;
}

Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:13:19: error: 'begin' was not declared in this scope
   13 | for(auto b:edges[a]){
      |                   ^
a.cc:13:19: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
                 from a.cc:1:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:13:19: error: 'end' was not declared in this scope
   13 | for(auto b:edges[a]){
      |                   ^
a.cc:13:19: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~
a.cc:14:20: error: expression cannot be used as a function
   14 |         dist[b]=max(dist[b],dist[a]+1);
      |                    ^
a.cc: In function 'int main()':
a.cc:32:18: error: request for member 'push_back' in 'edges.std::vector<int>::operator[](((std::vector<int>::size_type)a))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   32 |         edges[a].push_back(b);
      |                  ^~~~~~~~~
a.cc:41:15: error: expression cannot be used as a function
   41 |         an=max(an,dist[i]);
      |               ^
Language: C++

#include <bits/stdc++.h>


using namespace std;
#define max 999999
vector<int>edges;
int in_Degree[max];
int dist[max];
bool vis[max];
void dfs(int a){
assert(!vis[a]);
vis[a]=1;
for(auto b:edges[a]){
	dist[b]=max(dist[b],dist[a]+1);
	--in_Degree[b];
	if(in_Degree[b]==0)
		dfs(b);
}
}





int main()
{
int n,m;
cin>>n>>m;
while(m--)
{int a,b;
	cin>>a>>b;
	edges[a].push_back(b);
	++in_Degree[b];
} 
for(int i=1;i<=n;i++)
	if(!vis[i] && in_Degree[i]==0)
	dfs(i);

int an=0;
for(int i=1;i<=n;i++)
	an=max(an,dist[i]);

cout<<an;
return 0;
}

Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:13:19: error: 'begin' was not declared in this scope
   13 | for(auto b:edges[a]){
      |                   ^
a.cc:13:19: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
                 from a.cc:1:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:13:19: error: 'end' was not declared in this scope
   13 | for(auto b:edges[a]){
      |                   ^
a.cc:13:19: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~
a.cc:14:20: error: expression cannot be used as a function
   14 |         dist[b]=max(dist[b],dist[a]+1);
      |                    ^
a.cc: In function 'int main()':
a.cc:32:18: error: request for member 'push_back' in 'edges.std::vector<int>::operator[](((std::vector<int>::size_type)a))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   32 |         edges[a].push_back(b);
      |                  ^~~~~~~~~
a.cc:41:15: error: expression cannot be used as a function
   41 |         an=max(an,dist[i]);
      |               ^
Language: C++

#include <bits/stdc++.h>


using namespace std;
#define max 999999
vector<int>edges;
int in_Degree[max];
int dist[max];
bool vis[max];
void dfs(int a){
assert(!vis[a]);
vis[a]=1;
for(int b:edges[a]){
	dist[b]=max(dist[b],dist[a]+1);
	--in_Degree[b];
	if(in_Degree[b]==0)
		dfs(b);
}
}





int main()
{
int n,m;
cin>>n>>m;
while(n--)
{int a,b;
	cin>>a>>b;
	edges[a].push_back(b);
	++in_Degree[b];
} 
for(int i=1;i<=n;i++)
	if(!vis[i] && in_Degree[i]==0)
	dfs(i);

int an=0;
for(int i=1;i<=n;i++)
	an=max(an,dist[i]);

cout<<an;
return 0;
}

Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:13:18: error: 'begin' was not declared in this scope
   13 | for(int b:edges[a]){
      |                  ^
a.cc:13:18: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
                 from a.cc:1:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:13:18: error: 'end' was not declared in this scope
   13 | for(int b:edges[a]){
      |                  ^
a.cc:13:18: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~
a.cc:14:20: error: expression cannot be used as a function
   14 |         dist[b]=max(dist[b],dist[a]+1);
      |                    ^
a.cc: In function 'int main()':
a.cc:32:18: error: request for member 'push_back' in 'edges.std::vector<int>::operator[](((std::vector<int>::size_type)a))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   32 |         edges[a].push_back(b);
      |                  ^~~~~~~~~
a.cc:41:15: error: expression cannot be used as a function
   41 |         an=max(an,dist[i]);
      |               ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
vector<vector<int>>to(100000);
typedef long long l
l dp(l i){
l res=0;//初期値
  for (l b:to.at(i)){//bにはiにつながる要素を当てる
	res=max(res,dp(b)+1);
  }
return res;
}
/*i=0  3               
1     2
2     0
3     1
 4    4

0(3 2)
1(2 3)
2(0)
3(2)
4(2 1 0)*/


int main(){
//入力は同じでいい
  l N,M;
  cin >>N>>M;
   
for(l i= 0;i<M;i++){
  l a,b;
  	cin >>a>>b;
  --a;
  --b;
  //0番目からのスタートにしたいから。
  to.at(a).push_back(b);
 //これで木の入力は済んだはず
}
 priority_queue<l>q;
 for (l i=0;i<N;i++){
   //cout <<dp(i)<<endl;//dpを出力させる
   q.push(dp(i));//ここでdp(i)はi番目出発の最長経路を表す数値 or 戻り値でそれを返す関数。
 }
 cout <<q.top()<<endl; 
}


Compiler output:
a.cc:5:1: error: expected initializer before 'l'
    5 | l dp(l i){
      | ^
a.cc: In function 'int main()':
a.cc:27:3: error: 'l' was not declared in this scope
   27 |   l N,M;
      |   ^
a.cc:28:9: error: 'N' was not declared in this scope
   28 |   cin >>N>>M;
      |         ^
a.cc:28:12: error: 'M' was not declared in this scope
   28 |   cin >>N>>M;
      |            ^
a.cc:30:6: error: expected ';' before 'i'
   30 | for(l i= 0;i<M;i++){
      |      ^~
      |      ;
a.cc:30:12: error: 'i' was not declared in this scope
   30 | for(l i= 0;i<M;i++){
      |            ^
a.cc:31:4: error: expected ';' before 'a'
   31 |   l a,b;
      |    ^~
      |    ;
a.cc:32:15: error: 'a' was not declared in this scope
   32 |         cin >>a>>b;
      |               ^
a.cc:32:18: error: 'b' was not declared in this scope
   32 |         cin >>a>>b;
      |                  ^
a.cc:39:18: error: template argument 2 is invalid
   39 |  priority_queue<l>q;
      |                  ^
a.cc:39:18: error: template argument 3 is invalid
a.cc:40:8: error: expected ';' before 'i'
   40 |  for (l i=0;i<N;i++){
      |        ^~
      |        ;
a.cc:40:13: error: 'i' was not declared in this scope
   40 |  for (l i=0;i<N;i++){
      |             ^
a.cc:42:6: error: request for member 'push' in 'q', which is of non-class type 'int'
   42 |    q.push(dp(i));//ここでdp(i)はi番目出発の最長経路を表す数値 or 戻り値でそれを返す関数。
      |      ^~~~
a.cc:42:11: error: 'dp' was not declared in this scope; did you mean 'dup'?
   42 |    q.push(dp(i));//ここでdp(i)はi番目出発の最長経路を表す数値 or 戻り値でそれを返す関数。
      |           ^~
      |           dup
a.cc:44:11: error: request for member 'top' in 'q', which is of non-class type 'int'
   44 |  cout <<q.top()<<endl;
      |           ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
//# define pair<int,int>  pi
void get(vector<vector<int> >& g,int i,vector<int>& dp)
{  int n=g.size();
   dp[i]=0;
  for(auto& k:g[i])
  {dp[k]==-1)
     get(g,k,dp);
    
  dp[i]=max(dp[i],dp[k]+1);
    
    
}
 
  
 
}
int main()
{
  int n,m;
  cin>>n>>m;
  int k1,k2;
  vector<vector<int> > g(n+1);
  for(int i=0;i<m;i++)
  { cin>>k1>>k2;
   g[k1].push_back(k2);
   }
  int max1=INT_MIN;
  int c;
// vector<bool> vis(n+1,false);
 vector<int> dp(n+1,-1);
  for(int i=1;i<=n;i++)
  { if(dp[i]==-1)
    get(g,i,dp);
   
  }
  
 int d=*max_element(dp.begin(),dp.end());
   cout<<d;
  
}


Compiler output:
a.cc: In function 'void get(std::vector<std::vector<int> >&, int, std::vector<int>&)':
a.cc:8:13: error: expected ';' before ')' token
    8 |   {dp[k]==-1)
      |             ^
      |             ;
Language: C++

#include<bits/stdc++.h>
using namespace std;
//# define pair<int,int>  pi
void get(vector<vector<int> >& g,int i, vector<int>& vis,vector<int>& dp)
{  int n=g.size();
   dp[i]=0;
  for(auto& k:g[i])
  {dp[k]==-1)
     get(g,k,vis,dp);
    
  dp[i]=max(dp[i],dp[k]+1);
    
    
}
 
  
 
}
int main()
{
  int n,m;
  cin>>n>>m;
  int k1,k2;
  vector<vector<int> > g(n+1);
  for(int i=0;i<m;i++)
  { cin>>k1>>k2;
   g[k1].push_back(k2);
   }
  int max1=INT_MIN;
  int c;
// vector<bool> vis(n+1,false);
 vector<int> dp(n+1,-1);
  for(int i=1;i<=n;i++)
  { if(dp[i]==-1)
    get(g,i,vis,dp);
   
  }
  
 int d=*max_element(dp.begin(),dp.end());
   cout<<d;
  
}


Compiler output:
a.cc: In function 'void get(std::vector<std::vector<int> >&, int, std::vector<int>&, std::vector<int>&)':
a.cc:8:13: error: expected ';' before ')' token
    8 |   {dp[k]==-1)
      |             ^
      |             ;
a.cc: In function 'int main()':
a.cc:35:13: error: 'vis' was not declared in this scope
   35 |     get(g,i,vis,dp);
      |             ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
//# define pair<int,int>  pi
int get(vector<vector<int> >& g,int i)
{  int n=g.size();
  vector<int> vis(n,INT_MIN);
  vis[i]=0;
 queue<pair<int,int>> q;
 q.push({i,0});
 while(!q.empty())
 {
   pair<int,int> p=q.front();
   q.pop();
   int k=p.first;
   int c=p.second;
   vis[k]=max(vis[k],c);
   for(int j=0;j<g[k].size();j++)
   {
     if(vis[g[k][j]]==INT_MIN)
     q.push({g[k][j],c+1});
     else if(vis[g[k][j]]<vis[k]+1)
     q.push({g[k][j],vis[k]+1});  
    }
   
  int c=*max_element(vis.begin(),vis.end());
   return c;
   }
  
  
  
}
int main()
{
  int n,m;
  cin>>n>>m;
  int k1,k2;
  vector<vector<int> > g(n+1);
  for(int i=0;i<m;i++)
  { cin>>k1>>k2;
   g[k1].push_back(k2);
   }
  int max1=INT_MIN;
  for(int i=1;i<=n;i++)
  {
    int c=get(g,i);
    if(c>max1)
      max1=c;
    
    
  }
  
  cout<<max1;
  
}

Compiler output:
a.cc: In function 'int get(std::vector<std::vector<int> >&, int)':
a.cc:25:7: error: redeclaration of 'int c'
   25 |   int c=*max_element(vis.begin(),vis.end());
      |       ^
a.cc:15:8: note: 'int c' previously declared here
   15 |    int c=p.second;
      |        ^
a.cc:31:1: warning: control reaches end of non-void function [-Wreturn-type]
   31 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
# define pair<int,int>  pi
int get(vector<vector<int> >& g,int i)
{  int n=g.size();
  vector<int> vis(n,INT_MIN);
  vis[i]=0;
 queue<pi> q;
 q.push({i,0});
 while(!q.empty())
 {
   pi p=q.front();
   q.pop();
   int k=p.first;
   int c=p.second;
   vis[k]=max(vis[k],c);
   for(int j=0;j<g[k].size();j++)
   {
     if(vis[g[k][j]]==INT_MIN)
     q.push({g[k][j],c+1});
     else if(vis[g[k][j]]<vis[k]+1)
     q.push({g[k][j],vis[k]+1});  
    }
   
  int c=*max_element(vis.begin(),vis.end());
   return c;
   }
  
  
  
}
int main()
{
  int n,m;
  cin>>n>>m;
  int k1,k2;
  vector<vector<int> > g(n+1);
  for(int i=0;i<m;i++)
  { cin>>k1>>k2;
   g[k1].push_back(k2);
   }
  int max1=INT_MIN;
  for(int i=1;i<=n;i++)
  {
    int c=get(g,i);
    if(c>max1)
      max1=c;
    
    
  }
  
  cout<<max1;
  
}

Compiler output:
a.cc:3:10: warning: ISO C++11 requires whitespace after the macro name
    3 | # define pair<int,int>  pi
      |          ^~~~
a.cc: In function 'int get(std::vector<std::vector<int> >&, int)':
a.cc:8:8: error: 'pi' was not declared in this scope; did you mean 'i'?
    8 |  queue<pi> q;
      |        ^~
      |        i
a.cc:8:10: error: template argument 1 is invalid
    8 |  queue<pi> q;
      |          ^
a.cc:8:10: error: template argument 2 is invalid
a.cc:9:4: error: request for member 'push' in 'q', which is of non-class type 'int'
    9 |  q.push({i,0});
      |    ^~~~
a.cc:10:11: error: request for member 'empty' in 'q', which is of non-class type 'int'
   10 |  while(!q.empty())
      |           ^~~~~
a.cc:12:6: error: expected ';' before 'p'
   12 |    pi p=q.front();
      |      ^~
      |      ;
a.cc:13:6: error: request for member 'pop' in 'q', which is of non-class type 'int'
   13 |    q.pop();
      |      ^~~
a.cc:14:10: error: 'p' was not declared in this scope
   14 |    int k=p.first;
      |          ^
a.cc:20:8: error: request for member 'push' in 'q', which is of non-class type 'int'
   20 |      q.push({g[k][j],c+1});
      |        ^~~~
a.cc:22:8: error: request for member 'push' in 'q', which is of non-class type 'int'
   22 |      q.push({g[k][j],vis[k]+1});
      |        ^~~~
a.cc:25:7: error: redeclaration of 'int c'
   25 |   int c=*max_element(vis.begin(),vis.end());
      |       ^
a.cc:15:8: note: 'int c' previously declared here
   15 |    int c=p.second;
      |        ^
a.cc:31:1: warning: control reaches end of non-void function [-Wreturn-type]
   31 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define pair<int,int> pi
int get(vector<vector<int> >& g,int i)
{  int n=g.size();
  vector<int> vis(n,INT_MIN);
  vis[i]=0;
 queue<pi> q;
 q.push({i,0});
 while(!q.empty())
 {
   pi p=q.front();
   q.pop();
   int k=p.first;
   int c=p.second;
   vis[k]=max(vis[k],c);
   for(int j=0;j<g[k].size();j++)
   {
     if(vis[g[k][j]]==INT_MIN)
     q.push({g[k][j],c+1});
     else if(vis[g[k][j]]<vis[k]+1)
     q.push({g[k][j],vis[k]+1});  
    }
   
  int c=*max_element(vis.begin(),vis.end());
   return c;
   }
  
  
  
}
int main()
{
  int n,m;
  cin>>n>>m;
  int k1,k2;
  vector<vector<int> > g(n+1);
  for(int i=0;i<m;i++)
  { cin>>k1>>k2;
   g[k1].push_back(k2);
   }
  int max1=INT_MIN;
  for(int i=1;i<=n;i++)
  {
    int c=get(g,i);
    if(c>max1)
      max1=c;
    
    
  }
  
  cout<<max1;
  
}

Compiler output:
a.cc:3:9: warning: ISO C++11 requires whitespace after the macro name
    3 | #define pair<int,int> pi
      |         ^~~~
a.cc: In function 'int get(std::vector<std::vector<int> >&, int)':
a.cc:8:8: error: 'pi' was not declared in this scope; did you mean 'i'?
    8 |  queue<pi> q;
      |        ^~
      |        i
a.cc:8:10: error: template argument 1 is invalid
    8 |  queue<pi> q;
      |          ^
a.cc:8:10: error: template argument 2 is invalid
a.cc:9:4: error: request for member 'push' in 'q', which is of non-class type 'int'
    9 |  q.push({i,0});
      |    ^~~~
a.cc:10:11: error: request for member 'empty' in 'q', which is of non-class type 'int'
   10 |  while(!q.empty())
      |           ^~~~~
a.cc:12:6: error: expected ';' before 'p'
   12 |    pi p=q.front();
      |      ^~
      |      ;
a.cc:13:6: error: request for member 'pop' in 'q', which is of non-class type 'int'
   13 |    q.pop();
      |      ^~~
a.cc:14:10: error: 'p' was not declared in this scope
   14 |    int k=p.first;
      |          ^
a.cc:20:8: error: request for member 'push' in 'q', which is of non-class type 'int'
   20 |      q.push({g[k][j],c+1});
      |        ^~~~
a.cc:22:8: error: request for member 'push' in 'q', which is of non-class type 'int'
   22 |      q.push({g[k][j],vis[k]+1});
      |        ^~~~
a.cc:25:7: error: redeclaration of 'int c'
   25 |   int c=*max_element(vis.begin(),vis.end());
      |       ^
a.cc:15:8: note: 'int c' previously declared here
   15 |    int c=p.second;
      |        ^
a.cc:31:1: warning: control reaches end of non-void function [-Wreturn-type]
   31 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define pair<int,int> pi;
int get(vector<vector<int> >& g,int i)
{  int n=g.size();
  vector<int> vis(n,INT_MIN);
  vis[i]=0;
 queue<pi> q;
 q.push({i,0});
 while(!q.empty())
 {
   pi p=q.front();
   q.pop();
   int k=p.first;
   int c=p.second;
   vis[k]=max(vis[k],c);
   for(int j=0;j<g[k].size();j++)
   {
     if(vis[g[k][j]]==INT_MIN)
     q.push({g[k][j],c+1});
     else if(vis[g[k][j]]<vis[k]+1)
     q.push({g[k][j],vis[k]+1});  
    }
   
  int c=*max_element(vis.begin(),vis.end());
   return c;
   }
  
  
  
}
int main()
{
  int n,m;
  cin>>n>>m;
  int k1,k2;
  vector<vector<int> > g(n+1);
  for(int i=0;i<m;i++)
  { cin>>k1>>k2;
   g[k1].push_back(k2);
   }
  int max1=INT_MIN;
  for(int i=1;i<=n;i++)
  {
    int c=get(g,i);
    if(c>max1)
      max1=c;
    
    
  }
  
  cout<<max1;
  
}

Compiler output:
a.cc:3:9: warning: ISO C++11 requires whitespace after the macro name
    3 | #define pair<int,int> pi;
      |         ^~~~
a.cc: In function 'int get(std::vector<std::vector<int> >&, int)':
a.cc:8:8: error: 'pi' was not declared in this scope; did you mean 'i'?
    8 |  queue<pi> q;
      |        ^~
      |        i
a.cc:8:10: error: template argument 1 is invalid
    8 |  queue<pi> q;
      |          ^
a.cc:8:10: error: template argument 2 is invalid
a.cc:9:4: error: request for member 'push' in 'q', which is of non-class type 'int'
    9 |  q.push({i,0});
      |    ^~~~
a.cc:10:11: error: request for member 'empty' in 'q', which is of non-class type 'int'
   10 |  while(!q.empty())
      |           ^~~~~
a.cc:12:6: error: expected ';' before 'p'
   12 |    pi p=q.front();
      |      ^~
      |      ;
a.cc:13:6: error: request for member 'pop' in 'q', which is of non-class type 'int'
   13 |    q.pop();
      |      ^~~
a.cc:14:10: error: 'p' was not declared in this scope
   14 |    int k=p.first;
      |          ^
a.cc:20:8: error: request for member 'push' in 'q', which is of non-class type 'int'
   20 |      q.push({g[k][j],c+1});
      |        ^~~~
a.cc:22:8: error: request for member 'push' in 'q', which is of non-class type 'int'
   22 |      q.push({g[k][j],vis[k]+1});
      |        ^~~~
a.cc:25:7: error: redeclaration of 'int c'
   25 |   int c=*max_element(vis.begin(),vis.end());
      |       ^
a.cc:15:8: note: 'int c' previously declared here
   15 |    int c=p.second;
      |        ^
a.cc:31:1: warning: control reaches end of non-void function [-Wreturn-type]
   31 | }
      | ^