~/algor $ cat problems/reyting-jadvali
Leaderboard
Medium
2000 ms
128 MB
62%
$n$ contestants took part in an olympiad; for each of them the name and the score are given. Build the leaderboard: contestants are placed in decreasing order of score, and with equal scores — by name in alphabetical order.
Input
The first line contains a positive integer $n$. Each of the next $n$ lines contains a name and an integer $b_{i}$ — the score, separated by a space.
Output
$n$ lines: in leaderboard order, the name and score of each contestant separated by a space.
Note
$1 \le n \le 10^{5}$
$0 \le b_{i} \le 10^{9}$
A name consists of $1$ to $20$ lowercase Latin letters, names do not repeat
Examples
Input #1
4 ali 90 vali 95 salim 90 anvar 100
Output #1
anvar 100 vali 95 ali 90 salim 90
Input #2
1 bobur 0
Output #2
bobur 0