Language: C++

#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node{
  int key,priority;
  Node *right,*left;
};

Node *root, *NIL;

Node * find(Node *u,int k){
  while(u!=NIL && k!=u->key){
    if(k<u->key) u = u->left;
    else u=u->right;
  }
  return u;
}

void inorder(Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

Node *rightRotate(Node *u){
  Node *k=u->left;
  u->left=k->right;
  k->right=u;
  return k;
}

Node *leftRotate(Node *u){
  Node *k=u->right;
  u->right=k->left;
  k->left=u;
  return k;
}

Node* insert(Node *t,int key,int priority){
	
  if(t==NIL)
    return Node(key,priority);
  if (t->key==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 * Delete(Node *t,int key){
  if(t==NIL)
    return NIL;
		
  if(key < t->key)
    t->left=Delete(t->left,key);
		
  else if(key > t->key)
    t->right=Delete(t->right,key);
		
  else return _delete(t,key);
	
  return t;
}

Node * _delete(Node *t,int key){
  if(t->left==NIL && t->right==NIL)
    return NIL;
  else if(t->left==NIL)
    t=leftRotate(t);
  else if(t->right==NIL)
    t=rightRotate(t);
  else {
    if(t->left->priority > t->right->priority)
      t=rightRotate(t);
    else
      t=leftRotate(t);
  }
  return Delete(t,key);
}

int main(){
  int n,i,x;
  string com;

  scanf("%d",&n);

  for(i = 0;i < n; i++){
    cin >> com;

    if(com[0] == 'f'){
      scanf("%d",&x);
      Node *t = find(root,x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    }else if(com == "insert"){
      scanf("%d",&x);
      insert(x);
    }else if(com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }else if(com == "delete"){
      scanf("%d",&x);
      Delete(root,x);
    }
  }

  return 0;
}



Compiler output:
a.cc: In function 'Node* insert(Node*, int, int)':
a.cc:53:29: error: no matching function for call to 'Node::Node(int&, int&)'
   53 |     return Node(key,priority);
      |                             ^
a.cc:7:8: note: candidate: 'Node::Node()'
    7 | struct Node{
      |        ^~~~
a.cc:7:8: note:   candidate expects 0 arguments, 2 provided
a.cc:7:8: note: candidate: 'constexpr Node::Node(const Node&)'
a.cc:7:8: note:   candidate expects 1 argument, 2 provided
a.cc:7:8: note: candidate: 'constexpr Node::Node(Node&&)'
a.cc:7:8: note:   candidate expects 1 argument, 2 provided
a.cc: In function 'Node* Delete(Node*, int)':
a.cc:82:15: error: '_delete' was not declared in this scope; did you mean 'Delete'?
   82 |   else return _delete(t,key);
      |               ^~~~~~~
      |               Delete
a.cc: In function 'int main()':
a.cc:119:14: error: invalid conversion from 'int' to 'Node*' [-fpermissive]
  119 |       insert(x);
      |              ^
      |              |
      |              int
a.cc:119:13: error: too few arguments to function 'Node* insert(Node*, int, int)'
  119 |       insert(x);
      |       ~~~~~~^~~
a.cc:50:7: note: declared here
   50 | Node* insert(Node *t,int key,int priority){
      |       ^~~~~~