Language: C++

#include <cstdio>

#define R register
#define maxn 100010
struct Edge {
	Edge *next;
	int to;
}*last[maxn], e[maxn << 1], *ecnt = e;
int deg[maxn];
inline void link(R int a, R int b)
{
	++deg[a]; ++deg[b];
	*++ecnt = (Edge) {last[a], b}; last[a] = ecnt;
	*++ecnt = (Edge) {last[b], a}; last[b] = ecnt;
}
bool vis[maxn];
int ans[maxn], ac;
void dfs(R int x)
{
	vis[x] = 1; ans[++ac] = x;
	for (R Edge *iter = last[x]; iter; iter = iter -> next)
		if (!vis[iter -> to])
		{
			dfs(iter -> to);
			return ;
		}
}
int main()
{
	R int n, m; scanf("%d%d", &n, &m);
	for (R int i = 1; i <= m; ++i)
	{
		R int a, b; scanf("%d%d", &a, &b);
		link(a, b);
	}
	for (R int i = 1; i <= n; ++i)
		if (deg[i] == 1)
		{
			dfs(i);
			printf("%d\n", ac);
			for (R int i = 1; i <= ac; ++i) printf("%d ", ans[i]);
			return 0;
		}
	dfs(rand() % n + 1);
	printf("%d\n", ac);
	for (R int i = 1; i <= ac; ++i) printf("%d ", ans[i]);
	return 0;
}

Compiler output:
a.cc:10:24: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   10 | inline void link(R int a, R int b)
      |                        ^
a.cc:10:33: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   10 | inline void link(R int a, R int b)
      |                                 ^
a.cc:18:16: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   18 | void dfs(R int x)
      |                ^
a.cc: In function 'void dfs(int)':
a.cc:21:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   21 |         for (R Edge *iter = last[x]; iter; iter = iter -> next)
      |                      ^~~~
a.cc: In function 'int main()':
a.cc:30:15: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   30 |         R int n, m; scanf("%d%d", &n, &m);
      |               ^
a.cc:30:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   30 |         R int n, m; scanf("%d%d", &n, &m);
      |                  ^
a.cc:31:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   31 |         for (R int i = 1; i <= m; ++i)
      |                    ^
a.cc:33:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   33 |                 R int a, b; scanf("%d%d", &a, &b);
      |                       ^
a.cc:33:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   33 |                 R int a, b; scanf("%d%d", &a, &b);
      |                          ^
a.cc:36:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   36 |         for (R int i = 1; i <= n; ++i)
      |                    ^
a.cc:41:36: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   41 |                         for (R int i = 1; i <= ac; ++i) printf("%d ", ans[i]);
      |                                    ^
a.cc:44:13: error: 'rand' was not declared in this scope
   44 |         dfs(rand() % n + 1);
      |             ^~~~
a.cc:46:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   46 |         for (R int i = 1; i <= ac; ++i) printf("%d ", ans[i]);
      |                    ^