result = []
replacements = [('\\ue000', 'X'), ('is', 'Z')]
s = ''.join([''.join(t) for t in cin])
for f, r in replacements:
    s = s.replace(f, r)
print(s)
How to do Byte Pair Encoding bigram counting and replacements efficiently in Python?