Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, A, B, C=map(int,input().split())2l=[int(input())foriinrange(N)]3INF=10**945defdfs(cur, a, b, c):6ifcur==N:7returnabs(a-A)+abs(b-B)+abs(c-C)-30ifmin(a, b, c)>0elseINF8ret0=dfs(cur+1, a, b, c)9ret1=dfs(cur+1, a+l[cur], b, c)+1010ret2=dfs(cur+1, a, b+l[cur], c)+1011ret3=dfs(cur+1, a, b, c+l[cur])+1012returnmin(ret0, ret1, ret2, ret3)1314print(dfs(0,0,0,0))

Fixed submission:
from bisect import *
from collections import *
from fractions import gcd
from math import factorial
from itertools import *
N,A,B,C=map(int,input().split())
L=[int(input()) for i in range(N)]
value=10**10
itelst=[list(permutations(L,i)) for i in range(3,N+1)]
for n in range(N-2):
    for lst in itelst[n]:
        lstsum=sum(lst)
        a=0
        for i1 in range(len(lst)-2):
            a+=lst[i1]
            b=0
            for i2 in range(i1+1,len(lst)-1):
                b+=lst[i2]
                c=lstsum-a-b
                c1,b1,a1=sorted([a,b,c])
                a1=A-a1 if A-a1>0 else a1-A
                b1=B-b1 if B-b1>0 else b1-B
                c1=C-c1 if C-c1>0 else c1-C
                value=min(value, (len(lst)-3)*10 + a1+b1+c1)





print(value)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import *
from collections import *
from fractions import gcd
from math import factorial
from itertools import *
N,A,B,C=map(int,input().split())
L=[int(input()) for i in range(N)]
value=10**10
itelst=[list(permutations(L,i)) for i in range(3,N+1)]
for a,b,c in list(permutations([A,B,C])):
    for n in range(N-2):
        for lst in itelst[n]:
            for i1 in range(1,len(lst)-1):
                for i2 in range(i1+1,len(lst)):
                    value=min(value, (len(lst)-3)*10+\
                            round(abs(a-sum(lst[  :i1])))+\
                            round(abs(b-sum(lst[i1:i2])))+\
                            round(abs(c-sum(lst[i2:  ]))))

print(value)


Fixed submission:
from bisect import *
from collections import *
from fractions import gcd
from math import factorial
from itertools import *
N,A,B,C=map(int,input().split())
L=[int(input()) for i in range(N)]
value=10**10
itelst=[list(permutations(L,i)) for i in range(3,N+1)]
for n in range(N-2):
    for lst in itelst[n]:
        lstsum=sum(lst)
        a=0
        for i1 in range(len(lst)-2):
            a+=lst[i1]
            b=0
            for i2 in range(i1+1,len(lst)-1):
                b+=lst[i2]
                c=lstsum-a-b
                c1,b1,a1=sorted([a,b,c])
                a1=A-a1 if A-a1>0 else a1-A
                b1=B-b1 if B-b1>0 else b1-B
                c1=C-c1 if C-c1>0 else c1-C
                value=min(value, (len(lst)-3)*10 + a1+b1+c1)





print(value)
Buggy python submission (verdict: Runtime Error):
from itertools import *
import copy
from collections import *


N=int(input())
A=list(map(int,input().split()))
idle_max=10**9
peki2=[]
for i in range(1,100):
    a=2**i
    if a<=2*idle_max:
        peki2.append(a)
peki2.sort(reverse=True)
lst=[[],[]]
for a in A:
    if a%2:
        lst[1].append(a)
    else:
        lst[0].append(a)

lst[0].sort(reverse=True)
lst[1].sort(reverse=True)
setlst=[set(lst[0]),set(lst[1])]
Counerlst=[Counter(lst[0]),Counter(lst[1])]

count=0
for l in range(2):
    for n in lst[l]:
        if n in setlst[l]:
            for p in peki2:
                a=p-n
                if a in setlst[l]:
                    count+=1
                    Counerlst[l][a]-=1
                    Counerlst[l][n]-=1
                    if Counerlst[l][a]==0:
                        setlst[l].remove(a)
                    if Counerlst[l][n]==0:
                        setlst[l].remove(n)
                    break
print(count)


Fixed submission:
from itertools import *
import copy
from collections import *


N=int(input())
A=list(map(int,input().split()))
idle_max=10**9
peki2=[]
for i in range(1,100):
    a=2**i
    if a<=2*idle_max:
        peki2.append(a)
peki2.sort(reverse=True)
lst=[[],[]]
for a in A:
    if a%2:
        lst[1].append(a)
    else:
        lst[0].append(a)

lst[0].sort(reverse=True)
lst[1].sort(reverse=True)
setlst=[set(lst[0]),set(lst[1])]
Counerlst=[Counter(lst[0]),Counter(lst[1])]

count=0
for l in range(2):
    for n in lst[l]:
        if n in setlst[l]:
            for p in peki2:
                a=p-n

                if a in setlst[l]:
                    if n==a:
                        if Counerlst[l][n]>=2:
                            count+=1
                            Counerlst[l][n]-=2
                            if Counerlst[l][n]==0:
                                setlst[l].remove(n)
                    else:

                        count+=1
                        Counerlst[l][a]-=1
                        Counerlst[l][n]-=1
                        if Counerlst[l][a]==0:
                            setlst[l].remove(a)
                        if Counerlst[l][n]==0:
                            setlst[l].remove(n)
                    break
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
def lcm(a,b):
    return(a*b//gcd(a,b))

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

_lcm=lcm(N,M)
n=_lcm//N
m=_lcm//M
for i in range(_lcm):
    if i%n==0 and i%m==0:
        if S[i//n]!=T[i//m]:
            print(-1)
            exit()
print(_lcm)


Fixed submission:
from fractions import gcd
def lcm(a,b):
    return(a*b//gcd(a,b))

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

_lcm=lcm(N,M)
n=_lcm//N
m=_lcm//M
for i in range(0,_lcm,n*m):
    if S[i//n]!=T[i//m]:
        print(-1)
        exit()    
print(_lcm)
Buggy python submission (verdict: Runtime Error):
import bisect
x=int(input())
a=[i*111 for i in range(1,9)]
print(a[bisect.bisect_left(a,x)])


Fixed submission:
import bisect
x=int(input())
a=[i*111 for i in range(1,10)]
print(a[bisect.bisect_left(a,x)])
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
X=list(map(int,input().split()))
if 0 in X:
    K-=1
left=[i for i in X if i<0]
right=[i for i in X if i>0]
lst=set()
for l,L in enumerate(left):
    i=K-(l+1)
    if i>=0:
        if i>=len(right):
            continue
        R=right[i]
        lst.add(R-L*2)
    else:
        lst.add(-L)

for l,R in enumerate(right):
    i=K-(l+1)
    if i>=0:
        if i>=len(left):
            continue
        L=left[i]
        lst.add(R*2-L)
    else:
        lst.add(R)

print(min(list(lst)))


Fixed submission:
N,K=map(int,input().split())
X=list(map(int,input().split()))
if K==1 and 0 in X:
    print(0)
    exit()
if 0 in X:
    K-=1
left=sorted([i for i in X if i<0],reverse=True)
right=[i for i in X if i>0]

lst=set()
for l,L in enumerate(left):
    i=K-(l+1)-1
    if i>=0:
        if i<len(right):
            lst.add(right[i]-L*2)
    else:
        lst.add(-L)

for l,R in enumerate(right):
    i=K-(l+1)-1
    if i>=0:
        if i<len(left):
            lst.add(R*2-left[i])
    else:
        lst.add(R)

print(min(list(lst)))
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import *
N,M,Q=map(int,input().split())
LR=[list(map(int,input().split())) for i in range(M)]
PQ=[list(map(int,input().split())) for i in range(Q)]
data=[[] for i in range(N+1)]
for l,r in LR:
    data[l].append(r)
for i in range(1,N):
    data[i].sort()
for p,q in PQ:
    count=0
    for i in range(p,q+1):
        count+=bisect_right(data[i],q)
    print(count)


Fixed submission:
from bisect import *
N,M,Q=map(int,input().split())
LR=[list(map(int,input().split())) for i in range(M)]
PQ=[list(map(int,input().split())) for i in range(Q)]
data=[[] for i in range(N+1)]
for l,r in LR:
    data[l].append(r)
for i in range(1,N):
    data[i].sort()

data2=[[0] for i in range(N+1)]
for i in range(1,N+1):
    for c in range(1,N+1):
        data2[i].append(bisect_right(data[i],c))
#print(data2)
for p,q in PQ:
    count=0
    for i in range(p,q+1):
        count+=data2[i][q]
    print(count)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import *
N,M,Q=map(int,input().split())
LR=[list(map(int,input().split())) for i in range(M)]
PQ=[list(map(int,input().split())) for i in range(Q)]
data=[[] for i in range(N+1)]
for l,r in LR:
    data[l].append(r)
data=[sorted(data[i]) for i in range(N+1)]
for p,q in PQ:
    count=0
    for i in range(p,q+1):
        count+=bisect_right(data[i],q)
    print(count)


Fixed submission:
from bisect import *
N,M,Q=map(int,input().split())
LR=[list(map(int,input().split())) for i in range(M)]
PQ=[list(map(int,input().split())) for i in range(Q)]
data=[[] for i in range(N+1)]
for l,r in LR:
    data[l].append(r)
for i in range(1,N):
    data[i].sort()

data2=[[0] for i in range(N+1)]
for i in range(1,N+1):
    for c in range(1,N+1):
        data2[i].append(bisect_right(data[i],c))
#print(data2)
for p,q in PQ:
    count=0
    for i in range(p,q+1):
        count+=data2[i][q]
    print(count)
Buggy python submission (verdict: Time Limit Exceeded):
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math
mod=(10**9+7)**2
ferumaC=300000
fac=[0 for i in range(ferumaC)]
fac[0]=1
ifac=[0 for i in range(ferumaC)]
ifac[0]=1
def mpow(x,n):
    num=1
    while n > 0:
        if n&1:
            num=num*x%mod
        x=x*x%mod
        n=n>>1
    return(num)
for i in range(0,ferumaC-1):
    fac[i+1]=(fac[i]*(i+1))%mod
    ifac[i+1]=ifac[i]*mpow(i+1,mod-2)%mod
def comb(a,b):
    if a==0 and b==0:return(1)
    if a<b or a<0:return(0)
    tmp=ifac[a-b]*ifac[b]%mod
    return(tmp*fac[a]%mod)
N,M=map(int,input().split())
A=list(map(int,input().split()))
#A=[i%M for i in A]
data=[0 for i in range(N)]
data[0]=A[0]%M
for i in range(1,N):
    data[i]=(data[i-1]+A[i])%M
data.append(0)
data=Counter(data)
print(sum([comb(data[i],2) for i in data if data[i]>=2]))


Fixed submission:
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math

N,M=map(int,input().split())
A=list(map(int,input().split()))
#A=[i%M for i in A]
data=[0 for i in range(N)]
data[0]=A[0]%M
for i in range(1,N):
    data[i]=(data[i-1]+A[i])%M
data.append(0)
data=Counter(data)
print(sum([data[i]*(data[i]-1)//2 for i in data if data[i]>=2]))

Buggy python submission (verdict: Runtime Error):
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math
mod=10**9+7
ferumaC=10000
fac=[0 for i in range(ferumaC)]
fac[0]=1
ifac=[0 for i in range(ferumaC)]
ifac[0]=1
def mpow(x,n):
    num=1
    while n > 0:
        if n&1:
            num=num*x%mod
        x=x*x%mod
        n=n>>1
    return(num)
for i in range(0,ferumaC-1):
    fac[i+1]=(fac[i]*(i+1))%mod
    ifac[i+1]=ifac[i]*mpow(i+1,mod-2)%mod
def comb(a,b):
    if a==0 and b==0:return(1)
    if a<b or a<0:return(0)
    tmp=ifac[a-b]*ifac[b]%mod
    return(tmp*fac[a]%mod)
N,M=map(int,input().split())
A=list(map(int,input().split()))
#A=[i%M for i in A]
data=[0 for i in range(N)]
data[0]=A[0]%M
for i in range(1,N):
    data[i]=(data[i-1]+A[i])%M
data.append(0)
data=Counter(data)
print(sum([comb(data[i],2) for i in data if data[i]>=2]))


Fixed submission:
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math

N,M=map(int,input().split())
A=list(map(int,input().split()))
#A=[i%M for i in A]
data=[0 for i in range(N)]
data[0]=A[0]%M
for i in range(1,N):
    data[i]=(data[i-1]+A[i])%M
data.append(0)
data=Counter(data)
print(sum([data[i]*(data[i]-1)//2 for i in data if data[i]>=2]))
Buggy python submission (verdict: Runtime Error):
from bisect import *
from collections import *
from fractions import gcd
from math import factorial
from itertools import *
from heapq import *
import copy

T=int(input())
ABCD=[list(map(int,input().split())) for i in range(T)]
for A,B,C,D in ABCD:
    if B>D or A<B:
        print("No")
    elif C>=B:
        print("Yes")
    else:
        F=D-B
        _gcd=gcd(D,B)
        st=(A-B)%_gcd
        #if A==14 and B==10 and C==8 and D==12:
        #    print(B-C-1)
        if ((B-A%_gcd)//g)*g+A%_gcd>C:
            print("No")
        else:
            print("Yes")


Fixed submission:
from bisect import *
from collections import *
from fractions import gcd
from math import factorial
from itertools import *
from heapq import *
import copy

T=int(input())
ABCD=[list(map(int,input().split())) for i in range(T)]
for A,B,C,D in ABCD:
    if B>D or A<B:
        print("No")
    elif C>=B:
        print("Yes")
    else:
        F=D-B
        _gcd=gcd(D,B)
        st=(A-B)%_gcd
        #if A==14 and B==10 and C==8 and D==12:
        #    print(B-C-1)
        if B-_gcd+A%_gcd>C:
            print("No")
        else:
            print("Yes")
Buggy python submission (verdict: Runtime Error):
print(N*(100**D)) if N!=100 else print(101*(100**D))

Fixed submission:
D,N= (int(i) for i in input().split())
print(N*(100**D)) if N!=100 else print(101*(100**D))
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import *

N,C=map(int,input().split())
D=[list(map(int,input().split())) for i in range(C)]
c=[list(map(int,input().split())) for i in range(N)]

lst=[[],[],[]]

for y in range(N):
    for x in range(N):
        lst[(y+x)%3].append(c[y][x])


Revalue=10**18
for Color1,Color2,Color3 in list(permutations(list(range(1,C+1)),3)):
    value=0
    for i in lst[0]:
        value+=D[i-1][Color1-1]
    for i in lst[1]:
        value+=D[i-1][Color2-1]
    for i in lst[2]:
        value+=D[i-1][Color3-1]
    Revalue=min(Revalue,value)
print(Revalue)


Fixed submission:
from itertools import *
N,C=map(int,input().split())
D=[list(map(int,input().split())) for i in range(C)]
c=[list(map(int,input().split())) for i in range(N)]

lst=[[],[],[]]

for y in range(N):
    for x in range(N):
        lst[(y+x)%3].append(c[y][x])


Revalue=10**18

valuelst=[[0 for i in range(C)] for i in range(3)]
for v in range(3):
    for Color in range(1,C+1):
        value=0
        for i in lst[v]:
            value+=D[i-1][Color-1]
        valuelst[v][Color-1]=value


for Color1,Color2,Color3 in list(permutations(list(range(1,C+1)),3)):
    value=valuelst[0][Color1-1]+valuelst[1][Color2-1]+valuelst[2][Color3-1]

    Revalue=min(Revalue,value)
print(Revalue)

Buggy python submission (verdict: Runtime Error):
import numpy as np
from itertools import *

N,C=map(int,input().split())
D=[list(map(int,input().split())) for i in range(C)]
c=[list(map(int,input().split())) for i in range(N)]

lst=[[],[],[]]

for y in range(N):
    for x in range(N):
        lst[(y+x)%3].append(c[y][x])


Revalue=10**18
for Color1,Color2,Color3 in list(permutations(list(range(1,C+1)),3)):
    value=0
    for i in lst[0]:
        value+=D[i-1][Color1-1]
    for i in lst[1]:
        value+=D[i-1][Color2-1]
    for i in lst[2]:
        value+=D[i-1][Color3-1]
    Revalue=min(Revalue,value)
print(Revalue)


Fixed submission:
from itertools import *
N,C=map(int,input().split())
D=[list(map(int,input().split())) for i in range(C)]
c=[list(map(int,input().split())) for i in range(N)]

lst=[[],[],[]]

for y in range(N):
    for x in range(N):
        lst[(y+x)%3].append(c[y][x])


Revalue=10**18

valuelst=[[0 for i in range(C)] for i in range(3)]
for v in range(3):
    for Color in range(1,C+1):
        value=0
        for i in lst[v]:
            value+=D[i-1][Color-1]
        valuelst[v][Color-1]=value


for Color1,Color2,Color3 in list(permutations(list(range(1,C+1)),3)):
    value=valuelst[0][Color1-1]+valuelst[1][Color2-1]+valuelst[2][Color3-1]

    Revalue=min(Revalue,value)
print(Revalue)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=list(input())
for i in range(len(S)):
    S[i]=-1 if S[i]=="W" else 1
data=[0 for i in range(N)]

for i in range(N):
    data[i]=-1*sum([S[m] for m in range(0,i) if S[m]==-1])+sum([S[m] for m in range(i+1,N) if S[m]==1])
print(min(data))


Fixed submission:
N=int(input())
S=list(input())
data=[0 for i in range(N)]
data[0]=S[1:].count("E")
for i in range(N-1):
    if S[i]=="W":
        data[i+1]+=1
    if S[i+1]=="E":
        data[i+1]-=1
    data[i+1]+=data[i]
print(min([i for i in data]))
Buggy python submission (verdict: Runtime Error):

N=int(input())
data=[int(input()) for i in range(N)]
mae=N//2+N%2
count=0
print(N-[i for i in data if i>N//2+N%2][0]+[i for i in data if i<=N//2+N%2][0])


Fixed submission:
N=int(input())
data=[int(input()) for i in range(N)]
count=0
dic={}
for i in data:

    if i-1 in dic:
        num=dic.pop(i-1)
        dic.update({i:num+1})
    else:
        dic.update({i:1})
print(N-max([dic[i] for i in dic]))

Buggy python submission (verdict: Time Limit Exceeded):

N=int(input())
data=[int(input()) for i in range(N)]
mae=N//2+N%2
i=1
count=0

maelist=[]
maeset=set()
usirolist=[]
usiroset=set()
flag=1
lst=set()
nikaime=0
dellst=set()
while flag:
    flag=0
    if lst:
        lst.clear()
    for i in range(len(data)):
        if data[i] in dellst:
            dellst.remove(data[i])
            data[i]=0
            continue
        lst.add(data[i])
        if data[i]+1 in lst or data[i]+1 in maeset:
            flag=2
            count+=1
            if data[i]<=mae:
                maelist.append(data[i])
                maeset.add(data[i])

                data[i]=0


            else:
                usirolist.append(data[i]+1)
                usiroset.add(data[i]+1)
                dellst.add(data[i]+1)

    for i in usirolist:
        if i+1 in set(data):
            dellst.add(i+1)
            usirolist.append(i+1)
            count+=1
            flag=1

    if flag:
        data=[i for i in data if i]
    if not nikaime:
        nikaime=1

maelist.reverse()
print(count)


Fixed submission:
N=int(input())
data=[int(input()) for i in range(N)]
count=0
dic={}
for i in data:

    if i-1 in dic:
        num=dic.pop(i-1)
        dic.update({i:num+1})
    else:
        dic.update({i:1})
print(N-max([dic[i] for i in dic]))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N=int(input())
data=deque([int(input()) for i in range(N)])
mae=N//2+N%2
i=1
count=0

while i<N:
    data2=list(data)
    #print(data)
    if (data[i]+1) in data2[:i]:
        #print("unko",i)
        t=data[i]
        if t<=mae:

            data.remove(t)
            data.appendleft(t)
            count+=1
        else:
            t+=1
            data.remove(t)
            data.append(t)
            count+=1
        i=0
    i+=1

#print(data)
print(count)


Fixed submission:
N=int(input())
data=[int(input()) for i in range(N)]
count=0
dic={}
for i in data:

    if i-1 in dic:
        num=dic.pop(i-1)
        dic.update({i:num+1})
    else:
        dic.update({i:1})
print(N-max([dic[i] for i in dic]))
Buggy python submission (verdict: Runtime Error):
alphabet=[chr(i+97) for i in range(0,26)]
S=input()

#S=    "zyawvutsrqponmlkjihgfedcbx"
if S=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
else:

    for i in S:
        alphabet.remove(i)
    if alphabet:
        print(S+alphabet[0])
    else:
        motoS=S
        S=list(S)
        poplist=[]
        stringlist=[]
        while len(S)>=2:
            poplist.append(S.pop())
            for s in poplist:
                _S=S
                _S[-1]=s
                string=""
                for ss in _S:
                    string+=ss
                stringlist.append(string)
        stringlist.append(motoS)
        stringlist.sort()
        print(stringlist[stringlist.index(motoS)+1])


Fixed submission:
alphabet=[chr(i+97) for i in range(0,26)]
S=input()
if S=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
else:
    for i in S:
        alphabet.remove(i)
    if alphabet:
        print(S+alphabet[0])
    else:
        motoS=S
        S=list(S)
        poplist=[]
        stringlist=[]
        while len(S)>=2:
            poplist.append(S[-1])
            S.pop()
            for s in poplist:
                _S=[i for i in S]
                _S[-1]=s
                string=""
                for ss in _S:
                    string+=ss
                stringlist.append(string)
        stringlist.append(motoS)
        stringlist.sort()
        try:print(stringlist[stringlist.index(motoS)+1])
        except:print(stringlist[stringlist.index(motoS)])

Buggy python submission (verdict: Runtime Error):
alphabet=[chr(i+97) for i in range(0,26)]
S=input()

#S=    "zyawvutsrqponmlkjihgfedcbx"
if S=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
else:

    for i in S:
        alphabet.remove(i)
    if alphabet:
        print(S+alphabet[0])
    else:
        motoS=S
        S=list(S)
        poplist=[]
        stringlist=[]
        while len(S)>=2:
            poplist.append(S.pop())
            for s in poplist:
                _S=S
                _S[-1]=s
                string=""
                for ss in _S:
                    string+=ss
                stringlist.append(string)
        stringlist.append(motoS)
stringlist.sort()
print(stringlist[stringlist.index(motoS)+1])


Fixed submission:
alphabet=[chr(i+97) for i in range(0,26)]
S=input()
if S=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
else:
    for i in S:
        alphabet.remove(i)
    if alphabet:
        print(S+alphabet[0])
    else:
        motoS=S
        S=list(S)
        poplist=[]
        stringlist=[]
        while len(S)>=2:
            poplist.append(S[-1])
            S.pop()
            for s in poplist:
                _S=[i for i in S]
                _S[-1]=s
                string=""
                for ss in _S:
                    string+=ss
                stringlist.append(string)
        stringlist.append(motoS)
        stringlist.sort()
        try:print(stringlist[stringlist.index(motoS)+1])
        except:print(stringlist[stringlist.index(motoS)])
Buggy python submission (verdict: Runtime Error):
from bisect import *
from collections import *
from fractions import gcd
from math import factorial
from itertools import *

N=int(input())

if N==3:
    print(2,5,63)
elif N==4:
    print(2,5,20,63)
elif N==5:
    print(2,5,20,63,30)
else:
    lst=[2,3,4,6,9,12]
    count=N-6
    div2=[i for i in range(14,30001,2) if i%6!=0]
    if len(div2)%2==1:
        div2.pop()
    div3=[i for i in range(15,30001,6)]
    if len(div3)%2==1:
        div3.pop()
    div6=[i for i in range(18,30001,6)]

    while count>=2 and div2:
        lst.append(div2.pop())
        lst.append(div2.pop())
        count-=2
    while count>=2 and div3:
        lst.append(div3.pop())
        lst.append(div3.pop())
        count-=2
    while count>=1:
        lst.append(div6.pop())
        count-=1
    print(" ".join(list(map(str,lst))))


Fixed submission:
from bisect import *
from collections import *
from fractions import gcd
from math import factorial
from itertools import *

N=int(input())

if N==3:
    print(2,5,63)
elif N==4:
    print(2,5,20,63)
elif N==5:
    print(2,5,20,63,30)
else:
    lst=[2,3,4,6,9,12]
    count=N-6
    div2=[i for i in range(10,30001,2) if i%6!=0]
    div2.append(8)
    #if len(div2)%2==1:
    #    div2.pop()
    div3=[i for i in range(15,30001,6)]
    #if len(div3)%2==1:
    #    div3.pop()
    div6=[i for i in range(18,30001,6)]
    #print(len(div2),len(div3),len(div6))
    while count>=2 and len(div2)>=2:
        lst.append(div2.pop())
        lst.append(div2.pop())
        count-=2
    while count>=2 and len(div3)>=2:
        lst.append(div3.pop())
        lst.append(div3.pop())
        count-=2
    while count>=1:
        lst.append(div6.pop())
        count-=1
    print(" ".join(list(map(str,lst))))
Buggy python submission (verdict: Time Limit Exceeded):
N,A,B=map(int,input().split())

if (B-A)%2==0:
    print((B-A)//2)
else:
    C=N+1-B
    D=N+1-A
    print(min(A + (B-A-1)//2,D + (D-C-1)//2))


Fixed submission:
N=int(input())
print(N-1)
s=input()
if s=="Vacant":
    exit()
elif s=="Male":
    flag=1
else:
    flag=0
print(0)
s=input()
if s=="Vacant":
    exit()
elif s=="Male":
    flag=1
else:
    flag=0
st=0
end=N-1

while s!="Vacant":
    a=(end+st)//2
    print(a)
    s=input()
    if (a+flag*1)%2:
        if s=="Male":
            st=a
        else:
            end=a
    else:
        if s=="Female":
            st=a
        else:
            end=a