Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque


def solve():
    H, W, N = list(map(int, input().split()))
    # print(H, W, N)

    # 座標は(y, x)
    blacks = {}
    for _ in range(N):
        pos = input().split()
        blacks[(int(pos[0]), int(pos[1]))] = 0

    # print(blacks)

    # [*][*][*]
    # [*][c][*]
    # [*][*][*]
    # ある座標から, それを中心にした9つの座標を返す
    def center_of_boxes_from_point(y, x):
        center_pos_lis = deque()

        for dy in range(-1, 2):
            for dx in range(-1, 2):
                cy = y + dy
                cx = x + dx
                if 1 <= cy <= H and 1 <= cx <= W:
                    center_pos_lis.append((cy, cx))
        return center_pos_lis

    ANS_TABLE = [0 for _ in range(10)]

    # 探索を終了したboxを保存する
    # keyはboxの中心の座標
    done_boxes = {}
    for blk in blacks:
        # print(blk)
        y, x = blk
        boxes = center_of_boxes_from_point(y, x)

        # boxを探索して黒マスをカウントする
        for center_of_box in boxes:
            if center_of_box not in done_boxes:
                y, x = center_of_box
                if 2 <= y < H and 2 <= x < W:
                    count = 0
                    for dy in range(-1, 2):
                        for dx in range(-1, 2):
                            cy = y + dy
                            cx = x + dx
                            if (cy, cx) in blacks:
                                count += 1
                    # print(center_of_box, count)
                    ANS_TABLE[count] += 1
                    done_boxes[center_of_box] = 0

    # print('total boxes', (W - 2) * (H - 2))
    ANS_TABLE[0] = (W - 2) * (H - 2) - sum(ANS_TABLE)

    return ANS_TABLE


if __name__ == '__main__':
    res = solve()
    for r in res:
        print(r)


Fixed submission:
from collections import deque


def solve():
    H, W, N = list(map(int, input().split()))
    # print(H, W, N)

    # 座標は(y, x)
    blacks = {}
    for _ in range(N):
        pos = input().split()
        blacks[(int(pos[0]), int(pos[1]))] = 0

    # print(blacks)

    # [*][*][*]
    # [*][c][*]
    # [*][*][*]
    # ある座標から, それを中心にした9つの座標を返す
    def center_of_boxes_from_point(y, x):
        center_pos_lis = deque()

        for dy in range(-1, 2):
            for dx in range(-1, 2):
                cy = y + dy
                cx = x + dx
                if 1 <= cy <= H and 1 <= cx <= W:
                    center_pos_lis.append((cy, cx))
        return center_pos_lis

    ANS_TABLE = [0 for _ in range(10)]

    # 探索を終了したboxを保存する
    # keyはboxの中心の座標
    done_boxes = {}
    for blk in blacks:
        # print(blk)
        y, x = blk
        boxes = center_of_boxes_from_point(y, x)

        # boxを探索して黒マスをカウントする
        for center_of_box in boxes:
            if center_of_box not in done_boxes:
                y, x = center_of_box
                if 2 <= y < H and 2 <= x < W:
                    count = 0
                    for dy in range(-1, 2):
                        for dx in range(-1, 2):
                            cy = y + dy
                            cx = x + dx
                            if (cy, cx) in blacks:
                                count += 1
                    # print(center_of_box, count)
                    ANS_TABLE[count] += 1
                    done_boxes[center_of_box] = 0

    # print('total boxes', (W - 2) * (H - 2))
    ANS_TABLE[0] = (W - 2) * (H - 2) - sum(ANS_TABLE)

    return ANS_TABLE


if __name__ == '__main__':
    res = solve()
    for r in res:
        print(r)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
import numpy as np


def solve():
    H, W, N = map(int, input().split())
    # print("H, W", H, W)
    # print("N", N)

    blacks = deque()
    for _ in range(N):
        blacks.append(tuple(map(int, input().split())))

    TABLE = deque()
    for _ in range(H + 1):
        TABLE.append(0)

    dx = W
    for pos in blacks:
        x = dx - pos[1]
        y = pos[0]
        # print(y, x)
        TABLE[y] = TABLE[y] | 2**x

    RES_TABLE = [0 for _ in range(10)]
    fLAG_DICT = {0: 0, 1: 1, 2: 1, 3: 2, 4: 1, 5: 2, 6: 2, 7: 3}
    for y in range(1, H + 1, 1):
        if y + 2 > H:
            break

        lis = []
        top_middle_bottom = []
        for y2 in range(y, y + 3):
            line = TABLE[y2]
            lines = []
            for head in range(W - 1, -1, -1):
                tail = (head - 2)
                if tail >= 0:
                    key = line >> tail & 0b111
                    lines.append(fLAG_DICT[key])
            top_middle_bottom.append(np.array(lines))

        total = sum(top_middle_bottom)
        for t in total:
            RES_TABLE[t] += 1

    return RES_TABLE


if __name__ == '__main__':
    res = solve()
    for lis in res:
        print(lis)


Fixed submission:
from collections import deque


def solve():
    H, W, N = list(map(int, input().split()))
    # print(H, W, N)

    # 座標は(y, x)
    blacks = {}
    for _ in range(N):
        pos = input().split()
        blacks[(int(pos[0]), int(pos[1]))] = 0

    # print(blacks)

    # [*][*][*]
    # [*][c][*]
    # [*][*][*]
    # ある座標から, それを中心にした9つの座標を返す
    def center_of_boxes_from_point(y, x):
        center_pos_lis = deque()

        for dy in range(-1, 2):
            for dx in range(-1, 2):
                cy = y + dy
                cx = x + dx
                if 1 <= cy <= H and 1 <= cx <= W:
                    center_pos_lis.append((cy, cx))
        return center_pos_lis

    ANS_TABLE = [0 for _ in range(10)]

    # 探索を終了したboxを保存する
    # keyはboxの中心の座標
    done_boxes = {}
    for blk in blacks:
        # print(blk)
        y, x = blk
        boxes = center_of_boxes_from_point(y, x)

        # boxを探索して黒マスをカウントする
        for center_of_box in boxes:
            if center_of_box not in done_boxes:
                y, x = center_of_box
                if 2 <= y < H and 2 <= x < W:
                    count = 0
                    for dy in range(-1, 2):
                        for dx in range(-1, 2):
                            cy = y + dy
                            cx = x + dx
                            if (cy, cx) in blacks:
                                count += 1
                    # print(center_of_box, count)
                    ANS_TABLE[count] += 1
                    done_boxes[center_of_box] = 0

    # print('total boxes', (W - 2) * (H - 2))
    ANS_TABLE[0] = (W - 2) * (H - 2) - sum(ANS_TABLE)

    return ANS_TABLE


if __name__ == '__main__':
    res = solve()
    for r in res:
        print(r)