Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

H, W, N = map(int, input().split())
cand = set()
dot = set()
for _ in range(N):
    x, y = map(int, input().split())
    dot.add((x, y))
    for i in range(-2, 1):
        if 1 <= x + i <= H - 2:
            for j in range(-2, 1):
                if 1 <= y + j <= W - 2:
                    cand.add((x + i, y + j))

ans = [0] * 10
for x, y in cand:
    cnt = 0
    for i in range(3):
        for j in range(3):
            cnt += int((x + i, y + j) in dot)
    ans[cnt] += 1

zero = (H - 2) * (W - 2) - sum(ans)
ans[0] = zero
print(*ans, sep="\n")

Fixed submission:
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

H, W, N = map(int, input().split())
cand = set()
dot = set()
for _ in range(N):
    x, y = map(int, input().split())
    dot.add((x, y))
    for i in range(-2, 1):
        if 1 <= x + i <= H - 2:
            for j in range(-2, 1):
                if 1 <= y + j <= W - 2:
                    cand.add((x + i, y + j))

ans = [0] * 10
for x, y in cand:
    cnt = 0
    for i in range(3):
        for j in range(3):
            cnt += int((x + i, y + j) in dot)
    ans[cnt] += 1

zero = (H - 2) * (W - 2) - sum(ans)
ans[0] = zero
print(*ans, sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

H, W, N = map(int, input().split())
xy = []
dot = defaultdict(int)
seen = defaultdict(bool)
for _ in range(N):
    a, b = map(int, input().split())
    xy.append((a, b))
    dot[(a, b)] = 1

ans = [0] * 10
for x, y in xy:
    for dx in [-2, -1, 0]:
        for dy in [-2, -1, 0]:
            nx = x + dx
            ny = y + dy
            if seen[(nx, ny)] or nx <= 0 or nx + 2 > H or ny <= 0 or ny + 2 > W:
                continue
            seen[(nx, ny)] = True
            cnt = 0
            for i in range(3):
                for j in range(3):
                    cnt += int(dot[(nx + i, ny + j)])
            ans[cnt] += 1

zero = (H - 2) * (W - 2) - sum(ans)
ans[0] = zero
print(*ans, sep="\n")

Fixed submission:
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

H, W, N = map(int, input().split())
cand = set()
dot = set()
for _ in range(N):
    x, y = map(int, input().split())
    dot.add((x, y))
    for i in range(-2, 1):
        if 1 <= x + i <= H - 2:
            for j in range(-2, 1):
                if 1 <= y + j <= W - 2:
                    cand.add((x + i, y + j))

ans = [0] * 10
for x, y in cand:
    cnt = 0
    for i in range(3):
        for j in range(3):
            cnt += int((x + i, y + j) in dot)
    ans[cnt] += 1

zero = (H - 2) * (W - 2) - sum(ans)
ans[0] = zero
print(*ans, sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

H, W, N = map(int, input().split())
xy = []
dot = defaultdict(int)
seen = defaultdict(bool)
for _ in range(N):
    a, b = map(int, input().split())
    xy.append((a, b))
    dot[(a, b)] = 1

ans = [0] * 10
for x, y in xy:
    for dx in [-2, -1, 0]:
        for dy in [-2, -1, 0]:
            nx = x + dx
            ny = y + dy
            if seen[(nx, ny)] or nx <= 0 or nx + 2 > H or ny <= 0 or ny + 2 > W:
                continue
            seen[(nx, ny)] = True
            cnt = 0
            for i in range(3):
                for j in range(3):
                    cnt += int(dot[(nx + i, ny + j)])
            ans[cnt] += 1

zero = (H - 2) * (W - 2) - sum(ans)
ans[0] = zero
print(*ans, sep="\n")

Fixed submission:
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

H, W, N = map(int, input().split())
cand = set()
dot = set()
for _ in range(N):
    x, y = map(int, input().split())
    dot.add((x, y))
    for i in range(-2, 1):
        if 1 <= x + i <= H - 2:
            for j in range(-2, 1):
                if 1 <= y + j <= W - 2:
                    cand.add((x + i, y + j))

ans = [0] * 10
for x, y in cand:
    cnt = 0
    for i in range(3):
        for j in range(3):
            cnt += int((x + i, y + j) in dot)
    ans[cnt] += 1

zero = (H - 2) * (W - 2) - sum(ans)
ans[0] = zero
print(*ans, sep="\n")