Language: C++

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;
const ll 	N 		= 	2*1e6;

vll adj[MAXN];ll visit[MAXN]={};

// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m,q,k,w;
string s,t;
vll a,b,c;
// <------------- Implement Functions Here ----------> //

ll dp[200000];

void dfs(ll x, ll p=-1) {
	if(p!=-1) {
		dp[x] = max(dp[x], dp[p]+1);
	}

	for(auto it : adj[x]) {
		if(it!=p) {
			dfs(it,x);
		}
	}
}

// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> m;
	for(ll i=0;i<m;i++) {
		cin>>x>>y;
		adj[x].pb(y);
		visit[y]++;
	}	

	mset(dp,0);

	for(ll i=1;i<=n;i++) {
		if(visit[i]==0) {
			dfs(i);
		}
	}

	//for(ll i=1;i<=n;i++) cout<<dp[i]<<" ";
	//newl;	
	//for(ll i=1;i<=n;i++) cout<<visit[i]<<" ";
	//newl;

	cout<<*max_element(dp+1,dp+n+1);
}

int main() {
	fastio;randomINT;
	//cin>>T;
	while(T--) {
		MAIN();
	}
	return 0;
}



Compiler output:
a.cc: In function 'void MAIN()':
a.cc:67:17: error: reference to 'visit' is ambiguous
   67 |                 visit[y]++;
      |                 ^~~~~
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:36:18: note:                 'll visit [10000007]'
   36 | vll adj[MAXN];ll visit[MAXN]={};
      |                  ^~~~~
a.cc:73:20: error: reference to 'visit' is ambiguous
   73 |                 if(visit[i]==0) {
      |                    ^~~~~
/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:36:18: note:                 'll visit [10000007]'
   36 | vll adj[MAXN];ll visit[MAXN]={};
      |                  ^~~~~