Language: C++

using namespace std;

class maxHeap {
private:
    int *arr;
    int maxSize;
    int size;

public:
    maxHeap(int maxSize) {
        this->maxSize = maxSize;
        this->size = 0;
        this->arr = new int[maxSize];
    }

    void maxHeapify(maxHeap* heap, int num) {
        int left = num * 2;
        int right = num* 2 + 1;
        int largest;

        if (left <= heap->size && heap->arr[left] > heap->arr[num]) {
            largest = left;
        } else {
            largest = num;
        }
        if (right <= heap->size && heap->arr[right] > heap->arr[largest]) {
            largest = right;
        }
        if (largest != num) {
            swap(heap->arr[largest], heap->arr[num]);
            maxHeapify(heap, largest);
        }
    }

    void insert(maxHeap* heap, int number) {
        heap->size++;
        heap->arr[heap->size] = number;
        for(int i = heap->size; i > 1 && heap->arr[i/2] < heap->arr[i];) {
            swap(heap->arr[i/2], heap->arr[i]);
            i = i/2;
        }
    }

    int extractMax(maxHeap* heap){
        int max = heap->arr[1];
        heap->arr[1] = heap->arr[size];
        heap->size--;
        maxHeapify(heap, 1);
        return max;
    }
};

int main() {
    maxHeap *arrHeap = new maxHeap(2000001);
    string cases;
    while(getline(cin, cases) && cases.substr(0,3) != "end") {
        if(cases.substr(0, 6) == "insert") {
            int number = stoi(cases.substr(7));
            arrHeap->insert(arrHeap, number);

        } else if (cases.substr(0,7) == "extract") {
            int max = arrHeap->extractMax(arrHeap);
            cout << max << endl;
        } else {
            break;
        }
    }
    return 0;
}


Compiler output:
a.cc: In member function 'void maxHeap::maxHeapify(maxHeap*, int)':
a.cc:30:13: error: 'swap' was not declared in this scope
   30 |             swap(heap->arr[largest], heap->arr[num]);
      |             ^~~~
a.cc: In member function 'void maxHeap::insert(maxHeap*, int)':
a.cc:39:13: error: 'swap' was not declared in this scope
   39 |             swap(heap->arr[i/2], heap->arr[i]);
      |             ^~~~
a.cc: In function 'int main()':
a.cc:55:5: error: 'string' was not declared in this scope
   55 |     string cases;
      |     ^~~~~~
a.cc:1:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
  +++ |+#include <string>
    1 | using namespace std;
a.cc:56:19: error: 'cin' was not declared in this scope
   56 |     while(getline(cin, cases) && cases.substr(0,3) != "end") {
      |                   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:56:24: error: 'cases' was not declared in this scope
   56 |     while(getline(cin, cases) && cases.substr(0,3) != "end") {
      |                        ^~~~~
a.cc:56:11: error: 'getline' was not declared in this scope
   56 |     while(getline(cin, cases) && cases.substr(0,3) != "end") {
      |           ^~~~~~~
a.cc:58:26: error: 'stoi' was not declared in this scope
   58 |             int number = stoi(cases.substr(7));
      |                          ^~~~
a.cc:58:26: note: 'std::stoi' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
a.cc:63:13: error: 'cout' was not declared in this scope
   63 |             cout << max << endl;
      |             ^~~~
a.cc:63:13: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:63:28: error: 'endl' was not declared in this scope
   63 |             cout << max << endl;
      |                            ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;