Language: C++

#include<bits/stdc++.h>
#pragma comment(linker, "/STACK:16000000")
#define PI 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
#define ii pair<int,int>
using namespace std;
const int inf=0x3f3f3f3f;
const long long inf2=0x3f3f3f3f3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
int n,k;
vector<int> nei[100005];
int d[100005];
priority_queue<pii, vector<pii>, greater<pii> > pq;
int a[100005];
int b[100005];
int main(){
	memset(d,-1,sizeof(d));
	scanf("%d",&n);
	for(int i=0;i<n-1;++i){
		scanf("%d%d",&a[i],&b[i]);
		--a[i],--b[i];
		nei[a[i]].push_back(b[i]);
		nei[b[i]].push_back(a[i]);
	}
	scanf("%d",&k);
	for(int i=0;i<k;++i){
		int v,p;
		scanf("%d%d",&v,&p);
		--v;
		d[v]=p;
		pq.push(pii(p,v));
	}
	while(!pq.empty()){
		pii p=pq.top();
		pq.pop();
		int v=p.second;
		for(int i=0;i<nei[v].size();++i){
			int u=nei[v][i];
			if(d[u]==-1){
				d[u]=d[v]+1;
				pq.push(pii(d[u],u));
			}
		}
	} 
	for(int i=0;i<n-1;++i){
		if(abs(d[a[i]]-d[b[i]])!=1)byebye("No");
	}
	puts("Yes");
	for(int i=0;i<n;++i)printf("%d\n",d[i]);
	return 0;
}


Compiler output:
a.cc:13:16: error: 'pii' was not declared in this scope; did you mean 'ii'?
   13 | priority_queue<pii, vector<pii>, greater<pii> > pq;
      |                ^~~
      |                ii
a.cc:13:28: error: 'pii' was not declared in this scope; did you mean 'ii'?
   13 | priority_queue<pii, vector<pii>, greater<pii> > pq;
      |                            ^~~
      |                            ii
a.cc:13:31: error: template argument 1 is invalid
   13 | priority_queue<pii, vector<pii>, greater<pii> > pq;
      |                               ^
a.cc:13:31: error: template argument 2 is invalid
a.cc:13:42: error: 'pii' was not declared in this scope; did you mean 'ii'?
   13 | priority_queue<pii, vector<pii>, greater<pii> > pq;
      |                                          ^~~
      |                                          ii
a.cc:13:45: error: template argument 1 is invalid
   13 | priority_queue<pii, vector<pii>, greater<pii> > pq;
      |                                             ^
a.cc:13:47: error: template argument 1 is invalid
   13 | priority_queue<pii, vector<pii>, greater<pii> > pq;
      |                                               ^
a.cc:13:47: error: template argument 2 is invalid
a.cc:13:47: error: template argument 3 is invalid
a.cc: In function 'int main()':
a.cc:31:20: error: request for member 'push' in 'pq', which is of non-class type 'int'
   31 |                 pq.push(pii(p,v));
      |                    ^~~~
a.cc:31:25: error: 'pii' was not declared in this scope; did you mean 'ii'?
   31 |                 pq.push(pii(p,v));
      |                         ^~~
      |                         ii
a.cc:33:19: error: request for member 'empty' in 'pq', which is of non-class type 'int'
   33 |         while(!pq.empty()){
      |                   ^~~~~
a.cc:34:17: error: 'pii' was not declared in this scope; did you mean 'ii'?
   34 |                 pii p=pq.top();
      |                 ^~~
      |                 ii
a.cc:35:20: error: request for member 'pop' in 'pq', which is of non-class type 'int'
   35 |                 pq.pop();
      |                    ^~~
a.cc:36:23: error: 'p' was not declared in this scope
   36 |                 int v=p.second;
      |                       ^
a.cc:41:36: error: request for member 'push' in 'pq', which is of non-class type 'int'
   41 |                                 pq.push(pii(d[u],u));
      |                                    ^~~~
a.cc:46:44: error: 'byebye' was not declared in this scope
   46 |                 if(abs(d[a[i]]-d[b[i]])!=1)byebye("No");
      |                                            ^~~~~~