Buggy python submission (verdict: Time Limit Exceeded):
def sol():
    import sys
    input=sys.stdin.readline
    h,w,n=map(int,input().split())
    d={}
    for i in range(n):
        y,x=map(int,input().split())
        if y in d:
            d[y].add(x)
        else:
            d[y]={x}
    for i in range(1,h+1):
        for j in range(1,w+1):
            pass
    ans=[0]*10
    for i in range(3,h+1):
        for j in range(3,w+1):
            chk=0
            if i in d:
                chk+=0+(j in d[i])+(j-1 in d[i])+(j-2 in d[i])
            if i-1 in d:
                chk+=0+(j in d[i-1])+(j-1 in d[i-1])+(j-2 in d[i-1])
            if i-2 in d:
                chk+=0+(j in d[i-2])+(j-1 in d[i-2])+(j-2 in d[i-2])
            ans[chk]+=1
    for i in ans:
        print(i)

if __name__=="__main__":
    sol()


Fixed submission:
def sol():
    import sys
    input=sys.stdin.readline
    h,w,n=map(int,input().split())
    d={}
    for i in range(n):
        y,x=map(int,input().split())
        if (y,x) in d:
            d[(y,x)]+=1
        else:
            d[(y,x)]=1
        if y+1<=h and (y+1,x) in d:
            d[(y+1,x)]+=1
        elif y+1<=h:
            d[(y+1,x)]=1
        if y+2<=h and (y+2,x) in d:
            d[(y+2,x)]+=1
        elif y+2<=h:
            d[(y+2,x)]=1
 
        if x+1<=w and (y,x+1) in d:
            d[(y,x+1)]+=1
        elif x+1<=w:
            d[(y,x+1)]=1
        if x+2<=w and (y,x+2) in d:
            d[(y,x+2)]+=1
        elif x+2<=w:
            d[(y,x+2)]=1
        if x+1<=w and y+1<=h and (y+1,x+1) in d:
            d[(y+1,x+1)]+=1
        elif x+1<=w and y+1<=h:
            d[(y+1,x+1)]=1
        if x+2<=w and y+1<=h and (y+1,x+2) in d:
            d[(y+1,x+2)]+=1
        elif x+2<=w and y+1<=h:
            d[(y+1,x+2)]=1
        if x+1<=w and y+2<=h and (y+2,x+1) in d:
            d[(y+2,x+1)]+=1
        elif x+1<=w and y+2<=h:
            d[(y+2,x+1)]=1
        if x+2<=w and y+2<=h and (y+2,x+2) in d:
            d[(y+2,x+2)]+=1
        elif x+2<=w and y+2<=h:
            d[(y+2,x+2)]=1
    ans=[0]*10
    for i in d:
        if i[0]>2 and i[1]>2:
            ans[d[i]]+=1
 
    ans[0]=h*w-sum(ans)-w*2-h*2+4
    for i in ans:
        print(i)
        
if __name__=="__main__":
    sol()

Buggy python submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
h,w,n=map(int,input().split())
d=[[0]*(w+1) for i in range(h+1)]
t=[[0]*(w+1) for i in range(h+1)]
for i in range(n):
    y,x=map(int,input().split())
    d[y][x]=1
for i in range(1,h+1):
    for j in range(1,w+1):
        t[i][j]=t[i][j-1]
        if d[i][j]==1:
            t[i][j]+=1
ans=[0]*10
for i in range(3,h+1):
    for j in range(3,w+1):
        p=(t[i][j]-t[i][j-3])+(t[i-1][j]-t[i-1][j-3])+(t[i-2][j]-t[i-2][j-3])
        ans[p]+=1
for i in ans:
    print(i)

Fixed submission:
def sol():
    import sys
    input=sys.stdin.readline
    h,w,n=map(int,input().split())
    d={}
    for i in range(n):
        y,x=map(int,input().split())
        if (y,x) in d:
            d[(y,x)]+=1
        else:
            d[(y,x)]=1
        if y+1<=h and (y+1,x) in d:
            d[(y+1,x)]+=1
        elif y+1<=h:
            d[(y+1,x)]=1
        if y+2<=h and (y+2,x) in d:
            d[(y+2,x)]+=1
        elif y+2<=h:
            d[(y+2,x)]=1
 
        if x+1<=w and (y,x+1) in d:
            d[(y,x+1)]+=1
        elif x+1<=w:
            d[(y,x+1)]=1
        if x+2<=w and (y,x+2) in d:
            d[(y,x+2)]+=1
        elif x+2<=w:
            d[(y,x+2)]=1
        if x+1<=w and y+1<=h and (y+1,x+1) in d:
            d[(y+1,x+1)]+=1
        elif x+1<=w and y+1<=h:
            d[(y+1,x+1)]=1
        if x+2<=w and y+1<=h and (y+1,x+2) in d:
            d[(y+1,x+2)]+=1
        elif x+2<=w and y+1<=h:
            d[(y+1,x+2)]=1
        if x+1<=w and y+2<=h and (y+2,x+1) in d:
            d[(y+2,x+1)]+=1
        elif x+1<=w and y+2<=h:
            d[(y+2,x+1)]=1
        if x+2<=w and y+2<=h and (y+2,x+2) in d:
            d[(y+2,x+2)]+=1
        elif x+2<=w and y+2<=h:
            d[(y+2,x+2)]=1
    ans=[0]*10
    for i in d:
        if i[0]>2 and i[1]>2:
            ans[d[i]]+=1
 
    ans[0]=h*w-sum(ans)-w*2-h*2+4
    for i in ans:
        print(i)
        
if __name__=="__main__":
    sol()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import time
import sys
import io
import re
import math
import itertools
import collections
import bisect
#sys.stdin=file('input.txt')
#sys.stdout=file('output.txt','w')
#10**9+7
mod=1000000007
#mod=1777777777
pi=3.141592653589
IS=float('inf')
xy=[(1,0),(-1,0),(0,1),(0,-1)]
bs=[(-1,-1),(-1,1),(1,1),(1,-1)]
def niten(a,b): return abs(a-b) if a>=0 and b>=0 else  a+abs(b) if a>=0 else abs(a)+b if b>=0 else abs(abs(a)-abs(b))
def gcd(a,b): return a if b==0 else gcd(b,a%b)
def lcm(a,b): return a*b/gcd(a,b)
def euclid_dis(x1,y1,x2,y2): return ((x1-x2)**2+(y1-y2)**2)**0.5
def choco(xa,ya,xb,yb,xc,yc,xd,yd): return 1 if abs((yb-ya)*(yd-yc)+(xb-xa)*(xd-xc))<1.e-10 else 0

#n=int(raw_input())
h,w,n=map(int,raw_input().split())
ans=[0]*10
b=[[0 for i in range(w)] for j in range(h)]
for i in range(n):
    y,x=map(int,raw_input().split())
    b[y-1][x-1]=1
for i in range(h-2):
    for j in range(w-2):
        tmp=(b[i][j]+b[i+1][j]+b[i+2][j]+b[i][j+1]+b[i+1][j+1]+b[i+2][j+1]+b[i][j+2]+b[i+1][j+2]+b[i+2][j+2])
        ans[tmp]+=1
for i in ans:
    print i

Fixed submission:
def sol():
    import sys
    input=sys.stdin.readline
    h,w,n=map(int,input().split())
    d={}
    for i in range(n):
        y,x=map(int,input().split())
        if (y,x) in d:
            d[(y,x)]+=1
        else:
            d[(y,x)]=1
        if y+1<=h and (y+1,x) in d:
            d[(y+1,x)]+=1
        elif y+1<=h:
            d[(y+1,x)]=1
        if y+2<=h and (y+2,x) in d:
            d[(y+2,x)]+=1
        elif y+2<=h:
            d[(y+2,x)]=1
 
        if x+1<=w and (y,x+1) in d:
            d[(y,x+1)]+=1
        elif x+1<=w:
            d[(y,x+1)]=1
        if x+2<=w and (y,x+2) in d:
            d[(y,x+2)]+=1
        elif x+2<=w:
            d[(y,x+2)]=1
        if x+1<=w and y+1<=h and (y+1,x+1) in d:
            d[(y+1,x+1)]+=1
        elif x+1<=w and y+1<=h:
            d[(y+1,x+1)]=1
        if x+2<=w and y+1<=h and (y+1,x+2) in d:
            d[(y+1,x+2)]+=1
        elif x+2<=w and y+1<=h:
            d[(y+1,x+2)]=1
        if x+1<=w and y+2<=h and (y+2,x+1) in d:
            d[(y+2,x+1)]+=1
        elif x+1<=w and y+2<=h:
            d[(y+2,x+1)]=1
        if x+2<=w and y+2<=h and (y+2,x+2) in d:
            d[(y+2,x+2)]+=1
        elif x+2<=w and y+2<=h:
            d[(y+2,x+2)]=1
    ans=[0]*10
    for i in d:
        if i[0]>2 and i[1]>2:
            ans[d[i]]+=1
 
    ans[0]=h*w-sum(ans)-w*2-h*2+4
    for i in ans:
        print(i)
        
if __name__=="__main__":
    sol()