Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
a = input()
N = int(a)
A = [int(input()) for i in range(N)]
ind = A.index(max(A))

for i in range(N):
    if i == ind:
        B = sorted(A)
        print(B[N-2])
    else:
        print(max(A))


Fixed submission:
a = input()
N = int(a)
A = [int(input()) for i in range(N)]
ind = A.index(max(A))
max = max(A)

for i in range(N):
    if i == ind:
        B = sorted(A)
        print(B[N-2])
    else:
        print(max)

Buggy python submission (verdict: Time Limit Exceeded):
a = input()
N = int(a)
A = [int(input()) for i in range(N)]

for i in range(N):
    if i == A.index(max(A)):
        B = sorted(A)
        print(B[N-2])
    else:
        print(max(A))

Fixed submission:
a = input()
N = int(a)
A = [int(input()) for i in range(N)]
ind = A.index(max(A))
max = max(A)

for i in range(N):
    if i == ind:
        B = sorted(A)
        print(B[N-2])
    else:
        print(max)

Buggy python submission (verdict: Time Limit Exceeded):
a = input()
N = int(a)
A = [int(input()) for i in range(N)]

for i in range(N):
    if i != A.index(max(A)):
        print(max(A))
    else:
        B = sorted(A)
        print(B[N-2])

Fixed submission:
a = input()
N = int(a)
A = [int(input()) for i in range(N)]
ind = A.index(max(A))
max = max(A)

for i in range(N):
    if i == ind:
        B = sorted(A)
        print(B[N-2])
    else:
        print(max)
Buggy python submission (verdict: Time Limit Exceeded):
a = list(map(int,input().split()))
N = a[0]
K = a[1]

i = 2
x = (N-K+1)
y = 1
z = (x*y)%(10**9+7)
print(z)

while K >= i:
    if (N-K+1) >= i:
        x = (N-K+2-i)*x//i
        y = (K-i+1)*y//(i-1)
        z = (x*y)%(10**9+7)
        print(z)
        i = i + 1
    else:
        print(0)

Fixed submission:
a = list(map(int,input().split()))
N = a[0]
K = a[1]

i = 2
x = (N-K+1)
y = 1
z = (x*y)%(10**9+7)
print(z)

while K >= i:
    if (N-K+1) >= i:
        x = (N-K+2-i)*x//i
        y = (K-i+1)*y//(i-1)
        z = (x*y)%(10**9+7)
        print(z)
    else:
        print(0)
    i = i + 1

Buggy python submission (verdict: Runtime Error):
a = list(map(int,input().split()))
N = a[0]
K = a[1]

i = 2
x = (N-K+1)
y = 1
z = (x*y)%(10**9+7)
print(z)

while (N-K+1) >= i and K >= i:
    x = (N-K+2-i)*x/i
    y = (K-i+1)*y/(i-1)
    z = (x*y)%(10**9+7)
    print(int(z))
    i = i + 1

Fixed submission:
a = list(map(int,input().split()))
N = a[0]
K = a[1]

i = 2
x = (N-K+1)
y = 1
z = (x*y)%(10**9+7)
print(z)

while K >= i:
    if (N-K+1) >= i:
        x = (N-K+2-i)*x//i
        y = (K-i+1)*y//(i-1)
        z = (x*y)%(10**9+7)
        print(z)
    else:
        print(0)
    i = i + 1
Buggy python submission (verdict: Time Limit Exceeded):
#n=int(input())
n,k=map(int,input().split())
al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
def f(l):
    res=1
    for li in l:
        res=res*li
    return res
sc=[]
alr=0
for i in range(k-1,n):
    
    if alr==0:
        score=f(al[i-k+1:i+1])
        alr=1
    else:
        first=al[i-k]
        last=al[i]
        score=(score//first)*last
    sc.append(score)
for i in range(n-k):
    if sc[i+1]>sc[i]:
        print('Yes')
    else:
        print('No')

Fixed submission:
#n=int(input())
n,k=map(int,input().split())
al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
def f(l):
    res=1
    for li in l:
        res=res*li
    return res
sc=[]
alr=0
for i in range(k-1,n):
    if i==k-1:
        #score=f(al[i-k+1:i+1])
        first=al[i-k+1]
        alr=1
    else:
        #first=al[i-k]
        last=al[i]
        if last>first :
            print('Yes')
        else:
            print('No')
        first=al[i-k+1]

Buggy python submission (verdict: Time Limit Exceeded):
#n=int(input())
n,k=map(int,input().split())
al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
def f(l):
    res=1
    for li in l:
        res=res*li
    return res
sc=[]
for i in range(k-1,n):
    score=f(al[i-k+1:i+1])
    sc.append(score)
for i in range(n-k):
    if sc[i+1]>sc[i]:
        print('Yes')
    else:
        print('No')

Fixed submission:
#n=int(input())
n,k=map(int,input().split())
al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
def f(l):
    res=1
    for li in l:
        res=res*li
    return res
sc=[]
alr=0
for i in range(k-1,n):
    if i==k-1:
        #score=f(al[i-k+1:i+1])
        first=al[i-k+1]
        alr=1
    else:
        #first=al[i-k]
        last=al[i]
        if last>first :
            print('Yes')
        else:
            print('No')
        first=al[i-k+1]
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10 ** 7)
n = int(input())
#k, x = map(int, input().split())
al = list(map(int, input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
money=[]
m=2
day=0
def dfs(cur, day, kabu):
    global money
    if day==n:
        money.append(cur)
        return
    # buy
    for v in range(0,cur//al[day]+1):
        buynum=v*al[day]
        nowkabu=kabu+v
        dfs(cur-v*al[day],day+1,kabu+v)
        #A.append(v)
        #dfs(A)
        #A.pop()
    # sell
    for w in range(0,kabu+1):
        sellnum=w
        dfs(cur+w*al[day],day+1,kabu-w)
dfs(1000,day,0)
print(max(money))

Fixed submission:
n=int(input())
#n,k=map(int,input().split())
al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
stock = 0
money = 1000
for i in range(n-1):
    sell = stock*al[i]
    stock = 0
    money += sell
    if al[i] < al[i+1]:# buy
        buynum = money//al[i]
        stock= buynum
        money -= buynum*al[i]

print(money + stock*al[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

import math 

def gcds(l):
    res=0
    for val in l:
        res=math.gcd(res,val)
    return res
ans=0
for i in range(1,k+1):
    for j in range(1,k+1):
        for m in range(1,k+1):
            ans+=gcds([i,j,m])
print(ans)


Fixed submission:
k=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

import math 

def gcds(l):
    res=0
    for val in l:
        res=math.gcd(res,val)
    return res
ans=0
for i in range(1,k+1):
    for j in range(1,k+1):
        for m in range(1,k+1):
            ans+=gcds([i,j,m])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#n=int(input())
n,x,y=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

adjl=[[0 for i in range(n)] for j in range(n)]

dic={}

for i in range(n):
    for j in range(i,n):
        #if i>=j:
        #    continue
        dis=j-i
        maybe=abs(x-(i+1))+1+abs(y-(j+1))
        dis=min(dis,maybe)
        adjl[i][j]=dis

for i in range(n):
    for j in range(i,n):
        #if i>=j:
        #    continue
        dis=adjl[i][j]
        dic[dis]=dic.get(dis,0)+1
for k in range(1,n):
    print(dic.get(k,0))


Fixed submission:
#n=int(input())
n,x,y=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

#adjl=[[0 for i in range(n)] for j in range(n)]

dic={}

for i in range(n):
    for j in range(i,n):
        #if i>=j:
        #    continue
        dis=j-i
        maybe=abs(x-(i+1))+1+abs(y-(j+1))
        dis=min(dis,maybe)
        #adjl[i][j]=dis
        dic[dis]=dic.get(dis,0)+1

for k in range(1,n):
    print(dic.get(k,0))
Buggy python submission (verdict: Runtime Error):
#n=int(input())
h,w=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
v1=h//2
v2=w//2
if h==1 or w==1:
    print(0)
elif h%2==0:
    
    ans=v1*w
else:
    if w%2==0:
        ans=v1*v2+(v1-1)*v2
    else:
        t=v1+1
        ans=v2*(t-1)+(v2+1)*t
print(ans)


Fixed submission:
#n=int(input())
h,w=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
v1=h//2
v2=w//2
if h==1 or w==1:
    ans=1
elif h%2==0:
    ans=v1*w
else:
    if w%2==0:
        ans=(v1+1)*v2+(v1)*v2
    else:
        t=v1+1
        ans=v2*(v1)+(v2+1)*(v1+1)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#n=int(input())
n,a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

v=n//(a+b)
ans=v*a
mod=n%(a+b)

for i in range(min(mod,a)):
    ans+=1
print(ans)  

Fixed submission:
#n=int(input())
n,a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

v=n//(a+b)
ans=v*a
mod=n%(a+b)

temp=min(mod,a)
ans+=temp
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#n=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

sl=list(input())
q=int(input())
l=[list(map(str,input().split())) for i in range(q)]

#print(l)

count=0
isR=False
from collections import deque
for i in range(q):
    order=l[i]
    if order[0]=="1":
        count+=1
        #反転
    if count%2==0:
        isR=False
    else:
        isR=True
    if order[0]!="1":
        
        f=order[1]
        c=order[2]
        temp_f=f
        if isR:
            if temp_f=="1":
                temp_f="2"
            else:
                temp_f="1"
        if temp_f=="1":
            tempq=deque(sl)
            tempq.appendleft(c)
            sl=list(tempq)
        else:
            sl.append(c)
ln=len(sl)
ansl=[]
if isR:
    for i in range(ln-1,-1,-1):
        ansl.append(sl[i])
else:
    ansl=sl
ans=''.join(ansl)
print(ans)



Fixed submission:
#n=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

sl=list(input())
q=int(input())
l=[list(map(str,input().split())) for i in range(q)]

#print(l)

count=0
isR=False
from collections import deque
sl=deque(sl)
for i in range(q):
    order=l[i]
    if order[0]=="1":
        count+=1
        #反転
    if count%2==0:
        isR=False
    else:
        isR=True
    if order[0]!="1":
        f=order[1]
        c=order[2]
        temp_f=f
        if isR:
            if temp_f=="1":
                temp_f="2"
            else:
                temp_f="1"
        if temp_f=="1":
            #tempq=deque(sl)
            sl.appendleft(c)
            #tempq.appendleft(c)
            #sl=list(tempq)
        else:
            sl.append(c)
sl=list(sl)
ln=len(sl)
ansl=[]
if isR:
    for i in range(ln-1,-1,-1):
        ansl.append(sl[i])
else:
    ansl=sl
ans=''.join(ansl)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
h=int(input())
count=1
ans=1
v=h
while True:
    temp=v//2
    #count=count*2
    #ans+=count
    if temp==1:
        #count=count*2
        ans+=1
        #ans+=count
        break
    v=temp
    #count=count*2
    #ans+=count
    ans+=1
    
print(int((1-2**ans)/(1-2)))




Fixed submission:
h=int(input())
count=1
ans=1
v=h
import math
while True:
    temp=math.floor(v/2)
    if temp==0:
        #count=count*2
        #ans+=1
        #ans+=count
        break
    v=temp
    ans+=1
    
print(int((1-2**(ans))/(1-2)))

Buggy python submission (verdict: Time Limit Exceeded):
h=int(input())
count=1
ans=1
v=h
while True:
    temp=int(v//2)
    #count=count*2
    #ans+=count
    if temp==1:
        count=count*2
        ans+=count
        break
    v=temp
    count=count*2
    ans+=count
    
print(ans)




Fixed submission:
h=int(input())
count=1
ans=1
v=h
import math
while True:
    temp=math.floor(v/2)
    if temp==0:
        #count=count*2
        #ans+=1
        #ans+=count
        break
    v=temp
    ans+=1
    
print(int((1-2**(ans))/(1-2)))
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
sl=[]
pl=[]
pena=0
ac=0
ac_p=[]
wa={}
for i in range(m):
    #p,s=map(str,input().split())
    li = input().split()
    p=int(li[0])
    s=li[1]
    #p=int(p)
    if s=="WA":
        wa[p]=wa.get(p,0)+1
    else:#もしACなら
        if not p in ac_p:
            ac+=1
            ac_p.append(p)
            pena+=wa.get(p,0)

print("{0} {1}".format(ac,pena))



Fixed submission:
n,m=map(int,input().split())
sl=[]
pl=[]
pena=0
ac=0
ac_p=[]
wa={}
acdic={}

for i in range(m):
    #p,s=map(str,input().split())
    li = input().split()
    p=int(li[0])
    s=li[1]
    #p=int(p)
    if s=="WA":
        wa[p]=wa.get(p,0)+1
    else:#もしACなら
        #acdic[p]=True
        if acdic.get(p,False)==False:
            ac+=1
            acdic[p]=True
            pena+=wa.get(p,0)

print("{0} {1}".format(ac,pena))

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
sl=[]
pl=[]
pena=0
ac=0
ac_p=[]
wa={}
for i in range(m):
    p,s=map(str,input().split())
    p=int(p)
    if s=="WA":
        wa[p]=wa.get(p,0)+1
    else:#もしACなら
        if not p in ac_p:
            ac+=1
            ac_p.append(p)
            pena+=wa.get(p,0)

print("{0} {1}".format(ac,pena))



Fixed submission:
n,m=map(int,input().split())
sl=[]
pl=[]
pena=0
ac=0
ac_p=[]
wa={}
acdic={}

for i in range(m):
    #p,s=map(str,input().split())
    li = input().split()
    p=int(li[0])
    s=li[1]
    #p=int(p)
    if s=="WA":
        wa[p]=wa.get(p,0)+1
    else:#もしACなら
        #acdic[p]=True
        if acdic.get(p,False)==False:
            ac+=1
            acdic[p]=True
            pena+=wa.get(p,0)

print("{0} {1}".format(ac,pena))

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
sl=[]
pl=[]
pena=0
ac=0
ac_p=[]
wa={}
for i in range(m):
    p,s=map(str,input().split())
    p=int(p)
    if s=="WA":
        wa[p]=wa.get(p,0)+1
    else:#もしACなら
        if not p in ac_p:
            ac+=1
            ac_p.append(p)
            pena+=wa.get(p,0)

print("{0} {1}".format(ac,pena))



Fixed submission:
n,m=map(int,input().split())
sl=[]
pl=[]
pena=0
ac=0
ac_p=[]
wa={}
acdic={}

for i in range(m):
    #p,s=map(str,input().split())
    li = input().split()
    p=int(li[0])
    s=li[1]
    #p=int(p)
    if s=="WA":
        wa[p]=wa.get(p,0)+1
    else:#もしACなら
        #acdic[p]=True
        if acdic.get(p,False)==False:
            ac+=1
            acdic[p]=True
            pena+=wa.get(p,0)

print("{0} {1}".format(ac,pena))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
#m1,d1=map(int,input().split())
#hl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
S=list(input())
d=list('0123456789')
ans=0
for d1 in d:
    for d2 in d:
        for d3 in d:
            v=d1+d2+d3
            i=0
            p=0
            while i < N :
                if v[p]==S[i]:
                    p+=1
                    if p == 3:
                        break
                i+=1
            if p==3 :
                ans+=1
print(ans)

Fixed submission:
n=int(input())
s=input()
ans=0
for i in range(1000,2000):
    templ=list(str(i))
    t=templ[1:]
    #print(t)
    p=0
    for q in range(n):
        if s[q]==t[p]:
            p+=1
        if p>2:
            ans+=1
            break         

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
ans=0
for i in range(1000,2000):
    templ=list(str(i))
    t=templ[1:]
    #print(t)
    p=0
    for q in range(n):
        if s[q]==t[p]:
            p+=1
        if p>2:
            ans+=1
            break         

print(ans)


Fixed submission:
n=int(input())
s=input()
ans=0
for i in range(1000,2000):
    templ=list(str(i))
    t=templ[1:]
    #print(t)
    p=0
    for q in range(n):
        if s[q]==t[p]:
            p+=1
        if p>2:
            ans+=1
            break         

print(ans)
Buggy python submission (verdict: Runtime Error):
#n=int(input())
a,b,x=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

import math

s=x/a
if s<= a*b/2:
    c=2*s/b
    deg=math.degrees(math.atan(c/b))
    ans=90.0-deg
    print('{:.9f}'.format(ans))
else:
    s=a*b-s
    h=2*s/a
    deg=math.degrees(math.atan(a/h))
    ans=90.0-deg
    print('{:.9f}'.format(ans))


Fixed submission:
#n=int(input())
a,b,x=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

import math

s=x/a
if x==a*a*b:
    print(0)
elif s<= a*b/2:
    c=2*s/b
    deg=math.degrees(math.atan(c/b))
    ans=90.0-deg
    print('{:.9f}'.format(ans))
else:
    s=a*b-s
    h=2*s/a
    deg=math.degrees(math.atan(a/h))
    ans=90.0-deg
    print('{:.9f}'.format(ans))

Buggy python submission (verdict: Runtime Error):
#n=int(input())
a,b,x=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

import math

s=x/a
if s<= a*b/s:
    c=2*s/b
    deg=math.degrees(math.atan(c/b))
    ans=90.0-deg
    print('{:.9f}'.format(ans))
else:
    s=a*b-s
    h=2*s/a
    deg=math.degrees(math.atan(a/h))
    ans=90.0-deg
    print('{:.9f}'.format(ans))


Fixed submission:
#n=int(input())
a,b,x=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

import math

s=x/a
if x==a*a*b:
    print(0)
elif s<= a*b/2:
    c=2*s/b
    deg=math.degrees(math.atan(c/b))
    ans=90.0-deg
    print('{:.9f}'.format(ans))
else:
    s=a*b-s
    h=2*s/a
    deg=math.degrees(math.atan(a/h))
    ans=90.0-deg
    print('{:.9f}'.format(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n,k,q=map(int,input().split())

al=[int(input()) for i in range(q)]
pointl=[k for i in range(n)]

for i in range(q):
  pointl=[point-1 for point in pointl]
  pointl[al[i]-1]+=1
  #print(pointl)
#print(pointl)
for p in pointl:
  if p <= 0:
    print("No")
  else :
    print("Yes")

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

#al=[int(input()) for i in range(q)]
d={}
for i in range(q):
  s=int(input())
  if not s in d.keys():
    d[s]=1
  else :
    d[s]+=1
#print(d)

pointl=[k-q for i in range(n)]

for k,v in d.items():
  pointl[k-1]+=v
for p in pointl:
  if p <= 0:
    print("No")
  else :
    print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
#n=int(input())
l,r=map(int,input().split())
#t=int(input())
#al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

if l-r>=2019:
    mn=0
else:
    mn=(l*r)%2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            mn=min(mn,(i*j)%2019)
print(mn)


Fixed submission:
l,r=map(int,input().split())
temp=[]
if r-l>=2019:
    print(0)
else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            temp.append((i*j)%2019)
    print(min(temp))

Buggy python submission (verdict: Time Limit Exceeded):
l,r=map(int,input().split())
temp=[]
if l-r>=2019:
    print(0)
else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            temp.append((i*j)%2019)
    print(min(temp))


Fixed submission:
l,r=map(int,input().split())
temp=[]
if r-l>=2019:
    print(0)
else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            temp.append((i*j)%2019)
    print(min(temp))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
li = list(map(int,input().split()))

li.sort()

ind=int(n//2)-1

count=0
for k in range(li[ind]+1,li[ind+1]+1):
  miman=0
  ijou=0
  for num in li:
    if num >= k:
      ijou+=1
    elif num < k:
      miman+=1
      
  if ijou==miman:
    count+=1
    
print(count)

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

li.sort()

ind=int(n//2)-1

count=0

for k in range(li[ind]+1,li[ind+1]+1):
  count+=1
  
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
li = list(map(int,input().split()))

li.sort()

ind=int(n//2)-1

count=0
for k in range(li[ind],li[ind+1]+1):
  miman=0
  ijou=0
  for num in li:
    if num >= k:
      ijou+=1
    elif num < k:
      miman+=1
      
  if ijou==miman:
    count+=1
    
print(count)

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

li.sort()

ind=int(n//2)-1

count=0

for k in range(li[ind]+1,li[ind+1]+1):
  count+=1
  
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
al=list(map(int,input().split()))

import fractions

def gcdoflist(l):
    n=len(l)
    if n==1:
        return l[0]
    else:
        ans=l[0]
        for i in range(1,n):
            ans=fractions.gcd(ans,l[i])
        return ans
m_list=[]
#端点の場合
#右端
m_list.append(gcdoflist(al[0:n-1]))

#左端
m_list.append(gcdoflist(al[1:n]))
ans=max(m_list)
for i in range(1,n-1):
    left=al[0:i]
    right=al[i+1:n]
    temp=fractions.gcd(gcdoflist(left),gcdoflist(right))
    if temp>ans:
        ans=temp
print(ans)

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

import fractions
ans=0
left=[0]
for i in range(1,n):
    ans=fractions.gcd(ans,al[i-1])
    left.append(ans)
#print(left)
right=[0 for i in range(n+1)]
for i in range(1,n+1):
    right[n-i]=fractions.gcd(right[n-i+1],al[n-i])
#print(right)

ans=0

for i in range(n):
    ans=max(ans,(fractions.gcd(left[i],right[i+1])))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
al=list(map(int,input().split()))

import fractions

def gcdoflist(l):
    n=len(l)
    if n==1:
        return l[0]
    else:
        ans=l[0]
        for i in range(1,n):
            ans=fractions.gcd(ans,l[i])
        return ans
m_list=[]
#端点の場合
#右端
m_list.append(gcdoflist(al[0:n-1]))

#左端
m_list.append(gcdoflist(al[1:n]))

for i in range(1,n-1):
    left=al[0:i]
    right=al[i+1:n]
    m_list.append(fractions.gcd(gcdoflist(left),gcdoflist(right)))
print(max(m_list))



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

import fractions
ans=0
left=[0]
for i in range(1,n):
    ans=fractions.gcd(ans,al[i-1])
    left.append(ans)
#print(left)
right=[0 for i in range(n+1)]
for i in range(1,n+1):
    right[n-i]=fractions.gcd(right[n-i+1],al[n-i])
#print(right)

ans=0

for i in range(n):
    ans=max(ans,(fractions.gcd(left[i],right[i+1])))
print(ans)
Buggy python submission (verdict: Runtime Error):
S=list(input())

n=len(S)
l=list("ACGT")
ans=[]

for i in range(7):
  count=0
  for j in range(i,7):
    if S[j] in l:
      count+=1
    else:
      break
  ans.append(count)
print(max(ans))

Fixed submission:
S=list(input())

n=len(S)
l=list("ACGT")
ans=[]

for i in range(n):
  count=0
  for j in range(i,n):
    if S[j] in l:
      count+=1
    else:
      break
  ans.append(count)
print(max(ans))
Buggy python submission (verdict: Runtime Error):
s=input()
k=int(input())

for i in range(len(s)):
    if s[i]!="1":
        nextone=s[i]
        break
    
if i>=k:
    print(1)
else:
    print(nextone)

Fixed submission:
s=input()
k=int(input())

for i in range(len(s)):
    if s[i]!="1":
        nextone=s[i]
        break
if s.count("1")==len(s):
    print(1)
elif i>=k:
    print(1)
else:
    print(nextone)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=list(input())
ans=n

for i in range(n):
  l=s[0:i]
  r=s[i+1:n]
  v=l.count("W")+r.count("E")
  if ans>v:
    ans=v
print(ans)


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

#累積和を求める
wcum=[];wcount=0
ecum=[];ecount=0
for i in range(n):
  if s[i]=="W":
    wcount+=1
  else:
    ecount+=1
  ecum.append(ecount)
  wcum.append(wcount)
ans=ecum[n-1]-ecum[0]
for i in range(1,n):
  v=wcum[i-1]+(ecum[n-1]-ecum[i])
  if ans>v:
    ans=v
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
st="NO"
for i in range(a,b*a+1):
  if i%b==c:
    st="YES"
    break

print(st)


Fixed submission:
#n=int(input())
a,b,c=map(str,input().split())
#al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(m)]

if a[-1]==b[0] and b[-1]==c[0]:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())
count=0
for x in range(0,k+1):
  for y in range(0,k+1):
    for z in range(0,k+1):
      if s==x+y+z :
        count+=1
print(count)

Fixed submission:
k,s=map(int,input().split())
count=0
for x in range(0,k+1):
  for y in range(0,k+1):
    #for z in range(0,k+1):
    z=s-(x+y)
    if z >=0 and z<=k:
      count+=1
print(count)