Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
n, k = map(int, input().split())
s = input()
sList = [] #連続する1の数、0の数、1の数...と格納するリスト
switch = int(s[0])
num = 1
if int(s[0]) == 0:
  sList.append(0)
if n > 1:
  for i in range(1, n):
    if int(s[i]) == switch:
      num += 1
    else:
      sList.append(num)
      num = 1
      switch = int(s[i])
sList.append(num)
if len(sList) // 2 < k: #全部ひっくり返せる
  print(n)
  sys.exit()
elif len(sList) % 2 == 0: #最後が0の数で終わっている場合、1の数で終わらせる
  sList.append(0)
  
sMax = 0
for i in range(0, (len(sList)-2*k) // 2 + 1): #リストの2k+1個の部分和のうち、最大のものが答え
  s = sum(sList[2*i:2*i+2*k+1])
  if sMax < s:
    sMax = s
    
print(sMax)

Fixed submission:
import sys
n, k = map(int, input().split())
s = input()
sList = [] #連続する1の数、0の数、1の数...と格納するリスト
switch = int(s[0])
num = 1
if int(s[0]) == 0:
  sList.append(0)
if n > 1:
  for i in range(1, n):
    if int(s[i]) == switch:
      num += 1
    else:
      sList.append(num)
      num = 1
      switch = int(s[i])
sList.append(num)
if len(sList) // 2 < k: #全部ひっくり返せる
  print(n)
  sys.exit()
elif len(sList) % 2 == 0: #最後が0の数で終わっている場合、1の数で終わらせる
  sList.append(0)
  
s = sum(sList[0:2*k+1])
sMax = s

for i in range(1, (len(sList)-2*k) // 2 + 1): #リストの2k+1個の部分和のうち、最大のものが答え
  s += - sList[2*i-2] - sList[2*i-1] + sList[2*i+2*k] + sList[2*i+2*k-1]
  if sMax < s:
    sMax = s
    
print(sMax)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n, k = map(int, input().split())
s = input()
sList = [] #連続する1の数、0の数、1の数...と格納するリスト
switch = int(s[0])
num = 1
if int(s[0]) == 0:
  sList.append(0)
if n > 1:
  for i in range(1, n):
    if int(s[i]) == switch:
      num += 1
    else:
      sList.append(num)
      num = 1
      switch = int(s[i])
sList.append(num)
if len(sList) // 2 < k: #全部ひっくり返せる
  print(n)
  sys.exit()
elif len(sList) % 2 == 0: #最後が0の数で終わっている場合、1の数で終わらせる
  sList.append(0)
  
sMax = 0
for i in range(0, (len(sList)-2*k) // 2 + 1): #リストの2k+1個の部分和のうち、最大のものが答え
  s = sum(sList[2*i:2*i+2*k+1])
  if sMax < s:
    sMax = s
    
print(sMax)

Fixed submission:
import sys
n, k = map(int, input().split())
s = input()
sList = [] #連続する1の数、0の数、1の数...と格納するリスト
switch = int(s[0])
num = 1
if int(s[0]) == 0:
  sList.append(0)
if n > 1:
  for i in range(1, n):
    if int(s[i]) == switch:
      num += 1
    else:
      sList.append(num)
      num = 1
      switch = int(s[i])
sList.append(num)
if len(sList) // 2 < k: #全部ひっくり返せる
  print(n)
  sys.exit()
elif len(sList) % 2 == 0: #最後が0の数で終わっている場合、1の数で終わらせる
  sList.append(0)
  
s = sum(sList[0:2*k+1])
sMax = s

for i in range(1, (len(sList)-2*k) // 2 + 1): #リストの2k+1個の部分和のうち、最大のものが答え
  s += - sList[2*i-2] - sList[2*i-1] + sList[2*i+2*k] + sList[2*i+2*k-1]
  if sMax < s:
    sMax = s
    
print(sMax)
Buggy python submission (verdict: Time Limit Exceeded):
# 蟻本1-6-1例題相当
# 数学的に解けそうであるが、とりあえず3重のfor文で回してみる
# 最大で2500^3≒100億となる
# また、条件分岐による打ち切りもしない(x+y<s-kなら、zの値に関係なく不成立だが、それを考慮しない)

count = 0
k, s = map(int,input().split())
for x in range(k+1):
  for y in range(k+1):
    for z in range(k+1):
      if x+y+z == s:
        count += 1
print(count)

Fixed submission:
# 蟻本1-6-1例題相当
# 続いて、x、yを確定した際、zは一意に決まるか値が存在しないかのいずれかであることに着目する。
# よって2重のfor文で回してみる
# 最大で2500^2≒600万となる
# また、条件分岐による打ち切りもしない(x+y<s-kなら、zの値に関係なく不成立だが、それを考慮しない)

count = 0
k, s = map(int,input().split())
for x in range(k+1):
  for y in range(k+1):
    if 0 <= s-x-y and s-x-y <= k:
        count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
s = input()
answer = 0
sumList = []
numStr = ""
for i in range(2**(len(s)-1)):
  bit = "0" + str(len(s) - 1) + "b"
  iStr = format(i, bit)
  numStr += s[0]
  for j in range(len(iStr)):
    if iStr[j] == "1":
      sumList.append(int(numStr))
      numStr = s[j+1]
    else:
      numStr += s[j+1]
  sumList.append(int(numStr))
  numStr = ""
  answer += sum(sumList)
  sumList = []
print(answer)

Fixed submission:
s = input()
answer = 0
sumList = []
numStr = ""
if len(s) == 1:
  print(s)
else:
  for i in range(2**(len(s)-1)):
    bit = "0" + str(len(s) - 1) + "b"
    iStr = format(i, bit)
    numStr += s[0]
    for j in range(len(iStr)):
      if iStr[j] == "1":
        sumList.append(int(numStr))
        numStr = s[j+1]
      else:
        numStr += s[j+1]
    sumList.append(int(numStr))
    numStr = ""
    answer += sum(sumList)
    sumList = []
  print(answer)
Buggy python submission (verdict: Runtime Error):
import sys
S = int(input())

for i in range(3):
  if S[i] == S[i+1]:
    print("Bad")
    sys.exit()
print("Good")

Fixed submission:
import sys
S = input()

for i in range(3):
  if S[i] == S[i+1]:
    print("Bad")
    sys.exit()
print("Good")
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python

N=int(input())
a=[int(i) for i in input().split()] 

a.sort()
numbers=[int(i) for i in set(a)]
numbers.sort()

# print("a", a)
# print("numbers", numbers)

def main():
    label=0 # numbersの添字
    i=0 # aの添字
    err=0 # 削除する要素の数
    while(True):
        # 範囲を超えるパターン
        if(len(numbers) <= label or len(a) <= i):
            # print("Exit")
            return err
        # 最初が一致
        if(a[i]==numbers[label]):
            # 要素数分を確保
            ar=[ numbers[label] ] * numbers[label]
            # ピッタリ一致
            if(a[ i:i+numbers[label] ] == ar):
                # print("[ fit ] i="+str(i))
                # print("a["+str(i)+"]="+str(a[i]))
                i += numbers[label]
                label += 1
            # 最初が一致かつ不完全一致
            else:
                # print("[unfit] i="+str(i))
                for j in range(0, i):
                    try:
                        # 値が不一致(要素)
                        # print("a[i+j]="+str(a[i+j]))
                        # print("numbers[label]="+str(numbers[label]))
                        if(a[i+j]!=numbers[label]):
                            # print("Unmatched: j=", j)
                            i+=j
                            err+=j
                            break
                    except IndexError:
                        err+=j
                        # print("i, j=", i, j)
                        return err
        # 最初が不一致(右に1つずらす)
        else:
            err+=1
            i+=1

if(N==1):
    if(a[0]==1):
        print(0)
    else:
        print(1)
else:
    print(main())



Fixed submission:
#!/usr/bin/env python

N=int(input())
a=[int(i) for i in input().split()] 
a.sort()
numbers=[int(i) for i in set(a)]
numbers.sort()

# dictの初期化
numbers_count = {}
# for i in numbers:
for i in numbers:
    numbers_count[i] = 0 

# 数値別の集計
for i in a:
    numbers_count[i] += 1

# 取り除く数を算出
remove=0
for i in numbers:
    # 3が2つある
    if(i > numbers_count[i]):
        remove += numbers_count[i]
    # 3が4つある
    elif(i < numbers_count[i]):
        remove += numbers_count[i] - i

print(remove)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
 
# input
str1=input()
str2=input()
 
if str1 == str2[::-1]:
    print("YES")
else:
    print("NO")

Fixed submission:
#!/usr/bin/env python

# input
str1=input()
str2=input()

if str1 == str2[::-1]:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python

n=int(input())
a=[int(i) for i in input().split()]
b=[]

for k,v in enumerate(a):
    if(k%2==0):
        b.insert(0, v)
    else:
        b.append(v)

if(n%2==0):
    b.reverse()

for k,v in enumerate(b):
    print(v, end="")
    if(k!=len(b)-1):
        print(" ", end="")
    else:
        print()


Fixed submission:
#!/usr/bin/env python

n=int(input())
a=[int(i) for i in input().split()]

def cal(p, rev):
    if(rev):
        lst=reversed(list(enumerate(a)))
    else:
        lst=list(enumerate(a))
    for k,v in lst:
        if(k%2==p):
            print(str(v)+" ", end="")

if(n%2==1):
    cal(0, True)
    cal(1, False)
    print()
else:
    cal(1, True)
    cal(0, False)
    print()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python

n=int(input())
a=[int(i) for i in input().split()]
b=[]

for i in a:
    b.append(i)
    b.reverse()

for k,v in enumerate(b):
    print(v, end="")
    if(k!=len(b)-1):
        print(" ", end="")
    else:
        print()


Fixed submission:
#!/usr/bin/env python

n=int(input())
a=[int(i) for i in input().split()]

def cal(p, rev):
    if(rev):
        lst=reversed(list(enumerate(a)))
    else:
        lst=list(enumerate(a))
    for k,v in lst:
        if(k%2==p):
            print(str(v)+" ", end="")

if(n%2==1):
    cal(0, True)
    cal(1, False)
    print()
else:
    cal(1, True)
    cal(0, False)
    print()
Buggy python submission (verdict: Time Limit Exceeded):
#!/ust/bin/env python

N,A,B=[int(i) for i in input().split()]

def main():
    def sum(count, num):
        tmp=0
        for i in range(0, count):
            tmp+=num
        # print("tmp",tmp)
        return tmp

    if(A>B):
        print(0)
        return
    elif(A==B):
        print(1)
        return

    ### A<B
    Max=(A+B)+sum(N-2, B)
    Min=(A+B)+sum(N-2, A)

    if(N==1):
        print(0)
    elif(N==2):
        print((B+B)-(A+A)+1)
    elif(Max-Min+1<=0):
        print(0)
    else:
        print(Max-Min+1)

main()


Fixed submission:
#!/ust/bin/env python

N,A,B=[int(i) for i in input().split()]

def main():
    if(A>B):
        print(0)
        return
    elif(A==B):
        print(1)
        return

    ### A<B
    Max=(A+B)+(N-2)*B
    Min=(A+B)+(N-2)*A

    if(N==1):
        print(0)
    elif(N==2):
        print((B+B)-(A+A)+1)
    elif(Max-Min+1<=0):
        print(0)
    else:
        print(Max-Min+1)

main()
Buggy python submission (verdict: Time Limit Exceeded):
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD=10**9+7

N,M=rl()
A=rl()
B=[0]*M
C=[0]*M
for i in range(M):
    B[i],C[i]=rl()

for b,c in zip(B,C):
    A.extend([c]*b)

A.sort(reverse=True)
print(sum(A[:N]))

Fixed submission:
import sys
input = sys.stdin.readline
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD=10**9+7

N,M=rl()
A=rl()
B=[0]*M
C=[0]*M
for i in range(M):
    B[i],C[i]=rl()


D = []
for a in A:
    D.append([a,1])
for b,c in zip(B,C):
    D.append([c,b])

D.sort(reverse=True)

ans = 0
cnt = N
for val,num in D:
    if cnt >= num:
        cnt -= num
        ans += val*num
    else:
        ans += val*cnt
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
ri = lambda: int(input())
#rl = lambda: [int(x) if x.isdecimal() else x for x in input().split()]
#rl = lambda: list(input().split()))
rl = lambda: map(int,input().split())
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7

N=ri()
A=list(rl())
cnt = [0]*3
ans = 0
sei = []
for a in A:
    ans += abs(a)
    if a > 0:
        sei.append(a)
        cnt[0] += 1
    elif a == 0:
        cnt[1] += 1
    elif a < 0:
        cnt[2] += 1

if cnt[1] > 0 or cnt[2]%2 == 0:
    None
else:
    ans -= 2 * min(sei)

print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
ri = lambda: int(input())
#rl = lambda: [int(x) if x.isdecimal() else x for x in input().split()]
#rl = lambda: list(input().split()))
rl = lambda: map(int,input().split())
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7

N=ri()
A=list(rl())
cnt = [0]*3
ans = 0
sei = []
for a in A:
    sei.append(abs(a))
    ans += abs(a)
    if a > 0:
        cnt[0] += 1
    elif a == 0:
        cnt[1] += 1
    elif a < 0:
        cnt[2] += 1

if cnt[1] > 0 or cnt[2]%2 == 0:
    None
else:
    ans -= 2 * min(sei)

print(ans)
Buggy python submission (verdict: Runtime Error):
import bisect
I=lambda:map(int,input().split())
N,Q=I()
S=input()
L=[0]*Q
R=[0]*Q
for i in range(Q):
    L[i],R[i] = I()
m=[]
for i in range(N-1):
    if S[i]=='A' and S[i+1]=='C':
        m += [i]
#print(m)
for i in range(Q):
    l=L[i]
    r=R[i]
    li=bisect.bisect_left(m,l-1)
    ri=bisect.bisect_left(m,r-1)
    #print(i,li,ri)
    print(ri-li-1 if m[ri-1]==r else ri-li)


Fixed submission:
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

N,Q=rl()
S=input()
L,R=[0]*Q,[0]*Q
for i in range(Q):
    L[i],R[i] = rl()
s = [0]*(N+2)
ss = [0]*(N+2)
for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        s[i] = 1
        s[i+1] = 1

ss[0] = s[0]
for i in range(1,N):
    ss[i] = ss[i-1] + s[i]

for i in range(Q):
    l,r = L[i],R[i]
    l -= 1
    r -= 1
    res = (ss[r] - ss[l-1])//2
    if s[r]==1 and s[l]==1 and S[r]=='A' and S[l]=='C':
        res -= 1
    print(res)
Buggy python submission (verdict: Time Limit Exceeded):
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

S=input()
N=len(S)

buf = []
ans = 0
for s in S:
    if buf:
        if buf[-1] != s:
            buf = buf[:-1]
            ans += 2
        else:
            buf += s
    else:
        buf += s

print(ans)


Fixed submission:
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

S=input()
N=len(S)

buf = []
h = 0
ans = 0
for s in S:
    if s=='0':
        h -= 1
    else:
        h += 1
ans = N-abs(h)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

S=input()
N=len(S)

buf = []
ans = 0
for s in S:
    if buf:
        if buf[-1] != s:
            buf = buf[:-1]
            ans += 2
        else:
            buf += s
    else:
        buf += s

print(ans)


Fixed submission:
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

S=input()
N=len(S)

buf = []
h = 0
ans = 0
for s in S:
    if s=='0':
        h -= 1
    else:
        h += 1
ans = N-abs(h)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
A,B,Q=list(map(int,input().split()))
s=[0]*(A+2)
t=[0]*(B+2)
X=[0]*Q
s[0] = -float('inf')
s[A+1] = float('inf')
t[0] = -float('inf')
t[B+1] = float('inf')
for i in range(1,A+1):
    s[i] = int(input())
for i in range(1,B+1):
    t[i] = int(input())
for i in range(Q):
    X[i] = int(input())

import bisect


def dec(x,s,t):
    s_ = s-x
    t_ = t-x
    as_ = abs(s_)
    at_ = abs(t_)
    if (s_>0 and t_<0) or (s_<0 and t_>0):
        return as_ + at_ + min(as_, at_)
    else:
        return max(as_,at_)


for x in X:
    s_i = bisect.bisect_left(s,x)
    t_i = bisect.bisect_left(t,x)
    s_l = s[s_i-1]
    s_r = s[s_i]
    t_l = t[t_i-1]
    t_r = t[t_i]
    ans = dec(x,s_l,t_l)
    ans_ = dec(x,s_l,t_r)
    if ans > ans_:
        ans = ans_
    ans_ = dec(x,s_r,t_l)
    if ans > ans_:
        ans = ans_
    ans_ = dec(x,s_r,t_r)
    if ans > ans_:
        ans = ans_
    print(ans)




Fixed submission:
A,B,Q=list(map(int,input().split()))
s=[0]*(A+2)
t=[0]*(B+2)
X=[0]*Q
s[0] = -float('inf')
s[A+1] = float('inf')
t[0] = -float('inf')
t[B+1] = float('inf')
for i in range(1,A+1):
    s[i] = int(input())
for i in range(1,B+1):
    t[i] = int(input())
for i in range(Q):
    X[i] = int(input())

import bisect

for x in X:
    s_i = bisect.bisect_left(s,x)
    t_i = bisect.bisect_left(t,x)
    s_l = abs(s[s_i-1]-x)
    s_r = s[s_i]-x
    t_l = abs(t[t_i-1]-x)
    t_r = t[t_i]-x
    ans = min([max(s_l,t_l),s_l+t_r+min(s_l,t_r),s_r+t_l+min(s_r,t_l),max(s_r,t_r)])

    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
A,B,Q=list(map(int,input().split()))
s=[0]*(A+2)
t=[0]*(B+2)
X=[0]*Q
s[0] = -float('inf')
s[A+1] = float('inf')
t[0] = -float('inf')
t[B+1] = float('inf')
for i in range(1,A+1):
    s[i] = int(input())
for i in range(1,B+1):
    t[i] = int(input())
for i in range(Q):
    X[i] = int(input())

import bisect
import numpy as np

def dec(x,s,t):
    s_ = s-x
    t_ = t-x
    as_ = abs(s_)
    at_ = abs(t_)
    if np.sign(s_)*np.sign(t_) == -1:
        return as_ + at_ + min(as_, at_)
    else:
        return max(as_,at_)


for x in X:
    s_i = bisect.bisect_left(s,x)
    t_i = bisect.bisect_left(t,x)
    s_l = s[s_i-1]
    s_r = s[s_i]
    t_l = t[t_i-1]
    t_r = t[t_i]
    ans = dec(x,s_l,t_l)
    ans_ = dec(x,s_l,t_r)
    if ans > ans_:
        ans = ans_
    ans_ = dec(x,s_r,t_l)
    if ans > ans_:
        ans = ans_
    ans_ = dec(x,s_r,t_r)
    if ans > ans_:
        ans = ans_
    print(ans)




Fixed submission:
A,B,Q=list(map(int,input().split()))
s=[0]*(A+2)
t=[0]*(B+2)
X=[0]*Q
s[0] = -float('inf')
s[A+1] = float('inf')
t[0] = -float('inf')
t[B+1] = float('inf')
for i in range(1,A+1):
    s[i] = int(input())
for i in range(1,B+1):
    t[i] = int(input())
for i in range(Q):
    X[i] = int(input())

import bisect

for x in X:
    s_i = bisect.bisect_left(s,x)
    t_i = bisect.bisect_left(t,x)
    s_l = abs(s[s_i-1]-x)
    s_r = s[s_i]-x
    t_l = abs(t[t_i-1]-x)
    t_r = t[t_i]-x
    ans = min([max(s_l,t_l),s_l+t_r+min(s_l,t_r),s_r+t_l+min(s_r,t_l),max(s_r,t_r)])

    print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]

import math
import itertools

m = min(A)

for v in itertools.combinations(A,2):
    m1 = math.gcd(*v)
    if m > m1:
        m = m1
print(m)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

def gcp(a,b):
    if b == 0:
        return a
    else:
        a,b = b,a%b
        return gcp(a,b)

a = A[0]
for i in range(1,N):
    a = gcp(a,A[i])
print(a)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

print(gcd(*A))

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

def gcp(a,b):
    if b == 0:
        return a
    else:
        a,b = b,a%b
        return gcp(a,b)

a = A[0]
for i in range(1,N):
    a = gcp(a,A[i])
print(a)
Buggy python submission (verdict: Runtime Error):
2 3
2 55
2 77
2 99

Fixed submission:
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

N,M=rl()
P=[0]*M
Y=[0]*M
dic = [[] for _ in range(N+1)]
for i in range(M):
    P[i],Y[i] = rl()
    dic[P[i]] += [Y[i]]

for i in range(N+1):
    dic[i].sort()

import bisect
for i in range(M):
    print("{:0>6}{:0>6}".format(P[i], bisect.bisect_left(dic[P[i]],Y[i])+1))
Buggy python submission (verdict: Time Limit Exceeded):
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

N,M=rl()

if M%N==0:
    print(M//N)
else:
    x = M//N
    ans = 1
    for i in range(x,0,-1):
        if M%i != 0:
            continue
        else:
            ans = i
            break
    print(ans)

Fixed submission:
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

N,M=rl()

if M%N==0:
    print(M//N)
else:
    x = M//N
    ans = 1
    for i in range(x,0,-1):
        if M%i != 0:
            continue
        else:
            ans = i
            break
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

N,M=rl()

if M%N==0:
    print(M//N)
else:
    x = M//N
    ans = 1
    for i in range(x,0,-1):
        if M%i != 0:
            continue
        else:
            if M//i >= N:
                ans = i
                break
    
    print(ans)

Fixed submission:
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

N,M=rl()

if M%N==0:
    print(M//N)
else:
    x = M//N
    ans = 1
    for i in range(x,0,-1):
        if M%i != 0:
            continue
        else:
            ans = i
            break
    print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a.sort()
a_i = a[-1]
max = 0
b = 0
from scipy.misc import comb
for i in a[0:-2]:
    buf = comb(a_i,i)
    if max < buf:
        max = buf
        b = i
    else:
        break
print("{} {}".format(a_i, b))

Fixed submission:
a,b,x = (int(i) for i in input().split())
if a <= x and x <= a + b:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

N=ri()
X=rl()
Xs = sorted(X)
Xsl = Xs[:N//2]
Xsr = Xs[N//2:]

for x in X:
    if x in Xsl:
            print(Xsr[0])
    else:
            print(Xsl[-1])



Fixed submission:
n = int(input())
x = list(map(int,input().split()))
import numpy as np
import copy
md = np.median(x)
x_c = copy.copy(x)
x_c.sort()
a = x_c[int(n/2 - 1)]
b = x_c[int(n/2)]
for i in range(n):
    if x[i] < md:
        print(b)
    else:
        print(a)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int,input().split()))
import numpy as np
import copy
np.median(x)
for i in range(n):
    x_c = copy.copy(x)
    x_c.pop(i)
    print("{}".format(int(np.median(x_c))))


Fixed submission:
n = int(input())
x = list(map(int,input().split()))
import numpy as np
import copy
md = np.median(x)
x_c = copy.copy(x)
x_c.sort()
a = x_c[int(n/2 - 1)]
b = x_c[int(n/2)]
for i in range(n):
    if x[i] < md:
        print(b)
    else:
        print(a)