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

#include <stdio.h>
#define N 1000000
#define INF 1000000

int parent_key(int);
int left_key(int);
int right_key(int);
void BuildMaxHeap();
void maxHeapify(int);
void insert(int);
void HeapIncreaseKey(int);
int HeapExtractMax();

int n,A[N+1];
int main()
{
  int key;
  char length[10];
  while(1)
    {
      scanf("%s",length);
      if(length[0]=='e'&&length[1]=='n') break;
      if(length[0]=='i')
	{
	  scanf("%d",&key);
	  insert(key);
	}
      else printf("%d\n",HeapExtractMax());
    }
  return 0;
}

void maxHeapify(int x)
{
  int l=0,r=0,largest=0;
  int es_largest=0; //??\???????????????????????¨???
  l=left_key(x);
  r=right_key(x);
  
  if(l<=n&&A[l]>A[x]) largest=l;
  else largest=x;
  
  if(r<=n&&A[r]>A[largest]) largest=r;
  
  if(largest!=x)
    {
      es_largest=A[largest];
      A[largest]=A[x];
      A[x]=es_largest;
      maxHeapify(largest);
    }
}

int parent_key(int x)
{
  return x/2;
}

int left_key(int x)
{
  return 2*x;
}
int right_key(int x)
{
  return 2*x+1;
}

void insert(int x)
{
  n++;
  A[n]=-INF;
  HeapIncreaseKey(x);
}

void HeapIncreaseKey(int x)
{
  int escape=0;
  if(x<A[n]) return;
  A[n]=x;
  while(n>1&&A[parent_key(n)]<A[n])
    {
      escape=A[parent_key(n)];
      A[parent_key(n)]=A[n];
      A[n]=escape;
      n=parent_key(n);
    }
}

int HeapExtractMax()
{
  int max=0;
  if(n<1) return;
  max=A[1];
  A[1]=A[n];
  n--;
  maxHeapify(1);
  return max;
}

Compiler output:
a.cc: In function 'int HeapExtractMax()':
a.cc:92:11: error: return-statement with no value, in function returning 'int' [-fpermissive]
   92 |   if(n<1) return;
      |           ^~~~~~
Language: C++

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

static const int cMaxNumber = 500001;

void maxHeapify(int array[], int interRoNode, int array_size) {
	int left = 2 * interRoNode;
	int right = 2 * interRoNode + 1;

	//?????§??????????????????????????¶
	int largestNodeNumber;
	if (left <= array_size && array[left] > array[interRoNode])
		largestNodeNumber = left;
	else
		largestNodeNumber = interRoNode;
	if (right <= array_size && array[right] > array[largestNodeNumber])
		largestNodeNumber = right;

	//?????????????????§??????????????\????????????
	if (largestNodeNumber != interRoNode) {
		swap(array[largestNodeNumber], array[interRoNode]);
		maxHeapify(array, largestNodeNumber, array_size);
	}
}

void buildMaxHeap(int array[], int array_size) {
	for (int i = array_size / 2; i >= 1; i--)
		maxHeapify(array, i, array_size);
}

class PriorityQueue {
public:
	PriorityQueue() {
		cur_size_ = 0;
	}

	//add
	void insert(int key) {
		cur_size_++;
		array_[cur_size_] = 1 << 30;
		increaseKey(cur_size_, key);
	}

	//remove
	int heapExtractMax() {
		if (cur_size_ < 1) return 0;
		int key = array_[1];

		array_[1] = array_[cur_size_];
		cur_size_--;
		maxHeapify(array_, 1, cur_size_);
		return key;
	}

private:
	void increaseKey(int i, int key) {
		if (key < array_[i]) return;
		array_[i] = key;

		while (i > 1 && array_[i / 2] < array_[i]) {
			swap(array_[i], array_[i / 2]);
			i = i / 2;
		}
	}

	int array_[2000001];
//	int max_size;
	int cur_size_;
};

int main() {
	PriorityQueue pq;

	while (1) {
		string s;
		cin >> s;

		if (s[0] == 'i') {
			int key;
			cin >> key;
			pq.insert(key);
		}
		else if (s[0] == 'e'){
			if (s[1] == 'n')
				break;
			int key;
			key = pq.heapExtractMax();
			cout << key << endl;			
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:93:2: error: expected '}' at end of input
   93 | }
      |  ^
a.cc:72:12: note: to match this '{'
   72 | int main() {
      |            ^
Language: C++

#include<stdio>
#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=r;
  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:1:9: fatal error: stdio: No such file or directory
    1 | #include<stdio>
      |         ^~~~~~~
compilation terminated.
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=r;
  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:6:15: error: expected parameter name, found "1"
    6 | #define INFTY(1<<30)
      |               ^
a.cc: In function 'int extract()':
a.cc:22:18: error: 'INFTY' was not declared in this scope
   22 |   if(H<1)return -INFTY;
      |                  ^~~~~
a.cc: In function 'void insert(int)':
a.cc:38:10: error: 'INFTY' was not declared in this scope
   38 |   A[H]= -INFTY;
      |          ^~~~~
Language: C++

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)
int H,A[MAX+1];
int ext(){
  int maxv;
  if(H<1){
    return -INFTY;
  }
  maxv=A[1];
  A[1]=A[H--];
  maxHeapify(1);
  return maxv;
}
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);
  }
}
void ins(int key){
  H++;
  A[H]=-INFTY;
  incKey(H,key);
}
void incKey(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;
  }
}


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);
      ins(key);
    }
    else{printf("%d\n",ext());
  }
  }
  return 0;
}

Compiler output:
a.cc: In function 'int ext()':
a.cc:15:3: error: 'maxHeapify' was not declared in this scope
   15 |   maxHeapify(1);
      |   ^~~~~~~~~~
a.cc: In function 'void ins(int)':
a.cc:33:3: error: 'incKey' was not declared in this scope
   33 |   incKey(H,key);
      |   ^~~~~~
Language: C++

#include <stdio.h>
#include <string.h>
#define N 200000000
#define INF 2000000000
  
int size;
int h[N];
  
void swap(int* a, int* b){
  int tmp = *a;
  *a = *b;
  *b = tmp;
}
  
void maxHeapify(i){
  int l = 2*i;
  int r = 2*i+1;
  int valM;
  if(l <= size && h[l] > h[i]) valM = l;
  else valM = i;
  if(r <= size && h[r] > h[valM]) valM = r;
  if(valM != i){
    swap(&h[i], &h[valM]);
    maxHeapify(valM);
  }
}
  
void hIncreaseKey(int i, int key){
  if(key < h[i]) return;
  h[i] = key;
  while(i>1 && h[i/2]<h[i]){
    swap(&h[i], &h[i/2]);
    i = i/2;
  }
}
  
void maxHeapInsert(int key){
  size++;
  h[size] = -INF;
  hIncreaseKey(size, key);
}
  
int heapExtractMax(){
  int valM;
  if(size < 1) return 0;
  valM = h[1];
  h[1] = h[size--];
  maxHeapify(1);
  return valM;
}
  
int main(){
  char input[20];
  size = 0;
  while(scanf("%s", input)){
    if(!strcmp(input, "end")) break;
    if(!strcmp(input, "extract")) printf("%d\n", heapExtractMax());
    else{
      char val[20];
      scanf("%s", val);
      maxHeapInsert(atoi(val));
    }
  }
  return 0;
}

Compiler output:
a.cc:15:6: error: variable or field 'maxHeapify' declared void
   15 | void maxHeapify(i){
      |      ^~~~~~~~~~
a.cc:15:17: error: 'i' was not declared in this scope
   15 | void maxHeapify(i){
      |                 ^
a.cc: In function 'int heapExtractMax()':
a.cc:48:3: error: 'maxHeapify' was not declared in this scope
   48 |   maxHeapify(1);
      |   ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:61:21: error: 'atoi' was not declared in this scope
   61 |       maxHeapInsert(atoi(val));
      |                     ^~~~
Language: C++

#include <stdio.h>
#include <string.h>
#define N 200000001
#define INF 2000000001
  
int size;
int h[N];
  
void swap(int* a, int* b){
  int tmp = *a;
  *a = *b;
  *b = tmp;
}
  
void maxHeapify(i){
  int l = 2*i;
  int r = 2*i+1;
  int valM;
  if(l <= size && h[l] > h[i]) valM = l;
  else valM = i;
  if(r <= size && h[r] > h[valM]) valM = r;
  if(valM != i){
    swap(&h[i], &h[valM]);
    maxHeapify(valM);
  }
}
  
void hIncreaseKey(int i, int key){
  if(key < h[i]) return;
  h[i] = key;
  while(i>1 && h[i/2]<h[i]){
    swap(&h[i], &h[i/2]);
    i = i/2;
  }
}
  
void maxHeapInsert(int key){
  size++;
  h[size] = -INF;
  hIncreaseKey(size, key);
}
  
int heapExtractMax(){
  int valM;
  if(size < 1) return 0;
  valM = h[1];
  h[1] = h[size--];
  maxHeapify(1);
  return valM;
}
  
int main(){
  char input[20];
  size = 0;
  while(scanf("%s", input)){
    if(!strcmp(input, "end")) break;
    if(!strcmp(input, "extract")) printf("%d\n", heapExtractMax());
    else{
      char val[20];
      scanf("%s", val);
      maxHeapInsert(atoi(val));
    }
  }
  return 0;
}

Compiler output:
a.cc:15:6: error: variable or field 'maxHeapify' declared void
   15 | void maxHeapify(i){
      |      ^~~~~~~~~~
a.cc:15:17: error: 'i' was not declared in this scope
   15 | void maxHeapify(i){
      |                 ^
a.cc: In function 'int heapExtractMax()':
a.cc:48:3: error: 'maxHeapify' was not declared in this scope
   48 |   maxHeapify(1);
      |   ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:61:21: error: 'atoi' was not declared in this scope
   61 |       maxHeapInsert(atoi(val));
      |                     ^~~~
Language: C++

#include <stdio.h>
#include <string.h>
#define N 200000000
#define INF 2000000001

int size;
int h[N];

void swap(int* a, int* b){
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

void maxHeapify(i){

  int l = 2*i;
  int r = 2*i+1;
  int valM;

  if(l <= size && h[l] > h[i]) valM = l;
  else valM = i;
  if(r <= size && h[r] > h[valM]) valM = r;
  if(valM != i){
    swap(&h[i], &h[valM]);
    maxHeapify(valM);
  }
}

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

void maxHeapInsert(int key){
  size++;
  h[size] = -INF;
  hIncreaseKey(size, key);
}

int heapExtractMax(){
  int valM;
  if(size < 1) return 0;
  valM = h[1];
  h[1] = h[size--];
  maxHeapify(1);
  return valM;
}

int main(){
  char input[20];
  size = 0;
  while(scanf("%s", input)){
    if(!strcmp(input, "end")) break;
    if(!strcmp(input, "extract")) printf("%d\n", heapExtractMax());
    else{
      char val[20];
      scanf("%s", val);
      maxHeapInsert(atoi(val));
    }
  }
  return 0;
}

Compiler output:
a.cc:15:6: error: variable or field 'maxHeapify' declared void
   15 | void maxHeapify(i){
      |      ^~~~~~~~~~
a.cc:15:17: error: 'i' was not declared in this scope
   15 | void maxHeapify(i){
      |                 ^
a.cc: In function 'int heapExtractMax()':
a.cc:50:3: error: 'maxHeapify' was not declared in this scope
   50 |   maxHeapify(1);
      |   ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:63:21: error: 'atoi' was not declared in this scope
   63 |       maxHeapInsert(atoi(val));
      |                     ^~~~
Language: C++

#include <stdio.h>
#include <string.h>

#define N 200000000
#define INF 2000000001

int size;
int h[N];

void swap(int* a, int* b){
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

void maxHeapify(i){

  int l = 2*i;
  int r = 2*i+1;
  int valM;

  if(l <= size && h[l] > h[i]) valM = l;
  else valM = i;
  if(r <= size && h[r] > h[valM]) valM = r;
  if(valM != i){
    swap(&h[i], &h[valM]);
    maxHeapify(valM);
  }
}

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

void maxHeapInsert(int key){
  size++;
  h[size] = -INF;
  hIncreaseKey(size, key);
}

int heapExtractMax(){
  int valM;
  if(size < 1) return 0;
  valM = h[1];
  h[1] = h[size--];
  maxHeapify(1);
  return valM;
}

int main(){
  char input[20];
  size = 0;
  while(scanf("%s", input)){
    if(!strcmp(input, "end")) break;
    if(!strcmp(input, "extract")) printf("%d\n", heapExtractMax());
    else{
      char val[20];
      scanf("%s", val);
      maxHeapInsert(atoi(val));
    }
  }
  return 0;
}

Compiler output:
a.cc:16:6: error: variable or field 'maxHeapify' declared void
   16 | void maxHeapify(i){
      |      ^~~~~~~~~~
a.cc:16:17: error: 'i' was not declared in this scope
   16 | void maxHeapify(i){
      |                 ^
a.cc: In function 'int heapExtractMax()':
a.cc:51:3: error: 'maxHeapify' was not declared in this scope
   51 |   maxHeapify(1);
      |   ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:64:21: error: 'atoi' was not declared in this scope
   64 |       maxHeapInsert(atoi(val));
      |                     ^~~~
Language: C++

#include <iostream>
#include<stdio.h>
#define MAX 500001
#define INFTY (1<<30)

using namespace std;
int n = 0, arr[MAX];

void swapNode(int index1, int index2) {
    int temp = arr[index1];
    arr[index1] = arr[index2];
    arr[index2] = temp;
}

void maxHeapify(int i) {
    //if(i > n) return;
    int left = 2*i;
    int right = 2*i+1;
    int largest = i;
    if(left <= n && right <= n) {
       int larger = arr[left] > arr[right] ? left : right;
       largest = arr[largest] > arr[larger] ? largest : larger;
    }else if(left <= n) {
        largest = arr[largest] > arr[left] ? largest : left;
    }else if(right <= n) {
        largest = arr[largest] > arr[right] ? largest : right;
    }
    if(largest != i) {
        swapNode(i, largest);
        maxHeapify(largest);
    }
}

void insertKey(int i, int key) {
    if(key < arr[i]) return;
    arr[i] = key;
    while(i > 1 && arr[i/2] < arr[i]) {
        swapNode(i, i/2);
        i = i/2;
    }
}

int insert(int key) {
    n++;
    A[n] = -INFTY;
    insertKey(n, key);
}

int main()
{
    /*
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &arr[i]);
    }
    for(int i = n/2; i >= 1; i--) {
        maxHeapify(i);
    }
    for(int i = 1; i <= n; i++) {
        printf(" %d",arr[i]);
    }
    printf("\n");
    */

    char com[10];
    int key;
    while(1) {
        scanf("%s", com);
        if(com[0] == 'e' && com[1] == 'n') break;
        else if(com[0] == 'i') {
            //n++;
            //scanf("%d", &arr[n]);
            scanf("%d", &key);
            insert(key);

        }else {
            /*
            for(int i = n/2; i >= 1; i--) {
                maxHeapify(i);
            }
            */
            printf("%d\n", arr[1]);
            arr[1] = arr[n];
            n--;
            maxHeapify(1);
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'int insert(int)':
a.cc:45:5: error: 'A' was not declared in this scope
   45 |     A[n] = -INFTY;
      |     ^
a.cc:47:1: warning: no return statement in function returning non-void [-Wreturn-type]
   47 | }
      | ^
Language: C++

#include <stdio.h>
#include <queue>
using namespace std;
int main(){
int temp;
priority_queue<int> q;
char a[1000];
while(1){
scanf("%s",a);
if(a[2]=='d')return 0;
scanf("%d",&temp);
if(a[2]=='s'){
q.push(temp);
}
if(a[2]=='t'){
printf("%d\n",q.top);
q.pop();
}
}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:17: error: invalid use of non-static member function 'std::priority_queue<_Tp, _Sequence, _Compare>::const_reference std::priority_queue<_Tp, _Sequence, _Compare>::top() const [with _Tp = int; _Sequence = std::vector<int, std::allocator<int> >; _Compare = std::less<int>; const_reference = const int&]'
   16 | printf("%d\n",q.top);
      |               ~~^~~
In file included from /usr/include/c++/14/queue:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_queue.h:721:7: note: declared here
  721 |       top() const
      |       ^~~
Language: C++

#include <iostream>
#include <stdio.h>
#define MAX 2000000010

using namespace std;

int h, A[MAX];


void max_heepify(int ind){
    int left = ind*2;
    int right = ind*2+1;
    int largest;
    if (left <= h && A[left] > A[ind] ){
        largest = left;
    }
    else{
        largest = ind;
    }
    if(right <= h && A[right] > A[largest]){
        largest = right;
    }
    
    if(largest != ind){
        int temp = A[ind];
        A[ind] = A[largest];
        A[largest] = temp;
        
        max_heepify(largest);
    }
}

void heap_increasekey(int i, int key){
    if(key < A[i]) cout << "Error: New key is smaller than current key"<<endl;
    A[i] = key;
    while(i > 1 && A[i/2] < A[i]){
        int temp = A[i];
        A[i] = A[i/2];
        A[i/2] = temp;
        
        i = i/2;
    }
}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include <stdio.h>
#include <algorithm>
#include <iostream>
 
using namespace std;
 
class Heap{
public:
    Heap(){
        array = new int[2000000];
        n = 0;
    }
    void insert(int data){
        array[n] = data;
        n++;
    }
void max_heapify(int* array, int start, int end)
{
	int dad = start;
	int son = dad * 2 + 1;

	while (son <= end)
	{
		if (array[son] < array[son+1] && son+1 <= end)
			son++;
		if (array[dad] > array[son])
			return;
		else
		{
			swap(array[son], array[dad]);
			dad = son;
			son = dad * 2 + 1;
		}
		
	}
}

void heap_sort(int* array, int len)
{
	int i;
	for(i=len/2-1;i>=0;--i)
	{
		max_heapify(array, i, len-1);
	}
        swap(array[0],array[len-1]);
return array[len-1];
}
    int extract(){
    int ret = heap_sort(array,n);
    n--;
    return ret
    }
 
private:
    int* array;
    int n;
};
 
int main(){
 
    int insert_data;
    char buf[22];
    Heap heap;
 
    while(true){
        fgets(buf,22,stdin);
        if(buf[2] == 'd') break;
        if(buf[0] == 'i'){
            insert_data = 0;
            for(int i = 0; buf[i] != '\0';i++){
                if(buf[i] >= '0' && buf[i] <= '9'){
                    insert_data = 10*insert_data + (buf[i] - '0');
                }
            }
            heap.insert(insert_data);
        }else{
            printf("%d\n",heap.extract());
        }
    }
}


Compiler output:
a.cc: In member function 'void Heap::heap_sort(int*, int)':
a.cc:46:19: error: return-statement with a value, in function returning 'void' [-fpermissive]
   46 | return array[len-1];
      |        ~~~~~~~~~~~^
a.cc: In member function 'int Heap::extract()':
a.cc:49:24: error: void value not ignored as it ought to be
   49 |     int ret = heap_sort(array,n);
      |               ~~~~~~~~~^~~~~~~~~
a.cc:52:5: error: expected ';' before '}' token
   52 |     }
      |     ^
Language: C++

#include <stdio.h>
#include <algorithm>
#include <iostream>
 
using namespace std;
 
class Heap{
public:
    Heap(){
        array = new int[2000000];
        n = 0;
    }
    void insert(int data){
        array[n] = data;
        n++;
    }
void max_heapify(int* array, int start, int end)
{
	int dad = start;
	int son = dad * 2 + 1;

	while (son <= end)
	{
		if (array[son] < array[son+1] && son+1 <= end)
			son++;
		if (array[dad] > array[son])
			return;
		else
		{
			swap(array[son], array[dad]);
			dad = son;
			son = dad * 2 + 1;
		}
		
	}
}

void heap_sort(int* array, int len)
{
	int i;
	for(i=len/2-1;i>=0;--i)
	{
		max_heapify(array, i, len-1);
	}
        swap(array[0],array[len-1]);
return array[len-1];
}
    int extract(){
    int ret = heap_sort(array,n);
    n--;
    return ret;
    }
 
private:
    int* array;
    int n;
};
 
int main(){
 
    int insert_data;
    char buf[22];
    Heap heap;
 
    while(true){
        fgets(buf,22,stdin);
        if(buf[2] == 'd') break;
        if(buf[0] == 'i'){
            insert_data = 0;
            for(int i = 0; buf[i] != '\0';i++){
                if(buf[i] >= '0' && buf[i] <= '9'){
                    insert_data = 10*insert_data + (buf[i] - '0');
                }
            }
            heap.insert(insert_data);
        }else{
            printf("%d\n",heap.extract());
        }
    }
}


Compiler output:
a.cc: In member function 'void Heap::heap_sort(int*, int)':
a.cc:46:19: error: return-statement with a value, in function returning 'void' [-fpermissive]
   46 | return array[len-1];
      |        ~~~~~~~~~~~^
a.cc: In member function 'int Heap::extract()':
a.cc:49:24: error: void value not ignored as it ought to be
   49 |     int ret = heap_sort(array,n);
      |               ~~~~~~~~~^~~~~~~~~
Language: C++

#include <cstdio>
#include <string>
#include <iostream>
#include<queue>
using namespace std;
int main(){
	cin.tie(0);  //切記！這兩句要放main一開頭 
    ios_base::sync_with_stdio(0);	
	int num,max;

	priority_queue<int> pq;
	while(1){	
		string str;
		cin >> str;
		
		if(str=="insert"){
			cin >> num;
			pq.push(num);
		}			
		else if(str=="extract"){
			num = pq.top();
			pq.pop();
			cout << num << "\n";
		}		
		else if
			return 0;
	}	
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:25: error: expected '(' before 'return'
   26 |                         return 0;
      |                         ^~~~~~
      |                         (
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=1;
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 inseret(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:45:7: error: extended character “ is not valid in an identifier
   45 | scanf(“%s",com);
      |       ^
a.cc:45:10: warning: missing terminating " character
   45 | scanf(“%s",com);
      |          ^
a.cc:45:10: error: missing terminating " character
   45 | scanf(“%s",com);
      |          ^~~~~~~
a.cc: In function 'int main()':
a.cc:45:7: error: '\U0000201c' was not declared in this scope
   45 | scanf(“%s",com);
      |       ^
a.cc:45:9: error: 's' was not declared in this scope
   45 | scanf(“%s",com);
      |         ^
a.cc:49:1: error: 'insert' was not declared in this scope; did you mean 'inseret'?
   49 | insert(key);
      | ^~~~~~
      | inseret
Language: C++

#include <iostream>

constexpr int MAX_HEAP_SIZE = 2000000;
int H[MAX_HEAP_SIZE + 1];
int heap_size = 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* H, int i) {
    int l = left(i);
    int r = right(i);
    int largest;
    if ((l <= heap_size) && (H[l] > H[i])) {
        largest = l;
    }else{
        largest = i;
    }
    if ((r <= heap_size) && (H[r] > H[largest])) {
        largest = r;
    }

    if (largest != i) {
        std::swap(H[i], H[largest]);
        MaxHeapify(H, largest);
    }
}

void IncreaseHeapKey(int *H, int tgt, int key) {
    if (H[tgt] > key) {
        std::cerr << "Setting key should be higher." << std::endl;
        exit(-1);
    }
    H[tgt] = key;
    while ((tgt > 1) && (H[parent(tgt)] < H[tgt]) ) {
        std::swap(H[parent(tgt)], H[tgt]);
        tgt = parent(tgt);
    }
}
void Insert(int *H, int key) {
    heap_size++;
    H[heap_size] = INTMAX_MIN;
    IncreaseHeapKey(H, heap_size, key);
}

int ExtractMax(int *H) {
    if (heap_size < 1) {
        std::cerr << "Heap under flow" << std::endl;
        exit(-1);
    }
    int max = H[1];
    H[1] = H[heap_size];
    heap_size--;
    MaxHeapify(H, 1);
    return max;
}


void BuildMaxHeap(int *H) {
    for (int i = heap_size / 2; i > 0; i--) {
        MaxHeapify(H, i);
    }
}

int main() {
    while (true) {
        std::string str;
        std::cin >> str;
        if (str == "extract") {
            std::cout << ExtractMax(H) << std::endl;
            continue;
        }
        if (str == "insert") {
            int k;
            std::cin >> k;
            Insert(H, k);
            continue;
        }
        break;
    }
    return 0;
}


Compiler output:
a.cc: In function 'void Insert(int*, int)':
a.cc:43:20: error: 'INTMAX_MIN' was not declared in this scope
   43 |     H[heap_size] = INTMAX_MIN;
      |                    ^~~~~~~~~~
Language: C++

#include <iostream>

constexpr int MAX_HEAP_SIZE = 2000000;
int H[MAX_HEAP_SIZE + 1];
int heap_size = 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* H, int i) {
    int l = left(i);
    int r = right(i);
    int largest;
    if ((l <= heap_size) && (H[l] > H[i])) {
        largest = l;
    }else{
        largest = i;
    }
    if ((r <= heap_size) && (H[r] > H[largest])) {
        largest = r;
    }

    if (largest != i) {
        std::swap(H[i], H[largest]);
        MaxHeapify(H, largest);
    }
}

void IncreaseHeapKey(int *H, int tgt, int key) {
    if (H[tgt] > key) {
        std::cerr << "Setting key should be higher." << std::endl;
        exit(-1);
    }
    H[tgt] = key;
    while ((tgt > 1) && (H[parent(tgt)] < H[tgt]) ) {
        std::swap(H[parent(tgt)], H[tgt]);
        tgt = parent(tgt);
    }
}
void Insert(int *H, int key) {
    heap_size++;
    H[heap_size] = -INT_MAX;
    IncreaseHeapKey(H, heap_size, key);
}

int ExtractMax(int *H) {
    if (heap_size < 1) {
        std::cerr << "Heap under flow" << std::endl;
        exit(-1);
    }
    int max = H[1];
    H[1] = H[heap_size];
    heap_size--;
    MaxHeapify(H, 1);
    return max;
}


void BuildMaxHeap(int *H) {
    for (int i = heap_size / 2; i > 0; i--) {
        MaxHeapify(H, i);
    }
}

int main() {
    while (true) {
        std::string str;
        std::cin >> str;
        if (str == "extract") {
            std::cout << ExtractMax(H) << std::endl;
            continue;
        }
        if (str == "insert") {
            int k;
            std::cin >> k;
            Insert(H, k);
            continue;
        }
        break;
    }
    return 0;
}


Compiler output:
a.cc: In function 'void Insert(int*, int)':
a.cc:43:21: error: 'INT_MAX' was not declared in this scope
   43 |     H[heap_size] = -INT_MAX;
      |                     ^~~~~~~
a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    1 | #include <iostream>
  +++ |+#include <climits>
    2 |
Language: C++

#include<iostream>
#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() {
  cin >> H;
  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 'int main()':
a.cc:57:20: error: 'key' was not declared in this scope; did you mean 'key_t'?
   57 |       scanf("%d", &key);
      |                    ^~~
      |                    key_t
Language: C++

#include <bits/stdc++.h>

using namespace std;


struct Node
{
  int key, lazy;
  Node *l, *r;
} *root = nullptr;

Node pool[2000001];

template< typename T >
struct SkewHeap
{
  bool rev;

  int ptr;

  SkewHeap(bool rev = false) : rev(rev) {}

  Node *propagate(Node *t)
  {
    if(t->lazy != 0) {
      if(t->l) t->l->lazy += t->lazy;
      if(t->r) t->r->lazy += t->lazy;
      t->key += t->lazy;
      t->lazy = 0;
    }
    return t;
  }

  Node *merge(Node *x, Node *y)
  {
    if(!x || !y) return x ? x : y;
    propagate(x), propagate(y);
    if((x->key > y->key) ^ rev) swap(x, y);
    x->r = merge(y, x->r);
    swap(x->l, x->r);
    return x;
  }

  Node *push(const T &key)
  {
    pool[ptr].key = key;
    root = merge(root, &pool[ptr++]);
  }

  T top()
  {
    return propagate(root)->key;
  }

  void pop()
  {
    propagate(root)
    auto *temp = root;
    root = merge(root->l, root->r);
    //  delete temp;
  }

  bool empty() const
  {
    return !root;
  }

  void add(const T &lazy)
  {
    if(root) {
      root->lazy += lazy;
      propagate(root);
    }
  }

};

int main()
{
  char buff[100];
  int key;

  SkewHeap< int > que(true);
  for(;;) {
    scanf("%s", buff);
    if(buff[0] == 'e' && buff[1] == 'n') break;
    if(buff[0] == 'i') {
      scanf("%d", &key);
      que.push(key);
    } else {
      printf("%d\n", que.top());
      que.pop();
    }
  }
}


Compiler output:
a.cc: In member function 'Node* SkewHeap<T>::push(const T&)':
a.cc:48:3: warning: no return statement in function returning non-void [-Wreturn-type]
   48 |   }
      |   ^
a.cc: In member function 'void SkewHeap<T>::pop()':
a.cc:58:5: error: expected ';' before 'auto'
   58 |     auto *temp = root;
      |     ^~~~
Language: C++

//#define NDEBUG
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
/*
二重連鎖木によるpairing heapの実装例
*/
template<class T,bool P=false>
class pairing_heap {
	static constexpr uint64 ALLOCSIZE = (uint64)1 << 10;
	struct node_t {
		T data;
		node_t *left, *right;
	};
	node_t *root;
	static node_t *pool;
	static node_t *merge(node_t *x, node_t *y) {
		if (P ^ (x->data < y->data)) std::swap(x, y);
		x->right = y->left;
		y->left = x;
		return y;
	}

public:
	pairing_heap() :root(nullptr) {}
	T pop() {
		assert(root);
		node_t *n = nullptr, *x = root->left, *y;
		root->left = pool;
		pool = root;
		while (x) {
			y = x;
			if (x->right) {
				x = x->right->right;
				y = merge(y, y->right);
			}
			else {
				x = nullptr;
			}
			y->right = n;
			n = y;
		}
		if (!n) { root = nullptr;return pool->data; }
		root = n;
		n = n->right;
		while (n) {
			x = n;
			n = n->right;
			root = merge(root, x);
		}
		return pool->data;
	}
	void push(const T &data) {
		if (!pool) {
			pool = (node_t *)malloc(ALLOCSIZE * sizeof(node_t));
			uint32 i = ALLOCSIZE;
			pool[i - 1].left = nullptr;
			while (--i) {
				pool[i - 1].left = pool + i;
			}
		}
		node_t *top = pool;
		pool = pool->left;
		top->data = data;
		top->left = nullptr;
		root = root ? merge(root, top) : top;
	}
	pairing_heap &operator+=(pairing_heap &other) {
		root = merge(root, other.root);
		other.root = nullptr;
		return *this;
	}
};
template<class T,bool P>
typename pairing_heap<T,P>::node_t *pairing_heap<T,P>::pool = nullptr;

template<typename T>
void uscan(T &d) {
	d = 0;int c = 0;
	while (c < '0' || '9' < c) c = fgetc(stdin);
	while ('0' <= c&&c <= '9') {
		d = (d << 3) + (d << 1) + c - '0';c = fgetc(stdin);
	}
}
void sscan(std::string &s) {
	s = std::string();
	int c = 0;
	while (c < 'a' || 'z' < c) c = fgetc(stdin);
	while ('a' <= c&&c <= 'z') {
		s.push_back(c);
		c = fgetc(stdin);
	}
}

int main(void) {
	std::ios::sync_with_stdio(false);
	std::string s;
	uint32 k;
	pairing_heap<uint32, true> Q;
	sscan(s);
	while (s[2] != 'd') {
		if (s[0] == 'e') {
			printf("%u\n", Q.pop());
		}
		else {
			uscan(k);
			Q.push(k);
		}
		sscan(s);
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:117:19: error: incomplete type 'std::ios' {aka 'std::basic_ios<char>'} used in nested name specifier
  117 |         std::ios::sync_with_stdio(false);
      |                   ^~~~~~~~~~~~~~~
Language: C++

#include <iostream>

int A[int(2e9)+10];
int last = 0;

void buildHeap(int i) {
  int l = 2 * i;
  int r = 2 * i + 1;
  int largest;
  if(l <= last && A[l] >= A[i]) {
    largest = l;
  } else {
    largest = i;
  }
  if(r <= last && A[r] >= A[largest]) {
    largest = r;
  }

  if(largest != i) {
    std::swap(A[i], A[largest]);
    buildHeap(largest);
  }
}

int main() {
  std::string com;

  while(std::cin >> com) {
    if(com == "end") break;
    if(com == "insert") {
      int x;
      std::cin >> x;
      last++;
      A[last] = x;
      
      for(int i=last/2; i>=1; --i) {
        buildHeap(i);
      }
    } else if (com == "extract") {
      std::cout << A[1] << std::endl;
      last--;
      // 多分だけどここがダメなのでは
      for(int i=1; i<=last; i++){
        A[i] = A[i+1];
      }
      for(int i=last/2; i>=1; --i) {
        buildHeap(i);
      }
    }
  }
}


Compiler output:
/tmp/ccBy2WyT.o: in function `buildHeap(int)':
a.cc:(.text+0x20): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccBy2WyT.o
a.cc:(.text+0x6b): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccBy2WyT.o
/tmp/ccBy2WyT.o: in function `main':
a.cc:(.text+0x164): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccBy2WyT.o
a.cc:(.text+0x16d): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccBy2WyT.o
a.cc:(.text+0x173): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccBy2WyT.o
a.cc:(.text+0x191): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccBy2WyT.o
a.cc:(.text+0x205): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccBy2WyT.o
a.cc:(.text+0x20e): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccBy2WyT.o
a.cc:(.text+0x253): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccBy2WyT.o
a.cc:(.text+0x25e): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccBy2WyT.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>

int A[int(2e9)+10];
int last = 0;

void buildHeap(int i) {
  int l = 2 * i;
  int r = 2 * i + 1;
  int largest;
  if(l <= last && A[l] >= A[i]) {
    largest = l;
  } else {
    largest = i;
  }
  if(r <= last && A[r] >= A[largest]) {
    largest = r;
  }

  if(largest != i) {
    std::swap(A[i], A[largest]);
    buildHeap(largest);
  }
}

int main() {
  std::string com;

  while(std::cin >> com) {
    if(com == "end") break;
    if(com == "insert") {
      int x;
      std::cin >> x;
      last++;
      A[last] = x;
      
      for(int i=last/2; i>=1; --i) {
        buildHeap(i);
      }
    } else if (com == "extract") {
      std::cout << A[1] << std::endl;
      last--;
      for(int i=1; i<=last; i++){
        A[i] = A[i+1];
      }
      for(int i=last/2; i>=1; --i) {
        buildHeap(i);
      }
    }
  }
}


Compiler output:
/tmp/ccM8gvdi.o: in function `buildHeap(int)':
a.cc:(.text+0x20): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccM8gvdi.o
a.cc:(.text+0x6b): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccM8gvdi.o
/tmp/ccM8gvdi.o: in function `main':
a.cc:(.text+0x164): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccM8gvdi.o
a.cc:(.text+0x16d): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccM8gvdi.o
a.cc:(.text+0x173): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccM8gvdi.o
a.cc:(.text+0x191): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccM8gvdi.o
a.cc:(.text+0x205): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccM8gvdi.o
a.cc:(.text+0x20e): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccM8gvdi.o
a.cc:(.text+0x253): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccM8gvdi.o
a.cc:(.text+0x25e): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccM8gvdi.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>

int A[int(2e9)+10];
int last = 0;

void buildHeap(int i) {
  int l = 2 * i;
  int r = 2 * i + 1;
  int largest;
  if(l <= last && A[l] >= A[i]) {
    largest = l;
  } else {
    largest = i;
  }
  if(r <= last && A[r] >= A[largest]) {
    largest = r;
  }

  if(largest != i) {
    std::swap(A[i], A[largest]);
    buildHeap(largest);
  }
}

int main() {
  std::string com;

  while(std::cin >> com) {
    if(com == "end") break;
    if(com == "insert") {
      int x;
      std::cin >> x;
      last++;
      A[last] = x;
      
      for(int i=last/2; i>=1; --i) {
        buildHeap(i);
      }
    } else if (com == "extract") {
      std::cout << A[1] << std::endl;
      last--;
      for(int i=1; i<=last; i++){
        A[i] = A[i+1];
      }
      for(int i=last/2; i>=1; --i) {
        buildHeap(i);
      }
    }
  }
}


Compiler output:
/tmp/ccslhF31.o: in function `buildHeap(int)':
a.cc:(.text+0x20): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccslhF31.o
a.cc:(.text+0x6b): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccslhF31.o
/tmp/ccslhF31.o: in function `main':
a.cc:(.text+0x164): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccslhF31.o
a.cc:(.text+0x16d): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccslhF31.o
a.cc:(.text+0x173): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccslhF31.o
a.cc:(.text+0x191): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccslhF31.o
a.cc:(.text+0x205): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccslhF31.o
a.cc:(.text+0x20e): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccslhF31.o
a.cc:(.text+0x253): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccslhF31.o
a.cc:(.text+0x25e): relocation truncated to fit: R_X86_64_PC32 against symbol `last' defined in .bss section in /tmp/ccslhF31.o
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
#define Lens 2000005

using namespace std;
int N, h = 0;;
int A[Lens];
char com[20];

int parent(int i)
{
	return i / 2;
}
int lc(int i)
{
	return 2 * i;
}
int rc(int i)
{
	return 2 * i + 1;
}

void Insert(int k)
{
	h++;
	A[h] = k;
	changeheapify(h);
}

void changeheapify(int i)
{
	int p = parent(i);
	if (p > 0)
	{
		if (A[i] > A[p])
		{
			swap(A[i], A[p]);
			changeheapify(p);
		}
	}
}

void maxheapify(int i)
{
	int l = lc(i);
	int r = rc(i);
	int largest=i;
	if (A[l] > A[i] && l <= h)
		largest = l;
	if (A[r] > A[largest]&&r<=h)
		largest = r;
	if (largest != i)
	{
		swap(A[i], A[largest]);
		maxheapify(largest);
	}
}


int Delete()
{
	int tmp = A[1];
	A[1] = A[h];
	A[h] = 0;
	h--;
	maxheapify(1);
	return tmp;
}

int main()
{
	int k;
	while (cin >> com)
	{
		if (com[0]== 'i')
		{
			cin >> k;
			Insert(k);
		}
		else if (com[0] == 'e'&&com[1]=='x')
		{
			int tmp = Delete();
			cout << tmp<<endl;
		}
		else if (com[0]=='e'&&com[1]=='n')
			break;
	}
	return 0;
}



Compiler output:
a.cc: In function 'void Insert(int)':
a.cc:28:9: error: 'changeheapify' was not declared in this scope
   28 |         changeheapify(h);
      |         ^~~~~~~~~~~~~
Language: C++

#include<stdio.h>
#include<algorithm>
using namespace std;
#define NIL -2000000001
#define MAX 2000000

int A[MAX];
int n = 0;

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

void insert(int key) {
  n++;
  A[n] = key;
  int i = n;
  int parent = (i+1)/2-1;
  while (i > 0 && A[parent] < A[i]) {
    swap(A[i], A[parent]);
    i = (i+1)/2-1;
    parent = (i+1)/2-1;
  }
}

void heapExtractMax() {
  printf("%d\n", A[0]);
  A[0] = A[n];
  A[n] = NIL;
  n--;
  maxHeapify(0);
}

int main() {
  for ( int i = 0; i < MAX; i++ ) {
    A[i] = NIL;
  }

  char str[14];
  int key;
  for ( ;; ) {
    scanf("%s", str);
    if ( strcmp(str, "insert") == 0 ) {
      scanf("%d", &key);
      insert(key);
    } else if ( strcmp(str, "extract") == 0 ) {
      heapExtractMax();
    } else if ( strcmp(str, "end") == 0 ) {
      break;
    }
  }

  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:57:10: error: 'strcmp' was not declared in this scope
   57 |     if ( strcmp(str, "insert") == 0 ) {
      |          ^~~~~~
a.cc:3:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include<algorithm>
  +++ |+#include <cstring>
    3 | using namespace std;
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, t, largest;
  l = i * 2;
  r = i * 2 + 1;
  if ( l <= H && A[l] > A[i] ) largest = l;
  else largest = i;

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

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

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

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' && con[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 'int extract()':
a.cc:27:16: error: return-statement with no value, in function returning 'int' [-fpermissive]
   27 |   if ( H < 1 ) return;
      |                ^~~~~~
a.cc: In function 'void increaseKey(int, int)':
a.cc:38:8: error: return-statement with a value, in function returning 'void' [-fpermissive]
   38 |   A[i] = key;
      |   ~~~~~^~~~~
a.cc: In function 'int main()':
a.cc:57:27: error: 'con' was not declared in this scope; did you mean 'com'?
   57 |     if ( com[0] == 'e' && con[1] == 'n' ) break;
      |                           ^~~
      |                           com
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, t, largest;
  l = i * 2;
  r = i * 2 + 1;
  if ( l <= H && A[l] > A[i] ) largest = l;
  else largest = i;

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

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

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

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' && con[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:38:8: error: return-statement with a value, in function returning 'void' [-fpermissive]
   38 |   A[i] = key;
      |   ~~~~~^~~~~
a.cc: In function 'int main()':
a.cc:57:27: error: 'con' was not declared in this scope; did you mean 'com'?
   57 |     if ( com[0] == 'e' && con[1] == 'n' ) break;
      |                           ^~~
      |                           com
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, t, largest;
  l = i * 2;
  r = i * 2 + 1;
  if ( l <= H && A[l] > A[i] ) largest = l;
  else largest = i;

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

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

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

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' && con[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 'int main()':
a.cc:57:27: error: 'con' was not declared in this scope; did you mean 'com'?
   57 |     if ( com[0] == 'e' && con[1] == 'n' ) break;
      |                           ^~~
      |                           com