- This is a state-of-the-art entropy encoder. Bits are compressed to the extent they are predictable.
- Each input bit is encoded using a probability: Before the bit was observed, how likely was it to be 1?
- 0 <= probability1 <= 65535 (0 denotes a probability near 0 and 65535 denotes a probability near 1)
- For each bit, this code splits a numeric range (from lo to hi, inclusive) according to probability1.
- The observed bit (is1) selects one side of that split to be the new numeric range (updating lo or hi).
- If the observed bit is likely, the range narrows less. If it is unlikely, the range narrows more.
- Both sides of the split always contain at least one number. If lo becomes equal to hi, that is ok.
- When the most-significant byte of lo matches the most-significant byte of hi, that byte is emitted.
- Once all the input bits have been encoded, the remaining bytes of lo are emitted.

To receive a hint, submit unfixed code.