Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
if __name__ == '__main__':
    N = int(input())
    A = [None]*N
    A = list(map(int, input().split()))
    Alice = 0
    Bob = 0
    while(A):
        Alice += max(A)
        A.remove(max(A))
        Bob += max(A)
        A.remove(max(A))
    print(Alice - Bob)

Fixed submission:
if __name__ == '__main__':
    N = int(input())
    A = [None]*N
    A = list(map(int, input().split()))
    Alice = 0
    Bob = 0
    while(A):
        Alice += max(A)
        A.remove(max(A))
        if A:
            Bob += max(A)
            A.remove(max(A))
    print(Alice - Bob)
Buggy python submission (verdict: Runtime Error):
if __name__ == '__main__':
    N = int(input())
    t = [None]*N
    x = [None]*N
    y = [None]*N
    for i in range(N):
        t[i], x[i], y[i] = map(int, input().split())
    flag=True
    # check first step
    if (t[0] - max(x[0], -x[0]) - max(y[0], -y[0])) %2 != 0 or t[0] < max(x[0], -x[0]) + max(y[0], -y[0]):
        print('No')
        flag = False
    
    for i in range(N):
        delta_t = t[i+1] - t[i]
        delta_x = x[i+1] - x[i]
        if delta_x < 0:
            delta_x = -delta_x
        delta_y = y[i+1] - y[i]
        if delta_y < 0:
            delta_y = -delta_y
        delta = delta_x + delta_y
        if (delta_t - delta) % 2 == 0 and delta_t >= delta:
            continue
        else:
            print('No')
            flag = False
            break
    if flag:
        print('Yes')

Fixed submission:
if __name__ == '__main__':
    N = int(input())
    t = [None]*N
    x = [None]*N
    y = [None]*N
    for i in range(N):
        t[i], x[i], y[i] = map(int, input().split())
    flag=True
    # check first step
    if (t[0] - max(x[0], -x[0]) - max(y[0], -y[0])) %2 != 0 or t[0] < max(x[0], -x[0]) + max(y[0], -y[0]):
        print('No')
        flag = False
    
    for i in range(N-1):
        delta_t = t[i+1] - t[i]
        delta_x = x[i+1] - x[i]
        if delta_x < 0:
            delta_x = -delta_x
        delta_y = y[i+1] - y[i]
        if delta_y < 0:
            delta_y = -delta_y
        delta = delta_x + delta_y
        if (delta_t - delta) % 2 == 0 and delta_t >= delta:
            continue
        else:
            if flag:
                print('No')
                flag = False
            break
    if flag:
        print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
if __name__ == '__main__':
    N, K = map(int, input().split())
    A = [None]*N
    A = list(map(int, input().split()))
    Adict = [0]*N
    for a in A:
        Adict[a-1] += 1
    num = len(set(A))
    while(0 in Adict):
        Adict.remove(0)
    Adict = sorted(Adict,reverse=True)
    count=0
    for _ in range(num - K):
        count += Adict.pop()
    print(count)

Fixed submission:
from collections import defaultdict
if __name__ == '__main__':
    N, K = map(int, input().split())
    A = [None]*N
    A = list(map(int, input().split()))

    Adict = [0]*N
    for a in A:
        Adict[a-1] += 1
    num = len(set(A))

    
    Adict = sorted(Adict,reverse=True)
    count=0
    for _ in range(num - K):
        while True:
            min_num = Adict.pop()
            count += min_num
            if min_num != 0:
                break
    
    print(count)
Buggy python submission (verdict: Runtime Error):
if __name__ = '__main__':
  A, B, C = map(int, input().split())
  if A == B:
    print(C)
  elif A == C:
    print(B)
  else:
    print(A)

Fixed submission:
if __name__ == '__main__':
  A, B, C = map(int, input().split())
  if A == B:
    print(C)
  elif A == C:
    print(B)
  else:
    print(A)
Buggy python submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit = 100000

def get_gcd(A, B):
    r = A%B
    if r == 0:
        return B
    else:
        return get_gcd(B, r)
           
if __name__ == '__main__':
    N = int(input())
    T = [int(input()) for _ in range(N)]
    
    for n in range(N-1):
        gcd = get_gcd(T[n], T[n+1])
        T[n+1] = int(T[n]/gcd)*T[n+1]
        
    print(T[N-1])

Fixed submission:
import sys

sys.setrecursionlimit = 10000000

def get_gcd(A, B):
    r = A%B
    if r == 0:
        return B
    else:
        return get_gcd(B, r)
           
if __name__ == '__main__':
    N = int(input())
    T = [int(input()) for _ in range(N)]
    
    ans = 1
    for t in T:
        gcd = get_gcd(ans, t)
        ans = t//gcd*ans
        
    print(ans)

Buggy python submission (verdict: Runtime Error):
def get_gcd(A, B):
    r = A%B
    if r == 0:
        return B
    else:
        return get_gcd(B, r)

           
if __name__ == '__main__':
    N = int(input())
    T = [int(input()) for _ in range(N)]
    
    for n in range(N-1):
        gcd = get_gcd(T[n], T[n+1])
        T[n+1] = int(T[n]/gcd)*T[n+1]
        
    print(T[N-1])

Fixed submission:
import sys

sys.setrecursionlimit = 10000000

def get_gcd(A, B):
    r = A%B
    if r == 0:
        return B
    else:
        return get_gcd(B, r)
           
if __name__ == '__main__':
    N = int(input())
    T = [int(input()) for _ in range(N)]
    
    ans = 1
    for t in T:
        gcd = get_gcd(ans, t)
        ans = t//gcd*ans
        
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import re
if __name__ == '__main__':
    S = str(input())
while True:
    S_new = re.sub(r'eraser$|erase$|dreamer$|dream$', '', S)
    if S_new == S:
        print('NO')
        break
    elif S_new == '':
        print('YES')
        break
    S = S_new

Fixed submission:
if __name__ == '__main__':
    S = str(input())
    T = ''
    while True:
        if len(S) == 0:
            print('YES')
            break
        elif S[len(S)-7:len(S)] == 'dreamer':
            S = S[:len(S)-7]
            continue
        elif S[len(S)-6:len(S)] == 'eraser':
            S = S[:len(S)-6]
            continue
        elif S[len(S)-5:len(S)] == 'dream':
            S = S[:len(S)-5]
            continue
        elif S[len(S)-5:len(S)] == 'erase':
            S = S[:len(S)-5]
            continue
        else:
            print('NO')
            break
Buggy python submission (verdict: Runtime Error):
N,K = int(input())
p = list(map(int, input().split(" ")))
cnt = 0
for i in range(N):
  if p[i]=="l" and i!=0:
    if p[i]==p[i-1]:
      cnt += 1
  elif p[i]=="r" and i!=N-1:
    if p[i]==p[i+1]:
      cnt += 1
cnt += 2*K
if cnt>=N:
  cnt = N-1
print(cnt)

Fixed submission:
N,K = list(map(int, input().split(" ")))
p = input()
cnt = 0
for i in range(N):
  if p[i]=="L" and i!=0:
    if p[i]==p[i-1]:
      cnt += 1
  elif p[i]=="R" and i!=N-1:
    if p[i]==p[i+1]:
      cnt += 1
cnt += 2*K
if cnt>=N:
  cnt = N-1
print(cnt)
Buggy python submission (verdict: Runtime Error):
import sys

n = int(input())
hs = list(map(int, input().split()))

gap = []
for i in range(n-1):
    if hs[i+1] - hs[i] == 0:
        gap.append(0)
    elif hs[i+1] - hs[i] > 0:
        gap.append(1)
    else:
        gap.append(-1)


maxcount = 0
count = 0
g_prev = gap[0]

for g in gap:
    if g == 1:
        g_prev = g
        continue
    if g == g_prev:
        count += 1
    elif g == 0:
        count += 1
    else:
        if count >= maxcount:
            maxcount = count
        count = 1
    g_prev = g

print(max(count, maxcount))


Fixed submission:
n = int(input())
hs = list(map(int, input().split()))


maxcount = 0
count = 0
for i in range(n-1):
    if hs[i+1] - hs[i] == 0:
        count += 1
    elif hs[i+1] - hs[i] < 0:
        count += 1
    else:
        if count >= maxcount:
            maxcount = count
        count = 0


print(max(count, maxcount))
Buggy python submission (verdict: Time Limit Exceeded):


n = int(input())

# i = np.array([i+1 for i in range(n)])
#
# ps = [i+1 for i in range(1, n)] + [1]
#
# ps = np.array(ps)
#
# ms = i % ps

print(sum([i+1 for i in range(0, n-1)]))


Fixed submission:
n = int(input())

if n == 1:
    print(0)
else:
    ans = n *(n-1) // 2
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input())

i = np.array([i+1 for i in range(n)])

ps = [i+1 for i in range(1, n)] + [1]

ps = np.array(ps)

ms = i % ps

print(np.sum(ms))


Fixed submission:
n = int(input())

if n == 1:
    print(0)
else:
    ans = n *(n-1) // 2
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import json
import hashlib

N = int(input())
c = []

for _ in range(N):
    s = input()
    d = dict(Counter(s))
    ds = sorted(d.items(), key=lambda x:x[0])
    h = hashlib.md5(json.dumps(ds).encode("utf-8")).hexdigest()
    c.append(h)

sum = 0
for i , v in Counter(c).items():
    sum += (v*(v-1)//2)
print(sum)


Fixed submission:
from collections import Counter
import json

N = int(input())
ss = []
c = []

for _ in range(N):
    s = input()
    ss.append("".join(sorted(s)))

sum = 0

for i , v in Counter(ss).items():
    sum += (v*(v-1)//2)
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import json
N = int(input())
c = []

for _ in range(N):
    s = input()
    d = dict(Counter(s))
    ds = sorted(d.items(), key=lambda x:x[0])
    c.append(json.dumps(ds))

res = [c.count(e) for e in set(c) if c.count(e) > 1]

sum = 0
for i in res:
    sum += (i*(i-1)//2)


print(sum)


Fixed submission:
from collections import Counter
import json

N = int(input())
ss = []
c = []

for _ in range(N):
    s = input()
    ss.append("".join(sorted(s)))

sum = 0

for i , v in Counter(ss).items():
    sum += (v*(v-1)//2)
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

N = int(input())
count = []

for _ in range(N):
    s = input()
    count.append(Counter(s))

ans = 0
for i in range(N):
    for j in range(i+1, N):
        if(count[i] == count[j]):
            ans += 1

print(ans)


Fixed submission:
from collections import Counter
import json

N = int(input())
ss = []
c = []

for _ in range(N):
    s = input()
    ss.append("".join(sorted(s)))

sum = 0

for i , v in Counter(ss).items():
    sum += (v*(v-1)//2)
print(sum)
Buggy python submission (verdict: Runtime Error):
import itertools

N, k = map(int, input().split())



bits = [format(i,'b').zfill(N) for i in range(2**N)]

ans = [0 for i in range(k)]

for item in bits:
    if item.count('1') != k:
        continue;
    else:
        i_prev = "0"
        count = 0
        for i in item:
            if i == "1" and i_prev == "0":
                count += 1
            i_prev = i
        ans[count-1] += 1

# for i in ans:
#     print(i % 1000000007 )

print(ans)


Fixed submission:

s = input()

a = s.count(s[0])
b = s.count(s[1])
c = s.count(s[2])
d = s.count(s[3])

if(a==b==c==d==2):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import math

a, b, c, d = map(int, input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

cd = lcm(c, d)

div_c = b // c - (a-1)//c
div_d = b // d - (a-1)//d
div_cd = b // cd - (a-1)//cd
count = b - a + 1 - div_c - div_d + div_cd
print(count)


Fixed submission:


a, b, c, d = map(int, input().split())


def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

cd = lcm(c, d)

div_c = b // c - (a-1)//c
div_d = b // d - (a-1)//d
div_cd = b // cd - (a-1)//cd
count = b - a + 1 - div_c - div_d + div_cd
print(count)
Buggy python submission (verdict: Runtime Error):
# https://img.atcoder.jp/abc131/editorial.pdf

import sys

n, k = map(int, input().split())

# n個の頂点から2つ選ぶ組み合わせ
comb = n*(n-1)/2

v = comb - (n-1)

# そのうちn-1組は距離１なので...
if k > v:
    print(-1)
    sys.exit()

# それ以外の場合(k <= comb - (n-1))は必ず解がある
# 「うに」を考える

add_edge = v - k

m = n - 1 + add_edge
print(m)

# まずはうにの辺を出力（n-1本）, １はうにの中心
for i in range(n-1):
    print(1, 2+i)

# その後 add_edgeを出力
for i in range(add_edge):
    start = 2*i + 2
    end = start+1
    print(start, end)


Fixed submission:
# https://img.atcoder.jp/abc131/editorial.pdf

import sys

n, k = map(int, input().split())

maxPossible = (n-2) * (n-1) // 2

if k > maxPossible:
    print(-1)
    sys.exit()
ret = []

# うに(1が中心)
for i in range(2, n+1):
    ret.append((1, i))

# maxPossible - k 個の辺を追加
count = 0
for i in range(2, n+1):
    if count == maxPossible - k:
        break
    for j in range(i+1, n+1):
        ret.append((i, j))
        count += 1
        if count == maxPossible - k:
            break

print(len(ret))
for u, v in ret:
    print(u, v)
Buggy python submission (verdict: Runtime Error):
# 尺取り法
import sys

def input():
    return sys.stdin.readline()[:-1]

N, K = map(int, input().split())
a = list(map(int, input().split()))

count = 0
right = 0
sum = 0
for left in range(N):
    while(sum < K):
        if right == N:
            break
        else:
            sum += a[right]
            right += 1
    if sum < K:
        break
    count += N - right + 1
    sum -= a[left]

print(count)


Fixed submission:

X, A = map(int, input().split())

if(X < A):
    print(0)
else:
    print(10)

Buggy python submission (verdict: Runtime Error):
import sys

def input():
    return sys.stdin.readline()[:-1]

N, K = map(int, input().split())
a = list(map(int, input().split()))

from itertools import accumulate
count = 0
acum = list(accumulate(a))

for i in range(N-1, -1, -1):
    if acum[i] >= K:
        count += 1
    else:
        break

for i in range(N):
    for j in range(N-1, i, -1):
        s = acum[j]-acum[i]
        if s >= K:
            count += 1
        else:
            break

print(count)


Fixed submission:

X, A = map(int, input().split())

if(X < A):
    print(0)
else:
    print(10)
Buggy python submission (verdict: Runtime Error):

import sys

def input():
    return sys.stdin.readline()[:-1]

n, m = map(int, input().split())

# 0 - n-1
a = sorted(list(map(int, input().split())))

for j in range(m):
    b, newVal = map(int, input().split())
    if b >= n:
        a_new = [i if i >= newVal else newVal for i in a]
    else:
        mae = a[:b]
        ato = a[b:]
        mae_new = [i if i >= newVal else newVal for i in mae]
        mae_new.extend(ato)
        a = sorted(mae_new)

print(sum(a))

Fixed submission:
a, b = map(int, input().split())

if a >= 13:
    print(b)
elif a >= 6:
    print(int(b/2))
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

n, m = map(int, input().split())

x = list(map(int, input().split()))

gap = []


if( n >= m):
    print(0)
    sys.exit()
else:
    x = sorted(x)
    for i in range(m-1):
        gap.append(x[i+1] - x[i])
        gaps = sorted(gap)

print(sum(gaps[:m-n]))


Fixed submission:
import sys

n, m = map(int, input().split())

x = list(map(int, input().split()))

gap = []


if( n >= m):
    print(0)
    sys.exit()
else:
    x = sorted(x)
    for i in range(m-1):
        gap.append(x[i+1] - x[i])
    gaps = sorted(gap)

print(sum(gaps[:m-n]))

Buggy python submission (verdict: Time Limit Exceeded):
import sys

n, m = map(int, input().split())

x = list(map(int, input().split()))

gap = []


if( n >= m):
    print(0)
    sys.exit()
else:
    x = sorted(x)
    for i in range(m-1):
        gap.append(x[i+1] - x[i])
        gaps = sorted(gap)



print(sum(gaps[:m-n]))


Fixed submission:
import sys

n, m = map(int, input().split())

x = list(map(int, input().split()))

gap = []


if( n >= m):
    print(0)
    sys.exit()
else:
    x = sorted(x)
    for i in range(m-1):
        gap.append(x[i+1] - x[i])
    gaps = sorted(gap)

print(sum(gaps[:m-n]))
Buggy python submission (verdict: Runtime Error):
N = int(intput())

sum = 0
max = 0
for _ in range(N):
  p = int(intput())
  if(p > max):
    max = p
  sum += p
val = sum - max/2
print(int(val))

Fixed submission:
N = int(input())
 
sum = 0
max = 0
for _ in range(N):
  p = int(input())
  if(p > max):
    max = p
  sum += p
val = sum - max/2
print(int(val))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
N,Q = map(int,input().split())
S = input()
p = set()
for n,i in enumerate(S[:-1]):
    if i == "A" and S[n+1]=="C":
        p.add(n)
#print(p)
for i in range(Q):
    a,b = map(int,input().split())
    #tmp = {}
    # tmp = {i for i in range(a-1,b-1)}
    # print(tmp)
    # print(len(tmp&p))
    count=0
    for j in p:
        #print("j",j)
        if a <= j+1 and j+1 < b:
            count+=1
        elif j > b:
            break
    print(count)

Fixed submission:

a = input()
if a == "A":
    print("T")
elif a == "T":
    print("A")
elif a == "G":
    print("C")
else:
    print("G")
Buggy python submission (verdict: Runtime Error):
N,Q = map(int,input().split())
S = input()
p = [0]*(N+1)
a = 0
for i in range(-1,N-1):
    if S[i+1] == "A" and S[i+2]=="C":
        a+=1
    p[i+2]=a
#print(p)
for i in range(Q):
    a,b = map(int,input().split())
    print(p[b-1] - p[a-1])

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

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = input()
p = set()
for n,i in enumerate(S[:-1]):
    if i == "A" and S[n+1]=="C":
        p.add(n)
#print(p)
for i in range(Q):
    a,b = map(int,input().split())
    #tmp = {}
    # tmp = {i for i in range(a-1,b-1)}
    # print(tmp)
    # print(len(tmp&p))
    count=0
    for j in p:
        #print("j",j)
        if a <= j+1 and j+1 < b:
            count+=1
    print(count)

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

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
N,Q = map(int,input().split())
S = input()
p = set()
for n,i in enumerate(S[:-1]):
    if i == "A" and S[n+1]=="C":
        p.add(n)
#print(p)
for i in range(Q):
    a,b = map(int,input().split())
    tmp = {}
    tmp = {i for i in range(a-1,b-1)}
#    print(tmp)
    print(len(tmp&p))

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

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

Fixed submission:
N,Q = map(int,input().split())
S = input()
p = [0]*(N)
a = 0
for i in range(-1,N-2):
    if S[i+1] == "A" and S[i+2]=="C":
        a+=1
    p[i+2]=a
#print(p)
for i in range(Q):
    a,b = map(int,input().split())
    print(p[b-1] - p[a-1])
Buggy python submission (verdict: Runtime Error):
A = int(input())
ls = [int(input())%2 for i in range(A)]
if ls.count(1) % 2 == 1 or (A % 2 == 0 and s.count(1) % 2 == 0):
    print("first")
else:
    print("second")

Fixed submission:
A = int(input())
ls = [int(input())%2 for i in range(A)]
if ls.count(1) != 0:
    print("first")
else:
    print("second")
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
count=0
for i in range(len(S)):
    if S[i] =="W":
        count+=S.count("B",0,i)
print(count)

Fixed submission:

S = input()
count=0
w=0
for i in range(len(S)):
    if S[i] =="W":
        count+=i-w
        w+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

S = input()
count,chk_count=0,0
for i in range(sys.maxsize):
    chk_count=count
    count+=S.count("BW")
    S=S.replace("BW","WB")
    if chk_count == count:
        print(count)
        exit()

Fixed submission:

S = input()
count=0
w=0
for i in range(len(S)):
    if S[i] =="W":
        count+=i-w
        w+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

S = list(input())
count,chk_count=0,0
for i in range(sys.maxsize):
    chk_count=count
    for j in range(len(S)-1):
        if S[j]=="B" and S[j+1]=="W":
            S[j],S[j+1] ="W","B"
            count+=1
    if chk_count == count:
        print(count)
        exit()

Fixed submission:

S = input()
count=0
w=0
for i in range(len(S)):
    if S[i] =="W":
        count+=i-w
        w+=1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = input().split()
P = []
for i in range(int(N[1])):
    P.append(list(map(int, input().split())))
#print(P)
K = sorted(P)
#print(K)
for i, n in enumerate(P):

#	print("K,n",K,n[1])
#	print(K.index(n))
	tmp = 0;
	for i in range(0,K.index(n)+1):
		#print("K[i]",K[i])
		if K[i][0] == n[0]:
			tmp+=1
	print("{:0=6}".format(int(n[0]))+"{:0=6}".format(tmp))
	#print(n[0])

Fixed submission:
N = input().split()
count = [0] * int(int(N[0])+1)
P = []
ans = []
for i in range(int(N[1])):
	p,y = map(int, input().split())
	P.append((y,p,i))
# print(P)
K = sorted(P)
# print(K)
for y,p,i in K:
	count[p] += 1
	ans.append((i,p,count[p]))

ans.sort()
for i,p,count in ans:
	print("{:0=6}".format(int(p))+"{:0=6}".format(count))
Buggy python submission (verdict: Runtime Error):
import math
N,T  = list(map(int,input().split()))
#d = int(T / N)
m = []
def ans():
    for i in range(1,int(math.sqrt(T))):    
            if T % i ==0:
                m.append(i)
    print (m[-1])
if T % N == 0:
    print (d)
else:
    ans()
    

Fixed submission:
N,T  = list(map(int,input().split()))
d = int(T / N)
def ans():
    for i in range(d+1,0,-1):    
            if T % i ==0:
                print(i)
                break
if T % N == 0:
    print (d)
else:
    ans()

Buggy python submission (verdict: Runtime Error):
import math
N,T  = list(map(int,input().split()))
#d = int(T / N)
m = 1
def ans():
    for i in range(1,int(math.sqrt(T))):    
            if T % i ==0:
                m = max(1,i)
    print (m)
if T % N == 0:
    print (d)
else:
    ans()
    

Fixed submission:
N,T  = list(map(int,input().split()))
d = int(T / N)
def ans():
    for i in range(d+1,0,-1):    
            if T % i ==0:
                print(i)
                break
if T % N == 0:
    print (d)
else:
    ans()

Buggy python submission (verdict: Time Limit Exceeded):
N,T  = list(map(int,input().split()))
d = int(T / N)
if T % N == 0:
    print (d)


else:
    for i in range(d+1,0,-1):    
        if T % i ==0:
            print(i)
            break
   

Fixed submission:
N,T  = list(map(int,input().split()))
d = int(T / N)
def ans():
    for i in range(d+1,0,-1):    
            if T % i ==0:
                print(i)
                break
if T % N == 0:
    print (d)
else:
    ans()

Buggy python submission (verdict: Time Limit Exceeded):
N,T  = map(int,input().split())
d = int(T / N)
if T % N == 0:
    print (d)


else:
    for i in range(d+1,0,-1):    
        if T % i ==0:
            print(i)
            break

Fixed submission:
N,T  = list(map(int,input().split()))
d = int(T / N)
def ans():
    for i in range(d+1,0,-1):    
            if T % i ==0:
                print(i)
                break
if T % N == 0:
    print (d)
else:
    ans()

Buggy python submission (verdict: Time Limit Exceeded):
N,T  = map(int,input().split())
if T % N == 0:
    print (int(T / N))


else:
    d = int(T / N)
    for i in range(d+1,0,-1):    
        if T % i ==0:
            print(i)
            break
   

Fixed submission:
N,T  = list(map(int,input().split()))
d = int(T / N)
def ans():
    for i in range(d+1,0,-1):    
            if T % i ==0:
                print(i)
                break
if T % N == 0:
    print (d)
else:
    ans()

Buggy python submission (verdict: Runtime Error):
N,T  = map(int,input().split())
if T % N == 0:
    print (int(T / N))

d = int(T / N)
else:
    for i in range(d+1,0,-1):    
        if T % i ==0:
            print(i)
            break

Fixed submission:
N,T  = list(map(int,input().split()))
d = int(T / N)
def ans():
    for i in range(d+1,0,-1):    
            if T % i ==0:
                print(i)
                break
if T % N == 0:
    print (d)
else:
    ans()