Problem:
 Score : 400 points    Problem Statement We have a grid with H rows and W columns. At first, all cells were painted white.  Snuke painted N of these cells. The i -th ( 1 \leq i \leq N ) cell he painted is the cell at the a_i -th row and b_i -th column.  Compute the following:   For each integer j ( 0 \leq j \leq 9 ), how many subrectangles of size 3×3 of the grid contains exactly j black cells, after Snuke painted N cells?       Constraints  3 \leq H \leq 10^9  3 \leq W \leq 10^9  0 \leq N \leq min(10^5,H×W)  1 \leq a_i \leq H  (1 \leq i \leq N)  1 \leq b_i \leq W  (1 \leq i \leq N)  (a_i, b_i) \neq (a_j, b_j)  (i \neq j)         Input The input is given from Standard Input in the following format:  H  W  N  a_1  b_1 : a_N  b_N       Output Print 10 lines.
The (j+1) -th ( 0 \leq j \leq 9 ) line should contain the number of the subrectangles of size 3×3 of the grid that contains exactly j black cells.        Sample Input 1 4 5 8
1 1
1 4
1 5
2 3
3 1
3 2
3 4
4 4      Sample Output 1 0
0
0
2
4
0
0
0
0
0   There are six subrectangles of size 3×3 . Two of them contain three black cells each, and the remaining four contain four black cells each.       Sample Input 2 10 10 20
1 1
1 4
1 9
2 5
3 10
4 2
4 7
5 9
6 4
6 6
6 7
7 1
7 3
7 7
8 1
8 5
8 10
9 2
10 4
10 9      Sample Output 2 4
26
22
10
2
0
0
0
0
0       Sample Input 3 1000000000 1000000000 0      Sample Output 3 999999996000000004
0
0
0
0
0
0
0
0
0

Solution (Python):
import sys
input=sys.stdin.readline
h,w,n=map(int,input().split())
ans=[(h-2)*(w-2)]+[0]*9
s1=set()
s2=set()
for i in range(n):
  a,b=map(int,input().split())
  s2.add(a*(10**10)+b)
  for j in range(3):
    for k in range(3):
      if 0<a-j<h-1 and 0<b-k<w-1:
        s1.add((a-j)*(10**10)+b-k)
for x in s1:
  now=0
  for i in range(3):
    for j in range(3):
      if (x+i*(10**10)+j) in s2:
        now+=1
  ans[now]+=1
ans[0]-=sum(ans[1:])
[print(x) for x in ans]

Solution (Python):
from itertools import product
from collections import defaultdict,Counter

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

dic = defaultdict(int)

for _ in range(n):
    y,x= map(int,input().split())
    for i,j in product([-1,0,1],repeat=2):
        nx = x+i
        ny = y+j
        if 2 <= nx <= w-1 and 2 <= ny <= h-1:
            dic[nx,ny] += 1

c = Counter(dic.values())
c[0] = (w-2)*(h-2)-sum(c.values())

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

Solution (Python):






from collections import deque





h,w,n=map(int,input().split())
d={}
p=((1,1),(1,0),(1,-1),(0,1),(0,0),(0,-1),(-1,1),(-1,0),(-1,-1))
for i in range(n):
    a,b=map(int,input().split())
    a-=1
    b-=1
    for idx in p:
        s,t=idx
        if 0<a+s<h-1 and 0<b+t<w-1:
          if (a+s,b+t) not in d:
            d[(a+s,b+t)]=1
          else:
            d[(a+s,b+t)]+=1
ans=[0]*10
for x in d.values():
  ans[x]+=1
ans[0]=(h-2)*(w-2)-sum(ans)
print(*ans)

Solution (Python):
a={}
h,w,n=map(int,input().split())
for i in range(n):
  y,x=map(int,input().split())
  for j in range(max(2,x-1),min(w-1,x+1)+1):
    for k in range(max(2,y-1),min(h-1,y+1)+1):
      if j*(10**10)+k in a:
        a[j*(10**10)+k]+=1
      else:
        a[j*(10**10)+k]=1
ans=[0]*10
ans[0]=(h-2)*(w-2)
for key in a:
  ans[0]-=1
  ans[a[key]]+=1
for i in ans:
  print(i)

Solution (Python):
from collections import defaultdict
from itertools import product

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

covered = defaultdict(int)
vector = [[-1,-1],[-1,0],[-1,1],[1,0],[1,1],[0,0],[0,-1],[0,1],[1,-1]]

for _ in range(N):
    a,b = map(int,input().split())
    for dx,dy in vector:
        x = a+dx-1
        y = b+dy-1
        if 1 <= x < H-1 and 1 <= y < W-1:
            covered[(x,y)] += 1

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

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

for v in values:
    print(v)

Solution (Python):
import sys
from collections import defaultdict

def solve():
    input = sys.stdin.readline
    H, W, N = map(int, input().split())
    C = defaultdict(int)
    for _ in range(N):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        for h in range(3):
            for w in range(3):
                if 0 <= a-h < H - 2 and 0 <= b-w < W - 2:
                    C[(a-h, b-w)] += 1
    
    ans = [0] * 10
    s = 0
    for key in C:
        ans[C[key]] += 1
        s += 1
    ans[0] = ((H - 2) * (W - 2) - s)
    print(*ans, sep="\n") 
    

    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
from collections import defaultdict
from itertools import product

H, W, N = map(int, input().split())
cnt = defaultdict(int)
D = tuple(product((-1, 0, 1), repeat=2))

for _ in range(N):
    a, b = map(int, input().split())
    for dh, dw in D:
        h = a + dh
        w = b + dw
        if 2 <= h <= H - 1 and 2 <= w <= W - 1:
            cnt[(h, w)] += 1

ans = [0] * 10
for c in cnt.values():
    ans[c] += 1
ans[0] = (H - 2) * (W - 2) - sum(ans)
print(*ans, sep='\n')

Solution (Python):
import sys
import math
from collections import deque
from collections import Counter

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    H, W, N = NMI()
    grid = {}
    for i in range(N):
        a, b = NMI()
        for t in range(-2, 1):
            for k in range(-2, 1):
                if a + t < 1 or b + k < 1:
                    continue
                if a + t >= H - 1 or b + k >= W - 1:
                    continue
                point = (a+t) * 10**10 + b+k
                grid[point] = grid.get(point, 0) + 1
    c = Counter(grid.values())
    for i in range(10):
        if i == 0:
            print((H-2)*(W-2) - sum(c.values()))
        else:
            print(c.get(i, 0))


if __name__ == "__main__":
    main()

Solution (Python):
from collections import defaultdict


def main():
    H, W, N = list(map(int, input().split(' ')))
    coord_list = [list(map(int, input().split(' '))) for _ in range(N)]
    
    square_count = defaultdict(int)
    for coord in coord_list:
        coord = tuple(coord)
        
        if coord[0] + 2 <= H and coord[1] + 2 <= W:
            square_count[coord] += 1
        if coord[0] + 2 <= H and 1 <= coord[1] - 1 and coord[1] + 1 <= W:
            square_count[(coord[0], coord[1] - 1)] += 1
        if coord[0] + 2 <= H and 1 <= coord[1] - 2:
            square_count[(coord[0], coord[1] - 2)] += 1
        
        if 1 <= coord[0] - 1 and coord[0] + 1 <= H and coord[1] + 2 <= W:
            square_count[(coord[0] - 1, coord[1])] += 1
        if 1 <= coord[0] - 1 and coord[0] + 1 <= H and 1 <= coord[1] - 1 and coord[1] + 1 <= W:
            square_count[(coord[0] - 1, coord[1] - 1)] += 1
        if 1 <= coord[0] - 1 and coord[0] + 1 <= H and 1 <= coord[1] - 2:
            square_count[(coord[0] - 1, coord[1] - 2)] += 1
        
        if 1 <= coord[0] - 2 and coord[1] + 2 <= W:
            square_count[(coord[0] - 2, coord[1])] += 1
        if 1 <= coord[0] - 2 and 1 <= coord[1] - 1 and coord[1] + 1 <= W:
            square_count[(coord[0] - 2, coord[1] - 1)] += 1
        if 1 <= coord[0] - 2 and 1 <= coord[1] - 2:
            square_count[(coord[0] - 2, coord[1] - 2)] += 1
    
    count = defaultdict(int)  
    for v in square_count.values():
        count[v] += 1
    count_white_only = (H - 2) * (W - 2) - sum(count.values())
    count[0] = count_white_only
    
    for c in range(0, 10):
        print(count[c])


if __name__ == '__main__':
    main()

Solution (Python):
h, w, n = map(int, input().split())
cnt = {}

for _ in range(n):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    for i in range(-1, 2):
        for j in range(-1, 2):
            if 0 < a + i < h - 1 and 0 < b + j < w - 1:
                if (a+i, b+j) not in cnt:
                    cnt[(a+i, b+j)] = 0
                cnt[(a+i, b+j)] += 1

ans = {i: 0 for i in range(10)}
ans[0] = (h - 2) * (w - 2)
for _, x in cnt.items():
    ans[x] += 1
    ans[0] -= 1

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

Solution (Python):
h, w, n = map(int, input().split())
from collections import defaultdict
d = defaultdict(int)
surround = [(0, 0), (1,1), (1, 0), (1, -1), (0, -1), (-1, -1), (-1, 0), (-1, 1), (0, 1)]
for _ in range(n):
    x, y  = map(int, input().split())
    x -= 1
    y -= 1
    for i in surround:
        if x + i[0] >= h or x + i[0] < 0 or y + i[1] < 0 or y + i[1] >= w:
            continue
        else:
            d[(x+i[0], y + i[1])] += 1
num = [0]*10
for key in d:
    if key[0] >= 1 and key[0] < h -1 and key[1] >= 1 and key[1] < w-1:
        num[d[key]] += 1

num[0] = (h-2)*(w-2) - sum(num)

for ans in num:
    print(ans)

Solution (Python):
from collections import defaultdict

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

d = defaultdict(int)

for _ in range(n):
    a,b = map(int,input().split())

    for i in range(-1,2):
        for j in range(-1,2):
            if 1 < a+i < h and 1 < b+j < w:
                d[(a+i,b+j)] += 1

ans = [0]*10

for i in d.values():
    ans[i] += 1

ans[0] = (h-2)*(w-2)-sum(ans)
for i in ans:
    print(i)

Solution (Python):
import sys
from collections import defaultdict

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(IN())
mod=1000000007



def main():
	
	H, W, N = tin()
	
	dd=defaultdict(lambda : 0)
	for _ in range(N):
		a, b = tin()
		for da in range(3):
			for db in range(3):
				if a - da <= 0 or b - db <= 0:
					continue
				if a - da > H -2 or b -db > W-2:
					continue
				ii = (a - da)*(W+1)+(b - db)
				dd[ii]+=1
	
	nn = [0]*10
	for k in dd:
		nn[dd[k]]+=1
	nn[0]=((H-2)*(W-2))-sum(nn[1:])
	for v in nn:
		print(v)
	
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

Solution (Python):
def main():
    from collections import defaultdict
    import sys
    input = sys.stdin.readline

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

    g = defaultdict(int)
    for _ in range(N):
        a, b = (int(x) - 1 for x in input().split())
        for i in range(3):
            if a - i < 0: continue
            if a - i + 3 > H: continue
            for j in range(3):
                if b - j < 0: continue
                if b - j + 3 > W: continue
                g[(a - i) * W + (b - j)] += 1
                

    ctr = [0] * 10
    tot = (H - 2) * (W - 2)
    for cnt in g.values():
        ctr[cnt] += 1
        tot -= 1
    ctr[0] = tot

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


if __name__ == '__main__':
    main()

Solution (Python):
"""
参考(神様)
https://atcoder.jp/contests/abc045/submissions/6046010
"""




import sys
from collections import defaultdict,Counter

def input():
    return sys.stdin.readline().strip()

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

covered = defaultdict(int)
vector = [(0,0),(0,1),(0,-1),(1,0),(-1,0),(1,1),(-1,-1),(1,-1),(-1,1)]

for _ in range(N):
    a,b = map(int,input().split())

    for i,j in vector:
        x = a+i-1
        y = b+j-1

        if 0 < x < H-1 and 0 < y < W-1:
            covered[(x,y)] += 1

num = Counter(covered.values())

num[0] = (H-2)*(W-2)-sum(num.values())

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

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

m = {}

for i in range(N):
    a, b = map(int, input().split())
    for j in range(-2, 1):
        for k in range(-2, 1):
            if not 1 <= a + j <= H - 2 or not 1 <= b + k <= W - 2:
                continue
            m[(a + j, b + k)] = m.get((a + j, b + k), 0) + 1

ans = [0] * 10

for k, v in m.items():
    ans[v] += 1


ans[0] = (H - 2) * (W - 2) - sum(ans[1 : 10])
for i in range(10):
    print(ans[i])

Solution (Python):
H, W, N = [int(v) for v in input().split()]
points = (map(int, input().split()) for _ in range(N))
memory = {}
for ai, bi in points:
    for i in range(max(2, ai - 1), min(H - 1, ai + 1) + 1):
        for j in range(max(2, bi - 1), min(W - 1, bi + 1) + 1):
            key = (i, j)
            if not key in memory:
                memory[key] = 0
            memory[key] += 1

counter = {i: 0 for i in range(1, 10)}
for v in memory.values():
    counter[v] += 1

print((H - 2) * (W - 2) - sum(counter.values()))
for i in range(1, 10):
    print(counter[i])

Solution (Python):
from collections import defaultdict
H,W,N=map(int,input().split())

allcase=(H-2)*(W-2)

abset=set()
for _ in range(N):
  a,b=map(int,input().split())
  abset.add((a-1,b-1))


memo=defaultdict(int)
for a,b in abset:
  for j in range(-2,1):
    if a+j<0 or H-2<=a+j:
      continue    
    for k in range(-2,1):
      if b+k<0 or W-2<=b+k:
        continue
      memo[(a+j,b+k)]+=1


case_list=[0]*10
for v in memo.values():
  case_list[v]+=1
case_list[0]=allcase-sum(case_list[1:])


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

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

allcase=(H-2)*(W-2)

abset=set()
for _ in range(N):
  a,b=map(int,input().split())
  abset.add((a-1,b-1))


memo={}
def count_black(x,y):
  if (x,y) in memo:
    return memo[(x,y)]
  
  num_black=0
  for ii in range(3):
    for jj in range(3):
      if (x+ii,y+jj) in abset:
        num_black+=1
        
  memo[(x,y)]=num_black
  return num_black

case_list=[0]*10
for a,b in abset:
  for j in range(3):
    if a-j<0 or H-2<=a-j:
      continue    
    for k in range(3):
      if b-k<0 or W-2<=b-k:
        continue
      count_black(a-j,b-k)


case_list=[0]*10
for v in memo.values():
  case_list[v]+=1
case_list[0]=allcase-sum(case_list[1:])


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

Solution (Python):
from collections import defaultdict
import sys

input = sys.stdin.buffer.readline
h, w, n = map(int, input().split())
count = defaultdict(int)

for i in range(n):
    a, b = map(int, input().split())
    for s in range(3):
        if a + s - 2 < 1 or a + s - 2 > h - 2:
            continue
        for t in range(3):
            if b - 2 + t < 1 or b - 2 + t > w - 2:
                continue
            count[(a - 2 + s, b - 2 + t)] += 1
ans = [0] * 10
for key, val in count.items():
    ans[val] += 1
ans[0] = (h - 2) * (w - 2) - sum(ans[1:])
print(*ans, sep="\n")

Solution (Python):
from collections import defaultdict

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

for i in range(n):
    a, b = map(int, input().split())
    for s in range(3):
        if a + s - 2 < 1 or a + s - 2 > h - 2:
            continue
        for t in range(3):
            if b - 2 + t < 1 or b - 2 + t > w - 2:
                continue
            count[(a - 2 + s, b - 2 + t)] += 1
ans = [0] * 10
for key, val in count.items():
    ans[val] += 1
ans[0] = (h - 2) * (w - 2) - sum(ans[1:])
print(*ans, sep="\n")

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

A = {}
for i in range(N):
  a,b = map(int,input().split())
  a-=1;b-=1
  for t in range(3):
    for s in range(3):
      if 0<=a-t<H-2 and 0<=b-s<W-2:
        if (a-t,b-s) not in A:
          A[(a-t,b-s)]  = 1
        else:
          A[(a-t,b-s)]  += 1

ans = [-1]
temp = list(A.values())
total = 0
for i in range(1,10):
  c = temp.count(i)
  total += c
  ans.append(c)
ans[0] = (H-2)*(W-2)-total
print(*ans, sep="\n")

Solution (Python):
from itertools import product
from collections import Counter

H, W, N = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
D = tuple(product((-1, 0, 1), repeat=2))

cnt = Counter()
for a, b in AB:
    for h, w in D:
        if 2 <= a + h <= H - 1 and 2 <= b + w <= W - 1:
            cnt[(a + h, b + w)] += 1

ans = [0] * 10
for c in cnt.values():
    ans[c] += 1

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

Solution (Python):
from itertools import product
from collections import Counter

H, W, N = map(int, input().split())
V = set([tuple(map(int, input().split())) for _ in range(N)])
D = tuple(product((-1, 0, 1), repeat=2))

A = set()
cnt = Counter()
for a, b in V:
    for h, w in D:
        if 2 <= a + h <= H - 1 and 2 <= b + w <= W - 1:
            cnt[(a + h, b + w)] += 1

ans = [0] * 10
for c in cnt.values():
    ans[c] += 1

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

Solution (Python):
from itertools import product

H, W, N = map(int, input().split())
V = set([tuple(map(int, input().split())) for _ in range(N)])
D = tuple(product((-1, 0, 1), repeat=2))

A = set()
for a, b in V:
    for h, w in D:
        if 2 <= a + h <= H - 1 and 2 <= b + w <= W - 1:
            A.add((a + h, b + w))

ans = [0] * 10
for a, b in A:
    cnt = 0
    for h, w in D:
        if (a + h, b + w) in V:
            cnt += 1
    ans[cnt] += 1

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

Solution (Python):
import sys
input = sys.stdin.readline

MOD = 10 ** 9 + 7

from collections import defaultdict

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

dic = defaultdict(int)
lst = [0] * (10)
lst[0] = (H - 2) * (W - 2)

for _ in range(N):
    a, b = map(int, input().split())
    for i in range(-1, 2):
        for j in range(-1, 2):
            if 2 <= (a + i) <= (H - 1):
                if 2 <= (b + j) <= (W - 1):
                    tmp = dic[(a + i, b + j)]
                    lst[tmp] -= 1
                    lst[tmp + 1] += 1
                    dic[((a + i, b + j))] += 1

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

Solution (Python):
h,w,n=map(int,input().split())
ls=[]
while True:
    try:
        ls.append(tuple(map(int,input().split())))
    except EOFError:break
check={}
count={0:(h-2)*(w-2)}
for i in range(1,10):
    count[i]=0
for tup in ls:
    for i in range(-2,1):
        for j in range(-2,1):
            if(tup[0]+i>0 and tup[0]+i<h-1 and tup[1]+j>0 and tup[1]+j<w-1):
              try:
                check[(tup[0]+i,tup[1]+j)]+=1
              except KeyError:
                check[(tup[0]+i,tup[1]+j)]=1
              index=check[(tup[0]+i,tup[1]+j)]
              count[index]+=1
              count[index-1]-=1
for i in range(10):
    print("{}".format(count[i]))

Solution (Python):
import itertools

int1 = lambda x: int(x) - 1

H, W, N = map(int, input().split())
B = set(tuple(map(int1, input().split())) for _ in range(N))

adj = (-1, 0, 1)
visited = set()
ans = [0] * 10
for a, b in B:
    for dy, dx in itertools.product(adj, repeat=2):
        if not (1 <= a + dy < H - 1 and 1 <= b + dx < W - 1):
            continue
        elif (a + dy, b + dx) in visited:
            continue
        visited.add((a + dy, b + dx))
        c = 0
        for ddy, ddx in itertools.product(adj, repeat=2):
            if (a + dy + ddy, b + dx + ddx) in B:
                c += 1
        ans[c] += 1
ans[0] = (H - 2) * (W - 2) - sum(ans[1:])
for x in ans:
    print(x)

Solution (Python):
from collections import defaultdict as dd
H,W,N=map(int,input().split())
ab = [tuple(map(int,input().split())) for _ in range(N)]
tpl = [(-1,-1),(-1,0),(-1,1),(0,-1),(0,0),(0,1),(1,-1),(1,0),(1,1)]
edge_WtoB = dd(int)
edge_BtoB = dd(int)
node_B = set(ab)

res = dd(int)

for a,b in ab:
    for s,t in tpl:
        tgt = (a+s,b+t)
        
        if tgt in node_B:
            if not (1 < a < H and 1 < b < W):
                continue
            edge_BtoB[(a,b)] += 1
        
        else:
            if not (1 < a + s < H and 1 < b + t < W):
                continue
            edge_WtoB[tgt] += 1
            
for val in edge_WtoB.values():
    res[val] += 1
for val in edge_BtoB.values():
    res[val] += 1
zero = (H-2)*(W-2)
for j in range(1,10):
    zero -= res[j]
res[0] = zero
for j in range(10):
    print(res[j])

Solution (Python):
h, w, n = map(int, input().split())
square = dict()
for i in range(n):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    for x in range(b-2,b+1,1):
        for y in range(a-2,a+1,1):
            if 0 <= y <= (h - 3) and 0 <= x <= (w - 3) :
                if (x,y) in square:
                    square[(x,y)] += 1
                else:
                    square[(x,y)] = 1
ans = [0 for i in range(10)]
for i in square.values():
    ans[i] += 1
ans[0] = (h - 2) * (w - 2) - sum(ans)
for i in range(10):
    print(ans[i])

Solution (Python):
from collections import defaultdict, Counter

H, W, N = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]

d = defaultdict(int)
for a, b in ab:
  for da in range(3):
    aa = a - da
    if aa < 1 or H < aa + 2:
      continue
    for db in range(3):
      bb = b - db
      if bb < 1 or W < bb + 2:
        continue
      
      d[(aa, bb)] += 1

num = [0] * 10
num[0] = (H - 2) * (W - 2)
count_n = Counter(list(d.values()))
for i in range(1, 10):
  n = count_n[i]
  num[i] += n
  num[0] -= n

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

Solution (Python):
import sys
input = sys.stdin.readline

H, W, N = map(int, input().split())
ab = set(tuple(map(int, input().split())) for i in range(N))

dxy = {0:[0, 1, 2], 1:[-1, 0, 1], 2:[-2, -1, 0]}
num_all = (H - 2) * (W - 2)
num = [0] * 10
for a, b in ab:
  for i in range(3):
    Da = dxy[i]
    for j in range(3):
      n = 0
      flag = False
      Db = dxy[j]
      for da in Da:
        aa = a + da
        for db in Db:
          bb = b + db
          if aa < 1 or H < aa or bb < 1 or W < bb:
            flag = True
            break
          if (aa, bb) in ab:
            n += 1
        if flag:
          break
      if flag:
        continue
      num[n] += 1

for i in range(2, 10):
  num[i] //= i

num[0] = num_all - sum(num[1:])
print(*num, sep='\n')

Solution (Python):
H, W, N = map(int, input().split())
ab = set(tuple(map(int, input().split())) for i in range(N))

dxy = {0:[0, 1, 2], 1:[-1, 0, 1], 2:[-2, -1, 0]}
num_all = (H - 2) * (W - 2)
num = [0] * 10
for a, b in ab:
  for i in range(3):
    Da = dxy[i]
    for j in range(3):
      n = 0
      flag = False
      Db = dxy[j]
      for da in Da:
        aa = a + da
        for db in Db:
          bb = b + db
          if aa < 1 or H < aa or bb < 1 or W < bb:
            flag = True
            break
          if (aa, bb) in ab:
            n += 1
        if flag:
          break
      if flag:
        continue
      num[n] += 1

for i in range(2, 10):
  num[i] //= i

num[0] = num_all - sum(num[1:])
print(*num, sep='\n')

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    H,W,N=map(int,input().split())
    s=set()
    for i in range(N):
        s.add(tuple(map(int1,input().split())))
    ans=[0]*10
    used=set()
    for y,x in s:
        for dy in range(-1,2):
            for dx in range(-1,2):
                if 0>y+dy-1 or y+dy+1>=H or 0>x+dx-1 or x+dx+1>=W or (y+dy,x+dx) in used:
                    continue
                tmp=0
                used.add((y+dy,x+dx))
                for ddy in range(-1,2):
                    for ddx in range(-1,2):
                        if (y+dy+ddy,x+dx+ddx) in s:
                            tmp+=1
                ans[tmp]+=1
    ans[0]=(H-2)*(W-2)-sum(ans[1:])
    for row in ans:
        print(row)
    
    

if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict

H, W, N = map(int, input().split())
dic = defaultdict(int)
dx = [-1, 0, 1, -1, 0, 1, -1, 0, 1]
dy = [1, 1, 1, 0, 0, 0, -1, -1, -1]
for i in range(N):
    y, x = map(int, input().split())
    for j in range(9):
        ny, nx = y+dy[j], x+dx[j]
        if not 1 < ny < H: continue
        if not 1 < nx < W: continue
        dic[str(ny)+":"+str(nx)] += 1
count = [0]*10
tot = (H-3+1)*(W-3+1)
count[0] = tot-len(dic.keys())
for k,v in dic.items():
    count[v] += 1
for c in count:
    print(c)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict

H, W, N = map(int, input().split())
dic = defaultdict(int)
dx = [-1, 0, 1, -1, 0, 1, -1, 0, 1]
dy = [1, 1, 1, 0, 0, 0, -1, -1, -1]
for i in range(N):
    y, x = map(int, input().split())
    for j in range(9):
        ny, nx = y+dy[j], x+dx[j]
        if not 1 < ny < H: continue
        if not 1 < nx < W: continue
        dic[str(ny)+":"+str(nx)] += 1
count = [0]*10
tot = (H-3+1)*(W-3+1)
count[0] = tot-len(dic.keys())
for k,v in dic.items():
    count[v] += 1
for c in count:
    print(c)

Solution (Python):


import sys






















def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())


    def contained_in_dict_set(d, i, j):
        if i in d:
            if j in d[i]:
                return True
        return False
    
    def register_dict_set(d, i, j):
        if i not in d:
            d[i] = set()
        d[i].add(j)

    def count_black_around_center(point_dict, i, j):
        cnt = 0
        for s in range(i-1, i+2):
            for t in range(j-1, j+2):
                if contained_in_dict_set(point_dict, s, t):
                    cnt += 1
        return cnt
    

    h, w, n = mi()
    points = [lmi() for _ in range(n)]
    num_of_grids_contains_black = [0] * 10

    point_dict = dict()
    visited_dict = dict()

    for x, y in points:
        register_dict_set(point_dict, x, y)

    for x, y in points:
        for i in range(x-1, x+2):
            for j in range(y-1, y+2):
                if 2<=i<=h-1 and 2<=j<=w-1 and not contained_in_dict_set(visited_dict, i, j):
                    cnt = count_black_around_center(point_dict, i, j)
                    num_of_grids_contains_black[cnt] += 1
                    register_dict_set(visited_dict, i, j)
    
    num_of_grids_contains_black[0] = (h - 2) * (w - 2) - sum(num_of_grids_contains_black[1:])
    print(*num_of_grids_contains_black, sep='\n')    



if __name__ == "__main__":
    main()

Solution (Python):
H, W , N = map(int,input().split())
from bisect import bisect_left
from bisect import bisect_right
matrix = []
for _ in range(N):
    x,y = map(int,input().split())
    matrix.append([x-1,y-1])
ans = [0 for _ in range(10)]
cand = {}
for l in matrix:
    for x_r in [-2, -1 , 0]:
        for y_r in [-2, -1 , 0]:
            nowx = l[0] + x_r
            nowy = l[1] + y_r
            if nowx < 0 or nowy < 0 or nowx + 2>= H or nowy+ 2 >= W:
                continue
            
            name = str(nowx) + ' '  +str(nowy)
            if name in cand : cand[name] += 1
            else: cand[name] = 1
tmp = ((H - 2) * (W - 2))
for x in cand.values():
  ans[x] +=1
ans[0] =tmp - len(cand)
for x in ans:
    print(x)

Solution (Python):
H, W , N = map(int,input().split())
from bisect import bisect_left
from bisect import bisect_right
matrix = []
for _ in range(N):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    matrix.append([x,y])
ans = [0 for _ in range(10)]
cand = {}
for l in matrix:
    for x_r in [-2, -1 , 0]:
        for y_r in [-2, -1 , 0]:
            nowx = l[0] + x_r
            nowy = l[1] + y_r
            if nowx < 0 or nowy < 0 or nowx + 2>= H or nowy+ 2 >= W:
                continue
            
            name = str(nowx) + ' '  +str(nowy)
            if name in cand : cand[name] += 1
            else: cand[name] = 1
tmp = ((H - 2) * (W - 2))
for x in cand.values():
    ans[x] += 1
    tmp -= 1
ans[0] = tmp
for x in ans:
    print(x)

Solution (Python):
H, W , N = map(int,input().split())
from bisect import bisect_left
from bisect import bisect_right
matrix = []
for _ in range(N):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    matrix.append([x,y])
ans = [0 for _ in range(10)]
cand = {}
for l in matrix:
    for x_r in [-2, -1 , 0]:
        for y_r in [-2, -1 , 0]:
            nowx = l[0] + x_r
            nowy = l[1] + y_r
            if nowx < 0 or nowy < 0 or nowx + 2>= H or nowy+ 2 >= W:
                continue
            
            name = str(nowx) + ' '  +str(nowy)
            if name in cand : cand[name] += 1
            else: cand[name] = 1
tmp = ((H - 2) * (W - 2))
for x in cand.values():
    ans[x] += 1
    tmp -= 1
ans[0] = tmp
for x in ans:
    print(x)

Solution (Python):
H, W , N = map(int,input().split())
from bisect import bisect_left
from bisect import bisect_right
matrix = []
for _ in range(N):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    matrix.append([x,y])
matrix.sort()
ans = [0 for _ in range(10)]
cand = {}
for l in matrix:
    for x_r in [-2, -1 , 0]:
        for y_r in [-2, -1 , 0]:
            nowx = l[0] + x_r
            nowy = l[1] + y_r
            if nowx < 0 or nowy < 0 or nowx + 2>= H or nowy+ 2 >= W:
                continue
            
            name = str(nowx) + ' '  +str(nowy)
            if name in cand : cand[name] += 1
            else: cand[name] = 1
tmp = ((H - 2) * (W - 2))
for x in cand.values():
    ans[x] += 1
    tmp -= 1
ans[0] = tmp
for x in ans:
    print(x)

Solution (Python):
H, W , N = map(int,input().split())
from bisect import bisect_left
from bisect import bisect_right
matrix = []
for _ in range(N):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    matrix.append([x,y])
matrix.sort()
ans = [0 for _ in range(10)]
cand = {}
for l in matrix:
    for x_r in [-2, -1 , 0]:
        for y_r in [-2, -1 , 0]:
            nowx = l[0] + x_r
            nowy = l[1] + y_r
            if nowx < 0 or nowy < 0 or nowx + 2>= H or nowy+ 2 >= W:
                continue
            
            name = str(nowx) + ' '  +str(nowy)
            try: cand[name] += 1
            except: cand[name] = 1
tmp = ((H - 2) * (W - 2))
for x in cand.values():
    ans[x] += 1
    tmp -= 1
ans[0] = tmp
for x in ans:
    print(x)

Solution (Python):
H, W , N = map(int,input().split())
from bisect import bisect_left
from bisect import bisect_right
matrix = []
for _ in range(N):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    matrix.append([x,y])
matrix.sort()
ans = [0 for _ in range(10)]
cand = {}
for l in matrix:
    for x_r in [-2, -1 , 0]:
        for y_r in [-2, -1 , 0]:
            nowx = l[0] + x_r
            nowy = l[1] + y_r
            if nowx < 0 or nowy < 0 or nowx + 2>= H or nowy+ 2 >= W:
                continue
            
            name = str(nowx) + 'sakoda'  +str(nowy)
            try: cand[name] += 1
            except: cand[name] = 1
tmp = ((H - 2) * (W - 2))
for x in cand.values():
    ans[x] += 1
    tmp -= 1
ans[0] = tmp
for x in ans:
    print(x)