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

#include <bits/stdc++.h>
using namespace std;
using lint = long long;
int n, m;
vector<vector<int> > G;
vector<int> field;
vector<bool> visit;

void bfs(){
	queue<int> que;
	que.push(0);
	visit[0] = true;
	while(!que.empty()){
		int now = que.front(); que.pop();
		for(auto next : G[now]){
			if(!visit[next]){
				que.push(next);
				field[next] = now;
				visit[next] = true;
			} 
		}
	}
}

signed main(){
	cin >> n >> m;
	vector<lint> a(m), b(m);
	G.resize(n); field.resize(n); visit.resize(n, false);
	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);
	}
	bfs();
	cout << "Yes" << endl;
	for(int i = 1; i < n; i++) cout << field[i] + 1 << endl;
}

Compiler output:
a.cc: In function 'void bfs()':
a.cc:12:9: error: reference to 'visit' is ambiguous
   12 |         visit[0] = true;
      |         ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:7:14: note:                 'std::vector<bool> visit'
    7 | vector<bool> visit;
      |              ^~~~~
a.cc:16:29: error: reference to 'visit' is ambiguous
   16 |                         if(!visit[next]){
      |                             ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:7:14: note:                 'std::vector<bool> visit'
    7 | vector<bool> visit;
      |              ^~~~~
a.cc:19:33: error: reference to 'visit' is ambiguous
   19 |                                 visit[next] = true;
      |                                 ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:7:14: note:                 'std::vector<bool> visit'
    7 | vector<bool> visit;
      |              ^~~~~
a.cc: In function 'int main()':
a.cc:28:39: error: reference to 'visit' is ambiguous
   28 |         G.resize(n); field.resize(n); visit.resize(n, false);
      |                                       ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:7:14: note:                 'std::vector<bool> visit'
    7 | vector<bool> visit;
      |              ^~~~~
Language: C++

#include<bits/stdc++.h> 
using namespace std; 
  
// A utility function to add an edge in an 
// undirected graph. 
void addEdge(vector<int> adj[], int u, int v) 
{ 
    adj[u].push_back(v); 
    adj[v].push_back(u); 
} 
  
// A utility function to print the adjacency list 
// representation of graph 
void printGraph(vector<int> adj[], int v,int e) 
{ 
    int visited[e]={0};
    vector<int>v;
    visited[1]=1;
    for(int i=0;i<adj[1].size();i++)
    {
        v.push_back(adj[i][i]);
        visited[adj[i][i]]=1;
    }
    while(!v.empty())
    {
        int x=v[0];
        v.erase(v.begin());
        for(int i=0;i<adj[x].size();i++)
        {
            if(visited[adj[x][i]]==0)
            {
                visited[adj[x][i]]==x;
            }
        }
    }
    int flag=0;
    for(int i=1;i<visited.size();i++)
    {
        if(visited[i]==0)
        {
            flag=1;
            break;
        }
    }
    if(flag==1)
    {
        cout<<"No";
    }
    else
    
    {
        cout<<"Yes";
        for(int i=2;i<visited.size();i++)
        {
            cout<<visited[i]<<endl;
        }
    }
} 
  
// Driver code 
int main() 
{ 
    int v,e;
    cin>>v>>e;
    v=v+1;
    vector<int> adj[v];
    for(int i=0;i<e;i++){
        int x,y;
        cin>>x>>y;
    addEdge(adj, x, y);
    addEdge(adj ,y,x);
    }
    printGraph(adj, v,e); 
    return 0; 
} 

Compiler output:
a.cc: In function 'void printGraph(std::vector<int>*, int, int)':
a.cc:17:16: error: declaration of 'std::vector<int> v' shadows a parameter
   17 |     vector<int>v;
      |                ^
a.cc:14:40: note: 'int v' previously declared here
   14 | void printGraph(vector<int> adj[], int v,int e)
      |                                    ~~~~^
a.cc:37:27: error: request for member 'size' in 'visited', which is of non-class type 'int [e]'
   37 |     for(int i=1;i<visited.size();i++)
      |                           ^~~~
a.cc:53:31: error: request for member 'size' in 'visited', which is of non-class type 'int [e]'
   53 |         for(int i=2;i<visited.size();i++)
      |                               ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<pair<int,int>> c(m);
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    c.at(i).first=min(a,b);
    c.at(i).second=max(a,b);
  }
  vector<int> ans(n);
  for(int i=0;i<n;i++){
    ans(i)=0;
  }
  for(int i=1;i<n;i++){
    if(c.at(i).first==1)
        ans.at(c.at(i).second)=1;
  }
  int q=0;
  while(q==0){
    for(int i=1;i<n;i++){
      if(ans.at(i)!=0) q=1;
      else{
        q=0;
        break;
      }
    }
  for(int i=1;i<n;i++){
    if(ans.at(c.at(i).first)!=0&&ans.at(c.at(i).second)==0)
      ans.at(c.at(i).second)=c.at(i).first;
    if(ans.at(c.at(i).first)==0&&ans.at(c.at(i).second)!=0)
       ans.at(c.at(i).first)=c.at(i).second;
  }
  }
   cout<<"Yes"<<endl;
  for(int i=i;i<n;i++)
    cout<<ans.at(i)<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:8: error: no match for call to '(std::vector<int>) (int&)'
   15 |     ans(i)=0;
      |     ~~~^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<pair<int,int>> c(m);
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    c.at(i).fist=min(a,b);
    c.at(i).second=max(a,b);
  }
  vector<int> ans(n);
  for(int i=0;i<n;i++){
    ans(i)=0;
  }
  for(int i=1;i<n;i++){
    if(c.at(i).first==1)
        ans.at(c.at(i).second)=1;
  }
  int q=0;
  while(q==0){
    for(int i=1;i<n;i++){
      if(ans.at(i)!=0) q=1;
      else{
        q=0;
        break;
      }
    }
  for(int i=1;i<n;i++){
    if(ans.at(c.at(i).first)!=0&&ans.at(c.at(i).second)==0)
      ans.at(c.at(i).second)=c.at(i).first;
    if(ans.at(c.at(i).first)==0&&ans.at(c.at(i).second)!=0)
       ans.at(c.at(i).first)=c.at(i).second;
  }
  }
   cout<<"Yes"<<endl;
  for(int i=i;i<n;i++)
    cout<<ans.at(i)<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:13: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'fist'; did you mean 'first'?
   10 |     c.at(i).fist=min(a,b);
      |             ^~~~
      |             first
a.cc:15:8: error: no match for call to '(std::vector<int>) (int&)'
   15 |     ans(i)=0;
      |     ~~~^~~
Language: C

#include <stdio.h>
#include <string.h>
#include <math.h>

int path[200200][200200];
int exist = 0;
long kai;
long min = 200200;
long ans[200200],no[200200];
long N,M;
int cycle(long node){
	//printf("node:%ld\n",node);
	int ret;
	if(node ==1){
		if(min>kai)min=kai;
		//printf("<<%ld>>\n",min);
		exist = 1;
		kai = 0;
		return 0;
	}
	long i;
	kai++;
	if(no[node]==1){
		//kai=0;
		return 1;
	}
	no[node]=1;
	
	//printf("kai:%ld\n",kai);
	for(i=1;i<=M;i++){
		if(path[node][i]){
			//printf("-->%ld\n",i);
			ret=cycle(i);
			if(ret==0){
				//printf("don\n");
				return 0;
			}
		}
	}

	return 1;
	
}
int main(){
	

	long i;
	scanf("%ld%ld",&N,&M);
	
	for(i=0;i<M;i++){
		long t,s;
		scanf("%ld%ld",&t,&s);
		path[t][s]=1;
		path[s][t]=1;
	}
	
	for(i=2;i<=N;i++){
		cycle(i);
		//printf("(%ld)%ld %ld\n",i,kai,min);
		ans[i-1]=min;
		min = 200200;
		long j;
		for(j=0;j<=N;j++)no[j]=0;
	}
	if(exist){
		printf("Yes\n");
		for(i=1;i<N;i++)printf("%ld\n",ans[i]);
		
	}else {
		printf("No\n");
	}
	
	
	
		
	return 0;
}


Compiler output:
/tmp/ccric15y.o: in function `cycle':
main.c:(.text+0x1d): relocation truncated to fit: R_X86_64_PC32 against symbol `kai' defined in .bss section in /tmp/ccric15y.o
main.c:(.text+0x29): relocation truncated to fit: R_X86_64_PC32 against symbol `kai' defined in .bss section in /tmp/ccric15y.o
main.c:(.text+0x36): relocation truncated to fit: R_X86_64_PC32 against symbol `exist' defined in .bss section in /tmp/ccric15y.o
main.c:(.text+0x41): relocation truncated to fit: R_X86_64_PC32 against symbol `kai' defined in .bss section in /tmp/ccric15y.o
main.c:(.text+0x56): relocation truncated to fit: R_X86_64_PC32 against symbol `kai' defined in .bss section in /tmp/ccric15y.o
main.c:(.text+0x61): relocation truncated to fit: R_X86_64_PC32 against symbol `kai' defined in .bss section in /tmp/ccric15y.o
main.c:(.text+0x74): relocation truncated to fit: R_X86_64_PC32 against symbol `no' defined in .bss section in /tmp/ccric15y.o
main.c:(.text+0x9b): relocation truncated to fit: R_X86_64_PC32 against symbol `no' defined in .bss section in /tmp/ccric15y.o
main.c:(.text+0xfd): relocation truncated to fit: R_X86_64_PC32 against symbol `M' defined in .bss section in /tmp/ccric15y.o
/tmp/ccric15y.o: in function `main':
main.c:(.text+0x119): relocation truncated to fit: R_X86_64_PC32 against symbol `M' defined in .bss section in /tmp/ccric15y.o
main.c:(.text+0x123): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

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

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;

int main(){
 int N,M;
  vector<int> A(M),B(M);
  for(int i=0;i<M;i++){
    cin >> A.at(i) >> B.at(i);
  }
  
  string ans = "No";
  int a;
  for()
  void miti(){
    for(int i=0;i<N;i++){
      for(int j =0;j<N;j++){
        if(A.at(i) == i+1){
          if(B.at(i) ==1){
            ans ="Yes";
            a =
          }else
        }
      }
    }
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:13:7: error: expected primary-expression before ')' token
   13 |   for()
      |       ^
a.cc:25:4: error: expected primary-expression at end of input
   25 |   }
      |    ^
a.cc:25:4: error: expected ';' at end of input
   25 |   }
      |    ^
      |    ;
a.cc:25:4: error: expected primary-expression at end of input
a.cc:25:4: error: expected ')' at end of input
   25 |   }
      |    ^
      |    )
a.cc:13:6: note: to match this '('
   13 |   for()
      |      ^
a.cc:25:4: error: expected statement at end of input
   25 |   }
      |    ^
a.cc:25:4: error: expected '}' at end of input
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C

#include <stdio.h>
#include <string.h>
#include <math.h>

int path[200200][200200];
int exist = 0;
long kai;
long min = 200200;
int ans[200200],no[200200];
long N,M;
int cycle(long node){
	//printf("node:%ld\n",node);
	int ret;
	if(node ==1){
		if(min>kai)min=kai;
		//printf("<<%ld>>\n",min);
		exist = 1;
		kai = 0;
		return 0;
	}
	long i;
	kai++;
	if(no[node]==1){
		//kai=0;
		return 1;
	}
	no[node]=1;
	
	//printf("kai:%ld\n",kai);
	for(i=1;i<=M;i++){
		if(path[node][i]){
			//printf("-->%ld\n",i);
			ret=cycle(i);
			if(ret==0){
				//printf("don\n");
				return 0;
			}
		}
	}

	return 1;
	
}
int main(){
	

	long i;
	scanf("%ld%ld",&N,&M);
	
	for(i=0;i<M;i++){
		long t,s;
		scanf("%ld%ld",&t,&s);
		path[t][s]=1;
		path[s][t]=1;
	}
	
	for(i=2;i<=N;i++){
		cycle(i);
		//printf("(%ld)%ld %ld\n",i,kai,min);
		ans[i-1]=min;
		min = 200200;
		long j;
		for(j=0;j<=N;j++)no[j]=0;
	}
	if(exist){
		printf("Yes\n");
		for(i=1;i<N;i++)printf("%ld\n",ans[i]);
		
	}else {
		printf("No\n");
	}
	
	
	
		
	return 0;
}


Compiler output:
/tmp/ccIh1LyT.o: in function `cycle':
main.c:(.text+0x1d): relocation truncated to fit: R_X86_64_PC32 against symbol `kai' defined in .bss section in /tmp/ccIh1LyT.o
main.c:(.text+0x29): relocation truncated to fit: R_X86_64_PC32 against symbol `kai' defined in .bss section in /tmp/ccIh1LyT.o
main.c:(.text+0x36): relocation truncated to fit: R_X86_64_PC32 against symbol `exist' defined in .bss section in /tmp/ccIh1LyT.o
main.c:(.text+0x41): relocation truncated to fit: R_X86_64_PC32 against symbol `kai' defined in .bss section in /tmp/ccIh1LyT.o
main.c:(.text+0x56): relocation truncated to fit: R_X86_64_PC32 against symbol `kai' defined in .bss section in /tmp/ccIh1LyT.o
main.c:(.text+0x61): relocation truncated to fit: R_X86_64_PC32 against symbol `kai' defined in .bss section in /tmp/ccIh1LyT.o
main.c:(.text+0x74): relocation truncated to fit: R_X86_64_PC32 against symbol `no' defined in .bss section in /tmp/ccIh1LyT.o
main.c:(.text+0x96): relocation truncated to fit: R_X86_64_PC32 against symbol `no' defined in .bss section in /tmp/ccIh1LyT.o
main.c:(.text+0xf7): relocation truncated to fit: R_X86_64_PC32 against symbol `M' defined in .bss section in /tmp/ccIh1LyT.o
/tmp/ccIh1LyT.o: in function `main':
main.c:(.text+0x113): relocation truncated to fit: R_X86_64_PC32 against symbol `M' defined in .bss section in /tmp/ccIh1LyT.o
main.c:(.text+0x11d): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair

// void Fast_IO(){
// 	ios_base::sync_with_stdio(false);
// 	cin.tie(NULL);
// 	#ifndef ONLINE_JUDGE
// 	freopen("input.in","r",stdin);
// 	freopen("output.out","w",stdout);
// 	freopen("debug.out","w",stderr);
// 	#endif
// }

vector <int> visited;
vector <int> a[100032];
vector <int> ans;

void dfs(int x){
	int i,z;
	visited[x]=1;
	for(i=0;i<a[x].size();i++){
		//cout<<z<<'\n';
		z=a[x][i];
		if(visited[z]==0){
			ans[z]=x;
			dfs(z);
		}
	}
}

int main(){
	Fast_IO();
	int n,i,m,x,y;
	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>x>>y;
		a[x].pb(y);
		a[y].pb(x);
	}
	for(i=0;i<=n;i++){
		visited.pb(0);
		ans.pb(0);
	}
	dfs(1);
	int flag=1;
	for(i=1;i<=n;i++){
		if(visited[i]==0){
			flag=0;
			break;
		}
	}
	if(flag){
		cout<<"Yes"<<'\n';
		for(i=2;i<=n;i++){
			cout<<ans[i]<<'\n';
		}
	}
	else{
		cout<<"No"<<'\n';
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:9: error: 'Fast_IO' was not declared in this scope
   34 |         Fast_IO();
      |         ^~~~~~~
Language: Java

package code;

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

/**
 * 6 9
3 4-
6 1-
2 4-
5 3-
4 6-
1 5-
6 2
4 5-
5 6-
 * @author dell
 *
 */
public class Test {
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		int n=scanner.nextInt();
		int m=scanner.nextInt();
		int start,end;
		ArrayList<Node> nodes=new ArrayList<Node>();
		nodes.add(new Node(0));
		nodes.add(new Node(1));
		nodes.get(1).length=0;
		for(int i=2;i<=n;i++) {
			nodes.add(new Node(i));
		}
		for(int i=0;i<m;i++) {
			start=scanner.nextInt();
			end=scanner.nextInt();
			nodes.get(start).next.add(end);
			nodes.get(end).next.add(start);
		}
		
		for(int i=1;i<=n;i++) {
			for(int j=0;j<nodes.get(i).next.size();j++) {
				if(nodes.get(nodes.get(i).next.get(j)).length>nodes.get(i).length) {
					nodes.get(nodes.get(i).next.get(j)).length=nodes.get(i).length+1;
					nodes.get(nodes.get(i).next.get(j)).pre=i;
				}
				else if(nodes.get(nodes.get(i).next.get(j)).length<nodes.get(i).length) {
					nodes.get(i).length=nodes.get(nodes.get(i).next.get(j)).length+1;
					nodes.get(i).pre=nodes.get(nodes.get(i).next.get(j)).num;
				}
			}
		}
		for(int i=1;i<=n;i++) {
			if(nodes.get(i).length==10000000) {
				System.out.println("No");
				return;
			}
			
		}
		System.out.println("Yes");
		for(int i=2;i<=n;i++) {
			System.out.println(nodes.get(i).pre);
		}
	}
	
}
class Node implements Comparable<Node>{
	int num;
	int pre=-1;
	int length=10000000;
	ArrayList<Integer> next=new ArrayList<Integer>();
	public Node(int num) {
		this.num=num;
	}
	@Override
	public int compareTo(Node o) {
		
		return this.length-o.length;
	}
	
}

Compiler output:
Main.java:21: error: class Test is public, should be declared in a file named Test.java
public class Test {
       ^
1 error
Language: C++

#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

void set_zero(ll *a,ll n){
	rep(i,n){
		a[i]=0;
	}
}

void set_flag(const ll *a,const ll *b,ll *flag,ll m,ll n,ll key,ll count){
	if(count==m){
		return;
	}
	int tmp1,tmp2=0;
	rep(i,n){
		if(a[i]==key&&flag[b[i]-1]==0){
			flag[b[i]-1]=key;
			if(tmp1==0)
				tmp1=b[i];
		}
		else if(b[i]==key&&flag[a[i]-1]==0){
			flag[a[i]-1]=key;
			if(tmp2==0)
				tmp2=a[i];
		}
	}
	if(tmp1>0)
		set_flag(a,b,flag,m,n,tmp1,count+1);
	else if(tmp2>0)
		set_flag(a,b,flag,m,n,tmp2,count+1);
	else
		set_flag(a,b,flag,m,n,key+1,count+1);
}

bool judge(ll *a,ll n){
	for(int i=1;i<n;i++){
		if(a[i]==0)
			return false;
	}
	return true;
}

int main(){
	ll n,m;
	cin >> n >> m;
	ll a[m],b[m];
	rep(i,m){
		cin >> a[i] >> b[i];
	}
	ll flag[n];
	set_zero(flag,n);
	flag[0]=1;
	set_flag(a,b,flag,m,1,0);
	if(judge(flag,n)==false)
		cout << "No" << endl;
	else{
		cout << "Yes" << endl;
		for(int i=1;i<n;i++){
			cout << flag[i] << endl;
		}
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:61:17: error: too few arguments to function 'void set_flag(const ll*, const ll*, ll*, ll, ll, ll, ll)'
   61 |         set_flag(a,b,flag,m,1,0);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~
a.cc:18:6: note: declared here
   18 | void set_flag(const ll *a,const ll *b,ll *flag,ll m,ll n,ll key,ll count){
      |      ^~~~~~~~
Language: C

#include <stdio.h>

typedef long long ll;

ll dfs(int i, int n, ll count, double c[]) {
  if(i == n) {
    return count + 1;
  }
  ll ret = 0;
  for(int j = i + 1;j <= n;j++) {
    if(c[i] + 1/c[j] != 0) {
      	
	    ret += dfs(j, n, count+1, c);
    }
  }
  return ret;

int main(void) {
  int n;
  ll a[200001] = {0};
  ll b[200001] = {0};
  double c[200001] = {0};
  scanf("%d", &n);
  for(int i = 0;i < n;i++) {
    scanf("%lld %lld", a + i, b + i);
    c[i] = (double)a / b;
  }
  ll ret = n;
  ret += dfs(2, n, ret, c);
  
  printf("%lld\n", ret % (1000000007));
  return 0;
}
  	  

Compiler output:
main.c: In function 'main':
main.c:26:5: error: pointer value used where a floating-point was expected
   26 |     c[i] = (double)a / b;
      |     ^
main.c: In function 'dfs':
main.c:33:1: error: expected declaration or statement at end of input
   33 | }
      | ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int root[200001][200001] = {0};
int cnt[200001] = {0};
int mark[200001] = {0};


void aaa(queue<int> que1){
    if(que1.size() == 0) return;
    queue<int> que2;
    while (!que1.empty()) {
        int room = que1.front(); // 先頭要素を参照する
        que1.pop(); // 先頭要素を削除
        rep(j,cnt[room]){
            if(mark[root[room][j]] == 0){
                mark[root[room][j]] = room;
                que2.push(root[room][j]);
            }
        }
    }
    aaa(que2);
}

int main() {
    int N,M;
    cin >> N >> M;
    rep(i,M) {
        int A,B;
        cin >> A >> B;
        root[A][cnt[A]++] = B;
        root[B][cnt[B]++] = A;
    }
    queue<int> que;
    que.push(1);
    aaa(que);

    for(int i=2;i<N+1;i++){
        if(mark[i] == 0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for(int i=2;i<N+1;i++){
        cout << mark[i] << endl;
    }
    
	return 0;
}

Compiler output:
/tmp/ccfci5li.o: in function `aaa(std::queue<int, std::deque<int, std::allocator<int> > >)':
a.cc:(.text+0xa7): relocation truncated to fit: R_X86_64_PC32 against symbol `mark' defined in .bss section in /tmp/ccfci5li.o
a.cc:(.text+0xe6): relocation truncated to fit: R_X86_64_PC32 against symbol `mark' defined in .bss section in /tmp/ccfci5li.o
a.cc:(.text+0x13d): relocation truncated to fit: R_X86_64_PC32 against symbol `cnt' defined in .bss section in /tmp/ccfci5li.o
/tmp/ccfci5li.o: in function `main':
a.cc:(.text+0x269): relocation truncated to fit: R_X86_64_PC32 against symbol `cnt' defined in .bss section in /tmp/ccfci5li.o
a.cc:(.text+0x281): relocation truncated to fit: R_X86_64_PC32 against symbol `cnt' defined in .bss section in /tmp/ccfci5li.o
a.cc:(.text+0x2ca): relocation truncated to fit: R_X86_64_PC32 against symbol `cnt' defined in .bss section in /tmp/ccfci5li.o
a.cc:(.text+0x2e2): relocation truncated to fit: R_X86_64_PC32 against symbol `cnt' defined in .bss section in /tmp/ccfci5li.o
a.cc:(.text+0x38e): relocation truncated to fit: R_X86_64_PC32 against symbol `mark' defined in .bss section in /tmp/ccfci5li.o
a.cc:(.text+0x41e): relocation truncated to fit: R_X86_64_PC32 against symbol `mark' defined in .bss section in /tmp/ccfci5li.o
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int root[200001][200001] = {0};
int cnt[200001] = {0};
int mark[200001] = {0};


void aaa(queue<int> que1){
    if(que1.size() == 0) return;
    queue<int> que2;
    while (!que1.empty()) {
        int room = que1.front(); // 先頭要素を参照する
        que1.pop(); // 先頭要素を削除
        rep(j,cnt[room]){
            if(mark[root[room][j]] == 0){
                mark[root[room][j]] = room;
                que2.push(root[room][j]);
            }
        }
    }
    aaa(que2);
}

int main() {
    int N,M;
    cin >> N >> M;
    rep(i,M) {
        int A,B;
        cin >> A >> B;
        root[A][cnt[A]++] = B;
        root[B][cnt[B]++] = A;
    }
    queue<int> que;
    que.push(1);
    aaa(que);

    for(int i=2;i<N+1;i++){
        if(mark[i] == 0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for(int i=2;i<N+1;i++){
        cout << mark[i] << endl;
    }
    
	return 0;
}

Compiler output:
/tmp/ccQPPOEi.o: in function `aaa(std::queue<int, std::deque<int, std::allocator<int> > >)':
a.cc:(.text+0xa7): relocation truncated to fit: R_X86_64_PC32 against symbol `mark' defined in .bss section in /tmp/ccQPPOEi.o
a.cc:(.text+0xe6): relocation truncated to fit: R_X86_64_PC32 against symbol `mark' defined in .bss section in /tmp/ccQPPOEi.o
a.cc:(.text+0x13d): relocation truncated to fit: R_X86_64_PC32 against symbol `cnt' defined in .bss section in /tmp/ccQPPOEi.o
/tmp/ccQPPOEi.o: in function `main':
a.cc:(.text+0x269): relocation truncated to fit: R_X86_64_PC32 against symbol `cnt' defined in .bss section in /tmp/ccQPPOEi.o
a.cc:(.text+0x281): relocation truncated to fit: R_X86_64_PC32 against symbol `cnt' defined in .bss section in /tmp/ccQPPOEi.o
a.cc:(.text+0x2ca): relocation truncated to fit: R_X86_64_PC32 against symbol `cnt' defined in .bss section in /tmp/ccQPPOEi.o
a.cc:(.text+0x2e2): relocation truncated to fit: R_X86_64_PC32 against symbol `cnt' defined in .bss section in /tmp/ccQPPOEi.o
a.cc:(.text+0x38e): relocation truncated to fit: R_X86_64_PC32 against symbol `mark' defined in .bss section in /tmp/ccQPPOEi.o
a.cc:(.text+0x41e): relocation truncated to fit: R_X86_64_PC32 against symbol `mark' defined in .bss section in /tmp/ccQPPOEi.o
collect2: error: ld returned 1 exit status
Language: C++

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

typedef long long int ll;
#define PI 3.141592653

vector <ll> visit(100005);
vector <ll> adj[100005];
vector <ll> sign(100005);

void dfs(ll x){
  visit[x]=1;
  for(ll i=0;i<adj[x].size();i++){
    if(visit[adj[x][i]]==0){
      visit[adj[x][i]]=1;
      if(sign[adj[x][i]]==0){
        sign[adj[x][i]]=x;
      }
      dfs(adj[x][i]);
    }
  }
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n,m;
  cin>>n>>m;

  ll i;
  // for(i=0;i<100005;i++){
  //   visit[i]=false;
  // }
  for(i=0;i<m;i++){
    ll x,y;
    cin>>x>>y;
    adj[x].push_back(y);
  }
  dfs(1);
  ll flag=1;
  for(i=2;i<=n;i++){
    if(sign[i]==0){
      flag=0;
      break;
    }
  }
  if(!flag){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
    for(i=2;i<=n;i++){
      cout<<sign[i]<<endl;
    }
  }

  return 0;
}


Compiler output:
a.cc: In function 'void dfs(ll)':
a.cc:12:3: error: reference to 'visit' is ambiguous
   12 |   visit[x]=1;
      |   ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:7:13: note:                 'std::vector<long long int> visit'
    7 | vector <ll> visit(100005);
      |             ^~~~~
a.cc:14:8: error: reference to 'visit' is ambiguous
   14 |     if(visit[adj[x][i]]==0){
      |        ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:7:13: note:                 'std::vector<long long int> visit'
    7 | vector <ll> visit(100005);
      |             ^~~~~
a.cc:15:7: error: reference to 'visit' is ambiguous
   15 |       visit[adj[x][i]]=1;
      |       ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:7:13: note:                 'std::vector<long long int> visit'
    7 | vector <ll> visit(100005);
      |             ^~~~~
Language: C++

#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
#include <cstdlib> //絶対値 abs()
#include <iomanip>
#include <queue>
using namespace std;

int main(){
  int n,m;
  cin >> n >> m;
  int a, b;

  vector<int> depth(n,-1);
  vector<vector<int>> tree(n,vector<int>(0));
  vector<int> path(n);
  for(int i=0; i<m; i++){
    cin >> a >> b;
    a--; b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  
  queue<int> que;
  que.push(0);
  depth[0] = 0;
  
  while(!que.empty()){
    int v = que.front();
    que.pop();
    
    for(int k : tree[v]){
      if(depth[k] != -1) continue;
      depth[k] = depth[v] + 1;
      path[k] = v; 
      que.push(k);
    }
  }
  bool b = true;
  for(int i=0; i<n; i++){
    if(depth[i] == -1){
      b = false;
      break;
    }
  }
  if(b){
    cout << "Yes" << endl;
    for(int i=1; i<n; i++){
      cout << path[i] + 1 << endl;
    }
  }
  else{
    cout << "No" << endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:8: error: conflicting declaration 'bool b'
   39 |   bool b = true;
      |        ^
a.cc:12:10: note: previous declaration as 'int b'
   12 |   int a, b;
      |          ^
Language: C++

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

typedef long long int ll;
#define PI 3.141592653

bool visit[100005];
vector <ll> adj[100005];
vector <ll> sign(100005);

void dfs(ll x){
  visit[x]=true;
  for(ll i=0;i<adj[x].size();i++){
    if(visit[adj[x][i]]==false){
      visit[adj[x][i]]=true;
      if(sign[adj[x][i]]==0){
        sign[adj[x][i]]=x;
      }
      dfs(adj[x][i]);
    }
  }
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n,m;
  cin>>n>>m;

  ll i;
  for(i=0;i<100005;i++){
    visit[i]=false;
  }
  for(i=0;i<m;i++){
    ll x,y;
    cin>>x>>y;
    adj[x].push_back(y);
  }
  dfs(1);
  ll flag=1;
  for(i=2;i<=n;i++){
    if(sign[i]==0){
      flag=0;
      break;
    }
  }
  if(!flag){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
    for(i=2;i<=n;i++){
      cout<<sign[i]<<endl;
    }
  }

  return 0;
}


Compiler output:
a.cc: In function 'void dfs(ll)':
a.cc:12:3: error: reference to 'visit' is ambiguous
   12 |   visit[x]=true;
      |   ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:7:6: note:                 'bool visit [100005]'
    7 | bool visit[100005];
      |      ^~~~~
a.cc:14:8: error: reference to 'visit' is ambiguous
   14 |     if(visit[adj[x][i]]==false){
      |        ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:7:6: note:                 'bool visit [100005]'
    7 | bool visit[100005];
      |      ^~~~~
a.cc:15:7: error: reference to 'visit' is ambiguous
   15 |       visit[adj[x][i]]=true;
      |       ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:7:6: note:                 'bool visit [100005]'
    7 | bool visit[100005];
      |      ^~~~~
a.cc: In function 'int main()':
a.cc:33:5: error: reference to 'visit' is ambiguous
   33 |     visit[i]=false;
      |     ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:7:6: note:                 'bool visit [100005]'
    7 | bool visit[100005];
      |      ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60; //intじゃ扱えないことに注意！
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意！
const double pi = 3.14159265359;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
 
    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++) {
            par[i] = i;
        }
    }
 
    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) {
          return x;
        }
        return par[x] = root(par[x]);
    }
 
    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) {
          return; //xとyの根が同じ(=同じ木にある)時はそのまま
        }
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
 
    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  ll N,M;
  UnionFind tree(N);
  vector<int> par(N);

  vector<ll> A(M),B(M);
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    cin >> A[i] >> B[i];
    tree.unite(A[i]-1, B[i]-1);
    par[A[i]-1] = B[i];
  }

  
  bool can = true;
  for(int i = 1; i < N; i++){
    if(!same(i, 0)){
      cout << "No" << endl;
      can = false;
      break;
    }
  }
  
  if(can){
    cout << "Yes" << endl;
    for(int i = 1; i < N; i++){
      cout << par[i] << endl;
    }
  }

}


Compiler output:
a.cc: In function 'int main()':
a.cc:57:9: error: 'same' was not declared in this scope
   57 |     if(!same(i, 0)){
      |         ^~~~
Language: C++

#include <iostream>
#include <vector>
#include<queue>
#include<iomanip>
#include<array>
#include<cmath>
#include<utility>
using namespace std;
#define MAX 100001
#define ll long long
#ifndef M_PI
#define M_PI 3.14159265358979
#endif

#define deg_to_rad(deg) (((deg)/360)*2*M_PI)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

queue<pair<int,int>> next_pos;	//first どこにいくか　second どこからきたか
bool footprint[MAX];
pair<int,int> root[MAX * 2]; //first　入口　seconde 出口
int ans[MAX];
int index[MAX * 2];
int isfinish(int N)
{
	for (int i = 1; i < N + 1; ++i)
	{
		if (footprint[i] == false)
			return 0;
	}
	return 1;
}


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

	int N, M;
	cin >> N>> M;
	root[0].first = 0; root[0].second = 0;
	for (int i = 1; i < M+1; ++i)
	{
		cin >> root[i].first >> root[i].second;
	}
	sort(root);
	for (int i = 0; i < MAX; ++i)
	{
		footprint[i] = false;
		ans[i] = 0;
	}




	pair<int, int> pos( 1,1 );
	next_pos.push(pos);
	while(true)
	{
		pos=next_pos.front();
		next_pos.pop();

		for (int i = 1; i < M+1; ++i)
		{
			if (root[i].first == pos.first && footprint[root[i].second]==false)
			{
				
				pair<int, int> temp( root[i].second,pos.first );
				next_pos.push(temp);
				ans[root[i].second] = pos.first;
				footprint[root[i].second] = true;
			}
			else if (root[i].second == pos.first && footprint[root[i].first] == false)
			{
				pair<int, int> temp(root[i].first, pos.first);
				next_pos.push(temp);
				ans[root[i].first] = pos.first;
				footprint[root[i].first] = true;

			}

		}
		if (isfinish(N))
		{
			cout << "Yes" << '\n';
			for (int i = 2; i < N + 1; ++i)
			{
				cout << ans[i] << '\n';
			}
			break;
		}
		if (next_pos.empty())
		{
			cout << "No";
			break;
		}

	}

	return 0;
}

Compiler output:
a.cc:22:5: warning: built-in function 'index' declared as non-function [-Wbuiltin-declaration-mismatch]
   22 | int index[MAX * 2];
      |     ^~~~~
a.cc: In function 'int main()':
a.cc:45:9: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   45 |         sort(root);
      |         ^~~~
      |         sqrt
Language: C++

n, m = map(int, input().split())
road = {}

for idx in range(n):
    road[idx] = []

for idx in range(m):
    a, b = map(int, input().split())
    road[a - 1].append(b - 1)
    road[b - 1].append(a - 1)

visited = [-1 for i in range(n)]

from collections import deque
def bfs(road):
    global visited
    queue = deque([0])
    visited[0] = 0
    while queue:
        x = queue.popleft()
        for r in road[x]:
            if visited[r] == -1:
                visited[r] = x
                queue.append(r)

bfs(road)
if (-1) in visited:
    print('No')
else:
    print('Yes')
    for x in visited[1:]:
        print(x + 1)


Compiler output:
a.cc:28:11: warning: multi-character character constant [-Wmultichar]
   28 |     print('No')
      |           ^~~~
a.cc:30:11: warning: multi-character character constant [-Wmultichar]
   30 |     print('Yes')
      |           ^~~~~
a.cc:1:1: error: 'n' does not name a type
    1 | n, m = map(int, input().split())
      | ^
a.cc:4:1: error: expected unqualified-id before 'for'
    4 | for idx in range(n):
      | ^~~
Language: C++

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

typedef long long int ll;
#define PI 3.141592653

bool visit[100005]={false};
vector <ll> adj[100005];
vector <ll> sign(100005);

void dfs(ll x){
  visit[x]=true;
  for(ll i=0;i<adj[x].size();i++){
    if(visit[adj[x][i]]==false){
      visit[adj[x][i]]=true;
      if(sign[adj[x][i]]==0){
        sign[adj[x][i]]=x;
      }
      dfs(adj[x][i]);
    }
  }
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n,m;
  cin>>n>>m;

  ll i;
  for(i=0;i<m;i++){
    ll x,y;
    cin>>x>>y;
    adj[x].push_back(y);
  }
  dfs(1);
  ll flag=1;
  for(i=2;i<=n;i++){
    if(sign[i]==0){
      flag=0;
      break;
    }
  }
  if(!flag){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
    for(i=2;i<=n;i++){
      cout<<sign[i]<<endl;
    }
  }

  return 0;
}


Compiler output:
a.cc: In function 'void dfs(ll)':
a.cc:12:3: error: reference to 'visit' is ambiguous
   12 |   visit[x]=true;
      |   ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:7:6: note:                 'bool visit [100005]'
    7 | bool visit[100005]={false};
      |      ^~~~~
a.cc:14:8: error: reference to 'visit' is ambiguous
   14 |     if(visit[adj[x][i]]==false){
      |        ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:7:6: note:                 'bool visit [100005]'
    7 | bool visit[100005]={false};
      |      ^~~~~
a.cc:15:7: error: reference to 'visit' is ambiguous
   15 |       visit[adj[x][i]]=true;
      |       ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:7:6: note:                 'bool visit [100005]'
    7 | bool visit[100005]={false};
      |      ^~~~~
Language: C++

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

typedef long long int ll;
#define PI 3.141592653

bool visit[100005];
vector <ll> adj[100005];
vector <ll> sign(100005);

void dfs(ll x){
  visit[x]=true;
  for(ll i=0;i<adj[x].size();i++){
    if(visit[adj[x][i]]==false){
      visit[adj[x][i]]=true;
      if(sign[adj[x][i]]==0){
        sign[adj[x][i]]=x;
      }
      dfs(adj[x][i]);
    }
  }
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n,m;
  cin>>n>>m;

  ll i;
  for(i=0;i<m;i++){
    ll x,y;
    cin>>x>>y;
    adj[x].push_back(y);
  }
  dfs(1);
  ll flag=1;
  for(i=2;i<=n;i++){
    if(sign[i]==0){
      flag=0;
      break;
    }
  }
  if(!flag){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
    for(i=2;i<=n;i++){
      cout<<sign[i]<<endl;
    }
  }

  return 0;
}


Compiler output:
a.cc: In function 'void dfs(ll)':
a.cc:12:3: error: reference to 'visit' is ambiguous
   12 |   visit[x]=true;
      |   ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:7:6: note:                 'bool visit [100005]'
    7 | bool visit[100005];
      |      ^~~~~
a.cc:14:8: error: reference to 'visit' is ambiguous
   14 |     if(visit[adj[x][i]]==false){
      |        ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:7:6: note:                 'bool visit [100005]'
    7 | bool visit[100005];
      |      ^~~~~
a.cc:15:7: error: reference to 'visit' is ambiguous
   15 |       visit[adj[x][i]]=true;
      |       ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:7:6: note:                 'bool visit [100005]'
    7 | bool visit[100005];
      |      ^~~~~
Language: C++

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

int nextr[100010];
int route[100010][100010];
int record[100010];


int main(){
    int N,M;
    cin >> N >> M;
    for (int i =1;i<N+1;i++){
        for(int j=1;j<N+1;j++){
            route[i][j]=0;
        }
    }
    for(int i=1;i<N+1;i++)nextr[i]=record[i]=0;
    int A[M],B[M];
    for(int i=0;i< M;i++){
        cin >> A[i] >> B[i];
        route[A[i]][B[i]]= route[B[i]][A[i]]=1;
    }
    queue<int> q;
    q.push(1);
    record[1]=1;
    while (!q.empty()){
        int cur =q.front();
        q.pop();

        for(int i=1;i<N+1;i++){
           if(route[cur][i]==1 && record[i]==0){
               nextr[i]=cur;
               record[i]=1;//このタイミングで訪問済みにする
               q.push(i);
           } 
        }
    }
    cout << "Yes"<<endl;
    for(int i =2;i<N+1;i++){
        cout <<nextr[i] << endl;
    }
    return 0;
}



Compiler output:
/tmp/ccM89VVv.o: in function `main':
a.cc:(.text+0xaa): relocation truncated to fit: R_X86_64_PC32 against symbol `record' defined in .bss section in /tmp/ccM89VVv.o
a.cc:(.text+0xc5): relocation truncated to fit: R_X86_64_PC32 against symbol `record' defined in .bss section in /tmp/ccM89VVv.o
a.cc:(.text+0x2b5): relocation truncated to fit: R_X86_64_PC32 against symbol `record' defined in .bss section in /tmp/ccM89VVv.o
a.cc:(.text+0x336): relocation truncated to fit: R_X86_64_PC32 against symbol `record' defined in .bss section in /tmp/ccM89VVv.o
a.cc:(.text+0x371): relocation truncated to fit: R_X86_64_PC32 against symbol `record' defined in .bss section in /tmp/ccM89VVv.o
collect2: error: ld returned 1 exit status
Language: C++

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> to(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    vector<int> prev(n);
    vector<int> dist(n);
    // store distance and node
    priority_queue<pair<int, int>> que;

    // Dijkstra
    int MAX_DIST = 1000000;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            dist[i] = 0;
        } else {
            dist[i] = MAX_DIST;
        }
    }
    que.push(make_pair(0, 0));

    unordered_set<int> not_visited;
    for (int i = 0; i < n; i++) {
        not_visited.insert(i);
    }

    cout << "No" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:5: error: 'cin' was not declared in this scope
    3 |     cin >> n >> m;
      |     ^~~
a.cc:4:5: error: 'vector' was not declared in this scope
    4 |     vector<vector<int>> to(n);
      |     ^~~~~~
a.cc:4:19: error: expected primary-expression before 'int'
    4 |     vector<vector<int>> to(n);
      |                   ^~~
a.cc:9:9: error: 'to' was not declared in this scope
    9 |         to[a].push_back(b);
      |         ^~
a.cc:12:12: error: expected primary-expression before 'int'
   12 |     vector<int> prev(n);
      |            ^~~
a.cc:13:12: error: expected primary-expression before 'int'
   13 |     vector<int> dist(n);
      |            ^~~
a.cc:15:5: error: 'priority_queue' was not declared in this scope
   15 |     priority_queue<pair<int, int>> que;
      |     ^~~~~~~~~~~~~~
a.cc:15:20: error: 'pair' was not declared in this scope
   15 |     priority_queue<pair<int, int>> que;
      |                    ^~~~
a.cc:15:25: error: expected primary-expression before 'int'
   15 |     priority_queue<pair<int, int>> que;
      |                         ^~~
a.cc:21:13: error: 'dist' was not declared in this scope
   21 |             dist[i] = 0;
      |             ^~~~
a.cc:23:13: error: 'dist' was not declared in this scope
   23 |             dist[i] = MAX_DIST;
      |             ^~~~
a.cc:26:5: error: 'que' was not declared in this scope
   26 |     que.push(make_pair(0, 0));
      |     ^~~
a.cc:26:14: error: 'make_pair' was not declared in this scope
   26 |     que.push(make_pair(0, 0));
      |              ^~~~~~~~~
a.cc:28:5: error: 'unordered_set' was not declared in this scope
   28 |     unordered_set<int> not_visited;
      |     ^~~~~~~~~~~~~
a.cc:28:19: error: expected primary-expression before 'int'
   28 |     unordered_set<int> not_visited;
      |                   ^~~
a.cc:30:9: error: 'not_visited' was not declared in this scope
   30 |         not_visited.insert(i);
      |         ^~~~~~~~~~~
a.cc:33:5: error: 'cout' was not declared in this scope
   33 |     cout << "No" << endl;
      |     ^~~~
a.cc:33:21: error: 'endl' was not declared in this scope
   33 |     cout << "No" << endl;
      |                     ^~~~
Language: C

#include<stdio.h>


int main(){
  int n,m;
  scanf("%d%d",&n,&m);
  int a[m+1],b[m+1],len[n+1],root[n+1];
  
  for(int i=1;i<=m;i++)scanf("%d%d",&a[i],&b[i]);
  
  for(int i=1;i<=n;i++) len[i]=m;
  len[1]=0;
  
  for(int i=1;i<=m;i++){
    if(a[i]==1||b[i]==1){
      int s=a[i],t=b[i];
      a[i]=a[1];
      b[i]=b[1];
      a[1]=s;
      b[1]=t;
      break;
    }
  }
  
  for(int i=1;i<=m;i++){
    if(len[a[i]]>len[b[i]]){
      len[a[i]]=len[b[i]]+1;
      root[a[i]]=b[i];
    }
    if(len[a[i]]<len[b[i]]){
      len[b[i]]=len[a[i]]+1;
      root[b[i]]=a[i];
    }
  }
  
  for(int i=m;i<=1;i--){
    if(len[a[i]]>len[b[i]]){
      len[a[i]]=len[b[i]]+1;
      root[a[i]]=b[i];
    }
    if(len[a[i]]<len[b[i]]){
      len[b[i]]=len[a[i]]+1;
      root[b[i]]=a[i];
    }
  }
  printf("Yes\n");
  for(int i=2;i<=n;i++){
    printf("%d",root(i));
  }
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:48:17: error: called object 'root' is not a function or function pointer
   48 |     printf("%d",root(i));
      |                 ^~~~
main.c:7:30: note: declared here
    7 |   int a[m+1],b[m+1],len[n+1],root[n+1];
      |                              ^~~~
Language: C++

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;

int vist[100002];
int main()
{
    //freopen("B.data", "r", stdin);
    int N,M;
    int A,B;
    scanf("%d%d",&N,&M);
    memset(vist,-1,sizeof(vist));
    vector<vector<int>  > path(N+1);
    for(int i = 0 ; i < M; ++i){
        scanf("%d%d",&A,&B);
        path[A].push_back(B);
        path[B].push_back(A);
    }
    queue<int> q;
    q.push(1);
    vist[1]= 0;
    int cnt = 0;
    while(!q.empty()){
        int cur = q.front();
        //cout<<endl<<"cur = "<<cur<<endl;
        for(int i = 0 ; i < path[cur].size();++i){
            int tmp = path[cur][i];
            // cout<<"tmp = "<<tmp<<endl;
            // for(int j = 1 ; j <= N ; ++j){
            //     cout<<" "<<vist[j]<<" ";
            // }
            // cout<<endl;
            if(vist[tmp] == -1){
                q.push(tmp);
                vist[tmp] = cur;
            }
        }
        cnt++;
        q.pop();
    }
    if(cnt != N){
        printf("No\n");
    }else {
        printf("Yes\n");
        for(int i = 2; i <= N ; ++i){
            printf("%d\n",vist[i]);
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:5: error: 'memset' was not declared in this scope
   15 |     memset(vist,-1,sizeof(vist));
      |     ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include<queue>
  +++ |+#include <cstring>
    6 | using namespace std;