Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
import heapq
hqx=[]
hqy=[]
for i in range(n):
    x,y=map(int,input().split())
    heapq.heappush(hqx,(x,i))
    heapq.heappush(hqy,(y,i))
prex,prexi=heapq.heappop(hqx)
prey,preyi=heapq.heappop(hqy)
edges=[]#(cost,v1,v2)
for i in range(n-1):
    x,xi=heapq.heappop(hqx)
    y,yi=heapq.heappop(hqy)
    heapq.heappush(edges,(x-prex,prexi,xi))
    heapq.heappush(edges,(y-prey,preyi,yi))
    prex,prexi=x,xi
    prey,preyi=y,yi

frag=list(range(n+1))
fragnum=[0]*(n+1)

#以下でフラグ建設 フラグが同じなら同じチームである
def takefrag(p):
    stock=[]
    while frag[frag[p]]!=frag[p]:
        stock.append(p)
        p=frag[p]
    p=frag[p]
    for i in stock:
        frag[i]=p
    return p

count=0
ans=0
while True:
    cost,a,b=heapq.heappop(edges)
    f1,f2 = map(takefrag,(a,b))
    if f1!=f2:
        count+=1
        f1,f2 = min(f1,f2),max(f1,f2)
        frag[f1]=f2
        ans+=cost
    if count==n-1:
        break

print(ans)

Fixed submission:
n=int(input())
hqx=[]
hqy=[]
for i in range(n):
    x,y=map(int,input().split())
    hqx.append((x,i))
    hqy.append((y,i))
hqx.sort()
hqy.sort()
prex,prexi=hqx[0]
prey,preyi=hqy[0]
edges=[]#(cost,v1,v2)
for i in range(1,n):
    x,xi=hqx[i]
    y,yi=hqy[i]
    edges.append((x-prex,prexi,xi))
    edges.append((y-prey,preyi,yi))
    prex,prexi=x,xi
    prey,preyi=y,yi
edges.sort()

frag=list(range(n+1))
fragnum=[0]*(n+1)

def takefrag(p):
    stock=[]
    while frag[frag[p]]!=frag[p]:
        stock.append(p)
        p=frag[p]
    p=frag[p]
    for i in stock:
        frag[i]=p
    return p

count=0
ans=0
for i in range(2*n):
    cost,a,b=edges[i]
    f1,f2 = map(takefrag,(a,b))
    if f1!=f2:
        count+=1
        f1,f2 = min(f1,f2),max(f1,f2)
        frag[f1]=f2
        ans+=cost
    if count==n-1:
        break

print(ans)
Buggy python submission (verdict: Runtime Error):
n,m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

breakFlag = False
for i in range(1,m-1):
    if a[i]%2==1:
        if a[0]%2==1:
            if a[len(a)-1]%2==1:
                print("Impossible")
                breakFlag = True
                break
            else:
                a[i],a[len(a)-1] = a[len(a)-1],a[i]
        else:
            a[i],a[0] = a[0],a[i]

if breakFlag==False:
    ans = ''.join([str(s)+" " for s in a])
    print(ans[:-1])
    if a[len(a)-1]==1:
        print(m-1)
        a.pop()
        a[0]+=1
    else:
        print(m)
        a[0]+=1
        a[len(a)-1] -= 1
    ans = ''.join([str(s)+" " for s in a])
    print(ans[:-1])

Fixed submission:
n,m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

breakFlag = False
for i in range(1,m-1):
    if a[i]%2==1:
        if a[0]%2==1:
            if a[len(a)-1]%2==1:
                print("Impossible")
                breakFlag = True
                break
            else:
                a[i],a[len(a)-1] = a[len(a)-1],a[i]
        else:
            a[i],a[0] = a[0],a[i]

if breakFlag==False:
    ans = ''.join([str(s)+" " for s in a])
    print(ans[:-1])
    if m==1:
        if a[0]>1:
            a[0]-=1
            a.append(1)
            print(m+1)
        else:
            print(m)
    else:
        if a[len(a)-1]==1:
            print(m-1)
            a.pop()
            a[0]+=1
        else:
            print(m)
            a[0]+=1
            a[len(a)-1] -= 1
    ans = ''.join([str(s)+" " for s in a])
    print(ans[:-1])
Buggy python submission (verdict: Runtime Error):
s,w = map(int,input())
if w >= s:
    print('unsafe')
else:
    print('safe')


Fixed submission:
s,w = map(int,input().split())
if w >= s:
    print('unsafe')
else:
    print('safe')
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=[]
for i in range(N):
    S.append(str(input()))

S_set=set(S)

c_max=0
ans=[]
for i in S_set:
    c= S.count(i)
    if c > c_max:
        c_max = c
        ans=[]
        ans.append(i)
    elif c == c_max:
        ans.append(i)

ans=sorted(ans)
for j in ans:
    print(j)
    

Fixed submission:
a=sorted(list(map(int,input().split())))

if (a[0] != a[2] and a[1]==a[0] )or (a[0] != a[2] and a[1]==a[2] ):
    
    print('Yes')

else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=[]
for i in range(N):
    S.append(str(input()))

S_set=set(S)

c_max=0
ans=[]
for i in S_set:
    c= S.count(i)
    if c > c_max:
        c_max = c
        ans=[]
        ans.append(i)
    elif c == c_max:
        ans.append(i)

ans=sorted(ans)
for j in ans:
    print(j)
    

Fixed submission:
import collections

N=int(input())
S=[]
for i in range(N):
    S.append(str(input()))

c = collections.Counter(S)

ans = c.most_common()[0][1]

a=sorted([i[0] for i in c.items() if i[1] == ans])
            
for i in a:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=[]
for i in range(N):
    S.append(str(input()))

S_set=set(S)

c_max=0
ans=[]
for i in S_set:
    c= S.count(i)
    if c > c_max:
        c_max = c
        ans=[]
        ans.append(i)
    elif c == c_max:
        ans.append(i)

ans=sorted(ans)
for j in ans:
    print(j)
    


        
        
    




Fixed submission:
import collections

N=int(input())
S=[]
for i in range(N):
    S.append(str(input()))

c = collections.Counter(S)

ans = c.most_common()[0][1]

a=sorted([i[0] for i in c.items() if i[1] == ans])
            
for i in a:
    print(i)
Buggy python submission (verdict: Runtime Error):
import math
A,B=map(int,input().split())
gcd=math.gcd(A,B)
print(A*B//gcd)


Fixed submission:
import fractions
A,B=map(int,input().split())
gcd = fractions.gcd(A,B)
print(A*B//gcd)
Buggy python submission (verdict: Runtime Error):
import fractions
 
a,b = map(int,input().split())
g = fractions.gcd(a,b)
 
ans=[1]
p=2
while g != 1:
    if g%p == 0:
        ans.append(p)
        g = g//p
    else:
        p += 1
 
print(len(set(ans)))


Fixed submission:
N=int(input())
a=(N-1)//2 + 1
print(a/N)
Buggy python submission (verdict: Runtime Error):
n,x=map(int,input().split())
L=list(map(int,input().split()))
d=0
count=1
for i in range(n+1):
    d += L[i]

    if d > x:
        print(count)
        break
    else:
        count += 1
        

Fixed submission:
n,x=map(int,input().split())
L=list(map(int,input().split()))
d=0
count=1
for i in range(n):
    d += L[i]
 
    if d <= x:
        count += 1
    else:
        break

print(count)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
d=[0]*n
s=[0]*n

if k !=0:
    for i in range(k):
        p=int(input())
        d[p-1]=1

 
if d[0]==1:
    s[0]=0
else:
    s[0]=1
 
if d[1]==1:
    s[1]=0
else:
    s[1]= s[0]+1
 
 
for i in range(2,n):
    if d[i]==1:
        s[i]=0
    else:
        s[i]=(s[i-1]+s[i-2])%1000000007
 
print( s[n-1] % 1000000007)


Fixed submission:
n,k=map(int,input().split())
d=[0]*n
s=[0]*n

if k !=0:
    for i in range(k):
        p=int(input())
        d[p-1]=1

if n==1:
    print(1)
    exit()

 
if d[0]==1:
    s[0]=0
else:
    s[0]=1
 
if d[1]==1:
    s[1]=0
else:
    s[1]= s[0]+1
 
 
for i in range(2,n):
    if d[i]==1:
        s[i]=0
    else:
        s[i]=(s[i-1]+s[i-2])%1000000007
 
print( s[n-1] % 1000000007)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
d=[0]*n
s=[0]*n
for i in range(k):
    p=int(input())
    d[p-1]=1

 
if d[0]==1:
    s[0]=0
else:
    s[0]=1
 
if d[1]==1:
    s[1]=0
else:
    s[1]= s[0]+1
 
 
for i in range(2,n):
    if d[i]==1:
        s[i]=0
    else:
        s[i]=(s[i-1]+s[i-2])%1000000007
 
print( s[n-1] % 1000000007)


Fixed submission:
n,k=map(int,input().split())
d=[0]*n
s=[0]*n

if k !=0:
    for i in range(k):
        p=int(input())
        d[p-1]=1

if n==1:
    print(1)
    exit()

 
if d[0]==1:
    s[0]=0
else:
    s[0]=1
 
if d[1]==1:
    s[1]=0
else:
    s[1]= s[0]+1
 
 
for i in range(2,n):
    if d[i]==1:
        s[i]=0
    else:
        s[i]=(s[i-1]+s[i-2])%1000000007
 
print( s[n-1] % 1000000007)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
d=[]
s=[0]*n
for i in range(k):
    d.append(int(input()))

if 1 in d:
    s[0]=0
else:
    s[0]=1

if 2 in d:
    s[1]=0
else:
    s[1]= s[0]+1


for i in range(2,n):
    if i+1 in d:
        s[i]=0
    else:
        s[i]=(s[i-1]+s[i-2])%1000000007

print( s[n-1] % 1000000007)

  



Fixed submission:
n,k=map(int,input().split())
d=[0]*n
s=[0]*n

if k !=0:
    for i in range(k):
        p=int(input())
        d[p-1]=1

if n==1:
    print(1)
    exit()

 
if d[0]==1:
    s[0]=0
else:
    s[0]=1
 
if d[1]==1:
    s[1]=0
else:
    s[1]= s[0]+1
 
 
for i in range(2,n):
    if d[i]==1:
        s[i]=0
    else:
        s[i]=(s[i-1]+s[i-2])%1000000007
 
print( s[n-1] % 1000000007)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
d=[]
s=[0]*n
for i in range(k):
    d.append(int(input()))

if 1 in d:
    s[0]=0
else:
    s[0]=1

if 2 in d:
    s[1]=0
else:
    s[1]= s[0]+1


for i in range(2,n):
    if i+1 in d:
        s[i]=0
    else:
        s[i]=s[i-1]+s[i-2]

print( s[n-1] % (1000000007))


Fixed submission:
n,k=map(int,input().split())
d=[0]*n
s=[0]*n

if k !=0:
    for i in range(k):
        p=int(input())
        d[p-1]=1

if n==1:
    print(1)
    exit()

 
if d[0]==1:
    s[0]=0
else:
    s[0]=1
 
if d[1]==1:
    s[1]=0
else:
    s[1]= s[0]+1
 
 
for i in range(2,n):
    if d[i]==1:
        s[i]=0
    else:
        s[i]=(s[i-1]+s[i-2])%1000000007
 
print( s[n-1] % 1000000007)
Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N= map(int,input().split())

x_max= N//R
y_max= N//G
ans=0

for x in range(x_max+1):
    for y in range(y_max+1):

        z= (N-R*x-G*y)//B

        if z >=0 and (N-R*x-G*y)% B ==0:
            ans += 1

print(ans)

Fixed submission:
R,G,B,N= map(int,input().split())

x_max= N//R
y_max= N//G
ans=0

for x in range(x_max+1):
    for y in range(y_max+1):

        z= (N-R*x-G*y)//B

        if z >=0 and (N-R*x-G*y)% B ==0:
            ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
L=[]

ans=0

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

    L.append([a,b])

L= sorted(L)



for i in range(N):

    if M < L[i][1]
        ans=L[i][0]*M

        print(ans)
        exit()
        
    else:


        ans = L[i][0]*L[i][1]
        M -= L[i][1]


            if M==0:

                print(ans)
                exit()


            if M <= L[i+1][1]:

                ans += M * L[i+1][0]

                print(ans)

                exit()

        




Fixed submission:
N,M=map(int,input().split())
L=[]
ans=0

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

    L.append([a,b])

L= sorted(L)

for i in range(N):

    if M < L[i][1]:
        ans=L[i][0]*M

        print(ans)
        exit()
        
    else:
        ans += L[i][0]*L[i][1]
        M -= L[i][1]

        if M==0:

            print(ans)
            exit()

        elif M <= L[i+1][1]:

            ans += M * L[i+1][0]
            print(ans)
            exit()

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
L=[]

ans=0

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

    L.append([a,b])

L= sorted(L)



for i in range(N):

    ans = L[i][0]*L[i][1]
    M -= L[i][1]


    if M <= L[i+1][1]:

        ans += M * L[i+1][0]

        print(ans)

        exit()

Fixed submission:
N,M=map(int,input().split())
L=[]
ans=0

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

    L.append([a,b])

L= sorted(L)

for i in range(N):

    if M < L[i][1]:
        ans=L[i][0]*M

        print(ans)
        exit()
        
    else:
        ans += L[i][0]*L[i][1]
        M -= L[i][1]

        if M==0:

            print(ans)
            exit()

        elif M <= L[i+1][1]:

            ans += M * L[i+1][0]
            print(ans)
            exit()
Buggy python submission (verdict: Time Limit Exceeded):
s=str(input())
L=len(s)

while '01' in s or '10' in s:

    s=s.replace('10','')
    s=s.replace('01','')

Ls=len(s)

print(L-Ls)





Fixed submission:
s=str(input())

Rc=s.count('1')
Bc=s.count('0')

print(min(Rc,Bc)*2)
Buggy python submission (verdict: Runtime Error):
import math

n=int(input())
a=list(map(int,input().split()))

ans = a[0]

for i in range(1,n):
    ans = math.gcd(ans,a[i])

print(ans)

Fixed submission:
import fractions

n=int(input())
a=list(map(int,input().split()))

ans = a[0]

for i in range(1,n):
    ans = fractions.gcd(ans,a[i])

print(ans)

Buggy python submission (verdict: Runtime Error):
import fraction

n=int(input())
a=list(map(int,input().split()))

ans = a[0]

for i in range(1,n):
    ans = fraction.gcd(ans,a[i])

print(ans)



Fixed submission:
import fractions

n=int(input())
a=list(map(int,input().split()))

ans = a[0]

for i in range(1,n):
    ans = fractions.gcd(ans,a[i])

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,P = map(int,input().split())

if N==1:
    print(P)
else:
    pmax = int(P **(1/N)) +2
    ans=1 
    for i in range(1,pmax):
 
        if P % (i**N) == 0:
            ans = i
 
    print(ans)


Fixed submission:
N,P = map(int,input().split())

if N==1:
    print(P)
else:
    pmax = round(P **(1/N)) +1
    ans=1 
    for i in range(2,pmax):
 
        if P % (i**N) == 0:
            ans = i
 
    print(ans)
Buggy python submission (verdict: Runtime Error):
from operator import itemgetter

N,T=map(int,input().split())
a=[]
for i in range(N):
    c,t=map(int,input().split())
    a.append([c,t])

a=sorted(a,key=itemgetter(1))

key=0
ans=1001
while a[key][1]<=T:
    ans = min(ans,a[key][0])
    key += 1

if ans==1001:
    print('TLE')
else:
    print(ans)




    
      


Fixed submission:
N,T=map(int,input().split())
a=[]
for i in range(N):
    c,t=map(int,input().split())
    a.append([c,t])

cost=10000
for i in range(N):
    if a[i][1] <= T:
        cost = min(cost,a[i][0])



if cost==10000:
    print('TLE')
else:
    print(cost)

Buggy python submission (verdict: Runtime Error):
from operator import itemgetter

N,T=map(int,input().split())
a=[]
for i in range(N):
    c,t=map(int,input().split())
    a.append([c,t])

a=sorted(a,key=itemgetter(1))

key=0
ans=1001
while a[key][1]<=T:
    ans = min(ans,a[key][0])
    key += 1

if key==0:
    print('TLE')
else:
    print(ans)
    

Fixed submission:
N,T=map(int,input().split())
a=[]
for i in range(N):
    c,t=map(int,input().split())
    a.append([c,t])

cost=10000
for i in range(N):
    if a[i][1] <= T:
        cost = min(cost,a[i][0])



if cost==10000:
    print('TLE')
else:
    print(cost)

Buggy python submission (verdict: Runtime Error):
from operator import itemgetter

N,T=map(int,input().split())
a=[]
for i in range(N):
    c,t=map(int,input().split())
    a.append([c,t])

a=sorted(a,key=itemgetter(1))

key=0
ans=1001
while a[key][1]<=T:
    ans = min(ans,a[key][0])
    key += 1

if key==0:
    print('TLE')
else:
    print(ans)
    

Fixed submission:
N,T=map(int,input().split())
a=[]
for i in range(N):
    c,t=map(int,input().split())
    a.append([c,t])

cost=10000
for i in range(N):
    if a[i][1] <= T:
        cost = min(cost,a[i][0])



if cost==10000:
    print('TLE')
else:
    print(cost)
Buggy python submission (verdict: Runtime Error):
import fractions

n,x=map(int,input().split())
a=list(map(int,input().split()))

b=[]
for i in a:
    b.append(abs(x-i))

if n==1:
    print(abs(x-a[0]))

else:
    ans=fractions.gcd(b[0],b[1])

    for i in range(2,n):
        ans = fractions.gcd(ans ,b[i])

    print(ans)


    





Fixed submission:
a,b=map(int,input().split())
if a*b % 2 ==0:
    print('No')
else:
    print('Yes')
Buggy python submission (verdict: Runtime Error):
import fractions

n,x=map(int,input().split())
a=list(map(int,input().split()))

b=[]
for i in a:
    b.append(abs(x-i))

if n==1:
    print(abs(x-a[0]))

else:
    ans=fractions.gcd(b[0],b[1])

    for i in range(2,n):
        ans = math.gcd(ans ,b[i])

    print(ans)

Fixed submission:
import fractions

n,x=map(int,input().split())
a=list(map(int,input().split()))

b=[]
for i in a:
    b.append(abs(x-i))

if n==1:
    print(abs(x-a[0]))

else:
    ans=fractions.gcd(b[0],b[1])

    for i in range(2,n):
        ans = fractions.gcd(ans ,b[i])

    print(ans)
Buggy python submission (verdict: Runtime Error):
x1,y1,x2,y2=map(int,input().split())

xd= x2-x1
yd= y2-y1

if xd >=0 and yd >= 0:
    x3 = x2 - abs(yd)
    y3 = y2 + abs(xd)
    x4 = x1 - abs(yd)
    y4 = y1 + abs(xd)

elif xd < 0 and yd > 0:

    x3 = x2 - abs(yd)
    y3 = y2 - abs(xd)
    x4 = x1 - abs(yd)
    y4 = y1 - abs(xd)

elif xd < 0 and yd < 0:

    x3 = x2 + abs(yd)
    y3 = y2 - abs(xd)
    x4 = x1 + abs(yd)
    y4 = y1 - abs(xd)

elif xd >0 and yd < 0:

    x3 = x2 + abs(yd)
    y3 = y2 + abs(xd)
    x4 = x1 + abs(yd)
    y4 = y1 + abs(xd)


print(x3,y3,x4,y4)


Fixed submission:
x1,y1,x2,y2=map(int,input().split())

xd= x2-x1
yd= y2-y1

if xd >=0 and yd >= 0:
    x3 = x2 - abs(yd)
    y3 = y2 + abs(xd)
    x4 = x1 - abs(yd)
    y4 = y1 + abs(xd)

elif xd <= 0 and yd >= 0:

    x3 = x2 - abs(yd)
    y3 = y2 - abs(xd)
    x4 = x1 - abs(yd)
    y4 = y1 - abs(xd)

elif xd <= 0 and yd <= 0:

    x3 = x2 + abs(yd)
    y3 = y2 - abs(xd)
    x4 = x1 + abs(yd)
    y4 = y1 - abs(xd)

elif xd >= 0 and yd <= 0:

    x3 = x2 + abs(yd)
    y3 = y2 + abs(xd)
    x4 = x1 + abs(yd)
    y4 = y1 + abs(xd)


print(x3,y3,x4,y4)
Buggy python submission (verdict: Runtime Error):
S=str(input())
K=int(input())

for i in range(K):
    if S[i] != '1':
        print(S[i])
        exit()
elif len(S) > K:
    print(S[K])
else:
    print(S[K-1])



Fixed submission:
S=str(input())
K=int(input())

for i in range(K):
    if S[i] != '1':
        print(S[i])
        exit()
        
print(S[K-1])

Buggy python submission (verdict: Runtime Error):
S=str(input())
K=int(input())
if S[0]!= '1':
    print(S[0])
    exit()
    
else:
    count=0
    i=0
    while S[i] == '1':
        count += 1
        i += 1

if K <= count:
    print('1')
else:
    print(S[count])


Fixed submission:
S=str(input())
K=int(input())

for i in range(K):
    if S[i] != '1':
        print(S[i])
        exit()
        
print(S[K-1])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
x=list(map(int,input().split()))
a=sorted(x)

for i in x:
    p=a.index(i)

    if p< n//2:
        print(a[n//2])
    else:
        print(a[n//2-1])
        
        

Fixed submission:
n=int(input())
x=list(map(int,input().split()))
a=sorted(x)
ans={}

for i in range(n):

    if i<n//2:
        ans[a[i]]=a[n//2]
    else:
        ans[a[i]]=a[n//2-1]

for j in x:
    print(ans[j])
Buggy python submission (verdict: Runtime Error):
m=input()
print(48-m)


Fixed submission:
m=int(input())
print(48-m)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))

b=set(a)
ans =0
for i in b:
    c=a.count(i)
    if c>i:
        ans +=  c-i
    elif c<i:
        ans += c
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a=sorted(a)
a.append(-1)

count=1
ans=0

for i in range(0,n):
    if a[i+1]==a[i]:
        count += 1
    else:

        if count > a[i]:
            ans += count - a[i]
        elif count < a[i]:
            ans += count

        count = 1

print(ans)
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())

a=[['.' for x in range(w+2)]]

for i in range(h):
    b=list(str(input()))
    b= ['.']+b+['.']
    a.append(b)

footer=['.' for x in range(w+2)]
a.append(footer)
    

for i in range(1,w+1):
    ans=''
    for j in range(1,h+1):
        count=0
        if a[i][j]=='#':
            ans += '#'
        else:
            if a[i-1][j-1]=='#':
                count += 1
            if a[i][j-1]=='#':
                count += 1
            if a[i+1][j-1]=='#':
                count += 1
            if a[i-1][j]=='#':
                count += 1
            if a[i+1][j]=='#':
                count += 1
            if a[i-1][j+1]=='#':
                count += 1
            if a[i][j+1]=='#':
                count += 1
            if a[i+1][j+1]=='#':
                count += 1

            ans += str(count)

    print(ans)
    



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

a=[['.' for x in range(w+2)]]

for i in range(h):
    b=list(str(input()))
    b= ['.']+b+['.']
    a.append(b)

footer=['.' for x in range(w+2)]
a.append(footer)
    

for i in range(1,h+1):
    ans=''
    for j in range(1,w+1):
        count=0
        if a[i][j]=='#':
            ans += '#'
        else:
            if a[i-1][j-1]=='#':
                count += 1
            if a[i-1][j]=='#':
                count += 1
            if a[i-1][j+1]=='#':
                count += 1
            if a[i][j-1]=='#':
                count += 1
            if a[i][j+1]=='#':
                count += 1
            if a[i+1][j-1]=='#':
                count += 1
            if a[i+1][j]=='#':
                count += 1
            if a[i+1][j+1]=='#':
                count += 1

            ans += str(count)

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


N=int(input())
D=list(map(int,input().split()))
M=int(input())
T=list(map(int,input().split()))

TS=collections.Counter(T)

for i,k in TS.items():
    if k > D.count(i):
        print('NO')
        exit()

print('YES')


Fixed submission:
import collections

N=int(input())
D=list(map(int,input().split()))
M=int(input())
T=list(map(int,input().split()))

DS=collections.Counter(D)
TS=collections.Counter(T)

for i,k in TS.items():

    if k > DS[i]:
        print('NO')
        exit()

print('YES')

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
D=list(map(int,input().split()))
M=int(input())
T=list(map(int,input().split()))

for i in T:
    if T.count(i)>D.count(i):
        print('NO')
        exit()

print('YES')


Fixed submission:
import collections

N=int(input())
D=list(map(int,input().split()))
M=int(input())
T=list(map(int,input().split()))

DS=collections.Counter(D)
TS=collections.Counter(T)

for i,k in TS.items():

    if k > DS[i]:
        print('NO')
        exit()

print('YES')

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
D=list(map(int,input().split()))
M=int(input())
T=list(map(int,input().split()))
TS=set(T)
for i in TS:
    if T.count(i)>D.count(i):
        print('NO')
        exit()

print('YES')

Fixed submission:
import collections

N=int(input())
D=list(map(int,input().split()))
M=int(input())
T=list(map(int,input().split()))

DS=collections.Counter(D)
TS=collections.Counter(T)

for i,k in TS.items():

    if k > DS[i]:
        print('NO')
        exit()

print('YES')
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
for n in range(1,3501):
    for w in range(1,3501):
        if n*(4*w-N)-N*w==0:
            continue
        if N*n*w % (n*(4*w-N)-N*w) ==0:
            h= (N*n*w) // (n*(4*w-N)-N*w)
            if h>=1:
                print(h,n,w)
                exit()


Fixed submission:
N=int(input())
for n in range(1,3501):
    for w in range(1,3501):
        if n*(4*w-N)-N*w==0:
            continue
        if N*n*w % (n*(4*w-N)-N*w) ==0:
            h= (N*n*w) // (n*(4*w-N)-N*w)
            if h>=1:
                print(h,n,w)
                exit()
Buggy python submission (verdict: Runtime Error):
    n=int(input())
    buff=set()
    for i in range(n):
        a=int(input())
        if a in buff:
            buff.remove(a)
        else:
            buff.add(a)
     
    print(len(buff))

Fixed submission:
n=int(input())
buff=[]
ans=1
for i in range(n):
    buff.append(input())

a=sorted(buff)

for i in range(1,n):
    if a[i] == a[i-1]:
        a[i-1]= -1
        a[i]= -1
        if ans>0:
            ans -= 1
    else:
        ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
buff=[]
for i in range(n):
    a=int(input())
    if a in buff:
        buff.remove(a)
    else:
        buff.append(a)

print(len(buff))

Fixed submission:
n=int(input())
buff=[]
ans=1
for i in range(n):
    buff.append(input())

a=sorted(buff)

for i in range(1,n):
    if a[i] == a[i-1]:
        a[i-1]= -1
        a[i]= -1
        if ans>0:
            ans -= 1
    else:
        ans += 1

print(ans)