Language: C++

//LCA
template <typename T = ll>
struct LowestCommonAncestor {
  struct Edge {
    ll to;
    T cost;
    Edge(ll to, T cost) : to(to), cost(cost) {}
  };
  ll n;
  ll l;
  vector<vector<Edge>> es;
  vector<vector<ll>> par;
  vector<ll> dep;
  vector<T> dists;
  LowestCommonAncestor(ll n) : n(n), es(n), dep(n), dists(n + 1) {
    l = 0;
    while ((1 << l) < n) l++;
    par.assign(n + 1, vector<ll>(l, n));
  }
  void add_edge(ll v, ll u, T c = 0) {
    es[v].emplace_back(u, c);
    es[u].emplace_back(v, c);
  }
  void dfs(ll v = 0, ll d = 0, T c = 0, ll p = -1) {
    if (p != -1) par[v][0] = p;
    dep[v] = d;
    dists[v] = c;
    for (auto e : es[v]) {
      if (e.to == p) continue;
      dfs(e.to, d + 1, c + e.cost, v);
    }
  }
  void build() {
    dfs();
    for (ll i = 0; i < l - 1; i++) {
      for (ll v = 0; v < n; v++) {
        par[v][i + 1] = par[par[v][i]][i];
      }
    }
  }
  ll lca(ll v, ll u) {
    if (dep[v] < dep[u]) swap(v, u);
    ll gap = dep[v] - dep[u];
    for (ll i = l - 1; i >= 0; i--) {
      if ((1 << i) & gap) v = par[v][i];
    }
    if (v == u) return v;
    for (ll i = l - 1; i >= 0; i--) {
      ll pv = par[v][i];
      ll pu = par[u][i];
      if (pv != pu) v = pv, u = pu;
    }
    return par[v][0];
  }
  ll length(ll v, ll u) {
    ll a = lca(v, u);
    return dep[v] + dep[u] - dep[a] * 2;
  }
  T dist(ll v, ll u) {
    ll a = lca(v, u);
    return dists[v] + dists[u] - dists[a] * 2;
  }
};

Compiler output:
a.cc:2:24: error: 'll' does not name a type
    2 | template <typename T = ll>
      |                        ^~
a.cc:5:5: error: 'll' does not name a type
    5 |     ll to;
      |     ^~
a.cc:7:12: error: expected ')' before 'to'
    7 |     Edge(ll to, T cost) : to(to), cost(cost) {}
      |         ~  ^~~
      |            )
a.cc:9:3: error: 'll' does not name a type
    9 |   ll n;
      |   ^~
a.cc:10:3: error: 'll' does not name a type
   10 |   ll l;
      |   ^~
a.cc:11:3: error: 'vector' does not name a type
   11 |   vector<vector<Edge>> es;
      |   ^~~~~~
a.cc:12:3: error: 'vector' does not name a type
   12 |   vector<vector<ll>> par;
      |   ^~~~~~
a.cc:13:3: error: 'vector' does not name a type
   13 |   vector<ll> dep;
      |   ^~~~~~
a.cc:14:3: error: 'vector' does not name a type
   14 |   vector<T> dists;
      |   ^~~~~~
a.cc:15:26: error: expected ')' before 'n'
   15 |   LowestCommonAncestor(ll n) : n(n), es(n), dep(n), dists(n + 1) {
      |                       ~  ^~
      |                          )
a.cc:20:17: error: 'll' has not been declared
   20 |   void add_edge(ll v, ll u, T c = 0) {
      |                 ^~
a.cc:20:23: error: 'll' has not been declared
   20 |   void add_edge(ll v, ll u, T c = 0) {
      |                       ^~
a.cc:24:12: error: 'll' has not been declared
   24 |   void dfs(ll v = 0, ll d = 0, T c = 0, ll p = -1) {
      |            ^~
a.cc:24:22: error: 'll' has not been declared
   24 |   void dfs(ll v = 0, ll d = 0, T c = 0, ll p = -1) {
      |                      ^~
a.cc:24:41: error: 'll' has not been declared
   24 |   void dfs(ll v = 0, ll d = 0, T c = 0, ll p = -1) {
      |                                         ^~
a.cc:41:3: error: 'll' does not name a type
   41 |   ll lca(ll v, ll u) {
      |   ^~
a.cc:55:3: error: 'll' does not name a type
   55 |   ll length(ll v, ll u) {
      |   ^~
a.cc:59:10: error: 'll' has not been declared
   59 |   T dist(ll v, ll u) {
      |          ^~
a.cc:59:16: error: 'll' has not been declared
   59 |   T dist(ll v, ll u) {
      |                ^~
a.cc: In member function 'void LowestCommonAncestor<T>::add_edge(int, int, T)':
a.cc:21:5: error: 'es' was not declared in this scope
   21 |     es[v].emplace_back(u, c);
      |     ^~
a.cc: In member function 'void LowestCommonAncestor<T>::dfs(int, int, T, int)':
a.cc:25:18: error: 'par' was not declared in this scope
   25 |     if (p != -1) par[v][0] = p;
      |                  ^~~
a.cc:26:5: error: 'dep' was not declared in this scope
   26 |     dep[v] = d;
      |     ^~~
a.cc:27:5: error: 'dists' was not declared in this scope; did you mean 'dist'?
   27 |     dists[v] = c;
      |     ^~~~~
      |     dist
a.cc:28:19: error: 'es' was not declared in this scope; did you mean 'e'?
   28 |     for (auto e : es[v]) {
      |                   ^~
      |                   e
a.cc: In member function 'void LowestCommonAncestor<T>::build()':
a.cc:35:10: error: 'll' was not declared in this scope
   35 |     for (ll i = 0; i < l - 1; i++) {
      |          ^~
a.cc:35:20: error: 'i' was not declared in this scope
   35 |     for (ll i = 0; i < l - 1; i++) {
      |                    ^
a.cc:35:24: error: 'l' was not declared in this scope
   35 |     for (ll i = 0; i < l - 1; i++) {
      |                        ^
a.cc:36:15: error: expected ';' before 'v'
   36 |       for (ll v = 0; v < n; v++) {
      |               ^
a.cc:36:22: error: 'v' was not declared in this scope
   36 |       for (ll v = 0; v < n; v++) {
      |                      ^
a.cc:36:26: error: 'n' was not declared in this scope
   36 |       for (ll v = 0; v < n; v++) {
      |                          ^
a.cc:37:9: error: 'par' was not declared in this scope
   37 |         par[v][i + 1] = par[par[v][i]][i];
      |         ^~~
a.cc: In member function 'T LowestCommonAncestor<T>::dist(int, int)':
a.cc:60:5: error: 'll' was not declared in this scope
   60 |     ll a = lca(v, u);
      |     ^~
a.cc:61:12: error: 'dists' was not declared in this scope; did you mean 'dist'?
   61 |     return dists[v] + dists[u] - dists[a] * 2;
      |            ^~~~~
      |            dist
a.cc:61:40: error: 'a' was not declared in this scope
   61 |     return dists[v] + dists[u] - dists[a] * 2;
      |                                        ^