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

Fixed submission:
import math
 
N = int(input())
A = [int(a) for a in input().split(" ")]
ave = sum(A) / N
can1 = math.floor(ave)
can2 = math.ceil(ave)
 
cost1 = sum([(a - can1) ** 2 for a in A])
cost2 = sum([(a - can2) ** 2 for a in A])
print(min([cost1, cost2]))

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
A = [int(a) for a in input().split(" ")]
ave = sum(A) / N
can1 = math.floor(ave)
can2 = math.ceil(ave)

cost1 = sum([(a - can1) ** 2 for a in A])
cost2 = sum([(a - can2) ** 2 for a in A])
print(min[cost1, cost2])
Problem p03547 (python)

Fixed submission:
dicta={'A':10,'B':11,'C':12,'D':13,'E':14,'F':15}
x, y = input().split()
if dicta[x]<dicta[y]:
  print('<')
elif dicta[x]==dicta[y]:
  print('=')
else:
  print('>')

Buggy submission (verdict: Runtime Error):
dicta={'A':10,'B':11,'C':12,'D':13,'E':14,'F':15}
x=input()
y=input()
if dicta[x]<dicta[y]:
  print('<')
elif dicta[x]==dicta[y]:
  print('=')
else:
  print('>')
Problem p02664 (python)

Fixed submission:
t = input()
s = [i for i in t]
if s[0] == "?":
    s[0] = "D"
for i in range(1, len(t) - 1):
    if s[i] == "?":
        if s[i-1] == "D" and s[i+1] == "D":
            s[i] = "P"
        elif s[i-1] == "p" and s[i+1] == "P":
            s[i] = "D"
        elif s[i-1] == "D" and s[i+1] == "?":
            s[i] = "P"
        elif s[i-1] == "P" and s[i+1] == "?":
            s[i] = "D"
        else:
            s[i] = "D"
if s[-1] == "?":
    s[-1] = "D"
print("".join(s))

Buggy submission (verdict: Runtime Error):
t = input()
s = [i for i in t]
if s[0] == "?":
    if s[1] == "D":
        s[0] = "P"
    s[0] = "D"
for i in range(1, len(t) - 1):
    if s[i-1] == "D" and s[i+1] == "D":
        s[i] = "P"
    elif s[i-1] == "D" and s[i+1] == "?":
        s[i] = "P"
    else:
        s[i] = "D"
if s[-1] == "?":
    s[-1] = "D"
print("".join(s))
Problem p02681 (python)

Fixed submission:
s = input()
t = input()
n = len(s)
a = [i for i in t]
if s == "".join(a[:n]):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a, b, c, k = map(int, input().split())
ans = 0
if k <= a:
    print(k)
else:
    k -= a
    ans += a
    if k <= b:
        print(ans)
    else:
        k -= b
        ans += -1 * k
        print(ans)
Problem p02687 (python)

Fixed submission:
s = input()
print('ABC' if s == 'ARC' else 'ARC')

Buggy submission (verdict: Runtime Error):
x = int(input())
for a in range(-10000, 10000):
    for b in range(-1000, 1000):
        if a**5 - b**5 == x:
            print(a, b)
            quit()

Buggy submission (verdict: Runtime Error):
x = int(input())
for a in range(-1000, 1000):
    for b in range(-1000, 1000):
        if a**5 - b**5 == x:
            print(a, b)
            quit()
Problem p02706 (python)

Fixed submission:
N, M = map(int, input().split())
A = input().split()
if sum(int(i) for i in A) > N:
    print(-1)
else:
    print(N - sum(int(i) for i in A))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = input().split()
if sum(A) > N:
  print(-1)
else:
  print(N - sum(A))
Problem p02724 (python)

Fixed submission:
X = int(input())
a = X // 500
b = X % 500
c = b // 5
print(a * 1000 + c * 5)

Buggy submission (verdict: Runtime Error):
X = input()
a = X // 500
b = X % 500
c = b // 5
print(a * 1000 + c * 5)
Problem p02730 (python)

Fixed submission:
s = input()
n = len(s)
if (s == s[::-1]):
    a = s[:(n-1)//2]
    if (a == a[::-1]):
        b = s[(n+3)//2-1:]
        if (b == b[::-1]):
            print("Yes")
            quit()
print("No")

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
print("Yes" if S == S[::-1] and S[:(N - 1)//2][::-1] == S[:(N - 1)//2] and S[(N + 3)//2][::-1] == S[(N + 3)//2] else "No")
Problem p02909 (python)

Fixed submission:
s = input()
if s == 'Sunny':
    print('Cloudy')
elif s ==  'Cloudy':
    print('Rainy')
else:
    print('Sunny')

Buggy submission (verdict: Runtime Error):
from collections import Counter
n, k, q = map(int, input().split())
a = [int(input()) for _ in range(q)]
ans = ['No'] * n
c = Counter(a)
for i in range(1, n+1):
    if c[i] > q - k:
        ans[i] = 'Yes'
for k in ans:
    print(k)

Buggy submission (verdict: Runtime Error):
s = input()
if s == 'Sunny':
    print('Cloudy')
elif s ==  'Cloudy':
    print('Rainy'):
else:
    print('Sunny')
Problem p02910 (python)

Fixed submission:
def tapdance(s):
    for i in range(len(s)):
        if i % 2 == 0:
            if s[i] != 'R' and s[i] != 'U' and s[i] != 'D':
                return 'No'
        else:
            if s[i] != 'L' and s[i] != 'U' and s[i] != 'D':
                return 'No'
    return 'Yes'
s = input()
print(tapdance(s))

Buggy submission (verdict: Runtime Error):
def tapdance(s):
    for i in range(len(s)):
        if i % 2 == 0:
            if s[i] = 'L':
                return 'No'
        else:
            if s[i] = 'R':
                return 'No'
    return 'Yes'
s = input()
print(tapdance(s))
Problem p02917 (python)

Fixed submission:
n = int(input())
b = list(map(int, input().split()))
if n == 2:
    print(b[0] * 2)
else:
    res = [0] * n
    res[0] = b[0]
    for i in range(n-2):
        if b[i] < b[i+1]:
            res[i+1] = b[i]
        else:
            res[i+1] = b[i+1]
    if b[-2] < b[-1]:
        res.append(b[-1])
    else:
        res.append(b[-1])
    print(sum(res))

Buggy submission (verdict: Runtime Error):
 = int(input())
b = list(map(int, input().split()))
if n == 2:
    print(b[0] * 2)
else:
    res = [0] * n
    for i in range(n-2):
        if b[i] < b[i+1]:
            res[i] = b[i]
            res[i+1] = b[i]
        else:
            res[i+1] = b[i+1]
    if b[-2] < b[-1]:
        res.append(b[-1])
    else:
        res[-1] = b[-1]
        res.append(b[-1])
    print(sum(res))
Problem p02971 (python)

Fixed submission:
n = int(input())
l = []
for i in range(n):
    l.append(int(input()))
m = max(l)
ans = [m]*n
if len(set(l)) == 1 or l.count(m) > 1:
    for i in ans:
        print(i)
else:
    x = sorted(set(l))[-2]
    a = l.index(m)
    ans[a] = x
    for i in ans:
        print(i)

Buggy submission (verdict: Runtime Error):
m = max(l)
ans = [m]*n
if len(set(l)) == 1:
    for i in ans:
        print(i)
else:
    x = sorted(set(l))[-2]
    a = l.index(m)
    ans[a] = x
    for i in ans:
        print(i)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = []
for i in range(n):
    l.append(int(input()))
m = max(l)
x = sorted(set(l))[-2]
ans = [m]*n
a = [index for index, value in enumerate(l) if value == m]
for i in a:
    ans[i] = x
[print(i) for i in ans]
Problem p04043 (python)

Fixed submission:
a = list(map(int, input().split()))
a.sort()
if a == [5, 5, 7]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a = list(map(int, intput().split()))
a.sort()
if a = [5, 5, 7]:
  print("YES")
else:
  print("NO")
Problem p02812 (python)

Fixed submission:
N = int(input())
S = input()
count = 0
for i in range(N):
    try:
        if S[i] == "A" and S[i + 1] == "B" and S[i + 2] == "C":
            count += 1
    except IndexError:
        break
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
count = 0
for i in range(N):
    if S[i] == "A" and S[i + 1] == "B" and S[i + 2] == "C":
        count += 1
print(count)
Problem p03085 (python)

Fixed submission:
dict = {'A':'T','C':'G','T':'A', 'G':'C'}
a = input()
print(dict[a])

Buggy submission (verdict: Runtime Error):
dict = {'A':'T','C':'G','T':'A', 'G':'C'}
a = input()
print(dict(a))
Problem p03086 (python)

Fixed submission:
s = input()
ans=0
now=0
for a in s:
    if a in ["A", "C", "G", "T"]:
        now+=1
    else:
        now=0
    ans=max(ans,now)
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
count = 0
res = []
for i in S:
    if i in ["A", "C", "G", "T"]:
        count += 1
    else:
        res.append(count)
        count = 0
print(max(res))

Buggy submission (verdict: Runtime Error):
S = input()
count = 0
res = []
for i in range(len(S)):
    if S[i] in ["A", "C", "G", "T"]:
        count += 1
    else:
        res.append(count)
        count = 0
print(max(res, 0))

Buggy submission (verdict: Runtime Error):
S = input()
count = 0
res = []
for i in range(len(S)):
    try:
        if S[i] in ["A", "C", "G", "T"]:
            count += 1
        else:
            res.append(count)
            count = 0
    except:
        continue
print(max(res))

Buggy submission (verdict: Runtime Error):
S = input()
count = 0
res = []
for i in range(len(S)):
    if S[i] in ["A", "C", "G", "T"]:
        count += 1
    else:
        res.append(count)
        count = 0
print(max(res))

Buggy submission (verdict: Runtime Error):
S = input()
count = 0
res = []
for i in range(len(S)):
    if S[i] in ["A", "C", "G", "T"]:
        count += 1
    else:
        res.append(count)
        count = 0

print(max(res))
Problem p03101 (python)

Fixed submission:
H,W = map(int,input().split())
h,w = map(int,input().split())
A = H - h
B = W - w
print(int(A * B))

Buggy submission (verdict: Runtime Error):
H,W = map(int,input())
h,w = map(int,input())
print(int(H * W - h * w))
Problem p03469 (python)

Fixed submission:
s = str(input())
l = s.replace("2017", "2018")
print(l)

Buggy submission (verdict: Runtime Error):
N,Y = map(int, input().split())
for i in range(N + 1):
    for l in range(N - i + 1):
            if 10000*i + 5000*l + 1000*(N - i - l) == Y:
                print(i ,l ,(N - i - l))
                exit()

print(-1 ,-1 ,-1)

Buggy submission (verdict: Runtime Error):
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n - i + 1):
        if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
            print(i, j, n - i - j)
            exit()
print("-1 -1 -1")

Buggy submission (verdict: Runtime Error):
N,Y = map(int, input().split())
for i in range(N + 1):
    for l in range(N - i):
            ans = 10000*i + 5000*l + 1000*(N - i - l)
            if ans == Y:
                print("{} {} {} ".format(i ,l  ,(N - i - l)))
                exit()

print(-1 ,-1 ,-1)

Buggy submission (verdict: Runtime Error):
N,Y = map(int, input().split())
for i in range(N):
    for l in range(N):
            ans = 10000*i + 5000*l + 1000*(N - i - l)
            if ans == Y:
                print("{} {} {} ".format(i ,l  ,(N - i - l)))
                exit()

print("-1 -1 -1")
Problem p03493 (python)

Fixed submission:
s = str(input())
print(s.count("1"))

Buggy submission (verdict: Runtime Error):
s = str(input())
print(s.count(1))
Problem p03494 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
j = True
count = 0
while j :
     for i in A:
             if i % 2 == 0 or i == 0:
                     A[A.index(i)] = i / 2
             else:
                     j = False
     if j == True:             
     	count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
j = True
count = 0
while j :
     for i in range(N):
             if A[i] % 2 == 0 or A[i] == 0:
                     A[i] =/ 2
             else:
                     j = False
     if j == True:             
     	count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
j = True
count = 0
while j:
     for i in A:
             if i % 2 == 0:
                     A[A.index(i)] = i / 2
             else:
                     j = False
                  	 break
     count += 1
print(count)
Problem p03737 (python)

Fixed submission:
a,b,c = input().split()
print(a.upper()[0]+b.upper()[0]+c.upper()[0])

Buggy submission (verdict: Runtime Error):
a,b,c = input().split()
print(a.upper()[0]+b.upper()[0].c.upper()[0])
Problem p03759 (python)

Fixed submission:
a,b,c = map(int,input().split())
if b-a == c-b:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
if b−a==c−b:
  print("YES")
else:
  print("NO")
Problem p03761 (python)

Fixed submission:
import collections

n = int(input())
s = [input() for i in range(n)]
w = ""
if n == 1:
    r = collections.Counter(s[0])
    for k in sorted(r):
        w += k * r[k]
    print(w)
    exit()
a = collections.Counter(s[0])
b = collections.Counter(s[1])
res = a & b
if n <= 2:
    for k in sorted(res):
        w += k * res[k]
    print(w)
else:
    for i in s[2:]:
        res = res & collections.Counter(i)
    if not res:
        print("")
    for k in sorted(res):
        w += k * res[k]
    print(w)

Buggy submission (verdict: Runtime Error):
import collections

n = int(input())
s = [input() for i in range(n)]
w = ""

if n == 1:
    r = sorted(collections.Counter(s))
    for k, v in r.items():
        w += k * r[k]
    print(w)
    exit()
a = collections.Counter(s[0])
b = collections.Counter(s[1])
res = a & b
if n <= 2:
    for k in sorted(res):
        w += k * res[k]
    print(w)
else:
    for i in s[2:]:
        res = res & collections.Counter(i)
    if not res:
        print("")
    for k in sorted(res):
        w += k * res[k]
    print(w)

Buggy submission (verdict: Runtime Error):
import collections

n = int(input())
s = [input() for i in range(n)]
w = ""

if n == 1:
    r = sorted(collections.Counter(s[0]))
    for k, v in r.items():
        w += k * r[k]
    print(w)
    exit()
a = collections.Counter(s[0])
b = collections.Counter(s[1])
res = a & b
if n <= 2:
    for k in sorted(res):
        w += k * res[k]
    print(w)
else:
    for i in s[2:]:
        res = res & collections.Counter(i)
    if not res:
        print("")
    for k in sorted(res):
        w += k * res[k]
    print(w)

Buggy submission (verdict: Runtime Error):
import collections

n = int(input())
s = [input() for i in range(n)]
a = collections.Counter(s[0])
b = collections.Counter(s[1])
res = a & b
w = ""
if n <= 2:
    for k in sorted(res):
        w += k * res[k]
    print(w)
else:
    for i in s[2:]:
        res = res & collections.Counter(i)
    if not res:
        print("")
    for k in sorted(res):
        w += k * res[k]
    print(w)
Problem p03777 (python)

Fixed submission:
a,b = input().split()
if a=="H":
  print(b)
 
  
else:
  if b =="H":
    print("D")
  else:
    print("H")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a=="H":
  print(b)
 
  
else:
  if b =="H":
    print("D")
  else:
    print("H")
Problem p03778 (python)

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

if abs(a-b) <= w:
  print(0)
else:
  print(abs(a-b)-w)

Buggy submission (verdict: Runtime Error):
w,a,b = map(int,input().split())
if w+a => b:
  print(0)
else:
	print(b-(a+w))

Buggy submission (verdict: Runtime Error):
w,a,b = map(int,input().split())
print(b-(a+W))
Problem p03828 (python)

Fixed submission:
import math

N = int(input())
N = math.factorial(N) 

i = 2 
num = 1
ans = 1

while N != 1: 
    if N % i == 0:
        N = N // i
        num += 1
    else:
        ans *= num
        num = 1
        i += 1
ans *= num
ans %= (10 ** 9) + 7

print(ans)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
N = math.factorial(N) 

i = 2 　
num = 1
ans = 1

while N != 1: 
    if N % i == 0:
        N //= i
        num += 1
    else:
        ans *= num
        num = 1
        i += 1
ans *= num
ans %= (10 ** 9) + 7

print(ans)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
N = math.factorial(N) # N!を出してくれる (N=3, 0+1+2+3=6)

i = 2 　#Nを素因数分解するためまずは2で
num = 1
ans = 1

while N != 1: 
    if N % i == 0:
        N //= i
        num += 1
    else:
        ans *= num
        num = 1
        i += 1
ans *= num
ans %= (10 ** 9) + 7

print(ans)
Problem p02641 (python)

Fixed submission:
def resolve():
    x, n = list(map(int, input().split()))

    if n > 0:
        p = list(map(int, input().split()))
        q = [i for i in range(min(p)-1, max(p)+2)]
        for item in p:
            if item in q:
                q.remove(item)

        ans = []
        current_min = float('inf')
        for item in q:
            diff = abs(x-item)
            if diff < current_min:
                current_min = diff
                ans.clear()
                ans.append(item)
            elif diff == current_min:
                ans.append(item)

        print(min(ans))
    else:
        print(x)


if 'unittest' not in globals():
    resolve()

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

    if n > 0:
        p = list(map(int, input().split()))
        q = [i for i in range(1, max(p)+1)]
        for item in p:
            if item in q:
                q.remove(item)

        ans = []
        current_min = float('inf')
        for item in q:
            diff = abs(x-item)
            if diff < current_min:
                current_min = diff
                ans = []
                ans.append(item)
            elif diff == current_min:
                ans.append(item)

        print(min(ans))
    else:
        print(x)


if 'unittest' not in globals():
    resolve()
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]

ans = [-1] * N

for i in range(M):
    s = sc[i][0] - 1
    c = sc[i][1]
    if ans[s] is -1:
        ans[s] = c
    elif not ans[s] == c:
        print(-1)
        exit()

if N!=1 and ans[0] == 0:
    print(-1)
    exit()

a = 0
for i in range(N):
    if ans[i] is -1:
        if i == 0 and N!= 1:
            ans[i] = 1
        else:
            ans[i] = 0
    a += ans[i]*10**(N-i-1)

print(a)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]

ans = [-1] * N

for i in range(M):
    s = sc[i][0] - 1
    c = sc[i][1]
    if ans[s] is -1:
        ans[s] = c
    elif not ans[s] == c:
        print(-1)
        exit(-1)
if ans[-1] == 0:
    print(-1)
    exit(-1)

a = 0
for i in range(N):
    if ans[i] is -1:
        ans[i] = 0
    a += ans[i]*10**(N-i-1)

print(a)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]

ans = [-1] * N

for i in range(M):
    s = sc[i][0] - 1
    c = sc[i][1]
    if ans[s] is -1:
        ans[s] = c
    elif ans[s] is not c:
        print(-1)
        exit(-1)
if ans[0] == 0:
    print(-1)
    exit(-2)

a = 0
for i in range(N):
    if ans[i] is -1:
        ans[i] = 0
    a += ans[i]*10**(N-i-1)

print(a)
Problem p03000 (python)

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

ans = 1
d = 0
for i in range(n):
    d += l[i]
    if d <= x:
        ans += 1
print(ans)

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

cnt = 0
d = 0
while True:
    d += l[cnt]
    cnt += 1
    if d > x or cnt > len(l):
        break
print(cnt)

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

def iter(d, idx):
    return d+l[idx]

cnt = 0
d = 0
while True:
    d = iter(d, cnt)
    cnt += 1
    if d > x:
        break
print(cnt)
Problem p02641 (python)

Fixed submission:
X, N = map(int, input().split())
L = list(map(int, input().split()))

if len(L) == 0:
    print(X)
    exit()

list = [0 for _ in range(len(L))]
for i in range(len(L)):
    list[i] = abs(X - L[i])
list = sorted(list)

if min(list) != 0:
    print(X)
    exit()
else:
    num = 1
    cnt = 0
    for i in range(1, len(list)):
        if list[i] != num:
            break
        cnt += 1
        if cnt == 2:
            cnt = 0
            num += 1
if cnt == 0:
    print(X - num)
else:
    if X + num in L:
        print(X - num)
    else:
        print(X + num)

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

if len(L) == 0:
    print(X)
    exit()

list = [0 for _ in range(len(L))]
for i in range(len(L)):
    list[i] = abs(X - L[i])
list = sorted(list)

if min(list) != 0:
    print(X)
    eixt()
else:
    num = 1
    cnt = 0
    for i in range(1, len(list)):
        if list[i] != num:
            break
        cnt += 1
        if cnt == 2:
            cnt = 0
            num += 1
if cnt == 0:
    print(X - num)
else:
    if X + num in L:
        print(X - num)
    else:
        print(X + num)
Problem p02837 (python)

Fixed submission:
N = int(input())
XY_list = [[] for _ in range(N)]
for i in range(N):
    num = int(input())
    for j in range(num):
        person, state = map(int, input().split())
        XY_list[i].append([person - 1, state])
ans = 0
for i in range(1 << N):
    bool = True
    for j in range(N):
        if (i >> j) & 1 == 1:
            for person, state in XY_list[j]:
                if (i >> person) & 1 != state:
                    bool = False
                    break

    if bool:
        ans = max(ans, bin(i)[2:].count("1"))
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
XY_list = [[] for _ in range(N)]
for i in range(N):
    num = int(input())
    for j in range(num):
        person, state = map(int, input().split())
        XY_list[i].append([person - 1, state])
ans = 0
for i in range(1 << N):
    bool = True
    for j in range(N):
        if (i >> j) & 1 == 1:
            for person, state in XY_list[j]:
                if (i >> person) & 1 != state:
                    bool = False
                    break
"""
        else:
            for person, state in XY_list[j]:
                if (i >> person) & 1 == state:
                    bool = False
                    break
"""
    if bool:
        ans = max(ans, bin(i)[2:].count("1"))
print(ans)
Problem p03371 (python)

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

ans = float("inf")

if X > Y:
    ab = 2 * X
    while ab >= 0:
        a = X - (ab / 2)
        if ab / 2 < Y:
            b = int(Y - ab / 2)
        else:
            b = 0
        money = a * A + b * B + ab * C
        ans = min(ans, money)
        ab -= 2
else:
    ab = 2 * Y
    while ab >= 0:
        b = Y - (ab / 2)
        if ab / 2 < X:
            a = int(X - ab / 2)
        else:
            a = 0
        money = a * A + b * B + ab * C
        ans = min(ans, money)
        ab -= 2
print(int(ans))

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

ans = float("inf")

if X > Y:
    ab = 2 * X
    while ab > 0:
        a = X - (ab / 2)
        if ab / 2 < Y:
            b = int(Y - 2 * ab)
        else:
            b == 0
        money = a * A + b * B + ab * C
        ans = min(ans, money)
        ab -= 2
else:
    ab = 2 * Y
    while ab > 0:
        b = Y - (ab / 2)
        if ab / 2 < X:
            a = int(X - 2 * ab)
        else:
            a = 0
        money = a * A + b * B + ab * C
        ans = min(ans, money)
        ab -= 2
print(int(ans))
Problem p03166 (python)

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

N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
  x, y = map(lambda x: int(x)-1, input().split())
  graph[x].append(y)

dp = [-1]*N
def rec(v):
  if dp[v] != -1:
    return dp[v]
  
  res = 0
  for nv in graph[v]:
    res = max(res, rec(nv)+1)
  dp[v] = res
  return res

res = 0
for v in range(N):
  res = max(res, rec(v))
print(res)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
  x, y = map(lambda x: int(x)-1, input().split())
  graph[x].append(y)

dp = [-1]*N
def rec(v):
  if dp[v] != -1:
    return dp[v]
  
  res = 0
  for nv in graph[v]:
    res = max(res, rec(nv)+1)
  dp[v] = res
  return res

res = 0
for v in range(N):
  res = max(res, rec(v))
print(res)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
  x, y = map(lambda x: int(x)-1, input().split())
  graph[x].append(y)

dp = [-1]*N
def rec(v):
  if dp[v] != -1:
    return dp[v]
  
  res = 0
  for nv in graph[v]:
    res = max(res, rec(nv)+1)
  dp[v] = res
  return res

res = 0
for i in range(N):
  res = max(res, rec(i))
print(res)