while 1: k=a=[] for x in input():a+=[[]]*(x<k);a[-1]+=x,;k=x print`sum(sorted(a),[])`.replace(' ','')

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return top