Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
p=set()
ans=0
for c in s:
    ci=int(c)
    t=set()
    for i in p:
        i=(i*10+ci)%2019
        if i==0:
            ans+=1
        else:
            t.add(i)
    t.add(ci)
    p=t.copy()
print(ans)

Fixed submission:
S=input()
MOD=2019
dp=[0]*MOD
dp[0]=1
r=0
t=1
for c in reversed(S):
    r+=int(c)*t
    r%=MOD
    t*=10
    t%=MOD
    dp[r]+=1
print(sum(i*(i-1)//2 for i in dp))

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
p=set()
ans=0
for c in s:
    t=set()
    for i in p:
        i=(i*10+int(c))%2019
        if i==0:
            ans+=1
        else:
            t.add(i)
    t.add(int(c))
    p=t.copy()
print(ans)

Fixed submission:
S=input()
MOD=2019
dp=[0]*MOD
dp[0]=1
r=0
t=1
for c in reversed(S):
    r+=int(c)*t
    r%=MOD
    t*=10
    t%=MOD
    dp[r]+=1
print(sum(i*(i-1)//2 for i in dp))

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
t=[]
ans=0
for c in s:
    l=len(t)
    for i in range(l):
        t[i]*=10
        t[i]+=int(c)
        t[i]%=2019
        if t[i]==0:
            ans+=1
    t.append(int(c))
    t=list(set(t))
print(ans)

Fixed submission:
S=input()
MOD=2019
dp=[0]*MOD
dp[0]=1
r=0
t=1
for c in reversed(S):
    r+=int(c)*t
    r%=MOD
    t*=10
    t%=MOD
    dp[r]+=1
print(sum(i*(i-1)//2 for i in dp))

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
t=[]
ans=0
for c in s:
    l=len(t)
    for i in range(l):
        t[i]*=10
        t[i]+=int(c)
        t[i]%=2019
        if t[i]==0:
            ans+=1
    t.append(int(c))
    t=list(set(t))
print(ans)

Fixed submission:
S=input()
MOD=2019
dp=[0]*MOD
dp[0]=1
r=0
t=1
for c in reversed(S):
    r+=int(c)*t
    r%=MOD
    t*=10
    t%=MOD
    dp[r]+=1
print(sum(i*(i-1)//2 for i in dp))

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
t=[]
ans=0
for c in s:
    l=len(t)
    for i in range(l):
        t[i]*=10
        t[i]+=int(c)
        t[i]%=2019
        if t[i]==0:
            ans+=1
    t.append(int(c))
print(ans)

Fixed submission:
S=input()
MOD=2019
dp=[0]*MOD
dp[0]=1
r=0
t=1
for c in reversed(S):
    r+=int(c)*t
    r%=MOD
    t*=10
    t%=MOD
    dp[r]+=1
print(sum(i*(i-1)//2 for i in dp))

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
t=[]
ans=0
for c in s:
    l=len(t)
    for i in range(l):
        t[i]*=10
        t[i]+=int(c)
        t[i]%=2019
        if t[i]==0:
            ans+=1
    t.append(int(c))
print(ans)

Fixed submission:
S=input()
MOD=2019
dp=[0]*MOD
dp[0]=1
r=0
t=1
for c in reversed(S):
    r+=int(c)*t
    r%=MOD
    t*=10
    t%=MOD
    dp[r]+=1
print(sum(i*(i-1)//2 for i in dp))

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
ans=0
for i in range(n:=len(s)):
    for j in range(i+3,n):
        t=int(s[i:j+1])
        if t%2019==0:
            ans+=1
print(ans)

Fixed submission:
S=input()
MOD=2019
dp=[0]*MOD
dp[0]=1
r=0
t=1
for c in reversed(S):
    r+=int(c)*t
    r%=MOD
    t*=10
    t%=MOD
    dp[r]+=1
print(sum(i*(i-1)//2 for i in dp))
Buggy python submission (verdict: Time Limit Exceeded):
import math
n=int(input())
ans=0
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            ans+=math.gcd(math.gcd(i,j),k)
print(ans)

Fixed submission:
import math
n=int(input())
ans=0
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            ans+=math.gcd(math.gcd(i,j),k)
print(ans)
Buggy python submission (verdict: Runtime Error):
x,y,a,b,c=map(int,input().split())
p=sorted(list(map(int,input().split())),reverse=True)[:x]
q=sorted(list(map(int,input().split())),reverse=True)[:y]
r=list(map(int,input().split()))
print(sum(sorted(p+q+r,reverse=True)[:x+y]))

Fixed submission:
n,x,y=map(int,input().split())
ans=[0]*n
for i in range(1,n):
    for j in range(i+1,n+1):
        ans[min(j-i,abs(x-i)+abs(y-j)+1,abs(x-j)+abs(y-i)+1)]+=1
for i in range(1,n):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
from decimal import *
getcontext().prec=3000
a,b,c=map(int,input().split())
print('Yes' if Decimal(a)**Decimal(0.5)+Decimal(b)**Decimal(0.5)<Decimal(c)**Decimal(0.5) else 'No')

Fixed submission:
a,b,c=map(int,input().split())
print('Yes' if c-a-b>0 and 4*a*b<(c-a-b)**2 else 'No')
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
q=int(input())
flg=True
for _ in range(q):
    t=list(input().split())
    if t[0]=='1':
        flg=not flg
    else:
        if t[1]=='1':
            if flg:
                s=t[2]+s
            else:
                s=s+t[2]
        else:
            if flg:
                s=s+t[2]
            else:
                s=t[2]+s
if flg:
    print(s)
else:
    print(s[::-1])

Fixed submission:
from collections import deque
s=input()
q=int(input())
flg=True
s1=deque()
s2=deque()
for _ in range(q):
    t=list(input().split())
    if t[0]=='1':
        flg=not flg
    else:
        if t[1]=='1':
            if flg:
                s1.appendleft(t[2])
            else:
                s2.append(t[2])
        else:
            if flg:
                s2.append(t[2])
            else:
                s1.appendleft(t[2])
if flg:
    print(''.join(s1)+s+''.join(s2))
else:
    print(''.join(s2)[::-1]+s[::-1]+''.join(s1)[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
q=int(input())
for _ in range(q):
    t=list(input().split())
    if t[0]=='1':
        s=s[::-1]
    else:
        if t[1]=='1':
            s=t[2]+s
        else:
            s=s+t[2]
print(s)

Fixed submission:
from collections import deque
s=input()
q=int(input())
flg=True
s1=deque()
s2=deque()
for _ in range(q):
    t=list(input().split())
    if t[0]=='1':
        flg=not flg
    else:
        if t[1]=='1':
            if flg:
                s1.appendleft(t[2])
            else:
                s2.append(t[2])
        else:
            if flg:
                s2.append(t[2])
            else:
                s1.appendleft(t[2])
if flg:
    print(''.join(s1)+s+''.join(s2))
else:
    print(''.join(s2)[::-1]+s[::-1]+''.join(s1)[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
al=list(map(int,input().split()))
mod=10**9+7
t=[0]*61
for a in al:
    for i in range(61):
        if 2**i&a:
            t[i]+=1
ans=0
for i in range(61):
    if t[i]>0:
        ans+=(n-t[i])*t[i]*2**i%mod
print(ans%mod)

Fixed submission:
n=int(input())
al=list(map(int,input().split()))
mod=10**9+7
t=[0]*61
for a in al:
    for i in range(61):
        if 2**i&a:
            t[i]+=1
ans=0
for i in range(61):
    if t[i]>0:
        ans+=(n-t[i])*t[i]*2**i%mod
print(ans%mod)
Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
dl=list(map(int,input().split()))
MOD=998244353
if dl[0]>0:
    print(0)
    exit()
dist=[0]*(n-1)
for d in dl:
    dist[d]+=1
if dist[0]!=1:
    print(0)
    exit()
ans=1
flg=False
for i in range(1,n-1):
    if dist[i]>0:
        if flg:
            ans=0
            break
        else:
            ans*=dist[i-1]**dist[i]%MOD
    else:
        flg=True
print(ans%MOD)

Fixed submission:
import math
n=int(input())
dl=list(map(int,input().split()))
MOD=998244353
if dl[0]>0:
    print(0)
    exit()
dist=[0]*(n)
for d in dl:
    dist[d]+=1
if dist[0]!=1:
    print(0)
    exit()
ans=1
flg=False
for i in range(1,n):
    if dist[i]>0:
        if flg:
            ans=0
            break
        else:
            ans*=dist[i-1]**dist[i]%MOD
    else:
        flg=True
print(ans%MOD)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int,input().split()))
l=sorted(l)
ans=0
for i in range(n):
    a=l[i]
    for j in range(i+1,n):
        b=l[j]
        for k in range(j+1,n):
            c=l[k]
            if c>=a+b:
                break
            if a<b+c and b<a+c and c<a+b:
                ans+=1
print(ans)

Fixed submission:
import bisect
n=int(input())
l=list(map(int,input().split()))
l=sorted(l)
ans=0
for i in range(n):
    a=l[i]
    for j in range(i+1,n):
        b=l[j]
        idx=bisect.bisect_left(l,a+b)
        t=idx-j-1
        if t>0:
            ans+=t
print(ans)
Buggy python submission (verdict: Runtime Error):
h,w,a,b=map(int,input().split())
ans=['']*w
for i in range(h):
    for j in range(w):
        if (i<b and j<a) or (i>=b and j>=a):
            ans[i]+='0'
        else:
            ans[i]+='1'
for i in range(h):
    print(ans[i])

Fixed submission:
h,w,a,b=map(int,input().split())
ans=['']*h
for i in range(h):
    for j in range(w):
        if (i<b and j<a) or (i>=b and j>=a):
            ans[i]+='0'
        else:
            ans[i]+='1'
for i in range(h):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N,Q=map(int,input().split())
AB=[tuple(map(int,input().split())) for _ in range(N-1)]
k=[0]*N
for _ in range(Q):
    p,x=map(int,input().split())
    k[p-1]+=x
q=deque([1])
ab=AB[:]
while q:
    t=q.popleft()
    tab=ab[:]
    for a,b in tab:
        if t==a:
            q.append(b)
            k[b-1]+=k[t-1]
            ab.remove((a,b))
        elif t==b:
            q.append(a)
            k[a-1]+=k[t-1]
            ab.remove((a,b))
print(*k)

Fixed submission:
from collections import deque
N,Q=map(int,input().split())
tr=[[] for _ in range(N)]
for _ in range(N-1):
    a,b=map(int,input().split())
    tr[a-1].append(b-1)
    tr[b-1].append(a-1)
k=[0]*N
for _ in range(Q):
    p,x=map(int,input().split())
    k[p-1]+=x
q=deque([0])
v=[True]*N
while q:
    t=q.popleft()
    if v[t]:
        v[t]=False
        for j in tr[t]:
            if v[j]:
                k[j]+=k[t]
                q.append(j)
print(*k)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N,Q=map(int,input().split())
AB=[tuple(map(int,input().split())) for _ in range(N-1)]
k=[0]*N
for _ in range(Q):
    p,x=map(int,input().split())
    k[p-1]+=x
q=deque([1])
ab=AB[:]
while q:
    t=q.popleft()
    tab=ab[:]
    for a,b in tab:
        if t==a:
            q.append(b)
            k[b-1]+=k[t-1]
            ab.remove((a,b))
        elif t==b:
            q.append(a)
            k[a-1]+=k[t-1]
            ab.remove((a,b))
print(*k)

Fixed submission:
from collections import deque
N,Q=map(int,input().split())
tr=[[] for _ in range(N)]
for _ in range(N-1):
    a,b=map(int,input().split())
    tr[a-1].append(b-1)
    tr[b-1].append(a-1)
k=[0]*N
for _ in range(Q):
    p,x=map(int,input().split())
    k[p-1]+=x
q=deque([0])
v=[True]*N
while q:
    t=q.popleft()
    if v[t]:
        v[t]=False
        for j in tr[t]:
            if v[j]:
                k[j]+=k[t]
                q.append(j)
print(*k)
Buggy python submission (verdict: Runtime Error):
from scipy import special
n=int(input())
s=[''.join(sorted(input())) for _ in range(n)]
s=sorted(s)
ans=0
c=1
t=s[0]
for i in range(1,n):
    if t==s[i]:
        c+=1
    else:
        ans+=special.comb(c,2,True)
        t=s[i]
        c=1
ans+=special.comb(c,2,True)
print(ans)

Fixed submission:
from scipy import misc
n=int(input())
s=[''.join(sorted(input())) for _ in range(n)]
s=sorted(s)
ans=0
c=1
t=s[0]
for i in range(1,n):
    if t==s[i]:
        c+=1
    else:
        ans+=misc.comb(c,2,True)
        t=s[i]
        c=1
ans+=misc.comb(c,2,True)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[''.join(sorted(input())) for _ in range(n)]
ans=0
t=[]
for i in range(n):
    ans+=t.count(s[i])
    t.append(s[i])
print(ans)

Fixed submission:
from scipy import misc
n=int(input())
s=[''.join(sorted(input())) for _ in range(n)]
s=sorted(s)
ans=0
c=1
t=s[0]
for i in range(1,n):
    if t==s[i]:
        c+=1
    else:
        ans+=misc.comb(c,2,True)
        t=s[i]
        c=1
ans+=misc.comb(c,2,True)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
al=[int(input()) for _ in range(n)]
ans=[]
for a in al:
    for i in range(len(ans)):
        if max(ans[i])<a:
            ans[i].append(a)
            break
    else:
        ans.append([a])
print(len(ans))

Fixed submission:
import bisect
n=int(input())
al=[-int(input()) for _ in range(n)]
ans=[al[0]]
for a in al[1:]:
    i=bisect.bisect(ans,a)
    if i==len(ans):
        ans.append(a)
    else:
        ans[i]=a
print(len(ans))
Buggy python submission (verdict: Runtime Error):
n=int(input())
al=list(map(int,input().split()))
s=set(al)
s=sorted(s)
if len(s)==1 and s[0]==0:
    print('Yes')
    exit()
if len(al)%3>0 or len(s)>3 or len(s)==1:
    print('No')
    exit()
if len(s)==2 and s[0]==0:
    if al.count(0)==n//3:
        print('Yes')
        exit()
if (s[0]^s[1]^s[2])==0:
    if al.count(s[0])==n//3 and al.count(s[1])==n//3:
        print('Yes')
        exit()
print('No')

Fixed submission:
n=int(input())
al=list(map(int,input().split()))
t=0
for i in range(n):
    t^=al[i]
if t==0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
w,h,x,y=map(int,input().split())

if w==x:
    print('{:6f}'.format(min(w*(h-y),w*y)),0)
elif h==x:
    print('{:6f}'.format(min((w-x)*h,x*h)),0)
elif (w-x)*h==w*(h-y):
    print('{:6f}'.format((w-x)*h,1)
elif min((w-x)*h,x*h)>min(w*(h-y),w*y):
    print('{:6f}'.format(min((w-x)*h,x*h)),0)
else:
    print('{:6f}'.format(min(w*(h-y),w*y)),0)

Fixed submission:
w,h,x,y=map(int,input().split())
print(w*h/2)
if x==w/2 and y==h/2:
    print(1)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
w,h,x,y=map(int,input().split())
tl=set([(w-x)*h,w*(h-y),x*h,w*y])

if (w-x)*h==w*(h-y):
    print('{:6f}'.format((w-x)*h),1)
elif min((w-x)*h,x*h)>min(w*(h-y),w*y):
    print('{:6f}'.format(min((w-x)*h,x*h)),0)
else:
    print('{:6f}'.format(min(w*(h-y),w*y),0)

Fixed submission:
w,h,x,y=map(int,input().split())
print(w*h/2)
if x==w/2 and y==h/2:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
sl=[input() for i in range(h)]
ll=[[0]*w for i in range(h)]
for i in range(h):
    for j in range(w):
        if sl[i][j]=='.':
            if j==0:
                ll[i][j]=1
            else:
                ll[i][j]=ll[i][j-1]+1
        else:
            ll[i][j]=0
rl=[[0]*w for i in range(h)]
for i in range(h):
    for j in range(w-1,-1,-1):
        if sl[i][j]=='.':
            if j==w-1:
                rl[i][j]=1
            else:
                rl[i][j]=rl[i][j+1]+1
        else:
            rl[i][j]=0
ul=[[0]*w for i in range(h)]
for j in range(w):
    for i in range(h):
        if sl[i][j]=='.':
            if i==0:
                ul[i][j]=1
            else:
                ul[i][j]=ul[i-1][j]+1
        else:
            ul[i][j]=0
dl=[[0]*w for i in range(h)]
for j in range(w):
    for i in range(h-1,-1,-1):
        if sl[i][j]=='.':
            if i==h-1:
                dl[i][j]=1
            else:
                dl[i][j]=dl[i+1][j]+1
        else:
            dl[i][j]=0
ans=0
for i in range(h):
    for j in range(w):
            ans=max(ans,ll[i][j]+rl[i][j]+ul[i][j]+dl[i][j]-3)
print(ans)

Fixed submission:
p,q,r=map(int,input().split())
print(sum([p,q,r])-max(p,q,r))
Buggy python submission (verdict: Runtime Error):
import functools
import operator
q=int(input())
for i in range(q):
    x,d,n=map(int,input().split())
    a=range(x,x+d*(n-1)+1,d)
    print(functools.reduce(operator.mul,a)%1000003)

Fixed submission:
q=int(input())
m=10**6+3
f=[1]
for i in range(1,m):
    f.append(f[-1]*i%m)
for i in range(q):
    x,d,n=map(int,input().split())
    if d==0:
        print(pow(x,n,m))
    else:
        t=x*pow(d,m-2,m)%m
        if t==0 or t+n-1>=m:
            print(0)
        else:
            print(f[t+n-1]*pow(f[t-1],m-2,m)*pow(d,n,m)%m)

Buggy python submission (verdict: Runtime Error):
import numpy
q=int(input())
for i in range(q):
    x,d,n=map(int,input().split())
    a=numpy.arange(x,x+d*(n-1)+1,d)
    print(a.prod()%1000003)

Fixed submission:
q=int(input())
m=10**6+3
f=[1]
for i in range(1,m):
    f.append(f[-1]*i%m)
for i in range(q):
    x,d,n=map(int,input().split())
    if d==0:
        print(pow(x,n,m))
    else:
        t=x*pow(d,m-2,m)%m
        if t==0 or t+n-1>=m:
            print(0)
        else:
            print(f[t+n-1]*pow(f[t-1],m-2,m)*pow(d,n,m)%m)

Buggy python submission (verdict: Time Limit Exceeded):
q=int(input())
for i in range(q):
    x,d,n=map(int,input().split())
    ans=1
    for i in range(1,n+1):
        m=x+(d*(i-1))
        ans*=m
    print(ans%1000003)

Fixed submission:
q=int(input())
m=10**6+3
f=[1]
for i in range(1,m):
    f.append(f[-1]*i%m)
for i in range(q):
    x,d,n=map(int,input().split())
    if d==0:
        print(pow(x,n,m))
    else:
        t=x*pow(d,m-2,m)%m
        if t==0 or t+n-1>=m:
            print(0)
        else:
            print(f[t+n-1]*pow(f[t-1],m-2,m)*pow(d,n,m)%m)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n,k=map(int,input().split())
d=list(map(int,input().split()))
oll=list(itertools.product(['a','b','c','d'],repeat=k))
ans=0
for ol in oll:
    tv=0
    t=[]
    td=d[:]
    for o in ol:
        if o=='a':
            t+=[td.pop(0)]
            tv=sum(t)
            ans=max(ans,tv)
        elif o=='b':
            t+=[td.pop(-1)]
            tv=sum(t)
            ans=max(ans,tv)
        elif o=='c':
            if len(t)!=0:
                td.insert(0,min(t))
                t.remove(min(t))
                tv=sum(t)
                ans=max(ans,tv)
            else:
                break
        elif o=='d':
            if len(t)!=0:
                td.append(min(t))
                t.remove(min(t))
                tv=sum(t)
                ans=max(ans,tv)
            else:
                break
print(ans)

Fixed submission:
n,k=map(int,input().split())
d=list(map(int,input().split()))
ans=0
for l in range(min(n,k)+1):
    for r in range(min(n-l,k-l)+1):
        tl=d[:l]+d[-r:] if r>0 else d[:l]
        tk=k-l-r
        s=0
        for t in sorted(tl):
            if t<0 and tk>0:
                s+=-t
                tk-=1
            ans=max(ans,sum(tl)+s)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n,k=map(int,input().split())
d=list(map(int,input().split()))
oll=list(itertools.product(['a','b','c','d'],repeat=k))
ans=0
for ol in oll:
    tv=0
    t=[]
    td=d[:]
    for o in ol:
        if o=='a':
            t+=[td.pop(0)]
            tv=sum(t)
            ans=max(ans,tv)
        elif o=='b':
            t+=[td.pop(-1)]
            tv=sum(t)
            ans=max(ans,tv)
        elif o=='c':
            if len(t)!=0:
                td.insert(0,min(t))
                t.remove(min(t))
                tv=sum(t)
                ans=max(ans,tv)
            else:
                break
        elif o=='d':
            if len(t)!=0:
                td.append(min(t))
                t.remove(min(t))
                tv=sum(t)
                ans=max(ans,tv)
            else:
                break
print(ans)

Fixed submission:
n,k=map(int,input().split())
d=list(map(int,input().split()))
ans=0
for l in range(min(n,k)+1):
    for r in range(min(n-l,k-l)+1):
        tl=d[:l]+d[-r:] if r>0 else d[:l]
        tk=k-l-r
        s=0
        for t in sorted(tl):
            if t<0 and tk>0:
                s+=-t
                tk-=1
            ans=max(ans,sum(tl)+s)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n=map(int,input().split())
rm=n//r
gm=n//g
bm=n//b
ans=0
for i in range(rm,-1,-1):
    for j in range(gm,-1,-1):
        for k in range(bm,-1,-1):
            t=i*r+j*g+k*b
            if t<n:
                break
            elif t==n:
                ans+=1
print(ans)

Fixed submission:
r,g,b,n=map(int,input().split())
ans=0
for i in range(n//r+1):
    for j in range((n-(r*i))//g+1):
        if (n-(r*i)-(g*j))%b==0:
            ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))

def gcd(t1,t2):
    while t2:
        t1,t2=t2,t1%t2
    return t1

if n==2:
    print(max(a))
    exit()

ans=[gcd(a[0],a[1]),gcd(a[0],a[2]),gcd(a[1],a[2])]
ans=list(set(ans))
tmp1=max(ans)
tmp2=tmp1
for i in range(2,n):
    tmp1=gcd(tmp1,a[i])
    if tmp1!=tmp2:
        ans+=[tmp1]
        tmp2=tmp1
ans.sort()
print(ans[1])

Fixed submission:
import fractions
n=int(input())
a=list(map(int,input().split()))
a=[0]+a+[0]
l=[0]*(n+2)
r=[0]*(n+2)
for i in range(1,n+1):
    l[i]=fractions.gcd(l[i-1],a[i])
for i in range(n,0,-1):
    r[i]=fractions.gcd(r[i+1],a[i])
print(max(fractions.gcd(l[i-1],r[i+1]) for i in range(1,n+1)))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
S=S+'9'
ans=0
for i in range(N):
    if S[i]=='#' and S[i+1]=='.':
        cntj=0
        for j in range(i,-1,-1):
            if S[j]=='#':
                cntj+=1
            else:
                break
        cntk=0
        for k in range(i+1,N+1):
            if S[k]=='.':
                cntk+=1
            else:
                break
        if cntj >= cntk:
            ans += cntk
            S = S[:i+1]+'#'*cntk+S[i+cntk+1:]
        else:
            ans += cntj
            S = S[:i-cntj+1]+'.'*cntj+S[i+1:]
print(ans)

Fixed submission:
n=int(input())
s=input()
w=s.count('.')
b=0
ans=w
for i in range(n):
    if s[i]=='#':
        b+=1
    else:
        w-=1
    ans=min(ans,w+b)
print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
S=input()
S=S+'9'
ans=0
for i in range(N):
    if S[i]=='#' and S[i+1]=='.':
        cntj=0
        for j in range(i,-1,-1):
            if S[j]=='#':
                cntj+=1
            else:
                break
        cntk=0
        for k in range(i+1,N+1):
            if S[k]=='.':
                cntk+=1
            else:
                break
        if cntj < cntk:
            ans += cntj
            S = S[:i-cntj]+'.'*cntj+S[i+1:]
        else:
            ans += cntk
            S = S[:i]+'#'*cntk+S[i+1+cntk:]
print(ans)

Fixed submission:
n=int(input())
s=input()
w=s.count('.')
b=0
ans=w
for i in range(n):
    if s[i]=='#':
        b+=1
    else:
        w-=1
    ans=min(ans,w+b)
print(ans)
Buggy python submission (verdict: Runtime Error):
    S = input()
     
    cnt = 0
    max = 0
    for str in S:
      if str in {'A', 'C', 'G', 'T'}:
        cnt += 1
      else:
        if max < cnt:
          max = cnt
        cnt = 0
     
    print(cnt)

Fixed submission:
S = input()
cnt = 0
max = 0

for str in S:
  if str in {'A', 'C', 'G', 'T'}:
    cnt += 1
  else:
    if max < cnt:
      max = cnt
    cnt = 0
    
if max < cnt:
  max = cnt
  
print(max)
Buggy python submission (verdict: Time Limit Exceeded):
S=input()
ans=0
while 1:
    flg=True
    for i in range(len(S)-1):
        if S[i]!=S[i+1]:
            ans+=1
            S=S[:i]+S[i+2:]
            flg=False
            break
    if flg:
        break
print(ans*2)

Fixed submission:
S=input()
a=S.count('1')
b=S.count('0')
print(min(a,b)*2)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
ans=[0]*m
for i in range(n):
    a=list(map(int,input().split()))
    for j in range(len(a)):
        if j!=0:
            ans[a[j-1]]+=1
print(ans.count(n))

Fixed submission:
n,m=map(int,input().split())
ans=[0]*m
for i in range(n):
    a=list(map(int,input().split()))
    for j in range(len(a)):
        if j!=0:
            ans[a[j]-1]+=1
print(ans.count(n))
Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
print(min(a,b),max(0,a+b-n)))


Fixed submission:
n,a,b=map(int,input().split())
print(min(a,b),max(0,a+b-n))
Buggy python submission (verdict: Runtime Error):
s=input()
a='keyence'
i=0
f1=False
f2=False
for c in s:
    if c==a[i]:
        f1=False
        i+=1
    else:
        if not f1 and f2:
            print('NO')
            exit()
        else:
            f1=True
            f2=True
if i==7:
    print('YES')
else:
    print('NO')

Fixed submission:
s=input()
n=len(s)
for i in range(n):
    for j in range(i,n+1):
        if 'keyence'==s[:i]+s[j:]:
            print('YES')
            exit()
print('NO')