Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]

    def root(self, x):
        if self.par[x] == x:
            return x
        r = self.root(self.par[x])
        self.par[x] = r
        return r

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry:
            return
        self.par[x] = ry
        self.par[rx] = ry

def main():
    N, M, *AB = map(int, open(0).read().split())
    uf = UnionFind(N)
    elems = [1] * (N + 1)
    ans = N * (N - 1) // 2
    ANS = [0]*M
    for i in range(M):
        # print(ans)
        ANS[M - i - 1] = ans
        a = AB[2 * M - i * 2 - 2 + 0]
        b = AB[2 * M - i * 2 - 2 + 1]
        ra = uf.root(a)
        rb = uf.root(b)
        uf.unite(ra, rb)
        r = uf.root(ra)
        if ra != rb:
            era = elems[ra]
            erb = elems[rb]
            ans -= era * erb
            elems[r] = era + erb
    for ans in ANS:
        print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0]*(n + 1)

    def root(self, x):
        if self.par[x] == x:
            return x
        r = self.root(self.par[x])
        self.par[x] = r
        return r

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry:
            return
        if self.rank[rx] < self.rank[ry]:
            self.par[x] = ry
            self.par[rx] = ry
        else:
            self.par[y] = rx
            self.par[ry] = rx
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

def main():
    N, M, *AB = map(int, open(0).read().split())
    uf = UnionFind(N)
    elems = [1] * (N + 1)
    ans = N * (N - 1) // 2
    ANS = [0]*M
    for i in range(M):
        # print(ans)
        ANS[M - i - 1] = ans
        a = AB[2 * M - i * 2 - 2 + 0]
        b = AB[2 * M - i * 2 - 2 + 1]
        ra = uf.root(a)
        rb = uf.root(b)
        uf.unite(ra, rb)
        r = uf.root(ra)
        if ra != rb:
            era = elems[ra]
            erb = elems[rb]
            ans -= era * erb
            elems[r] = era + erb
    for ans in ANS:
        print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
N, M = map(int, input().split())
S = input()
T = input()

def lcm(N, M):
    return N * M // gcd(N, M)

L = lcm(N, M)
n = L // N
m = L // M

# print(N, M, L, n, m, S, T)

ans = True
for i in range(L):
    if i % n == 0 and i % m == 0:
        s = S[i // n]
        t = T[i // m]
        if s != t:
            ans = False
            break

if ans:
    print(L)
else:
    print(-1)


Fixed submission:
from fractions import gcd
N, M = map(int, input().split())
S = input()
T = input()

def lcm(N, M):
    return N * M // gcd(N, M)

L = lcm(N, M)
n = L // N
m = L // M
C = n * m

# print(N, M, L, n, m, S, T)

ans = True
for i in range(0, L, C):
    s = S[i // n]
    t = T[i // m]
    if s != t:
        ans = False
        break

if ans:
    print(L)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
def main():
    N, K = map(int, input().split())
    X = list(map(int, input().split()))
    D = [0]*(N - 1)
    for i in range(1, N):
        D[i-1] = X[i] - X[i - 1]
    ans = 0
    t = 0
    T = [0]*(N - K + 1)
    for i in range(1, N):
        t += D[i-1]
        if i < K:
            if i == K - 1:
                T[0] = t
            continue
        t -= D[i - K]
        T[i - K + 1] = t
    # print(D, T)
    ans = K * 10**8
    for i in range(N - K + 1):
        a = T[i] + min(abs(X[i]), abs(X[i + K - 1])]
        ans = min(a, ans)
    print(ans)

if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N, K = map(int, input().split())
    X = list(map(int, input().split()))
    D = [0]*(N - 1)
    for i in range(1, N):
        D[i-1] = X[i] - X[i - 1]
    ans = 0
    t = 0
    T = [0]*(N - K + 1)
    for i in range(1, N):
        t += D[i-1]
        if i < K:
            if i == K - 1:
                T[0] = t
            continue
        t -= D[i - K]
        T[i - K + 1] = t
    # print(D, T)
    ans = K * 10**8
    for i in range(N - K + 1):
        a = T[i] + min(abs(X[i]), abs(X[i + K - 1]))
        ans = min(a, ans)
    print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    N, K = map(int, input().split())
    X = list(map(int, input().split()))
    D = [0]*(N - 1)
    for i in range(1, N):
        D[i-1] = X[i] - X[i - 1]
    ans = 0
    t = 0
    T = [0]*(N - K + 1)
    for i in range(1, N):
        t += D[i-1]
        if i < K:
            if i == K - 1:
                T[0] = t
            continue
        t -= D[i - K]
        T[i - K + 1] = t
    # print(D, T)
    ans = K * 10**8
    for i in range(N - K + 1):
        a = T[i] + min(abs(X[i]), abs[X[i + K - 1])]
        ans = min(a, ans)
    print(ans)

if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N, K = map(int, input().split())
    X = list(map(int, input().split()))
    D = [0]*(N - 1)
    for i in range(1, N):
        D[i-1] = X[i] - X[i - 1]
    ans = 0
    t = 0
    T = [0]*(N - K + 1)
    for i in range(1, N):
        t += D[i-1]
        if i < K:
            if i == K - 1:
                T[0] = t
            continue
        t -= D[i - K]
        T[i - K + 1] = t
    # print(D, T)
    ans = K * 10**8
    for i in range(N - K + 1):
        a = T[i] + min(abs(X[i]), abs(X[i + K - 1]))
        ans = min(a, ans)
    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
S,K,c=input(),int(input()),0
while c<K and S[c]=='1':c+=1
print(S[c])


Fixed submission:
S = input()
K = int(input())
# print(S, K)
for i in range(len(S)):
    s = S[i]
    if i >= K:
        break
    if s != '1':
        print(s)
        exit()
print('1')

Buggy python submission (verdict: Runtime Error):
S=input()
K=int(input())
c=0
a='1'
while c<K and S[c]=='1':
 c+=1
print(S[c])


Fixed submission:
S = input()
K = int(input())
# print(S, K)
for i in range(len(S)):
    s = S[i]
    if i >= K:
        break
    if s != '1':
        print(s)
        exit()
print('1')

Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())
# print(S, K)
for i in range(len(S)):
    if i >= K:
        break
    if s != '1':
        print(s)
        exit()
print('1')


Fixed submission:
S = input()
K = int(input())
# print(S, K)
for i in range(len(S)):
    s = S[i]
    if i >= K:
        break
    if s != '1':
        print(s)
        exit()
print('1')
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, M, Q, *X = map(int, open(0).read().split())
    L = [0]*M
    R = [0]*M
    p = [0]*Q
    q = [0]*Q
    for i in range(M):
        L[i], R[i] = X[2*i], X[2*i + 1]
    for i in range(Q):
        p[i], q[i] = X[2*M + 2*i], X[2*M + 2*i + 1]
    # print(N, M, Q, L, R, p, q)
    S = [[0]*(N+1) for i in range(N+1)]
    for i in range(M):
        S[L[i]][R[i]] += 1
    # for s in S:
    #     print(s)
    S2 = [[0]*(N+1) for i in range(N+1)]
    for i in range(N+1):
        S2[i][0] = S[i][0]
        for j in range(1, N+1):
            S2[i][j] = S2[i][j-1] + S[i][j]
    # for s in S2:
    #     print(s)
    for i in range(Q):
        pi, qi = p[i], q[i]
        ans = 0
        for j in range(pi, qi + 1):
            ans += (S2[j][qi] - S2[j][pi-1])
        print(ans)

if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N, M, Q, *X = map(int, open(0).read().split())
    L = [0]*M
    R = [0]*M
    p = [0]*Q
    q = [0]*Q
    for i in range(M):
        L[i], R[i] = X[2*i], X[2*i + 1]
    for i in range(Q):
        p[i], q[i] = X[2*M + 2*i], X[2*M + 2*i + 1]
    # print(N, M, Q, L, R, p, q)
    S = [[0]*(N+1) for i in range(N+1)]
    for i in range(M):
        S[L[i]][R[i]] += 1
    # for s in S:
    #     print(s)
    S2 = [[0]*(N+1) for i in range(N+1)]
    for i in range(N+1):
        S2[i][0] = S[i][0]
        for j in range(1, N+1):
            S2[i][j] = S2[i][j-1] + S[i][j]
    # for s in S2:
    #     print(s)
    for i in range(Q):
        pi, qi = p[i], q[i]
        ans = 0
        for j in range(pi, qi + 1):
            ans += (S2[j][qi] - S2[j][pi-1])
        print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    S = [0]*N
    s = 0
    for i in range(N):
        a = A[i]
        s += a
        S[i] = s

    # print(S)
    ans = 0
    if S[0] == 0:
        ans += 1
    for i in range(1, N):
        if S[i] == 0:
            ans += 1
        for j in range(i):
            d = S[i] - S[j]
            if d == 0:
                ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Fixed submission:
def cmb(n, r):
    ans1 = 1
    for i in range(n - r + 1, n + 1):
        ans1 *= i
    ans2 = 1
    for i in range(1, r + 1):
        ans2 *= i
    return ans1 // ans2

def main():
    N = int(input())
    A = list(map(int, input().split()))
    S = [0]*N
    s = 0
    for i in range(N):
        a = A[i]
        s += a
        S[i] = s

    # print(S)
    ans = 0
    B = {}
    for s in S:
        if s not in B:
            B[s] = 0
        B[s] += 1
    # print(B)
    for b in B:
        if b == 0:
            ans += B[b]
        if B[b] > 1:
            ans += cmb(B[b], 2)
    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
l = input().split()
N = int(l[0])
Y = int(l[1])

k10 = 0
k5 = 0
k1 = 0

max_k10 = min(N, Y // 10000)
for i in reversed(range(max_k10 + 1)):
    remain10 = Y - i * 10000
    if remain10 == 0 and i == N:
        print(i, 0, 0)
        exit()
    max_k5 = min(N, remain10 // 5000)
    for j in reversed(range(max_k5 + 1)):
        remain5 = remain10 - j * 5000
        if remain5 == 0 and i + j == N:
            print(i, j, 0)
            exit()
        max_k1 = min(N, remain5 // 1000)
        for k in reversed(range(max_k1 + 1)):
            remain1 = remain5 - k * 1000
            if remain1 == 0 and i + j + k == N:
                print(i, j, k)
                exit()

print(-1, -1, -1)


Fixed submission:
l = input().split()
N = int(l[0])
Y = int(l[1])

k10 = 0
k5 = 0
k1 = 0

max_k10 = min(N, Y // 10000)
for i in reversed(range(max_k10 + 1)):
    remain10 = Y - i * 10000
    if remain10 == 0 and i == N:
        print(i, 0, 0)
        exit()
    max_k5 = min(N, remain10 // 5000)
    for j in reversed(range(max_k5 + 1)):
        remain5 = remain10 - j * 5000
        if remain5 == 0 and i + j == N:
            print(i, j, 0)
            exit()
        z = N - i - j
        if remain5 - z * 1000 == 0:
            print(i, j, z)
            exit()

print(-1, -1, -1)

Buggy python submission (verdict: Time Limit Exceeded):
l = input().split()
N = int(l[0])
Y = int(l[1])

k10 = 0
k5 = 0
k1 = 0

max_k10 = Y // 10000
for i in reversed(range(max_k10 + 1)):
    remain10 = Y - i * 10000
    if remain10 == 0 and i == N:
        print(i, 0, 0)
        exit()
    max_k5 = remain10 // 5000
    for j in reversed(range(max_k5 + 1)):
        remain5 = remain10 - j * 5000
        if remain5 == 0 and i + j == N:
            print(i, j, 0)
            exit()
        max_k1 = remain5 // 1000
        for k in reversed(range(max_k1 + 1)):
            remain1 = remain5 - k * 1000
            if remain1 == 0 and i + j + k == N:
                print(i, j, k)
                exit()

print(-1, -1, -1)


Fixed submission:
l = input().split()
N = int(l[0])
Y = int(l[1])

k10 = 0
k5 = 0
k1 = 0

max_k10 = min(N, Y // 10000)
for i in reversed(range(max_k10 + 1)):
    remain10 = Y - i * 10000
    if remain10 == 0 and i == N:
        print(i, 0, 0)
        exit()
    max_k5 = min(N, remain10 // 5000)
    for j in reversed(range(max_k5 + 1)):
        remain5 = remain10 - j * 5000
        if remain5 == 0 and i + j == N:
            print(i, j, 0)
            exit()
        z = N - i - j
        if remain5 - z * 1000 == 0:
            print(i, j, z)
            exit()

print(-1, -1, -1)
Buggy python submission (verdict: Time Limit Exceeded):
import math

Q = int(input())
L = [0]*Q
R = [0]*Q
for i in range(Q):
    L[i], R[i] = map(int, input().split())

# print(Q, L, R)

def gen_primes():
    max_lr = 10**5
    primes = [2]
    for i in range(3, max_lr, 2):
        is_prime = True
        limit = int(math.sqrt(i)) + 1
        for p in primes:
            if p > limit:
                break
            if i % p == 0:
                is_prime = False
                break
        if is_prime:
            primes.append(i)
    # print(len(primes))
    return primes

primes = gen_primes()

def is_2017_like(n):
    m = (n + 1) // 2
    return n in primes and m in primes

for i in range(Q):
    ans = 0
    for j in range(L[i], R[i] + 1, 2):
       if is_2017_like(j):
           ans += 1
    print(ans)


Fixed submission:
import math

Q = int(input())
L = [0]*Q
R = [0]*Q
for i in range(Q):
    L[i], R[i] = map(int, input().split())

# print(Q, L, R)

max_lr = 10**5

def gen_primes():
    primes = [2]
    for i in range(3, max_lr, 2):
        is_prime = True
        limit = int(math.sqrt(i)) + 1
        for p in primes:
            if p > limit:
                break
            if i % p == 0:
                is_prime = False
                break
        if is_prime:
            primes.append(i)
    # print(len(primes))
    return primes

primes = gen_primes()

def is_2017_like(n):
    m = (n + 1) // 2
    return n in primes and m in primes

A = [0]*(max_lr//2 + 1)
a = 0
for i in range(1, max_lr, 2):
    if is_2017_like(i):
        a += 1
    A[i//2 + 1] = a

for i in range(Q):
    ans = A[R[i]//2 + 1] - A[L[i]//2]
    print(ans)
Buggy python submission (verdict: Runtime Error):
l = input().split()
N = int(l[0])
M = int(l[1])

C = []

for i in range(M):
    l = input().split()
    C.append([int(x) - 1 for x in l])

# print(N, M, C)

def visit(s, G, visited):
    # print(s, G, visited)
    visited.add(s)
    for g in G:
        if g[0] in visited:
            n = g[1]
            G.remove(g)
            return visit(n, G, visited)
        elif g[1] in visited:
            n = g[0]
            G.remove(g)
            return visit(n, G, visited)
    return

ans = 0
for i in range(N):
    D = []
    for j in range(N):
        if i != j:
            D.append(C[j])
    visited = set()
    visit(0, D, visited)
    # print(i, len(visited))
    if len(visited) != N:
        ans += 1

print(ans)


Fixed submission:
l = input().split()
N = int(l[0])
M = int(l[1])

C = []

for i in range(M):
    l = input().split()
    C.append([int(x) - 1 for x in l])

# print(N, M, C)

def visit(s, G, visited):
    # print(s, G, visited)
    visited.add(s)
    for g in G:
        if g[0] in visited:
            n = g[1]
            G.remove(g)
            return visit(n, G, visited)
        elif g[1] in visited:
            n = g[0]
            G.remove(g)
            return visit(n, G, visited)
    return

ans = 0
for i in range(M):
    D = []
    for j in range(M):
        if i != j:
            D.append(C[j])
    visited = set()
    visit(0, D, visited)
    # print(i, len(visited))
    if len(visited) != N:
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
def solve():
    N, M = map(int, input().split())
    T = {}
    for i in range(M):
        a, b = map(int, input().split())
        if a not in T:
            T[a] = []
        T[a].append(b)
        if b not in T:
            T[b] = []
        T[b].append(a)
    # print(N, M, T)
    FROM_1 = set(T[1])
    TO_N = set(T[N])
    ans = FROM_1 & TO_N
    print('POSSIBLE') if ans else print('IMPOSSIBLE')

if __name__ == '__main__':
    solve()


Fixed submission:
N, M = map(int, input().split())
T = {}
for i in range(M):
    a, b = map(int, input().split())
    if a not in T:
        T[a] = []
    T[a].append(b)
    if b not in T:
        T[b] = []
    T[b].append(a)
# print(N, M, T)
FROM_1 = T[1]

for f in FROM_1:
    if N in T[f]:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
import math

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

# print(N, A, B, V)

V.sort(reverse=True)

max_list = V[:A]
max_sum = sum(max_list)
print(max_sum / A)

replace = max_list[-1]

num_replace = 0
for v in V:
    if v == replace:
        num_replace += 1

if num_replace == 1:
    print(1)
    exit()

num_replace_in_list = 0
for v in max_list:
    if v == replace:
        num_replace_in_list += 1

if replace * A != max_sum:
    ans = 0
    for i in range(A, B + 1):
        # print(i, num_replace_in_list, num_replace)
        if i - A + num_replace_in_list > num_replace:
            break
        ans += math.factorial(num_replace) // (math.factorial(num_replace - i) * math.factorial(i))
    print(ans)
    exit()


ans = 0
for i in range(A, B + 1):
    if i > num_replace:
        break
    ans += math.factorial(num_replace) // (math.factorial(num_replace - i) * math.factorial(i))

print(ans)


Fixed submission:
import math

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

# print(N, A, B, V)

V.sort(reverse=True)

max_list = V[:A]
max_sum = sum(max_list)
print(max_sum / A)

replace = max_list[-1]

num_replace = 0
for v in V:
    if v == replace:
        num_replace += 1

if num_replace == 1:
    print(1)
    exit()

num_replace_in_list = 0
for v in max_list:
    if v == replace:
        num_replace_in_list += 1

if replace * A != max_sum:
    ans = math.factorial(num_replace) // (math.factorial(num_replace - num_replace_in_list) * math.factorial(num_replace_in_list))
    print(ans)
    exit()


ans = 0
for i in range(A, B + 1):
    if i > num_replace:
        break
    ans += math.factorial(num_replace) // (math.factorial(num_replace - i) * math.factorial(i))

print(ans)
Buggy python submission (verdict: Runtime Error):
l = input().split()
N = int(l[0])
M = int(l[1])

A = []
B = []
C = [[] for i in range(N)]

for i in range(M):
    l = input().split()
    a = int(l[0]) - 1
    b = int(l[1]) - 1
    A.append(a)
    B.append(b)
    C[a].append(b)
    C[b].append(a)

# print(N, M, A, B, C)

def visit(cur, ans, visited):
    # print('cur={}, ans={}'.format(cur, ans))
    visited.append(cur)
    if cur == N - 1:
        # print('goal')
        return ans + 1
    for next in C[cur]:
        if next not in visited:
            return visit(next, ans, visited)

ans = 0
for next in C[0]:
    visited = []
    ans += visit(0, 0, visited)

print(ans)


Fixed submission:
l = input().split()
N = int(l[0])
M = int(l[1])

C = [[] for i in range(N)]

for i in range(M):
    l = input().split()
    a = int(l[0]) - 1
    b = int(l[1]) - 1
    C[a].append(b)
    C[b].append(a)

# print(N, M, C)

def visit(cur, visited, ans, depth):
    depth += 1
    # print('depth={}, cur={}, visited={}, ans={}, C[cur]={}'.format(
    #     depth, cur, visited, ans, C[cur]))
    visited.append(cur)
    if len(visited) == N:
        # print('goal')
        return ans + 1
    for n in C[cur]:
        # print('n={}'.format(n))
        if n not in visited:
            v = [x for x in visited]
            ans = visit(n, v, ans, depth)
    return ans

ans = 0
for n in C[0]:
    visited = [0]
    ans += visit(n, visited, 0, 0)

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

X = input()

ret = deque([X[0]])
for i in range(1, len(X)):
    x = X[i]
    if x == 'S':
        ret.append(x)
    else:
        if ret[-1] == 'S':
            ret.pop()
        else:
            ret.append(x)
print(len(ret))


Fixed submission:
from collections import deque

X = input()

ret = deque([X[0]])
for i in range(1, len(X)):
    x = X[i]
    if x == 'S':
        ret.append(x)
    else:
        if len(ret) > 0 and ret[-1] == 'S':
            ret.pop()
        else:
            ret.append(x)
print(len(ret))
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(map(int,input().split()))
ans = []
for p in range(min(x), max(x)):
    meter = 0
    for xi in x:
        meter += pow((xi-p),2)
    ans.append(meter)
print(min(ans))

Fixed submission:
n = int(input())
x = list(map(int,input().split()))
ans = []
if len(set(x)) == 1:
    print(0)
else: 
    for p in range(min(x), max(x)):
        meter = 0
        for xi in x:
            meter += pow((xi-p),2)
        ans.append(meter)
    print(min(ans))
Buggy python submission (verdict: Runtime Error):
s =  list(input())
combo = False
cnt = 0
ans = [] 
for mozi in s:
    if(mozi == "A" or mozi == "G" or mozi == "C" or mozi == "T"):
        cnt = cnt + 1 
        if combo != True:
            combo = True
    elif combo:
        ans.append(cnt)
        cnt = 0
        combo = False
print(max(ans))


Fixed submission:
s =  list(input())
combo = False
cnt = 0
ans = [0,] 
for mozi in s:
    if(mozi == "A" or mozi == "G" or mozi == "C" or mozi == "T"):
        cnt = cnt + 1 
        if combo != True:
            combo = True
    else:
        if combo:
            ans.append(cnt)
            cnt = 0
            combo = False
ans.append(cnt)
print(max(ans))
Buggy python submission (verdict: Runtime Error):
num = int(input())
mochi = [int(input()) for m in range(0, num)]
maisuu = len(set([n for n in mochi]))
print(maisuu)

Fixed submission:
datestr = input()

if (datestr[0:8] == '2017/01/'):
    ans = datestr.replace("2017",'2018')
    
print(ans)
Buggy python submission (verdict: Runtime Error):
s =  list(input())
if ("C" in s and "F" in s):
    
    if(s.index("C") < s.index("F",1)):
       print("Yes")
    else:
       print("No")
else:
    print("No")

Fixed submission:
s =  list(input())
if ("C" in s and "F" in s):
    if(s.count("F") == 1):
        if(s.index("C") < s.index("F")):
            print("Yes")
        else:
            print("No")
    else:
        if(s.index("C") < s.index("F",1)):
            print("Yes")
        else:
            print("No")

else:
    print("No")
Buggy python submission (verdict: Runtime Error):
input()
a=map(int,input().split())
print(max(a)-min(a))


Fixed submission:
input()
a=list(map(int,input().split()))
print(max(a)-min(a))
Buggy python submission (verdict: Runtime Error):
a = []
b = []
mem = {}
ans = 0
def flip(f):
    for i in range(len(a)):
        for j in range(3):
            if f & (1 << j) == 1:
                a[i][j] = - a[i][j]
def solve(n,m):
    if(mem.get((n,m))!=None):
        return mem[(n,m)]
    if m == 0:
        return 0
    if n == m:
        mem[(n,m)] = sum(b[:n])
        return mem[(n,m)]
    ans = max([solve(n-1,m-1) + b[n-1] , solve(n-1,m)])
    mem[(n,m)] = ans
    return ans
n,m = map(int,input().split())
for i in range(n):
    a.append(list(map(int,input().split())))
for f in range(8):
    b.clear()
    flip(f)
    for x in a:
        b.append(sum(x))
    mem.clear()
    ans = max([ans,solve(n,m)])
    flip(f)
print(ans)


Fixed submission:
a,b = map(int,input().split())
if a<=8 and b<=8:
    print("Yay!")
else:
    print(":(")