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

h, w, n = map(int, input().split())
pos = collections.defaultdict(lambda: collections.defaultdict(bool))
squares = collections.defaultdict(lambda: collections.defaultdict(bool))
for index in range(n):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    pos[a][b] = True
    for i in range(-2, 1):
        for j in range(-2, 1):
            y = a + i
            x = b + j
            if 0 <= x < w - 2 and 0 <= y < h - 2:
                squares[y][x] = True
counter = collections.Counter()
for y, xs in squares.items():
    for x in xs:
        count = 0
        for i in range(3):
            for j in range(3):
                if pos[y + i][x + j]:
                    count += 1
        counter[count] += 1
print((h - 2) * (w - 2) - sum(counter.values()))
for i in range(1, 10):
    print(counter[i])

Fixed submission:
import collections

h, w, n = map(int, input().split())
squares = collections.defaultdict(lambda: collections.defaultdict(int))
for index in range(n):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    for i in range(-2, 1):
        for j in range(-2, 1):
            y = a + i
            x = b + j
            if 0 <= x < w - 2 and 0 <= y < h - 2:
                squares[y][x] += 1
counter = collections.Counter()
for y, xs in squares.items():
    for x, count in xs.items():
        counter[count] += 1
print((h - 2) * (w - 2) - sum(counter.values()))
for i in range(1, 10):
    print(counter[i])

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

h, w, n = map(int, input().split())
pos = collections.defaultdict(lambda: collections.defaultdict(bool))
squares = set()
for index in range(n):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    pos[a][b] = True
    for i in range(-2, 1):
        for j in range(-2, 1):
            y = a + i
            x = b + j
            if 0 <= x < w - 2 and 0 <= y < h - 2:
                squares.add((y, x))
counter = collections.Counter()
for y, x in squares:
    count = 0
    for i in range(3):
        for j in range(3):
            if pos[y + i][x + j]:
                count += 1
    counter[count] += 1
print((h - 2) * (w - 2) - sum(counter.values()))
for i in range(1, 10):
    print(counter[i])

Fixed submission:
import collections

h, w, n = map(int, input().split())
squares = collections.defaultdict(lambda: collections.defaultdict(int))
for index in range(n):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    for i in range(-2, 1):
        for j in range(-2, 1):
            y = a + i
            x = b + j
            if 0 <= x < w - 2 and 0 <= y < h - 2:
                squares[y][x] += 1
counter = collections.Counter()
for y, xs in squares.items():
    for x, count in xs.items():
        counter[count] += 1
print((h - 2) * (w - 2) - sum(counter.values()))
for i in range(1, 10):
    print(counter[i])

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

h, w, n = map(int, input().split())
pos = collections.defaultdict(lambda: collections.defaultdict(bool))
squares = set()
for index in range(n):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    pos[a][b] = True
    for i in range(-2, 1):
        for j in range(-2, 1):
            y = a + i
            x = b + j
            if 0 <= x < w - 2 and 0 <= y < h - 2:
                squares.add((y, x))
counter = collections.Counter()
for y, x in squares:
    count = 0
    for i in range(3):
        for j in range(3):
            if pos[y + i][x + j]:
                count += 1
    counter[count] += 1
print((h - 2) * (w - 2) - sum(counter.values()))
for i in range(1, 10):
    print(counter[i])

Fixed submission:
import collections

h, w, n = map(int, input().split())
squares = collections.defaultdict(lambda: collections.defaultdict(int))
for index in range(n):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    for i in range(-2, 1):
        for j in range(-2, 1):
            y = a + i
            x = b + j
            if 0 <= x < w - 2 and 0 <= y < h - 2:
                squares[y][x] += 1
counter = collections.Counter()
for y, xs in squares.items():
    for x, count in xs.items():
        counter[count] += 1
print((h - 2) * (w - 2) - sum(counter.values()))
for i in range(1, 10):
    print(counter[i])