SORTED

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
import sys
from operator import itemgetter
vals = sys.stdin.read().split()
zipped = zip(map(int, vals[1::2]), map(int, vals[2::2]))
zipped = sorted(zipped, key=itemgetter(0))
zipped = sorted(zipped, key=itemgetter(1), reverse=True)
print len(zipped)
for ids, score in zipped:
print ids, score