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

#include<bits/stdc++.h>
using namespace std;
long int dp[100000+1];
for(i=0;i<=n;i++)
dp[i]=-1;
long int pathlen(long int i,long int index[],vector <pair<long int,long int> > v,long int dp[])
{
	if(index[i]==-1)
	return 0;
	else
	{
		vector <pair<long int,long int> > :: iterator it;
		it=v.begin()+index[i];
		//cout<<index[i]<<endl;
		long int max=0;
		while(it->first==i)
		{
			//cout<<i<<" calls "<<it->second<<endl;
			if(dp[it->second]==-1)
			dp[it->second]=pathlen(it->second,index,v,dp);
			if(max<dp[it->second])
			max=dp[it->second];
			it++;
		}
		//cout<<"call for "<<i<<" returns l="<<max+1<<endl;
		return dp[i]=max+1;
		//for(it=v.begin+index[i];)
	}
}
int main()
{
	long int n,m,i,a,b,k;
	cin>>n>>m;
	vector <pair<long int,long int> > v;
	vector <pair<long int,long int> > :: iterator it;
	for(i=0;i<m;i++)
	{
		cin>>a>>b;
		v.push_back(make_pair(a,b));
	}
	int present[n+1];
	for(i=0;i<=n;i++)
	present[i]=-1;
	for(it=v.begin();it!=v.end();it++)
	present[it->second]=1;
	sort(v.begin(),v.end());
	long int index[n+1];
	for(i=0;i<=n;i++)
	index[i]=-1;
	it=v.begin();
	k=it->first;
	it++;
	index[k]=0;
	i=1;
	for(;it!=v.end();it++)
	{
		if(it->first!=k)
		{
			k=it->first;
			index[k]=i;
		}
		i++;
	}
	
//	cout<<"indices :"<<endl;
//	for(i=1;i<=n;i++)
//	cout<<i<<" "<<index[i]<<endl;
//	for(it=v.begin();it!=v.end();it++){
//	cout<<it->first<<" "<<it->second;cout<<"\n";}
	
	long int max=0,res;
	for(i=1;i<=n;i++)
	{
		if(present[i]==-1)
		{
			//cout<<"main calls "<<i<<endl;
			res=pathlen(i,index,v,dp);
			if(res>max)
			max=res;
		}
	}
	cout<<max;
}

Compiler output:
a.cc:4:1: error: expected unqualified-id before 'for'
    4 | for(i=0;i<=n;i++)
      | ^~~
a.cc:4:9: error: 'i' does not name a type
    4 | for(i=0;i<=n;i++)
      |         ^
a.cc:4:14: error: 'i' does not name a type
    4 | for(i=0;i<=n;i++)
      |              ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
long int dp[n+1];
for(i=0;i<=n;i++)
dp[i]=-1;
long int pathlen(long int i,long int index[],vector <pair<long int,long int> > v,long int dp[])
{
	if(index[i]==-1)
	return 0;
	else
	{
		vector <pair<long int,long int> > :: iterator it;
		it=v.begin()+index[i];
		//cout<<index[i]<<endl;
		long int max=0;
		while(it->first==i)
		{
			//cout<<i<<" calls "<<it->second<<endl;
			if(dp[it->second]==-1)
			dp[it->second]=pathlen(it->second,index,v,dp);
			if(max<dp[it->second])
			max=dp[it->second];
			it++;
		}
		//cout<<"call for "<<i<<" returns l="<<max+1<<endl;
		return dp[i]=max+1;
		//for(it=v.begin+index[i];)
	}
}
int main()
{
	long int n,m,i,a,b,k;
	cin>>n>>m;
	vector <pair<long int,long int> > v;
	vector <pair<long int,long int> > :: iterator it;
	for(i=0;i<m;i++)
	{
		cin>>a>>b;
		v.push_back(make_pair(a,b));
	}
	int present[n+1];
	for(i=0;i<=n;i++)
	present[i]=-1;
	for(it=v.begin();it!=v.end();it++)
	present[it->second]=1;
	sort(v.begin(),v.end());
	long int index[n+1];
	for(i=0;i<=n;i++)
	index[i]=-1;
	it=v.begin();
	k=it->first;
	it++;
	index[k]=0;
	i=1;
	for(;it!=v.end();it++)
	{
		if(it->first!=k)
		{
			k=it->first;
			index[k]=i;
		}
		i++;
	}
	
//	cout<<"indices :"<<endl;
//	for(i=1;i<=n;i++)
//	cout<<i<<" "<<index[i]<<endl;
//	for(it=v.begin();it!=v.end();it++){
//	cout<<it->first<<" "<<it->second;cout<<"\n";}
	
	long int max=0,res;
	for(i=1;i<=n;i++)
	{
		if(present[i]==-1)
		{
			//cout<<"main calls "<<i<<endl;
			res=pathlen(i,index,v,dp);
			if(res>max)
			max=res;
		}
	}
	cout<<max;
}

Compiler output:
a.cc:3:13: error: 'n' was not declared in this scope; did you mean 'yn'?
    3 | long int dp[n+1];
      |             ^
      |             yn
a.cc:4:1: error: expected unqualified-id before 'for'
    4 | for(i=0;i<=n;i++)
      | ^~~
a.cc:4:9: error: 'i' does not name a type
    4 | for(i=0;i<=n;i++)
      |         ^
a.cc:4:14: error: 'i' does not name a type
    4 | for(i=0;i<=n;i++)
      |              ^
a.cc: In function 'int main()':
a.cc:77:47: error: 'dp' was not declared in this scope; did you mean 'dup'?
   77 |                         res=pathlen(i,index,v,dp);
      |                                               ^~
      |                                               dup
Language: C++

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

int n, m, x, y;
vector<int> G[N];
int dp[N];

int dfs(int u)
{
	int& ans = dp[u];
	if (ans > 0) return ans;
	for (int j = 0; j < G[u].size(); j++)
		ans = max(ans, dfs(G[u][j]) + 1);
	return ans;
}

int main() {
	//freopen("demo.in", "r", stdin);
	//freopen("demo.out", "w", stdout);
	
	int size = 512 << 20; // 256MB  
    char *p = (char*)malloc(size) + size;  
    __asm__("movl %0, %%esp\n" :: "r"(p));
	
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++)
	{
		scanf("%d %d", &x, &y);
		G[x].push_back(y);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++)
		ans = max(ans, dfs(i));
	
	printf("%d\n", ans);
	

	return 0;
}


Compiler output:
a.cc: Assembler messages:
a.cc:24: Error: operand type mismatch for `mov'
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int> > g(n+1);
  int i,j,k;
  int cnt[n+1]={};
  for(i=0;i<m;i++){
    cin >> j >> k;
  	g[j].push_back(k);
    cnt[k]++;
  }

  queue<int> que,topo;
  for(i=1;i<=n;i++){
    if(cnt[i]==0){
      que.push(i);
      topo.push(i);
    }
  }
  
  while(!que.empty()){
    int x = que.top();
    que.pop();
    int s=g[x].size();
    for(i=0;i<s;i++){
      cnt[g[x][i]]--;
      if(cnt[g[x][i]]==0){
        que.push(g[x][i]);
        topo.push(g[x][i]);
      }
    }
  }
  int dp[n+1]={};
  while(!topo.empty()){
    int x = topo.top();
    topo.pop();
    int s = g[x].size();
    for(i=0;i<s;i++){
      dp[g[x][i]]=max(dp[g[x][i]],dp[x]+1);
    }
  }
  int ret=0;
  for(i=1;i<=n;i++)ret=max(ret,dp[i]);
  cout << ret << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:17: error: 'class std::queue<int>' has no member named 'top'; did you mean 'pop'?
   28 |     int x = que.top();
      |                 ^~~
      |                 pop
a.cc:41:18: error: 'class std::queue<int>' has no member named 'top'; did you mean 'pop'?
   41 |     int x = topo.top();
      |                  ^~~
      |                  pop
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int> > g(n+1);
  int i,j,k;
  int cnt[n+1]={};
  for(i=0;i<m;i++){
    cin >> j >> k;
  	g[j].push_back(k);
    cnt[k]++;
  }
  stack<int> st;
  queue<int> que,topo;
  for(i=1;i<=n;i++){
    if(cnt[i]==0){
      que.push(i);
      topo.push(i);
    }
  }
  
  while(!que.empty()){
    int x = que.top();
    que.pop();
    int s=g[x].size();
    for(i=0;i<s;i++){
      cnt[g[x][i]]--;
      if(cnt[g[x][i]]==0){
        que.push(g[x][i]);
        topo.push(g[x][i]);
      }
    }
  }
  int dp[n+1]={};
  while(!topo.empty()){
    int x = topo.top();
    topo.pop();
    int s = g[x].size();
    for(i=0;i<s;i++){
      dp[g[x][i]]=max(dp[g[x][i]],dp[x]+1);
    }
  }
  int ret=0;
  for(i=1;i<=n;i++)ret=max(ret,dp[i]);
  cout << ret << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:3: error: 'stack' was not declared in this scope
   18 |   stack<int> st;
      |   ^~~~~
a.cc:5:1: note: 'std::stack' is defined in header '<stack>'; this is probably fixable by adding '#include <stack>'
    4 | #include <queue>
  +++ |+#include <stack>
    5 | using namespace std;
a.cc:18:9: error: expected primary-expression before 'int'
   18 |   stack<int> st;
      |         ^~~
a.cc:28:17: error: 'class std::queue<int>' has no member named 'top'; did you mean 'pop'?
   28 |     int x = que.top();
      |                 ^~~
      |                 pop
a.cc:41:18: error: 'class std::queue<int>' has no member named 'top'; did you mean 'pop'?
   41 |     int x = topo.top();
      |                  ^~~
      |                  pop
Language: C++

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


int count(int i,vector<vector<int>> a,int *s)
{
    if(a[i].size()==0)
    {
      s[i]=0;  
      return 0;
    }
    if(s[i]!=-1)
      return s[i];
    int t=0;
    int j;
    for(j=0;j<a[i].size();j++)
    {
        if(s[a[i][j]]==-1)
        s[a[i][j]]= 1+count(a[i][j],a,s);

        if(t<s[a[i][j]])
        t=s[a[i][j]];
    }
    return t;
}
int main()
{
  int n,m,x,y,i;
  cin>>n>>m;
  vector<vector<int> >a;
  for(i=0;i<=n;i++)
  {
     vector<ll> vec1;
     a[i].push_back(vec1);
  }
  for(i=0;i<m;i++)
    {
        cin>>x>>y;
        a[x].push_back(y);
    }
  int t=0;
  int s[n+1];
  memset(s,-1,sizeof(s));

  for(i=1;i<=n;i++)
  {
      if(s[i]==-1)
      {
          s[i]=1+count(i,a,s);
      }
      if(t<s[i])
      t=s[i];
  }
  cout<<t-1;
    
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:20: error: no matching function for call to 'std::vector<int>::push_back(std::vector<long long int>&)'
   35 |      a[i].push_back(vec1);
      |      ~~~~~~~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'const std::vector<int>::value_type&' {aka 'const int&'}
 1283 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1300 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
Language: C++

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


int count(int i,vector<vector<int>> a,int *s)
{
    if(a[i].size()==0)
    {
      s[i]=0;  
      return 0;
    }
    if(s[i]!=-1)
      return s[i];
    int t=0;
    int j;
    for(j=0;j<a[i].size();j++)
    {
        if(s[a[i][j]]==-1)
        s[a[i][j]]= 1+count(a[i][j],a,s);

        if(t<s[a[i][j]])
        t=s[a[i][j]];
    }
    return t;
}
int main()
{
  int n,m,x,y,i;
  cin>>n>>m;
  vector<vector<int>>;
  for(i=0;i<=n;i++)
  {
     vector<ll> vec1;
     a[i].push_back(vec1);
  }
  for(i=0;i<m;i++)
    {
        cin>>x>>y;
        a[x].push_back(y);
    }
  int t=0;
  int s[n+1];
  memset(s,-1,sizeof(s));

  for(i=1;i<=n;i++)
  {
      if(s[i]==-1)
      {
          s[i]=1+count(i,a,s);
      }
      if(t<s[i])
      t=s[i];
  }
  cout<<t-1;
    
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:3: error: declaration does not declare anything [-fpermissive]
   31 |   vector<vector<int>>;
      |   ^~~~~~~~~~~~~~~~~~~
a.cc:35:6: error: 'a' was not declared in this scope
   35 |      a[i].push_back(vec1);
      |      ^
a.cc:40:9: error: 'a' was not declared in this scope
   40 |         a[x].push_back(y);
      |         ^
a.cc:50:26: error: 'a' was not declared in this scope
   50 |           s[i]=1+count(i,a,s);
      |                          ^
Language: C++

// G - Longest path
// A. Bacca
#include <bits/stdc++.h>
using namespace std;

int n, m;
vector <vector <int> > Adj;
vector <bool> Visited;
vector <int> dp_path;

void Recibir() {
	int x, y;
	
	cin >> n >> m;
	Adj.resize(n);
	
	for (int i=0; i<m; i++) {
		cin >> x >> y;
		Adj[x-1].push_back(y-1);
	}
	
	dp_path.assign(n, 0);
}

int DFS_VISIT(int u) {
	int tot {0};
	
	for (int v : Adj[u]) {
		if (dp_path[v] != 0) tot = max(tot, dp_path[u] + 1);
		else tot = max(tot, DFS_VISIT(v) + 1)
	}
	
	return dp_path[u] = tot;
}

int DFS() {
	for (int i=0; i<n; i++)  {
		if (dp_path[i] == 0) DFS_VISIT(i);
	
	int res {0};
	for (int x : dp_path) res = max(res, x);
	return res;
}

int main() {
	Recibir();
	cout << DFS();
	return 0;
}

Compiler output:
a.cc: In function 'int DFS_VISIT(int)':
a.cc:30:54: error: expected ';' before '}' token
   30 |                 else tot = max(tot, DFS_VISIT(v) + 1)
      |                                                      ^
      |                                                      ;
   31 |         }
      |         ~                                             
a.cc: In function 'int DFS()':
a.cc:45:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   45 | int main() {
      |         ^~
a.cc:45:9: note: remove parentheses to default-initialize a variable
   45 | int main() {
      |         ^~
      |         --
a.cc:45:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:45:12: error: a function-definition is not allowed here before '{' token
   45 | int main() {
      |            ^
a.cc:49:2: error: expected '}' at end of input
   49 | }
      |  ^
a.cc:36:11: note: to match this '{'
   36 | int DFS() {
      |           ^
a.cc:49:2: warning: control reaches end of non-void function [-Wreturn-type]
   49 | }
      |  ^
Language: C++

 #include<bits/stdc++.h>
 #include<stdio.h> 
  	
 using namespace std;
 int dp[10];
 

 int maxi(int a,int b){
 if (a>b)
 return a;
 else 
 return b;}
 void dfs(int t ,vector<int>a[10],vector<bool>visited,int n)
 {
	
	 for(int i=0;i<a[t].size();i++)
	 {
		 if(visited[a[t][i]]!=true){
		 dp[a[t][i]]=maxi(dp[a[t][i]],dp[t]+1);
		   visited[a[t][i]]=true;
		}
		 else {
		  dp[a[t][i]]=maxi(dp[a[t][i]],dp[t]+1);}
		   dfs(a[t][i],a,visited,n);
		
	 }

  
 
}
	
 
 int main()
 { 
 vector<int>a[10];
 int p=0;
 vector<bool>visited(100,false);
int n,e,x,y;
cin>>n>>e;
for(int i=0;i<e;i++){
cin>>x>>y;
a[x].push_back(y);
}
for(int i=1;i<=n;i++)
a[0].push_back(i);


     dfs(0,a,visited,n);
    
    for(int i=0;i<n;i++)
    p=max(k,dp[i]);
    cout<<p-1;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:51:11: error: 'k' was not declared in this scope
   51 |     p=max(k,dp[i]);
      |           ^
Language: C++

#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// vector<int> dp; // 頂点 i から始まるパスで最長のものの長さ
int dp[100001];        // メモ化再帰
multimap<int, int> mp; // 入力値(from, to)

// 一番遠い場所を探す
int rec(int from) {
    if (dp[from] != 0) {
        return dp[from];
    }
    int res = 0;
    // キーを持つ値を列挙する
    auto p = mp.equal_range(from);
    for (auto it = p.first; it != p.second; ++it) {
        res = max(res, rec(it->second) + 1);
    }
    return dp[from] = res;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, ans = 0;
    cin >> n >> m;
    // dp.resize(n + 1, 0);
    for (int i = 1; i <= m; i++) {
        int x, y;
        cin >> x >> y;
        mp.emplace(x, y);
    }
    for (int i = 1; i <= n; i++) {
        ans = rec(i);
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:29: error: request for member 'begin' in 'dp', which is of non-class type 'int [100001]'
   42 |     cout << *max_element(dp.begin(), dp.end()) << endl;
      |                             ^~~~~
a.cc:42:41: error: request for member 'end' in 'dp', which is of non-class type 'int [100001]'
   42 |     cout << *max_element(dp.begin(), dp.end()) << endl;
      |                                         ^~~
Language: C++

#include <iostream>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

vector<int> dp; // 頂点 i から始まるパスで最長のものの長さ
multimap<int, int> mp; // 入力値(from, to)
// 一番遠い場所を探す
void searchDist(int from, vector<int> route) {
    int cnt = 0;
    route.push_back(from);
    // 計算済み、もしくはキーが存在しない場合
    if (dp[from] != 0 || mp.count(from) == 0) {
        reverse(route.begin(), route.end());
        if (dp[from] != 0) {
            cnt = dp[from];
        }
        for (auto x : route) {
            dp[x] = max(dp[x], cnt++);
        }
    } else {
        // キーを持つ値を列挙する
        auto p = mp.equal_range(from);
        for (auto it = p.first; it != p.second; ++it) {
            searchDist(it->second, route);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    dp.resize(n + 1, 0);
    for (int i = 1; i <= m; i++) {
        int x, y;
        cin >> x >> y;
        mp.emplace(x, y);
    }
    for (int i = 1; i <= n; i++) {
        if (dp[i] == 0) {
            vector<int> dr;
            searchDist(i, dr);
        }
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
    return 0;
}

Compiler output:
a.cc: In function 'void searchDist(int, std::vector<int>)':
a.cc:17:9: error: 'reverse' was not declared in this scope
   17 |         reverse(route.begin(), route.end());
      |         ^~~~~~~
a.cc: In function 'int main()':
a.cc:50:14: error: 'max_element' was not declared in this scope
   50 |     cout << *max_element(dp.begin(), dp.end()) << endl;
      |              ^~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>

#define int long long
using namespace std;
#define maxn 100010
int n,m;
vector<int> g[maxn];
int indegree[maxn] ,dist[maxn] ;
bool visited[maxn];

void dfs(int v,int p){
    visited[v] = true#include <bits/stdc++.h>

#define int long long
using namespace std;
#define maxn 100010
int n,m;
vector<int> g[maxn];
int indegree[maxn] ,dist[maxn] ;
bool visited[maxn];

void dfs(int v,int p){
    visited[v] = true;
    for(auto x: g[v]){
        if(x == p)continue;
        dist[x] = max(dist[x] , 1 + dist[v]);
        indegree[x]--;
        if(indegree[x] == 0 and !visited[x])
            dfs(x ,v);
    }
}

int32_t main() {

    cin >> n >> m;

    int a ,b;
    for (int i = 0; i < m; ++i) {
        cin >> a >> b;
        g[a].push_back(b);
        indegree[b]++;
    }
    for(int i = 1; i <= n ;i++){
        if(!visited[i] and indegree[i] == 0)
            dfs(i , -1);
    }
    int ans = 0;
    for (int j = 1; j <= n; ++j) {
        ans = max(ans,dist[j]);
    }
    cout << ans;
}

;
    for(auto x: g[v]){
        if(x == p)continue;
        dist[x] = max(dist[x] , 1 + dist[v]);
        indegree[x]--;
        if(indegree[x] == 0 and !visited[x])
            dfs(x ,v);
    }
}

int32_t main() {

    cin >> n >> m;

    int a ,b;
    for (int i = 0; i < m; ++i) {
        cin >> a >> b;
        g[a].push_back(b);
        indegree[b]++;
    }
    for(int i = 1; i <= n ;i++){
        if(!visited[i] and indegree[i] == 0)
            dfs(i , -1);
    }
    int ans = 0;
    for (int j = 1; j <= n; ++j) {
        ans = max(ans,dist[j]);
    }
    cout << ans;
}



Compiler output:
a.cc:12:22: error: stray '#' in program
   12 |     visited[v] = true#include <bits/stdc++.h>
      |                      ^
a.cc: In function 'void dfs(long long int, long long int)':
a.cc:12:22: error: expected ';' before 'include'
   12 |     visited[v] = true#include <bits/stdc++.h>
      |                      ^~~~~~~~
      |                      ;
a.cc:22:22: error: a function-definition is not allowed here before '{' token
   22 | void dfs(int v,int p){
      |                      ^
a.cc:33:13: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   33 | int32_t main() {
      |             ^~
a.cc:33:13: note: remove parentheses to default-initialize a variable
   33 | int32_t main() {
      |             ^~
      |             --
a.cc:33:13: note: or replace parentheses with braces to value-initialize a variable
a.cc:33:16: error: a function-definition is not allowed here before '{' token
   33 | int32_t main() {
      |                ^
Language: C++

/*	Don’t Quit
	
	When things go wrong as they sometimes will;
		When the road you’re trudging seems all uphill;
			When the funds are low, and the debts are high;
				And you want to smile, but you have to sigh;
					When care is pressing you down a bit
						Rest if you must, but don’t you quit.
*/
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=2e5+10;
int dp[N],vis[N];
vector<int>v[N],v1[N];

int dfs(int n)
{
	if(dp[n]!=-1)
		return dp[n];
	int ans=0;
	for(int i=0;i<v[n].size();i++)
	{
		ans=max(ans,dfs(vp[n][i])+1);
	}
	dp[n]=ans;
	return ans;
}
int32_t main()
{
	int n,m;
	cin>>n>>m;
	int x,y;
	for(int i=0;i<m;i++)
	{
		cin>>x>>y;
		v[x].pb(y);
		v1[y].pb(x);
	}
	for(int i=1;i<=n;i++)
	{
		dp[i]=-1;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		
			ans=max(ans,dfs(i));
	}
	cout<<ans<<endl;

}


Compiler output:
a.cc: In function 'long long int dfs(long long int)':
a.cc:31:33: error: 'vp' was not declared in this scope; did you mean 'v1'?
   31 |                 ans=max(ans,dfs(vp[n][i])+1);
      |                                 ^~
      |                                 v1
Language: C++

#include <iostream>
#include<iomanip>
#include <cmath>
#include <climits>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
using namespace std;

vector <int> edges[100000];
int dp[100000];

int rec(int v){
    if(dp[v] >= 0){
        return dp[v];
    }
    int max_length = 0;
    for(int i = 0; i < edges[v].size(); i++){
        max_length = max(rec(edges[v][i]) + 1, max_length);
    }
    dp[v] = max_length;
    return max_length;
}

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

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


    vector <int> sources;
    for(int i = 0; i < N; i++){
        if(reverse_edges[i].size() <= 0){
            sources.push_back(i);
        }
    }

    for(int i = 0; i < N; i++){
        dp[i] = -1;
    }
    
    int ans = 0;
    for(int i = 0; i < sources.size(); i++){
        ans = max(ans, rec(sources[i]));
    }
    cout << ans << endl;
    return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:12: error: 'reverse_edges' was not declared in this scope
   41 |         if(reverse_edges[i].size() <= 0){
      |            ^~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <stdio.h>
#include <vector>
#include <set>
using namespace std;


//void dfs(int ind, vector<int> adj[], vector<bool> visited, vector<int> arr){
void dfs(int ind, vector<int> adj[], bool visited[], int arr[]){
  visited[ind] = true;
  for (int i=0; i < adj[ind].size(); i++){
    if(!visited[adj[ind][i]]){
      dfs(adj[ind][i], adj, visited, arr);
    }
  }
  for (int i=0; i < adj[ind].size(); i++){
    arr[ind] = max(arr[ind], arr[adj[ind][i]] + 1);
  }
}

int main()
{
  int n = 0;
  int m = 0;
  scanf("%d %d", &n, &m);
  vector<int> adj[n]; //array of vectors
  int s, e;
  for(int i = 0; i<m; i++){
    scanf("%d %d", &s, &e);
    adj[s-1].push_back(e-1);
  }
  //vector<bool> visited(n+1, false);
  //vector<int> arr(n+1, 0);
  int arr[n];
  bool visited[n];
  memset(arr, 0, sizeof arr);
  memset(visited, false, sizeof visited);


  for (int i=0; i<n; i++){
    dfs(i, adj, visited, arr);
  }
  int result = 0;
  for (int i=0; i<n; i++){
    //printf("%d ", arr[i]);
    result = max(result, arr[i]);
  }
  //printf("\n");
  printf("%d\n", result);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:3: error: 'memset' was not declared in this scope
   36 |   memset(arr, 0, sizeof arr);
      |   ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <set>
  +++ |+#include <cstring>
    5 | using namespace std;
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class LongestPath {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] header = reader.readLine().split(" ");
        int vertexCount = Integer.parseInt(header[0]);
        int edgeCount = Integer.parseInt(header[1]);

        Map<Integer, List<Integer>> edges = new HashMap<>();
        for (int i = 0; i < vertexCount; ++i) {
            edges.put(i, new ArrayList<>());
        }
        int[] incoming = new int[vertexCount];

        for (int i = 0; i < edgeCount; ++i) {
            String[] parts = reader.readLine().split(" ");
            int src = Integer.parseInt(parts[0]);
            int dst = Integer.parseInt(parts[1]);
            edges.get(src).add(dst);
            incoming[dst] += 1;
        }

        ArrayDeque<Integer> queue = new ArrayDeque<>();
        for (int i = 0; i < vertexCount; ++i) {
            if (incoming[i] == 0) {
                queue.addLast(i);
            }
        }

        ArrayList<Integer> sorted = new ArrayList<>();
        while (!queue.isEmpty()) {
            int vertex = queue.removeFirst();
            for (int dst : edges.get(vertex)) {
                incoming[dst] -= 1;
                if (incoming[dst] == 0) {
                    queue.addLast(dst);
                }
            }
            sorted.add(vertex);
        }

        int[] dp = new int[vertexCount];
        int maxPath = 0;
        for (int vertex : sorted) {
            for (int dst : edges.get(vertex)) {
                dp[dst] = Math.max(dp[dst], dp[vertex] + 1);
                maxPath = Math.max(maxPath, dp[dst]);
            }
        }

        System.out.println(maxPath);
    }
}


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

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

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

        Map<Integer, List<Integer>> edges = new HashMap<>();
        int[] incoming = new int[vertexCount];

        for (int i = 0; i < edgeCount; ++i) {
            int src = scanner.nextInt() - 1;
            int dst = scanner.nextInt() - 1;
            edges.computeIfAbsent(src, ArrayList::new).add(dst);
            incoming[dst] += 1;
        }

        ArrayDeque<Integer> queue = new ArrayDeque<>();
        for (int i = 0; i < vertexCount; ++i) {
            if (incoming[i] == 0) {
                queue.addLast(i);
            }
        }

        ArrayList<Integer> sorted = new ArrayList<>();
        while (!queue.isEmpty()) {
            int vertex = queue.removeFirst();
            List<Integer> destinations = edges.get(vertex);
            if (destinations != null) {
                for (int dst : destinations) {
                    incoming[dst] -= 1;
                    if (incoming[dst] == 0) {
                        queue.addLast(dst);
                    }
                }
            }
            sorted.add(vertex);
        }

        int[] dp = new int[vertexCount];
        int maxPath = 0;
        for (int vertex : sorted) {
            List<Integer> destinations = edges.get(vertex);
            if (destinations != null) {
                for (int dst : edges.get(vertex)) {
                    dp[dst] = Math.max(dp[dst], dp[vertex] + 1);
                    maxPath = Math.max(maxPath, dp[dst]);
                }
            }
        }

        System.out.println(maxPath);
    }

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

#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

vi dp;
vvi edges;

int dfs(int x) {
  if (dp[x] != -1) return dp[x];

  int mx = 0;
  rep(i, edges[x].size()) {
    int next = edges[x][i];
    mx = max(mx, dfs(next));
  }
  return dp[x] = mx + 1;
}

int main() {
  int N, M; cin >> N >> M;
  edges.resize(N);
  vi x(M), y(M);
  rep(i, M) {
    cin >> x[i] >> y[i];
    x[i]--; y[i]--;
    edges[x[i]].pb(y[i]);
  }
  dp.assign(N, -1);
  int ans = 0;
  rep(i, N) {
    ans = max(ans, dfs(i));
  }
  cout << ans-1 << endl;
  return 0;
}


Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<ll> adj[100002];

bool visited[100002];
ll dp[100002];

void initialize() 
{
        for(ll i = 0;i <100002;++i)
         {
		 visited[i] = false;
		 }
}

ll dfs(ll i)
{
	visited[i]=true;
	
	if(adj[1].size()==0)
	return dp[i]=0;
	
	ll c=INT_MIN;
	
	for(auto j : adj[i])
	{
		if(!visited[j])
		{
			c=max(c,dfs(j));
		}
		else
		{
			c=max(c,dp[j]);
		}
	}
	
	return dp[i]=1+c;
}



int main()
{
	ll N,M;
	cin>>N>>M;
	
	ll x,y;

for(ll i=0;i<M;i++)
{
		cin>>x; cin>>y;
		adj[x].push_back(y);
}
	
initialize();
	

for(ll i=1;i<N;i++)
{
	dfs(i);
}
	
ll ans=-1;

for(ll i=1;i<=N;i++)
{
	if(dp[i]>ans)
	{
		ans=dp[i];
	}
}
cout<<ans<<endl;/

}





Compiler output:
a.cc: In function 'int main()':
a.cc:74:17: error: expected primary-expression before '/' token
   74 | cout<<ans<<endl;/
      |                 ^
a.cc:76:1: error: expected primary-expression before '}' token
   76 | }
      | ^
Language: C++

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

int main() {
	int n, m;


	std::cin.tie(false);
	std::cin.sync_with_stdio(false);

	std::cin >> n >> m;

	std::vector<std::vector<int>> g;
	g.resize(n);

	for (int i{}; i < m; ++i) {
		int x, y;
		std::cin >> x >> y;
		g[x - 1].emplace_back(y - 1);
	}


	std::vector<int> lp(n, 0);

	for (int i{}; i < n; ++i) {
		if (g[i].empty())
			continue;

		std::queue<int> q;
		q.emplace(i);

		while (!q.empty()) {
			auto v = q.front(); q.pop();

			for (const auto vi : g[v]) {
				if (lp[v] + 1 <= lp[vi])
					continue;

				lp[vi] = lp[v] + 1;
				q.emplace(vi);
			}
		}

	}

	auto me = *std::max_element(std::cbegin(lp), std::cend(lp));
	std::cout << me << "\n";
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:21: error: no matching function for call to 'std::basic_istream<char>::tie(bool)'
   10 |         std::cin.tie(false);
      |         ~~~~~~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_ios.h:299:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>* std::basic_ios<_CharT, _Traits>::tie() const [with _CharT = char; _Traits = std::char_traits<char>]'
  299 |       tie() const
      |       ^~~
/usr/include/c++/14/bits/basic_ios.h:299:7: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/basic_ios.h:311:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>* std::basic_ios<_CharT, _Traits>::tie(std::basic_ostream<_CharT, _Traits>*) [with _CharT = char; _Traits = std::char_traits<char>]'
  311 |       tie(basic_ostream<_CharT, _Traits>* __tiestr)
      |       ^~~
/usr/include/c++/14/bits/basic_ios.h:311:43: note:   no known conversion for argument 1 from 'bool' to 'std::basic_ostream<char>*'
  311 |       tie(basic_ostream<_CharT, _Traits>* __tiestr)
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
Language: C++

#include <iostream>
#include <vector>

using namespace std;

// 頂点数、変数
int v, e;
const int MAX_N = 100100;
// 隣接リスト
vector<int> g[MAX_N], b[MAX_N];
int dp[MAX_N];
bool used[MAX_N];
// トポロジカルソートされた数列
vector<int> ans;

void dfs(int u) {
  if(used[u]) return;
  used[u] = true;
  for(auto i: g[u]) dfs(i);
  // 帰りがけ順で追加
  ans.push_back(u);
}

void tsort() {
  for(int i=1; i<=v; ++i) dfs(i);
  reverse(ans.begin(), ans.end());
}

signed main(void)
{
  cin >> v >> e;
  for(int i=0; i<e; ++i) {
    int s, t;
    cin >> s >> t;
    g[s].push_back(t);
    b[t].push_back(s);
    dp[i] = 0;
  }
  // 先にトポロジカルソートを行い，dpの一次元の順序を決定する．
  tsort();
  
  // dp開始
  int ANS = 0;
  for (int i = 1; i < ans.size(); i++) {
    int j = ans[i];
    // jへの道
    for (auto l : b[j]) {
      dp[j] = max(dp[j], dp[l] + 1);
      ANS = max(ANS, dp[j]);  
    }    
  }
  cout << ANS << endl;

  return 0;
}

Compiler output:
a.cc: In function 'void tsort()':
a.cc:26:3: error: 'reverse' was not declared in this scope
   26 |   reverse(ans.begin(), ans.end());
      |   ^~~~~~~
Language: C

#include <stdarg.h>
#include <stdio.h>

int dp[100010], M, G[100010][10010], k[100010]={0};

int max(int len, ...) {
    int i, _max, num;
    va_list ap;
    va_start(ap, len);

    _max = va_arg(ap, int);
    for (i = 1; i < len; i++) {
        num = va_arg(ap, int);
        if (num > _max)
            _max = num;
    }
    va_end(ap);
    return _max;
}

int rec(int v) {
    int i, res;
    if (dp[v] != -1) return dp[v]; // 既に更新済み

    res = 0;
    for (i=0;i<k[v];i++) {
        int nv = G[v][i];
        res = max(2,res, rec(nv) + 1);
    }
    return dp[v] = res; // メモしながらリターン
}

int main(void) {
    int i, N, res, x, y;
    scanf("%d%d", &N, &M);
    for (i=0;i<M;i++) {
        scanf("%d%d", &x, &y);
        x--; y--;
        G[x][k[x]++] = y;
    }

    for (i=0;i<N;i++) dp[i] = -1;
    res = 0;
    for (i=0;i<N;i++) res = max(2,res,rec(i));
    printf("%d\n", res);
    return 0;
}

Compiler output:
/tmp/cc2kRV5E.o: in function `rec':
main.c:(.text+0x20a): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/cc2kRV5E.o
/tmp/cc2kRV5E.o: in function `main':
main.c:(.text+0x2c4): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/cc2kRV5E.o
main.c:(.text+0x2dc): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/cc2kRV5E.o
collect2: error: ld returned 1 exit status
Language: C

#include <stdarg.h>
#include <stdio.h>

int dp[100010], M, G[100010][100010], k[100010]={0};

int max(int len, ...) {
    int i, _max, num;
    va_list ap;
    va_start(ap, len);

    _max = va_arg(ap, int);
    for (i = 1; i < len; i++) {
        num = va_arg(ap, int);
        if (num > _max)
            _max = num;
    }
    va_end(ap);
    return _max;
}

int rec(int v) {
    int i, res;
    if (dp[v] != -1) return dp[v]; // 既に更新済み

    res = 0;
    for (i=0;i<k[v];i++) {
        int nv = G[v][i];
        res = max(2,res, rec(nv) + 1);
    }
    return dp[v] = res; // メモしながらリターン
}

int main(void) {
    int i, N, res, x, y;
    scanf("%d%d", &N, &M);
    for (i=0;i<M;i++) {
        scanf("%d%d", &x, &y);
        x--; y--;
        G[x][k[x]++] = y;
    }

    for (i=0;i<N;i++) dp[i] = -1;
    res = 0;
    for (i=0;i<N;i++) res = max(2,res,rec(i));
    printf("%d\n", res);
    return 0;
}

Compiler output:
/tmp/ccIa2g1K.o: in function `rec':
main.c:(.text+0x20a): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/ccIa2g1K.o
/tmp/ccIa2g1K.o: in function `main':
main.c:(.text+0x2c4): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/ccIa2g1K.o
main.c:(.text+0x2dc): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/ccIa2g1K.o
collect2: error: ld returned 1 exit status
Language: C++

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

Compiler output:
a.cc: In function 'void addedge(int, int)':
a.cc:10:9: error: reference to 'next' is ambiguous
   10 |         next[tot]=head[u];
      |         ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:3:29: note:                 'int next [100001]'
    3 | int head[100001],to[100001],next[100001];
      |                             ^~~~
a.cc: In function 'int dfs(int)':
a.cc:19:35: error: reference to 'next' is ambiguous
   19 |         for(int i=head[index];i;i=next[i])
      |                                   ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:3:29: note:                 'int next [100001]'
    3 | int head[100001],to[100001],next[100001];
      |                             ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
long long next[100001],head[100001],to[100001],f[100001],degree[100001],tot=0;
void addedge(long long u,long long v)
{
        ++tot;
        next[tot]=head[u];
        to[tot]=v;
        head[u]=tot;
}
long long dfs(long long n)
{
        long long u,v;
        f[n]=0;
        for(u=head[n];u;u=next[u])
        {
                v=to[u];
                if(f[v]!=-1)
                        f[n]=max(f[n],f[v]+1);
                else
                        f[n]=max(f[n],dfs(v)+1);
        }
        //printf("%lld %lld\n",n,f[n]);
        return f[n];
}
int main()
{
        long long i,n,m,a,b,ans=0;
        scanf("%lld %lld",&n,&m);
        memset(f,0xff,sizeof(f));
        for(i=1;i<=m;i++)
        {
                scanf("%lld %lld",&a,&b);
                addedge(a,b);
                degree[b]++;
        }
        for(i=1;i<=n;i++)
        {
                if(degree[i]==0)
                {
                        ans=max(ans,dfs(i));
                }
        }
        printf("%lld",ans);
        return 0;
}


Compiler output:
a.cc: In function 'void addedge(long long int, long long int)':
a.cc:7:9: error: reference to 'next' is ambiguous
    7 |         next[tot]=head[u];
      |         ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:3:11: note:                 'long long int next [100001]'
    3 | long long next[100001],head[100001],to[100001],f[100001],degree[100001],tot=0;
      |           ^~~~
a.cc: In function 'long long int dfs(long long int)':
a.cc:15:27: error: reference to 'next' is ambiguous
   15 |         for(u=head[n];u;u=next[u])
      |                           ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:3:11: note:                 'long long int next [100001]'
    3 | long long next[100001],head[100001],to[100001],f[100001],degree[100001],tot=0;
      |           ^~~~
Language: C++

//       In the name of         ****                      God                     ****

/*

Copyright (C)          JadedBeast

                                   Morocco

created : 19/3/2019

*/

#include <bits/stdc++.h>

using namespace std;

inline void JadedBeast() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}
const int MAX=1e5+1;
int n,m,x,y;
vector <int> v[MAX];
bool used[MAX];
int d[MAX];
int connected[MAX];
int ans=0;
void addEdge(int x , int y){
	v[x].push_back(y);
}
void dfs(int s){
    if(used[s])return;
    used[s] = true;
    for(int x: v[s]){
        dp[x] = max(dp[x],dp[s]+1);
        connected[x]--;
        if(connected[x]==0)
            dfs(x);
        
    }
}
int main() {
	JadedBeast();
	memset(used,false,sizeof(used));
	memset(d,0,sizeof(d));
	memset(connected,0,sizeof(connected));
	cin >> n >> m;
	for(int i=0 ; i<m ;i++){
		cin >>x >> y;
		addEdge(x,y);
		connected[y]++;
	}

	for(int i=1 ; i<=n ; i++)
		if(!used[i])
			dfs(i);
	for(int x:d)
        ans = max(ans,x);
    
	cout << ans <<endl;

    return 0;
}


Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:35:9: error: 'dp' was not declared in this scope; did you mean 'dup'?
   35 |         dp[x] = max(dp[x],dp[s]+1);
      |         ^~
      |         dup
Language: C++

//       In the name of         ****                      God                     ****

/*

Copyright (C)          JadedBeast

                                   Morocco

created : 19/3/2019

*/

#include <bits/stdc++.h>

using namespace std;

inline void JadedBeast() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}
const int MAX=1e5+1;
int n,m,x,y;
vector <int> v[MAX];
bool used[MAX];
int d[MAX];
int connected[MAX];
int ans=0;
void addEdge(int x , int y){
	v[x].push_back(y);
}
void dfs(int s){
	if(used[s]) return;
	used[s]=true;
	for( int x : v[s]){
			d[x]=max(d[x],d[s]+1);
			ans=max(ans,d[x]);
			connected[x]--;
			if(connected[x]==0)
				dfs(x);
		}
}
int main() {
	JadedBeast();
	memset(used,false,sizeof(used));
	memset(d,0,sizeof(d));
	memset(connected,0,sizeof(connected));
	cin >> n >> m;
	for(int i=0 ; i<m ;i++){
		cin >>x >> y;
		addEdge(x,y);
		connected[y]++;
	}

	for(int i=1 ; i<=n ; i++)
		if(!used[i])
			dfs(i);
	for(int x:dp)
        ans = max(ans,x);
    
	cout << ans <<endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:57:19: error: 'dp' was not declared in this scope; did you mean 'dup'?
   57 |         for(int x:dp)
      |                   ^~
      |                   dup
Language: C++

#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <climits>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(),x.end()

int main()
{
  int N, M, x, y, s, z;
  cin >> N >> M;
  vector<int> E[N];
  int V[N] = {1};
  for (int i = 0; i < N; ++i) {
    V[i] = 1;
  }

  for (int i = 0; i < M; ++i) {
    cin >> x >> y;
    x--; y--;
    V[y] = 0;
    E[x].push_back(y);
  }
  vector<int> S;
  int Pathdistance[N] = {-1};
  for (int i = 0; i < N; ++i) {
    Pathdistance[i] = -1
  }

  for (int i = 0; i < N; ++i) {
    if (V[i] == 1) {
      S.push_back(i);
    }
  }
  while (S.size()) {
    s = S.back();
    S.pop_back();
    Pathdistance[s] = 0;
    int now = 1;
    vector<int> Z;
    for (unsigned int i = 0; i < E[s].size(); ++i) {
      if (Pathdistance[E[s][i]] < now) {
        Z.push_back(E[s][i]);
        Pathdistance[E[s][i]] = now;
      }
    }
    while (Z.size()) {
      vector<int> T(0,0);
      now++;
      for (unsigned int i = 0; i < Z.size(); ++i) {
        z = Z.back();
        Z.pop_back();
        for (unsigned int j = 0; j < E[z].size(); ++j) {
          if (Pathdistance[E[z][i]] < now) {
            T.push_back(E[z][i]);
            Pathdistance[E[z][i]] = now;
          }
        }
      }
      Z = T;
    }
  }
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    if (ans < Pathdistance[i]){
      ans = Pathdistance[i];
    }
  }
  cout << ans << "\n";
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:25: error: expected ';' before '}' token
   30 |     Pathdistance[i] = -1
      |                         ^
      |                         ;
   31 |   }
      |   ~
Language: Java


/*
USER: caoash3
LANG: JAVA
TASK: 
*/

import java.io.*;
import java.util.*;

public class longestPath {

	static final boolean stdin = true;
	static final String filename = "";
	static FastScanner br;
	static PrintWriter pw;

	public static void main(String[] args) throws IOException {

		if (stdin) {
			br = new FastScanner();
			pw = new PrintWriter(new OutputStreamWriter(System.out));
		}

		else {
			br = new FastScanner(filename + ".in");
			pw = new PrintWriter(new FileWriter(filename + ".out"));
		}

		X solver = new X();
		solver.solve(br, pw);
	}

	static class X {
		
		static ArrayList<Integer> ts;
		static ArrayList<Integer>[] edges;
		static boolean[] vis;
		static int N,M;
		
		public void solve(FastScanner br, PrintWriter pw) throws IOException {
			
			N = br.nextInt();
			M = br.nextInt();
			edges = new ArrayList[N];
			ts = new ArrayList<Integer>();
			vis = new boolean[N];
			
			for(int i = 0; i < N; i++) {
				edges[i] = new ArrayList<Integer>();
			}
			
			for(int i = 0; i < M; i++) {
				int x = br.nextInt();
				int y = br.nextInt();
				x--;
				y--;
				
				edges[x].add(y);
			}
			
			for(int i = 0; i < N; i++) {
				if(!vis[i]) {
					dfs(i);
				}
			}
			
			Collections.reverse(ts);
			
			int[] dp = new int[N];
			
			for(int curr : ts) {
				for(int e : edges[curr]) {
					dp[e] = Math.max(dp[e], dp[curr]+1);
				}
			}
			int ans = 0;
			for(int i = 0; i < dp.length; i++) {
				ans = Math.max(ans, dp[i]);
			}
			
			pw.println(ans);
			
			pw.close();
		}
		
		public static void dfs(int v) {
			vis[v] = true;
			for(int u : edges[v]) {
				if(vis[u]) {
					continue;
				}
				dfs(u);
			}
			
			ts.add(v);
		}

	}

	//fastscanner class
	public static 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:11: error: class longestPath is public, should be declared in a file named longestPath.java
public class longestPath {
       ^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error