Language: C

edges[100001][100001], n, u, v, td[100001], ad[100001], a, b, res;

dfs (int arr[], int start, int step) {
    arr[start] = step;
    for (int i = 1; i <= n; i++) {
        if (edges[start][i] && !arr[i]) {
            dfs(arr, i, step + 1);
        }
    }
}

main () {
    scanf("%d %d %d", &n, &u, &v);
    for (int i = 1; i < n; i++) {
        scanf("%d %d", &a, &b);
        edges[a][b] = edges[b][a] = 1;
    }
    dfs(td, u, 1);
    dfs(ad, v, 1);
    for (int i = 1; i <= n; i++) {
        if (ad[i] > td[i] && ad[i] > res)
            res = ad[i];
    }

    printf("%d\n", res - 2);
}


Compiler output:
main.c:1:1: warning: data definition has no type or storage class
    1 | edges[100001][100001], n, u, v, td[100001], ad[100001], a, b, res;
      | ^~~~~
main.c:1:1: error: type defaults to 'int' in declaration of 'edges' [-Wimplicit-int]
main.c:1:24: error: type defaults to 'int' in declaration of 'n' [-Wimplicit-int]
    1 | edges[100001][100001], n, u, v, td[100001], ad[100001], a, b, res;
      |                        ^
main.c:1:27: error: type defaults to 'int' in declaration of 'u' [-Wimplicit-int]
    1 | edges[100001][100001], n, u, v, td[100001], ad[100001], a, b, res;
      |                           ^
main.c:1:30: error: type defaults to 'int' in declaration of 'v' [-Wimplicit-int]
    1 | edges[100001][100001], n, u, v, td[100001], ad[100001], a, b, res;
      |                              ^
main.c:1:33: error: type defaults to 'int' in declaration of 'td' [-Wimplicit-int]
    1 | edges[100001][100001], n, u, v, td[100001], ad[100001], a, b, res;
      |                                 ^~
main.c:1:45: error: type defaults to 'int' in declaration of 'ad' [-Wimplicit-int]
    1 | edges[100001][100001], n, u, v, td[100001], ad[100001], a, b, res;
      |                                             ^~
main.c:1:57: error: type defaults to 'int' in declaration of 'a' [-Wimplicit-int]
    1 | edges[100001][100001], n, u, v, td[100001], ad[100001], a, b, res;
      |                                                         ^
main.c:1:60: error: type defaults to 'int' in declaration of 'b' [-Wimplicit-int]
    1 | edges[100001][100001], n, u, v, td[100001], ad[100001], a, b, res;
      |                                                            ^
main.c:1:63: error: type defaults to 'int' in declaration of 'res' [-Wimplicit-int]
    1 | edges[100001][100001], n, u, v, td[100001], ad[100001], a, b, res;
      |                                                               ^~~
main.c:3:1: error: return type defaults to 'int' [-Wimplicit-int]
    3 | dfs (int arr[], int start, int step) {
      | ^~~
main.c:12:1: error: return type defaults to 'int' [-Wimplicit-int]
   12 | main () {
      | ^~~~
main.c: In function 'main':
main.c:13:5: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   13 |     scanf("%d %d %d", &n, &u, &v);
      |     ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | edges[100001][100001], n, u, v, td[100001], ad[100001], a, b, res;
main.c:13:5: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   13 |     scanf("%d %d %d", &n, &u, &v);
      |     ^~~~~
main.c:13:5: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:25:5: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   25 |     printf("%d\n", res - 2);
      |     ^~~~~~
main.c:25:5: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:25:5: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:25:5: note: include '<stdio.h>' or provide a declaration of 'printf'