BWT by murky-satyr

for(;s=readline(a=[o='']);print(a.indexOf(s),o)){for(i in s)a[i]=(s+s).substr(i,s[-1])
for([,x]in a.sort())o+=x[i]}

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

download

return top