struct man { int h, w, id; }; bool operator<(const man &a, const man &b) { return tie(a.h, a.w, a.id) < tie(b.h, b.w, b.id); }
ho