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

Fixed submission:
# バージョン 3.4.X 以前
import fractions
# バージョン 3.5 以降
# mport math


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


def main():
    A, B, C, D = map(int, input().split())
    first = B // C - A // C
    first += 1 if A % C == 0 else 0
    second = B // D - A // D
    second += 1 if A % D == 0 else 0
    tmp = lcm(C, D)
    both = B // tmp - A // tmp
    both += 1 if A % tmp == 0 else 0
    print(B - A + 1 - first - second + both)
    return


main()

Buggy submission (verdict: Runtime Error):
import math


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


def main():
    A, B, C, D = map(int, input().split())
    first = B // C - A // C
    first += 1 if A % C == 0 else 0
    second = B // D - A // D
    second += 1 if A % D == 0 else 0
    tmp = lcm(C, D)
    both = B // tmp - A // tmp
    both += 1 if A % tmp == 0 else 0
    print(B - A + 1 - first - second + both)
    return


main()
Problem p03037 (python)

Fixed submission:
def main():
    LRm = open(0).read().split()[2:]
    max_L = max(map(int, LRm[::2]))
    min_M = min(map(int, LRm[1::2]))
    print(min_M - max_L + 1 if max_L <= min_M else 0)
    return


main()

Buggy submission (verdict: Runtime Error):
def main():
    LR = open(0).read().split()[2:]
    max_L = max(map(int, LR[::2]))
    min_R = min(map(int, LR[1::2]))
    print(min_R - max_L + 1 if max_L <= min_M else 0)
    return


main()
Problem p03043 (python)

Fixed submission:
from functools import reduce
from operator import mul


def main():
    N, K = map(int, input().split())
    ans = []
    lst = []
    for i in range(1, N + 1):
        lst.clear()
        for j in range(K):
            if K <= i << j:
                break
            lst.append(0.5)
        ans.append(reduce(mul, lst, 1 / N))
    print(sum(ans))
    return


main()

Buggy submission (verdict: Runtime Error):
from functools import reduce
from operator import mul


def end_of_loop():
    raise StopIteration


def main():
    N, K = map(int, input().split())
    print(sum(reduce(mul, (0.5
                           if i << j < K
                           else end_of_loop()
                           for j in range(bin(K)-2)), 1 / N)
              for i in range(1, N + 1)))
    return


main()
Problem p03087 (python)

Fixed submission:
from sys import stdin


def main():
    lines = stdin.readlines()
    N = int(lines[0].split()[0])
    S = lines[1]
    lr = [[int(j) - 1 for j in i.split()] for i in lines[2:]]
    AC = [0] * N
    pre = 0
    for i, c1, c2 in zip(range(1, N), S[:], S[1:]):
        AC[i] += pre
        if c1 == "A" and c2 == "C":
            AC[i] += 1
        pre = AC[i]
    for l, r in lr:
        print(AC[r] - AC[l])
    return


main()

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


def main():
    lines = stdin.readlines()
    S = lines[1]
    lr = [[int(j) - 1 for j in i.split()] for i in lines[2:]]
    AC = []
    cnt = 0
    for c in S:
        if c == "A":
            pre = "A"
        elif pre == "A" and c == "C":
            cnt += 1
        elif pre == "A":
            pre = None
        AC.append(cnt)
    for l, r in lr:
        print(AC[r] - AC[l])
    return


main()
Problem p03239 (python)

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

ct = []

for i in range(N):
    ct.append([int(i) for i in input().split()])

ct.sort(key=lambda x: x[0])

ans = 1001

for i in range(N):
    if ct[i][1] <= T:
        ans = ct[i][0]
        break

print("TLE" if ans == 1001 else ans)

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

ct = [int(j) for j in input().split() for i in range(H)]

ct.sort(key=lambda x: x[0])

ans = 1001

for i in range(N):
    if ct[i][1] <= T:
        ans = ct[i][0]
        break

print("TLE" if ans == 1001 else ans)
Problem p03240 (python)

Fixed submission:
import sys

input = sys.stdin.readline

N = int(input())

xn = [0] * N
yn = [0] * N
hn = [0] * N

for i in range(N):
    xi, yi, hi = map(int, input().split())
    xn[i] = xi
    yn[i] = yi
    hn[i] = hi

div = 0

for Cx in range(101):
    for Cy in range(101):
        for i in range(N):

            if 0 < hn[i]:
                h = abs(xn[i] - Cx) + abs(yn[i] - Cy) + hn[i]
                if div in [0, 2]:
                    H = h
                    div = 1
                else:
                    if (H != h):
                        div = 2
                        break

        if div == 2:
            continue

        for i in range(N):
            if 0 == hn[i]:
                h = abs(xn[i] - Cx) + abs(yn[i] - Cy)
                if h < H:
                    div = 2
                    break

        if div == 2:
            continue

        print(Cx, Cy, H)
        break

    if div == 1:
        break

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

    xn = []
    yn = []
    hn = []

    for i in range(N):
        xi, yi, hi = map(int, input().split())
        if hi:
            xn.append(xi)
            yn.append(yi)
            hn.append(hi)

    if N == 1:
        print(xn[0], yn[0], hn[0])
        return

    for Cx in range(101):
        for Cy in range(101):

            last = None

            for i in range(N):
                H = abs(xn[i] - Cx) + abs(yn[i] - Cy) + hn[i]

                if H < 0:
                    continue
                if last:
                    if (last != H):
                        break

                last = H
            else:
                print(Cx, Cy, H)
                return


main()
Problem p03262 (python)

Fixed submission:
from sys import stdin

input = stdin.readline


def gcd(a, b):
    result = a
    k = 0
    n = b

    while True:
        k = result % n
        result = n
        n = k
        if k == 0:
            break

    return result


def gcd_n(numbers):
    l = numbers[0]

    for i in range(len(numbers)):
        l = gcd(l, numbers[i])

    return l


def lcm(a, b):
    g = gcd(a, b)

    return a * (b / g)


def lcm_n(numbers):
    l = numbers[0]

    for i in range(len(numbers)):
        l = lcm(l, numbers[i])

    return l


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

xn = [abs(X - int(i)) for i in input().split()]


def main():
    print(gcd_n(xn))
    return


main()

Buggy submission (verdict: Runtime Error):
from sys import stdin
from functools import reduce
import math

input = stdin.readline

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

xn = [abs(X - int(i)) for i in input().split()]


def main():
    print(reduce(math.gcd, xn))
    return


main()
Problem p03273 (python)

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

l = []

for i in range(H):
    l.append(input())

y = [False] * H
x = [False] * W

for i in range(H):
    flg = True
    for j in range(W):
        if l[i][j] != '.':
            flg = False
            break
    if flg:
        y[i] = True

for i in range(W):
    flg = True
    for j in range(H):
        if l[j][i] != '.':
            flg = False
            break
    if flg:
        x[i] = True

for i in range(H):
    if y[i]:
        continue
    for j in range(W):
        if x[j]:
            continue
        print(l[i][j], end='')
    print()

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

l = [int(input()) for i in range(H)]

y = [False] * H
x = [False] * W

for i in range(H):
    flg = True
    for j in range(W):
        if l[i][j] != '.':
            flg = False
            break
    if flg:
        y[i] = True

for i in range(W):
    flg = True
    for j in range(H):
        if l[j][i] != '.':
            flg = False
            break
    if flg:
        x[i] = True

for i in range(H):
    if y[i]:
        continue
    for j in range(W):
        if x[j]:
            continue
        print(l[i][j], end='')
    print()
Problem p03274 (python)

Fixed submission:
MAX = 300000001

N, K = map(int, input().split())
xn = [int(i) for i in input().split()]


def main():
    if 0 <= xn[0]:
        print(xn[K - 1])
        return

    if xn[N - 1] < 0:
        print(abs(xn[N - K]))
        return

    ans = MAX

    for i in range(N):
        if N - 1 < i + K - 1:
            break

        if xn[i] < 0:
            if xn[i + K - 1] < 0 and i + K <= N - 1 and 0 < xn[i + K]:
                ans = min(ans, abs(xn[i]))

            elif 0 <= xn[i + K - 1]:
                ans = min(ans,
                          2 * abs(xn[i]) + abs(xn[i + K - 1]),
                          abs(xn[i]) + 2 * abs(xn[i + K - 1]))

        elif 0 == xn[i]:
            ans = min(ans, xn[i + K - 1])

        elif 0 != i and xn[i - 1] < 0:
            ans = min(ans, xn[i + K - 1])

    print(ans)
    return


main()

Buggy submission (verdict: Runtime Error):
MAX = 300000001

N, K = map(int, input().split())
xn = [int(i) for i in input().split()]


def main():
    ans = MAX

    if 0 < xn[0]:
        ans = xn[K - 1]
        print(ans)
        return

    if xn[N - 1] < 0:
        ans = xn[N - K]
        print(ans)
        return

    for i in range(N):
        if xn[i] <= 0 and 0 <= xn[i + K - 1]:
            ans = min(ans,
                      2 * abs(xn[i]) + abs(xn[i + K - 1]),
                      abs(xn[i]) + 2 * abs(xn[i + K - 1]))

    print(ans)
    return


main()
Problem p03543 (python)

Fixed submission:
N = list(input())
len = len(N)
num = 0
for i in range(0, len, 1):
    cnt = 1
    for j in range(i + 1, len, 1):
        if (N[i] != N[j]):
            break
        else:
            cnt += 1
    num = max(num, cnt)
print("Yes" if 3 <= num else "No")

Buggy submission (verdict: Runtime Error):
N = input()
len = len(N)
cnt = 1
for i in range(0, len, 1):
    cnt = 1
    for j in range(i + 1, len, 1):
        if (N[i] != N[j]):
            break
        else:
            cnt += 1
    num = max(num, cnt)
print("Yes" if 3 <= num else "No")
Problem p03599 (python)

Fixed submission:
A, B, C, D, E, F = map(int, input().split())

ans = {}


def main():
    MAX_A = F // (100 * A)

    for i in range(MAX_A + 1):
        MAX_B = (F - i * 100 * A) // (100 * B)

        for j in range(MAX_B + 1):
            if i == 0 and j == 0:
                continue

            a = i * A + j * B

            SAT = a * E

            CD = F - a * 100

            SAT_FLG = True

            if CD < SAT:
                SAT_FLG = False

            CD = min(SAT, CD)

            MAX_C = CD // C

            for k in range(MAX_C + 1):
                l = (CD - k * C) // D

                b = k * C + l * D

                if SAT == b:
                    print(a * 100 + b, b)
                    return

                LACK = SAT - b
                if not LACK in ans:
                    # Create New
                    ans[LACK] = (a * 100 + b, b, SAT_FLG)
                elif not ans[LACK][-1]:
                    # SAT_FLG False
                    # Overwrite
                    ans[LACK] = (a * 100 + b, b, SAT_FLG)

    print(" ".join([str(i) for i in ans[min(ans.keys())][:-1]]))
    return


main()

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

ans = {}


def main():
    MAX_A = F // (100 * A)

    for i in range(MAX_A + 1):
        MAX_B = (F - i * 100 * A) // (100 * B)

        for j in range(MAX_B + 1):
            if i == 0 and j == 0:
                continue

            a = i * A + j * B

            SAT = a * E

            if F - a * 100 < SAT:
                continue

            MAX_C = SAT // C

            for k in range(MAX_C + 1):
                l = (SAT - k * C) // D

                b = k * C + l * D
                if (SAT == b):
                    print(a * 100 + b, b)
                    return

                LACK = SAT - b
                if not LACK in ans:
                    ans[LACK] = (a * 100 + b, b)

    print(" ".join([str(i) for i in ans[min(ans.keys())]]))
    return


main()

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


def main():
    sa = {100 * i * A + 100 * j * B
          for i in range(F) for j in range(F)
          if 100 * i * A + 100 * j * B <= F and i + j != 0}

    sb = {i * C + j * D for i in range(F) for j in range(F)
          if i * C + j * D <= F and i + j != 0}

    a = sorted(sa)
    b = sorted(sb)

    conc = 0.0

    for i in a:
        for j in b:
            if F < i + j:
                break
            if E * i / 100 < j:
                break

            if conc < j / (i + j) * 100:
                conc = j / (i + j) * 100
                water = i
                sugar = j

    print(water + sugar, sugar)
    return


main()
Problem p03680 (python)

Fixed submission:
N = int(input())

a = []

for i in range(N):
    a.append(int(input()) - 1)

done = [False] * N

i = 0

ans = 0

while True:
    if done[i] == False:
        done[i] = True
        ans += 1
        if a[i] == 1:
            break
        i = a[i]
    else:
        ans = -1
        break

print(ans)

Buggy submission (verdict: Runtime Error):
import sys

l = [int(i) for i in sys.stdin]

N = l[0]

a = l[1:]

done = [False] * N

i = 0

ans = 0

while True:
    if done[i] == False:
        done[i] = True
        ans += 1
        if a[i] == 1:
            break
        i = a[i]
    else:
        ans = -1
        break

print(ans)
Problem p03681 (python)

Fixed submission:
INF = int(1e9 + 7)
FCT = [0] * (int(1e5) + 1)


def modmulti(a, b):
    # aとbを掛けた値をmodする(a * b mod p)
    return a * b % INF


def factorial(x):
    FCT[0] = 1
    FCT[1] = 1
    for i in range(2, x + 1):
        FCT[i] = modmulti(FCT[i - 1], i)


def main():
    N, M = map(int, input().split())
    if N == M or N + 1 == M or N == M + 1:
        if N < M:
            factorial(M)
        else:
            factorial(N)
        print(modmulti(2, modmulti(FCT[N], FCT[M]))
              if N == M else modmulti(FCT[N], FCT[M]))
    else:
        print(0)

    return


main()

Buggy submission (verdict: Runtime Error):
from functools import reduce
INF = int(1e9 + 7)


def modmulti(a, b):
    # aとbを掛けた値をmodする(a * b mod p)
    return a * b % INF


def factorial(x):
    FCT = 1
    FCT = reduce(modmulti, range(2, x + 1))
    return FCT


def main():
    N, M = map(int, input().split())
    MIN_NM = factorial(min(N, M))
    if N == M or N + 1 == M or N == M + 1:
        print(modmulti(2, modmulti(MIN_NM, MIN_NM))
              if N == M else modmulti(MIN_NM, modmulti(MIN_NM, max(N, M))))
    else:
        print(0)

    return


main()
Problem p03845 (python)

Fixed submission:
N = int(input())
T = [int(i) for i in input().split()]
M = int(input())

PX = []

for i in range(M):
    # 0-indexed
    PX.append([int(j) for j in input().split()])
    PX[i][0] -= 1

ans = sum(T)

for i in range(M):
    print(ans - T[PX[i][0]] + PX[i][1])

Buggy submission (verdict: Runtime Error):
N = int(input())
T = [int(i) for i in input().split()]
M = int(input())

PX = []

for i in range(M):
    # 0-indexed
    PX.append([int(j) for j in input().split()])
    PX[i][0] -= 1

ans = sum(T)

for i in range(M):
    print(ans - T[PX[i][0]] + T[PX[i][1]])

Buggy submission (verdict: Runtime Error):
N = int(input())
T = [int(i) for i in input().split()]
M = int(input())

PX = []

for i in range(M):
    # 0-indexed
    PX.append([int(j) for j in input().split()])
    PX[i][0] -= 1

ans = sum(T)

for i in range(M):
    print(ans - T[PX[i][0]] + T[PX[i][1]])
Problem p02743 (python)

Fixed submission:
def main(a,b,c):
    if c-a-b < 0:
        return "No"
    else:
        if 4*a*b < (c-a-b)**2:
            return "Yes"
        else: return "No"

a,b,c = map(int, input().split())
print(main(a,b,c))

Buggy submission (verdict: Runtime Error):
import math
def main(a,b,c):
    temp = math.sqrt(a) + math.sqrt(b)
    return "Yes" if math.sqrt(c) > temp else "No"

a,b,c = map(int, input().split())
print(main2(a,b,c))
Problem p02801 (python)

Fixed submission:
C = input()

print(chr(ord(C)+1))

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

print(chr(ord(C)+1)
Problem p02802 (python)

Fixed submission:
def main(n,m,r):
    ac = [0]*n
    wa = [0]*n
    for i in range(len(r)):
        seq = int(r[i][0])
        judge = r[i][1]
        if ac[seq-1] == 1:
            continue
        if judge == "WA":
            wa[seq-1] += 1
        else:
            ac[seq-1] = 1
    for i in range(len(ac)):
        if ac[i] == 0:
            wa[i] = 0
    return "{0} {1}".format(sum(ac), sum(wa))

n,m = map(int, input().split())
r = list(input().split() for _ in range(m))
print(main(n,m,r))

Buggy submission (verdict: Runtime Error):
def main(n,m,r):
    ac = [0]*n
    wa = [0]*n
    for i in range(len(r)):
        if r[i][1] == "WA":
            if ac[int(r[i][0])] != 0:
                wa[int(r[i][0])] += 1
        elif r[i][1] == "AC":
            ac[int(r[i][0])] = 1
    acsum = sum(ac)
    wasum = sum(wa)
    return "{0} {1}".format(acsum, wasum)

n,m = map(int, input().split())
r = list(input().split() for _ in range(m))
print(main(n,m,r))
Problem p02952 (python)

Fixed submission:
N = str(input())
def main1(N):
    count = 0
    for i in range(1, len(N) + 1):
        if i % 2 != 0 :
            if i != len(N):
                count += 9 * 10**(i-1)
            else:
                if len(N) != 1:
                    count += ((int(N[0]) - 1) * 10**(i-1)
                        + int(N[1:len(N)]) + 1)
                else:
                    count += int(N[0])
    print(count)

main1(N)

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

count = 0
for i in range(1, len(N)):
    if i % 2 != 0:
        count += 9 * 10**(i-1)

hasuu = int(N[1:len(N)]) + 1 if (len(N) % 2 != 0) else 0

print(str(count+hasuu))
Problem p02957 (python)

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

I,m = divmod((A+B), 2)

if m != 0:
    res = msg
else:
    res = int((A+B)/2)

print(res)

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

I,m = divmod((A+B), 2)

if m != 0:
    res = msg
else:
    res = (A+B)/2

print(res)
Problem p02988 (python)

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

count = 0

for i in range(0, len(lst)-2):
    target = lst[i:i+3]
    minVal = min(target)
    maxVal = max(target)
    val = lst[i+1]
    if val != minVal and val != maxVal:
        count += 1

print(count)

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

count = 0
for i in range(1, len(lstp)-1):
    lst = list(lstp[i-1], lstp[i], lstp[i+1])
    if (min(lst) != lstp[i]) and (max(lst) != lstp[i]):
        count = count + 1

print(count)
Problem p02993 (python)

Fixed submission:
S = input()

flag = 0;

for i in range(1, 4):
    if S[i-1] == S[i] :
        flag = 1

res = "Good" if flag==0 else "Bad"

print(res)

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

flag = 0;

for i in range(1, 3):
    if S[i-1] = S[i] :
        flag = 1

res = "Good" if flag==0 else "Bad"

print(res)
Problem p02999 (python)

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

res = (int)(10 if X>=A else 0)

print(res)

Buggy submission (verdict: Runtime Error):
def calcBoundCount(rangex, lstL):
    d = 0
    for i in range(0, len(lstL)):
        d = d + lstL[i]
        if rangex < d:
            return i + 1
    return len(lstL) + 1

N, X = map(int, input().split())
lstL = list(map(int, input().split()))

count = calcBoundCount(X, lstL)
print((count if count <= N+1 else N+1))
Problem p03000 (python)

Fixed submission:
def calcBoundCount(rangex, lstL):
    d = 0
    for i in range(0, len(lstL)):
        d = d + lstL[i]
        if rangex < d:
            return i + 1
    return len(lstL) + 1
 
N, X = map(int, input().split())
lstL = list(map(int, input().split()))
 
count = calcBoundCount(X, lstL)
print((count if count <= N+1 else N+1))

Buggy submission (verdict: Runtime Error):
def calcBoundCount(rangex, lstL):
    d = 0
    for i in range(0, len(lstL)):
        d = d + lstL[i]
        if rangex < d:
            return i + 1

N, X = map(int, input().split())
lstL = list(map(int, input().split()))

count = calcBoundCount(X, lstL)
print((count if count <= N+1 else N+1))
Problem p03035 (python)

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

price = (int)(
    B   if A >= 13 else
    B/2 if A >= 6 else
    0)

print(price)

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

    price = (int)(
        B   if A >= 13 else
        B/2 if A >= 6 else
        0)

    print(price)

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

    price = (int)(
        B   if A >= 13 else
        B/2 if A >= 6 else
        0)

    return price 


if __name__ == '__main__'
    print(main())

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

    price = B if B >= 13 else B/2 if B >= 6 else 0

    return price 


if __name__ == '__main__'
    print(main())
Problem p03071 (python)

Fixed submission:
def main1(A, B):
    res = 0
    if A == B:
        res = A * 2
    else:
        res = (max(A,B) * 2) - 1
    print(res)

A, B = map(int, input().split())
main1(A, B)

#main1(5,3)#9
#main1(3,4)#7
#main1(6,6)#12

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

def main1(A, B):
    res = 0
    if B + 1 < A:
        res = (A * 2) - 1
    elif A == B :
        res = A + B
    else:
        res = (B * 2) - 1
    print(res)

main(A, B)
Problem p02681 (python)

Fixed submission:
X = input()
Y = input()
if X==Y[:-1]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a = [int(x) for x in input().split()]
count1=0
count0=0
count2=0
if a[3]>a[1]:
   count1=a[0]
if a[3]<=a[1]:
    count1=a[3]
if a[3]-a[1]-a[0]>0:
    count2=-(a[3]-a[1]-a[0])
print(count1+count2)
Problem p02700 (python)

Fixed submission:
N=[int(x) for x in input().split()]
if not N[2]%N[1]==0:
   c=N[2]//N[1]+1
else:
    c=N[2]//N[1]
if not N[0]%N[3]==0:
   d=N[0]//N[3]+1
else:
    d=N[0]//N[3]
if d>=c:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N=[int(x) for x in input().split()]
if not N[2]%N[1]==0:
   c=N[2]//N[1]+1
else:
    c=N[2]//N[1]
if not N[0]%N[3]==0:
   c=N[0]//N[3]+1

   d=N[0]//N[3]+1
else:
    d=N[0]//N[3]
if d=>c:
    print("Yes")
else:
    print("No")
Problem p02705 (python)

Fixed submission:
import math
N=int(input())
PI=math.pi
print(2.0*PI*N)

Buggy submission (verdict: Runtime Error):
n,  = map(int, input().split())
A = [int(x) for x in input().split()]
freq=[]
k=1
for k in range(n):
    freq.append(k+1)
count=0
for k in range(n):
    for j in range(n-1):
        if A[j]==freq[k]:
           count=count+1
    print(count)
    count=0

Buggy submission (verdict: Runtime Error):
N=[int(x) for x in input().split()]
A=[int(x) for x in input().split()]
sum=0
for a in range(N[1]):
    sum=sum+A[a]
if N[0]-sum)>=0:
   print(N[0]-sum)
else:
   print(-1)

Buggy submission (verdict: Runtime Error):
N=[int(x) for x in input().split()]
A=[int(x) for x in input().split()]
sum=0
for a in range(N[1]):
    sum=sum+A[a]
if sum>=0:
   print(N[0]-sum)
else:
   print(-1)

Buggy submission (verdict: Runtime Error):
import math
N=[int(x) for x in input().split()]
print(2*math.pi*r)
Problem p02772 (python)

Fixed submission:
N = input()
A = list(map(str, input().split()))
B=[]
C=[]
l=[]
m=[]
n=0
i=0
for a in range(int(N)):
    if int(A[a])%2==0:
       B.append(A[a])
       i=i+1
for a in range(int(i)):
    if int(B[a])%3==0 or int(B[a])%5==0:
       n=n+1
if n==i:
   print("APPROVED")
else:
   print("DENIED")

Buggy submission (verdict: Runtime Error):
N = input()
A = list(map(str, input().split()))
B=[]
l=[]
m=[]
i=0
for a in range(int(N)):
    if int(A[a])%2==0:
       B.append(A[a])
       i=i+1
for a in range(int(i)):
    if not int(B[a])%3==0 or int(B[a])%5==0:
       C.append(B[a])
    else:
       C=[0]
if C==0:
   print("DENIED")
else:
   print("APPROVED")