Result [link]

AC

Code [DL]

p/0000a
loop
m/1001a/1100a/1000a/1011a/0111a/1010a/0110a/1001a/0101a/1000a/g
s/a(.)/\1a/g
m/0([01]{4}a)/\1/1([01]{4}a)/0001a\1/
e/a$/
end
s/^0+a//
m/0000a/0/0001a/1/0010a/2/0011a/3/0100a/4/0101a/5/0110a/6/0111a/7/1000a/8/1001a/9/g

stdin

0100101111011100011001110000001000010011101000001010000101101000110100011110101101110010010110100101

stdout

375645213743546080771758826917

stderr

strace