Language: C++

#include <bits/stdc++.h>
#define LL long long
using namespace std;
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }

const int N = 200050;
int n,fa[N],siz0[N],siz1[N],deg[N];

LL Ans = 0;
struct Union_Find_Set{
	int fa[N],v0[N],v1[N];
	inline void init(int n,int *s0,int *s1){ for (int i = 1; i <= n; ++i) fa[i] = i,v0[i] = s0[i],v1[i] = s1[i]; }
	inline int Find(int x){ return x == fa[x] ? x : (fa[x] = Find(fa[x])); }
	inline void Merge(int x,int y){
		x = Find(x),y = Find(y);
		Ans += 1ll * v1[y] * v0[x];
		fa[x] = y; v0[y] += v0[x],v1[y] += v1[x];
	}
}S;
struct data{
	int x,v0,v1;
	data(int xx=0,int vv0=0,int vv1=0){ x = xx,v0 = vv0,v1 = vv1; }
	bool operator < (data w) const{ return 1ll * v0 * w.v1 < 1ll * w.v0 * v1; }
}t;
priority_queue<data>H;

int main(){
	int i,x,f;
	read(n);
	for (i = 2; i <= n; ++i) read(fa[i]),++deg[fa[i]];
	for (i = 1; i <= n; ++i) read(siz1[i]),siz0[i] = 1 - siz1[i];
	S.init(n,siz0,siz1);
	for (i = 1; i <= n; ++i) H.push(data(i,siz0[i],siz1[i])),deg[i] = -1;
	while (!H.empty()){
		t = H.top(),H.pop(),x = S.Find(t.x);
		if (S.v0[x] != t.v0 || S.v1[x] != t.v1 || x == 1) continue;
		f = S.Find(fa[x]); S.Merge(x,f);// --deg[f];
		H.push(data(f,S.v0[f],S.v1[f]));
	//	if (!deg[f]) H.push(data(f,S.v0[f],S.v1[f])),deg[f] = -1;
	}
	cout << Ans << '\n';
	return 0;
}

Compiler output:
a.cc:31:20: error: template argument 1 is invalid
   31 | priority_queue<data>H;
      |                    ^
a.cc:31:20: error: template argument 2 is invalid
a.cc:31:20: error: template argument 3 is invalid
a.cc: In function 'int main()':
a.cc:39:36: error: request for member 'push' in 'H', which is of non-class type 'int'
   39 |         for (i = 1; i <= n; ++i) H.push(data(i,siz0[i],siz1[i])),deg[i] = -1;
      |                                    ^~~~
a.cc:39:41: error: reference to 'data' is ambiguous
   39 |         for (i = 1; i <= n; ++i) H.push(data(i,siz0[i],siz1[i])),deg[i] = -1;
      |                                         ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:26:8: note:                 'struct data'
   26 | struct data{
      |        ^~~~
a.cc:40:19: error: request for member 'empty' in 'H', which is of non-class type 'int'
   40 |         while (!H.empty()){
      |                   ^~~~~
a.cc:41:23: error: request for member 'top' in 'H', which is of non-class type 'int'
   41 |                 t = H.top(),H.pop(),x = S.Find(t.x);
      |                       ^~~
a.cc:41:31: error: request for member 'pop' in 'H', which is of non-class type 'int'
   41 |                 t = H.top(),H.pop(),x = S.Find(t.x);
      |                               ^~~
a.cc:44:19: error: request for member 'push' in 'H', which is of non-class type 'int'
   44 |                 H.push(data(f,S.v0[f],S.v1[f]));
      |                   ^~~~
a.cc:44:24: error: reference to 'data' is ambiguous
   44 |                 H.push(data(f,S.v0[f],S.v1[f]));
      |                        ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:26:8: note:                 'struct data'
   26 | struct data{
      |        ^~~~