Buggy python submission (verdict: Runtime Error):

def dfs(hands, pair):
    hands.sort()

    if not hands:
        return True
    target = hands[0]
    # sequence
    if all(map(lambda x: x in hands, range(target, target + 3))):
        for i in range(target, target + 3):
            hands.remove(i)
        if dfs(hands, pair):
            return True
        for i in range(target, target + 3):
            hands.append(i)
    # triple
    if hands.count(target) >= 3:
        for i in range(3):
            hands.remove(target)
        if dfs(hands, pair):
            return True
        for i in range(3):
            hands.append(target)
    # pair
    if not pair and hands.count(target) >= 2:
        for i in range(2):
            hands.remove(target)
        if dfs(hands, True):
            return True
        for i in range(2):
            hands.append(target)
    return False

for line in filter(lambda line: line.strip(), open("input.txt").readlines()):
    result = []
    data = [int(ch) for ch in line.strip()]
    for num in filter(lambda x: data.count(x) < 4, range(1, 10)):
        data_cp = list(data)
        data_cp.append(num)
        data_cp.sort()
        if dfs(data_cp, False):
            result.append(num)
    print result

Fixed submission:
import sys

def dfs(hands, pair):
    hands.sort()

    if not hands:
        return True
    target = hands[0]
    # sequence
    if all(map(lambda x: x in hands, range(target, target + 3))):
        for i in range(target, target + 3):
            hands.remove(i)
        if dfs(hands, pair):
            return True
        for i in range(target, target + 3):
            hands.append(i)
    # triple
    if hands.count(target) >= 3:
        for i in range(3):
            hands.remove(target)
        if dfs(hands, pair):
            return True
        for i in range(3):
            hands.append(target)
    # pair
    if not pair and hands.count(target) >= 2:
        for i in range(2):
            hands.remove(target)
        if dfs(hands, True):
            return True
        for i in range(2):
            hands.append(target)
    return False

for line in filter(lambda line: line.strip(), sys.stdin.readlines()):
    result = []
    data = [int(ch) for ch in line.strip()]
    for num in filter(lambda x: data.count(x) < 4, range(1, 10)):
        data_cp = list(data)
        data_cp.append(num)
        data_cp.sort()
        if dfs(data_cp, False):
            result.append(num)
    if result:
        print " ".join(map(str, result))
    else:
        print 0

Buggy python submission (verdict: Runtime Error):

def dfs(hands, pair):
    hands.sort()

    if not hands:
        return True
    target = hands[0]
    # sequence
    if all(map(lambda x: x in hands, range(target, target + 3))):
        for i in range(target, target + 3):
            hands.remove(i)
        if dfs(hands, pair):
            return True
        for i in range(target, target + 3):
            hands.append(i)
    # triple
    if hands.count(target) >= 3:
        for i in range(3):
            hands.remove(target)
        if dfs(hands, pair):
            return True
        for i in range(3):
            hands.append(target)
    # pair
    if not pair and hands.count(target) >= 2:
        for i in range(2):
            hands.remove(target)
        if dfs(hands, True):
            return True
        for i in range(2):
            hands.append(target)
    return False

for line in filter(lambda line: line.strip(), stdin.readlines()):
    result = []
    data = [int(ch) for ch in line.strip()]
    for num in filter(lambda x: data.count(x) < 4, range(1, 10)):
        data_cp = list(data)
        data_cp.append(num)
        data_cp.sort()
        if dfs(data_cp, False):
            result.append(num)
    print " ".join(result)

Fixed submission:
import sys

def dfs(hands, pair):
    hands.sort()

    if not hands:
        return True
    target = hands[0]
    # sequence
    if all(map(lambda x: x in hands, range(target, target + 3))):
        for i in range(target, target + 3):
            hands.remove(i)
        if dfs(hands, pair):
            return True
        for i in range(target, target + 3):
            hands.append(i)
    # triple
    if hands.count(target) >= 3:
        for i in range(3):
            hands.remove(target)
        if dfs(hands, pair):
            return True
        for i in range(3):
            hands.append(target)
    # pair
    if not pair and hands.count(target) >= 2:
        for i in range(2):
            hands.remove(target)
        if dfs(hands, True):
            return True
        for i in range(2):
            hands.append(target)
    return False

for line in filter(lambda line: line.strip(), sys.stdin.readlines()):
    result = []
    data = [int(ch) for ch in line.strip()]
    for num in filter(lambda x: data.count(x) < 4, range(1, 10)):
        data_cp = list(data)
        data_cp.append(num)
        data_cp.sort()
        if dfs(data_cp, False):
            result.append(num)
    if result:
        print " ".join(map(str, result))
    else:
        print 0