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

// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")
 
// #include <bits/extc++.h>
// using namespace __gnu_pbds;
 
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;
 
// #define X first
// #define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back
 
#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);
 
const int INF = 1E18;
const int mod = 1E9 + 7;
const int maxn = 1E5 + 5;

vector<int> adj[maxn], vis(maxn, 0);
deque<int> deck;

void dfs(int now, int root) {
    vis[now] = 1;
    for (auto x : adj[now]) {
        if (!vis[x]) {
            vis[x] = 1, dfs(x, root);
            
            if (root == -1) deck.push_front(x);
            else deck.push_back(x);
            
            if (now != root) return;
            else root = -1;
        }
    }
}

int32_t main() {
    fastIO();
    
    int n, m;
    cin >> n >> m;
    
    while (m--) cin >> u >> v, adj[u].eb(v), adj[v].eb(u);
    
    dfs(1);
    
    while (!deck.empty()) {cout << deck.front() << " "; deck.pop_front();}
    
    return 0;
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:60:24: error: 'u' was not declared in this scope
   60 |     while (m--) cin >> u >> v, adj[u].eb(v), adj[v].eb(u);
      |                        ^
a.cc:60:29: error: 'v' was not declared in this scope
   60 |     while (m--) cin >> u >> v, adj[u].eb(v), adj[v].eb(u);
      |                             ^
a.cc:62:8: error: too few arguments to function 'void dfs(long long int, long long int)'
   62 |     dfs(1);
      |     ~~~^~~
a.cc:39:6: note: declared here
   39 | void dfs(int now, int root) {
      |      ^~~
Language: C++

12 18
3 5
4 12
9 11
1 10
2 5
6 10
8 11
1 3
4 10
2 4
3 7
2 10
3 12
3 9
1 7
2 3
2 11
10 11

Compiler output:
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 12 18
      | ^~
Language: C++

#include<bits/stdc++.h>

using namespace std;

int main(void) {
    long n, m;
    cin >> n >> m;

    vector<vector<int>> G(n);

    int s = 0;
    for(int i=0; i<m; i++) {
        int a,b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
        s = a;
    }
    int ss = s;

    vector<int> res = {s};
    set<int> st; st.insert(s);

    while(1) {
        for(auto v: G[s]) {
            if(st.count(v)) continue;
            s = v;
            res.push_back(s);
            st.insert(s);
            goto nxt;
        }
        break;
nxt:
        ;
    }

    vector<int> ser;
    s = ss;
    while(1) {
        for(auto v: G[s]) {
            if(st.count(v)) continue;
            s = v;
            ser.push_back(s);
            st.insert(s);
            goto nxt;
        }
        break;
nxt:
        ;
    }

    cout << ser.size() + res.size() << endl;
    for(auto x: ser) cout << x+1 << endl;
    for(auto x: res) cout << x+1 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:1: error: duplicate label 'nxt'
   49 | nxt:
      | ^~~
Language: C++

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

#define pb push_back

const int MAXN = 1e5 + 10;

int n, m;
int u, v;
int d[MAXN], dd[MAXN], par[MAXN];
vector <int> adj[MAXN];

void dfs(int root) {
    for (auto y: adj[root])
        if (!d[y]) {
            d[y] = d[root] + 1;
            dfs(y);
        }
}

void dfs_2(int root) {
    for (auto y: adj[root])
        if (!dd[y]) {
            dd[y] = dd[root] + 1;
            par[y] = root;
            dfs(y);
        }
}

int main() {
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> u >> v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    
    d[1] = 1;
    dfs(1);
    
    int tmp, mx = 0;
    for (int i = 1; i <= n; i++)
        if (mx < d[i]) {
            mx = d[i];
            tmp = i;
        }
        
    dd[tmp] = 1;
    par[tmp] = -1;
    dfs_2(tmp);
    
    mx = 0;
    for (int i = 1; i <= n; i++)
        if (mx < dd[i]) {
            mx = dd[i];
            tmp = i;
        }
    cout << mx << '\n';
    while (par[tmp] > 0) {
        cout << tmp << ' ';
        tmp = par[tmp];
    }
    cout << tmp << '\n';
    return 0;
}

Compiler output:
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:4:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::_Vector_base<int, std::allocator<int> >::_Vector_impl::~_Vector_impl()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = int]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:132:14: note: called from here
  132 |       struct _Vector_impl
      |              ^~~~~~~~~~~~
Language: C++

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int MAX_N = 100010;

int a, b, visited[MAX_N];
vector<int> to[MAX_N], ret;

void dfs(int v) {

	ret.push_back(v); 

    visited[v] = 1;

	for(auto u : to[v]) {
        if(!visited[u]) {
            dfs(u);
            break;
	    }
    }

}

int main() {
    int n, m;
    cin >> n >> m;
	
	rep(i, m) {
		cin >> a >> b;
        a--;  b--;
		to[a].push_back(b); 
        to[b].push_back(a);
	}

	visited[b] = 1;

	dfs(a);

	reverse(all(ret));

	visited[b] = 0;

	dfs(a);

	cout << ret.size() << "\n";

	for(auto p : ret) {
        cout << p << " ";
    } 

    cout << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:17: error: 'all' was not declared in this scope; did you mean 'll'?
   50 |         reverse(all(ret));
      |                 ^~~
      |                 ll
Language: C++

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int MAX_N = 100010;

int a, b;
vector<int> to(MAX_N), visited(MAX_N), ret;

void dfs(int v) {

	ret.push_back(v); 

    visited[v] = 1;

	for(auto u : to[v]) {
        if(!visited[u]) {
            dfs(u);
            break;
	    }
    }

}

int main() {
    int n, m;
    cin >> n >> m;
	
	rep(i, m) {
		cin >> a >> b;
        a--;  b--;
		to[a].push_back(b); 
        to[b].push_back(a);
	}

	visited[b] = 1;

	dfs(a);

	reverse(all(ret));

	visited[b] = 0;

	dfs(a);

	cout << ret.size() << "\n";

	for(auto p : ret) {
        cout << p << " ";
    } 

    cout << endl;
    return 0;
}

Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:26:26: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   26 |         for(auto u : to[v]) {
      |                          ^
      |                          std::begin
In file included from /usr/include/c++/14/string:53,
                 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/range_access.h:114:37: note: 'std::begin' declared here
  114 |   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
      |                                     ^~~~~
a.cc:26:26: error: 'end' was not declared in this scope; did you mean 'std::end'?
   26 |         for(auto u : to[v]) {
      |                          ^
      |                          std::end
/usr/include/c++/14/bits/range_access.h:116:37: note: 'std::end' declared here
  116 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
      |                                     ^~~
a.cc: In function 'int main()':
a.cc:42:23: error: request for member 'push_back' in 'to.std::vector<int>::operator[](((std::vector<int>::size_type)a))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   42 |                 to[a].push_back(b);
      |                       ^~~~~~~~~
a.cc:43:15: error: request for member 'push_back' in 'to.std::vector<int>::operator[](((std::vector<int>::size_type)b))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   43 |         to[b].push_back(a);
      |               ^~~~~~~~~
a.cc:50:17: error: 'all' was not declared in this scope; did you mean 'll'?
   50 |         reverse(all(ret));
      |                 ^~~
      |                 ll
Language: C++

#include <bits/stdc++.h>
using namespace std;
struct edge{int from, to;};
int N, M;
typedef vector<int> vi;
vi G[N];
bool used[N];

int main(){
  cin>>N>>M;
  for (int i=0;i<M;++i){
    int a, b;cin >>a>>b;
    G[a].push_back(b);G[b].push_back(a);
  }

  int cnt=0;
  vector<edge> path;
  int pos=0;

  while(true){
    int j=0;
    while(used[G[pos][j]]&&j<G[pos].size()) j++;
    if(j==G[pos].size()) break;
    int v=G[pos][j];
    edge e=(edge){pos, v};
    path.push_back(e);
    used[v]=true;
    pos=v;
  }

  int K=path.size();
  cout << K << endl;
  for (int i=0;i<K;++i){
    edge e=path[i];int f=e.from, t=e.to;
    cout << f << ' ' << t << endl;
  }
  return 0;
}

Compiler output:
a.cc:6:6: error: size of array 'G' is not an integral constant-expression
    6 | vi G[N];
      |      ^
a.cc:7:11: error: size of array 'used' is not an integral constant-expression
    7 | bool used[N];
      |           ^
Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef complex<ld> Point;
const ll mod = 1000000007;
const ld INF = 1e+30;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

bool used[1 << 17];
vector<int> G[1 << 17];
void solve() {
	int n, m; cin >> n >> m;
	rep(i, m) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int l = 0, r = 1; used[0] = used[1] = true;
	vector<int> le({ 0 }), ri({ 1 });
	while (true) {
		bool f = true;
		rep(j, G[l].size()) {
			int to = G[l][j];
			if (used[to])continue;
			else {
				f = false;
				le.push_back(to);
				used[to] = true;
				l = to;
				break;
			}
		}
		if (f)break;
	}
	while (true) {
		bool f = true;
		rep(j, G[r].size()){
			int to = G[r][j];
			if (used[to])continue;
			else {
				f = false;
				ri.push_back(to);
				used[to] = true;
				r = to;
				break;
			}
		}
		if (f)break;
	}
	reverse(le.begin(), le.end());
	rep(i, ri.size())le.push_back(ri[i]);
	cout << le.size() << endl;
	rep(i, le.size()) {
		if (i > 0)cout << " ";
		cout << le[i];
	}
	cout << endk;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	//stop
	return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:88:17: error: 'endk' was not declared in this scope
   88 |         cout << endk;
      |                 ^~~~
Language: C++

#include <iostream>
#include <vector>
#include <deque>
using namespace std;
int main() {
  int n, m;
  vector<vector<int>> g(n+1);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  // dfs-like
  deque<int> ans;
  vector<bool> v(n+1, false);
  ans.push_back(1);
  v[1] = true;
  while (true) {
    auto p = ans.back();
    bool finished = true;
    for (const auto &r : g[p]) {
      if (!v[r]) {
        ans.push_back(r);
        v[r] = true;
        finished = false;
        break;
      }
    }
    if (finished) break;
  }
  while (!ans.empty) {
    const auto r = ans.back();
    ans.pop_back();
    cout << r;
    if (ans.empty()) cout << endl; else cout << " ";
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:15: error: cannot convert 'std::deque<int>::empty' from type 'bool (std::deque<int>::)() const noexcept' to type 'bool'
   33 |   while (!ans.empty) {
      |               ^~~~~
a.cc:33:15: error: in argument to unary !
   33 |   while (!ans.empty) {
      |           ~~~~^~~~~
Language: C++

#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;

int n,m,f,r;
vector<int> g[100100];
set<int> t;
int out[300000];

bool find(int x){
	for(int i=0;i<g[x].size();i++){
		if(t.find(g[x][i])==t.end())return false;
	}
	return true;
}

void fun(int x,bool fl){
	while(!find(x)){
		for(int i=0;i<g[x].size();i++){
			if(t.find(g[x][i])==t.end()){
				a=g[x][i];
				t.insert(x);
				if(fl)out[f--]=x;
				else out[r++]=x;
				break;
			}
		}
	}
}

void func(int a,int b){
	t.insert(a);
	out[f--]=a;out[r++]=b;
	t.insert(b);
	fun(a,1);fun(b,0);
}

int main(){
	
	f=150000,r=150001;
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>m;
	int a,b;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	func(a,b);
	cout<<t.size()<<endl;
	for(int i=f+1;i<r;i++){
		if(out[i]!=0) cout<<out[i]<<' ';
	}
	return 0;
}

Compiler output:
a.cc: In function 'void fun(int, bool)':
a.cc:31:33: error: 'a' was not declared in this scope
   31 |                                 a=g[x][i];
      |                                 ^
Language: C++

#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;

int n,m;
int f,r;
vector<int> g[100100];
set<int> t;
int out[300000];

bool find(int x){
	for(int i=0;i<g[x].size();i++){
		if(t.find(g[x][i])==t.end())return false;
	}
	return true;
}

void func(int a,int b){
	t.insert(a);
	out[f--]=a;out[r++]=b;
	t.insert(b);
	while(!find(a)){
		for(int i=0;i<g[a].size();i++){
			if(t.find(g[a][i])==t.end()){
				a=g[a][i];
				t.insert(a);
				out[f--]=a;
				break;
			}
		}
	}
	while(!find(b)){
		for(int i=0;i<g[b].size();i++){
			if(t.find(g[b][i])==t.end()){
				b=g[b][i];
				t.insert(b);
				out[r++]=b;
				break;
			}
		}
	}
}

int mbin(){
	
	f=150000,r=150001;
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>m;
	int a,b;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	func(a,b);
	cout<<t.size()<<endl;
	for(int i=f+1;i<r;i++){
		if(out[i]!=0) cout<<out[i]<<' ';
	}
	return 0;
}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+3;
vector<int> v[N];
bool vis[N];
list<int> L;
int n,m;
void dfs(int u, bool ok){
	for(int i=0; i<v[u].size(); ++i){ 
		if(!vis[v[u][i]]){
			if(ok) L.push_front(v[u][i]);
			else L.push_back(v[u][i]);
			vis[v[u][i]] = true;
			dfs(e,ok);
			return;
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);
	memset(vis,false,sizeof(vis));
	while(m--){
		int a,b;
		scanf("%d%d",&a,&b);
		v[a].push_back(b);
		v[b].push_back(a);
	}
	L.push_back(1);
	L.push_back(v[1][0]);
	vis[1]=vis[v[1][0]]=true;
	dfs(1,true);
	dfs(v[1][0], false);
	printf("%d\n",L.size());
	for(auto it=L.begin(); it!=L.end(); ++it)
		printf("%d ",*it);
	printf("\n");
	return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, bool)':
a.cc:14:29: error: 'e' was not declared in this scope
   14 |                         dfs(e,ok);
      |                             ^
Language: C++

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

vector<int> dfs(vector< vector<int> > &G, vector<bool> &visited, int v){
  vector<int> ret;
  for(int i = 0; i < G[v].size(); ++i){
    int v_ = G[v][i];
    if(visited[v_]) continue;
    visited[v_] = true;
    ret = dfs(G, visited, v_);
	break;
  }
  ret.push_back(v);
  return ret;
}

int main(){
  int N, M;
  cin >> N >> M;
  vector< vector<int> > G(N);
  for(int i = 0; i < M; ++i){
    int a, b;
    cin >> a >> b;
    --a;--b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<bool> visited(N, false);
  int s = 0, t = G[0][0];
    visited[s] = true;
  visited[t] = true;
  vector<int> S = dfs(G, visited, s), T = dfs(G, visited, t);
  reverse(T.begin(), T.end());
  cout << S.size() + T.size() << endl;
  for(int i = 0; i < S.size(); ++i) cout << S[i]+1 << " ";
  for(int i = 0; i < T.size()-1; ++i) cout << T[i]+1 << " ";
  cout << T.back()+1 << endl;
  return 0;
}


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

#include <bits/stdc++.H>
#define N 200010
using namespace std;

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}

struct edge{int v,next;}vs[N];
int st[N],ee,n,m,A[N],B[N],vis[N];
inline void addedge(int u,int v)
{
	vs[++ee].v=v;vs[ee].next=st[u];st[u]=ee;
}
inline bool check(int x)
{
	for(int i=st[x];i;i=vs[i].next)
		if(!vis[vs[i].v]) return 0;
	return 1;
}
int main()
{
	n=read(); m=read();
	for(int i=1;i<=m;i++)
	{
		int u=read(), v=read();
		addedge(u,v); addedge(v,u);
	}
	int S=1,T=vs[st[1]].v;
	vis[S]=1; vis[T]=1;
	while(1)
	{
		if(check(S)) break;
		for(int i=st[S];i;i=vs[i].next)
		{
			if(vis[vs[i].v]) continue;
			A[++A[0]]=S; S=vs[i].v; vis[S]=1;
			break;
		}
	}
	while(1)
	{
		if(check(T)) break;
		for(int i=st[T];i;i=vs[i].next)
		{
			if(vis[vs[i].v]) continue;
			B[++B[0]]=T; T=vs[i].v; vis[T]=1;
			break;
		}
	}
	printf("%d ",S); for(int i=A[0];i>=1;i--) printf("%d ",A[i]);
	for(int i=1;i<=B[0];i++) printf("%d ",B[i]); printf("%d\n",T);
	return 0;
}

Compiler output:
a.cc:1:10: fatal error: bits/stdc++.H: No such file or directory
    1 | #include <bits/stdc++.H>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
using namespace std;
int next[10001],head[10001],to[10001],cnt;
int a[10001],num,N=1;
int book[10001];
void add(int u,int v)
{
	cnt++;
	next[cnt]=head[u];
	head[u]=cnt;
	to[cnt]=v;
}
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++) 
	{
		int x,y;
		cin>>x>>y;
		add(x,y);
		add(y,x);
	} 
	for(int i=1;i<=n;i++)
	{
		if(head[i]!=0)
		{
			int y=i,x;
			num++;
			a[num]=y;
			book[y]=1;
			while(N==1)
			{
				N=0;
				for(int j=head[y];j!=0;j=next[j])
				{
					if(book[to[j]]==0)  { y=to[j];N=1;break;}
				}
				num++;
				a[num]=y;
				book[y]=1;
			}
			break;
		}
	}
	for(int i=1;i<=num-1;i++)  cout<<a[i]<<" ";
	return 0;
}

Compiler output:
a.cc: In function 'void add(int, int)':
a.cc:9:9: error: reference to 'next' is ambiguous
    9 |         next[cnt]=head[u];
      |         ^~~~
In file included from /usr/include/c++/14/string:47,
                 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_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:3:5: note:                 'int next [10001]'
    3 | int next[10001],head[10001],to[10001],cnt;
      |     ^~~~
a.cc: In function 'int main()':
a.cc:35:58: error: reference to 'next' is ambiguous
   35 |                                 for(int j=head[y];j!=0;j=next[j])
      |                                                          ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:3:5: note:                 'int next [10001]'
    3 | int next[10001],head[10001],to[10001],cnt;
      |     ^~~~
Language: C++

#include <iostream>
#include <set>
#include <vector>
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef vector<vector<int> > G;
const int inf = 1e9;

int n, m;
G graph;
vector<int> ans;

int visited[100005];

void dfs(int u){
    ans.push_back(u);
    visited[u] = 1;
    for(int i=0; i<graph[u].size(); i++){
        int v = graph[u][i];
        if( !( visited[v] ) ){
            return dfs(v);
            break;
        }
        return;
    }
}

int main(void){
    cin >> n >> m;
    graph = G(n);
    for(int i=0; i<m; i++){
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    
    dfs(0);
    reverse(ALL(ans));
    ans.pop_back();
    dfs(0);

    cout << ans.size() << endl;
    for(int i=0; i<ans.size(); i++){
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:5: error: 'reverse' was not declared in this scope
   41 |     reverse(ALL(ans));
      |     ^~~~~~~
Language: C++

#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
const long long llinf=LLONG_MAX;
const int inf=LONG_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,m,i,x,y,viz[nmax];
vector<int>a[nmax];
void dfs(int x)
{
	if(!viz[x])ans.pb(x);
	viz[x]=1;
	for(i=0;i<a[x].size();i++)
	 if(!viz[a[x][i]])
	 {
	 	dfs(a[x][i]);
	 	break;
	 }
}
int main()
{
	//freopen("sol.in","r",stdin);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>m;
	while(m--)
	{
		cin>>x>>y;
		a[x].pb(y);
		a[y].pb(x);
	}
	dfs(1);
	reverse(ans.begin(),ans.end());
	dfs(1);
	for(i=0;i<ans.size();i++)cout<<ans[i]<<" ";cout<<endl;
	return 0;
}

Compiler output:
a.cc:11:15: warning: overflow in conversion from 'long int' to 'int' changes value from '9223372036854775807' to '-1' [-Woverflow]
   11 | const int inf=LONG_MAX;
      |               ^~~~~~~~
a.cc: In function 'void dfs(int)':
a.cc:19:20: error: 'ans' was not declared in this scope; did you mean 'abs'?
   19 |         if(!viz[x])ans.pb(x);
      |                    ^~~
      |                    abs
a.cc: In function 'int main()':
a.cc:40:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   40 |         reverse(ans.begin(),ans.end());
      |                 ^~~
      |                 abs
Language: C++

#include <bits/stdc++.h>
  
using namespace std;
  
//#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

#define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) ;
#define LINE 	;
#define dumpV(v);
#define STOP 	;
#endif
#define mp make_pair

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fi<<", "<<a.se<<')';
    return out;
  }
}


const int MAX_N = 1e5+10;
vi es[MAX_N];
bool used[MAX_N];

int main(){
	int n, m;
	cin >> n >> m;
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		es[a].pb(b);
		es[b].pb(a);
	}
	deque<int> d;
	d.push_front(0);
	d.push_back(*es[0].begin());
	rep(i, 2) used[d[i]] = true;
	LINE;
	while(1) {
		dump(mp(d.front(), d.back()));
		bool update = false;
		for(auto& to : es[d.front()]) {
			if(!used[to]) {
				update = true;
				d.push_front(to);
				used[to] = true;
				break;
			}
		}
		for(auto& to : es[d.back()]) {
			if(!used[to]) {
				update = true;
				d.push_back(to);
				used[to] = true;
				break;
			}
		}
		if(!update) break;
	}
	cout << d.size() << endl;
	rep(i, d.size()) {
		cout << d[i]+1;
		if(i + 1 != d.size()) cout <<" ";
		else cout << endl;
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:55:13: error: 'i' was not declared in this scope
   55 |         rep(i, m) {
      |             ^
a.cc:55:9: error: 'rep' was not declared in this scope; did you mean 'repr'?
   55 |         rep(i, m) {
      |         ^~~
      |         repr
Language: C++

#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;

list<long long int> Prime(long long int num) {
	list<long long int>P;
	P.push_back(2);
	P.push_back(3);
	for (int i = 5; i <= num; i += 6) {
		bool flag = true;
		for (auto j : P) {
			if (i%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i);
		flag = true;
		for (auto j : P) {
			if ((i + 2) % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i + 2);
	}
	return P;
}

int main() {
	ios::sync_with_stdio(false);
	cin >> N >> M;
	list<int>edge[100001] = {};
	bool used[100001] = {};
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	int a, b;
	a = 1;
	b = *edge[1].begin();
	used[a] = true;
	used[b] = true;
	stack<pair<int, int>>s;
	s.push({ a, 0 });
	s.push({ b,1 });
	list<int>ret;
	ret.push_back(a);
	ret.push_back(b);
	while (!s.empty()) {
		int c;
		int d;
		c = s.top().first;
		d = s.top().second;
		s.pop();
		for (auto i : edge[c]) {
			if (!used[i]) {
				s.push({ i,d });
				used[i] = true;
				if (!d)ret.push_front(i);
				else ret.push_back(i);
				break;
			}
		}
	}
	int box = 0;
	for (auto i : ret) {
		if (box)cout << " ";
		cout << i << ;
		box++;
	}
	cout << endl;
	return 0;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:100:30: error: expected primary-expression before ';' token
  100 |                 cout << i << ;
      |                              ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>

int main(void)
{
	int n, m;

	std::cin >> n >> m;

	std::vector<std::vector<int> > v(n);

	for (int i = 0; i < m; i++) {
		int a, b;
		std::cin >> a >> b;

		a--;
		b--;
		v[a].push_back(b);
		b[b].push_back(a);
	}

	std::stack<int> s;
	for (int i = 0; i < n; i++) {
		std::vector<bool> visited(n, false);
		s.push(i);
		visited[i] = true;
		while (v[s.top()].size() > 0) {
			for (size_t j = 0; j < v[s.top()].size(); j++) {
				if (!visited[v[s.top()][j]]) {
					s.push(visited[s.top()][j]);
					break;
				}
			}
		}
		if (s.size() > 2) {
			while (!s.empty()) {
				std::cout << s.top() << std::endl;
				s.pop();
			}
			return 0;
		}
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:18: error: invalid types 'int[int]' for array subscript
   21 |                 b[b].push_back(a);
      |                  ^
a.cc:32:64: error: no match for 'operator[]' (operand types are 'std::vector<bool>::reference' and 'size_t' {aka 'long unsigned int'})
   32 |                                         s.push(visited[s.top()][j]);
      |                                                                ^
Language: C++

/*
 * Author:  vawait
 * Created Time:  六  4/22 11:59:08 2017
 * File Name: a.cpp
 */
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define red(i, a, b) for (int i = (a); i >= (b); --i)
#define clr( x , y ) memset(x,y,sizeof(x))
#define sqr(x) ((x) * (x))
#define mp make_pair
#define pb push_back
#define db pop_back
typedef long long lint;
const int maxn = 101000;
int x , y , n , m , l , r , ans[maxn*2];
int vis[maxn];
vector < int > g[maxn];

void init()
{
    scanf("%d%d",&n,&m);
    rep(i,1,m) {
        scanf("%d%d",&x,&y);
        g[x].pb( y );
        g[y].pb( x );
    }
}

void dfs(int t,int ty) {
    int y;
    if ( ty > 0 ) ans[++r] = t; else ans[--l] = t;
    vis[t] = 1;
    red(i,g[t].size()-1,0) {
        y = g[t][i];
        if ( vis[y] ) continue;
        dfs( y , ty );
        return;
    }
}

void work()
{
    l = r = maxn;
    r --;
    vis[x] = vis[y] = 1;
    dfs( x , 1 );
    dfs( y , -1 );
    printf("%d\n",r-l+1);
    rep(i,l,r) printf("%d%c",ans[i],i==r?'\n':' ');
}

int main()
{
    init();
    work();


Compiler output:
a.cc: In function 'int main()':
a.cc:68:12: error: expected '}' at end of input
   68 |     work();
      |            ^
a.cc:66:1: note: to match this '{'
   66 | {
      | ^
Language: Java


import java.util.ArrayList;
import java.util.Scanner;

import javafx.util.Pair;

class Node{
	int id;
	ArrayList<Integer>side_id_list;
	public Node(int id){
		this.id = id;
		this.side_id_list = new ArrayList<Integer>();
	}
}

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int vertex_count = sc.nextInt();
		int side_count = sc.nextInt();

		ArrayList<Node>node_list = new ArrayList<Node>();
		ArrayList<Pair<Integer,Integer>>side_list = new ArrayList<>();

		for(int i = 0;i < vertex_count;i++){
			node_list.add(new Node(i + 1));
		}

		for(int i = 0;i < side_count;i++){
			int j = sc.nextInt() - 1;
			int k = sc.nextInt() - 1;
			node_list.get(j).side_id_list.add(i);
			node_list.get(k).side_id_list.add(i);
			side_list.add(new Pair<Integer,Integer>(j,k));
		}

		ArrayList<Integer>selected_side_list = new ArrayList<Integer>();

		System.out.println("1 2");

		sc.close();
	}

}


Compiler output:
Main.java:5: error: package javafx.util does not exist
import javafx.util.Pair;
                  ^
Main.java:25: error: cannot find symbol
		ArrayList<Pair<Integer,Integer>>side_list = new ArrayList<>();
		          ^
  symbol:   class Pair
  location: class Main
Main.java:36: error: cannot find symbol
			side_list.add(new Pair<Integer,Integer>(j,k));
			                  ^
  symbol:   class Pair
  location: class Main
3 errors
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define K 600001
#define FOE(i, s, t) for (int i = s; i <= t; i++)

vector<int> nxt[K];
int n;

int dfs[K];
vector<int> ans1, ans2;

void DFS(int u, int f){
	if (f) ans2.push_back(u);
	else ans1.push_back(u);
	dfs[u] = 1;
	for (auto Z : nxt[u]) if (!dfs[Z]) {DFS(Z, f); return;}
}

int main(){
	int cx, cy;
	scanf("%d%d", &n, &m);
	FOE(i, 1, m){
		int s, t; scanf("%d%d", &s, &t);
		nxt[s].push_back(t);
		nxt[t].push_back(s);
		cx = s; cy = t;
	}
	
	dfs[cy] = 1;
	DFS(cx, 0);
	DFS(cy, 1);
	printf("%lu\n", ans1.size() + ans2.size());
	for (int i = ans1.size() - 1; i >= 0; i--) printf("%d ", ans1[i]);
	for (int i = 0; i < ans2.size(); i++) printf("%d%c", ans2[i], (i == ans2.size() - 1?'\n':' '));
}



Compiler output:
a.cc: In function 'int main()':
a.cc:23:28: error: 'm' was not declared in this scope; did you mean 'tm'?
   23 |         scanf("%d%d", &n, &m);
      |                            ^
      |                            tm
Language: C++


#include <bits/stdc++.h>
using namespace std;
 
#define pb         push_back
 
typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;
 
list<int> e[100005];
bool used[100005];
list<int> seq;
 
int main(void) {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
 
	for(int i=0; i<m; i++){
		int eb, ee;
		cin >> eb >> ee;
		eb--;
		ee--;
 
		e[eb].pb(ee);
		e[ee].pb(eb);
	}

	int n1 = 1;
	int n2 = e[1].front();
	seq.pb(n1);
	seq.pb(n2);
	used[n1] = used[n2] = true;
	//e[0].erase(e[0].begin());
	e[1].pop_front();

	int cnt = 0;
	while(1){
		cnt++;
		if(cnt > 100000/2) puts("aaa");

		bool f = true;
		for(auto it = e[n1].begin(); it != e[n1].end(); it++){
			if(used[*it] != true){
				f = false;
				seq.push_front(*it);
				used[*it] = true;
				int tmp = *it;
				e[n1].pop_front();
				n1 = tmp;
				break;
			}
		}
		if(f) break;
	}

	while(1){
		cnt++;
		if(cnt > 100000/2) puts("aaa");

		bool f = true;
		for(auto it = e[n2].begin(); it != e[n2].end(); it++){
			if(used[*it] != true){
				f = false;
				seq.push_back(*it);
				used[*it] = true;
				int tmp = *it;
				e[n2].pop_back();
				n2 = tmp;
				break;
			}
		}
		if(f) break;
	}
 
	cout << seq.size() << endl;
	int cnt = 0;
	auto it = seq.begin();
	for(; it != seq.end(); it++){
		if(cnt == seq.size()-1) break;
		printf("%d ", (*it) + 1);
		cnt++;
	}
	printf("%d\n", (*it)+1);
	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:81:13: error: redeclaration of 'int cnt'
   81 |         int cnt = 0;
      |             ^~~
a.cc:41:13: note: 'int cnt' previously declared here
   41 |         int cnt = 0;
      |             ^~~
Language: C++


#include <bits/stdc++.h>
using namespace std;
 
#define pb         push_back
 
typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;
 
list<int> e[100005];
vector<int> used(n, 0);
list<int> seq;
 
int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int n, m;
	cin >> n >> m;
 
	for(int i=0; i<m; i++){
		int eb, ee;
		cin >> eb >> ee;
		eb--;
		ee--;
 
		e[eb].pb(ee);
		e[ee].pb(eb);
	}

	int n1 = 1;
	int n2 = e[1].front();
	seq.pb(n1);
	seq.pb(n2);
	used[n1] = used[n2] = 1;
	//e[0].erase(e[0].begin());
	e[1].pop_front();

	while(1){
		/*
		int cnt = 0;
		auto it = seq.begin();
		for(; it != seq.end(); it++){
			if(cnt == seq.size()-1) break;
			printf("%d ", (*it) + 1);
			cnt++;
		}
		printf("%d\n", (*it)+1);
		*/

		bool f = true;
		for(auto it = e[n1].begin(); it != e[n1].end(); it++){
			if(used[*it] != 1){
				f = false;
				seq.push_front(*it);
				used[*it] = 1;
				int tmp = *it;
				e[n1].pop_front();
				n1 = tmp;
				break;
			}
		}
		if(!f) continue;

		for(auto it = e[n2].begin(); it != e[n2].end(); it++){
			if(used[*it] != 1){
				f = false;
				seq.push_back(*it);
				used[*it] = 1;
				int tmp = *it;
				e[n2].pop_front();
				n2 = tmp;
				break;
			}
		}
		if(!f) continue;
 
		cout << seq.size() << endl;
		int cnt = 0;
		auto it = seq.begin();
		for(; it != seq.end(); it++){
			if(cnt == seq.size()-1) break;
			printf("%d ", (*it) + 1);
			cnt++;
		}
		printf("%d\n", (*it)+1);
		break;
	}
	
	return 0;
}


Compiler output:
a.cc:13:18: error: 'n' was not declared in this scope; did you mean 'yn'?
   13 | vector<int> used(n, 0);
      |                  ^
      |                  yn
Language: C++

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

int N,M;

vector<int> mat[100000];
vector<int> ans;
bool visited[100000];

void DFS(int v)
{
	visited[v] = 1;
	for(int i = 0; i < mat[v].size(); i++){
		int u = mat[v][i];
		if(visited[u]==0){
			ans.push_back(u+1);
			DFS(u);
			break;
		}
	}
}

int main()
{
	cin >> N >> M;
	for(int i=0;i<M;i++){
		int a,b;
		cin >> a >> b;
		a--; b--;
		mat[a].push_back(b);
		mat[b].push_back(a);
	}
	ans.push_back(1);
	DFS(0);
	reverse(ans.begin(), ans.end());
	DFS(0);
	cout << ans.size() << endl;
	for(int i=0;i<ans.size();i++){
		cout << ans[i];
		if(i!=ans.size()-1)
			cout << " ";
	}
	cout << endl;
	return 0;
}

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

#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int k=0;
bool back = false;

void dfs(vector<vector<int> >&G, int N, int p, int s, vector<int>&visited, vector<int>&fpath, vector<int>&bpath)
{
  visited[p] = 1;
  if(back == false){
    fpath[k] = p;
    k++;
  }else{
    bpath[k] = p;
    k++;
  }
  for(int i=0; i < G[p].size(); i++){
    if(visited[G[p][i]] == 0 && back = false){
      dfs(G,N,G[p][i],s,visited,fpath,bpath);
      break;
    }
    if(visited[G[p][i]] == 0 && back = true){
      dfs(G,N,G[p][i],G[p][i],visited,fpath,bpath);
      break;
    }
    if(i == G[p].size()-1){
      if(back == true) break;
      if(back == false) k = 0;
      back = true;
      for(int i=0; i < G[s].size(); i++){
	if(visited[G[s][i]] == 0){
	  dfs(G,N,G[s][i],G[s][i],visited,fpath,bpath);
          break;
        }
      }
    }
  }
  return;
}


int main()
{
  int N,M;
  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);
    G[b-1].push_back(a-1);
  }

  vector<int>fpath(N,-1);
  vector<int>bpath(N,-1);
  vector<int>visited(N,0);
  dfs(G,N,0,0,visited,fpath,bpath);
  int bsum=0;
  int fsum=0;

  for(int i=0; i < N; i++){
    if(bpath[i] == -1) break;
    bsum++;
  }
  for(int i=0; i < N; i++){
    if(fpath[i] == -1) break;
    fsum++;
  }
  cout << fsum+bsum << endl;
  for(int i=0; i < bsum; i++){
    cout << bpath[i]+1 << " ";
  }
  for(int i=0; i < fsum; i++){
    cout << fpath[i]+1 << " ";
  }
  cout << endl;

  return 0;
}


Compiler output:
a.cc: In function 'void dfs(std::vector<std::vector<int> >&, int, int, int, std::vector<int>&, std::vector<int>&, std::vector<int>&)':
a.cc:24:30: error: lvalue required as left operand of assignment
   24 |     if(visited[G[p][i]] == 0 && back = false){
a.cc:28:30: error: lvalue required as left operand of assignment
   28 |     if(visited[G[p][i]] == 0 && back = true){
Language: C++

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
using namespace std;
const int N = 1e5 + 5;
int a[N];
vector<int> e[N];
int in[N];
bool b[N];
int s[N]; // step
vector<int> asr;
int pre[N];
int mx, ed2;

bool dfs1(int cur, int ed)
{
	b[cur] = true;
	asr.push_back(cur);
	if(cur == ed)
		return true;
	for(int i = 0 ; i < e[cur].size(); i++)
	{
		int nxt = e[cur][i];
		if(b[nxt])
			continue;
		if(dfs1(nxt, ed))
			return true;
	}
	return false;
}

void dfs2(int cur, int t)
{
	b[cur] = true;
	s[cur] = t;
	for(int i = 0 ; i < e[cur].size(); i++)
	{
		int nxt = e[cur][i];
		if(!b[nxt])
		{
			pre[nxt] = cur;
			dfs2(nxt, t + 1);
		}
		else
		{
			int tmp = s[cur] - s[nxt] + 1;
			if(tmp > mx)
			{
				mx = tmp;
				ed2 = nxt;
				pre[ed2] = cur;
			}
		}
	}
}

int main()
{
	int n, m;
	cin>>n>>m;
	memset(in, 0, sizeof(in));
	for(int i = 0; i < m; i++)
	{
		int u,v;
		cin>>u>>v;
		e[u].push_back(v);
		e[v].push_back(u);
		in[u]++;
		in[v]++;
	}
	memset(b, 0, sizeof(b));
	for(int i = 1; i<= n; i++ )
	{
		if(in[i] == 1)
		{
			for(int j = i + 1; j <= n ; j++)
			{
				if(in[j] == 1)
				{
					dfs1(i, j);
					cout<<asr.size() << endl;
					cout<<asr[0];
					for(int k = 1; k < asr.size(); k++)
					{
						printf(" %d",asr[k]);
					}
					cout<<endl;
					return 0;
				}
			}
		}
	}
	mx = 0;
	dfs2(1, 0);
	int cur = ed2;
	set<int> s1,s2;
	int sz = 0;
	do{
		sz++;
		s1.insert(cur);
		cur = pre[cur];
	}while(cur != ed2);
	for(int i = 1 ; i <= n ; i++)
	{
		if(s1.find(i) == s1.end())
		{
			s2.insert(i);
		}
	}
	cur = ed2;
	int pr;
	while(1)
	{
		pr = pre[cur];
		bool ok1 = true, ok2 = true;
		for(int i = 0; i < e[cur].size(); i++)
		{
			if(s2.find(e[cur][i]) != s2.end())
			{
				ok1 = false;
				break;
			}
		}
		for(int i = 0; i < e[pr].size(); i++)
		{
			if(s2.find(e[pr][i]) != s2.end())
			{
				ok2 = false;
				break;
			}
		}
		if(ok1 && ok2)
		{
			break;
		}
		cur = pr;
	}
	cout<<sz<<endl;
	ed2 = cur;
	cur = pr;
	cout<<cur;
	do{
		cur = pre[cur];
		printf(" %d",cur);
	}while(cur != ed2);
	cout<<endl;
	//system("pause");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:63:9: error: 'memset' was not declared in this scope
   63 |         memset(in, 0, sizeof(in));
      |         ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <set>
  +++ |+#include <cstring>
    5 | #include <string>
Language: C++

#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;
const int N = 1e5 + 5;
int a[N];
vector<int> e[N];
int in[N];
bool b[N];
int s[N]; // step
vector<int> asr;
int pre[N];
int mx, ed2;

bool dfs1(int cur, int ed)
{
	b[cur] = true;
	asr.push_back(cur);
	if(cur == ed)
		return true;
	for(int i = 0 ; i < e[cur].size(); i++)
	{
		int nxt = e[cur][i];
		if(b[nxt])
			continue;
		if(dfs1(nxt, ed))
			return true;
	}
	return false;
}

void dfs2(int cur, int t)
{
	b[cur] = true;
	s[cur] = t;
	for(int i = 0 ; i < e[cur].size(); i++)
	{
		int nxt = e[cur][i];
		if(!b[nxt])
		{
			pre[nxt] = cur;
			dfs2(nxt, t + 1);
		}
		else
		{
			int tmp = s[cur] - s[nxt] + 1;
			if(tmp > mx)
			{
				mx = tmp;
				ed2 = nxt;
				pre[ed2] = cur;
			}
		}
	}
}

int main()
{
	int n, m;
	cin>>n>>m;
	memset(in, 0, sizeof(in));
	for(int i = 0; i < m; i++)
	{
		int u,v;
		cin>>u>>v;
		e[u].push_back(v);
		e[v].push_back(u);
		in[u]++;
		in[v]++;
	}
	memset(b, 0, sizeof(b));
	for(int i = 1; i<= n; i++ )
	{
		if(in[i] == 1)
		{
			for(int j = i + 1; j <= n ; j++)
			{
				if(in[j] == 1)
				{
					dfs1(i, j);
					cout<<asr.size() << endl;
					cout<<asr[0];
					for(int k = 1; k < asr.size(); k++)
					{
						printf(" %d",asr[k]);
					}
					cout<<endl;
					return 0;
				}
			}
		}
	}
	mx = 0;
	dfs2(1, 0);
	int cur = ed2;
	set<int> s1,s2;
	int sz = 0;
	do{
		sz++;
		s1.insert(cur);
		cur = pre[cur];
	}while(cur != ed2);
	for(int i = 1 ; i <= n ; i++)
	{
		if(s1.find(i) == s1.end())
		{
			s2.insert(i);
		}
	}
	cur = ed2;
	int pr;
	while(1)
	{
		pr = pre[cur];
		bool ok1 = true, ok2 = true;
		for(int i = 0; i < e[cur].size(); i++)
		{
			if(s2.find(e[cur][i]) != s2.end())
			{
				ok1 = false;
				break;
			}
		}
		for(int i = 0; i < e[pr].size(); i++)
		{
			if(s2.find(e[pr][i]) != s2.end())
			{
				ok2 = false;
				break;
			}
		}
		if(ok1 && ok2)
		{
			break;
		}
		cur = pr;
	}
	cout<<sz<<endl;
	ed2 = cur;
	cur = pr;
	cout<<cur;
	do{
		cur = pre[cur];
		printf(" %d",cur);
	}while(cur != ed2);
	cout<<endl;
	//system("pause");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:62:9: error: 'memset' was not declared in this scope
   62 |         memset(in, 0, sizeof(in));
      |         ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <set>
  +++ |+#include <cstring>
    5 | using namespace std;
Language: C

#include <stdio.h>

int main(void){
    int n, m;
    scanf("%d %d", &n, &m);
    int a[m], b[m], g[n+1][n+1], c[n+1];
    for(int i=0; i<=n; i++){
        for(int j=0; j=<n; j++){
            g[i][j]=0;
        }
        c[i]=0;
    }

    for(int i=0; i<m; i++){
        scanf("%d %d", &a[i], &b[i]);
        g[a[i]][b[i]]=1;
        g[b[i]][a[i]]=1;
        c[a[i]]++;
        c[b[i]]++;
    }
    //FR
    
    for(int i=1; i<n+1; i++){
        if(c[i]==1){
            for(int j=1; j<n+1; j++){
                if(g[i][j]==1){
                    printf("2\n%d %d\n", i, j);
                    return 0;
                }
            }
        }
    }

    //printf("");
    return 0;
}


Compiler output:
main.c: In function 'main':
main.c:8:24: error: expected expression before '<' token
    8 |         for(int j=0; j=<n; j++){
      |                        ^
Language: C

#include <stdio.h>
#define MaxSize 100000
char neighbour[MaxSize][MaxSize];
char visited[MaxSize];
char nbCount[MaxSize];
int startPath[MaxSize];
int endPath[MaxSize];
int startPathLen = 0;
int endPathLen = 0;

void searchEnd(int end, int pathArr[], int * pLength) {
    char allNbSearched = 0;
    char foundNew = 0;
    while(!foundNew && !allNbSearched) {
        for(int i = 0; i < nbCount[end]; i++) {
            int newEnd = neighbour[end][i];
            if(!visited[newEnd]) {
                end = newEnd;
                visited[newEnd] = 1;
                foundNew = 1;
                allNbSearched = 0;
                pathArr[*pLength] = newEnd;
                (*pLength)++;
                break; //for
            }
        }
        allNbSearched = 1;
    }
}
int main(int argc, const char * argv[]) {
    int N, M;
    memset(neighbour, 0, MaxSize * MaxSize);
    memset(visited, 0, MaxSize);
    memset(nbCount, 0, MaxSize);
    scanf("%d%d", &N, &M);
    int start = -1, end = -1;
    for(int i = 1; i < M; i++) {
        scanf("%d%d", &start, &end);
        neighbour[start][nbCount[start]] = end;
        neighbour[end][nbCount[end]] = start;
        nbCount[start]++;
        nbCount[end]++;
    }
    
    visited[start] = visited[end] = 1;
    searchEnd(start, startPath, &startPathLen);
    searchEnd(end, endPath, &endPathLen);
    
    printf("%d\n", startPathLen + endPathLen + 2);
    for(int i = 0; i < startPathLen; i++)
        printf("%d ", startPath[i]);
    printf("%d %d ", start, end);
    for(int i = 0; i < endPathLen; i++)
        printf("%d ", endPath[i]);
    printf("\n");
    return 0;
}


Compiler output:
main.c: In function 'main':
main.c:32:5: error: implicit declaration of function 'memset' [-Wimplicit-function-declaration]
   32 |     memset(neighbour, 0, MaxSize * MaxSize);
      |     ^~~~~~
main.c:2:1: note: include '<string.h>' or provide a declaration of 'memset'
    1 | #include <stdio.h>
  +++ |+#include <string.h>
    2 | #define MaxSize 100000
main.c:32:5: warning: incompatible implicit declaration of built-in function 'memset' [-Wbuiltin-declaration-mismatch]
   32 |     memset(neighbour, 0, MaxSize * MaxSize);
      |     ^~~~~~
main.c:32:5: note: include '<string.h>' or provide a declaration of 'memset'
main.c:32:34: warning: integer overflow in expression of type 'int' results in '1410065408' [-Woverflow]
   32 |     memset(neighbour, 0, MaxSize * MaxSize);
      |                                  ^