Result [link]

AC

Code [DL]

^
0000a
{`1001a
1100a
1000a
1011a
0111a
1010a
0110a
1001a
0101a
1000a
a(.)
$1a
0([01]{4}a)
$1
1([01]{4}a)
0001a$1
a$
b
}+`a(.+b)
b$1
^0+b

0000b
0
0001b
1
0010b
2
0011b
3
0100b
4
0101b
5
0110b
6
0111b
7
1000b
8
1001b
9

stdin

1010010100000001010011100101010001011110111100001111000110001101110010110000100000011110110010000110

stdout

817065687156719206687477722246

stderr

strace