Language: C++

#define _CRT_SECURE_NO_WARNINGS
#include <cassert>
#include <cstddef>
#include <functional>
#include <memory>
#include <utility>
#include <type_traits>

template <class TotallyOrderedSet> class pairing_heap {

public:
	using set_type = TotallyOrderedSet;
	using value_type = typename set_type::value_type;
	using const_reference = const value_type &;
	using size_type = std::size_t;

private:
	struct node_t {
		value_type value;
		std::unique_ptr<node_t> left, right;
		template <class... Args>
		node_t(Args &&... args) noexcept(
			std::is_nothrow_constructible<value_type, Args...>::value)
			: value(std::forward<Args>(args)...), left(), right() {}
	};
	using pointer = std::unique_ptr<node_t>;
	pointer root;
	size_type s;
	static pointer merge(pointer x, pointer y) noexcept(set_type::less_equal(
		std::declval<value_type>(), std::declval<value_type>())) {
		if (!set_type::less_equal(x->value, y->value))
			x.swap(y);
		y->right = std::move(x->left);
		x->left = std::move(y);
		return std::move(x);
	}
	static pointer mergelist(pointer curr) noexcept(
		merge(std::declval<pointer>(), std::declval<pointer>())) {
		pointer head, temp, next;
		while (curr) {
			next = std::move(curr->right);
			if (next) {
				temp = std::move(next->right);
				curr = merge(std::move(curr), std::move(next));
			}
			curr->right = std::move(head);
			head = std::move(curr);
			curr = std::move(temp);
		}
		if (head) {
			curr = std::move(head);
			head = std::move(curr->right);
		}
		while (head) {
			next = std::move(head->right);
			curr = merge(std::move(curr), std::move(head));
			head = std::move(next);
		}
		return std::move(curr);
	}

public:
	pairing_heap()noexcept : root(), s(0) {}

	bool empty() const noexcept { return !root; }
	size_type size() const noexcept { return s; }

	const_reference top() const {
		assert(!empty());
		return root->value;
	}

	void push(const value_type &x) {
		if (empty())
			root = std::make_unique<node_t>(x);
		else
			root = merge(std::move(root), std::make_unique<node_t>(x));
		++s;
	}
	void push(value_type &&x) {
		if (empty())
			root = std::make_unique<node_t>(std::move(x));
		else
			root = merge(std::move(root), std::make_unique<node_t>(std::move(x)));
		++s;
	}
	template <class... Args> void emplace(Args &&... args) {
		if (empty())
			root = std::make_unique<node_t>(std::forward<Args>(args)...);
		else
			root = merge(std::move(root),
				std::make_unique<node_t>(std::forward<Args>(args)...));
		++s;
	}

	void pop() {
		assert(!empty());
		root = mergelist(std::move(root->left));
		--s;
	}

	pairing_heap &meld(pairing_heap &other) {
		if (!other.empty()) {
			s += other.s;
			other.s = 0;
			root = merge(std::move(root), std::move(other.root));
		}
		return *this;
	}
	pairing_heap &operator+=(pairing_heap &other) { return meld(other); }
};
#include <algorithm>
#include <limits>
#include <utility>

template <class T> class ordered_set {
public:
	using value_type = T;

	static bool less_equal(const value_type &x, const value_type &y) noexcept(
		true) {
		return x <= y;
	}
};

#include<cstdio>
#include<string>
void scan(std::string &s) {
	s.clear();
	int c = fgetc(stdin);
	while (c == ' ' || c == '\n') c = fgetc(stdin);
	while (c != ' '&&c != '\n') {
		s.push_back(c);
		c = fgetc(stdin);
	}
}

int main() {
	pairing_heap<ordered_set<int>> Q;
	std::string s;
	int k;
	while (scan(s),s[2] != 'd') {
		if (s[0] == 'i') {
			scanf("%d", &k);
			Q.push(k);
		}
		else {
			printf("%d\n", Q.top());
			Q.pop();
		}
	}
	return 0;
}


Compiler output:
a.cc:38:22: error: call to non-'constexpr' function 'static pairing_heap<TotallyOrderedSet>::pointer pairing_heap<TotallyOrderedSet>::merge(pointer, pointer)'
   38 |                 merge(std::declval<pointer>(), std::declval<pointer>())) {
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:29:24: note: 'static pairing_heap<TotallyOrderedSet>::pointer pairing_heap<TotallyOrderedSet>::merge(pointer, pointer)' declared here
   29 |         static pointer merge(pointer x, pointer y) noexcept(set_type::less_equal(
      |                        ^~~~~
a.cc: In instantiation of 'static pairing_heap<TotallyOrderedSet>::pointer pairing_heap<TotallyOrderedSet>::merge(pointer, pointer) [with TotallyOrderedSet = ordered_set<int>; pointer = std::unique_ptr<pairing_heap<ordered_set<int> >::node_t, std::default_delete<pairing_heap<ordered_set<int> >::node_t> >]':
a.cc:77:16:   required from 'void pairing_heap<TotallyOrderedSet>::push(const value_type&) [with TotallyOrderedSet = ordered_set<int>; value_type = int]'
   77 |                         root = merge(std::move(root), std::make_unique<node_t>(x));
      |                                ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:145:10:   required from here
  145 |                         Q.push(k);
      |                         ~~~~~~^~~
a.cc:29:81: error: call to non-'constexpr' function 'static bool ordered_set<T>::less_equal(const value_type&, const value_type&) [with T = int; value_type = int]'
   29 |         static pointer merge(pointer x, pointer y) noexcept(set_type::less_equal(
      |                                                             ~~~~~~~~~~~~~~~~~~~~^
   30 |                 std::declval<value_type>(), std::declval<value_type>())) {
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~          
a.cc:120:21: note: 'static bool ordered_set<T>::less_equal(const value_type&, const value_type&) [with T = int; value_type = int]' declared here
  120 |         static bool less_equal(const value_type &x, const value_type &y) noexcept(
      |                     ^~~~~~~~~~
In file included from /usr/include/c++/14/bits/move.h:37,
                 from /usr/include/c++/14/bits/stl_function.h:60,
                 from /usr/include/c++/14/functional:49,
                 from a.cc:4:
/usr/include/c++/14/type_traits: In instantiation of 'decltype (__declval<_Tp>(0)) std::declval() [with _Tp = int; decltype (__declval<_Tp>(0)) = int&&]':
a.cc:30:27:   required from 'static pairing_heap<TotallyOrderedSet>::pointer pairing_heap<TotallyOrderedSet>::merge(pointer, pointer) [with TotallyOrderedSet = ordered_set<int>; pointer = std::unique_ptr<pairing_heap<ordered_set<int> >::node_t, std::default_delete<pairing_heap<ordered_set<int> >::node_t> >]'
   30 |                 std::declval<value_type>(), std::declval<value_type>())) {
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~^~
a.cc:77:16:   required from 'void pairing_heap<TotallyOrderedSet>::push(const value_type&) [with TotallyOrderedSet = ordered_set<int>; value_type = int]'
   77 |                         root = merge(std::move(root), std::make_unique<node_t>(x));
      |                                ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:145:10:   required from here
  145 |                         Q.push(k);
      |                         ~~~~~~^~~
/usr/include/c++/14/type_traits:2487:47: error: static assertion failed: declval() must not be used!
 2487 |       static_assert(__declval_protector<_Tp>::__stop,
      |                                               ^~~~~~
/usr/include/c++/14/type_traits:2487:47: note: 'std::__declval_protector<int>::__stop' evaluates to false