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


def read_nums():
    return map(int, raw_input().split(' '))


H, W, N = read_nums()
As = [0 for _ in range(N)]
Bs = [0 for _ in range(N)]
vs = []
for i in range(-1, 2):
    for j in range(-1, 2):
        vs.append((i, j))

cnt = []
for i in range(N):
    a, b = read_nums()
    for v in vs:
        i, j = v
        x = a + i
        y = b + j
        if x >= 2 and x <= H-1 and y >= 2 and y <= W-1:
            cnt.append(x * W + y)
cnt = collections.Counter(cnt)
cnt2 = [0] * 10
cnt2[0] = (H - 2) * (W - 2)
for k, v in cnt.items():
    cnt2[v] += 1
    cnt2[0] -= 1
for c in cnt2:
    print c


Fixed submission:
import collections


def read_nums():
    return map(int, raw_input().split(' '))


H, W, N = read_nums()

vs = []
for i in range(-1, 2):
    for j in range(-1, 2):
        vs.append((i, j))

cnt = []
for i in range(N):
    a, b = read_nums()
    for v in vs:
        i, j = v
        x = a + i
        y = b + j
        if x >= 2 and x <= H-1 and y >= 2 and y <= W-1:
            cnt.append(x * W + y)

cnt = collections.Counter(cnt)
cnt2 = [0] * 10
cnt2[0] = (H - 2) * (W - 2)

for k in cnt:
    cnt2[cnt[k]] += 1
    cnt2[0] -= 1

for c in cnt2:
    print c

Buggy python submission (verdict: Time Limit Exceeded):
def read_nums():
    return map(int, raw_input().split(' '))


def is_in_the_map(x, y):
    return x < H-1 and x > 0 and y < W-1 and y > 0


def solve():
    res = [0 for _ in range(10)]
    for i in range(N):
        a = As[i]
        b = Bs[i]
        for j in [-1, 0, 1]:
            for k in [-1, 0, 1]:
                x_mid = a + j
                y_mid = b + k
                if not is_in_the_map(x_mid, y_mid) or memo[x_mid][y_mid] == 1:
                    continue
                memo[x_mid][y_mid] = 1
                count = 0
                for x_pad in [-1, 0, 1]:
                    for y_pad in [-1, 0, 1]:
                        x = x_mid + x_pad
                        y = y_mid + y_pad
                        if Map[x][y] == 1:
                            count += 1
                res[count] += 1
    res[0] = (H-2) * (W-2) - sum(res)
    return res


H, W, N = read_nums()
As = [0 for _ in range(N)]
Bs = [0 for _ in range(N)]
Map = [[0 for _ in range(W)] for _ in range(H)]
for i in range(N):
    a, b = read_nums()
    As[i] = a - 1
    Bs[i] = b - 1
    Map[a - 1][b - 1] = 1
memo = [[0 for _ in range(W)] for _ in range(H)]
res = solve()
for i in res:
    print i

Fixed submission:
import collections


def read_nums():
    return map(int, raw_input().split(' '))


H, W, N = read_nums()

vs = []
for i in range(-1, 2):
    for j in range(-1, 2):
        vs.append((i, j))

cnt = []
for i in range(N):
    a, b = read_nums()
    for v in vs:
        i, j = v
        x = a + i
        y = b + j
        if x >= 2 and x <= H-1 and y >= 2 and y <= W-1:
            cnt.append(x * W + y)

cnt = collections.Counter(cnt)
cnt2 = [0] * 10
cnt2[0] = (H - 2) * (W - 2)

for k in cnt:
    cnt2[cnt[k]] += 1
    cnt2[0] -= 1

for c in cnt2:
    print c

Buggy python submission (verdict: Time Limit Exceeded):
def read_nums():
    return map(int, raw_input().split(' '))


def solve(H,W, Map):
    res = [0 for _ in range(10)]
    for x in range(1, H-1):
        for y in range(1, W-1):
            count = 0
            for i in range(-1, 2):
                for j in range(-1, 2):
                    if Map[x+i][y+j] == 1:
                        count += 1
            res[count] += 1
    return res


H, W, N = read_nums()
As = []
Bs = []
Map = [[0 for _ in range(W)] for _ in range(H)]
for i in range(N):
    a, b = read_nums()
    Map[a-1][b-1] = 1
res = solve(H, W, Map)
for i in res:
    print i


Fixed submission:
import collections


def read_nums():
    return map(int, raw_input().split(' '))


H, W, N = read_nums()

vs = []
for i in range(-1, 2):
    for j in range(-1, 2):
        vs.append((i, j))

cnt = []
for i in range(N):
    a, b = read_nums()
    for v in vs:
        i, j = v
        x = a + i
        y = b + j
        if x >= 2 and x <= H-1 and y >= 2 and y <= W-1:
            cnt.append(x * W + y)

cnt = collections.Counter(cnt)
cnt2 = [0] * 10
cnt2[0] = (H - 2) * (W - 2)

for k in cnt:
    cnt2[cnt[k]] += 1
    cnt2[0] -= 1

for c in cnt2:
    print c