#include <bits/stdc++.h>
using namespace std;
int main() {
auto cmp = [](auto& a , auto& b)
{
return a.first * a.second < b.first * b.second
|| (a.first * a.second == b.first * b.second && a.first < b.first);
};
priority_queue<pair<int,int> , vector<pair<int,int>> , decltype(cmp)> p(cmp);
p.emplace(2 , 5);
p.emplace(5 , 10);
p.emplace(3 , 6);
p.emplace(6 , 3);
while(!p.empty())
{
auto t = p.top();
p.pop();
cout << t.first << " " << t.second << endl;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCQoJYXV0byBjbXAgPSBbXShhdXRvJiBhICwgYXV0byYgYikKCXsKCQlyZXR1cm4gYS5maXJzdCAqIGEuc2Vjb25kIDwgYi5maXJzdCAqIGIuc2Vjb25kIAoJICAgICAgIHx8IChhLmZpcnN0ICogYS5zZWNvbmQgPT0gIGIuZmlyc3QgKiBiLnNlY29uZCAmJiBhLmZpcnN0IDwgYi5maXJzdCk7Cgl9OwoJCglwcmlvcml0eV9xdWV1ZTxwYWlyPGludCxpbnQ+ICwgdmVjdG9yPHBhaXI8aW50LGludD4+ICwgZGVjbHR5cGUoY21wKT4gcChjbXApOwoJCglwLmVtcGxhY2UoMiAsIDUpOwoJcC5lbXBsYWNlKDUgLCAxMCk7CglwLmVtcGxhY2UoMyAsIDYpOwoJcC5lbXBsYWNlKDYgLCAzKTsKCQoJd2hpbGUoIXAuZW1wdHkoKSkKCXsKCQlhdXRvIHQgPSBwLnRvcCgpOwoJCXAucG9wKCk7CgkJY291dCA8PCB0LmZpcnN0IDw8ICIgIiA8PCB0LnNlY29uZCA8PCBlbmRsOwoJfQoJCglyZXR1cm4gMDsKfQ==