Language: C++

#include<bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define pb push_back
#define pii pair<int64_t,int64_t>
#define mp make_pair
#define whole(v) begin(v),end(v)
#define print(c,n) for(int64_t i=0;i<n;i++) cout << c[i] << " ";
#define MOD 1000000007
int n,m;
vector<int> v[100005];
bool visited[100005];
int dis[100005];
int64_t bfs(int u){
	visited[u]=true;
	int64_t ans=-1e18;
	dis[u]=0;
	queue<int> q;
	q.push(u);
	while(!q.empty()){
		auto j = q.front();
		q.pop();
		for(auto i : v[j]){
			//if(!visited[i]){
				visited[i]=1;
				//dis[i] = dis[j]+1;
				q.push(i);
			//}
			//else{
				dis[i] = max(dis[i],dis[j]+1);
				ans = max(ans,dis[i]);
			//}
		}
	}
	//print(dis,n);
	//cout << "\n";
	//return 1;
	return ans;
	//return *max_element(dis,dis+n);
}
void solve(){
	cin >> n >> m;
	for(int i=0;i<m;i++){
		int a,b;
		cin >> a >> b;
		a--,b--;
		v[a].eb(b);
	}
	int ans=-1;
	for(int i=0;i<n;i++){
		//memset(visited,0,sizeof(visited));
		for(int i=0;i<n;i++){
			dis[i] = INT_MIN;
		}
		dis[i]=0;
		//cout << bfs(i) << "\n";
		ans = max(ans,bfs(i));
	}
	cout << ans << "\n";
}
int main(){
	
	solve();
}

Compiler output:
a.cc: In function 'int64_t bfs(int)':
a.cc:31:42: error: no matching function for call to 'max(int64_t&, int&)'
   31 |                                 ans = max(ans,dis[i]);
      |                                       ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:31:42: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   31 |                                 ans = max(ans,dis[i]);
      |                                       ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:31:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   31 |                                 ans = max(ans,dis[i]);
      |                                       ~~~^~~~~~~~~~~~
a.cc: In function 'void solve()':
a.cc:57:26: error: no matching function for call to 'max(int&, int64_t)'
   57 |                 ans = max(ans,bfs(i));
      |                       ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:57:26: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'int64_t' {aka 'long int'})
   57 |                 ans = max(ans,bfs(i));
      |                       ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:57:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   57 |                 ans = max(ans,bfs(i));
      |                       ~~~^~~~~~~~~~~~