Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

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

memo = {}
def doit(i, f):
    if i == len(a) - 1:
        return a[i]
    if not (i, f) in memo:
        ret = gcd(a[i], doit(i + 1, f))
        if f == 0:
            ret = max(ret, doit(i + 1, 1))
        memo[(i, f)] = ret
    return memo[(i, f)]

print(doit(0, 0))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
def gcd(a, b):
    return b if a == 0 else gcd(b % a, a)
l = [0]
r = [0]
for i in range(n):
    l.append(gcd(l[-1], a[i]))
    r.append(gcd(r[-1], a[n - i - 1]))
ret = 0
for i in range(n):
    ret = max(ret, gcd(l[i], r[n - i - 1]))
print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for _ in range(n)]
suma = sum(a)
suma2 = suma // 2
mod = 998244353

dp1 = [3] + [0] * suma2
dp2 = [3] + [0] * suma2
for ai in a:
    for j in range(suma2, ai - 1, -1):
        dp1[j] = (dp1[j] + dp1[j - ai] * 2) % mod
        dp2[j] = (dp2[j] + dp2[j - ai]    ) % mod
half = dp2[suma2] if suma % 2 == 0 else 0
print(((3 ** n) - sum(dp1) + half + mod) % mod)


Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]
suma = sum(a)
suma2 = suma // 2
mod = 998244353

dp1 = [3] + [0] * suma2
dp2 = [3] + [0] * suma2
for ai in a:
    for j in range(suma2, ai - 1, -1):
        dp1[j] = (dp1[j] + dp1[j - ai] * 2) % mod
        dp2[j] = (dp2[j] + dp2[j - ai]    ) % mod
half = dp2[suma2] if suma % 2 == 0 else 0
print(((3 ** n) - sum(dp1) + half + mod) % mod)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = sorted([int(input()) for _ in range(n)], reverse=True)
suma = sum(a)
mod = 998244353

dp1 = [3] + [0] * (suma // 2)
dp2 = [3] + [0] * (suma // 2)
for ai in a:
    for j in range(suma // 2, -1, -1):
        dp1[j] = (dp1[j] + (dp1[j - ai]  * 2 if j >= ai else 0)) % mod
        dp2[j] = (dp2[j] + (dp2[j - ai]      if j >= ai else 0)) % mod
half = dp2[suma // 2] if suma % 2 == 0 else 0
print(((3 ** n) - sum(dp1) + half + mod) % mod)


Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]
suma = sum(a)
suma2 = suma // 2
mod = 998244353

dp1 = [3] + [0] * suma2
dp2 = [3] + [0] * suma2
for ai in a:
    for j in range(suma2, ai - 1, -1):
        dp1[j] = (dp1[j] + dp1[j - ai] * 2) % mod
        dp2[j] = (dp2[j] + dp2[j - ai]    ) % mod
half = dp2[suma2] if suma % 2 == 0 else 0
print(((3 ** n) - sum(dp1) + half + mod) % mod)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = sorted([int(input()) for _ in range(n)], reverse=True)
suma = sum(a)

mod = 998244353
memo = {}
def doit(index, s, c):
    if index >= len(a):
        if s * 2 < suma:
            return 0
        elif s * 2 == suma:
            return ((2 ** (len(a) - c) - 1) * 3) % mod
        else:
            return ((2 ** (len(a) - c)) * 3) % mod
    key = (index, s, c)
    if key not in memo:
        memo[key] = (doit(index + 1, s + a[index], c + 1) + doit(index + 1, s, c)) % mod
    return memo[key]

print((3 ** len(a) - doit(0, 0, 0)) % mod)

Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]
suma = sum(a)
suma2 = suma // 2
mod = 998244353

dp1 = [3] + [0] * suma2
dp2 = [3] + [0] * suma2
for ai in a:
    for j in range(suma2, ai - 1, -1):
        dp1[j] = (dp1[j] + dp1[j - ai] * 2) % mod
        dp2[j] = (dp2[j] + dp2[j - ai]    ) % mod
half = dp2[suma2] if suma % 2 == 0 else 0
print(((3 ** n) - sum(dp1) + half + mod) % mod)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq

x, y, z, k = map(int, raw_input().split())
a = map(int, raw_input().split())
b = map(int, raw_input().split())
c = map(int, raw_input().split())

def diff(l):
    m = max(l)
    return sorted(m - v for v in l)[1:]

s = sum(map(max, [a, b, c]))
sa, sb, sc = map(diff, [a, b, c])
da, db, dc = [0], [0], [0]
q = [0]
while k > 0:
    while True:
        if len(sa) > 0 and (len(q) == 0 or q[0] >= sa[0]):
            for v in [sa[0] + bb + cc for bb in db for cc in dc]:
                heapq.heappush(q, v)
            da.append(sa[0])
            sa = sa[1:]
        elif len(sb) > 0 and (len(q) == 0 or q[0] >= sb[0]):
            for v in [sb[0] + aa + cc for aa in da for cc in dc]:
                heapq.heappush(q, v)
            db.append(sb[0])
            sb = sb[1:]
        elif len(sc) > 0 and (len(q) == 0 or q[0] >= sc[0]):
            for v in [sc[0] + aa + bb for aa in da for bb in db]:
                heapq.heappush(q, v)
            dc.append(sc[0])
            sc = sc[1:]
        else:
            break
    v = heapq.heappop(q)
    print s - v
    k -= 1


Fixed submission:
import heapq

x, y, z, k = map(int, raw_input().split())
a = map(int, raw_input().split())
b = map(int, raw_input().split())
c = map(int, raw_input().split())

def diff(l):
    m = max(l)
    return sorted(m - v for v in l)[1:]

s = sum(map(max, [a, b, c]))
sa, sb, sc = map(diff, [a, b, c])
da, db, dc = [0], [0], [0]
q = [0]
while k > 0:
    while True:
        if len(sa) > 0 and (len(q) == 0 or q[0] > sa[0]):
            for v in [sa[0] + bb + cc for bb in db for cc in dc]:
                heapq.heappush(q, v)
            da.append(sa[0])
            sa = sa[1:]
        elif len(sb) > 0 and (len(q) == 0 or q[0] > sb[0]):
            for v in [sb[0] + aa + cc for aa in da for cc in dc]:
                heapq.heappush(q, v)
            db.append(sb[0])
            sb = sb[1:]
        elif len(sc) > 0 and (len(q) == 0 or q[0] > sc[0]):
            for v in [sc[0] + aa + bb for aa in da for bb in db]:
                heapq.heappush(q, v)
            dc.append(sc[0])
            sc = sc[1:]
        else:
            break
    v = heapq.heappop(q)
    print s - v
    k -= 1
Buggy python submission (verdict: Runtime Error):
n, q = map(int, raw_input().split())
s = raw_input()
td = [raw_input().split() for _ in range(q)];
left, right = 0, n
for t, d in reversed(td):
    if d == 'L':
        if left < n and s[left] == t:
            left += 1
        if right < n and s[right] == t:
            right += 1
    elif d == 'R':
        if left > 0 and s[left - 1] == t:
            left -= 1
        if right > 0 and s[right - 1] == t:
            right -= 1
print(max(0, right - left))

Fixed submission:
n, q = map(int, raw_input().split())
s = raw_input()
td = [raw_input().split() for _ in range(q)];
left, right = 0, n
for t, d in reversed(td):
    if d == 'L':
        if left < n and s[left] == t:
            left += 1
        if right < n and s[right] == t:
            right += 1
    elif d == 'R':
        if left > 0 and s[left - 1] == t:
            left -= 1
        if right > 0 and s[right - 1] == t:
            right -= 1
print max(0, right - left)

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, raw_input().split())
s = raw_input()
g1 = [1] * n
for _ in range(q):
    t, d = raw_input().split()
    g2 = [0] * n
    for i in range(n):
        if s[i] != t:
            g2[i] += g1[i]
        elif d == 'L' and i > 0:
            g2[i - 1] += g1[i]
        elif d == 'R' and i < n - 1:
            g2[i + 1] += g1[i]
    g1 = g2
print sum(g1)

Fixed submission:
n, q = map(int, raw_input().split())
s = raw_input()
td = [raw_input().split() for _ in range(q)];
left, right = 0, n
for t, d in reversed(td):
    if d == 'L':
        if left < n and s[left] == t:
            left += 1
        if right < n and s[right] == t:
            right += 1
    elif d == 'R':
        if left > 0 and s[left - 1] == t:
            left -= 1
        if right > 0 and s[right - 1] == t:
            right -= 1
print max(0, right - left)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(raw_input())
c = [int(raw_input()) for i in range(n)]
mod = 1000000007

dp = [0] * len(c)
dp[-1] = 1
for i in range(len(c) - 2, -1, -1):
    dp[i] = dp[i + 1]
    try:
        j = c.index(c[i], i + 1)
        if j > i + 1:
            dp[i] = (dp[i] + dp[j]) % mod
    except:
        pass

print dp[0]

Fixed submission:
n = int(raw_input())
c = [int(raw_input()) for i in range(n)]
mod = 1000000007

dp = [0] * len(c)
last = [-1] * 200001
dp[0] = 1
last[c[0]] = 0
for i in range(1, len(c)):
    dp[i] = dp[i - 1]
    if last[c[i]] >= 0 and last[c[i]] < i - 1:
        dp[i] = (dp[i] + dp[last[c[i]]]) % mod
    last[c[i]] = i

print dp[-1]
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
memo = {}
matches = [100, 2, 5, 5, 4, 5, 6, 3, 7, 6]

def doit(n):
    if n == 0:
        return ""
    if not n in memo:
        ret = None
        for d in a:
            m = matches[d]
            if n - m >= 0 and doit(n - m) is not None:
                r = max(doit(n - m) + str(d), str(d) + doit(n - m))
                if ret is None or len(r) > len(ret) or len(r) == len(ret) and r > ret:
                    ret = r
        memo[n] = ret
    return memo[n]

print(doit(n))

Fixed submission:
import sys

sys.setrecursionlimit(100000)

n, m = map(int, input().split())
a = list(map(int, input().split()))
memo = {}
matches = [100, 2, 5, 5, 4, 5, 6, 3, 7, 6]

def doit(n):
    if n == 0:
        return ""
    if not n in memo:
        ret = None
        for d in a:
            m = matches[d]
            if n - m >= 0 and doit(n - m) is not None:
                r = max(doit(n - m) + str(d), str(d) + doit(n - m))
                if ret is None or len(r) > len(ret) or len(r) == len(ret) and r > ret:
                    ret = r
        memo[n] = ret
    return memo[n]

print(doit(n))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
td = list(sorted([tuple(map(int, input().split())) for _ in range(n)], key=lambda td: -td[1]))
td2 = []
eaten = set()
dup = 0
score = k * k
i = 0
j = 0
while len(eaten) + dup < k:
    if td[i][0] in eaten:
        td2.append(td[i])
        i += 1
    else:
        diff = (k - dup) * (k - dup) - (k - dup - 1) * (k - dup - 1)
        if i < n and (j >= len(td2) or td[i][1] >= td2[j][1] - diff):
            t, d = td[i]
            score += d
            eaten.add(t)
            i += 1
        else:
            t, d = td2[j]
            score += d - diff
            dup += 1
            j += 1
print(score)


Fixed submission:
n, k = map(int, input().split())
td = list(sorted([tuple(map(int, input().split())) for _ in range(n)], key=lambda td: -td[1]))
td2 = []
eaten = set()
dup = 0
score = k * k
i = 0
j = 0
while len(eaten) + dup < k:
    if i < n and td[i][0] in eaten:
        td2.append(td[i])
        i += 1
    else:
        diff = (k - dup) * (k - dup) - (k - dup - 1) * (k - dup - 1)
        if i < n and (j >= len(td2) or td[i][1] >= td2[j][1] - diff):
            t, d = td[i]
            score += d
            eaten.add(t)
            i += 1
        else:
            t, d = td2[j]
            score += d - diff
            dup += 1
            j += 1
print(score)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
td = list(sorted([tuple(map(int, input().split())) for _ in range(n)], key=lambda td: -td[1]))
td2 = []
eaten = set()
dup = 0
score = k * k
while len(eaten) + dup < k:
    if td[0][0] in eaten:
        td2.append(td.pop(0))
    else:
        diff = (k - dup) * (k - dup) - (k - dup - 1) * (k - dup - 1)
        if not td2 or td[0][1] >= td2[0][1] - diff:
            t, d = td.pop(0)
            score += d
            eaten.add(t)
        else:
            t, d = td2.pop(0)
            score += d - diff
            dup += 1

print(score)


Fixed submission:
n, k = map(int, input().split())
td = list(sorted([tuple(map(int, input().split())) for _ in range(n)], key=lambda td: -td[1]))
td2 = []
eaten = set()
dup = 0
score = k * k
i = 0
j = 0
while len(eaten) + dup < k:
    if i < n and td[i][0] in eaten:
        td2.append(td[i])
        i += 1
    else:
        diff = (k - dup) * (k - dup) - (k - dup - 1) * (k - dup - 1)
        if i < n and (j >= len(td2) or td[i][1] >= td2[j][1] - diff):
            t, d = td[i]
            score += d
            eaten.add(t)
            i += 1
        else:
            t, d = td2[j]
            score += d - diff
            dup += 1
            j += 1
print(score)
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
def doit(l, x):
    layers = 2 ** (l + 1) - 3
    if x >= layers + 2:
        return doit(l - 1, x - layers - 2) + 2 ** l
    elif x >= 1:
        return doit(l - 1, x - 1)
    else:
        return 0
print(doit(n, x))

Fixed submission:
n, x = map(int, input().split())
def layers(l):
    return 2 ** (l + 2) - 3
def patties(l):
    return 2 ** (l + 1) - 1
def doit(l, x):
    if x >= layers(l):
        return patties(l)
    y = layers(l - 1)
    ret = 0
    if x >= 1:
        ret += doit(l - 1, x - 1)
    if x >= y + 2:
        ret += 1
        ret += doit(l - 1, x - y - 2)
    return ret
print(doit(n, x))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]
d = []
s = ["" for _ in xy]
while True:
    p = [max(abs(x), abs(y)) for x, y in xy]
    q = [abs(x) + abs(y) for x, y in xy]
    if max(q) == 0:
        break
    elif max(q) == 1 and min(q) == 0:
        d = None
        break
    d.append((max(p) + min(p)) // 2)
    for i in range(len(xy)):
        x, y = xy[i]
        if p[i] == abs(x):
            if x > 0:
                s[i] += "R"
                xy[i] = (x - d[-1], y)
            else:
                s[i] += "L"
                xy[i] = (x + d[-1], y)
        else:
            if y > 0:
                s[i] += "U"
                xy[i] = (x, y - d[-1])
            else:
                s[i] += "D"
                xy[i] = (x, y + d[-1])

if d is None or len(d) > 40:
    print(-1)
else:
    print(len(d))
    print(*d)
    for t in s:
        print(t)


Fixed submission:
n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]
s = set([(x + y) % 2 for x, y in xy])
if len(s) > 1:
    print(-1)
    exit(0)

d = []
w = ["" for _ in xy]
if s.pop() == 0:
    d = [1]
    w = ["L" for _ in xy]
    xy = [(x + 1, y) for x, y in xy]

b = 1
while True:
    if all(abs(x) + abs(y) == 1 for x, y in xy):
        d.append(b)
        for i in range(len(xy)):
            x, y = xy[i]
            if x > 0:
                w[i] += 'R'
            elif x < 0:
                w[i] += 'L'
            elif y > 0:
                w[i] += 'U'
            else:
                w[i] += 'D'
        break
    d.append(b)
    for i in range(len(xy)):
        x, y = xy[i]
        if x % 2 == 1:
            if y % 4 == 2 and (x - 1) % 4 == 0 or y % 4 == 0 and (x - 1) % 4 == 2:
                w[i] += 'R'
                xy[i] = ((x - 1) // 2, y // 2)
            else:
                w[i] += 'L'
                xy[i] = ((x + 1) // 2, y // 2)
        else:
            if x % 4 == 2 and (y - 1) % 4 == 0 or x % 4 == 0 and (y - 1) % 4 == 2:
                w[i] += 'U'
                xy[i] = (x // 2, (y - 1) // 2)
            else:
                w[i] += 'D'
                xy[i] = (x // 2, (y + 1) // 2)
    b *= 2

print(len(d))
print(*d)
for t in w:
    print(t)
Buggy python submission (verdict: Runtime Error):
n, m, x, y = map(int, input().split())
xs = map(int, input().split())
ys = map(int, input().split())
if max([x] + list(xs)) < min([y] + list(ys)):
    print "No War"
else:
    print "War"

Fixed submission:
n, m, x, y = map(int, input().split())
xs = map(int, input().split())
ys = map(int, input().split())
print("No War" if max([x] + list(xs)) < min([y] + list(ys)) else "War")
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
mod = 1000000007
d = 1
divisor = []
while d * d <= m:
    if m % d == 0:
        divisor.append(d)
        if d != m // d:
            divisor.append(m // d)
    d += 1
divisor = sorted(divisor)
l = len(divisor)
matrix = [[0] * l for _ in range(l)]
for i in range(l):
    for j in range(l):
        matrix[i][j] = 1 if divisor[i] % divisor[j] == 0 else 0

dp = [1] * l
t = n - 1
while t > 0:
    if t % 2 == 1:
        newdp = [0] * l
        for i in range(l):
            for j in range(l):
                newdp[i] = (newdp[i] + matrix[i][j] * dp[j]) % mod
        dp = newdp
    newmatrix = [[0] * l for _ in range(l)]
    for i in range(l):
        for j in range(i + 1):
            newmatrix[i][j] = sum(matrix[i][k] * matrix[k][j] for k in range(j, i + 1)) % mod
    matrix = newmatrix
    t //= 2

print(dp[-1])


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

def cmb(n, k):
    ret = 1
    for i in range(k):
        ret *=  n - i
        ret //= i + 1
    return ret % mod

primes = [2]
for p in range(3, 1000):
    if all(p % q for q in primes):
        primes.append(p)

ret = 1
for p in primes:
    q = 0
    while m % p == 0:
        m //= p
        q += 1
    if q > 0:
        ret = (ret * cmb(n + q - 1, q)) % mod
if m > 1:
    ret = (ret * cmb(n, 1)) % mod

print(ret)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
mod = 1000000007
d = 1
divisor = []
while d * d <= m:
    if m % d == 0:
        divisor.append(d)
        if d != m // d:
            divisor.append(m // d)
    d += 1
divisor = sorted(divisor)
l = len(divisor)
matrix = [[0] * l for _ in range(l)]
for i in range(l):
    for j in range(l):
        matrix[i][j] = 1 if divisor[i] % divisor[j] == 0 else 0

dp = [1] * l
t = n - 1
while t > 0:
    if t % 2 == 1:
        newdp = [0] * l
        for i in range(l):
            for j in range(l):
                newdp[i] = (newdp[i] + matrix[i][j] * dp[j]) % mod
        dp = newdp
    newmatrix = [[0] * l for _ in range(l)]
    for i in range(l):
        for j in range(l):
            newmatrix[i][j] = sum(matrix[i][k] * matrix[k][j] for k in range(l)) % mod
    matrix = newmatrix
    t //= 2

print(dp[-1])


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

def cmb(n, k):
    ret = 1
    for i in range(k):
        ret *=  n - i
        ret //= i + 1
    return ret % mod

primes = [2]
for p in range(3, 1000):
    if all(p % q for q in primes):
        primes.append(p)

ret = 1
for p in primes:
    q = 0
    while m % p == 0:
        m //= p
        q += 1
    if q > 0:
        ret = (ret * cmb(n + q - 1, q)) % mod
if m > 1:
    ret = (ret * cmb(n, 1)) % mod

print(ret)
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
r, c, d = 0, 0, 3
ret = []
for y in range(h * w - 1):
    if y % w == 0 or y % w == w - 1:
        d = (d + 1) % 4
    dy, dx = [(0, 1), (1, 0), (0, -1), (1, 0)][d]
    if a[r][c] % 2 != 0:
        ret.append((r, c, r + dy, c + dx))
        a[r + dy][c + dx] += 1
    r, c = r + dy, c + dx
print(len(ret))
for r1, c1, r2, c2 in ret:
    print(r1 + 1, c1 + 1, r2 + 1, c2 + 1)


Fixed submission:
h, w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
r, c, d = 0, 0, 3
ret = []
for y in range(h * w - 1):
    if y % w == 0:
        d = (d + 1) % 4
    if y % w == w - 1:
        d = (d + 1) % 4
    dy, dx = [(0, 1), (1, 0), (0, -1), (1, 0)][d]
    if a[r][c] % 2 != 0:
        ret.append((r, c, r + dy, c + dx))
        a[r + dy][c + dx] += 1
    r, c = r + dy, c + dx
print(len(ret))
for r1, c1, r2, c2 in ret:
    print(r1 + 1, c1 + 1, r2 + 1, c2 + 1)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
x = sorted(map(int, input().split()))
ret = 1000000000000000000
for s in range(n - k + 1):
    e = s + k - 1
    if x[e] <= 0:
	ret = min(ret, -x[s])
    elif x[s] <= 0:
	ret = min(ret, x[e] - x[s] + min(-x[s], x[e]))
    else:
        ret = min(ret, x[e])
print(ret)


Fixed submission:
n, k = map(int, input().split())
x = sorted(map(int, input().split()))
ret = 1000000000000000000
for s in range(n - k + 1):
    e = s + k - 1
    if x[e] <= 0:
        ret = min(ret, -x[s])
    elif x[s] <= 0:
        ret = min(ret, x[e] - x[s] + min(-x[s], x[e]))
    else:
        ret = min(ret, x[e])
print(ret)
Buggy python submission (verdict: Runtime Error):
import math

def main():
    n = int(input())
    t, a = map(int, input().split())
    h = list(map(int, input().split()))

    ans = 0
    temp = math.inf
    for i in range(n):
        if temp > abs(a - (t - h[i] * 0.006)):
            temp = abs(a - (t - h[i] * 0.006))
            ans = i + 1
        
    print(ans)

main()


Fixed submission:
def main():
    n = int(input())
    t, a = map(int, input().split())
    h = list(map(int, input().split()))

    ans = 0
    temp = float('inf')
    for i in range(n):
        if temp > abs(a - (t - h[i] * 0.006)):
            temp = abs(a - (t - h[i] * 0.006))
            ans = i + 1
        
    print(ans)

main()
Buggy python submission (verdict: Runtime Error):
a, b, k = [int(i) for i in input().split(" ")]
if a >= k:
    print("%d %d" % (a - k, b))
else: # a < k
    print("%d %d" % (0, max([b + (a - k), 0]))



Fixed submission:
a, b, k = [int(i) for i in input().split(" ")]
if a >= k:
    print("%d %d" % (a - k, b))
else: # a < k
    print("%d %d" % (0, max([b + (a - k), 0])))
Buggy python submission (verdict: Runtime Error):
num = [int(n) for n in input().split()] 
    
s = sum(num[1:num[0]+1])/num[0]
s = round(s)
r = 0
for i in range(1,num[0]+1):
    r += pow(num[i]-s,2)
print(r)

Fixed submission:
import sys

num = []

while True:
    try:
        num.extend([int(n) for n in input().split()])
    except EOFError:
        break
    
s = sum(num[1:num[0]+1])/num[0]
s = round(s)
r = 0
for i in range(1,num[0]+1):
    r += pow(num[i]-s,2)
print(r)

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

num = [int(n) for n in input().split()] 
    
s = sum(num[1:num[0]+1])/num[0]
s = round(s)
r = 0
for i in range(1,num[0]+1):
    r += pow(num[i]-s,2)
print(r)

Fixed submission:
import sys

num = []

while True:
    try:
        num.extend([int(n) for n in input().split()])
    except EOFError:
        break
    
s = sum(num[1:num[0]+1])/num[0]
s = round(s)
r = 0
for i in range(1,num[0]+1):
    r += pow(num[i]-s,2)
print(r)
Buggy python submission (verdict: Runtime Error):
s = input()
w = ['Sunny', 'Cloudy', 'Rainy']
print(w[w.index(s) + 1])

Fixed submission:
s = input()
w=["Sunny","Cloudy","Rainy","Sunny"]
print(w[w.index(s)+1])
Buggy python submission (verdict: Runtime Error):
s = input()
print(s.replace(',',' ')）

Fixed submission:
s = input()
print(s.replace(',',' '))

Buggy python submission (verdict: Runtime Error):
s = input()
print(S.replace(',',' ')）

Fixed submission:
s = input()
print(s.replace(',',' '))
Buggy python submission (verdict: Runtime Error):
s = input()
a = s.find('C')

if a == -1:
    print("No")
else:
    if s[a:].find('F') == -1:
        print("No")
    else print("Yes")

Fixed submission:
s = input()
a = s.find('C')

if a == -1:
    print("No")
else:
    if s[a:].find('F') == -1:
        print("No")
    else: print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p_n = list(map(int, input().split()))
ans = 1
p_i_1 = [p_n[0]]
for i in range(1, n):
    if min(p_i_1) > p_n[i]:
        ans += 1
    p_i_1.append(p_n[i])
print(ans)


Fixed submission:
n = int(input())
p_n = list(map(int, input().split()))
ans = 1
p_i_1 = [p_n[0]]
m = p_n[0]
for i in range(1, n):
    if m > p_n[i]:
        ans += 1
    m = min(m, p_n[i])
    p_i_1.append(p_n[i])
    if m == 1:
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
brick = list(map(int, input().split()))
cnt = 0
def Break(brick, i):
    if len(brick) == 0:
        return
    else:
        if i not in brick:
            return
        else:
            j = brick.index(i)
            brick = [brick[k] for k in range(j+1, len(brick))]
            global cnt
            cnt += 1
            Break(brick, i + 1)
Break(brick, 1)
if cnt == 0:
    print(-1)
else:
    print(n - cnt)


Fixed submission:
n = int(input())
brick = list(map(int, input().split()))
cnt = 0
i = 0
j = 1
while i < n:
    if brick[i] == j:
        cnt += 1
        j += 1
    i += 1
if cnt == 0:
    print(-1)
else:
    print(n - cnt)