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

import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class ALDS1_7_A {

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

        int n = sc.nextInt();
        Tree t = new Tree(n);
        
        for(int i = 0; i < n; i++) {
        	int id = sc.nextInt();
            int k = sc.nextInt();
            int pc = -1;
            for(int j = 0; j < k; j++) {
            	int c = sc.nextInt();
            	if (j == 0)
                    t.setChild(id, c);
                else
                    t.setRightSib(pc, c);
                t.setPar(c, id);
                pc = c;
            }
        }
        
        for(int i = 0; i < n; i++)
        	t.printR(i);
	}
}

class Tree {
	private class Node {
		int parent = -1;
		int leftChild = -1;
		int rightSib = -1;
		
		public int getDepth() {
			if(parent == -1)
				return 0;
			else
				return getDepth() + 1;
		}
		
		public String getType() {
			if(parent == -1)
				return "root";
			else if(leftChild == -1)
				return "leaf";
			else
                return "internal node";
		}
	}
	
	private Node[] node;
	
	public Tree(int n) {
		node = new Node[n];
		for(int i = 0; i < n; i++) {
			node[i] = new Node();
		}
	}
	
    public void setChild(int id, int c) {
        node[id].leftChild = c;
    }
 
    public void setRightSib(int id, int sib) {
        node[id].rightSib = sib;
    }
 
    public void setPar(int id, int par) {
        node[id].parent = par;
    }
    
    public void printR(int id) {
    	System.out.print("node " + id + ": parent = " + node[id].parent + ", depth = " + node[id].getDepth() + ", "
                + node[id].getType() + ", [");
        if (node[id].leftChild != -1) {
            System.out.print(node[id].leftChild);
            for (int c = node[node[id].leftChild].rightSib; c != -1; c = node[c].rightSib)
                System.out.print(", " + c);
        }
        System.out.println("]");
    }
	
}



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

import java.util.Scanner;

public class Main {
	public static Scanner sc = new Scanner(System.in);
	public static class node{
		String status,child;
		String [] children;
		int parent,depth,i;
		
		node(){
			child = sc.nextLine();
		}
		void spt(){
			children = child.split(" ");
		}
		
	}
	
	public static void pd(node [] branch,int index){
		int i,j;
		for(i=0;i<index;i++){
			for(j=0;j<branch[i].children.length;j++){
				branch[Integer.valueOf(branch[i].children[j]]) = i; 
			}
		}
	}
	
	public static void main(String[] args){
		
		int i,n = sc.nextInt();
		String buf;
		node [] tree = new node[n];
		buf = sc.nextLine();
		
		for(i=0;i<n;i++){
			sc.skip(String.valueOf(i)+" ");
			tree[i] = new node();
			tree[i].spt();
		}
		
		for(i=0;i<n;i++){
			System.out.println(tree[i].child);
		}
	}

}


Compiler output:
Main.java:23: error: ')' or ',' expected
				branch[Integer.valueOf(branch[i].children[j]]) = i; 
				                                            ^
Main.java:23: error: not a statement
				branch[Integer.valueOf(branch[i].children[j]]) = i; 
				      ^
Main.java:23: error: ';' expected
				branch[Integer.valueOf(branch[i].children[j]]) = i; 
				                                             ^
Main.java:23: error: not a statement
				branch[Integer.valueOf(branch[i].children[j]]) = i; 
				                                                 ^
4 errors
Language: C

#include<stdio.h>

#define max 100005
#define nil -1

typedef struct Node{
  int p, l, r;
} node;

node t[max];
int n, d[max];

void Pr(int u){
  int i, c;
  printf("node %d: parent = %d, depth = %d, ", u, t[u].p, d[u]);
  if(t[u].p==nil)printf("root, ");
  else if(t[u].l==nil)printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  c=t[u].l;
  for(i=0 ; c!=nil ; i++){
    if(i)printf(", ");
    printf("%d",c);
    c=t[c].r;
  }
  printf("]\n");
}

int Dep(int u, int p){
  d[u]=p;
  if(t[u].r!=nil)Dep(t[u].r, p);
  if(t[u].l!=nil)Dep(t[u], p+1);
}

int main(){
  int i, j, d, v, c, l, r;
  scanf("%d",&n);
  for(i=0 ; i<n ; i++)t[i].p=t[i].r=t[i].l=nil;
  for(i=0 ; i<n ; i++){
    scanf("%d%d", &v, &d);
    for(j=0 ; j<d ; j++){
      scanf("%d", &c);
      if(j==0)t[v].l=c;
      else t[l].r=c;
      l=c;
      t[c].p=v;
    }
  }
  for(i=0 ; i<n ; i++){
    if(t[i].p==nil)r=i;
  }
  Dep(r, 0);
  for(i=0 ; i<n ; i++)Pr(i);
  return 0;
}


Compiler output:
main.c: In function 'Dep':
main.c:32:23: error: incompatible type for argument 1 of 'Dep'
   32 |   if(t[u].l!=nil)Dep(t[u], p+1);
      |                      ~^~~
      |                       |
      |                       node {aka struct Node}
main.c:29:13: note: expected 'int' but argument is of type 'node' {aka 'struct Node'}
   29 | int Dep(int u, int p){
      |         ~~~~^
Language: C

#include<stdio.h>
#define NO -1
#define MAX 1000000
typedef struct Node{
  int p,l,r;
}S;
S tree[MAX];
int getdepth(int x){
  int d=0;
  while(tree[x].p!=NO){
    x=tree[x].p;
    d++;
  }
  return d;
}
void out(int y){
  int i,j;
  print("node %d: ",y);
  printf("parent = %d, ",tree[y].p);
  printf("depth = %d, ",getdepth(y));
  if(tree[y].p==NO)printf("root, ");
  else if(tree[y].l==NO)printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  for(i=0,j=tree[y].l;j!=NO;i++,j=tree[j].r){
    if(i)printf(", ");
    printf("%d",j);
  }
  printf("]\n");
}
int main(){
  int n,i,j,a,b,m,z,l;
  scanf("%d",&n);
  for(i=0;i<n;i++)tree[i].p=tree[i].r=tree[i].l=NO;
  for(i=0;i<n;i++){
    scanf("%d%d",&a,&b);
    for(j=0;j<b;j++){
      scanf("%d",&m);
      if(j==0)tree[a].l=m;
      else tree[l].r=m;
      l=m;
      tree[m].p=a;
    }
  }
  for(i=0;i<n;i++)out(i);
  return 0;
}



Compiler output:
main.c: In function 'out':
main.c:18:3: error: implicit declaration of function 'print'; did you mean 'printf'? [-Wimplicit-function-declaration]
   18 |   print("node %d: ",y);
      |   ^~~~~
      |   printf
Language: C

#include <stdio.h>
#define N 100000

Node node[N];

int main(){
  int n;
  int i;

  struct Node{
    int p,l,r;
  };

  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&node[i]);
    scanf("%d",);

  }
  for(i=0; i<n; i++){
    printf("node %d: ",node[i]);
    printf("parent = %d, ",);
    printf("depth = %d, ");
    if(parent==-1)
      printf("root, ");
    else if(){
      printf("internal node, ");
    else{
      printf("leaf");
    }
    }
  }

}



Compiler output:
main.c:4:1: error: unknown type name 'Node'
    4 | Node node[N];
      | ^~~~
main.c: In function 'main':
main.c:17:16: error: expected expression before ')' token
   17 |     scanf("%d",);
      |                ^
main.c:22:28: error: expected expression before ')' token
   22 |     printf("parent = %d, ",);
      |                            ^
main.c:24:8: error: 'parent' undeclared (first use in this function)
   24 |     if(parent==-1)
      |        ^~~~~~
main.c:24:8: note: each undeclared identifier is reported only once for each function it appears in
main.c:26:13: error: expected expression before ')' token
   26 |     else if(){
      |             ^
main.c:28:5: error: expected '}' before 'else'
   28 |     else{
      |     ^~~~
main.c: At top level:
main.c:34:1: error: expected identifier or '(' before '}' token
   34 | }
      | ^
Language: C

#include <iostream>
using namespace std;

const int maxn=100000;

struct Tree {
  int parent,left,right;
};

Tree tree[maxn]; int depth[maxn];

void print(int u) {
  cout<<"node "<<u<<": "<<flush;
  cout<<"parent = "<<tree[u].parent<<", "<<flush;
  cout<<"depth = "<<depth[u]<<", "<<flush;

  if (tree[u].parent==(-1)) {
    cout<<"root, "<<flush;
  }
  else if (tree[u].left==(-1)) {
    cout<<"leaf, "<<flush;
  }
  else {
    cout<<"internal node, "<<flush;
  }
  cout<<"["<<flush;
  for (int i=0,c=tree[u].left; c!=(-1); i++,c=tree[c].right) {
    if (i) {
      cout<<", "<<flush;
    }
    cout<<c<<flush;
  }
  cout<<"]"<<endl;
}
void Depth(int u,int dpt) {
  depth[u]=dpt;
  if (tree[u].right!=(-1)) {
    Depth(tree[u].right,dpt);
  }
  if (tree[u].left!=(-1)) {
    Depth(tree[u].left,dpt+1);
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  int n; cin>>n;
  for (int i=0; i<n; i++) {
    tree[i].parent=tree[i].left=tree[i].right=(-1);
  }
  int l;
  for (int j=0; j<n; j++) {
    int id,k; cin>>id>>k;
    for (int i=0; i<k; i++) {
      int c; cin>>c;
      if (i==0) {
	tree[id].left=c;
      }
      else {
	tree[l].right=c;
      }
      l=c;
      tree[c].parent=id;
    }
  }
  int x;
  for (int i=0; i<n; i++) {
    if (tree[i].parent==(-1)) {
      x=i;
    }
  }
  Depth(x,0);
  for (int i=0; i<n; i++) {
    print(i);
  }
  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>
#define MAX 100000
#define NIL -1

typedef struct{
  int p;
  int l;
  int r;
}Tree;

Tree T[MAX];


 /*深さを数える*/
int getDepth(int x){

  int dep=0;

  while(T[x].p != NIL){
    x = T[x].p;
    dep++;
  }
  return dep;
}

void Print(x){

  int a;
  
  if(T[x].p == NIL){ 
  //printf("node %d: parent = %d, depth = %d, root, ",x,T[x].p,getDepth(x));
    printf("node %d: parent = %d , sibling = %d , degree = %d, depth = %d, height = %d, root");
  }
  else if(T[x].l == NIL){
  //printf("node %d: parent = %d, depth = %d, leaf, ",x,T[x].p,getDepth(x));
    printf("node %d: parent = %d , sibling = %d , degree = %d, depth = %d, height = %d, leaf");
  }
  else{
  //printf("node %d: parent = %d, depth = %d, internal node, ",x,T[x].p,getDepth(x)); 
    printf("node %d: parent = %d , sibling = %d , degree = %d, depth = %d, height = %d, inertnal node");  
  }
  
}


int main(void){
  v
  int n,i,j,a,b,c,r;

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    T[i].p = NIL;
    T[i].l = NIL;
    T[i].r = NIL;    
  }

  for(i = 0; i < n; i++){
    scanf("%d %d",&a,&b);
    for(j = 0; j < b; j++){
      scanf("%d",&c);
      T[c].p = a;
      if(j == 0) T[a].l = c;
      else if (j >= 1) T[r].r = c;
      r = c;
    }
  }

  //for(i = 0; i <n; i++) getDepth(i);
  for(i = 0; i <n; i++) Print(i);

    return 0;
}


Compiler output:
main.c: In function 'Print':
main.c:26:6: error: type of 'x' defaults to 'int' [-Wimplicit-int]
   26 | void Print(x){
      |      ^~~~~
main.c: In function 'main':
main.c:47:3: error: 'v' undeclared (first use in this function)
   47 |   v
      |   ^
main.c:47:3: note: each undeclared identifier is reported only once for each function it appears in
main.c:47:4: error: expected ';' before 'int'
   47 |   v
      |    ^
      |    ;
   48 |   int n,i,j,a,b,c,r;
      |   ~~~
main.c:50:15: error: 'n' undeclared (first use in this function)
   50 |   scanf("%d",&n);
      |               ^
main.c:51:7: error: 'i' undeclared (first use in this function)
   51 |   for(i = 0; i < n; i++){
      |       ^
main.c:58:20: error: 'a' undeclared (first use in this function)
   58 |     scanf("%d %d",&a,&b);
      |                    ^
main.c:58:23: error: 'b' undeclared (first use in this function)
   58 |     scanf("%d %d",&a,&b);
      |                       ^
main.c:59:9: error: 'j' undeclared (first use in this function)
   59 |     for(j = 0; j < b; j++){
      |         ^
main.c:60:19: error: 'c' undeclared (first use in this function)
   60 |       scanf("%d",&c);
      |                   ^
main.c:63:26: error: 'r' undeclared (first use in this function)
   63 |       else if (j >= 1) T[r].r = c;
      |                          ^
Language: C

#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node {int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u)
{
  int i, c;
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p << ", ";
  cout << "depth = " << D[u] << ", ";

  if(T[u].p == NIL) cout << "root, ";
  else if(T[u].l == NIL) cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";

  for(i=0, c=T[u].l; c!=NIL; i++, c=T[c].r)
  {
    if(i)cout << ", ";
    cout << c;
  }
  cout << "]" << endl;
}

//再帰的に深さを求める
int rec(int u, int p)
{
  D[u]=p;
  if(T[u].r != NIL) rec(T[u].r, p);
  if(T[u].l != NIL) rec(T[u].l, p+1);
}

int main(){
  int i, j, d, v, c, l, r;
  cin >> n;

  for(i=0; i<n; i++)
    T[i].p=T[i].l=T[i].r=NIL;

  for(i=0; i<n; i++)
  {
    cin >> v >> d;
    for(j=0; j<d; j++)
    {
      cin >> c;
      if(j == 0) T[v].l=c;
      else T[l].r=c;
      l=c;
      T[c].p=v;
    }
  }
  for(i=0; i<n; i++)
  {
    if(T[i].p == NIL)
      r=i;
  }

  rec(r, 0);

  for(i=0; i<n; i++)
    print(i);

  return 0;
}


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

import java.util.Scanner;
public class Main{
 static int[][] tree;
 static int[]par;
	public static void main(String[] args) {
	int x,i,j,n,pn,swi=0,root = 0;
	// TODO Auto-generated method stub
     Scanner sca = new Scanner(System.in);
     n=sca.nextInt();
     tree = new int[n][n+1];
     par=new int[n];
    for(j=0;j<n;j++){
    	x=sca.nextInt();
	if(j==0)root=x;
    	tree[x][n]=pn=sca.nextInt();
    	for(i=0;i<pn;i++) {
    		tree[x][i]=sca.nextInt();
    	}
    	if(swi==0&&pn!=0){
    		swi=-1;
    		root=x;
    	}
    }
    chain(root,n,-1);
     for(i=0;i<n;i++){
    	 System.out.print("node "+i+": parent = "+ par[i]+", depth = "+serdepth(i,0)+", ");
    	if(par[i]==-1){
    	System.out.print("root, [");
    	}else if(tree[i][n]==0){
    	 System.out.print("leaf, [");
    	}else{
    		System.out.print("internal node, [");
    	}
    	for(j=0;j<tree[i][n];j++){
    		System.out.print(tree[i][j]);
    		if(j+1<tree[i][n]){
    			System.out.print(", ");
    		}
    	}
	   System.out.println("]");	   
   
  }
	}
    public static void chain(int chi,int n,int p){
	int i;
	 par[chi]=p;
	if(tree[chi][n]==0)return;
	for(i=0;i<tree[chi][n];i++){
	    chain(tree[chi][i],n,chi);
	}
	}
	public static int serdepth(int x,int cnt){
		if(par[x]==-1)return cnt;
		cnt++;
		return serdepth(par[x],cnt);
	}
}


Compiler output:
main.c:1:1: error: unknown type name 'import'
    1 | import java.util.Scanner;
      | ^~~~~~
main.c:1:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    1 | import java.util.Scanner;
      |            ^
main.c:2:1: error: unknown type name 'public'
    2 | public class Main{
      | ^~~~~~
main.c:2:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Main'
    2 | public class Main{
      |              ^~~~
Language: C

#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node {int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u){
  int i, c;
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p << ", ";
  cout << "depth = " << D[u] << ", ";

  if(T[u].p == NIL) cout << "root, ";
  else if(T[u].l == NIL) cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";

  for(i = 0, c = T[u].l; c != NIL; i++, c = T[c].r){
    if(i) cout << ", ";
    cout << c;
  }
  cout << "]" << endl;
}

int rec(int u, int p){
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r, p);
  if(T[u].l != NIL) rec(T[u].l, p+1);
}

int main(){
  int i, j, d, v, c, l, r;
  cin >> n;
  for(i=0;i<n;i++) T[i].p=T[i].l=T[i].r=NIL;

  for(i=0;i<n;i++){
    cin>>v>>d;
    for(j=0;j<d;j++){
      cin>>c;
      if(j==0) T[v].l=c;
      else T[l].r=c;
      l=c;
      T[c].p=v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p==NIL) r=i;
  }

  rec(r,0);

  for(i=0;i<n;i++) print(i);

  return 0;
}



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

#include<stdio.h>
#include<stdlib.h>
typedef struct Node{
  int id;
  int k;
  struct Node *p;
  struct Node *c;
}node;

int getdepth(node);
char* gettype(node);
void drowchildren(node);

int main(){

  int i,j;
  int a,n;

  //input
  scanf("%d",&n);
  node tree[n];
  for(i=0;i<n;i++){
    tree[i].p=NULL;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&tree[i].id,&tree[i].k);
    tree[i].c=malloc(tree[i].k*sizeof(node));
    for(j=0;j<tree[i].k;j++){
      scanf("%d",&tree[i].c[j].id);
      tree[tree[i].c[j].id].p=&tree[i];
    }
  }
  //output
  for(i=0;i<n;i++){
    printf("node %d: ",i);
    if(tree[i].p==NULL) printf("parent = -1, ");
    else printf("parent = %d, ",tree[i].p->id);
    printf("depth = %d, ",getdepth(tree[i]));
    printf("%s, ",gettype(tree[i]));
    drowchildren(tree[i]);
  }
  
  //free 
  for(i=0;i<n;i++){
    free(tree[i].c);
  }
  return 0;
}

int getdepth(node tree){

  int count=0;
  node *q;
  
  if(tree.p==NULL) return 0;
  q=&tree;
  while(q->p!=NULL){
    q=q->p;
    count++;
  }
  return count;
}
char* gettype(node tree){
  if(tree.p==NULL) return "root";
  if(tree.k>=1) return "internal node";
  else return "leaf";
}
void drowchildren(node tree){

  int i;

  if(tree.k==0){
    printf("[]\n");
  }
  else{
    printf("[");
    for(i=0;i<tree.k;i++){
      if(i==tree.k-1) printf("%d",tree.c[i]);
      else printf("%d, ",tree.c[i]);
    }
    printff("]\n");
  }
}



Compiler output:
main.c: In function 'drowchildren':
main.c:81:5: error: implicit declaration of function 'printff'; did you mean 'printf'? [-Wimplicit-function-declaration]
   81 |     printff("]\n");
      |     ^~~~~~~
      |     printf
Language: C

#include<stdio.h>
#include<stdlib.h>
typedef struct Node{
  int id;
  int k;
  struct Node *p;
  struct Node *c;
}node;

int getdepth(node);
char* gettype(node);
void drowchildren(node);

int main(){

  int i,j;
  int a,n;

  //input
  scanf("%d",&n);
  node tree[n];
  for(i=0;i<n;i++){
    tree[i].p=NULL;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&tree[i].id,&tree[i].k);
    tree[i].c=malloc(tree[i].k*sizeof(node));
    for(j=0;j<tree[i].k;j++){
      scanf("%d",&tree[i].c[j].id);
      tree[tree[i].c[j].id].p=&tree[i];
    }
  }
  //output
  for(i=0;i<n;i++){
    printf("node %d: ",i);
    if(tree[i].p==NULL) printf("parent = -1, ");
    else printf("parent = %d, ",tree[i].p->id);
    printf("depth = %d, ",getdepth(tree[i]));
    printf("%s, ",gettype(tree[i]));
    //drowchildren(tree[i]);
    if(tree.k==0){
      printf("[]\n");
    }
    else{
      printf("[");
      for(j=0;j<tree.k;j++){
	if(j==tree.k-1) printf("%d",tree.c[j]);
	else printf("%d, ",tree.c[j]);
      }
      printf("]\n");
    }
  }
  
  //free 
  for(i=0;i<n;i++){
    free(tree[i].c);
  }
  return 0;
}

int getdepth(node tree){

  int count=0;
  node *q;
  
  if(tree.p==NULL) return 0;
  q=&tree;
  while(q->p!=NULL){
    q=q->p;
    count++;
  }
  return count;
}
char* gettype(node tree){
  if(tree.p==NULL) return "root";
  if(tree.k>=1) return "internal node";
  else return "leaf";
}
void drowchildren(node tree){

  int i;

  if(tree.k==0){
    printf("[]\n");
  }
  else{
    printf("[");
    for(i=0;i<tree.k;i++){
      if(i==tree.k-1) printf("%d",tree.c[i]);
      else printf("%d, ",tree.c[i]);
    }
    printf("]\n");
  }
}



Compiler output:
main.c: In function 'main':
main.c:41:12: error: '(node *)&tree' is a pointer; did you mean to use '->'?
   41 |     if(tree.k==0){
      |            ^
      |            ->
main.c:46:21: error: '(node *)&tree' is a pointer; did you mean to use '->'?
   46 |       for(j=0;j<tree.k;j++){
      |                     ^
      |                     ->
main.c:47:19: error: '(node *)&tree' is a pointer; did you mean to use '->'?
   47 |         if(j==tree.k-1) printf("%d",tree.c[j]);
      |                   ^
      |                   ->
main.c:47:41: error: '(node *)&tree' is a pointer; did you mean to use '->'?
   47 |         if(j==tree.k-1) printf("%d",tree.c[j]);
      |                                         ^
      |                                         ->
main.c:48:32: error: '(node *)&tree' is a pointer; did you mean to use '->'?
   48 |         else printf("%d, ",tree.c[j]);
      |                                ^
      |                                ->
Language: C

typedef struct
{
    int id;
    int degree;
    int *children;
    int parent;
    int depth;
    int quilty;
}Node;
#include <stdio.h>
#include <stdlib.h>

/*
 * 
 */
void findParent(Node *node, int size);
int findDepth(Node a, Node *node);
void quilty(Node *a, int size);
int main(int argc, char** argv) {
    int size;
    scanf("%d",&size);
    Node node[size];
    for(int i = 0; i<size;i++)
    {
        scanf("%d",&node[i].id);
        scanf("%d",&node[i].degree);
        node[i].children = (int*)malloc(sizeof(int)*node[i].degree);
        if(node[i].degree != 0)
        {
            for(int j=0; j < node[i].degree; j++)
            {
                int readScan = scanf("%d",&node[i].children[j]);
                node[node[i].children[j]].parent = node[i].id;
            } 
        }
    }
    
    
    
   for(int i=0; i<size;i++)
    {
       if(node[i].parent == NULL||node[i].parent > size||node[i].parent < 0)
           node[i].parent = -1;
    }
    for(int i=0; i<size;i++)
    {
        node[i].depth = findDepth(node[i], node);
    }
    
    quilty(node, size);
    
    for(int i= 0; i<size;i++)
    {
        printf("node %d: ", node[i].id);
        printf("parent = %d, ", node[i].parent);
        printf("depth = %d, ", node[i].depth);
        if(node[i].quilty==1)
        {
            printf("root, ");
        }
        if(node[i].quilty==2)
        {
            printf("internal node, ");
        }
        if(node[i].quilty==3)
        {
            printf("leaf, ");
        }

        printf("[");
        for(int j=0; j < node[i].degree; j++)
        {
            if(j<node[i].degree-1)
            {
                printf("%d, ",node[i].children[j]);
            }
            if(j==node[i].degree-1)
            {
                printf("%d",node[node[i].children[j]]);
            }
        }
        printf("]\n");
    }
  

    return (EXIT_SUCCESS);
}



int findDepth(Node a, Node *node)
{
    int count = 0;
    if(a.parent != -1)
    {
        count = count + findDepth(node[a.parent], node);
        count++;
    }
    return count;
}

void quilty(Node *a, int size)
{
    for(int i=0;i<size;i++)
    {
        if( a[i].parent==-1)
        {
            a[i].quilty=1;
        }
        if(a[i].degree!=0 && a[i].parent !=-1)
        {
            a[i].quilty=2;
        }
        if(a[i].degree==0 && a[i].parent!=-1)
        {
            a[i].quilty=3;
        }
  
    }
}

  
    }
}



Compiler output:
main.c: In function 'main':
main.c:42:26: warning: comparison between pointer and integer
   42 |        if(node[i].parent == NULL||node[i].parent > size||node[i].parent < 0)
      |                          ^~
main.c: At top level:
main.c:123:5: error: expected identifier or '(' before '}' token
  123 |     }
      |     ^
main.c:124:1: error: expected identifier or '(' before '}' token
  124 | }
      | ^
Language: C

#include<stdio.h>
struct Node{
  int a,b,c;
};
struct Node N[100000];
int h,o,S[100000];

int depth(int);

int main(){
  int i,j,k,l,m,n,q,e;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    N[i].a=-1;
    N[i].b=-1;
    N[i].c=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&l,&m);
    for(j=0;j<m;j++){
      scanf("%d",&q);
      if(j==0){
        N[l].b=q;
      }
      else{
        N[l].c=q;
      }
      l=q;
      N[q].a=l;
      }
    }
    o=0;
    for(i=0;i<n;i++){
      S[i]=depth(i);
      if(S[i]>o){
        o=S[i];
      }
    }
    for(i=0;i<n;i++){
      printf("node %d: ",i);
      printf("parent = %d, ",N[i].a);
      printf("depth = %d, ",S[i]);
      if(N[i].a==-1){
        printf("root, ");
      }
      else if(N[i].b==-1){
        printf("leaf, ");
      }
      else{
        printf("internal node, ");
      }
      printf("[");
      for(j=0,e=N[i].b;e!=-1;j++,e=N[e].c){
        if(j>0){
          printf(", ");
        }
        printf("%d",e)
      }
      printf("]\n");
    }
    return 0;
}

int depth(int r){
  int a=0;
  while(N[r].a==-1){
    r=N[r].a;
    a++;
  }
  return a;
}



Compiler output:
main.c: In function 'main':
main.c:57:23: error: expected ';' before '}' token
   57 |         printf("%d",e)
      |                       ^
      |                       ;
   58 |       }
      |       ~
Language: C

#include<stdio.h>
typedef struct{
  int left,right,parent;
}node;
int main(){
  int id,n,i,j,d,t,x;
  node A[100000];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    A[i].parent = A[i].right = A[i].left = -1;
  for(i=0;i<n;i++){
    scanf("%d %d",&id,&t);
    for(j=0;j<t;j++){
      scanf("%d",&c);
      A[c].parent = id;
      if(j == 0)A[id].left = c;
      else A[x].right = c;
      x = c;
    }
  }
  for(i=0;i<n;i++){  
    x = A[i].parent;
    d = 0;
    while(x != -1){
      x = A[x].parent;
      d++;
    }
    printf("node %d: parent = %d, depth = %d, ",i,A[i].parent,d);
    if(A[i].parent == -1)printf("root, [");
    else if(A[i].left == -1)printf("leaf, [");
    else printf("internal node, [");
    x = A[i].left;
    if(x != -1){
      printf("%d",A[i].left);
      while(A[x].right != -1){
    printf(", %d",A[x].right);
    x = A[x].right;
      }
    }
    printf("]\n");
  }
    return 0;
}





Compiler output:
main.c: In function 'main':
main.c:14:19: error: 'c' undeclared (first use in this function)
   14 |       scanf("%d",&c);
      |                   ^
main.c:14:19: note: each undeclared identifier is reported only once for each function it appears in
Language: C

/*ツリー構造*/
#include <stdio.h>
#include <stdlib.h>
#define N 100001

typedef struct node{
  int no;
  int depth;
  int nch;
  struct node *pa;
  int c[N];
} Node;

int n;
Node a[N], gnd;

void init();
void printTree(int);
void makeAll(int);
void relation(int, int *, int);
void depth(int);

void init(){
  gnd.depth = -1;
  gnd.no = -1;
}

void makeAll(int n){
  int i;

  for (i=0; i<n; i++){
    a[i].no = i;
    a[i].pa = &gnd;
  }
}

void relation(int num, int *c, int x){
  int i;
  
  for(i=0; i<x; i++){
    a[c[i]].pa = &a[num];
  }
}


void depth(int n){
  int i, j, count=0;
  
  j=-1;
  while(j<N){
    for (i=0; i<n; i++){
      if (a[i].pa->depth == j){
	a[i].depth = j+1;
      }
    }
    j++;
  }
  
}

void printTree(int n){
  int i, j;
  
   for (i=0; i<n; i++){
     printf("node %d: parent = %d, depth = %d, "
	    , a[i].no, a[i].pa->no, a[i].depth);
     
     if (a[i].pa->no == -1){
       printf("root, [");
       for (j=0; j<a[i].nch; j++){
	 if (j == a[i].nch-1)
	   printf("%d", a[i].c[j]);
	 else
	   printf("%d, ",a[i].c[j]);
       }
       printf("]\n");
     }
     
     else if (a[i].nch != 0){
       printf("internal node, [");
       for (j=0; j<a[i].nch; j++){
	 if (j == a[i].nch-1)
	   printf("%d", a[i].c[j]);
	 else
	   printf("%d, ",a[i].c[j]);
       }
       printf("]\n");
     }
     
     else printf("leaf, []\n");
   }
}


int main(){
  int num, root, i, j;

  init();
  
  scanf("%d", &n);
  makeAll(n);
  
  /*
  for (i=0; i<n; i++){
    printf("node %d: parent = %d\n", a[i].no, a[i].pa->no);
  }
  */
  
  for (i=0; i<n; i++){
    scanf("%d %d", &num, &root);
    a[num].nch = root;
    if (root!=0){
      for (j=0; j<root; j++)
	scanf("%d", &a[num].c[j]);
      relation(num, a[num].c, j);
    }
  }
  depth(n);

  printTree(n);
  
  return 0;
}



Compiler output:
/tmp/ccKVmhSV.o: in function `init':
main.c:(.text+0x6): relocation truncated to fit: R_X86_64_PC32 against symbol `gnd' defined in .bss section in /tmp/ccKVmhSV.o
main.c:(.text+0x10): relocation truncated to fit: R_X86_64_PC32 against symbol `gnd' defined in .bss section in /tmp/ccKVmhSV.o
/tmp/ccKVmhSV.o: in function `makeAll':
main.c:(.text+0x5a): relocation truncated to fit: R_X86_64_PC32 against symbol `gnd' defined in .bss section in /tmp/ccKVmhSV.o
collect2: error: ld returned 1 exit status
Language: C

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

struct NODE{
  int id,k,p,depth;
  int *next;
  char *type;
};

struct NODE *root;
int n;
void makedepth(struct NODE);
int main(){
  int i,j,l,m,;
  struct NODE temp;
  scanf("%d",&n);
  root=(struct NODE *)malloc(sizeof(struct NODE)*n);
  for(i=0;i<n;i++){
    root[i].p=-1;
    root[i].depth=0;
  }
  for(i=0;i<n;i++){
    scanf("%d",&root[i].id);
    scanf("%d",&root[i].k);
    root[i].next=malloc(sizeof(int)*root[i].k);
      for(j=0;j<root[i].k;j++){
	scanf("%d",&m);
	root[i].next[j]=m;
      }
    }
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      for(l=0;l<root[i].k;l++){
	if(root[i].next[l]==root[j].id)root[j].p=root[i].id;
      }
    }
  }
  for(i=0;i<n;i++){
    
    if(root[i].p==-1)makedepth(root[i]);
    
  }
  for(i=0;i<n;i++){
    for(j=n-1; j>i; j--){
      if(root[j].id < root[j-1].id){
        temp = root[j];
        root[j] = root[j-1];
        root[j-1] = temp;
      }
    }

  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(root[i].p==-1)root[i].type="root";
      else if(root[i].p!=-1&&root[i].k!=0)root[i].type="internal node";
      else root[i].type="leaf";
      if(root[i].id==j){
	printf("node %d: parent = %d, depth = %d, %s, [",root[i].id,root[i].p,root[i].depth,root[i].type);
	for(l=0;l<root[i].k;l++){
	  if(l+1==root[i].k)printf("%d",root[i].next[l]);
	  else printf("%d, ",root[i].next[l]);
	}
	printf("]\n");
      }
    }
  }
  return 0;
}

void makedepth(struct NODE Root){
  int i;
  for(i=0;i<n;i++){
    if(Root.id==root[i].p){
      root[i].depth=Root.depth+1;
      if(root[i].k!=0)makedepth(root[i]);
    }
  }
}



Compiler output:
main.c: In function 'main':
main.c:14:15: error: expected identifier or '(' before ';' token
   14 |   int i,j,l,m,;
      |               ^
Language: C

#include<stdio.h>

int parent[100001];
int count[100001];
int root[100001][100001];
int flag[100001];
int depth(int);

int main()
{
  int i,n,k,id,c,node;

  scanf("%d",&n);
  
  for(i=0; i<n; i++){
    parent[i] = -1;
    flag[i] = 1;
  }
  
  for(i=0; i<n; i++){
    scanf("%d %d",&id,&k);
    count[id]=k;
    node=0;
    while(k-->=1){
      scanf("%d",&c);
      root[id][node++]=c;
      parent[c]=id;
      flag[id]=0;
    }
  } 
    
    for(i=0; i<n; i++){
      int j,l;
      printf("node %d: parent = %d, depth = %d, ",i,parent[i],depth(i));
      if(flag[i]==1 && depth(i)==0){
	printf("root, []\n");
      }

      else if(flag[i] == 1)
	printf("leaf, []\n");

      else if(depth(i) == 0){
	printf("root, [");
	for(j=0; j<count[i]-1; j++){
	    printf("%d, ",root[i][j]);
	    }
	  printf("%d]\n",root[i][j]);
	  l=j+1;
      }

      else{
	printf("internal node, [");
	for(j=0; j<count[i]-1; j++){
	    printf("%d, ",root[i][j]);
	    }
	  printf("%d]\n",root[i][j]);
      }
    }
    return 0;
}

int depth(int i){
  if(parent[i] == -1)return 0;
  else return depth(parent[i])+1;
}



Compiler output:
/tmp/ccLJL24Z.o: in function `main':
main.c:(.text+0x57): relocation truncated to fit: R_X86_64_PC32 against symbol `flag' defined in .bss section in /tmp/ccLJL24Z.o
main.c:(.text+0x136): relocation truncated to fit: R_X86_64_PC32 against symbol `flag' defined in .bss section in /tmp/ccLJL24Z.o
main.c:(.text+0x1ba): relocation truncated to fit: R_X86_64_PC32 against symbol `flag' defined in .bss section in /tmp/ccLJL24Z.o
main.c:(.text+0x1f8): relocation truncated to fit: R_X86_64_PC32 against symbol `flag' defined in .bss section in /tmp/ccLJL24Z.o
collect2: error: ld returned 1 exit status
Language: C

/*id�̃\�[�g���K�v*/


#include<stdio.h>
#include<string.h>
#define N 100000

typedef struct{

	int id;
	int p;
	int d;
	int k;
	char type[20];
	int c[20];
}node;

node no[N];

int main()
{
	int i,j,n,l=0,m;
  
	while(1)
	{
		scanf("%d",&n);
		if(n >= 1 && n <= N) break;
	}

	for(i = 0;i < n; i++)
	{
		no[i].p = -1;
		scanf("%d%d",&no[i].id,&no[i].k);
		for(j = 0; j < no[i].k; j++) scanf("%d",&no[i].c[j]);
	}

	for(i = 0;i < n;i++)
	{
		for(j = i+1;j < n;j++)
		{
			if(no[i].id > no[j].id)
			{
				tmp = no[i].id;
				no[i].id = no[j].id;
				no[j].id = tmp;
				
				tmp = no[i].k;
				no[i].k = no[j].k;
				no[j].k = tmp;


				if(no[i].k - no[j].k >= 0) l = no[i].k;
				else l = no[j].k;

				for(m = 0;m < l;m++)
				{
					tmp = no[i].c[m];
					no[i].c[m] = no[j].c[m];
					no[j].c[m] = tmp;
				}
			}
		}
	}

	for(i=0;i<n;i++)
	{
		if(no[i].k != 0) strcpy(no[i].type,"internal node");
		else strcpy(no[i].type,"leaf");
	}

	for(i = 0; i < n; i++)
	{
		for(j = 0; j < n; j++)
			for(m = 0; m < no[j].k; m++)
				if(no[i].id == no[j].c[m]) no[i].p = no[j].id;
	}

	for(i = 0; i < n; i++)	
		if((strcmp(no[i].type,"internal node") == 0) || (strcmp(no[i].type,"leaf") == 0)) no[i].d = no[no[i].p].d + 1;		
	
	for(i = 0; i < n; i++)
	{
		printf("node %d: parent = %d, depth = %d, %s, [",no[i].id,no[i].p,no[i].d,no[i].type);
		if(no[i].k == 0) printf("]\n");
		else
		{
			for(j = 0; j < no[i].k - 1; j++) printf("%d, ",no[i].c[j]);
			printf("%d]\n",no[i].c[j]);
		}
	}

 	 return 0;
}


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

#include<stdio.h>
#define max 100005
#define NIL -1

typedef struct{
  int p;
  int l;
  int r;
}Node;

Node T[max];
int n,H,D[max];

int Depth(int u){
  int d=0;
  for(;T[u].p!=NIL;d++) u=T[u].p;
  return d;
}

void print(int u){

  int main(){
    int i,j,k,id,c,l;

    scanf("%d",&n);

    for(i=0;i<n;i++) T[i].p=T[i].l=T[i].r=NIL;

    for(i=0;i<n;i++){
      scanf("%d%d",&id,&k);
      for(j=0;j<k;j++){
	scanf("%d",&c);
	if(j==0) T[id].l=c;
	else T[l].r=c;
	l=c;
	T[c].p=id;
      }
    }

    H=0;
    for(i=0;i<n;i++){
      D[i]=Depth(i);
      if(D[i]>H) H=D[i];
    }

    for(i=0;i<n;i++){
      printf("node %d: parent = %d, depth = %d, ",i,T[i].p,D[i]);

      if(T[i].p==NIL) printf("root, ");
      else if(T[i].l==NIL) printf("leaf, ");
      else printf("internal node, ");

      printf("[");
      for(j=0,c=T[i].l;c!=NIL;j++,c=T[c].r){
	if(j) printf(", ");
	printf("%d",c);
      }
      printf("]\n");
    }
  }
  return 0;
}



Compiler output:
main.c: In function 'print':
main.c:61:10: error: 'return' with a value, in function returning void [-Wreturn-mismatch]
   61 |   return 0;
      |          ^
main.c:20:6: note: declared here
   20 | void print(int u){
      |      ^~~~~
Language: C

#include<stdio.h>

#define MAX 100000

typedef struct{
  int parent;
  int right;
  int left;
}Tree;

Tree tree[MAX];
int n,tt[MAX];

void ccccc(int,int);

int main(){
  int i,j,q,r,c,right,left;

  scanf("%d",&n);

  for( i = 0 ; i < n ; i++ )
    {
      tree[i].parent = -1;
      tree[i].right = -1;
      tree[i].left = -1;
    }

  for( i = 0 ; i < n ; i++ )
    {
      scanf("%d%d",&r,&q);
      for( j = 0 ; j < q ; j++ )
        {
          scanf("%d",&c);
          if( j == 0 ) tree[i].left=c;
          else tree[left].right = c;
          left = c;
          tree[c].parent = i;
        }
    }

  for( i = 0 ; i < n ; i++ ){
    if(tree[i].parent == -1) right =i;
  }

  ccccc(right,0);

  for(i = 0 ; i < n ; i++ ){
    printf("node %d: parent = %d, depth = %d, ",i,tree[i].parent,tt[i]);
    if(tree[i].parent == -1 ) printf("root, [");
    else if(tree[i].left == -1 ) printf("leaf, [");
    else printf("internal node, [");

    for(j = 0,c=tree[i].left;c!=-1;j++,c=tree[c].right){
      if(j) printf(", ");
      printf("%d",c);
    }
    printf("]\n");
  }

  return 0;
}

void (int u,int p){
  tt[u]=p;
  if(tree[u].right!=-1) ccccc(tree[u].right,p);
  if(tree[u].left!=-1) ccccc(tree[u].left,p+1);
}



Compiler output:
main.c:63:7: error: expected identifier or '(' before 'int'
   63 | void (int u,int p){
      |       ^~~
Language: C

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

#define MAX 100005
#define NIL -1

struct Node{
  int p, l, r;
};

struct Node T[MAX];
int n, D[MAX];

void print(int u){
  int i, c;
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p  << ", ";
  cout << "depth = " << D[u] << ", ";
  if(T[u].p==NIL) cout << "root, ";
  else if(T[u].l==NIL) cout << "leaf, ";
  else cout << "internal node, ";
  cout << "[";
  for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
    if(i!=0) cout << ", ";
    cout << c;
  }
  cout << "]" <<endl;
}

int setDepth(int u, int p){
  D[u]=p;
  if(T[u].r!=NIL) setDepth(T[u].r,p);
  if(T[u].l!=NIL) setDepth(T[u].l,p+1);
}

int main(){
  int i,j,d,v,c,l,r;
  cin >> n;
  for(i=0;i<n;i++) T[i].p=T[i].l=T[i].r=NIL;

  for(i=0;i<n;i++){
    cin >> v >> d;
    for(j=0;j<d;j++){
      cin >>c;
      if(j==0) T[v].l=c;
      else T[l].r=c;
      l=c;
      T[c].p=v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p==NIL) r=i;
  }

  setDepth(r,0);
  for(i=0;i<n;i++) print(i);

  return 0;
}


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

#include<stdio.h>
#define M 100005
#define N -1

struct Node{ int p, l, r;};
struct Node t[MAX];
int n, H, d[MAX];

int Depth(int u){
  int x = 0;
  for(; t[u].p != N ;x++) u = t[u].p;
  return x;
}

void print(int u){
  int i, c;
  printf("node %d: ", u);
  printf("parent = %d, ", t[u].p);
  printf("depth = %d, ", d[u]);

  if ( t[u].p == N ) printf("root, ");
  else if ( t[u].l == N ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for(i = 0, c = t[u].l; c != N; i++, c = t[c].r){
    if (i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}

main(){
  int i, j, s, v, c, l;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) t[i].p = t[i].l = t[i].r = N;

  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &v, &s);
    for ( j = 0; j < s; j++ ){
      scanf("%d", &c);
      if ( j == 0 ) t[v].l = c;
      else t[l].r = c;
      l = c;
      t[c].p = v;
    }
  }

  H = 0;
  for ( i = 0; i < n; i++ ){
    d[i] = Depth(i);
    if ( d[i] > H ) H = d[i];
  }

  for ( i = 0; i < n; i++ ) print(i);
  return 0;
}



Compiler output:
main.c:6:15: error: 'MAX' undeclared here (not in a function)
    6 | struct Node t[MAX];
      |               ^~~
main.c:33:1: error: return type defaults to 'int' [-Wimplicit-int]
   33 | main(){
      | ^~~~
Language: C

#include <stdio.h>
#define N 200001
#define NT -1

struct Node{
    int p,left,right;
};

struct Node T[N];
int getDepth(int p){
    if(T[p].p == NT) return 0;
    return getDepth(T[p].p)+1;
}
int main()
{
    int n,i,key,j,c;
    int id,temp;
    int depth[N];

    scanf("%d",&n);

    for( i=0;i<n;i++){

      T[i].p=T[i].left=T[i].right=NT;
    }
    
    for(i=0;i<n;i++){

      scanf("%d%d",&id,&key);

	for(j=0;j<key;j++){

	  scanf("%d",&c);

	    if(j==0){
                T[id].left=c;
                T[c].p=id;
                temp=c;
            }

	    else{
                T[temp].right=c;
                T[c].p=id;
                temp=c;
            }
        }
    }
    for(i=0;i<n;i++)
      depth[i]=getDepth(i);
    
    for(i=0;i<n;i++){
      printf("node %d: parent = %d, depth = %d, ",i,T[i].p,depth[i]);

      ifif(T[i].p==NT)
	printf("root, [");
      else  if(T[i].left==NT)
	printf("leaf, [");
       
      else
	printf("internal node, [");

      if(T[i].left != NT){
	printf("%d",T[i].left);
                temp = T[i].left;
		
                while(1){
                    if(T[temp].right==NT) break;
                    printf(", %d",T[temp].right);
                    temp = T[temp].right;
                }
		
            }
            printf("]\n");
        }
  return 0;
}



Compiler output:
main.c: In function 'main':
main.c:54:7: error: implicit declaration of function 'ifif' [-Wimplicit-function-declaration]
   54 |       ifif(T[i].p==NT)
      |       ^~~~
main.c:54:23: error: expected ';' before 'printf'
   54 |       ifif(T[i].p==NT)
      |                       ^
      |                       ;
   55 |         printf("root, [");
      |         ~~~~~~         
main.c:56:7: error: 'else' without a previous 'if'
   56 |       else  if(T[i].left==NT)
      |       ^~~~
Language: C

#include<iostream>
using namespace std;

#define MAX 100005
#define NIL -1

struct Node
{
  int p, l, r;
};

Node T[MAX];
int n, D[MAX];

void print(int u){
  int i, c;

  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p << ", ";
  cout << "depth = " << D[u] << ", ";

  if(T[u].p == NIL) cout << "root, ";
  else if(T[u].l == NIL) cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";

  for(i=0, c = T[u].l; c != NIL; i++, c = T[c].r)
  {
    if(i)cout << ", ";
    cout << c;
  }
  cout << "]" << endl;
}

int rec(int u, int p){
  D[u]=p;
  if(T[u].r != NIL) rec(T[u].r, p);
  if(T[u].l != NIL) rec(T[u].l, p+1);
}

int main(){
  int i, j, d, v, c, l, r;

  cin >> n;

  for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;

  for(i=0; i<n; i++){
    cin >> v >> d;
    for(j=0; j<d; j++){
      cin >> c;
      if(j == 0) T[v].l = c;
      else T[l].r = c;
      T[c].p = v;
    }
  }

  for(i=0; i<n; i++){
    if(T[i].p == NIL) r=i;
  }

  rec(r,0);

  for(i=0; i<n; i++) print(i);

  return 0;
}



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

#include<stdio.h>
#define MAX 100000
typedef struct{
  int p,l,r;
}Rooted;
  struct Rooted N[MAX];
  int n,H,D[MAX];

int Depth(int i){
  int d=0;
  while(N[i].p != -1){
    i=N[i].p;
    d++;
  }
  return d;
}
void print(int i){
  int j=0,c;
  printf("node %d: ",i);
  printf("parent = %d,",N[i].p);
  printf("depth = %d,",D[i]);
  if(N[i].p==-1)printf("root, ");
  else if(N[i].l == -1)printf("leaf, ");
  else printf("internal node,");
  printf("[");
  if(N[i].l != -1){
      printf("%d",N[i].l);
      c=N[i].l;
  while(c!=-1){ 
    printf(", %d",c);
     c=N[c].r;  
  }
  }
  printf("]\n");
}
    
int main(){
  int id,k,c;
  int i,j,l;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    N[i].p=N[i].l=N[i].r=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&k,&id);
    for(j=0;j<id;j++){
      scanf("%d",&c);
      if(j==0){
	N[k].l=c;
      }
      else N[l].r=c;
      l=c;
      N[c].p=k;
    }
  }
  H=0;
  for(i=0;i<n;i++){
    D[i]=Depth(i);
    if(D[i]>H)H=D[i];
  }
  for(i=0;i<n;i++)print(i);
  return 0;
}



Compiler output:
main.c:6:17: error: array type has incomplete element type 'struct Rooted'
    6 |   struct Rooted N[MAX];
      |                 ^
Language: C

#include<stdio.h>
#define MAX 1000
struct Rooted{
  int p,l,r;
}
  struct Rooted N[MAX];
  int n,H,D[MAX];

int Depth(int i){
  int d=0;
  while(N[i].p != -1){
    i=N[i].p;
    d++;
  }
  return d;
}
void print(int i){
  int j=0,c;
  printf("node %d: ",i);
  printf("parent = %d, ",N[i].p);
  printf("depth = %d, ",D[i]);
  if(N[i].p==-1)printf("root, ");
  else if(N[i].l == -1)printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  if(N[i].l != -1){
      printf("%d",N[i].l);
      c=N[i].l;
  while(c!=-1){ 
    printf(", %d",c);
     c=N[c].r;  
  }
  }
  printf("]\n");
}
    
int main(){
  int id,k,c;
  int i,j,l;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    N[i].p=N[i].l=N[i].r=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&k,&id);
    for(j=0;j<id;j++){
      scanf("%d",&c);
      if(j==0){
	N[k].l=c;
      }
      else N[l].r=c;
      l=c;
      N[c].p=k;
    }
  }
  H=0;
  for(i=0;i<n;i++){
    D[i]=Depth(i);
    if(D[i]>H)H=D[i];
  }
  for(i=0;i<n;i++)print(i);
  return 0;
}



Compiler output:
main.c:6:3: error: expected ';', identifier or '(' before 'struct'
    6 |   struct Rooted N[MAX];
      |   ^~~~~~
Language: C

#include<iostream>
using namespace std;

#define MAX 100005
#define NIL -1

struct Node
{
  int p, l, r;
};

Node T[MAX];
int n, D[MAX];

void print(int u){
  int i, c;

  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p << ", ";
  cout << "depth = " << D[u] << ", ";

  if(T[u].p == NIL) cout << "root, ";
  else if(T[u].l == NIL) cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";

  for(i=0, c = T[u].l; c != NIL; i++, c = T[c].r)
  {
    if(i)cout << ", ";
    cout << c;
  }
  cout << "]" << endl;
}

int rec(int u, int p){
  D[u]=p;
  if(T[u].r != NIL) rec(T[u].r, p);
  if(T[u].l != NIL) rec(T[u].l, p+1);

  return 0;
}

int main(){
  int i, j, d, v, c, l, r;

  cin >> n;

  for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;

  for(i=0; i<n; i++){
    cin >> v >> d;
    for(j=0; j<d; j++){
      cin >> c;
      if(j == 0) T[v].l = c;
      else T[l].r = c;
      T[c].p = v;
    }
  }

  for(i=0; i<n; i++){
    if(T[i].p == NIL) r=i;
  }

  rec(r,0);

  for(i=0; i<n; i++) print(i);

  return 0;
}



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

#include<stdio.h>
#define MAX 1000
struct Rooted{
  int p,l,r;
};
  struct Rooted N[MAX];
  int n,H,D[MAX];

int Depth(int i){
  int d=0,x;
  while(N[i].p != -1){
    d++;
    x=N[i].p;
    i=x ;
  }
  return d;
}
void print(node *N,int i){
  int c;
  printf("node %d: ",i);
  printf("parent = %d, ",N[i]);
  printf("depth = %d, ",Depth(i));
  if(N[i].p==-1)printf("root, ");
  if(N[i].p == -1 && N[i].l == -1)printf("leaf, ");
  if(N[i].p == -1 && N[i].l != -1)printf("internal node, ");
  printf("[");
  if(N[i].l != -1){
      printf("%d",N[i].l);
      c=N[i].l;
  while(N[c].r!=-1){ 
    printf(", %d",N[c].r);
     c=N[c].r;  
  }
  }
  printf("]\n");
}
    
int main(){
  int id,k,c;
  int i,j,l;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    N[i].p=-1;
    N[i].l=-1;
    N[i].r=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&id,&k);
    for(j=0;j<k;j++){
      scanf("%d",&c);
      if(j==0){
	N[id].l=c;
      }
      else N[l].r=c;
      l=c;
      N[c].p=id;
    }
  }
  for(i=0;i<n;i++)print(N,i);
  return 0;
}



Compiler output:
main.c:18:12: error: unknown type name 'node'
   18 | void print(node *N,int i){
      |            ^~~~
main.c: In function 'main':
main.c:60:19: error: implicit declaration of function 'print'; did you mean 'printf'? [-Wimplicit-function-declaration]
   60 |   for(i=0;i<n;i++)print(N,i);
      |                   ^~~~~
      |                   printf
Language: C

#include<stdio.h>
#define MAX 1000
struct Rooted{
  int p,l,r;
};
  struct Rooted N[MAX];
  int n,H,D[MAX];

int Depth(int i){
  int d=0,x;
  while(N[i].p != -1){
    d++;
    x=N[i].p;
    i=x ;
  }
  return d;
}
void print(Rooted *N,int i){
  int c;
  printf("node %d: ",i);
  printf("parent = %d, ",N[i]);
  printf("depth = %d, ",Depth(i));
  if(N[i].p==-1)printf("root, ");
  if(N[i].p == -1 && N[i].l == -1)printf("leaf, ");
  if(N[i].p == -1 && N[i].l != -1)printf("internal node, ");
  printf("[");
  if(N[i].l != -1){
      printf("%d",N[i].l);
      c=N[i].l;
  while(N[c].r!=-1){ 
    printf(", %d",N[c].r);
     c=N[c].r;  
  }
  }
  printf("]\n");
}
    
int main(){
  int id,k,c;
  int i,j,l;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    N[i].p=-1;
    N[i].l=-1;
    N[i].r=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&id,&k);
    for(j=0;j<k;j++){
      scanf("%d",&c);
      if(j==0){
	N[id].l=c;
      }
      else N[l].r=c;
      l=c;
      N[c].p=id;
    }
  }
  for(i=0;i<n;i++)print(N,i);
  return 0;
}



Compiler output:
main.c:18:12: error: unknown type name 'Rooted'
   18 | void print(Rooted *N,int i){
      |            ^~~~~~
main.c: In function 'main':
main.c:60:19: error: implicit declaration of function 'print'; did you mean 'printf'? [-Wimplicit-function-declaration]
   60 |   for(i=0;i<n;i++)print(N,i);
      |                   ^~~~~
      |                   printf