criyle/codenet-compile-errors huggingface dataset:
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;
  whie(!q.empty){
    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;
    }
  }
  for(int =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<k;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:13:12: error: expected ';' before '+' token
   13 |   for(int i+0;i<n;i++){
      |            ^
      |            ;
a.cc:13:18: error: expected ')' before ';' token
   13 |   for(int i+0;i<n;i++){
      |      ~           ^
      |                  )
a.cc:13:19: error: 'i' was not declared in this scope
   13 |   for(int i+0;i<n;i++){
      |                   ^
a.cc:18:11: error: cannot convert 'std::queue<int>::empty' from type 'bool (std::queue<int>::)() const' to type 'bool'
   18 |   whie(!q.empty){
      |           ^~~~~
a.cc:18:11: error: in argument to unary !
   18 |   whie(!q.empty){
      |         ~~^~~~~
a.cc:18:3: error: 'whie' was not declared in this scope
   18 |   whie(!q.empty){
      |   ^~~~
a.cc:28:11: error: expected unqualified-id before '=' token
   28 |   for(int =0;i<n;i++){
      |           ^
a.cc:28:10: error: expected ';' before '=' token
   28 |   for(int =0;i<n;i++){
      |          ^~
      |          ;
a.cc:28:11: error: expected primary-expression before '=' token
   28 |   for(int =0;i<n;i++){
      |           ^
a.cc:28:17: error: expected ')' before ';' token
   28 |   for(int =0;i<n;i++){
      |      ~          ^
      |                 )
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;
  whie(!q.empty){
    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;
    }
  }
  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<k;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:18:11: error: cannot convert 'std::queue<int>::empty' from type 'bool (std::queue<int>::)() const' to type 'bool'
   18 |   whie(!q.empty){
      |           ^~~~~
a.cc:18:11: error: in argument to unary !
   18 |   whie(!q.empty){
      |         ~~^~~~~
a.cc:18:3: error: 'whie' was not declared in this scope
   18 |   whie(!q.empty){
      |   ^~~~
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){
    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;
    }
  }
  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<k;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:18:12: error: cannot convert 'std::queue<int>::empty' from type 'bool (std::queue<int>::)() const' to type 'bool'
   18 |   while(!q.empty){
      |            ^~~~~
a.cc:18:12: error: in argument to unary !
   18 |   while(!q.empty){
      |          ~~^~~~~
a.cc:19:12: warning: ignoring return value of 'std::queue<_Tp, _Sequence>::reference std::queue<_Tp, _Sequence>::front() [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; reference = int&]', declared with attribute 'nodiscard' [-Wunused-result]
   19 |     q.front();
      |     ~~~~~~~^~
In file included from /usr/include/c++/14/queue:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_queue.h:231:7: note: declared here
  231 |       front()
      |       ^~~~~
a.cc:25:9: error: statement cannot resolve address of overloaded function
   25 |       q.push;
      |       ~~^~~~
Language: C++

#include <iostream>
#include <queue>

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

int n, G[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(G[u][v] == 0) continue;
      if(d[v] != INFTY) continue;
      d[v] = d[u] + 1;
      q.push(v);
    }
  }
  for(int i = 0; i < n; i++){
    cont << 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++) G[i][j] = 0;
  }

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

  bfs(0);
  return 0;
}

Compiler output:
a.cc: In function 'void bfs(int)':
a.cc:28:5: error: 'cont' was not declared in this scope; did you mean 'const'?
   28 |     cont << i + 1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
      |     ^~~~
      |     const
a.cc: In function 'int main()':
a.cc:46:7: error: 'M' was not declared in this scope
   46 |       M[u][v] = 1;
      |       ^
Language: C++

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

struct node_t {
    int key;
    struct node_t *next;
};
typedef struct node_t Node;

Node *enqueue(Node *node, int key) {
  Node *p, *q;

  if (node == NULL) {
    node = malloc(sizeof(Node));
    node->key = key;
    node->next = NULL;
    return node;
  }

  for (p = node; p != NULL; p = p->next) {
    q = p;
  }
  q->next = malloc(sizeof(Node));
  q->next->key = key;
  q->next->next = NULL;
  return node;
}

Node *dequeue(Node *node, int *key) {
  Node *p;

  if (node != NULL) {
    *key = node->key;
    p = node->next;
    free(node);
        return p;
  }
  return NULL;
}

int main(void) {
  int num, i, j, k, u;
  int way[101][101] = {{0}};
  int d[101];
  Node *q = NULL;

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

  d[0] = 0;
  for (i = 1; i < num; i++) {
    d[i] = -1;
  }
  q = enqueue(q, 0);

  while (q != NULL) {
    q = dequeue(q, &u);
    for (i = 0; i < num; i++) {
      k = way[u][i] - 1;
      if (d[k] < 0) {
    d[k] = d[u] + 1;
    q = enqueue(q, k);
      }
    }
  }

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

Compiler output:
a.cc: In function 'Node* enqueue(Node*, int)':
a.cc:14:18: error: invalid conversion from 'void*' to 'Node*' {aka 'node_t*'} [-fpermissive]
   14 |     node = malloc(sizeof(Node));
      |            ~~~~~~^~~~~~~~~~~~~~
      |                  |
      |                  void*
a.cc:23:19: error: invalid conversion from 'void*' to 'node_t*' [-fpermissive]
   23 |   q->next = malloc(sizeof(Node));
      |             ~~~~~~^~~~~~~~~~~~~~
      |                   |
      |                   void*
Language: C++

# -*- coding: utf-8 -*-
from collections import deque

N = int(input())
adj = [[0]*N for _ in range(N)]
unsearched = set(range(1, N))
result = {n:-1 for n in range(N)}

for n in range(N):
    inp = list(map(int, input().split()))
    for i in inp[2:]:
        adj[inp[0]-1][i-1] = 1

que = deque([[0, 0]]) # edge distance


while len(que):
    q = que.pop()
    result[q[0]] = q[1]
    next_ = [[i, q[1] + 1] for i, a in enumerate(adj[q[0]]) if (a==1) & (i in unsearched)]
    unsearched = unsearched.difference([i[0] for i in next_])
    que.extendleft(next_)

for n in range(N):
    print("{} {}".format(n+1, result[n]))

Compiler output:
a.cc:1:3: error: invalid preprocessing directive #-
    1 | # -*- coding: utf-8 -*-
      |   ^
a.cc:14:23: error: stray '#' in program
   14 | que = deque([[0, 0]]) # edge distance
      |                       ^
a.cc:2:1: error: 'from' does not name a type
    2 | from collections import deque
      | ^~~~
a.cc:9:1: error: expected unqualified-id before 'for'
    9 | for n in range(N):
      | ^~~
Language: C++

#include "stdafx.h"
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stdio.h>
#define REP(i, n) for(int i = 0;i < n;i++)

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);
	REP(i, n)
		d[i] = INFTY;
	d[s] = 0;
	int u;

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

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

	cin >> n;

	REP(i, n)
	{
		REP(j, n)
			M[n][n] = 0;
	}

	REP(i, n)
	{
		cin >> u >> k;
		u--;
		REP(i, k)
		{
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}

	bfs(0);
	return 0;
}

Compiler output:
a.cc:1:10: fatal error: stdafx.h: No such file or directory
    1 | #include "stdafx.h"
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stdio.h>
#define REP(i, n) for(int i = 0;i < n;i++)

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);
	REP(i, n)
		d[i] = INFTY;
	d[s] = 0;
	int u;

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

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

	cin >> n;

	REP(i, n)
	{
		REP(j, n)
			M[n][n] = 0;
	}

	REP(i, n)
	{
		cin >> u >> k;
		u--;
		REP(i, k)
		{
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}

	bfs(0);
	return 0;
}

Compiler output:
a.cc: In function 'void bfs(int)':
a.cc:26:19: error: cannot convert 'std::queue<int>::empty' from type 'bool (std::queue<int>::)() const' to type 'bool'
   26 |         while (!q.empty)
      |                   ^~~~~
a.cc:26:19: error: in argument to unary !
   26 |         while (!q.empty)
      |                 ~~^~~~~
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];
intd  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:1: error: 'intd' does not name a type; did you mean 'int'?
    9 | intd  d[N];
      | ^~~~
      | int
a.cc: In function 'void bfs(int)':
a.cc:15:5: error: 'd' was not declared in this scope
   15 |     d[i] = INFTY;
      |     ^
a.cc:17:3: error: 'd' was not declared in this scope
   17 |   d[s] = 0;
      |   ^
Language: C++

#include<iostream>
#include<queue>

using namespace std;

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

void bfs (int s) {

    int i, u, v;

    queue<int> Q;
    Q.push(s);
    for (i = 0; i < n; i++) {
        d[i] = (1 << 21);
    }
    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] != (1 << 21)) {
                continue;
            }
            d[v] = d[u] + 1;
            q.push(v);
        }
    }
    for (i = 0; i < n; i++) {
        cout << i + 1 << " " << ((d[i] == (1 << 21)) ? (-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:
a.cc: In function 'void bfs(int)':
a.cc:18:13: error: 'q' was not declared in this scope
   18 |     while (!q.empty()) {
      |             ^
Language: C++

#include<iostream>
#include<queue>

using namespace std;

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

void bfs (int s) {

    int i, u, v;

    queue<int> Q;
    Q.push(s);
    for (i = 0; i < n; i++) {
        d[i] = (1 << 21);
    }
    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] != (1 << 21)) {
                continue;
            }
            d[v] = d[u] + 1;
            q.push(v);
        }
    }
    for (i = 0; i < n; i++) {
        cout << i + 1 << " " << ((d[i] == (1 << 21)) ? (-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:
a.cc: In function 'void bfs(int)':
a.cc:29:13: error: 'q' was not declared in this scope
   29 |             q.push(v);
      |             ^
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];
intd  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:1: error: 'intd' does not name a type; did you mean 'int'?
    9 | intd  d[N];
      | ^~~~
      | int
a.cc: In function 'void bfs(int)':
a.cc:15:5: error: 'd' was not declared in this scope
   15 |     d[i] = INFTY;
      |     ^
a.cc:17:3: error: 'd' was not declared in this scope
   17 |   d[s] = 0;
      |   ^
Language: C++

#include <iostream>
#include <queue>

using namespace std;

int main(){
	int n, u, k, v;
	int D[100];
	bool adj[100][100] = {};
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> u >> k;
		for (int j = 0; j < k; j++){
			cin >> v;
			adj[u-1][v-1] = true;
		}
	}
	for (int i = 0; i < n; i++){
		D[i] = -1;
	}
	queue<int> Q;
	Q.push(1);
	D[0] = 0;
	e[0] = 1;
	while(!Q.empty()){
		int m = Q.front();
		Q.pop();
		for (int i = 0; i < n; i++){
			if (adj[m-1][i] == 1 && e[i] == 0){
				D[i] = D[m-1]+1;
				Q.push(i);
				e[i] = 1;
			}
		}
	}
	
	for (int i = 0; i < n; i++){
		cout << i+1 << ' ' << D[i] << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:9: error: 'e' was not declared in this scope
   24 |         e[0] = 1;
      |         ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <map>
#include <cmath>
#include <queue>

using namespace std;

static const int N = 100;

int main() {

    int graph[N][N] = {0};
    int distance[N] = {INT_MIN};
    bool alreadySearched[N] = {false};

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


    queue<int> Q;
    Q.push(0);
    distance[0] = 0;
    alreadySearched[0] = true;

    while(!Q.empty()){
        int u = Q.front();
        for(int i=0;i<n;i++){
            if(!alreadySearched[i] && graph[u][i] == 1){
                Q.push(i);
                alreadySearched[i] = true;
                distance[i] = distance[u] + 1;
            }
        }
        Q.pop();
    }

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

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:24: error: 'INT_MIN' was not declared in this scope
   20 |     int distance[N] = {INT_MIN};
      |                        ^~~~~~~
a.cc:12:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   11 | #include <queue>
  +++ |+#include <climits>
   12 |
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:
a.cc: In function 'void bfs(int)':
a.cc:18:27: error: expected ';' before 'for'
   18 |     u = q.front(); q.pop()
      |                           ^
      |                           ;
   19 |     for ( int v = 0; v < n; v++ ) {
      |     ~~~                    
a.cc:19:22: error: 'v' was not declared in this scope
   19 |     for ( int v = 0; v < n; v++ ) {
      |                      ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define MK make_pair 
typedef pair<int,int> pi;


int main(){
  const int MX=1e9+7;
  int a[1000][1000];
  fill(&a[0][0],&a[999][1000],MX);
  for(int i=0;i<1000;i++){
    a[i][i]=0;
  }
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int w;
    cin>>w;
    int m;
    cin>>m;
    for(int t=0;t<m;t++){
      int e;
      cin>>e;
      a[w][e]=1;
    }
  }
  for(int i=1;i<=n;i++){
    for(int t=1;t<=n;t++){
      for(int k=1;k<=n;k++){
	a[t][k]=min(a[t][k],a[t][i]+a[i][k]);
      }
    }
  }
  for(int i=1;i<=n;i++){
    cout<<i<<" "<<(a[1][i]==MX? -1:a[a][i])<<endl;
  }


  
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:35:37: error: invalid types 'int [1000][1000][int [1000][1000]]' for array subscript
   35 |     cout<<i<<" "<<(a[1][i]==MX? -1:a[a][i])<<endl;
      |                                     ^
Language: C++

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int table[101][101];

void init(){
    REP(i,101){
        REP(j,101){
            table[i][j]=1e9;
            if(i==j)table[i][j]=0;
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    init();
    int u,k,v;
    REP(i,n){
        cin >> u >> k;
        REP(j,k){
            cin >> v;
            table[u-1][v-1]=1;
        }
    }

    REP(k,n){
        REP(i,n){
            REP(j,n){
                table[i][j]=min(table[i][j],table[i][k]+table[k][j]);
            }
        }
    }
    REP(i,n){
        cout << i+1 << " " << ((table[0][i]<n)?table[0][i]:-1);
        cout << endl;
    }
}



Compiler output:
a.cc:1:3: error: stray '#' in program
    1 | zc#include <bits/stdc++.h>
      |   ^
a.cc:1:1: error: 'zc' does not name a type; did you mean 'sc'?
    1 | zc#include <bits/stdc++.h>
      | ^~
      | sc
a.cc: In function 'int main()':
a.cc:26:5: error: 'ios' has not been declared
   26 |     ios::sync_with_stdio(false);
      |     ^~~
a.cc:28:5: error: 'cin' was not declared in this scope
   28 |     cin >> n;
      |     ^~~
a.cc:42:29: error: 'min' was not declared in this scope; did you mean 'main'?
   42 |                 table[i][j]=min(table[i][j],table[i][k]+table[k][j]);
      |                             ^~~
      |                             main
a.cc:47:9: error: 'cout' was not declared in this scope
   47 |         cout << i+1 << " " << ((table[0][i]<n)?table[0][i]:-1);
      |         ^~~~
a.cc:48:17: error: 'endl' was not declared in this scope
   48 |         cout << endl;
      |                 ^~~~
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 (!p.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() {

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

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

  bfs(0);

  return 0;
}


Compiler output:
a.cc:13:3: error: expected initializer before 'queue'
   13 |   queue<int> q;
      |   ^~~~~
a.cc:15:3: error: 'q' does not name a type
   15 |   q.push(s);
      |   ^
a.cc:16:3: error: expected unqualified-id before 'for'
   16 |   for (int i = 0; i < n; i++) {
      |   ^~~
a.cc:16:19: error: 'i' does not name a type
   16 |   for (int i = 0; i < n; i++) {
      |                   ^
a.cc:16:26: error: 'i' does not name a type
   16 |   for (int i = 0; i < n; i++) {
      |                          ^
a.cc:19:3: error: 'd' does not name a type
   19 |   d[s] = 0;
      |   ^
a.cc:21:3: error: expected unqualified-id before 'while'
   21 |   while (!p.empty()) {
      |   ^~~~~
a.cc:34:3: error: expected unqualified-id before 'for'
   34 |   for (int i = 0; i < n; i++) {
      |   ^~~
a.cc:34:19: error: 'i' does not name a type
   34 |   for (int i = 0; i < n; i++) {
      |                   ^
a.cc:34:26: error: 'i' does not name a type
   34 |   for (int i = 0; i < n; i++) {
      |                          ^
a.cc:37:1: error: expected declaration before '}' token
   37 | }
      | ^
a.cc: In function 'int main()':
a.cc:59:3: error: 'bfs' was not declared in this scope
   59 |   bfs(0);
      |   ^~~
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 (!p.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() {

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

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

  bfs(0);

  return 0;
}


Compiler output:
a.cc: In function 'void bfs(int)':
a.cc:21:11: error: 'p' was not declared in this scope
   21 |   while (!p.empty()) {
      |           ^
Language: C++

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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

static const int N = 100;
static const int no = -1;

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

ll graph[N][N] = {{}}, d[N] = {}, n;

void bfs(int v) {
  queue<int> q;
  q.push(v);
  ll u;
  for(int i = 1; i <= n; i++) d[i] = no;
  d[v] = 0;
  while(!q.empty()) {
    u = q.front(); q.pop();
    for(int i = 1; i <= n; i++) {
      if(graph[u][i] == 0 continue;
      if(d[i] != no) continue;
      d[i] = d[u] + 1;
      q.push(i);
    }
  }
}

signed main() {
	ll u, v, k;
  cin >> n;
  rep(i, n) {
    cin >> u >> k;
    rep(j, k) {
      cin >> v;
      graph[u][v] = 1;
    }
  }

  bfs(1);

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

	return 0;
}


Compiler output:
a.cc: In function 'void bfs(ll)':
a.cc:33:26: error: expected ';' before 'continue'
   33 |       if(graph[u][i] == 0 continue;
      |                          ^~~~~~~~~
      |                          ;
a.cc:34:7: error: expected primary-expression before 'if'
   34 |       if(d[i] != no) continue;
      |       ^~
a.cc:33:36: error: expected ')' before 'if'
   33 |       if(graph[u][i] == 0 continue;
      |         ~                          ^
      |                                    )
   34 |       if(d[i] != no) continue;
      |       ~~
Language: C++

#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;
#define MAX 100000

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

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]==1){
        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:15:17: error: 'n' was not declared in this scope
   15 |   for(int i=0;i<n;i++) d[i]=INFTY;
      |                 ^
a.cc:15:24: error: 'd' was not declared in this scope
   15 |   for(int i=0;i<n;i++) d[i]=INFTY;
      |                        ^
a.cc:16:3: error: 'd' was not declared in this scope
   16 |   d[s]=0;
      |   ^
a.cc:21:19: error: 'n' was not declared in this scope
   21 |     for(int v=0;v<n;v++){
      |                   ^
a.cc:22:10: error: 'M' was not declared in this scope
   22 |       if(M[u][v]==1){
      |          ^
a.cc:28:17: error: 'n' was not declared in this scope
   28 |   for(int i=0;i<n;i++){
      |                 ^
a.cc: In function 'int main()':
a.cc:35:10: error: 'n' was not declared in this scope
   35 |   cin >> n;
      |          ^
a.cc:37:26: error: 'M' was not declared in this scope
   37 |     for(int j=0;j<n;j++) M[i][j]=0;
      |                          ^
a.cc:46:7: error: 'M' was not declared in this scope
   46 |       M[u][v]=1;
      |       ^
Language: C++

#include <iostream>
#include <vector>
#include <queue>
#include <cstdint>

using namespace std;

enum COLOR {
  WHITE,
  GRAY,
  BLACK,
};

static const int INFTY = INT_MAX;
static const int N = 100;

static int M[N][N] = {};
static vector<COLOR> color(N, WHITE);
static vector<int> d(N, INFTY);

static void bfs(int n, int s) {
  color[s] = GRAY;
  d[s] = 0;

  queue<int> Q;
  Q.push(s);

  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (int v = 0; v < n; v++) {
      if (M[u][v] && color[v] == WHITE) {
          color[v] = GRAY;
          d[v] = d[u] + 1;
          Q.push(v);
      }
      color[u] = BLACK;
    }
  }
}

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

  int number, count, value;
  for (int i = 0; i < n; i++) {
    cin >> number >> count;
    number--;
    for (int j = 0; j < count; j++) {
     cin >> value;
     value--;
     M[number][value] = 1; 
    }
  }
  
  bfs(n, 0);
  
  for (int i = 0; i < n; i++) {
    cout << i + 1 << " " << ((d[i] == INFTY) ? -1 : d[i]) << endl; 
  }

  return 0;
}



Compiler output:
a.cc:14:26: error: 'INT_MAX' was not declared in this scope
   14 | static const int INFTY = INT_MAX;
      |                          ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <cstdint>
  +++ |+#include <climits>
    5 |
Language: C++

#include <stdio.h>
#include <queue>

int time, n;
int d[100], color[100];
int M[100][100];

void bfs(int s) {
    queue<int> Q;
    
    for (int i=0; i<100; i++) color[i] = 0:
    for (int i=0; i<100; i++) d[i] = -1;
    
    color[s] = 1;
    d[s] = 0;
    Q.push(s);
    while (!Q.empty()) {
        int u = Q.front(); Q.pop();
        for (int i=0; i<n; i++) {
            if(M[u][i] && color[i] == 0) {
                color[i] = 1;
                d[i] = d[u]+1;
                Q.push(i);
            }
        }
        color[u] = 2;
    }
}

int main() {
    int u, k, v;
    scanf("%d", &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++) {
        scanf("%d %d", &u, &k);
        for (int j=0; j<k; j++) {
            scanf("%d", &v);
            M[u-1][v-1] = 1;
        }
    }
    
    bfs(0);
    
    for (int i=0; i<n; i++) {
        printf("%d %d\n", i+1, d[i]);
    }
    return 0;
}


Compiler output:
a.cc: In function 'void bfs(int)':
a.cc:9:5: error: 'queue' was not declared in this scope; did you mean 'std::queue'?
    9 |     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:9:11: error: expected primary-expression before 'int'
    9 |     queue<int> Q;
      |           ^~~
a.cc:11:43: error: expected ';' before ':' token
   11 |     for (int i=0; i<100; i++) color[i] = 0:
      |                                           ^
      |                                           ;
a.cc:12:19: error: 'i' was not declared in this scope
   12 |     for (int i=0; i<100; i++) d[i] = -1;
      |                   ^
a.cc:16:5: error: 'Q' was not declared in this scope
   16 |     Q.push(s);
      |     ^
Language: C++

#include <stdio.h>
#include <queue>

int time, n;
int d[100], color[100];
int M[100][100];

void bfs(int s) {
    std::queue<int> Q;
    
    for (int i=0; i<100; i++) color[i] = 0:
    for (int i=0; i<100; i++) d[i] = -1;
    
    color[s] = 1;
    d[s] = 0;
    Q.push(s);
    while (!Q.empty()) {
        int u = Q.front(); Q.pop();
        for (int i=0; i<n; i++) {
            if(M[u][i] && color[i] == 0) {
                color[i] = 1;
                d[i] = d[u]+1;
                Q.push(i);
            }
        }
        color[u] = 2;
    }
}

int main() {
    int u, k, v;
    scanf("%d", &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++) {
        scanf("%d %d", &u, &k);
        for (int j=0; j<k; j++) {
            scanf("%d", &v);
            M[u-1][v-1] = 1;
        }
    }
    
    bfs(0);
    
    for (int i=0; i<n; i++) {
        printf("%d %d\n", i+1, d[i]);
    }
    return 0;
}


Compiler output:
a.cc: In function 'void bfs(int)':
a.cc:11:43: error: expected ';' before ':' token
   11 |     for (int i=0; i<100; i++) color[i] = 0:
      |                                           ^
      |                                           ;
a.cc:12:19: error: 'i' was not declared in this scope
   12 |     for (int i=0; i<100; i++) d[i] = -1;
      |                   ^
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<cassert>
#include<cstdio>
#include<queue>

using namespace std;

int N, G[100][100], V[100], D[100];//G:２頂点,V:次数,D:距離

void bfs(int src){
	queue<int> Q;
	Q.push(src);
	fill(D, D + N, -1);
	D[src] = 0;
	while (!Q.empty()){
		int cur = Q.front();
		Q.pop();
		for (int k = 0; k < N; k++){
			if (G[cur][k] == 1 && D[k] == -1){
				D[k] = D[cur] + 1;
				Q.push(k);
			}
		}
	}
	for (int l = 0; l < N; l++){
		cerr << l + 1 << " " << D[l] << endl;
	}
}

int main(){
	scanf_s("%d", &N);
	int id, c;
	for (int i = 0; i < N; i++){
		scanf_s("%d", &id); id--;//配列は0から始まるので、頂点番号を-1して考える。
		scanf_s("%d", V + id);
		for (int j = 0; j < V[id]; j++){
			scanf_s("%d", &c); c--;//配列は0から始まるので、頂点番号を-1して考える。
			G[id][c] = 1;
		}
	}//データの読み込み完了。
	bfs(0);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   33 |         scanf_s("%d", &N);
      |         ^~~~~~~
      |         scanf
Language: C++

#include<iostream>

#include<algorithm>

#include<vector>

#include<cassert>

#include<cstdio>

#include<queue>



using namespace std;



int N, G[100][100], V[100], D[100];//G:２頂点,V:次数,D:距離



void bfs(int src){

	queue<int> Q;

	Q.push(src);

	fill(D, D + N, -1);

	D[src] = 0;

	while (!Q.empty()){

		int cur = Q.front();

		Q.pop();

		for (int k = 0; k < N; k++){

			if (G[cur][k] == 1 && D[k] == -1){

				D[k] = D[cur] + 1;

				Q.push(k);

			}

		}

	}

	for (int l = 0; l < N; l++){

		cerr << l + 1 << " " << D[l] << endl;

	}

}



int main(){

	scanf_s("%d", &N);

	int id, c;

	for (int i = 0; i < N; i++){

		scanf_s("%d", &id); id--;//配列は0から始まるので、頂点番号を-1して考える。

		scanf_s("%d", V + id);

		for (int j = 0; j < V[id]; j++){

			scanf_s("%d", &c); c--;//配列は0から始まるので、頂点番号を-1して考える。

			G[id][c] = 1;

		}

	}//データの読み込み完了。

	bfs(0);

}

Compiler output:
a.cc: In function 'int main()':
a.cc:65:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   65 |         scanf_s("%d", &N);
      |         ^~~~~~~
      |         scanf
Language: Java

import java.util.*;

public class Main {
	
	
	private int[][] matrix;
	private int numEdge;
	public int[] Mark;
	public int size;
	public boolean[] visited;
	
	public Main() {};
	public Main(int n) {
		Init(n);
	}
	
	public void Init(int n) {
		Mark = new int[n];
		visited = new boolean[n];
		matrix = new int[n][n];
		size = n;
	}
	
	public int n() {return Mark.length;}
	public int e() {return numEdge;}
	
	
	
	public boolean isEdge(int i, int j) {
		return matrix[i][j] != 0;
	}
	
	
	
	public void setRelation(int i, int j) {
		matrix[i][j] = 1;
	}
	
	public int[] getNeighbors(int v) {
		return matrix[v];
	}
	
	public void setVisited(int v) {
		visited[v] = true;
	}
	
	public boolean connected(int start, int end) {
		// basic case, if there exists an edge between start and end
		if(isEdge(start,end)) {
			return true;
		} 
		
		setVisited(start);
		int[] neighbors = getNeighbors(start);
		
		for(int i = 0; i < neighbors.length; i++) {
			int v = neighbors[i];
			if(visited[v] == false) connected(v, end);
			
		}
		
		return false;
	}
	
	
	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		
		//numbers of users
		int size = in.nextInt();
		ConnectedGraph graph = new ConnectedGraph(size);
		
		int relations_total = in.nextInt();
		while(relations_total > 0) {
			int x = in.nextInt();
			int y = in.nextInt();
			graph.setRelation(x, y);
			relations_total--;
		}
		
		
		int queries = in.nextInt();
		
		for(int i = 0; i<= queries; i++) {
			int a = in.nextInt();
			System.out.println(a);
			int b = in.nextInt();
			System.out.println(b);
			if(graph.connected(a,b)) {
				System.out.println("yes");
			} else
				System.out.println("no");
			
			
			
		}
		
		in.close();
		
		
	}

}



Compiler output:
Main.java:72: error: cannot find symbol
		ConnectedGraph graph = new ConnectedGraph(size);
		^
  symbol:   class ConnectedGraph
  location: class Main
Main.java:72: error: cannot find symbol
		ConnectedGraph graph = new ConnectedGraph(size);
		                           ^
  symbol:   class ConnectedGraph
  location: class Main
2 errors
Language: Java

import java.util.*;

public class Main {
	
	
	private int[][] matrix;
	private int numEdge;
	public int[] Mark;
	public int size;
	public boolean[] visited;
	
	public ConnectedGraph() {};
	public ConnectedGraph(int n) {
		Init(n);
	}
	
	public void Init(int n) {
		Mark = new int[n];
		visited = new boolean[n];
		matrix = new int[n][n];
		size = n;
	}
	
	public int n() {return Mark.length;}
	public int e() {return numEdge;}
	
	
	
	public boolean isEdge(int i, int j) {
		return matrix[i][j] != 0;
	}
	
	
	
	public void setRelation(int i, int j) {
		matrix[i][j] = 1;
	}
	
	public int[] getNeighbors(int v) {
		return matrix[v];
	}
	
	public void setVisited(int v) {
		visited[v] = true;
	}
	
	public boolean connected(int start, int end) {
		// basic case, if there exists an edge between start and end
		if(isEdge(start,end)) {
			return true;
		} 
		
		setVisited(start);
		int[] neighbors = getNeighbors(start);
		
		for(int i = 0; i < neighbors.length; i++) {
			int v = neighbors[i];
			if(visited[v] == false) connected(v, end);
			
		}
		
		return false;
	}
	
	
	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		
		//numbers of users
		int size = in.nextInt();
		ConnectedGraph graph = new ConnectedGraph(size);
		
		int relations_total = in.nextInt();
		while(relations_total > 0) {
			int x = in.nextInt();
			int y = in.nextInt();
			graph.setRelation(x, y);
			relations_total--;
		}
		
		
		int queries = in.nextInt();
		
		for(int i = 0; i<= queries; i++) {
			int a = in.nextInt();
			System.out.println(a);
			int b = in.nextInt();
			System.out.println(b);
			if(graph.connected(a,b)) {
				System.out.println("yes");
			} else
				System.out.println("no");
			
			
			
		}
		
		in.close();
		
		
	}

}



Compiler output:
Main.java:12: error: invalid method declaration; return type required
	public ConnectedGraph() {};
	       ^
Main.java:13: error: invalid method declaration; return type required
	public ConnectedGraph(int n) {
	       ^
2 errors
Language: Java

import java.util.*;
 class ID{
    public int id;
    public ID(int id){
        this.id = id;
    }
}
public class Main {

    public static void main(String[] args) {
        
        Scanner scanner = new Scanner(System.in);
        ID nullID = new ID(-1);
        ID[] group = new ID[scanner.nextInt()];
        for(int i=0; i<group.length;i++)
            group[i] = nullID;

        int m = scanner.nextInt();
        ArrayList<ID> idList = new ArrayList<ID>();
        int groupID = 0;
        for (int i = 0; i < m; i++) {
            int s = scanner.nextInt();
            int t = scanner.nextInt();
            if(group[s].id==-1 && group[t].id==-1){
                idList.add(new ID(groupID));
                group[s]=group[t]= idList.get(groupID++);
            }else if(group[s].id!=-1 && group[t].id==-1)
                group[t]=group[s];
            else if(group[s].id==-1 && group[t].id!=-1)
                group[s]=group[t];
            else{
                int tempID = group[s].id
                for(int k=0; k<idList.size();k++)
                    if(idList.get(k).id== tempID)
                        idList.get(k).id = group[t].id;
            }
        }
/*         for(int k=0; k<group.length ;k++)
             System.out.print(group[k].id+" ");
         System.out.println("");*/
        int q = scanner.nextInt();
        for (int i = 0; i < q; i++){
            int s = scanner.nextInt();
            int t = scanner.nextInt();
            if (group[s].id == group[t].id && group[s].id!=-1)
                System.out.println("yes");
            else
                System.out.println("no");
        }
    }
 

}

Compiler output:
Main.java:32: error: ';' expected
                int tempID = group[s].id
                                        ^
1 error
Language: Java

import java.util.Scanner;

public class QuickFindUF {
    private int[] id;

    public QuickFindUF(int N) {
        id = new int[N];
        for (int i = 0; i < N; i++) {
            id[i] = i;
        }
    }

    public boolean connected(int p, int q){
        return id[p] == id[q];
    }

    public void union(int p, int q){
        int pid = id[p];
        int qid = id[q];
        for (int i = 0; i < id.length; i++) {
            if(id[i] == pid) id[i] = qid;
        }
    }
}


public class Main {
    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int M = scanner.nextInt();
        QuickFindUF uf = new QuickFindUF(N);

        // input
        for (int i = 0; i < M; i++) {
            int p = scanner.nextInt();
            int q = scanner.nextInt();
            uf.union(p, q);
        }

        int Q = scanner.nextInt();
        for (int i = 0; i < Q; i++) {
            int p = scanner.nextInt();
            int q = scanner.nextInt();
            if (uf.connected(p,q))
                System.out.print("yes\n");
            else
                System.out.print("no\n");
        }
    }
}

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

import java.util.Scanner;

public class Main {
    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int M = scanner.nextInt();
        QuickFindUF uf = new QuickFindUF(N);

        // input
        for (int i = 0; i < M; i++) {
            int p = scanner.nextInt();
            int q = scanner.nextInt();
            uf.union(p, q);
        }

        int Q = scanner.nextInt();
        for (int i = 0; i < Q; i++) {
            int p = scanner.nextInt();
            int q = scanner.nextInt();
            if (uf.connected(p,q))
                System.out.print("yes\n");
            else
                System.out.print("no\n");
        }
    }
}


public class QuickFindUF {
    private int[] id;

    public QuickFindUF(int N) {
        id = new int[N];
        for (int i = 0; i < N; i++) {
            id[i] = i;
        }
    }

    public boolean connected(int p, int q){
        return id[p] == id[q];
    }

    public void union(int p, int q){
        int pid = id[p];
        int qid = id[q];
        for (int i = 0; i < id.length; i++) {
            if(id[i] == pid) id[i] = qid;
        }
    }
}

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

import java.util.Scanner;

public class Main {
public class QuickUnionUF {

    private int[] id;

    public QuickUnionUF(int N) {
        id = new int[N];
        for (int i = 0; i < N; i++) {
            id[i] = i;
        }
    }

    public void union(int p, int q) {
        int i = root(p);
        int j = root(q);

        id[i] = j;
    }

    private int root(int i) {
        while (i != id[i])
            i = id[i];
        return i;
    }

    public boolean connected(int p, int q) {
        return root(p) == root(q);
    }
}

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int M = scanner.nextInt();
//        QuickFindUF uf = new QuickFindUF(N);
        QuickUnionUF uf = new QuickUnionUF(N);

        // input
        for (int i = 0; i < M; i++) {
            int p = scanner.nextInt();
            int q = scanner.nextInt();
            uf.union(p, q);
        }

        // Query
        int Q = scanner.nextInt();
        for (int i = 0; i < Q; i++) {
            int p = scanner.nextInt();
            int q = scanner.nextInt();
            if (uf.connected(p,q))
                System.out.print("yes\n");
            else
                System.out.print("no\n");
        }
    }
}

Compiler output:
Main.java:40: error: non-static variable this cannot be referenced from a static context
        QuickUnionUF uf = new QuickUnionUF(N);
                          ^
1 error
Language: Java

import java.util.Scanner;

static class QuickUnionUF {

    private int[] id;
    private int[] sz;

    QuickUnionUF(int N) {
        id = new int[N];
        sz = new int[N];
        for (int i = 0; i < N; i++) {
            id[i] = i;
            sz[i] = 0;
        }
    }

    private int root(int i) {
        while (i != id[i]){
            id[i] = id[id[i]]; // Path Compression: node points to grandparent
            i = id[i];
        }
        return i;
    }

    void union(int p, int q) {
        int i = root(p);
        int j = root(q);

        if (i == j) return;
        if (sz[i] < sz[j]){
            id[i] = j;
            sz[j] += sz[i];
        }
        else {
            id[j] = i;
            sz[i] += sz[j];
        }
    }

    boolean connected(int p, int q) {
        return root(p) == root(q);
    }
}


public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int M = scanner.nextInt();
//        QuickFindUF uf = new QuickFindUF(N);
        QuickUnionUF uf = new QuickUnionUF(N);

        // input
        for (int i = 0; i < M; i++) {
            int p = scanner.nextInt();
            int q = scanner.nextInt();
            uf.union(p, q);
        }

        // Query
        int Q = scanner.nextInt();
        for (int i = 0; i < Q; i++) {
            int p = scanner.nextInt();
            int q = scanner.nextInt();
            if (uf.connected(p,q))
                System.out.print("yes\n");
            else
                System.out.print("no\n");
        }
    }
}

Compiler output:
Main.java:3: error: modifier static not allowed here
static class QuickUnionUF {
       ^
1 error