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

Fixed submission:
def main():
    xy = []
    n = int(input())
    for _ in range(n):
        a = int(input())
        xy.append([list(map(int, input().split())) for _ in range(a)])
    ans = 0
    
    for a in range(2**n):
        c = []
        for b in range(n):
            c.append(a >> b & 1)
       
        flag = True
        for i in range(n):
            if c[i] == 1:
                for x, y in xy[i]:
                    if c[x - 1] != y:
                        flag = False
                        
        if flag:
            ans = max(ans, sum(c))
    
    print(ans)
        
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):

def main():
    z = [-1] * 10
    xy = []
    n = int(input())
    for _ in range(n):
        a = int(input())
        xy.append([list(map(int, input().split())) for _ in range(a)])
    ans = 0
    
    for a in range(2**n):
        c = []
        for b in range(n):
            c.append(a >> b & 1)
       
        flag = True
        for i in range(n):
            if c[i] == 1:
                for x in xy[i]:
                    if z[x[0] - 1] == -1 or z[x[0] - 1] == x[1]:
                        z[x[0] - 1] = x[1]
                    else:
                        flag = False
            
        for i in range(n):
            if z[i] != -1:
                if z[i] !=c[i]:
                    flag = False
                        
        if flag:
            ans = max(ans, sum(c))
    
    print(ans)
        
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
@patch('builtins.input', test.test_input)
def main():
    z = [-1] * 10
    xy = []
    n = int(input())
    for _ in range(n):
        a = int(input())
        xy.append([list(map(int, input().split())) for _ in range(a)])
    ans = 0
    print(0)
        
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    z = [-1] * 10
    n = int(input())
    xy = []
    for _ in range(n):
        a = int(input())
        xy.append([list(map(int, input().split())) for _ in range(a)])
    ans = 0
    
    for a in range(2**n):
        c = []
        for b in range(n):
            c.append(a >> b & 1)
       
        flag = True
        for i in range(n):
            if c[i] == 1:
                for x, y in xy[i]:
                    if z[x - 1] == -1 or z[x - 1] == y:
                        z[x - 1] = y
                    else:
                        flag = False
            
        for i in range(n):
            if z[i] != -1:
                if z[i] !=c[i]:
                    flag = False
                        
        if flag:
            ans = max(ans, sum(c))
    
    print(ans)
        
    
if __name__ == '__main__':
    main()
Problem p02848 (python)

Fixed submission:
n=int(input())
s=input()
s=list(s)
for i in range(len(s)):
    a=ord(s[i])+n
    if a>90:
        a-=26
    s[i]=chr(a)
print(''.join(s), end='')

Buggy submission (verdict: Runtime Error):
n=input()
s=input()
s2=list(s)
for i in range(len(s2)):
    a=ord(s2[i])+n
    if a>90:
        a-=26
    s2[i]=chr(a)
print(''.join(s2))
Problem p02885 (python)

Fixed submission:
a, b = map(int, input().split())
if a - 2*b > 0:
    print(a - 2*b)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a - 2*b > 0
    print(a - 2*b)
else:
    print(0)
Problem p02924 (python)

Fixed submission:
def main():
    n = int(input())
    print((n * (n - 1)) // 2)
        
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    print(sum(list(range(1, n))))
        
if __name__ == '__main__':
    main()
Problem p02947 (python)

Fixed submission:
import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def main():
    n = int(input())
    d = {}
    ans = 0
    
    for _ in range(n):
        ss = ''.join(sorted(input()))
        d[ss] = d.get(ss, 0) + 1
        
    for k, v in d.items():
        if v != 1:
            ans += combinations_count(v, 2)
         
    print(ans)
       
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    s = [input() for _ in range(n)]
    d = []
    ans = 0
    for ss in s:
        c = collections.Counter(ss)
        d.append(c)
    for i in range(n):
        for j in range(i + 1, n):
            if d[i] == d[j]:
                ans += 1              
    print(ans)  
        
    
if __name__ == '__main__':
    main()
Problem p02953 (python)

Fixed submission:
def main():
    n = int(input())
    h = list(map(int, input().split()))
    
    pre = h[0]
    for hh in h:
        if hh < pre-1:
            print('No')
            return
        pre = max(pre, hh)
        
    print('Yes')
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
@patch('builtins.input', test.test_input)
def main():
    n = int(input())
    h = list(map(int, input().split()))
    
    pre = h[0]
    for hh in h:
        if hh < pre:
            if hh >= pre - 1:
                pre = hh
            else:
                print('No')
                return
        pre = hh
        
    print('Yes')
    
if __name__ == '__main__':
    main()
Problem p03251 (python)

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

x = max(x)
y = min(y)

flag = True
for z in range(-100, 100+1):
    if x < z <= y and X < z <= Y:
        flag = False
        
if flag:
    print('War')
else:
    print('No War')

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

x = max(x)
y = min(y)

flag = True
for z in range(-100, 100+1):
    if x < z <= y and X < Z <= Y:
        flag = False
        
if flag:
    print('War')
else:
    print('No War')
Problem p03288 (python)

Fixed submission:
r = int(input())
if r < 1200:
    print('ABC')
elif r < 2800:
    print('ARC')
else:
    print('AGC')

Buggy submission (verdict: Runtime Error):
r = int(input().split())
if r < 1200:
    print('ABC')
elif r < 2800:
    print('ARC')
else:
    print('AGC')
Problem p03324 (python)

Fixed submission:
d, n = map(int, input().split())
if n % 100 != 0:
    print((100 ** d) * n)
if n % 100 == 0:
    print((100 ** d) * (n+1))

Buggy submission (verdict: Runtime Error):
d, n = map(int, input().split())
print((100 ** d) * n if n % 100 != 0)
print((100 ** d) * (n+1) if n % 100 == 0)
Problem p03352 (python)

Fixed submission:
x = int(input())
s = {1}
for i in range(1, x):
    for j in range(2, x):
        if i**j <= x:
            s.add(i**j)
        else:
            break
print(max(s))

Buggy submission (verdict: Runtime Error):
x = int(input())
s = set()
for i in range(1, x):
    for j in range(2, x):
        if i**j <= x:
            s.add(i**j)
        else:
            break
print(max(s))
Problem p03379 (python)

Fixed submission:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = sorted(a)
    
    for i in range(n):
        if a[i] <=  b[n // 2 - 1]:
            print(b[n // 2])
        elif a[i] >  b[n // 2 - 1]:
            print(b[n // 2 - 1])
        
        
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = sorted(a)
    
    def seach(x):
        l = 0
        r = n - 1
        while True:
            i = (l + r) // 2
            if r - l <= 1:
                if b[r] == x:
                    return r
                else:
                    return l
            if b[i] < x:
                l = i
            elif f(i) > x:
                r = i
            else: 
                return i
    
    for i in range(n):
        j = seach(a[i])
        c = b[:j] + b[j+1:]
        print(c[n // 2 - 1])

        
if __name__ == '__main__':
    main()
Problem p03385 (python)

Fixed submission:
s = input()
if ('a' in s) and ('b' in s) and ('c' in s):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s = input()
if ('a' in s) and ('b' in s) and ('c' in s):
    print('Yes')
else;
    print('No')
Problem p03415 (python)

Fixed submission:
c =[list(input()) for _ in range(3)]
print(c[0][0]+c[1][1]+c[2][2])

Buggy submission (verdict: Runtime Error):
c =[list(input().split()) for _ in range(3)]
print(c[0][0]+c[1][1]+c[2][2])
Problem p03730 (python)

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

for i in range(1, 100):
    if a*i % b == c:
        print('YES')
        break
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
for i in range(1, 100):
    if a*i % b == c:
        print('YES')
        break
else:
    print('NO')
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, nput().split())
if b - a == c - b:
    print('YES')
else:
    print('NO')
Problem p03998 (python)

Fixed submission:
s = []
for _ in range(3):
    x = input().replace('a', '0').replace('b', '1').replace('c', '2')
    s.append(str(x))
    
now = 0
while True:
    if len(s[now]) == 0:
        if now == 0:
            print('A')
        if now == 1:
            print('B')   
        if now == 2:
            print('C')
        break
        
    after = int(s[now][0])
    s[now] =  s[now][1:]
    now = after

Buggy submission (verdict: Runtime Error):
s = []
for _ in range(3):
    x = input().replace('a', '0').replace('b', '1').replace('c', '2')
    s.append(str(x))
    
now = 0
while True:
    if len(s[0])==0:
        print('A')
        break
    elif len(s[1])==0:
        print('B')
        break
    elif len(s[1])==0:
        print('C')
        break
        
    after = int(s[now][0])
    s[now] =  s[now][1:]
    now = after
Problem p02613 (python)

Fixed submission:
n = int(input())
c0 = 0
c1 = 0
c2 = 0
c3 = 0

for i in range(n):
    test = input()
    if test == "AC":
        c0 += 1
    elif test == "WA":
        c1 += 1
    elif test == "TLE":
        c2 +=1
    elif test == "RE":
        c3 += 1
print("AC x", c0)
print("WA x", c1)
print("TLE x", c2)
print("RE x", c3)

Buggy submission (verdict: Runtime Error):
n = int(input())
c0 = 0
c1 = 0
c2 = 0
c3 = 0

for i in range(n):
    test = input()
    if test == "AC":
        c0 += 1
    elif test == "WA":
        c1 += 1
    elif test == "TLE":
        c2 +=1
    elif test == "RE":
        c3 += 1
print("AC x", c0)
print("WA x", c1)
print("TLE x", c2)
ptint("RE x", c3)

Buggy submission (verdict: Runtime Error):
n = int(input())
c0 = 0
c1 = 0
c2 = 0
c3 = 0

for i in range(n):
    test = input()
    if test == "AC":
        c0 += 1
    elif test == "WA":
        c1 += 1
    elif test == "TLE":
        c2 +=1
    elif test == "RE":
        c3 += 1
print("AC x", c0)
print("WA x", c1)
print("TLE x", c2)
ptinr("RE x", c3)
Problem p02639 (python)

Fixed submission:
a, b, c, d, e = map(int, input().split())
if a == 0:
    print(1)
elif b == 0:
    print(2)
elif c == 0:
    print(3)
elif d == 0:
    print(4)
else:
    print(5)

Buggy submission (verdict: Runtime Error):
x, y = map(int, input().split())
a = y - 2*x
if a < 0:
    print("No")
elif a > x:
    print("No")
elif a % 2 == 0:
    print("Yes")
elif a == 0:
    print("Yes")
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()))
if 0 in a:
    print(0)
else:
    ans = 1
    for i in a:
        ans *= i
        if ans > 10**18:
            print(-1)
            break
print(ans)
Problem p02658 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
else:
    ans = 1
    for i in a:
        ans *= i
        if ans > 10**18:
            print(-1)
            exit()
    print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
numlist = list(map(int, input().split()))
if 0 in a:
    print(0)
else:
    ans = 1
    for i in a:
        ans *= i
        if ans > 10**18:
            print(-1)
            exit()
	print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
if 0 in numlist:
    print(0)
else:
    ans = 1
    for i in a:
        ans *= i
        if ans > 10**18:
            print(-1)
            exit()
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
numlist = list(map(int, input().split()))
if 0 in numlist:
    print(0)
else:
    ans = 1
    for i in numlist:
        ans *= i
        if ans > 10**18:
            print(-1)
            exit()
	print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
numlist = list(map(int, input().split()))
if 0 in numlist:
    print(0)
else:
    ans = 1
    for i in numlist:
        ans *= i
        if ans > 10**18:
            print(-1)
            exit()
	print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
numlist = list(map(int, input().split()))
if 0 in numlist:
    print(0)
else:
    ans = 1
    for i in numlist:
        ans *= i
        if ans > 10**18:
            print(-1)
            exit()
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
else:
    ans = 1
    for i in a:
        ans *= i
        if ans > 10**18:
            print(-1)
            exit()
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
else:
    ans = 1
    for i in a:
        ans *= i
        if ans > 10**18:
            print(-1)
            exit()
print(ans)
Problem p02830 (python)

Fixed submission:
n = int(input())
S, T = input().split()

ans = ""

for i in range(n):
    ans += S[i]+T[i]
    
print(ans)

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())

x = min(a, k)
a -= x
k -= x
y = min(b, k)
b -= y

print(str(a),str(b))
Problem p02999 (python)

Fixed submission:
x, a = map(int, input().split())
if x < a:
    print(0)
else:
    print(10)

Buggy submission (verdict: Runtime Error):
x, a = map(int, input().split())
if s < a:
    print(0)
else:
    print(10)
Problem p03030 (python)

Fixed submission:
N = int(input())

L = []

for i in range(N):
    s,p = input().split()
    L.append([s, 100-int(p), i+1])
L.sort()
for j in L:
    print(j[2])

Buggy submission (verdict: Runtime Error):
n = int(input())
restaurant = [input().split() for i in range(n)]
restaurant_sorted = sorted(restaurant)

for i in range(n):
    print(restaurant.index((restaurant_sorted[i]))
Problem p03126 (python)

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

cnt = [0]*m

for i in range(n):
    survey = list(map(int, input().split()))
    k = survey[0]
    for j in range(1,k+1):
        favorite = survey[j]
        cnt[favorite - 1] += 1

print(cnt.count(n))

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

cnt = [0]*m

for i in range(n):
    survey = list(map(int, input().split()))
    k = survey[0]
    for j in range(1,k+1):
        cnt[survey[j-1]] += 1
    
ans = survey.count(n)
print(ans)

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

cnt = [0]*m

for i in range(n):
    survey = list(map(int, input().split()))
    k = survey[0]
    for j in range(1,k+1):
        cnt[survey[j-1]] += 1
    
ans = survey.count(n)
print(ans)
Problem p03853 (python)

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

for i in range(H):
    x = input()
    print(x)
    print(x)

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

C = [input() for i in range(W)]

for i in range(W):
    print(C[i])
    print(C[i])
Problem p04043 (python)

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

A_sort = sorted(A)

if A_sort[0]==5 and A_sort[1]==5 and A_sort[2]==7:
    print("YES")
else:
    print("NO")

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

if len(a) == 7:
    if len(b) == 5 and len(c) == 5:
        print("Yes")
    else:
        print("No")
        
if len(b) == 7:
    if len(a) == 5 and len(c) == 5:
        print("Yes")
    else:
        print("No")

if len(c) == 7:
    if len(a) == 5 and len(b) == 5:
        print("Yes")
    else:
        print("No")
Problem p02582 (python)

Fixed submission:
s = input()

if s == 'RRR':
    print(3)
    exit()
elif s == 'SSS':
    print(0)
    exit()
elif s[:2] == 'RR' or s[1:] == 'RR':
    print(2)
    exit()
elif 'R' in s:
    print(1)
    exit()
else:
    print(0)
    exit()

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

ans = 0
if s == 'RRR':
    print(3)
    exit()
elif s[0] == 'R' and s[1] == 'R':
    print(2)
    exit()
elif s[1] == 'R' and s[2] == 'R':
    print(2)
    eixt()
elif 'R' in s:
    print(1)
    exit()
else:
    print(0)
Problem p02640 (python)

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

for a in range(x + 1):
    b = x - a
    if (2 * a + 4 * b) == y:
        print('Yes')
        exit()
print('No')

Buggy submission (verdict: Runtime Error):
for a in range(x + 1):
    b = x - a
    if (2 * a + 4 * b) == y:
        print('Yes')
        exit()
print('No')
Problem p02681 (python)

Fixed submission:
s = input()
t = input()

if t == s + t[-1]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import sys
sys.stdin = open('input.txt', 'r', encoding='utf-8')

s = input()
t = input()

if t == s + t[-1]:
    print('Yes')
else:
    print('No')
Problem p02748 (python)

Fixed submission:
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [tuple(map(int, input().split())) for _ in range(M)]

minP = min(a) + min(b)
for x, y, c in xyc:
    minP = min(a[x-1]+b[y-1]-c, minP)
print(minP)

Buggy submission (verdict: Runtime Error):
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [tuple(map(int, input().split())) for _ in range(M)]

minP = min(a) + min(b)
for x, y, c in xyc:
    minP = min(a[x-1]+b[x-1]-c, minP)
print(minP)
Problem p02756 (python)

Fixed submission:
S = input()
Q = int(input())
Query = [input().split() for _ in range(Q)]

rev = False
S1 = ''
S2 = ''

for TFC in Query:
    if TFC[0] == '1':
        rev = not rev
    else:
        if TFC[1] == '1':
            if rev:
                S2 += TFC[2]
            else:
                S1 = TFC[2] + S1
        else:
            if rev:
                S1 = TFC[2] + S1
            else:
                S2 += TFC[2]

if rev:
    print(S2[::-1] + S[::-1] + S1[::-1])
else:
    print(S1 + S + S2)

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

S = input()
Q = int(input())
Query = [input().split() for _ in range(Q)]

S1 = deque('')
S2 = deque('')
rev = False

for TFC in Query:
    if TFC[0] == '1':
        rev = not rev
    else:
        if TFC[1] == '1':
            if rev:
                S2.append(TFC[2])
            else:
                S1.appendleft(TFC[2])
        else:
            if rev:
                S1.appendleft(TFC[2])
            else:
                S2.append(TFC[2])
if rev:
    S2 = ''.join(S2[::-1])
    S1 = ''.join(S1[::-1])
    print(S2 + S + S1)
else:
    S1 = ''.join(S1)
    S2 = ''.join(S2)
    print(S1 + S + S2)

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

S = input()
Q = int(input())
Query = [input().split() for _ in range(Q)]

S1 = deque('')
S2 = deque('')
rev = False

for TFC in Query:
    if TFC[0] == '1':
        rev = not rev
    else:
        if TFC[1] == '1':
            if rev:
                S2.append(TFC[2])
            else:
                S1.appendleft(TFC[2])
        else:
            if rev:
                S1.appendleft(TFC[2])
            else:
                S2.append(TFC[2])
if rev:
    S2 = ''.join(S2[::-1])
    S1 = ''.join(S1[::-1])
    print(S2 + S + S1)
else:
    S1 = ''.join(S1)
    S2 = ''.join(S2)
    print(S1 + S + S2)

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

S = input()
Q = int(input())
Query = [input().split() for _ in range(Q)]

S = deque(S)
S1 = deque('')
S2 = deque('')
rev = False

for TFC in Query:
    if TFC[0] == '1':
        rev = not rev
    else:
        if TFC[1] == '1':
            if rev:
                S2.append(TFC[2])
            else:
                S1.appendleft(TFC[2])
        else:
            if rev:
                S1.appendleft(TFC[2])
            else:
                S2.append(TFC[2])
if rev:
    S2.reverse()
    S.reverse()
    S1.reverse()
    print(''.join(S2 + S + S1))
else:
    print(''.join(S1 + S + S2))
Problem p02765 (python)

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

if n >= 10:
    print(r)
else:
    print(r + 100*(10-n))

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

if n >= 10:
    print(r)
else:
    print(r + 100*(10-n)))
Problem p03240 (python)

Fixed submission:
n = int(input())
XYH = list(tuple(map(int, input().split())) for _ in range(n))

# h != 0であるデータを取得
for x, y, h in XYH:
    if h != 0:
        x_, y_, h_ = x, y, h
        break

for cx in range(0, 101):
    for cy in range(0, 101):

        H = abs(x_ - cx) + abs(y_ - cy) + h_

        if all([max(H - abs(x - cx) - abs(y - cy), 0) == h for x, y, h in XYH]):
            print(cx, cy, H)
            exit()

Buggy submission (verdict: Runtime Error):
n = int(input())
XYH = list(tuple(map(int, input().split())) for _ in range(n))

for i in range(n):
    if XYH[i][2] == 0:
        del XYH[i]

for cx in range(0, 101):
    for cy in range(0, 101):

        x, y, h = XYH[0]
        H = abs(x-cx) + abs(y-cy) + h

        if all([H == abs(x-cx) + abs(y-cy) + h for x, y, h in XYH]):
            print(cx, cy, H)
            exit()
Problem p03351 (python)

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

if abs(a-c) <= d:
    print('Yes')
elif abs(a-b) <= d and abs(b-c) <= d:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
p(int, input().split())

if abs(a-c) <= d:
    print('Yes')
elif abs(a-b) <= d and abs(b-c) <= d:
    print('Yes')
else:
    print('No')
Problem p03371 (python)

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

if x > y:
    ans = min(A+B, 2*C) * y
    ans += min(A, 2*C) * (x-y)
elif x < y:
    ans = min(A+B, 2*C) * x
    ans += min(B, 2*C) * (y-x)
else:
    ans = min(A+B, 2*C) * x
print(ans)

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

if x > y:
    ans = min(A+B, 2*C) * y
    ans += min(A, 2*C) * (x-y)
elif x < y:
    ans = min(A+B, 2*C) * x
    ans += min(B, 2*C) * (y-x)
else:
    ans += min(A+B, 2*C) * x
print(ans)
Problem p03632 (python)

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

print(max(0, min(b, d) - max(a, c)))

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

print(max(min(b, d) - max(a, c), 0)
Problem p02537 (python)

Fixed submission:
N, K = map(int, input().split())
l = []
for i in range(N):
  l.append(int(input()))
  
cnts = [1] * N
for i in range(N):
  for j in range(max(0, i-200), i):
    if abs(l[i]-l[j]) <= K:
      cnts[i] = max(cnts[i], cnts[j]+1)
print(max(cnts))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
l = []
for i in range(N):
  l.append(int(input()))
  
cnts = [0] * 20
for i in range(N-1):
  tmp = 0
  for j in range(max(l[i]-3, 0), min(l[i]+4, 300000)):
    tmp = max(tmp, cnts[j])
  cnts[l[i]] = tmp+1
print(max(cnts))