alexjercan/bugnet huggingface dataset:
Problem p03238 (Python) — buggy submission, verdict: Runtime Error

N = input()

if N == "1":
    print("Hello World")
else:
    A = int(input())
    B = int(input())
    print(A + B)


Error: EOFError: EOF when reading a line
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03238/Python/s770594409.py", line 6, in <module>
    a = int(input())
EOFError: EOF when reading a line


Fixed submission:

n = input()

if n == 1:
    print("Hello Workd")
else:
    a = int(input())
    b = int(input())
    print(a + b)
Problem p03238 (Python) — buggy submission, verdict: Runtime Error

if int(input()) == 1:
    print("Hello World")
else:
    print(int(input()) + int(input()))


Error: 0

Fixed submission:

input_data = [int(i) for i in input().split(" ")]

if input_data[0] == 1:
    print("Hello World")
    exit()

print(input_data[1] + input_data[2])
Problem p03238 (Python) — buggy submission, verdict: Runtime Error

N = input()

if N == "1":
    print("Hello World")
else:
    A = input()
    B = input()
    print(str(int(A) + int(B)))


Error: EOFError: EOF when reading a line
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03238/Python/s676285942.py", line 2, in <module>
    A = input()
EOFError: EOF when reading a line


Fixed submission:

N = input()
A = input()
B = input()

if N == "1":
    print("Hello World")
else:
    print(str(int(A) + int(B)))
Problem p03238 (Python) — buggy submission, verdict: Runtime Error

N = int(input())
if N == 1:
    print("Hello World")
else:
    A = int(input())
    B = int(input())
    print(A + B)


Error: 0

Fixed submission:

N = int(input())
if N == 1:
    print("Hello World")
else:
    A, B = map(int, input().split())
    print(A + B)
Problem p03238 (Python) — buggy submission, verdict: Runtime Error

n = int(input())
if n == 1:
    print("Hello World")
else:
    a = int(input())
    b = int(input())
    print(a + b)


Error: EOFError: EOF when reading a line
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03238/Python/s158910161.py", line 2, in <module>
    a = int(input())
EOFError: EOF when reading a line


Fixed submission:

n = int(input())
a = int(input())
b = int(input())
if n == 1:
    print("Hello World")
else:
    print(a + b)
Problem p03238 (Python) — buggy submission, verdict: Runtime Error

N = int(input())

if N == 1:
    print("Hello World")
else:
    A = int(input())
    B = int(input())
    print(A + B)


Error: 0

Fixed submission:

N = int(input())

if N == 1:
    print("Hello World")
else:
    A, B = map(int, input().split())
    print(A + B)
Problem p03238 (Python) — buggy submission, verdict: Runtime Error

N = int(input())

if N == 1:
    print("Hello World")
elif N == 2:
    A = int(input())
    B = int(input())
    print(A + B)


Error: 0

Fixed submission:

N = int(input())

if N == 1:
    print("Hello World")
elif N == 2:
    A, B = map(int, input().split())

    print(A + B)
Problem p03239 (Python) — buggy submission, verdict: Runtime Error

import sys

input = sys.stdin.readline


def main():
    n, t = map(int, input().split())
    routes = list(
        filter(lambda x: x[1] <= t, [list(map(int, input().split())) for _ in range(n)])
    )
    if routes:
        print(min(routes)[0])
    else:
        print("TLE")


if __name__ == "__main__":
    main()


Error: 0

Fixed submission:

import sys

input = sys.stdin.readline


def main():
    n, t = map(int, input().split())
    routes = filter(
        lambda x: x[1] <= t, [list(map(int, input().split())) for _ in range(n)]
    )
    if routes:
        print(min(routes)[0])
    else:
        print("TLE")


if __name__ == "__main__":
    main()
Problem p03239 (Python) — buggy submission, verdict: Runtime Error

N, T = map(int, input().split())
r = [tuple(map(int, input().split())) for _ in range(N)]
f = [(c, t) for c, t in r if t <= T]
if len(f) == 0:
    print("TLE")
else:
    print(min(f, key=lambda x: x[0])[0])


Error: 0

Fixed submission:

N, T = map(int, input().split())
r = [tuple(map(int, input().split())) for _ in range(N)]
f = [(c, t) for c, t in r if t <= T]
print(min(f, key=lambda x: x[0])[0])
Problem p03240 (Python) — buggy submission, verdict: Runtime Error

import sys

input = sys.stdin.readline


def main():
    n = int(input())
    points = sorted(
        [[int(i) for i in input().split()] for _ in range(n)],
        key=lambda x: x[2],
        reverse=True,
    )
    hoge = 101
    for cx in range(hoge):
        for cy in range(hoge):
            x, y, z = points[0]
            h = z + abs(x - cx) + abs(y - cy)

            if h < 1:
                continue
            if all([z == max(h - abs(x - cx) - abs(y - cy), 0) for x, y, z in points]):
                print(cx, cy, h)
                return


if __name__ == "__main__":
    main()


Error: TypeError: reversed() takes no keyword arguments
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03240/Python/s083980174.py", line 30, in <module>
    main()
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03240/Python/s083980174.py", line 8, in main
    points = reversed(
TypeError: reversed() takes no keyword arguments


Fixed submission:

import sys

input = sys.stdin.readline


def main():
    n = int(input())
    points = reversed(
        [[int(i) for i in input().split()] for _ in range(n)],
        key=lambda x: x[2],
        reverse=True,
    )
    print(points)
    hoge = 101
    for cx in range(hoge):
        for cy in range(hoge):
            x, y, z = points[0]
            h = max(z + abs(x - cx) + abs(y - cy), 0)
            # print(h, [max(z + abs(x - cx) + abs(y - cy), 0) for x, y, z in points])
            if h == 0:
                continue
            if all(
                [h == max(z + abs(x - cx) + abs(y - cy), 0) for x, y, z in points[1:]]
            ):
                print(cx, cy, h)
                break


if __name__ == "__main__":
    main()
Problem p03240 (Python) — buggy submission, verdict: Runtime Error

N = int(input())
data = [tuple(map(int, input().split())) for _ in range(N)]
data.sort(key=lambda x: -x[2])
for cx in range(101):
    for cy in range(101):
        h0 = None
        for x, y, h in data:
            if h:
                h_tmp = h + abs(cx - x) + abs(cy - y)
                if h_tmp != h0 and h0 is not None:
                    break
                h0 = h_tmp
            else:
                if abs(cx - x) + abs(cy - y) < h0:
                    break
        else:
            print(cx, cy, h0)
            exit()


Error: 0

Fixed submission:

N = int(input())
data = [tuple(map(int, input().split())) for _ in range(N)]
data.sort(key=lambda x: x[2])
for cx in range(101):
    for cy in range(101):
        h0 = None
        for x, y, h in data:
            if h:
                h_tmp = h + abs(cx - x) + abs(cy - y)
                if h_tmp != h0 and h0 is not None:
                    break
                h0 = h_tmp
            else:
                if abs(cx - x) + abs(cy - y) < h0:
                    break
        else:
            print(cx, cy, h0)
            exit()
Problem p03240 (Python) — buggy submission, verdict: Runtime Error

N = int(input())
x = []
y = []
h = []
key = 0
for i in range(N):
    tmp = [int(i) for i in input().split()]
    if tmp[2] != 0:
        key = i
    x.append(tmp[0])
    y.append(tmp[1])
    h.append(tmp[2])

for Cx in range(100 + 1):
    for Cy in range(100 + 1):
        correct_flag = True
        H = abs(x[key] - Cx) + abs(y[key] - Cy) + h[key]
        for i in range(N):
            if h[i] == 0:
                if abs(x[i] - Cx) + abs(y[i] - Cy) < H:
                    correct_flag = False
                    break
            else:
                if abs(x[i] - Cx) + abs(y[i] - Cy) + h[i] != H:
                    correct_flag = False
                    break
        if correct_flag:
            print(Cx, Cy, H)
            break


Error: 0

Fixed submission:

N = int(input())
x = []
y = []
h = []
for _ in range(N):
    tmp = [int(i) for i in input().split()]
    if tmp[2] == 0:
        continue
    x.append(tmp[0])
    y.append(tmp[1])
    h.append(tmp[2])

for Cx in range(100 + 1):
    for Cy in range(100 + 1):
        correct_flag = True
        H = abs(x[0] - Cx) + abs(y[0] - Cy) + h[0]
        for i in range(1, N):
            if abs(x[i] - Cx) + abs(y[i] - Cy) + h[i] != H:
                correct_flag = False
                break
        if correct_flag:
            print(Cx, Cy, H)
            break
Problem p03240 (Python) — buggy submission, verdict: Time Limit Exceeded

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

i = 0
while 1:
    if P[i][2] > 0:
        break
    i += 1
x0, y0, h0 = P[i]
for cy in range(101):
    for cx in range(101):
        h = h0 + abs(cx - x0) + abs(cy - y0)
        for x, y, h1 in P:
            if h1 != max(h - abs(cx - x) - abs(cy - y), 0):
                break
        else:
            print(cx, cy, h)
            exit(0)
exit(1)


Error: TLE

Fixed submission:

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

i = 0
while 1:
    if P[0][2] > 0:
        break
    i += 1
x0, y0, h0 = P[i]
for cy in range(101):
    for cx in range(101):
        h = h0 + abs(cx - x0) + abs(cy - y0)
        for x, y, h1 in P:
            if h1 != max(h - abs(cx - x) - abs(cy - y), 0):
                break
        else:
            print(cx, cy, h)
            exit(0)
exit(1)
Problem p03240 (Python) — buggy submission, verdict: Runtime Error

# -*- coding: utf-8 -*-

N = int(input())
X, Y, H = [], [], []
for _ in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)

for x in range(101):
    for y in range(101):
        hc = {H[i] + abs(X[i] - x) + abs(Y[i] - y) for i in range(N) if H[i] > 0}
        h0 = {H[i] + abs(X[i] - x) + abs(Y[i] - y) for i in range(N) if H[i] == 0}
        if len(hc) == 1:
            if (len(h0) > 0 and min(h0) >= list(hc)[0]) or len(h0) == 0:
                print(x, y, list(hc)[0])
                break


Error: ValueError: max() arg is an empty sequence
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03240/Python/s122970234.py", line 15, in <module>
    if len(hc) == 1 and max(h0) <= max(hc):
ValueError: max() arg is an empty sequence


Fixed submission:

# -*- coding: utf-8 -*-

N = int(input())
X, Y, H = [], [], []
for _ in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)

for x in range(101):
    for y in range(101):
        hc = {H[i] + abs(X[i] - x) + abs(Y[i] - y) for i in range(N) if H[i] > 0}
        h0 = {H[i] + abs(X[i] - x) + abs(Y[i] - y) for i in range(N) if H[i] == 0}
        if len(hc) == 1 and max(h0) <= max(hc):
            print(x, y, list(hc)[0])
            break
Problem p03240 (Python) — buggy submission, verdict: Runtime Error

def solve(n):
    can = [[[-1, float("inf")] for _ in range(101)] for _ in range(101)]
    for k in range(n):
        x, y, h = map(int, input().split())
        for i in range(101):
            for j in range(101):
                if can[i][j] is None:
                    continue
                hh = h + abs(x - i) + abs(y - j)
                hl = 1 if h == 0 else hh
                nl, nh = max(can[i][j][0], hl), min(can[i][j][1], hh)
                if nl > nh:
                    can[i][j] = None
                else:
                    can[i][j][0] = nl
                    can[i][j][1] = nh

    for i in range(101):
        for j in range(101):
            if can[i][j] is None:
                continue
            return i, j, can[i][j][0]


n = int(input())
print(*solve(n))


Error: 0

Fixed submission:

n = int(input())
can = [[0] * 101 for _ in range(101)]


def solve(n, can):
    for k in range(n):
        x, y, h = map(int, input().split())
        if k == 0:
            for i in range(101):
                for j in range(101):
                    can[i][j] = h + abs(x - i) + abs(y - j)
        else:
            for i in range(101):
                for j in range(101):
                    if can[i][j] is None:
                        continue
                    if h + abs(x - i) + abs(y - j) != can[i][j]:
                        can[i][j] = None
    for i in range(101):
        for j in range(101):
            if can[i][j] is None:
                continue
            return i, j, can[i][j]


print(*solve(n, can))
Problem p03241 (Python) — buggy submission, verdict: Runtime Error

import math

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

if N == 1:
    print(M)
else:
    d = max(d for d in range(1, math.ceil(M / (N - 1))) if M % d == 0)
    print(d)


Error: 0

Fixed submission:

import math

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

d = max(d for d in range(1, math.ceil(M / (N - 1))) if M % d == 0)
print(d)
Problem p03241 (Python) — buggy submission, verdict: Runtime Error

# coding: utf-8
import math

(n, m) = [int(i) for i in input().rstrip().split(" ")]

ans = 0
divList = []
for i in range(1, int(math.sqrt(m)) + 1):
    if m % i == 0:
        j = m / i
        divList.append(i)
        divList.append(j)
divList = sorted(divList)
for i in divList:
    if i < n:
        continue
    ans = m / i
    break

print(int(ans))


Error: TypeError: 'float' object cannot be interpreted as an integer
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03241/Python/s345710504.py", line 6, in <module>
    for i in range(n, math.sqrt(m) + 1):
TypeError: 'float' object cannot be interpreted as an integer


Fixed submission:

# coding: utf-8
import math

(n, m) = [int(i) for i in input().rstrip().split(" ")]

for i in range(n, math.sqrt(m) + 1):
    if m % i == 0:
        print(int(m / i))
        break
Problem p03241 (Python) — buggy submission, verdict: Time Limit Exceeded

import math

n, m = map(int, input().split())
max_i = 1
for i in range(1, int(math.sqrt(m)) + 1):
    if m % i != 0:
        continue
    j = m // i
    if i * n <= m and i > max_i:
        max_i = i
    if j * n <= m and j > max_i:
        max_i = j
print(max_i)


Error: TLE

Fixed submission:

n, m = map(int, input().split())
max_i = m // n
for i in range(max_i, 0, -1):
    if m % i == 0:
        print(i)
        break
Problem p03241 (Python) — buggy submission, verdict: Time Limit Exceeded

import math

n, m = map(int, input().split())
root_m = int(math.sqrt(m))
ans = 1
for a in range(1, root_m):
    # print(a, ans)
    if m % a == 0:
        b = m // a
        if a * n <= m:
            ans = max(ans, a)
        if b * n <= m:
            ans = max(ans, b)
print(ans)


Error: TLE

Fixed submission:

n, m = map(int, input().split())
if m % n == 0:
    print(m // n)
else:
    gcd = m // n
    for i in range(gcd, 0, -1):
        if m % i == 0:
            j = m // gcd
            if j >= n:
                print(i)
                exit()
Problem p03241 (Python) — buggy submission, verdict: Runtime Error

def enum_divisors(n):
    res = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            res.append(i)
            if i != n // i:
                res.append(n // i)
    return res


N, M = map(int, input().split())
divs = filter(lambda x: x <= M // N, enum_divisors(M))
print(max(divs))


Error: 0

Fixed submission:

N, M = map(int, input().split())
ans = 0
for i in range(1, (M + N - 2) // (N - 1)):
    if (M - i * (N - 1)) % i == 0:
        ans = i
print(ans)
Problem p03241 (Python) — buggy submission, verdict: Time Limit Exceeded

import math

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


def calculate(n, m):
    res = 1
    for i in range(1, int(math.pow(m, 0.5))):
        if m % i != 0:
            continue

        j = m // i

        if i <= m // n:
            res = max(res, i)

        if j <= m // n:
            res = max(res, j)

    print(res)


calculate(N, M)


Error: TLE

Fixed submission:

import math

N, M = map(int, input().split())
i = math.floor(M / N)

while i >= 1:
    if M % i == 0:
        break
    i = i - 1

print(i)
Problem p03241 (Python) — buggy submission, verdict: Runtime Error

N, M = map(int, input().split())  # 項数N, Aの和M

ans = 1
for i in range(1, int(M ** (1 / 2)) + 1):
    if M % i != 0:
        continue
    j = M // i  # jはどんどん小さくなる
    if j >= N:
        ans = max(ans, i)
    if i >= N:
        ans = max(ans, j)

print(ans)


Error: ZeroDivisionError: integer division or modulo by zero
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03241/Python/s190829031.py", line 10, in <module>
    if (M >= N * i) and (M % i == 0):
ZeroDivisionError: integer division or modulo by zero


Fixed submission:

N, M = map(int, input().split())  # 項数N, Aの和M

ans = 1

if N == 1:
    print(M)
    exit()

for i in range(1000000):
    if (M >= N * i) and (M % i == 0):
        ans = i

print(ans)
Problem p03241 (Python) — buggy submission, verdict: Time Limit Exceeded

import math

N, M = map(int, input().split())
d = []
for i in range(1, int(math.sqrt(M)) + 1):
    if M % i == 0:
        d.append(i)
        d.append(int(M / i))
d = list(filter(lambda x: x <= int(M / N), d))
print(max(d))


Error: TLE

Fixed submission:

N, M = map(int, input().split())
d = [i for i in range(1, int(M / N) + 1) if M % i == 0]
print(max(d))
Problem p03241 (Python) — buggy submission, verdict: Runtime Error

# https://atcoder.jp/contests/abc112/tasks/abc112_d

# 答えansの満たす条件
# ans<=M//Nである
# M%ans==0である


# 仮説:M//Nからansを--して、M%ans==0となるansが答え
# でももしN=2, M=10*9+7とかだったらTLEしそう→しなかった(コーナーケースに助けられた？)
# 2 999999937でTLEしてしまうのでこれは嘘解答

N, M = list(map(int, input().split()))

# 以下嘘解答
# ans = M // N
# for a in range(ans, 0, -1):
#     if M % a == 0:
# print(a)
# exit()

# 本当の解答
ans_temp = M // N
if M % N == 0:
    print(ans_temp)
    exit()


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-(n**0.5) // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append((i, cnt))

    if temp != 1:
        arr.append((temp, 1))

    if arr == []:
        arr.append((n, 1))

    return arr


def make_divisors(n, sort=False):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    if sort:
        divisors.sort()
    return divisors


print(max(make_divisors(M), key=lambda x: 0 if x > ans_temp else x))


Error: 0

Fixed submission:

# https://atcoder.jp/contests/abc112/tasks/abc112_d

# 答えansの満たす条件
# ans<=M//Nである
# M%ans==0である


# 仮説:M//Nからansを--して、M%ans==0となるansが答え
# でももしN=2, M=10*9+7とかだったらTLEしそう →約数ならば

from math import sqrt

N, M = list(map(int, input().split()))

ans = M // N
if M % N == 0:
    print(ans)
    exit()

s = min(ans, sqrt(M) + 1)
for a in range(s, 0, -1):
    if M % a == 0:
        print(a)
        exit()
Problem p03241 (Python) — buggy submission, verdict: Time Limit Exceeded

N, M = map(int, input().split())
print(next(d for d in reversed(range(M // N + 1)) if M % d == 0))


Error: TLE

Fixed submission:

N, M = map(int, input().split())
print(max(d for d in range(1, M // N + 1) if M % d == 0))
Problem p03241 (Python) — buggy submission, verdict: Time Limit Exceeded

import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    n, m = map(int, input().split())

    for i in reversed(range(1, m // n + 1)):
        if (m - i * n) % i == 0:
            print(i)
            return


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """3 14"""
        output = """2"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """10 123"""
        output = """3"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """100000 1000000000"""
        output = """10000"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Error: TLE

Fixed submission:

import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    n, m = map(int, input().split())

    ans = []

    for i in range(1, m // n + 1):
        if (m - i * n) % i == 0:
            ans.append(i)

    print(max(ans))


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """3 14"""
        output = """2"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """10 123"""
        output = """3"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """100000 1000000000"""
        output = """10000"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()
Problem p03241 (Python) — buggy submission, verdict: Time Limit Exceeded

N, M = [int(str) for str in input().strip().split()]

for i in range(M // N, 0, -1):
    if M % i == 0:
        print(i)
        exit()

print(1)


Error: TLE

Fixed submission:

N, M = [int(str) for str in input().strip().split()]

for i in range(N, M + 1):
    if M % i == 0:
        print(M // i)
        exit()

print(1)
Problem p03241 (Python) — buggy submission, verdict: Time Limit Exceeded

import math

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

if n == 1:
    print(m)
    exit()
a = []
b = []
for i in range(1, math.ceil(math.sqrt(m))):
    if m % n == 0:
        print(m // n)
        exit()
    if m % i == 0:
        b.append(i)
        b.append(m // i)

# print(b)

for i in range(len(b)):
    if b[i] * n <= m:
        a.append(b[i])
# print(a)

if len(b) == 2:
    print(1)
else:
    print(max(a))


Error: TLE

Fixed submission:

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

if n == 1:
    print(m)
    exit()
a = []
for i in range(1, m // n + 1):
    if m % n == 0:
        print(m // n)
        exit()
    if m % i == 0:
        a.append(i)

print(max(a))