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

int adj[101][101];
int d[101];
int used[101];
void push(int x){
  queue[head]=x;
  head++;
}
int pop(){
  int x;
  x=queue[tail];
  tail++;
  return x;
}
void bfs(int x){
  int i;
  int v;
  push(x);
  used[x]=1;
  while(head!=tail){
    v=pop();
    for(i=1;i<=n;i++){
      if(adj[v][i]==1 && used[i]==0){
    push(i);
    d[i]=d[v]+1;
    used[i]=1;
      }
    }
  }
}
int main(){
  int i,j;
  int u,k,v;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
    adj[u][v]=1;
    }
  }
 
  for(i=1;i<=n;i++)d[i]=0;
  bfs(1);
  for(i=2;i<=n;i++){
    if(d[i]==0)d[i]=-1;
  }
  for(i=1;i<=n;i++)printf("%d %d\n",i,d[i]);
  return 0;
}

Compiler output:
main.c: In function 'push':
main.c:5:3: error: 'queue' undeclared (first use in this function)
    5 |   queue[head]=x;
      |   ^~~~~
main.c:5:3: note: each undeclared identifier is reported only once for each function it appears in
main.c:5:9: error: 'head' undeclared (first use in this function)
    5 |   queue[head]=x;
      |         ^~~~
main.c: In function 'pop':
main.c:10:5: error: 'queue' undeclared (first use in this function)
   10 |   x=queue[tail];
      |     ^~~~~
main.c:10:11: error: 'tail' undeclared (first use in this function)
   10 |   x=queue[tail];
      |           ^~~~
main.c: In function 'bfs':
main.c:19:9: error: 'head' undeclared (first use in this function)
   19 |   while(head!=tail){
      |         ^~~~
main.c:19:15: error: 'tail' undeclared (first use in this function)
   19 |   while(head!=tail){
      |               ^~~~
main.c:21:16: error: 'n' undeclared (first use in this function)
   21 |     for(i=1;i<=n;i++){
      |                ^
main.c: In function 'main':
main.c:33:3: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   33 |   scanf("%d",&n);
      |   ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | int adj[101][101];
main.c:33:3: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   33 |   scanf("%d",&n);
      |   ^~~~~
main.c:33:3: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:33:15: error: 'n' undeclared (first use in this function)
   33 |   scanf("%d",&n);
      |               ^
main.c:47:20: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   47 |   for(i=1;i<=n;i++)printf("%d %d\n",i,d[i]);
      |                    ^~~~~~
main.c:47:20: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:47:20: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:47:20: note: include '<stdio.h>' or provide a declaration of 'printf'
Language: C

#include <stdio.h>
#define SIZE 100
#define INF 100000000

typedef struct pp{  //queue???????£?
  char name[SIZE];
  int t;
}P_t;

P_t q[SIZE];
int head,tail,n,M[SIZE][SIZE];
int d[SIZE]; //?????¢??§????¨??????¶?????????????????????

void enqueue(P_t x){
  q[tail]=x;
  tail=(tail+1)%SIZE;
}

P_t dequeue(){
  P_t x=q[head];
  head=(head+1)%SIZE;
  return x;
}

int isEmpty(){
  return head==tail;
}

int min(int x, int y){
  if(x>y) return y;
  else return x;
}

void bfs(int s){
  int i,j;
  int u,k,v;
  P_t deq;

  enqueue(s); //?????\????????¶?????????(push)
  for(i=0;i<n;i++){
    d[i]=INF;
  }
  d[s]=0;

  while(!isEmpty()){ //?????\????????????????????§?????????
    u=head;
    deq=dequeue();
    for(v=0;v<n;v++){
    if(M[u][v]==0) continue;
    if(d[v]!=INF) continue;
    d[v]=d[u]+1;
    enqueue(v);
  }
}
for(i=0;i<n;i++){
  printf("%d ",i+1);
  if(d[i]==INF) printf("-1");
  else printf("%d",d[i]);
  }
}

int main(){
  int u,k,v;
  int i,j;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
}
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  bfs(0);

  return 0;
}

Compiler output:
main.c: In function 'bfs':
main.c:39:11: error: incompatible type for argument 1 of 'enqueue'
   39 |   enqueue(s); //?????\????????¶?????????(push)
      |           ^
      |           |
      |           int
main.c:14:18: note: expected 'P_t' {aka 'struct pp'} but argument is of type 'int'
   14 | void enqueue(P_t x){
      |              ~~~~^
main.c:52:13: error: incompatible type for argument 1 of 'enqueue'
   52 |     enqueue(v);
      |             ^
      |             |
      |             int
main.c:14:18: note: expected 'P_t' {aka 'struct pp'} but argument is of type 'int'
   14 | void enqueue(P_t x){
      |              ~~~~^
Language: C

#include <stdio.h>
#define SIZE 100
#define INF 100000000

int q[SIZE];
int head,tail,n,M[SIZE][SIZE];
int d[SIZE]; //?????¢??§????¨??????¶?????????????????????

void enqueue(int x){
  q[tail]=x;
  tail=(tail+1)%SIZE;
}

int dequeue(){
  int x=q[head];
  head=(head+1)%SIZE;
  return x;
}

int isEmpty(){
  return head==tail;
}

int min(int x, int y){
  if(x>y) return y;
  else return x;
}

void bfs(int s){
  int i,j;
  int u,k,v;
  P_t deq;

  enqueue(s); //?????\????????¶?????????(push)
  for(i=0;i<n;i++){
    d[i]=INF;
  }
  d[s]=0;

  while(!isEmpty()){ //?????\????????????????????§?????????
    u=head;
    deq=dequeue();
    for(v=0;v<n;v++){
    if(M[u][v]==0) continue;
    if(d[v]!=INF) continue;
    d[v]=d[u]+1;
    enqueue(v);
  }
}
for(i=0;i<n;i++){
  printf("%d ",i+1);
  if(d[i]==INF) printf("-1");
  else printf("%d",d[i]);
  }
}

int main(){
  int u,k,v;
  int i,j;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
}
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  bfs(0);

  return 0;
}

Compiler output:
main.c: In function 'bfs':
main.c:32:3: error: unknown type name 'P_t'
   32 |   P_t deq;
      |   ^~~
Language: C

#include<iostream>
#include<queue>
using namespace std;
static const int INFTY=(1<<21);
static const int N=100;
int n,M[N][N],d[N];

void bfs(int s){
  queue<int> q;
  int i,u,v;
  q.push(s);
  for(i=0;i<n;i++)d[i]=INFTY;
  d[s]=0;
  while(!q.empty()){
    u=q.front();
    q.pop();
    for(v=0;v<n;v++){
      if(M[u][v]==0)continue;
      if(d[v]!=INFTY)continue;
      d[v]=d[u]+1;
      q.push(v);
    }
  }
  for(i=0;i<n;i++){
    cout<< i+1<<" "<<( (d[i]==INFTY)?(-1):d[i])<<endl;
  }
}

int main(){
  int u,k,v,i,j;
  
  cin>>n;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++)M[i][j]=0;
  }

  for(i=0;i<n;i++){
    cin>>u>>k;
    u--;
    for(j=0;j<k;j++){
      cin>>v;
      v--;
      M[u][v]=1;
    }
  }
  bfs(0);

  return 0;
}

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

#include <iostream>
#include <queue>
using namespace std;
static const int N=100;
static const int INFTY=(1<<21);
int n,M[N][N];
int d[N];//通?距?管理??状?(color)
void bfs(int s){
    queue<int> q;//使用?准?中的queue
    q.push(s);
    for(int i=0;i<n;i++)d[i]=INFTY;
    d[s]=0;
    int u;
    while(!q.empty()){
        u=q.front();q.pop();
        for(int v=0;v<n;v++){
            if(M[u][v]==0)continue;
            if(d[v]!=INFTY)continue;
            d[v]=d[u]+1;
            q.push(v);
        }
    }
    for(int i=0;i<n;i++){
        cout<<i+1<<" "<<((d[i]==INFTY)?(-1):d[i])<<endl;
    } 
}
int main(){
    int u,k,v;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)M[i][j]=0;
    }
    for(int i=0;i<n;i++){
        cin>>u>>k;
        u--;
        for(int j=0;j<k;j++){
            cin>>v;
            v--;
            M[u][v]=1;
        }
    }
    bfs(0);
    return 0;
} 

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

#include <stdio.h>

int i,n,v,M[101][101];

void bfs(int s)
{
  queue<int> q;
  q.push(s);
  int u,d[101];
  
  for(i=0;i<n;i++){
    color[i]=0;
    d[i]=(1<<21);
  }
  color[s]=1;
  d[s]=0;
  while(!q.empty()){
    u=q.front();
    q.pop();
    for(v=;v<n;v++){
      if(M[u][v]>0&&color[v]==0){
        color[v]=1;
        d[v]=d[u];1;
        q.push(v);
    }
    color[u]=2;
  }
  fot(i=0;i<n;i++){
    printf("%d %d\n",i+1,(d[i]==(1<<21)?(-1):d[i]));
  }
}

int main
{
  int j,k,u;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    u--;
    for(j=0;j<n;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  bfs(0);
  
  return 0;
}

Compiler output:
main.c: In function 'bfs':
main.c:7:3: error: 'queue' undeclared (first use in this function)
    7 |   queue<int> q;
      |   ^~~~~
main.c:7:3: note: each undeclared identifier is reported only once for each function it appears in
main.c:7:9: error: expected expression before 'int'
    7 |   queue<int> q;
      |         ^~~
main.c:8:3: error: 'q' undeclared (first use in this function)
    8 |   q.push(s);
      |   ^
main.c:12:5: error: 'color' undeclared (first use in this function)
   12 |     color[i]=0;
      |     ^~~~~
main.c:20:11: error: expected expression before ';' token
   20 |     for(v=;v<n;v++){
      |           ^
main.c:28:3: error: implicit declaration of function 'fot' [-Wimplicit-function-declaration]
   28 |   fot(i=0;i<n;i++){
      |   ^~~
main.c:28:10: error: expected ')' before ';' token
   28 |   fot(i=0;i<n;i++){
      |      ~   ^
      |          )
main.c:28:19: error: expected ';' before '{' token
   28 |   fot(i=0;i<n;i++){
      |                   ^
      |                   ;
main.c:34:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
   34 | {
      | ^
main.c:54:10: error: 'return' with a value, in function returning void [-Wreturn-mismatch]
   54 |   return 0;
      |          ^
main.c:5:6: note: declared here
    5 | void bfs(int s)
      |      ^~~
main.c:55:1: error: expected declaration or statement at end of input
   55 | }
      | ^
Language: C

#include <stdio.h>

int i,n,v,M[101][101];

void bfs(int s)
{
  queue<int> q;
  q.push(s);
  int u,d[101];
  
  for(i=0;i<n;i++){
    color[i]=0;
    d[i]=(1<<21);
  }
  color[s]=1;
  d[s]=0;
  while(!q.empty()){
    u=q.front();
    q.pop();
    for(v=0;v<n;v++){
      if(M[u][v]>0&&color[v]==0){
        color[v]=1;
        d[v]=d[u];1;
        q.push(v);
    }
    color[u]=2;
  }
  fot(i=0;i<n;i++){
    printf("%d %d\n",i+1,(d[i]==(1<<21)?(-1):d[i]));
  }
}

int main
{
  int j,k,u;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    u--;
    for(j=0;j<n;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  bfs(0);
  
  return 0;
}

Compiler output:
main.c: In function 'bfs':
main.c:7:3: error: 'queue' undeclared (first use in this function)
    7 |   queue<int> q;
      |   ^~~~~
main.c:7:3: note: each undeclared identifier is reported only once for each function it appears in
main.c:7:9: error: expected expression before 'int'
    7 |   queue<int> q;
      |         ^~~
main.c:8:3: error: 'q' undeclared (first use in this function)
    8 |   q.push(s);
      |   ^
main.c:12:5: error: 'color' undeclared (first use in this function)
   12 |     color[i]=0;
      |     ^~~~~
main.c:28:3: error: implicit declaration of function 'fot' [-Wimplicit-function-declaration]
   28 |   fot(i=0;i<n;i++){
      |   ^~~
main.c:28:10: error: expected ')' before ';' token
   28 |   fot(i=0;i<n;i++){
      |      ~   ^
      |          )
main.c:28:19: error: expected ';' before '{' token
   28 |   fot(i=0;i<n;i++){
      |                   ^
      |                   ;
main.c:34:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
   34 | {
      | ^
main.c:54:10: error: 'return' with a value, in function returning void [-Wreturn-mismatch]
   54 |   return 0;
      |          ^
main.c:5:6: note: declared here
    5 | void bfs(int s)
      |      ^~~
main.c:55:1: error: expected declaration or statement at end of input
   55 | }
      | ^
Language: C

#include <stdio.h>

int i,n,v,M[101][101];

void bfs(int s)
{
  queue<int> q;
  q.push(s);
  int u,d[101,color[101];
  
  for(i=0;i<n;i++){
    color[i]=0;
    d[i]=(1<<21);
  }
  color[s]=1;
  d[s]=0;
  while(!q.empty()){
    u=q.front();
    q.pop();
    for(v=0;v<n;v++){
      if(M[u][v]>0&&color[v]==0){
        color[v]=1;
        d[v]=d[u];1;
        q.push(v);
    }
    color[u]=2;
  }
  fot(i=0;i<n;i++){
    printf("%d %d\n",i+1,(d[i]==(1<<21)?(-1):d[i]));
  }
}

int main()
{
  int j,k,u;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    u--;
    for(j=0;j<n;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  bfs(0);
  
  return 0;
}

Compiler output:
main.c: In function 'bfs':
main.c:7:3: error: 'queue' undeclared (first use in this function)
    7 |   queue<int> q;
      |   ^~~~~
main.c:7:3: note: each undeclared identifier is reported only once for each function it appears in
main.c:7:9: error: expected expression before 'int'
    7 |   queue<int> q;
      |         ^~~
main.c:8:3: error: 'q' undeclared (first use in this function)
    8 |   q.push(s);
      |   ^
main.c:9:14: error: expected ']' before ',' token
    9 |   int u,d[101,color[101];
      |              ^
      |              ]
main.c:55:1: error: expected declaration or statement at end of input
   55 | }
      | ^
Language: C

#include<stdio.h>
#define MAX 102
#define WHITE 0
#define BLACK 1
#define GRAY 2
#define NIL -1

void init();

int n, head = 0, tail = 0, color[MAX];
int d[MAX], edge[MAX], G[MAX][MAX];



void init(){
  int i;

  for(i = 0; i <= n; i++){
      color[i] = WHITE;
      d[i] = 10000000;    
  }
  
}

/*void Enqueue(int x){
  if((head == 1 && tail == length) || head == tail+1){
    return NIL;
  }

  Q[tail] = x;

  if(tail == length){
    tail = 1;
  } else {
    tail = tail+1;
  }

  }*/

void Enqueue(int *Q, int x){
 
  if(tail == n){
    tail = 1;
  } else {
    tail += 1;
  }
 
 Q[tail] = x;
}
 
int Dequeue(int *Q){
  if(head == n){
    head = 1;
  } else {
    head++;
  }
  return Q[head];
}

void BFS(){
  int i, s = 1, u, j = 0;
  int Q[101];
  init();

  color[s] = GRAY;
  d[s] = 0;
  for(i = 0 ; i <= n; i++){
    Q[i] = 0;
  }
  Enqueue(Q, s);

  while(head != tail){
    u = Dequeue(Q);
    
    for(i = 1; i <= n; i++){
      if(color[i] == WHITE && G[u][i] == 10){ 
	color[i] = GRAY;
	d[i] = d[u] + 1;
	Enqueue(Q, i); 
      }
    }
    color[u] = BLACK;
    j++;  
  }
  
  
}


int main(){
  
  int i,j,k = 0,vertex,number;
  
  scanf("%d",&n);

  for(i = 1; i <= n; i++){
    scanf("%d %d",&vertex,&edge[i]);
    for(j = 1; j <= edge[i]; j++){
      scanf("%d",&number);
      G[vertex][number] = 10;
    }

  }

  /*for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      printf("%d ",G[i][j]);
    }
    printf("\n");
    }*/

    BFS();
  
   for(i = 1; i <= n; i++){
    if(d[i] == 10000000){
      printf("%d %d\n", i, -1);
    } else {
    printf("%d %d\n", i, d[i]);
    }
  }
  
  return 0;


}

  return 0;


}

Compiler output:
main.c:127:3: error: expected identifier or '(' before 'return'
  127 |   return 0;
      |   ^~~~~~
main.c:130:1: error: expected identifier or '(' before '}' token
  130 | }
      | ^
Language: C

include <stdio.h>

#define N 100

int queue[N] = {0};
int b = 0, e = 0;
void enq( int v ) {
    queue[b++] = v;
}
int deq() {
    return queue[e++];
}
int is_empty() {
    return b == e;
}

int step[N] = {0};

void clear()
{
    int i;
    for( i=0; i<N; ++i ) {
        queue[i] = 0;
        step[i] = -1;
    }
    b = 0;
    e = 0;
}

void bfs( int table[], int s, int n )
{
    int u, v;

    enq( s - 1 );
    while( !is_empty() ) {
        u = deq();
        if ( step[u] == -1 )
            step[u] = 0;
                    
        for( v=0; v<n; ++v ) {
            if ( table[u*N+v] == 1 && step[v] == -1 ) {
                step[v] = step[u] + 1;
                enq( v );
            }
        }
    }
}

int main( void )
{
    int n, i, j, u, k, v;
    int cnt = 0;
    int table[N*N] = {0};
    scanf( "%d", &n );

    clear();

    for( i=0; i<n; ++i ) {
        scanf( "%d %d", &u, &k );
        for( j=0; j<k; ++j ) {
            scanf("%d", &v);
            table[((u-1)*N)+(v-1)] = 1;
        }
    }

    bfs( table, 1, n );

    for( i=0; i<n; ++i )
        printf("%d %d\n", i+1, step[i]);

    return 0;
}

Compiler output:
main.c:1:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    1 | include <stdio.h>
      |         ^
main.c: In function 'enq':
main.c:8:5: error: 'queue' undeclared (first use in this function)
    8 |     queue[b++] = v;
      |     ^~~~~
main.c:8:5: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function 'deq':
main.c:11:12: error: 'queue' undeclared (first use in this function)
   11 |     return queue[e++];
      |            ^~~~~
main.c: In function 'clear':
main.c:23:9: error: 'queue' undeclared (first use in this function)
   23 |         queue[i] = 0;
      |         ^~~~~
main.c: In function 'main':
main.c:54:5: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   54 |     scanf( "%d", &n );
      |     ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | include <stdio.h>
main.c:54:5: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   54 |     scanf( "%d", &n );
      |     ^~~~~
main.c:54:5: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:69:9: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   69 |         printf("%d %d\n", i+1, step[i]);
      |         ^~~~~~
main.c:69:9: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:69:9: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:69:9: note: include '<stdio.h>' or provide a declaration of 'printf'
Language: C

#include<stdio.h>

int main(){

  int n;

  scanf("%d", &n);
  int g[102][102],d[102];


  int i,j;
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      g[i][j] = 0;
    }
    d[i]=-1;
  }

  int u,k;
  for(i=0;i<n;i++){
    scanf("%d %d", &u,&k);
    for(j=0;j<k;j++){
      int v;
      scanf("%d", &v);
      g[u][v] = 1;
    }
  }

  int Q[102];
  int head=0,tail;
  tail=head+1;

    Q[head]=1;
    //  tail+=1;
    d[Q[head]]=0;
    while(head!=tail){
      u=Q[head];
      head++;
      for(i=1;i<=n;i++){
	if(g[u][i]==1 && d[i]==-1){
	  g[u][i]=0;
	  d[i]=d[u]+1;
	  Q[t++]=i;
	    }
	}
    }


  for(i=1;i<=n;i++){
    printf("%d %d\n", i, d[i]);
  }
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:43:13: error: 't' undeclared (first use in this function)
   43 |           Q[t++]=i;
      |             ^
main.c:43:13: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include<iostream>
#include<queue>

using namespace std;
static const int N=100;
static const int INFTY=(1<<21);

int n,m[N][N];
int d[n];

void bfs(int s){
  queue<int> q;
  q.push(s);
  for(int i=0;i<n;i++) d[i]=INFTY;
  d[s]=0;
  int u;
  while(!q.empty()){
    u=q.front();
    q.pop();
    for(int v=0;v<n;v++){
      if(m[u][v]==0) continue;
      if(d[v]!=INFTY) continue;
      d[v]=d[u]+1;
      q.push(v);
    }
  }
  for(int i=0;i<n;i++){
    cout<<i+1<<" "<<((d[i]==INFTY)?(-1):d[i])<<endl;
  }
}

int main(){
  int u,k,v;

  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++) m[i][j]=0;
  }

  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>v;
      v--;
      m[u][v]=1;
    }
  }

  bfs(0);

  return 0;
}



Compiler output:
a.cc:9:7: error: size of array 'd' is not an integral constant-expression
    9 | int d[n];
      |       ^
Language: C++

#include<iostream>
#include<queue>

using namespace std;
static const int N=100;
static const int INFTY=(1<<21);

int n,m[N][N];
int d[n];

void bfs(int s){
  queue<int> q;
  q.push(s);
  for(int i=0;i<n;i++) d[i]=INFTY;
  d[s]=0;
  int u;
  while(!q.empty()){
    u=q.front();
    q.pop();
    for(int v=0;v<n;v++){
      if(m[u][v]==0) continue;
      if(d[v]!=INFTY) continue;
      d[v]=d[u]+1;
      q.push(v);
    }
  }
  for(int i=0;i<n;i++){
    cout<<i+1<<" "<< ((d[i]==INFTY)?(-1):d[i])<<endl;
  }
}

int main(){
  int u,k,v;

  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++) m[i][j]=0;
  }

  for(int i=0;i<n;i++){
    cin>>u>>k;
    u--;
    for(int j=0;j<k;j++){
      cin>>v;
      v--;
      m[u][v]=1;
    }
  }

  bfs(0);

  return 0;
}



Compiler output:
a.cc:9:7: error: size of array 'd' is not an integral constant-expression
    9 | int d[n];
      |       ^
Language: C++

#include<iostream>
#include<queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n,M[N][N];
int d[N];

void bfs(int s){
  queue<int> q;
  q.push(s);
  for(int i = 0; i < n; i++) d[i] = INFTY;
  d[s] = 0;
  int u;
  while(!q.empty()){
    u = q.front();
    q.pop();
    for(int v=0;v<n;v++){
      if(M[u][v] == 0) continue;
      if(d[v]!=INFTY) continue;
      d[v] = d[u] + 1;
      q.push(v);
    }
  }
  for(int i = 0; i<n; i++){
    cout << i+1; << " " << ( (d[i] == INFTY) ? (-1) : d[i] ) << endl;
  }
}

int main(){
  int u,k,v;

  cin >> n;
  for(int i=0;i<n;i++){
    for(int j = 0; j < n; j++) M[i][j] = 0;
  }

  for(int i = 0; i < n; i++){
    cin >> u >> k;
    u--;
    for(int j = 0; j<k; j++){
      cin>>v;
      v--;
      M[u][v] = 1;
    }
  }
  bfs(0);

  return 0;
}



Compiler output:
a.cc: In function 'void bfs(int)':
a.cc:28:18: error: expected primary-expression before '<<' token
   28 |     cout << i+1; << " " << ( (d[i] == INFTY) ? (-1) : d[i] ) << endl;
      |                  ^~
Language: C++

#include<iosrteam>
#include<queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N];

void bfs(int s) {
  queue<int> q;
  q.push(s);
  for ( int i = 0; i < n; i++ ) d[i] = INFTY;
  d[s] = 0;
  int u;
  while ( !q.empty() ) {
    u = q.front(); q.pop();
    for ( int v = 0; v < n; v++ ) {
      if ( M[u][v] == 0 ) continue;
      if ( d[v] != INFTY ) continue;
      d[v] = d[u] + 1;
      q.push(v);
    }
  }
  for ( int i = 0; i < n; i++ ) {
    cout << i+1 << " " << ( (d[i] == INFTY) ? (-1) : d[i] ) << endl;
  }
}

int main() {
  int u, k, v;

  cin >> n;
  for ( int i = 0; i < n; i++ ) {
    for ( int j = 0; j < n; j++ ) M[i][j] = 0;
  }
  
  for ( int i = 0; i < n; i++ ) {
    cin >> u >> k;
    u--;
    for ( int j = 0; j < k; j++ ) {
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  dfs(0);

  return 0;
}



Compiler output:
a.cc:1:9: fatal error: iosrteam: No such file or directory
    1 | #include<iosrteam>
      |         ^~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N];

void bfs(int s) {
  queue<int> q;
  q.push(s);
  for ( int i = 0; i < n; i++ ) d[i] = INFTY;
  d[s] = 0;
  int u;
  while ( !q.empty() ) {
    u = q.front(); q.pop();
    for ( int v = 0; v < n; v++ ) {
      if ( M[u][v] == 0 ) continue;
      if ( d[v] != INFTY ) continue;
      d[v] = d[u] + 1;
      q.push(v);
    }
  }
  for ( int i = 0; i < n; i++ ) {
    cout << i+1 << " " << ( (d[i] == INFTY) ? (-1) : d[i] ) << endl;
  }
}

int main() {
  int u, k, v;

  cin >> n;
  for ( int i = 0; i < n; i++ ) {
    for ( int j = 0; j < n; j++ ) M[i][j] = 0;
  }
  
  for ( int i = 0; i < n; i++ ) {
    cin >> u >> k;
    u--;
    for ( int j = 0; j < k; j++ ) {
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  dfs(0);

  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:49:3: error: 'dfs' was not declared in this scope; did you mean 'bfs'?
   49 |   dfs(0);
      |   ^~~
      |   bfs
Language: C++

#include<iostream> #include<queue>
using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N];
void bfs(int s) {
    queue<int> q;
    q.push(s);
    for ( int i = 0; i < n; i++ ) d[i] = INFTY;
    
    d[s] = 0;
    int u;
    while ( !q.empty() ) {
        u = q.front();
        q.pop();
        for ( int v = 0; v < n; v++ ) {
            if ( M[u][v] == 0 ) continue;
            if ( d[v] != INFTY ) continue;
            d[v] = d[u] + 1;
            q.push(v);
            }
        
    }
    for ( int i =0; i<n; i++){
         cout << i+1 << " " << ( (d[i] == INFTY) ? (-1) : d[i] ) << endl;
         }
    
}
         int main() {
             int u, k, v;
             cin >> n;
             for ( int i =0; i<n; i++){
                 for ( int j=0; j<n; j++)  M[i][j] = 0;
                       }
             
             for ( int i =0; i<n; i++){
                            cin >> u >> k;
                 u--;
                 for ( int j =0; j<k; j++){
                                 cin >> v;
                     v--;
                     M[u][v] =1;
                                 }
                 
             }
           bfs(0);
       return 0;
             
         }


Compiler output:
a.cc:1:20: warning: extra tokens at end of #include directive
    1 | #include<iostream> #include<queue>
      |                    ^
a.cc: In function 'void bfs(int)':
a.cc:9:5: error: 'queue' was not declared in this scope
    9 |     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>
  +++ |+#include <queue>
    2 | using namespace std;
a.cc:9:11: error: expected primary-expression before 'int'
    9 |     queue<int> q;
      |           ^~~
a.cc:10:5: error: 'q' was not declared in this scope
   10 |     q.push(s);
      |     ^
Language: C++

from collections import deque
n = int(input())
A = [0]*(n+1)
D = [-1]*(n+1)
DP = [0]*(n+1)
d = deque()
for i in range(n):
    A[i+1] = [int(i) for i in input().split()]
d.append(1)
D[1] = 0
DP[1] = 0
while(len(d)>0):
    tmp = d.pop()
    for i in A[tmp][2:]:
        if not DP[i]:
            D[i] = D[tmp]+1
            DP[i] = 1
            d.appendleft(i)
for i in range(1,n+1):
    tmp = "{} {}".format(i,D[i])
    print(tmp)


Compiler output:
a.cc:1:1: error: 'from' does not name a type
    1 | from collections import deque
      | ^~~~
Language: C++

from collections import deque
n = int(input())
A = [0]*(n+1)
D = [-1]*(n+1)
DP = [0]*(n+1)
d = deque()
for i in range(n):
    A[i+1] = [int(i) for i in input().split()]
d.append(1)
D[1] = 0
DP[1] = 1
while(len(d)>0):
    tmp = d.pop()
    for i in A[tmp][2:]:
        if not DP[i]:
            D[i] = D[tmp]+1
            DP[i] = 1
            d.appendleft(i)
for i in range(1,n+1):
    tmp = "{} {}".format(i,D[i])
    print(tmp)


Compiler output:
a.cc:1:1: error: 'from' does not name a type
    1 | from collections import deque
      | ^~~~
Language: C++

#include <iostream>
#include <vector>
#include <unordered_map>
#include <queue>
#include "../cxx-prettyprint/prettyprint.hpp"


int main() {
    int n;
    std::cin >> n;

    std::unordered_map<int, std::vector<int>> Adj(n);

    for (int i = 0; i < n; i ++) {
        int u, k;
        std::cin >> u >> k;
        std::vector<int> V(k);
        for (int& v : V) {
            std::cin >> v;
        }
        Adj[u] = V;
    }

    std::set<int> nodes_unvisited;
    std::unordered_map<int, int> distances;

    for (int i = 1; i <= n; i ++) {
        nodes_unvisited.insert(i);
    }

    nodes_unvisited.erase(1);
    distances[1] = 0;
    std::queue<int> queue;
    queue.push(1);

    while (!queue.empty()) {
        int u = queue.front();
        queue.pop();
        for (int v : Adj[u]) {
            if (nodes_unvisited.find(v) != nodes_unvisited.end()) {
                nodes_unvisited.erase(v);
                distances[v] = distances[u] + 1;
                queue.push(v);
            }
        }
    }

    for (int i = 1; i <= n; i ++) {
        std::cout << i << " " << distances[i] << std::endl;
    }
}



Compiler output:
a.cc:5:10: fatal error: ../cxx-prettyprint/prettyprint.hpp: No such file or directory
    5 | #include "../cxx-prettyprint/prettyprint.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <vector>
#include <unordered_map>
#include <queue>
//#include "../cxx-prettyprint/prettyprint.hpp"


int main() {
    int n;
    std::cin >> n;

    std::unordered_map<int, std::vector<int>> Adj(n);

    for (int i = 0; i < n; i ++) {
        int u, k;
        std::cin >> u >> k;
        std::vector<int> V(k);
        for (int& v : V) {
            std::cin >> v;
        }
        Adj[u] = V;
    }

    std::set<int> nodes_unvisited;
    std::unordered_map<int, int> distances;

    for (int i = 1; i <= n; i ++) {
        nodes_unvisited.insert(i);
    }

    nodes_unvisited.erase(1);
    distances[1] = 0;
    std::queue<int> queue;
    queue.push(1);

    while (!queue.empty()) {
        int u = queue.front();
        queue.pop();
        for (int v : Adj[u]) {
            if (nodes_unvisited.find(v) != nodes_unvisited.end()) {
                nodes_unvisited.erase(v);
                distances[v] = distances[u] + 1;
                queue.push(v);
            }
        }
    }

    for (int i = 1; i <= n; i ++) {
        std::cout << i << " " << distances[i] << std::endl;
    }
}



Compiler output:
a.cc: In function 'int main()':
a.cc:24:10: error: 'set' is not a member of 'std'
   24 |     std::set<int> nodes_unvisited;
      |          ^~~
a.cc:5:1: note: 'std::set' is defined in header '<set>'; this is probably fixable by adding '#include <set>'
    4 | #include <queue>
  +++ |+#include <set>
    5 | //#include "../cxx-prettyprint/prettyprint.hpp"
a.cc:24:14: error: expected primary-expression before 'int'
   24 |     std::set<int> nodes_unvisited;
      |              ^~~
a.cc:28:9: error: 'nodes_unvisited' was not declared in this scope
   28 |         nodes_unvisited.insert(i);
      |         ^~~~~~~~~~~~~~~
a.cc:31:5: error: 'nodes_unvisited' was not declared in this scope
   31 |     nodes_unvisited.erase(1);
      |     ^~~~~~~~~~~~~~~
Language: C++

#include<stdio.h>
#define N 101
#define WHITE 2
#define GRAY 1
#define BLACK 0
#define INF 1000000

 
int n, h= 0, t = 0;
int col[N], d[N], a[N][N], e[N]; 

int Que[N];



 int Dequeque(){
  h++;
  return Que[h - 1];
}
void Enqueque(int b){
  Que[t] = b;
  t++;
}
 
void BFS(int s){
  int i, u, next;
  for(i = 1; i < n+1; i++){
      col[i] = WHITE;


      d[i] = -1;
  }
 
  col[s] = GRAY;
  d[s] = 0;
  Enqueque(s);
 
  while(h != t){
    u = Dequeque();
    for(i = 1; i <= n; i++){
      if((col[i] == WHITE) && (a[u][i] == 1)){


    col[i] = GRAY;
    d[i] = d[u] + 1;
    Enqueque(i);
      }
    }
   

    col[u] = BLACK;
  }
}
 

  
main(){
 
  scanf("%d", &n);
 
  int i, u, j,y=1;



  /*配列の初期化*/
  for(i = 1; i < n+1; i++){
    for(j = 1; j < n+1; j++){
     

 a[i][j] = 0;

    }
  }

  int x; 
  for(i = 1; i < n+1; i++){
    scanf("%d%d", &u, &e);
    for(j = 1; j <= e; j++){
      scanf("%d", &x);
      a[i][x] = 1;
    }
  }
 
  BFS(y);
   
  for(i = 1; i < n+1; i++){
    printf("%d ", i);
    printf("%d\n", d[i]);
  }
  return 0;
}

Compiler output:
a.cc:57:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   57 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:78:18: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   78 |     for(j = 1; j <= e; j++){
      |                ~~^~~~
Language: C++

#include <iostream>
#include <queue>

using namespace std;

int D[100100];//始点からの距離を入れる

int g[1001][1001]={{0}};//要素を0で初期化
void bfs(int src,int n){//srcは開始位置この場合だと頂点1だから0
  // cerr << "bfs_root = " << src << endl;
  queue<int> Q;
  Q.push(src);
  D[src] = 0;
  while (! Q.empty()  ){
    int cur = Q.front();
    Q.pop();
    // cerr << "visiting_" << cur << " " <<D[cur] <<endl;
    for(int dst= 0; dst < n; dst++){
      if(g[cur][dst]==1 && D[dst]==0){
        D[dst]=D[cur]+1;
        Q.push(dst);
      }
    }
  }
}
void ans(int n){
  cout << 1 <<" "<< 0 <<enl;
  for (int i = 1; i < n; ++i)
  {
    if(D[i]==0){
      cout << i+1 << " "<< -1 <<endl;
    }else{
      cout << i+1 <<" "<< D[i]<<endl;
    }
  }

}

int main(){
  // int g[1001][1001]={{0}};//要素を0で初期化
  int n,a,b,c;
  cin >> n;
  for (int i = 0; i < n; ++i)
  {
    cin >> a >> b ;
    for (int i = 0; i < b; ++i)
    {
      cin >> c;
      g[a-1][c-1]=1;/* code */
    }
  }
  bfs(0,n);
  ans(n);
  // for (int i = 0; i < n; ++i)
  // {
  //    for (int j = 0; j < n; ++j)
  //    {
  //     if (j==n-1)
  //     {
  //       cout << g[i][j] << endl;
  //     }else{
  //       cout << g[i][j] <<" ";
  //     }
  //    }
  // }


}

Compiler output:
a.cc: In function 'void ans(int)':
a.cc:27:25: error: 'enl' was not declared in this scope
   27 |   cout << 1 <<" "<< 0 <<enl;
      |                         ^~~
Language: C++

#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;
#define N 100
#define INF 1e9

queue<int> Q;
int n,M[N][N];
int dist[N];

void bsf(int l){
	Q.push(l);
	for(int i = 0;i < n;i++) dist[i] = INF;

	dist[l]=0;
	while(!Q.empty()){
		int u = Q.front();
		Q.pop();
		for(int i=0;i<n;i++){
			if(M[u][i] == 0)continue;
			if(dist[i] != INF)continue;
			dist[i] = dist[u] + 1;
			Q.push(i);
		}
	}

	for(int i=0;i<n;i++){ 
		if(dist[i] == INF)dist = -1;
		
		cout<<i+1<<" "<<dist[i]<<endl;
	}
}


int main(){
	int u,k,v;

	cin >> n;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++) M[i][j] = 0;
	}

	for(int i = 0;i < n;i++){
		cin >> u >> k;
		u--;
		for(int j = 0;j < k;j++){
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}
	bsf(0);
	return 0;
}

Compiler output:
a.cc: In function 'void bsf(int)':
a.cc:52:40: error: incompatible types in assignment of 'int' to 'int [100]'
   52 |                 if(dist[i] == INF)dist = -1;
      |                                   ~~~~~^~~~
Language: C++

#include<iostream>
#include<queue>

using namespeace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N];

coid dfs(int s)
{
  queue<int> q;
  q.push(s);
  for(int i = 0; i < n; i++)d[i] = INFTY;
  d[s] = 0;
  int u;
  while(!q.empty())
   {
     u =.front(); q.pop();
     for(int v = 0; v < n; v++)
      {
        if(M[u][v] == 0)continue;
        if(d[v] != INFTY)continue;
        d[v] = d[u] + 1;
        q.push(v);
      }
   }  
  for(int i = 0; i <n; i++)
    {
       cout << i+1 " " <<((d[i] == INFTY)?(-1):d[i])<<endl;
    } 
}

int main()
{
  int u, k, v;


  cin >> n;
  for(int i = 0; i < n; i++)
  {
      for(int j = 0; j < n; j++)M[i][j] = 0;
  }
  
  for(int i = 0; i < n; i++)
  {
    cin >> u >> k;
    u--;
    for(int j = 0; j < k; j++)
    {
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  bfs(0);

  return 0;
}

Compiler output:
a.cc:4:7: error: expected nested-name-specifier before 'namespeace'
    4 | using namespeace std;
      |       ^~~~~~~~~~
a.cc:11:1: error: 'coid' does not name a type; did you mean 'void'?
   11 | coid dfs(int s)
      | ^~~~
      | void
a.cc: In function 'int main()':
a.cc:40:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   40 |   cin >> n;
      |   ^~~
      |   std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:58:3: error: 'bfs' was not declared in this scope
   58 |   bfs(0);
      |   ^~~
Language: C++

#include<iostream>
#include<queue>

using namespeace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N];

void dfs(int s)
{
  queue<int> q;
  q.push(s);
  for(int i = 0; i < n; i++)d[i] = INFTY;
  d[s] = 0;
  int u;
  while(!q.empty())
   {
     u =.front(); q.pop();
     for(int v = 0; v < n; v++)
      {
        if(M[u][v] == 0)continue;
        if(d[v] != INFTY)continue;
        d[v] = d[u] + 1;
        q.push(v);
      }
   }  
  for(int i = 0; i <n; i++)
    {
       cout << i+1 " " <<((d[i] == INFTY)?(-1):d[i])<<endl;
    } 
}

int main()
{
  int u, k, v;


  cin >> n;
  for(int i = 0; i < n; i++)
  {
      for(int j = 0; j < n; j++)M[i][j] = 0;
  }
  
  for(int i = 0; i < n; i++)
  {
    cin >> u >> k;
    u--;
    for(int j = 0; j < k; j++)
    {
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  bfs(0);

  return 0;
}

Compiler output:
a.cc:4:7: error: expected nested-name-specifier before 'namespeace'
    4 | using namespeace std;
      |       ^~~~~~~~~~
a.cc: In function 'void dfs(int)':
a.cc:13:3: error: 'queue' was not declared in this scope; did you mean 'std::queue'?
   13 |   queue<int> q;
      |   ^~~~~
      |   std::queue
In file included from /usr/include/c++/14/queue:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_queue.h:96:11: note: 'std::queue' declared here
   96 |     class queue
      |           ^~~~~
a.cc:13:9: error: expected primary-expression before 'int'
   13 |   queue<int> q;
      |         ^~~
a.cc:14:3: error: 'q' was not declared in this scope
   14 |   q.push(s);
      |   ^
a.cc:20:9: error: expected primary-expression before '.' token
   20 |      u =.front(); q.pop();
      |         ^
a.cc:31:8: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   31 |        cout << i+1 " " <<((d[i] == INFTY)?(-1):d[i])<<endl;
      |        ^~~~
      |        std::cout
In file included from a.cc:1:
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc: In function 'int main()':
a.cc:40:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   40 |   cin >> n;
      |   ^~~
      |   std::cin
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:58:3: error: 'bfs' was not declared in this scope; did you mean 'dfs'?
   58 |   bfs(0);
      |   ^~~
      |   dfs
Language: C++

#include<iostream>
#include<queue>

using namespeace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N];

void dfs(int s)
{
  queue<int> q;
  q.push(s);
  for(int i = 0; i < n; i++)d[i] = INFTY;
  d[s] = 0;
  int u;
  while(!q.empty())
   {
     u =q.front(); q.pop();
     for(int v = 0; v < n; v++)
      {
        if(M[u][v] == 0)continue;
        if(d[v] != INFTY)continue;
        d[v] = d[u] + 1;
        q.push(v);
      }
   }  
  for(int i = 0; i < n; i++)
    {
       cout << i+1 " " <<((d[i] == INFTY)?(-1):d[i])<<endl;
    } 
}

int main()
{
  int u, k, v;


  cin >> n;
  for(int i = 0; i < n; i++)
  {
      for(int j = 0; j < n; j++)M[i][j] = 0;
  }
  
  for(int i = 0; i < n; i++)
  {
    cin >> u >> k;
    u--;
    for(int j = 0; j < k; j++)
    {
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  bfs(0);

  return 0;
}

Compiler output:
a.cc:4:7: error: expected nested-name-specifier before 'namespeace'
    4 | using namespeace std;
      |       ^~~~~~~~~~
a.cc: In function 'void dfs(int)':
a.cc:13:3: error: 'queue' was not declared in this scope; did you mean 'std::queue'?
   13 |   queue<int> q;
      |   ^~~~~
      |   std::queue
In file included from /usr/include/c++/14/queue:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_queue.h:96:11: note: 'std::queue' declared here
   96 |     class queue
      |           ^~~~~
a.cc:13:9: error: expected primary-expression before 'int'
   13 |   queue<int> q;
      |         ^~~
a.cc:14:3: error: 'q' was not declared in this scope
   14 |   q.push(s);
      |   ^
a.cc:31:8: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   31 |        cout << i+1 " " <<((d[i] == INFTY)?(-1):d[i])<<endl;
      |        ^~~~
      |        std::cout
In file included from a.cc:1:
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc: In function 'int main()':
a.cc:40:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   40 |   cin >> n;
      |   ^~~
      |   std::cin
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:58:3: error: 'bfs' was not declared in this scope; did you mean 'dfs'?
   58 |   bfs(0);
      |   ^~~
      |   dfs
Language: C++

#include<iostream>
#include<queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N];

void bfs(int s)
{
  queue<int> q;
  q.push(s);
  for(int i = 0; i < n; i++)d[i] = INFTY;
  d[s] = 0;
  int u;
  while(!q.empty())
   {
     u =q.front(); q.pop();
     for(int v = 0; v < n; v++)
      {
        if(M[u][v] == 0)continue;
        if(d[v] != INFTY)continue;
        d[v] = d[u] + 1;
        q.push(v);
      }
   }  
  for(int i = 0; i < n; i++)
    {
       cout << i+1 " " <<((d[i] == INFTY)?(-1):d[i])<<endl;
    } 
}

int main()
{
  int u, k, v;


  cin >> n;
  for(int i = 0; i < n; i++)
  {
      for(int j = 0; j < n; j++)M[i][j] = 0;
  }
  
  for(int i = 0; i < n; i++)
  {
    cin >> u >> k;
    u--;
    for(int j = 0; j < k; j++)
    {
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  bfs(0);

  return 0;
}

Compiler output:
a.cc: In function 'void bfs(int)':
a.cc:31:19: error: expected ';' before string constant
   31 |        cout << i+1 " " <<((d[i] == INFTY)?(-1):d[i])<<endl;
      |                   ^~~~
      |                   ;
Language: C++

#include <stdio.h>
#include <stdlib.h>

#define WHITE 0
#define GRAY 1
#define BLACK 2
#define MAX_N 110

int n,time,head,tail;
int queue[MAX_N];
int *dist;
int *color;
int **matrix;

void enqueue(int);
int dequeue(void);
void bfs(void);

int main(){
  int i,j,u,k,v;

  scanf("%d",&n);

  //queue = malloc(n * sizeof(int));
  color = malloc(n * sizeof(int));
  dist = malloc(n * sizeof(int));

  matrix = malloc(n * sizeof(int *));
  for(i = 0 ; i < n ; i++){
    matrix[i] = malloc(n * sizeof(int));
 }
 for(i = 0 ; i < n ; i++){
   dist[i] = -1;
 }
 for(i = 0 ; i < n ; i++){
   for(j = 0 ; j < n ; j++){
     matrix[i][j] = 0;
   }
 }

 for(i = 0 ; i < n ; i++){
    scanf("%d",&u); u--;
    scanf("%d",&k);
    for(j = 0 ; j < k ; j++){
      scanf("%d",&v); v--;
      matrix[u][v] = 1;
    }
  }

  bfs();
  for(i = 0 ; i < n ; i++){
    printf("%d %d\n",i+1,dist[i]);
  }

  for(i = 0 ; i < n ; i++){
    free(matrix[i]);
  }
  free(matrix);
  //free(queue);
  free(dist);
  free(color);
  return 0;
}

void bfs(){
  int u,i;

  head = tail = 0;
  color[0] = GRAY;
  dist[0] = 0;
  enqueue(0);

  while(head != tail){
    u = dequeue();
    for(i = 0 ; i < n ; i++){
      if(matrix[u][i] == 1 && color[i] == WHITE){
        color[i] = GRAY;
        dist[i] = dist[u] + 1;
        enqueue(i);
      }
    }
    color[u] = BLACK;
  }
}

void enqueue(int q){
  queue[tail%MAX_N] = q;
  tail++;
}

int dequeue(){
  int v = queue[head%MAX_N];
  head++;
  return v;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:17: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
   25 |   color = malloc(n * sizeof(int));
      |           ~~~~~~^~~~~~~~~~~~~~~~~
      |                 |
      |                 void*
a.cc:26:16: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
   26 |   dist = malloc(n * sizeof(int));
      |          ~~~~~~^~~~~~~~~~~~~~~~~
      |                |
      |                void*
a.cc:28:18: error: invalid conversion from 'void*' to 'int**' [-fpermissive]
   28 |   matrix = malloc(n * sizeof(int *));
      |            ~~~~~~^~~~~~~~~~~~~~~~~~~
      |                  |
      |                  void*
a.cc:30:23: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
   30 |     matrix[i] = malloc(n * sizeof(int));
      |                 ~~~~~~^~~~~~~~~~~~~~~~~
      |                       |
      |                       void*
Language: C++

#include <stdio.h>
#include <stdlib.h>

#define WHITE 0
#define GRAY 1
#define BLACK 2
#define MAX_N 110

int n,time,head,tail;
int *queue;
int *dist;
int *color;
int **matrix;

void enqueue(int);
int dequeue(void);
void bfs(void);

int main(){
  int i,j,u,k,v;

  scanf("%d",&n);

  queue = malloc(MAX_N * sizeof(int));
  color = malloc(n * sizeof(int));
  dist = malloc(n * sizeof(int));

  matrix = malloc(n * sizeof(int *));
  for(i = 0 ; i < n ; i++){
    matrix[i] = malloc(n * sizeof(int));
 }
 for(i = 0 ; i < n ; i++){
   dist[i] = -1;
 }
 for(i = 0 ; i < n ; i++){
   for(j = 0 ; j < n ; j++){
     matrix[i][j] = 0;
   }
 }

 for(i = 0 ; i < n ; i++){
    scanf("%d",&u); u--;
    scanf("%d",&k);
    for(j = 0 ; j < k ; j++){
      scanf("%d",&v); v--;
      matrix[u][v] = 1;
    }
  }

  bfs();
  for(i = 0 ; i < n ; i++){
    printf("%d %d\n",i+1,dist[i]);
  }

  for(i = 0 ; i < n ; i++){
    free(matrix[i]);
  }
  free(matrix);
  free(queue);
  free(dist);
  free(color);
  return 0;
}

void bfs(){
  int u,i;

  head = tail = 0;
  color[0] = GRAY;
  dist[0] = 0;
  enqueue(0);

  while(head != tail){
    u = dequeue();
    for(i = 0 ; i < n ; i++){
      if(matrix[u][i] == 1 && color[i] == WHITE){
        color[i] = GRAY;
        dist[i] = dist[u] + 1;
        enqueue(i);
      }
    }
    color[u] = BLACK;
  }
}

void enqueue(int q){
  queue[tail] = q;
  if(++tail == MAX_N+1) tail = 0;
}

int dequeue(){
  int v = queue[head];
  if(++head == MAX_N+1) head = 0;
  return v;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:17: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
   24 |   queue = malloc(MAX_N * sizeof(int));
      |           ~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |                 |
      |                 void*
a.cc:25:17: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
   25 |   color = malloc(n * sizeof(int));
      |           ~~~~~~^~~~~~~~~~~~~~~~~
      |                 |
      |                 void*
a.cc:26:16: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
   26 |   dist = malloc(n * sizeof(int));
      |          ~~~~~~^~~~~~~~~~~~~~~~~
      |                |
      |                void*
a.cc:28:18: error: invalid conversion from 'void*' to 'int**' [-fpermissive]
   28 |   matrix = malloc(n * sizeof(int *));
      |            ~~~~~~^~~~~~~~~~~~~~~~~~~
      |                  |
      |                  void*
a.cc:30:23: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
   30 |     matrix[i] = malloc(n * sizeof(int));
      |                 ~~~~~~^~~~~~~~~~~~~~~~~
      |                       |
      |                       void*