Language: C++

#include<iostream>
#include<vector>
#include<string>


template<class T>
class BinomialHeap{
	struct Tree{
		T val;
		std::vector<Tree *> edge;
		Tree(T &v):val(v){}
		~Tree(){
			for(int i=0;i<degree();i++)delete edge[i];
		}	
		void add(Tree *t){edge.push_back(t);}
		void pop(Tree *t){edge.pop_back();}
		int degree()const{return edge.size();}
	};
	std::vector<Tree*> trees;
	mutable int imax;

	static Tree* add(Tree* a,Tree* b){
		if(a->val > b->val){
			a->add(b);
			return a;
		}else{
			b->add(a);
			return b;
		}
	}
	int findmax(){
		for(int i=0;i<trees.size();i++)
			if(trees[i] && (imax==-1||trees[i]->val > trees[imax]->val))
				imax=i;
	}
	BinomialHeap(std::vector<Tree*>& e):trees(e),imax(-1){}
public:
	BinomialHeap():imax(-1){}
	~BinomialHeap(){
		clear();
	}
	//O(log n)
	void meld(BinomialHeap &h){
		imax=-1;
		Tree* carry=NULL;
		if(trees.size()<h.trees.size())trees.swap(h.trees);
		for(int i=0;i<trees.size();i++){
			if(carry){
				if(i<h.trees.size() && h.trees[i]){
					carry=add(carry,h.trees[i]);
					h.trees[i]=NULL;
				}else if(trees[i]){
					carry=add(carry,trees[i]);
					trees[i]=NULL;
				}else{
					trees[i]=carry;
					carry=NULL;
				}
			}else if(i<h.trees.size() && h.trees[i]){
				if(trees[i]){
					carry=add(trees[i],h.trees[i]);
					trees[i]=h.trees[i]=NULL;	
				}else{
					trees[i]=h.trees[i];
					h.trees[i]=NULL;		
				}
			}
		}
		if(carry)trees.push_back(carry);
		h.clear();
	}
	//O(log n)
	void push(T &v){
		BinomialHeap h;
		h.trees.push_back(new Tree(v));
		meld(h);
	}
	T getmax()const{
		if(imax==-1)findmax();
		return trees[imax]->val;
	}
	void popmax(){
		if(imax==-1)findmax();
		BinomialHeap h;
		trees[imax]->edge.swap(h.trees);
		delete trees[imax];
		trees[imax]=NULL;
		meld(h);
		while(!trees.empty() && trees.back()==NULL)trees.pop_back();
		imax=-1;
	}
	bool empty()const{
		return trees.empty();
	}
	void clear(){
		imax=-1;
		for(int i=0;i<trees.size();i++)
			if(trees[i])
				delete trees[i];
		trees.clear();
	}
	//void remove(int id){}
	//decrease_key remove(int id,T v){}
};

using namespace std;


int main(){
	BinomialHeap<int> heap;
	string s;
	while(1){
		cin>>s;
		if(s=="end")break;
		if(s=="insert"){
			int n;
			cin>>n;
			heap.push(n);
		}else if(s=="extract"){
			cout<<heap.getmax()<<endl;
			heap.popmax();
		}
	}
	return 0;
}

Compiler output:
a.cc: In instantiation of 'T BinomialHeap<T>::getmax() const [with T = int]':
a.cc:120:21:   required from here
  120 |                         cout<<heap.getmax()<<endl;
      |                               ~~~~~~~~~~~^~
a.cc:79:36: error: passing 'const BinomialHeap<int>' as 'this' argument discards qualifiers [-fpermissive]
   79 |                 if(imax==-1)findmax();
      |                             ~~~~~~~^~
a.cc:31:13: note:   in call to 'int BinomialHeap<T>::findmax() [with T = int]'
   31 |         int findmax(){
      |             ^~~~~~~
a.cc: In instantiation of 'int BinomialHeap<T>::findmax() [with T = int]':
a.cc:79:15:   required from 'T BinomialHeap<T>::getmax() const [with T = int]'
   79 |                 if(imax==-1)findmax();
      |                             ^~~~~~~
a.cc:120:21:   required from here
  120 |                         cout<<heap.getmax()<<endl;
      |                               ~~~~~~~~~~~^~
a.cc:35:9: warning: no return statement in function returning non-void [-Wreturn-type]
   35 |         }
      |         ^