Language: C++

import java.util.*;
// Java program to implement Max Heap 
class MaxHeap { 
	private int[] Heap; 
	private int size; 
	private int maxsize; 

	// Constructor to initialize an 
	// empty max heap with given maximum 
	// capacity. 
	public MaxHeap(int maxsize) 
	{ 
		this.maxsize = maxsize; 
		this.size = 0; 
		Heap = new int[this.maxsize + 1]; 
		Heap[0] = Integer.MAX_VALUE; 
	} 

	// Returns position of parent 
	private int parent(int pos) 
	{ 
		return pos / 2; 
	} 

	// Below two functions return left and 
	// right children. 
	private int leftChild(int pos) 
	{ 
		return (2 * pos); 
	} 
	private int rightChild(int pos) 
	{ 
		return (2 * pos) + 1; 
	} 

	// Returns true of given node is leaf 
	private boolean isLeaf(int pos) 
	{ 
		if (pos >= (size / 2) && pos <= size) { 
			return true; 
		} 
		return false; 
	} 

	private void swap(int fpos, int spos) 
	{ 
		int tmp; 
		tmp = Heap[fpos]; 
		Heap[fpos] = Heap[spos]; 
		Heap[spos] = tmp; 
	} 

	// A recursive function to max heapify the given 
	// subtree. This function assumes that the left and 
	// right subtrees are already heapified, we only need 
	// to fix the root. 
	private void maxHeapify(int pos) 
	{ 

		if (Heap[pos] < Heap[leftChild(pos)] || 
			Heap[pos] < Heap[rightChild(pos)]) { 

			if (Heap[leftChild(pos)] > Heap[rightChild(pos)]) { 
				swap(pos, leftChild(pos)); 
				maxHeapify(leftChild(pos)); 
			} 
			else { 
				swap(pos, rightChild(pos)); 
				maxHeapify(rightChild(pos)); 
			} 
		} 
	} 

	// Inserts a new element to max heap 
	public void insert(int element) 
	{ 
		Heap[++size] = element; 

		// Traverse up and fix violated property 
		int current = size; 
		while (Heap[current] > Heap[parent(current)]) { 
			swap(current, parent(current)); 
			current = parent(current); 
		} 
	} 

	public void print() 
	{ 
		for (int i = 1; i <= size / 2; i++) { 
			System.out.print(" PARENT : " + Heap[i] + " LEFT CHILD : " + 
					Heap[2 * i] + " RIGHT CHILD :" + Heap[2 * i + 1]); 
			System.out.println(); 
		} 
	} 

	// Remove an element from max heap 
	public int extractMax() 
	{ 
		int popped = Heap[1]; 
		Heap[1] = Heap[size--]; 
		maxHeapify(1); 
		return popped; 
	} 
} 

public Main{
    	public static void main(String[] arg) 
	{ 
		Scanner in = new Scanner(System.in);
		MaxHeap maxHeap = new MaxHeap(2000000); 
		String operacao; int valor;
		
		while(in.hasNext()){
			operacao = in.next();
			if(operacao.equals("end")) break;
			else if (operacao.equals("insert")){
				valor = in.nextInt();
				maxHeap.insert(valor); 
			} else {
				System.out.println(maxHeap.extractMax()); 
			}
		}
		//maxHeap.print(); 
		//System.out.println("The max val is " + maxHeap.extractMax()); 
	} 
}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:16: error: expected ':' before 'int'
    4 |         private int[] Heap;
      |                ^~~~
      |                :
a.cc:4:20: error: expected unqualified-id before '[' token
    4 |         private int[] Heap;
      |                    ^
a.cc:5:16: error: expected ':' before 'int'
    5 |         private int size;
      |                ^~~~
      |                :
a.cc:6:16: error: expected ':' before 'int'
    6 |         private int maxsize;
      |                ^~~~
      |                :
a.cc:11:15: error: expected ':' before 'MaxHeap'
   11 |         public MaxHeap(int maxsize)
      |               ^~~~~~~~
      |               :
a.cc:20:16: error: expected ':' before 'int'
   20 |         private int parent(int pos)
      |                ^~~~
      |                :
a.cc:27:16: error: expected ':' before 'int'
   27 |         private int leftChild(int pos)
      |                ^~~~
      |                :
a.cc:31:16: error: expected ':' before 'int'
   31 |         private int rightChild(int pos)
      |                ^~~~
      |                :
a.cc:37:16: error: expected ':' before 'boolean'
   37 |         private boolean isLeaf(int pos)
      |                ^~~~~~~~
      |                :
a.cc:37:17: error: 'boolean' does not name a type; did you mean 'bool'?
   37 |         private boolean isLeaf(int pos)
      |                 ^~~~~~~
      |                 bool
a.cc:45:16: error: expected ':' before 'void'
   45 |         private void swap(int fpos, int spos)
      |                ^~~~~
      |                :
a.cc:57:16: error: expected ':' before 'void'
   57 |         private void maxHeapify(int pos)
      |                ^~~~~
      |                :
a.cc:75:15: error: expected ':' before 'void'
   75 |         public void insert(int element)
      |               ^~~~~
      |               :
a.cc:87:15: error: expected ':' before 'void'
   87 |         public void print()
      |               ^~~~~
      |               :
a.cc:97:15: error: expected ':' before 'int'
   97 |         public int extractMax()
      |               ^~~~
      |               :
a.cc:104:2: error: expected ';' after class definition
  104 | }
      |  ^
      |  ;
a.cc: In constructor 'MaxHeap::MaxHeap(int)':
a.cc:13:22: error: request for member 'maxsize' in '(MaxHeap*)this', which is of pointer type 'MaxHeap*' (maybe you meant to use '->' ?)
   13 |                 this.maxsize = maxsize;
      |                      ^~~~~~~
a.cc:14:22: error: request for member 'size' in '(MaxHeap*)this', which is of pointer type 'MaxHeap*' (maybe you meant to use '->' ?)
   14 |                 this.size = 0;
      |                      ^~~~
a.cc:15:17: error: 'Heap' was not declared in this scope
   15 |                 Heap = new int[this.maxsize + 1];
      |                 ^~~~
a.cc:15:37: error: request for member 'maxsize' in '(MaxHeap*)this', which is of pointer type 'MaxHeap*' (maybe you meant to use '->' ?)
   15 |                 Heap = new int[this.maxsize + 1];
      |                                     ^~~~~~~
a.cc:16:27: error: 'Integer' was not declared in this scope
   16 |                 Heap[0] = Integer.MAX_VALUE;
      |                           ^~~~~~~
a.cc: In member function 'void MaxHeap::swap(int, int)':
a.cc:48:23: error: 'Heap' was not declared in this scope
   48 |                 tmp = Heap[fpos];
      |                       ^~~~
a.cc: In member function 'void MaxHeap::maxHeapify(int)':
a.cc:60:21: error: 'Heap' was not declared in this scope
   60 |                 if (Heap[pos] < Heap[leftChild(pos)] ||
      |                     ^~~~
a.cc: In member function 'void MaxHeap::insert(int)':
a.cc:77:17: error: 'Heap' was not declared in this scope
   77 |                 Heap[++size] = element;
      |                 ^~~~
a.cc: In member function 'void MaxHeap::print()':
a.cc:90:25: error: 'System' was not declared in this scope
   90 |                         System.out.print(" PARENT : " + Heap[i] + " LEFT CHILD : " +
      |                         ^~~~~~
a.cc:90:57: error: 'Heap' was not declared in this scope
   90 |                         System.out.print(" PARENT : " + Heap[i] + " LEFT CHILD : " +
      |                                                         ^~~~
a.cc: In member function 'int MaxHeap::extractMax()':
a.cc:99:30: error: 'Heap' was not declared in this scope
   99 |                 int popped = Heap[1];
      |                              ^~~~
a.cc: At global scope:
a.cc:106:1: error: expected unqualified-id before 'public'
  106 | public Main{
      | ^~~~~~