Optimize the codes of hamming distance manually.