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

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 2019
#define pi 2*acos(0.0)
int cost[200005];
vector<bool>visit(200005,0);
bool flag=false;
void bfs(vector<int>g[],int start)
{
    queue<int>q;
    int x=start,u;
    visit[x]=true;
    cost[x]=0;
    q.push(x);
    while(!q.empty())
    {
        u=q.front();
        q.pop();
        for(int i=0; i<(int)g[u].size(); i++)
        {
            int v=g[u][i];
            if(visit[v]==false)
            {
                visit[v]=true;
                cost[v]=cost[u]+1;
                if(cost[v]!=0)
                    flag=true;
                q.push(v);
            }
        }
    }

}
int main()
{
    int n,m,i,a,b,j;
    cin>>m>>n;
    vector<int>graph[m+1];
    for(i=1; i<=n; i++)
    {
        cin>>a>>b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    /*
    for(i=1;i<=m;i++)
    {
        for(j=0;j<graph[i].size();j++)
        {
            cout<<graph[i][j]<<' ';
        }
        puts("");
    }
    */
    bfs(graph,1);
    if(flag)
    {
        cout<<"Yes\n";
        for(i=1; i<=m; i++)
        {
            if(cost[i]!=0)
            {
                cout<<cost[i]<<'\n';
            }
        }
    }
    else
        cout<<"No\n";
    return 0;
}


Compiler output:
a.cc: In function 'void bfs(std::vector<int>*, int)':
a.cc:13:5: error: reference to 'visit' is ambiguous
   13 |     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:13: note:                 'std::vector<bool> visit'
    7 | vector<bool>visit(200005,0);
      |             ^~~~~
a.cc:23:16: error: reference to 'visit' is ambiguous
   23 |             if(visit[v]==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:13: note:                 'std::vector<bool> visit'
    7 | vector<bool>visit(200005,0);
      |             ^~~~~
a.cc:25:17: error: reference to 'visit' is ambiguous
   25 |                 visit[v]=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:13: note:                 'std::vector<bool> visit'
    7 | vector<bool>visit(200005,0);
      |             ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 2019
#define pi 2*acos(0.0)
int cost[200005];
int visit[200005]={0};
bool flag=false;
void bfs(vector<int>g[],int start)
{
    queue<int>q;
    int x=start,u;
    visit[x]=true;
    cost[x]=0;
    q.push(x);
    while(!q.empty())
    {
        u=q.front();
        q.pop();
        for(int i=0; i<(int)g[u].size(); i++)
        {
            int v=g[u][i];
            if(visit[v]==false)
            {
                visit[v]=true;
                cost[v]=cost[u]+1;
                if(cost[v]!=0)
                    flag=true;
                q.push(v);
            }
        }
    }

}
int main()
{
    int n,m,i,a,b,j;
    cin>>m>>n;
    vector<int>graph[m+1];
    for(i=1; i<=n; i++)
    {
        cin>>a>>b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    /*
    for(i=1;i<=m;i++)
    {
        for(j=0;j<graph[i].size();j++)
        {
            cout<<graph[i][j]<<' ';
        }
        puts("");
    }
    */
    bfs(graph,1);
    if(flag)
    {
        cout<<"Yes\n";
        for(i=1; i<=m; i++)
        {
            if(cost[i]!=0)
            {
                cout<<cost[i]<<'\n';
            }
        }
    }
    else
        cout<<"No\n";
    return 0;
}


Compiler output:
a.cc: In function 'void bfs(std::vector<int>*, int)':
a.cc:13:5: error: reference to 'visit' is ambiguous
   13 |     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:5: note:                 'int visit [200005]'
    7 | int visit[200005]={0};
      |     ^~~~~
a.cc:23:16: error: reference to 'visit' is ambiguous
   23 |             if(visit[v]==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:5: note:                 'int visit [200005]'
    7 | int visit[200005]={0};
      |     ^~~~~
a.cc:25:17: error: reference to 'visit' is ambiguous
   25 |                 visit[v]=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:5: note:                 'int visit [200005]'
    7 | int visit[200005]={0};
      |     ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 2019
#define pi 2*acos(0.0)
int cost[200005];
bool visit[200005]={false};
bool flag=false;
void bfs(vector<int>g[],int start)
{
    queue<int>q;
    int x=start,u;
    visit[x]=true;
    cost[x]=0;
    q.push(x);
    while(!q.empty())
    {
        u=q.front();
        q.pop();
        for(int i=0; i<(int)g[u].size(); i++)
        {
            int v=g[u][i];
            if(visit[v]==false)
            {
                visit[v]=true;
                cost[v]=cost[u]+1;
                if(cost[v]!=0)
                    flag=true;
                q.push(v);
            }
        }
    }

}
int main()
{
    int n,m,i,a,b,j;
    cin>>m>>n;
    vector<int>graph[m+1];
    for(i=1; i<=n; i++)
    {
        cin>>a>>b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    /*
    for(i=1;i<=m;i++)
    {
        for(j=0;j<graph[i].size();j++)
        {
            cout<<graph[i][j]<<' ';
        }
        puts("");
    }
    */
    bfs(graph,1);
    if(flag)
    {
        cout<<"Yes\n";
        for(i=1; i<=m; i++)
        {
            if(cost[i]!=0)
            {
                cout<<cost[i]<<'\n';
            }
        }
    }
    else
        cout<<"No\n";
    return 0;
}


Compiler output:
a.cc: In function 'void bfs(std::vector<int>*, int)':
a.cc:13:5: error: reference to 'visit' is ambiguous
   13 |     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 [200005]'
    7 | bool visit[200005]={false};
      |      ^~~~~
a.cc:23:16: error: reference to 'visit' is ambiguous
   23 |             if(visit[v]==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 [200005]'
    7 | bool visit[200005]={false};
      |      ^~~~~
a.cc:25:17: error: reference to 'visit' is ambiguous
   25 |                 visit[v]=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 [200005]'
    7 | bool visit[200005]={false};
      |      ^~~~~
Language: C++

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

int n, m;
vector<vector<int>> x(n, vector<int>(m));
vector<int> data(n);

void pei(int a){
  int i, j;
  vector<int> y(1, 0);
  for(i = 0; i < n; i++){
    if(x[a-1][i] == 1){
      y.push_back(i+1);
      data[i] = a;
      for(j = 0; j < n; j++){
        x[j][i] = 0;
        x[i][j] = 0;
      }
    }
  }
  int s = y.size();
  for(i = 1; i < (s+1); i++){
    pei(y[i]);
  }
}

int main(){
  int i;
  cin >> n >> m;
  vector<vector<int>> x(n, vector<int>(n, 0));
  vector<int> data(n, 0);
  for(i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    x[a][b] = 1;
    x[b][a] = 1;
  }
  pei(1);
  for(i = 0; i < n; i++){
    if(data[i] == 0){
      break;
    }
  }
  if(i < n){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
    for(i = 0; i < n; i++){
      cout << data[i] << endl;
    }
  }
  return 0;
}


Compiler output:
a.cc: In function 'void pei(int)':
a.cc:14:7: error: reference to 'data' is ambiguous
   14 |       data[i] = a;
      |       ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:6:13: note:                 'std::vector<int> data'
    6 | vector<int> data(n);
      |             ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 2019
#define pi 2*acos(0.0)
int cost[200005];
bool visit[200005];
bool flag=false;
void bfs(vector<int>g[],int start)
{
    queue<int>q;
    int x=start,u;
    visit[x]=true;
    cost[x]=0;
    q.push(x);
    while(!q.empty())
    {
        u=q.front();
        q.pop();
        for(int i=0; i<g[u].size(); i++)
        {
            int v=g[u][i];
            if(visit[v]==false)
            {
                visit[v]=true;
                cost[v]=cost[u]+1;
                if(cost[v]!=0)
                    flag=true;
                q.push(v);
            }
        }
    }

}
int main()
{
    int n,m,i,a,b,j;
    cin>>m>>n;
    vector<int>graph[m+1];
    for(i=1; i<=n; i++)
    {
        cin>>a>>b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    /*
    for(i=1;i<=m;i++)
    {
        for(j=0;j<graph[i].size();j++)
        {
            cout<<graph[i][j]<<' ';
        }
        puts("");
    }
    */
    bfs(graph,1);
    if(flag)
    {
        cout<<"Yes\n";
        for(i=1; i<=m; i++)
        {
            if(cost[i]!=0)
            {
                cout<<cost[i]<<'\n';
            }
        }
    }
    else
        cout<<"No\n";
    return 0;
}


Compiler output:
a.cc: In function 'void bfs(std::vector<int>*, int)':
a.cc:13:5: error: reference to 'visit' is ambiguous
   13 |     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 [200005]'
    7 | bool visit[200005];
      |      ^~~~~
a.cc:23:16: error: reference to 'visit' is ambiguous
   23 |             if(visit[v]==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 [200005]'
    7 | bool visit[200005];
      |      ^~~~~
a.cc:25:17: error: reference to 'visit' is ambiguous
   25 |                 visit[v]=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 [200005]'
    7 | bool visit[200005];
      |      ^~~~~
Language: C++

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

int n, m;
vector<vector<int>> x;
vector<int> data;

void pei(int a){
  int i, j;
  vector<int> y(1, 0);
  for(i = 0; i < n; i++){
    if(x[a-1][i] == 1){
      y.push_back(i+1);
      data[i] = a;
      for(j = 0; j < n; j++){
        x[j][i] = 0;
        x[i][j] = 0;
      }
    }
  }
  for(i = 1; i < (y.size()+1); i++){
    pei(y[i]);
  }
}

int main(){
  int i;
  cin >> n >> m;
  vector<vector<int>> x(n, vector<int>(n, 0));
  vector<int> data(n, 0);
  for(i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    x[a][b] = 1;
    x[b][a] = 1;
  }
  pei(1);
  for(i = 0; i < n; i++){
    if(data[i] == 0){
      break;
    }
  }
  if(i < n){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
    for(i = 0; i < n; i++){
      cout << data[i] << endl;
    }
  }
  return 0;
}


Compiler output:
a.cc: In function 'void pei(int)':
a.cc:14:7: error: reference to 'data' is ambiguous
   14 |       data[i] = a;
      |       ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:6:13: note:                 'std::vector<int> data'
    6 | vector<int> data;
      |             ^~~~
Language: C++

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm> 
using namespace std;
int m, n, a, b, head, tail = 1, k = 1, c[100010], f[100010][100010], q[100010];
int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; i++)
	{
		scanf("%d%d", &a, &b);
		f[a][b] = 1; f[b][a] = 1;
	}
	q[++head] = 1;
	while(head <= tail)
	{
		for(int i = 2; i <= n; i++)
		{
			if(f[q[head]][i] == 1) 
			{
				q[++tail] = i;
				f[i][q[head]] = 0;
				if(c[i] == 0) c[i] = q[head];
			} 
		}
		head++;
	}
	for(int i = 2; i <= n; i++)
	{
		if(c[i] == 0)  
		{
			printf("No");
			return 0;
		}
	}
	printf("Yes\n");
	for(int i = 2; i <= n; i++)
	{
		printf("%d\n", c[i]);
	}
	return 0;
}

Compiler output:
/tmp/cc8RQDmu.o: in function `main':
a.cc:(.text+0xfb): relocation truncated to fit: R_X86_64_PC32 against symbol `q' defined in .bss section in /tmp/cc8RQDmu.o
a.cc:(.text+0x12a): relocation truncated to fit: R_X86_64_PC32 against symbol `q' defined in .bss section in /tmp/cc8RQDmu.o
a.cc:(.text+0x184): relocation truncated to fit: R_X86_64_PC32 against symbol `q' defined in .bss section in /tmp/cc8RQDmu.o
a.cc:(.text+0x19e): relocation truncated to fit: R_X86_64_PC32 against symbol `q' defined in .bss section in /tmp/cc8RQDmu.o
a.cc:(.text+0x1fb): relocation truncated to fit: R_X86_64_PC32 against symbol `q' defined in .bss section in /tmp/cc8RQDmu.o
collect2: error: ld returned 1 exit status
Language: C++

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

int main() {
    int n,m;cin>>n>>m;
    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);
    }
    queue<int> q;
    q.push(0);
    int vis[n]{};
    int ans[n];
    while (q.size()) {
        int v=q.front();q.pop();
        vis[v]=1;
        for (int u:g[v])
            if (!vis(u)) {
                ans[u]=v+1;
                q.push(u);
            }
    }
    for (int i=0;i<n;i++)
        cout<<ans[i]<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:21: error: 'vis' cannot be used as a function
   21 |             if (!vis(u)) {
      |                  ~~~^~~
Language: C

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
  static void Main(string[] args)
  {
        int[] arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var N = arr[0];
        var M = arr[1];
        var G = new List<int>[N];
        for (int i = 0; i < N; i++)
        {
            G[i] = new List<int>();
        }
        for (int i = 0; i < M; i++)
        {
            int[] arrTwo = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var a = arrTwo[0];
            var b = arrTwo[1];
            a--; b--;
            G[a].Add(b);
            G[b].Add(a);
        }
        var q = new Queue<(int, int, int)>();
        var visited = new bool[N];
        visited[0] = true;
        var michishirube = new int[N];
        q.Enqueue((0, -1, 0));
        while (q.Count > 0)
        {
            var t = q.Dequeue();
            var now = t.Item1;
            var prev = t.Item2;
            var d = t.Item3;
            foreach (var next in G[now])
            {
                if (visited[next]) continue;
                visited[next] = true;
                michishirube[next] = now;
                q.Enqueue((next, now, d + 1));
            }
        }
        Console.WriteLine("Yes");
        for (int i = 1; i < N; i++)
        {
            Console.WriteLine(michishirube[i] + 1);
        }


    }

   

}



Compiler output:
main.c:1:1: error: unknown type name 'using'
    1 | using System;
      | ^~~~~
main.c:2:1: error: unknown type name 'using'
    2 | using System.Collections.Generic;
      | ^~~~~
main.c:2:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    2 | using System.Collections.Generic;
      |             ^
main.c:3:1: error: unknown type name 'using'
    3 | using System.Linq;
      | ^~~~~
main.c:3:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    3 | using System.Linq;
      |             ^
main.c:4:1: error: unknown type name 'using'
    4 | using System.Text;
      | ^~~~~
main.c:4:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    4 | using System.Text;
      |             ^
main.c:6:1: error: unknown type name 'class'
    6 | class Program
      | ^~~~~
main.c:7:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
    7 | {
      | ^
Language: C

#include <stdio.h>
#include <stdlib.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define MAX_DATA 100100
typedef long long ll;

struct queue
{
    int arr[MAX_DATA];
    int first; //次にpopする配列の添え字
    int last;  //次にpushする配列の添え字
};

int push(struct queue *que, int input)
{
    if (que->arr[que->last] <= MAX_DATA)
    {
        que->arr[que->last] = input;
        que->last++;
        //printf("push:%d\n", input);
        return 0;
    }
    else
    {
        printf("これ以上データを追加できません。\n");
        return -1;
    }
}

int pop(struct queue *que)
{
    int output = que->arr[que->first];

    if (output != -1)
    {
        que->arr[que->first] = -1;
        que->first++;
        //printf("pop:%d\n", output);
        return output;
    }
    else
    {
        printf("データがありません。\n");
        return -1;
    }
}

void init_queue(struct queue *que)
{
    int i;

    for (i = 0; i < MAX_DATA; i++)
        que->arr[i] = -1;

    que->first = 0;
    que->last = 0;
}

void show_queue(struct queue *que, int n)
{
    int i;
    for (i = 0; i < n; i++)
    {
        if (que->arr[i] != -1)
            printf("%d ", que->arr[i]);
    }

    printf("\nfirst:%d last%d\n\n", que->first, que->last);
}

int main(void)
{
    long *graph[100001], cnt[100001] = {0};
    long n, m;

    scanf("%ld%ld", &n, &m);
    rep(i, m)
    {
        long a, b;
        scanf("%ld%ld", &a, &b);

        graph[a] = (long *)realloc(graph[a], sizeof(long) * (cnt[a] + 1));
        graph[a][cnt[a]] = b;
        cnt[a]++;

        graph[b] = (long *)realloc(graph[b], sizeof(long) * (cnt[b] + 1));
        graph[b][cnt[b]] = a;
        cnt[b]++;
    }
    graph[0] = (long *)realloc(graph[0], sizeof(long) * (cnt[0] + 1));
    graph[0][cnt[0]] = 0;
    cnt[0]++;
    /*
    rep(i, n + 1)
    {
        printf("graph[%d]={ ", i);
        rep(j, cnt[i])
            printf("%ld ", graph[i][j]);
        printf("} cnt:%ld\n", cnt[i]);
    }
*/
    // 初期化してから先頭に1をpush
    struct queue que;
    init_queue(&que);
    push(&que, 1);

    // -1：未発見の頂点
    // 頂点1を初期ノードとして初期化
    int dist[n + 1];
    rep(i, n + 1)
        dist[i] = -1;
    dist[1] = 0;

    int ans[n + 1] = {0};
    // queが空になるまで探索
    while (que.first != que.last)
    {
        // queから先頭頂点を取り出す
        int v = pop(&que);

        // vから訪問できる頂点を調べる
        rep(i, cnt[v])
        {
            // graphから頂点を取得し発見済みは探索しない
            int nv = graph[v][i];
            if (dist[nv] != -1)
                continue;

            // 未発見の頂点nvについて距離を更新してqueにpush
            dist[nv] = dist[v] + 1;
            ans[nv] = v;
            push(&que, nv);
        }
        //show_queue(&que, n);
    }

    puts("Yes");
    for (int i = 2; i < n + 1; i++)
        printf("%d\n", ans[i]);

    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:116:22: error: variable-sized object may not be initialized except with an empty initializer
  116 |     int ans[n + 1] = {0};
      |                      ^
Language: C++

#include<iostream>
#include<queue>
#include<vector>
using namespace std;
const int INF=1001001001;
int main(){
int n,m;
  cin>>n>>m;
  int a,b;
  vector<int> to[10005];
  for(int i=0;i<m;i++){
    cin>>a>>b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  queue<int> q;
  vector<int> dist(n,INF);
  vector<int> pre(n,-1);
  dist[0]=0;
  q.push(0);
  while(!(q.empty()){
    int v=q.front();
    q.pop();
    for(int u:to[v]){
      if(dist[u]!=INF) continue;
      dist[u]=dist[v]+1;
      pre[u]=v;
      q.push(u);
    }
  }
  cout<<"Yes"<<endl;
  for(int i=0;i<n;i++){
    if(i==0) continue;
    int ans=pre[i]+1;
    cout<<ans<<endl;
  }
        return 0;
        }

Compiler output:
a.cc: In function 'int main()':
a.cc:23:21: error: expected ')' before '{' token
   23 |   while(!(q.empty()){
      |        ~            ^
      |                     )
Language: C

#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

typedef struct t_queue{
	int size, head, tail;
	int *datavec;
} Queue;

Queue *initQueue(int);
void freeQueue(Queue*);
void enqueue(Queue*, int);
int dequeue(Queue*);

Queue *initQueue(int size){
	Queue *q = (Queue*)malloc(sizeof(Queue));
	if(q == NULL) errorQueue();

	q->size = size;
	q->datavec = (int*)malloc(sizeof(int) * (size+1));
	if(q->datavec == NULL) errorQueue();
	q->head = q->tail = 0;
	return q;
}

void freeQueue(Queue *q){
	free(q->datavec);
	free(q);
}

void enqueue(Queue *q, int data){
	q->datavec[q->head] = data;
	q->head++;
	q->head %= (q->size+1);
}

int dequeue(Queue *q){
	int ret = q->datavec[q->tail];
	q->tail++;
	q->tail %= (q->size+1);
	return ret;
}

int main(int argc, char const *argv[]){
	int n, m;
	scanf("%d %d\n",&n, &m);
	int a[m], b[m], dep[n+1], sign[n+1];
	for(int i=0; i<n+1; i++){
		dep[i]=0;
	}
	for(int i=0; i<m; i++){
		scanf("%d %d\n",a+i, b+i);
	}
	
	Queue *q = initQueue(n+1);
	enqueue(q, 1);
	do{
		int t = dequeue(q);
		for(int i=0; i<m; i++){
			if(dep[b[i]] == 0 && a[i] == t){
				sign[b[i]] = t;
				dep[b[i]] = 1;
				enqueue(q,b[i]);
			}
			if(dep[a[i]] == 0 && b[i] == t){
				sign[a[i]] = t;
				dep[a[i]] = 1;
				enqueue(q,a[i]);
			}
		}
	}while(q->head != q->tail);
	
	printf("Yes\n");
	for(int i=2; i<n+1; i++){
		printf("%d\n", sign[i]);
	}
}

Compiler output:
main.c: In function 'initQueue':
main.c:19:23: error: implicit declaration of function 'errorQueue' [-Wimplicit-function-declaration]
   19 |         if(q == NULL) errorQueue();
      |                       ^~~~~~~~~~
Language: C++

#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
#define ll  long long 
  vector<ll>to[1000005];
int main(){
  ll n,m;cin>>n>>m;
  rep(i,m){
    ll a,b;cin>>a>>b;a--;b--;
    to[a].push_back(b);
    to[b].push_back(a);
  } 
  queue <ll>q;
  vector<ll>dist(n,INT_MAX);
  vector<ll>pre(n,-1);
  dist[0]=0;
  q.push(0);
  while(!q.empty()){
    ll v=q.front();q.pop();
    for(ll u:to[v]){
      if(dish[u]!=INT_MAX)continue;
      dish[u]=dish[v]+1;
      pre[u]=v;
      q.push(u);
    }
  }
  cout<<"Yes"<<endl;
  rep(i,n){
    if(i==0)continue;
    cout<<pre[i]+1<<endl;
  }
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:41:10: error: 'dish' was not declared in this scope; did you mean 'dist'?
   41 |       if(dish[u]!=INT_MAX)continue;
      |          ^~~~
      |          dist
a.cc:42:7: error: 'dish' was not declared in this scope; did you mean 'dist'?
   42 |       dish[u]=dish[v]+1;
      |       ^~~~
      |       dist
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>;
 
const int INF = 1001001001;
vector<int> to[100005];
 
int main() {
    int n, m;
    cin >> n >> m;
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
  
    queue<int> q;
    vector<int> dist(n, INF);
    vector<int> pre(n, -1);
    dist[0] = 0;
    q.push(0);
    while(!q.empty()) {
        int　v = q.front(); q.pop();
        for(int u : to[v]) {
            if(dist[u] != INF) continue;
            dist[u] = dist[v]+1;
            //通常のBFSとの違い
            pre[u] = v;
            //ここまで
            q.push(u);
        }
    }
  
    cout << "Yes" << "\n";
    rep(i,n) {
        if(i == 0) continue;
        int ans = pre[i];
        ++ans;
        cout << ans << "\n";
    }
    return 0;
}
#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>;
 
const int INF = 1001001001;
vector<int> to[100005];
 
int main() {
    int n, m;
    cin >> n >> m;
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
  
    queue<int> q;
    vector<int> dist(n, INF);
    vector<int> pre(n, -1);
    dist[0] = 0;
    q.push(0);
    while(!q.empty()) {
        int v = q.front(); q.pop();
        for(int u : to[v]) {
            if(dist[u] != INF) continue;
            dist[u] = dist[v]+1;
            //通常のBFSとの違い
            pre[u] = v;
            //ここまで
            q.push(u);
        }
    }
  
    cout << "Yes" << "\n";
    rep(i,n) {
        if(i == 0) continue;
        int ans = pre[i];
        ++ans;
        cout << ans << "\n";
    }
    return 0;
}
提出情報
提出日時

Compiler output:
a.cc:27:9: error: extended character 　 is not valid in an identifier
   27 |         int　v = q.front(); q.pop();
      |         ^
a.cc: In function 'int main()':
a.cc:27:9: error: 'int\U00003000v' was not declared in this scope
   27 |         int　v = q.front(); q.pop();
      |         ^~~~~~
a.cc:28:24: error: 'v' was not declared in this scope
   28 |         for(int u : to[v]) {
      |                        ^
a.cc: At global scope:
a.cc:53:11: error: redefinition of 'const int INF'
   53 | const int INF = 1001001001;
      |           ^~~
a.cc:7:11: note: 'const int INF' previously defined here
    7 | const int INF = 1001001001;
      |           ^~~
a.cc:54:13: error: redefinition of 'std::vector<int> to [100005]'
   54 | vector<int> to[100005];
      |             ^~
a.cc:8:13: note: 'std::vector<int> to [100005]' previously declared here
    8 | vector<int> to[100005];
      |             ^~
a.cc:56:5: error: redefinition of 'int main()'
   56 | int main() {
      |     ^~~~
a.cc:10:5: note: 'int main()' previously defined here
   10 | int main() {
      |     ^~~~
a.cc:93:1: error: '\U000063d0\U000051fa\U000060c5\U00005831' does not name a type
   93 | 提出情報
      | ^~~~~~~~
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>;
 
const int INF = 1001001001;
vector<int> to[100005];
 
int main() {
    int n, m;
    cin >> n >> m;
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
  
    queue<int> q;
    vector<int> dist(n, INF);
    vector<int> pre(n, -1);
    dist[0] = 0;
    q.push(0);
    while(!q.empty()) {
        int　v = q.front(); q.pop();
        for(int u : to[v]) {
            if(dist[u] != INF) continue;
            dist[u] = dist[v]+1;
            //通常のBFSとの違い
            pre[u] = v;
            //ここまで
            q.push(u);
        }
    }
  
    cout << "Yes" << "\n";
    rep(i,n) {
        if(i == 0) continue;
        int ans = pre[i];
        ++ans;
        cout << ans << "\n";
    }
    return 0;
}

Compiler output:
a.cc:27:9: error: extended character 　 is not valid in an identifier
   27 |         int　v = q.front(); q.pop();
      |         ^
a.cc: In function 'int main()':
a.cc:27:9: error: 'int\U00003000v' was not declared in this scope
   27 |         int　v = q.front(); q.pop();
      |         ^~~~~~
a.cc:28:24: error: 'v' was not declared in this scope
   28 |         for(int u : to[v]) {
      |                        ^
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>;

const int INF = 1001001001;
vector<int> to[100005];
 
int main() {
    int n, m;
    cin >> n >> m;
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
  
    queue<int> q;
    vector<int> dist(n, INF);
    vector<int> pre(n, -1);
    dist[0] = 0;
    q.push.(0);
    while(!q.empty()) {
        intv = q.front(); q.pop();
        for(int u : to[v]) {
            if(dist[u] != INF) continue;
            dist[u] = dist[v]+1;
            //通常のBFSとの違い
            pre[u] = v;
            //ここまで
            q.push(u);
        }
    }
  
    cout << "Yes" << "\n";
    rep(i,n) {
        if(i == 0) continue;
        int ans = pre[i];
        ++ans;
        cout << ans << "\n";
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:7: error: invalid use of member function 'std::queue<int>::push' (did you forget the '()' ?)
   25 |     q.push.(0);
      |     ~~^~~~
a.cc:27:9: error: 'intv' was not declared in this scope; did you mean 'int'?
   27 |         intv = q.front(); q.pop();
      |         ^~~~
      |         int
a.cc:28:24: error: 'v' was not declared in this scope
   28 |         for(int u : to[v]) {
      |                        ^
Language: C

//
//AtCoder Beginner Contest 168
//D - .. (Double Dots) 
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

using Graph = vector<vector<int>>;
vector<bool> seen;

int main()
{
    int n, m;

    cin >> n >> m;

    Graph G(n);
    REP(i, m){
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    // BFS のためのデータ構造
    vector<int> dist(n, -1);    // 全頂点を「未訪問」に初期化
    vector<int> guide(n, -1);   // 道標(前の頂点)
    vector<vector <int>> mem(n); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    guide[0] = 0;
    que.push(0);

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue;

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            if (guide[nv] == -1) guide[nv]=v;

            que.push(nv);
        }
    }

    //for (int v = 0; v < n; ++v) cout << v << ": " << dist[v] << ":" << guide[v] << endl;

    string f = "Yes";
    FOR(i, 1, n-1){
        if (dist[i] == 0) f="No";
    }

    cout << f << endl;
    if (f=="Yes"){
        FOR(i, 1, n-1) cout << guide[i]+1 << endl;
    }

    return 0;
}


Compiler output:
main.c:6:10: fatal error: iostream: No such file or directory
    6 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std; 
int main(){
  int n, m;
  cin >> n >> m;
  vector<vectot<int>> Graph(n);
  int a, b;
  for(int i = 0; i < m; i++){
    cin >> a >> b;
    Graph[b-1].emplace_back(a-1);
    Graph[a-1].emplace_back(b-1);
  }
  queue<int> q;
  vector<int> route(n, -1);
  route[0] = 0;
  q.push(0);
  while(!q.empty()){
    int now = q.front();
    q.pop();
    for(int next : Graph[now]){
      if(route[next] == -1){
        q.push(next);
        route[next] = now;
      }
    }
  }
  for(int i = 0; i < n; i++){
    if(route[i] == -1) {
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  for(int i = 0; i < n-1; i++){
    cout << route[i+1] + 1 << endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:10: error: 'vectot' was not declared in this scope
    6 |   vector<vectot<int>> Graph(n);
      |          ^~~~~~
a.cc:6:20: error: template argument 1 is invalid
    6 |   vector<vectot<int>> Graph(n);
      |                    ^~
a.cc:6:20: error: template argument 2 is invalid
a.cc:10:10: error: invalid types 'int[int]' for array subscript
   10 |     Graph[b-1].emplace_back(a-1);
      |          ^
a.cc:11:10: error: invalid types 'int[int]' for array subscript
   11 |     Graph[a-1].emplace_back(b-1);
      |          ^
a.cc:20:25: error: invalid types 'int[int]' for array subscript
   20 |     for(int next : Graph[now]){
      |                         ^
Language: C++

#include <bits/stdc++.h>
using namespace std; 
int main(){
  int n, m;
  cin >> n >> m;
  vector<vectot<int>> Graph(n);
  int a, b;
  for(int i = 0; i < m; i++){
    cin >> a >> b;
    Graph[b-1].emplace_back(a-1);
    Graph[a-1].emplace_back(b-1);
  }
  queue<int> q;
  vector<int> route(N, -1);
  route[0] = 0;
  q.push(0);
  while(!q.empty()){
    int now = q.front();
    q.pop();
    for(int next : Graph[now]){
      if(route[next] == -1){
        q.push(next);
        route[next] = now;
      }
    }
  }
  for(int i = 0; i < n; i++){
    if(route[i] == -1) {
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  for(int i = 0; i < n-1; i++){
    cout << route[i+1] + 1 << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:10: error: 'vectot' was not declared in this scope
    6 |   vector<vectot<int>> Graph(n);
      |          ^~~~~~
a.cc:6:20: error: template argument 1 is invalid
    6 |   vector<vectot<int>> Graph(n);
      |                    ^~
a.cc:6:20: error: template argument 2 is invalid
a.cc:10:10: error: invalid types 'int[int]' for array subscript
   10 |     Graph[b-1].emplace_back(a-1);
      |          ^
a.cc:11:10: error: invalid types 'int[int]' for array subscript
   11 |     Graph[a-1].emplace_back(b-1);
      |          ^
a.cc:14:21: error: 'N' was not declared in this scope
   14 |   vector<int> route(N, -1);
      |                     ^
a.cc:20:25: error: invalid types 'int[int]' for array subscript
   20 |     for(int next : Graph[now]){
      |                         ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[]) {
    int N, M;
    cin >> N >> M;

    vector<vector<int>> g(N, vector<int>());
    for (int i = 0; i < M; i++) {
        int from, to;
        cin >> from >> to;
        g[from - 1].push_back(to - 1);
        g[to - 1].push_back(from - 1);
    }

    queue<pair<int, int>> q;
    q.push(make_pair(0, 0));
    vector<int> ans(N);
    vector<int> visited(N, 0);
    while (!q.empty()) {
        auto p = q.front();
        q.pop();
      	if (visited[p.first] == 1) continue;
        visited[p.first] = 1;
      	ans[p.first] = p.second;

        for (int j = 0; j < g[p.first].size(); j++) {
            if (visited[g[p.first][j]] != 1) {
                q.push_back(make_pair(g[p.first][j], p.first));
            }
        }
    }

    cout << "Yes" << endl;
    for (int k = 1; k < N; k++) {
        cout << ans[k] + 1 << endl;
    }

    return 0;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:30:19: error: 'class std::queue<std::pair<int, int> >' has no member named 'push_back'
   30 |                 q.push_back(make_pair(g[p.first][j], p.first));
      |                   ^~~~~~~~~
Language: C++

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> G[M];
    for (int i = 0; i < M; i++)
    {
        int s, t;
        cin >> s >> t;
        G[s - 1].push_back(t - 1);
        G[t - 1].push_back(s - 1);
    }
    vector<int> dist(N, -1);
    //for(int i = 0; i < N; i++) cout << i << ": " << dist[i] << "\n";
    vector<int> key(N, 0);

    queue<int> que;

    dist[0] = 0;
    que.push(0);

    while(!que.empty()){
        int v = que.front();
        que.pop();

        for (int nv : G[v])
        {
            if (dist[nv] != -1) continue;
            
            dist[nv] = dist[v] + 1;
            que.push(nv);
            key[nv] = v;
        }
        
    }
    for (int i = 1; i < N; i++)
    {
        if (dist[i] == -1)
        {
            cout << "No" << "\n"
            return 0;
        }
        
    }
    cout << "Yes" << "\n";
    for (int v = 1; v < N; ++v){
        cout << key[v] + 1 << "\n";
    }
    /*
    if (find(dist.begin(), dist.end(), -1) != dist.end()){
		cout << "No" << "\n";
    }else{
		cout << "Yes" << "\n";
        for (int v = 1; v < N; ++v){
            cout << key[v] + 1 << "\n";
        }
    }*/
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:33: error: expected ';' before 'return'
   42 |             cout << "No" << "\n"
      |                                 ^
      |                                 ;
   43 |             return 0;
      |             ~~~~~~
Language: Java

import java.util.*;
import java.io.*;
 
public class Main {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    static int parent[]; 
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
 
        int N = nextInt();
        int M = nextInt();
     
        parent = new int [N+1];
 
           
        ArrayList<Integer> matrix [] = new ArrayList [N+1];
 
        for (int x=1; x<=N; x++) {
            matrix[x] = new ArrayList<Integer>();
        }
 
        for (int x=1; x<=M; x++) {
            int one = nextInt();
            int two = nextInt();
            matrix[one].add(two);
            matrix[two].add(one);
        }
    
        bfs(matrix, 1);
        
        boolean flag = true;
        for (int x=1; x<=N; x++) {
            if(parent[x] == 0){
                flag = false;
                break;
            }
        }
        if(flag){
            System.out.println("Yes");
            for (int x=2; x<=N; x++) {
                System.out.println(parent[x]);
            }
        }
        else{
            System.out.println("No");
        }
        
    
    }
        
    public static boolean bfs (ArrayList [] matrix,  int start) {
        Queue <Integer> queue = new LinkedList<Integer>();
        queue.add(start);
        
        while (!queue.isEmpty()) {
            int cur = queue.poll();
            for (int x=0; x<matrix[cur].size(); x++) {
                int now = (int) matrix[cur].get(x);
                if(parent[now]==0){
                    parent[now] = cur;
                    queue.add(now);
                }
            }
        }
        return false;
    }
}

Compiler output:
Main.java:14: error: cannot find symbol
        int N = nextInt();
                ^
  symbol:   method nextInt()
  location: class Main
Main.java:15: error: cannot find symbol
        int M = nextInt();
                ^
  symbol:   method nextInt()
  location: class Main
Main.java:27: error: cannot find symbol
            int one = nextInt();
                      ^
  symbol:   method nextInt()
  location: class Main
Main.java:28: error: cannot find symbol
            int two = nextInt();
                      ^
  symbol:   method nextInt()
  location: class Main
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 errors
Language: C++

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define INF 2147483647
using namespace std;
using Graph=vector<vector<int>>;

int main(){
  int n,m;
  cin>>n>>m;
  Graph G(n);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }
  vector<int> milestone(n,INF);
  queue<int> que;
  milestone[0]=0;
  que.push(0);
  while(!que.empty()){
    int v=que.front();
    que.pop();
    for(int nv:G[v]){
      if(milestone[nv]!=) continue;
      milestone[nv]=milestone[v]+1;
      que.push(nv);
    }
  }
  cout<<"Yes"<<"\n";
  for(int i=1;i<=n-1;i++){
    cout<<milestone[i]<<"\n";
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:25: error: expected primary-expression before ')' token
   39 |       if(milestone[nv]!=) continue;
      |                         ^
Language: C++

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define INF 2147483647
using namespace std;
using Graph=vector<vector<int>>;

int main(){
  int n,m;
  cin>>n>>m;
  Graph G(n);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    G[a-1].push_back(b-1);
    G(b-1).push_back(a-1);
  }
  vector<int> milestone(n,INF);
  queue<int> que;
  milestone[0]=0;
  que.push(0);
  while(!que.empty()){
    int v=que.front();
    que.pop();
    for(int nv:G(v)){
      milestone[nv]=min(milestone[nv],milestone[v]+1);
      que.push(nv);
    }
  }
  cout<<"Yes"<<"\n";
  for(int i=1;i<=n-1;i++){
    cout<<milestone[i]<<"\n";
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:6: error: no match for call to '(Graph {aka std::vector<std::vector<int> >}) (int)'
   28 |     G(b-1).push_back(a-1);
      |     ~^~~~~
a.cc:31:3: error: 'queue' was not declared in this scope
   31 |   queue<int> que;
      |   ^~~~~
a.cc:13:1: note: 'std::queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
   12 | #include<iomanip>
  +++ |+#include <queue>
   13 | #define rep(i,n) for(int i=0;i<n;i++)
a.cc:31:9: error: expected primary-expression before 'int'
   31 |   queue<int> que;
      |         ^~~
a.cc:33:3: error: 'que' was not declared in this scope
   33 |   que.push(0);
      |   ^~~
a.cc:37:17: error: no match for call to '(Graph {aka std::vector<std::vector<int> >}) (int&)'
   37 |     for(int nv:G(v)){
      |                ~^~~