Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
A=list(map(int,input().split()))
before=1
for i in range(K):
    before*=A[i]
for i in range(N-K):
    evaluation=before
    evaluation=evaluation//A[i]*A[i+K]
    print("Yes" if evaluation>before else "No")
    before=evaluation

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(N-K):
    print("Yes" if A[i+K]>A[i] else "No")

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
A=list(map(int,input().split()))
before=1
for i in range(K):
    before*=A[i]
point=1
for i in range(N-K):
    point=before
    point//=A[i]
    point*=A[i+K]
    print("Yes" if point>before else "No")
    before=point

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(N-K):
    print("Yes" if A[i+K]>A[i] else "No")
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=list(map(int,input().split()))
xor=[0]*N
for i in range(N):
    for j in range(N):
        if i!=j:
            xor[i]=xor[i]^a[j]
print(*xor)

Fixed submission:
N=int(input())
a=list(map(int,input().split()))
X=0
for i in range(N):
    X=X^a[i]
xor=[X]*N
for i in range(N):
    xor[i]^=a[i]
print(*xor)
Buggy python submission (verdict: Runtime Error):
X,N=map(int,input().split())
p=list(map(int,input().split()))
m=X
for i in range(101):
    diff=abs(X-i)
    if i not in p and diff<m and diff!=m:
        m=diff
        ans=i
print(ans)

Fixed submission:
X,N=map(int,input().split())
p=list(map(int,input().split()))
diff=102
for i in range(102):
    if i not in p and abs(X-i)<diff:
        diff=abs(X-i)
        ans=i
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
mul=1
for a in A:
    mul*=a
print(mul if mul<=10**18 else -1)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
if 0 in A:
    print(0)
else:
    mul=1
    for a in A:
        mul*=a
        if mul>10**18:
            print(-1)
            exit()
    print(mul)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
A=list(map(int,input().split()))
next_city=0
for i in range(K):
    next_city=A[next_city]-1
print(next_city+1)

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
if K<=N:
    next_city=0
    for i in range(K):
        next_city=A[next_city]-1
else:
    next_city=0
    visited=[-1]*N
    visited[0]=0
    for num in range(1,N):
        next_city=A[next_city]-1
        if visited[next_city]!=-1:
            break
        visited[next_city]=num
    K=(K-num)%(num-visited[next_city])
    for i in range(K):
        next_city=A[next_city]-1
print(next_city+1)
Buggy python submission (verdict: Time Limit Exceeded):
import math
K=int(input())
divisor=0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            divisor+=math.gcd(math.gcd(a,b),c)
print(divisor)

Fixed submission:
import math
K=int(input())
print(sum(math.gcd(math.gcd(a,b),c) for a in range(1,K+1) for b in range(1,K+1) for c in (range(1,K+1))))
Buggy python submission (verdict: Time Limit Exceeded):
K=int(input())
number=[]
for i in range(3234566668):
    k=str(i)
    if all([abs(int(k[j])-int(k[j-1]))<=1 for j in range(1,len(k))]):
        number.append(k)
print(number[K])

Fixed submission:
from collections import deque
K=int(input())
queue=deque([1,2,3,4,5,6,7,8,9])
for i in range(K):
    k=queue.popleft()
    if k%10!=0:
        queue.append(10*k+(k%10)-1)
    queue.append(10*k+(k%10))
    if k%10!=9:
        queue.append(10*k+(k%10)+1)
print(k)
Buggy python submission (verdict: Time Limit Exceeded):
S=input()
Q=int(input())
reverse=0
for q in range(Q):
    Query=list(input().split())
    T=Query[0]
    if T=="1":
        reverse+=1
    if T=="2":
        F,C=Query[1],Query[2]
        if F=="1" and reverse%2==0 or F=="2" and reverse%2==1:
            S=C+S
        else:
            S=S+C
print(S if reverse%2==0 else S[::-1])

Fixed submission:
from collections import deque
S=deque(input())
Q=int(input())
reverse=0
for q in range(Q):
    Query=list(input().split())
    T=Query[0]
    if T=="1":
        reverse+=1
    if T=="2":
        F,C=Query[1],Query[2]
        if F=="1" and reverse%2==0 or F=="2" and reverse%2==1:
            S.appendleft(C)
        else:
            S.append(C)
S="".join(S)
print(S if reverse%2==0 else S[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
S=input()
Q=int(input())
for q in range(Q):
    Query=list(input().split())
    T=Query[0]
    if T=="1":
        S=S[::-1]
    if T=="2":
        F,C=Query[1],Query[2]
        if F=="1":
            S=C+S
        if F=="2":
            S=S+C
print(S)

Fixed submission:
from collections import deque
S=deque(input())
Q=int(input())
reverse=0
for q in range(Q):
    Query=list(input().split())
    T=Query[0]
    if T=="1":
        reverse+=1
    if T=="2":
        F,C=Query[1],Query[2]
        if F=="1" and reverse%2==0 or F=="2" and reverse%2==1:
            S.appendleft(C)
        else:
            S.append(C)
S="".join(S)
print(S if reverse%2==0 else S[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
import collections
N=int(input())
S=collections.Counter(input() for i in range(N))
dictionary=sorted(key for key,value in S.items() if value==max(S.values()))
for d in dictionary:
    print(d)

Fixed submission:
import collections
N=int(input())
S=collections.Counter(input() for i in range(N))
maximum=max(S.values())
sort=sorted(key for key,value in S.items() if value==maximum)
for s in sort:
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=[input() for i in range(N)]
dictionary={}
for word in S:
    if word in dictionary:
        dictionary[word]+=1
    else:
        dictionary[word]=1
for key,value in sorted(dictionary.items()):
    if value==max(dictionary.values()):
        print(key)

Fixed submission:
import collections
N=int(input())
S=collections.Counter(input() for i in range(N))
maximum=max(S.values())
sort=sorted(key for key,value in S.items() if value==maximum)
for s in sort:
    print(s)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
for i in range(N):
    print(A.index(i+1)+1,end=" ")

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
sort=[0]*N
for i in range(N):
    sort[A[i]-1]+=i+1
print(*sort)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
total=0
for i in range(N):
    total+=i
print(total)

Fixed submission:
N=int(input())
print(N*(N-1)//2 if N>2 else 1 if N==2 else 0)

Buggy python submission (verdict: Time Limit Exceeded):
import math
N=int(input())
total=0
for i in range(N):
    total+=i
print(total)

Fixed submission:
N=int(input())
print(N*(N-1)//2 if N>2 else 1 if N==2 else 0)
Buggy python submission (verdict: Time Limit Exceeded):
L,R=map(int,input().split())
r=min(R,L+2019*2)
minimum=2019*2
for i in range(L,r+1):
    for j in range(i+1,r+1):
        minimum=min(minimum,i*j%2019)
print(minimum)

Fixed submission:
L,R=map(int,input().split())
left=L%2019
right=R%2019
print(0 if R-L>=2019 else min([i*j%2019 for i in range(left,right+1) for j in range(i+1,right+1)]))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
D=sorted(map(int,input().split()))
maximum=max(D)
medium=0
for threshold in range(1,maximum+1):
    count=0
    for d in D:
        if d<threshold:
            count+=1
    if count==len(D)//2:
        medium+=1
print(medium)

Fixed submission:
N=int(input())
d=sorted(map(int,input().split()))
print(d[N//2]-d[N//2-1])
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
A=set(int(input()) for i in range(m))
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in A:dp[i]=0
print(dp[n])

Fixed submission:
p,q,r=map(int,input().split())
print(min(p+q,q+r,r+p))
Buggy python submission (verdict: Runtime Error):
n=int(input())
w=list(map(int,input().split()))
m=sum(w)
for i in range(n)m=min(m,abs(sum(w[:i+1])-sum(w[i+1:])))
print(m)

Fixed submission:
n=int(input())
w=list(map(int,input().split()))
m=sum(w)
for i in range(n):m=min(m,abs(sum(w[:i+1])-sum(w[i+1:])))
print(m)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in a:dp[i]=0
print(dp[n])

Fixed submission:
n,m=map(int,input().split())
A=set(int(input()) for i in range(m))
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in A:dp[i]=0
print(dp[n])

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in a:dp[i]=0
print(dp[n])

Fixed submission:
n,m=map(int,input().split())
A=set(int(input()) for i in range(m))
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in A:dp[i]=0
print(dp[n])

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
A=[int(input()) for i in [0]*m]
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in A:dp[i]=0
print(dp[n])

Fixed submission:
n,m=map(int,input().split())
A=set(int(input()) for i in range(m))
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in A:dp[i]=0
print(dp[n])

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
A=[int(input()) for i in range(m)]
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in A:dp[i]=0
print(dp[n])


Fixed submission:
n,m=map(int,input().split())
A=set(int(input()) for i in range(m))
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in A:dp[i]=0
print(dp[n])

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
A=[int(input()) for i in range(m)]
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in A:dp[i]=0
print(dp[n])

Fixed submission:
n,m=map(int,input().split())
A=set(int(input()) for i in range(m))
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in A:dp[i]=0
print(dp[n])

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
A=[]
for i in range(m):
    a=int(input())
    A.append(a)
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in A:dp[i]=0
print(dp[n])

Fixed submission:
n,m=map(int,input().split())
A=set(int(input()) for i in range(m))
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in A:dp[i]=0
print(dp[n])
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
ans=float(0)
for i in range(n):ans+=(0.5**(int(k**0.5)+1-i))/n
print(ans)

Fixed submission:
N,K=map(int,input().split())
probability=0
for dice in range(1,N+1):
    coin=1/N
    point=dice
    while(point<K):
        point*=2
        coin/=2
    probability+=coin
print(probability)
Buggy python submission (verdict: Runtime Error):
n=int(input())
count=countA=countB=countAB=0
for i in range(n):
    s=input()
    if "AB" in s:
        count+=1
    if s[-1]=="A":countA+=1
    if s[0]=="B":countB+=1
    if s[-1]=="A" and s[0]=="B":countAB+=1
print(countAB-1 if countA==countB==0 and countAB>0 else min(countA,countB)+countAB)

Fixed submission:
n,k=map(int,input().split())
print(n-k+1)

Buggy python submission (verdict: Runtime Error):
n=int(input())
count=countA=countB=countAB=0
for i in range(n):
    s=input()
    if "AB" in s:
        count+=1
    if s[-1]=="A":countA+=1
    if s[0]=="B":countB+=1
    if s[-1]=="A" and s[0]=="B":countAB+=1
print(countAB-1 if countA=countB=0 and countAB>0 else min(countA,countB)+countAB)

Fixed submission:
n,k=map(int,input().split())
print(n-k+1)
Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n=map(int,input().split())
count=0
for x in range(n+1):
    for y in range(n-x+1):
        z=(n-r*x-g*y)//b
        if 0<=z<=3000:
            if r*x+g*y+z*b==n:count+=1
print(count)

Fixed submission:
r,g,b,n=map(int,input().split())
count=0
for x in range(n+1):
    for y in range(n-x+1):
        z=(n-r*x-g*y)//b
        if 0<=z<=3000:
            if r*x+g*y+z*b==n:count+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n=map(int,input().split())
print(sum(0<=(n-r*x-g*y)/b<=3000 and (n-r*x-g*y)//b==(n-r*x-g*y)/b for x in range(n+1) for y in range(n-x+1)))

Fixed submission:
r,g,b,n=map(int,input().split())
count=0
for x in range(n+1):
    for y in range(n-x+1):
        z=(n-r*x-g*y)//b
        if 0<=z<=3000:
            if r*x+g*y+z*b==n:count+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n=map(int,input().split())
count=0
for x in range(n+1):
    for y in range(n-x+1):
        z=(n-r*x-g*y)//b
        if 0<=z<=3000 and r*x+g*y+z*b==n:count+=1
print(count)

Fixed submission:
r,g,b,n=map(int,input().split())
count=0
for x in range(n+1):
    for y in range(n-x+1):
        z=(n-r*x-g*y)//b
        if 0<=z<=3000:
            if r*x+g*y+z*b==n:count+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n=map(int,input().split())
print(sum((n-r*z-g*y)/b==(n-r*z-g*y)//b and 0<=(n-r*z-g*y)/b<=3000 for z in range(3001) for y in range(3001)))

Fixed submission:
r,g,b,n=map(int,input().split())
count=0
for x in range(n+1):
    for y in range(n-x+1):
        z=(n-r*x-g*y)//b
        if 0<=z<=3000:
            if r*x+g*y+z*b==n:count+=1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=list(map(int,input().split()))
m=0
for i in range(max(A),0,-1):
    count=0
    for a in A:
        if a%i==0:count+=1
        if count>=n-1:
            print(i)
            exit()

Fixed submission:
from fractions import gcd
N=int(input())
A=list(map(int,input().split()))
R,L=[0],[0]
for i in range(N-1):
    R+=[gcd(R[i],A[i])]
    L+=[gcd(L[i],A[-i-1])]
print(max(gcd(R[i],L[-i-1]) for i in range(N)))
Buggy python submission (verdict: Time Limit Exceeded):
N,Q=map(int,input().split())
S=input()
count=[0]*(N-1)
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":count[i]=1
for i in range(Q):
    l,r=map(int,input().split())
    print(sum(count[l-1:r-1]))

Fixed submission:
N,Q=map(int,input().split())
S=input()
count=[0]*N
for i in range(1,N):
    count[i]+=count[i-1]
    if S[i-1]=="A" and S[i]=="C":
        count[i]+=1
for i in range(Q):
    l,r=map(int,input().split())
    print(count[r-1]-count[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q=map(int,input().split())
S=input()
for i in range(Q):
    l,r=map(int,input().split())
    s=S[l-1:r]
    print(s.count("AC"))

Fixed submission:
N,Q=map(int,input().split())
S=input()
count=[0]*N
for i in range(1,N):
    count[i]+=count[i-1]
    if S[i-1]=="A" and S[i]=="C":
        count[i]+=1
for i in range(Q):
    l,r=map(int,input().split())
    print(count[r-1]-count[l-1])
Buggy python submission (verdict: Runtime Error):
S=input()
stack=[]
ans=0
for s in S:
    if not stack:
        stack.append(s)
    elif stack[-1]!=s
        stack.pop()
        ans+=2
    else:
        stack.append(s)
print(ans)

Fixed submission:
s=list(input())
n=len(s)
zero=s.count("0")
one=s.count("1")
if n==1:print(0)
else:print(2*min(zero,one))

Buggy python submission (verdict: Time Limit Exceeded):
s=list(input())
N=len(s)
n=0
while len(set(s))>1:
    if s[n]!=s[n+1]:
        del s[n+1]
        del s[n]
        n=0
    elif len(s)==2:break
    else:n+=1
print(N-len(s))

Fixed submission:
s=list(input())
n=len(s)
zero=s.count("0")
one=s.count("1")
if n==1:print(0)
else:print(2*min(zero,one))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=sorted(map(int,input().split()))[::-1]
ans=A[0]
while True:
    M=A[0]
    m=A[1]
    del A[0]
    if M==1:ans=1;break
    if m==0:break
    A.append(M%m)
    A=sorted(A)[::-1]
    ans=min(ans,A[0])
print(ans)

Fixed submission:
import functools,fractions
n=input()
a=list(map(int,input().split()))
print(functools.reduce(fractions.gcd,a))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=sorted(map(int,input().split()))[::-1]
ans=A[0]
while True:
    M=A[0]
    m=A[1]
    del A[0]
    if m==0:break
    A.append(M%m)
    A=sorted(A)[::-1]
    ans=min(ans,A[0])
print(ans)

Fixed submission:
import functools,fractions
n=input()
a=list(map(int,input().split()))
print(functools.reduce(fractions.gcd,a))
Buggy python submission (verdict: Time Limit Exceeded):
k,a,b=map(int,input().split())
ans=1
m=0
for i in range(k):
    if i==k-1 and m==0:
        ans+=1
    elif m==1:
        m=0
        ans+=b
    elif ans<a:
        ans+=1
    elif ans>=a:
        ans-=a
        m=1
print(max(ans,k+1))

Fixed submission:
k,a,b=map(int,input().split())
t=k-(a-1)
print(max(k+1,(t//2)*(b-a)+t%2+a))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[]
B=[]
takahashi=0
aoki=0
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
for i in range(N):
    if not B or not A:
        break
    if max(A)>=max(B):
        num=A.index(max(A))
        takahashi+=A[num]
        del A[num]
        del B[num]
    else:
        num=B.index(max(B))
        takahashi+=A[num]
        del A[num]
        del B[num]
    if not B or not A:
        break
    if max(B)>=max(A):
        num=B.index(max(B))
        aoki+=B[num]
        del A[num]
        del B[num]
    else:
        num=A.index(max(A))
        aoki+=B[num]
        del A[num]
        del B[num]
print(takahashi-aoki)

Fixed submission:
N=int(input())
AB=[]
takahashi=0
aoki=0
for i in range(N):
    a,b=map(int,input().split())
    AB.append([a,b,a+b])
AB.sort(key=lambda AB:(AB[2],AB[1],AB[0]),reverse=True)
for i in range(N):
    if i%2==0:
        takahashi+=AB[i][0]
    else:
        aoki+=AB[i][1]
print(takahashi-aoki)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
TD=[[int(j) for j in input().split()] for i in range(N)]
TD=sorted(TD,key=lambda x:-x[1])
point=0
stack=[]
kind=set()
for t,d in TD[:K]:
    point+=d
    if t in kind:stack.append(d)
    else:kind.add(t)
ans1=delicious+len(kind)**2
ans2=ans1
for t,d in TD[K:]:
    if not stack:break
    if not t in kind:
        ans2+=d-stack.pop()+2*len(kind)+1
        kind.add(t)
        ans2=max(ans1,ans2)
print(ans2)

Fixed submission:
N,K=map(int,input().split())
TD=[[int(j) for j in input().split()] for i in range(N)]
TD=sorted(TD,key=lambda x:-x[1])
point=0
stack=[]
kind=set()
for t,d in TD[:K]:
    point+=d
    if t in kind:stack.append(d)
    else:kind.add(t)
point=point+len(kind)**2
ans=point
for t,d in TD[K:]:
    if not stack:break
    if not t in kind:
        point+=d-stack.pop()+2*len(kind)+1
        kind.add(t)
        ans=max(ans,point)
print(ans)
Buggy python submission (verdict: Runtime Error):
s=list(input())
t=list("keyence")
j=0
c=0
for i in range(len(s)):
    if s[i]==t[c]:
        j+=1
        if j==7:
            if s[i+1]="":
                print("YES")
                exit()
            else:
                break
        c+=1
print("NO")

Fixed submission:
import re
s=input()
if re.match("^keyence.*",s) or re.match(".*keyence$",s) or re.match("^k.*eyence$",s)  or re.match("^ke.*yence$",s) or re.match("^key.*ence$",s) or re.match("^keye.*nce$",s) or re.match("^keyen.*ce$",s)or re.match("^keyenc.*e$",s) or re.match("^keyence$",s) :
    print("YES")
else:print("NO")

Buggy python submission (verdict: Runtime Error):
s=list(input())
t=list("keyence")
j=0
c=0
for i in s:
    if i==t[c]:
        j+=1
        if j==7:
            print("YES")
            exit()
    c+=1
print("NO")

Fixed submission:
import re
s=input()
if re.match("^keyence.*",s) or re.match(".*keyence$",s) or re.match("^k.*eyence$",s)  or re.match("^ke.*yence$",s) or re.match("^key.*ence$",s) or re.match("^keye.*nce$",s) or re.match("^keyen.*ce$",s)or re.match("^keyenc.*e$",s) or re.match("^keyence$",s) :
    print("YES")
else:print("NO")
Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
dp=[0]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))print(dp[n-1])

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
dp=[0]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
PY=[list(map(int,input().split())) for i in range(M)]
x=collections.defaultdict(list)
for city,year in PY:
    x[city]+=[year]
for city,year in PY:
    num=bisect.bisect(x[city],year)
    print("%06d%06d"%(city,num))

Fixed submission:
import collections
import bisect
n,m=map(int,input().split())
p=[[int(j) for j in input().split()] for i in range(m)]
a=collections.defaultdict(list)
for x,y in sorted(p):
    a[x]+=[y]
for x,y in p:
    z=bisect.bisect(a[x],y)
    print("%06d%06d"%(x,z))
Buggy python submission (verdict: Runtime Error):
n,t=map(int,input().split())
m=1001
for i in range(n):c,t=map(int,input().split())
  if i<=t:m=min(m,c)
print("TLE" if m==1001 else m)

Fixed submission:
N,T=map(int,input().split())
m=1001
for i in range(N):
    c,t=map(int,input().split())
    if t<=T:m=min(m,c)
print("TLE" if m==1001 else m)
Buggy python submission (verdict: Runtime Error):
s=sorted(map(list(input()).count,set(s)))
t=sorted(map(list(input()).count,set(t)))
print("Yes" if s==t else "No")

Fixed submission:
from collections import Counter
s=Counter(list(input()))
t=Counter(list(input()))
s,t=list(s.values()),list(t.values())
print("Yes" if sorted(s)==sorted(t) else "No")
Buggy python submission (verdict: Runtime Error):
s=input()
k=int(input())
i=0
while s[i]=="1" and k:k,i=k-1,i+1
print(s[i])

Fixed submission:
s=input()
k=int(input())-1
i=0
while s[i]=="1" and k:k,i=k-1,i+1
print(s[i])
Buggy python submission (verdict: Runtime Error):
n=int(input())
print([N,N*2][N%2])

Fixed submission:
n=int(input())
print(2*n if n%2 else n)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print("Yay!" if A<9 and B<9 else ":(")

Fixed submission:
a,b=map(int,input().split())
print("Yay!" if a<9 and b<9 else ":(")
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
c=0
for i in a:while i%2==0:i,c=i/2,c+1
print(c)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
c=0
for i in a:
    while i%2==0:
        i=i/2
        c+=1
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
X=int(input())
bp=1
for b in range(1,X):
    for p in range(2,X):
        if b**p<=X:
            bp=max(bp,b**p)
print(bp)

Fixed submission:
x=int(input())
c=1
for b in range(1,x):
    for p in range(2,x):
        if b**p<=x:
            c=max(c,b**p)
        else:
            break
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
x=int(input())
c=1
for b in range(1,x):
    for p in range(2,x):
        if b**p<=x:
            c=max(c,b**p)
print(c)

Fixed submission:
x=int(input())
c=1
for b in range(1,x):
    for p in range(2,x):
        if b**p<=x:
            c=max(c,b**p)
        else:
            break
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
X=list(map(int,input().split()))
for i in range(N):
    sort=sorted(X[:i]+X[i+1:])
    print(sort[N//2-1])

Fixed submission:
N=int(input())
X=list(map(int,input().split()))
S=sorted(X)
b=S[N//2]
a=S[(N//2)-1]
for i in X:
    print(b if i<b else a)

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

s=[]
for i in range(N):
    s=sorted(X[:i]+X[i+1:])
    print(s[N//2-1])

Fixed submission:
N=int(input())
X=list(map(int,input().split()))
S=sorted(X)
b=S[N//2]
a=S[(N//2)-1]
for i in X:
    print(b if i<b else a)