"""
Perform Run Length Encoding compression on a string.
"""defcompress(raw:str)->bytes:"""
Compress the raw string to bytes using RLE.
"""out:list[int]=[]forbinraw.encode('utf-8'):ifout:byte=out.pop()ifb==byte:count=out.pop()out.append(count+1)out.append(byte)else:out.append(byte)out.append(1)out.append(b)else:out.append(1)out.append(b)returnbytes(out)