j=" ".join i=0 while 1: i+=1;a=[`i`]+raw_input().split() while a: \x09l=a;a=[] \x09while len(j(l))>40:a=[l.pop()]+a \x09s=~-len(l);x=0;o=l[0] \x09for q in l[1:]:x+=40-len(j(l));o+=x/s*" "*(a>[])+" "+q;x%=s \x09print o
Note that non-ascii characters in the above source code will be escaped (such as \x9f).