As the title says.
GNU C++17 (64)
GNU C++17
not only that,
running the first test case in custom invocation:
GNU G++17 ----------> 15000 ms [timed out]
GNU G++14 ----------> 5000 ms
GNU G++11 ----------> 0 ms
GNU G++17 (64) -----> 31 ms
what sorcery is this? help!
adding
#include <cmath>
and changing
while(r <= __lg(k)) {
to
while(r <= log2(k)) {
fixed the problem of TLE. I assume the answer would also be correct but I have not submitted; it does pass the sample, though.
You might want to further research
__lg()
.