Language: C++

#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

template<typename T> using maximum_heap = std::priority_queue<T, std::vector<T>, std::less<T>>;
template<typename T> using minimum_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

vector<set<uint64_t>> edge;
vector<int64_t> dp;

int main()
{
  uint64_t N, M;
  cin >> N >> M;

  edge = vector<set<uint64_t>>(N);
  N_TIMES(m, M) {
    uint64_t x, y;
    cin >> x >> y;

    edge[x - 1].insert(y - 1);
  }

  dp = vector<int64_t>(N, 0);
  // dp[i]; ノードiを始点とした有向パスの最大長

  struct StackItem {
    uint64_t node; int64_t length;
    StackItem(uint64_t node, int64_t length) : node(node), length(length) {}
  };

  const auto dfs = [&](uint64_t start) {
    stack<StackItem> s;
    s.emplace(start, 0);

    while (!s.empty()) {
      StackItem item = s.top(); s.pop();
      uint64_t src = item.node;

      if (item.length >= dp[src]) {
        dp[src] = item.length;

        for (uint64_t dst : edge[src]) {
          s.emplace(dst, dp[src] + 1);
        }
      }
    }

    return dp[start];
  };

  N_TIMES(i, N) {
    if (dp[i] == 0) {
      dp[i] = dfs(i);
    }
  }

  cout << *max_element(dp.begin(), dp.end()) << endl;

  return 0;
}

Compiler output:
a.cc:25:1: error: 'vector' does not name a type
   25 | vector<set<uint64_t>> edge;
      | ^~~~~~
a.cc:26:1: error: 'vector' does not name a type
   26 | vector<int64_t> dp;
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:31:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   31 |   cin >> N >> M;
      |   ^~~
      |   std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:33:3: error: 'edge' was not declared in this scope
   33 |   edge = vector<set<uint64_t>>(N);
      |   ^~~~
a.cc:33:10: error: 'vector' was not declared in this scope
   33 |   edge = vector<set<uint64_t>>(N);
      |          ^~~~~~
a.cc:33:10: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from a.cc:5:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:33:17: error: 'set' was not declared in this scope
   33 |   edge = vector<set<uint64_t>>(N);
      |                 ^~~
a.cc:33:17: note: suggested alternatives:
In file included from /usr/include/c++/14/set:63,
                 from a.cc:16:
/usr/include/c++/14/bits/stl_set.h:96:11: note:   'std::set'
   96 |     class set
      |           ^~~
/usr/include/c++/14/set:87:13: note:   'std::pmr::set'
   87 |       using set = std::set<_Key, _Cmp, polymorphic_allocator<_Key>>;
      |             ^~~
a.cc:33:29: error: expected primary-expression before '>>' token
   33 |   edge = vector<set<uint64_t>>(N);
      |                             ^~
a.cc:41:3: error: 'dp' was not declared in this scope
   41 |   dp = vector<int64_t>(N, 0);
      |   ^~
a.cc:41:22: error: expected primary-expression before '>' token
   41 |   dp = vector<int64_t>(N, 0);
      |                      ^
a.cc: In lambda function:
a.cc:50:5: error: 'stack' was not declared in this scope; did you mean 'std::stack'?
   50 |     stack<StackItem> s;
      |     ^~~~~
      |     std::stack
In file included from /usr/include/c++/14/stack:63,
                 from a.cc:14:
/usr/include/c++/14/bits/stl_stack.h:99:11: note: 'std::stack' declared here
   99 |     class stack
      |           ^~~~~
a.cc:50:20: error: expected primary-expression before '>' token
   50 |     stack<StackItem> s;
      |                    ^
a.cc:50:22: error: 's' was not declared in this scope
   50 |     stack<StackItem> s;
      |                      ^
a.cc: In function 'int main()':
a.cc:75:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   75 |   cout << *max_element(dp.begin(), dp.end()) << endl;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:75:12: error: 'max_element' was not declared in this scope; did you mean 'std::max_element'?
   75 |   cout << *max_element(dp.begin(), dp.end()) << endl;
      |            ^~~~~~~~~~~
      |            std::max_element
In file included from /usr/include/c++/14/algorithm:86,
                 from a.cc:4:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:528:1: note: 'std::max_element' declared here
  528 | max_element(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last);
      | ^~~~~~~~~~~
a.cc:75:49: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   75 |   cout << *max_element(dp.begin(), dp.end()) << endl;
      |                                                 ^~~~
      |                                                 std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~