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

Fixed submission:
N = int(input())
H = int(input())
W = int(input())

print((N-H+1)*(N-W+1))

Buggy submission (verdict: Runtime Error):
import sys 

sys.setrecursionlimit(100000000)

def dfs(row, column, black):
    global S, H, W, X, Y, visited, ans
    if black:
        for dx, dy in zip(X, Y):
            n_row = row + dx
            n_column = column + dy
            if 0 <= n_row < H and 0 <= n_column < W:
                if visited[n_row][n_column] == False and S[n_row][n_column] == '.':
                    visited[n_row][n_column] = True
                    ans += 1
                    dfs(n_row, n_column, False)
    
    else:
        for dx, dy in zip(X, Y):
            n_row = row + dx
            n_column = column + dy
            if 0 <= n_row < H and 0 <= n_column < W:
                if visited[n_row][n_column] == False and S[n_row][n_column] == '#':
                    visited[n_row][n_column] = True
                    dfs(n_row, n_column, True)






if __name__ == "__main__":
    H, W = map(int, input().split())

    S = [None] * H
    X = [0, 0, 1, -1]
    Y = [1, -1, 0, 0]
    for i in range(H):
        S[i] = list(input())
    black_row = []
    black_column = []
    for row in range(H):
        for column in range(W):
            if S[row][column] == "#":
                black_row.append(row)
                black_column.append(column)
    ans = 0
    for row, column in zip(black_row, black_column):
        visited = [[False] * W for i in range(H)]
        dfs(row, column, True)
    print(ans)
Problem p03163 (python)

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

weight = [None] * N
value  = [None] * N

for i in range(N):
    w, v = map(int, input().split())
    weight[i] = w
    value[i]  = v

dp = [[None] * (W+1) for _ in range(N+1)]
for i in range(W+1):
    dp[0][i] = 0
for v in range(N):
    for w in range(W+1):
        if w >= weight[v]:
            dp[v+1][w] = max(dp[v][w-weight[v]] + value[v], dp[v][w])
        else:
            dp[v+1][w] = dp[v][w]
print(dp[N][W])

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

weight = [None] * N
value  = [None] * N

for i in range(N):
    w, v = map(int, input().split())
    weight[i] = w
    value[i]  = v

dp = [[None] * (W+1) for _ in range(N+1)]
for i in range(W+1):
    dp[0][i] = 0
for v in range(N):
    for w in range(1, W+1):
        if w >= weight[v]:
            dp[v+1][w] = max(dp[v][w-weight[v]] + value[v], dp[v][w])
        else:
            dp[v+1][w] = dp[v][w]
print(dp[N][W])
Problem p03194 (python)

Fixed submission:
import math
def make_prime_list(num):
    if num < 2:
        return []
    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break
        
        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0
    return [prime for prime in prime_list if prime != 0]

def prime_factorization(num):
    if num <= 1:
        return {1 : 1}
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list(num_sqrt)

        dict_counter = {}
        for prime in prime_list:
            while num % prime == 0:
                if prime in dict_counter:
                    dict_counter[prime] += 1
                else:
                    dict_counter[prime] = 1
                num //= prime
        if num != 1:
            if num in dict_counter:
                dict_counter[num] += 1
            else:
                dict_counter[num] = 1
        return dict_counter




if __name__ == '__main__':
    N, P = map(int, input().split())

    d = prime_factorization(P)

    cnt = 1

    for key, value in d.items():
        while value >= N :
            cnt *= key
            value -= N
    if N == 1:
        print(P)
    else:
        print(cnt)

Buggy submission (verdict: Runtime Error):
import math
def make_prime_list(num):
    if num < 2:
        return []
    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break
        
        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0
    return [prime for prime in prime_list if prime != 0]

def prime_factorization(num):
    if num <= 1:
        return False
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list(num_sqrt)

        dict_counter = {}
        for prime in prime_list:
            while num % prime == 0:
                if prime in dict_counter:
                    dict_counter[prime] += 1
                else:
                    dict_counter[prime] = 1
                num //= prime
        if num != 1:
            if num in dict_counter:
                dict_counter[num] += 1
            else:
                dict_counter[num] = 1
        return dict_counter




if __name__ == '__main__':
    N, P = map(int, input().split())

    d = prime_factorization(P)

    cnt = 1

    for key, value in d.items():
        if value >= N:
            cnt *= key

    print(cnt)
Problem p03210 (python)

Fixed submission:
N = int(input())

if N == 3 or N == 5 or N == 7:
	print("YES")
else:
	print("NO")

Buggy submission (verdict: Runtime Error):
N = ini(input())

if N == 3 or N == 5 or N == 7:
	print("YES")
else:
	print("NO")
Problem p03219 (python)

Fixed submission:
X, Y = map(int, input().split())
print(int(X + Y/2))

Buggy submission (verdict: Runtime Error):
import numpy as np

N, M = map(int, input().split())
P = [None] * (N+1)
Y = [None] * (N+1)
for i in range(M):
    p, y = map(int, input().split())
    P[i] = p
    Y[i] = y
P = np.array(P)
Y = np.array(Y)
PY = np.c_[P, Y]
sort_ind = np.argsort(Y)
PY_sort = PY[sort_ind]
count = [0] * (N+1)
id_list = [None] * (N+1)
for i, py in enumerate(PY_sort):
    count[py[0]] += 1
    id_list[i] = (str(py[0]).zfill(6) + str(count[py[0]]).zfill(6))
id_list = np.array(id_list)
id_list = id_list[np.argsort(sort_ind)]
for city_id in id_list:
    print(city_id)
Problem p03229 (python)

Fixed submission:
def create_sum(N):
    list_align = [2 for _ in range(N)]
    for i in range(N):
        if i % 2 == 0:
            list_align[i] *= -1
    list_align[0] //= 2
    list_align[N-1] //= 2
    list_align.sort()
    return list_align

def solve(N, Array):
    sum1 = 0
    sum2 = 0
    arr = create_sum(N)
    for i in range(N):
        sum1 += arr[i] * Array[i]
        sum2 += arr[i] * Array[N-1-i]
    print(max(abs(sum1), abs(sum2)))
    
if __name__ == "__main__":
    N = int(input())
    A = [int(input()) for _ in range(N)]
    A.sort()
    solve(N, A)

Buggy submission (verdict: Runtime Error):
def neighbor_sum(N, A):
    A_1 = [] 
    A_2 = []
    i = 0
    j = N-1
    change = True
    while i < j:
        if change == True:
            A_1.append(A[i])
            A_2.append(A[j])
            i += 1
            j -= 1
            change = False
        else:
            A_1.append(A[j])
            A_2.append(A[i])
            i += 1
            j -= 1
            change = True
        if N % 2 == 1:
            if change == True:
                A_1.append(A[N//2])
            else:
                A_2.append(A[N//2])
        return A_1[::-1] + A_2[:]

if __name__ == "__main__":
    N = int(input())
    A = [int(input()) for _ in range(N)]
    A.sort()
    diff = neighbor_sum(N, A)
    diff_sum = [abs(diff[i+1] - diff[i]) for i in range(N-1)]
    print(sum(diff_sum))

Buggy submission (verdict: Runtime Error):
def neighbor_sum(N, A):
    A_1 = [] 
    A_2 = []
    i = 0
    j = N-1
    change = True
    while i < j:
        if change == True:
            A_1.append(A[i])
            A_2.append(A[j])
            i += 1
            j -= 1
            change = False
        else:
            A_1.append(A[j])
            A_2.append(A[i])
            i += 1
            j -= 1
            change = True
        return A_1[::-1] + A_2[:]

if __name__ == "__main__":
    N = int(input())
    A = [int(input()) for _ in range(N)]
    A.sort()
    diff = neighbor_sum(N, A)
    diff_sum = [abs(diff[i+1] - diff[i]) for i in range(N-1)]
    print(sum(diff_sum))
Problem p03231 (python)

Fixed submission:
def gcb(A, B):
    while B != 0:
        A, B = B, A%B
    return A

N, M = map(int, input().split())
S = input()
T = input()
can = True
agc = N // gcb(N, M) * M
L_N = agc // N
L_M = agc // M
i = 0
while i*L_M < N and i*L_N < M:
    if S[i*L_M] != T[i*L_N]:
        can = False
        break
    i += 1

if can:
    print(agc)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
def gcd(A, B):
    while B != 0:
        A, B = B, A%B
    return A

N, M = map(int, input().split())
S = input()
T = input()
can = True
agc = N // gcd(N, M) * M
L_N = agc // N
L_M = agc // M
i = 0

while i*L_M < agc and i*L_N < agc:
    if S[i*L_M] != T[i*L_N]:
        can = False
        break
    i += 1

if can:
    print(agc)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
def gcd(A, B):
    while B != 0:
        A, B = B, A%B
    return A

N, M = map(int, input().split())
S = input()
T = input()
can = True
agc = N * M // gcd(N, M)
L_N = agc // N
L_M = agc // M
i = 0

while i*L_M < agc and i*L_N < agc:
    if S[i*L_M] != T[i*L_N]:
        can = False
        break
    i += 1

if can:
    print(agc)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
def gcd(A, B):
    while B != 0:
        A, B = B, A%B
    return A

N, M = map(int, input().split())
S = input()
T = input()
agc = N * M // gcd(N, M)
can = True
i = 0
while i*L_M < agc and i*L_N < agc:
    if S[i*L_M] != T[i*L_N]:
        can = False
        break
    i += 1
    if can:
    print(agc)
else:
    print(-1)
Problem p03238 (python)

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

Buggy submission (verdict: Runtime Error):
N = int(input())
A = int(input())
B = int(input())
if N == 1:
    print("Hello World")
else:
    print(A + B)
Problem p03239 (python)

Fixed submission:
N, T = map(int, input().split())
A = []
for i in range(N):
    temp , B = map(int, input().split())
    if B <= T:
        A.append(temp)
if not A:
    print("TLE")
else:
    print(min(A))

Buggy submission (verdict: Runtime Error):
N, T = map(int, input().split())
A = []
for i in range(N):
    temp , B = map(int, input().split())
    if B <= T:
        A.append(temp)
if not A:
    print("TLE")
else:
    print(A.min())
Problem p03240 (python)

Fixed submission:
import numpy as np

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

for j in range(101):
    for k in range(101):
        needH = -1
        for i in range(N):
            if a[i][2] > 0:
                temp = a[i][2] + np.abs(a[i][0] - j) + np.abs(a[i][1] - k)
                if needH == -1:
                    needH = temp
                else:
                    if needH != temp:
                        needH = -2
                        break
        if needH == -2:
            continue
            
        for i in range(N):
            if a[i][2] == 0:
                dist = np.abs(a[i][0] - j) + np.abs(a[i][1] - k)
                if needH > dist:
                    needH = -2
                    break
        if needH == -2:
            continue
            
        print("{} {} {}\n".format(j, k, needH))

Buggy submission (verdict: Runtime Error):
import numpy as np

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

for j in range(101):
    for k in range(101):
        can = True
        needH = a[0][2] + np.abs(a[0][0] - j) + np.abs(a[0][1] - k)
        for i in range(N):
            if a[i][2] > 0:
                if  a[i][2] != needH - np.abs(a[i][0] - j) - np.abs(a[i][1] - k):
                    can = False
                    break
        if can == False:
            continue
        for i in range(N):
            if a[i][2] == 0:
                if  first > np.abs(a[i][0] - j) - np.abs(a[i][1] - k):
                    can = False
                    break
        if can:
            print("{} {} {}\n".format(j, k, first))
Problem p03244 (python)

Fixed submission:
import collections

n = int(input())
v = list(map(int, input().split()))

if len(list(set(v))) == 1:
    print(int(n/2))
    exit()
    
v1 = []
v2 = []
for i in range(n):
    if i%2:
        v1.append(v[i])
    else:
        v2.append(v[i])
v1 = collections.Counter(v1)
v2 = collections.Counter(v2)

v1_cnt = v1.most_common()
v2_cnt = v2.most_common()

if len(v1_cnt) > 1:
    e1 = v1_cnt[0]
    e2 = v1_cnt[1]
else:
    e1 = v1_cnt[0]
    e2 = e1
if len(v2_cnt) > 1:
    d1 = v2_cnt[0]
    d2 = v2_cnt[1]
else:
    d1 = v2_cnt[0]
    d2 = d1

if e1[0] != d1[0]:
    print(n - e1[1] - d1[1])
else:
    more = max(e1[1] + d2[1], e2[1] + d1[1])
    print(n - more)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())

v = list(map(int,input().split()))
v1 = []
v2 = []
len_v = len(v)

for i in range(len_v):
        if i % 2:
            v1.append(v[i])
        else:
            v2.append(v[i])

v1_unique = np.array(list(set(v1)))
v2_unique = np.array(list(set(v2)))

v1_cnt = []
v2_cnt = []

for i in range(len(v1_unique)):
    cnt = 0
    for j in range(int(len_v / 2)):
        if v1[j] == v1_unique[i]:
            cnt += 1
    v1_cnt.append(cnt)

for i in range(len(v2_unique)):
    cnt = 0
    for j in range(int(len_v / 2)):
        if v2[j] == v2_unique[i]:
            cnt += 1
    v2_cnt.append(cnt)

v1_unique[np.argsort(v1_cnt)]
v2_unique[np.argsort(v2_cnt)]
np.sort(v1_cnt)
np.sort(v2_cnt)

if v1_unique[-1] != v2_unique[-1]:
    print(n - v1_cnt[-1] - v2_cnt[-1])
else:
    if len(v1_unique) == 1 and len(v2_unique) == 1:
        print(int(len_v / 2))
    else:
        print(max(n - v1_cnt[-1] - v2_[-2], n - v1_cnt[-2] -v2_cnt[-1]))
Problem p03262 (python)

Fixed submission:
def gcd(A, B):
    if A%B == 0:
        return B
    else:
        return gcd(B, A%B)
N, X = map(int, input().split())
x = [abs(int(i) - X) for i in input().split()] 
if N == 1:
    print(x[0])
    exit()
gcd_x = []
for i in range(N-1):
    gcd_x.append(gcd(x[i], x[i+1]))
print(min(gcd_x))

Buggy submission (verdict: Runtime Error):
def gcd(A, B):
    while B != 0:
        A, B = B, A%B
    return A
N, X = map(int, input().split())
x = [abs(int(i) - X) for i in input().split()] 
y = x[0]
for i in range(N):
    if x[i] % y == 0:
        continue
    y = gcd(y, x[i])
print(min(gcd_x))
Problem p03323 (python)

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

if a <= 8 and b <= 8:
  print('Yay!')
else:
  print(':(')

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a <= 8 and b <= 8:
  print('Yay!')
else:
  print(':(')

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a <= 8 and b <= 8:
  print('Yay!')
else:
  print(':(')
Problem p03331 (python)

Fixed submission:
def digit_sum(x):
    sum = 0
    while x :
        sum += x % 10
        x = int(x / 10)
    return sum

N = int(input())
l = [ digit_sum(x) for x in range(1, N+1)]

sum_a_b = []
if N % 2 == 0:
    sum_a_b.append(l[int(N/2)-1]*2)

for i in range(1, int(N/2)):
    sum_a_b.append(l[i-1] + l[N-i-1])

print(min(sum_a_b))

Buggy submission (verdict: Runtime Error):
def digit_sum(x):
    sum = 0
    while x :
        sum += x % 10
        x = int(x / 10)
    return sum

N = int(input())
l = [ digit_sum(x) for x in range(1, N+1)]

sum_a_b = []

for i in range(1, int(N/2)):
    sum_a_b.append(l[i-1] + l[N-i-1])

print(min(sum_a_b))
Problem p03337 (python)

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

print('{}'.format(max([A+B,A-B,A*B])))

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

print('{}'.format(max([A+B,A-B,A*B,A/B])))
Problem p03359 (python)

Fixed submission:
a , b = (int(i) for i in input().split())
if a <= b :
    print('{}'.format(a))
else:
    print('{}'.format(a-1))

Buggy submission (verdict: Runtime Error):
a , b = (int(i) for i in input().split())
if a <= b :
    print('{}'.format(a)
else :
    print('{}'.format(a-1))

Buggy submission (verdict: Runtime Error):
a , b = (int(i) for i in input().split())
if a <= b :
    print('{}'.format(a)
else :
    print('{}'.format(a-1))

Buggy submission (verdict: Runtime Error):
a , b = (int(i) for i in input().split())
if a >= b :
    print('{}'.format(a)
else b < a :
    print('{}'.format(b))
Problem p03379 (python)

Fixed submission:
N = int(input())
X = list(map(int,input().split()))
X_sort = sorted(X)
N_half = int(N/2)
median_large = X_sort[N_half]
median_small = X_sort[N_half-1]
if median_large == median_small:
    for _ in range(N):
        print(median_large)
else:
    for i in range(N):
        if X[i] <= median_small:
            print(median_large)
        elif X[i] >= median_large:
            print(median_small)

Buggy submission (verdict: Runtime Error):
N = int(input())
X = list(map(int,input().split()))
X_sort = sorted(X)
N_half = int(N/2)
median_large = X_sort[N_half+1]
median_small = X_sort[N_half]
if median_large == median_small:
    for _ in range(N):
        print(median_large)
else:
    for i in range(N):
        if X[i] <= median_small:
            print(median_large)
        elif X[i] >= median_large:
            print(median_small)
Problem p03385 (python)

Fixed submission:
S = str(input() )
if ('a' in S) == ('b' in S) == ('c' in S) == True: 
    print('Yes')
else :
    print('No')

Buggy submission (verdict: Runtime Error):
S = input()
a = s.find('a')  # indexは1(2文字目)
b = s.find('b')  # indexは1(2文字目)
c = s.find('c')  # indexは1(2文字目)

if a != b != c :
    print('Yes')
else :
    print('No')
Problem p03423 (python)

Fixed submission:
print('{}'.format(int(input())//3))

Buggy submission (verdict: Runtime Error):
print('{}'.fotmat(int(input())//3))
Problem p03485 (python)

Fixed submission:
a,b = map(int,input().split())
print(-(-(a+b)//2))

Buggy submission (verdict: Runtime Error):
print((int(input())+int(input()))//2)
Problem p03489 (python)

Fixed submission:
N = int(input())
l = list(map(int, input().split()))
unique_l = list(set(l))
unique_l.sort()
l.sort()
l.append(0)
ans = 0
j = 0
cnt =[]
for i in unique_l:
    temp = 0
    while l[j] == i and j < N:
        temp += 1
        j += 1
    cnt.append(temp)
for i, j in zip(unique_l, cnt):
    if i == j:
        pass
    elif j > i:
        ans += j - i
    elif j < i:
        ans += j
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
j = 0
for i in unique_l:
    cnt = 0
    
    while l[j] == i and j < len(l):
        cnt += 1
        j += 1
    j += 1
    if cnt == i:
        pass
    elif cnt > i:
        ans += cnt - 1
    elif cnt < i:
        ans += cnt
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
l = list(map(int, input().split()))
N_MAX =  int(1e+5 + 1)
cnt = [0 for _ in range(N_MAX)]
for i in l:
    cnt[i] += 1
ans = 0
for idx, val in enumerate(cnt):
    if val == 0 or val == idx:
        pass
    elif val < idx:
        ans += val
    elif idx < val:
        ans += val - idx
print(ans)
Problem p03563 (python)

Fixed submission:
a = int(input())
g = int(input())

print('{}'.format((2*g-a)))

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
if a>=b:
    print('{}'.format((a+b)/2))
else :
    print('{}'.format((b-a)/2))
Problem p03597 (python)

Fixed submission:
print('{}'.format(int(input())**2-int(input())))

Buggy submission (verdict: Runtime Error):
print('{}'.format(int(input())**2-int(input()))
Problem p03657 (python)

Fixed submission:
a , b = map(int, input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
    print('Possible')
else:
    print('Impossible')

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    l = list(map(int, input().split()))
    ans = []
    X = sum(l)
    x = 0
    for i in range(N-1):
        x += l[i]
        ans.append(abs(X-2*x))
    print(min(ans))
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    l = list(map(int, input().split()))
    ans = []
    X = sum(l)
    for i in range(N-1):
      	X = abs(X-2*l[i])
        ans.append(X)
    print(min(ans))
if __name__ == '__main__':
    main()
Problem p03659 (python)

Fixed submission:
def main():
    N = int(input())
    l = list(map(int, input().split()))
    ans = []
    sunuke = 0
    arai = sum(l)
    for i in range(N-1):
        sunuke += l[i]
        arai   -= l[i]
        ans.append(abs(sunuke-arai))
    print(min(ans))
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    l = list(map(int, input().split()))
    ans = []
    X = sum(l)
    for i in range(N-1):
      	X = abs(X-2*l[i])
        ans.append(X)
    print(min(ans))
if __name__ == '__main__':
    main()
Problem p03713 (python)

Fixed submission:
H, W = map(int, input().split())

S_list = []
for h in range(1, H):
    w = W//2
    S_A = h*W
    S_B = (H-h)*w
    S_C = (H-h)*(W-w)
    S_list.append(max(S_A,S_B,S_C) -min(S_A,S_B,S_C))
for h in range(1, H):
    S_A = h*W
    S_B = ((H-h)//2)*W
    S_C = -(-(H-h)//2)*W
    S_list.append(max(S_A,S_B,S_C) -min(S_A,S_B,S_C))
H, W = W, H
for h in range(1, H):
    w = W//2
    S_A = h*W
    S_B = (H-h)*w
    S_C = (H-h)*(W-w)
    S_list.append(max(S_A,S_B,S_C) -min(S_A,S_B,S_C))
for h in range(1, H):
    S_A = h*W
    S_B = ((H-h)//2)*W
    S_C = -(-(H-h)//2)*W
    S_list.append(max(S_A,S_B,S_C) -min(S_A,S_B,S_C))
print(min(S_list))

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

S_list = []
for h in range(1, H-1):
    w = W//2
    S_A = h*W
    S_B = (H-h)*w
    S_C = (H-h)*(W-w)
    S_list.append(max(S_A,S_B,S_C) -min(S_A,S_B,S_C))
for h in range(1, H-1):
    S_A = h*W
    S_B = ((H-h)//2)*W
    S_C = -(-(H-h)//2)*W
    S_list.append(max(S_A,S_B,S_C) -min(S_A,S_B,S_C))
H, W = W, H
for h in range(1, H-1):
    w = W//2
    S_A = h*W
    S_B = (H-h)*w
    S_C = (H-h)*(W-w)
    S_list.append(max(S_A,S_B,S_C) -min(S_A,S_B,S_C))
for h in range(1, H-1):
    S_A = h*W
    S_B = ((H-h)//2)*W
    S_C = -(-(H-h)//2)*W
    S_list.append(max(S_A,S_B,S_C) -min(S_A,S_B,S_C))
print(min(S_list))

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

S_list = []
for i in range(1, H-1):
    w = W//2
    S_A = i*W
    S_B = (H-i)*w
    S_C = (H-i)*(W-w)
    S_list.append(max(S_A,S_B,S_C) -min(S_A,S_B,S_C))
for i in range(1, W-1):
    h = H//2
    S_A = i*H
    S_B = (W-i)*h
    S_C = (W-i)*(H-h)
    S_list.append(max(S_A,S_B,S_C) -min(S_A,S_B,S_C))
print(min(S_list))

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

if H % 3 == 0 or W % 3 == 0:
    print(0)
else:
    S_list = []
    for i in range(1, H-1):
        w = W//2
        S_A = i*W
        S_B = (H-i)*w
        S_C = (H-i)*(W-w)
        S_list.append(max(S_A,S_B,S_C) -min(S_A,S_B,S_C))
    for i in range(1, W-1):
        h = H//2
        S_A = i*H
        S_B = (W-i)*h
        S_C = (W-i)*(H-h)
        S_list.append(max(S_A,S_B,S_C) -min(S_A,S_B,S_C))
    print(min(S_list))
Problem p03721 (python)

Fixed submission:
def main():
    len_s = 0
    ans = -1
    dic = {}
    N, K = map(int, input().split())
    for _ in range(N):
        a, b = map(int, input().split())
        if a not in dic:
            dic[a] = b
        else:
            dic[a] += b
    dic = sorted(dic.items())
    for key, value in dic:
        len_s += value
        if len_s >= K and ans == -1:
            ans = key
    print(ans)
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    len_s = 0
    ans = -1
    dic = {}
    N, K = map(int, input().split())
    for _ in range(N):
        a, b = map(int, input().split())
        if a not in dic:
            dic[a] = b
        else:
            dic[a] = b + dic[a].values
    dic = sorted(dic.items())
    for key, value in dic:
        len_s += value
        if len_s >= K and ans == -1:
            ans = key
    print(ans)
if __name__ == '__main__':
    main()