Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02641 (python)

Fixed submission:
import sys
from bisect import bisect_left
x, n = [int(i) for i in sys.stdin.readline().split()]
p_s = [int(i) for i in sys.stdin.readline().split()]
candidate = [i for i in range(-1000,1000) if i not in p_s]
ind = bisect_left(candidate, x)
if ind == len(candidate):
    print(candidate[-1])
elif x - candidate[ind-1] <= candidate[ind] - x:
    print(candidate[ind-1])
else:
    print(candidate[ind])

Buggy submission (verdict: Runtime Error):
import sys
from bisect import bisect_left
x, n = [int(i) for i in sys.stdin.readline().split()]
p_s = [int(i) for i in sys.stdin.readline().split()]
candidate = [i for i in range(1,101) if i not in p_s]
ind = bisect_left(candidate, x)
if ind == len(candidate):
    print(candidate[-1])
elif x - candidate[ind-1] <= candidate[ind] - x:
    print(candidate[ind-1])
else:
    print(candidate[ind])
Problem p02660 (python)

Fixed submission:
from math import sqrt
n = int(input())
cnt = 0
for i in range(2, int(sqrt(n))):
    if n % i == 0:
        div = i
        while n % div == 0:
            n /= div
            div *= i
            cnt += 1
        while n % i == 0:
            n /= i
if n > 1:
    cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
from math import sqrt
n = int(input())
cnt = 0
for i in range(2, int(sqrt(n))):
    if n % i == 0:
        div = i
        while n % div == 0:
            n /= div
            div *= i
            cnt += 1
        while n % i == 0:
            n /= i
if cnt == 0 and i > 1:
    cnt += 1
print(cnt)
Problem p02850 (python)

Fixed submission:
import sys
from collections import deque
sys.setrecursionlimit(10**7)

n = int(input())
graph = {i : [] for i in range(n)}
ls = []
for i in range(n-1):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    ls.append((a,b))
    graph[a].append(b)
    graph[b].append(a)
_max = 0
_max_node = None
for k, v in graph.items():
    if len(v) > _max:
        _max = len(v)
        _max_node = k

parent = [_max_node] * (n)
order = []
stack = [_max_node]
while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)

colors = [-1 for i in range(n)]
for i in order:
    c = 1
    for _next in graph[i]:
        if _next == parent[i]:
            continue
        if c == colors[i]:
            c += 1
        colors[_next] = c
        c += 1
print(_max)
for a, b in ls:
    if parent[a] == b:
        print(colors[a])
    else:
        print(colors[b])

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)

n = int(input())
graph = {i : [] for i in range(n)}
ls = []
for i in range(n-1):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    ls.append((a,b))
    graph[a].append(b)
    graph[b].append(a)
_max = 0
_max_node = None
for k, v in graph.items():
    if len(v) > _max:
        _max = len(v)
        _max_node = k
colors = [[0 for i in range(n)] for j in range(n)]
color_dict = {i : set(range(1,1+_max)) for i in range(n)}
candidate = set(range(1,_max+1))
def dfs(_from, ind, last):
    next_constain = []
    for _next in graph[ind]:
        if _next == _from:
            continue
        res = dfs(ind, _next, next_constain)
        last.append(res)
        next_constain.append(res)
    if _from == -1:
        return 0
    used = list(candidate - set(last))[0]
    colors[ind][_from] = used
    colors[_from][ind] = used
    return used

dfs(-1, _max_node, [])
print(_max)
for a, b in ls:
    print(colors[a][b])
Problem p02868 (python)

Fixed submission:
import sys
import heapq
sys.setrecursionlimit(10**7)
n, m = [int(i) for i in sys.stdin.readline().split()]
INF = 10**9
graph = {j:[(j-1, 1e-10)] if j > 0 else [] for j in range(n)}
for i in range(m):
    l, r, c = [int(i) for i in sys.stdin.readline().split()]
    l -= 1
    r -= 1
    graph[l].append((r, c))
    graph[r].append((l, c))
que = [(0,0)]
already = set()
res = [-1 for i in range(n)]
while len(que) > 0:
    cost, cand = heapq.heappop(que)
    if cand in already:
        continue
    res[cand] = cost
    already.add(cand)
    for _next, _next_cost in graph[cand]:
        if _next in already:
            continue
        heapq.heappush(que, (cost + _next_cost, _next))
print(int(res[-1]))

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix
sys.setrecursionlimit(10**7)
n, m = [int(i) for i in sys.stdin.readline().split()]
INF = 10**9
graph = np.ones(shape=(n,n)) * INF
for i in range(m):
    l, r, c = [int(i) for i in sys.stdin.readline().split()]
    l -= 1
    r -= 1
    graph[l][:r+1] = np.where(graph[l][:r+1] < c, graph[l][:r+1], np.ones_like(graph[l][:r+1]) * c)
graph = np.where(graph == INF, np.zeros_like(graph), graph)
graph = csr_matrix(graph)
res = dijkstra(graph, indices=[0])
print(int(res[0][-1]) if res[0][-1] < INF else -1)

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix
n, m = [int(i) for i in sys.stdin.readline().split()]
INF = 10**9
graph = np.ones(shape=(n,n)) * INF
for i in range(m):
    l, r, c = [int(i) for i in sys.stdin.readline().split()]
    l -= 1
    r -= 1
    graph[l][:r+1] = np.where(graph[l][:r+1] < c, graph[l][:r+1], np.ones_like(graph[l][:r+1]) * c)
graph = np.where(graph == INF, np.zeros_like(graph), graph)
graph = csr_matrix(graph)
res = dijkstra(graph, indices=[0])
print(int(res[0][-1]) if res[0][-1] < INF else -1)
Problem p02882 (python)

Fixed submission:
import sys
import math
a, b, x = [float(i) for i in sys.stdin.readline().split()]

if x < a**2*b / 2:
    print(90.0 - math.degrees(math.atan(x / (a*b**2/2))))
elif a**2*b-x == 0:
    print(0.0)
else:
    print(90.0 - math.degrees(math.atan(a**3 / 2 / (a**2*b-x))))

Buggy submission (verdict: Runtime Error):
import sys
import math
a, b, x = [float(i) for i in sys.stdin.readline().split()]
if x < a**2*b / 2:
    print(90.0 - math.degrees(math.atan(x / (a*b**2/2))))
else:
    print(90.0 - math.degrees(math.atan(a**3 / 2 / (a**2*b-x))))

Buggy submission (verdict: Runtime Error):
import sys
import math
a, b, x = [int(i) for i in sys.stdin.readline().split()]
if x < a**2*b / 2:
    print(90.0 - math.degrees(math.atan(x / (a*b**2/2))))
else:
    print(90.0 - math.degrees(math.atan(a**3 / 2 / (a**2*b-x))))

Buggy submission (verdict: Runtime Error):
import sys
import math
a, b, x = [int(i) for i in sys.stdin.readline().split()]
if x <= a**2*b / 2:
    print(90 - math.degrees(math.atan(x / (a*b**2/2))))
else:
    print(90 - math.degrees(math.atan(a**3 / 2 / (a**2*b-x))))
Problem p02888 (python)

Fixed submission:
import sys
from itertools import combinations
import bisect
import math
n = int(input())
l_ls = [int(i) for i in sys.stdin.readline().split()]
l_ls.sort()
cnt = 0
for a, b in combinations(l_ls, 2):
    _sum = a + b
    ind = bisect.bisect_left(l_ls, _sum)
    cnt += n - ind
print(int(math.factorial(n) // math.factorial(3) // math.factorial(n-3)) - cnt)

Buggy submission (verdict: Runtime Error):
import sys
from itertools import combinations
import bisect
import math
n = int(input())
l_ls = [int(i) for i in sys.stdin.readline().split()]
l_ls.sort()
#l_dict = { i : j for i, j in enumerate(l_ls)}
_sum_ls = []
cnt = 0
for combi in combinations(l_ls, 2):
    _sum = combi[0] + combi[1]
    ind = bisect.bisect_left(l_ls, _sum)
    cnt += n - ind
print(int(math.factorial(n) / math.factorial(3) / math.factorial(n-3)) - cnt)

Buggy submission (verdict: Runtime Error):
import sys
from itertools import combinations
import bisect
import math
n = int(input())
l_ls = [int(i) for i in sys.stdin.readline().split()]
l_ls.sort()
#l_dict = { i : j for i, j in enumerate(l_ls)}
_sum_ls = []
cnt = 0
for combi in combinations(l_ls, 2):
    _sum = combi[0] + combi[1]
    ind = bisect.bisect_left(l_ls, _sum)
    cnt += n - ind
print(int(math.factorial(n) / math.factorial(3) / math.factorial(n-3)) - cnt)

Buggy submission (verdict: Runtime Error):
import sys
from itertools import combinations
import bisect
import math
import numpy as np
n = int(input())
l_ls = [int(i) for i in sys.stdin.readline().split()]
l_ls.sort()
l_dict = { i : j for i, j in enumerate(l_ls)}
_sum_ls = []
cnt = 0
count_ls = np.zeros(2*10**3, dtype=np.int64)
for l in l_ls:
    count_ls[:l+1] += 1
for combi in combinations(l_ls, 2):
    ind = count_ls[combi[0] + combi[1]]
    cnt += ind
"""
for combi in combinations(l_ls, 2):
    count_ls[combi[0] + combi[1]:] += 1
    #bisect.insort_left(_sum_ls, combi[0] + combi[1])
len_sum_ls = len(_sum_ls)
for l in l_ls:
    #ind = bisect.bisect_right(_sum_ls, l)
    ind = count_ls[l]
    cnt += ind
"""

print(int(math.factorial(n) / math.factorial(3) / math.factorial(n-3)) - cnt)

Buggy submission (verdict: Runtime Error):
import sys
from itertools import combinations
import bisect
import math
import numpy as np
n = int(input())
l_ls = [int(i) for i in sys.stdin.readline().split()]
l_ls.sort()
l_dict = { i : j for i, j in enumerate(l_ls)}
_sum_ls = []
cnt = 0
count_ls = np.zeros(2*10**3, dtype=np.int)
for l in l_ls:
    count_ls[:l+1] += 1
for combi in combinations(l_ls, 2):
    ind = count_ls[combi[0] + combi[1]]
    cnt += ind
"""
for combi in combinations(l_ls, 2):
    count_ls[combi[0] + combi[1]:] += 1
    #bisect.insort_left(_sum_ls, combi[0] + combi[1])
len_sum_ls = len(_sum_ls)
for l in l_ls:
    #ind = bisect.bisect_right(_sum_ls, l)
    ind = count_ls[l]
    cnt += ind
"""

print(int(math.factorial(n) / math.factorial(3) / math.factorial(n-3)) - cnt)
Problem p02937 (python)

Fixed submission:
import bisect
s = input()
len_s = len(s)
t = input()

ind_dict = {i : [] for i in t}
for i, _s in enumerate(s):
    if _s in t:
        ind_dict[_s] += [i]

def get_least(last, s, dic):
    ls = dic[s]
    ind = bisect.bisect_right(ls, last)
    if ind >= len(ls):
        return ls[0]
    else:
        return ls[ind]

if -1 in [s.find(_t) for _t in t]:
    print(-1)
else:
    cnt = 0
    last = get_least(-1, t[0], ind_dict)
    _next = last
    for _t in t[1:]:
        _next = get_least(last, _t, ind_dict)
        if _next <= last:
            cnt += 1
        last = _next
    print(cnt * len(s) + _next + 1)

Buggy submission (verdict: Runtime Error):
import re
import bisect
s = input()
len_s = len(s)
t = input()

ind_dict = {i : [] for i in t}
for i, _s in enumerate(s):
    if _s in t:
        ind_dict[_s] += [i]
ind_ls = [[j.start(0) for j in re.finditer(i,s)] for i in t]

def get_least(last, s, dic):
    ls = dic[s]
    ind = bisect.bisect_right(ls, last)
    if ind >= len(ls):
        return ls[0]
    else:
        return ls[ind]

if -1 in [s.find(_t) for _t in t]:
    print(-1)
else:
    cnt = 0
    last = get_least(0, t[0], ind_dict)
    for _t in t[1:]:
        _next = get_least(last, _t, ind_dict)
        if _next < last:
            cnt += 1
        last = _next
    print(cnt * len(s) + _next + 1)

Buggy submission (verdict: Runtime Error):
import re
import bisect
s = input()
len_s = len(s)
t = input()

ind_ls = [[j.start(0) for j in re.finditer(i,s)] for i in t]

def get_least(s_ind, ls):
    ind = bisect.bisect_right(ls, s_ind)
    if ind >= len(ls):
        return ls[0]
    else:
        return ls[ind]

if -1 in [s.find(_t) for _t in t]:
    print(-1)
else:
    cnt = 0
    last = get_least(0, ind_ls[0])
    for ind in ind_ls[1:]:
        _next = get_least(last, ind)
        if _next < last:
            cnt += 1
        last = _next
    print(cnt * len(s) + _next + 1)

Buggy submission (verdict: Runtime Error):
import re
import bisect
s = input()
len_s = len(s)
t = input()

ind_ls = [[j.start(0) for j in re.finditer(i,s)] for i in t]

def get_least(s_ind, ls):
    ind = bisect.bisect_right(ls, s_ind)
    if ind >= len(ls):
        return ls[0]
    else:
        return ls[ind]

if -1 in [s.find(_t) for _t in t]:
    print(-1)
else:
    cnt = 0
    last = get_least(0, ind_ls[0])
    for ind in ind_ls[1:]:
        _next = get_least(last, ind)
        if _next < last:
            cnt += 1
        last = _next
    print(cnt * len(s) + _next + 1)
Problem p02947 (python)

Fixed submission:
from collections import Counter
n = int(input())
ct_ls = []
for i in range(n):
    ct_ls.append("".join(sorted(input())))
ct = Counter(ct_ls)
_ct = 0
for n in ct.values():
    if n >= 2:
        _ct += n * (n - 1) / 2
print(int(_ct))

Buggy submission (verdict: Runtime Error):
from collections import Counter
from math import factorial
n = int(input())
ct_ls = []
for i in range(n):
    ct_ls.append("".join(sorted(input())))
ct = Counter(ct_ls)
_ct = 0
for n in ct.values():
    if n >= 2:
        _ct += factorial(n) / factorial(2) / factorial(n - 2)
print(int(_ct))
Problem p02991 (python)

Fixed submission:
import sys
INF = 10 ** 9
n, m = [int(i) for i in sys.stdin.readline().split()]
graph = {j:[] for j in range(3 * n)}
for i in range(m):
    u, v = [int(i) for i in sys.stdin.readline().split()]
    u -= 1
    v -= 1
    graph[u].append(n+v)
    graph[u+n].append(2*n+v)
    graph[u + 2 * n].append(v)
s, t = [int(i) for i in sys.stdin.readline().split()]
s -= 1
t -= 1

que = [s]
flg = False
already = set()
dist = [INF for i in range(3 * n)]
dist[s] = 0
while que:
    cur= que[0]
    que.pop(0)
    for i in graph[cur]:
        if i not in already:
            if i == t:
                res = dist[cur] + 1
                que.clear()
                flg = True
                break
            que.append(i)
            dist[i] = dist[cur] + 1
            already.add(i)
if not flg:
    res = -1
else:
    res //= 3

print(res)

Buggy submission (verdict: Runtime Error):
import sys
INF = 10 ** 9
n, m = [int(i) for i in sys.stdin.readline().split()]
graph = {j:[] for j in range(3 * n)}
for i in range(m):
    u, v = [int(i) for i in sys.stdin.readline().split()]
    u -= 1
    v -= 1
    graph[u].append(n+v)
    graph[u+n].append(2*n+v)
    graph[u + 2 * n].append(v)
s, t = [int(i) for i in sys.stdin.readline().split()]
s -= 1
t -= 1

que = [s]
flg = False
already = set()
dist = [INF for i in range(3 * n)]
dist[s] = 0
while que:
    cur= que[0]
    que.pop(0)
    for i in graph[cur]:
        if i not in already:
            if i == t:
                res = dist[cur] + 1
                que.clear()
                flg = True
                break
            que.append(i)
            dist[i] = dist[cur] + 1
            already.add(i)
if not flg:
    res = -1
else:
    res //= 3

print(res)
Problem p02995 (python)

Fixed submission:
import sys
def gcd(x, y):
    while True:
        if x > y:
            x %= y
        else:
            y %= x
        if x == 0 or y == 0:
            break
    return max(x, y)

a, b, c, d = [int(i) for i in sys.stdin.readline().split()]
gcd_cd = gcd(c, d)
lcm = c * d // gcd_cd
n_c = b // c - (a - 1) // c
n_d = b // d - (a - 1) // d
n_cd = b // lcm - (a - 1) // lcm
res = (b - a + 1) - n_c - n_d + n_cd
print(res)

Buggy submission (verdict: Runtime Error):
import sys
from math import gcd
a, b, c, d = [int(i) for i in sys.stdin.readline().split()]
gcd_cd = gcd(c, d)
lcm = c * d // gcd_cd
n_c = b // c - (a - 1) // c
n_d = b // d - (a - 1) // d
n_cd = b // lcm - (a - 1) // lcm
res = (b - a + 1) - n_c - n_d + n_cd
print(res)
Problem p03006 (python)

Fixed submission:
import sys
from collections import Counter
n = int(input())
ls = []
if n == 1:
    print(1)
else:
    for i in range(n):
        x, y = [int(i) for i in sys.stdin.readline().split()]
        ls.append((x, y))
    res = []
    for i in range(n - 1):
        for j in range(i+1, n):
            res.append((ls[j][0] - ls[i][0], ls[j][1] - ls[i][1]))
            res.append((- ls[j][0] + ls[i][0], - ls[j][1] + ls[i][1]))
    ct = Counter(res)
    print(n - max(ct.values()))

Buggy submission (verdict: Runtime Error):
import sys
from collections import Counter
n = int(input())
ls = []
for i in range(n):
    x, y = [int(i) for i in sys.stdin.readline().split()]
    ls.append((x, y))
res = []
for i in range(n - 1):
    for j in range(i+1, n):
        res.append((ls[j][0] - ls[i][0], ls[j][1] - ls[i][1]))
ct = Counter(res)
print(n - max(ct.values()))

Buggy submission (verdict: Runtime Error):
import sys
from collections import Counter
n = int(input())
ls = []
for i in range(n):
    x, y = [int(i) for i in sys.stdin.readline().split()]
    ls.append((x, y))
res = [[0 for i in range(n)] for j in range(n)]
ct = Counter()
for i in range(n - 1):
    for j in range(i+1, n):
        res[i][j] = (ls[j][0] - ls[i][0], ls[j][1] - ls[i][1])
        res[j][i] = (- ls[j][0] + ls[i][0], - ls[j][1] + ls[i][1])
    ct.update(res[i])
ct.pop(0)
print(n - max(ct.values()))
Problem p03032 (python)

Fixed submission:
import sys
n, k = [int(i) for i in sys.stdin.readline().split()]
v_ls = [int(i) for i in sys.stdin.readline().split()]
inv_v_ls = v_ls[::-1]
sum_a_b = min(n, k) + 1
best = 0
for a in range(sum_a_b):
    for b in range(sum_a_b - a):
        ls = v_ls[:a] + inv_v_ls[:b]
        ls.sort()
        for c in range(k + 1 - a - b):
            if c >= len(ls):
                break
            score = sum(ls[c:])
            if score > best:
                best = score
            if ls[c] > 0:
                break
print(best)

Buggy submission (verdict: Runtime Error):
import sys
n, k = [int(i) for i in sys.stdin.readline().split()]
v_ls = [int(i) for i in sys.stdin.readline().split()]
inv_v_ls = v_ls[::-1]
sum_a_b = min(n, k) + 1
INF = 1e10
best = -INF
for a in range(sum_a_b):
    for b in range(sum_a_b - a):
        ls = v_ls[:a] + inv_v_ls[:b]
        ls.sort()
        for c in range(sum_a_b - a - b):
            score = sum(ls[c:])
            if score > best:
                best = score
            if v_ls[c] > 0:
                break
print(best)

Buggy submission (verdict: Runtime Error):

import sys
n, k = [int(i) for i in sys.stdin.readline().split()]
v_ls = [int(i) for i in sys.stdin.readline().split()]
right_memo_ls = [[0 for i in range(k)]for j in range(k)]
left_memo_ls = [[0 for i in range(k)]for j in range(k)]
right_memo_ls[0][0] = 0
left_memo_ls[0][0] = 0
INF = 1e10
right_cost2val = {i : -INF for i in range(1+k)}
left_cost2val = {i : -INF for i in range(1+k)}
right_cost2val[0] = 0
left_cost2val[0] = 0
for i in range(k):
    for j in range(0, min(k - i, i + 2)):
        if j == 0:
            right_memo_ls[i][j] = right_memo_ls[max(0,i-1)][j] + v_ls[i]
            left_memo_ls[i][j] = left_memo_ls[max(0,i-1)][j] + v_ls[-i - 1]
        elif j == i+1:
            right_memo_ls[i][j] = 0
            left_memo_ls[i][j] = 0
        else:
            right_memo_ls[i][j] = max(right_memo_ls[max(0, i-1)][max(0, j-1)], right_memo_ls[max(0, i-1)][j] + v_ls[i])
            left_memo_ls[i][j] = max(left_memo_ls[max(0, i-1)][max(0, j-1)], left_memo_ls[max(0, i-1)][j] + v_ls[-i-1])
        right_cost2val[i + j + 1] = max(right_cost2val[i + j + 1], right_memo_ls[i][j])
        left_cost2val[i + j + 1] = max(left_cost2val[i + j + 1], left_memo_ls[i][j])


best = -INF
for i in range(k+1):
    for j in range(k+1-i):
        score = right_cost2val[i] + left_cost2val[j]
        if best < score:
            best = score
print(best)
Problem p03048 (python)

Fixed submission:
import sys
r, g, b, n = [int(i) for i in sys.stdin.readline().split()]
memo_ls = [[0 for j in range(n+1)] for i in range(4)]
memo_ls[0][0] = 1
for i, color in enumerate(sorted([r, g, b]), 1):
    for j in range(n + 1):
        if j >= color:
            memo_ls[i][j] = memo_ls[i-1][j] + memo_ls[i][j-color]
        else:
            memo_ls[i][j] = memo_ls[i-1][j]
print(memo_ls[-1][-1])

Buggy submission (verdict: Runtime Error):
import sys
r, g, b, n = [int(i) for i in sys.stdin.readline().split()]
memo_ls = [[0 for j in range(n+1)] for i in range(4)]
memo_ls[0][0] = 1
for i, color in enumerate([r, g, b], 1):
    for j in range(n + 1):
        memo_ls[i][j] = memo_ls[i-1][j] + memo_ls[i][j-color]
print(memo_ls[-1][-1])
Problem p03105 (python)

Fixed submission:
A, B, C = [int(i) for i in input().split()]
print(min(B // A, C))

Buggy submission (verdict: Runtime Error):
A, B, C = [int(i) for i in input().split()]
print(min(B // A, C)

Buggy submission (verdict: Runtime Error):
A, B, C = [int(i) for i in input().split()]
print(max(B // A, C)
Problem p03106 (python)

Fixed submission:
A, B, K = [int(i) for i in input().split()]
cnt = 1
while True:
    if A % min(A,B) == B % min(A, B) == 0:
        break
    if A > B:
        A %= B
    else:
        B %= A

target = min(A,B)
if K == 1:
    print(target)
else:
    for i in range(2,target):
        if target % i == 0:
            cnt += 1
        if cnt == K:
            break
    print(int(target / i))

Buggy submission (verdict: Runtime Error):
A, B, K = [int(i) for i in input().split()]
cnt = 1
while True:
    if A % min(A,B) == B % min(A, B) == 0:
        break
    if A > B:
        A %= B
    else:
        B %= A

target = min(A,B)
print(target)
for i in range(2,target):
    if target % i == 0:
        cnt += 1
    if cnt == K:
        break
print(int(target / i))

Buggy submission (verdict: Runtime Error):
A, B, K = [int(i) for i in input().split()]
cnt = 1
while True:
    if A % min(A,B) == B % min(A, B) == 0:
        break
    if A > B:
        A %= B
    else:
        B %= A

target = min(A,B)
for i in range(target):
    if target % i == 0:
        cnt += 1
    if cnt == K:
        break
print(i)
Problem p03111 (python)

Fixed submission:
from itertools import product
N, A, B, C = [int(i) for i in input().split()]
l_ls = list()
for i in range(N):
    l_ls.append(int(input()))
best = 1e9
for combi in product(range(4),repeat=N):
    a = [l for l, label in zip(l_ls, combi) if label == 1]
    b = [l for l, label in zip(l_ls, combi) if label == 2]
    c = [l for l, label in zip(l_ls, combi) if label == 3]
    dis = abs(A - sum(a)) + abs(B - sum(b)) + abs(C - sum(c)) \
          + (len(a) + len(b) + len(c) - 3) * 10
    if len(a) * len(b) * len(c) == 0:
        continue
    if best > dis:
        best = dis
print(best)

Buggy submission (verdict: Runtime Error):
from itertools import combinations
N, A, B, C = [int(i) for i in input().split()]
l_ls = list()
for i in range(N):
    l_ls.append(int(input()))
dis_ls = [(i,[i]) for i in l_ls]
for i in range(2,7):
    dis_ls += [(sum(i),i) for i in combinations(l_ls, i)]
best = 1e9
for hoge in [[A, B, C], [A, C, B],[B, A, C],[B, C, A], [C,B,A],[C,A,B]]:
    _sum = 0
    for target in hoge:
        min = 1e9
        for dis in dis_ls:
            c_sa = abs(dis[0] - target) + 10 * (len(dis[1]) - 1)
            if sa < min:
                min = sa
                min_combi = dis[1]
        _sum += min
        dis_ls = [i for i in dis_ls if len(set(min_combi).intersection(set(i[1]))) == 0]
    if _sum < best:
        best = _sum
print(best)
Problem p03136 (python)

Fixed submission:
N = int(input())
L_ls = [int(i) for i in input().split()]
if sum(L_ls) - 2*max(L_ls) > 0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
L_ls = map(int, input().split())
if sum(L_ls) - 2*max(L_ls) > 0:
  print("Yes")
else:
  print("No")