def encode(x):
    """
    Encode the integer `x` using a 7-bit+continuation-bit encoding,
    and return the list of 8-bit code words.
    """
    r = []
    while True:
        r.append(x & 127)
        x >>= 7
        if x == 0:
            break
    r = r[::-1]
    n = len(r) - 1
    i = 0
    while i < n:
        r[i] |= 128
        i += 1
    return r
