Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <utility>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1e9 + 7;

struct Edge {
    int src, dst, cost;
    Edge(int s, int d, int c = 1) : src(s), dst(d), cost(c) {}
    bool operator<(const Edge &e){ return cost < e.cost;}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;


int N,M,S,T;
vector<int> start,goal; // lengths of cycle, lengths of start to goal
Graph g;
bool visited[100010];

void dfs(int v,int pv,int c){
    visited[v] = true;
    if(v==S&&c!=0){
        start.push_back(c);
        return;
    } else if(v==T) {
        goal.push_back(c);
    }
    for(Edge e : g[v]) {
        int nv = e.dst;
        if(nv==pv) continue;
        dfs(nv,v,c+1);
    }
    return;
}


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> N >> M;
    g.resize(N);
    REP(i,M){
        int u,v;
        cin >> u >> v;
        --u; --v;
        g[u].emplace_back(u,v);
    }

    cin >> S >> T;
    --S; --T;
    dfs(S, -1, 0);
    if(!visited[T]) cout << -1 << endl;
    ll ans = INF;
    REP(i,start.size()){
          REP(j,goal.size()){
              if((goal[j]+start[i])%3==0) ans = min(ans,(goal[j]+start[i])/3);
          }
    }
    cout << ans<<endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:66:52: error: no matching function for call to 'min(ll&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   66 |               if((goal[j]+start[i])%3==0) ans = min(ans,(goal[j]+start[i])/3);
      |                                                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:66:52: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   66 |               if((goal[j]+start[i])%3==0) ans = min(ans,(goal[j]+start[i])/3);
      |                                                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:66:52: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   66 |               if((goal[j]+start[i])%3==0) ans = min(ans,(goal[j]+start[i])/3);
      |                                                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~