Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
cnt=0
if (b-a)%2 == 0:
  cnt=round(b-(b+a)/2)
  print(cnt)
  exit()
if (b-a)%2 == 1:
  if a==1:
    if b==n:
        c=n-a
    d=round(1+((b-1)-(((b-1)+a)/2)))
    cnt=min(c,d)
    print(cnt)
    exit()
  if b==n:
    if a==1:
        c=b-1
    d=round(1+(b-(b+a+1)/2))
    cnt=min(c,d)
    print(cnt)
    exit()
  if a-1 >= n-b:
    cnt=round(n-a)
    print(cnt)
    exit()
  if a-1 <= n-b:
    cnt=round(b-1)
    print(cnt)
    exit()

Fixed submission:
n,a,b=map(int,input().split())
cnt=0
c=100000000000000000
if (b-a)%2 == 0:
  cnt=b-(b+a)//2
  print(cnt)
  exit()
if (b-a)%2 == 1:
    cnt=min(a-1,n-b)+1+((b-a-1)//2)
    print(cnt)
    exit()

Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split()))
cnt=0
if (b-a) != 1:
    while a:
        a+=1
        b-=1
        cnt+=1
        if a == b:
            print(cnt)
            exit()
if (b-a) == 1:
    if a-1 > n-b:
        while a:
            if b != n:
                b+=1
                a+=1
                cnt+=1
            if b == n:
                a+=1
                cnt+=1
            if a == n and b == n:
                print(cnt)
                exit()
    if a-1 < n-b:
        while a:
            if a != 1:
                a-=1
                b-=1
                cnt+=1
            if a == 1:
                b-=1
                cnt+=1
            if a == 1 and b == 1:
                print(cnt)
                exit()

Fixed submission:
n,a,b=map(int,input().split())
cnt=0
c=100000000000000000
if (b-a)%2 == 0:
  cnt=b-(b+a)//2
  print(cnt)
  exit()
if (b-a)%2 == 1:
    cnt=min(a-1,n-b)+1+((b-a-1)//2)
    print(cnt)
    exit()
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input(),split())
if a+b+c>21:
    print("bust")
else:
    print("win")


Fixed submission:
a,b,c=map(int,input().split())
if a+b+c>21:
    print("bust")
else:
    print("win")
Buggy python submission (verdict: Runtime Error):
m,d=map(int,input()split())
s,t=map(int,input()split())
if t==1:
    print(1)
else:
    print(0)


Fixed submission:
m,d=map(int,input().split())
s,t=map(int,input().split())
if t==1:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
N=int(input())
ans="No"
for i in range(1,10):
    for j in range(1,10):
        if i*j==N:
            ans="Yes"
print(ans)


Fixed submission:
a,b=map(int,input().split())
ans=-1
if a>0 and a<10 and b>0 and b<10:
    ans=a*b
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
tako=list(map(int,input().split()))
umami=0
for i in range(n):
  for j in range(i+1,n):
    umami+==tako[i]*tako[j]
print(umami)

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

Buggy python submission (verdict: Runtime Error):
n=int(input())
tako=list(map(int,input().split()))
umami=0
for i in range(n):
  for j in range(i+1,n):
    umami+==tako[i]*tako[j]
print(umami)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(N-1):
    for j in range(i+1,N):
        ans+=A[i]*A[j]
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
K=int(input())
h=list(map(int,input().split()))
for i in range(N):
    if h[i]>=K:
        ans+=1
print(ans)


Fixed submission:
N,K=map(int,input().split())
h=list(map(int,input().split()))
ans=0
for i in range(N):
    if h[i]>=K:
        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=sum(B)
for i in range(N):
    if A[i+1]-A[i]==1:
        ans=+C[A[i]]
print(ans)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=sum(B)
for i in range(N-1):
    if A[i+1]-A[i]==1:
        ans+=C[A[i]-1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
h=list(map(int,input().split()))
h.append(float('inf'))
ans=0
cnt=0
for i in range(n):
  c=h[i]
  for j in range(i+1,n+1):
    if c>=h[j]:
      cnt+=1
      c=h[j]
    else:
      ans=max(ans,cnt)
      cnt=0
      break
print(ans)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
h.append(float('inf'))
ans=0
cnt=0
for i in range(n):
  if h[i]>=h[i+1]:
      cnt+=1
  else:
    ans=max(ans,cnt)
    cnt=0
ans=max(ans,cnt)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
h=list(map(int,input().split()))
h.append(float('inf'))
ans=0
cnt=0
for i in range(n):
  c=h[i]
  for j in range(i+1,n+1):
    if c>=h[j]:
      cnt+=1
      c=h[j]
    else:
      ans=max(ans,cnt)
      cnt=0
      break
print(ans)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
h.append(float('inf'))
ans=0
cnt=0
for i in range(n):
  if h[i]>=h[i+1]:
      cnt+=1
  else:
    ans=max(ans,cnt)
    cnt=0
ans=max(ans,cnt)
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=map(int,input().split())
x=0
for i in range(N):
    x+=1/A[i]
x=1/x
print(x)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
x=0
for i in range(N):
    x+=1/A[i]
x=1/x
print(x)
Buggy python submission (verdict: Time Limit Exceeded):
def Comb(n,k):
    comb_ans=1
    for i in range(1,k+1):
        comb_ans*=(n-i+1)/i
    comb_ans=int(comb_ans)
    return comb_ans

N=int(input())
S=[str(sorted(input())) for i in range(N)]
T=set(S)
ans=0
for i in T:
    cnt=S.count(i)
    ans+=Comb(cnt,2)
#print(S)
#print(T)
print(ans)

Fixed submission:
import collections
def Comb(n,k):
    comb_ans=1
    for i in range(1,k+1):
        comb_ans*=(n-i+1)/i
    comb_ans=int(comb_ans)
    return comb_ans

N=int(input())
S=[''.join(sorted(input())) for i in range(N)]
T=collections.Counter(S)
ans=0
for i in T.most_common():
    ans+=Comb(i[1],2)
#print(S)
#print(T)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=[str(sorted(input())) for i in range(N)]
cnt=0
for i in range(N-1):
    for j in range(i+1,N):
        if S[i]==S[j]:
            cnt+=1
#print(S)
print(cnt)

Fixed submission:
import collections
def Comb(n,k):
    comb_ans=1
    for i in range(1,k+1):
        comb_ans*=(n-i+1)/i
    comb_ans=int(comb_ans)
    return comb_ans

N=int(input())
S=[''.join(sorted(input())) for i in range(N)]
T=collections.Counter(S)
ans=0
for i in T.most_common():
    ans+=Comb(i[1],2)
#print(S)
#print(T)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(input()) for i in range(n)]
for i in range(n):
	b=a[i]
	a[i]=0
	print(max(a))
	a[i]=b

Fixed submission:
n=int(input())
a=[int(input()) for i in range(n)]
f=max(a)
b=sorted(a,reverse=True)
s=b[1]
for i in range(n):
    if a[i]==f:
        print(s)
    else:
        print(f)
Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n=map(int,input().split())
cnt=0
for i in range(n//r+1):
    for j in range(n//g+1):
        bc=n-(r*i+g*j)
        if bc%b==0 and bc>=0:
            cnt+=1
print(cnt)

Fixed submission:
r,g,b,n=map(int,input().split())
cnt=0
for i in range(n//r+1):
    for j in range(n//g+1):
        bc=n-(r*i+g*j)
        if bc%b==0 and bc>=0:
            cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
s=input()
ans=0
for i in s:
    if i in ["A","T","C","G"]:
        cnt+=1
    else:
        ans=max(ans,cnt)
        cnt=0
print(ans)

Fixed submission:
s=input()
s+="Z"
ans=0
cnt=0
for i in s:
    if i in ["A","T","C","G"]:
        cnt+=1
    else:
        ans=max(ans,cnt)
        cnt=0
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(n):
  if a[i]%2==0:
    while a[i]%2==0:
      cnt+=1
      a[i]//2
print(cnt)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(n):
  if a[i]%2==0:
    b=a[i]
    while b%2==0:
      cnt+=1
      b=b//2
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n,y=map(int,input().split())
for a in range(n+1):
    for b in range(n+1):
        c=(y-(a*10000+b*5000))//1000
        if y == (a*10000+b*5000+c*1000):
            if a+b+c==n and c>=0:
              print(a,b,c)
              exit()
print(-1,-1,-1)

Fixed submission:
n,y=map(int,input().split())
for a in range(n+1):
    for b in range(n+1):
        c=(y-(a*10000+b*5000))//1000
        if a+b+c==n and c>=0:
            print(a,b,c)
            exit()
print(-1,-1,-1)

Buggy python submission (verdict: Time Limit Exceeded):
n,y=map(int,input().split())
for a in range(n+1):
    for b in range(n+1):
        c=(y-(a*10000+b*5000))//1000
        if a+b+c>n:
            continue
        if y == (a*10000+b*5000+c*1000):
            if a+b+c==n and a>=0 and b>=0 and c>=0:
              print(a,b,c)
              exit()
print(-1,-1,-1)

Fixed submission:
n,y=map(int,input().split())
for a in range(n+1):
    for b in range(n+1):
        c=(y-(a*10000+b*5000))//1000
        if a+b+c==n and c>=0:
            print(a,b,c)
            exit()
print(-1,-1,-1)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
cnt=0
for i range(n):
  if a[i]%2==0:
    cnt+=1
ans=(3*n)-2*cnt
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(n):
  if a[i]%2==0:
    cnt+=1
ans=(3**n)-2**cnt
print(ans)
Buggy python submission (verdict: Runtime Error):
H,W=map(int,input().split())
field=[["."]*(W+2)]
for i in range(H):
    field.append(["."])
    field[-1].extend(list(input()))　#ここらへんミスりそうでこわひ
    field[-1].append(".")
field.append(["."]*(W+2))
print(field)
for i in range(1,H+1):
    for j in range(1,W+1):
        if field[i][j]=="#":
            print("#",end="")
        else:
            cnt=0
            for dy in range(-1,2):
                for dx in range(-1,2):
                    if field[i+dy][j+dx]=="#":
                        cnt+=1
            print(cnt,end="")
    print("")

Fixed submission:
H,W=map(int,input().split())
field=[["."]*(W+2)]
for i in range(H):
    field.append(["."])
    field[-1].extend(list(input()))
    field[-1].append(".")
field.append(["."]*(W+2))
for i in range(1,H+1):
    for j in range(1,W+1):
        if field[i][j]=="#":
            print("#",end="")
        else:
            cnt=0
            for dy in range(-1,2):
                for dx in range(-1,2):
                    if field[i+dy][j+dx]=="#":
                        cnt+=1
            print(cnt,end="")
    print("")
Buggy python submission (verdict: Time Limit Exceeded):
import math
m,n=map(int,input().split())
f=abs(m-n)
if f == 0:
  ans=2*math.factorial(m)*math.factorial(n)
  print(ans)
  exit()
elif f == 1:
  ans=math.factorial(m)*math.factorial(n)
  print(ans)
  exit()
else:
  print(0)
  exit()

Fixed submission:
import math
MOD = 1000000007
m,n=map(int,input().split())
f=abs(m-n)
if f == 0:
  ans=2*math.factorial(m)*math.factorial(n)%MOD
  print(ans)
  exit()
elif f == 1:
  ans=math.factorial(m)*math.factorial(n)%MOD
  print(ans)
  exit()
else:
  print(0)
  exit()
Buggy python submission (verdict: Runtime Error):
s=input()
di={maerd,remaerd,esare,resare}
s.reverse()
for i in range(len(s)):
  for j in range(4):
    f=False
    t=di[j]
    if s[i:len(t)]==t:
      f=True
      i+=len(t)
  if (not f):
    print("NO")
    exit()
print("YES")

Fixed submission:
S=input()
div=["maerd","remaerd","esare","resare"]
S=S[::-1]
judge=True
cnt=0
while cnt<len(S):
    can=False
    for j in range(4):
        d=div[j]
        if S[cnt:len(d)+cnt]==d:
            can=True
            cnt+=len(d)
    if not can:
        judge=False
        break
if judge:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
a,b,x=map(int,input().split())
ans=(b//x)-((a-1)//x)
print(ans)

Fixed submission:
s=input()
print("A"+s[8]+"C")
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
a,b=map(int,input().split())

cf=[1]
for i in range(2,min(a,b)+1):
    if a%i==0 and b%i==0:
        cf.append(i)
n=len(cf)
dele=[]
for i in range(n-1):
    flag=0
    for j in range(i+1,n):
        if fractions.gcd(cf[i],cf[j])!=1:
            dele.append(cf[j])
result=set(cf)-set(dele)
print(len(result))

Fixed submission:
a,b=map(int,input().split())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            while temp%i==0:
                temp //= i
            arr.append(i)
    if temp!=1:
        arr.append(temp)

    if arr==[]:
        arr.append(n)

    return arr
aa=factorization(a)
bb=factorization(b)
n=len(aa)
ans=[]
if n>len(bb):
    n=len(bb)
    for i in range(n):
        if bb[i] in aa:
            ans.append(bb[i])
else:
    for i in range(n):
        if aa[i] in bb:
            ans.append(aa[i])
ans.append(1)
ans=set(ans)
print(len(ans))
Buggy python submission (verdict: Runtime Error):
h,w,a,b,=map(int,input().split())
ans='No'
if h==1 and b==0:
        ans=['1']*a+['0']*(w-a)
        print(''.join(ans))
elif w==1 and a==0:
        ans=['1']*b+['0']*(h-b)
        for i in ans:
                print(i)
else:
    ans1='0'*a+'1'*(w-a)
    ans2='1'*a_+'0'*(w-a)
    for i in range(h):
        if i<=b-1:
            print(ans1)
        else:
            print(ans2)

Fixed submission:
h,w,a,b,=map(int,input().split())
ans='No'
if h==1 and b==0:
        ans=['1']*a+['0']*(w-a)
        print(''.join(ans))
elif w==1 and a==0:
        ans=['1']*b+['0']*(h-b)
        for i in ans:
                print(i)
else:
    ans1='0'*a+'1'*(w-a)
    ans2='1'*a+'0'*(w-a)
    for i in range(h):
        if i<=b-1:
            print(ans1)
        else:
            print(ans2)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n,k,q=map(int,input().split())
a=[int(input()) for i in range(q)]
point=np.array([k]*n)
for i in range(q):
    point[:a[i]-1]-=1
    point[a[i]:]-=1
for i in range(n):
    if point[i]<=0:
        print('No')
    else:
        print('Yes')

Fixed submission:
n,k,q=map(int,input().split())
a=[int(input()) for i in range(q)]
point=[k-q]*n
for i in range(q):
    point[a[i]-1]+=1
for i in range(n):
    if point[i]>0:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
n=int(input())
inf=10*9+7
h=list(map(int,input().split()))+[inf]
n=len(h)
length=[0]*n
cnt=[]
move=0
for i in range(n-1):
    if h[i]<h[i+1]:
        length[i+1]=1
        if i==0:
            length[i]=1
for i in range(1,n):
    if length[i]==0:
        move+=1
    else:
        cnt.append(move)
        move=0
print(max(cnt))

Fixed submission:
n=int(input())
inf=10*100
h=list(map(int,input().split()))+[inf]
n=len(h)
length=[0]*(n-1)+[1]
cnt=[]
move=0
for i in range(n-1):
    if h[i]<h[i+1]:
        length[i+1]=1
        if i==0:
            length[i]=1
for i in range(1,n):
    if length[i]==0:
        move+=1
    else:
        cnt.append(move)
        move=0
if len(cnt)==0:
    print(n-2)
else:
    print(max(cnt))

Buggy python submission (verdict: Runtime Error):
n=int(input())
inf=10*9+7
h=list(map(int,input().split()))+[inf]
n=len(h)
length=[0]*n
cnt=[]
move=0
for i in range(n-1):
    if h[i]<h[i+1]:
        if i==0:
            length[0]=1
        length[i+1]=1
for i in range(n):
    if length[i]==0:
        move+=1
    else:
        cnt.append(move)
        move=0
print(max(cnt))

Fixed submission:
n=int(input())
inf=10*100
h=list(map(int,input().split()))+[inf]
n=len(h)
length=[0]*(n-1)+[1]
cnt=[]
move=0
for i in range(n-1):
    if h[i]<h[i+1]:
        length[i+1]=1
        if i==0:
            length[i]=1
for i in range(1,n):
    if length[i]==0:
        move+=1
    else:
        cnt.append(move)
        move=0
if len(cnt)==0:
    print(n-2)
else:
    print(max(cnt))
Buggy python submission (verdict: Time Limit Exceeded):
l,r=map(int,input().split())
ans=l*r%2019
for i in range(l,r):
    for j in range(i+1,r+1):
        ans=min(ans,i*j%2019)
        if ans==0:
            break
        
print(ans)

Fixed submission:
l,r=map(int,input().split())
ans=l*r%2019
for i in range(l,r):
    for j in range(i+1,r+1):
        ans=min(ans,i*j%2019)
        if ans==0:
            break
    if ans==0:
        break
print(ans)

Buggy python submission (verdict: Runtime Error):
l,r=map(int,input().split())
ans=0
if l%2019>r%2019 or r-l>=2018:
    ans=0
else:
    if l%673>r%673 or r-l>=672:
        ans=0
    else:
        ll=l%2019
        rr=r%2019
        ans=min((rr*((r-1)%2019))%2019,(ll*((l+1)%2019)%2019)
print(ans)

Fixed submission:
l,r=map(int,input().split())
ans=l*r%2019
for i in range(l,r):
    for j in range(i+1,r+1):
        ans=min(ans,i*j%2019)
        if ans==0:
            break
    if ans==0:
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
lr=[[int(i) for i in input().split()] for i in range(m)]
cnt=[i for i in range(lr[0][0],lr[0][1]+1)]
ans=len(cnt)
for i in range(m):
    cnt=list(set([i for i in range(lr[i][0],lr[i][1]+1)])&set(cnt))
    ans=len(cnt)
    if len(cnt)==0:
        ans=0
        break
print(ans)

Fixed submission:
n,m=map(int,input().split())
lr=[[int(i) for i in input().split()] for i in range(m)]
l=lr[0][0]
r=lr[0][1]
ans=0
for i in range(1,m):
    l=max(l,lr[i][0])
    r=min(r,lr[i][1])
ans=r-l+1
if r<l:
    ans=0
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
import fractions
n=int(input())
a=list(map(int,input().split()))
c=a[1:]
gcdc=reduce(fractions.gcd,c)
d=[gcdc]
for i in range(1,n):
    b=a[:i]+a[i+1:]
    gcd=reduce(fractions.gcd, b)
    d.append(gcd)
print(max(d))

Fixed submission:
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
ans=1
l=[0]*(n+1)
r=[0]*(n+1)
for i in range(n):
    l[i]=gcd(l[i-1],a[i])
for i in reversed(range(n)):
    r[i]=gcd(r[i+1],a[i])
for i in range(n):
    if gcd(l[i-1],r[i+1])>ans:
        ans=gcd(l[i-1],r[i+1])
print(ans)
Buggy python submission (verdict: Runtime Error):
s=list(input())
n=len(s)
ACGT=['A','C','G','T']
t=[]
count=0
for i in s:
    if i in ACGT:
        count+=1
    else:
        t.append(count)
print(max(t))

Fixed submission:
s=list(input())+['Z']
ACGT=['A','C','G','T']
t=[]
count=0
for i in s:
    if i in ACGT:
        count+=1
    else:
        t.append(count)
        count=0

if len(t)==0:
    print(len(s))
else:
    print(max(t))
Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
lr=[[int(i) for i in input().split()] for _ in range(q)]
for i in range(q):
    t=s[lr[i][0]-1:lr[i][1]]
    print(t.count('AC'))

Fixed submission:
N,Q = map(int,input().split())
S = input()
qs = [tuple(map(int,input().split())) for i in range(Q)]

cums = [0,0]
for i in range(1,N):
    if S[i-1:i+1] == 'AC':
        cums.append(cums[-1] + 1)
    else:
        cums.append(cums[-1])

for l,r in qs:
    print(cums[r] - cums[l])
Buggy python submission (verdict: Runtime Error):
N,M=list(map(int,input().split(" ")))
l=[]
l=[list(map(int,input().split(" "))) for i in range(n)]
drink=0
price=0
i=0
l.sort(key=lambda x: x[0])
while drink<M:
    pri=l[i][0]
    num=l[i][1]
    i+=1
    drink+=num
    price+=pri*num
if drink>M:
    price-=(drink-m)*pri
print(price)


Fixed submission:
n,m=list(map(int,input().split(" ")))
l=[]
l=[list(map(int,input().split(" "))) for i in range(n)]
drink=0
price=0
i=0
l.sort(key=lambda x: x[0])
while drink<m:
    pri=l[i][0]
    num=l[i][1]
    i+=1
    drink+=num
    price+=pri*num
if drink>m:
    price-=(drink-m)*pri
print(price)
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
def gcdlist(numbers):
    return reduce(math.gcd,numbers)
n=int(input())
a=list(map(int,input().split()))
print(gcdlist(a))

Fixed submission:
import fractions
from functools import reduce
def gcdlist(numbers):
    return reduce(fractions.gcd,numbers)
n=int(input())
a=list(map(int,input().split()))
print(gcdlist(a))
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input())
ans='NO'
if k<=(n+1)//2:
  ans='YES'
print(ans)

Fixed submission:
n,k=map(int,input().split())
ans='NO'
if k<=(n+1)//2:
  ans='YES'
print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
k=list('keyence')
ans='NO'
cnt=[0]*n
final=0
j=0
for i in range(n):
    if j==n-1:
        break
    if s[i]==k[j]:
        cnt[i]=1
        j+=1
for i in range(n-1):
    if cnt[i]!=cnt[i+1]:
        final+=1
if cnt[0]==0 and final==1:
    ans='YES'
elif cnt[0]==1 and final==2:
    ans='YES'
if n==7 and final==0:
    ans='YES'
print(ans)

Fixed submission:
s=input()
n=len(s)
k='keyence'
ans='NO'
for i in range(n):
    if s[:i]+s[i+n-7:]==k:
        ans='YES'
print(ans)

Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
k=list('keyence')
ans='NO'
cnt=[0]*n
final=0
j=0
for i in range(n):
    if s[i]==k[j]:
        cnt[i]=1
        j+=1
for i in range(n-1):
    if cnt[i]!=cnt[i+1]:
        final+=1
if cnt[0]==0 and final==1:
    ans='YES'
elif cnt[0]==1 and final==2:
    ans='YES'
if n==7 and final==0:
    ans='YES'
print(ans)

Fixed submission:
s=input()
n=len(s)
k='keyence'
ans='NO'
for i in range(n):
    if s[:i]+s[i+n-7:]==k:
        ans='YES'
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
h=sorted(list(int(input()) for i in range(N)))
H=list()
for i in range(0,N-K+1):
    H.append(max(h[i:i+K])-min(h[i:i+K]))
print(min(H))

Fixed submission:
N,K=map(int,input().split())
h=sorted([int(input()) for i in range(N)])
print(min(h[i+K-1]-h[i] for i in range(N-K+1)))
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
ans=1
for i in range(1,m**0.5+1):
    if m%i==0:
        if m/i>=n:
            ans=max(ans,i)
        elif i>=n:
            ans=max(ans,m//i)
print(ans)

Fixed submission:
n,m=map(int,input().split())
ans=1
for i in range(1,int(m**0.5)+1):
    if m%i==0:
        if m/i>=n:
            ans=max(ans,i)
        if i>=n:
            ans=max(ans,m//i)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
#m%g=0 and m>=g*nが成立
ans=1
for i in range(1,m//n+1):
    if m%i==0:
        ans=i
print(ans)

Fixed submission:
n,m=map(int,input().split())
ans=1
for i in range(1,int(m**0.5)+1):
    if m%i==0:
        if m/i>=n:
            ans=max(ans,i)
        if i>=n:
            ans=max(ans,m//i)
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
x=list(int(100*i+10*i+i) for i in range(1,9))
y=list(t for t in x if t>=N)
print(min(y))

Fixed submission:
N=int(input())
x=list(int(100*i+10*i+i) for i in range(1,10))
y=list(t for t in x if t>=N)
print(min(y))
Buggy python submission (verdict: Runtime Error):
import collections
n=int(input())
v=list(map(int,input().split()))
vo=v[0::2]
ve=v[1::2]
co=collections.Counter(vo)
ce=collections.Counter(ve)
cmo=co.most_common()
cme=ce.most_common()
ans=n-cmo[0][1]-cme[0][1]
if cmo[0][0]==cme[0][0]:
    if cmo[0][1]>cme[0][1]:
       if cmo[0][1]!=n//2:
           ans=n-cmo[0][1]-cme[1][1]
    elif cmo[0][1]<cme[0][1]:
        if cme[0][1]!=n//2:
            ans=n-cmo[1][1]-cme[0][1]
    else:
        ans=n-cmo[0][1]-max(cmo[1][1],cme[1][1])
print(ans)

Fixed submission:
import collections
n=int(input())
v=list(map(int,input().split()))
vo=v[0::2]
ve=v[1::2]
co=collections.Counter(vo)
ce=collections.Counter(ve)
cmo=co.most_common()
cme=ce.most_common()
ans=n-cmo[0][1]-cme[0][1]
if cmo[0][0]==cme[0][0]:
    if cmo[0][1]>cme[0][1]:
       if cmo[0][1]!=n//2:
           ans=n-cmo[0][1]-cme[1][1]
    elif cmo[0][1]<cme[0][1]:
        if cme[0][1]!=n//2:
            ans=n-cmo[1][1]-cme[0][1]
    else:
        if cmo[0][1]==n//2:
            ans=n//2
        else:
            ans=n-cmo[0][1]-max(cmo[1][1],cme[1][1])
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
W=[input() for i in range(N)]
if len(W)!=len(set(W)):
    print('No')
    exit()
for i in range(len(W)-1):
       if W[i][-1]==W[i+1][0]:
          ans='Yes'
print(ans)


Fixed submission:
N=int(input())
W=[input() for i in range(N)]
if len(W)!=len(set(W)):
    print('No')
    exit()
for i in range(len(W)-1):
       if W[i][-1]!=W[i+1][0]:
          print('No')
          exit()
print('Yes')