#include<stdio.h>
#include<stdlib.h>
struct Node{
    int key;
    struct Node*left, right;
    int height;
};
int max(int a,int b){
    return(a>b)? a:b;
}
int height(struct Node*N)
{
if(N==NULL)return 0;
return N->height;
}
struct Node*new newnode(int key){
    struct Node* node=(struct Node*)malloc(sizeof(structNode));
    node->key=key;
    node->left=node->right=NULL;
    node->height=1;
    return node;
}
struct Node*rightRotare(struct Node*y){
    struct Node*rightx=y->left;
    struct Node*T2=x->right;
    x->right=y;
    y->left=T2;
    y->height=max(height(y->left),height(y->right))+1;
      x->height=max(height(x->left),height(x->right))+1;
      return x;
    
}struct Node*leftRotate(struct Node*x){
    struct Node*y=x->right;
    struct Node*T2=y->left;
    y->left=x;
    x->right=T2;
    x->height=max(height(x->left),height(x->right))+1;
     y->height=max(height(y->left),height(y->right))+1;
     return y;
}
int getBalance(struct Node*N){
    if(N==NULL)return 0;
    return height(N->left)-height(N->right);
}
struct Node*insert(struct Node*node,int key)
{
    if(node==NULL)return newNode(key);
    if(key<node->key)
    node->left=insert(node->left,key);
    else if(key>node->key)
      node->right=insert(node->right,key);
    else
    return node;
    node->height=1+
    max(heigth(node->left),height(node->right));
    int balance=getBalance(node);
    if(balance>1&&key<node->left->key)
    return leftrotate(node);
    if(balance < -1&&key >node->right->key)
    return leftrorate(node);
    if(balance > 1 &&key >node->left->key){
        node->left=leftRotate(node->left);
    
    return leftrorate(node);
    }
    return node;
} 
struct Node*minValueNode(struct Node*nodr){
struct Node*current=node;
while(current->left !=NULL)
current=current->left;
return current;
}
struct Node*deleteNode(struct Node*root,int key){
    if(root ==NULL)return root;
    if(key<root->key)
    root->left=deleteNode(root->left,key);
    else if(key>root->key)
    root->right=deleteNode(root->right,key);
    else{
        if ((root->left==NULL)||(root->right==NULL)){
            struct Node*temp=root->left?root->left:root->right;
            if(temp==NULL){
                temp=root;
                root=NULL;
            }else{
                struct Node*temp=minValueNode(root->left);
                root->key=temp->key;
                root->right=deletNode(root->right,temp->key);
            }
            
        }
        if(root==NULL)return root;
        root->height=1+,max(height(root->left),height(root->right));
        int balance-getBalance()
    }
    
}
}