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

Fixed submission:
from collections import deque
def main():
    X, Y, A, B, C = map(int, input().split())
    
    apple = []
    red = sorted(map(int, input().split()), reverse=True)[:X]
    green = sorted(map(int, input().split()), reverse=True)[:Y]
    nocolor = list(map(int, input().split()))
    apple.extend(red)
    apple.extend(green)
    apple.extend(nocolor)
    
    print(sum(sorted(apple, reverse=True)[:X+Y]))      
        

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from collections import deque
def main():
    X, Y, A, B, C = map(int, input().split())
    
    red = deque(sorted(map(int, input().split()), reverse=True))
    green = deque(sorted(map(int, input().split()), reverse=True))
    nocolor = deque(sorted(map(int, input().split()), reverse=True))

    INF = 10 ** 9 + 1
    times = A + B + C - (X + Y)
    for _ in range(times):
        red_num = len(red)
        green_num = len(green)
        nocolor_num = len(nocolor)

        if red_num and red_num + nocolor_num > X:
            r = red[-1]
        else:
            r = INF
        
        if green_num and green_num + nocolor_num > Y:
            g = green[-1]
        else:
            g = INF
        
        if nocolor_num:
            no = nocolor[-1]
        else:
            no = INF
        
        l = [no, r, g]
        idx = l.index(min(l))
        if idx == 0:
            red.pop()
        if idx == 1:
            green.pop()
        if idx == 2:
            nocolor.pop()

    print(sum(red) + sum(green) + sum(nocolor))
        
        

if __name__ == "__main__":
    main()
Problem p02760 (python)

Fixed submission:
A = []
for i in range(3):
    line = list(map(int, input().split()))
    A.extend(line)
N = int(input())

bingo = [False] * 9

def num_check(num):
    for i in range(9):
        if A[i] == num:
            bingo[i] = True


for _ in range(N):
    num = int(input())
    num_check(num)

bingo_flag = False
# row check
if any([bingo[i] and bingo[i+1] and bingo[i+2] for i in range(0, 9, 3)]):
    bingo_flag = True

# col check
if any([bingo[i] and bingo[i+3] and bingo[i+6] for i in range(3)]):
    bingo_flag = True

# cross check
if (bingo[0] and bingo[4] and bingo[8]) or (bingo[2] and bingo[4] and bingo[6]):
    bingo_flag = True

print("Yes") if bingo_flag else print("No")

Buggy submission (verdict: Runtime Error):
A = []
for i in range(3):
    line = list(map(int, input().split()))
    A.extend(line)
N = int(input())

bingo = [False] * 9

def num_check(num):
    for i in range(9):
        if A[i] == num:
            bingo[i] = True


for _ in range(N):
    num = int(input())
    num_check(num)

bingo_flag = False
# row check
if any([bingo[i] and bingo[i+1] and bingo[i+2] for i in range(0, 9, 3)]):
    bingo_flag = True

# col check
if any([bingo[i] and bingo[i+3] and bingo[i+6] for i in range(3)]):
    bingo_flag = True

# cross check
if (bingo[0] and bingo[4] and bingo[8]) or (bingo[2] and bing[4] and bingo[6]):
    bingo_flag = True

print("Yes") if bingo_flag else print("No")
Problem p02850 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**9)

N = int(input())
edge = [[] for i in range(N)]
count = [0] * N
color = {}
egs = []
for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    count[a] += 1
    count[b] += 1
    edge[a].append(b)
    edge[b].append(a)
    egs.append(tuple(sorted([a, b])))


ans = max(count)
c = 1



def dfs(idx, pr):
    c = 1
    col = color[pr]
    for i in edge[idx]:
        if i in pr:
            continue
        if c == col:
            c+=1
        x, y = sorted([i, idx])
        color[(x, y)] = c
        dfs(i, (x, y))
        c+=1

color[(-1, -1)] = 0
dfs(0, (-1, -1))
print(ans)
for tpl in egs:
    print(color[tpl])

Buggy submission (verdict: Runtime Error):
port sys
sys.setrecursionlimit(10**9)
 
N = int(input())
edge = [[] for i in range(N)]
count = [0] * N
color = {}
egs = []
for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    count[a] += 1
    count[b] += 1
    edge[a].append(b)
    edge[b].append(a)
    egs.append(tuple(sorted([a, b])))
 
 
ans = max(count)
c = 1
 
 
 
def dfs(idx, pr):
    c = 1
    col = color[pr]
    for i in edge[idx]:
        if i in pr:
            continue
        if c == col:
            c+=1
        x, y = sorted([i, idx])
        color[(x, y)] = c
        dfs(i, (x, y))
        c+=1
 
color[(-1, -1)] = 0
dfs(0, (-1, -1))
print(ans)
for tpl in egs:
    print(color[tpl])

Buggy submission (verdict: Runtime Error):
N = int(input())
edge = [[] for i in range(N)]
count = [0] * N
color = {}
egs = []
for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    count[a] += 1
    count[b] += 1
    edge[a].append(b)
    edge[b].append(a)
    egs.append(tuple(sorted([a, b])))


ans = max(count)
c = 1



def dfs(idx, pr):
    c = 1
    col = color[pr]
    for i in edge[idx]:
        if i not in pr:
            if c == col:
                c+=1
            x, y = sorted([i, idx])
            color[(x, y)] = c
            dfs(i, (x, y))
        c+=1

color[(-1, -1)] = 0
dfs(0, (-1, -1))
print(ans)
for tpl in egs:
    print(color[tpl])
Problem p02853 (python)

Fixed submission:
X, Y = map(int, input().split())
syoukin = [3*10**5, 2*10**5, 1*10**5]
if X == 1 and Y == 1:
    print(10*10**5)
else:
    money = 0
    if X <= 3:
        money += syoukin[X-1]
    if Y <= 3:
        money += syoukin[Y-1]
    print(money)

Buggy submission (verdict: Runtime Error):
money = [300000, 200000, 100000]
X, Y = map(int, input().split())
X -= 1; Y -= 1
ans = money[X] + money[Y]
if X + Y:
    print(ans)
else:
    print(ans + 400000)
Problem p02928 (python)

Fixed submission:
def main():
    MOD = 10**9 + 7
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    left_smaller = [0]*N
    right_smaller = [0]*N
    for i, a in enumerate(A):
        left_smaller[i] = sum(b < a for b in A[:i])
        right_smaller[i] = sum(b < a for b in A[i+1:])

    ans = sum((l*(K)*(K-1)//2%MOD + r*(K+1)*(K)//2%MOD)%MOD for l, r in zip(left_smaller, right_smaller))%MOD
    print(ans)

if __name__ == "__main__":
    main()

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

def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    
    c = Counter(A).most_common()

    if c[0][0] == "0" and c[0][1] == N:
        print("Yes")
    elif len(c) == 2 and c[0][1] == 2*N//3 and c[1][0] == "0" and c[1][1] == N//3:
        print("Yes")
    elif len(c) == 3 and int(c[0][0])^int(c[1][0]) == int(c[2][0]) and c[0][1] == c[1][1] and c[1][1] == c[2][1]:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()
Problem p03006 (python)

Fixed submission:
N = int(input())

d = {}
x = [0] * N
y = [0] * N
from collections import defaultdict
for i in range(N):
    x[i], y[i] = map(int, input().split())

d = defaultdict(int)
for i in range(N):
    for j in range(N):
        dx = x[i] - x[j]
        dy = y[i] - y[j]
        if i == j:
            continue
        d[(dx, dy)] += 1
        
if N == 1:
    print(1)
else:
    print(N - max(d.values()))

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

d = {}
x = [0] * N
y = [0] * N
from collections import defaultdict
for i in range(N):
    x[i], y[i] = map(int, input().split())

d = defaultdict(int)
for i in range(N):
    for j in range(N):
        dx = x[i] - x[j]
        dy = y[i] - y[j]
        if i == j:
            continue
        d[(dx, dy)] += 1

print(N - max(d.values()))

Buggy submission (verdict: Runtime Error):
from fractions import Fraction
N = int(input())
l = []

d = {}
x = [0] * N
y = [0] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())

for i in range(N):
    temp = set([])
    for j in range(i + 1, N):
        dx = x[i] - x[j]
        dy = y[i] - y[j]
        if dx == 0:
            frac = "x=0"
        elif dy == 0:
            frac = "y=0"
        else:
            frac = Fraction(dy, dx)
            frac = str(frac)

        temp.add(frac)
    
    for frac in temp:
        if frac not in d:
            d[frac] = 1
        else:
            d[frac] += 1

print(N - max(d.values()))

Buggy submission (verdict: Runtime Error):
from fractions import Fraction
N = int(input())
l = []

d = {}
x = [0] * N
y = [0] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())

for i in range(N):
    for j in range(i + 1, N):
        dx = x[i] - x[j]
        dy = y[i] - y[j]
        if dx == 0:
            frac = "-0"
        else:
            frac = Fraction(dy, dx)
        frac = str(frac)
        if frac not in d:
            d[frac] = 1
        else:
            d[frac] += 1


print(max(1, N - max(d.values())))
Problem p03044 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

N = int(input())

edges = [{} for i in range(N)]
colors = [0 for i in range(N)]

def dfs(s, dist):

    for key, val in edges[s].items():
        d = dist + val
        if d % 2 == 0:
            colors[key] = 0 
        else :
            colors[key] = 1
        
        if s in edges[key]:
            del edges[key][s]

        dfs(key, d)

    return

for i in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    edges[u][v] = w
    edges[v][u] = w

dfs(0, 0)

for color in colors:
    print(color)

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

edges = [{} for i in range(N)]
colors = [0 for i in range(N)]

def dfs(s, dist):
    for key, val in edges[s].items():
        d = dist + val
        if d % 2 == 0:
            colors[key] = 0 
        else :
            colors[key] = 1
        
        if s in edges[key]:
            del edges[key][s]

        dfs(key, d)
    return

for i in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1; v -= 1
    edges[u][v] = w
    edges[v][u] = w

dfs(0, 0)
for color in colors:
    print(color)

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

edges = [{} for i in range(N)]
colors = [0 for i in range(N)]

def dfs(s, dist):
    for key, val in edges[s].items():
        d = dist + val
        if d % 2 == 0:
            colors[key] = 0 
        else :
            colors[key] = 1
        
        del edges[key][s]
        dfs(key, d)
    return

for i in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1; v -= 1
    edges[u][v] = w
    edges[v][u] = w

dfs(0, 0)
for color in colors:
    print(color)
Problem p03074 (python)

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

nums = []
now = 1
seq_count = 0
for char in S:
    if char == str(now):
        seq_count += 1
    else:
        now = 1 - now
        nums.append(seq_count)
        seq_count = 1

nums.append(seq_count)

if len(nums) % 2 == 0:
    nums.append(0)

sums = [0] * (len(nums) + 1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]

ans = 0
for i in range(1, len(sums), 2):
    left = i - 1
    right = min(i + 2 * K, len(sums) - 1)
    ans = max(ans, sums[right] - sums[left])
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input()
S = S + "2"
chokuritsu = []
sakadachi = []
flag = S[0]
count = 1
for c in S:
    if flag != c:
        if c == "1":
            chokuritsu.append(count)
        elif c == "0":
            sakadachi.append(count)
        elif c == "2":
            if flag == "1":
                sakadachi.append(count-1)
            else:
                chokuritsu.append(count-1)

        count = 1
        flag = c
    else:
        count += 1
ans = 0
sub_ans = 0

if S[0] == "1":
    for i in range(min(K, len(sakadachi) - 1)):
        sub_ans += sakadachi[i] + chokuritsu[i]
    sub_ans += sakadachi[min(K-1, len(sakadachi)-1)]
    ans = max(ans, sub_ans)
    for i in range(len(sakadachi) - K):
        sub_ans += sakadachi[i+K] + chokuritsu[i+K-1]
        sub_ans -= sakadachi[i] + chokuritsu[i-1]
        ans = max(ans, sub_ans)

    if S[-1] == "0":
        sub_ans = chokuritsu[-1]
        for i in ragne(len(sakadachi)-1, len(sakadachi) - 1 - min(K -1, len(sakadachi)), -1):
            sub_ans += sakadachi[i] + chokuritsu[i]
    ans = max(ans, sub_ans)

else:
    sub_ans = chokuritsu[0]
    for i in range(min(K - 1, len(sakadachi) - 1)):
        sub_ans += sakadachi[i] + chokuritsu[i]
    ans = max(ans, sub_ans)
    sub_ans = 0
    for i in range(min(K, len(sakadachi) - 1)):
        sub_ans += sakadachi[i] + chokuritsu[i+1]
    sub_ans += sakadachi[min(K-1, len(sakadachi)-1)]

    for i in range(len(sakadachi) - K):
        sub_ans += sakadachi[i+K] + chokuritsu[i+K]
        sub_ans -= sakadachi[i] + chokuritsu[i]
        ans = max(ans, sub_ans)

    if S[-1] == "0":
        sub_ans = chokuritsu[-1]
        for i in ragne(len(sakadachi)-1, len(sakadachi) - 1 - min(K -1, len(sakadachi)), -1):
            sub_ans += sakadachi[i] + chokuritsu[i]
    ans = max(ans, sub_ans)

print(ans)
Problem p03197 (python)

Fixed submission:
import numpy as np

def main():
    stdin = np.fromstring(open(0).read(), dtype=np.int32, sep=' ')
    N = stdin[0]
    A = stdin[1:]
    A = np.mod(A, 2)
    print("first") if np.count_nonzero(A) else print("second")
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().split()
def main():
    _ = input()
    A = (map(int, input().split()))
    print("second") if all(( a%2==0 for a in A)) else print("first")
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
buf = sys.stdin.buffer

def main():
    N = int(buf.readline())
    A = np.frombuffer(buf.read(), dtype="int64")
    A = np.mod(A, 2)
    print("first") if np.count_nonzero(A) else print("second")
if __name__ == "__main__":
    main()
Problem p03274 (python)

Fixed submission:
import bisect
N, K = map(int, input().split())
x = list(map(int, input().split()))
t = 2 * (x[-1] - x[0])
i = bisect.bisect_right(x, 0)
for j in range(0, N):
    if N <= j + K -1 :
        break
    if (j - (i - 0.1)) * (j + K- 1 - (i - 0.1)) >= 0:
        t = min(t, max(abs(x[j]), abs(x[j+K-1])))
    else:
        t = min(t, abs(2 * x[j]) + x[j+K-1])
        t = min(t, abs(x[j]) + 2 * x[j+K-1])
print(t)

Buggy submission (verdict: Runtime Error):
from collections import Counter
import numpy as np
H, W = map(int, input().split())
a = []
r_idx = []
c_idx = []
#a.shape = (H, W)
for i in range(H):
    line = list(input())
    if Counter(line).most_common()[0][1] != W:
        r_idx.append(i)
    a.append(line)
a = np.array(a).T
#a.shape = (W, H)
b = []
for i in range(W):
    if Counter(a[i]).most_common()[0][1] == H:
        continue
    b.append(a[i])

b = np.array(b).T
c = []
for idx in r_idx:
    c.append(b[idx])

for i in range(len(c)):
    print("".join(c[i]))
Problem p03353 (python)

Fixed submission:
s = input()
K = int(input())
l = []
for i in range(5):
    for j in range(len(s)):
        if j + i >=  len(s):
            break
        l.append(s[j:j + i + 1])
l = sorted(set(l))
print(l[K-1])

Buggy submission (verdict: Runtime Error):
s = input()
K = int(input())
l = []
for i in range(5):
    for j in range(len(s)):
        if j + i + 1 >=  len(s):
            break
        l.append(s[j:j + i + 1])
l = sorted(set(l))
print(l[K-1])
Problem p03435 (python)

Fixed submission:
c = [list(map(int, input().split())) for i in range(3)]
a = [0 for i in range(3)]
b = [0 for i in range(3)]
a[0] = 0
a[1] = c[1][1] - c[0][1]
a[2] = c[2][2] - c[0][2]
b[0] = c[0][0]
b[1] = c[0][1]
b[2] = c[0][2]
flag = True
for i in range(3):
    for j in range(3):
        if c[i][j] != a[i] + b[j]:
            flag = False
print("Yes") if flag else print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
red = [list(map(int, input().split())) for i in range (N)]
blue = [list(map(int, input().split())) for i in range (N)]
blue.sort(key=lambda x:x[0])
red.sort(key=lambda x:x[1], reverse=True)
pairs = 0
flag = [True for i in range(N)]
for i in range(N):
    for j in range(N):
        if blue[i][0] > red[j][0] and blue[i][1] > red[j][1] and flag[j]:
            pairs += 1
            flag[j] = False
            break
print(pairs)
Problem p03503 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10000)

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)]
INF = 10 ** 9

def dfs(s):
    if len(s) == 10:
        value = -INF
        if "1" in s:
            value = 0
            c = [0 for i in range(N)]
            for i in range(5):
                for j in range(2):
                    for k in range(N):
                        if int(s[2*i+j]) * F[k][2*i+j]:
                            c[k] += 1
            for i in range(N):
                value += P[i][c[i]]
        return value
    else:
        return max(dfs(s+"0"), dfs(s+"1"))

print(dfs(""))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

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)]
INF = 10 ** 9

def dfs(s):
    if len(s) == 10:
        value = -INF
        if "1" in s:
            value = 0
            c= [0 for i in range(10)]
            for i in range(5):
                for j in range(2):
                    for k in range(N):
                        if int(s[2*i+j]) * F[k][2*i+j]:
                            c[k] += 1
            for i in range(N):
                value += P[i][c[i]]
        return value
    else:
        return max(dfs(s+"0"), dfs(s+"1"))

print(dfs(""))

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)]
INF = 10 ** 9

def dfs(s):
    if len(s) == 10:
        value = -INF
        if "1" in s:
            value = 0
            c= [0 for i in range(10)]
            for i in range(5):
                for j in range(2):
                    for k in range(N):
                        if int(s[2*i+j]) * F[k][2*i+j]:
                            c[k] += 1
            for i in range(N):
                value += P[i][c[i]]
        return value
    else:
        return max(dfs(s+"0"), dfs(s+"1"))

print(dfs(""))
Problem p03565 (python)

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

def f():
    l = []
    for i in range(len(S)):
        if i + len(T) > len(S):
            break
        flag = True
        for j in range(len(T)):
            if S[i + j] not in [T[j], "?"] :
                flag = False
                break
        if flag:
            s = S
            s = s[:i] + T + s[i+len(T):]
            s = s.replace("?", "a")
            l.append(s)
    l.sort()
    if len(l):
        return l[0]
    else:
        return "UNRESTORABLE"

print(f())

Buggy submission (verdict: Runtime Error):
def main():
    S = list(input())
    T = list(input())

    for i in range(max(0, len(S)-len(T)+1)):
        ans = ""
        for j in range(i):
            if S[j] == "?":
                ans += "a"
            else:
                ans += S[j]

        for j in range(i, len(S)):
            if S[j] == T[j-i]:
                ans += S[j]
            elif S[j] == "?":
                ans += T[j-i]
            else:
                break

        if len(ans) == len(S):
            print(ans)
            exit()

    print("UNRESTORABLE")

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    S = list(input())
    T = list(input())

    for i in range(len(S)-len(T)+1):
        ans = ""
        for j in range(i):
            if S[j] == "?":
                ans += "a"
            else:
                ans += S[j]

        for j in range(i, len(S)):
            if S[j] == T[j-i]:
                ans += S[j]
            elif S[j] == "?":
                ans += T[j-i]
            else:
                break

        if len(ans) == len(S):
            print(ans)
            exit()
            
    print("UNRESTORABLE")

if __name__ == "__main__":
    main()
Problem p03569 (python)

Fixed submission:
def main():
    s = input()
    N = len(s)

    nox = []
    idxs = []
    ans = 0
    for i, c in enumerate(s):
        if c != "x":
            nox.append(c)
            idxs.append(i)
    
    if nox != nox[::-1]:
        print(-1)
        exit()
    
    if len(nox) == 0:
        print(0)
        exit()

    if len(nox)%2 == 0:
        left = len(nox)//2 - 1
        right = len(nox)//2
        
        left_idx = idxs[left]
        right_idx = idxs[right]

    else:
        center = len(nox)//2
        left_idx = idxs[center]
        right_idx = idxs[center]

    while not(left_idx == 0 and right_idx == N-1):
        if s[left_idx] == s[right_idx]:
            if left_idx > 0 and right_idx < N - 1:
                left_idx -= 1
                right_idx += 1
            else:
                if left_idx <= idxs[0] and right_idx >= idxs[-1] and (left_idx > 0 or right_idx < N - 1):
                    ans += 1
                if left_idx > 0:
                    left_idx -= 1
                if right_idx < N-1:
                    right_idx += 1

        elif s[left_idx] == "x":
            ans += 1
            if left_idx > 0:
                left_idx -= 1
        elif s[right_idx] == "x":
            ans += 1
            if right_idx < N-1:
                right_idx += 1
    print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    s = input()
    N = len(s)

    nox = []
    idxs = []
    ans = 0
    for i, c in enumerate(s):
        if c != "x":
            nox.append(c)
            idxs.append(i)
    
    if nox != nox[::-1]:
        print(-1)
        exit()
    

    if len(nox)%2 == 0:
        left = len(nox)//2 - 1
        right = len(nox)//2
        
        left_idx = idxs[left]
        right_idx = idxs[right]
        
    else:
        center = len(nox)//2
        left_idx = idxs[center]
        right_idx = idxs[center]

    old_left = -1
    old_right = -1
    while not (old_left == left_idx and old_right == right_idx):
        old_left = left_idx
        old_right = right_idx

        if s[left_idx] == s[right_idx]:
            if left_idx > 0:
                left_idx -= 1
            if right_idx < N-1:
                right_idx += 1
        elif s[left_idx] == "x":
            ans += 1
            if left_idx > 0:
                left_idx -= 1
        elif s[right_idx] == "x":
            ans += 1
            if right_idx < N-1:
                right_idx += 1

    print(ans)

if __name__ == "__main__":
    main()
Problem p03583 (python)

Fixed submission:
def main():
    N = int(input())

    for h in range(1, 3501):
        for n in range(N-h+1, 3501):
            if (4*h*n - N*h - N*n)>0 and N*h*n % (4*h*n - N*h - N*n)==0:
                w = N*h*n // (4*h*n - N*h - N*n)
                print(h, n, w)
                exit()

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())

    for h in range(1, 3501):
        for n in range(h+N-1, 3501):
            if N*h*n % (4*h*n - N*h - N*n)==0:
                w = N*h*n // (4*h*n - N*h - N*n)
                print(h, n, w)
                exit()

if __name__ == "__main__":
    main()