#include <assert.h>
unsigned int mod_power_of_two(unsigned int a, unsigned int b)
{
//assert(b && (b & (b - 1)) == 0);
return a & (b - 1);
}
unsigned int mod(unsigned int a, unsigned int b)
{
return a % b;
}
int main()
{
assert(mod_power_of_two
(17, 1) == mod
(17, 1)); assert(mod_power_of_two
(17, 2) == mod
(17, 2)); assert(mod_power_of_two
(17, 4) == mod
(17, 4)); assert(mod_power_of_two
(17, 8) == mod
(17, 8)); return 0;
}
I2luY2x1ZGUgPGFzc2VydC5oPgoKdW5zaWduZWQgaW50IG1vZF9wb3dlcl9vZl90d28odW5zaWduZWQgaW50IGEsIHVuc2lnbmVkIGludCBiKQp7CiAgLy9hc3NlcnQoYiAmJiAoYiAmIChiIC0gMSkpID09IDApOwogIHJldHVybiBhICYgKGIgLSAxKTsKfQoKdW5zaWduZWQgaW50IG1vZCh1bnNpZ25lZCBpbnQgYSwgdW5zaWduZWQgaW50IGIpCnsKICByZXR1cm4gYSAlIGI7Cn0KCmludCBtYWluKCkKewogIGFzc2VydChtb2RfcG93ZXJfb2ZfdHdvKDE3LCAxKSA9PSBtb2QoMTcsIDEpKTsKICBhc3NlcnQobW9kX3Bvd2VyX29mX3R3bygxNywgMikgPT0gbW9kKDE3LCAyKSk7CiAgYXNzZXJ0KG1vZF9wb3dlcl9vZl90d28oMTcsIDQpID09IG1vZCgxNywgNCkpOwogIGFzc2VydChtb2RfcG93ZXJfb2ZfdHdvKDE3LCA4KSA9PSBtb2QoMTcsIDgpKTsKICByZXR1cm4gMDsKfQ==