Language: C++

#include <cstdio>  //{{{
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>

#define ALL(c) (c).begin(), (c).end()
#define DUMP(x) std::cerr << #x << ':' << x << '\n';

typedef long long ll;
// clang-format off
template<typename T,typename U>inline bool chmax(T&x,U a){if(x>=a)return 0;x=a;return 1;}
template<typename T,typename U>inline bool chmin(T&x,U a){if(x<=a)return 0;x=a;return 1;}
inline int in(){int x;scanf("%d", &x);return x;}
// clang-format on
// }}}
//{{{ graph.hpp
#ifndef INCLUDE_GRAPH_HPP
#define INCLUDE_GRAPH_HPP
#include <vector>
#include <climits>
namespace orliv {
namespace graph {
struct Edge {
  using weight_type = int;
  static constexpr weight_type INF =
      std::numeric_limits<weight_type>::max() - 100;

  int from, to;
  weight_type w;
  Edge(int from, int to, weight_type w = 1) : from(from), to(to), w(w) {}
  bool operator<(const Edge& rhs) const {
    if (w != rhs.w) return w > rhs.w;
    if (from != rhs.from) return from < rhs.from;
    return to < rhs.to;
  }
};

using Weight = Edge::weight_type;
using Edges = std::vector<Edge>;
using Weights = std::vector<Weight>;
using Path = std::vector<int>;
using Nodes = std::vector<int>;
}
using Graph = std::vector<graph::Edges>;
}
#endif
//}}}
//{{{ scc.cc
#ifndef INCLUDE_GRAPH_HPP
#include "graph.hpp"
#endif
#include <stack>

namespace orliv {
namespace graph {
namespace scc_internal {
struct SCCImpl {
  const Graph& G;
  int k;
  std::vector<int> ord, low;
  std::stack<int> stack;
  std::vector<bool> instack;
  std::vector<Nodes> scc;
  SCCImpl(const Graph& g)
      : G(g), k(0), ord(g.size(), -1), low(g.size()), instack(g.size()) {}
  std::vector<Nodes> get() {
    for (int v = 0; v < G.size(); v++) {
      if (ord[v] >= 0) continue;
      dfs(v);
    }
    return std::move(scc);
  }

 private:
  void dfs(int v) {
    ord[v] = low[v] = k++;
    stack.push(v);
    instack[v] = true;
    for (const auto& e : G[v]) {
      int u = e.to;
      if (ord[u] < 0) {
        dfs(u);
        low[v] = std::min(low[v], low[u]);
      } else if (instack[u]) {
        low[v] = std::min(low[v], ord[u]);
      }
    }
    if (low[v] != ord[v]) return;

    scc.emplace_back();
    while (1) {
      int u = stack.top();
      stack.pop();
      instack[u] = false;
      scc.back().emplace_back(u);
      if (v == u) break;
    }
  }
};
}
std::vector<Nodes> scc(const Graph& g) {
  return std::move(scc_internal::SCCImpl(g).get());
}
}
}
//}}}

using namespace std;

int main() {
  int V = in(), E = in();
  orliv::Graph g(V);
  for (int i = 0; i < E; i++) {
    int s = in(), t = in();
    g[s].emplace_back(s, t);
  }
  auto scc = orliv::graph::scc(g);
  bool cycle = false;
  for (auto& nodes : scc) {
    cycle |= nodes.size() > 1u;
  }
  if (cycle) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}

Compiler output:
a.cc:29:12: error: 'numeric_limits' is not a member of 'std'
   29 |       std::numeric_limits<weight_type>::max() - 100;
      |            ^~~~~~~~~~~~~~
a.cc:29:38: error: expected primary-expression before '>' token
   29 |       std::numeric_limits<weight_type>::max() - 100;
      |                                      ^
a.cc:29:41: error: '::max' has not been declared; did you mean 'std::max'?
   29 |       std::numeric_limits<weight_type>::max() - 100;
      |                                         ^~~
      |                                         std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:7:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~