#include #include #include using namespace std; struct Point {int x, y;}; bool operator < (Point const & a, Point const & b) { if (a.y != b.y) return a.y > b.y; return a.x < b.x; } int main () { int n; cin >> n; vector a (n); for (auto & [x, y] : a) // C++17 cin >> x >> y; sort (a.begin (), a.end ()); for (auto [x, y] : a) // C++17 cout << x << " " << y << endl; return 0; }