#include<stdio.h> #include<stdlib.h> #define MAX 1000  struct task{     int id;     int p; }; struct task heap[MAX]; int size=0; void swap(struct task *a , struct task *b){     struct task temp=*a;     *a=*b;     *b=temp; } void heapify_up(int index){     if(index<=0)     return;     int parent=(index-1)/2;     if(heap[index].p<heap[parent].p){         swap(&heap[index],&heap[parent]);         heapify_up(parent);     } } void heapify_down(int index){     int left=2*index +1;     int right=2*index +2;     int smallest= index;     if(left<size && heap[left].p<heap[smallest].p)         smallest=left;     if(right<size && heap[right].p<heap[smallest].p)         smallest=right;     if(smallest !=index){         swap(&heap[index], &heap[smallest]);         heapify_down(