Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
str = list(raw_input())
f = int(str[0]+str[1])
l = int(str[2]+str[3])
# 文字列の入力
ans = ""
if(f > 0 and 13 > f):
    if(l == 0):
        ans = "MMYY"
    if(l > 0 and 13 > l):
        ans = "AMBIGUOUS"
    if(l >= 13):
        ans= "MMYY"
elif(f == 0):
    if(l == 0):
        ans = "NA"
    if(l > 0 and 13> l):
        ans = "YYMM"
    if(l >= 13):
        ans= "NA"
elif(f>=13):
    if(l == 0):
        ans = "NA"
    if(l > 0 and 13> l):
        ans = "YYMM"
    if(l >= 13):
        ans= "NA"
 
print ans

Fixed submission:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
n, k = map(int, raw_input().split())

# 文字列の入力
str = list(raw_input())

str[k-1] = str[k-1].lower()
# 出力
newstr = "".join(str)
print(newstr)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
str = list(raw_input())
f = int(str[0]+str[1])
l = int(str[2]+str[3])
# 文字列の入力
if(f == 0):
    if(l == 0):
        ans = "NA"
    if(l > 0 and 13> l):
        ans = "YYMM"
    if(l >= 13):
        ans= "NA"
elif(f > 0 and 13 > f):
    if(l == 0):
        ans = "MMYY"
    if(l > 0 and 13 > l):
        ans = "AMBIGUOUS"
    if(l >= 13):
        ans= "MMYY"
elif(f >= 13):
    if(l == 0):
        ans = "NA"
    if(l > 0 and 13> l):
        ans = "YYMM"
    if(l >= 13):
        ans= "NA"

print ans


Fixed submission:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
n, k = map(int, raw_input().split())

# 文字列の入力
str = list(raw_input())

str[k-1] = str[k-1].lower()
# 出力
newstr = "".join(str)
print(newstr)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
str = list(raw_input())
f = int(str[0]+str[1])
l = int(str[2]+str[3])
# 文字列の入力
if(f == 0):
    if(l == 0):
        ans = "NA"
    if(l > 0 and 13> l):
        ans = "YYMM"
    if(l >= 13):
        ans= "NA"
elif(f > 0 and 13 > f):
    if(l == 0):
        ans = "MMYY"
    if(l > 0 and 13 > l):
        ans = "AMBIGUOUS"
    if(l >= 13):
        ans= "MMYY"
elif(f >= 13):
    if(l == 0):
        ans = "NA"
    if(l > 0 and 13> l):
        ans = "YYMM"
    if(l >= 13):
        ans= "NA"

print ans
# 出力


Fixed submission:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
n, k = map(int, raw_input().split())

# 文字列の入力
str = list(raw_input())

str[k-1] = str[k-1].lower()
# 出力
newstr = "".join(str)
print(newstr)
Buggy python submission (verdict: Time Limit Exceeded):
N=input()
N=int(N)
A=[]
for i in range(N):
    b=input()
    b=int(b)
    A.append(b)

max_value=max(A)
for i in range(N):
    if A[i]<max_value:
        print(max_value)
    else:
        data=A.pop(i)
    #    print(lst,i)
        print(max(A))
        A.insert(i,data)


Fixed submission:
N=input()
N=int(N)
A=[]
for i in range(N):
    b=input()
    b=int(b)
    A.append(b)
flag=0
max_value=max(A)
for i in range(N):
    if flag==1:
        print(max_value)
    elif A[i]<max_value:
        print(max_value)
    else:
        data=A.pop(i)
        print(max(A))
        A.insert(i,data)
        if max(A)==max_value:
            flag=1

Buggy python submission (verdict: Time Limit Exceeded):
N=input()
N=int(N)
A=[]
for i in range(N):
    b=input()
    b=int(b)
    A.append(b)
for i in range(N):
#    A=a
#    print(A)
    data=A.pop(i)

#    print(lst,i)
    print(max(A))
    A.insert(i,data)


Fixed submission:
N=input()
N=int(N)
A=[]
for i in range(N):
    b=input()
    b=int(b)
    A.append(b)
flag=0
max_value=max(A)
for i in range(N):
    if flag==1:
        print(max_value)
    elif A[i]<max_value:
        print(max_value)
    else:
        data=A.pop(i)
        print(max(A))
        A.insert(i,data)
        if max(A)==max_value:
            flag=1
Buggy python submission (verdict: Runtime Error):
S=int(input())


for i in range(len(S)):
    A=S[i:i+1]
    print(A)

if S[0:1]==S[1:2]:
    print("Bad")
elif S[1:2]==S[2:3]:
    print("Bad")
elif S[3:4]==S[2:3]:
    print("Bad")
else:
    print("Good")

Fixed submission:

S=input()

if S[0:1]==S[1:2] or S[1:2]==S[2:3] or S[3:4]==S[2:3]:
    print("Bad")
else:
    print("Good")

Buggy python submission (verdict: Runtime Error):
S=int(input())


for i in range(len(S)):
    A=S[i:i+1]
    print(A)

if S[0:1]==S[1:2]:
    print("Bad")
elif S[1:2]==S[2:3]:
    print("Bad")
elif S[3:4]==S[2:3]:
    print("Bad")
else:
    print("Good")

Fixed submission:

S=input()

if S[0:1]==S[1:2] or S[1:2]==S[2:3] or S[3:4]==S[2:3]:
    print("Bad")
else:
    print("Good")

Buggy python submission (verdict: Runtime Error):
for i in range(len(S)):
    A=S[i:i+1]
    print(A)

if S[0:1]==S[1:2]:
    print("Bad")
elif S[1:2]==S[2:3]:
    print("Bad")
elif S[3:4]==S[2:3]:
    print("Bad")
else:
    print("Good")

Fixed submission:

S=input()

if S[0:1]==S[1:2] or S[1:2]==S[2:3] or S[3:4]==S[2:3]:
    print("Bad")
else:
    print("Good")
Buggy python submission (verdict: Runtime Error):
ini=input().split()
ini=[int(i) for i in ini]
N=ini[0]
K=ini[1]
a=input().split()
a=[int(i) for i in a]


count=0
ans=0
x=0
lena=len(a)

for i in range(lena):
    for j in range(N-i):
        #print(i,j,a[i+j])
        x += a[i+j]
#        print(i,j,x,count)
        if x >= K:
#            print("aaa",i,j,x,count,ans)
            count = N-j-i
            x=0
            break
        if j==N-i-1:
            x=0
#    print(i,j,ans)
    ans+=count
    count=0
print(ans)

Fixed submission:
alfa=input()

X=alfa[0]
A=alfa[2]

if X<A:
    print("0")
else:
    print("10")

Buggy python submission (verdict: Runtime Error):
alfa=input().split()
N=int(alfa[0])
X=int(alfa[1])
#L=[int(input().split()) for i in range(N)]
L=input().split()

#print(N,X,L)
D=0
count=1
for i in range(N):
    D+=int(L[i])
    if D>X:
        print(count)
        break
    else:
        count+=1

if D<X:
    print(count)

Fixed submission:
alfa=input()

X=alfa[0]
A=alfa[2]

if X<A:
    print("0")
else:
    print("10")

Buggy python submission (verdict: Runtime Error):
alfa=input().split()
N=int(alfa[0])
X=int(alfa[1])
#L=[int(input().split()) for i in range(N)]
L=input().split()


print(N,X,L)
D=0
count=1
for i in range(N):
    D+=int(L[i])
    if D>X:
        print(count,D,X,i,L[i])
        break
    else:
        count+=1


Fixed submission:
alfa=input()

X=alfa[0]
A=alfa[2]

if X<A:
    print("0")
else:
    print("10")

Buggy python submission (verdict: Runtime Error):
alfa=input()
N=int(alfa[0])
X=int(alfa[2])
#L=[int(input().split()) for i in range(N)]
L=input().split()


print(N,X,L)
D=0
count=0
for i in range(N):
    count+=1
    D+=int(L[i])
    if D>X:
        print(count)
        break


Fixed submission:
alfa=input()

X=alfa[0]
A=alfa[2]

if X<A:
    print("0")
else:
    print("10")
Buggy python submission (verdict: Runtime Error):
x=input().split()
x=[int(i) for i in x]

W=x[0]
H=x[1]
x=x[2]
y=x[3]

max=W*H*0.5

if x==W/2 and y==H/2:
    print("1")
else:
    print("0")

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

W=a[0]
H=a[1]
x=a[2]
y=a[3]

max=round(W*H*0.5,9)
print(max)

if x==W/2 and y==H/2:
    print("1")
else:
    print("0")
Buggy python submission (verdict: Runtime Error):
ini=input().split()
ini=[int(i) for i in ini]
N=ini[0]
M=ini[1]

a=[0]
for i in range(M):
    a.append(int(input()))
a.append(N)

#print(a)
ans=1
def fib(n):
    
    atai = 1
    atai2 = 2
   # global atai,atai2
    if n==1:
        atai2=1
        return atai2
    if n==2:
        atai2=2
        return atai2
    else:
        for i in range(1,n):
            temp=atai2
            atai2=atai+temp
            atai=temp
        return atai2
#print(N,M)
for i in range(M+1):
    b=a[i+1]-a[i]-1
    # if i==M:
    #     ans=ans*fib(N-a[i]-1)
    #     print("iff",ans,fib(N-a[i]-1))
    if b==0 and a[1]!=1:
        ans=0
        break
    if b>0:
        ans=ans*fib(b)
#        if ans>1000000007:
        ans=ans % 1000000007
#        print("if",ans,fib(b))
#        print(ans,fib(b),c[i])

ans=ans % 1000000007
print(ans)



Fixed submission:
ini=input().split()
ini=[int(i) for i in ini]

P=ini[0]
Q=ini[1]
R=ini[2]

ans=P+Q+R-max(ini)

print(ans)
Buggy python submission (verdict: Runtime Error):
N=input()

ini=input().split()
W=[int(i) for i in ini]

Wa=0
S=0
for i in range(N):
    Wa+=W[i]


for i in range(N):
    S+=W[i]
    if S>Wa/2:
        S1=S-W[i-1]
        S2=S

ans=abs(S1-S2)

print(ans)

Fixed submission:
N=input()
N=int(N)

ini=input().split()
W=[int(i) for i in ini]

Wa=0
S=0
for i in range(N):
    Wa+=W[i]

#print(Wa)
for i in range(N):
    S+=W[i]
    if S>Wa/2:
        S1=S
        S2=Wa-S1
        S11=S-W[i]
        S22=Wa-S11
        break

ans1=abs(S1-S2)
ans2=abs(S11-S22)

#print(ans1,ans2,S1,S2,S11,S22)

if ans1>=ans2:
    print(ans2)
else:
    print(ans1)
Buggy python submission (verdict: Runtime Error):
r,g,b,n = map(int,input().split())

i,j,k = 0,0,0

ans = 0

while True:
	temp = i * r
	j,k = 0,0
	if(temp > n):
		break
	while True:
		temp = i * r + j * g
		k = 0
		if(temp > n):
			break
		while True:
			temp = i * r + j * g + k * b
			#print(temp)
			if(temp > n): break
			if (temp == n):
				ans += 1
			k += 1
		j+= 1
	i += 1

print(ans)

Fixed submission:
n,k = map(int,input().split())

ans = n - k + 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n = map(int,input().split())

i,j,k = 0,0,0

ans = 0

while True:
	temp = i * r
	j,k = 0,0
	if(temp > n):
		break
	while True:
		temp = i * r + j * g
		k = 0
		if(temp > n):
			break
		while True:
			temp = i * r + j * g + k * b
			#print(temp)
			if(temp > n): break
			if (temp == n):
				ans += 1
			k += 1
		j+= 1
	i += 1

print(ans)

Fixed submission:
r,g,b,n = map(int,input().split())

i,j,k = 0,0,0

ans = 0



while True:
	temp = i * r
	j,k = 0,0
	if(temp > n):
		break
	while True:
		temp = i * r + j * g
		k = 0
		if(temp > n):
			break
		if((n - temp)%b == 0):
			ans+= 1
		j+= 1
	i += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
n = input()
s = list(input())

ans = 0

for i in range(len(s)-1):
	if(s[i] == "#" and s[i+1] == "."):
		if(i == 0):
			s[i] = "."
		elif(i > 0 and s[i-1] != "#"):
			s[i] = "."
		else:
			s[i+1] = "#"
		ans += 1

print(ans)


Fixed submission:
a,b,c = map(int,input().split())

if(a > b):
	temp = a
	a = b
	b = temp

if (c > a and c < b):
	print("Yes")
else:
	print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
s = list(input())
 
ans = len(s)

sharp = 0
dot = 0
for string in s:
	if(string == "#"):
		sharp += 1
	else:
		dot += 1 

for i in range(len(s)):
	temp_ans = 0
	for j in range(0, i):
		if(s[j]) == "#":
			temp_ans += 1
	for j in range(i,len(s)):
		if (s[j] == "."):
			temp_ans += 1
	ans = min(ans, temp_ans, len(s) - dot)
 
print(ans)

Fixed submission:
n = input()
s = list(input())
 
ans = len(s)

sharp = 0
dot = 0
for string in s:
	if(string == "#"):
		sharp += 1
	else:
		dot += 1 

left_sharp = 0
right_dot = dot

for i in range(len(s)):
	temp_ans = left_sharp + right_dot
	ans = min(ans,temp_ans)
	if(s[i] == "."):
		right_dot -= 1
	else:
		left_sharp += 1

ans = min(ans, len(s) - dot) 

print(ans)

Buggy python submission (verdict: Runtime Error):
n = input()
s = list(input())

sb = s.copy()

ans = 0

for i in range(len(s)-1):
	if(s[i] == "#" and s[i+1] == "."):
		if(i == 0):
			s[i] = "."
		elif(i > 0 and s[i-1] != "#"):
			s[i] = "."
		else:
			s[i+1] = "#"
		ans += 1

ansb = 0
for i in range(len(sb)-1):
	if(i == 0 and sb[i] != "."):
		sb[i] = "."
		ansb += 1
	elif(sb[i] == "#" and sb[i+1] == "."):
		if(i > 0 and sb[i-1] != "#"):
			sb[i] = "."
		else:
			sb[i+1] = "#"
		ansb += 1

#print(s)
#print(sb)


#print(ans)
#print(ansb)

ans = min(ans, ansb)

print(ans)

Fixed submission:
n = input()
s = list(input())
 
ans = len(s)

sharp = 0
dot = 0
for string in s:
	if(string == "#"):
		sharp += 1
	else:
		dot += 1 

left_sharp = 0
right_dot = dot

for i in range(len(s)):
	temp_ans = left_sharp + right_dot
	ans = min(ans,temp_ans)
	if(s[i] == "."):
		right_dot -= 1
	else:
		left_sharp += 1

ans = min(ans, len(s) - dot) 

print(ans)

Buggy python submission (verdict: Runtime Error):
n = input()
s = list(input())

ans = 0

for i in range(len(s)-1):
	if(s[i] == "#" and s[i+1] == "."):
		if(i == 0):
			s[i] = "."
		else if(i > 0 and s[i-1] != "#"):
			s[i] = "."
		else:
			s[i+1] = "#"
		ans += 1

print(ans)


Fixed submission:
n = input()
s = list(input())
 
ans = len(s)

sharp = 0
dot = 0
for string in s:
	if(string == "#"):
		sharp += 1
	else:
		dot += 1 

left_sharp = 0
right_dot = dot

for i in range(len(s)):
	temp_ans = left_sharp + right_dot
	ans = min(ans,temp_ans)
	if(s[i] == "."):
		right_dot -= 1
	else:
		left_sharp += 1

ans = min(ans, len(s) - dot) 

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

inputs[1] = int(input())

inputs[2] = int(input())

inputs[3] = int(input())

inputs[4] = int(input())

posi = [n,0,0,0,0,0]

it = 0
while True:
	for i in range(1,6):
		j = 5 - i
		if posi[j] >= inputs[j]:
			posi[j] = posi[j] - inputs[j]
			posi[j+1] = posi[j+1] + inputs[j]
		else:
			posi[j+1] = posi[j+1] + posi[j]
			posi[j] = 0
	#print(posi)
	it = it + 1
	if posi[5] == n:
		break
print(it)

Fixed submission:
n = int(input())
inputs = [0,0,0,0,0]
inputs[0] = int(input())

inputs[1] = int(input())

inputs[2] = int(input())

inputs[3] = int(input())

inputs[4] = int(input())

posi = [n,0,0,0,0,0]

min = inputs[0]

for inp in inputs:
	if min > inp:
		min = inp

nn = int(n / min)
if nn != 0:
	if n % min != 0:
		nn += 1
	nn = nn -1

nn = 5 + nn

print(nn)
Buggy python submission (verdict: Time Limit Exceeded):
x,y,z,k = map(int,input().split())
a = []
for i in input().split():
	a.append(int(i))
b = []
for i in input().split():
	b.append(int(i))
c = []
for i in input().split():
	c.append(int(i))

#a.reverse()
#b.reverse()
#c.reverse()

a_bsum = []

for i in range(x):
	for j in range(y):
			a_bsum.append(a[i]+b[j])
a_bsum.sort()
a_bsum.reverse()

temp_sum = a_bsum[0:k]

sum = []

c.sort()
c.reverse()
c = c[0:k]

for i in a_bsum:
	for j in c:
		sum.append(i+j)

sum.sort()
sum.reverse()

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

Fixed submission:
x,y,z,k = map(int,input().split())
a = []
for i in input().split():
	a.append(int(i))
b = []
for i in input().split():
	b.append(int(i))
c = []
for i in input().split():
	c.append(int(i))

#a.reverse()
#b.reverse()
#c.reverse()

a_bsum = []

for i in range(x):
	for j in range(y):
			a_bsum.append(a[i]+b[j])
a_bsum.sort()
a_bsum.reverse()

a_bsum = a_bsum[0:k]

sum = []

c.sort()
c.reverse()
c = c[0:k]

for i in a_bsum:
	for j in c:
		sum.append(i+j)

sum.sort()
sum.reverse()

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

Buggy python submission (verdict: Time Limit Exceeded):
x,y,z,k = map(int,input().split())
a = []
for i in input().split():
	a.append(int(i))
b = []
for i in input().split():
	b.append(int(i))
c = []
for i in input().split():
	c.append(int(i))

#a.reverse()
#b.reverse()
#c.reverse()

sum = []

for i in range(x):
	for j in range(y):
		for jj in range(z):
			sum.append(a[i]+b[j]+c[jj])
sum.sort()
sum.reverse()

#print(sum)
summ = 0

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

Fixed submission:
x,y,z,k = map(int,input().split())
a = []
for i in input().split():
	a.append(int(i))
b = []
for i in input().split():
	b.append(int(i))
c = []
for i in input().split():
	c.append(int(i))

#a.reverse()
#b.reverse()
#c.reverse()

a_bsum = []

for i in range(x):
	for j in range(y):
			a_bsum.append(a[i]+b[j])
a_bsum.sort()
a_bsum.reverse()

a_bsum = a_bsum[0:k]

sum = []

c.sort()
c.reverse()
c = c[0:k]

for i in a_bsum:
	for j in c:
		sum.append(i+j)

sum.sort()
sum.reverse()

for i in range(k):
	print(sum[i])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
data = []
for x in range(N):
    data.append(int(input()))
for x in range(N):
    print(max(data[0:x] + data[x+1:N]))


Fixed submission:
N = int(input())
data = []
max1 = 0
max2 = 0
for i in range(N):
    x = int(input())
    if x > max1:
        max1 = x
        max_i = i
    elif x > max2:
        max2 = x
for i in range(N):
    if max_i == i:
        print(max2)
    else:
        print(max1)
Buggy python submission (verdict: Runtime Error):
def combination(n, r):
    r = min(r, n-r)
    nume = 1
    denomi = 1
    for i in range(1, r+1):
        denomi *= i
    for i in range(n-r+1, n+1):
        nume *= i
    return nume // denomi

N, M = map(int, input().split())

sl = []
cnt = -1
ng = 0
for i in range(M):
    a = int(input())
    b = (a - 1) - (cnt + 1)
    if b == -1:
        ng = 1
    sl.append(max(b, 1))
    cnt = a

if ng:
    print(0)
else:
    sl.append(max(N - (a + 1), 1))
    ans = 1
    for s in sl:
        p = 0
        for i in range(s):
            j = s - i
            if (i <= j):
                p += combination(j, i)
            else:
                break
        ans *= p
    print(ans % 1000000007)

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

print(min(*[abs(sum(wl[:a]) - sum(wl[a:])) for a in range(N)]))
Buggy python submission (verdict: Time Limit Exceeded):
# ナイーブに総当たり
s = input()

cnt = 0

while True:
    i = s.find("ABC")
    if i == -1:
        break
    else:
        cnt += 1
        s = s[:i] + "BCA" + s[i+3:]
        continue

print(cnt)

Fixed submission:
s = input()
s = s.replace("BC", "D")

cnt = 0
num_a = 0
for i in range(len(s)):
    if s[i] in ["B", "C"]:
        num_a = 0
    elif s[i] == "A":
        num_a += 1
    elif s[i] == "D":
        cnt += num_a

print(cnt)
Buggy python submission (verdict: Runtime Error):
import numpy as np
 
N, K = map(int, input().split())
 
def get_x(n, K):
    if n >= K:
        return 0
    else:
      	x_raw = (np.log(K) - np.log(n))/np.log(2)
        # x_raw = np.log2(K) - np.log2(n)
        return np.ceil(x_raw)

def get_prob(n, K):
    x = get_x(n, K)
    if x == 0:
        return 1
    else:
        return (1/2)**x
    
ans = np.mean([get_prob(n, K) for n in range(1, N+1)])
 
print(ans)

Fixed submission:
import numpy as np
 
N, K = map(int, input().split())
 
def get_x(n, K):
    if n >= K:
        return 0
    else:
        x_raw = np.log2(K) - np.log2(n)
        return np.ceil(x_raw)

def get_prob(n, K):
    x = get_x(n, K)
    if x == 0:
        return 1
    else:
        return (1/2)**x
    
ans = np.mean([get_prob(n, K) for n in range(1, N+1)], dtype=np.float64)
 
print('{0:.12f}'.format(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
al = [int(a) for a in input().split()]
      
def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a

l = [0]*N
r = [0]*N

# 左から右
for i in range(N-1):
    if i == 0:
        a = al[i]
        l[i+1] = a
    if i >= 1:
        a = gcd(a, al[i])
        l[i+1] = a

# 右から左
for i in range(N-1):
    if i == 0:
        a = al[::-1][i]
        r[-i-2] = a
    if i >= 1:
        a = gcd(a, al[::-1][i])
        r[-i-2] = a

# 最大公約数リスト
ansl = [0]*N
for i in range(N):
    if i == 0:
        ansl[i] = r[i]
    elif i == N-1:
        ansl[i] = l[i]
    else:
        ansl[i] = gcd(r[i], l[i])
print(max(ansl))

Fixed submission:
N = int(input())
al = [int(a) for a in input().split()]
      
def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a

l = [0]*N
r = [0]*N

# 左から右
for i in range(N-1):
    if i == 0:
        a = al[i]
        l[i+1] = a
    if i >= 1:
        a = gcd(a, al[i])
        l[i+1] = a

# 右から左
for i in range(N-1):
    if i == 0:
        a = al[-i-1]
        r[-i-2] = a
    if i >= 1:
        a = gcd(a, al[-i-1])
        r[-i-2] = a

# 最大公約数リスト
ansl = [0]*N
for i in range(N):
    if i == 0:
        ansl[i] = r[i]
    elif i == N-1:
        ansl[i] = l[i]
    else:
        ansl[i] = gcd(r[i], l[i])
print(max(ansl))

Buggy python submission (verdict: Time Limit Exceeded):
from copy import copy
N = int(input())
al = [int(a) for a in input().split()]

def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a
  
ans_l = [0]*N

for i in range(N):
    tmp2 = copy(al)
    del tmp2[i]
    a = tmp2[0]
    for j in range(N-1):
        a = gcd(a, tmp2[j])
    ans_l[i] = a

print(max(ans_l))

Fixed submission:
N = int(input())
al = [int(a) for a in input().split()]
      
def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a

l = [0]*N
r = [0]*N

# 左から右
for i in range(N-1):
    if i == 0:
        a = al[i]
        l[i+1] = a
    if i >= 1:
        a = gcd(a, al[i])
        l[i+1] = a

# 右から左
for i in range(N-1):
    if i == 0:
        a = al[-i-1]
        r[-i-2] = a
    if i >= 1:
        a = gcd(a, al[-i-1])
        r[-i-2] = a

# 最大公約数リスト
ansl = [0]*N
for i in range(N):
    if i == 0:
        ansl[i] = r[i]
    elif i == N-1:
        ansl[i] = l[i]
    else:
        ansl[i] = gcd(r[i], l[i])
print(max(ansl))
Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
S = input()

ans = [np.zeros(N), np.zeros(N)]

for i in range(N):
    if S[i] == "#":
        ans[0][i:] += 1
    else:
        ans[1][:i+1] += 1

print(min(ans[0][N-1], ans[1][0], np.min(ans[0][1:]+ans[1][:N-1])))

Fixed submission:
N = int(input())
S = input()

ans =  S.count(".")
l = [0, ans]
for i in range(N):
    if S[i] == "#":
        l[0] += 1
    else:
         l[1] -= 1
    
    if ans > sum(l):
        ans = sum(l)
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()

ans1 = 1e7
ans2 = 1e7
ans3 = 1e7
f = False
for i in range(N-1):
    if S[i:i+2] == "#.":
        ans1 = S[i+1:].count(".")
        f = True
        break

for i in range(N-1):
    j = N - i
    if S[j-2:j] == "#.":
        ans2= S[:j-1].count("#")
        f = True
        break
        
for k in range(j-1):
    if S[j-2-k] == ".":
        ans3 = S[:j-1-k].count("#") + S[j-1:].count(".")
        break
    
print(min(ans1, ans2, ans3) if f else 0)

Fixed submission:
N = int(input())
S = input()

ans =  S.count(".")
l = [0, ans]
for i in range(N):
    if S[i] == "#":
        l[0] += 1
    else:
         l[1] -= 1
    
    if ans > sum(l):
        ans = sum(l)
print(ans)