qyliang/CodeNanoFix huggingface dataset:
Buggy code:
inp=input().split(" ")
H=int(inp[0])
W=int(inp[1])
N=int(inp[2])
square=[]
plot=[]
times=[0 for i in range(10)]
times[0]=(H-2)*(W-2)
from collections import defaultdict
count=defaultdict(lambda:0)
def check(a,b,count):
    for i in range(3):
        for j in range(3):
            if a-i>=0 and b-j>=0 and a+2-i<=H-1 and b+2-j<=W-1:
                count[str([a-i,b-j])]+=1
for i in range(N):
    plot.append(list(map(int,input().split(" "))))
    check(plot[i][0]-1,plot[i][1]-1,square)
for i in count.values():
    times[i]+=1
    times[0]-=1
for i in range(len(times)):
    print(times[i])

Fixed code:
inp=input().split(" ")
H=int(inp[0])
W=int(inp[1])
N=int(inp[2])
plot=[]
times=[0 for i in range(10)]
times[0]=(H-2)*(W-2)
from collections import defaultdict
count=defaultdict(lambda:0)
def check(a,b,count):
    for i in range(3):
        for j in range(3):
            if a-i>=0 and b-j>=0 and a+2-i<=H-1 and b+2-j<=W-1:
                count[str([a-i,b-j])]+=1
for i in range(N):
    plot.append(list(map(int,input().split(" "))))
    check(plot[i][0]-1,plot[i][1]-1,count)
for i in count.values():
    times[i]+=1
    times[0]-=1
for i in range(len(times)):
    print(times[i])
Buggy code:
from collections import Counter, defaultdict

ans = defaultdict(lambda: 0)
h, w, n = map(int, input().split())
for _ in range(n):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    for a_i in range(a - 2, a + 1):
        for b_i in range(b - 2, b + 1):
            if (0 <= a_i < h - 2) & (0 <= b_i < w - 2):
                ans[(a_i, b_i)] += 1

k = Counter(ans.values())
for i in range(10):
    if i in k.keys():
        print(k[i])
    else:
        print(0)

Fixed code:
from collections import Counter, defaultdict

ans = defaultdict(lambda: 0)
h, w, n = map(int, input().split())
for _ in range(n):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    for a_i in range(a - 2, a + 1):
        for b_i in range(b - 2, b + 1):
            if (0 <= a_i < h - 2) & (0 <= b_i < w - 2):
                ans[(a_i, b_i)] += 1

k = Counter(ans.values())
print((h - 2) * (w - 2) - sum(k.values()))
for i in range(1, 10):
    if i in k.keys():
        print(k[i])
    else:
        print(0)
Buggy code:
from collections import defaultdict as de
from collections import Counter as C
h,w,n=map(int,input().split())
s=[0]*10
c=de(int)
for i in range(n):
    a,b=map(int,input().split())
    for j in range(max(2,a-1),min(a+2,h)):
        for q in range(max(2,b-1),min(b+2,w)):
            c[(j,q)]+=1
a=C(c.values())
print((h-8)*(w-8)-sum(a.values()))
for i in range(1,10):
    print(a[i])

Fixed code:
from collections import defaultdict as de
from collections import Counter as C
h,w,n=map(int,input().split())
s=[0]*10
c=de(int)
for i in range(n):
    a,b=map(int,input().split())
    for j in range(max(2,a-1),min(a+2,h)):
        for q in range(max(2,b-1),min(b+2,w)):
            c[(j,q)]+=1
a=C(c.values())
print((h-2)*(w-2)-sum(a.values()))
for i in range(1,10):
    print(a[i])
Buggy code:
h,w,n=map(int,input().split())
ab=[list(map(int,input().split())) for _ in [0]*n]
ab_d={a*(10**9)+b-1 for a,b in ab}

ans=[set() for _ in range(9)]
for a,b in ab:
    temp=[None for _ in [0]*25]
    for p in range(25):
        i,j=p//5,p%5
        if 0<a+i-2<=h and 0<b+j-2<=w:
            if (a+i-2)*(10**9)+b+j-3 in ab_d:
                temp[i*5+j]=1
            else:
                temp[i*5+j]=0
    for p in range(3):
        i,j=p//3,p%3
        cnt=[temp[(i+k)*5+j+l] for k in range(3) for l in range(3)]
        if None not in cnt:
            ans[sum(cnt)-1].add((a+i-2)*(10**9)+b+j-3)
                
ans=[len(ans[i]) for i in range(9)]

print((h-2)*(w-2)-sum(ans))
for i in ans:
    print(i)

Fixed code:
h,w,n=map(int,input().split())
ab=[list(map(int,input().split())) for _ in [0]*n]
ab_d={a*(10**9)+b-1 for a,b in ab}

ans=[set() for _ in range(9)]
for a,b in ab:
    temp=[None for _ in [0]*25]
    for i in range(5):
        for j in range(5):
            if 0<a+i-2<=h and 0<b+j-2<=w:
                if (a+i-2)*(10**9)+b+j-3 in ab_d:
                    temp[i*5+j]=1
                else:
                    temp[i*5+j]=0
    for i in range(3):
        for j in range(3):
            cnt=[temp[(i+k)*5+j+l] for k in range(3) for l in range(3)]
            if None not in cnt:
                ans[sum(cnt)-1].add((a+i-2)*(10**9)+b+j-3)
                
for i in range(9):
    ans[i]=len(ans[i])

print((h-2)*(w-2)-sum(ans))
for i in ans:
    print(i)
Buggy code:
from collections import defaultdict


def read_input():
    h, w, n = map(int, input().split())
    alist = []
    for i in range(n):
        (px, py) = map(int, input().split())
        alist.append((px, py))

    return h, w, n, alist


def count_arround(px, py, count):
    for xx in [-2, -1, 0]:
        for yy in [-2, -1, 0]:
            count[(px+xx, py+yy)] += 1


def is_area(p, h, w):
    if 1 <= p[0] <= h - 2:
        if 1 <= p[1] <= w - 2:
            return True
    return False


def submit():
    h, w, n, alist = read_input()

    count = defaultdict(int)

    for a in alist:
        count_arround(a[0], a[1], count)

    counts = count.items()
    counts = [c[1] for c in counts if is_area(c[0], h, w)]

    for i in range(10):
        print(sum([1 for c in counts if c == i]))


if __name__ == '__main__':
    submit()

Fixed code:
from collections import defaultdict


def read_input():
    h, w, n = map(int, input().split())
    alist = []
    for i in range(n):
        (px, py) = map(int, input().split())
        alist.append((px, py))

    return h, w, n, alist


def count_arround(px, py, count):
    for xx in [-2, -1, 0]:
        for yy in [-2, -1, 0]:
            count[(px+xx, py+yy)] += 1


def is_area(p, h, w):
    if 1 <= p[0] <= h - 2:
        if 1 <= p[1] <= w - 2:
            return True
    return False


def submit():
    h, w, n, alist = read_input()

    count = defaultdict(int)

    for a in alist:
        count_arround(a[0], a[1], count)

    counts = count.items()
    counts = [c[1] for c in counts if is_area(c[0], h, w)]

    result = []
    s = 0
    for i in range(1, 10):
        result.append(sum([1 for c in counts if c == i]))
        s += result[-1]

    print((h - 2)*(w - 2) - s)
    for r in result:
        print(r)


if __name__ == '__main__':
    submit()
Buggy code:
from collections import defaultdict
H, W, N = map(int, input().split())
A = defaultdict(int)

for i in range(N):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    for j in range(-1, 2):
        for k in range(-1, 2):
            if 1 <= a + j < H - 1 and 1 <= b + k < W - 1:
                A[(a + j, b + k)] += 1
                
for i in range(10):
    cnt = 0
    for v in A.values():
        if v == i:
            cnt += 1
    print(cnt)

Fixed code:
from collections import defaultdict
H, W, N = map(int, input().split())
A = defaultdict(int)

for i in range(N):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    for j in range(-1, 2):
        for k in range(-1, 2):
            if 1 <= a + j < H - 1 and 1 <= b + k < W - 1:
                A[(a + j, b + k)] += 1
                
print((H - 2) * (W - 2) - len(A))
                
for i in range(1, 10):
    cnt = 0
    for v in A.values():
        if v == i:
            cnt += 1
    print(cnt)
Buggy code:
# -*- coding: utf-8 -*-
import sys

def main():
	H, W, N = map(int, input().split(" "))
	AB = []
	for _ in range(N):
		a, b = map(int, input().split(" "))
		AB.append((a, b))

	ans = {}
	for i, val in enumerate(AB):
		a, b = val
		a, b = a-1, b-1
		for ba in range(max(0, a-2), min(H-2, a+1)):
			for bb in range(max(0, b-2), min(W-2, b+1)):
				if (ba, bb) in ans.keys():
					ans[(ba, bb)] += 1
				else:
					ans[(ba, bb)] = 1
				if bb == 3:
					print("{} {}".format(a+1, b+1))

	ans2 = [0] * 10
	total = (H-2) * (W-2)
	t = 0
	print(ans)
	for i in ans.values():
		ans2[i] += 1
		t += 1
	ans2[0] = total - t
	for i in range(10):
		print(ans2[i])

if __name__ == "__main__":
	main()


Fixed code:
# -*- coding: utf-8 -*-
import sys

def main():
	H, W, N = map(int, input().split(" "))
	AB = []
	for _ in range(N):
		a, b = map(int, input().split(" "))
		AB.append((a, b))

	ans = {}
	for i, val in enumerate(AB):
		a, b = val
		a, b = a-1, b-1
		for ba in range(max(0, a-2), min(H-2, a+1)):
			for bb in range(max(0, b-2), min(W-2, b+1)):
				if (ba, bb) in ans.keys():
					ans[(ba, bb)] += 1
				else:
					ans[(ba, bb)] = 1

	ans2 = [0] * 10
	total = (H-2) * (W-2)
	t = 0
	for i in ans.values():
		ans2[i] += 1
		t += 1
	ans2[0] = total - t
	for i in range(10):
		print(ans2[i])

if __name__ == "__main__":
	main()
Buggy code:
h,w,n = map(int,input().split())
coord = [list(map(int,input().split())) for i in range(n)]

num = {}

for i in range(n):
  for j,k in [[0,0],[0,1],[0,-1],[1,0],[1,1],[1,-1],[-1,0],[-1,1],[-1,-1]]:
    if not(2<=coord[i][0]+j<=h-1) or not(2<=coord[i][1]+k<=w-1):
      continue
    if not coord[i][0]+j in num:
      num[coord[i][0]+j] = {}
    if not coord[i][1]+k in num[coord[i][0]+j]:
      num[coord[i][0]+j][coord[i][1]+k] = 1
    else:
      num[coord[i][0]+j][coord[i][1]+k] += 1

ans = [0]*9
for i in num:
  for value in num[i].values():
    ans[value] +=1

print((h-2)*(w-2)-sum(ans))
for i in range(1,9):
  print(ans[i])

Fixed code:
h,w,n = map(int,input().split())
coord = [list(map(int,input().split())) for i in range(n)]

num = {}

for i in range(n):
  for j,k in [[0,0],[0,1],[0,-1],[1,0],[1,1],[1,-1],[-1,0],[-1,1],[-1,-1]]:
    if not(2<=coord[i][0]+j<=h-1) or not(2<=coord[i][1]+k<=w-1):
      continue
    if not coord[i][0]+j in num:
      num[coord[i][0]+j] = {}
    if not coord[i][1]+k in num[coord[i][0]+j]:
      num[coord[i][0]+j][coord[i][1]+k] = 1
    else:
      num[coord[i][0]+j][coord[i][1]+k] += 1

ans = [0]*10
for i in num:
  for value in num[i].values():
    ans[value] +=1

print((h-2)*(w-2)-sum(ans))
for i in range(1,10):
  print(ans[i])
Buggy code:
from collections import defaultdict
h,w,n = map(int,input().split())
x = []
for i in range(n):
  x.append(list(map(int,input().split())))
d = defaultdict(int)
for i in x:
  a = []
  for j in range(3):
    for k in range(3):
      if (i[0]-j-1>=0 and i[1]-k-1 >= 0 and i[0]-j-1<=h-3 and i[1]-k-1 <= w-3):
        a.append((i[0]-j-1,i[1]-k-1))
  for j in a:
    d[j] += 1
a = list(d.values())
ans = [0]*9
ans[0] = (h-2)*(w-2)-len(a)
for i in a:
  ans[i-1] += 1
for i in ans:
  print(i)

Fixed code:
from collections import defaultdict
h,w,n = map(int,input().split())
x = []
for i in range(n):
  x.append(list(map(int,input().split())))
d = defaultdict(int)
for i in x:
  a = []
  for j in range(3):
    for k in range(3):
      if (i[0]-j-1>=0 and i[1]-k-1 >= 0 and i[0]-j-1<=h-3 and i[1]-k-1 <= w-3):
        a.append((i[0]-j-1,i[1]-k-1))
  for j in a:
    d[j] += 1
a = list(d.values())
ans = [0]*10
ans[0] = (h-2)*(w-2)-len(a)
for i in a:
  ans[i] += 1
for i in ans:
  print(i)
Buggy code:
from collections import Counter
H,W,N = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(N)]

blacks = Counter()
for y,x in src:
    for i in range(-1,2):
        if not 0 <= y+i < H: continue
        for j in range(-1,2):
            if not 0 <= x+j < W: continue
            blacks[(x+j, y+i)] += 1

ans = [0] * 10
for (x,y),v in blacks.items():
    if x<2 or y<2: continue
    ans[v] += 1
print(*ans,sep='\n')

Fixed code:
from collections import Counter
H,W,N = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(N)]

blacks = Counter()
for y,x in src:
    for i in range(-1,2):
        if not 0 <= y+i < H: continue
        for j in range(-1,2):
            if not 0 <= x+j < W: continue
            blacks[(x+j, y+i)] += 1

ans = [0] * 10
for (x,y),v in blacks.items():
    if x<2 or y<2: continue
    ans[v] += 1
ans[0] = (H-2)*(W-2) - sum(ans[1:])
print(*ans,sep='\n')
Buggy code:
from collections import Counter, defaultdict
from itertools import product

H, W, N = map(int, input().split())

c = defaultdict(int)
for _ in range(N):
    a, b = map(int, input().split())
    for dx, dy in product([-1, 0, 1], repeat=2):
        y = a - 2 + dy
        x = b - 2 + dx
        if 0 <= y < H - 2 and 0 <= x < W - 2:
            c[(x, y)] += 1

ans = Counter(c.values())
for i in range(10):
    print(ans[i])

Fixed code:
from collections import Counter, defaultdict
from itertools import product

H, W, N = map(int, input().split())

c = defaultdict(int)
for _ in range(N):
    a, b = map(int, input().split())
    for dx, dy in product([-1, 0, 1], repeat=2):
        y = a - 2 + dy
        x = b - 2 + dx
        if 0 <= y < H - 2 and 0 <= x < W - 2:
            c[(x, y)] += 1

ans = Counter(c.values())
print((H - 2) * (W - 2) - sum(ans.values()))
for i in range(1, 10):
    print(ans[i])
Buggy code:
H, W, N = (int(i) for i in input().split())

P = []
for i in range(N):
    pa, pb = input().split()
    P.append((int(pa)-1, int(pb)-1))

Q = {}
for pa, pb in P:
    for i in range(3):
        for j in range(3):
            if (pa - i >= 0) and (pb - j >= 0) and (pa - i <= H - 3) and (pb - j <= W - 3):
                if (pa - i, pb - j) in Q:
                    Q[(pa - i, pb - j)] += 1
                else:
                    Q[(pa - i, pb - j)] = 1
cnt = [0] * 9
for k, v in Q.items():
    cnt[v] += 1
cnt[0] = (H - 2) * (W - 2) - len(Q)
print(cnt)

Fixed code:
H, W, N = (int(i) for i in input().split())

P = []
for i in range(N):
    pa, pb = input().split()
    P.append((int(pa)-1, int(pb)-1))

Q = {}
for pa, pb in P:
    for i in range(3):
        for j in range(3):
            if (pa - i >= 0) and (pb - j >= 0) and (pa - i <= H - 3) and (pb - j <= W - 3):
                if (pa - i, pb - j) in Q:
                    Q[(pa - i, pb - j)] += 1
                else:
                    Q[(pa - i, pb - j)] = 1
cnt = [0] * 10
for k, v in Q.items():
    cnt[v] += 1
cnt[0] = (H - 2) * (W - 2) - len(Q)
for i in range(10):
    print(cnt[i])
Buggy code:
h, w, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

sa = {}
for a,b in ab:
    for i in range(3):
        aa = a + i
        if aa < 3 or h < aa:
            continue
        for j in range(3):
            bb = b + j
            if bb < 3 or w < bb:
                continue
            id = "%d,%d" % (aa, bb)
            sa[id] = sa.get(id, 0) + 1

s = {}
for x in sa.values():
    s[x] = s.setdefault(x, 0) + 1
print((w - 2) * (h - 2) - len(sa.keys()))
for i in range(10):
    print(s.get(i, 0))

Fixed code:
h, w, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

sa = {}
for a,b in ab:
    for i in range(3):
        aa = a + i
        if aa < 3 or h < aa:
            continue
        for j in range(3):
            bb = b + j
            if bb < 3 or w < bb:
                continue
            id = "%d,%d" % (aa, bb)
            sa[id] = sa.get(id, 0) + 1

s = {}
for x in sa.values():
    s[x] = s.setdefault(x, 0) + 1
print((w - 2) * (h - 2) - len(sa.keys()))
for i in range(1, 10):
    print(s.get(i, 0))
Buggy code:
from collections import defaultdict

h, w, n = list(map(int, input().split()))
ans = [0 for i in range(10)]

if n != 0:
    board = defaultdict(int)
    for i in range(n):
        a, b = list(map(int, input().split()))
        a = a - 1
        b = b - 1
        for dx in range(b-1, b+2):
            if dx <= 0 or dx >= w - 1:
                continue
            for dy in range(a-1, a+2):
                if dy <= 0 or dy >= h - 1:
                    continue
                board[(dx, dy)] += 1

    for v in board.values():
        ans[v] += 1

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


Fixed code:
from collections import defaultdict

h, w, n = list(map(int, input().split()))
ans = [0 for i in range(10)]

board = defaultdict(int)
for i in range(n):
    a, b = list(map(int, input().split()))
    a = a - 1
    b = b - 1
    for dx in range(b-1, b+2):
        if dx <= 0 or dx >= w - 1:
            continue
        for dy in range(a-1, a+2):
            if dy <= 0 or dy >= h - 1:
                continue
            board[(dx, dy)] += 1

for v in board.values():
    ans[v] += 1
ans[0] = (h - 2) * (w - 2) - sum(ans)

for i in range(10):
    print(ans[i])
Buggy code:
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    H, W, N = map(int, sys.stdin.readline().split())
    nb = [0] * 10
    dx = (1, 0, -1, 0, 1, 1, -1, -1)
    dy = (0, 1, 0, -1, 1, -1, 1, -1)
    bb = []

    for lp in range(N):
        a, b = map(int, sys.stdin.readline().split())
        a, b = a-1, b-1

        if in_field(H, W, a, b):
            bb.append((a,b))

        for i in range(len(dx)):
            if in_field(H, W, a+dx[i], b+dy[i]):
                bb.append((a+dx[i], b+dy[i]))

    bb.sort()
    cnt = 1

    for i, box in enumerate(bb):
        if i == 0:
            continue
        if box != bb[i-1]:
            nb[cnt] += 1
            cnt = 1
        else:
            cnt += 1

    nb[cnt] += 1

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

    print(*nb, sep='\n')

def in_field(H, W, a, b):
    return (1 <= a <= H-2) and (1 <= b <= W-2)

if __name__ == '__main__':
    solve()

Fixed code:
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    H, W, N = map(int, sys.stdin.readline().split())
    nb = [0] * 10
    dx = (1, 0, -1, 0, 1, 1, -1, -1)
    dy = (0, 1, 0, -1, 1, -1, 1, -1)
    bb = []

    for lp in range(N):
        a, b = map(int, sys.stdin.readline().split())
        a, b = a-1, b-1

        if in_field(H, W, a, b):
            bb.append((a,b))

        for i in range(len(dx)):
            if in_field(H, W, a+dx[i], b+dy[i]):
                bb.append((a+dx[i], b+dy[i]))

    bb.sort()
    cnt = 0

    for i, box in enumerate(bb):
        if i == 0:
            cnt += 1
            continue
        if box != bb[i-1]:
            nb[cnt] += 1
            cnt = 1
        else:
            cnt += 1

    if cnt > 0:
        nb[cnt] += 1

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

    print(*nb, sep='\n')

def in_field(H, W, a, b):
    return (1 <= a <= H-2) and (1 <= b <= W-2)

if __name__ == '__main__':
    solve()
Buggy code:
from collections import Counter, defaultdict

h, w, n = map(int, input().split())
dd = defaultdict(int)

for a, b in (map(int, input().split()) for _ in range(n)):
    for y in range(max(0, a - 3), min(a, h - 2)):
        for x in range(max(0, b - 3), min(b, w - 2)):
            dd[(y, x)] += 1

c = Counter(dd.values())
for i in range(10):
    print(c[i] if i in c else 0)


Fixed code:
from collections import Counter, defaultdict

h, w, n = map(int, input().split())
hs, ws = h - 2, w - 2
dd = defaultdict(int)

for a, b in (map(int, input().split()) for _ in range(n)):
    for y in range(max(0, a - 3), min(a, hs)):
        for x in range(max(0, b - 3), min(b, ws)):
            dd[(y, x)] += 1

print(hs * ws - len(dd))

c = Counter(dd.values())
for i in range(1, 10):
    print(c[i] if i in c else 0)
Buggy code:
F=lambda:tuple(int(X)for X in input().split());H,W,N=F();S={F()for _ in[0]*N};T=set();Z=[0]*10
for Y,X in S:
	for A in range(9):
		A,B=X+A%3-1,Y+A//3-1
		if 0<A<W-1 and 0<B<H-1 and(A,B)not in T:
			T.add((A,B));Q=0
			for C in range(9):Q+=(B+C//3,A+C%3)in S
			Z[Q]+=1
print(*Z,sep='\n')

Fixed code:
F=lambda:tuple(int(X)for X in input().split());H,W,N=F();S={F()for _ in[0]*N};T=set();Z=[0]*10
for Y,X in S:
	for A in range(9):
		P=A,B=X-A%3,Y-A//3
		if(0<A<W-1)*(0<B<H-1)*(P not in T):T.add(P);Z[sum((B+C//3,A+C%3)in S for C in range(9))]+=1
Z[0]+=(H-2)*(W-2)-sum(Z);print(*Z,sep='\n')
Buggy code:
from collections import defaultdict


def main():
    H, W, N = map(int, input().split())

    d = defaultdict(int)
    for _ in range(N):
        a, b = map(int, input().split())
        for y in range(-2, 1):
            for x in range(-2, 1):
                n_y, n_x = y + a, x + b
                if 0 < n_y <= H - 2 and 0 < n_x <= W - 2:
                    d[(n_y, n_x)] += 1

    ans = [0] * 10
    for k, v in d.items():
        ans[v] += 1

    print(*ans, sep="\n")

if __name__ == '__main__':
    main()


Fixed code:
from collections import defaultdict


def main():
    H, W, N = map(int, input().split())

    d = defaultdict(int)
    for _ in range(N):
        a, b = map(int, input().split())
        for y in range(-2, 1):
            for x in range(-2, 1):
                n_y, n_x = y + a, x + b
                if 0 < n_y <= H - 2 and 0 < n_x <= W - 2:
                    d[(n_y, n_x)] += 1

    ans = [0] * 10
    for k, v in d.items():
        ans[v] += 1
    ans[0] = (H - 2) * (W - 2) - sum(ans)

    print(*ans, sep="\n")

if __name__ == '__main__':
    main()
Buggy code:
from collections import defaultdict

def inside(x, y):    
    return 0 <= x <= h - 3 and 0 <= y <= w - 3

h, w, n = (int(_) for _ in input().split())
black = defaultdict(int)
for i in range(n):
    a, b = (int(_) - 1 for _ in input().split())
    for j in range(3):
        for k in range(3):
            x, y = a - j, b - k
            if not inside(x, y):
                continue
            black[(x, y)] += 1
ans = defaultdict(int)
ans[0] = (h-2)*(w-2)
for k in black:
    ans[black[k]] += 1
for i in range(10):
    print(i, ans[i])

            
    


Fixed code:
from collections import defaultdict

def inside(x, y):    
    return 0 <= x <= h - 3 and 0 <= y <= w - 3

h, w, n = (int(_) for _ in input().split())
black = defaultdict(int)
for i in range(n):
    a, b = (int(_) - 1 for _ in input().split())
    for j in range(3):
        for k in range(3):
            x, y = a - j, b - k
            if not inside(x, y):
                continue
            black[(x, y)] += 1
ans = [0 for i in range(10)]
ans[0] = (h-2)*(w-2) - len(black)
for k in black:
    ans[black[k]] += 1
for i in range(10):
    print(ans[i])
Buggy code:
def solve():
    w, h, n = [int(i) for i in input().split()]
    dic = dict()
    for i in range(n):
        a, b = map(lambda x: int(x) - 1, input().split())
        for j in range(3):
            for k in range(3):
                aj = a + j - 1
                bk = b + k - 1
                if 0 < aj and aj < w - 1 and 0 < bk and bk < h - 1:
                    print("DEBUG", aj, bk)
                    if (aj, bk) in dic:
                        dic[(aj, bk)] += 1
                    else:
                        dic[(aj, bk)] = 1
    ans = [0 for i in range(10)]
    for v in dic.values():
        ans[v] += 1
    for i in range(10):
        if i == 0:
            print((w - 2) * (h - 2) - sum(ans))
        else:
            print(ans[i])


if __name__=="__main__":
    solve()


Fixed code:
def solve():
    w, h, n = [int(i) for i in input().split()]
    dic = dict()
    for i in range(n):
        a, b = map(lambda x: int(x) - 1, input().split())
        for j in range(3):
            for k in range(3):
                aj = a + j - 1
                bk = b + k - 1
                if 0 < aj and aj < w - 1 and 0 < bk and bk < h - 1:
                    if (aj, bk) in dic:
                        dic[(aj, bk)] += 1
                    else:
                        dic[(aj, bk)] = 1
    ans = [0 for i in range(10)]
    for v in dic.values():
        ans[v] += 1
    for i in range(10):
        if i == 0:
            print((w - 2) * (h - 2) - sum(ans))
        else:
            print(ans[i])


if __name__=="__main__":
    solve()