Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
iList = [int(input()) for i in range(5)]

P1toP2 = math.ceil(N / iList[0])
P2toP3 = math.ceil(iList[0] / iList[1])
P3toP4 = math.ceil(min(iList[:1]) / iList[2])
P4toP5 = math.ceil(min(iList[:2]) / iList[3])
P5toP6 = math.ceil(min(iList[:3]) / iList[4])


print(P1toP2 + P2toP3 + P3toP4 + P4toP5 + P5toP6)

Fixed submission:
import math
N = int(input())
iList = [int(input()) for i in range(5)]
print(math.ceil(N/min(iList))+4)
Buggy python submission (verdict: Time Limit Exceeded):
pattern = "AC"
N, Q = map(int, input().split(" "))
S = input()

ACIndex = []
findFrom = 0
while(1) :
    i = S[findFrom:].find("AC")
    if i == -1 :
        break
    else :
        ACIndex.append(i+findFrom)
        findFrom = i+1+findFrom


for i in range(Q) :
    count = 0
    l, r = map(int, input().split(" "))
    for j in ACIndex :
        if j>=l-1 and j<r-1 :
            count+= 1
    
    print(count)


Fixed submission:
N, Q = map(int, input().split(" "))
S = input()

ACIndex = [0] * (N+1)
for i in range(N) :
    ACIndex[i+1] = ACIndex[i] + (1 if S[i:i+2] == "AC" else 0)

for i in range(Q) :
    l,r = map(int, input().split(" "))
    print(ACIndex[r-1] - ACIndex[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
pattern = "AC"
N, Q = map(int, input().split(" "))
S = input()
for i in range(Q) :
    l, r = map(int, input().split(" "))
    print(S[l-1:r].count("AC"))

Fixed submission:
N, Q = map(int, input().split(" "))
S = input()

ACIndex = [0] * (N+1)
for i in range(N) :
    ACIndex[i+1] = ACIndex[i] + (1 if S[i:i+2] == "AC" else 0)

for i in range(Q) :
    l,r = map(int, input().split(" "))
    print(ACIndex[r-1] - ACIndex[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
import re

pattern = "AC"
N, Q = map(int, input().split(" "))
S = input()
for i in range(Q) :
    l, r = map(int, input().split(" "))
    results = re.findall(pattern, S[l-1:r], re.S)
    print(len(results))


Fixed submission:
N, Q = map(int, input().split(" "))
S = input()

ACIndex = [0] * (N+1)
for i in range(N) :
    ACIndex[i+1] = ACIndex[i] + (1 if S[i:i+2] == "AC" else 0)

for i in range(Q) :
    l,r = map(int, input().split(" "))
    print(ACIndex[r-1] - ACIndex[l-1])
Buggy python submission (verdict: Runtime Error):

A,B,K  = map(int, input().split(" "))
count = 0
i = 1
tempList = []
for i in range(1,max(A,B)) :
    if A%i == 0 and B%i == 0:
        tempList.append(i)
print(tempList[-K])
    

Fixed submission:

A,B,K  = map(int, input().split(" "))
count = 0
i = 1
tempList = []
for i in range(1,200) :
    if A%i == 0 and B%i == 0:
        tempList.append(i)
print(tempList[-K])
Buggy python submission (verdict: Time Limit Exceeded):
import re
S = input()
count = 0
Olength = len(S)
previousCount = 0

while(1) :
    S = re.sub("(01|10)", "", S)
    count = count + (Olength - len(S))
    Olength = len(S)
    
    if previousCount == count :
        break
    previousCount = count
print(count)

Fixed submission:
S = input()
C1 = S.count("0")
C2 = S.count("1")

print(min(C1,C2)*2)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
count = 0
Olength = len(S)
previousCount = 0

while(1) :
    S = S.replace("01", "")
    count = count + (Olength - len(S))
    Olength = len(S)
    S = S.replace("10", "")
    count = count + (Olength - len(S))
    Olength = len(S)
    
    if previousCount == count :
        break
    previousCount = count
print(count)

Fixed submission:
S = input()
C1 = S.count("0")
C2 = S.count("1")

print(min(C1,C2)*2)

Buggy python submission (verdict: Runtime Error):
S = input()
S = list(S)
count = 0


for j in range(200) :
    if len(S) < 2:
        break
    
    if S[0] != S[1] :
        S.pop(0)
        S.pop(0)
        count+=2
    
    
    for i in range(1,len(S)-2) :
        print(S, i)
        if S[i] != S[i+1] :
            if S[i-1] != S[i+2] :
                S.pop(i)
                S.pop(i)
                count +=2
                break
            
print(count)
        


Fixed submission:
S = input()
C1 = S.count("0")
C2 = S.count("1")

print(min(C1,C2)*2)
Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().split(" "))
XList = list(map(int,input().split()))

XList = sorted(XList)
deltaList = []

for i in range(M-1) :
    deltaList.append(XList[i+1] - XList[i])
deltaList = sorted(deltaList, reverse=True)

for i in range(N-1) :
    deltaList[i] = 0
print(sum(deltaList))

Fixed submission:
N,M = map(int, input().split(" "))
XList = list(map(int,input().split()))

XList = sorted(XList)
deltaList = [0]

for i in range(M-1) :
    deltaList.append(XList[i+1] - XList[i])
deltaList = sorted(deltaList, reverse=True)


for i in range(N-1) :
    deltaList[i] = 0
    if i == len(deltaList)-1 :
        break
print(sum(deltaList))
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = [[int(i) for i in input().split()] for i in range(n)]

max = 100

for posX in range(0,101) :
    for posY in range(0,101) :
        needH = -1
        
        for i in range(0,n) :
            if p[i][2] > 0 :
                tmp = p[i][2] + abs(posY-p[i][1]) + abs(posX - p[i][0])
                if needH == -1 :
                    needH = tmp
            else :
                if needH != tmp :
                    needH = -2
                    break
        if needH == -2 : continue
            
        for i in range(0,n) :
            if p[i][2] == 0 :
                dist =  abs(posY-p[i][1]) + abs(posX - p[i][0])
                if needH > dist :
                    needH = -2
                    break
        if needH == -2 : continue
        
        print(posX, posY, needH)
        break
    break

Fixed submission:
def execute() :
    n = int(input())
    p = [[int(i) for i in input().split()] for i in range(n)]
    
    for posX in range(101) :
        for posY in range(101) :
            needH = -1
    
            for i in range(n) :
                x, y, h = p[i]
                if h > 0 :
                    tmp = h + abs(posY-y) + abs(posX-x)
                    if needH == -1 :
                        needH = tmp
                    else :
                        if needH != tmp :
                            needH = -2
                            break
            if needH == -2 : 
                continue
    
            for i in range(n) :
                x, y, h = p[i]
                if h == 0 :
                    dist =  abs(posY-y) + abs(posX - x)
                    if needH > dist :
                        needH = -2
                        break
            if needH == -2 : 
                continue
            
            return (posX, posY, needH)

result = execute()     
print(result[0], result[1], result[2])
Buggy python submission (verdict: Runtime Error):
from collections import Counter

n = int(input())
v = [int(i) for i in input().split()]

ki = v[::2]
gu = v[1::2]

ki = Counter(ki)
gu = Counter(gu)

ki = ki.most_common()
gu = ki.most_common()

if ki[0][0] == gu[0][0] :
    if(len(ki) == len(gu)) :
        print(n/2)
    else :
        if(ki[1][1] > gu[1][1]) :
            print(n-ki[1][1]-gu[0][1])
        else :
            print(n-ki[0][1]- gu[1][1])

else :
    print(n-ki[0][1]-gu[0][1])

Fixed submission:
from collections import Counter

n = int(input())
v = [int(i) for i in input().split()]

ki = v[::2]
gu = v[1::2]

ki = Counter(ki)
gu = Counter(gu)

ki = ki.most_common()
gu = gu.most_common()

if ki[0][0] == gu[0][0] :
    if len(ki) == 1 and len(gu) == 1 :
        print(int(n/2))
    else :
        if ki[1][1] > gu[1][1] :
            print(n-ki[1][1]-gu[0][1])
        else :
            print(n-ki[0][1]- gu[1][1])

else :
    print(n-ki[0][1]-gu[0][1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

mod = 10**9 + 7
ans = 0
for i in range(n):
    for j in range(i+1, n):
        ans += a[i]*a[j]

print(ans%mod)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
s = [0] * n

for i in range(1, n):
    s[i] = s[i-1] + a[i-1]

ans = 0
for i in range(1, n):
    ans += a[i] * s[i]

mod = 10**9 + 7

# for i in range(n-1):
#     for j in range(i+1, n):
#         ans += a[i]*a[j]

print(ans%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
q = int(input())

b, c = [0] * q, [0] * q
for i in range(q):
    b[i], c[i] = map(int, input().split())

a.sort()

for i in range(q):
    if b[i] in a:
        s = a.index(b[i])
        while s < n and a[s] == b[i]:
            a[s] = c[i]
            s += 1
    print(sum(a))

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

b, c = [0] * q, [0] * q
for i in range(q):
    b[i], c[i] = map(int, input().split())

cnt = [0] * (10**5 +  5)
for i in range(n):
    cnt[a[i]] += 1

tot = sum(a)

for i in range(q):
    if cnt[b[i]] > 0:
        tot += cnt[b[i]] * (c[i] - b[i])
        cnt[c[i]] += cnt[b[i]]
        cnt[b[i]] = 0
    print(tot)
Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())

for a in range(x + 1):
    tem = 2 * a + 4 * (x - a)
    if (tem == y):
        #  and (2 * x <= y <= 4 * x):
        print('Yes')
        exit(1)

print('No')

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

for a in range(x + 1):
    tem = 2 * a + 4 * (x - a)
    if (tem == y):
        #  and (2 * x <= y <= 4 * x):
        print('Yes')
        exit()

print('No')

Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())

for a in range(x + 1):
    if (2 * a + 4 * (x - a) == y) and (2 * x <= y <= 4 * x):
        print('Yes')
        exit(1)

print('No')

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

for a in range(x + 1):
    tem = 2 * a + 4 * (x - a)
    if (tem == y):
        #  and (2 * x <= y <= 4 * x):
        print('Yes')
        exit()

print('No')

Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())

for a in range(x + 1):
    if  a == - y / 2 + x:
        print('Yes')
        exit(1)

print('No')


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

for a in range(x + 1):
    tem = 2 * a + 4 * (x - a)
    if (tem == y):
        #  and (2 * x <= y <= 4 * x):
        print('Yes')
        exit()

print('No')

Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())

for a in range(x + 1):
    if (2 * a + 4 * (x - a) == y):
        print('Yes')
        exit(1)

print('No')

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

for a in range(x + 1):
    tem = 2 * a + 4 * (x - a)
    if (tem == y):
        #  and (2 * x <= y <= 4 * x):
        print('Yes')
        exit()

print('No')
Buggy python submission (verdict: Runtime Error):
x, n = map(int, input().split())

if n != 0:
    p = list(map(int, input().split()))
else:
    print(x)
    exit(1)

dif = 100
ans = 0

for i in range(min(p) - 1, max(p) + 2):
    if not (i in p):
        if dif > abs(x - i):
            dif = abs(x - i)
            ans = i

print(ans)


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

if n != 0:
    p = list(map(int, input().split()))
else:
    print(x)
    exit()

dif = 100
ans = 0

for i in range(min(p) - 1, max(p) + 2):
    if not (i in p):
        if dif > abs(x - i):
            dif = abs(x - i)
            ans = i

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = a[0]

if 0 in a:
    ans = 0
else:
    for i in range(1, n):
        ans *= a[i]

if ans <= 10 ** 18:
    print(ans)
else:
    print(-1)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = a[0]

if 0 in a:
    ans = 0
else:
    for i in range(1, n):
        if ans <= 10 ** 18:
            ans *= a[i]
        else:
            break

if ans <= 10 ** 18:
    print(ans)
else:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = a[0]

for i in range(1, n):
    ans *= a[i]


if ans <= 10 ** 18:
    print(ans)
else:
    print(-1)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = a[0]

if 0 in a:
    ans = 0
else:
    for i in range(1, n):
        if ans <= 10 ** 18:
            ans *= a[i]
        else:
            break

if ans <= 10 ** 18:
    print(ans)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
k, n = map(int, input().split())
a = list(map(int, input().split()))
d = 0

for i in range(n-1):
    d = (d, a[i+1] - a[i])
d = (d, k - a[-1] + a[0])

print(K - d)

Fixed submission:
k, n = map(int, input().split())
a = list(map(int, input().split()))
d = 0

for i in range(n-1):
    d = max(d, a[i+1] - a[i])
d = max(d, k - a[-1] + a[0])

print(k - d)
Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = map(int, input().split())

x = []
cnt = 0
flag = True
while cnt < n:
    if flag:
        for j in range(a):
            if cnt + j >= n:
                break
            x.append(1)
        cnt += a
        flag = False
    else:
        for j in range(b):
            if cnt + j >= n:
                break
            x.append(0)
        cnt += b
        flag = True

cnt = 0
for i in range(n):
    if x[i] == 1:
        cnt += 1

print(cnt)


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

ans = n // (a + b) * a
rem = n % (a + b)
print(ans + min(rem, a))

Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())

x = [0] * n
cnt = 0
flag = True
while cnt < n:
    if flag:
        for j in range(a):
            if cnt + j >= n:
                break
            x[cnt + j] = 1
        cnt += a
        flag = False
    else:
        for j in range(b):
            if cnt + j >= n:
                break
            x[cnt + j] = 0
        cnt += b
        flag = True

cnt = 0
for i in range(n):
    if x[i] == 1:
        cnt += 1

print(cnt)


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

ans = n // (a + b) * a
rem = n % (a + b)
print(ans + min(rem, a))
Buggy python submission (verdict: Runtime Error):
import math

N = int(input())

a = math.floor(n / 1.08)
b = a + 1

aa = math.floor(a * 1.08)
bb = math.floor(b * 1.08)

if(aa == N):
    print(aa)
elif(bb == N):
    print(bb)
else:
    print(":(")

Fixed submission:
import math

N = int(input())

a = math.floor(N / 1.08)
b = a + 1

aa = math.floor(a * 1.08)
bb = math.floor(b * 1.08)

if(aa == N):
    print(a)
else:
    if(bb == N):
        print(b)
    else:
        print(":(")
Buggy python submission (verdict: Runtime Error):
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	ans := 0
	for i := 1; i < n; i++ {
		ans += i
	}

	fmt.Println(ans)
}

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

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

if n == 1:
    print(0)
    exit()
elif n == 2:
    print(1)
    exit()

ans = 0
for i in range(1, n):
    ans += i

print(ans)


Fixed submission:
n = int(input())
print(n*(n-1)//2)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
l, r = [0]*(m+1), [0]*(m+1)
for i in range(m):
    l[i], r[i] = map(int, input().split())

res = [i+1 for i in range(n)]

for i in range(m):
    if min(res) < l[i]:
        for j in range(min(res), l[i]):
            if j in res:
                res.remove(j)
    if max(res) > r[i]:
        for j in range(r[i]+1, max(res)+1):
            if j in res:
                res.remove(j)

print(len(res))

Fixed submission:
n, m = map(int, input().split())
l, r = [0]*m, [0]*m
for i in range(m):
    l[i], r[i] = map(int, input().split())

if max(l) <= min(r):
    print(min(r)-max(l)+1)
else:
    print('0')
Buggy python submission (verdict: Runtime Error):
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
cost_0, cost_n = 0, 0

if max(a) <= x or min(a) >= x:
    print(0)
    exit(1)

for i in range(1, x):
    if i in a:
        cost_0 += 1

for i in range(x + 1, n):
    if i in a:
        cost_n += 1

print(min(cost_0, cost_n))

Fixed submission:
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
cost_0, cost_n = 0, 0

# if max(a) <= x or min(a) >= x:
#     print(0)
#     exit(1)

for i in range(1, x):
    if i in a:
        cost_0 += 1

for i in range(x + 1, n):
    if i in a:
        cost_n += 1

print(min(cost_0, cost_n))

Buggy python submission (verdict: Runtime Error):
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
cost_0, cost_n = 0, 0

if max(a) <= x or min(a) >= x:
    print(0)
    exit(1)

for i in range(x + 1):
    if i in a:
        cost_0 += 1

for i in range(x, n + 1):
    if i in a:
        cost_n += 1

print(min(cost_0, cost_n))

Fixed submission:
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
cost_0, cost_n = 0, 0

# if max(a) <= x or min(a) >= x:
#     print(0)
#     exit(1)

for i in range(1, x):
    if i in a:
        cost_0 += 1

for i in range(x + 1, n):
    if i in a:
        cost_n += 1

print(min(cost_0, cost_n))
Buggy python submission (verdict: Runtime Error):
a, b, c, d = [0] * n, [0] * n, [0] * m, [0] * m
for i in range(n):
    a[i], b[i] = map(int, input().split())
for i in range(m):
    c[i], d[i] = map(int, input().split())

for i in range(n):
    min_dist, min_c = abs(a[0]-c[0]) + abs(b[0]-d[0]), 0
    for j in range(m):
        dist = abs(a[i]-c[j]) + abs(b[i]-d[j])
        if dist < min_dist:
            min_dist = dist
            min_c = j
    print(min_c+1)

Fixed submission:
n, m = map(int, input().split())
a, b, c, d = [0] * n, [0] * n, [0] * m, [0] * m
for i in range(n):
    a[i], b[i] = map(int, input().split())
for i in range(m):
    c[i], d[i] = map(int, input().split())

for i in range(n):
    min_dist, min_c = 10**9, -1
    for j in range(m):
        dist = abs(a[i]-c[j]) + abs(b[i]-d[j])
        if dist < min_dist:
            min_dist = dist
            min_c = j
    print(min_c+1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
res = 1
temp = 1

for i in range(1, N + 1):
    res = res * i

for i in range(9):
    temp = temp * 10
temp = temp + 7


print(res % temp)


Fixed submission:
N = int(input())
ans = 1

for i in range(1, N + 1):
    ans = (ans * i) % (10 ** 9 + 7)

print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, n = map(int, input().split())
print(b // x - (a - 1) // x)

Fixed submission:
a, b, x = map(int, input().split())
print(b // x - (a - 1) // x)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = map(int, input().split())

flag = 0
for i in range(a, b + 1):
    if i % x == 0:
        flag = flag + 1 
        break

if flag == 1:
    print((b - i) // x + flag)
else:
    print(0)

Fixed submission:
a, b, x = map(int, input().split())
print(b // x - (a - 1) // x)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = map(int, input().split())

count = 0
for i in range(a,b+1):
    if i % x == 0:
        count = count + 1

print(count)

Fixed submission:
a, b, x = map(int, input().split())
print(b // x - (a - 1) // x)
Buggy python submission (verdict: Runtime Error):
d = {"a": input(), "b": input(), "c": input()}

def func(s):
    if len(d[s]) == 0:
        return s.upper()
    next = d[s][0]
    d[s] = d[s][1:]
    return func(next)

print(func(a))

Fixed submission:
d = {"a": input(), "b": input(), "c": input()}

def func(s):
    if len(d[s]) == 0:
        return s.upper()
    next = d[s][0]
    d[s] = d[s][1:]
    return func(next)

print(func("a"))

Buggy python submission (verdict: Runtime Error):
d = {"a": input(), "b": input(), "c": input()}

def func(s):
    if len(d[s]) == 0:
        return upper()
    next = d[s][0]
    d[s] = d[s][1:]
    return func(next)

print(func(a))

Fixed submission:
d = {"a": input(), "b": input(), "c": input()}

def func(s):
    if len(d[s]) == 0:
        return s.upper()
    next = d[s][0]
    d[s] = d[s][1:]
    return func(next)

print(func("a"))
Buggy python submission (verdict: Runtime Error):
if int(input()) == 5 and int(input()) == 5 and int(input()) == 7:
    print('YES')
elif int(input()) == 5 and int(input()) == 7 and int(input()) == 5:
    print('YES')
elif int(input()) == 7 and int(input()) == 5 and int(input()) == 5:
    print('YES')
else: print('NO')



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

if i[0] == 5 and i[1] == 5 and i[2] == 7:
    print('YES')
elif i[0] == 5 and i[1] == 7 and i[2] == 5:
    print('YES')
elif i[0] == 7 and i[1] == 5 and i[2] == 5:
    print('YES')
else: print('NO')
Buggy python submission (verdict: Runtime Error):
for i in range(0, N+1):
    for j in range(0, N+1-i):
        if i == ((Y - 1000*N - 4000*j) / 9000):
            if (N-i-j) >= 0: print(str(i) + " " + str(j) + " " +str(N-i-j))
            exit()
print ("-1 -1 -1")

Fixed submission:
def calcPattern(N, Y):
    for i in range(0, N+1):
        for j in range(0, N+1):
            if i == ((Y - 1000*N - 4000*j) / 9000):
                if (N-i-j) >= 0: return (str(i) + " " + str(j) + " " +str(N-i-j))
    return ("-1 -1 -1")

n,y = map(int, input().split())
print(calcPattern(n,y))

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

for i in range(0, N+1):
  for j in range(0, N+1):
    if i == ((Y - 1000*N - 4000*j) / 9000):
      if (N-i-j) >= 0: print(str(i) + " " + str(j) + " " +str(N-i-j))
        return 0
print("-1 -1 -1")


Fixed submission:
def calcPattern(N, Y):
    for i in range(0, N+1):
        for j in range(0, N+1):
            if i == ((Y - 1000*N - 4000*j) / 9000):
                if (N-i-j) >= 0: return (str(i) + " " + str(j) + " " +str(N-i-j))
    return ("-1 -1 -1")

n,y = map(int, input().split())
print(calcPattern(n,y))
Buggy python submission (verdict: Runtime Error):
x = [int(v) for v in input().rstrip().split()
i = x.index(0)
print(i + 1)


Fixed submission:
x = [int(v) for v in input().rstrip().split()]
i = x.index(0)
print(i + 1)
Buggy python submission (verdict: Runtime Error):
def run():
	X, N = [int(v) for v in input().rstrip().split()]
	p = []
	if N > 0:
		p = [int(v) for v in input().rstrip().split()]

	i = -1
	try:
		i = p.index(X)
	except ValueError:
		pass

	if i == -1:
		# not contained	
		return X

	d1 = {}
	for k in range(1, 101):
		d1[k] = k

	for v in p:
		del d1[v]

	l2 = sorted(list(d1.keys()))

	l2.append(X)
	l2.sort()
	i = l2.index(X)

	r = 0
	if i == 0:
		r = l2[1]
	elif (i + 1) == len(l2):
		r = l2[-2]
	else:
		v1 = l2[i + 1] - X
		v2 = X - l2[i - 1]
		if v1 < v2 :
			r = l2[i + 1]
		elif v1 > v2 :
			r = l2[i - 1]
		else:
			# v1 == v2
			r = l2[i - 1]


	return r

r = run()
print(r)



Fixed submission:
def run():
	X, N = [int(v) for v in input().rstrip().split()]
	p = []
	if N > 0:
		p = [int(v) for v in input().rstrip().split()]

	i = -1
	try:
		i = p.index(X)
	except ValueError:
		pass

	if i == -1:
		# not contained	
		return X

	d1 = {}
	for k in range(0, 102):
		d1[k] = k

	for v in p:
		del d1[v]

	l2 = sorted(list(d1.keys()))

	l2.append(X)
	l2.sort()
	i = l2.index(X)

	r = 0
	if i == 0:
		r = l2[1]
	elif (i + 1) == len(l2):
		r = l2[-2]
	else:
		v1 = l2[i + 1] - X
		v2 = X - l2[i - 1]
		if v1 < v2 :
			r = l2[i + 1]
		elif v1 > v2 :
			r = l2[i - 1]
		else:
			# v1 == v2
			r = l2[i - 1]


	return r

r = run()
print(r)
Buggy python submission (verdict: Runtime Error):
n, m = list(map(int, input().rstrip().split()))
total = sum([int(i) for i in input().rstrip().split()])
result = -1 if n < total else n - total
print(result)

Fixed submission:
import math

r = int(input().rstrip())
print(r * 2 * math.pi)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = list(map(int, input().rstrip().split()))
for i in range(k):
    if a >= 1:
        a -= 1
    elif b >= 1:
        b -= 1
    else:
        break

print('{} {}'.format(a, b))



Fixed submission:
a, b, k = list(map(int, input().rstrip().split()))
if a > k:
    a -= k
    k = 0
else:
    # a <= k
    k -= a
    a = 0

if b > k:
    b -= k
else:
    # b <= k
    b = 0


print('{} {}'.format(a, b))