Implementation of Byte Pair Encoding