#include <algorithm>
#include <iostream>
#include <set>
#include <stdint.h>
int main() {
const auto n_hashbits = 5;
const auto i_max = 1ull << n_hashbits;
uint64_t min_magic = -1;
for (uint64_t i_b2 = 1; i_b2 < i_max; ++i_b2) {
for (uint64_t i_d2 = 1; i_d2 < i_max; ++i_d2) {
if (i_d2 == i_b2) continue;
for (uint64_t i_e3 = 1; i_e3 < i_max; ++i_e3) {
if (i_e3 == i_d2 || i_e3 == i_b2) continue;
for (uint64_t i_f4 = 1; i_f4 < i_max; ++i_f4) {
if (i_f4 == i_e3 || i_f4 == i_d2 || i_f4 == i_b2) continue;
for (uint64_t i_g5 = 1; i_g5 < i_max; ++i_g5) {
if (i_g5 == i_f4 || i_g5 == i_e3 || i_g5 == i_d2 || i_g5 == i_b2) continue;
uint64_t magic = i_b2 << 50;
magic |= i_d2 << 48;
magic |= i_e3 << 39;
magic |= i_f4 << 30;
magic |= i_g5 << 21;
min_magic = std::min(min_magic, magic);
}
}
}
}
}
std::cout << "Min magic: " << std::hex << min_magic << std::endl;
}
I2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c2V0PgojaW5jbHVkZSA8c3RkaW50Lmg+CgppbnQgbWFpbigpIHsKCWNvbnN0IGF1dG8gbl9oYXNoYml0cyA9IDU7Cgljb25zdCBhdXRvIGlfbWF4ID0gMXVsbCA8PCBuX2hhc2hiaXRzOwoJdWludDY0X3QgbWluX21hZ2ljID0gLTE7CgkKCWZvciAodWludDY0X3QgaV9iMiA9IDE7IGlfYjIgPCBpX21heDsgKytpX2IyKSB7CgkJCgkgIGZvciAodWludDY0X3QgaV9kMiA9IDE7IGlfZDIgPCBpX21heDsgKytpX2QyKSB7CgkgIAlpZiAoaV9kMiA9PSBpX2IyKSBjb250aW51ZTsKCSAgCQoJICAgIGZvciAodWludDY0X3QgaV9lMyA9IDE7IGlfZTMgPCBpX21heDsgKytpX2UzKSB7CgkgICAgICBpZiAoaV9lMyA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