For this Question: Given a binary tree, determine if it is height-balanced. Tree is rooted at 1.

Height-balanced binary tree : is defined as a binary tree in which the depth of the two sub-trees of every node never differ by more than 1.The first line of the input contains an integer N, the number of nodes in the Binary Tree.
The following N-1 lines contain two integers, u and v, denoting an edge.

Constraints
1 <= N <= 100000
1 <= u, v <= N
u and v are distinctOutput "YES" if tree is balanced, else output "NO".Sample Input
3
1 2
1 3

Sample Output
YES

Sample Input
3
1 2
2 3

Sample Output
NO, I have written this Solution Code: #include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

bool flag = 1;
vector<int> g[N];

int check(int u, int p){
	int l = -1, r = -1;
	int x = 0, y = 0;
	for(auto i: g[u]){
		if(i == p)	continue;
		if(l == -1){
			l = i;
			x = 1 + check(l, u);
		}
		else if(r == -1){
			r = i;
			y = 1 + check(r, u);
		}
	}
	if(abs(x-y) > 1)
		flag = 0;
	return max(x, y);
}

signed main() {
	IOS;
	int n;	cin >> n;
	for(int i = 1; i <= n-1; i++){
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}	
	check(1, 0);
	if(flag)
		cout << "YES";
	else
		cout << "NO";
	return 0;
}, In this Programming Language: C++, Now tell me if this Code is compilable or not?