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

Fixed submission:
a, b, c, d = map(int, input().split())

dist1 = abs(a - b)
dist2 = abs(b - c)

if dist1 <= d and dist2 <= d or abs(a - c) <= d:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
a, b, c, d = map(int, input())

dist1 = abs(a - b)
dist2 = abs(b - c)

if dist1 <= d and dist2 <= d:
    print('Yes')
else:
    print('No')
Problem p03371 (python)

Fixed submission:
A, B, C, X, Y = map(int, input().split())
sum = 0

while X > 0 or Y > 0:
    if X > 0 and Y > 0:
        if A + B > 2 * C:
            sum += 2 * C
            X -= 1
            Y -= 1
        else:
            sum += A + B
            X -= 1
            Y -= 1
    else:
        if X > 0:
            if A > 2 * C:
                sum += 2 * C
                X -= 1
                Y -= 1
            else:
                sum += A
                X -= 1
        else:
            if B > 2 * C:
                sum += 2 * C
                X -= 1
                Y -= 1
            else:
                sum += B
                Y -= 1

print(sum)

Buggy submission (verdict: Runtime Error):
A, B, C, X, Y = map(int, input().split())

while X > 0 or Y > 0:
    if A + B > C:
        sum += C
        X -= 1
        Y -= 1
    else:
        sum += A + B
        X -= 1
        Y -= 1
    if X > 0 and Y > 0:
        continue
    if X > 0:
        if A > C:
            sum += C
            X -= 1
            Y -= 1
        else:
            sum += A
            X -= 1
    else:
        if B > C:
            sum += C
            X -= 1
            Y -= 1
        else:
            sum += B
            Y -= 1

print(sum)
Problem p03475 (python)

Fixed submission:
N = int(input())
C = [0] * (N-1)
S = [0] * (N-1)
F = [0] * (N-1)
for i in range(N-1):
    C[i], S[i], F[i] = map(int, input().split())

for i in range(N):
    time = 0
    for j in range(i, N-1):
        if time < S[j]:
            time = S[j]
        elif time % F[j]:
            time += F[j] - (time % F[j])
        time += C[j]

    print(time)

Buggy submission (verdict: Runtime Error):
N = int(input())
C = [0] * (N-1)
S = [0] * (N-1)
F = [0] * (N-1)
for i in range(N-1):
    C[i], S[i], F[i] = map(int, input().split())

for i in range(N):
    time = 0
    for j in range(i, N-1):
        if time < S[j]:
            time = S[j]
        elif time % F[j]:
            time += F[j] - (t % F[j])
        time += C[j]
        
    print(time)
Problem p03477 (python)

Fixed submission:
A, B, C, D = map(int, input().split())

if A + B > C + D:
    print('Left')
elif A + B == C + D:
    print('Balanced')
else:
    print('Right')

Buggy submission (verdict: Runtime Error):
A = map(int, input().split())

if A + B < C + D:
    print('Left')
elif A + B == C + D:
    print('Balanced')
else:
    print('Right')
Problem p03493 (python)

Fixed submission:
s = input()

print(s.count('1'))

Buggy submission (verdict: Runtime Error):
print(input.count('1'))
Problem p03503 (python)

Fixed submission:
N = int(input())
F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for i in range(N)]
ans = -10**9
v = [0] * 10

def culc():
    global ans
    score = 0
    if any(v) == False:
        return
    for i in range(N):
        index = 0
        for j in range(10):
            index += F[i][j] * v[j]
        score += P[i][index]
    ans = max(ans, score)
    return

def dfs(pos):
    if pos == 10:
        culc()
        return

    v[pos] = 0
    dfs(pos+1)
    v[pos] = 1
    dfs(pos+1)

    return

dfs(0)

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for i in range(N)]
ans = -10**9
v = [0] * 10

def culc():
    global ans
    score = 0
    index = 0
    if any(v) == False:
        return
    for i in range(N):
        for j in range(10):
            index += F[i][j] * v[j]
        score += P[i][index]
    ans = max(ans, score)
    return

def dfs(pos):
    if pos == 10:
        culc()
        return

    v[pos] = 0
    dfs(pos+1)
    v[pos] = 1
    dfs(pos+1)
    
    return

dfs(0)

print(ans)
Problem p03565 (python)

Fixed submission:
S = input()
T = input()

index = []
ss = []
flag = False

for i in range(len(S)-len(T)+1):
    for j in range(len(T)):
        if S[i+j] != T[j] and S[i+j] != '?':
            break
        if j == len(T) - 1:
            flag = True
            index.append(i)

if flag:
    for v in index:
        s = ''
        k = 0
        for i in range(len(S)):
            if v <= i <= v + len(T) - 1:
                s += T[k]
                k += 1
                continue
            if S[i] == '?':
                s += 'a'
            else:
                s += S[i]
        ss.append(s)
    ss.sort()
    s = ss[0]
else:
    s = 'UNRESTORABLE'

print(s)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
change_index = []

for i in range(len(S)-len(T)+1):
    step = 0
    for j in T:
#        if i + step >= len(S):
#            break
        if S[i+step] != j and S[i+step] != '?':
            break
        step += 1
        if step == len(T):
            change_index.append(i)

if len(change_index) or len(T) == 0:
    Sa_list = list(S.replace('?', 'a'))
    for i in change_index[0]:
        step = 0
        for j in T:
            Sa_list[i+step] = j
            step += 1
    Sa = ''.join(Sa_list)
    print(Sa)
else :
    print('UNRESTORABLE')
Problem p03719 (python)

Fixed submission:
A, B, C = map(int, input().split())
if A <= C <= B:
   print("Yes")
else:
   print("No")

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
if A <= C <= B:
   print(“Yes”)
else:
   print(“No”)

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
if A <= C <= B:
   print(“Yes”)
else:
   print(“No”)

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
if A <= C <= B:
  print(“Yes”)
else:
  print(“No”)
Problem p03762 (python)

Fixed submission:
n, m = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

mod = 10 ** 9 + 7

x_sum = 0
for i in range(n-1):
    x_sum += (x[i+1] - x[i]) * (i + 1) * (n - i - 1)
    x_sum %= mod

y_sum = 0
for i in range(m-1):
    y_sum += (y[i+1] - y[i]) * (i + 1) * (m - i - 1)
    y_sum %= mod

print((x_sum * y_sum) % mod)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

mod = 10 ** 9 + 7

x_sum = 0
for i in range(n-1):
    x_sum += (x[i+1] - x[i]) * (i + 1) * (n - i - 1)
    x_sum %= mod

y_sum = 0
for i in range(n-1):
    y_sum += (y[i+1] - y[i]) * (i + 1) * (n - i - 1)
    y_sum %= mod

print((x_sum * y_sum) % mod)
Problem p03779 (python)

Fixed submission:
X = int(input())

sum = 0
for i in range(1, 10**9+1):
    sum += i
    if sum >= X:
        break

print(i)

Buggy submission (verdict: Runtime Error):
X = int(input())

sum = 0
for i in range(1, N):
    sum += i
    if sum >= X:
        break

print(i)
Problem p04019 (python)

Fixed submission:
s = input()

if 'E' in s and 'W' in s:
    if 'N' in s and 'S' in s:
        print('Yes')
    elif 'N' in s or 'S' in s:
        print('No')
    else:
        print('Yes')
elif 'E' in s or 'W' in s:
    print('No')
else:
    if 'N' in s and 'S' in s:
        print('Yes')
    elif 'N' in s or 'S' in s:
        print('No')
    else:
        print('Yes')

Buggy submission (verdict: Runtime Error):
s = input()

if 'E' in s and 'W' in s:
    if 'N' in s and 'S' in s:
        print('Yes')
    elif 'N' in s or in 'S' in s:
        print('No')
    else:
        print('Yes')
elif 'E' in s or 'W' in s:
    print('No')
else:
    print('Yes')
Problem p04045 (python)

Fixed submission:
N, K = map(int, input().split())
D = list(map(int, input().split()))
A = [i for i in range(10)]
A = set(A) - set(D)
A = list(A)
A.sort()
S = str(N)
s = ''
for i in range(len(S)):
    for j in range(len(A)):
        if int(S[i]) == A[j]:
            s += str(A[j])
            break
        if int(S[i]) < A[j]:
            s += str(A[j])
            for i in range(len(S)-i-1):
                s += str(A[0])
            break
    if len(s) == len(S):
        break
            
if len(s) == len(S):
    print(s)
else:
    if A[0] == 0:
        s = str(A[1])
        for i in range(len(S)):
            s += str(A[0])
    else:
        s = str(A[0])
        for i in range(len(S)):
            s += str(A[0])
    print(s)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
D = list(map(int, input().split()))
A = [i for i in range(10)]
A = set(A) - set(D)
A = list(A)
A.sort()
S = str(N)
s = ''
for i in range(len(S)):
    for j in range(len(A)):
        if int(S[i]) <= A[j]:
            s += str(A[j])
            break
if len(s) == len(S):
    print(s)
else:
    if A[0] == 0:
        s = str(A[1])
        for i in range(len(S)):
            s += str(A[0])
    else:
        s = str(A[0])
        for i in range(len(S)):
            s += str(A[1])
    print(s)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
D = list(map(int, input().split()))
A = [i for i in range(10)]
A = set(A) - set(D)
A = list(A)
A.sort()
S = str(N)
s = ''
for i in range(len(S)):
    for j in range(len(A)):
        if int(S[i]) <= A[j]:
            s += str(A[j])
            break
if len(s) == len(S):
    print(s)
else:
    if A[0] == 0:
        s = A[1]
        for i in range(len(S)):
            s += A[0]
    else:
        s = A[0]
        for i in range(len(S)):
            s += A[1]
    print(s)
Problem p02657 (python)

Fixed submission:
a,b = map(int,input().split())
print(a*b)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
s = 1

for i in range(n):
    s *= a[i]

if s <= 10**18:
    print(s)
elif s > 10**18:
    print("-1")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
s = 1

for i in range(n):
    s *= a[i]

if s < 10**18:
    print(s)
elif s > 10**18:
    print(-1)
Problem p02755 (python)

Fixed submission:
A, B = map(int, input().split())

for p in range(13, 1250):
	if int(p * 0.08) == A and int(p * 0.1) == B:
		print(p)
		exit()

print(-1)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input())

for p in range(13, 1250):
	if int(p * 0.08) == A and int(p * 0.1) == B:
		print(p)
		exit()

print(-1)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input())

for p in range(13, A):
	if int(p * 0.08) == A and int(p * 0.1) == B:
		print(p)
		exit()

print(-1)
Problem p03043 (python)

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

ans = 0

for i in range(1,n+1):
    t = 1
    while i * t < k:
        t *= 2
    ans += 1 / t

print(ans / n)

Buggy submission (verdict: Runtime Error):
import math
#負けを考える

n, k = map(int, input().split())
if k == 1:
    p = 1
    print(p)
else:
    h = math.floor(math.log2(k - 1))

    p = 0

    s = [k - 1]
    for i in range(h):
        s.append(math.floor((k - 1) / (2 ** (i + 1))))
    s = s[::-1]
    t = [s[0]]
    for j in range(h):
        t.append(s[j + 1] - s[j])

    t = t[::-1]
    for i in range(len(t)):
        p += t[i] * ((1 / 2) ** (i + 1)) * (1 / n)

    p += (n + 1 - k) / n

    print(p)

Buggy submission (verdict: Runtime Error):
import math
#負けを考える

n, k = map(int, input().split())
h = math.floor(math.log2(k-1))

p = 0

s = [k-1]
for i in range(h):
    s.append(math.floor((k-1) / (2**(i+1))))
s = s[::-1]
t = [s[0]]
for j in range(h):
    t.append(s[j+1] - s[j])

t = t[::-1]
for i in range(len(t)):
    p += t[i] * ((1/2)**(i+1)) * (1/n)

p += (n+1-k)/n

print(p)
Problem p03436 (python)

Fixed submission:
from collections import deque

h, w = map(int, input().split())

maze = [list(input()) for _ in range(h)]
step = [[0] * w for _ in range(h)]
direction = [[1,0],[-1,0],[0,1],[0,-1]]

def bfs(maze,h,w):
    start = [0,0]
    #キューで座標保存
    q = deque([start])
    while q:
        x, y = q.popleft()
        for d in direction:
            nx = x + d[0]
            ny = y + d[1]
            if 0 <= nx < h and 0 <= ny < w and maze[nx][ny] == "." and step[nx][ny] == 0:
                q.append([nx,ny])
                step[nx][ny] = step[x][y] + 1
        if step[h-1][w-1] != 0:
            return step[h-1][w-1]
    return -1

#壁の数
wall = 0
for i in maze:
    for j in i:
        if j == "#":
            wall += 1
if bfs(maze,h,w) >= 0:
    ans = h * w - wall - (bfs(maze,h,w) + 1)
else:
    ans = -1
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque

h, w = map(int, input().split())

maze = [list(input()) for _ in range(h)]
step = [[0] * w for _ in range(h)]
direction = [[1,0],[-1,0],[0,1],[0,-1]]

def bfs(maze,h,w):
    start = [0,0]
    #キューで座標保存
    q = deque([start])
    while q:
        x, y = q.popleft()
        for d in direction:
            nx = x + d[0]
            ny = y + d[1]
            if 0 <= nx < h and 0 <= ny < w and maze[nx][ny] == "." and step[nx][ny] == 0:
                q.append([nx,ny])
                step[nx][ny] = step[x][y] + 1
        if step[h-1][w-1] != 0:
            return step[h-1][w-1]

#壁の数
wall = 0
for i in maze:
    for j in i:
        if j == "#":
            wall += 1

ans = h * w - wall - (bfs(maze,h,w) + 1)
print(ans)
Problem p03455 (python)

Fixed submission:
a,b = map(int, input().split())
print("Even" if ( a * b ) % 2 == 0 else "Odd")

Buggy submission (verdict: Runtime Error):
a,b = input().split()
print("Even" if (a*b)//2 == 0 else "Odd")
Problem p03478 (python)

Fixed submission:
N, A, B = map(int, input().split())

Num = 0
for i in range(1, N+1):
    List = [int(a) for a in list(str(i))]
    if A <= sum(List) <= B:
        Num += i

print(Num)

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())

Num = 0
for i in range(N+1):
    list = [int(a) for a in list(str(i))]
    if sum(list) >= A and sum(list) <= B:
        Num += 1
Problem p02585 (python)

Fixed submission:
def mss(l,length,k):
    x = - 1000000001
    for i in range(length):
        temp = 0
        for j in range(i,i+k):
            temp += l[j]
            if temp > x:
                x = temp
    return x
  
def mss2(l,length,total,k):
    x = - 1000000001
    if k <= length:
      for i in range(length):
          temp = 0
          for j in range(i,i+k):
              temp += l[j]
              if temp > x:
                  x = temp
      return x
    else:
      for i in range(length):
          temp = 0
          for j in range(i,i+length):
              temp += l[j]
              r = j - i + 1
              if temp + (total * ((k-r) // length)) > x:
                  x = temp + (total * ((k-r) // length))
      return x
      

if __name__ == '__main__':
    N,K = map(int,input().split())
    P = [int(p)-1 for p in input().split()]
    C = [int(c) for c in input().split()]
    #閉路の探索
    L_close = []
    Done = [0] * N
    for i in range(N):
        if Done[i] == 1:
            continue
        score = []
        #start
        Done[i] = 1
        #Next
        p = P[i]
        Done[p] = 1
        score.append(C[p])
        while p != i:
            p = P[p]
            Done[p] = 1
            score.append(C[p])
        L_close.append(score)
    #それぞれの閉路に対して
    ans = - 1000000001
    for l in L_close:
        total = sum(l)
        length = len(l)
        l = l + l
        if total <= 0:
            ans = max(ans,mss(l,length,min(K,length)))
        else:
            ans = max(ans,mss2(l,length,total,K))
    print(ans)

Buggy submission (verdict: Runtime Error):
def mss(l,length,k):
    x = 0
    for i in range(length):
        temp = 0
        for j in range(i,i+k-1):
            temp += l[j]
            if temp > x:
                x = temp
    return x

if __name__ == '__main__':
    N,K = map(int,input().split())
    P = [int(p)-1 for p in input().split()]
    C = [int(c) for c in input().split()]
    #閉路の探索
    L_close = []
    Done = [0] * N
    for i in range(N):
        if Done[i] == 1:
            continue
        score = []
        #start
        Done[i] = 1
        #Next
        p = P[i]
        Done[p] = 1
        score.append(C[p])
        while p != i:
            p = P[p]
            Done[p] = 1
            score.append(C[p])
        L_close.append(score)
    #それぞれの閉路に対して
    ans = 0
    for l in L_close:
        total = sum(l)
        length = len(l)
        l = l + l
        if total <= 0:
            ans = max(ans,mss(l,length,K))
        else:
            ans = max(ans,total * (K//length) + mss(l,length,K%length))
    print(ans)
Problem p02600 (python)

Fixed submission:
X = int(input())
print(8 - ((X-400)//200))

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
    N = int(input())
    l = []
    S = []; X = []; Y = []; P = []
    ans = 0
    for _ in range(N):
        x,y,p = map(int,input().split())
        s = p * min(abs(x),abs(y))
        ans += s
        S.append(s)
        X.append(x); Y.append(y); P.append(p)
    print(ans)
    l_S = []
    for i in range(N*2):
        if i < N:
            x = X[i]
            S_temp = []
            temp = 0
            for j in range(N):
                m = min(S[j],P[j] * (abs(X[j]-x)))
                S_temp.append(m)
                temp += m
            if ans > temp:
                 ans = temp
        else:
            y = Y[i-N]
            S_temp = []
            temp = 0
            for j in range(N):
                m = min(S[j],P[j] * (abs(Y[j]-y)))
                S_temp.append(m)
                temp += m
            if ans > temp:
                 ans = temp
        l_S.append(S_temp)
    print(ans)
    memo = [n for n in range(2 * N)]
    l_S0 = l_S
    for _ in range(N-1):
        if ans == 0:
          print(0)
          continue
        l_S1 = []
        newMemo = []
        for j in range(len(l_S0)):
            for k in range(memo[j]+1, N * 2):
                l = l_S[k]
                l0 = l_S0[j]
                S_temp = []
                temp = 0
                for h in range(N):
                    m = min(l[h],l0[h])
                    S_temp.append(m)
                    temp += m
                if ans > temp:
                     ans = temp
                l_S1.append(S_temp)
                newMemo.append(k)
        memo = newMemo
        l_S0 = l_S1
        print(ans)
Problem p02619 (python)

Fixed submission:
#入力
D = int(input())
C = [int(c) for c in input().split()]
S = []
for _ in range(D):
    s = [int(x) for x in input().split()]
    S.append(s)
T = []
for _ in range(D):
    t = int(input()) - 1
    T.append(t)
    
#スコア計算
score = 0
last_day = [-1] * 26
for t in range(D):
    test = T[t]
    score += S[t][test]
    last_day[test] = t
    for i in range(26):
        score -= (C[i] * (t - last_day[i]))
    print(score)

Buggy submission (verdict: Runtime Error):
#入力
D = int(input())
C = [int(c) for c in input().split()]
S = []
for _ in range(D):
    s = [int(x) for x in input().split()]
    S.append(s)
T = []
for _ in range(D):
    t = int(input()) - 1
    T.append(t)
    
＃スコア計算
score = 0
last_day = [-1] * 26
for t in range(D):
    test = T[t]
    score += S[t][test]
    last_day[test] = t
    for i in range(26):
        score -= (C * (t - last_day[i]))
    print(score)
Problem p02606 (python)

Fixed submission:
R,L,d = map(int, input().split())
counter = 0
for i in range(R, L+1):
  if i%d == 0:
    counter += 1
print(counter)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
counter = 0
for i in range((len(a)+1)//2):
  if a[i*2]%2 == 1:
    counter += 1
print(counter)
Problem p03035 (python)

Fixed submission:
A,B = map(int, input().split())
if A>= 13:
    print(B)
elif A>=6:
    print(B//2)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
A,B = map(int, input().split())
if a>= 13:
    print(B)
elif a>=6:
    print(B//2)
else:
    print(0)
Problem p03078 (python)

Fixed submission:
from heapq import heappush, heappop

# input
X,Y,Z,K = map(int, input().split())
a_list = [int(i) for i in input().split()]
b_list = [int(i) for i in input().split()]
c_list = [int(i) for i in input().split()]
a_list.sort(reverse = True)
b_list.sort(reverse = True)
c_list.sort(reverse = True)

#solve
hq = []
arg_hash = {}
val = a_list[0] + b_list[0] + c_list[0]
heappush(hq, (-val,0,0,0))

for i in range(K):
    ans, a, b, c = heappop(hq)
    print(-ans)

    arg_a = (a+1, b, c)
    arg_b = (a, b+1, c)
    arg_c = (a, b, c+1)

    if a < X-1 and arg_a not in arg_hash:
        arg_hash[arg_a] = 1
        heappush(hq, (-(a_list[a+1]+b_list[b]+c_list[c]),)+arg_a)
    if b < Y-1 and arg_b not in arg_hash:
        arg_hash[arg_b] = 1
        heappush(hq, (-(a_list[a]+b_list[b+1]+c_list[c]),)+arg_b)
    if c < Z-1 and arg_c not in arg_hash:
        arg_hash[arg_c] = 1
        heappush(hq, (-(a_list[a]+b_list[b]+c_list[c+1]),)+arg_c)

Buggy submission (verdict: Runtime Error):
X,Y,Z,K = map(int, input().split())
a_list = [int(i) for i in input().split()]
b_list = [int(i) for i in input().split()]
c_list = [int(i) for i in input().split()]
a_list.sort(reverse = True)
b_list.sort(reverse = True)
c_list.sort(reverse = True)
total_list = [0 for _ in range(min(106307,X*Y*Z))]
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1) <= K:
                total_list[i*(Z*Y)+j*Z+k] = (a_list[i] + b_list[j] + c_list[k])
            else:
                break
total_list =  sorted(total_list, reverse = True)
for i in range(K):
    print(total_list[i])

Buggy submission (verdict: Runtime Error):
X,Y,Z,K = map(int, input().split())
a_list = [int(i) for i in input().split()]
b_list = [int(i) for i in input().split()]
c_list = [int(i) for i in input().split()]
a_list.sort(reverse = True)
b_list.sort(reverse = True)
c_list.sort(reverse = True)
total_list = [0 for _ in range(min(106307,X*Y*Z))]
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1) <= K:
                total_list[i*(Z*Y)+j*Z+k] = (a_list[i] + b_list[j] + c_list[k])
            else:
                break
total_list =  sorted(total_list, reverse = True)
for i in range(K):
    print(total_list[i])

Buggy submission (verdict: Runtime Error):
X,Y,Z,K = map(int, input().split())
a_list = [int(i) for i in input().split()]
b_list = [int(i) for i in input().split()]
c_list = [int(i) for i in input().split()]
a_list.sort(reverse = True)
b_list.sort(reverse = True)
c_list.sort(reverse = True)
total_list = [0 for _ in range(min(106307,X*Y*Z))]
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1) <= K:
                total_list[i*(Z*Y)+j*Z+k] = (a_list[i] + b_list[j] + c_list[k])
            else:
                break
print(total_list)
total_list =  sorted(total_list, reverse = True)
for i in range(K):
    print(total_list[i])
Problem p03106 (python)

Fixed submission:
a, b, k = map(int, input().split())
count = 0
ans = min(a,b)
while count != k:
    if a%ans == b %ans == 0:
        count += 1
    ans -= 1
print(ans+1)

Buggy submission (verdict: Runtime Error):
from sympy import gcd
a, b, k = map(int, input().split())
c = gcd(a,b)
count = 0
for i in range(1,c+1):
    if c%i == 0:
        count += 1
    if count == k:
        ans = i
        break
print(ans)

Buggy submission (verdict: Runtime Error):
import math
a, b, k = map(int, input().split())
c = math.gcd(a,b)
count = 0
for i in range(1,c+1):
    if c%i == 0:
        count += 1
    if count == k:
        ans = i
        break
print(ans)