criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>

using namespace std;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<int>;

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

	mat edge(N);

	for (int i = 0; i < M; ++i)
	{
		int A, B;
		cin >> A >> B;
		--A; --B;
		edge[A].emplace_back(B);
	}


	for (int s = 0; s < N; ++s)
	{
		lst Q;
		vec used(N, -1);
		
		Q.emplace_back(s);
		used[s] = s;

		bool flag = true;

		while(!Q.empty()&&flag)
		{
			int v = Q.front(); Q.pop_front();
			
			for (int u : edge[v])
			{
				if (used[u] == -1)
				{
					Q.emplace_back(u);
					used[u] = v;
				}
				else if (u == s)
				{
					set<int> st;
					lst ans={s};
					
					while (v != s)
					{
						if (st.count(v)) { flag = false; break; }

						ans.emplace_back(v);
						for (auto w : edge[v])
						{
							if (w != used[v]) { st.insert(w); }
						}
						v = used[v];
					}

					if (flag)
					{
						cout << ans.size() << endl;
						for (int a : ans) { cout << a+1 << endl; }
						return 0;
					}

					break;
				}
			}
		}
	}

	cout << -1 << endl;

	return 0;
}

Compiler output:
a.cc:14:13: error: 'list' does not name a type
   14 | using lst = list<int>;
      |             ^~~~
a.cc: In function 'int main()':
a.cc:34:17: error: 'lst' was not declared in this scope
   34 |                 lst Q;
      |                 ^~~
a.cc:37:17: error: 'Q' was not declared in this scope
   37 |                 Q.emplace_back(s);
      |                 ^
a.cc:56:44: error: expected ';' before 'ans'
   56 |                                         lst ans={s};
      |                                            ^~~~
      |                                            ;
a.cc:62:49: error: 'ans' was not declared in this scope; did you mean 'abs'?
   62 |                                                 ans.emplace_back(v);
      |                                                 ^~~
      |                                                 abs
a.cc:72:57: error: 'ans' was not declared in this scope; did you mean 'abs'?
   72 |                                                 cout << ans.size() << endl;
      |                                                         ^~~
      |                                                         abs
Language: C++

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using namespace __gnu_pbds; // gp_hash_table<int, int> table;

template <typename T> void smin(T &a, const T &b) { a = (a < b ? a : b); }
template <typename T> void smax(T &a, const T &b) { a = (a > b ? a : b); }

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

const int N = 1010;

vector <int> g[N];
int used[N];


vector <int> st;
bool dfs1(int u, vector <int> &ans)
{
  st.push_back(u);
  used[u] = 1;
  for (int v : g[u])
  {
    if (used[v] == 1)
    {
      while (st.back() != v)
      {
        ans.push_back(st.back());
        st.pop_back();
      }
      ans.push_back(st.back());
      return 1;
    }
    if (!used[v] && dfs1(v, ans))
      return 1;
  }
  used[u] = 2;
  st.pop_back();
  return 0;
}

signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector <pair <int, int>> es;
  for (int i = 0; i < m; i++)
  {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    es.push_back({u, v});
  }

  vector <int> ans;

  for (int i = 1; i <= n; i++)
    if (dfs(i))
      break;
  reverse(all(ans));

  if (ans.empty())
    return cout << -1, 0;

  for (auto e : es)
  {
    int pos1 = -1, pos2 = -1;
    for (int i = 0; i < ans.size(); i++)
    {
      if (ans[i] == e.first)
        pos1 = i;
      else if (ans[i] == e.second)
        pos2 = i;
    }
    if (pos1 == -1 || pos2 == -1)
      continue;
    vector <int> tmp;
    if (pos1 < pos2)
    {
      for (int i = pos2; i != pos1; i = (i + 1) % ans.size())
        tmp.push_back(ans[i]);
      tmp.push_back(ans[pos1]);
    }
    else
    {
      for (int i = pos2; i <= pos1; i++)
        tmp.push_back(ans[i]);
    }
    ans = tmp;
  }

  cout << ans.size() << "\n";
  for (int i : ans)
    cout << i << "\n";

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:66:9: error: 'dfs' was not declared in this scope; did you mean 'ffs'?
   66 |     if (dfs(i))
      |         ^~~
      |         ffs
Language: C++

#include <bits/stdc++.h>//Atcorder 142 
#include <queue>
#include <vector>
#include <iostream>
#include <utility>
#define chmin(x, y) x = min(x , y);
#define chmax(x, y) x = max(x, y);
#define rep(i, j) for (int (i)=0;(i)<(j);(i)++)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long int ll;

const ll INF = 1e8;

int N, M;
vector<int> Graph[1001];
//bfsする。
vector<int> bfs(int sv){
    vector<int> dist(N, INF), pre(N, -1);
    queue<int> q;
    dist[sv] = 0;
    q.push_back(sv);
    //bfs
    while(!q.empty()){
        int v = q.front(); q.pop();
        for (int u : Graph[v]){
            if(dist[u] != INF) continue;//訪問済み
            pre[u] = v;//u からどこ
            dist[u] = dist[v]+1;//dist[u]はどの位の距離でsvからuに行けたのか示す
            q.push(u);
         }
    }
    //最小サイクルを探す.distにsvからのコストがあるので、dist[i]でGraph[i]にsvへの辺があるなら、それはサイクルであり、minをとる。
    pair<int ,int > best(INF, -1);
    rep(i,N){
        if(i == sv) continue;
        for(int u: Graph[i]){
            if(u == sv){
            best = min(best, make_pair(dist[u],u));//最小サイクルGET。dist[u]がコストであり、uがsvに至る直前の辺
            }
        }
    }
    if (best.first == INF) return vector<int>(N+1);
    int v = best.second;
    vector<int> res;
    //早速グラフをゲット！
    while (v != -1){
        res.push_back(v);
        v = pre[v];
    }
    return res;//svを親ノードにした最小グラフ（サイクル）を入手
}


void input() {
    cin >> N >> M;
    rep(i, M) {
        int a, b;cin >> a >> b;a--;b--;
        Graph[a].push_back(b);
    }
}

//bfsベクトルの中に処理系を設置する。nowに与えられたグラフを収納
void solve () {
    input();
    vector<int> ans;
    rep(i, N){
        vector<int> now = bfs(i);
        if(now.size() < ans.size()) ans = now;
    }
    if(ans.size() == N+1){
        cout <<-1 << endl;
        return ;
    }
    cout << ans.size() << endl;
    for (int v:ans){
        cout << v << endl;
    }
    return;
}

int main () {
    solve();
    return 0;
}



Compiler output:
a.cc: In function 'std::vector<int> bfs(int)':
a.cc:23:7: error: 'class std::queue<int>' has no member named 'push_back'
   23 |     q.push_back(sv);
      |       ^~~~~~~~~
Language: C++

#include <bits/stdc++.h>//Atcorder 142 
#include <queue>
#include <vector>
#include <iostream>
#include <utility>
#define chmin(x, y) x = min(x , y);
#define chmax(x, y) x = max(x, y);
#define rep(i, j) for (int (i)=0;(i)<(j);(i)++)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long int ll;

const ll INF = 1e8;

int N, M;
vector<int> Graph[1001];
//bfsする。
vector<int> bfs(int sv){
    vector<int> dist(N, INF), pre(N, -1);
    queue<int> q;
    dist[sv] = 0;
    q.push_back(sv);
    //bfs
    while(!q.empty()){
        int v = q.front(); q.pop();
        for (int u : Graph[v]){
            if(dist[u] != INF) continue;//訪問済み
            pre[u] = v;//u からどこ
            dist[u] = dist[v]+1;//dist[u]はどの位の距離でsvからuに行けたのか示す
            q.push_back(u);
        }
    }
    //最小サイクルを探す.distにsvからのコストがあるので、dist[i]でGraph[i]にsvへの辺があるなら、それはサイクルであり、minをとる。
    pair<int ,int > best(INF, -1);
    rep(i,N){
        if(i == sv) continue;
        for(int u: Graph[i]){
            if(u == sv){
            best = min(best, make_pair(dist[u],u));//最小サイクルGET。dist[u]がコストであり、uがsvに至る直前の辺
            }
        }
    }
    if (best.first == INF) return vector<int>(N+1);
    int v = best.second;
    vector<int> res;
    //早速グラフをゲット！
    while (v != -1){
        res.push_back(v);
        v = pre[v]
    }
    return res;//svを親ノードにした最小グラフ（サイクル）を入手
}


void input() {
    cin >> N >> M;
    rep(i, M) {
        int a, b;cin >> a >> b;a--;b--;
        Graph[a].push_back(b);
    }
}

//bfsベクトルの中に処理系を設置する。nowに与えられたグラフを収納
void solve () {
    input();
    vector<int> ans;
    rep(i, n){
        vector<int> now = bfs(i);
        if(now.size() < ans.size()) ans = now;
    }
    if(ans.size() == N+1){
        cout <<-1 << endl;
        return ;
    }
    cout << ans.size() << endl;
    for (int v:ans){
        cout << v << endl;
    }
    return;
}

int main () {
    solve();
    return 0;
}



Compiler output:
a.cc: In function 'std::vector<int> bfs(int)':
a.cc:23:7: error: 'class std::queue<int>' has no member named 'push_back'
   23 |     q.push_back(sv);
      |       ^~~~~~~~~
a.cc:31:15: error: 'class std::queue<int>' has no member named 'push_back'
   31 |             q.push_back(u);
      |               ^~~~~~~~~
a.cc:50:19: error: expected ';' before '}' token
   50 |         v = pre[v]
      |                   ^
      |                   ;
   51 |     }
      |     ~              
a.cc: In function 'void solve()':
a.cc:68:12: error: 'n' was not declared in this scope
   68 |     rep(i, n){
      |            ^
a.cc:8:39: note: in definition of macro 'rep'
    8 | #define rep(i, j) for (int (i)=0;(i)<(j);(i)++)
      |                                       ^
Language: C++

#include <bits/stdc++.h>//Atcorder 142 
#include <vector>
#include <iostream>
#include <utility>
#define chmin(x, y) x = min(x , y);
#define chmax(x, y) x = max(x, y);
#define rep(i, j) for (int (i)=0;(i)<(j);(i)++)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long int ll;

const ll INF = 1e12;

int N, M;
vector<vector<int>> Graph;

vector<int> bfs(int sv){
    vector<int> dist(n, INF), pre(n, -1);
    vector<int> q;
    dist[sv] = 0;
    q.push_back(sv);
    while(!q.empty()){
        int v = q.front(); q.pop();
        for (int u : Graph[v]){
            if(dist[u] == INF) continue;
            pre[u] = v;
            dist[u] = dist[v]+1;
            q.push_back(u);
        }
    }
    pair<int ,int > best(INF, -1);
    rep(i,N){
        if(i == sv) continue;
        for(int u: Graph[v]){
            if(u == sv){
            best = min(best, make_pair(dist[u],u);
            }
        }
    }
    if (best.first == INF) return vector<int>(n+1);
    int v = best.second;
    vector<int> res;
    while (v != -1){
        res.push_back(v);
        v = pre[v]
    }
    return res;
}


void input() {
    cin >> N >> M;
    rep(i, M) {
        int a, b;cin >> a >> b;a--;b--;
        Graph[a].push_back(b);
    }
}


void solve () {
    input();
    auto ans (n+1);
    rep(i, n){
        vi now = dfs(i);
        if(now.size() < ans.size()) ans = now;
    }
    if(ans.size() == N+1){
        cout <<-1 << endl;
        return ;
    }
    cout << ans.size() << endl;
    for (int v:ans){
        cout << v << endl;
    }
    return;
}

int main () {
    solve();
    return 0;
}



Compiler output:
a.cc: In function 'std::vector<int> bfs(int)':
a.cc:19:22: error: 'n' was not declared in this scope
   19 |     vector<int> dist(n, INF), pre(n, -1);
      |                      ^
a.cc:24:30: error: 'class std::vector<int>' has no member named 'pop'
   24 |         int v = q.front(); q.pop();
      |                              ^~~
a.cc:35:26: error: 'v' was not declared in this scope
   35 |         for(int u: Graph[v]){
      |                          ^
a.cc:37:50: error: expected ')' before ';' token
   37 |             best = min(best, make_pair(dist[u],u);
      |                       ~                          ^
      |                                                  )
a.cc:46:19: error: expected ';' before '}' token
   46 |         v = pre[v]
      |                   ^
      |                   ;
   47 |     }
      |     ~              
a.cc: In function 'void solve()':
a.cc:63:15: error: 'n' was not declared in this scope
   63 |     auto ans (n+1);
      |               ^
a.cc:65:9: error: 'vi' was not declared in this scope; did you mean 'i'?
   65 |         vi now = dfs(i);
      |         ^~
      |         i
a.cc:66:12: error: 'now' was not declared in this scope; did you mean 'pow'?
   66 |         if(now.size() < ans.size()) ans = now;
      |            ^~~
      |            pow
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const ll inf=100100100100;
const int Inf=1001001001;
const int mod=1000000007;
const double pi=3.141592653589793;

ll to[1005];
int dfs(ll i,vvi v){
    for(ll x:v[i]){
        to[i]=x;
        if(to[x]!=-1)return i;
        int k=dfs(x,v);
        if(k!=-1)return k;
    }
    to[i]=-1;
    return -1;
}

int main(){
    ll n,m;cin>>n>>m;
    rep(i,n)to[i]=-1;
    vvi v(n);
    rep(i,m){
        ll a,b;cin>>a>>b;
        a--;b--;
        v[a].pb(b);
    }
    rep(i,n){
        ll k=dfs(i,v);
        if(k!=-1){
            while(true){
            vi d;
            ll j=k;
            d.pb(j);
            j=to[k];
            while(j!=k){
                d.pb(j);
                j=to[j];
            }
            ll from=inf,go;
            for(ll j: d){
             	bool b=false;
                for(ll x: v[j]){
                    if(x!=to[j]&&to[x]!=-1){
                        from=j;
                        go=x;
                      	b=true;
                        break;
                    }
                }
              	if(b)break;
            }
            if(from==inf){
                cout<<d.size()<<endl;
                rep(i,d.size())cout<<d[i]+1<<endl;
                return 0;
            }
            ll j=from;
            while(true){
                ll k=to[j];
                to[j]=-1;
                j=k;
                if(j==go)break;
            }
            to[from]=go;
            }
        }
    }
    cout<<-1<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:76:16: error: redeclaration of 'll j'
   76 |             ll j=from;
      |                ^
a.cc:51:16: note: 'll j' previously declared here
   51 |             ll j=k;
      |                ^
Language: C++

#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
using namespace std;

int main() {

	int N, M; cin >> N >> M;
	using P = pair<int, int>;

	bool end_flag = false;
	vector<int> cycle;
	vector<bool> seen(N, false);
	vector<vector<int>> edge(N);
	for (int i = 0; i < M; ++i)
	{
		int a, b;
		cin >> a >> b;
		a--; b--;
		edge[a].push_back(b);
	}
	stack<int> stk;
	function<int(int)> dfs = [&](int now)
	{
		stk.push(now);
		seen[now] = true;
		if (edge.empty())
		{
			stk.pop();
			return -1;
		}
		int size = edge[now].size();
		vector<int> pass;
		for (int i = 0; i < size; i++)
		{
			int next = edge[now][i];
			if (seen[next])
			{
				pass.push_back(next);
			}
		}
		if (!pass.empty())
		{
			int min;
			bool flag = true;
			while (flag)
			{
				int num = stk.top();
				stk.pop();
				for (int p : pass)
				{
					if (p == num)
					{
						min = p;
						flag = false;
						break;
					}
				}
			}
			cycle.push_back(now);
			return min;
		}
		for (int i = 0; i < size; i++)
		{
			int next = edge[now][i];

			int ret = dfs(next);
			if (ret != -1)
			{
				if (!end_flag) cycle.push_back(now);
				if (now == ret) end_flag = true;
				return ret;
			}

		}
		seen[now] = false;
		stk.pop();
		return -1;
	};
	for (int i = 0; i < N; i++)
	{
		int res = dfs(i);
		if (res != -1)
			break;
	}
	if (!end_flag)
	{
		cout << -1 << endl;
		return 0;
	}
	reverse(cycle.begin(), cycle.end());
	cout << cycle.size() << endl;
	for (int c : cycle)
	{
		cout << c + 1 << endl;
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:93:9: error: 'reverse' was not declared in this scope
   93 |         reverse(cycle.begin(), cycle.end());
      |         ^~~~~~~
Language: C++

#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

const int inf=0x3f3f3f3f;
typedef pair<int, int> pii;
const int maxn = 201000;
vector<int> vec[maxn];
int fa[maxn];
int vis[maxn];
vector<int> ans,res;
int cnt;
pii aa[maxn*maxn];


void unite(int x, int y){
    fa[y] = x;
}
void dfs(int x){
    vis[x] = 1;
    for(auto it : vec[x]){
        if(!vis[it]){
            unite(x, it);
            dfs(it);
        }else{
            aa[cnt].first = it;
            aa[cnt].second = x;
            cnt++;
        }
    }
}
void print(int x, int ff){
    ans.emplace_back(x);
    if(x == ff)return;
    print(fa[x], ff);
}

bool ff = false;

void check(int x, int y){
    if(ff)return;
    for(auto it : vec[x]){
        if(it == y)ff=true;
        else check(it, y);
    }
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n, m;
    cin>>n>>m;
    for(int i = 1; i <= n; i++)fa[i] = i;
    for(int i = 1; i <= m; i++){
        int x, y; cin>>x>>y;
        vec[x].emplace_back(y);
    }
    dfs(1);
    int kk = inf;
    for(int i = 0; i < cnt; i++){
        ff = false;
        ans.clear();
        check(aa[i].first, aa[i].second);
        if(ff){
            print(aa[i].second, aa[i].first);
            if(ans.size() < kk){
                res = ans;
                kk = ans.size();
            }
        }
    }
    if(kk != inf){
        cout<<res.size()<<endl;
        for(auto it : res)cout<<it<<endl;
    }
    else cout<<-1;
    return 0;
}


Compiler output:
a.cc:13:12: warning: integer overflow in expression of type 'int' results in '1746294336' [-Woverflow]
   13 | pii aa[maxn*maxn];
      |        ~~~~^~~~~
a.cc:13:12: error: size of array 'aa' exceeds maximum object size '9223372036854775807'
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  vector<int> res;
  cin>>n>>m;
  vector<vector<int>> G(n);
  for(int i=0;i<m;++i){
    int a,b;
    cin>>a>>b;
    G[a-1].push_back(b-1);
  }
  for(int src=0;src<n;++src){
    deque<int> que;
    que.push_back(src);
    vector<bool> vis(n,false);
    while(!que.empty()){
      int x=que.back();
      if(x<0){
        que.pop_back();
        if(!que.empty()&&que.back()>=0)que.pop_back();
        continue;
      }
      cerr << "["<<src<<": "<<x<<"]";
      deque<int> erque=que;
      while(!erque.empty()){cerr<<" "<<erque.front(); erque.pop_front();}
      cerr << endl;
      if(vis[x]){
        res.push_back(x+1);
        que.pop_back();
        bool neg=false;
        while(!que.empty()){
          int y=que.back();
          if(y==x)break;
          if(y>=0&&neg)res.push_back(y+1);
          neg=(y<0);
          que.pop_back();
        }
        cout<<res.size()<<"\n";
        for(auto i:res)cout<<i<<"\n";
        return 0;
      }
      vis[x]=true;

      abrtc++;
      assert(abrtc<ABRT_LIM);
      if(x==que.front()&&que.size()>1){
        bool neg=false;
        while(!que.empty()){
          int y=que.back();
          if(y>=0&&neg)res.push_back(y+1);
          neg=(y<0);
          que.pop_back();
        }
        cout<<res.size()<<"\n";
        for(auto i:res)cout<<i<<"\n";
        return 0;
      }
      else{
        que.push_back(-1);
        for(auto i:G[x])que.push_back(i);
      }
    }
  }
  cout<<-1;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:7: error: 'abrtc' was not declared in this scope
   45 |       abrtc++;
      |       ^~~~~
In file included from /usr/include/c++/14/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:106,
                 from a.cc:1:
a.cc:46:20: error: 'ABRT_LIM' was not declared in this scope
   46 |       assert(abrtc<ABRT_LIM);
      |                    ^~~~~~~~
Language: C++

#include <iostream>
#include <cstring>
#include <vector>
#include <queue>

using namespace std;
int N, M;
vector <int> edge[1005];
bool vis[1005];
int dist[1005];
int previous[1005];
int best = INT_MAX;
vector <int> ans;

int bfs(int v){
    queue <int> q;
    q.push(v);
    dist[v] = 0;
    vis[v] = true;
    while (!q.empty()){
        int node = q.front();
        q.pop();
        for (int e: edge[node]){
            if (!vis[e]) {
                q.push(e);
                dist[e] = dist[node] + 1;
                previous[e] = node;
                vis[e] = true;
            } else if (e == v){
                if (dist[node] + 1 < best){
                    best = dist[node] + 1;
                    return node;
                }
            }
        }
    }
    return -1;
}

int main() {
    scanf("%d %d", &N, &M);
    for (int i=0; i<M; i++){
        int a, b;
        scanf("%d %d", &a, &b);
        edge[a].push_back(b);
    }
    for (int i=1; i<=N; i++) {
        memset(vis, false, sizeof(vis));
        memset(dist, 0, sizeof(dist));
        memset(previous, 0, sizeof(previous));
        int p = bfs(i);
        if (p != -1){
            ans.clear();
            while (p != 0) {
                ans.push_back(p);
                p = previous[p];
            }
        }
    }
    if (best == INT_MAX) printf("-1\n");
    else {
        printf("%d\n", best);
        for (int a: ans){
            printf("%d\n", a);
        }
    }
    return 0;
}

Compiler output:
a.cc:12:12: error: 'INT_MAX' was not declared in this scope
   12 | int best = INT_MAX;
      |            ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <queue>
  +++ |+#include <climits>
    5 | 
a.cc: In function 'int main()':
a.cc:60:17: error: 'INT_MAX' was not declared in this scope
   60 |     if (best == INT_MAX) printf("-1\n");
      |                 ^~~~~~~
a.cc:60:17: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    vector<vector<int>> edges(n);
    for(int i = 0; i < m; ++i){
        cin >> a[i] >> b[i];
        --a[i], --b[i];
        edges[a[i]].emplace_back(b[i]);
    }
    
    vector<int> v;
    unordered_set<int> s;
    function<bool(int)> f = [&](int x){

        v.emplace_back(x);
        if(v.size() >= n)
            break;
        s.insert(x);
        for(auto& y : edges[x]){
            if(v[0] == y)
                return true;
            if(s.find(y) != s.end())
                continue;
            if(f(y))
                return true;
        }
        v.pop_back();
        s.erase(x);
        return false;
    };
    
    bool fl = false;
    for(int i = 0; i < n; ++i){
        if(f(i)){
            fl = true;
            break;
        }
    }
    if(!fl){
        cout << -1 << endl;
        return 0;
    }
    
    auto g = [&](){
        vector<int> idx(n, -1);
        for(int i = 0; i < v.size(); ++i)
            idx[v[i]] = i;
        for(int i = 0; i < m; ++i){
            int ai = idx[a[i]];
            int bi = idx[b[i]];
            if(ai != -1 && bi != -1){
                if(abs(ai - bi) <= 1)
                    continue;
                if(min(ai, bi) == 0 && max(ai, bi) == v.size() - 1)
                    continue;
                vector<int> w;
                if(ai < bi){
                    for(int i = 0; i <= ai; ++i)
                        w.emplace_back(v[i]);
                    for(int i = bi; i < v.size(); ++i)
                        w.emplace_back(v[i]);
                }
                else{
                    for(int i = bi; i <= ai; ++i)
                        w.emplace_back(v[i]);
                }
                v = move(w);
                return true;
            }
        }
        return false;
    };
    
    while(g());
    cout << v.size() << endl;
    for(auto& x : v)
        cout << x + 1 << endl;
    
    return 0;
}

Compiler output:
a.cc: In lambda function:
a.cc:22:13: error: break statement not within loop or switch
   22 |             break;
      |             ^~~~~
Language: C++

#include <bits/stdc++.h>
#include <queue>
using namespace std;
int n,m,flag=0;
queue <int> q;
int cnt=0,tot=0,index=0,cal=0;
const int maxn=25005;
int to[maxn*4],nex[maxn*4],jud[maxn];
int vis[maxn],head[maxn],stacks[maxn],dnf[maxn],low[maxn];
void add(int u,int v)
{
    to[++cnt]=v,nex[cnt]=head[u],head[u]=cnt;
}
void Tarjan(int u)
{
    if(flag)
        return;
    dnf[u]=low[u]=++tot;
    stacks[++index]=u;
    vis[u]=1;
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];
        if(!dnf[v])
        {
            Tarjan(v);
            low[u]=min(low[u],low[v]);
        }
        else if(vis[v])
        {
            flag=1;
            low[u]=min(low[u],dnf[v]);
            break;
        }
    }
    if(low[u]==dnf[u])
    {
        int mid;
        do
        {
            mid=stacks[index--];
           // printf("%d\n",mid);
            q.push(mid);
            vis[mid]=0;
        }while(mid!=u);
        if(q.size()==1)
            q.pop();
    }
}
int main()
{
    scanf("%d%d",&m,&n);
    for(int i=1;i<=n;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        add(u,v);
    }
    memset(dnf,0,sizeof(dnf));
    memset(low,0,sizeof(low));
    for(int i=1;i<=m;i++)
    {
        if(q.size()>1)
            break;
        else
        {
            while(!q.empty())
                q.pop();
        }
        if(!dnf[i])
        {
            Tarjan(i);
        }
    }
    if(q.size()<2)
        printf("-1");
    else
    {
        printf("%d\n",q.size());
        while(!q.empty())
        {
            int t=q.front();
            printf("%d\n",t);
            q.pop();
        }
    }
    return 0;
}


Compiler output:
a.cc:6:17: error: 'int index' redeclared as different kind of entity
    6 | int cnt=0,tot=0,index=0,cal=0;
      |                 ^~~~~
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'void Tarjan(int)':
a.cc:19:14: error: no pre-increment operator for type
   19 |     stacks[++index]=u;
      |              ^~~~~
a.cc:41:29: error: no post-decrement operator for type
   41 |             mid=stacks[index--];
      |                             ^~
Language: C++

import sys
input = sys.stdin.readline

n , m = map(int,input(),split())

edge = [[]for _ in [0] * n]
back = [[]for _ in [0] * n]

for _ in [0] * m:
    a , b = map(int,input(),split())
    edge[a-1].append(b-1)
    back[b-1].aapend(a-1)

res = [None] * (n+1)

for end in range (n):
    for start in edge [end]:
        cost = [-1] * n
        cost = [start] = 0
        new = [start]
        tank = []
        judge = True

    while len (new) > 0 and judge:
        tank = []
        for fr in new:
            for go in edge [fr]:
                if cost [go] < 0:
                    cost [go] = cost [fr] + 1
                    tank.append(go)
                    if go == end:
                        judge = False
        new = tank

    if cost [end] >= 0 and cost [end] < len (res):
        p = end
        res = [p + 1]
        while p! = start:
            for e in back [p]:
                if cost [p] == cost [e] + 1:
                    p = e
                    res.append (p + 1)
                    break

    if res [0] == None:
        print (-1)

    else:
        print(les(res))
        for e in res:
            print(e)

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import sys
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define gcd __gcd
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define mp make_pair
#define pb push_back
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define sbits(a) __builtin_popcount(a)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define nani(x) cerr << #x << " is " << x << endl;
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 1000000000
#define mod 1000000007

typedef long long ll;

const int N = 1005;

int p[N];
vector<int> G[N];

int bfs(int x)
{
    queue<int> q;
    q.push(x);

    while (!q.em) {
        int a = q.front();
        q.pop();
        vis[a] = 1;
        for (auto& i : G[a]) {
            if (i == x)
                return a;
            q.push(i);
            p[i] = a;
        }
    }

    return 0;
}

int main()
{
    fast;

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, m;
    cin >> n >> m;

    while (m--) {
        int u, v cin >> u >> v;
        G[u].pb(v);
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++)
            p[j] = 0;

        int q = bfs(i);

        if (q) {
            vector<int> v;
            v.pb(i);

            while (q != i) {
                v.pb(q);
                q = p[q];
            }

            cout << v.sz << "\n";

            for (auto& j : v)
                cout << j << "\n";

            return 0;
        }
    }

    cout << -1;

    return 0;
}


Compiler output:
a.cc: In function 'int bfs(int)':
a.cc:61:9: error: 'vis' was not declared in this scope
   61 |         vis[a] = 1;
      |         ^~~
a.cc: In function 'int main()':
a.cc:84:18: error: expected initializer before 'cin'
   84 |         int u, v cin >> u >> v;
      |                  ^~~
a.cc:85:17: error: 'v' was not declared in this scope
   85 |         G[u].pb(v);
      |                 ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N, M;
vector<int> pathes[1005];
bool visiting[1005];
bool visited[1005];
int indexes[1005];
bool appeared[1005];
vector<int> circuit;
vector<int> ans;
int endpoint = -1;
bool dfs(int now) {
    if(endpoint != -1) return;
    visiting[now] = true;
    visited[now] = true;
    for(auto to : pathes[now]) {
        if(visiting[to]) {
            circuit.push_back(now);
            endpoint = to;
            return true;
        }
        if(visited[to]) continue;
        if(dfs(to)) {
            circuit.push_back(now);
            return endpoint != now;
        }
    }
    visiting[now] = false;
    return false;
}


int main() {
    //cout.precision(10);
    cin >> N >> M;
    for(int i = 1; i <= M; i++) {
        int a, b;
        cin >> a >> b;
        pathes[a].push_back(b);
    }
    for(int i = 1; i <= N; i++) {
        if(visited[i]) continue;
        if(dfs(i)) break;
    }
    if(circuit.empty()) {
        cout << -1 << endl;
        return 0;
    }
    reverse(circuit.begin(), circuit.end());
    bool ok = false;
    int n = circuit.size() - 1;
    for(auto to : pathes[circuit[n]]) {
        if(to == circuit[0]) ok = true;
    }
    if(!ok) return 1;
    for(int i = 1; i <= N; i++) indexes[i] = -1;
    for(int i = 0; i < circuit.size(); i++) {
        indexes[circuit[i]] = i;
    }
    for(int i = 0; i < circuit.size(); i++) {
        appeared[circuit[i]] = true;
        int maxi = -1;
        for(auto to : pathes[circuit[i]]) {
            if(indexes[to] == -1) continue;
            if(!appeared[to]) continue;
            if(indexes[to] < i) chmax(maxi, indexes[to]);
        }
        if(maxi != -1) {
            cerr << "B" << endl;
            for(int j = maxi; j <= i; j++) if(appeared[circuit[j]]) ans.push_back(circuit[j]);
            cout << ans.size() << endl;
            for(auto to : ans) cout << to << endl;
            return 0;
        }
        if(i + 1 == circuit.size()) {
            cerr << "A" << endl;
            for(int j = 0; j < circuit.size(); j++) if(appeared[circuit[j]]) ans.push_back(circuit[j]);
            cout << ans.size() << endl;
            for(auto to : ans) cout << to << endl;
            return 0;
        }
        maxi = -1;
        for(auto to : pathes[circuit[i]]) {
            if(indexes[to] == -1) continue;
            if(indexes[to] > i) chmax(maxi, indexes[to]);
        }
        if(maxi != -1) i = maxi - 1;
    }
    return 0;
}


Compiler output:
a.cc: In function 'bool dfs(int)':
a.cc:38:24: error: return-statement with no value, in function returning 'bool' [-fpermissive]
   38 |     if(endpoint != -1) return;
      |                        ^~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int N, M, A[1 << 18], B[1 << 18];
pair<int, int> dist[1 << 18];
vector<int> X[1 << 18], Y;

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> A[i] >> B[i];
		X[A[i]].push_back(B[i]);
	}
	for (int i = 0; i < 10000; i++) Y.push_back(i);
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) dist[j] = make_pair(1 << 30, -1);

		queue<int> Q;
		for (int j : X[i]) {
			dist[j] = make_pair(1, i);
			Q.push(j);
		}
		while (!Q.empty()) {
			int pos = Q.front(); Q.pop();
			for (int j : X[pos]) {
				if (dist[j].first > dist[pos].first + 1) {
					dist[j].first = dist[pos].first + 1;
					dist[j].second = pos;
					Q.push(j);
				}
			}
		}

		if (dist[i].first != (1 << 30)) {
			vector<int> R; int cx = i;
			while (true) {
				cx = dist[cx].second;
				R.push_back(cx);
				if (cx == i) break;
			}
			reverse(R.begin(), R.end());
			if (Y.size() > R.size()) Y = R;
		}
	}
	if (Y.size() == 10000) cout << "-1" << endl;
	else {
		cout << Y.size() << endl;
		for (int i = 0; i < Y.size(); i++) cout << Y[i] << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:25: error: 'reverse' was not declared in this scope
   43 |                         reverse(R.begin(), R.end());
      |                         ^~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

int n = 1000, m, cost[1000][1000];
void warshall_floyd(){
  for(int k = 0; k < n; k++)
    for(int i = 0; i < n; i++)
      for(int j = 0; j < n; j++)
        if(cost[i][j] > cost[i][k] + cost[k][j])
          cost[i][j] = cost[i][k] + cost[k][j];
}
void answer(int to){
  int from = to, size = cost[to][to];
  while(size--){
    for(int i = 0; i < n; i++)
      if(cost[from][i] == 1 && cost[i][to] == size){
        cout << from << endl;
        from = i;
    }
  }
}
int main(){
  for(auto& i : cost) for(auto& j : i) j = 0x3fffffff;
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    cost[a - 1][b - 1] = 1;
  }
  warshall_floyd();
  int min = 0x3fffffff, index = -1;
  for(int i = 0; i < n; i++)
    if(min > cost[i][i]){
      min = cost[i][i];
      index = i;
  }
  if(index == -1) puts("-1");
  else answer(i);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:15: error: 'i' was not declared in this scope
   38 |   else answer(i);
      |               ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

int n = 1000, m;
int cost[n][n];
void warshall_floyd(){
  for(int k = 0; k < n; k++)
    for(int i = 0; i < n; i++)
      for(int j = 0; j < n; j++)
        if(cost[i][j] > cost[i][k] + cost[k][j])
          cost[i][j] = cost[i][k] + cost[k][j];
}
void answer(int to){
  int from = to, size = cost[to][to];
  while(size--){
    for(int i = 0; i < n; i++)
      if(cost[from][i] == 1 && cost[i][to] == size){
        cout << from << endl;
        from = i;
    }
  }
}
int main(){
  for(auto& i : cost) for(auto& j : i) j = 0x3fffffff;
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    cost[a - 1][b - 1] = 1;
  }
  warshall_floyd();
  int min = 0x3fffffff, index = -1;
  for(int i = 0; i < n; i++)
    if(min > cost[i][i]){
      min = cost[i][i];
      index = i;
  }
  if(index == -1) puts("-1");
  else answer(i);
}


Compiler output:
a.cc:5:13: error: size of array 'cost' is not an integral constant-expression
    5 | int cost[n][n];
      |             ^
a.cc:5:10: error: size of array 'cost' is not an integral constant-expression
    5 | int cost[n][n];
      |          ^
a.cc: In function 'int main()':
a.cc:39:15: error: 'i' was not declared in this scope
   39 |   else answer(i);
      |               ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

int n = 1000, m, cost[n][n];
void warshall_floyd(){
  for(int k = 0; k < n; k++)
    for(int i = 0; i < n; i++)
      for(int j = 0; j < n; j++)
        if(cost[i][j] > cost[i][k] + cost[k][j])
          cost[i][j] = cost[i][k] + cost[k][j];
}
void answer(int to){
  int from = to, size = cost[to][to];
  while(size--){
    for(int i = 0; i < n; i++)
      if(cost[from][i] == 1 && cost[i][to] == size){
        cout << from << endl;
        from = i;
    }
  }
}
int main(){
  for(auto& i : cost) for(auto& j : i) j = 0x3fffffff;
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    cost[a - 1][b - 1] = 1;
  }
  warshall_floyd();
  int min = 0x3fffffff, index = -1;
  for(int i = 0; i < n; i++)
    if(min > cost[i][i]){
      min = cost[i][i];
      index = i;
  }
  if(index == -1) puts("-1");
  else answer(i);
}

Compiler output:
a.cc:4:26: error: size of array 'cost' is not an integral constant-expression
    4 | int n = 1000, m, cost[n][n];
      |                          ^
a.cc:4:23: error: size of array 'cost' is not an integral constant-expression
    4 | int n = 1000, m, cost[n][n];
      |                       ^
a.cc: In function 'int main()':
a.cc:38:15: error: 'i' was not declared in this scope
   38 |   else answer(i);
      |               ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int n,m,s,f,id=0;
vector <int> g[1005],used,ans,viz;
void check(int v,int p){
    viz[v]=1;
    if(v==p){
    id=1;
    return ;
    }
       for(int k=0;k<g[v].size();k++){
        int to=g[v][k];
        if(viz[to]==0)
           check(to,p);
        }

}

void DFS(int v){
    used[v]=1;
    for(int k=0;k<g[v].size();k++){
        int to=g[v][k];
        if(used[to]==0)
           DFS(to);
        else{
        viz.resize(0);
        viz.resize(n+1,0);
        id=0;
        check(to,v);
        if(id){
           s=to;
           f=v;
        }
        }
    }
}
void get(int v,vector <int> p){
    used[v]=1;
    p.push_back(v);
    if(v==f && asn.size()==0){
        ans=p;
        return;
    }
 for(int k=0;k<g[v].size();k++){
        int to=g[v][k];
        if(used[to]==0)
           get(to,p);
    }
}
main(){
cin>>n>>m;
for(int k=1;k<=m;k++){
   int a,b;
   cin>>a>>b;
   g[a].push_back(b);
}
used.resize(0);
used.resize(n+1,0);
for(int k=1;k<=n;k++){
   if(used[k]==0){
   DFS(k);
   }
}
if(s==0 && f==0){
    cout<<-1;
    return 0;
}
used.resize(0);
used.resize(n+1,0);
get(s,ans);
cout<<ans.size()<<endl;
for(auto i : ans)
    cout<<i<<endl;
return 0;
}


Compiler output:
a.cc: In function 'void get(int, std::vector<int>)':
a.cc:40:16: error: 'asn' was not declared in this scope; did you mean 'asin'?
   40 |     if(v==f && asn.size()==0){
      |                ^~~
      |                asin
a.cc: At global scope:
a.cc:50:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   50 | main(){
      | ^~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);

  int N, M; cin>>N>>M;
  vector<vector<int>> graph(N);
  for (int i = 0; i < M; i++) {
	int a, b; cin>>a>>b;
	a--; b--;
	graph[a].push_back(b);
  }
  auto find_circuit = [&, f=[&](auto g, int root, int c, vector<bool>& visited) -> unordered_set<int> {
    if (visited[c]) {
	  unordered_set<int> res;
	  for (int i = 0; i < N; i++) {
		if (visited[i]) {
		  res.insert(i);
		}
	  }
	  return res;
    }
	visited[c] = true;
	for (auto t : graph[c]) {
	  set<int> res = g(g, root, t, visited);
	  if (not res.empty()) {
	    return res;
	  }
	}
	visited[c] = false;
	return {};
  }](int root) {
    vector<bool> visited(N, false);
	return f(f, root, root, visited);
  };

  auto make_graph = [&](unordered_set<int>& route) {
	vector<vector<int>> ngraph(N);
	for (auto s : route) {
	  for (auto t : graph[s]) {
		if (route.count(t)) {
		  ngraph[s].push_back(t);
		}
	  }
	}
	return ngraph;
  };

  unordered_set<int> route;
  for (int i = 0; i < N; i++) {
	route = find_circuit(i);
	if (not route.empty()) {
	  break;
	}
  }
  if (route.empty()) {
    cout << -1 << endl;
    return 0;
  }

  while (true) {
	graph = make_graph(route);
	int r = -1;
	{
	  // Find vertex more than 2 in-degrees.
	  unordered_set<int> in;
	  for (auto s : route) {
		for (auto t : graph[s]) {
		  if (in.count(t)) {
			r = t;
			break;
		  }
		  in.insert(t);
		}
		if (r != -1)
		  break;
	  }
	}
	if (r == -1) {
	  break;
	}
	set<int> from;
	for (auto s : route) {
	  for (auto t : graph[s]) {
	    if (t == r)
	      from.insert(s);
	  }
	}

	route = {r};
	int c = r;
	while (from.count(c) == 0) {
	  c = graph[c].front();
	  route.insert(c);
	}
  }
  cout << route.size() << endl;
  for (auto s : route)
	cout << s+1 << endl;

  return 0;
}


Compiler output:
a.cc: In lambda function:
a.cc:29:20: error: could not convert 'static_cast<std::set<int>&&>(res)' from 'std::set<int>' to 'std::unordered_set<int>'
   29 |             return res;
      |                    ^~~
      |                    |
      |                    std::set<int>
a.cc: In instantiation of 'main()::<lambda(auto:28, int, int, std::vector<bool>&)> [with auto:28 = main()::<lambda(auto:28, int, int, std::vector<bool>&)>]':
a.cc:36:10:   required from here
   36 |         return f(f, root, root, visited);
      |                ~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:27:27: error: conversion from 'std::unordered_set<int>' to non-scalar type 'std::set<int>' requested
   27 |           set<int> res = g(g, root, t, visited);
      |                          ~^~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
inline bool chmin(T &a, T b) { return a > b && (a = b, true); }

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;

	vector<vector<int>> d(N, vector<int>(N, INF));

	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		d[a][b] = 1;
	}
	DMP(d);

	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	DMP(d);

	int mincyc = INF;
	vector<int> ans;
	for (int i = 0; i < N; i++) chmin(mincyc, d[i][i]);
	for (int i = 0; i < N; i++) {
		if (d[i][i] == mincyc) {
			if (ans.empty()) ans.emplace_back(i);
			else if (mincyc == d[i][ans[0]] + d[ans[0]][i]) ans.emplace_back(i);
		}
	}

	if (ans.empty()) cout << -1 << "\n";
	else {
		cout << ans.size() << "\n";
		for (const auto &e : a) cout << e + 1<< "\n";
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:81:38: error: 'a' was not declared in this scope
   81 |                 for (const auto &e : a) cout << e + 1<< "\n";
      |                                      ^
Language: C++

#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;
 
#define BUFF ios::sync_with_stdio(false)
#define rep(i,a,b) for (int i=a; i<b; i++)
#define pb push_back
#define vvi vector<vector<int>> 
#define vi vector<int>
#define vb vector<bool>
#define vvb vector<vector<bool>> 
 
vi p;
vector<int> cor;
pair<int, int> par = {-1, -1}; 
void dfs_visit(vvi & adj, int i) {
		cor[i] = 1;
		for (int j : adj[i]) {
			if (cor[j] == 1) {
				par = {i, j};
				for(int i=1; i<=n; i++) {
					cor[i] = 2;
				}
			}
			if (cor[j] == 0) {
				p[j] = i;
				dfs_visit(adj, j);
			}
		}
		cor[i] = 2;
}
 
void dfs(vvi & adj, int n) {
	p.assign(n+1, 1);
	cor.assign(n+1, 0);
	for(int i=1; i<=n; i++) {
		if (cor[i] == 0) {
			dfs_visit(adj, i);
		}
	}
}
 
int main() {
	int n, m, a, b;
	cin >> n >> m;
 
	vi vetor;
	vetor.assign(n+1, 0);
 
	vvi adj;
	vi lista;
	lista.clear();
	adj.assign(n+1, lista);
	for (int i=1; i<=m; i++) { 
		cin >> a >> b;
		adj[a].pb(b);
	}
	dfs(adj, n);

	if (par.first == -1) cout << -1 << endl;
	else {
		vector<int> w;
		int k = par.first;
		while (k != par.second) {
			w.push_back(k);
			k = p[k];
		}
		w.push_back(k);
		cout << w.size() << endl;
		for(int i=0; i<w.size(); i++) {
			cout << w[i] << endl;
		}
	}
   
   return 0;
 
}


Compiler output:
a.cc: In function 'void dfs_visit(std::vector<std::vector<int> >&, int)':
a.cc:35:49: error: 'n' was not declared in this scope
   35 |                                 for(int i=1; i<=n; i++) {
      |                                                 ^