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

#include<iostream>
using namespace std;
#define MAX 2000000

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 = r;
 else largest = i;
 if(r<=H && A[r] > A[largest]) largest = r;

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

int main(){
  cin >> H;

  for(int i=1; i<=H;i++) cin >> A[i];
  for(int i=H/2;i>=1;i--) maxHeapify(i);

  for(int i=1;i<=H;i++){
    cout << " " << A[i];
    cout << endl;

    return 0;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:33:4: error: expected '}' at end of input
   33 |   }
      |    ^
a.cc:22:11: note: to match this '{'
   22 | int main(){
      |           ^
Language: C++

#include <iostream>
using namespace std;

int H;
int largest;

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

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

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

void maxHeap(int A[],int i){
    int l = left(i);
    int r= right(i);
    
    if(l<=H && A[l]>A[i])
        largest = l;
    else
        largest = i;
    
    if(r<=H && A[r] > A[largest])
        largest = r;
    
    if(largest!=i){
        int temp = A[i];
        A[i] = A[largest];
        A[largest] = temp;
        maxHeap(A, largest);
    }
    
}

int main(int argc, const char * argv[]) {
    cin >> H;
    int A[H];
    for(int i=1;i<=H;i++){
       cin >> A[i];
    }
    
    for(int i=H/2;i>0;i--)
        maxHeap(A, i);
    
    for(int i=1;i<=H;i++){
        cout <<" " << A[i] <<;
    }
    
    return 0;
}

Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:51:30: error: expected primary-expression before ';' token
   51 |         cout <<" " << A[i] <<;
      |                              ^
Language: C++

#include <iostream>
#include <climits>
const long MAX_H = 500000;

void swap(long A[], long i, long j) {
  long tmp = A[i];
  A[i] = A[j];
  A[j] = tmp;
}

void maxHeapify(long A[], long i, long H) {
  long leftIndex = 2 * i;
  long rightIndex = 2 * i + 1;

  long largest = i;
    
  if ((leftIndex <= H) && (A[leftIndex] > A[i])) {
    largest = leftIndex;
  }

  if ((rightIndex <= H) && (A[rightIndex] > A[largest])) {
    largest = rightIndex;
  }

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

void buildMaxHeap(long A[], long H) {
  for (long i = H / 2; i >= 1; i--) {
    maxHeapify(A, i, H);
  }
}

long main(void) {
  long H = 0;
  long A[MAX_H + 1];

  std::cin >> H;

  for (long i = 1; i < MAX_H; i++) {
    std::cin >> A[i];
  }

  buildMaxHeap(A, H);

  for (long i = 1; i <= H; i++) {
    std::cout << " " << A[i];
  }

  std::cout << std::endl;
  
  return 0;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#inlcude <iostream>
using namespace std;

int H, A[5000000];

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

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

void maxHeapify(int i)
{
	int l, r, largest;
	l = left(i);
	r = right(i);

	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 main(void)
{
	cin >> H;

	for (int i = 1; i <= H; i++) cin >> A[i];
	for (int i = H / 2; i >= 1; i--) maxHeapify(i);
	for (int i = 1; i <= H; i++) cout << " " << A[i];
	cout << endl;

	return 0;
}

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #inlcude; did you mean #include?
    1 | #inlcude <iostream>
      |  ^~~~~~~
      |  include
a.cc: In function 'void maxHeapify(int)':
a.cc:29:17: error: 'swap' was not declared in this scope
   29 |                 swap(A[i], A[largest]);
      |                 ^~~~
a.cc: In function 'int main()':
a.cc:36:9: error: 'cin' was not declared in this scope
   36 |         cin >> H;
      |         ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #inlcude <iostream>
a.cc:40:38: error: 'cout' was not declared in this scope
   40 |         for (int i = 1; i <= H; i++) cout << " " << A[i];
      |                                      ^~~~
a.cc:40:38: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:41:9: error: 'cout' was not declared in this scope
   41 |         cout << endl;
      |         ^~~~
a.cc:41:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:41:17: error: 'endl' was not declared in this scope
   41 |         cout << endl;
      |                 ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | #inlcude <iostream>
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define MAX 5000000
void maxHeapify(int);
int B;
int A[MAX+1];
int main(){
  int i;
  cin >> B;
  for(i = 1; i <= B;i++){
    cin >> A[i];
  }
  for(i = B/2; i >= 1; i--){
    maxHeapify(i);
  }
  for(i = 1; i <=B; i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}

void maxHeapify(int i){

Compiler output:
a.cc: In function 'void maxHeapify(int)':
a.cc:23:24: error: expected '}' at end of input
   23 | void maxHeapify(int i){
      |                       ~^
Language: C++

#include<stdio.h>
#define MAX 2000000
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=1;
  else largest=i;
  if(r<=H && A[r]>A[largest]) largest=r;
  if(largest!=i){
    swap(A[i],A[largest]);
    maxHeapify(largest);
  }
}
int main(){
  int i;
  scanf("%d",&H);
  for( i=1;i<=H;i++){
    scanf("%d",A[i]);
  }
  for(i=H/2;i>=1;i--) maxHeapify(i);
  for(i=1;i<=H;i++){
    printf("%d ",A[i]);
  }
  printf("\n");
  return 0;
}

Compiler output:
a.cc: In function 'void maxHeapify(int)':
a.cc:12:5: error: 'swap' was not declared in this scope
   12 |     swap(A[i],A[largest]);
      |     ^~~~
Language: C++

#define MAX 2000000
int H,A[MAX+1];
void maxHeapify(int);

void maxHeapify(int i){
  int l,r,largest,c;
  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){
    c=A[i];
    A[i]=A[largest];
    A[largest]=c;
    maxHeapify(largest);
  }
}

int main()
{
  int i;
  
  scanf("%d",&H);

  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }

  for(i=H/2;i>=1;i--){
    maxHeapify(i);
  }

  for(i=1;i<=H;i++){
    printf("%d ",A[i]);
  }

  printf("\n");

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:3: error: 'scanf' was not declared in this scope
   26 |   scanf("%d",&H);
      |   ^~~~~
a.cc:37:5: error: 'printf' was not declared in this scope
   37 |     printf("%d ",A[i]);
      |     ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | #define MAX 2000000
a.cc:40:3: error: 'printf' was not declared in this scope
   40 |   printf("\n");
      |   ^~~~~~
a.cc:40:3: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
Language: C++

#include <stdio.h>
#include <stdlib.h>

int parent(int);
int left(int);
int right(int);
void maxHeapify(int*,int);
void insert(int*,int);
void extract(int*);
void increase(int*,int);

int h=0;

int main(){
  int i,k,*A;
  char s[10];

  A = (int *)malloc(sizeof(int)*2000000);

  while(1){
    scanf("%s",s);
    if(s[0]=='e'){
      if(s[1]=='n') break;
      else if(s[1]=='x') extract(A);
    }
    else if(s[0]=='i'){
      scanf("%d",&k);
      insert(A,k);
    }
    
  }


  return 0;
}

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

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

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

void maxHeapify(int* A,int i){
  int l,r,largest,tmp;
  
  l = left(i);
  r = right(i);

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

  if(r<=h && A[r]>A[largest]) largest = r;
  
  if(largest != i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(A,largest);
  }

  return;
}

void insert(int* A,int k){
  h++;
  A[h]=k;
  increase(A,k);
  return;
}

void extract(int* A){
  printf("%d\n",A[1]);
  A[1]=A[h];
  h--;
  maxHeapify(A,1);
  return;
}

Compiler output:
/usr/bin/ld: /tmp/ccrLDnDg.o: in function `insert(int*, int)':
a.cc:(.text+0x23f): undefined reference to `increase(int*, int)'
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
using namespace std
#define MAX 2000000

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 main(){
  int i;

  cin >> H;

  for(i = 1 ; i <= H ; i++){
    cin >> A[i];
  }
  for(i = H / 2 ; i >= 1 ; i--){
    maxHeapify(i);
  }
  for(i = 1 ; i <= H ; i++){
     cout << " " << A[i];
  }
  cout << endl;

  return 0;
}

Compiler output:
a.cc:2:20: error: expected ';' before 'int'
    2 | using namespace std
      |                    ^
      |                    ;
......
    5 | int H, A[MAX + 1];
      | ~~~
Language: C++

#include<iostream>
using namespace std
#define MAX 2000000

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 main(){

  cin >> H;

  for(int i = 1 ; i <= H ; i++){
    cin >> A[i];
  }
  for(int i = H / 2 ; i >= 1 ; i--){
    maxHeapify(i);
  }
  for(int i = 1 ; i <= H ; i++){
    cout << " " << A[i];
  }
  cout << endl;

  return 0;
}

Compiler output:
a.cc:2:20: error: expected ';' before 'int'
    2 | using namespace std
      |                    ^
      |                    ;
......
    5 | int H, A[MAX + 1];
      | ~~~
Language: C++

#include <stdio.h>
#define H 200000
void maxHeapify(int);

int x,A[H];
int main(){
  int i;
  scanf("%d",&x);
  for(i = 1;i <= x;i++){
    scanf("%d",&A[i]);
  }
  buildMaxHeap();
  for(i = 1;i <= x;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}
void maxHeapify(i){
  int l,r,largest,tmp;
  
  for(i = 1;i <= x;i++){
    l = 2*i;
    r = 2*i+1;
    if(l <= x && A[l] > A[i]){
      largest = l;
    }
    else largest = i;
    if(r <= x && A[r] > A[largest]){
      largest = r;
    }
    if(largest != i){
      tmp = A[i];
      A[i] = A[largest];
      A[largest] = tmp;
      maxHeapify(largest);
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:3: error: 'buildMaxHeap' was not declared in this scope
   12 |   buildMaxHeap();
      |   ^~~~~~~~~~~~
a.cc: At global scope:
a.cc:19:6: error: variable or field 'maxHeapify' declared void
   19 | void maxHeapify(i){
      |      ^~~~~~~~~~
a.cc:19:17: error: 'i' was not declared in this scope
   19 | void maxHeapify(i){
      |                 ^
Language: C++

#include <iostream>
using namespace std;
#define MAX 100000

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

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

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

int main(){
	int H,i,A[MAX+1];
	
	cin>>H;
	
	for(i=1;i<=H;i++){
		cin>>A[i];
	}
	
	for(i=1;i<=H;i++){
		cout<<"Node "<<i<<" key = "<<A[i]<<", ";
		if(parent(i)>=1) cout<<"parent key = "<<A[parent(i)]<<", ";
		if(left(i)<=H) cout<<"left key = "<<A[left(i)]<<", ";
		if(right(i)<=H) cout<<"right key = "<<A[right(i)]<<", "; 
		cout<<endl;
	}
	retu

Compiler output:
a.cc: In function 'int main()':
a.cc:30:9: error: 'retu' was not declared in this scope
   30 |         retu
      |         ^~~~
a.cc:30:13: error: expected '}' at end of input
   30 |         retu
      |             ^
a.cc:14:11: note: to match this '{'
   14 | int main(){
      |           ^
Language: C++

#include <stdio.h>
 
  
void maxH(int *node, int i, int g){
  int l, r, large, s;
   
  l = i*2;
  r = i*2+1;
     
  if(l <= g && node[l] > node[i]) large = l;
1  else large = i;
  if(r <= g && node[r] > node[large])large = r;
  
  if(large != i){
    s = node[i];
    node[i] = node[large];
    node[large] = s;
    maxH(node, large, g);
  }
}
  
main(){
  int i, g;
  int node[500001];
  
  scanf("%d", &g);
  
  for(i=1;i<=g;i++) scanf("%d", &node[i]);
  
  for(i =g/2;i>0;i--) maxH(node,i,g);
  
  
  for(i=1;i<=g;i++) printf(" %d",node[i]);
  
  printf("\n");
  return 0; 
}

Compiler output:
a.cc: In function 'void maxH(int*, int, int)':
a.cc:11:2: error: expected ';' before 'else'
   11 | 1  else large = i;
      |  ^ ~~~~
      |  ;
a.cc: At global scope:
a.cc:22:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   22 | main(){
      | ^~~~
Language: C++

#include<iostream>
using namespace std;
#define  MAX 2000000

int H, A[MAX + 1];

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

int main() {
	cin >> H;
	for (int i = 1; i <= H; i++) cin >> A[i];

	for (int i = H / 2; i >= 1; i--) macHeapify(i);

	for (int i = 1; i <= H; i++)
	{
		cout << " " << A[i];
	}
	cout << endl;

	return 0;
}

Compiler output:
a.cc: In function 'void macHeapify(int)':
a.cc:11:34: error: expected ')' before 'largest'
   11 |         if (l <= H && A[l] > A[i]largest = 1);
      |            ~                     ^~~~~~~
      |                                  )
Language: C++

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

int h,heap[500001];

void maxheap(int i){
  int l,r,lage=i;
  
  l=i*2;
  r=i*2+1;
  
  if(l<=h&&heap[l]>heap[lage]) lage=l;
  if(r<=H&&heap[r]>heap[lage]) lage=r;
  
  if(lage!=i){
    swap(heap[i],heap[lage]);
    maxheap(lage);
  }
  
}

int main(){
  scanf("%d",&h);
  for(int i=1;i<=h;i++) scanf("%d",&heap[i]);
  
  for(int i=h/2;i>=1;--i) maxheap(i);
  for(int i=1;i<=h;++i)printf(" %d",heap[i]);
  
  return (0);
}



Compiler output:
a.cc: In function 'void maxheap(int)':
a.cc:13:9: error: 'H' was not declared in this scope
   13 |   if(r<=H&&heap[r]>heap[lage]) lage=r;
      |         ^
Language: C++

#include<iostream>
using namespace std;
#define MAX 2000000000

int H;
int A[MAX+1];

void maxHeapify(int i) {
  int largest;
  left = 2 * i;
  right = 2 * i + 1;
  if ( l <= H && A[left] > A[i] ) largest = left;
  else larget = i;
  if ( r <= H && A[right > A{i] ) largest = right;
  
  if ( largest != i ) {
    swap(A[i], A[largest]);
    maxHeapify (largest);
  }
}

int main() {
  cin >> H;
  for ( int i = 1; i < H ; i++) cin >> A[i];
  
  for ( int i = H / 2 ; i >= 1; i-- ) maxHeapify(i);
  
  for ( int i = 1; i < H; i++ ) cout << " " << A[i]   ;
  cout << endl;
  return 0;
}


Compiler output:
a.cc: In function 'void maxHeapify(int)':
a.cc:10:8: error: assignment of function 'std::ios_base& std::left(ios_base&)'
   10 |   left = 2 * i;
      |   ~~~~~^~~~~~~
a.cc:11:9: error: assignment of function 'std::ios_base& std::right(ios_base&)'
   11 |   right = 2 * i + 1;
      |   ~~~~~~^~~~~~~~~~~
a.cc:12:8: error: 'l' was not declared in this scope
   12 |   if ( l <= H && A[left] > A[i] ) largest = left;
      |        ^
a.cc:12:19: error: invalid types 'int [2000000001][std::ios_base&(std::ios_base&)]' for array subscript
   12 |   if ( l <= H && A[left] > A[i] ) largest = left;
      |                   ^
a.cc:12:45: error: invalid conversion from 'std::ios_base& (*)(std::ios_base&)' to 'int' [-fpermissive]
   12 |   if ( l <= H && A[left] > A[i] ) largest = left;
      |                                             ^~~~
      |                                             |
      |                                             std::ios_base& (*)(std::ios_base&)
a.cc:13:8: error: 'larget' was not declared in this scope; did you mean 'largest'?
   13 |   else larget = i;
      |        ^~~~~~
      |        largest
a.cc:14:8: error: 'r' was not declared in this scope
   14 |   if ( r <= H && A[right > A{i] ) largest = right;
      |        ^
a.cc:14:26: error: comparison between distinct pointer types 'std::ios_base& (*)(std::ios_base&)' and 'int*' lacks a cast
   14 |   if ( r <= H && A[right > A{i] ) largest = right;
      |                    ~~~~~~^~~
a.cc:14:29: error: expected ']' before '{' token
   14 |   if ( r <= H && A[right > A{i] ) largest = right;
      |                             ^
      |                             ]
a.cc:14:29: error: expected ')' before '{' token
   14 |   if ( r <= H && A[right > A{i] ) largest = right;
      |      ~                      ^
      |                             )
a.cc:14:31: error: expected primary-expression before ']' token
   14 |   if ( r <= H && A[right > A{i] ) largest = right;
      |                               ^
Language: C++

#include<iostream>
using namespace std;
#define MAX 2000000

int H;
int A[MAX+1];

void maxHeapify(int i) {
  int largest;
  left = 2 * i;
  right = 2 * i + 1;
  if ( l <= H && A[left] > A[i] ) largest = left;
  else larget = i;
  if ( r <= H && A[right > A{i] ) largest = right;
  
  if ( largest != i ) {
    swap(A[i], A[largest]);
    maxHeapify (largest);
  }
}

int main() {
  cin >> H;
  for ( int i = 1; i < H ; i++) cin >> A[i];
  
  for ( int i = H / 2 ; i >= 1; i-- ) maxHeapify(i);
  
  for ( int i = 1; i < H; i++ ) cout << " " << A[i]   ;
  cout << endl;
  return 0;
}


Compiler output:
a.cc: In function 'void maxHeapify(int)':
a.cc:10:8: error: assignment of function 'std::ios_base& std::left(ios_base&)'
   10 |   left = 2 * i;
      |   ~~~~~^~~~~~~
a.cc:11:9: error: assignment of function 'std::ios_base& std::right(ios_base&)'
   11 |   right = 2 * i + 1;
      |   ~~~~~~^~~~~~~~~~~
a.cc:12:8: error: 'l' was not declared in this scope
   12 |   if ( l <= H && A[left] > A[i] ) largest = left;
      |        ^
a.cc:12:19: error: invalid types 'int [2000001][std::ios_base&(std::ios_base&)]' for array subscript
   12 |   if ( l <= H && A[left] > A[i] ) largest = left;
      |                   ^
a.cc:12:45: error: invalid conversion from 'std::ios_base& (*)(std::ios_base&)' to 'int' [-fpermissive]
   12 |   if ( l <= H && A[left] > A[i] ) largest = left;
      |                                             ^~~~
      |                                             |
      |                                             std::ios_base& (*)(std::ios_base&)
a.cc:13:8: error: 'larget' was not declared in this scope; did you mean 'largest'?
   13 |   else larget = i;
      |        ^~~~~~
      |        largest
a.cc:14:8: error: 'r' was not declared in this scope
   14 |   if ( r <= H && A[right > A{i] ) largest = right;
      |        ^
a.cc:14:26: error: comparison between distinct pointer types 'std::ios_base& (*)(std::ios_base&)' and 'int*' lacks a cast
   14 |   if ( r <= H && A[right > A{i] ) largest = right;
      |                    ~~~~~~^~~
a.cc:14:29: error: expected ']' before '{' token
   14 |   if ( r <= H && A[right > A{i] ) largest = right;
      |                             ^
      |                             ]
a.cc:14:29: error: expected ')' before '{' token
   14 |   if ( r <= H && A[right > A{i] ) largest = right;
      |      ~                      ^
      |                             )
a.cc:14:31: error: expected primary-expression before ']' token
   14 |   if ( r <= H && A[right > A{i] ) largest = right;
      |                               ^
Language: C++

#include<iostream>
using namespace std;
#define MAX 2000000

int H;
int A[MAX+1];

void maxHeapify(int i) {
  int largest;
  int left = 2 * i;
  int right = 2 * i + 1;
  if ( l <= H && A[left] > A[i] ) largest = left;
  else larget = i;
  if ( r <= H && A[right > A{i] ) largest = right;
  
  if ( largest != i ) {
    swap(A[i], A[largest]);
    maxHeapify (largest);
  }
}

int main() {
  cin >> H;
  for ( int i = 1; i < H ; i++) cin >> A[i];
  
  for ( int i = H / 2 ; i >= 1; i-- ) maxHeapify(i);
  
  for ( int i = 1; i < H; i++ ) cout << " " << A[i]   ;
  cout << endl;
  return 0;
}


Compiler output:
a.cc: In function 'void maxHeapify(int)':
a.cc:12:8: error: 'l' was not declared in this scope
   12 |   if ( l <= H && A[left] > A[i] ) largest = left;
      |        ^
a.cc:13:8: error: 'larget' was not declared in this scope; did you mean 'largest'?
   13 |   else larget = i;
      |        ^~~~~~
      |        largest
a.cc:14:8: error: 'r' was not declared in this scope
   14 |   if ( r <= H && A[right > A{i] ) largest = right;
      |        ^
a.cc:14:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   14 |   if ( r <= H && A[right > A{i] ) largest = right;
      |                    ~~~~~~^~~
a.cc:14:29: error: expected ']' before '{' token
   14 |   if ( r <= H && A[right > A{i] ) largest = right;
      |                             ^
      |                             ]
a.cc:14:29: error: expected ')' before '{' token
   14 |   if ( r <= H && A[right > A{i] ) largest = right;
      |      ~                      ^
      |                             )
a.cc:14:31: error: expected primary-expression before ']' token
   14 |   if ( r <= H && A[right > A{i] ) largest = right;
      |                               ^
Language: C++

#include<iostream>
using namespace std;
#define MAX 2000000

int H;
int A[MAX+1];

void maxHeapify(int i) {
  int largest;
  int left = 2 * i;
  int right = 2 * i + 1;
  if ( left  <= H && A[left] > A[i] ) largest = left;
  else larget = i;
  if ( right  <= H && A[right] > A{i] ) largest = right;
  
  if ( largest != i ) {
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

int main() {
  cin >> H;
  for ( int i = 1; i < H ; i++) cin >> A[i];
  
  for ( int i = H / 2 ; i >= 1; i-- ) maxHeapify(i);
  
  for ( int i = 1; i < H; i++ ) cout << " " << A[i]   ;
  cout << endl;
  return 0;
}


Compiler output:
a.cc: In function 'void maxHeapify(int)':
a.cc:13:8: error: 'larget' was not declared in this scope; did you mean 'largest'?
   13 |   else larget = i;
      |        ^~~~~~
      |        largest
a.cc:14:32: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   14 |   if ( right  <= H && A[right] > A{i] ) largest = right;
      |                       ~~~~~~~~~^~~
a.cc:14:35: error: expected ')' before '{' token
   14 |   if ( right  <= H && A[right] > A{i] ) largest = right;
      |      ~                            ^
      |                                   )
a.cc:14:37: error: expected primary-expression before ']' token
   14 |   if ( right  <= H && A[right] > A{i] ) largest = right;
      |                                     ^
Language: C++

#include<iostream>
using namespace std;
#define MAX 2000000

int H;
int A[MAX+1];

void maxHeapify(int i) {
  int largest;
  int left = 2 * i;
  int right = 2 * i + 1;
  if ( left  <= H && A[left] > A[i] ) largest = left;
  else larget = i;
  if ( right  <= H && A[right] > A{i] ) largest = right;
  
  if ( largest != i ) {
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

int main() {
  cin >> H;
  for ( int i = 1; i < H ; i++) cin >> A[i];
  
  for ( int i = H / 2 ; i >= 1; i-- ) maxHeapify(i);
  
  for ( int i = 1; i <= H; i++ ) cout << " " << A[i]   ;
  cout << endl;
  return 0;
}


Compiler output:
a.cc: In function 'void maxHeapify(int)':
a.cc:13:8: error: 'larget' was not declared in this scope; did you mean 'largest'?
   13 |   else larget = i;
      |        ^~~~~~
      |        largest
a.cc:14:32: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   14 |   if ( right  <= H && A[right] > A{i] ) largest = right;
      |                       ~~~~~~~~~^~~
a.cc:14:35: error: expected ')' before '{' token
   14 |   if ( right  <= H && A[right] > A{i] ) largest = right;
      |      ~                            ^
      |                                   )
a.cc:14:37: error: expected primary-expression before ']' token
   14 |   if ( right  <= H && A[right] > A{i] ) largest = right;
      |                                     ^
Language: C++

#include<iostream>
using namespace std;
#define MAX 2000000

int H;
int A[MAX+1];

void maxHeapify(int i) {
  int largest;
  int left = 2 * i;
  int right = 2 * i + 1;
  if ( left  <= H && A[left] > A[i] ) largest = left;
  else larget = i;
  if ( right  <= H && A[right] > A{i] ) largest = right;
  
  if ( largest != i ) {
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

int main() {
  cin >> H;
  for ( int i = 1; i <= H ; i++) cin >> A[i];
  
  for ( int i = H / 2 ; i >= 1; i-- ) maxHeapify(i);
  
  for ( int i = 1; i <= H; i++ ) cout << " " << A[i]   ;
  cout << endl;
  return 0;
}


Compiler output:
a.cc: In function 'void maxHeapify(int)':
a.cc:13:8: error: 'larget' was not declared in this scope; did you mean 'largest'?
   13 |   else larget = i;
      |        ^~~~~~
      |        largest
a.cc:14:32: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   14 |   if ( right  <= H && A[right] > A{i] ) largest = right;
      |                       ~~~~~~~~~^~~
a.cc:14:35: error: expected ')' before '{' token
   14 |   if ( right  <= H && A[right] > A{i] ) largest = right;
      |      ~                            ^
      |                                   )
a.cc:14:37: error: expected primary-expression before ']' token
   14 |   if ( right  <= H && A[right] > A{i] ) largest = right;
      |                                     ^
Language: C++

#include<iostream>
using namespace std;
#define MAX 2000000

int H;
int A[MAX+1];

void maxHeapify(int i) {
  int largest;
  int left = 2 * i;
  int right = 2 * i + 1;
  if ( left  <= H && A[left] > A[i] ) largest = left;
  else larget = i;
  if ( right  <= H && A[right] > A{i] ) largest = right;
  
  if ( largest != i ) {
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

int main() {
  cin >> H;
  for ( int i = 1; i <= H ; i++) cin >> A[i];
  
  for ( int i = H / 2 ; i >= 1; i-- ) maxHeapify(i);
  
  for ( int i = 1; i <= H; i++ ) {
  cout << " " << A[i] ;
  }
  
  cout << endl;
  return 0;
}


Compiler output:
a.cc: In function 'void maxHeapify(int)':
a.cc:13:8: error: 'larget' was not declared in this scope; did you mean 'largest'?
   13 |   else larget = i;
      |        ^~~~~~
      |        largest
a.cc:14:32: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   14 |   if ( right  <= H && A[right] > A{i] ) largest = right;
      |                       ~~~~~~~~~^~~
a.cc:14:35: error: expected ')' before '{' token
   14 |   if ( right  <= H && A[right] > A{i] ) largest = right;
      |      ~                            ^
      |                                   )
a.cc:14:37: error: expected primary-expression before ']' token
   14 |   if ( right  <= H && A[right] > A{i] ) largest = right;
      |                                     ^
Language: C++

#include<iostream>
using namespace std;
#define MAX 2000000

int H;
int A[MAX+1];

void maxHeapify(int i) {
  int largest;
  int left = 2 * i;
  int right = 2 * i + 1;
  if ( left  <= H && A[left] > A[i] ) largest = left;
  else larget = i;
  if ( right  <= H && A[right] > A[i] ) largest = right;
  
  if ( largest != i ) {
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

int main() {
  cin >> H;
  for ( int i = 1; i <= H ; i++) cin >> A[i];
  
  for ( int i = H / 2 ; i >= 1; i-- ) maxHeapify(i);
  
  for ( int i = 1; i <= H; i++ ) {
  cout << " " << A[i] ;
  }
  
  cout << endl;
  return 0;
}


Compiler output:
a.cc: In function 'void maxHeapify(int)':
a.cc:13:8: error: 'larget' was not declared in this scope; did you mean 'largest'?
   13 |   else larget = i;
      |        ^~~~~~
      |        largest
Language: C++

#include<iostream>
using namespace std;
#define MAX 2000000

int H;
int A[MAX+1];

void maxHeapify(int i) {
  int largest;
  int left = 2 * i;
  int right = 2 * i + 1;
  if ( left  <= H && A[left] > A[i] ) largest = left;
  else larget = i;
  if ( right  <= H && A[right] > A[i] ) largest = right;
  
  if ( largest != i ) {
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

int main() {
  cin >> H;
  for ( int i = 1; i <= H ; i++) cin >> A[i];
  
  for ( int i = H / 2 ; i >= 1; i-- ) maxHeapify(i);
  
  for ( int i = 1; i <= H; i++ ) {
    cout << " " << A[i] ;
  }
  
  cout << endl;
  return 0;
}


Compiler output:
a.cc: In function 'void maxHeapify(int)':
a.cc:13:8: error: 'larget' was not declared in this scope; did you mean 'largest'?
   13 |   else larget = i;
      |        ^~~~~~
      |        largest
Language: C++

#include<iostream>
using namespace std;

int A[500001];
int H;

void maxHeapfily(int i){
    int l = i*2;
    int r = i*2+1;
    int 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[largest], A[i]);
        maxHeapify(largest);
    }
}

int main(){
    cin >> H;
    for(int i = 1; i <= H; i++) cin >> A[i];
    
    for(int i = H/2; i >= 1; i--){
        maxHeapify(i);
    }
    
    for(int i = 1; i <= H; i++){
        cout << " " << A[i];
    }
    cout << endl;
    
    return 0;
}


Compiler output:
a.cc: In function 'void maxHeapfily(int)':
a.cc:18:9: error: 'maxHeapify' was not declared in this scope; did you mean 'maxHeapfily'?
   18 |         maxHeapify(largest);
      |         ^~~~~~~~~~
      |         maxHeapfily
a.cc: In function 'int main()':
a.cc:27:9: error: 'maxHeapify' was not declared in this scope; did you mean 'maxHeapfily'?
   27 |         maxHeapify(i);
      |         ^~~~~~~~~~
      |         maxHeapfily
Language: C++

#include<stdio.h>
using namespace std;
#include<iostream>

#define MAX = 500000

int H, A[MAX+1];

int parent(int i) { return i/2; }
int left(int i) { return i*2; }
int right(int i) { return i*2+1; } 

void maxHeapify(A, i) {
  int l, r, t;
  l = left(i);
  r = right(i);
  if ( l <= H && A[l] > A[i] ) largest = l;
  else largest = i;

  if ( r <= H && A[r] > A[largest] ) largest = r;
  
  if ( largest != i ) {
    t = A[i]; A[i] = A[largest]; A[largest] = t;
    maxHeapify(A, largest);
}

void buildMaxHeap(A) {
  for ( int i = H/2; i >= 1; i++ ) maxHeapify(i);
}

int main() {
  cin >> H;
  for ( i = 1; i <= H; i++ ) cin >> A[i];

  buildMaxHeap(A);

  for( i = 1; i <= H; i++ ) printf("%d ", A[i]);

  return 0 
}


Compiler output:
a.cc:5:13: error: expected primary-expression before '=' token
    5 | #define MAX = 500000
      |             ^
a.cc:7:10: note: in expansion of macro 'MAX'
    7 | int H, A[MAX+1];
      |          ^~~
a.cc:13:6: error: variable or field 'maxHeapify' declared void
   13 | void maxHeapify(A, i) {
      |      ^~~~~~~~~~
a.cc:13:17: error: 'A' was not declared in this scope
   13 | void maxHeapify(A, i) {
      |                 ^
a.cc:13:20: error: 'i' was not declared in this scope
   13 | void maxHeapify(A, i) {
      |                    ^
Language: C++

#include<stdio.h>
using namespace std;
#include<iostream>

#define MAX 500000

int H, A[MAX+1];

int parent(int i) { return i/2; }
int left(int i) { return i*2; }
int right(int i) { return i*2+1; } 

void maxHeapify(A, i) {
  int l, r, t;
  l = left(i);
  r = right(i);
  if ( l <= H && A[l] > A[i] ) largest = l;
  else largest = i;

  if ( r <= H && A[r] > A[largest] ) largest = r;
  
  if ( largest != i ) {
    t = A[i]; A[i] = A[largest]; A[largest] = t;
    maxHeapify(A, largest);
}

void buildMaxHeap(A) {
  for ( int i = H/2; i >= 1; i++ ) maxHeapify(i);
}

int main() {
  cin >> H;
  for ( i = 1; i <= H; i++ ) cin >> A[i];

  buildMaxHeap(A);

  for( i = 1; i <= H; i++ ) printf("%d ", A[i]);

  return 0 
}


Compiler output:
a.cc:13:6: error: variable or field 'maxHeapify' declared void
   13 | void maxHeapify(A, i) {
      |      ^~~~~~~~~~
a.cc:13:20: error: 'i' was not declared in this scope
   13 | void maxHeapify(A, i) {
      |                    ^
Language: C++

#include<stdio.h>
using namespace std;
#include<iostream>

#define MAX 500000

int H, A[MAX+1];

int parent(int i) { return i/2; }
int left(int i) { return i*2; }
int right(int i) { return i*2+1; } 

void maxHeapify(A, i) {
  int l, r, t;
  l = left(i);
  r = right(i);
  if ( l <= H && A[l] > A[i] ) largest = l;
  else largest = i;

  if ( r <= H && A[r] > A[largest] ) largest = r;
  
  if ( largest != i ) {
    t = A[i]; A[i] = A[largest]; A[largest] = t;
    maxHeapify(A, largest);
  }
}

void buildMaxHeap(A) {
  for ( int i = H/2; i >= 1; i++ ) maxHeapify(i);
}

int main() {
  cin >> H;
  for ( i = 1; i <= H; i++ ) cin >> A[i];

  buildMaxHeap(A);

  for( i = 1; i <= H; i++ ) printf("%d ", A[i]);

  return 0 
}


Compiler output:
a.cc:13:6: error: variable or field 'maxHeapify' declared void
   13 | void maxHeapify(A, i) {
      |      ^~~~~~~~~~
a.cc:13:20: error: 'i' was not declared in this scope
   13 | void maxHeapify(A, i) {
      |                    ^
a.cc:28:6: error: variable or field 'buildMaxHeap' declared void
   28 | void buildMaxHeap(A) {
      |      ^~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:34:9: error: 'i' was not declared in this scope
   34 |   for ( i = 1; i <= H; i++ ) cin >> A[i];
      |         ^
a.cc:36:3: error: 'buildMaxHeap' was not declared in this scope
   36 |   buildMaxHeap(A);
      |   ^~~~~~~~~~~~
a.cc:38:8: error: 'i' was not declared in this scope
   38 |   for( i = 1; i <= H; i++ ) printf("%d ", A[i]);
      |        ^
a.cc:40:11: error: expected ';' before '}' token
   40 |   return 0
      |           ^
      |           ;
   41 | }
      | ~
Language: C++

#include<stdio.h>
using namespace std;
#include<iostream>

#define MAX 500000

int H, A[MAX+1];

int parent(int i) { return i/2; }
int left(int i) { return i*2; }
int right(int i) { return i*2+1; } 

void maxHeapify(int i) {
  int l, r, t;
  l = left(i);
  r = right(i);
  if ( l <= H && A[l] > A[i] ) largest = l;
  else largest = i;

  if ( r <= H && A[r] > A[largest] ) largest = r;
  
  if ( largest != i ) {
    t = A[i]; A[i] = A[largest]; A[largest] = t;
    maxHeapify(A, largest);
  }
}

void buildMaxHeap() {
  for ( int i = H/2; i >= 1; i++ ) maxHeapify(i);
}

int main() {
  cin >> H;
  for ( i = 1; i <= H; i++ ) cin >> A[i];

  buildMaxHeap();

  for( i = 1; i <= H; i++ ) printf("%d ", A[i]);

  return 0 
}


Compiler output:
a.cc: In function 'void maxHeapify(int)':
a.cc:17:32: error: 'largest' was not declared in this scope
   17 |   if ( l <= H && A[l] > A[i] ) largest = l;
      |                                ^~~~~~~
a.cc:18:8: error: 'largest' was not declared in this scope
   18 |   else largest = i;
      |        ^~~~~~~
a.cc:20:27: error: 'largest' was not declared in this scope
   20 |   if ( r <= H && A[r] > A[largest] ) largest = r;
      |                           ^~~~~~~
a.cc:22:8: error: 'largest' was not declared in this scope
   22 |   if ( largest != i ) {
      |        ^~~~~~~
a.cc: In function 'int main()':
a.cc:34:9: error: 'i' was not declared in this scope
   34 |   for ( i = 1; i <= H; i++ ) cin >> A[i];
      |         ^
a.cc:38:8: error: 'i' was not declared in this scope
   38 |   for( i = 1; i <= H; i++ ) printf("%d ", A[i]);
      |        ^
a.cc:40:11: error: expected ';' before '}' token
   40 |   return 0
      |           ^
      |           ;
   41 | }
      | ~
Language: C++

#include<stdio.h>
using namespace std;
#include<iostream>

#define MAX 500000

int H, A[MAX+1];

int parent(int i) { return i/2; }
int left(int i) { return i*2; }
int right(int i) { return i*2+1; } 

void maxHeapify(int i) {
  int l, r, t;
  l = left(i);
  r = right(i);
  if ( l <= H && A[l] > A[i] ) largest = l;
  else largest = i;

  if ( r <= H && A[r] > A[largest] ) largest = r;
  
  if ( largest != i ) {
    t = A[i]; A[i] = A[largest]; A[largest] = t;
    maxHeapify(largest);
  }
}

int main() {
  cin >> H;
  for ( i = 1; i <= H; i++ ) cin >> A[i];

  for ( int i = H/2; i >= 1; i++ ) maxHeapify(i);

  for( i = 1; i <= H; i++ ) printf("%d ", A[i]);

  return 0 
}


Compiler output:
a.cc: In function 'void maxHeapify(int)':
a.cc:17:32: error: 'largest' was not declared in this scope
   17 |   if ( l <= H && A[l] > A[i] ) largest = l;
      |                                ^~~~~~~
a.cc:18:8: error: 'largest' was not declared in this scope
   18 |   else largest = i;
      |        ^~~~~~~
a.cc:20:27: error: 'largest' was not declared in this scope
   20 |   if ( r <= H && A[r] > A[largest] ) largest = r;
      |                           ^~~~~~~
a.cc:22:8: error: 'largest' was not declared in this scope
   22 |   if ( largest != i ) {
      |        ^~~~~~~
a.cc: In function 'int main()':
a.cc:30:9: error: 'i' was not declared in this scope
   30 |   for ( i = 1; i <= H; i++ ) cin >> A[i];
      |         ^
a.cc:34:8: error: 'i' was not declared in this scope
   34 |   for( i = 1; i <= H; i++ ) printf("%d ", A[i]);
      |        ^
a.cc:36:11: error: expected ';' before '}' token
   36 |   return 0
      |           ^
      |           ;
   37 | }
      | ~
Language: C++

#include<stdio.h>
using namespace std;
#include<iostream>

#define MAX 500000

int H, A[MAX+1];

int parent(int i) { return i/2; }
int left(int i) { return i*2; }
int right(int i) { return i*2+1; } 

void maxHeapify(int i) {
  int l, r, t, largest;
  l = left(i);
  r = right(i);
  if ( l <= H && A[l] > A[i] ) largest = l;
  else largest = i;

  if ( r <= H && A[r] > A[largest] ) largest = r;
  
  if ( largest != i ) {
    t = A[i]; A[i] = A[largest]; A[largest] = t;
    maxHeapify(largest);
  }
}

int main() {
  cin >> H;
  for ( i = 1; i <= H; i++ ) cin >> A[i];

  for ( int i = H/2; i >= 1; i++ ) maxHeapify(i);

  for( i = 1; i <= H; i++ ) printf("%d ", A[i]);

  return 0 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:9: error: 'i' was not declared in this scope
   30 |   for ( i = 1; i <= H; i++ ) cin >> A[i];
      |         ^
a.cc:34:8: error: 'i' was not declared in this scope
   34 |   for( i = 1; i <= H; i++ ) printf("%d ", A[i]);
      |        ^
a.cc:36:11: error: expected ';' before '}' token
   36 |   return 0
      |           ^
      |           ;
   37 | }
      | ~
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;

long H ;
long A[500000];

long l(long i) {
    return i * 2;
}

long r(long i) {
    return i * 2 + 1;
}

long p(long i) {
    return i/2;
}

void maxify(long i) {
    long mi = i;
    if (l(i) <= H && A[l(i)] > A[i]) {
        mi = l(i);
    }
    if (r(i) <= H && A[r(i)] > A[mi]) {
        mi = r(i);
    }
    if (mi != i) {
        swap(A[i], A[mi]);
        maxify(mi);
    }
}

long main() {
    cin >> H;
    for (long i = 1; i <= H; ++i) {
        cin >> A[i];
    }

    for (long j = H; j >= 1 ; --j) {
        maxify(j);
    }

    for (long k = 0; k < H; ++k) {
        cout << " " << A[k + 1];

    }
    cout << endl;
    return 0;
}



Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;

long H ;
long A[500001];

long l(long i) {
    return i * 2;
}

long r(long i) {
    return i * 2 + 1;
}

long p(long i) {
    return i/2;
}

void maxify(long i) {
    long mi = i;
    if (l(i) <= H && A[l(i)] > A[i]) {
        mi = l(i);
    }
    if (r(i) <= H && A[r(i)] > A[mi]) {
        mi = r(i);
    }
    if (mi != i) {
        swap(A[i], A[mi]);
        maxify(mi);
    }
}

long main() {
    cin >> H;
    for (long i = 1; i <= H; ++i) {
        cin >> A[i];
    }

    for (long j = H; j >= 1 ; --j) {
        maxify(j);
    }

    for (long k = 0; k < H; ++k) {
        cout << " " << A[k + 1];

    }
    cout << endl;
    return 0;
}



Compiler output:
cc1plus: error: '::main' must return 'int'
Language: Java

import java.util.Scanner;

class Main {
  public static final int MAX = 2000001;

  public static void main(String... args) {
    Scanner sc = new Scanner(System.in);
    int[] heap = new int[MAX];
    int current = 0;
    int tmp;
    boolean flg = true;

    while (flg) {
      switch(sc.next().length()) {
        case 6: // insert
          heap[++current] = sc.nextInt();
          break;

        case 7: // extract
          build(heap, current);
          System.out.println(heap[1]);
          tmp = heap[1];
          heap[1] = heap[current];
          heap[current--] = tmp;
          break;

        default: // end
          flg = false;
          break;
      }
    }
  }

  public static void maxHeapify(int[] heap, int i, int size) {
    int l = i * 2;
    int r = i * 2 + 1;
    int largest;

    if (l < size && heap[l] > heap[i]) {
      largest = l;

    } else {
      largest = i;
    }

    if (r < size && heap[r] > heap[largest]) {
      largest = r;
    }

    if (largest != i) {
      int tmp = heap[i];
      heap[i] = heap[largest];
      heap[largest] = tmp;
      maxHeapify(heap, largest, size);
    }
  }
}




Compiler output:
Main.java:20: error: cannot find symbol
          build(heap, current);
          ^
  symbol:   method build(int[],int)
  location: class Main
1 error
Language: Java

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:
Main.java:106: error: class, interface, enum, or record expected
public Main{
       ^
Main.java:107: error: unnamed classes are a preview feature and are disabled by default.
    	public static void main(String[] arg) 
    	              ^
  (use --enable-preview to enable unnamed classes)
Main.java:126: error: class, interface, enum, or record expected
}
^
3 errors
Language: Java

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:
Main.java:106: error: class, interface, enum, or record expected
public Main{
       ^
Main.java:107: error: unnamed classes are a preview feature and are disabled by default.
    	public static void main(String[] arg) 
    	              ^
  (use --enable-preview to enable unnamed classes)
Main.java:126: error: class, interface, enum, or record expected
}
^
3 errors