#!ruby -n
i=chomp.unpack"U*"
a=72
b=700
d=-1
$><<:-if 0<h=i.count{|j|putc(j)if j<N=?\x7f}
i.map{|j|j<N&&d+=1
j==N&&(q=d/b
(putc (T+49+(d-=T)%v=36-T)%75+48;d/=v)until d<T=[1,-a-=36,26].sort[1]
putc 97+d
b=2
q+=q/h-=~a=0
q/=35%a+=36while$$<q
a+=36*q/q+=38
d=0)}while i[h]?d-=(~N+N=i.sort[h])*~h-1:puts
Note that non-ascii characters in the above source code will be escaped (such as \x9f).