Luke Two by rolf

import sys;l=sys.stdin.readlines();i=0;c=" "
for z in l:
 i+=1;z=`i`+c+z[:-1]
 while z:
  r=len(z);d=(r,z.rfind(c,0,41))[r>40];t=z[:d];z=z[d+1:];a=40-d;b=s=0;p=t.find(c)
  for x in t:b+=x==c   
  for j in [0]*a:
   s+=b
   while s>a:p=t.find(c,p+1);s-=a
   if z:t=t[:p]+c+t[p:];p+=1
  print t

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

download

return top