Buggy python submission (verdict: Runtime Error):
H, W, N = map(int,input().split())
ans = [0] * 10
points = []
MAP = [[0] * W for _ in range(H)]
for _ in range(N):
    a, b = map(int,input().split())
    MAP[a-1][b-1] = 1
    points.append([a-1, b-1])
for i in range(N):
    a, b = points[i]
    for p in range(-1, 2):
        for q in range(-1, 2):
            cnt = 0
            if 1 <= a + p <= H - 2 and 1 <= b + q <= W - 2:
                for h in range(-1, 2):
                    cnt += sum(MAP[a + p + h][b + q - 1: b + q + 2])
            ans[cnt] += 1
for i in range(1,10):
    ans[i] //= i
SUM = sum(ans[1:])
ans[0] = (H-2) * (W-2) - SUM
for i in ans:
    print(i)

Fixed submission:
from collections import defaultdict

H, W, N = map(int,input().split())
d = defaultdict(int)
ta = [1,1,0,-1,-1,-1,0,1,0]
tb = [0,1,1,1,0,-1,-1,-1,0]

for _ in range(N):
    a, b = map(int,input().split())
    for i in range(9):
        na = a + ta[i]
        nb = b + tb[i]
        if 1 <= na <= H and 1 <= nb <= W:
            d[(na, nb)] += 1

ans = [0] * 10

for i, v in d.items():
    if 2 <= i[0] <= H-1 and 2 <= i[1] <= W-1:
        ans[v] += 1

ans[0] = (H-2) * (W-2) - sum(ans)

for i in range(10):
    print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
H, W, N = map(int,input().split())
ans = [0 for _ in range(10)]
points = []
MAP = [[0 for i in range(W)] for j in range(H)]
for _ in range(N):
    a, b = map(int,input().split())
    MAP[a-1][b-1] = 1
    points.append([a-1, b-1])
for i in range(N):
    a, b = points[i]
    for p in range(-1, 2):
        for q in range(-1, 2):
            cnt = 0
            if 1 <= a + p <= H - 2 and 1 <= b + q <= W - 2:
                for h in range(-1, 2):
                    cnt += sum(MAP[a + p + h][b + q - 1: b + q + 2])
            ans[cnt] += 1
for i in range(1,10):
    ans[i] //= i
SUM = sum(ans[1:])
ans[0] = (H-2) * (W-2) - SUM
for i in ans:
    print(i)

Fixed submission:
from collections import defaultdict

H, W, N = map(int,input().split())
d = defaultdict(int)
ta = [1,1,0,-1,-1,-1,0,1,0]
tb = [0,1,1,1,0,-1,-1,-1,0]

for _ in range(N):
    a, b = map(int,input().split())
    for i in range(9):
        na = a + ta[i]
        nb = b + tb[i]
        if 1 <= na <= H and 1 <= nb <= W:
            d[(na, nb)] += 1

ans = [0] * 10

for i, v in d.items():
    if 2 <= i[0] <= H-1 and 2 <= i[1] <= W-1:
        ans[v] += 1

ans[0] = (H-2) * (W-2) - sum(ans)

for i in range(10):
    print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
H, W, N = map(int,input().split())
ans = [0 for _ in range(10)]
points = []
MAP = [[0 for i in range(W)] for j in range(H)]
for _ in range(N):
    a, b = map(int,input().split())
    MAP[a-1][b-1] = 1
    points.append([a-1, b-1])
for i in range(N):
    a, b = points[i]
    for p in range(-1, 2):
        for q in range(-1, 2):
            cnt = 0
            if 1 <= a + p <= H - 2 and 1 <= b + q <= W - 2:
                for h in range(-1, 2):
                    cnt += sum(MAP[a + p + h][b + q - 1: b + q + 2])
            ans[cnt] += 1
for i in range(1,10):
    ans[i] //= i
SUM = sum(ans[1:])
ans[0] = (H-2) * (W-2) - SUM
for i in ans:
    print(i)

Fixed submission:
from collections import defaultdict

H, W, N = map(int,input().split())
d = defaultdict(int)
ta = [1,1,0,-1,-1,-1,0,1,0]
tb = [0,1,1,1,0,-1,-1,-1,0]

for _ in range(N):
    a, b = map(int,input().split())
    for i in range(9):
        na = a + ta[i]
        nb = b + tb[i]
        if 1 <= na <= H and 1 <= nb <= W:
            d[(na, nb)] += 1

ans = [0] * 10

for i, v in d.items():
    if 2 <= i[0] <= H-1 and 2 <= i[1] <= W-1:
        ans[v] += 1

ans[0] = (H-2) * (W-2) - sum(ans)

for i in range(10):
    print(ans[i])