Language: C

int max_color;

int main (void) {
	int a, b, i;
	
	scanf("%*d\n");
	
	for (i = 1; ~scanf("%d %d\n", &a, &b); i++) {
		list l1 = used_colors[a];
		list l2 = used_colors[b];
		int j = 1;
		
		while (true) {
			if ((!l1 || l1->val > j) && (!l2 || l2->val > j)) {
				break;
			}
			if (l1 && l1->val == j) l1 = l1->next;
			if (l2 && l2->val == j) l2 = l2->next;
			j++;
		}
		
		if (max_color < j) max_color = j;
		color[i] = j;
		used_colors[a] = insert(j, used_colors[a]);
		used_colors[b] = insert(j, used_colors[b]);
	}
	
	printf("%d\n", max_color);
	
	for (i = 1; color[i]; i++) {
		printf("%d\n", color[i]);
	}
}


Compiler output:
main.c: In function 'main':
main.c:6:9: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    6 |         scanf("%*d\n");
      |         ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | int max_color;
main.c:6:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    6 |         scanf("%*d\n");
      |         ^~~~~
main.c:6:9: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:9:17: error: unknown type name 'list'
    9 |                 list l1 = used_colors[a];
      |                 ^~~~
main.c:9:27: error: 'used_colors' undeclared (first use in this function)
    9 |                 list l1 = used_colors[a];
      |                           ^~~~~~~~~~~
main.c:9:27: note: each undeclared identifier is reported only once for each function it appears in
main.c:10:17: error: unknown type name 'list'
   10 |                 list l2 = used_colors[b];
      |                 ^~~~
main.c:13:24: error: 'true' undeclared (first use in this function)
   13 |                 while (true) {
      |                        ^~~~
main.c:1:1: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
  +++ |+#include <stdbool.h>
    1 | int max_color;
main.c:14:39: error: invalid type argument of '->' (have 'int')
   14 |                         if ((!l1 || l1->val > j) && (!l2 || l2->val > j)) {
      |                                       ^~
main.c:14:63: error: invalid type argument of '->' (have 'int')
   14 |                         if ((!l1 || l1->val > j) && (!l2 || l2->val > j)) {
      |                                                               ^~
main.c:17:37: error: invalid type argument of '->' (have 'int')
   17 |                         if (l1 && l1->val == j) l1 = l1->next;
      |                                     ^~
main.c:17:56: error: invalid type argument of '->' (have 'int')
   17 |                         if (l1 && l1->val == j) l1 = l1->next;
      |                                                        ^~
main.c:18:37: error: invalid type argument of '->' (have 'int')
   18 |                         if (l2 && l2->val == j) l2 = l2->next;
      |                                     ^~
main.c:18:56: error: invalid type argument of '->' (have 'int')
   18 |                         if (l2 && l2->val == j) l2 = l2->next;
      |                                                        ^~
main.c:23:17: error: 'color' undeclared (first use in this function)
   23 |                 color[i] = j;
      |                 ^~~~~
main.c:24:34: error: implicit declaration of function 'insert' [-Wimplicit-function-declaration]
   24 |                 used_colors[a] = insert(j, used_colors[a]);
      |                                  ^~~~~~
main.c:28:9: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   28 |         printf("%d\n", max_color);
      |         ^~~~~~
main.c:28:9: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:28:9: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:28:9: note: include '<stdio.h>' or provide a declaration of 'printf'