Buggy python submission (verdict: Time Limit Exceeded):
import logging

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
h = logging.FileHandler("logtest.log")
logger.addHandler(h)


N, M = map(int, input().split())
open_list = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    open_list[a].append(b)
    open_list[b].append(a)

logger.info("open_list: {}\n".format(open_list))

# 探索済みリスト
closed_list = [False] * N
closed_list[0] = True
cnt = 0
level = 1

# 深さ優先探索
def dfs(target):
    global cnt, level
    logger.info("***********open_list[target]: {}".format(open_list[target]))
    if all(closed_list):
        cnt += 1
        logger.info("[level: {}] closed_list: {}".format(level, closed_list))
        logger.info("cnt: {}".format(cnt))
        logger.info("*****************************************")
        return
    # open_listリストのnode
    for node in open_list[target]:
        logger.info("node: {}".format(node))
        logger.info("[level: {}] closed_list: {}".format(level, closed_list))
        # 探索済みでない場合
        if closed_list[node] is False:
            # 探索開始
            closed_list[node] = True
            # 再帰
            level += 1
            dfs(node)
            level = 1
            # levalを戻す
            closed_list[node] = False
            logger.info("[level: {}] closed_list: {}".format(level, closed_list))
    return


dfs(0)
print(cnt)


Fixed submission:
# from log import logger

N, M = map(int, input().split())
key_value = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    key_value[a].append(b)
    key_value[b].append(a)

# logger.info('key_value: {}\n'.format(key_value))

closed_list = [False] * N
closed_list[0] = True
cnt = 0


def dfs(target):
    global cnt
    # logger.info('key_value[target]: {}'.format(key_value[target]))
    if all(closed_list):
        cnt += 1
        return
    for node in key_value[target]:
        # logger.info('node: {}'.format(node))
        # 探索済みでない場合
        if closed_list[node] is False:
            closed_list[node] = True
            dfs(node)
            closed_list[node] = False
        # logger.info('closed_list: {}\n'.format(closed_list))
    return


dfs(0)
print(cnt)

Buggy python submission (verdict: Runtime Error):
from log import logger

N, M = map(int, input().split())
key_value = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    key_value[a].append(b)
    key_value[b].append(a)

logger.info('key_value: {}\n'.format(key_value))

closed_list = [False] * N
closed_list[0] = True
cnt = 0


def dfs(target):
    global cnt
    logger.info('key_value[target]: {}'.format(key_value[target]))
    if all(closed_list):
        cnt += 1
        return
    for node in key_value[target]:
        logger.info('node: {}'.format(node))
        # 探索済みでない場合
        if closed_list[node] is False:
            closed_list[node] = True
            dfs(node)
            closed_list[node] = False
        logger.info('closed_list: {}\n'.format(closed_list))
    return


dfs(0)
print(cnt)


Fixed submission:
# from log import logger

N, M = map(int, input().split())
key_value = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    key_value[a].append(b)
    key_value[b].append(a)

# logger.info('key_value: {}\n'.format(key_value))

closed_list = [False] * N
closed_list[0] = True
cnt = 0


def dfs(target):
    global cnt
    # logger.info('key_value[target]: {}'.format(key_value[target]))
    if all(closed_list):
        cnt += 1
        return
    for node in key_value[target]:
        # logger.info('node: {}'.format(node))
        # 探索済みでない場合
        if closed_list[node] is False:
            closed_list[node] = True
            dfs(node)
            closed_list[node] = False
        # logger.info('closed_list: {}\n'.format(closed_list))
    return


dfs(0)
print(cnt)

Buggy python submission (verdict: Runtime Error):
from log import logger

N, M = list(map(int, input().split()))

key_value = {}
for i in range(M):
    a, b = input().split()
    try:
        key_value[a].append(b)
    except KeyError:
        key_value[a] = [b]
    try:
        key_value[b].append(a)
    except KeyError:
        key_value[b] = [a]

logger.info("key_value: {}\n".format(key_value))

"""深さ優先探索: depthFirst
# 初期化
# nodeを展開し，nodeをclosed_listに入れる
# 2つの条件を満たしたら，childrenをopen_listに入れる
# # 1. open_listに同じchildrenがない
# # 2. closedに同じchildrenがない
# 条件を満たせばcntをインクリメントする
"""
# 初期化
node = "1"
# 探索対象
open_list = [node]
# 探索済み
closed_list = []

cnt = 0
while True:
    # for i in range(10):
    logger.info(
        "[before] open_list: {}, closed_list: {}".format(open_list, closed_list)
    )
    if len(open_list) == 0:
        break
    else:
        # 先頭を削除し，探索済みに追加する
        node = open_list[0]
        open_list = open_list[1:]
        closed_list.append(node)
        # 結果の照合
        if sorted(closed_list) == list(map(str, range(1, N + 1))):
            cnt += 1
        else:
            # nodeの展開
            try:
                children = key_value[node]
                for i in range(len(children)):
                    if children[i] not in open_list and children[i] not in closed_list:
                        open_list.append(children[i])
            except KeyError:
                pass
    logger.info(
        "[after] open_list: {}, closed_list: {}\n".format(open_list, closed_list)
    )
print(cnt)


Fixed submission:
# from log import logger

N, M = map(int, input().split())
key_value = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    key_value[a].append(b)
    key_value[b].append(a)

# logger.info('key_value: {}\n'.format(key_value))

closed_list = [False] * N
closed_list[0] = True
cnt = 0


def dfs(target):
    global cnt
    # logger.info('key_value[target]: {}'.format(key_value[target]))
    if all(closed_list):
        cnt += 1
        return
    for node in key_value[target]:
        # logger.info('node: {}'.format(node))
        # 探索済みでない場合
        if closed_list[node] is False:
            closed_list[node] = True
            dfs(node)
            closed_list[node] = False
        # logger.info('closed_list: {}\n'.format(closed_list))
    return


dfs(0)
print(cnt)