criyle/codenet-compile-errors huggingface dataset:
Language: C

#include<stdio.h>
#include<string.h>
#define MAX 2000200
#define MIN -2000000300
typedef long long ll;

int pindex;
ll Array[MAX];

int getParent(int i){
  return i/2;
}

int getLeft(int i){
  return 2*i;
}

int getRight(int i){
    return 2*i+1;
}


int heapIncreaseKey(int i,ll key){
  ll h;
  if(key < Array[i])return -1;
  Array[i] = key;
  while(i > 1 && Array[getParent(i)] < Array[i]){
    h = Array[i];
    Array[i] = Array[getParent(i)];
    Array[getParent(i)] = h;
    i = getParent(i);
  }
}

void maxHeapify(int i){
  ll l = getLeft(i);
  ll r = getRight(i);
  ll largest;
  ll h;
  if(l <= pindex && Array[l] > Array[i])largest=l;
  else largest=i;
  if(r<=pindex && Array[r] > Array[largest])largest = r;
  if(largest != i){
    h = Array[i];
    Array[i] = Array[largest];
    Array[largest] = h;
    maxHeapify(largest);
  } 
}


void Insert(ll key){ //maxHeapInsert
  ++pindex;
  Array[pindex] = MIN;
  heapIncreaseKey(pindex,key);
}

ll heapExtractMax(){
  ll max;
  if(pindex < 1)return -1;
  max = Array[1];
  Array[1] = Array[pindex];
  pindex--;
  maxHeapify(1);
  return max;
}




int main(){
  char op[1000];
  ll val;

  while(true){
    scanf("%s",op);
    if(strcmp(op,"insert") == 0){
      scanf("%lld",&val);
      Insert(val);
    }
    else if(strcmp(op,"extract") == 0){
      printf("%lld\n",heapExtractMax());
    }
    else if(strcmp(op,"end") == 0)break;
  }

  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:75:9: error: 'true' undeclared (first use in this function)
   75 |   while(true){
      |         ^~~~
main.c:3:1: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
    2 | #include<string.h>
  +++ |+#include <stdbool.h>
    3 | #define MAX 2000200
main.c:75:9: note: each undeclared identifier is reported only once for each function it appears in
   75 |   while(true){
      |         ^~~~
Language: C

#include<stdio.h>
#include<string.h>
#define MAX 2000200
#define MIN -2000000300
typedef long ll;

int pindex;
ll Array[MAX];

int getParent(int i){
  return i/2;
}

int getLeft(int i){
  return 2*i;
}

int getRight(int i){
    return 2*i+1;
}


int heapIncreaseKey(int i,ll key){
  ll h;
  if(key < Array[i])return -1;
  Array[i] = key;
  while(i > 1 && Array[getParent(i)] < Array[i]){
    h = Array[i];
    Array[i] = Array[getParent(i)];
    Array[getParent(i)] = h;
    i = getParent(i);
  }
}

void maxHeapify(int i){
  ll l = getLeft(i);
  ll r = getRight(i);
  ll largest;
  ll h;
  if(l <= pindex && Array[l] > Array[i])largest=l;
  else largest=i;
  if(r<=pindex && Array[r] > Array[largest])largest = r;
  if(largest != i){
    h = Array[i];
    Array[i] = Array[largest];
    Array[largest] = h;
    maxHeapify(largest);
  } 
}


void Insert(ll key){ //maxHeapInsert
  ++pindex;
  Array[pindex] = MIN;
  heapIncreaseKey(pindex,key);
}

ll heapExtractMax(){
  ll max;
  if(pindex < 1)return -1;
  max = Array[1];
  Array[1] = Array[pindex];
  pindex--;
  maxHeapify(1);
  return max;
}




int main(){
  char op[1000];
  ll val;

  while(true){
    scanf("%s",op);
    if(strcmp(op,"insert") == 0){
      scanf("%ld",&val);
      Insert(val);
    }
    else if(strcmp(op,"extract") == 0){
      printf("%ld\n",heapExtractMax());
    }
    else if(strcmp(op,"end") == 0)break;
  }

  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:75:9: error: 'true' undeclared (first use in this function)
   75 |   while(true){
      |         ^~~~
main.c:3:1: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
    2 | #include<string.h>
  +++ |+#include <stdbool.h>
    3 | #define MAX 2000200
main.c:75:9: note: each undeclared identifier is reported only once for each function it appears in
   75 |   while(true){
      |         ^~~~
Language: C

#include <stdio.h>
#include <stdlib.h>
define N 200000;

void maxheap(int *,int);
 
int main(int argc,char*argv[]) {
    int *heap, key, index, half, tmp;
    char cmd[20];
 
    heap = malloc(sizeof(int) * N);
    heap[0] = 1;
    while (1) {
        scanf("%s %d ", cmd, &key);
        if (cmd[0] == 'i') {
            heap[0]++;
            index = heap[0];
            heap[index] = key;
 
            half = index / 2;
            while (index > 1 && heap[half] < heap[index]) {
                tmp = heap[index];
                heap[index] = heap[half];
                heap[half] = tmp;
                index /= 2;
                half = index / 2;
            }
        } else if (cmd[1] == 'x') {
            printf("%d\n", heap[1]);
            heap[1] = heap[heap[0]];
            heap[0]--;
            maxheapify(heap, 1);
        } else {
            return 0;
        }
    }
    return 0;
}

void maxheap(int *heap, int i) {
    int heapsize, l, r, largest, tmp;
 
    heapsize = heap[0];
    l = 2*i;
    r = 2*i + 1;
    if (l <= heapsize && heap[l] > heap[i]) {
        largest = l;
    } else {
        largest = i;
    }
    if (r <= heapsize && heap[r] > heap[largest]) {
        largest = r;
    }
    if (largest != i) {
        tmp = heap[i];
        heap[i] = heap[largest];
        heap[largest] = tmp;
        maxheap(heap, largest);
    }
}

Compiler output:
main.c:3:1: error: unknown type name 'define'
    3 | define N 200000;
      | ^~~~~~
main.c:3:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before numeric constant
    3 | define N 200000;
      |          ^~~~~~
main.c: In function 'main':
main.c:11:33: error: 'N' undeclared (first use in this function)
   11 |     heap = malloc(sizeof(int) * N);
      |                                 ^
main.c:11:33: note: each undeclared identifier is reported only once for each function it appears in
main.c:32:13: error: implicit declaration of function 'maxheapify'; did you mean 'maxheap'? [-Wimplicit-function-declaration]
   32 |             maxheapify(heap, 1);
      |             ^~~~~~~~~~
      |             maxheap
Language: C

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#define N 2000005 //命令の数の最大量
int A[N],j=0;
 
int Parent(int i){ //親のアドレス値
  return i/2;
}
int Left(int i){ //左の子のアドレス値
  return 2*i;
}
int Right(int i){ //右の子のアドレス値
  return 2*i+1;
}
 
void heapIncreaseKey(int i,int key){
	int tmp;
  if(key<A[i])  return;//例外エラー処理
  A[i]=key; //挿入
  while(i>1 && A[Parent(i)]<A[i]){ //今回挿入した子が、その親より大きい場合は入れ替える、そして親＞子の関係になるまで繰り返す
    tmp=A[i];
    A[i]=A[Parent(i)];
    A[Parent(i)]=tmp;
    i=Parent(i);
  }
}
 
void maxHeapInsert(int key){ //A[j]にkeyをインサートします
  j++;
  A[j]=-1; //小さい値を入れます（keyの最小値が０なので、ここではー１）
  heapIncreaseKey(j,key); //ここで挿入
}
 
void maxHeapify(int i){ //最大値削除に伴う辻褄合わせ。末端の値が木の一番上に来たので、それ（i）を親＞子の関係が成立するまで下げていく
  int tmp,l=Left(i),r=Right(i),largest;
 
  if(l<=j && A[l]>A[i]) largest=l;
  else largest=i;
 
  if(r<=j && A[r]>A[largest])largest=r;
 
  if(largest!=i){
    tmp=A[i];
    A[i]=A[Largest];
    A[largest]=tmp;
    maxHeapify(largest);
  }
}
 
int heapExtractMax(){ //最大値のリターン、削除
  int max;
 
  if (j<1) return 0; //例外エラー処理
  max=A[1]; //maxに木の一番上の値を入れる
  A[1]=A[j]; //木の一番上に木の末端の値を入れる
  j--; //末端のアドレス値を一つ消す
  maxHeapify(1);
  return max;
}
 
main(){
  char str[20];
  int key;
   
  while(1){ //無限ループ回しましょうか
    scanf("%s",str);  //まずは文字の読み込み
    if(strcmp(str,"end")==0) break;  //文字列がendでループ抜ける
 
    if(str[0]=='i') { //文字列がinsertでkeyをinsert
      scanf("%d",&key);
      maxHeapInsert(key);
    }
    else printf("%d\n",heapExtractMax());  //文字列がextractで最大値を出力、および木から最大値の削除
  }
  return 0;
}

Compiler output:
main.c: In function 'maxHeapify':
main.c:46:12: error: 'Largest' undeclared (first use in this function); did you mean 'largest'?
   46 |     A[i]=A[Largest];
      |            ^~~~~~~
      |            largest
main.c:46:12: note: each undeclared identifier is reported only once for each function it appears in
main.c: At top level:
main.c:63:1: error: return type defaults to 'int' [-Wimplicit-int]
   63 | main(){
      | ^~~~
Language: C

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#define N 2000005 //命令の数の最大量
int A[N],j=0;
 
int Parent(int i){ //親のアドレス値
  return i/2;
}
int Left(int i){ //左の子のアドレス値
  return 2*i;
}
int Right(int i){ //右の子のアドレス値
  return 2*i+1;
}
 
void heapIncreaseKey(int i,int key){
	int tmp;
  if(key<A[i])  return; //例外エラー処理
  A[i]=key; //挿入
  while(i>1 && A[Parent(i)]<A[i]){ //今回挿入した子が、その親より大きい場合は入れ替える、そして親＞子の関係になるまで繰り返す
    tmp=A[i];
    A[i]=A[Parent(i)];
    A[Parent(i)]=tmp;
    i=Parent(i);
  }
}
 
void maxHeapInsert(int key){ //A[j]にkeyをインサートします
  j++;
  A[j]=-1; //小さい値を入れます（keyの最小値が０なので、ここではー１）
  heapIncreaseKey(j,key); //ここで挿入
}
 
void maxHeapify(int i){ //最大値削除に伴う辻褄合わせ。末端の値が木の一番上に来たので、それ（i）を親＞子の関係が成立するまで下げていく
  int tmp,l=Left(i),r=Right(i),largest;
 
  if(l<=j && A[l]>A[i]) largest=l;
  else largest=i;
 
  if(r<=j && A[r]>A[largest])largest=r;
 
  if(largest!=i){
    tmp=A[i];
    A[i]=A[Largest];
    A[largest]=tmp;
    maxHeapify(largest);
  }
}
 
int heapExtractMax(){ //最大値のリターン、削除
  int max;
  if (j<1) return 0; //例外エラー処理
  max=A[1]; //maxに木の一番上の値を入れる
  A[1]=A[j]; //木の一番上に木の末端の値を入れる
  j--; //末端のアドレス値を一つ消す
  maxHeapify(1);
  return max;
}
 
main(){
  char str[20];
  int key;
   
  while(1){ //無限ループ回しましょうか
    scanf("%s",str); //まずは文字の読み込み
    if(strcmp(str,"end")==0) break; //文字列がendでループ抜ける
 
    if(str[0]=='i') { //文字列がinsertでkeyをinsert
      scanf("%d",&key);
      maxHeapInsert(key);
    }
    else printf("%d\n",heapExtractMax()); //文字列がextractで最大値を出力、および木から最大値の削除
  }
  return 0;
}

Compiler output:
main.c: In function 'maxHeapify':
main.c:46:12: error: 'Largest' undeclared (first use in this function); did you mean 'largest'?
   46 |     A[i]=A[Largest];
      |            ^~~~~~~
      |            largest
main.c:46:12: note: each undeclared identifier is reported only once for each function it appears in
main.c: At top level:
main.c:62:1: error: return type defaults to 'int' [-Wimplicit-int]
   62 | main(){
      | ^~~~
Language: C

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#define N 2000005
int A[N],j=0;
 
int Parent(int i){ //親のアドレス値
  return i/2;
}
int Left(int i){ //左の子のアドレス値
  return 2*i;
}
int Right(int i){ //右の子のアドレス値
  return 2*i+1;
}
 
void heapIncreaseKey(int i,int key){
	int tmp;
  if(key<A[i])  return; //例外エラー処理
  A[i]=key; //挿入
  while(i>1 && A[Parent(i)]<A[i]){ //今回挿入した子が、その親より大きい場合は入れ替える、そして親＞子の関係になるまで繰り返す
    tmp=A[i];
    A[i]=A[Parent(i)];
    A[Parent(i)]=tmp;
    i=Parent(i);
  }
}
 
void maxHeapInsert(int key){ //A[j]にkeyをインサートします
  j++;
  A[j]=-1; //小さい値を入れます（keyの最小値が０なので、ここではー１）
  heapIncreaseKey(j,key); //ここで挿入
}
 
void maxHeapify(int i){ //最大値削除に伴う辻褄合わせ。末端の値が木の一番上に来たので、それ（i）を親＞子の関係が成立するまで下げていく
  int tmp,l=Left(i),r=Right(i),largest;
 
  if(l<=j && A[l]>A[i]) largest=l;
  else largest=i;
 
  if(r<=j && A[r]>A[largest])largest=r;
 
  if(largest!=i){
    tmp=A[i];
    A[i]=A[Largest];
    A[largest]=tmp;
    maxHeapify(largest);
  }
}
 
int heapExtractMax(){ //最大値のリターン、削除
  int max;
  if (j<1) return 0; //例外エラー処理
  max=A[1]; //maxに木の一番上の値を入れる
  A[1]=A[j]; //木の一番上に木の末端の値を入れる
  j--; //末端のアドレス値を一つ消す
  maxHeapify(1);
  return max;
}
 
main(){
  char str[20];
  int key;
   
  while(1){ //無限ループ回しましょうか
    scanf("%s",str); //まずは文字の読み込み
    if(strcmp(str,"end")==0) break; //文字列がendでループ抜ける
 
    if(str[0]=='i') { //文字列がinsertでkeyをinsert
      scanf("%d",&key);
      maxHeapInsert(key);
    }
    else printf("%d\n",heapExtractMax()); //文字列がextractで最大値を出力、および木から最大値の削除
  }
  return 0;
}

Compiler output:
main.c: In function 'maxHeapify':
main.c:46:12: error: 'Largest' undeclared (first use in this function); did you mean 'largest'?
   46 |     A[i]=A[Largest];
      |            ^~~~~~~
      |            largest
main.c:46:12: note: each undeclared identifier is reported only once for each function it appears in
main.c: At top level:
main.c:62:1: error: return type defaults to 'int' [-Wimplicit-int]
   62 | main(){
      | ^~~~
Language: C++

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H,A[MAX+1];

void maxHeapify(int i){
  int l,r,largest;
  l=2*i;
  r=2*i+1;

  if(l<=H&&A[l]>A[i]) largest=l;
  else largest=i;
  if(r<=H&&A[r]>A[largest]) largest=r;

  if(largest!=i){
    swap(A[i],A[largest]);
    maxHeapify(largest);
  }
}

int extract(){
  int maxv;
  if(H<1) return -INFTY;
  maxv=A[1];
  A[1]=A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int key){
  if(key<A[i]) return;
  A[i]=key;
  while(i>1&&A[i/2]<A[i]){
    swap(A[i],A[i/2]);
    i=i/2
      }
}

void insert(int key){
  H++;
  A[H]=-INFTY;
  increaseKey(H,key);
}

int main(){
  int key;
  char com[10];

  while(1){
    scanf("%s",com);
    if(com[0]=='e'&&com[1]=='n') break;
    if(com[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }else{
      printf("%d\n"extract());
    }
  }
  return 0;
}



Compiler output:
a.cc: In function 'void increaseKey(int, int)':
a.cc:39:10: error: expected ';' before '}' token
   39 |     i=i/2
      |          ^
      |          ;
   40 |       }
      |       ~   
a.cc: In function 'int main()':
a.cc:60:14: error: unable to find string literal operator 'operator""extract' with 'const char [4]', 'long unsigned int' arguments
   60 |       printf("%d\n"extract());
      |              ^~~~~~~~~~~~~
Language: C++

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H,A[MAX+1];

void maxHeapify(int i){
  int l,r,largest;
  l=2*i;
  r=2*i+1;

  if(l<=H&&A[l]>A[i]) largest=l;
  else largest=i;
  if(r<=H&&A[r]>A[largest]) largest=r;

  if(largest!=i){
    swap(A[i],A[largest]);
    maxHeapify(largest);
  }
}

int extract(){
  int maxv;
  if(H<1) return -INFTY;
  maxv=A[1];
  A[1]=A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int key){
  if(key<A[i]) return;
  A[i]=key;
  while(i>1&&A[i/2]<A[i]){
    swap(A[i],A[i/2]);
    i=i/2
      }
}

void insert(int key){
  H++;
  A[H]=-INFTY;
  increaseKey(H,key);
}

int main(){
  int key;
  char com[10];

  while(1){
    scanf("%s",com);
    if(com[0]=='e'&&com[1]=='n') break;
    if(com[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }else{
      printf("%d\n",extract());
    }
  }
  return 0;
}



Compiler output:
a.cc: In function 'void increaseKey(int, int)':
a.cc:39:10: error: expected ';' before '}' token
   39 |     i=i/2
      |          ^
      |          ;
   40 |       }
      |       ~
Language: C++

#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int H,A[2000000001],key;
string com;
void maxHeapify(int A[],int i){
    int l=2*i,r=2*i+1,largest;
    if(l<=H&&A[l]>A[i]) largest=l;
    else largest=i;
    if(r<=H&&A[r]>A[largest]) largest=r;
    if(largest!=i){
        swap(A[i],A[largest]);
        maxHeapify(A,largest);
    }
}
void insert(int key){
    H++;
    int h=H;
    A[H]=key;
    while(h>1&&A[h]>A[h/2]){
        swap(A[h],A[h/2]);
        h=h/2;
    }
}
void extract(){
    if(H<1)return;
    else{
        cout<<A[1]<<endl;
        swap(A[1],A[H]);
        H--;
        maxHeapify(A,1);
    }
}
int main(){
    H=0;
    while(1){
        cin>>com;
        if(com=="end") break;
        if(com=="insert"){cin>>key; insert(key);}
        else extract();
    }
    return 0;
}


Compiler output:
/tmp/cc7nWtTM.o: in function `main':
a.cc:(.text+0x272): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/cc7nWtTM.o
a.cc:(.text+0x295): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/cc7nWtTM.o
a.cc:(.text+0x2b2): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/cc7nWtTM.o
a.cc:(.text+0x2c5): relocation truncated to fit: R_X86_64_PC32 against symbol `key' defined in .bss section in /tmp/cc7nWtTM.o
a.cc:(.text+0x2dd): relocation truncated to fit: R_X86_64_PC32 against symbol `key' defined in .bss section in /tmp/cc7nWtTM.o
/tmp/cc7nWtTM.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x303): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/cc7nWtTM.o
a.cc:(.text+0x31c): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/cc7nWtTM.o
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int H,A[2000000001],key;
string com;
void maxHeapify(int A[],int i){
    int l=2*i,r=2*i+1,largest;
    if(l<=H&&A[l]>A[i]) largest=l;
    else largest=i;
    if(r<=H&&A[r]>A[largest]) largest=r;
    if(largest!=i){
        swap(A[i],A[largest]);
        maxHeapify(A,largest);
    }
}
void insert(int key){
    H++;
    int h=H;
    A[H]=key;
    while(h>1&&A[h]>A[h/2]){
        swap(A[h],A[h/2]);
        h=h/2;
    }
}
void extract(){
    if(H<1)return;
    else{
        cout<<A[1]<<endl;
        swap(A[1],A[H]);
        H--;
        maxHeapify(A,1);
    }
}
int main(){
    H=0;
    while(1){
        cin>>com;
        if(com=="end") break;
        if(com=="insert"){cin>>key; insert(key);}
        else extract();
    }
    return 0;
}


Compiler output:
/tmp/cc9juosy.o: in function `main':
a.cc:(.text+0x272): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/cc9juosy.o
a.cc:(.text+0x295): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/cc9juosy.o
a.cc:(.text+0x2b2): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/cc9juosy.o
a.cc:(.text+0x2c5): relocation truncated to fit: R_X86_64_PC32 against symbol `key' defined in .bss section in /tmp/cc9juosy.o
a.cc:(.text+0x2dd): relocation truncated to fit: R_X86_64_PC32 against symbol `key' defined in .bss section in /tmp/cc9juosy.o
/tmp/cc9juosy.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x303): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/cc9juosy.o
a.cc:(.text+0x31c): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/cc9juosy.o
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int H=0,A[2000000001],key;
string com;
void maxHeapify(int A[],int i){
    int l=2*i,r=2*i+1,largest;
    if(l<=H&&A[l]>A[i]) largest=l;
    else largest=i;
    if(r<=H&&A[r]>A[largest]) largest=r;
    if(largest!=i){
        swap(A[i],A[largest]);
        maxHeapify(A,largest);
    }
}
void insert(int key){
    H++;
    int h=H;
    A[H]=key;
    while(h>1&&A[h]>A[h/2]){
        swap(A[h],A[h/2]);
        h=h/2;
    }
}
void extract(){
    if(H<1)return;
    else{
        cout<<A[1]<<endl;
        swap(A[1],A[H]);
        H--;
        maxHeapify(A,1);
    }
}
int main(){
    while(1){
        cin>>com;
        if(com=="end") break;
        if(com=="insert"){cin>>key; insert(key);}
        else extract();
    }
    return 0;
}


Compiler output:
/tmp/cc07VTIU.o: in function `main':
a.cc:(.text+0x268): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/cc07VTIU.o
a.cc:(.text+0x28b): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/cc07VTIU.o
a.cc:(.text+0x2a8): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/cc07VTIU.o
a.cc:(.text+0x2bb): relocation truncated to fit: R_X86_64_PC32 against symbol `key' defined in .bss section in /tmp/cc07VTIU.o
a.cc:(.text+0x2d3): relocation truncated to fit: R_X86_64_PC32 against symbol `key' defined in .bss section in /tmp/cc07VTIU.o
/tmp/cc07VTIU.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x2f9): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/cc07VTIU.o
a.cc:(.text+0x312): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/cc07VTIU.o
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int H=0,A[2000000001];
string com;
void maxHeapify(int A[],int i){
    int l=2*i,r=2*i+1,largest;
    if(l<=H&&A[l]>A[i]) largest=l;
    else largest=i;
    if(r<=H&&A[r]>A[largest]) largest=r;
    if(largest!=i){
        swap(A[i],A[largest]);
        maxHeapify(A,largest);
    }
}
void insert(int key){
    H++;
    int h=H;
    A[H]=key;
    while(h>1&&A[h]>A[h/2]){
        swap(A[h],A[h/2]);
        h=h/2;
    }
}
void extract(){
    if(H<1)return;
    else{
        cout<<A[1]<<endl;
        swap(A[1],A[H]);
        H--;
        maxHeapify(A,1);
    }
}
int main(){
    while(1){
        cin>>com;
        int key;
        if(com=="end") break;
        if(com=="insert"){cin>>key; insert(key);}
        else extract();
    }
    return 0;
}


Compiler output:
/tmp/ccbIk2Jh.o: in function `main':
a.cc:(.text+0x26c): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/ccbIk2Jh.o
a.cc:(.text+0x28f): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/ccbIk2Jh.o
a.cc:(.text+0x2b3): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/ccbIk2Jh.o
/tmp/ccbIk2Jh.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x2f8): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/ccbIk2Jh.o
a.cc:(.text+0x311): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/ccbIk2Jh.o
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int H=0,A[2000000001];
string com;
void maxHeapify(int i){
    int l=2*i,r=2*i+1,largest;
    if(l<=H&&A[l]>A[i]) largest=l;
    else largest=i;
    if(r<=H&&A[r]>A[largest]) largest=r;
    if(largest!=i){
        swap(A[i],A[largest]);
        maxHeapify(largest);
    }
}
void insert(int key){
    H++;
    int h=H;
    A[H]=key;
    while(h>1&&A[h]>A[h/2]){
        swap(A[h],A[h/2]);
        h=h/2;
    }
}
void extract(){
    if(H<1)return;
    else{
        cout<<A[1]<<endl;
        swap(A[1],A[H]);
        H--;
        maxHeapify(1);
    }
}
int main(){
    while(1){
        cin>>com;
        int k;
        if(com=="end") break;
        if(com=="insert"){cin>>k; insert(k);}
        else extract();
    }
    return 0;
}


Compiler output:
/tmp/ccOqdzCi.o: in function `main':
a.cc:(.text+0x261): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/ccOqdzCi.o
a.cc:(.text+0x284): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/ccOqdzCi.o
a.cc:(.text+0x2a8): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/ccOqdzCi.o
/tmp/ccOqdzCi.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x2ed): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/ccOqdzCi.o
a.cc:(.text+0x306): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/ccOqdzCi.o
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int H=0,A[2000000001];
string com;
void maxHeapify(int i){
    int l=2*i,r=2*i+1,largest;
    if(l<=H&&A[l]>A[i]) largest=l;
    else largest=i;
    if(r<=H&&A[r]>A[largest]) largest=r;
    if(largest!=i){
        swap(A[i],A[largest]);
        maxHeapify(largest);
    }
}
void insert(int key){
    H++;
    int h=H;
    A[H]=key;
    while(h>1&&A[h]>A[h/2]){
        swap(A[h],A[h/2]);
        h=h/2;
    }
}
void extract(){
    if(H<1)return;
    else{
        cout<<A[1]<<endl;
        swap(A[1],A[H]);
        H--;
        maxHeapify(1);
    }
}
int main(){
    while(1){
        cin>>com;
        int k;
        if(com=="end") break;
        if(com=="insert"){cin>>k; insert(k);}
        else extract();
    }
    return 0;
}


Compiler output:
/tmp/ccJYYegm.o: in function `main':
a.cc:(.text+0x261): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/ccJYYegm.o
a.cc:(.text+0x284): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/ccJYYegm.o
a.cc:(.text+0x2a8): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/ccJYYegm.o
/tmp/ccJYYegm.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x2ed): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/ccJYYegm.o
a.cc:(.text+0x306): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/ccJYYegm.o
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int H=0,A[2000000001];
string com;
void maxHeapify(int i){
    int l=2*i,r=2*i+1,largest;
    if(l<=H&&A[l]>A[i]) largest=l;
    else largest=i;
    if(r<=H&&A[r]>A[largest]) largest=r;
    if(largest!=i){
        swap(A[i],A[largest]);
        maxHeapify(largest);
    }
}
void insert(int key){
    H++;
    int h=H;
    A[H]=key;
    while(h>1&&A[h]>A[h/2]){
        swap(A[h],A[h/2]);
        h=h/2;
    }
}
void extract(){
    if(H<1)return;
    else{
        cout<<A[1]<<endl;
        swap(A[1],A[H]);
        H--;
        maxHeapify(1);
    }
}
int main(){
    while(1){
        cin>>com;
        int k;
        if(com=="end") break;
        if(com=="insert"){cin>>k; insert(k);}
        else extract();
    }
    return 0;
}


Compiler output:
/tmp/ccmRZ7nQ.o: in function `main':
a.cc:(.text+0x261): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/ccmRZ7nQ.o
a.cc:(.text+0x284): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/ccmRZ7nQ.o
a.cc:(.text+0x2a8): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/ccmRZ7nQ.o
/tmp/ccmRZ7nQ.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x2ed): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/ccmRZ7nQ.o
a.cc:(.text+0x306): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/ccmRZ7nQ.o
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int H=0,A[2000000001];
string com;
void maxHeapify(int i){
    int l=2*i,r=2*i+1,largest;
    if(l<=H&&A[l]>A[i]) largest=l;
    else largest=i;
    if(r<=H&&A[r]>A[largest]) largest=r;
    if(largest!=i){
        swap(A[i],A[largest]);
        maxHeapify(largest);
    }
}
void insert(int key){
    H++;
    int h=H;
    A[H]=key;
    while(h>1&&A[h]>A[h/2]){
        swap(A[h],A[h/2]);
        h=h/2;
    }
}
void extract(){
    if(H<1)return;
    else{
        cout<<A[1]<<endl;
        swap(A[1],A[H]);
        H--;
        maxHeapify(1);
    }
}
int main(){
    while(1){
        cin>>com;
        int k;
        if(com=="end") break;
        if(com=="insert"){cin>>k; insert(k);}
        else extract();
    }
    return 0;
}


Compiler output:
/tmp/cc51DINJ.o: in function `main':
a.cc:(.text+0x261): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/cc51DINJ.o
a.cc:(.text+0x284): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/cc51DINJ.o
a.cc:(.text+0x2a8): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/cc51DINJ.o
/tmp/cc51DINJ.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x2ed): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/cc51DINJ.o
a.cc:(.text+0x306): relocation truncated to fit: R_X86_64_PC32 against symbol `com[abi:cxx11]' defined in .bss section in /tmp/cc51DINJ.o
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
using namespace std;

int A[2000000],h;

void maxheapify(int i){
  int l,r,largest;
  l=2*i;
  r=2*i+1;
  if(l<=h && A[l]>A[i]) largest=l;
  else largest=i;
  if(r<=h && A[r]>A[largest]) largest=r;
  if(largest!=i){
    swap(A[i],A[largest]);
    maxheapify(largest);
  }
}

int extractmax(){
  int v;
  if(h<1) return 0;
  v=A[1];
  A[1]=A[h--];
  maxheapify(1)
  return v;
}

void buildmaxheap(){
  for(int i=h/2;i>0;i--){
    maxheapify(i);
  }
}

void insert(int k){
  h++;
  int i=h;
  A[h]=k;
  while(i>1 && A[i/2]<A[i]){
    swap(A[i], A[i/2]);
    i/=2;
  } 
  
}

int main(){
  string s;
  int a;
  while(1){
    cin>>s;
    if(s[0]=='i'){
      cin>>a;
      insert(a);
    }
    else if(s[1]=='x'){
      cout<<extractmax()<<endl;
    }
    else return 0;
  }
}



Compiler output:
a.cc: In function 'int extractmax()':
a.cc:24:16: error: expected ';' before 'return'
   24 |   maxheapify(1)
      |                ^
      |                ;
   25 |   return v;
      |   ~~~~~~        
a.cc:24:13: warning: control reaches end of non-void function [-Wreturn-type]
   24 |   maxheapify(1)
      |   ~~~~~~~~~~^~~
Language: C++

#include<bits/stdc++h>
#include<string>

using namespace std;

int main(){
letter[30], dump[30];
Int b;
priority_queue<int>PQ;
do{
gets(A, 25, stdin);
if(A[0]==i){
Sscanf(A, "%*s %d, &b, sizeof(b));
PQ.push(b);
}else{
if(A[0]=='e' && A[1]=='n' && A[2]=='d){
break:
}else{
cout << PQ.top() << endl;
PQ.pop();
}
}while(1);
return 0;
}


Compiler output:
a.cc:1:9: fatal error: bits/stdc++h: No such file or directory
    1 | #include<bits/stdc++h>
      |         ^~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++h>
#include<string>

using namespace std;

int main(){
char letter[30], dump[30];
int b;
priority_queue<int>PQ;
do{
fgets(letter, 25, stdin);
if(letter[0]==i){
sscanf(letter, "%*s %d", &b, sizeof(b));
PQ.push(b);
}else{
if(letter[0]=='e' && letter[1]=='n' && letter[2]=='d'){
break;
}else{
cout << PQ.top() << endl;
PQ.pop();
}
}while(1);
return 0;
}


Compiler output:
a.cc:1:9: fatal error: bits/stdc++h: No such file or directory
    1 | #include<bits/stdc++h>
      |         ^~~~~~~~~~~~~~
compilation terminated.
Language: C++

import java.util.Scanner;
// Java program to implement Max Heap 
public 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 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.Scanner;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
    3 | public class MaxHeap {
      | ^~~~~~
Language: C++

import java.util.Scanner;
// Java program to implement Max Heap 
public 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.Scanner;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
    3 | public class MaxHeap {
      | ^~~~~~
a.cc:106:1: error: expected unqualified-id before 'public'
  106 | public Main{
      | ^~~~~~
Language: C++

import java.util.*;
// Java program to implement Max Heap 
public 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:3:1: error: expected unqualified-id before 'public'
    3 | public class MaxHeap {
      | ^~~~~~
a.cc:106:1: error: expected unqualified-id before 'public'
  106 | public Main{
      | ^~~~~~
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 (2*input + 1);
	}
	
	int filhoDireito(int input){
		return (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 < Heap.tamanho && Array[esquerdo] > Array[arrumar]){
			maior = esquerdo;
		}
		if (direito < Heap.tamanho && Array[direito] > Array[arrumar]){
			maior = direito;
		}
		if (maior != arrumar){
			swap(Array[arrumar], Array[maior]);
			HeapifyRemover(maior);
		}
	}
	
	void HeapifyInserir(int arrumar){
		if (arrumar && Array[pai(arrumar)] < Array[arrumar]){
			swap(Array[pai(arrumar)], Array[arrumar]);
			HeapifyInserir(pai(arrumar));
		}
	}
	
	void inserirHeap(int valor){
		Array[tamanho+1] = valor;		
		HeapifyInserir(tamanho);
		tamanho++;
	}
	
	int removerRaiz(){
		int raiz = Array[0];
		Array[0] = Array[tamanho-1];
		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: In member function 'void Heap::HeapifyRemover(int)':
a.cc:29:36: error: expected primary-expression before '.' token
   29 |                 if (esquerdo < Heap.tamanho && Array[esquerdo] > Array[arrumar]){
      |                                    ^
a.cc:32:35: error: expected primary-expression before '.' token
   32 |                 if (direito < Heap.tamanho && Array[direito] > Array[arrumar]){
      |                                   ^
Language: C++

#include <iostream>
#include <vector>
#include <stdio.h>

using namespace std;

struct Heap{
	int Array[2000000];
	int tamanho;
	
	int pai(int input){
		return (input - 1)/2;
	}
	
	int filhoEsquerdo(int input){
		return (2*input + 1);
	}
	
	int filhoDireito(int input){
		return (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[esquerdo] > Array[arrumar]){
			maior = esquerdo;
		}
		if (direito < tamanho && Array[direito] > Array[maior]){
			maior = direito;
		}
		if (maior != arrumar){
			swap(Array[arrumar], Array[maior]);
			HeapifyRemover(maior);
		}
	}
	
	void HeapifyInserir(int arrumar){
		if (arrumar && Array[pai(arrumar)] < Array[arrumar]){
			swap(Array[pai(arrumar)], Array[arrumar]);
			HeapifyInserir(pai(arrumar));
		}
	}
	
	void inserirHeap(int valor){
		Array[tamanho](valor);
		tamanho++;
		HeapifyInserir(tamanho-1);
	}
	
	void printaRaiz(){
		printf("%i\n", Array[0]);
	}
	
	int removerRaiz(){
		Array[0] = Array[tamanho-1]);
		Array[tamanho-1] = 0;
		tamanho--;
		HeapifyRemover(0);
	}
};

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



Compiler output:
a.cc: In member function 'void Heap::inserirHeap(int)':
a.cc:51:31: error: expression cannot be used as a function
   51 |                 Array[tamanho](valor);
      |                 ~~~~~~~~~~~~~~^~~~~~~
a.cc: In member function 'int Heap::removerRaiz()':
a.cc:61:44: error: expected ';' before ')' token
   61 |                 Array[0] = Array[tamanho-1]);
      |                                            ^
a.cc:65:9: warning: no return statement in function returning non-void [-Wreturn-type]
   65 |         }
      |         ^
Language: C++

#include <iostream>
#include <stdio.h>

using namespace std;

struct Heap{
	int Array[2000000];
	int tamanho;
	
	int pai(int input){
		return (input - 1)/2;
	}
	
	int filhoEsquerdo(int input){
		return (2*input + 1);
	}
	
	int filhoDireito(int input){
		return (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[esquerdo] > Array[arrumar]){
			maior = esquerdo;
		}
		if (direito < tamanho && Array[direito] > Array[maior]){
			maior = direito;
		}
		if (maior != arrumar){
			swap(Array[arrumar], Array[maior]);
			HeapifyRemover(maior);
		}
	}
	
	void HeapifyInserir(int arrumar){
		if (arrumar && Array[pai(arrumar)] < Array[arrumar]){
			swap(Array[pai(arrumar)], Array[arrumar]);
			HeapifyInserir(pai(arrumar));
		}
	}
	
	void inserirHeap(int valor){
		Array[tamanho](valor);
		tamanho++;
		HeapifyInserir(tamanho-1);
	}
	
	void printaRaiz(){
		printf("%i\n", Array[0]);
	}
	
	int removerRaiz(){
		Array[0] = Array[tamanho-1]);
		Array[tamanho-1] = 0;
		tamanho--;
		HeapifyRemover(0);
	}
};

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



Compiler output:
a.cc: In member function 'void Heap::inserirHeap(int)':
a.cc:50:31: error: expression cannot be used as a function
   50 |                 Array[tamanho](valor);
      |                 ~~~~~~~~~~~~~~^~~~~~~
a.cc: In member function 'int Heap::removerRaiz()':
a.cc:60:44: error: expected ';' before ')' token
   60 |                 Array[0] = Array[tamanho-1]);
      |                                            ^
a.cc:64:9: warning: no return statement in function returning non-void [-Wreturn-type]
   64 |         }
      |         ^
Language: C++

#include <iostream>
#include <stdio.h>

using namespace std;

struct Heap{
	int Array[2000000];
	int tamanho;
	
	int pai(int input){
		return (input - 1)/2;
	}
	
	int filhoEsquerdo(int input){
		return (2*input + 1);
	}
	
	int filhoDireito(int input){
		return (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[esquerdo] > Array[arrumar]){
			maior = esquerdo;
		}
		if (direito < tamanho && Array[direito] > Array[maior]){
			maior = direito;
		}
		if (maior != arrumar){
			swap(Array[arrumar], Array[maior]);
			HeapifyRemover(maior);
		}
	}
	
	void HeapifyInserir(int arrumar){
		if (arrumar && Array[pai(arrumar)] < Array[arrumar]){
			swap(Array[pai(arrumar)], Array[arrumar]);
			HeapifyInserir(pai(arrumar));
		}
	}
	
	void inserirHeap(int valor){
		Array[tamanho](valor);
		tamanho++;
		HeapifyInserir(tamanho-1);
	}
	
	void printaRaiz(){
		printf("%i\n", Array[0]);
	}
	
	int removerRaiz(){
		Array[0] = Array[tamanho-1];
		Array[tamanho-1] = 0;
		tamanho--;
		HeapifyRemover(0);
	}
};

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



Compiler output:
a.cc: In member function 'void Heap::inserirHeap(int)':
a.cc:50:31: error: expression cannot be used as a function
   50 |                 Array[tamanho](valor);
      |                 ~~~~~~~~~~~~~~^~~~~~~
a.cc: In member function 'int Heap::removerRaiz()':
a.cc:64:9: warning: no return statement in function returning non-void [-Wreturn-type]
   64 |         }
      |         ^