#include<bits/stdc++.h>
#define SEN INT_MIN
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
struct node
{
int data;
struct node* left, *right;
};
typedef struct node* Node;
typedef struct node node;
Node newNode(int data)
{
Node temp = (Node)malloc(sizeof(struct node));
temp->data = data;
temp->left = temp->right = NULL;
return(temp);
}
bool isleaf(Node root) { return root->left == NULL && root->right == NULL; }
int issumtree(Node root) {
if(root == NULL) return 0;
if(isleaf(root)) return root->data;
int l = issumtree(root->left);
int r = issumtree(root->right);
if(root->data == l + r) return (root->data + l + r);
else return SEN;
}
int main()
{
// Let us construct the BST shown in the above figure
struct node *root = newNode(26);
root->left = newNode(10);
root->right = newNode(3);
root->left->left = newNode(4);
root->left->right = newNode(6);
root->right->right = newNode(3);
// root->left->left->left = newNode(0);
/* Constructed binary tree is
26
/ \
10 3
/ \ \
4 6 3
*/
if (issumtree(root) != SEN)
cout << "Yes" << endl;
else cout << "No\n";
return 0;
}