Language: C++

#pragma GCC optimize("O3", "unroll-loops")

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <limits>
#include <ext/rope>

using namespace std;
using namespace __gnu_cxx;

const int inf = (1 << 30) + 9e8;
const int MAXN = 1e5;
const int P = 131;
const long long MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;
typedef vector<bool> vb;

#define FAST ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define all(a) a.begin(), a.end()
#define pb push_back
#define files(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define ppb pop_back
#define ppf pop_front
#define fs first
#define sd second
#define eb emplace_back

template<class T> inline void sort(T &a) { sort(all(a)); }
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }
std::mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

vi g[MAXN];
vb used;
int n, m;
vi top;

void dfs(int v) {
    used[v] = true;
    for (auto u : g[v])
        if (!used[u])
            dfs(u);
    top.pb(v);
}

void topsort() {
    used.resize(n, false);
    for (int i = 0; i < n; ++i) {
        if (!used[i])
            dfs(i);
    }
    reverse(all(top));
}

void solve() {
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].pb(b);
    }
    topsort();
    used.assign(n, false);
    vll dist(n, -1);
    dist[top[0]] = 0;
    for (int i = 0; i < n; ++i) {
        int v = top[i];
        for (auto u : g[v]) {
            if (dist[u] < dist[v] + 1)
                dist[u] = dist[v] + 1;
        }
    }
    int mx = -inf;
    for (auto it : dist)
        mx = max(mx, it);
    cout << mx;
}

signed main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    FAST;
    int q = 1;
    // cin >> q;
    // int st = clock();
    while (q--) {
        solve();
    }
    // int en = clock();
    // cout << en - st << "ms.";
    return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:86:17: error: no matching function for call to 'max(int&, long long int&)'
   86 |         mx = max(mx, it);
      |              ~~~^~~~~~~~
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:4:
/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:86:17: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   86 |         mx = max(mx, it);
      |              ~~~^~~~~~~~
/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:86:17: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   86 |         mx = max(mx, it);
      |              ~~~^~~~~~~~