Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
a = list(map(int,input().split()))
a.sort()

for i in range(m):
    cnt = 0
    b,c = map(int, input().split())
    for j in range(n):
        if a[j] < c:
            a[j] = c
            cnt += 1
            if cnt >= b:
                break
        else:
            break
    a.sort()

print(sum(a))


Fixed submission:
n,m = map(int, input().split())
a = list(map(int,input().split()))
a.sort()
ans = 0
tmp = []
tm = 0
for i in range(m):
    cnt = 0
    b,c = map(int, input().split())
    tmp.append([b,c])

tmp = sorted(tmp, reverse = True, key = lambda x : x[1])
cnt = 0
for i in range(n):
    if a[i] < tmp[cnt][1]:
        a[i] = tmp[cnt][1]
        tmp[cnt][0] -= 1
        if tmp[cnt][0] == 0:
            cnt += 1
            if cnt == m:
                break
    else:
        break

print(sum(a))
Buggy python submission (verdict: Runtime Error):
input();a=sorted(map(int,input().split()));print("{} {} {}".format(a[0],a[-1],sum(a)))

Fixed submission:
n,k = map(int, input().split())
s = list(input())
if s[k-1] == "A":
    s[k-1] = 'a'
elif s[k-1] == "B":
    s[k-1] = 'b'
else:
    s[k-1] = 'c'

print("".join(s))
Buggy python submission (verdict: Runtime Error):
import math

a = []
b = []
ans = 0
for i in range(5):
    a.append(int(input()))
ans = sum(a)
for i in range(5):
    tmp = a[i] % 10
    if tmp != 0:
        b.append(10 - tmp)
print(ans + sum(b) - max(b))


Fixed submission:
import math

a = []
b = []
ans = 0
for i in range(5):
    a.append(int(input()))
ans = sum(a)
for i in range(5):
    tmp = a[i] % 10
    if tmp != 0:
        b.append(10 - tmp)
if len(b) == 0:
    print(ans)
else:
    print(ans + sum(b) - max(b))
Buggy python submission (verdict: Runtime Error):
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
anss = []

a.sort(reverse = True)
b.sort(reverse = True)
c.sort(reverse = True)

for i in range(x):
    for j in range(y):
        for l in range(z):
            if i + j + l + 3 <= k:
                anss.append(a[i] + b[j] + c[l])
            else:
                break
anss.sort(reverse = True)

for i in range(k):
    print(anss[i])


Fixed submission:
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
anss = []

a.sort(reverse = True)
b.sort(reverse = True)
c.sort(reverse = True)

for i in range(x):
    for j in range(y):
        for l in range(z):
            if (i + 1) * (j + 1) * (l + 1) <= k:
                anss.append(a[i] + b[j] + c[l])
            else:
                break
anss.sort(reverse = True)

for i in range(k):
    print(anss[i])

Buggy python submission (verdict: Runtime Error):
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
anss = []

a.sort(reverse = True)
b.sort(reverse = True)
c.sort(reverse = True)

for i in range(x):
    for j in range(y):
        for l in range(z):
            if i + j + l + 3 <= k:
                anss.append(a[i] + b[j] + c[l])
            else:
                break
anss.sort(reverse = True)

for i in range(k):
    print(anss[i])


Fixed submission:
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
anss = []

a.sort(reverse = True)
b.sort(reverse = True)
c.sort(reverse = True)

for i in range(x):
    for j in range(y):
        for l in range(z):
            if (i + 1) * (j + 1) * (l + 1) <= k:
                anss.append(a[i] + b[j] + c[l])
            else:
                break
anss.sort(reverse = True)

for i in range(k):
    print(anss[i])

Buggy python submission (verdict: Runtime Error):
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
anss = []

a.sort(reverse = True)
b.sort(reverse = True)
c.sort(reverse = True)

for i in range(x):
    for j in range(y):
        for l in range(z):
            if i + j + l + 3 <= k:
                anss.append(a[i] + b[j] + c[l])

anss.sort(reverse = True)

for i in range(k):
    print(anss[i])


Fixed submission:
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
anss = []

a.sort(reverse = True)
b.sort(reverse = True)
c.sort(reverse = True)

for i in range(x):
    for j in range(y):
        for l in range(z):
            if (i + 1) * (j + 1) * (l + 1) <= k:
                anss.append(a[i] + b[j] + c[l])
            else:
                break
anss.sort(reverse = True)

for i in range(k):
    print(anss[i])
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
while(len(a) != 1):
    a.sort()
    for i in range(1, len(a) - 1):
        a[i] = a[i] % a[0]
        if a[i] <= 0:
            del a[i]
    if len(a) == 2:
        a[1] = a[1] % a[0]
        a.sort()
        if a[0] == 0:
            del a[0]
            break
        a[1] = a[1] % a[0]
        a.sort()
        del a[1]
    if len(a) == 1:
        break
    
print(a[0])


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
s = a
while(len(a) != 1):
    a = s
    s = []
    a.sort()
    for i in range(len(a)):
        if i == 0:
            pass
        else:
            a[i] = a[i] % a[0]
    # print(len(a))
    for j in range(len(a)):
        if a[j] > 0:
            s.append(a[j])
    if len(a) == 1:
        break
print(a[0])
Buggy python submission (verdict: Runtime Error):
import sys

n, m = map(int, input().split())
x = list(map(int, input().split()))
if m == 1:
    print(0)
    sys.exit()
if n == 1:
    print(max(x) - min(x))
    sys.exit()
x.sort()
a = []
for i in range(m - 1):
    a.append(abs(x[i] - x[i + 1]))
ans = sum(a)
a.sort(reverse=True)
for i in range(n - 1):
    ans -= a[i]
print(max(0, ans))


Fixed submission:
import sys

n, m = map(int, input().split())
x = list(map(int, input().split()))
if m == 1:
    print(0)
    sys.exit()
if n == 1:
    print(max(x) - min(x))
    sys.exit()
if n >= m:
    print(0)
    sys.exit()
x.sort()
a = []
for i in range(m - 1):
    a.append(abs(x[i] - x[i + 1]))
ans = sum(a)
a.sort(reverse=True)
for i in range(n - 1):
    ans -= a[i]
print(max(0, ans))

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

n, m = map(int, input().split())
x = list(map(int, input().split()))
if m == 1:
    print(0)
    sys.exit()
x.sort()
a = []
for i in range(m - 1):
    a.append(abs(x[i] - x[i + 1]))
ans = sum(a)
a.sort(reverse=True)
for i in range(n - 1):
    ans -= a[i]
print(ans)


Fixed submission:
import sys

n, m = map(int, input().split())
x = list(map(int, input().split()))
if m == 1:
    print(0)
    sys.exit()
if n == 1:
    print(max(x) - min(x))
    sys.exit()
if n >= m:
    print(0)
    sys.exit()
x.sort()
a = []
for i in range(m - 1):
    a.append(abs(x[i] - x[i + 1]))
ans = sum(a)
a.sort(reverse=True)
for i in range(n - 1):
    ans -= a[i]
print(max(0, ans))
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n = int(input())
h = list(map(int, input().split()))
if n == 1:
    print(h[0])
else:
    ans = h[0]
    for i in range(1, n):
        if h[i] > h[i-1]:
            ans += h[i] - h[i-1]
print(ans)


Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
h = list(map(int, input().split()))
if n == 1:
    print(h[0])
else:
    ans = h[0]
    for i in range(1, n):
        if h[i] > h[i-1]:
            ans += h[i] - h[i-1]
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,w = map(int,input().split())
weight = [0] * n
value = [0] * n
dp = [ [0 for i in range(w + 1)] for j in range(n + 1)]
for i in range(n):
    weight[i], value[i] = map(int, input().split())

for i in range(n):
    for w in range(w + 1):
        if weight[i] <= w:
            dp[i + 1][w] = max(dp[i][w - weight[i]] + value[i], dp[i][w])
        else:
            dp[i + 1][w] = dp[i][w]
print(dp[n][w])


Fixed submission:
N,W=map(int,input().split())
weight=[0]*N
value=[0]*N
for i in range(N):
    weight[i],value[i]=map(int,input().split())
dp=[[0 for i in range(W+1)] for j in range(N+1)]
for i in range(W+1):
    dp[0][i]=0

for i in range(N):
    for w in range(W+1):
        if weight[i]<=w:
            dp[i+1][w]=max(dp[i][w-weight[i]]+value[i], dp[i][w])
        else:
            dp[i+1][w]=dp[i][w]
print(dp[N][W])

Buggy python submission (verdict: Time Limit Exceeded):
N,W=map(int,input().split())
weight=[0]*N
value=[0]*N
for i in range(N):
    weight[i],value[i]=map(int,input().split())
dp=[[0 for i in range(W+1)] for j in range(N+1)]
for i in range(W+1):
    dp[0][i]=0

for i in range(N):
    for w in range(W+1):
        if weight[i]<=w:
            dp[i+1][w]=max(dp[i][w-weight[i]]+value[i], dp[i][w])
        else:
            dp[i+1][w]=dp[i][w]
print(dp[N][W])


Fixed submission:
N,W=map(int,input().split())
weight=[0]*N
value=[0]*N
for i in range(N):
    weight[i],value[i]=map(int,input().split())
dp=[[0 for i in range(W+1)] for j in range(N+1)]
for i in range(W+1):
    dp[0][i]=0

for i in range(N):
    for w in range(W+1):
        if weight[i]<=w:
            dp[i+1][w]=max(dp[i][w-weight[i]]+value[i], dp[i][w])
        else:
            dp[i+1][w]=dp[i][w]
print(dp[N][W])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input  =  sys.stdin.readline

s = input()
t = input()
dp = [[0]*(len(t) + 1) for i in range(len(s) + 1)]
for i in range(1,len(dp)):
    for j in range(1,len(t) + 1):
        if s[i - 1] == t[j - 1]:
            dp[i][j] = dp[i - 1][j - 1] + 1
        else:
            dp[i][j] = max(dp[i - 1][j],dp[i][j - 1])
out = ''
i = len(s)
j = len(t)
while i != 0 and j != 0:
    if s[i - 1] == t[j - 1]:
        out += s[i - 1]
        i -= 1
        j -= 1
    elif dp[i][j - 1]>dp[i - 1][j]:
        j -= 1
    else:
        i -= 1
print(out[::-1])


Fixed submission:
import sys
input  =  sys.stdin.readline

s = input()
t = input()
dp = [[0]*(len(t) + 1) for i in range(len(s) + 1)]
for i in range(1,len(dp)):
    for j in range(1,len(t) + 1):
        if s[i - 1] == t[j - 1]:
            dp[i][j] = dp[i - 1][j - 1] + 1
        else:
            dp[i][j] = max(dp[i - 1][j],dp[i][j - 1])
out = ''
i = len(s)
j = len(t)
while i != 0 and j != 0:
    if s[i - 1] == t[j - 1]:
        out += s[i - 1]
        i -= 1
        j -= 1
    elif dp[i][j - 1]>dp[i - 1][j]:
        j -= 1
    else:
        i -= 1
print(out[::-1])
Buggy python submission (verdict: Runtime Error):
print(input().count(2))

Fixed submission:
n = input()
n = list(n)
print(n.count('2'))
Buggy python submission (verdict: Runtime Error):
import sympy

n, p = map(int, input().split())
a = sympy.factorint(p)
ans = 1
for i, j in a.items():
    if j >= n:
        ans *= i
print(ans)


Fixed submission:
def usage():
    c, n = map(int, input().split())
    if c == 1:
        print(n)
        return 0
    ans = 1
    fct = factorize(n)
    for i in range(len(fct)):
        if fct[i][1] >= c:
            ans *= fct[i][0] ** (fct[i][1] // c)
    print(ans)


def factorize(n):
    fct = []
    b, e = 2, 0
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


if __name__ == '__main__':
    usage()
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=m//n
ans=1
for i in range(1,a+1):
    if m%i==0:
        ans=max(ans,i)
print(ans)


Fixed submission:
import sys
n,m=map(int,input().split())
a=m//n
ans=1
if m%n==0:
  print(int(m//n))
  sys.exit()
for i in range(1,a+1):
    if m%i==0:
        ans=max(ans,i)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=m//n
ans=1
for i in range(1,a+1):
    if m%i==0:
        ans=max(ans,i)
print(ans)


Fixed submission:
import sys
n,m=map(int,input().split())
a=m//n
ans=1
if m%n==0:
  print(int(m//n))
  sys.exit()
for i in range(1,a+1):
    if m%i==0:
        ans=max(ans,i)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
from collections import Counter
s=input()
t=input()
s1=set(s)
t1=set(t)
if s==t:
    print('Yes')
    sys.exit()
qu2=[]
if len(s1)==len(t1):
    for i in s:
        if s.count(i)>1:
            qu=[j for j,e in enumerate(s) if e==i]
            for j in qu:
                j=int(j)
                qu2.append(t[j])
            qu3=set(qu2)
            if len(qu3)!=1:
                print('No')
                sys.exit()
            else:
                qu3.clear()
        qu2=[]
        qu=[]
    print('Yes')
elif len(s1)!=len(t1):
    print('No')


Fixed submission:
import sys
import numpy as np
from collections import Counter
s=input()
t=input()
s1=set(s)
t1=set(t)
if s==t:
    print('Yes')
    sys.exit()
qu2=[]
if len(s1)==len(t1):
    for i in s1:
        if s.count(i)>1:
            qu=[j for j,e in enumerate(s) if e==i]
            for j in qu:
                j=int(j)
                qu2.append(t[j])
            qu3=set(qu2)
            if len(qu3)!=1:
                print('No')
                sys.exit()
            else:
                qu3.clear()
        qu2=[]
        qu=[]
    print('Yes')
elif len(s1)!=len(t1):
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.append(0)
comb=list(itertools.combinations_with_replacement(a,n))
ans=[]
for i in comb:
    per=sum(i)
    if per==x:
        if 0 in i:
            ans.append(len(set(i))-1)
        else:
            ans.append(len(set(i)))
if len(ans)==0:
    print(0)
else:
    print(max(ans))


Fixed submission:
cnt=0
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
for i,j in enumerate(a):
    if x>=j:
        x-=j
        cnt+=1
        if i==(n-1) and x>0:
            cnt-=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
import math
n,x=map(int,input().split())
a=list(map(int,input().split()))
dis1=x-min(a)
dis2=max(a)-x
print(math.gcd(dis1,dis2))


Fixed submission:
from functools import reduce
from fractions import gcd
n,x=map(int,input().split())
a=list(map(int,input().split()))
dist=[]
for i in range(n):
    dist.append(abs(x-a[i]))
print(reduce(gcd,dist))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n,k=map(int,input().split())
aa=k/2
a=[]
b=[]
if k%2==0:
    for i in range(1,n+1):
        if i%k==0:
            a.append(i)
        elif i%k==aa:
            b.append(i)
else:
    for i in range(1,n+1):
        if i%k==0:
            a.append(i)
print(len(list(itertools.product(a,repeat=3)))+len(list(itertools.product(b,repeat=3))))


Fixed submission:
import itertools
n,k=map(int,input().split())
aa=k/2
a=[]
b=[]
if k%2==0:
    for i in range(1,n+1):
        if i%k==0:
            a.append(i)
        elif i%k==aa:
            b.append(i)
else:
    for i in range(1,n+1):
        if i%k==0:
            a.append(i)
tot=len(set(a))**3+len(set(b))**3
print(tot)
Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
ans=(A-1)*(B-1)
print(ans)


Fixed submission:
A,B=map(int,input().split())

ans=(A-1)*(B-1)
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=0
cnt=1
for i in range(n):
    if a[i]==a[i+1]:
        cnt+=1
    else:
        ans+=cnt/2
        cnt=1
print(cnt)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=0
cnt=0
for i in range(1,n):
    if a[i]==a[i-1]:
        cnt+=1
        a[i]=0
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=list(input())
s1=[]
s2=[]
for i in s:
    if i=='W':
        s1.append(0)
    else:
        s1.append(1)
#print(s1)
for i in range(n):
    tmp1=i-sum(s1[0:i])
    tmp2=abs(0-sum(s1[i+1:n]))
    #print("tmp1:{} tmp2:{}".format(tmp1,tmp2))
    s2.append(tmp1+tmp2)
print(min(s2))


Fixed submission:
n=int(input())
s=list(input())
p=s.count('E')
ans=p
for i in s:
    if i=="E":
        p-=1
    else:
        p+=1
    ans=min(p,ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b=map(int(input()).split());print([a-1,a][b>=a])


Fixed submission:
a,b=map(int,input().split());print([a-1,a][b>=a])

Buggy python submission (verdict: Runtime Error):
a,b=map(int(input()));print([a-1,a][b>=a])

Fixed submission:
a,b=map(int,input().split());print([a-1,a][b>=a])

Buggy python submission (verdict: Runtime Error):
a,b=map(int(input()));print(min(a,b)-1)

Fixed submission:
a,b=map(int,input().split());print([a-1,a][b>=a])
Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
s=range(a,b+1)
for i in sorted(set(s[:k]) | set(a[-k:])):
    print(i)


Fixed submission:
a,b,k=map(int,input().split())
s=range(a,b+1)
for i in sorted(set(s[:k]) | set(s[-k:])):
    print(i)

Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
s=range(a,b+1)
for i in sorted(set(s[:k])|set(a[:-k])):
    print(i)


Fixed submission:
a,b,k=map(int,input().split())
s=range(a,b+1)
for i in sorted(set(s[:k]) | set(s[-k:])):
    print(i)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
if n==1 and m==1:
    print(1)
elif n==1 and m!=1:
    print(m-2)
else:
    print((n-2)(m-2))


Fixed submission:
n,m=map(int,input().split())
print(abs((n-2)*(m-2)))
Buggy python submission (verdict: Time Limit Exceeded):
q=int(input())
b=[]
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
a=primes(100000)
for i in range(q):
    l,r=map(int,input().split())
    cnt=0
    for j in a:
        if l<=j<=r:
            if (j+1)//2 in a:
                cnt+=1
        if r<=j:
            break
    print(cnt)


Fixed submission:
import math
p=[0 for k in range(100000)]
p[1]=1
for k in range(3,100000,2):
    f=1
    for l in range(2,int(math.sqrt(k))+1):
        if k%l==0:
            f=0
            break
    if f==1:
        p[k]=1
c=[0 for k in range(100000)]
c[3]=1
for k in range(3,100000,2):
    if p[k] and p[(k+1)//2]:
        c[k]=1
for k in range(1,100000):
    c[k]+=c[k-1]
for k in range(int(input())):
    l,r=map(int,input().split())
    print(c[r]-c[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
q=int(input())
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
a=primes(100000)
for i in range(q):
    l,r=map(int,input().split())
    cnt=0
    for j in a:
        if l<=j<=r:
            if (j+1)//2 in a:
                cnt+=1
    print(cnt)


Fixed submission:
import math
p=[0 for k in range(100000)]
p[1]=1
for k in range(3,100000,2):
    f=1
    for l in range(2,int(math.sqrt(k))+1):
        if k%l==0:
            f=0
            break
    if f==1:
        p[k]=1
c=[0 for k in range(100000)]
c[3]=1
for k in range(3,100000,2):
    if p[k] and p[(k+1)//2]:
        c[k]=1
for k in range(1,100000):
    c[k]+=c[k-1]
for k in range(int(input())):
    l,r=map(int,input().split())
    print(c[r]-c[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[]
kind=set(a)
c=len(kind)
ans=0
if len(kind)<=k:
    print(0)
else:
    for i in kind:
        b.append(a.count(i))
    b.sort()
    for i in range(c-k):
        ans+=b[i]
    print(ans)


Fixed submission:
from collections import Counter
n,k=map(int,input().split())
a=list(map(int,input().split()))
c=len(set(a))
b=dict(Counter(a).most_common())
d=list(b.values())
d.sort()
if c<=k:
    print(0)
else:
    tmp=c-k
    ans=0
    for i in range(tmp):
        ans+=d[i]
    print(ans)
Buggy python submission (verdict: Runtime Error):
a=input()
b=input()
print(["NO","YES"][a==a[::-1] and b=b[::-1]])

Fixed submission:
a=input()
b=input()
print(["NO","YES"][b==a[::-1] and a==b[::-1]])
Buggy python submission (verdict: Runtime Error):
g,r=map(int,input().split())
A=["."]*(r+2)
for i in range(g):
  w="."+input()+"."
  A.append(w)
A.append("."*(r+2))
for i in range(1,g+1):
  for j in range(1,r+1):
    if A[i][j]==".":
      B=[]
      for m in [i-1,i,i+1]:
        for k in [j-1,j,j+1]:
          B.append(A[m][k])
      A[i]=A[i][1:r+1:].replace(".",str(B.count("#")),1)
      A[i]="."+A[i]+"."
for i in range(1,g+1):
  print(A[i][1:r+1:])


Fixed submission:
g,r=map(int,input().split())
A=["."*(r+2)]
for i in range(g):
    w="."+input()+"."
    A.append(w)
A.append("."*(r+2))
for i in range(1,g+1):
    for j in range(1,r+1):
        if A[i][j]==".":
            B=[]
            for m in [i-1,i,i+1]:
                for k in [j-1,j,j+1]:
                    B.append(A[m][k])
            A[i]=A[i][1:r+1:].replace(".",str(B.count("#")),1)
            A[i]="."+A[i]+"."
for i in range(1,g+1):
    print(A[i][1:r+1:])
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
a,B,ans = [[] for _ in range(n)],[],0
def solve(v,a,b):
    visited[v] = True
    for n in a[v]:
        if not visited[n] and set([v,n]) != set([a,b]):
            solve(n,a,b)

for i in range(m):
    a,b = map(int,input().split())
    a[a-1].append(b-1)
    a[b-1].append(a-1)
    B.append((a-1,b-1))

for i in range(m):
    visited = [True]+[False]*(n-1)
    a,b = B[i]
    solve(0,a,b)
    if visited != [True]*n:
        ans += 1

print(ans)


Fixed submission:
n,m = map(int,input().split())
a,b,ans = [[] for _ in range(n)],[],0
def solve(v,aa,bb):
    visited[v] = True
    for n in a[v]:
        if not visited[n] and set([v,n]) != set([aa,bb]):
            solve(n,aa,bb)

for i in range(m):
    x,y = map(int,input().split())
    a[x-1].append(y-1)
    a[y-1].append(x-1)
    b.append((x-1,y-1))

for i in range(m):
    visited = [True]+[False]*(n-1)
    x,y = b[i]
    solve(0,x,y)
    if visited != [True]*n:
        ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
tmp = []

for i in range(n):
    a = int(input())
    tmp = list(set(tmp))
    if not (a in tmp):
        tmp.append(a)
    else:
        tmp.remove(a)

print(len(tmp))


Fixed submission:
n=int(input())
a=set()
for i in range(n):
    b=int(input())
    if b in a:
        a.remove(b)
    else:
        a.add(b)
print(len(a))

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


Fixed submission:
n=int(input())
a=set()
for i in range(n):
    b=int(input())
    if b in a:
        a.remove(b)
    else:
        a.add(b)
print(len(a))
Buggy python submission (verdict: Runtime Error):
import sys
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
for i in range(n-1):
    if a[i]=a[i+1]:
        a[i+1]==0
    else:
        a[i]=0
a.sort(reverse=True)
print(a[0]*a[1])


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
for i in range(n-1):
    if a[i]==a[i+1]:
        a[i+1]=0
    else:
        a[i]=0
a.sort()
a.reverse()
print(a[0]*a[1])