Language: C++

#include<iostream>
#include<string>
using namespace std;
 
struct Node{
  Node* right;
  Node* left;
  int key,priority;
};
 
Node* rightRotate(Node* t) {
    Node* s = t->left;
    t->left = s->right;
    s->right = t;
    return s;
}
  
Node* insert(Node* t, int key, int priority) {
    if(t == NULL) {
        Node* t = new Node;
        t->left=NULL; t->right = NULL;
        t->key = key; t->priority = priority;
        return t;
    }
    if(key == t->key) return t;
 
    if(key < t->key) {
        t->left = insert(t->left, key, priority);
        if(t->priority < t->left->priority) t = rightRotate(t);
    }
    else {
        t->right = insert(t->right, key, priority);
        if(t->priority < t->right->priority) t = leftRotate(t);
    }
    return t;
}
 
Node* erase(Node* t, int key){
    if(t == NULL) 
        return NULL;
 
    if(key == t->key) {
        if(t->left == NULL && t->right == NULL) 
            return NULL;
        else if(t->left == NULL) t = leftRotate(t);
        else if(t->right == NULL) t = rightRotate(t);
        else {
            if(t->left->priority > t->right->priority) t = rightRotate(t);
            else t = leftRotate(t);
        }
        return erase(t,key);
    }
    if(key < t->key) t->left = erase(t->left, key);
    else t->right = erase(t->right, key);
    return t;
}
 
void find(Node* t, int key) {
    while(t != NULL && key != t->key) {
        if(key < t->key) t = t->left;
        else t = t->right;
    }
    if(t == NULL) cout << "no" << endl;
    else cout << "yes" << endl;
}

void ppp(Node* t) {
    if(t == NULL) return;
    cout << " " << t->key;
    ppp(t->left);
    ppp(t->right);
}
 

void iii(Node* t) {
    if(t==NULL) return;
    iii(t->left);
    cout << " " << t->key;
    iii(t->right);
}

main() {
    Node* root=NULL;
    int n,key,priority;
    string s;
 
    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> s;
        if(s == "insert") {
            cin >> key >> priority;
            root = insert(root, key, priority);
        }
        else if(s == "find") {
            cin >> key;
            find(root, key);
        }
        else if(s == "delete") {
            cin >> key;
            root = erase(root, key);
        }
        else {
            iii(root);
            cout << endl;
            ppp(root);
            cout << endl;
        }
    }
    return 0;
}


Compiler output:
a.cc: In function 'Node* insert(Node*, int, int)':
a.cc:33:50: error: 'leftRotate' was not declared in this scope; did you mean 'setstate'?
   33 |         if(t->priority < t->right->priority) t = leftRotate(t);
      |                                                  ^~~~~~~~~~
      |                                                  setstate
a.cc: In function 'Node* erase(Node*, int)':
a.cc:45:38: error: 'leftRotate' was not declared in this scope; did you mean 'setstate'?
   45 |         else if(t->left == NULL) t = leftRotate(t);
      |                                      ^~~~~~~~~~
      |                                      setstate
a.cc:49:22: error: 'leftRotate' was not declared in this scope; did you mean 'setstate'?
   49 |             else t = leftRotate(t);
      |                      ^~~~~~~~~~
      |                      setstate
a.cc: At global scope:
a.cc:82:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   82 | main() {
      | ^~~~