Language: C++

#include <iostream>

using namespace std;

struct Heap{
	int Array[2000000];
	int tamanho;
	
	int pai(int input){
		return (input - 1)/2;
	}
	
	int filhoEsquerdo(int input){
		return (input 2*input + 1);
	}
	
	int filhoDireito(int input){
		return (input 2*input + 2);
	}
	
	// Arruma após inserção
	void HeapifyRemover(int arrumar){
		int esquerdo = filhoEsquerdo(arrumar);
		int direito = filhoDireito(arrumar);
		
		int maior = arrumar;
		
		//Vejo quem é maior
		if (esquerdo < tamanho && Array[esquerda] > Array[arrumar]){
			maior = esquerdo;
		}
		if (direito < tamanho && Array[direito] > Array[arrumar]){
			maior = direito;
		}
		if (maior != arrumar){
			swap(&Array[maior], &Array[arrumar]);
			Heapify(maior);
		}
	}
	
	void HeapifyInserir(int arrumar){
		if (arrumar != 0 && Array[pai(arrumar) < Array[arrumar]]{
			swap(&Array[arrumar], &Array[arrumar]);
			HeapifyInserir(pai(arrumar));
		}
	}
	
	void inserirHeap(int valor){
		Heap.Array[tamanho] = valor;
		HeapifyInserir(tamanho);
		Heap.tamanho++;
	}
	
	int removerRaiz(){
		int raiz = Array[0];
		Array[0] = Array[tamanho-1];
		Heap.tamanho--;
		return raiz;
	}
};

int main(){
	Heap heap;
	string operacao; int valor;
	while(cin >> operacao){
		if (operacao == "insert"){
			cin >> valor;
			heap.inserirHeap(valor);
		} else if (operacao == "extract"){
			cout << heap.removerRaiz; endl;
		} else {
			break;
		}
	}
	return 0;
}



Compiler output:
a.cc:76:2: error: expected '}' at end of input
   76 | }
      |  ^
a.cc:5:12: note: to match this '{'
    5 | struct Heap{
      |            ^
a.cc: In member function 'int Heap::filhoEsquerdo(int)':
a.cc:14:31: error: expected ')' before numeric constant
   14 |                 return (input 2*input + 1);
      |                               ^
a.cc:14:24: note: to match this '('
   14 |                 return (input 2*input + 1);
      |                        ^
a.cc: In member function 'int Heap::filhoDireito(int)':
a.cc:18:31: error: expected ')' before numeric constant
   18 |                 return (input 2*input + 2);
      |                               ^
a.cc:18:24: note: to match this '('
   18 |                 return (input 2*input + 2);
      |                        ^
a.cc: In member function 'void Heap::HeapifyRemover(int)':
a.cc:29:49: error: 'esquerda' was not declared in this scope; did you mean 'esquerdo'?
   29 |                 if (esquerdo < tamanho && Array[esquerda] > Array[arrumar]){
      |                                                 ^~~~~~~~
      |                                                 esquerdo
a.cc:36:29: error: no matching function for call to 'swap(int*, int*)'
   36 |                         swap(&Array[maior], &Array[arrumar]);
      |                         ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/exception_ptr.h:41,
                 from /usr/include/c++/14/exception:166,
                 from /usr/include/c++/14/ios:41,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/move.h:226:5: note: candidate: 'std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = int*; _Require<__not_<__is_tuple_like<_Tp> >, is_move_constructible<_Tp>, is_move_assignable<_Tp> > = void]' (near match)
  226 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
/usr/include/c++/14/bits/move.h:226:5: note:   conversion of argument 2 would be ill-formed:
a.cc:36:45: error: cannot bind non-const lvalue reference of type 'int*&' to an rvalue of type 'int*'
   36 |                         swap(&Array[maior], &Array[arrumar]);
      |                                             ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/exception_ptr.h:229:5: note: candidate: 'void std::__exception_ptr::swap(exception_ptr&, exception_ptr&)'
  229 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |     ^~~~
/usr/include/c++/14/bits/exception_ptr.h:229:25: note:   no known conversion for argument 1 from 'int*' to 'std::__exception_ptr::exception_ptr&'
  229 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |          ~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/move.h:250:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> std::__enable_if_t<((bool)std::__is_swappable<_Tp>::value)> std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm])'
  250 |     swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
      |     ^~~~
/usr/include/c++/14/bits/move.h:250:5: note:   template argument deduction/substitution failed:
a.cc:36:29: note:   mismatched types '_Tp [_Nm]' and 'int*'
   36 |                         swap(&Array[maior], &Array[arrumar]);
      |                         ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44:
/usr/include/c++/14/bits/stl_pair.h:1089:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)'
 1089 |     swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
      |     ^~~~
/usr/include/c++/14/bits/stl_pair.h:1089:5: note:   template argument deduction/substitution failed:
a.cc:36:29: note:   mismatched types 'std::pair<_T1, _T2>' and 'int*'
   36 |                         swap(&Array[maior], &Array[arrumar]);
      |                         ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1106:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<(! std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value)>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)' (deleted)
 1106 |     swap(pair<_T1, _T2>&, pair<_T1, _T2>&) = delete;
      |     ^~~~
/usr/include/c++/14/bits/stl_pair.h:1106:5: note:   template argument deduction/substitution failed:
a.cc:36:29: note:   mismatched types 'std::pair<_T1, _T2>' and 'int*'
   36 |                         swap(&Array[maior], &Array[arrumar]);
      |                         ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:54:
/usr/include/c++/14/bits/basic_string.h:4039:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> void std::swap(__cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 4039 |     swap(basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~
/usr/include/c++/14/bits/basic_string.h:4039:5: note:   template argument deduction/substitution failed:
a.cc:36:29: note:   mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int*'
   36 |                         swap(&Array[maior], &Array[arrumar]);
      |                         ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
                 from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2805:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<std::__and_<std::__is_swappable<_Elements>...>::value>::type std::swap(tuple<_UTypes ...>&, tuple<_UTypes ...>&)'
 2805 |     swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y)
      |     ^~~~
/usr/include/c++/14/tuple:2805:5: note:   template argument deduction/substitution failed:
a.cc:36:29: note:   mismatched types 'std::tuple<_UTypes ...>' and 'int*'
   36 |                         swap(&Array[maior], &Array[arrumar]);
      |                         ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/tuple:2823:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<(! std::__and_<std::__is_swappable<_Elements>...>::value)>::type std::swap(tuple<_UTypes ...>&, tuple<_UTypes ...>&)' (deleted)
 2823 |     swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete;
      |     ^~~~
/usr/include/c++/14/tuple:2823:5: note:   template argument deduction/substitution failed:
a.cc:36:29: note:   mismatched types 'std::tuple<_UTypes ...>' and 'int*'
   36 |                         swap(&Array[maior], &Array[arrumar]);
      |                         ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:37:25: error: 'Heapify' was not declared in this scope; did you mean 'Heap'?
   37 |                         Heapify(maior);
      |                         ^~~~~~~
      |                         Heap
a.cc: In member function 'void Heap::HeapifyInserir(int)':
a.cc:42:73: error: expected ')' before '{' token
   42 |                 if (arrumar != 0 && Array[pai(arrumar) < Array[arrumar]]{
      |                                                                         ^
a.cc:42:20: note: to match this '('
   42 |                 if (arrumar != 0 && Array[pai(arrumar) < Array[arrumar]]{
      |                    ^
a.cc:46:9: error: expected primary-expression before '}' token
   46 |         }
      |         ^
a.cc: At global scope:
a.cc:76:2: error: expected unqualified-id at end of input
   76 | }
      |  ^