Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
bingo_list = [list(map(int,input().split())) for i in range(3)]
bingo_list = sum(bingo_list,[])
n = int(input())
bingo_number = [int(input())for i in range(n)]
check_list = [0 for i in range(9)]

for j in bingo_number:
    if j in bingo_list:
        check_list[bingo_list.index(j)] = 1

if [1,1,1] in [check_list[:3],check_list[3:6],check_list[6:],check_list[0:7:3],check_list[1:8:3]check_list[2:9:3],check_list[0:9:4],check_list[2:8:2]]:
    print('Yes')
else:
    print('No')

Fixed submission:
bingo_list = [list(map(int,input().split())) for i in range(3)]
bingo_list = sum(bingo_list,[])
n = int(input())
bingo_number = [int(input())for i in range(n)]
check_list = [0 for i in range(9)]

for j in bingo_number:
    if j in bingo_list:
        check_list[bingo_list.index(j)] = 1

if  [1,1,1]  in [check_list[:3], check_list[3:6], check_list[6:], check_list[0:7:3], check_list[1:8:3],check_list[2:9:3],check_list[0:9:4],check_list[2:7:2]]:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
bingo_list = [list(map(int,input().split())) for i in range(3)]
bingo_list = sum(bingo_list,[])
n = int(input())
bingo_number = [int(input())for i in range(n)]
check_list = [0 for i in range(9)]

for j in bingo_number:
    if j in bingo_list:
        check_list[bingo_list.index(j)] = 1

if [1,1,1]in [check_list[:3],check_list[3:6],check_list[6:],check_list[0:7:3],check_list[1:8:3]check_list[2:9:3],check_list[0:9:4],check_list[2:7:2]]:
    print('Yes')
else:
    print('No')

Fixed submission:
bingo_list = [list(map(int,input().split())) for i in range(3)]
bingo_list = sum(bingo_list,[])
n = int(input())
bingo_number = [int(input())for i in range(n)]
check_list = [0 for i in range(9)]

for j in bingo_number:
    if j in bingo_list:
        check_list[bingo_list.index(j)] = 1

if  [1,1,1]  in [check_list[:3], check_list[3:6], check_list[6:], check_list[0:7:3], check_list[1:8:3],check_list[2:9:3],check_list[0:9:4],check_list[2:7:2]]:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
bingo_list = [list(map(int,input().split())) for i in range(3)]
bingo_list = sum(bingo_list,[])
n = int(input())
bingo_number = [int(input())for i in range(n)]
check_list = [0 for i in range(9)]

for j in bingo_number:
    if j in bingo_list:
        check_list[bingo_list.index(j)] = 1

if [1,1,1]in [check_list[:3],check_list[3:6],check_list[6:],
             check_list[0:7:3],check_list[1:8:3]check_list[2:9:3],
             check_list[0:9:4],check_list[2:7:2]]:
    print('Yes')
else:
    print('No')

Fixed submission:
bingo_list = [list(map(int,input().split())) for i in range(3)]
bingo_list = sum(bingo_list,[])
n = int(input())
bingo_number = [int(input())for i in range(n)]
check_list = [0 for i in range(9)]

for j in bingo_number:
    if j in bingo_list:
        check_list[bingo_list.index(j)] = 1

if  [1,1,1]  in [check_list[:3], check_list[3:6], check_list[6:], check_list[0:7:3], check_list[1:8:3],check_list[2:9:3],check_list[0:9:4],check_list[2:7:2]]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
X = list(map(int,input().split()))
ans = []

for i in range(min(X),max(X)+1):
    ans.append(cnt)
    cnt = 0
    for j in X:
        cnt += (j-i)**2
    #ans.append(cnt)
        
print(min(ans))            
        

Fixed submission:
N = int(input())
X = list(map(int,input().split()))
ans = []

for i in range(min(X),max(X)+1):
    cnt = 0
    for j in X:
        cnt += (j-i)**2
    ans.append(cnt)
        
print(min(ans))

Buggy python submission (verdict: Runtime Error):
N = int(input())
X = list(map(int,input().split()))
ans = []
cnt = 0
for i in range(min(X),max(X)+1):
    ans.append(cnt)
    cnt = 0
    for j in X:
        cnt += (j-i)**2
print(min(ans[1:]))
        

Fixed submission:
N = int(input())
X = list(map(int,input().split()))
ans = []

for i in range(min(X),max(X)+1):
    cnt = 0
    for j in X:
        cnt += (j-i)**2
    ans.append(cnt)
        
print(min(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int,input().split()))
A = []
ans = 0

for i in range(N):
    A.append(P[i])
    if min(A) == P[i]:
        ans += 1
print(ans)

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

cnt = 10**18
ans = 0

for i in range(N):
    if cnt >= P[i]:
        cnt = P[i]
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())

print(6-a+b)

Fixed submission:
a = int(input())
b = int(input())

print(6-(a+b))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
ans = [0] * N
for i,val in enumerate(A):
    ans[val-1] = i+1
print(' '.join(ans))

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans = [0] * N
for i,val in enumerate(A):
    ans[val-1] = i+1
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
ans = []
for i in range(1,N+1):
    ans.append(str(A.index(i)+1))
print(' '.join(ans))

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans = [0] * N
for i,val in enumerate(A):
    ans[val-1] = i+1
print(*ans)
Buggy python submission (verdict: Runtime Error):
import collections

N = int(input())
S = [(sorted(input())) for _ in range(N)]
c = collections.Counter(S)
ans = 0
for i in set(S):
    n = c[i]
    ans += n*(n-1)//2
print(ans)

Fixed submission:
import collections

N = int(input())
S = [''.join(sorted(input())) for _ in range(N)]
c = collections.Counter(S)
ans = 0
for i in set(S):
    n = c[i]
    ans += n*(n-1)//2
print(ans)

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

N = int(input())
S = [(sorted(input()))for _ in range(N)]
c = collections.Counter(S)
ans = 0
print(S)

for i in set(S):
    n = c[i]
    ans += n*(n-1)//2
print(ans)

Fixed submission:
import collections

N = int(input())
S = [''.join(sorted(input())) for _ in range(N)]
c = collections.Counter(S)
ans = 0
for i in set(S):
    n = c[i]
    ans += n*(n-1)//2
print(ans)

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

N = int(input())
S = [{sorted(input())}for _ in range(N)]
c = collections.Counter(S)
ans = 0
print(S)

for i in set(S):
    n = c[i]
    ans += n*(n-1)//2
print(ans)

Fixed submission:
import collections

N = int(input())
S = [''.join(sorted(input())) for _ in range(N)]
c = collections.Counter(S)
ans = 0
for i in set(S):
    n = c[i]
    ans += n*(n-1)//2
print(ans)

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

N = int(input())
S = [sorted(input())for _ in range(N)]
c = collections.Counter(S)
ans = 0

for i in set(S):
    n = c[i]
    ans += n*(n-1)//2
print(ans)

Fixed submission:
import collections

N = int(input())
S = [''.join(sorted(input())) for _ in range(N)]
c = collections.Counter(S)
ans = 0
for i in set(S):
    n = c[i]
    ans += n*(n-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
N,X = map(int,input().split())
l = list(map(int,input().split()))
p = 0
count = 0

for i in range(N+1):
    p += l[i]
    count += 1
    if p > X:
        print(count)
        break

Fixed submission:
N,X = map(int,input().split())
l = list(map(int,input().split()))
p = 0
count = 1

for i in l:
    p += i
    count += 1
    if p > X:
        count -= 1
        break
print(count)
Buggy python submission (verdict: Runtime Error):
s = input()
s_f = int(s[0]+s[1])
s_b = int(s[2]+s[3])

#print(s_f)
#print(s_b)
if s_f==0 or s_b==0:
    print('NA')
elif s_f<=12 and s_b<=12:
    print("AMBIGUOUS")
elif s_f<=12 and s_b>12:
    print('MMYY')
elif s_f>12 and s_b<=12:
    print('YYMM')
elif s_f>12 and s_b>12
    print('NA')
    
    

Fixed submission:
def solve(yy,mm):
    if 1<=yy<=12:
        if 1 <= mm <=12:
            return 'AMBIGUOUS'
        else:
            return 'MMYY'
    else:
        if 1<= mm <= 12:
            return 'YYMM'
        else:
            return "NA"


s = input()
yy = int(s[:2])
mm = int(s[2:])
print(solve(yy,mm))
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(numbers):
    if len(numbers)>=2:
        return reduce(math.gcd,numbers)
    else:
        return math.gcd(0,*numbers)


N = int(input())
A = list(map(int,input().split()))

ans = []

for i in range(N):
    if i == 0:
        ans.append(gcd(A[i+1:]))
    elif i == N-1:
        ans.append(gcd(A[:N-1]))
    else:#N=1からN-2
        ans.append(math.gcd(gcd(A[:i]),gcd(A[i+1:])))
#print(ans)
print(max(ans))



Fixed submission:
from math import gcd

N = int(input())
A = list(map(int,input().split()))

L,R = [0],[0]

for i in range(N-1):
    L += [gcd(L[i],A[i])]
    R += [gcd(R[i],A[-i-1])]

print(max(gcd(L[i],R[-i-1])for i in range(N)))
Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = input()
#lr = [list(map(int,input().split()))for _ in range(Q)]
#l = [lr[i][0] for i in range(Q)]
#r = [lr[i][1] for i in range(Q)]
#print(lr)
#print(l)
#print(r)

c = [0] * (N+2)
cnt = 0

for i in range(1,N+1):
    #if S[i]+S[i+1]=='AC':
        #c[i+1]+=1
    c[i] = S[:i].count('AC')

#print(c)

for i in range(Q):
    #print(sum(c[:j])-sum(c[:i]))
    l,r = map(int,input().split())
    print(c[r]-c[l])

Fixed submission:
N,Q = map(int,input().split())
S = input()
lr = [list(map(int,input().split()))for _ in range(Q)]
l = [lr[i][0] for i in range(Q)]
r = [lr[i][1] for i in range(Q)]
#print(lr)
#print(l)
#print(r)

c = [0] * N
cnt = 0

for i in range(N-1):
    if S[i:i+2] == 'AC':
        c[i+1]=c[i]+1
    else:
        c[i+1]=c[i]
    #c[i] = S[:i].count('AC')

#print(c)

for i,j in zip(l,r):
    #print(sum(c[:j])-sum(c[:i]))
    #l,r = map(int,input().split())
    print(c[j-1]-c[i-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = input()
lr = [list(map(int,input().split()))for _ in range(Q)]
l = [lr[i][0] for i in range(Q)]
r = [lr[i][1] for i in range(Q)]
#print(lr)
#print(l)
#print(r)

c = [0] * (N+2)
cnt = 0

for i in range(1,N+1):
    #if S[i]+S[i+1]=='AC':
        #c[i+1]+=1
    c[i] = S[:i].count('AC')

#print(c)

for i,j in zip(l,r):
    #print(sum(c[:j])-sum(c[:i]))
    print(c[j]-c[i])

Fixed submission:
N,Q = map(int,input().split())
S = input()
lr = [list(map(int,input().split()))for _ in range(Q)]
l = [lr[i][0] for i in range(Q)]
r = [lr[i][1] for i in range(Q)]
#print(lr)
#print(l)
#print(r)

c = [0] * N
cnt = 0

for i in range(N-1):
    if S[i:i+2] == 'AC':
        c[i+1]=c[i]+1
    else:
        c[i+1]=c[i]
    #c[i] = S[:i].count('AC')

#print(c)

for i,j in zip(l,r):
    #print(sum(c[:j])-sum(c[:i]))
    #l,r = map(int,input().split())
    print(c[j-1]-c[i-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = input()
lr = [list(map(int,input().split()))for _ in range(Q)]
l = [lr[i][0] for i in range(Q)]
r = [lr[i][1] for i in range(Q)]
#print(lr)
#print(l)
#print(r)

c = [0] * (N+2)
cnt = 0

for i in range(N-1):
    if S[i]+S[i+1]=='AC':
        c[i+1]+=1

#print(c)

for i,j in zip(l,r):
    print(sum(c[:j])-sum(c[:i]))
 

Fixed submission:
N,Q = map(int,input().split())
S = input()
lr = [list(map(int,input().split()))for _ in range(Q)]
l = [lr[i][0] for i in range(Q)]
r = [lr[i][1] for i in range(Q)]
#print(lr)
#print(l)
#print(r)

c = [0] * N
cnt = 0

for i in range(N-1):
    if S[i:i+2] == 'AC':
        c[i+1]=c[i]+1
    else:
        c[i+1]=c[i]
    #c[i] = S[:i].count('AC')

#print(c)

for i,j in zip(l,r):
    #print(sum(c[:j])-sum(c[:i]))
    #l,r = map(int,input().split())
    print(c[j-1]-c[i-1])
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
sAB = sorted(AB,key=lambda x:x[0])
remain = M
ans = 0


for i in range(N):
    if remain > sAB[i][1]:
        remain -= sAB[i][1]
        ans += sAB[i][0]*sAB[i][1]
    else:
        while 1:
            remain -= 1
            ans+=sAB[i][0]
        
            if remain == 0:
                break
print(ans)

Fixed submission:
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
A = sorted(AB,key=lambda x:x[0])
ans = 0

for i in range(N):
    buy = min(M,A[i][1])
    ans += buy * A[i][0]
    M -= buy
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,k = map(int,input().split())
l=[]
for i in range(1,101):
    if a%i ==0 and b%i ==0:
        l.append(i)

print(l[-2])

Fixed submission:
a,b,k = map(int,input().split())
l=[]
for i in range(1,101):
    if a%i ==0 and b%i ==0:
        l.append(i)

print(l[-k])
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N,K = map(int,(input().split()))
h = [int(input())for _ in range(N)]

hmin =[]

c = itertools.combinations(h,K)

for v in c:
    hmin.append(max(v)-min(v))
print(min(hmin))

Fixed submission:
N,K = map(int,(input().split()))
h = [int(input())for _ in range(N)]
h.sort()

print(min(h[i+K-1]-h[i] for i in range(N-K+1)))

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N,K = map(int,(input().split()))
h = [int(input())for _ in range(N)]

hmin = 10**18

c = itertools.combinations(h,K)

for v in c:
    hmin = min(max(v)-min(v),hmin)
print(hmin)

Fixed submission:
N,K = map(int,(input().split()))
h = [int(input())for _ in range(N)]
h.sort()

print(min(h[i+K-1]-h[i] for i in range(N-K+1)))

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

N,K = map(int,(input().split()))
h = [int(input())for _ in range(N)]

hmin = 10**18

c = itertools.combinations(N,K)

for v in c:
    hmin = min(max(v)-min(v),hmin)
print(hmin)

Fixed submission:
N,K = map(int,(input().split()))
h = [int(input())for _ in range(N)]
h.sort()

print(min(h[i+K-1]-h[i] for i in range(N-K+1)))
Buggy python submission (verdict: Runtime Error):
import collections

n = int(input())
a = list(map(int,input().split()))
a1 = collections.Counter(a[0::2]).most_common()
a2 = collections.Counter(a[1::2]).most_common()
#a1.append((0,0))
#a2.append((0,0))
#print(a1)
#print(a2)

if a1[0] != a2[0]:
    print(n-a1[0][1]-a2[0][1])
else:
    print(min(n-a1[0][1]-a2[1][1],n-a1[1][1]-a2[0][1]))



Fixed submission:
import collections

n = int(input())
a = list(map(int,input().split()))
a1 = collections.Counter(a[0::2]).most_common()
a2 = collections.Counter(a[1::2]).most_common()
a1.append((0,0))
a2.append((0,0))
#print(a1)
#print(a2)

if a1[0] != a2[0]:
    print(n-a1[0][1]-a2[0][1])
else:
    print(min(n-a1[0][1]-a2[1][1],n-a1[1][1]-a2[0][1]))

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

n = int(input())
a = list(map(int,input().split()))
a1 = collections.Counter(a[0::2]).most_common()
a2 = collections.Counter(a[1::2]).most_common()
#a1.append((0,0))
#a2.append((0,0))
print(a1)
print(a2)

if a1[0] != a2[0]:
    print(n-a1[0][1]-a2[0][1])
else:
    print(min(n-a1[0][1]-a2[1][1],n-a1[1][1]-a2[0][1]))



Fixed submission:
import collections

n = int(input())
a = list(map(int,input().split()))
a1 = collections.Counter(a[0::2]).most_common()
a2 = collections.Counter(a[1::2]).most_common()
a1.append((0,0))
a2.append((0,0))
#print(a1)
#print(a2)

if a1[0] != a2[0]:
    print(n-a1[0][1]-a2[0][1])
else:
    print(min(n-a1[0][1]-a2[1][1],n-a1[1][1]-a2[0][1]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
W = [input() for _ in range(N)]
Ws =[]
ans = 'Yes'

for i in range(N):
    Ws.append(W[i])
    for j in range(1,N+1)
        if W[i][-1] == W[j][0]:
            break
        else:
            ans = 'No'
            break
        
#print(Ws)

if len(set(W)) != len(Ws):
    ans = 'No'
print(ans)  

Fixed submission:
N = int(input())
W = [input() for _ in range(N)]
ans = "Yes"

for i in range(N-1):
    if W[i][-1] != W[i+1][0] or W.count(W[i]) != 1:
        ans = "No"

print(ans)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
ans = 0

if K%2==0:
    d1=N//(N//2)
    d2=N//K
    ans=d2**3+(d1-d2)**3
else:
    d=N//K
    ans = d**3
print(ans)
    

Fixed submission:
N,K = map(int,input().split())
ans = 0

if K%2==0:
    d1=N//(K//2)
    d2=N//K
    ans=d2**3+(d1-d2)**3
else:
    d=N//K
    ans = d**3

print(ans)

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
ans = 0
if K%2==1:
    d1=n//(k//2)
    d2=n//k
    ans=d2**3+(d1-d2)**3
else:
    d=n//k
    ans = d**3
print(ans)
    

Fixed submission:
N,K = map(int,input().split())
ans = 0

if K%2==0:
    d1=N//(K//2)
    d2=N//K
    ans=d2**3+(d1-d2)**3
else:
    d=N//K
    ans = d**3

print(ans)

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
if K%2==0:
    d1=n//(k//2)
    d2=n//k
    ans=d2**3+(d1-d2)**3
else:
    d=n//k
    ans = d**3
print(ans)
    

Fixed submission:
N,K = map(int,input().split())
ans = 0

if K%2==0:
    d1=N//(K//2)
    d2=N//K
    ans=d2**3+(d1-d2)**3
else:
    d=N//K
    ans = d**3

print(ans)

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
if K%2==1:
    d1=n//(k//2)
    d2=n//k
    ans=d2**3+(d1-d2)**3
else:
    d=n//k
    ans = d**3
print(ans)
    

Fixed submission:
N,K = map(int,input().split())
ans = 0

if K%2==0:
    d1=N//(K//2)
    d2=N//K
    ans=d2**3+(d1-d2)**3
else:
    d=N//K
    ans = d**3

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N,K = map(int,input().split())
a=[]
b=[]
ans = 0
for i in range(1,N+1):
    a.append(i)
b += itertools.product(a,repeat = 3)

for i in b:
    #print(i[0],i[1],i[2])
    if (i[0]+i[1])%K==0 and (i[1]+i[2])%K==0 and (i[0]+i[2])%K==0:
        ans+=1
#print(a)
#print(b)
print(ans)

Fixed submission:
N,K = map(int,input().split())
ans = 0

if K%2==0:
    d1=N//(K//2)
    d2=N//K
    ans=d2**3+(d1-d2)**3
else:
    d=N//K
    ans = d**3

print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
sl = []
ans = 'AC'

for i in S:
    sl.append(i)
if sl[0] != 'A':
    ans = 'WA'
if sl[2:-1].count('C') != 1:
    ans = 'WA'

if sl[1:].replace("C","c",1).islower() == False:
    ans = 'WA'
#print(sl)
print(ans)

Fixed submission:
S = input()
sl = []
ans = 'AC'

for i in S:
    sl.append(i)
if S[0] != 'A':
    ans = 'WA'
if S[2:-1].count('C') != 1:
    ans = 'WA'

if S[1:].replace("C","c",1).islower() == False:
    ans = 'WA'
#print(sl)
print(ans)

Buggy python submission (verdict: Runtime Error):
S = input()
sl = []
ans = 'AC'

for i in S:
    sl.append(i)
if sl[0] != 'A':
    ans = 'WA'
if sl[2:-1].count('C') != 1:
    ans = 'WA'
sl.pop(0)
sl.pop(sl.index('C'))
s = "".join(sl)
#print(s)
if s.islower() == False:
    ans = 'WA'
#print(sl)
print(ans)

Fixed submission:
S = input()
sl = []
ans = 'AC'

for i in S:
    sl.append(i)
if S[0] != 'A':
    ans = 'WA'
if S[2:-1].count('C') != 1:
    ans = 'WA'

if S[1:].replace("C","c",1).islower() == False:
    ans = 'WA'
#print(sl)
print(ans)

Buggy python submission (verdict: Runtime Error):
S = input()
sl = []
ans = 'AC'

for i in S:
    sl.append(i)
if sl[0] != 'A':
    ans = 'WA'
if sl[2:-1].count('C') != 1:
    ans = 'WA'
sl.pop(0)
sl.pop(sl.index('C'))
s = "".join(sl)

if s.islower() == False:
    ans = 'WA'
#print(sl)
print(ans)

Fixed submission:
S = input()
sl = []
ans = 'AC'

for i in S:
    sl.append(i)
if S[0] != 'A':
    ans = 'WA'
if S[2:-1].count('C') != 1:
    ans = 'WA'

if S[1:].replace("C","c",1).islower() == False:
    ans = 'WA'
#print(sl)
print(ans)
Buggy python submission (verdict: Runtime Error):
H,W  = map(int,input().split())
s = []
ans = 'Yes'
for _ in range(W):
    s.append(input())

for i in range(1,H-1):
    for j in range(1,W-1):
        if s[i][j]=='#' and s[i][j+1]==s[i+1][j]==s[i][j-1]==s[i-1][j]=='.':
                print('No')
                exit()
print(ans)

Fixed submission:
H,W  = map(int,input().split())
s = []
ans = 'Yes'
for _ in range(H):
    s.append(input())

for i in range(1,H-1):
    for j in range(1,W-1):
        if s[i][j]=='#' and s[i][j+1]==s[i+1][j]==s[i][j-1]==s[i-1][j]=='.':
                print('No')
                exit()
print(ans)

Buggy python submission (verdict: Runtime Error):
H,W  = map(int,input().split())
s = []
ans = 'Yes'
for _ in range(W):
    s.append(input())

for i in range(H-1):
    for j in range(W-1):
        if s[i][j]=='#':
            if s[i][j+1]=='.' and s[i+1][j]=='.':
                print('No')
                exit()
print(ans)

Fixed submission:
H,W  = map(int,input().split())
s = []
ans = 'Yes'
for _ in range(H):
    s.append(input())

for i in range(1,H-1):
    for j in range(1,W-1):
        if s[i][j]=='#' and s[i][j+1]==s[i+1][j]==s[i][j-1]==s[i-1][j]=='.':
                print('No')
                exit()
print(ans)

Buggy python submission (verdict: Runtime Error):
H,W  = map(int,input().split())
s = []
ans = 'Yes'
for _ in range(W):
    s.append(input())

for i in range(H-1):
    for j in range(W-1):
        if s[i][j]=='.':
            continue
        else:
            if s[i][j+1]=='.' and s[i+1][j]=='.':
                print('No')
                exit()
print(ans)

Fixed submission:
H,W  = map(int,input().split())
s = []
ans = 'Yes'
for _ in range(H):
    s.append(input())

for i in range(1,H-1):
    for j in range(1,W-1):
        if s[i][j]=='#' and s[i][j+1]==s[i+1][j]==s[i][j-1]==s[i-1][j]=='.':
                print('No')
                exit()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
X = list(map(int,input().split()))
Y = []

for i in range(N):
    Y = sorted(X[:i]+X[i+1:])
    #print(Y)
    print(Y[len(Y)//2])

Fixed submission:
N = int(input())
X = list(map(int,input().split()))
Y = sorted(X)

m1=Y[N//2-1]
m2=Y[N//2]

medians = [m2 if x < m2 else m1 for x in X]
print('\n'.join(map(str,medians)))
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
#N>=Mとして一般性を失わない
if N==M==1:
    print(1)
if N==1 and M>=2:
    print(M-2)
if N==2 and M>=2:
    print(0)
if N>=3 and M>=3:
    print((N-2)*(M-2)

Fixed submission:
l = sorted(list(map(int,input().split())))
#N<=Mとして一般性を失わない
N=l[0]
M=l[1]

if N==M==1:
    print(1)
if N==1 and M>=2:
    print(M-2)
if N==2 and M>=2:
    print(0)
if N>=3 and M>=3:
    print((N-2)*(M-2))
Buggy python submission (verdict: Runtime Error):
import collections

N = int(input())
S = [input()[0] for _ in range(N)]
A = []
ans = 0 

for i in S:
    if i == 'M' or i == 'A' or i == 'R' or i == 'C' or i == 'H':
        A.append(i)
        
C = collections.Counter(A).most_common()
v,c =zip(*C)
s = c[0]

for i in range(1,len(c)):
    s *= c[i]
    
ans += s
print(ans)





Fixed submission:
import collections
import itertools

N = int(input())
S = [input()[0] for _ in range(N)]
A = []
ans = 0

for i in S:
    if i == 'M' or i == 'A' or i == 'R' or i == 'C' or i == 'H':
        A.append(i)
        
if len(A) != 0:       
    C = collections.Counter(A).most_common()
    v,c = zip(*C)
    #print(C)
    #print(c)

    for a,b,c in itertools.combinations(c,3):
        #print(a,b,c)
        ans += a*b*c

print(ans)