Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math

def lcm(a,b):
    res = a*b / math.gcd(a,b)
    return res
def ll(x,y,z):
    res = x
    res -= x/y
    res -= x/z
    res += x/lcm(y,z)
    return res
A, B, C, D = map(int, input().split())
ans = ll(B,C,D) - ll(A-1,C,D)
print(int(ans))

Fixed submission:
import fractions

def lcm(a,b):
    res = a*b // fractions.gcd(a,b)
    return res
def f(x,y,z):
    res = x
    res -= x//y
    res -= x//z
    res += x//lcm(y,z)
    return res


A, B, C, D = map(int, input().split())
ans1 = f(B,C,D)
ans2 = f(A-1,C,D)
ans = ans1 - ans2
print(int(ans))

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

def lcm(a,b):
    res = a*b / math.gcd(a,b)
    return res


def ll(x,y,z):
    res = x
    res -= x/y
    res -= x/z
    res += x/lcm(y,z)
    return res


A, B, C, D = map(int, input().split())
ans = ll(B,C,D) - ll(A-1,C,D)
print(int(ans))

Fixed submission:
import fractions

def lcm(a,b):
    res = a*b // fractions.gcd(a,b)
    return res
def f(x,y,z):
    res = x
    res -= x//y
    res -= x//z
    res += x//lcm(y,z)
    return res


A, B, C, D = map(int, input().split())
ans1 = f(B,C,D)
ans2 = f(A-1,C,D)
ans = ans1 - ans2
print(int(ans))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
dp = [int(input()) for i in range(N+1)]
for i in range(M):
    A = int(input())
    dp[A] = -1
dp[0] = 1
for j in range(2, N + 1):
    if dp[j] == -1:
        dp[j] = 0
        continue
    dp[j] = dp[j-2] + dp[j-1]

print(dp[N] % 1000000007)

Fixed submission:
N, M = map(int, input().split())
dp = [0 for i in range(N+1)]
for i in range(M):
    A = int(input())
    dp[A] = -1
dp[0] = 1
if dp[1] != -1:
    dp[1] = 1
else:
    dp[1] = 0
for j in range(2, N + 1):
    if dp[j] == -1:
        dp[j] = 0
        continue
    dp[j] = dp[j-2] + dp[j-1]

print(dp[N] % 1000000007)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
dp = [int(input()) for i in range(N+1)]
for i in range(M):
    A = int(input())
    dp[A] = -1
dp[0] = 1
for j in range(2, N + 1):
    if dp[j] == -1:
        dp[j] = 0
        continue
    dp[i] = dp[i-2] + dp[i-1]

print(dp[N] % 1000000007)

Fixed submission:
N, M = map(int, input().split())
dp = [0 for i in range(N+1)]
for i in range(M):
    A = int(input())
    dp[A] = -1
dp[0] = 1
if dp[1] != -1:
    dp[1] = 1
else:
    dp[1] = 0
for j in range(2, N + 1):
    if dp[j] == -1:
        dp[j] = 0
        continue
    dp[j] = dp[j-2] + dp[j-1]

print(dp[N] % 1000000007)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))
d = {}
for i in l:
    d[i]=l.count(i)
cp = 0
for i in d.values():
    cp+= i*(i-1)//2
for i in l:
    print(cp-d[i]+1)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
d = {}
for i in l:
    if i in d:
        d[i]+=1
    else:
        d[i] = 1
cp = 0
for i in d.values():
    cp+= i*(i-1)//2
for i in l:
    print(cp-d[i]+1)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
if len(set(s))==1:
    print(0)
else:
    count = 0
    while True:
        if s[-1]=='W':
            k = 0
            for i in range(-1,len(s)*(-1),-1):
                if s[i]=='B':
                    k = i
                    break
            s = s[0:k+1]+'B'*(k*(-1))+'B'
            count+=1
        elif s[-1]=='B':
            k = 0
            for i in range(-1,len(s)*(-1),-1):
                if s[i]=='W':
                    k = i
                    break
            s = s[0:k+1]+'W'*(k*(-1))+'W'
            count+=1
        if len(set(s))==1:
            break
    print(count)

Fixed submission:
s = input()
count = 0
for i in range(len(s)-1):
    if s[i]!=s[i+1]:
        count+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
if len(set(s))==1:
    print(0)
else:
    count = 0
    while True:
        if s[-1]=='W':
            k = 0
            for i in range(-1,len(s)*(-1),-1):
                if s[i]=='B':
                    k = i
                    break
            s = s[0:k+1]+'B'*(k*(-1))+'B'
            count+=1
        elif s[-1]=='B':
            k = 0
            for i in range(-1,len(s)*(-1),-1):
                if s[i]=='W':
                    k = i
                    break
            s = s[0:k+1]+'W'*(k*(-1))+'W'
            count+=1
        if len(set(s))==1:
            break
    print(count)

Fixed submission:
s = input()
count = 0
for i in range(len(s)-1):
    if s[i]!=s[i+1]:
        count+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
if len(set(s))==1:
    print(0)
else:
    count = 0
    while True:
        if s[-1]=='W':
            k = 0
            for i in range(-1,len(s)*(-1),-1):
                if s[i]=='B':
                    k = i
                    break
            s = s[0:k+1]+'B'*(k*(-1))+'B'
            count+=1
        elif s[-1]=='B':
            k = 0
            for i in range(-1,len(s)*(-1),-1):
                if s[i]=='W':
                    k = i
                    break
            s = s[0:k+1]+'W'*(k*(-1))+'W'
            count+=1
        if len(set(s))==1:
            break
    print(count)

Fixed submission:
s = input()
count = 0
for i in range(len(s)-1):
    if s[i]!=s[i+1]:
        count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
import sys

n,k = list(map(int, input().split()))
l = list(map(int, input().split()))
dp = [sys.maxsize]*n
dp[0]=0
# for i in range(1,n):
#     for j in range(1,k+1):
#         if i-j>=0:
#             dp[i]=min(dp[i],dp[i-j]+abs(l[i]-l[i-j]))
dp[1] = abs(l[1]-l[0])
for i in range(2,n):
    if i-j>=0:
        dp[i]=min(dp[i],dp[i-j]+abs(l[i]-l[i-j]))
print(dp[n-1])

Fixed submission:
import sys

n,k = list(map(int, input().split()))
l = list(map(int, input().split()))
dp = [sys.maxsize]*n
dp[0]=0
for i in range(1,n):
    for j in range(1,k+1):
        if i-j>=0:
            dp[i]=min(dp[i],dp[i-j]+abs(l[i]-l[i-j]))   
print(dp[n-1])

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

n,k = list(map(int, input().split()))
l = list(map(int, input().split()))
dp = [sys.maxsize]*n
dp[0]=0
# dp[1] = abs(l[1]-l[0])
for i in range(1,n):
    for j in range(1,k+1):
        if i-j>=0:
            dp[i]=min(dp[i],dp[i-j]+abs(l[i]-l[i-j]))
print(dp[n-1])

Fixed submission:
import sys

n,k = list(map(int, input().split()))
l = list(map(int, input().split()))
dp = [sys.maxsize]*n
dp[0]=0
for i in range(1,n):
    for j in range(1,k+1):
        if i-j>=0:
            dp[i]=min(dp[i],dp[i-j]+abs(l[i]-l[i-j]))   
print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
dp=[0]*3
cost=[0]*3
for _ in range(n):
    l = list(map(int, input().split()))
    for i in range(3):
        for j in range(3):
            if i!=j:
                dp[i]=max(dp[i],l[i]+cost[j])
    cost=dp.copy()
print(max(dp[0],max(dp[1],dp[2])))



Fixed submission:
n = int(input())
dp=[0]*3
cost=[0]*3
for _ in range(n):
    l = list(map(int, input().split()))
    for i in range(3):
        for j in range(3):
            if i!=j:
                dp[i]=max(dp[i],l[i]+cost[j])
    cost=dp.copy()
print(max(dp[0],max(dp[1],dp[2])))

Buggy python submission (verdict: Runtime Error):
n = int(input())
dp=[0]*3
cost=[0]*3
for _ in range(n):
    l = list(map(int, input().split()))
    for i in range(3):
        for j in range(3):
            if i!=j:
                dp[i]=max(dp[i],l[i]+cost[j])
    cost=dp.copy()
print(max(dp[0],max(dp[1],dp[2])))



Fixed submission:
n = int(input())
dp=[0]*3
cost=[0]*3
for _ in range(n):
    l = list(map(int, input().split()))
    for i in range(3):
        for j in range(3):
            if i!=j:
                dp[i]=max(dp[i],l[i]+cost[j])
    cost=dp.copy()
print(max(dp[0],max(dp[1],dp[2])))
Buggy python submission (verdict: Time Limit Exceeded):
n,c = list(map(int, input().split()))
W=[]
P=[]
for _ in range(n):
    w,val = list(map(int, input().split()))
    W.append(w)
    P.append(val)
dp=[]
for i in range(n+1):
    dp.append([0]*(c+1))
for i in range(1,n+1):
    for j in range(1,c+1):
        inc=0
        exc=0
        if j-W[i-1]>=0:
            inc=P[i-1]+dp[i-1][j-W[i-1]]
        exc=dp[i-1][j]
        dp[i][j]=max(inc,exc)
print(dp[n][c])

Fixed submission:
n,c = list(map(int, input().split()))
W=[]
P=[]
for _ in range(n):
    w,val = list(map(int, input().split()))
    W.append(w)
    P.append(val)
dp=[]
for i in range(n+1):
    dp.append([0]*(c+1))
for i in range(1,n+1):
    for j in range(1,c+1):
        inc=0
        exc=0
        if j-W[i-1]>=0:
            inc=P[i-1]+dp[i-1][j-W[i-1]]
        exc=dp[i-1][j]
        dp[i][j]=max(inc,exc)
print(dp[n][c])
Buggy python submission (verdict: Runtime Error):
def f(x):
    ans=0
    for e in d[x]:
        ans=max(ans,1+f(e))
    return ans

n,m = list(map(int, input().split()))
d={}
for i in range(1,n+1):
    d[i]=[]
for _ in range(m):
    a,b = list(map(int, input().split()))
    d[a].append(b)
ans=0
for i in range(1,n+1):
    ans=max(ans,f(i))
print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(10**9)

def f(x):
    if dp[x]!=-1:
        return dp[x]
    ans=0
    for e in d[x]:
        ans=max(ans,1+f(e))
    dp[x]=ans
    return ans

n,m = list(map(int, input().split()))
d={}
dp=[-1]
for i in range(1,n+1):
    d[i]=[]
    dp.append(-1)
for _ in range(m):
    a,b = list(map(int, input().split()))
    d[a].append(b)
ans=0
for i in range(1,n+1):
    ans=max(ans,f(i))
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)

def f(l,beg,end):
    if beg==end:
        dp[beg][end]=l[beg]
        return l[beg]
    # if beg+1==end:
    #     return max(l[beg],l[end])
    if dp[beg][end]!=-1:
        return dp[beg][end]
    ans1=l[beg]+min(f(l,beg+2,end),f(l,beg+1,end-1))
    ans2=l[end]+min(f(l,beg,end-2),f(l,beg+1,end-1))
    dp[beg][end]=max(ans1,ans2)
    return max(ans1,ans2)

n = int(input())
l = list(map(int, input().split()))
tl = sum(l)
dp=[]
for _ in range(n):
    dp.append([-1]*n)
a = f(l,0,n-1)
b = tl-a
print(a-b)
print(dp)

Fixed submission:
import sys

def f(l,beg,end):
    if beg==end:
        dp[beg][end]=l[beg]
        return l[beg]
    if beg+1==end:
        dp[beg][end] = max(l[beg],l[end]) 
        return max(l[beg],l[end])
    if dp[beg][end]!=-1:
        return dp[beg][end]
    ans1=l[beg]+min(f(l,beg+2,end),f(l,beg+1,end-1))
    ans2=l[end]+min(f(l,beg,end-2),f(l,beg+1,end-1))
    dp[beg][end]=max(ans1,ans2)
    return max(ans1,ans2)

n = int(input())
l = list(map(int, input().split()))
tl = sum(l)
dp=[]
for _ in range(n):
    dp.append([-1]*n)
a = f(l,0,n-1)
b = tl-a
print(a-b)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

def count_substring(s):
    found_remainder = defaultdict(int)
    current_mod = 0
    found_remainder[0] = 1

    output = 0
    for i in range(len(s)-1,-1,-1):
        digit = s[i]
        current_mod =  (int(digit)*10**(len(s)-1-i) % 2019 + current_mod) % 2019
        output += found_remainder[current_mod]
        found_remainder[current_mod] += 1

    return output

s = input()
print(count_substring(s))


Fixed submission:
from collections import defaultdict

def get_modulos():
    modulos = []
    for i in range(224):
        modulos.append(10**i%2019)
    return modulos

def count_substring(s):
    found_remainder = defaultdict(int)
    current_mod = 0
    found_remainder[0] = 1

    output = 0

    modulos = get_modulos()
    for i in range(len(s)-1,-1,-1):
        digit = s[i]
        current_mod =  (int(digit)*modulos[(len(s)-1-i)%224] % 2019 + current_mod) % 2019
        # print(i, current_mod)
        output += found_remainder[current_mod]
        found_remainder[current_mod] += 1
    #print(dict(found_remainder))

    return output

s = input()
print(count_substring(s))
Buggy python submission (verdict: Runtime Error):
def main():
	a,b,c = [int(x) for x in input().split()]
	a, b = b, a
	a, c = c, a
    print(a, b, c)

main()

Fixed submission:
def main():
	a,b,c = [int(x) for x in input().split()]
	a, b = b, a
	a, c = c, a
	print(a, b, c)
    
main()

Buggy python submission (verdict: Runtime Error):
def main():
	a,b,c = [int(x) for x in input().split()]
    a, b = b, a
    a, c = c, a
  	print(a, b, c)

main()

Fixed submission:
def main():
	a,b,c = [int(x) for x in input().split()]
	a, b = b, a
	a, c = c, a
	print(a, b, c)
    
main()
Buggy python submission (verdict: Runtime Error):
from collections import deque
def main(k):
    q = deque([])
    for i in range(1, 10):
        q.append(i)
    
    count = 0
    top = -1
    
    while True:
        top = q.popleft()

        count += 1
        if count == k:
            return top

        if top%10 != 0:
            q.append(top*10 + top%10-1)
        q.append(top*10 + top%10)
        if top%10 != 9:
            q.append(top*10 + top%10 + 1)

    return top

main(k)

Fixed submission:
from collections import deque
def main(k):
    q = deque([])
    for i in range(1, 10):
        q.append(i)
    
    count = 0
    top = -1
    
    while True:
        top = q.popleft()
 
        count += 1
        if count == k:
            return top
 
        if top%10 != 0:
            q.append(top*10 + top%10-1)
        q.append(top*10 + top%10)
        if top%10 != 9:
            q.append(top*10 + top%10 + 1)
 
    return top
k = int(input())
print(main(k))
Buggy python submission (verdict: Runtime Error):
k = int(input())
x, y = [int(i) for i in raw_input().split()]
 
def solve(k, x, y):
    if x < 0:
        x = -x
    if y < 0:
        y = -y
 
    if x==0 and y==0:
        print 0
        return
 
    if (x-y)%2==1 and k%2==0:
        print -1
        return
 
    output = [(x,y)]
    while True:
        # print 'while', x,y
        if x+y == k:
            break
        if x==0 and y == 0:
            break
        if x+y<k:
            output.append((abs((x-y)/2), k - abs((x-y)/2)))
            x, y = abs((x-y)/2), k - abs((x-y)/2)
 
        elif x+y <2*k:
            output.append((abs((x-y)/2), k - abs((x-y)/2)))
            x, y = abs((x-y)/2), k - abs((x-y)/2)
            # print 'x,y',x,y
        elif x > k:
            x -= k
            output.append((x,y))
        elif y > k:
            y -= k
            output.append((x,y))
        else:
            x = 0
            y -= x
            output.append((x,y))
 
    print len(output)
 
    for (a,b) in output[::-1]:
        print a, b
 
# k=4
# x,y=9,9
solve(k, x, y)


Fixed submission:
a, b = [int(i) for i in raw_input().split()]

if abs(a-b)%2==1:
  print "IMPOSSIBLE"
else:
  print (a+b)/2
Buggy python submission (verdict: Runtime Error):
N = int(i)
inp = [int(i) for i in raw_input().split()]

sorted_inp = sorted(inp)

diff = 0

for i in range(len(inp)):
  if inp[i] != sorted_inp[i]:
    diff += 1

if diff ==  or diff==2:
  print "YES"
else:
  print "NO"

Fixed submission:
N = int(raw_input())
inp = [int(i) for i in raw_input().split()]

sorted_inp = sorted(inp)

diff = 0

for i in range(len(inp)):
  if inp[i] != sorted_inp[i]:
    diff += 1

if diff == 0 or diff==2:
  print "YES"
else:
  print "NO"

Buggy python submission (verdict: Runtime Error):
inp = [int(i) for i in raw_input().split()]

sorted_inp = sorted(inp)

diff = 0

for i in range(len(inp)):
  if inp[i] != sorted_inp[i]:
    diff += 1

if diff ==  or diff==2:
  print "YES"
else:
  print "NO"

Fixed submission:
N = int(raw_input())
inp = [int(i) for i in raw_input().split()]

sorted_inp = sorted(inp)

diff = 0

for i in range(len(inp)):
  if inp[i] != sorted_inp[i]:
    diff += 1

if diff == 0 or diff==2:
  print "YES"
else:
  print "NO"

Buggy python submission (verdict: Runtime Error):
inp = [int(i) for i in raw_input().split()]

sorted_inp = sorted(inp)

diff = 0

for i in range(len(inp)):
	if inp[i] != sorted_inp[i]:
      diff += 1

if diff ==  or diff==2:
  print "YES"
else:
  print "NO"

Fixed submission:
N = int(raw_input())
inp = [int(i) for i in raw_input().split()]

sorted_inp = sorted(inp)

diff = 0

for i in range(len(inp)):
  if inp[i] != sorted_inp[i]:
    diff += 1

if diff == 0 or diff==2:
  print "YES"
else:
  print "NO"
Buggy python submission (verdict: Runtime Error):
print(vacation_planning(a,b,c))

Fixed submission:
n = int(raw_input())

a = []
b = []
c = []

for _ in range(n):
    ai, bi, ci = [int(i) for i in raw_input().split()]
    a.append(ai)
    b.append(bi)
    c.append(ci)


def vacation_planning(a,b,c):
    n = len(a)
    fa = [0] * n 
    fb = [0] * n
    fc = [0] * n

    fa[0] = a[0]
    fb[0] = b[0]
    fc[0] = c[0]

    for i in range(1, n):
        fa[i] = a[i] + max(fb[i-1], fc[i-1])
        fb[i] = b[i] + max(fa[i-1], fc[i-1])
        fc[i] = c[i] + max(fa[i-1], fb[i-1])

    return max(fa[-1], fb[-1], fc[-1])

print(vacation_planning(a,b,c))
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = str(input())
rn = s.count("R")
gn = s.count("G")
bn = s.count("B")

ct=0
for i in range(n):
  for j in range(i+1,n):
    k = 2*j - i
    if k = n:
      break
    elif s[i]!=s[j] and s[j]!=s[k]and s[i]!=s[k]:
      ct += 1
 
print(rn*gn*bn-ct)

Fixed submission:
n = int(input())
s = str(input())
rn = s.count("R")
gn = s.count("G")
bn = s.count("B")

ct=0
for i in range(n):
  for j in range(i+1,n):
    if 2*j - i >= n:
      break
    elif s[i]!=s[j] and s[j]!=s[2*j-i] and s[i]!=s[2*j-i]:
      ct += 1
 
print(rn*gn*bn-ct)
Buggy python submission (verdict: Time Limit Exceeded):
#横にn個入力
n, k = map(int, input().split())
a = input().split()
a = [int(m) for m in a]
nli = []
b = 0
for i in range(n):
    for j in range(i, n):
        b += a[j]
        nli.append(b)
    b = 0
nli.sort(reverse=True)
m = 40
x = 0

cnt = 0
candili = []
for i in range(m - 1, 0, -1):
    if x == 0:
        for j in range(len(nli)):
            if nli[j] & (x + 2 ** i) == x + 2 ** i:
                candili.append(nli[j])
                cnt += 1
        if cnt >= k:
            x += 2 ** i
            cnt = 0
        else:
            cnt = 0
            candili = []
    else:
        for j in candili:
            if j & (x + 2 ** i) == x + 2 ** i:
                cnt += 1
        if cnt >= k:
            x += 2 ** i
            cnt = 0
        else:
            cnt = 0
print(x)

Fixed submission:
#横にn個入力
n, k = map(int, input().split())
a = input().split()
a = [int(m) for m in a]
nli = []
b = 0
for i in range(n):
    for j in range(i, n):
        b += a[j]
        nli.append(b)
    b = 0
nli.sort(reverse=True)
m = 41
x = 0

cnt = 0
candili = []
for i in range(m - 1, -1, -1):
    if x == 0:
        for j in range(len(nli)):
            if nli[j] & (x + 2 ** i) == x + 2 ** i:
                candili.append(nli[j])
                cnt += 1
        if cnt >= k:
            x += 2 ** i
            cnt = 0
        else:
            cnt = 0
            candili = []
    else:
        for j in candili:
            if j & (x + 2 ** i) == x + 2 ** i:
                cnt += 1
        if cnt >= k:
            x += 2 ** i
            cnt = 0
        else:
            cnt = 0
print(x)
Buggy python submission (verdict: Runtime Error):
n = int(input())

w = [(list(map(int, input().split()))) for i in range(n)]#x,y,h

for cx in range(101):
    for cy in range(101):
        for i in range(n):
            if w[i][2] > 0:
                if i == 0:
                    hcon1 = abs(w[i][0] - cx) + abs(w[i][1] - cy) + w[i][2]
                elif i != 0 and i != n - 1:
                    hcon2 = abs(w[i][0] - cx) + abs(w[i][1] - cy) + w[i][2]
                    if hcon1 != hcon2:
                        break
                    else:
                        hcon1 = hcon2
                else:
                    hcon2 = abs(w[i][0] - cx) + abs(w[i][1] - cy) + w[i][2]
                    if hcon1 != hcon2:
                        break
                    else:
                        print(cx,cy,hcon1)
                        exit()

Fixed submission:
n = int(input())

w = [(list(map(int, input().split()))) for i in range(n)]#x,y,h
w.sort(key=lambda x:(x[2]),reverse=True)
hcon1 = 0
hcon2 = 0
for cx in range(101):
    for cy in range(101):
        for i in range(n):
            if w[i][2] > 0:
                if i == 0:
                    hcon1 = abs(w[i][0] - cx) + abs(w[i][1] - cy) + w[i][2]
                elif i != 0 and i != n - 1:
                    hcon2 = abs(w[i][0] - cx) + abs(w[i][1] - cy) + w[i][2]
                    if hcon1 != hcon2:
                        break
                    else:
                        hcon1 = hcon2
                else:
                    hcon2 = abs(w[i][0] - cx) + abs(w[i][1] - cy) + w[i][2]
                    if hcon1 != hcon2:
                        break
                    else:
                        print(cx,cy,hcon1)
                        exit()
            else:
                if i == 0:
                    hcon1 = 1
                elif i != 0 and i != n - 1:
                    if hcon1 > abs(w[i][0] - cx) + abs(w[i][1] - cy) + w[i][2]:
                        break
                else:
                    if hcon1 > abs(w[i][0] - cx) + abs(w[i][1] - cy) + w[i][2]:
                        break
                    else:
                        print(cx, cy, hcon1)
                        exit()
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
p = int(m / n)

if p < m + 1 - n:
    for i in range(p, 0, -1):
        if m % i == 0:
            print(i)
            break
else:
    for i in range(n, m + 1):
        if m % i == 0:
            print(int(m / i))
            break

Fixed submission:
n, m = map(int, input().split())
p = int(m / n)

if n > 100:
    for i in range(p, 0, -1):
        if m % i == 0:
            print(i)
            break
else:
    for i in range(n, m + 1):
        if m % i == 0:
            print(int(m / i))
            break

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
p = int(m / n)
for i in range(p, 0, -1):
    if m % i == 0:
        print(i)
        break

Fixed submission:
n, m = map(int, input().split())
p = int(m / n)

if n > 100:
    for i in range(p, 0, -1):
        if m % i == 0:
            print(i)
            break
else:
    for i in range(n, m + 1):
        if m % i == 0:
            print(int(m / i))
            break

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())


for i in range(n, m + 1):
    if m / i == 1:
        print(1)
        break
    if m % i == 0:
        print(int(m / i))
        break

Fixed submission:
n, m = map(int, input().split())
p = int(m / n)

if n > 100:
    for i in range(p, 0, -1):
        if m % i == 0:
            print(i)
            break
else:
    for i in range(n, m + 1):
        if m % i == 0:
            print(int(m / i))
            break

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())

for i in range(n, m + 1):
    if m % i == 0:
        print(int(m / i))
        break

Fixed submission:
n, m = map(int, input().split())
p = int(m / n)

if n > 100:
    for i in range(p, 0, -1):
        if m % i == 0:
            print(i)
            break
else:
    for i in range(n, m + 1):
        if m % i == 0:
            print(int(m / i))
            break