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

#include <bits/stdc++.h>

using namespace std;

void solve(map<int, vector<int>> adj_rooms, vector<bool> checked, vector<int>& direction, int cur_room){
    vector<int> adj_r = adj_rooms[cur_room];

    bool end_loop = true;

    for (int j = 0; j < (int)adj_r.size(); j++){
        int selected_room = adj_r[j];
        if (!checked[selected_room]){
            end_loop = false;
            checked[selected_room] = true;
            direction[selected_room] = cur_room;
        }
    }

    if (end_loop)
        return;

    for (int j = 0; j < (int)adj_r.size(); j++){
        solve(adj_rooms, checked, direction, adj_r[j]);
    }

}

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

    int A, B;
    map<int, vector<int>> adj_rooms;

    for (int i = 0; i < M; i++){
        cin >> A >> B;
        adj_rooms[A-1].push_back(B-1);
        adj_rooms[B-1].push_back(A-1);
    }

    for (int i = 0; i < N; i++){
        sort(adj_rooms[i].begin(), adj_rooms[i].end());
        adj_rooms[i].erase(unique(adj_rooms[i].begin(), adj_rooms[i].end()), adj_rooms[i].end());
    }

    vector<bool> checked(N);
    for (int i = 0; i < N; i++){
        checked[i] = false;
    }

    vector<int> direction(N);

    checked[0] = true;
    solve(adj_rooms, checked, direction, 0);

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

    return 0;
}



Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: Java

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt(), M = sc.nextInt();
        int[][] route = new int[M][2];
        for(int i=0;i<M;i++){
            route[i][0] = sc.nextInt()-1;   //最後に1を足せ
            route[i][1] = sc.nextInt()-1;
        }

        List<Integer>[] destination = new List[N];
        for(int i=0; i<destination.length; i++) {
            destination[i]= new ArrayList<Integer>();
        }
        for(int i=0; i<M; i++) {
            destination[route[i][0]].add(route[i][1]);
            destination[route[i][1]].add(route[i][0]);
        }

        int[] clear = new int[N];
        for(int i=0; i<clear.length; i++) {
            if(i!=0) {
                clear[i]=-1;
            }
        }

        List<Integer> queue = new ArrayList<Integer>();
        queue.add(0);

        for(int i=0; i<queue.size(); i++) {
            for(int j=0; j<destination[queue.get(i)].size(); j++) {
                if(clear[destination[queue.get(i)].get(j)]==-1) {s
                    queue.add(destination[queue.get(i)].get(j));
                    clear[destination[queue.get(i)].get(j)]=queue.get(i);
                }
            }
        }
        if(queue.size()==N) {
            System.out.println("Yes");
        }
        for(int i=1; i<clear.length; i++) {
            System.out.println(clear[i]+1);
        }
    }

}


Compiler output:
Main.java:38: error: ';' expected
                    queue.add(destination[queue.get(i)].get(j));
                         ^
1 error
Language: Java

package abc;

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

public class D168 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt(), M = sc.nextInt();
        int[][] route = new int[M][2];
        for(int i=0;i<M;i++){
            route[i][0] = sc.nextInt()-1;   //最後に1を足せ
            route[i][1] = sc.nextInt()-1;
        }

        int[] clear = new int[N];
        for(int i=0; i<clear.length; i++) {
            if(i!=0) {
                clear[i]=-1;
            }
        }

        List<Integer> queue = new ArrayList<Integer>();
        queue.add(0);

        for(int i=0; i<queue.size(); i++) {
            for(int j=0; j<M; j++) {
                if(route[j][0]==queue.get(i) && clear[route[j][1]]==-1) {
                    queue.add(route[j][1]);
                    clear[route[j][1]]=route[j][0];
                }
                if(route[j][1]==queue.get(i) && clear[route[j][0]]==-1) {
                    queue.add(route[j][0]);
                    clear[route[j][0]]=route[j][1];
                }
            }
        }
        if(queue.size()==N) {
            System.out.println("Yes");
        }
        for(int i=1; i<clear.length; i++) {
            System.out.println(clear[i]+1);
        }
    }

}


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

#include<bits/stdc++.h>
using namespace std;
const int inf=1001001001;
int main(){
 int n,m;
  cin>>n>>M;
  int a,b;
  vector<int> to[100005];
  for(int i=0;i<m;i++){
    cin>>a>>b;
    a--;
    b--;
    to.push_back(b);
    to.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]){
      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];
    ans++;
    cout<<ans<<endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:11: error: 'M' was not declared in this scope
    6 |   cin>>n>>M;
      |           ^
a.cc:13:8: error: request for member 'push_back' in 'to', which is of non-class type 'std::vector<int> [100005]'
   13 |     to.push_back(b);
      |        ^~~~~~~~~
a.cc:14:8: error: request for member 'push_back' in 'to', which is of non-class type 'std::vector<int> [100005]'
   14 |     to.push_back(a);
      |        ^~~~~~~~~
Language: C++

    #include <iostream>
    #include <sstream>
     #include <vector>

    using namespace std;
     vector<int> path;
vector<vector<int>> NtoN;
vector<int> minpath;


int rec(vector<int>& a,int b,int MAX){
  if(b == MAX)
  {
      for(int i = 0; i < MAX + 1;i++)
      cout << a[i] + 1 << " ";
   cout << endl;
for(int i = 1; i < MAX+1;i++)
{
  int k = i;
  
/*for(int d = 0; d < minpath[i];d++)
{
// cout << d << " " << a[k] << " " << k << endl;
 k = a[k];
}
  if(k != 0){
   return 0;
  }
}*/
        cout << "Yes" << endl;
    for(int i = 1; i < MAX + 1;i++)
      cout << a[i] + 1 << endl;
return 0;

  }
  
        b++;
  //if(minpath[b] == 1)
  //{
   // auto c = a;
   // c[b]= 0;
   // int d = rec(c,b,MAX);
   //     if(d == 1)
   //   return 1;
  //} else {
  for(int i = 0;i < path[b];i++)
    if(minpath[NtoN[b][i]] < minpath[b])
    {
    auto c = a;
    c[b] = NtoN[b][i];
   int d = rec(c,b,MAX) ;
    if(d == 1)
      return 1;
  }
  //}
  return 0;
}
    int main(){
     
      int N,M;
      string buf;
      getline(cin,buf);
      {
      stringstream line(buf);
        line >> N >> M;
      }
      NtoN = vector(N,vector<int>(0,0));
      
      path = vector<int>(N,0);
      minpath = vector<int>(N,N);
minpath[0] = 0;

      
      for(int i = 0;i < M;i++)
      {
        getline(cin,buf);
        int a,b;
        stringstream line(buf);
        line >> a >> b;
        NtoN[a-1].push_back(b-1);
        NtoN[b-1].push_back(a-1);
        
        path[a-1]++;
        path[b-1]++;
      }
      
      
 auto nextto = vector<int>(1,0);
      for(int d = 1; d < N;d++)
      {
        auto tmp = nextto;
    nextto = vector<int>();
        for(auto &j: tmp)
        {
          for(auto &i : NtoN[j]){
if(minpath[i] > d){
         	nextto.push_back(i);
  	minpath[i] = d;
}
          }

        }
      } // end
      
     
    //  for(auto &i : minpath)
       // cout << i << endl;
      auto f = vector<int>(N,0);
     int d = rec(f,0,N-1);
      if(d == 0)
      cout << "No" << endl;
    }

Compiler output:
a.cc: In function 'int rec(std::vector<int>&, int, int)':
a.cc:58:13: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   58 |     int main(){
      |             ^~
a.cc:58:13: note: remove parentheses to default-initialize a variable
   58 |     int main(){
      |             ^~
      |             --
a.cc:58:13: note: or replace parentheses with braces to value-initialize a variable
a.cc:58:15: error: a function-definition is not allowed here before '{' token
   58 |     int main(){
      |               ^
a.cc:112:6: error: expected '}' at end of input
  112 |     }
      |      ^
a.cc:11:38: note: to match this '{'
   11 | int rec(vector<int>& a,int b,int MAX){
      |                                      ^
a.cc:112:6: warning: control reaches end of non-void function [-Wreturn-type]
  112 |     }
      |      ^
Language: C++

    #include <iostream>
    #include <sstream>
     #include <vector>

    using namespace std;
     vector<int> path;
vector<vector<int>> NtoN;
vector<int> minpath;


int rec(vector<int>& a,int b,int MAX){
  if(b == MAX)
  {
//      for(int i = 0; i < MAX + 1;i++)
//      cout << a[i] + 1 << " ";
//   cout << endl;
for(int i = 1; i < MAX+1;i++)
{
  int k = i;
  
for(int d = 0; d < minpath[i];d++)
{
  //cout << d << " " << a[k] << " " << k << endl;
  k = a[k];
}
  if(k != 0){
   return 0;
  }
}
        cout << "Yes" << endl;
    for(int i = 1; i < MAX + 1;i++)
      cout << a[i] + 1 << endl;
return 1;

  }
  
        b++;
  if(minpath[b] == 1)
  {
    auto c = a;
    c[b]= 0;
    int d = rec(c,b,MAX);
        if(d == 1)
      return 1;
  } else {
  for(int i = 0;i < path[b];i++)
    if(minpath[NtoN[b][i]] < minpath[b])
    {
    auto c = a;
    c[b] = NtoN[b][i];
   int d = rec(c,b,MAX) ;
    if(d == 1)
      return 1;
  }
  }
  return 0;
}
    int main(){
     
      int N,M;
      string buf;
      getline(cin,buf);
      {
      stringstream line(buf);
        line >> N >> M;
      }
      NtoN = vector(N,vector<int>(0,0));
      
      path = vector<int>(N,0);
      minpath = vector<int>(N,N);
minpath[0] = 0;

      
      for(int i = 0;i < M;i++)
      {
        getline(cin,buf);
        int a,b;
        stringstream line(buf);
        line >> a >> b;
        NtoN[a-1].push_back(b-1);
        NtoN[b-1].push_back(a-1);
        
        path[a-1]++;
        path[b-1]++;
      }
      
      
 auto nextto = vector<int>(1,0);
      for(int d = 1; d < N;d++)
      {
        auto tmp = nextto;
    nextto = vector<int>();
        for(auto &j: tmp)
        {
          for(auto &i : NtoN[j]){
if(minpath[i] > d){
         	nextto.push_back(i);
  	minpath[i] = d;
}
          }

        }
      } // end
      return ;
    //  for(auto &i : minpath)
       // cout << i << endl;
      auto f = vector<int>(N,0);
     int d = rec(f,0,N-1);
      if(d == 0)
      cout << "No" << endl;
    }

Compiler output:
a.cc: In function 'int main()':
a.cc:104:7: error: return-statement with no value, in function returning 'int' [-fpermissive]
  104 |       return ;
      |       ^~~~~~
Language: C

#include <iostream>
#include <stringstream>

using namespace std;

int main(){

  int N,M;
  string buf;
  readline(buf,cin);
  {
  sstream line(buf) >> N >> M;
  }
  cout << N << " " << M << endl;
}


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

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> dist(n,inf);
    vector<int> prev(n,-1);
    vector<int> list[n];
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--, b--;
        list[a].push_back(b);
        list[b].push_back(a);
    }
    dist[0] = 0;
    queue<int> q;
    q.push(0);
    while(!q.empty()){
        int v = q.front(); q.pop;
        for(int u:list[v]){
            if(dist[u] != inf) continue;
            dist[u] = dist[v]+1;
            prev[u] = v;
            q.push(u);
        }
    }
    cout << "Yes" << endl;
    for(int i=0; i<n; i++){
        cout << prev[i]+1 << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:30: error: invalid use of non-static member function 'void std::queue<_Tp, _Sequence>::pop() [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >]'
   24 |         int v = q.front(); q.pop;
      |                            ~~^~~
In file included from /usr/include/c++/14/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_queue.h:316:7: note: declared here
  316 |       pop()
      |       ^~~
Language: Java


import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		int m=sc.nextInt();
		
		ArrayList<Integer>[] list=new ArrayList[n+1];
		for(int i=0;i<n+1;i++){
			list[i]=new ArrayList();
		}
		
		for(int i=0;i<m;i++){
			int a=sc.nextInt()-1;
			int b=sc.nextInt()-1;
			list[a].add(b);
			list[b].add(a);
		}
		

		int[] count=new int[n];
		int[] ans=new int[n];
		
		Arrays.fill(dist,-1);
		
		Deque<Integer> q = new ArrayDeque<>();
		q.add(0);
		dist[0]=0;
		
		while(!q.isEmpty()){
			int i=q.poll();
			for (int j = 0; j < list[i].size(); j++) {
                int v = list[i].get(j);
                if(count[v]<0){
                	count[v]=count[i]+1;
                	ans[v]=i;
                	q.add(v);
        		}
			}
		}
		
		System.out.println("Yes");
		
		
		for(int i=1;i<n;i++){
			System.out.println(ans[i]+1);
		}
	}
}

Compiler output:
Main.java:26: error: cannot find symbol
		Arrays.fill(dist,-1);
		            ^
  symbol:   variable dist
  location: class Main
Main.java:30: error: cannot find symbol
		dist[0]=0;
		^
  symbol:   variable dist
  location: class Main
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
Language: C++

#include<iostream>
using namespace std;
const int INF=1001001001;
int main(){
  int n,m;
  cin>>n>>m;
  int a,b;
  vector<int> to[100005];
  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(itn i=0;i<n;i++){
    if(i==0) continue;
    int ans=pre[i];
    ans++;
    cout<<ans<<endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: 'vector' was not declared in this scope
    8 |   vector<int> to[100005];
      |   ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include<iostream>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:8:10: error: expected primary-expression before 'int'
    8 |   vector<int> to[100005];
      |          ^~~
a.cc:13:5: error: 'to' was not declared in this scope; did you mean 'tm'?
   13 |     to[a].push_back(b);
      |     ^~
      |     tm
a.cc:16:3: error: 'queue' was not declared in this scope
   16 |   queue<int> q;
      |   ^~~~~
a.cc:2:1: note: 'std::queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
    1 | #include<iostream>
  +++ |+#include <queue>
    2 | using namespace std;
a.cc:16:9: error: expected primary-expression before 'int'
   16 |   queue<int> q;
      |         ^~~
a.cc:17:10: error: expected primary-expression before 'int'
   17 |   vector<int> dist(n,INF);
      |          ^~~
a.cc:18:10: error: expected primary-expression before 'int'
   18 |   vector<int> pre(n,-1);
      |          ^~~
a.cc:19:3: error: 'dist' was not declared in this scope
   19 |   dist[0]=0;
      |   ^~~~
a.cc:20:3: error: 'q' was not declared in this scope
   20 |   q.push(0);
      |   ^
a.cc:21:20: error: expected primary-expression before ')' token
   21 |   while(!q.empty())){
      |                    ^
a.cc:32:7: error: 'itn' was not declared in this scope; did you mean 'int'?
   32 |   for(itn i=0;i<n;i++){
      |       ^~~
      |       int
a.cc:32:15: error: 'i' was not declared in this scope
   32 |   for(itn i=0;i<n;i++){
      |               ^
a.cc:34:13: error: 'pre' was not declared in this scope
   34 |     int ans=pre[i];
      |             ^~~
Language: C++

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

const int INF = 1001001001;
#define PRINT(s) cout << s << endl;

typedef struct _node {
    int number;
    int step;
    int sign;
    vector<_node *> nodeList;
} node;

vector<node> makeTree(int numberOfRooms, vector<int>A, vector<int>B) {
    vector<node> nodeList(numberOfRooms);
    for (int i = 0; i < numberOfRooms; i++) {
        nodeList.at(i) = { i + 1, INF, -1,vector<node *>(0) };
    }
    for (int i = 0; i < (int)nodeList.size(); i++) {
        for (int j = 0; j < (int)A.size(); j++) {
            if (nodeList.at(i).number == A.at(j)) {
                nodeList.at(i).nodeList.push_back(&nodeList.at((B.at(j) - 1)));
            }
            if (nodeList.at(i).number == B.at(j)) {
                nodeList.at(i).nodeList.push_back(&nodeList.at((A.at(j) - 1)));
            }
        }
    }
    return nodeList;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> A, B;
    A = B = vector<int>(m);
    for (int i = 0; i < m; i ++) {
        cin >> A.at(i) >> B.at(i);
    }
    vector<node> nodeList = makeTree(n, A, B);
    nodeList.at(0).step = 0;
    queue<int> queue;
    queue.push(0);
    node root;
    while (!queue.empty()) {
        int index = queue.front();
        queue.pop();
        root = nodeList.at(index);
        for (int i = 0; i < (int)root.nodeList.size(); i ++) {
            if (root.nodeList.at(i) -> step == INF) {
                root.nodeList.at(i) -> step = root.step + 1;
                root.nodeList.at(i) -> sign = root.number;
                queue.push(root.nodeList.at(i) -> number - 1);
            }
        }
    }
    
    cout << "YES" << endl;
    for (int i = 1; I < (int)nodeList.size(); i++) {
        cout << nodeList.at(i).sign << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:59:21: error: 'I' was not declared in this scope
   59 |     for (int i = 1; I < (int)nodeList.size(); i++) {
      |                     ^
Language: C

#include <bits/stdc++.h>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    // 頂点数と辺数
    int N, M; 
    cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

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

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

    // BFS 開始 (キューが空になるまで探索を行う)
    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;
            que.push(nv);
         
          vector<int> dist(N-1,0);
          
          // 結果出力 (各頂点の頂点 0 からの距離を見る)
    for (int v = 0; v < N; ++v) cout << v << ": " << dist[v] << endl;
    }
}

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

#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main(){
  int n,m ;
  cin >>n>> m ;
  graph g(n) ;//nは頂点数
  rep(i,m){
  int a,b ;
  cin>> a>> b;
  a--;b--;
  g[a].pb(b) ;
  g[b].pb(a) ;
  }
 //ここからbfs
 
 vector<int> dist(n,-1) ;// n全て-1
 queue<int> q ;
  dist[0] =0 ;//通った頂点０との距離を記録
  q.push(0) ;
  //すたーと
  while(!q.empty()){ //qが空になるまで
  int v=q.front() ;
      q.pop() ;//出して記録してすぐ消す

      for(int u:g[v]){
        if(dist[u]!=-1) {continue;//無視
        dist[u]=v;//親を記録
        
        q.push(u) ;}
  }
   //全部の距離がdistに記録済み

    cout <<"Yes"<<endl;
    rep(i,n) cout<<dist[i]<<endl ;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:2: error: expected '}' at end of input
   49 | }
      |  ^
a.cc:16:11: note: to match this '{'
   16 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main(){
  int n,m ;
  cin >>n>> m ;
  graph g(n) ;//nは頂点数
  rep(i,m){
  int a,b ;
  cin>> a>> b;
  a--;b--;
  g[a].pb(b) ;
  g[b].pb(a) ;
  }
 //ここからbfs
 
 vector<int> dist(n,-1) ; n全て-1
 queue<int> q ;
  dist[0] =0 ;通った頂点０との距離を記録
  q.push(0) ;
  すたーと
  while(!q.empty()){ //qが空になるまで
  int v=que.front() ;
      que.pop() ;出して記録してすぐ消す

      for(int u:g[v]){
        if(dist[u]!=-1) continue;//無視
        dist[u]=v;//親を記録
        
        queue.push(u) ;
　　　　　
      }
  }
   //全部の距離がdistに記録済み

    cout <<"Yes"<<endl;
    rep(i,n) cout<<dist[i]<<endl ;
    return 0;
}

Compiler output:
a.cc:43:1: error: extended character 　 is not valid in an identifier
   43 | 　　　　　
      | ^
a.cc:43:1: error: extended character 　 is not valid in an identifier
a.cc:43:1: error: extended character 　 is not valid in an identifier
a.cc:43:1: error: extended character 　 is not valid in an identifier
a.cc:43:1: error: extended character 　 is not valid in an identifier
a.cc: In function 'int main()':
a.cc:29:27: error: 'n\U00005168\U00003066' was not declared in this scope
   29 |  vector<int> dist(n,-1) ; n全て-1
      |                           ^~~~~
a.cc:31:15: error: '\U0000901a\U00003063\U0000305f\U00009802\U000070b9\U0000ff10\U00003068\U0000306e\U00008ddd\U000096e2\U00003092\U00008a18\U00009332' was not declared in this scope
   31 |   dist[0] =0 ;通った頂点０との距離を記録
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:33:3: error: '\U00003059\U0000305f\U000030fc\U00003068' was not declared in this scope
   33 |   すたーと
      |   ^~~~~~~~
Language: C

#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main(){
  int n,m ;
  cin >>n>> m ;
  graph g(n) ;//nは頂点数
  rep(i,m){
  int a,b ;
  cin>> a>> b;
  a--;b--;
  g[a].pb(b) ;
  g[b].pb(a) ;
  }
 //ここからbfs
 
 vector<int> dist(n,-1) ; n全て-1
 queue<int> q ;
  dist[0] =0 ;通った頂点０との距離を記録
  q.push(0) ;
  すたーと
  while(!q.empty()){ //qが空になるまで
  int v=que.front() ;
      que.pop() ;出して記録してすぐ消す

      for(int u:g[v]){
        if(dist[u]!=-1) continue;//無視
        dist[u]=v;//親を記録
        
        queue.push(u) ;
　　　　　
      }
  }
   //全部の距離がdistに記録済み

    cout <<"Yes"<<endl;
    rep(i,n) cout<<dist[i]<<endl ;
    return 0;
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: Java

import java.io.*;
import java.util.*;

//AtCoder D
public class DoubleDots
{
    public static ArrayList<ArrayList<Integer>> adj;
    public static int[] par;
    public static void main(String args[]) throws IOException
    {
        IO io=new IO(System.in, System.out);
        int n=io.i(), m=io.i();

        par=new int[n+1];
        adj=new ArrayList<>();
        for(int i=0;i<=n;i++)
        {
            adj.add(new ArrayList<>());
        }

        for(int i=1;i<=m;i++)
        {
            int u=io.i(), v=io.i();
            adj.get(u).add(v);
            adj.get(v).add(u);
        }

        LinkedList<Integer> q=new LinkedList<Integer>();
        Boolean[] seen=new Boolean[n+1];
        Arrays.fill(seen, false);
        q.add(1);
        seen[0]=seen[1]=true;

        while(!q.isEmpty())
        {
            int u=q.poll();

            for(int v : adj.get(u)) if(!seen[v])
            {
                par[v]=u;
                q.add(v);
                seen[v]=true;
            }
        }

        if(Arrays.stream(seen).anyMatch(b -> !b))
        {
            io.pln("No");
        }
        else
        {
            io.pln("Yes");
            for(int i=2;i<=n;i++)
            {
                io.pln(par[i]);
            }
        }
        io.flush();
    }

    public static class IO
    {
        private BufferedReader br;
        private StringTokenizer tok;
        private PrintWriter pw;

        IO(InputStream inputStream, OutputStream outputStream)
        {
            br=new BufferedReader(new InputStreamReader(inputStream));
            pw=new PrintWriter(new OutputStreamWriter(outputStream));
        }

        public String s()
        {
            while(tok == null || !tok.hasMoreElements())
            {
                try
                {
                    tok=new StringTokenizer(br.readLine());
                }
                catch(IOException exc)
                {
                    exc.printStackTrace();
                }
            }
            return tok.nextToken();
        }

        public int i()
        {
            return Integer.parseInt(s());
        }

        public long l()
        {
            return Long.parseLong(s());
        }

        @SuppressWarnings("unchecked") public<T> void p(T... out)
        {
            for(T e : out) pw.print(e);
        }

        @SuppressWarnings("unchecked") public<T> void pln(T... out)
        {
            for(T e : out) pw.println(e);
        }

        public void pln()
        {
            pw.println();
        }

        public void flush()
        {
            pw.flush();
        }
    }    
}

Compiler output:
Main.java:5: error: class DoubleDots is public, should be declared in a file named DoubleDots.java
public class DoubleDots
       ^
1 error
Language: Java

import java.io.*;
import java.util.*;

//AtCoder D
public class DoubleDots
{
    public static ArrayList<ArrayList<Integer>> adj;
    public static int[] par;
    public static void main(String args[]) throws IOException
    {
        IO io=new IO(System.in, System.out);
        int n=io.i(), m=io.i();

        par=new int[n+1];
        adj=new ArrayList<>();
        for(int i=0;i<=n;i++)
        {
            adj.add(new ArrayList<>());
        }

        for(int i=1;i<=m;i++)
        {
            int u=io.i(), v=io.i();
            adj.get(u).add(v);
            adj.get(v).add(u);
        }

        var q=new LinkedList<Integer>();
        Boolean[] seen=new Boolean[n+1];
        Arrays.fill(seen, false);
        q.add(1);
        seen[0]=seen[1]=true;

        while(!q.isEmpty())
        {
            int u=q.poll();

            for(int v : adj.get(u)) if(!seen[v])
            {
                par[v]=u;
                q.add(v);
                seen[v]=true;
            }
        }

        if(Arrays.stream(seen).anyMatch(b -> !b))
        {
            io.pln("No");
        }
        else
        {
            io.pln("Yes");
            for(int i=2;i<=n;i++)
            {
                io.pln(par[i]);
            }
        }
        io.flush();
    }

    public static class IO
    {
        private BufferedReader br;
        private StringTokenizer tok;
        private PrintWriter pw;

        IO(InputStream inputStream, OutputStream outputStream)
        {
            br=new BufferedReader(new InputStreamReader(inputStream));
            pw=new PrintWriter(new OutputStreamWriter(outputStream));
        }

        public String s()
        {
            while(tok == null || !tok.hasMoreElements())
            {
                try
                {
                    tok=new StringTokenizer(br.readLine());
                }
                catch(IOException exc)
                {
                    exc.printStackTrace();
                }
            }
            return tok.nextToken();
        }

        public int i()
        {
            return Integer.parseInt(s());
        }

        public long l()
        {
            return Long.parseLong(s());
        }

        @SuppressWarnings("unchecked") public<T> void p(T... out)
        {
            for(T e : out) pw.print(e);
        }

        @SuppressWarnings("unchecked") public<T> void pln(T... out)
        {
            for(T e : out) pw.println(e);
        }

        public void pln()
        {
            pw.println();
        }

        public void flush()
        {
            pw.flush();
        }
    }    
}

Compiler output:
Main.java:5: error: class DoubleDots is public, should be declared in a file named DoubleDots.java
public class DoubleDots
       ^
1 error
Language: C

#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
const string YES = "Yes";

void bfs(vector<vll> &G, vll &checked, ll s){
    fill(ALL(checked), -1);
    checked[s] = 0;
    queue<ll> que;
    que.push(s);
    while(!que.empty()){
        ll u = que.front(); que.pop();
        for(ll v: G[u]){
            if(checked[v] >= 0) continue;
            checked[v] = u;
            que.push(v);
        }
    }
}

void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B){
    vector<vll> G(N);
    REP(i, M){
        G[A[i]].push_back(B[i]);
        G[B[i]].push_back(A[i]);
    }
    vll checked(N, -1);
    bfs(G, checked, 0);
    cout<<"Yes"<<endl;
    for(ll i = 1; i < N; i++){
        cout<<checked[i]+1<<endl;
    }
}
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
        A[i]--; B[i] --;
    }
    solve(N, M, std::move(A), std::move(B));
    return 0;
}


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

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using 11 = 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;
            pre[u] = v;
            q.push(u);
        }
    }

    cout << "Yes" << endl;
    rep(i,n) {
        if (i == 0) continue;
        int ans = pre[i];
        ++ans;
        cout << ans << endl;
    }
    return 0;
}


Compiler output:
a.cc:4:7: error: expected nested-name-specifier before numeric constant
    4 | using 11 = long long;
      |       ^~
Language: C++

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

class Node {
public:
    Node::Node(int iId, int iRoot) {
        id = iId;
        root = iRoot;
    }
    int id;
    int root;
};

int main(void) 
{
    long long N, M;
    std::vector<int> A,B;
    cin >> N >> M;
    A.resize(M);
    B.resize(M);
    std::vector<std::set<int>> connected(200001);
    for (int i = 0; i < M; i++)
    {
        cin >> A[i] >> B[i];
        connected[A[i]].insert(B[i]);
        connected[B[i]].insert(A[i]);
    }

    for (int i = 2; i <= N; i++)
    {
        std::queue<Node> q;
        std::vector<bool> isFound(200001,false);
        for (auto x : connected[i])
        {
            Node node = Node(x, x);
            q.push(node);
        }
           
        bool is1Found = false;
        int ans = 0;
        while (1)
        {
            if (q.empty()) break;
            Node pushed = q.front();
            if (1 == pushed.id)
            {
                ans = pushed.root;
                is1Found = true;
                break;
            }
            q.pop();
            if (true == isFound[pushed.id]) continue;
            isFound[i] = true;
            for (auto x : connected[pushed.id])
            {
                Node node = Node(x, pushed.root);
                q.push(node);
            }
        }

        if (is1Found) 
        {
            if (i == 2)
            {
                std::cout << "Yes" << std::endl;
            }
            std::cout << ans << std::endl;
        }
        else
        {
            std::cout << "Np" << std::endl;
        }
    }

    return 0;
}

Compiler output:
a.cc:9:5: error: extra qualification 'Node::' on member 'Node' [-fpermissive]
    9 |     Node::Node(int iId, int iRoot) {
      |     ^~~~
Language: C++

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

int main(){
  int n, m, i;
  vector<int> x[100005]
  cin >> n >> m;
  for(i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    x[a].push_back(b);
    x[b].push_back(a);
  }
  
  vector<int> t(n, 0);
  t[0] = 1;
  queue<int> q;
  vector<int> ans(n);
  vector<int> pre(n);
  ans[0] = 0;
  pre[0] = 0;
  int u = x[0].size();
  for(i = 0; i < u; i++){
    pre[x[0][i]] = 0;
  }
  q.push(0);
  while(q.empty() == 0){
    int p = q.front();
    q.pop();
    t[p] = 1;
    ans[p] = pre[p];
    int v = x[p].size();
    for(i = 0; i < u; i++){
      q.push(x[p][i]);
      pre[x[p][i]] = p;
    }
  }
  cout << "Yes" << endl;
  for(i = 1; i < n; i++){
    cout << ans[i]+1 << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: expected initializer before 'cin'
    7 |   cin >> n >> m;
      |   ^~~
a.cc:12:5: error: 'x' was not declared in this scope
   12 |     x[a].push_back(b);
      |     ^
a.cc:23:11: error: 'x' was not declared in this scope
   23 |   int u = x[0].size();
      |           ^
Language: C++

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

int n, m;
vector<int> x[100005];

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

int main(){
  int i;
  cin >> n >> m;
  vector<vector<int>> x(n, vector<int>(n, 0));
  vector<int> dat(n, 0);
  for(i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    x[a].push_back(b);
    x[b].push_back(a);
  }
  
  vector<int> t(n, 0);
  t[0] = 1;
  queue<int> q;
  vector<int> ans(n);
  vector<int> pre(n);
  ans[0] = 0;
  pre[0] = 0;
  int u = x[0].size();
  for(i = 0; i < u; i++){
    pre[x[0][i]] = 0;
  }
  q.push(0);
  while(q.empty() == 0){
    int p = q.front();
    q.pop();
    t[p] = 1;
    ans[p] = pre[p];
    int v = x[p].size();
    for(i = 0; i < u; i++){
      q.push(x[p][i]);
      pre[x[p][i]] = p;
    }
  }
  cout << "Yes" << endl;
  for(i = 1; i < n; i++){
    cout << ans[i]+1 << endl;
  }
}
    
  
  
  
  pei(1, x, dat);
  for(i = 1; i < n; i++){
    if(dat[i] == 0){
      break;
    }
  }
  if(i < n){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
    for(i = 1; i < n; i++){
      cout << dat[i] << endl;
    }
  }
  return 0;
}


Compiler output:
a.cc:74:6: error: expected constructor, destructor, or type conversion before '(' token
   74 |   pei(1, x, dat);
      |      ^
a.cc:75:3: error: expected unqualified-id before 'for'
   75 |   for(i = 1; i < n; i++){
      |   ^~~
a.cc:75:14: error: 'i' does not name a type
   75 |   for(i = 1; i < n; i++){
      |              ^
a.cc:75:21: error: 'i' does not name a type
   75 |   for(i = 1; i < n; i++){
      |                     ^
a.cc:80:3: error: expected unqualified-id before 'if'
   80 |   if(i < n){
      |   ^~
a.cc:82:4: error: expected unqualified-id before 'else'
   82 |   }else{
      |    ^~~~
a.cc:88:3: error: expected unqualified-id before 'return'
   88 |   return 0;
      |   ^~~~~~
a.cc:89:1: error: expected declaration before '}' token
   89 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline int read(){
  int x=0,f=1;
  char ch=getchar();
  while(ch<'0'||ch>'9'){
    if(ch=='-')
      f=-1;
    ch=getchar();
  }
  while(ch >= '0' && ch <= '9')
    x=x*10+(ch^48);
    ch=getchar();
  return x*f;
}
const int N=4e5+5;
int n,m,now,v[N],a[N],nex[N],pre[N],head[N];
void add(int x,int y){
  nex[++now]=head[x];
  head[x]=now;
  v[now]=y;
}
queue<int> que;
int main(){
  n=read();
  m=read();
  for(int i=1;i<=m;i++){
    int x=read();
    y=read();
    add(x,y);
    add(y,x);
  }
  que.push(1);
  a[1]=1;
  while(!que.empty()){
    int x=que.front();
    que.pop();
    for(int i=head[x];i;i=nex[i])
      if(!a[v[i]]){
      a[v[i]]=1,que.push(v[i]);
      pre[v[i]]=x;
      }
  }
  for(int i=1;i<=n;i++)
    if(!a[i]){
      cout<<"No";
      return 0;
  }
  cout<<"Yes"<<endl;
  for(int i=2;i<=n;i++)
    cout<<pre[i];
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:5: error: 'y' was not declared in this scope
   30 |     y=read();
      |     ^
Language: C++

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+34;
int bio[N];
vector<int> g[N];

void bfs(int p) {
  queue<int> q;
  q.push(p);
  bio[p] = 69;
  while (!q.empty()) {
    int p = q.top(); q.pop();
    for (int v: g[p]) {
      if (bio[v]) continue;
      q.push(v);
      bio[v] = p;
    }
  }
}

void solve() {
  int n, m; scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int u, v; scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  bfs(1);
  for (int i = 1; i <= n; ++i) {
    if (!bio[i]) {
      puts("No");
      return;
    }
  }
  puts("Yes");
  for (int i = 2; i <= n; ++i) {
    printf("%d\n", bio[i]);
  }
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Compiler output:
a.cc: In function 'void bfs(int)':
a.cc:24:15: error: 'class std::queue<int>' has no member named 'top'; did you mean 'pop'?
   24 |     int p = q.top(); q.pop();
      |               ^~~
      |               pop
Language: C++

#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb push_back;
#define sp " ";
void vout(vector<int> v){
    for(unsigned int i=1;i<v.size();i++)
    cout<<v.at(i)+1<<endl;
}
int main(){
    int n,m;
    cin>>n>>m;
    vvi edge(n,vi(n));
    vi ans(n,-1);
    rep(i,m){
        int s,t;
        cin>>s>>t;
        s--;
        t--;
        edge.at(s).push_back(t);
        edge.at(t).push_back(s);
    }
    queue<int> q;
    q.push(0);
    while(!q.empty()){
       int k=q.front();
       q.pop();
       for(int j:a.at(k)){
           if(ans.at(j)==-1){
               ans.at(j)=k;
               q.push(j);
           }
       }
    }
  cout<<"Yes"<<endl;
    vout(ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:18: error: 'a' was not declared in this scope
   35 |        for(int j:a.at(k)){
      |                  ^
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<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 y=g[u][i];
            if(visit[y]==0)
            {
                visit[y]=1;
                cost[y]=cost[u]+1;
                if(cost[y]!=0)
                    flag=true;
                q.push(y);
            }
        }
    }

}
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:12: note:                 'std::vector<int> visit'
    7 | vector<int>visit(200005,0);
      |            ^~~~~
a.cc:23:16: error: reference to 'visit' is ambiguous
   23 |             if(visit[y]==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:12: note:                 'std::vector<int> visit'
    7 | vector<int>visit(200005,0);
      |            ^~~~~
a.cc:25:17: error: reference to 'visit' is ambiguous
   25 |                 visit[y]=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:12: note:                 'std::vector<int> visit'
    7 | vector<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];
vector<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 y=g[u][i];
            if(visit[y]==false)
            {
                visit[y]=true;
                cost[y]=cost[u]+1;
                if(cost[y]!=0)
                    flag=true;
                q.push(y);
            }
        }
    }

}
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,false);
      |             ^~~~~
a.cc:23:16: error: reference to 'visit' is ambiguous
   23 |             if(visit[y]==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,false);
      |             ^~~~~
a.cc:25:17: error: reference to 'visit' is ambiguous
   25 |                 visit[y]=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,false);
      |             ^~~~~