Question: Python problem: standings table Your problem should generate standings table according to the information from logs. Each line should contain student login and number of

Python problem: standings table

Your problem should generate standings table according to the information from logs. Each line should contain student login and number of problems solved by this student. Students should be sorted in descending order of the number of solved problems. If two students have same number of solved problems, they should be printed in alphabetical order.

Input format

First line contains single integer number: 1 N 10000 number lines in the log file.

Following N lines describe the log file. Each of these lines contains student login terminated by line break character. Each login consists of 1-100 lowercase latin letters (a-z).

Output format

Your output should have N lines. Each should contain login of student followed by number of problems solved by this student. Students should be sorted in descending order of the number of solved problems. If two students have same number of solved problems, they should be printed in alphabetical order.

Time limit: 1 second

Memory limit: 256 Mb

Sample 1

Input

Output

3 kormen kormen kormen 
kormen 3 

Sample 2

Input

Output

3 knuth kormen dijkstra 
dijkstra 1 knuth 1 kormen 1 

Sample 3

Input

Output

7 knuth kormen kormen knuth dijkstra dijkstra dijkstra 
dijkstra 3 knuth 2 kormen 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!