Buggy python submission (verdict: Runtime Error):
class dllist:

    def __init__(self):
        self._list = []
        self._fp = 0
        self._bp = 0

    def insert(self, x):
        self._list.append(x)
        self._fp += 1

    def delete(self, x):
        t = self._list[::-1]
        if x in t[:-self._bp]:
            self._list.remove(x)
            self._fp -= 1

    def deleteFirst(self):
        self._list.pop()

    def deleteLast(self):
        self._bp += 1

    def disp(self):
        print(" ".join([str(x) for x in self._list[self._bp:][::-1]]))


if __name__ == '__main__':

    q = dllist()

    n = int(input())

    for _ in range(n):
        inst = input().split()

        if inst[0] == "insert":
            q.insert(int(inst[1]))
        elif inst[0] == "delete":
            q.delete(int(inst[1]))
        elif inst[0] == "deleteFirst":
            q.deleteFirst()
        elif inst[0] == "deleteLast":
            q.deleteLast()

    q.disp()


Fixed submission:
def check(aline):
    pools = []
    leftedge = []

    for i, c in enumerate(aline):
        if c == "\\":
            leftedge.append(i)
        elif c == "_":
            pass
        else:
            if leftedge:
                left = leftedge.pop()
                w = i - left

                while pools and left < pools[-1][0]:
                    w += pools.pop()[1]

                pools.append((left, w))

    return pools


if __name__ == '__main__':

    al = input().strip()
    ps = check(al)

    print(sum([x[1] for x in ps]))
    print(len(ps), *[x[1] for x in ps])

Buggy python submission (verdict: Time Limit Exceeded):
def decode():
    s = input()

    m = [0]
    h = 0
    for c in s:
        if c == "\\":
            h -= 1
        elif c == "_":
            pass
        else:
            h += 1

        m.append(h)

    return m


def checkwater(m, left):
    if m[left] <= m[left+1]:
        return False, 0, 0
    else:
        left_h = m[left]
        water = 0
        r = left + 1
        while r < len(m):
            if m[r] == m[r-1]:
                water += left_h - m[r]
            elif m[r] <= m[r-1]:
                water += left_h - m[r] - 0.5
            else:
                water += left_h - m[r] + 0.5

            if m[r] == left_h:
                return True, r, water

            r += 1

        return False, 0, 0


if __name__ == '__main__':

    def t():
        m = decode()
        print(m)
        left = int(input())
        result, r, water = checkwater(m, left)
        print(result, r, water)


    def main():
        m = decode()

        wlist = []
        left = 0
        while left < len(m) - 1:
            result, r, water = checkwater(m, left)
            if result:
                wlist.append(water)
                left = r
            else:
                left += 1

        print(int(sum(wlist)))
        wlist.insert(0, len(wlist))
        print(" ".join([str(int(x)) for x in wlist]))

    main()


Fixed submission:
def check(aline):
    pools = []
    leftedge = []

    for i, c in enumerate(aline):
        if c == "\\":
            leftedge.append(i)
        elif c == "_":
            pass
        else:
            if leftedge:
                left = leftedge.pop()
                w = i - left

                while pools and left < pools[-1][0]:
                    w += pools.pop()[1]

                pools.append((left, w))

    return pools


if __name__ == '__main__':

    al = input().strip()
    ps = check(al)

    print(sum([x[1] for x in ps]))
    print(len(ps), *[x[1] for x in ps])