when k is large, it would be broken. the reason of this bug is that the type of each element in  encoding_matrix is 'long long', it is not large enough because 2^k is more larger