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

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

# n番目の要素でソートsort
BC = sorted(BC, reverse=True, key=lambda x: x[1])

m = A[0]
D = []
for b, c in BC:
    if c > m:
        _ = [D.append(c) for i in range(b)]
    else:
        continue
    if len(D) > N:
        break

D.append(0)

for i, d in enumerate(D):
    if i >= N:
        break
    if A[i] < d:
        A[i] = d
    else:
        break

print(sum(A))

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

# n番目の要素でソートsort
BC = sorted(BC, reverse=True, key=lambda x: x[1])

m = A[0]
D = []
p = 0
for b, c in BC:
    if c > m:
        _ = [D.append(c) for i in range(b)]
        p += 1
        if p > N:
            break
    else:
        continue

D.append(0)

for i, d in enumerate(D):
    if i > N:
        break
    if A[i] < d:
        A[i] = d
    else:
        break

print(sum(A))

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

# n番目の要素でソートsort
BC = sorted(BC, reverse=True, key=lambda x: x[1])

m = A[0]
D = []
for b, c in BC:
    if c > m:
        _ = [D.append(c) for i in range(b)]
    else:
        continue
    if len(D) > N:
        break

D.append(0)

for i, d in enumerate(D):
    if i > N:
        break
    if A[i] < d:
        A[i] = d
    else:
        break

print(sum(A))

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

# n番目の要素でソートsort
BC = sorted(BC, reverse=True, key=lambda x: x[1])

m = A[0]
D = []
for b, c in BC:
    if c > m:
        _ = [D.append(c) for i in range(b)]
    else:
        continue
    if len(D) > N:
        break

D.append(0)

for i, d in enumerate(D):
    if i > N:
        break
    if A[i] < d:
        A[i] = d
    else:
        break

print(sum(A))

Buggy submission (verdict: Runtime Error):
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]

A = [-a for a in A]

for b, c in BC:
    q = [-c for _ in range(b)]
    A = heapq.merge(A, q)

A = list(A)

p = [heapq.heappop(A) for _ in range(N)]
ans = [-i for i in p]
print(sum(ans))
Problem p03053 (python)

Fixed submission:
def main():
    H, W = map(int, input().split())
    field = [list(input()) for _ in range(H)]
    dd = ((1, 0), (-1, 0), (0, 1), (0, -1))

    q = []
    for i in range(H):
        for j in range(W):
            if field[i][j] == "#":
                q.append((i, j))
                field[i][j] = 0
    moves = 0

    while q:
        qn = []
        moves += 1
        for x, y in q:
            for dx, dy in dd:
                nx, ny = int(x + dx), int(y + dy)
                if 0 <= nx < H and 0 <= ny < W:
                    if field[nx][ny] == ".":
                        field[nx][ny] = moves
                        qn.append((nx, ny))

        q = qn

    m = []
    for i in range(H):
        m.append(max(field[i]))
    print(max(m))


main()

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np

# 黒: #
# 白: .

H, W = input().split()

H = int(H)
W = int(W)

A = np.zeros([H,W])

for i in range(H):
    chars = np.array(list(input()))
    A[i,:] = np.where(chars=='.', 0, 1)

cnt = 0
w_num = np.sum(A == 0)

while w_num != 0:
    cnt += 1
    B = np.zeros([H+2,W+2])
    B[1:H+1,1:W+1] = A
#    for i in range(1,W+1):
#        for j in range(1,H+1):
#            B[i+1,j+1] = B[i+1,j+1] + B[i,j+1] + B[i+2,j+1] \
        #                            + B[i+1,j] + B[i+1,j+2]
#   for i in range(1,W+1)
#       for j in range(1,H+1)
#           B[i,j] = B[i,j] + B[i+1,j] + B[i-1,j]
#                           + B[i,j+1] + B[i,j-1]

    B[1:W+1,1:H+1] = B[1:W+1,1:H+1] + B[2:W+2,1:H+1] + B[0:W,1:H+1] \
                                    + B[1:W+1,2:H+2] + B[1:W+1,0:H]

    B = np.where(B == 0, 0, 1)
    A = B[1:H+1,1:W+1]
    w_num = np.sum(A== 0)
#    print(B)

print(cnt)

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np

# 黒: #
# 白: .

H, W = input().split()

H = int(H)
W = int(W)

A = np.zeros([H,W])

for i in range(H):
    chars = np.array(list(input()))
    A[i,:] = np.where(chars=='.', 0, 1)

cnt = 0
w_num = np.sum(A == 0)

while w_num != 0:
    cnt += 1
    B = np.zeros([H+2,W+2])
    B[1:H+1,1:W+1] = A

    C = np.zeros([H,W])
    for i in range(W):
        for j in range(H):
            C[i,j] = B[i+1,j+1] + B[i,j+1] + B[i+2,j+1] \
                            + B[i+1,j] + B[i+1,j+2]

    w_num = np.sum(C == 0)
    A = C
    print(A)

print(cnt)

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np

# 黒: #
# 白: .

H, W = input().split()

H = int(H)
W = int(W)

A = np.zeros([H,W])

for i in range(H):
    chars = np.array(list(input()))
    A[i,:] = np.where(chars=='.', 0, 1)

cnt = 0
w_num = np.sum(A == 0)

while w_num != 0:
    cnt += 1
    B = np.zeros([H,W])
    for i in range(W):
        for j in range(H):
            if A[i,j] == 1:
                B[i,j] = 1
                if i-1 >= 0:
                    B[i-1,j] = 1
                if i+1 < W:
                    B[i+1,j] = 1
                if j-1 >= 0:
                    B[i,j-1] = 1
                if j+1 < H:
                    B[i,j+1] = 1

    w_num = np.sum(B == 0)
    A = B

print(cnt)
Problem p03127 (python)

Fixed submission:
def vs(A):
    A = sorted(A)
    pA = list(map(lambda x: x % A[0], A))
    pA[0] = A[0]
    return list(filter(lambda x: x != 0, pA))


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


spA = -1
sA = -2
while spA != sA:
    sA = sum(A)
    pA = vs(A)
    spA = sum(pA)
    A = pA

print(sum(A))

Buggy submission (verdict: Runtime Error):
import sys

readline = sys.stdin.buffer.readline


def sss(A, N):
    A.sort()
    if A[0] == 0:
        A.remove(0)
    for i in range(1, len(A)):
        A[i] = A[i] % A[0]
    if A[0] == sum(A):
        print(sum(A))
    else:
        return sss(A, N)


def main():
    N = int(readline())
    A = list(map(int, readline().split()))

    sss(A, N)


main()
Problem p03242 (python)

Fixed submission:
i = input()

k = []

for j in i:
    if j == '1':
        k.append('9')
    else:
        k.append('1')

print(''.join(k))

Buggy submission (verdict: Runtime Error):
import sys

from collections import Counter

n = int(input())

v = []
v1 = []
v2 = []

v = list(map(int, input().split()))

for i in range(int(n/2)):
    v1.append(v[2*i])
    v2.append(v[2*i+1])

e = Counter(v1)
o = Counter(v2)

ee = e.most_common(2)
oo = o.most_common(2)

if ee[0][0] != oo[0][0]:
    print(n - (ee[0][1]+oo[0][1]))
    sys.exit()

if ee[0][0] == oo[0][0]:
    if len(ee) == 1 and len(oo) == 1:
        print(n - (ee[0][1]))
        sys.exit()

    if len(ee) == 1:
        print(n - (ee[0][1]+oo[1][1]))
        sys.exit()

    if len(oo) == 1:
        print(n - (ee[1][1]+oo[0][1]))
        sys.exit()

    if ee[0][1] == oo[0][1]:
        print(n - (ee[0][1] + min(ee[1][1],oo[1][1])))
    
    if ee[0][1] > oo[0][1]:
        print(n - (ee[0][1]+oo[1][1]))
        sys.exit()
    else:
        print(n - (ee[1][1]+oo[0][1]))
        sys.exit()
Problem p03426 (python)

Fixed submission:
from collections import defaultdict

H, W, D = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(H)]
Q = int(input())
LR = [list(map(int, input().split())) for _ in range(Q)]

# 1 -> 1+D ->
# 2 -> 2+D ->
# 3 -> 3+D -> みたいなものを事前に計算

# 辞書で管理する
# d[A[i][j]] = [i,j] みたいな感じ
d = defaultdict(list)
for i in range(H):
    for j in range(W):
        d[A[i][j]].append([i, j])


p = []
for s in range(1, D + 1):
    c = 0
    q = [0]
    for i in range(s + D, H * W + 1, D):
        i0, j0 = d[i - D][0]
        i1, j1 = d[i][0]
        c += abs(i0 - i1) + abs(j0 - j1)
        q.append(c)

    p.append(q)


for l, r in LR:
    i = l % D - 1
    s = (l - 1) // D
    e = (r - 1) // D
    print(p[i][e] - p[i][s])

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

H, W, D = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(H)]
Q = int(input())
LR = [list(map(int, input().split())) for _ in range(Q)]

# 1 -> 1+D ->
# 2 -> 2+D ->
# 3 -> 3+D -> みたいなものを事前に計算

# 辞書で管理する
# d[A[i][j]] = [i,j] みたいな感じ
d = defaultdict(list)
for i in range(H):
    for j in range(W):
        d[A[i][j]].append([i, j])


p = []
for s in range(1, D + 1):
    c = 0
    q = [0]
    for i in range(s + D, H * W + 1, D):
        i0, j0 = d[i - D][0]
        i1, j1 = d[i][0]
        c += abs(i0 - i1) + abs(j0 - j1)
        q.append(c)

    p.append(q)


for l, r in LR:
    i = l % D - 1
    s = (l + i) // D
    e = (r + i) // D
    print(p[i][e] - p[i][s])

Buggy submission (verdict: Runtime Error):
H, W, D = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(H)]
Q = int(input())
LR = [list(map(int, input().split())) for _ in range(Q)]

# 1 -> 1+D ->
# 2 -> 2+D ->
# 3 -> 3+D -> みたいなものを事前に計算

P = []
for k in range(1, D + 1):
    q = []
    for d in range(k, H * W + 1, D):
        for i in range(H):
            try:
                n = A[i].index(d)
                q.append([i, n])
                break
            except:
                continue
    P.append(q)

d = []

for p in P:
    c = 0
    q = [0]
    for i in range(len(p) - 1):
        c += abs(p[i][0] - p[i + 1][0])
        c += abs(p[i][1] - p[i + 1][1])
        q.append(c)
    d.append(q)

for l, r in LR:
    i = l % D - 1
    s = (l + i) // D
    e = (r + i) // D
    print(d[i][e] - d[i][s])
Problem p03634 (python)

Fixed submission:
import networkx as nx

N = int(input())
ABC = [list(map(int, input().split())) for _ in range(N - 1)]
Q, K = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(Q)]

G = nx.Graph()

for a, b, c in ABC:
    G.add_edge(a - 1, b - 1, weight=c)

pred, dist = nx.dijkstra_predecessor_and_distance(G, K - 1)

for x, y in XY:
    print(dist[x - 1] + dist[y - 1])

Buggy submission (verdict: Runtime Error):
import networkx as nx

N = int(input())
ABC = [list(map(int, input().split())) for _ in range(N - 1)]
Q, K = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(Q)]

G = nx.Graph()

for a, b, c in ABC:
    G.add_edge(a - 1, b - 1, weight=c)

pred, dist = nx.dijkstra_predecessor_and_distance(G, K - 1)

for x, y in XY:
    print(dist[x - 1] + dist[y - 1])
Problem p03835 (python)

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

cnt = 0
for i in range(K+1):
    for j in range(K+1):
        if 0 <= S - i - j <= K:
            cnt += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
import itertools

K, S = map(int, input().split())

cnt = 0

K = list(range(K + 1))

for i, j in itertools.product(K, repeat=2):
    if 0 <= S - i - j <= K:
        cnt += 1

print(cnt)
Problem p02598 (python)

Fixed submission:
from math import ceil

N,K,*A = map(int, open(0).read().split())
left = 1
right = max(A)
while left != right:
    mid = (left+right) // 2
    temp = 0
    for x in A:
        temp += ceil(x/mid) - 1
        if temp > K:
            left = mid + 1
            break
    else:
        right = mid
for i in range(max(1,left-1),left+2):
    temp = 0
    for x in A:
        temp += ceil(x/i) - 1
        if temp > K:
            break
    else:
        print(i)
        break

Buggy submission (verdict: Runtime Error):
from math import ceil

N,K,*A = map(int, open(0).read().split())
left = 1
right = max(A)
while left != right:
    mid = (left+right) // 2
    temp = 0
    for x in A:
        temp += ceil(x/mid) - 1
        if temp > K:
            left = mid + 1
            break
    else:
        right = mid
for i in range(left-1,left+2):
    temp = 0
    for x in A:
        temp += ceil(x/i) - 1
        if temp > K:
            break
    else:
        print(i)
        break
Problem p02726 (python)

Fixed submission:
import numpy as np
import scipy.sparse
N,X,Y = (int(x) for x in input().split())
lil = scipy.sparse.lil_matrix((N, N), dtype = int)
for i in range(N-1):
    lil[i, i+1] = 1
    lil[i+1, i] = 1
lil[X-1, Y-1] = 1
lil[Y-1, X-1] = 1
lil2 = scipy.sparse.csgraph.dijkstra(lil, directed = False).astype(int)
ans = np.bincount(lil2.ravel(), minlength = N) // 2
for i in range(1,N):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
import numpy as np
import scipy.sparse
N,X,Y = (int(x) for x in input().split())
lil = scipy.sparse.lil_matrix((N, N), dtype=int)
for i in range(N-1):
    lil[i, i+1] = 1
    lil[i+1, i] = 1
lil[X-1, Y-1] = 1
lil[Y-1, X-1] = 1
lil2 = scipy.sparse.csgraph.shortest_path(lil)
for i in range(1,N):
    print((np.count_nonzero(lil2 == i)) // 2)

Buggy submission (verdict: Runtime Error):
import numpy as np
import scipy.sparse
N,X,Y = (int(x) for x in input().split())
lil = scipy.sparse.lil_matrix((N, N), dtype=int)
for i in range(N-1):
    lil[i, i+1] = 1
    lil[i+1, i] = 1
lil[X, Y] = 1
lil[Y, X] = 1
shortest = scipy.sparse.csgraph.floyd_warshall(lil)
for i in range(N-1):
    print(np.count_nonzero(shortest == i))
Problem p02729 (python)

Fixed submission:
from scipy.misc import comb
N,M = (int(x) for x in input().split())
a = comb(N, 2, exact=True) + comb(M, 2, exact=True)
print(a)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
N,M = (int(x) for x in input().split())
a = int(comb(N, 2)) + int(comb(M, 2))
print(a)

Buggy submission (verdict: Runtime Error):
import math
N,M = (int(x) for x in input().split())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
a = combinations_count(N, 2) + combinations_count(M, 2)
print(a)
Problem p02753 (python)

Fixed submission:
S = input()
if S[0] == S[1] == S[2]:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
a,b,c = (str(x) for x in input().split())
if a == b == c:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
a,b,c = (str(x) for x in input().split())
if a == b == c:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
a,b,c = (str(x) for x in input().split())
if a == b == c:
    print(No)
else:
    print(Yes)

Buggy submission (verdict: Runtime Error):
a,b,c = (str(x) for x in input().split())
if a == b == c
    print(No)
    else
        print(Yes)
Problem p02762 (python)

Fixed submission:
from collections import deque
N,M,K = (int(x) for x in input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
CD = [list(map(int, input().split())) for _ in range(K)]
friends = [set() for _ in range(N)]
blocks = [set() for _ in range(N)]
searched = [0] * N
ans = [0] * N
d = deque()
for x, y in AB:
    friends[x-1].add(y-1)
    friends[y-1].add(x-1)
for x, y in CD:
    blocks[x-1].add(y-1)
    blocks[y-1].add(x-1)
for i in range(N):
    if searched[i]:
        continue
    trace = set()
    d.append(i)
    trace.add(i)
    searched[i] = 1
    while d:
        temp = d.popleft()
        for x in friends[temp]:
            if searched[x] == 0:
                d.append(x)
                trace.add(x)
                searched[x] = 1
    chain = len(trace)
    for j in trace:
        ans[j] = chain - 1 - len(trace&friends[j]) - len(trace&blocks[j])
print(*ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
import scipy.sparse
from itertools import combinations
N,M,K = (int(x) for x in input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
CD = [list(map(int, input().split())) for _ in range(K)]
lil = scipy.sparse.lil_matrix((N, N), dtype = int)
for i in range(M):
    lil[AB[i][0]-1, AB[i][1]-1] = 1
    lil[AB[i][1]-1, AB[i][0]-1] = 1
lil2 = scipy.sparse.csgraph.dijkstra(lil, directed = False).astype(int)
block = np.zeros((N, N))
for i in range(K):
    block[CD[i][0]-1, CD[i][1]-1] = -100000
    block[CD[i][1]-1, CD[i][0]-1] = -100000
sug = lil2 + block
ans = [np.count_nonzero(sug[i] > 1) for i in range(N)]
print(*ans)
Problem p02769 (python)

Fixed submission:
def memfact(a,m):
    temp = 1
    yield temp
    for i in range(1,a+1):
        temp = temp * i % m
        yield temp
def comb(n,r,m):
    if r == 0: return 1
    return memf[n]*pow(memf[r],m-2,m)*pow(memf[n-r],m-2,m)

n,k = map(int, open(0).read().split())
dp = [0] * n
dp[0] = 1
m = 1000000007
dp[1] = (n * (n-1)) % m
memf = []
mfappend = memf.append
for x in memfact(n,m):
    mfappend(x)
for i in range(2,min(k+1,n)):
    dp[i] = (dp[i-1]+comb(n,i,m)*comb(n-1,i,m)) % m
print((dp[min(n-1,k)]+1)%m)

Buggy submission (verdict: Runtime Error):
def memfact(a,m):
    temp = 1
    yield temp
    for i in range(1,a+1):
        temp = temp * i % m
        yield temp
def comb(n,r,m):
    if r == 0: return 1
    return memf[n]*pow(memf[r],m-2,m)*pow(memf[n-r],m-2,m)

n,k = map(int, open(0).read().split())
dp = [0] * n
dp[0] = 1
dp[1] = (n * (n-1)) % m
m = 1000000007
memf = []
mfappend = memf.append
for x in memfact(n,m):
    mfappend(x)
for i in range(2,min(k+1,n)):
    dp[i] = (dp[i-1]+comb(n,i,m)*comb(n-1,i,m)) % m
print((dp[min(n-1,k)]+1)%m)
Problem p02793 (python)

Fixed submission:
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    g = gcd(A[0],A[1])
    lcm = (A[0]*A[1]) // g
    for x in A[2:]:
        lcm = (lcm * x) // gcd(lcm,x)
    print(sum((lcm//x) for x in A)%1000000007)

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

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    b = Counter(a)
    return b

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    fac = prime_factorize(A[0]) | prime_factorize(A[1])
    for x in A[2:]:
        fac |= prime_factorize(x)
    ans = 0
    f = [pow(x[0],x[1],100000007) for x in fac.items()]
    lcm = reduce(mul,f)
    for x in A:
        ans = (ans + (lcm // x)) % 1000000007
    print(ans)

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

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    b = Counter(a)
    return b

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    fac = prime_factorize(A[0]) | prime_factorize(A[1])
    for x in A[2:]:
        fac |= prime_factorize(A[i])
    ans = 0
    f = [pow(x[0],x[1],100000007) for x in fac.items()]
    lcm = reduce(mul,f)
    for x in A:
        ans = (ans + (lcm // x)) % 1000000007
    print(ans)
Problem p02832 (python)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
count = 1
brick = 0
for i in range(N):
    if a[i] != count:
        brick += 1
    else:
        count += 1
if brick == N:
    print(-1)
else:
    print(brick)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
count = 0
if 1 not in a:
    print(-1)
else:
    count += a.index(1)
    prev_index = a.index(1)
    for i in range(prev_index):
        a[i] = 0
for i in range(2,N+2):
    if i not in a:
        count += N - (prev_index + 1)
        print(count)
        break
    else:
        count += a.index(i) - prev_index -1
        two_ago_index = prev_index
        prev_index = a.index(i)
        for j in range(two_ago_index,prev_index+1):
            a[j] = 0

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
count = 0
if 1 not in a:
    print(-1)
else:
    count += a.index(1)
    prev_index = a.index(1)
    for i in range(prev_index):
        a[i] = 0
for i in range(2,N+2):
    if i not in a:
        count += N - (prev_index + 1)
        break
        print(count)
    else:
        count += a.index(i) - prev_index -1
        two_ago_index = prev_index
        prev_index = a.index(i)
        for j in range(two_ago_index,prev_index+1):
            a[j] = 0

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
count = 0
if 1 not in a:
    print(-1)
else:
    count += a.index(1)
    prev_index = a.index(1)
    for i in range(prev_index):
        a[i] = 0
for i in range(2,N+2):
    if i not in a:
        count += N - (prev_index + 1)
        break
    else:
        count += a.index(i) - prev_index -1
        two_ago_index = prev_index
        prev_index = a.index(i)
        for j in range(two_ago_index,prev_index+1):
            a[j] = 0
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
count = 0
if 1 not in a:
    print(-1)
else:
    count += a.index(1)
    prev_index = a.index(1)
    for i in range(prev_index):
        a[i] = 0
for i in range(2,N+2):
    if i not in a:
        count += N - prev_index - 1
        break
    else:
        count += a.index(i) - prev_index -1
        prev_index = a.index(i)
        for j in range(prev_index):
            a[j] = 0
print(count)
Problem p02863 (python)

Fixed submission:
N,T,*ABf = map(int, open(0).read().split())
AB = [ABf[i:i+2] for i in range(0, len(ABf), 2)]
AB.sort()
dp = [[0] * 2 for _ in range(6000)]
filled = set([0])
for x in AB:
    temp = set()
    change = []
    for y in filled:
        if y + x[0] <= (T-1) + max(dp[y][1],x[0]):
            if dp[y+x[0]][0] <= dp[y][0] + x[1]:
                change.append((y,y+x[0],dp[y][0]+x[1],x[0]))
    for y in change:
        if dp[y[1]][0] == y[2]:
            dp[y[1]][1] = y[3]
        else:    
            dp[y[1]][0] = y[2]
            dp[y[1]][1] = y[3]
            temp.add(y[0]+x[0])
    filled = filled | temp
print(max(dp)[0])

Buggy submission (verdict: Runtime Error):
import numpy as np

N,T,*ABf = map(int, open(0).read().split())
AB = np.array(ABf).reshape(N,2).tolist()
dp = [[0] * 2 for _ in range(6000)]
filled = set([0])
for x in AB:
    temp = set()
    change = []
    for y in filled:
        if y + x[0] <= (T-1) + max(dp[y][1],x[0]):
            if dp[y+x[0]][0] < dp[y][0]+x[1]:
                change.append((y,y+x[0],dp[y][0]+x[1],x[0]))
                temp.add(y+x[0])
    for y in change:
        dp[y[1]][0] = y[2]
        dp[y[1]][1] = max(dp[y[0]][1],y[3])
    filled = filled | temp
print(max(dp)[0])
Problem p02912 (python)

Fixed submission:
import heapq
from numpy import ceil,sum
N,M = (int(x) for x in input().split())
A = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(A)
for i in range(M):
    t1 = heapq.heappop(A)
    t2 = t1 / 2
    heapq.heappush(A, t2)
B = ceil(A)
print(int(sum(B)*(-1)))

Buggy submission (verdict: Runtime Error):
import heapq
from numpy import sum
N,M = (int(x) for x in input().split())
A = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(A)
for i in range(M):
    t1 = heapq.heappop(A)
    t2 = t1 // 2
    heapq.heappush(A, t2)
print(int(sum(B)*(-1)))