h=Hash.new 0 gets $<.each_slice(3){|_,m,s|s.split.map{|t|h[t]+=m[/ .*/].to_i}} puts h.sort_by{|k,v|[-v,k]}.take(10).map{|s|s*" "}