qyliang/CodeNanoFix huggingface dataset:
Buggy code:
S = str(input())
l = list(map(str,(map(bin,range(2**(len(S)-1))))))
print(l)

ans = 0
for i in range(len(l)):
    ev = l[i][2:].zfill(len(S)-1)
    res = 0
    num_str = S[0]
    for j in range(1,len(S)):
        if(ev[j-1] == '0'):
            num_str = num_str + S[j]
        else:
            res += int(num_str)
            num_str = S[j]
    res += int(num_str)
    ans += res

print(ans)

Fixed code:
S = str(input())
l = list(map(str,(map(bin,range(2**(len(S)-1))))))

ans = 0
for i in range(len(l)):
    ev = l[i][2:].zfill(len(S)-1)
    res = 0
    num_str = S[0]
    for j in range(1,len(S)):
        if(ev[j-1] == '0'):
            num_str = num_str + S[j]
        else:
            res += int(num_str)
            num_str = S[j]
    res += int(num_str)
    ans += res

print(ans)
Buggy code:
# -*- coding: utf-8 -*-
s = input()
len_s = len(s)

ret = 0
def calc_cumsum(idx,right_str):
    if idx == len(right_str):
        return int(right_str)
    _ifplus = int(right_str[0:idx])* (2**(len(right_str[idx:len_s]) -1 )) + calc_cumsum(1,right_str[idx:len_s])
    _ifnotplus = calc_cumsum(idx+1,right_str)
    print(_ifplus+_ifnotplus)
    return (_ifplus+_ifnotplus)
print(calc_cumsum(1,s))


Fixed code:
# -*- coding: utf-8 -*-
s = input()
len_s = len(s)

ret = 0
def calc_cumsum(idx,right_str):
    if idx == len(right_str):
        return int(right_str)
    _ifplus = int(right_str[0:idx])* (2**(len(right_str[idx:len_s]) -1 )) + calc_cumsum(1,right_str[idx:len_s])
    _ifnotplus = calc_cumsum(idx+1,right_str)
    return (_ifplus+_ifnotplus)
print(calc_cumsum(1,s))
Buggy code:
S = input()
ans = 0
digit  = len(S)-1
for i in range(2**digit):
    bit = format(i,"0"+str(digit)+"b")
    temp = []
    num = S[0]
    for j in range(digit):
        if j == digit - 1:
            if bit[j] == "1":
                temp.append(int(num))
                temp.append(int(S[j+1]))
            else:
                temp.append(int(num+S[j+1:]))
        else:
            if bit[j] == "1":
                temp.append(int(num))
                num = S[j+1]     
            else:
                num += S[j+1]
    print(temp)
    ans += sum(temp)
print(ans)
            

Fixed code:
S = input()
ans = 0
digit  = len(S)-1
for i in range(2**digit):
    bit = format(i,"0"+str(digit)+"b")
    temp = []
    num = S[0]
    for j in range(digit):
        if j == digit - 1:
            if bit[j] == "1":
                temp.append(int(num))
                temp.append(int(S[j+1]))
            else:
                temp.append(int(num+S[j+1:]))
        else:
            if bit[j] == "1":
                temp.append(int(num))
                num = S[j+1]     
            else:
                num += S[j+1]
    ans += sum(temp)
print(int(S) if digit == 0 else ans)
Buggy code:
s = list(map(int,list(input())))
n = len(s)
m = 0
for i in range(n):
  for j in range(n-i):
    m += s[i]*2**max(n-j-2,0)*10**j
print(m)
  

Fixed code:
s = list(map(int,list(input())))
n = len(s)
m = 0
for i in range(n):
  for j in range(n-i):
    m += s[i]*2**i*10**j*2**(max(n-i-j-2,0))
print(m)
Buggy code:
s = input()
n = len(s)
ans = 0
for i in range(2**(n-1)):
  plus = [0]
  for j in range(n-1):
    if (i >> j) & 1 = 1:
      plus += [j+1]
  for j in range(len(plus)-1):
    ans += int(s[plus[j]:plus[j+1]])
print(ans)    

Fixed code:
s = input()
n = len(s)-1
ans = 0
for i in range(2**n):
    tmp = 0
    for j in range(n):
        if (i>>j)&1:
            ans += int(s[tmp:j+1])
            tmp = j+1
    ans += int(s[tmp:])
print(ans)
Buggy code:
n=input()
m=[[]for _ in range(n)]
m[0]+=[[0,int(n[0])]]
for i in range(1,len(n)):
  a=int(n[i])
  for m0,m1 in m[i-1]:
    m[i]+=[[m0+m1,a]]
    m[i]+=[[m0,m1*10+a]]
ans=0
for m0,m1 in m[len(n)-1]:
  ans+=m0+m1
print(ans)

Fixed code:
n=input()
m=[[]for _ in range(len(n))]
m[0]+=[[0,int(n[0])]]
for i in range(1,len(n)):
  a=int(n[i])
  for m0,m1 in m[i-1]:
    m[i]+=[[m0+m1,a]]
    m[i]+=[[m0,m1*10+a]]
ans=0
for m0,m1 in m[len(n)-1]:
  ans+=m0+m1
print(ans)
Buggy code:
n=input()
ans=0
def dfs(i,flag):
  if i!=len(n)-1:
    dfs(i+1,flag)
    dfs(i+1,flag|2**i)
  else:
    num=[]
    start=0
    for i in range(len(n)):
      if flag&2**i>0:
        num.append(n[start:i+1])
        start=i+1
    ans+=sum(num)

dfs(0,0)
print(ans)

Fixed code:
n=input()
ans=0
def dfs(i,flag):
  global ans
  if i!=len(n)-1:
    dfs(i+1,flag)
    dfs(i+1,flag|2**i)
  else:
    num=[]
    start=0
    for i in range(len(n)):
      if flag&2**i>0:
        num.append(int(n[start:i+1]))
        start=i+1
    if start!=n:
      num.append(int(n[start:]))
    ans+=sum(num)
dfs(0,0)
print(ans)
Buggy code:
import sys

S = input()
if len(S) == 1:
    print(int(S))
    sys.exit()

ls = []
a = [0, 1]
for i in itertools.product(a, repeat=len(S)-1):
    ans = 0
    start = 0
    for j, x in enumerate(i):
        if x == 1:
            ans += int(S[start:j+1])
            start = j + 1
    ans += int(S[start:len(S)])
    ls.append(ans)
print(sum(ls))


Fixed code:
import sys
import itertools

S = input()
if len(S) == 1:
    print(int(S))
    sys.exit()

ls = []
a = [0, 1]
for i in itertools.product(a, repeat=len(S)-1):
    ans = 0
    start = 0
    for j, x in enumerate(i):
        if x == 1:
            ans += int(S[start:j+1])
            start = j + 1
    ans += int(S[start:len(S)])
    ls.append(ans)
print(sum(ls))
Buggy code:
s = input()
n = len(s)
def dfs(i,f):
  if i == n:
    return sum(list(map(int,f.split("+"))))
  return dfs(i + 1, f + s[i + 1]) + \
           dfs(i + 1, f + "+" + s[i + 1])
print(dfs(0,0))

Fixed code:
def dfs(i, s, plus):
    if i == n - 1:
        return sum(list(map(int, s.split("+"))))
    return dfs(i + 1, s, plus) +\
           dfs(i + 1, s[:i + plus + 1] + "+" + s[i + plus + 1:], plus + 1)

s = input()
n = len(s)

print(dfs(0, s, 0))
Buggy code:
s = input()
n = len(s)


def dfs(i, f):
    if i == n - 1:
        return sum(list(map(int, f.split("+"))))

	return dfs(i + 1, f + s[i + 1]) + dfs(i + 1, f + "+" + s[i + 1])
    
print(dfs(0, s[0]))

Fixed code:
def dfs(i, s, plus):
    if i == n - 1:
        b = list(map(int, s.split("+")))
        return sum(b)
    return dfs(i + 1, s, plus) + dfs(i + 1, s[:i + plus + 1] + "+" + s[i + plus + 1:], plus + 1)

s = input()
n = len(s)

print(dfs(0, s, 0))
Buggy code:
s = input()
s_split = [s[i] for i in range(len(s))]
result = 0

for i in range(2**(len(s)-1)):
    b = bin(i)[2:]
    b = b.zfill(len(s)-1)
    tmp = s_split.copy()

    for j in range(len(b)-1, -1, -1):
        if b[j] == "1":
            print(b, j)
            tmp.insert(-j-1, "+")

    before = ""
    num = 0
    for x in range(len(tmp)):
        if tmp[x] == "+":
            num += int(before)
            before = ""
        else:
            before += tmp[x]
    if len(before) != 0:
        num += int(before)
    result += num
print(result)

Fixed code:
s = input()
s_split = [s[i] for i in range(len(s))]
result = 0

for i in range(2**(len(s)-1)):
    b = bin(i)[2:]
    b = b.zfill(len(s)-1)
    tmp = s_split.copy()

    for j in range(len(b)-1, -1, -1):
        if b[j] == "1":
            tmp.insert(-j-1, "+")

    before = ""
    num = 0
    for x in range(len(tmp)):
        if tmp[x] == "+":
            num += int(before)
            before = ""
        else:
            before += tmp[x]
    if len(before) != 0:
        num += int(before)
    result += num
print(result)
Buggy code:
s=input()
l=len(s)
ans=0
for i in range( 1<< (l-1)):
    temp=int(s[0])
    value=0
    for j in range(l-1):
        if i>>j &1:
            value+=temp
            temp=int(s[j+1])
        else :
            temp=10*temp+int(s[j+1])
    value+=temp
    ans+=value
    print(value)
    
print(ans)
    

Fixed code:
s=input()
l=len(s)
ans=0
for i in range( 1<< (l-1)):
    temp=int(s[0])
    value=0
    for j in range(l-1):
        if i>>j &1:
            value+=temp
            temp=int(s[j+1])
        else :
            temp=10*temp+int(s[j+1])
    value+=temp
    ans+=value
    
    
print(ans)
Buggy code:
s = input()
n = int(s)
r = 0

for bit in range(2**(len(s)-1)):
    e = s[0]
    for i in range(len(s)-1):
        if ((bit>>i)&1) == 1:
            e += '+'
        e += s[i+1]
        print(e)
    #r += sum(map(int, e.split('+')))
    r+= eval(e)
print(r)


Fixed code:
s = input()
n = int(s)
r = 0

for bit in range(2**(len(s)-1)):
    e = s[0]
    for i in range(len(s)-1):
        if ((bit>>i)&1) == 1:
            e += '+'
        e += s[i+1]
    r += sum(map(int, e.split('+')))
print(r)
Buggy code:
h, w, n = map(int,input().split())

xy_pos = dict()

for i in range(n):
    a, b = map(int, input().split())
    for k in range(-2,1):
        for l in range(-2,1):
            x = (a-1) + k
            y = (b-1) + l
            if (0 <= x <=(h-1)-2) and (0 <= y <=(w-1)-2):
                xy = str(x) + "x" + str(y)
                if xy in xy_pos:
                    xy_pos[xy] += 1
                else:
                    xy_pos[xy] = 1

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

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

xy_pos = dict()

for i in range(n):
    a, b = map(int, input().split())
    for k in range(-2,1):
        for l in range(-2,1):
            x = (a-1) + k
            y = (b-1) + l
            if (0 <= x <=(h-1)-2) and (0 <= y <=(w-1)-2):
                xy = str(x) + "x" + str(y)
                if xy in xy_pos:
                    xy_pos[xy] += 1
                else:
                    xy_pos[xy] = 1

ans = [0]*10                    
for v in xy_pos.values():
    ans[v] += 1
ans[0] = (h-2)*(w-2) - sum(ans)
for i in range(10):
    print(ans[i])
Buggy code:
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] >= w or x + i[0] < 0 or y + i[1] < 0 or y + i[1] >= h:
            continue
        else:
            d[(x+i[0], y + i[1])] += 1
num = [0]*9
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)


Fixed code:
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)
Buggy code:
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, 9 + 1)}
for v in memory.values():
    counter[v] += 1

for i in range(1, 9 + 1):
    print(counter[i])

Fixed code:
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])
Buggy code:
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
#print(A)
ans = [-1]
temp = list(A.values())
total = 0
for i in range(1,9):
  c = temp.count(i)
  total += c
  ans.append(c)
ans[0] = (H-2)*(W-2)-total
print(*ans, sep="\n")

  

Fixed code:
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
#print(A)
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")
Buggy code:
h, w, n = map(int, input().split())
a = {tuple(map(int, input().split())) for _ in range(n)}

d = {}
c = [0] * 9

def next(x, y):
    ret = []
    for i in range(max(0, x-2), min(h-2, x+1)):
        for j in range(max(0, y-2), min(w-2, y+1)):
            ret.append((i, j))
    return ret

for x, y in a:
    x -= 1
    y -= 1
    for s, t in next(x, y):
        if (s, t) not in d:
            count = 0
            for i in range(3):
                for j in range(3):
                    if (s + i + 1, t + j + 1) in a:
                        count += 1
            d[(s, t)] = count
            c[count] += 1

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

for x in c:
    print(x)

Fixed code:
h, w, n = map(int, input().split())
a = {tuple(map(int, input().split())) for _ in range(n)}

d = {}
c = [0] * 10

def next(x, y):
    ret = []
    for i in range(max(0, x-2), min(h-2, x+1)):
        for j in range(max(0, y-2), min(w-2, y+1)):
            ret.append((i, j))
    return ret

for x, y in a:
    x -= 1
    y -= 1
    for s, t in next(x, y):
        if (s, t) not in d:
            count = 0
            for i in range(3):
                for j in range(3):
                    if (s + i + 1, t + j + 1) in a:
                        count += 1
            d[(s, t)] = count
            c[count] += 1

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

for x in c:
    print(x)
Buggy code:
from collections import defaultdict

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

d = defaultdict(int)

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

cnt = [0] * 9
for v in d.values():
    cnt[v] += 1

cnt[0] = (h - 2) * (w - 2) - sum(cnt[1:])
print(*cnt, sep="\n")


Fixed code:
from collections import defaultdict

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

d = defaultdict(int)

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

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

cnt[0] = (h - 2) * (w - 2) - sum(cnt[1:])
print(*cnt, sep="\n")
Buggy code:
H,W,N = map(int,input().split())
Nli=[0 for j in range(9*N)]
q=0
for k in range(N):
    a,b=map(int,input().split())
    for n in range(-1,2):
        for m in range(-1,2):
            if 0<=a-2-m<H-2 and 0<=b-2-n<W-2:
                Nli[q]=(b-n)*(H)+(a-m)
                q+=1
print(Nli)
del Nli[q:]
print(Nli)
import collections
s = collections.Counter(Nli)
v = list(s.values())
print((H-2)*(W-2)-len(set(Nli)))
for k in range(1,10):
    print(v.count(k))

Fixed code:
H,W,N = map(int,input().split())
Nli=[0 for j in range(9*N)]
q=0
for k in range(N):
    a,b=map(int,input().split())
    for n in range(-1,2):
        for m in range(-1,2):
            if 0<=a-2-m<H-2 and 0<=b-2-n<W-2:
                Nli[q]=(b-n)*(H)+(a-m)
                q+=1
del Nli[q:]
import collections
s = collections.Counter(Nli)
v = list(s.values())
print((H-2)*(W-2)-len(set(Nli)))
for k in range(1,10):
    print(v.count(k))
Buggy code:
H,W,N = map(int,input().split())
B=[[0 for k in range(W-2)] for j in range(H-2)]
li=[-1,0,1]
Nli=[]
for k in range(N):
    a,b=map(int,input().split())
    for n in range(3):
        for m in range(3):
            if 0<=a-2-li[m]<H-2 and 0<=b-2-li[n]<W-2:
                Nli.append((b-2-li[n])*(H-2)+(a-2-li[m]))
import collections
s = collections.Counter(Nli)
v = list(s.values())
print((H-2)*(W-2)-len(set(Nli)))
for k in range(1,10):
    print(v.count(k))

Fixed code:
H,W,N = map(int,input().split())
Nli=[]
for k in range(N):
    a,b=map(int,input().split())
    for n in range(-1,2):
        for m in range(-1,2):
            if 0<=a-2-m<H-2 and 0<=b-2-n<W-2:
                Nli.append((b-n)*(H)+(a-m))
import collections
s = collections.Counter(Nli)
v = list(s.values())
print((H-2)*(W-2)-len(set(Nli)))
for k in range(1,10):
    print(v.count(k))
Buggy code:
from collections import *
h,w,n = map(int,input().split())
dic = defaultdict(int)
for _ in range(n):
  a,b = map(int,input().split())
  for i in range(9):
    dic[a - i //3,b - i % 3] += 1
ans =[0]*(n+1)
for i, j in dic:
  ans[dic[i,j]] += h-1 > i > 0 < j < w -1
ans[0] = (h -2)*(w-2) - sum(ans)
for item in ans:
  print(item)

Fixed code:
from collections import *
h,w,n = map(int,input().split())
dic = defaultdict(int)
for _ in range(n):
  a,b = map(int,input().split())
  for i in range(9):
    dic[a - i //3,b - i % 3] += 1
ans =[0]*10
for i, j in dic:
  ans[dic[i,j]] += h-1 > i > 0 < j < w -1
ans[0] = (h -2)*(w-2) - sum(ans)
for item in ans:
  print(item)
Buggy code:

f = lambda:map(int, input().split())

h, w, n = f()
d={}
while n:
    n -= 1
    x, y = f()
    for i in range(9):
        a = (x + i % 3, y + i // 3)
        d[a] = d.get(a, 0) + (h >= a[0] > 2 <a[1] <= w)
    c = [list(d.values()).count(i + 1) for i in range(9)]

print((h - 2) * (w - 2) - sum(c), *c)


Fixed code:
f=lambda:map(int,input().split())
h,w,n = f()

d={}
while n:
 n-=1
 x,y=f()
 for i in range(9):
     a=(x+i%3,y+i//3)
     d[a]=d.get(a,0)+(h>=a[0]>2<a[1]<=w)

c=[list(d.values()).count(i+1)for i in range(9)]

print((h-2)*(w-2)-sum(c))
for i in range(9):
    print(c[i])
Buggy code:
import sys
input = sys.stdin.readline
from collections import Counter
h,w,n=map(int,input().split())
c=Counter()
for _ in range(n):
    a,b=map(int,input().split())
    for i in [-1,0,1]:
        for j in [-1,0,1]:
            if 2<=a+i<w and 2<=b+j<h:
                c[a+i,b+j]+=1
#print(c.items())
c2=Counter(c.values())
print((h-2)*(w-2)-sum(c2.values()))
for i in range(1,10):
    print(c2[i])


Fixed code:
import sys
input = sys.stdin.readline
from collections import Counter
h,w,n=map(int,input().split())
c=Counter()
for _ in range(n):
    b,a=map(int,input().split())
    for i in [-1,0,1]:
        for j in [-1,0,1]:
            if 2<=a+i<w and 2<=b+j<h:
                c[a+i,b+j]+=1
#print(c.items())
c2=Counter(c.values())
print((h-2)*(w-2)-sum(c2.values()))
for i in range(1,10):
    print(c2[i])
Buggy code:
from collections import defaultdict

H,W,N = map(int,input().split())
D = defaultdict(bool)
B = []

for _ in range(N):
    a,b = map(lambda x: int(x)-1,input().split())
    D[(a,b)] = True
    B.append((a,b))

ans = [0 for _ in range(10)]

for a,b in B:
    for i in range(9):
        ix,iy = divmod(i,3)
        if a-ix<0 or b-iy<0:
            continue
        black_count = 0
        for j in range(9):
            jx,jy = divmod(j,3)
            if H<=a-ix+jx or W<=b-iy+jy:
                break
            if D[(a-ix+jx,b-iy+jy)]:
                if -ix+jx<0 or (-ix+jx==0 and -iy+jy<0):
                    print(a,b,ix,iy,jx,jy,-ix+jx,-iy+jy)
                    break
                black_count += 1
        else:
            ans[black_count] += 1

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

Fixed code:
from collections import defaultdict
import sys
input = sys.stdin.readline

H,W,N = map(int,input().split())
D = defaultdict(bool)
B = []

for _ in range(N):
    a,b = map(lambda x: int(x)-1,input().split())
    D[(a,b)] = True
    B.append((a,b))

ans = [0 for _ in range(10)]

for a,b in B:
    for i in range(9):
        ix,iy = divmod(i,3)
        if a-ix<0 or b-iy<0:
            continue
        black_count = 0
        for j in range(9):
            jx,jy = divmod(j,3)
            if H<=a-ix+jx or W<=b-iy+jy:
                break
            if (a-ix+jx,b-iy+jy) in D:
                if -iy+jy<0 or (-iy+jy==0 and -ix+jx<0):
                    break
                black_count += 1
        else:
            ans[black_count] += 1

ans[0] = (H-2)*(W-2)-sum(ans)
print(*ans,sep='\n')
Buggy code:
H, W, N = list(map(int, input().split()))
ans = {}
for i in range(N):
  a, b = list(map(int, input().split()))
  for j in range(-1, 2):
    for k in range(-1, 2):
      if a+j>=2 and b+k>=2 and a+j<=H-1 and b+k<=W-1:
        key = str(a+j) + "_" + str(b+k)
        ans[key] = ans.get(key, 0) + 1
ans_value = list(ans.values())
for i in range(10):
  print(ans_value.count(i))

Fixed code:
H, W, N = list(map(int, input().split()))
ans = {}
for i in range(N):
  a, b = list(map(int, input().split()))
  for j in range(-1, 2):
    for k in range(-1, 2):
      if (a+j)>=2 and (b+k)>=2 and (a+j)<=(H-1) and (b+k)<=(W-1):
        key = str(a+j) + "_" + str(b+k)
        ans[key] = ans.get(key, 0) + 1
ans_value = list(ans.values())
ans_n0 = 0
for i in range(1, 10):
  ans_n0 = ans_n0 + ans_value.count(i)
print((H-2)*(W-2)-ans_n0)
for i in range(1, 10):
  print(ans_value.count(i))
Buggy code:
H,W,N = map(int,input().split())
count = []
L = 0
for i in range(N):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    for i in range(max(0,a-2),min(a+1,H-2)):
        for j in range(max(0,b-2),min(b+1,W-2)):
            count.append((i,j))
            L += 1
count.sort()
ans = [0]*10
tmp = 0
for i in range(L-1):
    if count[i] == count[i+1]:
        tmp += 1
    else:
        ans[tmp] += 1
        tmp = 1
ans[tmp] += 1
ans[0] = (H-2)*(W-2)-sum(ans)
for i in range(10):
    print(ans[i])

Fixed code:
H,W,N = map(int,input().split())
count = []
L = 0
for i in range(N):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    for i in range(max(0,a-2),min(a+1,H-2)):
        for j in range(max(0,b-2),min(b+1,W-2)):
            count.append((i,j))
            L += 1
count.sort()
ans = [0]*10
tmp = 1
for i in range(L-1):
    if count[i] == count[i+1]:
        tmp += 1
    else:
        ans[tmp] += 1
        tmp = 1
if L>=1:
  ans[tmp] += 1
ans[0] = (H-2)*(W-2)-sum(ans)
for i in range(10):
    print(ans[i])
Buggy code:
H,W,N = map(int,input().split())
dic={}
for _ in range(N):
  a,b = [int(x)-1 for x in input().split()]
  for h in range(a,a+3):
    for w in range(b,b+3):
      if h<H and w<W:
        dic[10**10*h+w] = dic.get(10**10*h+w,0)+1
ans = [0]*10
for x in dic.values():
  ans[x] += 1
ans[0] = (H-2)*(W-2)-sum(ans[1:])
for x in ans:
  print(x)
        

Fixed code:
H,W,N = map(int,input().split())
dic={}
for _ in range(N):
  a,b = [int(x)-1 for x in input().split()]
  for h in range(a,a+3):
    for w in range(b,b+3):
      if 0<=h-2 and h<H and 0<=w-2 and w<W:
        dic[10**10*h+w] = dic.get(10**10*h+w,0)+1
ans = [0]*10
for x in dic.values():
  ans[x] += 1
ans[0] = (H-2)*(W-2)-sum(ans[1:])
for x in ans:
  print(x)