Hard
Who Takes Each Subject?
Read lines
student: subject1, subject2, … until END. Build a dictionary from each subject to the set of students taking it. Print the subjects sorted by number of students (most first, ties alphabetical) as subject (n): names with names sorted and joined by commas.Input
Lines, then END.
Output
Lines.
Sample 1
Input
Mim: math, physics Rafi: math Sara: physics, chemistry, math END
Output
math (3): Mim, Rafi, Sara physics (2): Mim, Sara chemistry (1): Sara
Sample 2
Input
A: x END
Output
x (1): A
Output appears here