Language: C++

#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))

#define INF 200000000

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

vector<int> G[100000];
int et[200000];
int depth[200000];
int id[100000];

struct ST
{
	vector<pii> data;
	int size;
	ST(int n)
	{
		size = 1;
		while (size < n)size *= 2;

		data.assign(2 * size - 1);
		for (int i = 0; i < size; i++)
		{
			if (i < n)
			{
				data[size - 1 + i] = make_pair(depth[i], et[i]);
			}
			else
			{
				data[size - 1 + i] = make_pair(INF, -1);
			}
		}

		int k = size - 1;
		while (--k > 0)
		{
			data[k] = min(data[2 * k + 1], data[2 * k + 2]);
		}
	}

	pii find(int s, int t, int k,int l, int r)
	{
		if (r == -1)
		{
			r = size;
		}
		if (t <= l || r <= s)
		{
			return make_pair(INF, -1);
		}
		if (s <= l&&r <= t)
		{
			return data[k];
		}

		return min(find(s, t, 2 * k + 1, l, (l + r) / 2), find(s, t, 2 * k + 2, (l + r) / 2, r));
	}
};

void ET(int n, int p, int& eti, int d)
{
	if (id[n] == 0)
	{
		id[n] = eti;
	}
	et[eti] = n;
	depth[eti] = d;
	eti++;

	for (auto& e : G[n])
	{
		if (e != p)
		{
			ET(e, n, eti, d + 1);
			et[eti] = n;
			depth[eti] = d;
			eti++;
		}
	}
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	id[0] = 0;

	int n;
	scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		int k;
		scanf("%d", &k);

		for (int j = 0; j < k; j++)
		{
			int c;
			scanf("%d", &c);
			G[i].emplace_back(c);
		}
	}

	int eti = 0;
	ET(0, -1, eti, 0);

	ST st(eti);

	int q;
	scanf("%d", &q);

	for (int i = 0; i < q; i++)
	{
		int u, v;
		scanf("%d %d", &u, &v);

		printf("%d\n", st.find(min(id[u], id[v]), max(id[u], id[v]) + 1, 0, 0, -1).second);
	}

	return 0;
}


Compiler output:
a.cc: In constructor 'ST::ST(int)':
a.cc:47:28: error: no matching function for call to 'std::vector<std::pair<int, int> >::assign(int)'
   47 |                 data.assign(2 * size - 1);
      |                 ~~~~~~~~~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:828:9: note: candidate: 'template<class _InputIterator, class> void std::vector<_Tp, _Alloc>::assign(_InputIterator, _InputIterator) [with <template-parameter-2-2> = _InputIterator; _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
  828 |         assign(_InputIterator __first, _InputIterator __last)
      |         ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:828:9: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_vector.h:808:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(size_type, const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; size_type = long unsigned int; value_type = std::pair<int, int>]'
  808 |       assign(size_type __n, const value_type& __val)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:808:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_vector.h:855:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(std::initializer_list<_Tp>) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
  855 |       assign(initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:855:43: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<std::pair<int, int> >'
  855 |       assign(initializer_list<value_type> __l)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~