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

////=====BIsmillahir Rahmanir Rahim =====////

/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
         Comilla University

*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long maX=1e5+5;
vector<ll>ara[maX];
ll dp[maX];
ll visit[maX];
ll dfs(ll x){
    if(visit[x])return dp[x];
    ll ans=0;
    for(ll i=0;i<ara[x].size();i++){
        ans=max(ans,1+dfs(ara[x][i]));
    }
    visit[x]=1;
    return dp[x]=ans;
}
int main(){
    ll n,m;
    cin>>n>>m;
    for(ll i=1;i<=m;i++){
        ll x,y;cin>>x>>y;
        ara[x].push_back(y);
    }
    ll mx=-1;
    for(ll i=1;i<=n;i++){
        ll x=dfs(i);
        mx=max(mx,dp[i]);
    }
    cout<<mx<<endl;
return 0;
}


Compiler output:
a.cc: In function 'long long int dfs(long long int)':
a.cc:21:8: error: reference to 'visit' is ambiguous
   21 |     if(visit[x])return dp[x];
      |        ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:13:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:19:4: note:                 'long long int visit [100005]'
   19 | ll visit[maX];
      |    ^~~~~
a.cc:26:5: error: reference to 'visit' is ambiguous
   26 |     visit[x]=1;
      |     ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:19:4: note:                 'long long int visit [100005]'
   19 | ll visit[maX];
      |    ^~~~~
Language: C++

#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
#include <atcoder/all>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x-I .)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false;}

int main(){
    int N, M, x, y;
    cin >> N >> M;
    vector<int> in(N,0);
    vector<vector<int>> G(N, vector<int>());
    vector<int> dist(N, -1);
    rep(i,M){
        cin >> x >> y;
        --x; --y;
        G[x].push_back(y);
        ++in[y];
    }
    queue<int> Q;
    rep(i,N)if(in[i] == 0){Q.push(i); dist[i] = 0;}
    while(!Q.empty()){
        int f = Q.front();
        Q.pop();
        for(auto t:G[f]){
            --in[t];
            if(in[t] == 0)Q.push(t);
            chmax(dist[t], dist[f] + 1);            
        }
    }
    int ans = 0;
    rep(i,N)chmax(ans, dist[i]);
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc:14:10: fatal error: atcoder/all: No such file or directory
   14 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
unordered_map<int, vector<int>> mp;
int memo[100000];
bool visit[100000];
int dp(int s){
	if(visit[s]==1)
		return memo[s];
	visit[s] =1;
	for(int i:mp[s]){
		memo[s]=max(memo[s],dp(i)+1);
	}
	return memo[s];
}
void solve(){
	int n, m; cin>>n>>m;
	for (int i = 0; i < m; ++i)
	{
		int x, y; cin>>x>>y;
		mp[x].push_back(y);
	}
	for(int i=1;i<=n;i++){
		memo[i] = max(memo[i], dp(i));
	}
	int ans = INT_MIN;
	for (int i = 1; i <=n; ++i)
	{
		ans= max(ans, memo[i]);
	}
	cout<<ans<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // ll t; cin>>t;
    // while(t--)
        solve();
    return 0;
}



Compiler output:
a.cc: In function 'int dp(int)':
a.cc:8:12: error: reference to 'visit' is ambiguous
    8 |         if(visit[s]==1)
      |            ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:6:6: note:                 'bool visit [100000]'
    6 | bool visit[100000];
      |      ^~~~~
a.cc:10:9: error: reference to 'visit' is ambiguous
   10 |         visit[s] =1;
      |         ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:6:6: note:                 'bool visit [100000]'
    6 | bool visit[100000];
      |      ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
unordered_map<int, vector<int>> mp;
int memo[100000];
int visit[100000] ;
int dp(int s){
	if(visit[s]==1)
		return memo[s];
	visit[s] =1;
	for(int i:mp[s]){
		memo[s]=max(memo[s],dp(i)+1);
	}
	return memo[s];
}
void solve(){
	int n, m; cin>>n>>m;
	for (int i = 0; i < m; ++i)
	{
		int x, y; cin>>x>>y;
		mp[x].push_back(y);
	}
	for(int i=1;i<=n;i++){
		memo[i] = max(memo[i], dp(i));
	}
	int ans = INT_MIN;
	for (int i = 1; i <=n; ++i)
	{
		ans= max(ans, memo[i]);
	}
	cout<<ans<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // ll t; cin>>t;
    // while(t--)
        solve();
    return 0;
}



Compiler output:
a.cc: In function 'int dp(int)':
a.cc:8:12: error: reference to 'visit' is ambiguous
    8 |         if(visit[s]==1)
      |            ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:6:5: note:                 'int visit [100000]'
    6 | int visit[100000] ;
      |     ^~~~~
a.cc:10:9: error: reference to 'visit' is ambiguous
   10 |         visit[s] =1;
      |         ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:6:5: note:                 'int visit [100000]'
    6 | int visit[100000] ;
      |     ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
unordered_map<int, vector<int>> mp;
int memo[100000]={0};
int visit[100000] = {0};
int dp(int s){
	if(visit[s]==1)
		return memo[s];
	visit[s] =1;
	for(int i:mp[s]){
		memo[s]=max(memo[s],dp(i)+1);
	}
	return memo[s];
}
void solve(){
	int n, m; cin>>n>>m;
	for (int i = 0; i < m; ++i)
	{
		int x, y; cin>>x>>y;
		mp[x].push_back(y);
	}
	for(int i=1;i<=n;i++){
		memo[i] = max(memo[i], dp(i));
	}
	int ans = INT_MIN;
	for (int i = 1; i <=n; ++i)
	{
		ans= max(ans, memo[i]);
	}
	cout<<ans<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // ll t; cin>>t;
    // while(t--)
        solve();
    return 0;
}



Compiler output:
a.cc: In function 'int dp(int)':
a.cc:8:12: error: reference to 'visit' is ambiguous
    8 |         if(visit[s]==1)
      |            ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:6:5: note:                 'int visit [100000]'
    6 | int visit[100000] = {0};
      |     ^~~~~
a.cc:10:9: error: reference to 'visit' is ambiguous
   10 |         visit[s] =1;
      |         ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:6:5: note:                 'int visit [100000]'
    6 | int visit[100000] = {0};
      |     ^~~~~
Language: C++

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

int fun(vector<int> graph[], int src, int dp[]){
	if(graph[src].size() == 0){
		return 0;
	}
	if(dp[src] != -1){
		return dp[src];
	}
	int ans = 0;
	for(auto x : graph[src]){
		int temp = 1 + fun(graph, x, dp);
		ans = max(ans, temp);
	}

	return dp[src] = ans;
}

int Solve(vector<int> graph[], int n){
	int dp[100002];
	memset(dp, -1, sizeof(dp));
	int res = 0;
	for(int i = 1; i <= n; i++){
		res = max(res, func(graph, i, dp));
	}
	return res;
}



int main(){


	int n, m, u, v;
	cin>>n>>m;

	vector<int> graph[100002];

	for(int i = 1; i <= m; i++){
		cin>>u>>v;
		graph[u].push_back(v);
	}

	// for(int i = 1; i <= n; i++){
	// 	cout<<i<<" --> ";
	// 	for(auto x : graph[i]){
	// 		cout<<x<<" ";
	// 	}
	// 	cout<<endl;
	// }

	cout<<Solve(graph, n)<<'\n';
	// cout<<graph[4].size();

}


Compiler output:
a.cc: In function 'int Solve(std::vector<int>*, int)':
a.cc:28:32: error: 'func' was not declared in this scope; did you mean 'fun'?
   28 |                 res = max(res, func(graph, i, dp));
      |                                ^~~~
      |                                fun
Language: C++

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

int fun(vector<int> graph[], int src, int dp[]){
	if(graph[src].size() == 0){
		return 0;
	}
	if(dp[src] != -1){
		return dp[src];
	}
	int ans = 0;
	for(auto x : graph[src]){
		int temp = 1 + fun(graph, x, dp);
		ans = max(ans, temp);
	}

	return dp[src] = ans;
}

int Solve(vector<int> graph[], int n){
	int dp[100002];
	memset(dp, -1, sizeof(dp));
	int res = 0;
	for(int i = 1; i <= n; i++){
		res = max(res, function(graph, i, dp));
	}
	return res;
}



int main(){


	int n, m, u, v;
	cin>>n>>m;

	vector<int> graph[100002];

	for(int i = 1; i <= m; i++){
		cin>>u>>v;
		graph[u].push_back(v);
	}

	// for(int i = 1; i <= n; i++){
	// 	cout<<i<<" --> ";
	// 	for(auto x : graph[i]){
	// 		cout<<x<<" ";
	// 	}
	// 	cout<<endl;
	// }

	cout<<Solve(graph, n)<<'\n';
	// cout<<graph[4].size();

}


Compiler output:
a.cc: In function 'int Solve(std::vector<int>*, int)':
a.cc:28:32: error: 'function' was not declared in this scope
   28 |                 res = max(res, function(graph, i, dp));
      |                                ^~~~~~~~
a.cc:5:1: note: 'std::function' is defined in header '<functional>'; this is probably fixable by adding '#include <functional>'
    4 | #include<cstring>
  +++ |+#include <functional>
    5 | using namespace std;
Language: C++

#include <iostream>
#include <deque>
#include <vector>
#include <cmath>
#define inf 99999999
using namespace std;
int a,b;
int max1;
deque<int> dp[100001];
long long int cal(int idx,int path){
    for(;!dp[idx].empty();){
        int temp3=dp[idx].front();
        dp[idx].pop_front();
        cal(temp3,path+1);
    }
    if(max1<path){
        max1=path;
    }
    return max1;
}
int main()
{
    int temp1;
    int temp2;
    while(cin>>a>>b){
        for(int i=1;i<b+1;i++){
            cin>>temp1>>temp2;
            dp[temp1].push_back(temp2);
        }
        max1=0;
        for(int i=1;i<=a;i++){
            ma[i-1]=cal(i,0);
        }
        cout<<max1<<endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:13: error: 'ma' was not declared in this scope; did you mean 'fma'?
   32 |             ma[i-1]=cal(i,0);
      |             ^~
      |             fma
Language: C++

#include<bits/stdc++.h>

int N, M, x, y;
vector <int> adj[100005];
int dis[100005];
using namespace std;
int dfs(int cur){
	if(dis[cur] != 1) return dis[cur];
	int maxtemp = 0;
	for(auto j : adj[cur]){
		maxtemp = max(maxtemp, dis[j]);
	}
	dis[cur] += maxtemp;
	return dis[cur];
}
int main(){
	scanf("%d%d", &N, &M);
	for(int i = 0 ; i<M ;  i++){
		scanf("%d%d", &x, &y);
		adj[x].push_back(y);
	}
	fill(dis,dis+N+1,1);
	int maxdis = 0;
	for(int i = 1 ; i<=N ; i++){
		maxdis = max(maxdis, dfs(i));
	}
	cout << maxdis <<endl;
}

Compiler output:
a.cc:4:1: error: 'vector' does not name a type
    4 | vector <int> adj[100005];
      | ^~~~~~
a.cc: In function 'int dfs(int)':
a.cc:10:22: error: 'adj' was not declared in this scope
   10 |         for(auto j : adj[cur]){
      |                      ^~~
a.cc: In function 'int main()':
a.cc:20:17: error: 'adj' was not declared in this scope
   20 |                 adj[x].push_back(y);
      |                 ^~~
Language: C++

#include<bits/stdc++.h>
int dp[100005];
vector<vector<int> > v;
int solve(int src)
{

    if(dp[src]!=-1)
        return dp[src];
    int best=0;
    bool leaf=1;
    for(auto i:v[src])
    {
        leaf=0;
        best=max(best,solve(i));
    }
    return dp[i]= leaf? 0: 1+ best;
}
int main()
{

    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        v[x].push_back(y);


    }
    memset(dp,-1,sizeof dp);
    int ans=0;
    for(int i=0;i<n;i++)
        ans=max(ans,solve(i));

        cout<<ans;

    return 0;

}


Compiler output:
a.cc:3:1: error: 'vector' does not name a type
    3 | vector<vector<int> > v;
      | ^~~~~~
a.cc: In function 'int solve(int)':
a.cc:11:16: error: 'v' was not declared in this scope
   11 |     for(auto i:v[src])
      |                ^
a.cc:14:14: error: 'max' was not declared in this scope; did you mean 'std::max'?
   14 |         best=max(best,solve(i));
      |              ^~~
      |              std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:16:15: error: 'i' was not declared in this scope
   16 |     return dp[i]= leaf? 0: 1+ best;
      |               ^
a.cc: In function 'int main()':
a.cc:22:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   22 |     cin>>n>>m;
      |     ^~~
      |     std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:27:9: error: 'v' was not declared in this scope
   27 |         v[x].push_back(y);
      |         ^
a.cc:34:13: error: 'max' was not declared in this scope; did you mean 'std::max'?
   34 |         ans=max(ans,solve(i));
      |             ^~~
      |             std::max
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:36:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   36 |         cout<<ans;
      |         ^~~~
      |         std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) (((n) >> (k)) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = true;
}  // namespace mydef
using namespace mydef;
#define pb push_back
//#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

#include "mylibrary/graph/Graph.hpp"

Graph<int> G;
int N, M;

int memo[101010];

int f(int x) {
    if (memo[x])
        return memo[x];
    int ret = 0;
    for (auto& nxt : G[x])
        chmax(ret, f(nxt) + 1);
    return memo[x] = ret;
}

void solve() {
    G.reverse();
    int ans = 0;
    for (int i = 0; i < N; i++) {
        chmax(ans, f(i));
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    cin >> N >> M;
    G.build_directed(N, M);

    solve();
    return 0;
}


Compiler output:
a.cc:80:10: fatal error: mylibrary/graph/Graph.hpp: No such file or directory
   80 | #include "mylibrary/graph/Graph.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

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

vector<vector<int>> g;
vector<int> dp;
int ans = INT_MIN;

int dfs(int v) {
  if (dp[v] != -1) {
    return dp[v];
  }
  int path = 0;
  for (auto c : g[v]) {
    path = max(path, 1 + dfs(c));
  }
  ans = max(ans, path);
  dp[v] = path;
  return path;
}

int main() {
  int n, m;
  cin >> n >> m;
  g.assign(n, vector<int>());
  dp.assign(n, -1);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    cin >> u >> v;
    --u;
    --v;
    g[u].push_back(v);
  }
  for (int i = 0; i < n; ++i) {
    if (dp[i] == -1) {
      dfs(i);
    }
  }
  cout << ans << '\n';
  return 0;
}



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

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long int lli;
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<pll> vop;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define REP(i,a,b) for( long long i=a;i<b;i++)
#define REPR(i,a,b) for(long long i=a;i>=b;i--)
#define adb(a) for(auto ii:a) cout << ii << " "; cout << endl
#define adp(a) for(auto ii:a) cout << ii.F << " " << ii.S << endl;
#define PB push_back
vl g[N];
bool vis[N];
ll dis[N];
ll ans = 0;

void dfs(ll v)
{
    vis[v] = true;
    for (auto u : g[v])
    {
        if (!vis[u])
            dfs(u);
        dis[v] = max(dis[v], 1 + dis[u]);
    }
}

int main()
{


    fastIO;
    int test = 1, num = 1;
    //cin >> test;
    while (test--)
    {
        ll n, m;
        cin >> n >> m;
        REP(i, 0, m)
        {
            ll u, v;
            cin >> u >> v;
            g[u].PB(v);
        }
        REP(i, 1, n + 1)
        {
            if (!vis[i])
            {
                dfs(i);
            }
        }
        REP(i, 1, n + 1) ans = max(ans, dis[i]);
        cout << ans << endl;
    }
    return 0;
}

Compiler output:
a.cc:20:6: error: 'N' was not declared in this scope
   20 | vl g[N];
      |      ^
a.cc:21:10: error: 'N' was not declared in this scope
   21 | bool vis[N];
      |          ^
a.cc:22:8: error: 'N' was not declared in this scope
   22 | ll dis[N];
      |        ^
a.cc: In function 'void dfs(ll)':
a.cc:27:5: error: 'vis' was not declared in this scope; did you mean 'vi'?
   27 |     vis[v] = true;
      |     ^~~
      |     vi
a.cc:28:19: error: 'g' was not declared in this scope
   28 |     for (auto u : g[v])
      |                   ^
a.cc:32:9: error: 'dis' was not declared in this scope; did you mean 'div'?
   32 |         dis[v] = max(dis[v], 1 + dis[u]);
      |         ^~~
      |         div
a.cc: In function 'int main()':
a.cc:51:13: error: 'g' was not declared in this scope
   51 |             g[u].PB(v);
      |             ^
a.cc:55:18: error: 'vis' was not declared in this scope; did you mean 'vi'?
   55 |             if (!vis[i])
      |                  ^~~
      |                  vi
a.cc:60:41: error: 'dis' was not declared in this scope; did you mean 'div'?
   60 |         REP(i, 1, n + 1) ans = max(ans, dis[i]);
      |                                         ^~~
      |                                         div
Language: Java

import java.util.Arrays;
import java.util.*;
class longpath
{
	static ArrayList<Integer> adj[];
	static int ans;
	public static void main (String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int i;
		int n=sc.nextInt(); int m=sc.nextInt();
		adj=new ArrayList[n]; ans=0;
		for(i=0;i<n;i++)
			adj[i]=new ArrayList();
		for(i=0;i<m;i++) 
		{
			int u=sc.nextInt()-1; int v=sc.nextInt()-1;
			adj[u].add(v); 
		}
		for(i=0;i<n;i++)
			dfs(i,0);	
		System.out.println(ans);
	}
	public static void dfs(int v,int l)
	{
		if(l>ans)
			ans=l;
		for(int node:adj[v])
			dfs(node,l+1);
	}
} 

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

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

void dfs(int v,vector<int> adj[], int dp[], bool vis[])
{
  vis[v] = true; 
  for(int i=0;i<adj[v].size();i++)
  {
    if (!vis[adj[v][i]]) 
            dfs(adj[v][i], adj, dp, vis); 
    dp[node] = max(dp[v], 1 + dp[adj[v][i]]);
  }
}

int main()
{
  int n,m;
  cin>>n>>m;
  vector<int> Graph[n+1];
  int i;
  vector<int> Indegree(n+1,0);
  int x,y;
  for(i=0;i<n;i++)
  {
    cin>>x>>y;
    Graph[x].push_back(y);
    Indegree[y]++;
  }
  int dp[n+1]={0};
  bool vis[n + 1]; 
    memset(vis, false, sizeof vis);
    for (int i = 1; i <= n; i++) { 
        if (!vis[i]) 
            dfs(i, Graph, dp, vis); 
    } 
    int ans = 0; 
  
    // Traverse and find the maximum of all dp[i] 
    for (int i = 1; i <= n; i++) { 
        ans = max(ans, dp[i]); 
    }
  cout<<ans<<endl;
    
}


Compiler output:
a.cc: In function 'void dfs(int, std::vector<int>*, int*, bool*)':
a.cc:12:8: error: 'node' was not declared in this scope
   12 |     dp[node] = max(dp[v], 1 + dp[adj[v][i]]);
      |        ^~~~
Language: C++

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

void dfs(int v,vector<int> adj[], int dp[], bool vis[])
{
  vis[node] = true; 
  for(int i=0;i<adj[v].size();i++)
  {
    if (!vis[adj[node][i]]) 
            dfs(adj[node][i], adj, dp, vis); 
    dp[node] = max(dp[node], 1 + dp[adj[node][i]]);
  }
}

int main()
{
  int n,m;
  cin>>n>>m;
  vector<int> Graph[n+1];
  int i;
  vector<int> Indegree(n+1,0);
  int x,y;
  for(i=0;i<n;i++)
  {
    cin>>x>>y;
    Graph[x].push_back(y);
    Indegree[y]++;
  }
  int dp[n+1]={0};
  bool vis[n + 1]; 
    memset(vis, false, sizeof vis);
    for (int i = 1; i <= n; i++) { 
        if (!vis[i]) 
            dfs(i, Graph, dp, vis); 
    } 
    int ans = 0; 
  
    // Traverse and find the maximum of all dp[i] 
    for (int i = 1; i <= n; i++) { 
        ans = max(ans, dp[i]); 
    }
  cout<<ans<<endl;
    
}

Compiler output:
a.cc: In function 'void dfs(int, std::vector<int>*, int*, bool*)':
a.cc:7:7: error: 'node' was not declared in this scope
    7 |   vis[node] = true;
      |       ^~~~
Language: C++

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

#define ll long long 

const int N=100001;
vector<ll>g[N];
ll dp[N];

ll solve(ll src)
{
	if(dp[src]!=-1)
	{
		return(dp[src]);
	}
	ll ans=INT_MIN;
	for(auto x:g[src])
	{
		ans=max(ans,solve(x));
	}
	if(ans==INT_MIN)
	{
		return(0);
	}
	return(dp[src]=ans+1);
}

int main()
{
	ll i;
	ll n,m,x,y;
	cin>>n>>m;
	memset(dp,-1,sizeof(dp));
	ll ans=0;
	for(i=0;i<m;i++)
	{
		cin>>x>>y;
		g[x].push_back(y);
	}
	for(i=1;i<=n;i++)
	{
		if(dp[i]==-1)
		{
			ans=max(ans,solve(i));
		}
		else
		{
			ans=max(ans,dp[i]);
		}
	}
	cout<<ans<<"\n";
}

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

#include "bits/stdc++.h"
using namespace std;
 
using ll = long long;
 
const ll inf = 1e18;
const int N = 2 * 1e5 + 10;

ll res;
ll a[N];
ll visit[N];
std::vector<ll> v[N], vv;

void dfs(ll node){
	visit[node] = 1;
	for(auto i : v[node]){
		if(!visit[i]){
			dfs(i);
		}
	}
	vv.push_back(node);
}

void solve(){
	ll n, m;
	cin >> n >> m;
	for (int i = 0; i < m; ++i){
		ll a, b;
		cin >> a >> b;
		v[a].push_back(b);
	}
	for (int i = 1; i <= n; ++i){
		if(!visit[i]){
			dfs(i);
		}
	}
	reverse(vv.begin(), vv.end());
	std::map<ll, ll> mp;
	for (int i = 0; i < vv.size(); ++i){
		for(auto j : v[vv[i]]){
			mp[j] = max(mp[j], mp[vv[i]] + 1);
		}
	}
	ll mx = 0;
	for (int i = 1; i <= n; ++i){
		mx = max(mx, mp[i]);
	}
	cout << mx;
}
 
int main(int argc, char const *argv[]){
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
    	solve();
    }
}
// Radhe Radhe

Compiler output:
a.cc: In function 'void dfs(ll)':
a.cc:15:9: error: reference to 'visit' is ambiguous
   15 |         visit[node] = 1;
      |         ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:11:4: note:                 'll visit [200010]'
   11 | ll visit[N];
      |    ^~~~~
a.cc:17:21: error: reference to 'visit' is ambiguous
   17 |                 if(!visit[i]){
      |                     ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:11:4: note:                 'll visit [200010]'
   11 | ll visit[N];
      |    ^~~~~
a.cc: In function 'void solve()':
a.cc:33:21: error: reference to 'visit' is ambiguous
   33 |                 if(!visit[i]){
      |                     ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:11:4: note:                 'll visit [200010]'
   11 | ll visit[N];
      |    ^~~~~
Language: C++

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

#define rep(i, a, b) for(int i=a; i<=b; i++)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int n, m, u, v;
bool visited[100001];
vi ord;
vi par[100001];

void dfs(int x){
	if(visited[x]) return;
	visited[x]=true;
	if(par[x].empty()) return;
	trav(k, par[x]){
		if(!visited[k]){
			dfs(k);
			ord.pb(k);
		}
	}
	ord.pb(x);
}

int main(){
  // freopen("input.txt", "r", stdin); 
  // freopen("output.txt", "w", stdout);
  cin.sync_with_stdio(0); cin.tie();
  cin.exceptions(cin.failbit);

  cin >> n >> m;
  rep(i, 1, m){
  	cin >> u >> v;
  	adj[u].pb(v);
  	par[v].pb(u);
  }

  rep(i, 1, n) visited[i]=false;
  rep(i, 1, n){
  	if(visited[i]) continue;
  	else(dfs(i));
  }

  vi dp(n+1);
  int ans=0;
  trav(x, ord){
  	trav(p, par[x]){
  		dp[x]=max(dp[x], dp[p]+1);
  	}
  	ans=max(ans, dp[x]);
  }
  cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:9: error: 'adj' was not declared in this scope
   40 |         adj[u].pb(v);
      |         ^~~
Language: C++

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

int dp[100000] = {} ;
vector<vector<int>> adj(100000) ;

int longest(int v) {

  if(dp[v]!=-1) return dp[v] ;
  
  if(adj[v].size()==0) {
  	dp[v] = 0 ;
  }
  
  else {

    for(int i : adj[v]) {    	
      dp[v] = max(dp[v],1 + longest(i)) ;
    }
  }
  
  return dp[v] ;
} 


int main() {

  int n,m; cin>>n>>m;
  
  for(int i=0; i<m; i++) {
    int x,y; cin>>x>>y ;
    adj[x-1].push_back(y-1) ;
  }
  
  for(int i=0; i<n; i++) dp[i] = -1 ;
  
  int ans = 0 ;
  
  for(int i=0; i<n; i++){
    ans = max(ans, longest(i)) ;
  }
  
  return 0 ;
} 



Compiler output:
a.cc:2:7: error: expected nested-name-specifier before 'namepsace'
    2 | using namepsace std ;
      |       ^~~~~~~~~
a.cc:5:1: error: 'vector' does not name a type
    5 | vector<vector<int>> adj(100000) ;
      | ^~~~~~
a.cc: In function 'int longest(int)':
a.cc:11:6: error: 'adj' was not declared in this scope
   11 |   if(adj[v].size()==0) {
      |      ^~~
a.cc:18:15: error: 'max' was not declared in this scope; did you mean 'std::max'?
   18 |       dp[v] = max(dp[v],1 + longest(i)) ;
      |               ^~~
      |               std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc: In function 'int main()':
a.cc:28:12: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   28 |   int n,m; cin>>n>>m;
      |            ^~~
      |            std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:32:5: error: 'adj' was not declared in this scope
   32 |     adj[x-1].push_back(y-1) ;
      |     ^~~
a.cc:40:11: error: 'max' was not declared in this scope; did you mean 'std::max'?
   40 |     ans = max(ans, longest(i)) ;
      |           ^~~
      |           std::max
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
Language: C++

/**Bismillahir Rahmanir Raheem
    Author:Refatul Fahad**/

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

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
#define IOS  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define sz(s)  (int)s.size()
#define all(s)  s.begin(),s.end()
const int N = 1e5 + 5;
const ll M = (ll)1e9 + 7;
const double pi=2*acos(0.0);
const double esp=1e-9;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}

int dx[]= {0,0,1,-1};
int dy[]= {1,-1,0,0};

vi adj[N];
bool visit[N];
int edcnt[N],deg[N];

void dfs(int node) {
    visit[node]=true;
    for(int x:adj[node]) {
        edcnt[x]=max(edcnt[x],edcnt[node]+1);
        --deg[x];
        if(!deg[x]) {
            dfs(x);
        }
    }
}
int main() {

    //IOS;
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);

    int test=1;
    //cin>>test;
    for(int cs=1; cs<=test; ++cs) {
        int n,m,ans=0;
        cin>>n>>m;
        for(int i=1; i<=m; ++i) {
            int x,y;
            cin>>x>>y;
            adj[x].pb(y);
            ++deg[y];
        }
        for(int i=1; i<=n; ++i) {
            if(!visit[i]&&!deg[i]) {
                dfs(i);
            }
        }
        for(int i=1; i<=n; ++i) {
            ans=max(ans,edcnt[i]);
        }
        cout<<ans<<endl;
    }
    return 0;
}



Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:41:5: error: reference to 'visit' is ambiguous
   41 |     visit[node]=true;
      |     ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:4:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:37:6: note:                 'bool visit [100005]'
   37 | bool visit[N];
      |      ^~~~~
a.cc: In function 'int main()':
a.cc:68:17: error: reference to 'visit' is ambiguous
   68 |             if(!visit[i]&&!deg[i]) {
      |                 ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:37:6: note:                 'bool visit [100005]'
   37 | bool visit[N];
      |      ^~~~~
Language: C++

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

6 7
1 2
2 3
5 3
2 6
5 1
3 4
4 6

*/
int recursiveLongestPath(map<int, vector<int>>& ma, int s){
    if(ma[s].size() == 0)
        return 0;
    int mxm = 0;
    for(auto x:ma[s]){
        int cur = 1 + recursiveLongestPath(ma, x);
        mxm = max(mxm, cur);
    }
    return mxm;
}
int memoLongestPath(map<int, vector<int>>& ma, int s, vector<int>& dp){
    if(dp[s] != -1)
        return dp[s];

    if(ma[s].size() == 0){
        dp[s] = 0;
        return dp[s];
    }
    int mxm = 0;
    for(auto x:ma[s]){
        int cur = 1 + memoLongestPath(ma, x);
        mxm = max(mxm, cur);
    }

    return dp[s] = mxm;

}

int main(){
    map<int, vector<int>> ma;
    int n,m;
    cin>>n>>m;
    int x,y;
    for(int i=0; i<m; i++){
        cin>>x>>y;
        ma[x].push_back(y);
    }
    // int mxm = 0;
    // for(int i=1; i<=n; i++){
    //     mxm = max(mxm, recursiveLongestPath(ma, i));
    // }
    // cout<<"The length of the Longest Path(Recursive Implementation) is "<<mxm<<endl;
    vector<int> dp(n+1, -1);
    int mxm = 0;
    for(int i=1; i<=n; i++){
        mxm = max(mxm, memoLongestPath(ma, i, dp));
    }
    // cout<<"The length of the Longest Path(Memoization Implementation) is "<<mxm<<endl;
    cout<<mxm<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int memoLongestPath(std::map<int, std::vector<int> >&, int, std::vector<int>&)':
a.cc:35:38: error: too few arguments to function 'int memoLongestPath(std::map<int, std::vector<int> >&, int, std::vector<int>&)'
   35 |         int cur = 1 + memoLongestPath(ma, x);
      |                       ~~~~~~~~~~~~~~~^~~~~~~
a.cc:25:5: note: declared here
   25 | int memoLongestPath(map<int, vector<int>>& ma, int s, vector<int>& dp){
      |     ^~~~~~~~~~~~~~~
Language: C++

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

void addEdge(vector<ll> adj[], ll u, ll v){
  adj[u].push_back(v);
}

void dfs(vector<ll> adj[], ll node, bool vis[], ll dp[]){
  vis[node]=true;
  for(ll i=0; i<adj[node].size(); i++){
    if(!vis[adj[node][i]]){
      dfs(adj,adj[node][i], vis, dp);
    }
    dp[node] = max(dp[node], 1+dp[adj[node][i]]);
  }
}

ll longestPath(vector<ll> adj[], ll n){
  ll dp[n+1];
  memset(dp, 0, sizeof(dp));
  bool vis[n+1];
  memset(vis, false, sizeof(vis));
  for(ll i=1; i<=n; i++){
    if(!vis[i]){
      dfs(adj,i,vis,dp);
    }
  }
  ll ans=0;
  for(ll i=0; i<=n; i++){
    ans = max(ans, dp[i]);
  }
  return ans;
}

int main(){
  ll n,m;
  cin>>n>>m;
  vector<ll> adj[n+1];
  while(m--){
    ll u,v;
    cin>>u>>v;
    addEdge(u,v);
  }
  ll ans = longestPath(adj, n);
  cout<<ans<<"\n";
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:13: error: invalid conversion from 'll' {aka 'long long int'} to 'std::vector<long long int>*' [-fpermissive]
   43 |     addEdge(u,v);
      |             ^
      |             |
      |             ll {aka long long int}
a.cc:43:12: error: too few arguments to function 'void addEdge(std::vector<long long int>*, ll, ll)'
   43 |     addEdge(u,v);
      |     ~~~~~~~^~~~~
a.cc:5:6: note: declared here
    5 | void addEdge(vector<ll> adj[], ll u, ll v){
      |      ^~~~~~~
Language: C++

#include <bits/stdc++.h> // Include every standard library
using namespace std;
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed << setprecision(n)
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;

const int maxsize= 1e5+5;
vi graph[maxsiz];
bool visited[maxsize];
int deg[maxsize]; //deg[v]= no of edges going into node v. 
int dist[maxsize];

void dfs(int v) {
    visited[v] = true;
    for (int a : graph[v]) {
        dist[a] = max(dist[a], dist[v] + 1);
        deg[a]--;
        if(deg[a]==0)
            dfs(a);
    }
}

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    while (m--){
        int x,y;
        scanf("%d%d", &x, &y);
        graph[x].pb(y);
        deg[y]++;
    }
    for (int a = 1; a <=n; a++) {
        if (!visited[a] && deg[a] == 0)
            dfs(a);
    }
    int res = 0;
    for (int a = 1; a <= n; a++)
        res = max(res, dist[a]);
    printf("%d", res);
}


Compiler output:
a.cc:15:10: error: 'maxsiz' was not declared in this scope; did you mean 'maxsize'?
   15 | vi graph[maxsiz];
      |          ^~~~~~
      |          maxsize
a.cc: In function 'void dfs(int)':
a.cc:22:18: error: 'graph' was not declared in this scope; did you mean 'isgraph'?
   22 |     for (int a : graph[v]) {
      |                  ^~~~~
      |                  isgraph
a.cc: In function 'int main()':
a.cc:37:9: error: 'graph' was not declared in this scope; did you mean 'isgraph'?
   37 |         graph[x].pb(y);
      |         ^~~~~
      |         isgraph
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;

public class Main{

	static class XandY{
		int x;
		int y; 
		XandY(int a, int b)
		{
			this.x = a;
			this.y = b;
		}
		
	}
	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		
		//int n = Integer.parseInt(reader.readLine());
		
		XandY  edge[] = new XandY[n];
		
		for(int i=0;i<n;i++)
		{
			String str[] = reader.readLine().split(" ");
			edge[i] = new XandY(Integer.parseInt(str[0]), Integer.parseInt(str[1]));
		}
	    
		int arr[] = new int [n+1];
		int max = Integer.MIN_VALUE;
		for(int i=1; i<n; i++)
		{
			arr[i] = 1;
			
			for(int j = i-1; j>=0; j--)
			{
				if(edge[i].x == edge[j].y && arr[j] >= arr[i])
					arr[i] = arr[i] + arr[j];
			}
			
			if(max < arr[i])
				max = arr[i];
		}
		
		System.out.println(max);
	}

}


Compiler output:
Main.java:24: error: cannot find symbol
		XandY  edge[] = new XandY[n];
		                          ^
  symbol:   variable n
  location: class Main
Main.java:26: error: cannot find symbol
		for(int i=0;i<n;i++)
		              ^
  symbol:   variable n
  location: class Main
Main.java:32: error: cannot find symbol
		int arr[] = new int [n+1];
		                     ^
  symbol:   variable n
  location: class Main
Main.java:34: error: cannot find symbol
		for(int i=1; i<n; i++)
		               ^
  symbol:   variable n
  location: class Main
4 errors
Language: C++

#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ )
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair  
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)
#define watch(x) cout << (#x) << " is #" << (x) <<"#" <<endl
#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
const ll mod = 1e9+7;
const ll MAX = 1e5+5;
const ll inf = 1e18+7;

ll dp[MAX];
bool visit[MAX];
vi adj[MAX];

ll DP(ll u)
{
  ll &ans = dp[u];
  if(ans) return ans;
  for(auto v : adj[u]) ans = max(ans,DP(v)+1);
  return ans;
}

int main() {
  fastio;
  ll n,m,x,y;
  cin>>n>>m;
  while(m--) 
  {
     cin>>x>>y;
     visit[y]=true;
     adj[x].pb(y);
  }
  ll ans=0;
  f(i,1,n+1){
    if(!visit[i]) ans = max(ans,DP(i));
  }
  cout<<ans<<"\n";
  return 0; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:6: error: reference to 'visit' is ambiguous
   49 |      visit[y]=true;
      |      ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:31:6: note:                 'bool visit [100005]'
   31 | bool visit[MAX];
      |      ^~~~~
a.cc:54:9: error: reference to 'visit' is ambiguous
   54 |     if(!visit[i]) ans = max(ans,DP(i));
      |         ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:31:6: note:                 'bool visit [100005]'
   31 | bool visit[MAX];
      |      ^~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;
using ll = long long;



void dfs(int node, vector<int> dir[], int dp[], bool vis[]) {
    vis[node] = 1;
    for(int i = 0; i < dir[node].size(); i++) {
        if(!vis[dir[node][i]]) {
            dfs(dir[node][i], dir, dp, vis);
        }

        dp[node] = max(dp[node], 1 + dp[dir[node][i]]);
    }
}




int longest(vector<int> dir[], int N) {
    int dp[N + 1];
    memset(dp, 0, sizeof(dp));

    bool vis[N + 1];
    memset(vis, 0, sizeof(vis));

    for(int i = 1; i < N + 1; i++) {
        if(!vis[i]) {
            dfs(i, dir, dp, vis);
        }
    }

    int res = 0;
    for(int i = 1; i < N + 1; i++) {
        res = max(res, dp[i]);
    }

    return res;

}


int main() {
    int N, M, X, Y;
    cin >> N >> M;
    vector<int> dir[N + 1];

    for (size_t i = 1; i < M + 1; i++)
    {
        cin >> X >> Y;
        dir[X].push_back(Y);
    }

    cout << longest(dir, N) << endl;
    
}


/*ダメ，時間かかる，元のところに来たときがやばい
int main() {
    int N = 0, M;
    cin >> M >> N;
    vector<int> x(N,0);
    vector<int> y(N,0);
    vector<int> longest(M,0);
    for(int i = 0; i < N; i++) {
        cin >> x.at(i);
        cin >> y.at(i);
    }
    /*
    for (size_t i = 0; i < N; i++)
    {
        longest.at(y.at(i) - 1) = max(longest.at(y.at(i) - 1), 1 + longest.at(x.at(i) - 1));
    }
    */


    for (size_t i = 0; i < N; i++)
    {
        for (size_t j = 0; j < N; j++)
        {
            longest.at(y.at(i) - 1) = max(longest.at(y.at(i) - 1), 1 + longest.at(x.at(i) - 1));
        }
    }
    sort(longest.begin(),longest.end());
    cout << longest.at(longest.size() - 1) << endl;
    


    return 0;
}

*/

Compiler output:
a.cc:80:5: error: expected unqualified-id before 'for'
   80 |     for (size_t i = 0; i < N; i++)
      |     ^~~
a.cc:80:24: error: 'i' does not name a type
   80 |     for (size_t i = 0; i < N; i++)
      |                        ^
a.cc:80:31: error: 'i' does not name a type
   80 |     for (size_t i = 0; i < N; i++)
      |                               ^
a.cc:87:9: error: expected constructor, destructor, or type conversion before '(' token
   87 |     sort(longest.begin(),longest.end());
      |         ^
a.cc:88:5: error: 'cout' does not name a type
   88 |     cout << longest.at(longest.size() - 1) << endl;
      |     ^~~~
a.cc:92:5: error: expected unqualified-id before 'return'
   92 |     return 0;
      |     ^~~~~~
a.cc:93:1: error: expected declaration before '}' token
   93 | }
      | ^
a.cc:95:2: error: expected unqualified-id before '/' token
   95 | */
      |  ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
void dfs(vector<int> &g, bool &vis[], int s, int dp[]){
  vis[s]=true;
  for(auto i::g[s]){
    if(!vis[i]){
      dfs(g, vis, i, dp);
    }
    dp[s]=max(dp[s], 1+dp[i]);
  }
}
int main(){
  int n, m, x, y;
  cin>>n>>m;
  vector<int> g[n+1];
  int dp[n+1];
  memset(dp, 0, sizeof(dp));
  for(int i=0;i<m;i++){
    cin>>x>>y;
    g[x].push_back(y);
  }
  bool vis[n+1];
  memset(vis, false, sizeof(vis));
  for(int i=1;i<=n;i++){
    if(!vis[i])
      dfs(g,vis,i,dp);
  }
  int ans=0;
  for(int i=1;i<=n;i++){
    ans=max(ans, dp[i]);
    cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc:3:32: error: declaration of 'vis' as array of references
    3 | void dfs(vector<int> &g, bool &vis[], int s, int dp[]){
      |                                ^~~
a.cc:3:37: error: expected ')' before ',' token
    3 | void dfs(vector<int> &g, bool &vis[], int s, int dp[]){
      |         ~                           ^
      |                                     )
a.cc:3:39: error: expected unqualified-id before 'int'
    3 | void dfs(vector<int> &g, bool &vis[], int s, int dp[]){
      |                                       ^~~
a.cc: In function 'int main()':
a.cc:33:2: error: expected '}' at end of input
   33 | }
      |  ^
a.cc:12:11: note: to match this '{'
   12 | int main(){
      |           ^