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;
template< typename T >
struct PairingHeap
{
	struct Node
	{
		T key;
		Node *head, *next;
	} *root = nullptr;
	bool rev;

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

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

	Node *push(const T &key)
	{
		auto t = new Node({ key, nullptr, nullptr });
		root = merge(root, t);
	}

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

	Node *_pop(Node *s)
	{
		Node *p = nullptr;
		while (s) {
			Node *a = s, *b = nullptr;
			s = s->next;
			a->next = nullptr;
			if (s) {
				b = s;
				s = s->next;
				b->next = nullptr;
			}
			a = merge(a, b);
			a->next = p;
			p = a;
		}
		while (p) {
			Node *j = p;
			p = p->next;
			s = merge(j, s);
		}
		return s;
	}

	void pop()
	{
		auto *temp = root;
		root = _pop(root->head);
	}

	bool empty() const
	{
		return !root;
	}

	void merge(PairingHeap< T > &p)
	{
		root = merge(root, p.root);
	}
};

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::string s;
	uint32 k;
	PairingHeap<uint32> Q(true);
	sscan(s);
	while (s[2] != 'd') {
		if (s[0] == 'e') {
			printf("%u\n", Q.top());
			Q.pop();
		}
		else {
			uscan(k);
			Q.push(k);
		}
		sscan(s);
	}
	return 0;
}


Compiler output:
a.cc: In instantiation of 'PairingHeap<T>::Node* PairingHeap<T>::push(const T&) [with T = long unsigned int]':
a.cc:129:10:   required from here
  129 |                         Q.push(k);
      |                         ~~~~~~^~~
a.cc:51:9: warning: no return statement in function returning non-void [-Wreturn-type]
   51 |         }
      |         ^
a.cc: In instantiation of 'PairingHeap<T>::Node* PairingHeap<T>::merge(Node*, Node*) [with T = long unsigned int]':
a.cc:50:15:   required from 'PairingHeap<T>::Node* PairingHeap<T>::push(const T&) [with T = long unsigned int]'
   50 |                 root = merge(root, t);
      |                        ~~~~~^~~~~~~~~
a.cc:129:10:   required from here
  129 |                         Q.push(k);
      |                         ~~~~~~^~~
a.cc:41:50: error: 'swap' was not declared in this scope
   41 |                 if ((x->key > y->key) ^ rev) swap(x, y);
      |                                              ~~~~^~~~~~
a.cc:41:50: note: suggested alternatives:
In file included from /usr/include/c++/14/string:54,
                 from a.cc:17:
/usr/include/c++/14/bits/basic_string.h:4039:5: note:   'std::swap'
 4039 |     swap(basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:61,
                 from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from a.cc:3:
/usr/include/c++/14/bits/move.h:226:5: note:   'std::swap'
  226 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
/usr/include/c++/14/bits/move.h:226:5: note:   'std::swap'