Language: C++

#include <cassert>
#include <cstdint>
#include <utility>
/*

tempplate<typename T, bool P = false>
class PairingHeap;

PairingHeapは融合可能なヒープ(優先度付きキュー)です
空間計算量 O(N)


テンプレートパラメータ
-typename T
operator< によって大小が定義された構造体
要素の型になります

-bool P
true を与えると最大ヒープになります
デフォルトでは false で最小ヒープです


メンバ関数
-(constructor) ()
空のヒープを構築します
時間計算量 O(1)

-top (void)->const T &
先頭の要素のconst参照を返します
時間計算量 O(1)

-pop (void)->const T &
先頭の要素を削除し、そのconst参照を返します
時間計算量 償却 O(logN)

-push (const T &data)
data を要素としてヒープに追加します
時間計算量 O(1)

-empty ()->bool
ヒープが空かどうかを返します
時間計算量 O(1)

-meld (ParingHeap<T, P> &other)
other の持つ要素全てをヒープに追加します
otherは空になります
時間計算量 O(1)


※N:要素数
※T の比較に掛かる時間計算量を O(1) と仮定

*/

template <typename T, bool P = false> class PairingHeap {
	static constexpr std::uint_fast64_t ALLOCSIZE = (std::uint_fast64_t)1 << 10;
	struct node_t {
		T data;
		node_t *left, *right;
	};
	node_t *root;
	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:
	PairingHeap() : root(nullptr) {}
	const T &top() const {
		assert(root);
		return root->data;
	}
	const T &pop() {
		assert(root);
		const T &ret = root->data;
		node_t *n = nullptr, *x = root->left, *y;
		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 ret;
		}
		root = n;
		n = n->right;
		while (n) {
			x = n;
			n = n->right;
			root = merge(root, x);
		}
		return ret;
	}
	void push(const T &data) {
		static node_t *pool = nullptr;
		static std::uint_fast64_t it = ALLOCSIZE;
		if (it == ALLOCSIZE) {
			pool = (node_t *)malloc(ALLOCSIZE * sizeof(node_t));
			it = 0;
		}
		node_t *top = &pool[it++];
		top->data = data;
		top->left = nullptr;
		root = root ? merge(root, top) : top;
	}
	bool empty() { return !root; }
	void meld(PairingHeap<T, P> &other) {
		if (other.root) {
			root = root ? merge(root, other.root) : other.root;
			other.root = nullptr;
		}
	}
};
//#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>
static constexpr double PI = 3.1415926535897932;

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
using intl32 = std::int_least32_t;
using intl64 = std::int_least64_t;
using uintl32 = std::uint_least32_t;
using uintl64 = std::uint_least64_t;

namespace n91 {
	template <typename T>
	auto scan(T &d) ->
		typename std::enable_if<std::is_same<T, std::string>::value>::type {
		d = std::string();
		int c = 0;
		while (c < 'a' || 'z' < c)
			c = fgetc(stdin);
		while ('a' <= c && c <= 'z') {
			d.push_back(c);
			c = fgetc(stdin);
		}
	}
	template <typename T>
	auto scan(T &d) ->
		typename std::enable_if<std::is_same<T, double>::value>::type {
		scanf("%lf", &d);
	}
	template <typename T>
	auto scan(T &d) ->
		typename std::enable_if<std::is_signed<T>::value ==
		std::is_same<T, std::string>::value>::type {
		d = 0;
		int c = 0;
		while (c < '0' || '9' < c)
			c = fgetc(stdin);
		while ('0' <= c && c <= '9') {
			d = d * 10 + c - '0';
			c = fgetc(stdin);
		}
	}
	template <typename T>
	auto scan(T &d) ->
		typename std::enable_if<std::is_signed<T>::value !=
		std::is_same<T, double>::value>::type {
		d = 0;
		int c = 0;
		bool f = 0;
		while (c < '0' || '9' < c) {
			if (c == '-')
				f = 1;
			c = fgetc(stdin);
		}
		while ('0' <= c && c <= '9') {
			d = d * 10 + c - '0';
			c = fgetc(stdin);
		}
		if (f)
			d = -d;
	}
} // namespace n91

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


Compiler output:
a.cc: In member function 'void PairingHeap<T, P>::push(const T&)':
a.cc:109:42: error: there are no arguments to 'malloc' that depend on a template parameter, so a declaration of 'malloc' must be available [-fpermissive]
  109 |                         pool = (node_t *)malloc(ALLOCSIZE * sizeof(node_t));
      |                                          ^~~~~~
a.cc:109:42: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
a.cc: In instantiation of 'void PairingHeap<T, P>::push(const T&) [with T = long unsigned int; bool P = true]':
a.cc:219:10:   required from here
  219 |                         Q.push(k);
      |                         ~~~~~~^~~
a.cc:109:48: error: 'malloc' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation
  109 |                         pool = (node_t *)malloc(ALLOCSIZE * sizeof(node_t));
      |                                          ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/bits/stl_algo.h:71,
                 from /usr/include/c++/14/algorithm:61,
                 from a.cc:127:
/usr/include/stdlib.h:672:14: note: 'void* malloc(size_t)' declared here, later in the translation unit
  672 | extern void *malloc (size_t __size) __THROW __attribute_malloc__
      |              ^~~~~~