Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
import itertools
INF = float("inf")


def solve(N: int, s: "List[str]"):

    ABcount = 0
    Aend = 0
    Bstart = 0
    AendBstart = 0
    for i in range(N):
        if "AB" in s[i]:
            ABcount += 1

        if s[i][0] == "B" and if s[i][-1] == "A":
            AendBstart += 1
        elif s[i][0] == "B":
            Bstart += 1
        elif s[i][-1] == "A":
            Aend += 1

    if AendBstart > 1:
        ABcount += AendBstart - 1
        AendBstart = 1
    if Aend > 0 or Bstart > 0:
        ABcount += min(Aend, Bstart)+AendBstart
    print(ABcount)

    # 愚直
    # print("愚直")
    # ans = []
    # for kumi in itertools.permutations(s, N):
    #     ans.append("".join(kumi).count("AB"))
    # print(max(ans))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, s)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
import itertools
INF = float("inf")


def solve(N: int, s: "List[str]"):

    ABcount = 0
    Aend = 0
    Bstart = 0
    AendBstart = 0
    for i in range(N):
        ABcount += s[i].count("AB")
        if s[i][0] == "B" and s[i][-1] == "A":
            AendBstart += 1
        elif s[i][0] == "B":
            Bstart += 1
        elif s[i][-1] == "A":
            Aend += 1

    if AendBstart == 0:
        ABcount += min(Aend, Bstart)
    else:
        if Aend + Bstart > 0:
            ABcount += min(Aend, Bstart) + AendBstart
        else:
            ABcount += AendBstart - 1
    print(ABcount)
    # if AendBstart > 1:
    #     ABcount += AendBstart - 1
    #     AendBstart = 1
    # if Aend > 0 or Bstart > 0:
    #     ABcount += min(Aend, Bstart)+AendBstart
    # print(ABcount)

    # 愚直
    # print("愚直")
    # ans = []
    # for kumi in itertools.permutations(s, N):
    #     ans.append("".join(kumi).count("AB"))
    # print(max(ans))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, s)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
import math
from collections import Counter
import collections
INF = float("inf")


import math


class SegmentTree(object):
    # セグメント木

    def __init__(self, N):
        """サイズNの配列を元にしたセグメント木
        """
        # 単位元
        self.idelem = 0
        # 比較関数
        self.func = GCD

        self.N0 = 2**(math.ceil(math.log2(N)))
        self.tree = [self.idelem]*(2*self.N0)

    def update(self, k, x):
        """k番目の値をxに更新
        """
        k += self.N0-1
        self.tree[k] = x
        while k > 1:
            k = (k-1)//2
            self.tree[k] = self.func(self.tree[2*k+1], self.tree[2*k+2])

    def query(self, l, r):
        """区間[l, r)の最小値
        """
        l += self.N0-1
        r += self.N0-1
        s = self.idelem
        while l < r:
            if r % 2 == 0:
                r -= 1
                s = self.func(s, self.tree[r])

            if l % 2 == 0:
                s = self.func(s, self.tree[l])
                l += 1
            l //= 2
            r //= 2
        return s

    def __str__(self):
        return str(self.tree[self.N0-1:-1])


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


def GCDs(*a):
    # リストで入力しないよう注意。
    if len(a) == 0:
        return -1  # エラー

    if len(a) == 1:
        return a[0]

    res = a[0]
    for i in range(1, len(a)):
        res = GCD(res, a[i])
    return res


def solve(N: int, A: "List[int]"):

    st = SegmentTree(N)
    for i, a in enumerate(A):
        st.update(i, a)

    buf = []
    for i in range(N):
        buf.append(GCD(st.query(0, i), st.query(i+1, N)))
    print(max(buf))

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(A: int, B: int, T: int):
    print(B*int(T/A))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    solve(A, B, T)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(N: int, Q: int, S: str, l: "List[int]", r: "List[int]"):
    # ACがある場所を記録する
    buf = None
    mem = []
    for i, c in enumerate(S):
        if buf is None and c == 'A':
            buf = 'A'
        elif buf == 'A' and c == 'C':
            mem.append(i-1)
            buf = None
    for i in range(Q):
        tot = 0
        for m in mem:
            if l[i]-1 <= m and m < r[i]-1:
                tot += 1
        print(tot)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    l = [int()] * (Q)  # type: "List[int]"
    r = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        l[i] = int(next(tokens))
        r[i] = int(next(tokens))
    solve(N, Q, S, l, r)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
# import random

# tc_1 = "".join([random.choice("ACGT") for x in range(100)])
# tc_q = sorted([random.choice(range(100)) for _ in range(2)])
# print(tc_1[tc_q[0]-1:tc_q[1]])
# print(tc_1[tc_q[0]-1:tc_q[1]].count("AC"))
# print(solve(1, 1, tc_1, [tc_q[0]], [tc_q[1]]))


def solve(N: int, Q: int, S: str, l: "List[int]", r: "List[int]"):
    # ACがある場所を記録する
    buf = None
    mem = []
    tot = 0
    for i, c in enumerate(S):
        if c == 'A':
            buf = 'A'
        elif buf == 'A' and c == 'C':
            tot += 1
            buf = None
        elif buf == 'A':
            buf = None
        mem.append(tot)
    # print(mem)
    for i in range(Q):
        print(mem[r[i]-1]-mem[l[i]-1])

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    l = [int()] * (Q)  # type: "List[int]"
    r = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        l[i] = int(next(tokens))
        r[i] = int(next(tokens))
    solve(N, Q, S, l, r)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import numpy as np
N, M, C = [int(x) for x in input().split()]
B = np.array([int(x) for x in input().split()])
A = np.array([[int(x) for x in input().split()] for _ in range(N)])
 
print(np.sum(A.dot(B) > -C))

Fixed submission:
H, W = [int(x) for x in input().split()]
h, w = [int(x) for x in input().split()]
print((H-h)*(W-w))
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import numpy as np
N, M, C = [int(x) for x in input().split()]
B = np.array([int(x) for x in input().split()])
A = np.array([[int(x) for x in input().split()] for _ in range(N)])

print(np.sum(A@B > -C))


Fixed submission:
import numpy as np
N, M, C = [int(x) for x in input().split()]
B = np.array([int(x) for x in input().split()])
A = np.array([[int(x) for x in input().split()] for _ in range(N)])
print(np.sum(np.sum(A*B, axis=1) > -C))
Buggy python submission (verdict: Runtime Error):
import numpy as np
N, M, C = [int(x) for x in input().split()]
B = np.array([int(x) for x in input().split()])
A = np.array([[int(x) for x in input().split()] for _ in range(N)])
 
print(np.sum(A.dot(B) > -C))

Fixed submission:
N, M = [int(x) for x in input().split()]
AB = [[int(x) for x in input().split()] for _ in range(N)]
AB.sort(key=lambda x: x[0])

s = 0
for ab in AB:
    if ab[1] > M:
        s += M*ab[0]
        break
    else:
        s += ab[0]*ab[1]
        M -= ab[1]

print(s)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N, M, C = [int(x) for x in input().split()]
B = np.array([int(x) for x in input().split()])
A = np.array([[int(x) for x in input().split()] for _ in range(N)])
 
print(np.sum(A@B > -C))

Fixed submission:
N, M = [int(x) for x in input().split()]
AB = [[int(x) for x in input().split()] for _ in range(N)]
AB.sort(key=lambda x: x[0])

s = 0
for ab in AB:
    if ab[1] > M:
        s += M*ab[0]
        break
    else:
        s += ab[0]*ab[1]
        M -= ab[1]

print(s)

Buggy python submission (verdict: Runtime Error):
print(AB)

N, M = [int(x) for x in input().split()]
AB = [[int(x) for x in input().split()] for _ in range(N)]
AB.sort(key=lambda x: x[0])

s = 0
for ab in AB:
    if ab[1] > M:
        s += M*ab[0]
        break
    else:
        s += ab[0]*ab[1]
        M -= ab[1]

print(s)


Fixed submission:
N, M = [int(x) for x in input().split()]
AB = [[int(x) for x in input().split()] for _ in range(N)]
AB.sort(key=lambda x: x[0])

s = 0
for ab in AB:
    if ab[1] > M:
        s += M*ab[0]
        break
    else:
        s += ab[0]*ab[1]
        M -= ab[1]

print(s)
Buggy python submission (verdict: Runtime Error):
from math import log2
import sys
N, K = [int(x) for x in input().split()]
a = [int(y) for y in input().split()]


def nketame(a, n):
    return (a & (1 << n)) >> n


def f(x):
    return sum([y ^ x for y in a])


if K == 0:
    print(f(0))
    sys.exit(1)

ans = []
for i in range(1, int(log2(K))+1):
    b = 1
    for j in range(i):
        b = b << 1
        c = [nketame(x, j) for x in a].count(1)
        if c < N-c:
            b += 1
    ans.append(b)
# print(ans)
# print(max(ans))
hprint(f(max(ans)))


Fixed submission:
from math import log2
import sys
N, K = [int(x) for x in input().split()]
a = [int(y) for y in input().split()]


def nketame(a, n):
    return (a & (1 << n)) >> n


def f(x):
    return sum([y ^ x for y in a])


if K == 0:
    print(f(0))
else:
    ans = []
    b = 0
    for i in range(int(log2(K))+1, 0, -1):
        # print("i", i)
        c = [nketame(x, i-1) for x in a].count(1)
        if c < N-c:
            bb = b + (1 << (i-1))
        else:
            bb = b
        if bb <= K:
            b = bb
            ans.append(b)
    # print(ans)
    print(f(max(ans)))

    # 全列挙
    # print("true ", max([(x, f(x)) for x in range(K+1)], key=lambda x: x[1]))

Buggy python submission (verdict: Runtime Error):
from math import log2
import sys
N, K = [int(x) for x in input().split()]
a = [int(y) for y in input().split()]
cand = [i for i in range(K)]


def nketame(a, n):
    return (a & (1 << (n-1))) >> (n-1)


def f(x):
    return sum([y ^ x for y in a])


if K == 0:
    print(f(0))
    sys.exit(1)

k = int(log2(K)+1)              # keta
# print(k)
ans = 0
for i in range(k, 0, -1):
    # print("sum", [nketame(x, i) for x in a])
    if sum([nketame(x, i) for x in a]) > int(N/2):
        ans += 0
    else:
        ans += 1
    # print("ans", "{0:08b}".format(ans << (i-1)), ans << (i-1))
    cand = [x for x in cand if nketame(x, i) == (ans & 1)]
    # print("cand", cand)
    if len(cand) == 1:
        break
    ans = ans << 1

ans = ans << (i-1)
# print("A", ans)
# print("f(A)", f(ans))
print(f(ans))

# for x in a:
#     print("0b{0:08b}".format(x))
# for i in range(K):
#     print("i:{0}, 0b{1:08b}".format(i, i))

# for i in range(K):
#     ans = sum([x ^ i for x in a])
#     print("f({0}) = {1:08b} = {2}".format(i, ans, ans))


Fixed submission:
from math import log2
import sys
N, K = [int(x) for x in input().split()]
a = [int(y) for y in input().split()]


def nketame(a, n):
    return (a & (1 << n)) >> n


def f(x):
    return sum([y ^ x for y in a])


if K == 0:
    print(f(0))
else:
    ans = []
    b = 0
    for i in range(int(log2(K))+1, 0, -1):
        # print("i", i)
        c = [nketame(x, i-1) for x in a].count(1)
        if c < N-c:
            bb = b + (1 << (i-1))
        else:
            bb = b
        if bb <= K:
            b = bb
            ans.append(b)
    # print(ans)
    print(f(max(ans)))

    # 全列挙
    # print("true ", max([(x, f(x)) for x in range(K+1)], key=lambda x: x[1]))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, K: int, h: "List[int]"):
    DP = [INF]*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(h[i]-h[i-j]))
    print(DP[N-1])
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, h)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, K: int, h: "List[int]"):
    DP = [INF]*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(h[i]-h[i-j]))
    print(DP[N-1])
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, h)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, W: int, w: "List[int]", v: "List[int]"):
    DP = [[0]*(W+1) for _ in range(N+1)]

    for i in range(N):
        for j in range(W+1):
            DP[i+1][j] = DP[i][j]
            if j-w[i] >= 0:
                DP[i+1][j] = max(DP[i+1][j], DP[i][j-w[i]]+v[i])
    print(DP[N][W])
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    w = [int()] * (N)  # type: "List[int]"
    v = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        w[i] = int(next(tokens))
        v[i] = int(next(tokens))
    solve(N, W, w, v)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, W: int, w: "List[int]", v: "List[int]"):
    DP = [[0]*(W+1) for _ in range(N+1)]

    for i in range(N):
        for j in range(W+1):
            DP[i+1][j] = DP[i][j]
            if j-w[i] >= 0:
                DP[i+1][j] = max(DP[i+1][j], DP[i][j-w[i]]+v[i])
    print(DP[N][W])
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    w = [int()] * (N)  # type: "List[int]"
    v = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        w[i] = int(next(tokens))
        v[i] = int(next(tokens))
    solve(N, W, w, v)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, p: "List[float]"):
    # prob[i][j]はi枚まで投げてj枚表になる確率
    prob = [[0]*(N+1) for _ in range(N+1)]
    prob[0][0] = 1
    for i in range(N):
        for j in range(N+1):
            prob[i+1][j] = prob[i][j]*(1-p[i])
            if j-1 >= 0:
                prob[i+1][j] += prob[i][j-1]*p[i]
    print(sum(prob[N][N//2+1:]))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p = [float(next(tokens)) for _ in range(N)]  # type: "List[float]"
    solve(N, p)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, p: "List[float]"):
    # prob[i][j]はi枚まで投げてj枚表になる確率
    prob = [[0]*(N+1) for _ in range(N+1)]
    prob[0][0] = 1
    for i in range(N):
        for j in range(N+1):
            prob[i+1][j] = prob[i][j]*(1-p[i])
            if j-1 >= 0:
                prob[i+1][j] += prob[i][j-1]*p[i]
    print(sum(prob[N][N//2+1:]))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p = [float(next(tokens)) for _ in range(N)]  # type: "List[float]"
    solve(N, p)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, a: "List[int]"):

    dp = [[0]*N for _ in range(N)]
    for sub in range(N):
        turn = sub % 2
        for i in range(N-sub):
            j = i+sub
            # i ~ jの数列に対して操作
            if i == j:
                if (N-sub+1) % 2 == 0:
                    dp[i][i] = a[i]
                else:
                    dp[i][i] = -a[i]
                continue

            if (N-sub+1) % 2 == 0:    # 先手番
                dp[i][j] = max(a[i] + dp[i+1][j], a[j]+dp[i][j-1])
            else:               # 後手番
                dp[i][j] = min(-a[i] + dp[i+1][j], -a[j]+dp[i][j-1])
    print(dp[0][N-1])
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, a: "List[int]"):

    dp = [[0]*N for _ in range(N)]
    for sub in range(N):
        turn = sub % 2
        for i in range(N-sub):
            j = i+sub
            # i ~ jの数列に対して操作
            if i == j:
                if (N-sub+1) % 2 == 0:
                    dp[i][i] = a[i]
                else:
                    dp[i][i] = -a[i]
                continue

            if (N-sub+1) % 2 == 0:    # 先手番
                dp[i][j] = max(a[i] + dp[i+1][j], a[j]+dp[i][j-1])
            else:               # 後手番
                dp[i][j] = min(-a[i] + dp[i+1][j], -a[j]+dp[i][j-1])
    print(dp[0][N-1])
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def bit(n, k):
    return (n >> k) & 1


def solve(N: int, a: "List[List[int]]"):
    DP = [0]*(1 << N)
    flag = [False]*(1 << N)

    def rec(S):
        if flag[S]:
            return DP[S]
        flag[S] = True

        ans = 0
        for i in range(N):
            for j in range(i+1, N):
                if bit(S, i) and bit(S, j):
                    ans += a[i][j]
        T = S
        while T > 0:
            ans = max(ans, rec(S)+rec(S ^ T))
            T = (T-1) & S
        DP[S] = ans
        return ans
    print(rec((1 << N)-1))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [[int(next(tokens)) for _ in range(N)]
         for _ in range(N)]  # type: "List[List[int]]"
    solve(N, a)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def bit(n, k):
    return (n >> k) & 1


def solve(N: int, a: "List[List[int]]"):
    DP = [0]*(1 << N)
    flag = [False]*(1 << N)

    def rec(S):
        if flag[S]:
            return DP[S]
        flag[S] = True

        ans = 0
        for i in range(N):
            for j in range(i+1, N):
                if bit(S, i) and bit(S, j):
                    ans += a[i][j]
        T = (S-1) & S
        while T > 0:
            ans = max(ans, rec(T)+rec(S ^ T))
            T = (T-1) & S
        DP[S] = ans
        return ans
    print(rec((1 << N)-1))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [[int(next(tokens)) for _ in range(N)]
         for _ in range(N)]  # type: "List[List[int]]"
    solve(N, a)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
import math
import collections
INF = float("inf")


def factorial(n):
    prime_count = collections.Counter()

    for i in range(2, int(math.sqrt(n)) + 2):
        while n % i == 0:
            n /= i
            prime_count[i] += 1
    if n > 1:
        prime_count[int(n)] += 1

    return prime_count


def solve(N: int, M: int):
    ans = 0
    for i in range(1, int(M/N)+1):
        if M % i == 0:
            ans = i
    print(ans)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
import math


def GCD(a, b):
    # a < b
    if a == 0:
        return b
    else:
        return GCD(b % a, a)


def solve(N: int, M: int):
    # O(sqrt(M))
    yakusu = [i for i in range(1, int(math.sqrt(M))+1) if M % i == 0]
    yakusu.extend([M/y for y in yakusu[::-1]])

    ans = 0
    for y in yakusu:
        rest = M / y
        if rest >= N:
            # print(y, rest, N)
            ans = y

    print(int(ans))
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)


if __name__ == '__main__':
    main()