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

Fixed submission:
nums = input().strip()
pre_num = ""
result = ""
flag = True

for num in nums:
	if pre_num == num: flag = False
	pre_num = num

if flag: result = "Good"
else: result = "Bad"

print(result)

Buggy submission (verdict: Runtime Error):
import fractions

A,B,C,D = input().strip().split(" ")
A = int(A)
B = int(B)
C = int(C)
D = int(D)

div1 = A // C
div2 = A // D
div3 = (B-1) // C
div4 = (B-1) // D

X = C*D // int(fractions.gcd(C,D))
div5 = B // X

del_nums = (div3 + div4) - (div1 + div2) + div5
result = B - A - del_nums
print(result)

Buggy submission (verdict: Runtime Error):
security_num = input()
pre_num = ""
    
for num in security_num:
	if pre_num == num: return "Bad"
	pre_num = num

return "Good"
Problem p02995 (python)

Fixed submission:
import fractions

A,B,C,D = input().strip().split(" ")
A = int(A)
B = int(B)
C = int(C)
D = int(D)
X = C*D // fractions.gcd(C,D)

c = B//C - A//C + int(A%C == 0)
d = B//D - A//D + int(A%D == 0)
cd = B//X - A//X + int(A%X == 0)

delim = c + d - cd
result = B - A + 1 - delim 
print(result)

Buggy submission (verdict: Runtime Error):
import collections

N = input().strip()
N = int(N)
dic = collections.defaultdict(lambda: 0)

for i in range(N):
    x,y = input().strip().split(" ")
    x = int(x)
    y = int(y)

    dic[y] += x

prev_time = 0
result = "Yes"

for k,v in dic.items():
    if v > k:
        result = "No"
        break
    prev_time += v

print(result)
Problem p02996 (python)

Fixed submission:
import collections

N = input().strip()
N = int(N)
dic = collections.defaultdict(lambda: 0)

for i in range(N):
    x,y = input().strip().split(" ")
    x = int(x)
    y = int(y)

    dic[y] += x

prev_time = 0
result = "Yes"

for k,v in sorted(dic.items(),key=lambda x:x[0]):
    if v+prev_time > k:
        result = "No"
        break
    prev_time += v

print(result)

Buggy submission (verdict: Runtime Error):
N = input().strip()
N = int(N)
dic = collections.defaultdict(lambda: 0)

for i in range(N):
    x,y = input().strip().split(" ")
    x = int(x)
    y = int(y)

    dic[y] += x

prev_time = 0
result = "Yes"

for k,v in dic.items():
    if v > k:
        result = "No"
        break
    prev_time += v

print(result)
Problem p02999 (python)

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

(print(10) if x >= a else print(0))

Buggy submission (verdict: Runtime Error):
x=int(input())
a=int(input())

(print(10) if x >= a else print(
Problem p02995 (python)

Fixed submission:
from sys import exit
import fractions

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

CD = (C * D) // fractions.gcd(C, D)

c_sum = B // C - (A - 1) // C
d_sum = B // D - (A - 1) // D
cd_sum = B // CD - (A - 1) // CD

print(B - A + 1 - (c_sum + d_sum - cd_sum))

Buggy submission (verdict: Runtime Error):
from sys import exit
import math

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

CD = (C * D) // math.gcd(C, D)

c_sum = B // C - (A - 1) // C
d_sum = B // D - (A - 1) // D
cd_sum = B // CD - (A - 1) // CD

print(B - A + 1 - (c_sum + d_sum - cd_sum))

Buggy submission (verdict: Runtime Error):
from sys import exit
import math

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

CD = (C * D) // math.gcd(C, D)

c_sum = B // C - (A - 1) // C
d_sum = B // D - (A - 1) // D
cd_sum = B // CD - (A - 1) // CD

print(B - A + 1 - (c_sum + d_sum - cd_sum))
Problem p03037 (python)

Fixed submission:
from sys import exit

N, M = map(int, input().split())

L = []
R = []

for i in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

l_max = max(L)
r_min = min(R)

if (r_min - l_max) < 0:
    print(0)
else:
    print(r_min - l_max + 1)

Buggy submission (verdict: Runtime Error):
from sys import exit

N, M = map(int, input().split())

ans = []

for i in range(M):
    L, R = map(int, input().split())

    if i == 0:
        for card in range(L, R + 1):
            ans.append(card)
        continue

    if ans[0] < L:
        for card in range(ans[0], L):
            ans.remove(card)

    if R < ans[-1]:
        for card in range(R + 1, ans[-1] + 1):
            ans.remove(card)

    if not ans:
        print(0)
        exit()

print(len(ans))
Problem p03048 (python)

Fixed submission:
from sys import exit

R, G, B, N = map(int, input().split())

count = 0

for r in range(N // R + 1):
	for g in range((N - r * R) // G + 1):
		if (N - r * R - g * G) % B == 0:
			count += 1

print(count)

Buggy submission (verdict: Runtime Error):
from sys import exit

R, G, B, N = map(int, input().split())

count = 0

for r in range(N // R + 1):
	for g in range(N // G + 1):
		for b in range(N // B + 1)
			if r + g + b == N:
				count += 1

print(count)
Problem p03061 (python)

Fixed submission:
from sys import exit

N = int(input())
A = list(map(int, input().split()))


def gcd(a, b):
    if a == 0:
        return b

    if b == 0:
        return a

    temp = a % b
    while temp != 0:
        a = b
        b = temp
        temp = a % b

    return b


left = [0 for i in range(N)]
right = left[:]

for i in range(1, N):
    left[i] = gcd(A[i - 1], left[i - 1])
    right[-i - 1] = gcd(A[-i], right[-i])

ans = [gcd(left[i], right[i]) for i in range(N)]

print(max(ans))

Buggy submission (verdict: Runtime Error):
from sys import exit

N = int(input())
A = list(map(int, input().split()))


def gcd(a, b):
    if a == 0:
        return b

    if b == 0:
        return a

    temp = a % b
    while temp != 0:
        a = b
        b = temp
        temp = a % b

    return b


# 0 ~ i
def left(i):
    if i == 0:
        return 0

    if left(i - 1) > A[i - 1]:
        return gcd(left(i - 1), A[i - 1])
    else:
        return gcd(A[i - 1], left(i - 1))


# i ~ N-1
def right(i):
    if i == N - 1:
        return 0

    if right(i + 1) > A[i + 1]:
        return gcd(right(i + 1), A[i + 1])
    else:
        return gcd(A[i + 1], right(i + 1))


ans = []

for i in range(N):
    ans.append(gcd(left(i), right(i)))

print(max(ans))

Buggy submission (verdict: Runtime Error):
from sys import exit

N = int(input())
A = list(map(int, input().split()))


def gcd(a, b):
    if a == 0:
        return b

    if b == 0:
        return a

    temp = a % b
    while temp != 0:
        a = b
        b = temp
        temp = a % b

    return b


# 0 ~ i
def left(i):
    if i == 0:
        return 0

    return gcd(left(i - 1), A[i - 1])


# i ~ N-1
def right(i):
    if i == N - 1:
        return 0

    return gcd(right(i + 1), A[i + 1])


ans = []

for i in range(N):
    ans.append(gcd(left(i), right(i)))

print(max(ans))
Problem p03076 (python)

Fixed submission:
from sys import exit

time = [int(input()), int(input()), int(input()), int(input()), int(input())]

total = 0
loss = []

for t in time:
    total += t
    if t % 10 != 0:
        loss.append(10 - t % 10)

if loss:
    total += sum(loss) - max(loss)

print(total)

Buggy submission (verdict: Runtime Error):
from sys import exit

time = [int(input()), int(input()), int(input()), int(input()), int(input())]

total = 0
loss = []

for t in time:
    total += t
    if t % 10 != 0:
        loss.append(10 - t % 10)

total += sum(loss) - max(loss)

print(total)
Problem p03103 (python)

Fixed submission:
from sys import exit

N, M = map(int, input().split())

shops = {}

for _ in range(N):
    A, B = map(int, input().split())
    if A in shops.keys():
        shops[A] += B
    else:
        shops[A] = B

shops = sorted(shops.items())
ans = 0

for k in shops:
    if M - k[1] <= 0:
        ans += k[0] * M
        break
    else:
        ans += k[0] * k[1]
        M -= k[1]

print(ans)

Buggy submission (verdict: Runtime Error):
from sys import exit

N, M = map(int, input().split())

shops = {}

for _ in range(N):
    A, B = map(int, input().split())
    if shops[A]:
        shops[A] += B
    else:
        shops[A] = B

shops = sorted(shops.items())
ans = 0

for k in shops:
    if M - k[1] <= 0:
        ans += k[0] * M
        break
    else:
        ans += k[0] * k[1]
        M -= k[1]

print(ans)
Problem p03145 (python)

Fixed submission:
def main():
    AB, BC, CA = map(int, input().split())
    print(int(AB * BC / 2))


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N, K = map(int, input().split())
    td = []
    for _ in range(N):
        ti, di = map(int, input().split())
        td.append([ti, di])
    td.sort(key=lambda x: -x[1])
    num = 0
    kind = set()
    changable = []
    for i in range(K):
        num += td[i][1]
        if td[i][0] in kind:
            changable.append(td[i][0])
        else:
            kind.add(td[i][0])
    num += len(kind) ** 2
    ans = num

    for i in range(K, N):
        if not changable:
            break
        if td[i][0] not in kind:
            num += td[i][1] + 2 * len(kind) + 1 - changable.pop()
            kind.add(td[i][0])
            ans = max(ans, num)


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

Fixed submission:
import math
from decimal import *

def main():
    N = int(input())
    T = []
    A = []
    for _ in range(N):
        t, a = map(int, input().split())
        T.append(t)
        A.append(a)

    for i in range(N - 1):
        if T[i] / T[i + 1] > 1 or A[i] / A[i + 1] > 1:
            mul = Decimal(max(math.ceil(T[i] / T[i + 1]), math.ceil(A[i] / A[i + 1])))
            A[i + 1] *= mul
            T[i + 1] *= mul
    print(T[N - 1] + A[N - 1])


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import math
from Decimal import *

def main():
    N = int(input())
    T = []
    A = []
    for _ in range(N):
        t, a = map(int, input().split())
        T.append(t)
        A.append(a)

    for i in range(N - 1):
        if T[i] / T[i + 1] > 1 or A[i] / A[i + 1] > 1:
            mul = Decimal(max(math.ceil(T[i] / T[i + 1]), math.ceil(A[i] / A[i + 1])))
            A[i + 1] *= mul
            T[i + 1] *= mul
    print(T[N - 1] + A[N - 1])


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import math


def main():
    N = int(input())
    T = []
    A = []
    for i in range(N):
        t, a = map(int, input().split())
        T.append(t)
        A.append(a)

    for i in range(N):
        if math.gcd(A[i], T[i]) != 1:
            A[i] = A[i] // math.gcd(A[i], T[i])
            T[i] = T[i] // math.gcd(A[i], T[i])

    for i in range(N - 1):

        if T[i] / T[i + 1] > 1 or A[i] / A[i + 1] > 1:
            if T[i] / T[i + 1] >= A[i] / A[i + 1]:
                A[i + 1] = math.ceil(T[i] / T[i + 1]) * A[i + 1]
                T[i + 1] = math.ceil(T[i] / T[i + 1]) * T[i + 1]
            else:
                T[i + 1] = math.ceil(A[i] / A[i + 1]) * T[i + 1]
                A[i + 1] = math.ceil(A[i] / A[i + 1]) * A[i + 1]
    print(T[N - 1] + A[N - 1])


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

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

N = A * 3 + P
result = N // 2
print(result)

Buggy submission (verdict: Runtime Error):
import itertools

n, m = input().split()
N = int(n)
M = int(m)

K = []
for i in range(M):
    K.append(list(map(int, input().strip().split(' '))))

P = list(map(int, input().strip().split(' ')))

SW = {0, 1}
SWlist = list(itertools.product(SW, repeat=N))

result = 0
fflag = False

for i in range(len(SWlist)):
    for j in range(len(K)):
        count = 0
        for k in range(K[j][0]):
            if SWlist[i][k] == 1:
                count += 1
        if count % 2 != P[j]:
            fflag = True
            break
    if not fflag:
        result += 1
    else:
        fflag = False
print(result)
Problem p03085 (python)

Fixed submission:
h = input()

if h == 'A':
    print("T")
elif h == 'T':
    print("A")
elif h == 'C':
    print("G")
elif h == 'G':
    print("C")

Buggy submission (verdict: Runtime Error):
n, q = input().split()
Q = int(q)
s = input()
S = list(s)

array = []
count = 0
ff = False
for i in range(len(S)):
    if len(S) < i+1:
        break
    if S[i] == 'A':
        flag = True
    elif flag == True and S[i] == 'C':
        count += 1
        array.append(-1)
        array.append(count)
        ff = True
    elif flag == True:
        array.append(0)
        array.append(0)
        flag = False
    else:
        array.append(0)

array_q = []
for q in range(Q):
    l, r = input().split()
    array_q.append([int(l), int(r)])

for arr in array_q:
    try:
        if ff != True:
            print(0)
            continue

        if len(array[arr[0]-1:arr[1]-1]) < 2:
            print(0)
            continue

        for a in array[arr[0]-1:]:
            if a == -1:
                flag = True
            elif flag == True:
                minv = a
                break

        for b in reversed(array[:arr[1]]):
            if b != 0 and b != -1:
                maxv = b
                break

        if minv == maxv and maxv != 0:
            print(1)
            
        elif maxv == 0:
            print(0)

        else:
            print(maxv - minv + 1)
            maxv = 0
            minv = 0
    except:
        print(0)
Problem p03086 (python)

Fixed submission:
h = input()
S = list(h)

atc = ['A', 'T', 'C', 'G']

flag = False
count = 0
maxt = 0
for i in range(len(S)):
    for s in range(len(S)):
        s = s + i
        if len(S) <= s:
            if maxt <= count:
                maxt = count
            break
        if flag == False and (S[s] in atc):
            flag = True
            count += 1
        elif flag == True and (S[s] in atc):
            count += 1
        elif flag == True:
            break
        if maxt < count:
            maxt = count
    count = 0
    flag = False
print(maxt)

Buggy submission (verdict: Runtime Error):
n, q = input().split()
Q = int(q)
s = input()
S = list(s)

array = []
count = 0
ff = False
for i in range(len(S)):
    if len(S) < i+1:
        break
    if S[i] == 'A':
        flag = True
        array.append(0)
    elif flag == True and S[i] == 'C':
        count += 1
        array.pop(-1)
        array.append(-1)
        array.append(count)
        ff = True
    elif flag == True:
        array.append(0)
        flag = False
    else:
        array.append(0)

array_q = []
for q in range(Q):
    l, r = input().split()
    array_q.append([int(l), int(r)])

for arr in array_q:
    if ff != True:
        print(0)
    if len(array[arr[0]-1:arr[1]-1]) < 2:
        print(0)
        continue
    for a in array[arr[0]-1:]:
        if a == -1:
            flag = True
        elif flag == True:
            minv = a
            break
    for b in reversed(array[:arr[1]]):
        if b != 0 and b != -1:
            maxv = b
            break
    if minv == maxv:
        print(1)
    else:
        print(maxv - minv + 1)
Problem p03000 (python)

Fixed submission:
n,x = (int(i) for i in input().split())  
l = [int(i) for i in input().split()] 
d = 0
i=0
while d <= x:
    try:
        d+=l[i]
    except:
        i+=1
        break
    i+=1

print(i)

Buggy submission (verdict: Runtime Error):
n,x = (int(i) for i in input().split())  
l = [int(i) for i in input().split()] 
d = 0
i=0
while d <= x or i >= n:
   d+=l[i]
   i+=1

print(i)

Buggy submission (verdict: Runtime Error):
n,x = (int(i) for i in input().split())  
l = [int(i) for i in input().split()] 
d = 0
i=0
while d <= x:
   d+=l[i]
   i+=1 

print(i)

Buggy submission (verdict: Runtime Error):
n,x = (int(i) for i in input().split())  
l = [int(i) for i in input().split()] 
d = 0
i=0
type(l)
while d <= x:
   d+=l[i]
   i+=1 

print(i)
Problem p03023 (python)

Fixed submission:
n = int(input())
print(180*(n-2))

Buggy submission (verdict: Runtime Error):
a,p = map(int,input().split())
print((a*3+p)//2)
Problem p03024 (python)

Fixed submission:
s = list(input())

res = 0
for i in range(len(s)):
    if s[i] == "x":
        res += 1
if res < 8:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
n = int(input())
lis = []
for i in range(n):
    s,p = list(input().split())
    lis.append([i+1,s,int(p)])
t = sorted(lis, key=lambda x: -x[2])
s = sorted(t, key=lambda x: x[1])


for i in s:
    print(i[0])
Problem p03067 (python)

Fixed submission:
a,b,c = map(int, input().split())
if (a <= c and c <= b) or (a >= c and c >= b):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
s = list(input())
lis = []
rtmp = 0
ltmp = 0
tmp = 0
l,r = 0,0

for i in range(n-1):
    if (s[i] != s[i+1]):
        #clis+= 1
        #print(i)
        rtmp = i+1
        ltmp = i
        for j in range(ltmp):
            if s[j] == '#':
                tmp += 1
        for j in range(rtmp,n):
            if s[j] == '.':
                tmp += 1
        lis.append(tmp)
        #print(lis)
    tmp = 0
    l,r = 0,0

if len(lis) == 0: 
    print(0)
else:
    print(min(lis))

Buggy submission (verdict: Runtime Error):
def chec(s):
    llis = []
    rlis = []
    clis = 0
    lef = 1
    rig = 1
    rtmp = 0
    ltmp = 0
    flg = 0
    na = len(s)
    for i in range(na):
        if na - i != 1 and s[na-i-1] == '#' and s[na-i] == '.' :
            #clis+= 1
            #print(i)
            rtmp = na - i
            ltmp = na - i-1
            while ltmp != 0 and s[ltmp] == s[ltmp-1]:
                lef += 1
                ltmp -= 1
            llis.append(lef)
            while rtmp != na and s[rtmp] == s[rtmp+1]:
                rig += 1
                rtmp += 1
            rlis.append(rig)
            lef = 1
            rig = 1
            rtmp = 0
            ltmp = 0
    #print(llis)
    #print(rlis)

    clis = min(sum(llis),sum(rlis))
    return clis


n = int(input())
s = list(input())
print(chec(s))
Problem p03457 (python)

Fixed submission:
n = int(input())
l = [input().split() for _ in range(n)]
ot = ox = oy = 0
can = True
for (t, x, y) in l:
    dt = int(t) - ot
    dist = abs(int(x) - ox) + abs(int(y) - oy)
    if dt < dist:
        can = False
    if (dist % 2 != dt % 2):
        can = False
    ox = int(x)
    oy = int(y)
    ot = int(t)

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

Buggy submission (verdict: Runtime Error):
n = int(input())
l = [input().split() for _ in range(n)]
ot = ox = oy = 0
for (t, x, y) in l:
    diff = int(t) - ot
    if abs(x - ox) + abs(y - oy) <= diff:
        ox = x
        oy = y
        ot = t
    else:
        print("No")
        exit(0)
print("Yes")
Problem p03478 (python)

Fixed submission:
(n, a, b) = [int(x) for x in input().split()]

def charSum(s):
    r = 0
    for c in s:
        r += int(c)
    return r

ans = sum(list(filter(lambda x: a <= charSum(str(x)) <= b, range(1, n+1))))
print(ans)

Buggy submission (verdict: Runtime Error):
(n, a, b) = [int(x) for x in input().split()]

def charSum(s):
    r = 0
    for c in s:
        r += int(c)

ans = sum(list(filter(lambda x: a <= charSum(str(x)) <= b, range(1, n+1))))
print(ans)
Problem p03493 (python)

Fixed submission:
count = 0
for s in input():
    if s == '1':
        count += 1

print(count)

Buggy submission (verdict: Runtime Error):
count = 0
for s in input():
    if s = '1':
        count += 1

print(count)
Problem p03854 (python)

Fixed submission:
s = input()


while len(s) > 0:
    if s[-6:] == 'eraser':
        s=s[:-6]
    elif s[-7:] == 'dreamer':
        s=s[:-7]
    elif s[-5:] == 'erase' or s[-5:] == 'dream':
        s=s[:-5]
    else:
        print('NO')
        exit(0)
print('YES')

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


def foo(s):
    last = s[-1:]
    # is empty
    if not s:
        return "YES"
    else:
        n = 0
        if last == 'r' and s[-6:] == 'eraser':
            n = -6
        elif last == 'r' and s[-7:] == 'dreamer':
            n = -7
        elif (last == 'e' and s[-5:] == 'erase') or (last == 'm' and s[-5:] == 'dream'):
            n = -5

        if n == 0:
            return "NO"
        else:
            return foo(s[:n])


print(foo(ins))

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


def foo(s):
    last = s[-1:]
    # is empty
    print(s)
    if not s:
        return "YES"
    else:
        n = 0
        if last == 'r' and s[-6:] == 'eraser':
            n = -6
        elif last == 'r' and s[-7:] == 'dreamer':
            n = -7
        elif (last == 'e' and s[-5:] == 'erase') or (last == 'm' and s[-5:] == 'dream'):
            n = -5

        if n == 0:
            return "NO"
        else:
            return foo(s[:n])


print(foo(ins))

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


def foo(s):
    last = s[-1:]
    # is empty
    if not s:
        return "YES"
    else:
        n = 0
        if last == 'r' and s[-6:] == 'eraser':
            n = -6
        elif last == 'r' and s[-7:] == 'dreamer':
            n = -7
        elif (last == 'e' and s[-5:] == 'erase') or (last == 'm' and s[-5:] == 'dream'):
            n = -5

        if n == 0:
            return "NO"
        else:
            return foo(s[:n])


print(foo(ins))

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


def foo(s):
    last = s[-1]
    # is empty
    if not s:
        return "YES"
    else:
        n = 0
        if last == 'r' and s[-6:] == 'eraser':
            n = -6
        elif last == 'r' and s[-7:] == 'dreamer':
            n = -7
        elif (last == 'e' and s[-5:] == 'erase') or (last == 'm' and s[-5:] == 'dream'):
            n = -5

        if n == 0:
            return "NO"
        else:
            return foo(s[:n])


print(foo(ins))
Problem p03000 (python)

Fixed submission:
n, x = map(int, input().split())
l = list(map(int, input().split()))
 
a = 0
b = 1
for i in range(n):
    a += l[i]
    b += 1
    if a > x:
        b -= 1
        break
    
print(b)

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

a = 0
b = 0
for i in range(n + 1):
    a += l[i]
    b += 1
    if a > x:
        break
print(b)
Problem p03160 (python)

Fixed submission:

def frog():
    n = int(input())
    h_list = list(map(int, input().split()))

    dp = [0] * 10 ** 5

    for n_element in range(n):
        if n_element >= 2:
            dp[n_element] = min(dp[n_element - 1] + abs(h_list[n_element] - h_list[n_element - 1]),
                                dp[n_element - 2] + abs(h_list[n_element] - h_list[n_element - 2]))
        elif n_element == 1:
            dp[n_element] = abs(h_list[n_element] - h_list[n_element - 1])
        else:
            dp[n_element] = 0

    print(dp[n - 1])


if __name__ == "__main__":
    frog()

Buggy submission (verdict: Runtime Error):

def frog():
    n = int(input())
    h_list = list(map(int, input().split()))

    dp = [0] * 100

    for n_element in range(n):
        if n_element >= 2:
            dp[n_element] = min(dp[n_element - 1] + abs(h_list[n_element] - h_list[n_element - 1]),
                                dp[n_element - 2] + abs(h_list[n_element] - h_list[n_element - 2]))
        elif n_element == 1:
            dp[n_element] = abs(h_list[n_element] - h_list[n_element - 1])
        else:
            dp[n_element] = 0

    print(dp[n - 1])


if __name__ == "__main__":
    frog()
Problem p03079 (python)

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

if a == b == c:
    print("Yes")
else:
    print("No")

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

char = {}
for i, c in enumerate(s):
    if c not in char.keys():
        char[c] = [i]
    else:
        char[c] = char[c] + [i]

count = [1] * N
out = 0
for _ in range(Q):
    A, L = input().split()
    try:
        idx = char[A]
    except KeyError:
        continue

    if L == "L":
        for ix in idx:
            temp = count[ix]
            count[ix] = 0
            if ix == 0:
                out += temp
            else:
                count[ix - 1] += temp
    else:
        for ix in idx:
            temp = count[ix]
            count[ix] = 0
            if ix == N - 1:
                out += temp
            else:
                count[ix + 1] += temp

print(N - out)