count and mask. Build a strictly increasing sequence of count positive integers whose bitwise AND (&) over all elements is exactly mask.
Return the smallest possible value of the last element of such a sequence.count=3, mask=5 → 13
The chain [5, 7, 13] works: 5 & 7 & 13 = 5. No chain ends lower.
count=4, mask=2 → 7
The chain [2, 3, 6, 7]: every number has the bit 2 and no other bit is shared by all of them.
count=1, mask=6 → 6
count=3, mask=5
13
Run checks the first 3 tests in your browser. Submit checks all 106 tests on the server, hidden ones included.