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

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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
#define endl "\n"
#define all(v) v.begin(), v.end()
#define UNIQUE(v) sort(all(v)),v.erase(unique(all(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 1e5 + 5;

template <class T> struct directed_graph {
  static const int N = 1e5 + 5;
  struct data {
    int node; T val;
    data() : node(-1), val(-1) {}
    data(int node, T val) : node(node), val(val){}
  };
  int n; T ind[ N ]; vector <data> g[ N ];
  init(int _n){
    n = _n;
    for (int i = 0; i <= n; i++) ind[i] = 0, g[i].clear();
  }
  void add_edge(int u, int v, T val = 0) {
    g[u].push_back(data(v, val)); ind[v]++;
  }
  vector <int> topological_order() {
    queue <int> q;
    for (int i = 1; i <= n; i++) if (ind[i] == 0) q.push(i);
    vector <int> ans;
    while (!q.empty()) {
      int to = q.front(); q.pop(); ans.push_back(to);
      for (auto x : g[to]) {
        ind[x.node]--;
        if (ind[x.node] == 0) q.push(x.node);
      }
    }
    if ((int)ans.size() != n) return vector <int> {}; return ans;
  }
};

directed_graph <int> g;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("input.txt", "r", stdin);
  #endif // LOCAL
  int n, e;
  cin >> n >> e;
  g.init(n);
  for (int i = 1; i <= e; i++) {
    int u, v;
    cin >> u >> v;
    g.add_edge(u, v, 1);
  }
  vector <int> t = g.topological_order();
  vector <int> path(n + 1, 0);
  for (auto x: t) {
    for (auto val: g.g[x]) {
      path[val.node] = path[x] + 1;
    }
  }
  int mx = 0;
  for (auto x: t) mx = max(mx, path[x]);
  cout << mx << endl;
  return 0;
}


Compiler output:
a.cc:35:3: error: ISO C++ forbids declaration of 'init' with no type [-fpermissive]
   35 |   init(int _n){
      |   ^~~~
a.cc: In instantiation of 'int directed_graph<T>::init(int) [with T = int]':
a.cc:67:9:   required from here
   67 |   g.init(n);
      |   ~~~~~~^~~
a.cc:38:3: warning: no return statement in function returning non-void [-Wreturn-type]
   38 |   }
      |   ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100005];
vector<int> dp(100005,-1);
int longest_path(int node)  {
    if(dp[node]!=-1)    return dp[node];
    int ans=0;
    for(auto i:adj[node])   {
        ans=max(ans,1+longest_path(i));
    }
    return dp[node]=ans;
}
int main()  {
    ios_base::sync_with_stdio(false);   cin.tie(0);     cout.tie(0);
    int n,m;    cin>>n>>m;
    int a,b;
    fl(i,0,m)   {
        cin>>a>>b;
        adj[a].pb(b);
    }
    int ans=0;
    fl(i,1,n+1)   ans=max(ans,longest_path(i));
    cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:8: error: 'i' was not declared in this scope
   17 |     fl(i,0,m)   {
      |        ^
a.cc:17:5: error: 'fl' was not declared in this scope
   17 |     fl(i,0,m)   {
      |     ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(), (a).end()
#define forn(i,a,b) for (int i = a; i <= b; i++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
#define er erase
#define in insert
#define pi pair <int, int>
# define sz(x) (int)((x).size())
#define int long long
 
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
 
const ll inf = 0x3f3f3f3f3f3f3f;
const ll mod = 1000000007;
const int N = 2e5 + 11;
int ans[N],anss;
vector<int>v[N];

int dfs(int nod){
	
	int cur = 0;
	for(auto it:v[nod]){
		if(!ans[it])dfs(it);
		cur = max(cur , ans[it]);
	}
	
	return ans[nod] = cur+1;
}

int32_t main(){
ios_base::sync_with_stdio(0); cin.tie(0); cerr.tie(0); cout.tie(0);
	
	int n,m;
	cin>>n>>m;
	while(m--){
		int x,y;
		cin>>x>>y;
		v[x].pb(y);
	}
	
	forn(i,1,n){
		if(!ans[i])ans[i] = dfs(i);
		anss = max(anss , ans[i]);
		//cout<<ans[i]<<' ';
	}//cout<<'\n';
	
 	cout<<(anss-1)<<'\n';
re

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:56:1: error: 're' was not declared in this scope; did you mean 'rc'?
   56 | re
      | ^~
      | rc
a.cc:56:3: error: expected '}' at end of input
   56 | re
      |   ^
a.cc:38:15: note: to match this '{'
   38 | int32_t main(){
      |               ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define  pb  push_back
queue<int>q;
int main()
{
    int i,j,n,m,x,f,mx=0;
    cin>>n>>m;
    int ind[n+2],dp[n+2];
    vector<int>v[n+2];
    memset(ind,0,sizeof(ind));
    memset(dp,0,sizeof(dp));
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        v[x].pb(y);
        ind[y]++;
    }
    for(i=1;i<=n;i++)
    {
        if(ind[i]==0)
        {
            q.push(i);
        }
    }
    while(!q.empty())
    {
        f=q.front();
        q.pop();
        for(auto y: v[f])
        {
            dp[y]=max(dp[y],1+dp[f]);
            mx=max(mx,dp[y]);
            ind[y]--;
            if(ind[y]==0)
            {
                q.push(y);
            }
        }
    }
    cout<<mx<<"\n";
    return 0;
}


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

/*
      @author: Charan Sai
*/
#include <bits/stdc++.h>
using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define ppi pair<int, int>
#define endl "\n"
#define nl cout << "\n"
#define deb(x) cout << #x << " " << x << endl;

int N, M;
const int X = 1e5 + 5;
int graph[X][X];
int dp[X];

int Backtrack(int node) {

    if(dp[node] != -1) return dp[node];

    int max_path = 0;
    for(int i = 1; i < X; ++i) {
        if(graph[node][i] == 1) {
            max_path = max(max_path, 1 + Backtrack(i));
        }
    }
    return (dp[node] = max_path);
}

int solution() {
    int longest_path = 0;
    for(int i = 1; i <= N; ++i) {
        longest_path = max(longest_path, Backtrack(i));
    }
    return longest_path;
}

int32_t main() {
      IOS;
      memset(graph, 0, sizeof(graph));
      memset(dp, -1, sizeof(dp));
      cin >> N >> M;
      for(int i = 0; i < M; ++i) {
        int x, y; cin >> x >> y;
        graph[x][y] = 1;
      }
      cout << solution() << endl;
}

Compiler output:
/tmp/ccSQM06o.o: in function `Backtrack(long long)':
a.cc:(.text+0x1b): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccSQM06o.o
a.cc:(.text+0x38): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccSQM06o.o
a.cc:(.text+0xd2): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccSQM06o.o
a.cc:(.text+0xe9): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccSQM06o.o
/tmp/ccSQM06o.o: in function `main':
a.cc:(.text+0x1b7): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccSQM06o.o
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
 
#define NMAX 100005
using namespace std;
 
int dp[NMAX], dg[NMAX];
vector<int>G[NMAX];
 
void DFS(int nod){
    for(auto it: G[nod]){
        if(dp[it] == 0)
            DFS(it);
        dp[nod] = max(dp[nod], dp[it] + 1);
    }
}
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;
 
    for(int i = 1; i <= m; ++i){
        int x, y;
        cin >> x >> y;
 
        G[x].emplace_back(y);
        dg[y]++;
    }
 
    for(int i = 1; i <= n; ++i)
        if(dg[i] == 0)
            DFS(i);
 
    int maxx = 0;
    for(int i = 1; i <= n; ++i)
        maxx = max(maxx, dp[i]);
    cout << maxx << '\n';
    return 0;
}
#include <bits/stdc++.h>

#define NMAX 100005
using namespace std;

int dp[NMAX], dg[NMAX];
vector<int>G[NMAX];

void DFS(int nod){
    for(auto it: G[nod]){
        if(dp[it] == 0)
            DFS(it);
        dp[nod] = max(dp[nod], dp[it] + 1);
    }
}

int main()
{

Compiler output:
a.cc:47:5: error: redefinition of 'int dp [100005]'
   47 | int dp[NMAX], dg[NMAX];
      |     ^~
a.cc:6:5: note: 'int dp [100005]' previously declared here
    6 | int dp[NMAX], dg[NMAX];
      |     ^~
a.cc:47:15: error: redefinition of 'int dg [100005]'
   47 | int dp[NMAX], dg[NMAX];
      |               ^~
a.cc:6:15: note: 'int dg [100005]' previously declared here
    6 | int dp[NMAX], dg[NMAX];
      |               ^~
a.cc:48:12: error: redefinition of 'std::vector<int> G [100005]'
   48 | vector<int>G[NMAX];
      |            ^
a.cc:7:12: note: 'std::vector<int> G [100005]' previously declared here
    7 | vector<int>G[NMAX];
      |            ^
a.cc:50:6: error: redefinition of 'void DFS(int)'
   50 | void DFS(int nod){
      |      ^~~
a.cc:9:6: note: 'void DFS(int)' previously defined here
    9 | void DFS(int nod){
      |      ^~~
a.cc:58:5: error: redefinition of 'int main()'
   58 | int main()
      |     ^~~~
a.cc:17:5: note: 'int main()' previously defined here
   17 | int main()
      |     ^~~~
a.cc: In function 'int main()':
a.cc:59:2: error: expected '}' at end of input
   59 | {
      | ~^
Language: C++

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

vector<int> adj[100001];
queue<int> topsort;
int indeg[100001];
int dp[100001];

int main(){
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, m, a, b;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> a >> b;
        adj[a].push_back(b);
        indeg[b]++;
    }
    
    for(int i = 1; i <= n; i++) if(!indeg[i]) topsort.push(i);
    int node;
    while(topsort.size()){
        node = topsort.top();
        topsort.pop();
        for(unsigned int i = 0; i < adj[node].size(); i++){
            dp[adj[node][i]] = max(dp[node]+1, adj[node][i]);
            indeg[adj[node][i]]--;
            if(!indeg[adj[node][i]]) topsort.push(adj[node][i]);
        }
    }

    int maxi = -1;
    for(int i = 1; i <= n; i++) maxi = max(maxi,dp[i]);
    cout << maxi;

    return 0;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:24: error: 'class std::queue<int>' has no member named 'top'; did you mean 'pop'?
   29 |         node = topsort.top();
      |                        ^~~
      |                        pop
Language: C++

#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define Rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;
typedef long long int  ll;
typedef pair<int, int> P;

//cout << fixed << setprecision(10);//
//最小公倍数//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//べき//
ll squ(ll n, ll p, ll m){
	if(p==0) return 1;
	if(p%2==0){
		ll t=squ(n, p/2, m);
		return t*t%m;
	}
	return n*squ(n,p-1,m);
	
}


//逆元mod(mを法とするaの逆元)//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//nが大

ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}

	return k;
}



//


////////////////////////////////////////////////////////////////////
ll dp[100004];
vector <ll> deg[100004];
vector <ll> edge[100004];
 
void dfs(ll q){
	for(ll i=0;i<edge[q].size();i++){
 dp[edge[q][i]]=max(dp[edge[q][i]],dp[q]+1);
 if(dp[edge][q][i]<dp[q]+1){
dfs(edge[q][i]);
 }
 }
	}
 
 
 
 
int main() {
ll n,m;
cin>>n>>m;
 
 
 
 
rep(i, m){
	ll p,q;
	cin>>p>>q;
	edge[p].push_back(q);
	deg[q].push_back(p);
}
 
 
for(int i=1;i<=n;i++){
	dp[i]=-1;
}
for(int i=1;i<=n;i++){
if(deg[i].size()==0){
	dp[i]=0;
	edge[0].push_back(i);
}
}
 
 
	dfs(0);
 
 
ll ans=0;
for(int i=1;i<=n;i++){
	ans=max(ans,dp[i]);
}
 
 


Compiler output:
a.cc: In function 'void dfs(ll)':
a.cc:101:7: error: invalid types 'll [100004] {aka long long int [100004]}[std::vector<long long int> [100004]]' for array subscript
  101 |  if(dp[edge][q][i]<dp[q]+1){
      |       ^
a.cc: In function 'int main()':
a.cc:142:2: error: expected '}' at end of input
  142 | }
      |  ^
a.cc:110:12: note: to match this '{'
  110 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>
#define mod 1000000007

using namespace std;

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

    char arr[h][w];
    int dp[h+1][w+1]={0};

    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            cin>>arr[i][j];
        }
    }

    for(int i=0; i<=h; i++){
        for(int j=0; j<=w; j++){

            if(i==0 or j==0) dp[i][j]=0;
            else{
                if(arr[i][j]=='.'){
                    dp[i][j]=(dp[i-1][j])%mod + (dp[i][j-1])%mod);
                }
                if(i==1 and j==1) dp[i][j]=1;
            }
        }
    }

    cout<<dp[h][w];
    /*for(int i=0; i<=h; i++){
        for(int j=0; j<=w; j++){
            cout<<dp[i][j]<<"  ";
        }
        cout<<"\n";
    }*/

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:65: error: expected ';' before ')' token
   25 |                     dp[i][j]=(dp[i-1][j])%mod + (dp[i][j-1])%mod);
      |                                                                 ^
Language: C++

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

// メモ化再帰
int dp[100100];
int n, m;

int rec(int v, vector<vector<int>>&G){
    if (dp[v] != -1) return dp[v];
    int result = 0;
    
    for (auto nv : G[v]){
        result = max(result, rec(nv) + 1);
    }
    
    return dp[v] = result;
}

int main(){
    
    int n, m;
    cin >> n >> m;
    
    vector<vector<int>> G(n, vector<int>());
    
    // 有向グラフの入力
    
    for (int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        x--, y--;
        
        G[x].push_back(y);
    }
    
    // initialization
    for (int v = 0; v < n; v++) dp[v] = -1;
    
    
    //  DP の更新順序が非自明
    // 各点を調べる
    int ans = 0;
    for (int i = 0; i < n; i++) ans = max(ans, rec(i, G));
    cout << ans << endl;
}



Compiler output:
a.cc: In function 'int rec(int, std::vector<std::vector<int> >&)':
a.cc:14:33: error: too few arguments to function 'int rec(int, std::vector<std::vector<int> >&)'
   14 |         result = max(result, rec(nv) + 1);
      |                              ~~~^~~~
a.cc:9:5: note: declared here
    9 | int rec(int v, vector<vector<int>>&G){
      |     ^~~
Language: C++

#include <iostream>
using namespace std;

// メモ化再帰
int dp[100100];
int n, m;

int rec(int v,  vector<vector<int>>&G){
    if (dp[v] != -1) return dp[v];
    int result = 0;
    
    for (auto nv : G[v]){
        result = max(result, rec(nv) + 1);
    }
    
    return dp[v] = result;
}

int main(){
    
    int n, m;
    cin >> n >> m;
    
    vector<vector<int>> G(n, vector<int>());
    
    // 有向グラフの入力
    
    for (int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        x--, y--;
        
        G[x].push_back(y);
    }
    
    // initialization
    for (int v = 0; v < n; v++) dp[v] = -1;
    
    
    //  DP の更新順序が非自明
    // 各点を調べる
    int ans = 0;
    for (int i = 0; i < n; i++) ans = max(ans, rec(i, G));
    cout << ans << endl;
}



Compiler output:
a.cc:8:17: error: 'vector' has not been declared
    8 | int rec(int v,  vector<vector<int>>&G){
      |                 ^~~~~~
a.cc:8:23: error: expected ',' or '...' before '<' token
    8 | int rec(int v,  vector<vector<int>>&G){
      |                       ^
a.cc: In function 'int rec(int, int)':
a.cc:12:20: error: 'G' was not declared in this scope
   12 |     for (auto nv : G[v]){
      |                    ^
a.cc: In function 'int main()':
a.cc:24:5: error: 'vector' was not declared in this scope
   24 |     vector<vector<int>> G(n, vector<int>());
      |     ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:24:19: error: expected primary-expression before 'int'
   24 |     vector<vector<int>> G(n, vector<int>());
      |                   ^~~
a.cc:33:9: error: 'G' was not declared in this scope
   33 |         G[x].push_back(y);
      |         ^
a.cc:43:55: error: 'G' was not declared in this scope
   43 |     for (int i = 0; i < n; i++) ans = max(ans, rec(i, G));
      |                                                       ^
Language: C++

#include <iostream>
using namespace std;

// メモ化再帰
int dp[100100];
int n, m;

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

int main(){
    
    int n, m;
    cin >> n >> m;
    
    vector<vector<int>> G(n, vector<int>());
    
    // 有向グラフの入力
    
    for (int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        x--, y--;
        
        G[x].push_back(y);
    }
    
    // initialization
    for (int v = 0; v < n; v++) dp[v] = -1;
    
    
    //  DP の更新順序が非自明
    // 各点を調べる
    int ans = 0;
    for (int i = 0; i < n; i++) ans = max(ans, rec(i, G));
    cout << ans << endl;
}



Compiler output:
a.cc:8:16: error: expected identifier before '&' token
    8 | int rec(int v, &G){
      |                ^
a.cc: In function 'int rec(int, int&)':
a.cc:12:21: error: invalid types 'int[int]' for array subscript
   12 |     for (auto nv : G[v]){
      |                     ^
a.cc: In function 'int main()':
a.cc:24:5: error: 'vector' was not declared in this scope
   24 |     vector<vector<int>> G(n, vector<int>());
      |     ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:24:19: error: expected primary-expression before 'int'
   24 |     vector<vector<int>> G(n, vector<int>());
      |                   ^~~
a.cc:33:9: error: 'G' was not declared in this scope
   33 |         G[x].push_back(y);
      |         ^
a.cc:43:55: error: 'G' was not declared in this scope
   43 |     for (int i = 0; i < n; i++) ans = max(ans, rec(i, G));
      |                                                       ^
Language: C++

#include <iostream>
#include <array>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;
const int MAX = 1e5+5;

int dp[MAX];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N, M, x, y;
    cin >> N >> M;
    
    memset(dp, 0, MAX);
    
    for (int i=1; i<=M; i++) {
        cin >> x >> y;
        dp[y] = max(dp[y], dp[x]+1);
    }
    
    cout << *max_element(dp, dp+M+1) << "\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:14: error: 'max_element' was not declared in this scope
   26 |     cout << *max_element(dp, dp+M+1) << "\n";
      |              ^~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)
#define REPR(i,n) for(int i = n; i >= 0; i--)
#define FOR(i,m, n) for(int i = m-1; i < n; i++)
#define INF 2000000000
#define ALL(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))
//vector<intなど> 変数名(要素数,初期値)
using namespace std;
typedef long long ll;
//gcd,lcmセット
ll gcd(ll a, ll b){
   if (a%b == 0) return b;
   else return gcd(b, a%b);
}
ll lcm(ll a, ll b){	
   return a*b/gcd(a, b);
}
bool isPrime(ll x){
    int i;
    if(x < 2)return false;
    else if(x == 2) return true;
    if(x%2 == 0) return false;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return false;
    return true;
}
int n_max=100100;
int memo[100100];
vector<vector<int>> g(n_max);
int rec(int i){
    if(memo[i]!=-1) return memo[i];
    int res=0;
    for(auto nv:g[i]) {chmax(res, rec(nv) + 1);
                      /*cout<<"res="<<res<<"|"<<i<<"→"<<nv<<endl;*/}
    return memo[i]=res;
}
int main(){
    int n,m;
    cin>>n>>m;
  int x,y;
    REP(i,m) {
        cin>>x>>y;
        x--;
        y--;
        g[x].push_back(y);
    }
  /*REP(i,n){
    cout<<"x:"<<i<<"|";
    for(auto y:g[i]) cout<<y<<",";
  cout<<endl;*/
  }
   REP(i,n)memo[i]={-1};
    int res=0;
  	
    REP(i,n) chmax(res,rec(i));
    cout<<res<<endl;
}

Compiler output:
a.cc:2:18: error: expected unqualified-id before 'for'
    2 | #define REP(i,n) for(int i = 0; i < n; i++)
      |                  ^~~
a.cc:56:4: note: in expansion of macro 'REP'
   56 |    REP(i,n)memo[i]={-1};
      |    ^~~
a.cc:56:8: error: 'i' does not name a type
   56 |    REP(i,n)memo[i]={-1};
      |        ^
a.cc:2:33: note: in definition of macro 'REP'
    2 | #define REP(i,n) for(int i = 0; i < n; i++)
      |                                 ^
a.cc:56:8: error: 'i' does not name a type
   56 |    REP(i,n)memo[i]={-1};
      |        ^
a.cc:2:40: note: in definition of macro 'REP'
    2 | #define REP(i,n) for(int i = 0; i < n; i++)
      |                                        ^
a.cc:2:18: error: expected unqualified-id before 'for'
    2 | #define REP(i,n) for(int i = 0; i < n; i++)
      |                  ^~~
a.cc:59:5: note: in expansion of macro 'REP'
   59 |     REP(i,n) chmax(res,rec(i));
      |     ^~~
a.cc:59:9: error: 'i' does not name a type
   59 |     REP(i,n) chmax(res,rec(i));
      |         ^
a.cc:2:33: note: in definition of macro 'REP'
    2 | #define REP(i,n) for(int i = 0; i < n; i++)
      |                                 ^
a.cc:59:9: error: 'i' does not name a type
   59 |     REP(i,n) chmax(res,rec(i));
      |         ^
a.cc:2:40: note: in definition of macro 'REP'
    2 | #define REP(i,n) for(int i = 0; i < n; i++)
      |                                        ^
a.cc:60:5: error: 'cout' does not name a type
   60 |     cout<<res<<endl;
      |     ^~~~
a.cc:61:1: error: expected declaration before '}' token
   61 | }
      | ^
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#include <stdafx.h>
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif>

#define LL long long
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000

using namespace std;

const int N = 1e5 + 10;
int a[N];
int dp[N];
int visited[N];
vector<int>vec[N];
vector<int>vec2;
void dfs(int n, int c) {

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

	dp[n] = max(dp[n], c);
	visited[n] = 1;

	for (auto x : vec[n])
		if (visited[x] == 0 || c + 1 > dp[x])
		dfs(x, c + 1);

}
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		
		int u, v;
		scanf("%d%d", &u, &v);
		a[v]++;
		vec[u].push_back(v);
	}
  while(1);
    
	for (int i = 1; i <= n; i++)
		if (a[i] == 0)
			vec2.push_back(i);

	for (auto x : vec2)
		dfs(x, 0);

	//for (int i = 1; i <= n; i++)
		//if(!visited[i])
			//dfs(i, 0);
	
	int ans = 0;
	for (int i = 1; i <= n; i++)
		ans = max(ans, dp[i]);

	printf("%d", ans);
	//cin >> ans;
}



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

#include <iostream>
#include <vector>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

void dfs(vector<int> &dp, vector<vector<int>> &graph_f, vector<vector<int>> &graph_b, int v){
    for (int next_v : graph_b[v]){
        dp[next_v] =  max(dp[next_v], dp[v] + 1);
//        vector<int> &graph_f[next_v] = graph_f[next_v];
        graph_f[next_v].erase(remove(graph_f[next_v].begin(), graph_f[next_v].end(), v), graph_f[next_v].end());
        if (graph_f[next_v].empty()){
            dfs(dp, graph_f, graph_b, next_v);
        }
    }
}

int main(){
    int n, m; cin >> n >> m;
    vector<vector<int>> graph_f(n);
    vector<vector<int>> graph_b(n);
    rep(i, m){
        int x, y; cin >> x >> y;
        x--; y--;
        graph_f[x].push_back(y);
        graph_b[y].push_back(x);
    }
    vector<int> starts;
    rep(i, n){
        vector<int> outcome = graph_f[i];
        if (outcome.empty()) starts.push_back(i);
    }
    vector<int> dp(n, 0);
    for (int start : starts) dfs(dp, graph_f, graph_b, start);
    int ans = 0;
    rep(i, n) ans = max(ans, dp[i]);
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'void dfs(std::vector<int>&, std::vector<std::vector<int> >&, std::vector<std::vector<int> >&, int)':
a.cc:16:59: error: cannot convert 'std::vector<int>::iterator' to 'const char*'
   16 |         graph_f[next_v].erase(remove(graph_f[next_v].begin(), graph_f[next_v].end(), v), graph_f[next_v].end());
      |                                      ~~~~~~~~~~~~~~~~~~~~~^~
      |                                                           |
      |                                                           std::vector<int>::iterator
In file included from /usr/include/c++/14/cstdio:42,
                 from /usr/include/c++/14/ext/string_conversions.h:45,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/stdio.h:158:32: note:   initializing argument 1 of 'int remove(const char*)'
  158 | extern int remove (const char *__filename) __THROW;
      |                    ~~~~~~~~~~~~^~~~~~~~~~
Language: C++

#include <iostream>
#include <vector>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

void dfs(vector<int> &dp, vector<vector<int>> &graph_f, vector<vector<int>> &graph_b, int v){
    for (int next_v : graph_b[v]){
        dp[next_v] =  max(dp[next_v], dp[v] + 1);
        vector<int> &forward = graph_f[next_v];
        forward.erase(remove(forward.begin(), forward.end(), v), forward.end());
        if (forward.empty()){
            dfs(dp, graph_f, graph_b, next_v);
        }
    }
}

int main(){
    int n, m; cin >> n >> m;
    vector<vector<int>> graph_f(n);
    vector<vector<int>> graph_b(n);
    rep(i, m){
        int x, y; cin >> x >> y;
        x--; y--;
        graph_f[x].push_back(y);
        graph_b[y].push_back(x);
    }
    vector<int> starts;
    rep(i, n){
        vector<int> outcome = graph_f[i];
        if (outcome.empty()) starts.push_back(i);
    }
    vector<int> dp(n, 0);
    for (int start : starts) dfs(dp, graph_f, graph_b, start);
    int ans = 0;
    rep(i, n) ans = max(ans, dp[i]);
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'void dfs(std::vector<int>&, std::vector<std::vector<int> >&, std::vector<std::vector<int> >&, int)':
a.cc:16:43: error: cannot convert 'std::vector<int>::iterator' to 'const char*'
   16 |         forward.erase(remove(forward.begin(), forward.end(), v), forward.end());
      |                              ~~~~~~~~~~~~~^~
      |                                           |
      |                                           std::vector<int>::iterator
In file included from /usr/include/c++/14/cstdio:42,
                 from /usr/include/c++/14/ext/string_conversions.h:45,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/stdio.h:158:32: note:   initializing argument 1 of 'int remove(const char*)'
  158 | extern int remove (const char *__filename) __THROW;
      |                    ~~~~~~~~~~~~^~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
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; }
using namespace std;
using Graph = vector< vector<int> >;
int dp[100010];
int n,m;

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


int main(){
    cin >> n >> m;
  Graph G(n);
    for(int i=0;i<m;++i){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
    }
    for(int v=0;v<n;++v) dp[v] = -1;
    int res = 0;
    for(int v=0;v<n;++v) chmax(res,rec(v));
    cout << res << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int rec(int)':
a.cc:12:19: error: 'G' was not declared in this scope
   12 |     for(auto nv : G[v]){
      |                   ^
Language: C++

#include <bits/stdc++.h>
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; }
using namespace std;
using Graph = vector< vector<int> >;
int dp[100010];
int n,m;

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


int main(){
    cin >> n >> m;
    for(int i=0;i<m;++i){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
    }
    for(int v=0;v<n;++v) dp[v] = -1;
    int res = 0;
    for(int v=0;v<n;++v) chmax(res,rec(v));
    cout << res << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int rec(int)':
a.cc:12:19: error: 'G' was not declared in this scope
   12 |     for(auto nv : G[v]){
      |                   ^
a.cc: In function 'int main()':
a.cc:24:9: error: 'G' was not declared in this scope
   24 |         G[a].push_back(b);
      |         ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,m,k,u,v,fix[100005],length[100005];
vector<int>V[100005];
int go(int u){
	
	if(fix[u]) return length[u];
	fix[u]=1;
	for(int i=0;i<V[u].size();i++){
		length[u]=max(length[u],go(V[u][i])+1);
	}
	return length[u];
}
int main(){
	cin>>n>>m;
	for(k=1;k<=m;k++){
		cin>>u>>v;
		V[v].push_back(u);
	}
	
	for(k=1;k<=n;k++){
		if(fix[k]==0){
			go(k);
		}
		ans=max(ans,length[k]);
	}
	cout<<ans;
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   25 |                 ans=max(ans,length[k]);
      |                 ^~~
      |                 abs
a.cc:27:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   27 |         cout<<ans;
      |               ^~~
      |               abs
Language: C++

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

int dfs(vector<vector<int>>& graph,int k,vector<int>& vis, int& res)
{
	if(!vis[k])
    {
        int x=0;
        for(int i=0;i<graph[k].size();++i)
        {
        	x=max(x,dfs(graph,graph[k][i],vis,res));
        }	
        vis[k]=x+1;
        res=max(res,vis[k]);
        return vis[k];
    }
    return vis[k];
}

int main() {
	
	vector<int> vis(100005,0);
	int n,m,x,y;
	cin>>n>>m;
	vector<vecotr<int>>graph(n+1);
	for(int i=0;i<m;i++)
	{
		cin>>x>>y;
		graph[x].push_back(y);
	}
	int res = 0;
	for(int i=1;i<=n;i++)
	{
		if(vis[i]==0)
		dfs(graph,i,vis,res);
	}
	
	cout<<res;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:16: error: 'vecotr' was not declared in this scope
   25 |         vector<vecotr<int>>graph(n+1);
      |                ^~~~~~
a.cc:25:26: error: template argument 1 is invalid
   25 |         vector<vecotr<int>>graph(n+1);
      |                          ^~
a.cc:25:26: error: template argument 2 is invalid
a.cc:29:22: error: invalid types 'int[int]' for array subscript
   29 |                 graph[x].push_back(y);
      |                      ^
a.cc:35:21: error: invalid initialization of reference of type 'std::vector<std::vector<int> >&' from expression of type 'int'
   35 |                 dfs(graph,i,vis,res);
      |                     ^~~~~
a.cc:4:30: note: in passing argument 1 of 'int dfs(std::vector<std::vector<int> >&, int, std::vector<int>&, int&)'
    4 | int dfs(vector<vector<int>>& graph,int k,vector<int>& vis, int& res)
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~~
Language: C++

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

int dfs(vector<vector<int>>& graph,int k,vector<int>& vis, int& res)
{
	if(!vis[k])
    {
        int x=0;
        for(int i=0;i<graph[k].size();++i)
        {
        	x=max(x,dfs(graph,graph[k][i],vis,res));
        }	
        vis[k]=x+1;
        res=max(res,vis[k]);
        return vis[k];
    }
    return vis[k];
}

int main() {
	
	vector<int> vis(100005,0);
	int n,m,x,y;
	cin>>n>>m;
	vector<<vecotr<int>>graph(n+1);
	for(int i=0;i<m;i++)
	{
		cin>>x>>y;
		graph[x].push_back(y);
	}
	int res = 0;
	for(int i=1;i<=n;i++)
	{
		if(vis[i]==0)
		dfs(graph,i,vis,res);
	}
	
	cout<<res;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:15: error: expected unqualified-id before '<<' token
   25 |         vector<<vecotr<int>>graph(n+1);
      |               ^~
a.cc:29:17: error: 'graph' was not declared in this scope; did you mean 'isgraph'?
   29 |                 graph[x].push_back(y);
      |                 ^~~~~
      |                 isgraph
a.cc:35:21: error: 'graph' was not declared in this scope; did you mean 'isgraph'?
   35 |                 dfs(graph,i,vis,res);
      |                     ^~~~~
      |                     isgraph
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
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; }
ll dx[8]={0,1,0,-1,1,1,-1,-1};
ll dy[8]={1,0,-1,0,1,-1,1,-1};
vll dp(100010);
ll rec(ll i,vvll &t){
  if(dp[i]!=-1) return dp[i];
  ll res=0;
  for(auto nv:t[i]){
    chmax(res,rec(nv,t)+1);
  }
  return dp[i]=res;
}
int main(){
  ll n,m;
  cin>>n>>m;
  vvll t(n,vll(0));
  rep(i,m){
    ll a,b;
    cin>>a>>b;
    a--;
    b--;
    t[a].pb(b);
  }
  rep(i,n) dp[i]=-1;
  ll ans=0;
  rep(i,n){
    ans=chmax(rec(i,t),ans);
  }
  COUT(ans);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:68:18: error: cannot bind non-const lvalue reference of type 'long long int&' to an rvalue of type 'long long int'
   68 |     ans=chmax(rec(i,t),ans);
      |               ~~~^~~~~
a.cc:41:40: note:   initializing argument 1 of 'bool chmax(T&, T) [with T = long long int]'
   41 | template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
      |                                     ~~~^
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
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; }
ll dx[8]={0,1,0,-1,1,1,-1,-1};
ll dy[8]={1,0,-1,0,1,-1,1,-1};
vll dp(100010);
ll rec(ll i,vvll &t){
  if(dp[i]!=-1) return dp[i];
  ll res=0;
  for(auto nv:t[i]){
    chmax(res,rec(nv,t)+1);
  }
  return dp[i]=res;
}
int main(){
  ll n,m;
  cin>>n>>m;
  vvll t(n,vll(0));
  rep(i,m){
    ll a,b;
    cin>>a>>b;
    a--;
    b--;
    t[a].pb(b);
  }
  rep(i,n) dp[i]=-1;
  ll ans=0;
  rep(i,n){
    ans=chmax(rec(i),ans);
  }
  COUT(ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:68:18: error: too few arguments to function 'long long int rec(long long int, vvll&)'
   68 |     ans=chmax(rec(i),ans);
      |               ~~~^~~
a.cc:46:4: note: declared here
   46 | ll rec(ll i,vvll &t){
      |    ^~~
Language: C++

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> child;
  vector<int> parent;
  rep(i, n) parent[i] = 0;
  int x, y;
  rep(i, m) {
    cin >> x >> y;
    x--; y--;
    parent[y]++;
    child[x].push_back(y);
  }
  
  vector<int> dp(n);
  queue<int> nodes;
  rep(i, n) {if (parent[i] == 0) nodes.push(i); dp[i].first = 0;}
  
  while (nodes.size()) {
    int j = nodes.front(); nodes.pop();
    
    rep(k, child[j].size()) {
      int c = child[j][k];
      dp[c] = max(dp[j] + 1, dp[c]);
      parent[c]--;
      if (parent[c] == 0) nodes.push(c);
    }
  }
  
  int max = 0;
  rep(i, n) if (max < dp[i]) max = dp[i];
  cout << max << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:55: error: request for member 'first' in 'dp.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   23 |   rep(i, n) {if (parent[i] == 0) nodes.push(i); dp[i].first = 0;}
      |                                                       ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std ;
#define ll long long int 
#define pb push_back 
int main()
{
    ll m , n ;
    cin >> n >> m;
    std::vector<vector<ll>> graph(n),rev(n) ;
    for(ll i =0 ; i <m ; i++)
{
    ll a ,b ;
    cin>>a >>b ;
    a-- ;b-- ;
    graph[a].pb(b) ;
    rev[b].pb(a) ;
    
}
vector<ll> dis(n,0) , null ;
stack<ll>s ;
for( ll i =0 ; i< n ;i++)
{
    if(graph[i].empty())
    {
        s.push(i) ;
    }
}

m = 0;
while(!s.empty() )
{
    
    m =max(m , dis[i] ) ;
     ll j = s.top() ;
    s.pop() ;
    if(!rev[j].empty())
    for(auto i : rev[j])
    {
        dis[i] = max(dis[i] , dis[j]+1) ;
        if(dis[i]==dis[j]+1)
        s.push(i) ;
    }
    
} 

cout<< m ;
return 0 ;


}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:20: error: 'i' was not declared in this scope
   33 |     m =max(m , dis[i] ) ;
      |                    ^
Language: C++

# include<bits/stdc++.h>
# include<unordered_map>
# include<unordered_set>
# include<prettyprint.hpp>
using namespace std;
# define ll long long
// # define ll int
# define vll vector<ll>
# define vvll vector<vector<ll> >
# define vchar vector<char>
# define vstr vector<string>
# define vpll vector<pair<ll, ll> >
# define mll map<ll, ll>
# define sll set<ll>
# define usll unordered_set<ll>
# define schar set<char>
# define pll pair<ll, ll>
# define append_left push_front
# define append push_back
# define pop_left pop_front
# define popb pop_back
# define add insert
# define all(v) v.begin(), v.end()
# define rall(v) v.rbegin(), v.rend()
# define loop(i, k, n, inc) for(ll i = k; i < n; i+=inc)
# define rloop(i, k, n, inc) for(ll i = k; i > n; i+=inc)
vll vin(ll n){vll a(n);loop(i, 0, n, 1) cin>>a[i];return a;}
ll intin() {ll n; cin>>n; return n;}
char charin(){char a; cin>>a; return a;}
string strin(){string s; cin>>s; return s;}
ll factorial(ll n){return (n==1 || n==0) ? 1: n * factorial(n - 1);}
ll n, m;
vvll d;
vll ts, vis;
void dfs(ll v){
    vis[v] = 1;
    for(auto i:d[v]) if (!vis[i]) dfs(i);
    ts.append(v);
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>m;
    d.resize(n);
    vis.resize(n, 0);
    ll x, y;
    loop(i, 0, m ,1){
        cin>>x>>y;
        d[x].append(y);
    }
    loop(i , 0, n, 1){
        if (!vis[i]) dfs(i);
    }
    reverse(all(ts));
    vll dist(n, -1);
    for(auto i:ts){
        if (dist[i] == -1) dist[i] = 0;
        for(auto j:d[i]) dist[j] = max(dist[j], dist[i]+1);
    }
    ll ans = *max_element(all(dist));
    cout<<ans+1<<endl;
    return 0;
}

Compiler output:
a.cc:4:10: fatal error: prettyprint.hpp: No such file or directory
    4 | # include<prettyprint.hpp>
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
Language: Java

import javax.swing.*;
import java.io.*;
import java.sql.Struct;
import java.util.*;

public class FightAgainstTraffic {


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

        ArrayList<Integer>[] graph = new ArrayList[n];
        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            graph[i] = new ArrayList<Integer>();
            arr[i] = -1;
        }

        for (int i = 0; i < m; i++) {
            int start = sc.nextInt();
            int end = sc.nextInt();
            graph[start - 1].add(end - 1);
        }

        int length = 0;
        for (int i = 0; i < n; i++) {
           int curLength = calculate(i, graph, arr);
           if (curLength > length) {
               length = curLength;
            }
        }
        System.out.println(length);
    }

    static int calculate(int vertex,  ArrayList<Integer>[] graph, int[] arr) {
        if (arr[vertex] != -1) {
            return arr[vertex];
        }
        int length = 0;
        for(int i = 0; i < graph[vertex].size(); i++) {
            int neghbourLength = calculate(graph[vertex].get(i), graph, arr);
            if (neghbourLength + 1 > length) {
                length = neghbourLength + 1;
            }
        }
        arr[vertex] = length;
        return length;
    }
}

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

#include <iostream>
#include <stack>
#include <vector>

using namespace std;

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

  int dpt[n];
  int indegree[n];
  for (int i = 0; i < n; i++) { dpt[i] = indegree[i] = 0; }

  vector<int> s2t(n);
  for (int i = 0; i < m; i++) {
    int s, t;
    cin >> s >> t;
    s2t[s - 1].push_back(t - 1);
    indegree[t - 1]++;
  }

  stack<int> st;
  for (int i = 0; i < n; i++) {
    if (indegree[i] == 0) {
      dpt[i] = 0;
      st.push(i);
    }
  }

  while (!st.empty()) {
    int s = st.top();
    st.pop();
    for (int i = 0; i < s2t[s].size(); i++) {
      int t = s2t[s][i];
      dpt[t] = max(dpt[t], dpt[s] + 1);
      indegree[t]--;
      if (indegree[t] == 0) { st.push(t); }
    }
  }

  int res = 0;
  for (int i = 0; i < n; i++) { res = max(res, dpt[i]); }

  cout << res << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:19:16: error: request for member 'push_back' in 's2t.std::vector<int>::operator[](((std::vector<int>::size_type)(s - 1)))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   19 |     s2t[s - 1].push_back(t - 1);
      |                ^~~~~~~~~
a.cc:34:32: error: request for member 'size' in 's2t.std::vector<int>::operator[](((std::vector<int>::size_type)s))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   34 |     for (int i = 0; i < s2t[s].size(); i++) {
      |                                ^~~~
a.cc:35:21: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   35 |       int t = s2t[s][i];
      |                     ^