Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
a_ls = [int(input()) for _ in range(m)]

dp = [0] * (n+1)
dp[0] = 1
dp[1] = 1 if 1 not in a_ls else 0
for i in range(n):
    if i + 2 not in a_ls and i not in a_ls and i+1 not in a_ls:
        dp[i+2] = dp[i] + dp[i+1] 
    elif dp[i+2] in a_ls:
        dp[i+2] = 0
    elif i in a_ls and i+1 not in a_ls:
        dp[i+2] = dp[i+1]
    elif i not in a_ls and i+1 in a_ls:
        dp[i+2] = dp[i]
print(dp[-1] % 1000000007)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

mod = 1000000007

n,m = map(int,input().split())
good = [True] * (n+1)
for _ in range(m):
    x = int(input())
    good[x] = False

dp = [0] * (n+1)
dp[0] = 1

for i in range(n):
    # 出発点になれるなら、のみでOK
        # Falseの部分が更新されることはあっても、出発点になれないから
    if good[i]:
        if i+1 <= n:
            dp[i+1] += dp[i]
            dp[i+1]%= mod
        if i+2 <= n:
            dp[i+2] += dp[i]
            dp[i+2] %= mod

print(dp[n])

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a_ls = [int(input()) for _ in range(m)]

dp = [0] * (n+1)
dp[0] = 1
for i in range(n):
    if i+1 not in a_ls and i not in a_ls:
        if dp[i + 1] == 0:
            dp[i+1] = dp[i]
        else:
            dp[i+1] = (dp[i+1] + dp[i]) % 1000000007
    if i+2 <= n and i+2 not in a_ls and i not in a_ls:
        if dp[i + 2] == 0:
            dp[i+2] = dp[i]
        else:
            dp[i+2] = (dp[i+2] + dp[i]) % 1000000007
print(dp[-1])

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

mod = 1000000007

n,m = map(int,input().split())
good = [True] * (n+1)
for _ in range(m):
    x = int(input())
    good[x] = False

dp = [0] * (n+1)
dp[0] = 1

for i in range(n):
    # 出発点になれるなら、のみでOK
        # Falseの部分が更新されることはあっても、出発点になれないから
    if good[i]:
        if i+1 <= n:
            dp[i+1] += dp[i]
            dp[i+1]%= mod
        if i+2 <= n:
            dp[i+2] += dp[i]
            dp[i+2] %= mod

print(dp[n])

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a_ls = [int(input()) for _ in range(m)]

dp = [0] * (n+1)
dp[0] = 1
for i in range(n):
    if i+1 not in a_ls and i not in a_ls:
        if dp[i + 1] == 0:
            dp[i+1] = dp[i]
        else:
            dp[i+1] = dp[i+1] + dp[i]
    if i+2 <= n and i+2 not in a_ls and i not in a_ls:
        if dp[i + 2] == 0:
            dp[i+2] = dp[i]
        else:
            dp[i+2] = dp[i+2] + dp[i]
print(dp[-1] % 1000000007)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

mod = 1000000007

n,m = map(int,input().split())
good = [True] * (n+1)
for _ in range(m):
    x = int(input())
    good[x] = False

dp = [0] * (n+1)
dp[0] = 1

for i in range(n):
    # 出発点になれるなら、のみでOK
        # Falseの部分が更新されることはあっても、出発点になれないから
    if good[i]:
        if i+1 <= n:
            dp[i+1] += dp[i]
            dp[i+1]%= mod
        if i+2 <= n:
            dp[i+2] += dp[i]
            dp[i+2] %= mod

print(dp[n])
Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())
grid = [0] * H
for i in range(H):
    grid[i] = input()
right = [[0]*W for _ in range(H)]
left = [[0]*W for _ in range(H)]
up = [[0]*W for _ in range(H)]
down = [[0]*W for _ in range(H)]
for y in range(H):
    for x in range(W):
        if grid[y][x] == '.':
            r = 0
            while True:
                if x+r+1 == W or grid[y][x+r+1] == '#':
                    break
                r += 1
            right[y][x] = r
            l = 0
            while True:
                if x-l-1 == -1 or grid[y][x-l-1] == '#':
                    break
                l += 1
            left[y][x] = l
            u = 0
            while True:
                if y-u-1 == -1 or grid[y-u-1][x] == '#':
                    break
                u += 1
            up[y][x] = u
            d = 0
            while True:
                if y+d+1 == H or grid[y+d+1][x] == '#':
                    break
                d += 1
            down[y][x] = d
ans = 0
for y in range(H):
    for x in range(W):
        if grid[y][x] == '.':
            can = 1 + right[y][x] + left[y][x] + up[y][x] + down[y][x]
            ans = max(ans,can)
print(ans)



Fixed submission:
H,W = map(int,input().split())
grid = [0] * H
for i in range(H):
    grid[i] = input()
right = [[0]*W for _ in range(H)]
left = [[0]*W for _ in range(H)]
up = [[0]*W for _ in range(H)]
down = [[0]*W for _ in range(H)]
for i in range(H):
    now = 0
    for x in range(W):
        if grid[i][x] == '.':
            left[i][x] = now
            now += 1
        else:
            now = 0
    now = 0
    for x in range(W-1,-1,-1):
        if grid[i][x] == '.':
            right[i][x] = now
            now += 1
        else:
            now = 0
for x in range(W):
    now = 0
    for y in range(H):
        if grid[y][x] == '.':
            up[y][x] = now
            now += 1
        else:
            now = 0
    now = 0
    for y in range(H-1,-1,-1):
        if grid[y][x] == '.':
            down[y][x] = now
            now += 1
        else:
            now = 0
ans = 0
for y in range(H):
    for x in range(W):
        if grid[y][x] == '.':
            can = 1 + right[y][x] + left[y][x] + up[y][x] + down[y][x]
            ans = max(ans,can)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
L = input()
n = len(L)
csum_1 = [0] * n
csum_0 = [0] * n
now1 = 0
now0 = 0
for i in range(n):
    if L[i] == '1':
        now1 += 1
    else:
        now0 += 1
    csum_1[i] = now1
    csum_0[i] = now0

mod = 10**9+7
ans = 0
# iは、「最初にL[i]=1かつai=0かつbi=0となるindex」
for i in range(n):
    if L[i] == '1':
        p = 1
        # 自分より左側の0の度に2パターン増加
        if i >= 1:
            p *= 2**csum_1[i-1]
        #print(p)
        p %= mod
        # 自分より右側はどの桁も3パターン増加
        p *= 3**(n-i-1)
        #print(p)
        p %= mod
        ans += p
        ans %= mod
# L=a+bの場合
p = 2**(csum_1[-1])
p %= mod
#print(p)
ans = (ans+p)%mod
print(ans)

Fixed submission:
L = input()
n = len(L)
csum_1 = [0] * n
csum_0 = [0] * n
now1 = 0
now0 = 0
for i in range(n):
    if L[i] == '1':
        now1 += 1
    else:
        now0 += 1
    csum_1[i] = now1
    csum_0[i] = now0

mod = 10**9+7
ans = 0
# iは、「最初にL[i]=1かつai=0かつbi=0となるindex」
for i in range(n):
    if L[i] == '1':
        p = 1
        # 自分より左側の0の度に2パターン増加
        if i >= 1:
            p *= pow(2,csum_1[i-1],mod)
        #print(p)
        # 自分より右側はどの桁も3パターン増加
        p *= pow(3,n-i-1,mod)
        #print(p)
        ans += p
        ans %= mod
# L=a+bの場合
p = pow(2,csum_1[-1],mod)
#print(p)
ans = (ans+p)%mod
print(ans)
Buggy python submission (verdict: Runtime Error):
n,a_start,b_start,a_goal,b_goal = map(int,input().split())
s = input()

no_rock_double = True
for i in range(a_start, b_goal):
    if i < n:
        if s[i] == '#' and s[i+1] == '#':
            no_rock_double = False
can_switch = False
if a_goal > b_goal:
    for i in range(b_start+1, b_goal):
        if i + 1 < n:
            if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.':
                can_switch = True
if a_goal > b_goal:
    if no_rock_double and can_switch:
        print('Yes')
    else:
        print('No')
else:
    if no_rock_double:
        print('Yes')
    else:
        print('No')



Fixed submission:
n,a_start,b_start,a_goal,b_goal = map(int,input().split())
s = input()

no_rock_double = True
for i in range(a_start, max(b_goal,a_goal)):
    if i+1 < n:
        if s[i] == '#' and s[i+1] == '#':
            no_rock_double = False
can_switch = False
if a_goal > b_goal:
    for i in range(b_start-1, b_goal):
        if s[i - 1:i + 2] == "...":
            can_switch = True
    if no_rock_double and can_switch:
        print('Yes')
    else:
        print('No')
else:
    if no_rock_double:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
import math
n, k = map(int,input().split())
ans = 0
for i in range(n):
    if i+1 < k:
        must = math.ceil(math.log2(k/(i+1)))
        ans += (1/n)*((0.5)**must)
    else:
        ans += (1/n)
print(ans)
    

Fixed submission:
import math
n, k = map(int,input().split())
ans = 0
for i in range(n):
    if i+1 < k:
        must = math.ceil(math.log2(k/(i+1)))
        ans += (1/n)*((0.5)**must)
    else:
        ans += (1/n)
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque
n = int(input())
ad_ls = [[] for _ in range(n)]
for _ in range(n-1):
    a,b,w = map(int,input().split())
    ad_ls[a-1].append([b-1,w])
    ad_ls[b-1].append([a-1,w])

cost_ls = [0] * n
done_ls = [0] * n
def dfs(v,c):
    for new,cost in ad_ls[v]:
        if not done_ls[new]:
            cost_ls[new] = c+cost
            done_ls[new] = 1
            dfs(new,c+cost)

dfs(0,0)

color_ls = [0] * n
for i in range(n):
    color_ls[i] = cost_ls[i] % 2

for color in color_ls:
    print(color)

Fixed submission:
from collections import deque
n = int(input())
ad_ls = [[] for _ in range(n)]
for _ in range(n-1):
    a,b,w = map(int,input().split())
    ad_ls[a-1].append([b-1,w])
    ad_ls[b-1].append([a-1,w])

cost_ls = [0] * n
done_ls = [0] * n
done_ls[0] = 1
q = deque()
q.append(0)

while q:
    now = q.pop()
    for new in ad_ls[now]:
        nex,cost = new[0],new[1]
        if not done_ls[nex]:
            cost_ls[nex] = cost + cost_ls[now]
            done_ls[nex] = 1
            q.append(nex)

color_ls = [0] * n
for i in range(n):
    color_ls[i] = cost_ls[i] % 2

for color in color_ls:
    print(color)
Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N = map(int,input().split())
ans = 0
for r in range(N+1):
    for g in range(N+1):
        num_box, amari = divmod(N-R*r-G*g, B)
        if num_box >= 0 and amari == 0:
            ans += 1
print(ans)

Fixed submission:
R,G,B,N = map(int,input().split())
ans = 0
for r in range(N+1):
    for g in range(N+1):
        num_box, amari = divmod(N-R*r-G*g, B)
        if num_box >= 0 and amari == 0:
            ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
sho_ls = []
amari_ls = []
a_ls = []
for _ in range(5):
    a = int(input())
    a_ls.append(a)
    sho, amari = divmod(a,10)
    sho_ls.append(sho)
    amari_ls.append(amari)

amari_ls_not0 = []
for i in range(5):
    if amari_ls[i] != 0:
        amari_ls_not0.append(amari_ls[i])

amari_min_not0 = min(amari_ls_not0)
arg_min = amari_ls.index(amari_min_not0)
ans = 0
for i in range(5):
    if i != arg_min:
        if amari_ls[i] != 0:
            plus = a_ls[i] + 10 - amari_ls[i]
            ans += plus
            
        else:
            plus = a_ls[i]
            ans += plus
plus = a_ls[arg_min]
ans += plus
print(ans)

Fixed submission:
import numpy as np
sho_ls = []
amari_ls = []
a_ls = []
for _ in range(5):
    a = int(input())
    a_ls.append(a)
    sho, amari = divmod(a,10)
    sho_ls.append(sho)
    amari_ls.append(amari)

amari_ls_not0 = []
for i in range(5):
    if amari_ls[i] != 0:
        amari_ls_not0.append(amari_ls[i])

if amari_ls != [0,0,0,0,0]:
    amari_min_not0 = min(amari_ls_not0)
    arg_min = amari_ls.index(amari_min_not0)
else:
    arg_min = 0
ans = 0
for i in range(5):
    if i != arg_min:
        if amari_ls[i] != 0:
            plus = a_ls[i] + 10 - amari_ls[i]
            ans += plus
            
        else:
            plus = a_ls[i]
            ans += plus
plus = a_ls[arg_min]
ans += plus
print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
sho_ls = []
amari_ls = []
a_ls = []
for _ in range(5):
    a = int(input())
    a_ls.append(a)
    sho, amari = divmod(a,10)
    sho_ls.append(sho)
    amari_ls.append(amari)

amari_ls_not0 = []
for i in range(5):
    if amari_ls[i] != 0:
        amari_ls_not0.append(amari_ls[i])

amari_min_not0 = min(amari_ls_not0)
arg_min = amari_ls.index(amari_min_not0)
ans = 0
for i in range(5):
    if i != arg_min:
        if amari_ls[i] != 0:
            plus = a_ls[i] + 10 - amari_ls[i]
            ans += plus
            
        else:
            plus = a_ls[i]
            ans += plus
plus = a_ls[arg_min]
ans += plus
print(ans)

Fixed submission:
import numpy as np
sho_ls = []
amari_ls = []
a_ls = []
for _ in range(5):
    a = int(input())
    a_ls.append(a)
    sho, amari = divmod(a,10)
    sho_ls.append(sho)
    amari_ls.append(amari)

amari_ls_not0 = []
for i in range(5):
    if amari_ls[i] != 0:
        amari_ls_not0.append(amari_ls[i])

if amari_ls != [0,0,0,0,0]:
    amari_min_not0 = min(amari_ls_not0)
    arg_min = amari_ls.index(amari_min_not0)
else:
    arg_min = 0
ans = 0
for i in range(5):
    if i != arg_min:
        if amari_ls[i] != 0:
            plus = a_ls[i] + 10 - amari_ls[i]
            ans += plus
            
        else:
            plus = a_ls[i]
            ans += plus
plus = a_ls[arg_min]
ans += plus
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
h_ls = list(map(int, input().split()))

dp = [float('inf') for _ in range(n)]
dp[0] = 0
for i in range(n):
    for j in range(1,k+1):
        if i + j < n:
            dp[i+j] = min(dp[i+j], dp[i] + abs(h_ls[i+j] - h_ls[i]))
print(dp[-1])

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

dp = [float('inf') for _ in range(n)]
dp[0] = 0
for i in range(n):
    for j in range(1,k+1):
        if i + j < n:
            dp[i+j] = min(dp[i+j], dp[i] + abs(h_ls[i+j] - h_ls[i]))
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
n,w_limit = map(int,input().split())
w_ls = [0] * n
v_ls = [0] * n
for i in range(n):
    w_ls[i],v_ls[i] = map(int,input().split())
dp = [[0] * (w_limit+1) for _ in range(n+1)]
for i in range(1,n+1):
    for w in range(w_limit+1):
        if w - w_ls[i-1] >= 0:
            dp[i][w] = dp[i-1][w-w_ls[i-1]] + v_ls[i-1]
        dp[i][w] = max(dp[i][w], dp[i-1][w])
print(dp[-1][w_limit])


Fixed submission:
N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

dp = [[0] * (W + 1) for _ in range(N + 1)]
# dp[i][j](j=0,1,...,W)の値が求まっている状態で、dp[i+1][j]を更新することを考える
for i in range(N):
	for j in range(W + 1):
		# 品物(w[i],v[i])を選ぶとき、j-w[i]>=0に限って、価値v[i]が加算される
		if j - w[i] >= 0:
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i])
		# 品物(w[i],v[i])を選ばないとき、何も加算しない
		dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
print(dp[N][W])
Buggy python submission (verdict: Runtime Error):
n,w = map(int,input().split())
w_ls, v_ls = [0] * n, [0] * n
for i in range(n):
    w_ls[i], v_ls[i] = map(int,input().split())
V = sum(v_ls)
dp = [[float("inf")] * (V+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(n):
    for j in range(V+1):
        if j - v[i] >= 0:
            dp[i+1][j] = min(dp[i+1][j], dp[i][j-v[i]] + w[i])
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])

ans = 0
for j in range(V+1):
    if dp[N][j] <= W:
        ans = j

print(ans)

Fixed submission:
n,w = map(int,input().split())
w_ls, v_ls = [0] * n, [0] * n
for i in range(n):
    w_ls[i], v_ls[i] = map(int,input().split())
V = sum(v_ls)
dp = [[float("inf")] * (V+1) for _ in range(n+1)]
dp[0][0] = 0
for i in range(n):
    for j in range(V+1):
        if j - v_ls[i] >= 0:
            dp[i+1][j] = min(dp[i+1][j], dp[i][j-v_ls[i]] + w_ls[i])
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])

ans = 0
for j in range(V+1):
    if dp[n][j] <= w:
        ans = j

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
n = int(input())
ls = [0] * n
for i in range(n):
    ls[i] = int(input())
ls.sort()
# 長さ2なら例外処理する
if n == 2:
    print(abs(ls[0],ls[1]))
    sys.exit()
if n % 2 == 1:
    # biggerを2つとる方
    smaller = ls[:n//2+1]
    bigger = ls[n//2+1:]
    diff_1 = 2 * sum(bigger) - 2*sum(smaller) + smaller[-1] + smaller[-2]
    # smallerを2つとる方
    smaller = ls[:n//2]
    bigger = ls[n//2:]
    diff_2 = -2 * sum(smaller) + 2 * sum(bigger) - bigger[0] - bigger[1]
    diff = max(diff_1,diff_2)
else:
    smaller = ls[:n//2]
    bigger = ls[n//2:]
    diff = 2 * sum(bigger) - min(bigger) - 2 * sum(smaller) + max(smaller)

print(diff)

Fixed submission:
import sys
n = int(input())
ls = [0] * n
for i in range(n):
    ls[i] = int(input())
ls.sort()
# 長さ2なら例外処理する
if n == 2:
    print(abs(ls[0]-ls[1]))
    sys.exit()
if n % 2 == 1:
    # biggerを2つとる方
    smaller = ls[:n//2+1]
    bigger = ls[n//2+1:]
    diff_1 = 2 * sum(bigger) - 2*sum(smaller) + smaller[-1] + smaller[-2]
    # smallerを2つとる方
    smaller = ls[:n//2]
    bigger = ls[n//2:]
    diff_2 = -2 * sum(smaller) + 2 * sum(bigger) - bigger[0] - bigger[1]
    diff = max(diff_1,diff_2)
else:
    smaller = ls[:n//2]
    bigger = ls[n//2:]
    diff = 2 * sum(bigger) - min(bigger) - 2 * sum(smaller) + max(smaller)

print(diff)
Buggy python submission (verdict: Runtime Error):
n = int(input())
hint_ls = [0] * n
for i in range(n):
    x,y,h = map(int,input().split())
    hint_ls[i] = [x,y,h]
target_ls = [[i,j] for i in range(101) for j in range(101)]
for x_target, y_target in target_ls:
    res = True
    for i in range(n):
        x_hint, y_hint, h_hint = hint_ls[i]
        if h_hint != 0:
            h_target_new = h_hint + abs(x_hint - x_target) + abs(y_hint - y_target)
            if i>= 1:
                if not h_target_new == h_target_old:
                    res = False
            h_target_old = h_target_new
        else:
            if h_target_old > abs(x_hint - x_target) + abs(y_hint - y_target):
                res = False
    if res:
        x_ans,y_ans,h_ans = x_target, y_target, h_target_new

print(x_ans, y_ans, h_ans)

Fixed submission:
import sys
n = int(input())
inf_ls = [[0]*3 for _ in range(n)]
for i in range(n):
    x,y,h = map(int,input().split())
    inf_ls[i] = x,y,h
for Cx in range(101):
    for Cy in range(101):
        this_is_C = True
        H_set = set()
        zero_ls = []
        for i in range(n):
            x,y,h = inf_ls[i]
            if h > 0:
                H = abs(x-Cx) + abs(y-Cy) + h
                H_set.add(H)
            else:
                zero_ls.append([x,y])
        if len(H_set) != 1:
            this_is_C = False
            continue
        H = list(H_set)[0]
        for x,y in zero_ls:
            if H - abs(x-Cx) - abs(y-Cy) > 0:
                this_is_C = False
        if this_is_C:
            print(Cx,Cy,H)
            exit()

Buggy python submission (verdict: Runtime Error):
n = int(input())
hint_ls = [0] * n
for i in range(n):
    x,y,h = map(int,input().split())
    hint_ls[i] = [x,y,h]
target_ls = [[i,j] for i in range(101) for j in range(101)]
for x_target, y_target in target_ls:
    res = True
    for i in range(n):
        x_hint, y_hint, h_hint = hint_ls[i]
        h_target_new = h_hint + abs(x_hint - x_target) + abs(y_hint - y_target)
        if i>= 1:
            if not h_target_new == h_target_old:
                res = False
        h_target_old = h_target_new
    if res:
        x_ans,y_ans,h_ans = x_target, y_target, h_target_new

print(x_ans, y_ans, h_ans)

Fixed submission:
import sys
n = int(input())
inf_ls = [[0]*3 for _ in range(n)]
for i in range(n):
    x,y,h = map(int,input().split())
    inf_ls[i] = x,y,h
for Cx in range(101):
    for Cy in range(101):
        this_is_C = True
        H_set = set()
        zero_ls = []
        for i in range(n):
            x,y,h = inf_ls[i]
            if h > 0:
                H = abs(x-Cx) + abs(y-Cy) + h
                H_set.add(H)
            else:
                zero_ls.append([x,y])
        if len(H_set) != 1:
            this_is_C = False
            continue
        H = list(H_set)[0]
        for x,y in zero_ls:
            if H - abs(x-Cx) - abs(y-Cy) > 0:
                this_is_C = False
        if this_is_C:
            print(Cx,Cy,H)
            exit()
Buggy python submission (verdict: Time Limit Exceeded):
import math
n,m = map(int,input().split())
ans = 1
for i in range(2,m//2+1):
    if m % i == 0:
        if m // i >= n:
            ans = i
    if m // i < n:
        break
if m % m == 0:
    if m // m >= n:
        ans = m
print(ans)

Fixed submission:
import math
n,m = map(int,input().split())

def make_divisors(n):
    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)

    divisors.sort()
    return divisors

divisor_ls = make_divisors(m)

ans = 1
for divisor in divisor_ls:
    if m // divisor < n:
        break
    else:
        ans = divisor

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
n,m = map(int,input().split())
ans = 1
for i in range(2,m//2+1):
    if m % i == 0:
        if m // i >= n:
            ans = i
if m % m == 0:
    if m // m >= n:
        ans = m
print(ans)

Fixed submission:
import math
n,m = map(int,input().split())

def make_divisors(n):
    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)

    divisors.sort()
    return divisors

divisor_ls = make_divisors(m)

ans = 1
for divisor in divisor_ls:
    if m // divisor < n:
        break
    else:
        ans = divisor

print(ans)
Buggy python submission (verdict: Runtime Error):
import math
from fractions import gcd
from functools import reduce
n,x = map(int, input().split())
y_ls = list(map(int, input().split()))
y_ls.sort()
d_ls = []

for i in range(n-1):
    distance = y_ls[i+1] - y_ls[i] 
    d_ls.append(distance)

ans = reduce(gcd, d_ls)
print(ans)

Fixed submission:
import math
from fractions import gcd
from functools import reduce
n,x = map(int, input().split())
y_ls = list(map(int, input().split()))
y_ls.sort()
d_ls = [0] * (n-1)

if n != 1:
    first_ls = []
    for i in range(n):
        first = abs(x - y_ls[i])
        first_ls.append(first)

    for i in range(n-1):
        distance = y_ls[i+1] - y_ls[i] 
        d_ls.append(distance)

    points_gcd = reduce(gcd, d_ls)
    ans = 0
    for i in range(n):
        D = gcd(points_gcd, first_ls[i])
        if D > ans:
            ans = D

else:
    ans = abs(x - y_ls[0])

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
n,k = map(int,input().split())
x_ls = list(map(int, input().split()))
x_ls.sort()
if x_ls[0] >= 0:
    print(x_ls[k-1])
    sys.exit()
elif x_ls[-1] <= 0:
    x_ls.sort(reverse=True)
    print(abs(x_ls[k-1]))
    sys.exit()
l = 0
r = k - 1
while True:
    if x_ls[r+1] > 0:
        break
    l += 1
    r += 1
ans = float('inf')
while r < n:
    cost_1 = 2*abs(x_ls[l]) + abs(x_ls[r])
    cost_2 = abs(x_ls[l]) + 2*abs(x_ls[r])
    cost = min(cost_1,cost_2)
    ans = min(cost, ans)
    r += 1
    l += 1
print(ans)
    

Fixed submission:
n,k = map(int,input().split())
x_ls = list(map(int, input().split()))
ans = float('inf')
for i in range(n-k+1):
    if x_ls[i+k-1] < 0:
        ans = min(ans, abs(x_ls[i]))
    elif x_ls[i] < 0 and x_ls[i+k-1] >= 0:
        near = min(abs(x_ls[i]),abs(x_ls[i+k-1]))
        far = max(abs(x_ls[i]),abs(x_ls[i+k-1]))
        ans = min(ans, 2 * near + far)
    elif x_ls[i] >= 0:
        ans = min(ans, x_ls[i+k-1])
print(ans)