Language: C++

vector<Pii> e[MAX_SIZE];
class LCA {
public:
	int V, logV;
	vector<int> depth;
	vector<ll> len;
	vector<vector<int> > parent;

	LCA() {}

	void init(int V) {
		this->V = V;
		logV = 0;
		while (V >= (1 << logV)) logV++;
		this->depth = vector<int>(V);
		this->len = vector<ll>(V);
		this->parent = vector<vector<int> >(logV, vector<int>(V));

		dfs(0, -1, 0, 0);
		build();
	}

	void dfs(int v, int par, int d, ll l) {
		depth[v] = d;
		parent[0][v] = par;
		len[v] = l;
		for (auto to : e[v]) {
			if (par == to.first) continue;
			dfs(to.first, v, d + 1, to.second + l);
		}
	}

	void build() {
		for (int k = 0; k + 1 < logV; k++) {
			for (int v = 0; v < V; v++) {
				if (parent[k][v] < 0) parent[k + 1][v] = -1;
				else parent[k + 1][v] = parent[k][parent[k][v]];
			}
		}
	}

	int prev_parent(int u, int par){
		for (int k = logV - 1; k >= 0; k--) {
			int diff = depth[u] - depth[par];
			if ((diff - (1 << k)) > 0){
				u = parent[k][u];
			}
		}
		return u;
	}

	int query(int u, int v) {
		if (depth[u] > depth[v]) swap(u, v);
		for (int k = 0; k < logV; k++) {
			if ((depth[v] - depth[u]) >> k & 1)
				v = parent[k][v];
		}
		if (u == v) return u;

		for (int k = logV - 1; k >= 0; k--) {
			if (parent[k][u] != parent[k][v]) {
				u = parent[k][u];
				v = parent[k][v];
			}
		}
		return parent[0][u];
	}

	ll get_len(int u, int v) {
		return len[u] + len[v] - 2 * len[query(u, v)];
	}
};

Compiler output:
a.cc:1:1: error: 'vector' does not name a type
    1 | vector<Pii> e[MAX_SIZE];
      | ^~~~~~
a.cc:5:9: error: 'vector' does not name a type
    5 |         vector<int> depth;
      |         ^~~~~~
a.cc:6:9: error: 'vector' does not name a type
    6 |         vector<ll> len;
      |         ^~~~~~
a.cc:7:9: error: 'vector' does not name a type
    7 |         vector<vector<int> > parent;
      |         ^~~~~~
a.cc:23:41: error: 'll' has not been declared
   23 |         void dfs(int v, int par, int d, ll l) {
      |                                         ^~
a.cc:69:9: error: 'll' does not name a type
   69 |         ll get_len(int u, int v) {
      |         ^~
a.cc: In member function 'void LCA::init(int)':
a.cc:15:23: error: 'class LCA' has no member named 'depth'
   15 |                 this->depth = vector<int>(V);
      |                       ^~~~~
a.cc:15:31: error: 'vector' was not declared in this scope
   15 |                 this->depth = vector<int>(V);
      |                               ^~~~~~
a.cc:15:38: error: expected primary-expression before 'int'
   15 |                 this->depth = vector<int>(V);
      |                                      ^~~
a.cc:16:23: error: 'class LCA' has no member named 'len'
   16 |                 this->len = vector<ll>(V);
      |                       ^~~
a.cc:16:36: error: 'll' was not declared in this scope
   16 |                 this->len = vector<ll>(V);
      |                                    ^~
a.cc:17:23: error: 'class LCA' has no member named 'parent'
   17 |                 this->parent = vector<vector<int> >(logV, vector<int>(V));
      |                       ^~~~~~
a.cc:17:46: error: expected primary-expression before 'int'
   17 |                 this->parent = vector<vector<int> >(logV, vector<int>(V));
      |                                              ^~~
a.cc: In member function 'void LCA::dfs(int, int, int, int)':
a.cc:24:17: error: 'depth' was not declared in this scope
   24 |                 depth[v] = d;
      |                 ^~~~~
a.cc:25:17: error: 'parent' was not declared in this scope
   25 |                 parent[0][v] = par;
      |                 ^~~~~~
a.cc:26:17: error: 'len' was not declared in this scope
   26 |                 len[v] = l;
      |                 ^~~
a.cc:27:32: error: 'e' was not declared in this scope
   27 |                 for (auto to : e[v]) {
      |                                ^
a.cc: In member function 'void LCA::build()':
a.cc:36:37: error: 'parent' was not declared in this scope
   36 |                                 if (parent[k][v] < 0) parent[k + 1][v] = -1;
      |                                     ^~~~~~
a.cc: In member function 'int LCA::prev_parent(int, int)':
a.cc:44:36: error: 'depth' was not declared in this scope
   44 |                         int diff = depth[u] - depth[par];
      |                                    ^~~~~
a.cc:46:37: error: 'parent' was not declared in this scope
   46 |                                 u = parent[k][u];
      |                                     ^~~~~~
a.cc: In member function 'int LCA::query(int, int)':
a.cc:53:21: error: 'depth' was not declared in this scope
   53 |                 if (depth[u] > depth[v]) swap(u, v);
      |                     ^~~~~
a.cc:53:42: error: 'swap' was not declared in this scope
   53 |                 if (depth[u] > depth[v]) swap(u, v);
      |                                          ^~~~
a.cc:55:30: error: 'depth' was not declared in this scope
   55 |                         if ((depth[v] - depth[u]) >> k & 1)
      |                              ^~~~~
a.cc:56:37: error: 'parent' was not declared in this scope
   56 |                                 v = parent[k][v];
      |                                     ^~~~~~
a.cc:61:29: error: 'parent' was not declared in this scope
   61 |                         if (parent[k][u] != parent[k][v]) {
      |                             ^~~~~~
a.cc:66:24: error: 'parent' was not declared in this scope
   66 |                 return parent[0][u];
      |                        ^~~~~~