Release Leaderboard
At the end of each quarter, the SRE team ranks every service for the release report. Each service has a name, a count of incidents during the quarter, and an uptime percentage measured to three decimal places.
Order the services from most to least reliable: fewest incidents first; among services with the same incident count, higher uptime first; among services tied on both incidents and uptime, alphabetically by name. Uptime is given as a decimal with exactly three digits after the point — compare it exactly (for example by scaling it to an integer), not as a rounded floating-point value, since naive float handling can turn genuinely different uptimes into accidental ties or get the order wrong.
Services that are tied on both incident count and uptime (name does not matter for this part —
it only breaks the tie for display order) share the same rank. The next service whose incidents or
uptime differ gets the rank equal to its 1-indexed position in the ordering, so ranks can skip
numbers: 1, 2, 2, 4, 5, 5, 5, 8, ....
Input
The first line contains a single integer n (1 ≤ n ≤ 2·10^5) — the number of services.
Each of the next n lines describes one service with three space-separated fields:
name— 1 to 20 lowercase English letters and digits. Names are not guaranteed to be distinct.incidents— an integer, 0 ≤ incidents ≤ 10^6.uptime— a decimal number with exactly three digits after the decimal point, written with no leading zeros in the integer part (except the integer part0itself), satisfying0.000 ≤ uptime ≤ 100.000.
Output
Print n lines, the services in leaderboard order, each as:
name incidents uptime rank
Print uptime exactly as it appeared in the input.
Notes
In the first example, beta has the fewest incidents (0) and comes first, then delta (1
incident). alpha and gamma both have 2 incidents and 99.900 uptime, so they tie for rank 3
(ordered alphabetically between themselves), and since no other service follows, rank 4 never
appears.