Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def min_cost(i, total):
    if i < 1:
        return 0

    total += min_cost(i - 1, abs(h[i] - h[i - 1]))
    total += min_cost(i - 2, abs(h[i] - h[i - 2]))
    return total


def chmin(a, b):
    if a > b:
        return b
    else:
        return a

      
N = int(input())
H = list(map(int, input().split(' ')))

dp = [10000] * 10000
dp[0] = 0

for i in range(1, N):
    dp[i] = chmin(dp[i], dp[i - 1] + abs(H[i] - H[i - 1]))
    if i > 1:
        dp[i] = chmin(dp[i], dp[i - 2] + abs(H[i] - H[i - 2]))

print(dp[N - 1])


Fixed submission:
N = int(input())
H = list(map(int, input().split(' ')))

dp = [100000000] * N
dp[0] = 0
dp[1] = abs(H[0] - H[1])

for i in range(2, N):
    dp[i] = min(dp[i - 1] + abs(H[i] - H[i - 1]), dp[i - 2] + abs(H[i] - H[i - 2]))

print(dp[N - 1])

Buggy python submission (verdict: Runtime Error):
def min_cost(i, total):
    if i < 1:
        return 0

    total += min_cost(i - 1, abs(h[i] - h[i - 1]))
    total += min_cost(i - 2, abs(h[i] - h[i - 2]))

    return total


def chmin(a, b):
    if a > b:
        return b
    else:
        return a


N = int(input())
H = list(map(int, input().split(' ')))

dp = [10000] * 10
dp[0] = 0  # 足場0のコストは0

for i in range(1, N):
    dp[i] = chmin(dp[i], dp[i - 1] + abs(H[i] - H[i - 1]))
    if i > 1:
        dp[i] = chmin(dp[i], dp[i - 2] + abs(H[i] - H[i - 2]))

print(dp[N - 1])


Fixed submission:
N = int(input())
H = list(map(int, input().split(' ')))

dp = [100000000] * N
dp[0] = 0
dp[1] = abs(H[0] - H[1])

for i in range(2, N):
    dp[i] = min(dp[i - 1] + abs(H[i] - H[i - 1]), dp[i - 2] + abs(H[i] - H[i - 2]))

print(dp[N - 1])
Buggy python submission (verdict: Runtime Error):
import math

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

pits = []

cost = 0

for i in range(0, N+1):
    pits.append(i)

half = int(len(pits) / 2)


if X == half:
    cost_r = 0
    cost_l = 0
    for a in A:
        # 右側
        if X < a:
            cost_r += 1
        # 左側
        if X > a:
            cost_l += 1
    cost = min(cost_l, cost_r)
elif half < X:
    for a in A:
        if X < a:
            count += 1
else:
    for a in A:
        if X > a:
            count += 1

print(cost)


Fixed submission:
N, M, X = map(int, input().split(' '))
A = list(map(int, input().split(' ')))

r_count = 0
l_count = 0

tmp_1 = X
tmp_2 = X


while tmp_1 != N:
    tmp_1 += 1
    if tmp_1 in A:
        r_count += 1

while tmp_2 != 0:
    tmp_2 -= 1
    if tmp_2 in A:
        l_count += 1


res = min(l_count, r_count)
print(res)

Buggy python submission (verdict: Runtime Error):
import math

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

pits = []

cost = 0

for i in range(0, N+1):
    pits.append(i)

half = int(len(pits) / 2)


# 真ん中
if X == half:
    cost_r = 0
    cost_l = 0
    for a in A:
        # 右側
        if X < a:
            cost_r += 1
        # 左側
        if X > a:
            cost_l += 1
    cost = min(cost_l, cost_r)
# 右側
elif half < X:
    for a in A:
        if X < a:
            count += 1
# 左側
else:
    for a in A:
        if X > a:
            count += 1

print(cost)

Fixed submission:
N, M, X = map(int, input().split(' '))
A = list(map(int, input().split(' ')))

r_count = 0
l_count = 0

tmp_1 = X
tmp_2 = X


while tmp_1 != N:
    tmp_1 += 1
    if tmp_1 in A:
        r_count += 1

while tmp_2 != 0:
    tmp_2 -= 1
    if tmp_2 in A:
        l_count += 1


res = min(l_count, r_count)
print(res)
Buggy python submission (verdict: Runtime Error):
H,W = map(int, input().split())

if H == 1:
    print(1)
elif W == 1: 
    print(1)
else:
    ans = H*(W // 2)
    if H % 2 == 1:
        if W % 2 == 0:
            ans += W // 2
        else:
            ans += W // 2 + 1
print(ans)


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

if W == 1:
    print(1)
elif H == 1:
    print(1)
else:
    ans = W * (H // 2)
    if H % 2 == 1:
        if W % 2 == 0:
            ans += W // 2
        else:
            ans += W // 2 + 1
    print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
X = List(map(int, input().split()))

def D(x, a):
    ans = 0
    for i in range(len(a)):
        ans += (x - a[i])**2
    return ans

for i in range(0, 101):
    if D(x, X) < D(i+1, X):
        print(D(i, X))
        break



Fixed submission:
N=int(input())
X=list(map(int,input().split()))
def D(x,a):
	ans=0
	for i in range(len(a)):
		ans+=(x-a[i])**2
	return ans
for i in range(0,101):
	if D(i,X)<D(i+1,X):
		print(D(i,X))
		break

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

def D(X,a):
	ans = 0
	for i in range(len(a)):
		ans += (x - a[i])**2
	return ans

for i in range(0,101):
	if D(i,X) < D(i+1,X):
		print(D(i,X))
		break

Fixed submission:
N=int(input())
X=list(map(int,input().split()))
def D(x,a):
	ans=0
	for i in range(len(a)):
		ans+=(x-a[i])**2
	return ans
for i in range(0,101):
	if D(i,X)<D(i+1,X):
		print(D(i,X))
		break

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

def D(X,a):
	ans = 0
	for i in range(len(a)):
		ans += (x - a[i])**2
	return ans

for i in range(0,101):
	if D(i,X) < D(i+1,X):
		print(D(i,X))
		break

Fixed submission:
N=int(input())
X=list(map(int,input().split()))
def D(x,a):
	ans=0
	for i in range(len(a)):
		ans+=(x-a[i])**2
	return ans
for i in range(0,101):
	if D(i,X)<D(i+1,X):
		print(D(i,X))
		break
Buggy python submission (verdict: Runtime Error):
N = int(input())
for i in raNge(N+1):
    if int(i*1.08)==N:
        primt(i)
        exit()
print(':(')


Fixed submission:
n=int(input())
for i in range(n+1):
    if int(i*1.08)==n:
        print(i)
        exit()
print(':(')

Buggy python submission (verdict: Runtime Error):
N = int(input())
for i in range(N+1):
    if int(i*1.08)==n:
        print(i)
        exit()
print(':(')


Fixed submission:
n=int(input())
for i in range(n+1):
    if int(i*1.08)==n:
        print(i)
        exit()
print(':(')

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

for i in range(N+1):
    if int(i*1.08)==n:
        print(i)
        exit()
print(':(')


Fixed submission:
n=int(input())
for i in range(n+1):
    if int(i*1.08)==n:
        print(i)
        exit()
print(':(')

Buggy python submission (verdict: Runtime Error):
n=int(input())
for i in range(n+1):
	if int(i*1.08)==n:
  		print(i)
    	exit()
print(':(')

Fixed submission:
n=int(input())
for i in range(n+1):
    if int(i*1.08)==n:
        print(i)
        exit()
print(':(')

Buggy python submission (verdict: Runtime Error):
n=int(input())
for i in range(n+1):
	if int(i*1.08)==n:
  	print(i)
    exit()
print(':(')

Fixed submission:
n=int(input())
for i in range(n+1):
    if int(i*1.08)==n:
        print(i)
        exit()
print(':(')
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())

ans = 0
consent = 1

while consent < B
    ans += 1
    consent -= 1
    consent -= A
print(ans)


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

ans = 0
consent = 1

while consent < B:
    ans += 1
    consent -= 1
    consent += A
print(ans)

Buggy python submission (verdict: Runtime Error):
zA, B = map(int, input().split())
 
ans = 0
consent = 1
 
while consent < B:
    ans += 1
    consent -= 1
    consent += A
print(ans)

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

ans = 0
consent = 1

while consent < B:
    ans += 1
    consent -= 1
    consent += A
print(ans)

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

K = 1
ans = 0

while(K < B):
	K -= 1
	L += A
	ans += 1

print(ans)

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

ans = 0
consent = 1

while consent < B:
    ans += 1
    consent -= 1
    consent += A
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b = map(str, input().split())

c = a + b
c = int(c)

for i in range(400)[1:]:
    if c = i**2:
        print('Yes')
        exit()

print('No')


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

c = a + b
c = int(c)

for i in range(400)[1:]:
    if c == i**2:
        print('Yes')
        exit()

print('No')

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

c = a + b
c = int(c)

for i in range(400)[1:]:
    if c = i**2:
        print('Yes')
        break

print('No')


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

c = a + b
c = int(c)

for i in range(400)[1:]:
    if c == i**2:
        print('Yes')
        exit()

print('No')
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
S = str(input())

total = 0
kaigai = 0

for i in range(0, len(S)):
    if L[i] == 'a':
        if total < A+B:
            print('Yes')
            total += 1
        else:
            print('No')
    elif L[i] == 'b':
        if total < A+B & kaigai <B:
            print('Yes')
            total += 1
            kaigai += 1
        else:
            print('No')
    else:
        print('No')


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

total = 0
kaigai = 0

for i in range(0, len(L)):
	if L[i] == 'a':
		if total < A + B:
			print('Yes')
			total += 1
		else:
			print('No')
	elif L[i] == 'b':
		if total < A + B and kaigai < B:
			print('Yes')
			total += 1
			kaigai += 1
		else:
			print('No')
	else:
		print('No')
Buggy python submission (verdict: Runtime Error):
input()
print(min(sum((x-p)**2 for x in map(int, input().split())) for p in range(101)))


Fixed submission:
def cal_cost(X, P):
    cost = 0
    for x in X:
        cost += (x - P) ** 2
    return cost


def main(N, X):
    return min(cal_cost(X, p) for p in range(max(X) + 1))


if __name__ == "__main__":
    N = int(input())
    X = list(map(int, input().split()))
    ans = main(N, X)
    print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
X = list(map(int, input().split()))
print(min(lambda p: sum((x-p)**2 for x in X) for i in range(max(X)+1)))


Fixed submission:
def cal_cost(X, P):
    cost = 0
    for x in X:
        cost += (x - P) ** 2
    return cost


def main(N, X):
    return min(cal_cost(X, p) for p in range(max(X) + 1))


if __name__ == "__main__":
    N = int(input())
    X = list(map(int, input().split()))
    ans = main(N, X)
    print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for _ in range(N)]

m1, m2 = sorted(A, reversed=True)[0:2]
for a in A:
    print(m2 if a == m1 else m1)

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]

mls = [-1 for _ in range(N+1)]
for i, a in enumerate(A, 1):
    mls[i] = max(mls[i-1], a)

mrs = [-1 for _ in range(N+1)]
for i, a in enumerate(A[::-1], 1):
    mrs[i] = max(mrs[i-1], a)
mrs = mrs[::-1]

for i in range(N):
    print(max(mls[i], mrs[i+1]))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]

for i, a in enumerate(A):
    print(max(A[:i] + A[i+1:]))


Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]

mls = [-1 for _ in range(N+1)]
for i, a in enumerate(A, 1):
    mls[i] = max(mls[i-1], a)

mrs = [-1 for _ in range(N+1)]
for i, a in enumerate(A[::-1], 1):
    mrs[i] = max(mrs[i-1], a)
mrs = mrs[::-1]

for i in range(N):
    print(max(mls[i], mrs[i+1]))
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

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

ans = 0
while(len(A) > 0):
    a = A.pop()
    b = (1 << a.bit_length()) - a
    i = bisect.bisect_left(A, b)
    if i < len(A) and A[i] == b:
        ans += 1
        A.pop(i)

print(ans)

Fixed submission:
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
c = Counter(A)

ans = 0
for a in A:
    b = (1 << a.bit_length()) - a
    if a == b and c[a] > 1:
        c[a] -= 2
        ans += 1
    elif a != b and c[a] > 0 and c[b] > 0:
        c[a] -= 1
        c[b] -= 1
        ans += 1

print(ans)

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

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

ans = 0
while(len(A) > 0):
    a = A[0]
    A.pop(0)
    for i in range(len(A)):
        if math.log2(A[i] + a).is_integer():
            ans += 1
            A.pop(i)
            break

print(ans)

Fixed submission:
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
c = Counter(A)

ans = 0
for a in A:
    b = (1 << a.bit_length()) - a
    if a == b and c[a] > 1:
        c[a] -= 2
        ans += 1
    elif a != b and c[a] > 0 and c[b] > 0:
        c[a] -= 1
        c[b] -= 1
        ans += 1

print(ans)

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

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

ans = 0
while(len(A) > 0):
    a = A[0]
    A = A[1:]
    for i in range(len(A)):
        if math.log2(A[i] + a).is_integer():
            ans += 1
            A.pop(i)
            break

print(ans)

Fixed submission:
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
c = Counter(A)

ans = 0
for a in A:
    b = (1 << a.bit_length()) - a
    if a == b and c[a] > 1:
        c[a] -= 2
        ans += 1
    elif a != b and c[a] > 0 and c[b] > 0:
        c[a] -= 1
        c[b] -= 1
        ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

def check_pow_two(n):
    while(n > 0):
        if n % 2 == 0:
            n //= 2
        elif n == 1:
            return True
        else:
            return False

ans = 0
while(len(A) > 0):
    a = A[0]
    A = A[1:]
    for i in range(len(A)):
        if check_pow_two(A[i] + a):
            ans += 1
            A.pop(i)
            break

print(ans)

Fixed submission:
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
c = Counter(A)

ans = 0
for a in A:
    b = (1 << a.bit_length()) - a
    if a == b and c[a] > 1:
        c[a] -= 2
        ans += 1
    elif a != b and c[a] > 0 and c[b] > 0:
        c[a] -= 1
        c[b] -= 1
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()

s = int((N - 1) / 2)
m = A[0:s+1]
M = A[s+1:][::-1]

n = N-1 if N % 2 == 1 else N
ans = [0 for _ in range(n)]

li = s
ri = s + 1

for i, (a, b) in enumerate(zip(m, M)):
    if i % 2 == 1:
        a, b = b, a
    ans[li] = a
    ans[ri] = b
    li -= 1
    ri += 1

if N % 2 == 1:
    if ans[0] < ans[-1]:
        ans = [m[-1]] + ans
    else:
        ans = ans + [m[-1]]

print(ans)

S = 0
for i, j in zip(ans[1:], ans[:-1]):
    S += abs(i - j)

print(S)

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()

if N % 2 == 0:
    c = N // 2
    S = -2 * sum(A[:c]) + 2 * sum(A[c:]) + A[c-1] - A[c]
else:
    c = (N-1) // 2
    tmp1 = -2 * sum(A[:c]) + 2 * sum(A[c+2:]) + A[c] + A[c+1]
    tmp2 = -2 * sum(A[:c-1]) + 2 * sum(A[c+1:]) - A[c-1] - A[c]
    S = max(tmp1, tmp2)

print(S)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()

s = int((N - 1) / 2)
m = A[0:s+1]
M = A[s+1:][::-1]

if N % 2 == 1:
    N -= 1
ans = [0 for _ in range(N)]

li = s
ri = s + 1

for i, (a, b) in enumerate(zip(m, M)):
    if i % 2 == 1:
        a, b = b, a
    ans[li] = a
    ans[ri] = b
    li -= 1
    ri += 1

if N % 2 == 1:
    if ans[0] < ans[-1]:
        ans = [m[-1]] + ans
    else:
        ans = ans + [m[-1]]

print(ans)

S = 0
for i, j in zip(ans[1:], ans[:-1]):
    S += abs(i - j)

print(S)

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()

if N % 2 == 0:
    c = N // 2
    S = -2 * sum(A[:c]) + 2 * sum(A[c:]) + A[c-1] - A[c]
else:
    c = (N-1) // 2
    tmp1 = -2 * sum(A[:c]) + 2 * sum(A[c+2:]) + A[c] + A[c+1]
    tmp2 = -2 * sum(A[:c-1]) + 2 * sum(A[c+1:]) - A[c-1] - A[c]
    S = max(tmp1, tmp2)

print(S)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()

s = int((N - 1) / 2)
m = A[0:s+1]
M = A[s+1:][::-1]

ans = [0 for _ in range(N)]

if (N - 7) % 4 == 0:
    flag = True

if (flag):
    li = s - 1
    ri = s + 1
else:
    li = s
    ri = s + 1

for i, (a, b) in enumerate(zip(m, M)):
    if i % 2 == 1:
        a, b = b, a
    ans[li] = a
    ans[ri] = b
    li -= 1
    ri += 1

if N % 2 == 1:
    if (flag):
        ans[-1] = m[-1]
    else:
        ans[0] = m[-1]

S = 0
for i, j in zip(ans[1:], ans[:-1]):
    S += abs(i - j)

print(S)


Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()

if N % 2 == 0:
    c = N // 2
    S = -2 * sum(A[:c]) + 2 * sum(A[c:]) + A[c-1] - A[c]
else:
    c = (N-1) // 2
    tmp1 = -2 * sum(A[:c]) + 2 * sum(A[c+2:]) + A[c] + A[c+1]
    tmp2 = -2 * sum(A[:c-1]) + 2 * sum(A[c+1:]) - A[c-1] - A[c]
    S = max(tmp1, tmp2)

print(S)
Buggy python submission (verdict: Runtime Error):
border = 101


def manhattan_distance(Cx, Cy, H, X, Y):
    return max(H - abs(X - Cx) - abs(Y - Cy), 0)


def judge_center(Cx, Cy, cords):
    for x, y, h in cords:
        if h > 0:
            H = abs(cords[0][0] - Cx) + abs(cords[0][1] - Cy) + cords[0][2]
            break
    for x, y, h in cords:
        tmp = manhattan_distance(Cx, Cy, H, x, y)
        if (h > 0 and H != tmp) or (h == 0 and H > tmp):
            return -1
    return H


def main():
    N = int(input())
    cords = [list(map(int, input().split(' '))) for _ in range(N)]

    for tmp_Cx in range(border):
        for tmp_Cy in range(border):
            h = judge_center(tmp_Cx, tmp_Cy, cords)
            if h != -1:
                print('{} {} {}'.format(tmp_Cx, tmp_Cy, h))
                return 0


if __name__ == '__main__':
    main()


Fixed submission:
N = int(input())


if N == 1:
    print("Hello World")
else:
    A = int(input())
    B = int(input())
    print(A+B)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = int(input())
B = int(input())

if N == 1:
    print("Hello World")
else:
    print(A+B)


Fixed submission:
N = int(input())


if N == 1:
    print("Hello World")
else:
    A = int(input())
    B = int(input())
    print(A+B)
Buggy python submission (verdict: Runtime Error):
import fraction

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

min_distance = abs(x[0] - X)
for i in x: min_distance = fraction.gcd(abs(i - X), min_distance)

print(min_distance)


Fixed submission:
import fractions

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

min_distance = abs(x[0] - X)
for i in x: min_distance = fractions.gcd(abs(i - X), min_distance)

print(min_distance)

Buggy python submission (verdict: Runtime Error):
import math

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

min_distance = abs(x[0] - X)
for i in x: min_distance = math.gcd(abs(i - X), min_distance)

print(min_distance)


Fixed submission:
import fractions

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

min_distance = abs(x[0] - X)
for i in x: min_distance = fractions.gcd(abs(i - X), min_distance)

print(min_distance)

Buggy python submission (verdict: Runtime Error):
import math

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

min_distance = abs(x[0] - X)
for i in x[1:]: min_distance = math.gcd(abs(i - X), min_distance)

print(min_distance)


Fixed submission:
import fractions

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

min_distance = abs(x[0] - X)
for i in x: min_distance = fractions.gcd(abs(i - X), min_distance)

print(min_distance)
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())

s = ''
for i in S:
    s += i
    if i != '1':
        break

if K > len(s):
    print(s[-1])
else:
    print(s[K])


Fixed submission:
S = input()
K = int(input())

s = ''
for i in S:
    s += i
    if i != '1':
        break

if K < len(s):
    print(s[K-1])
else:
    print(s[-1])
Buggy python submission (verdict: Runtime Error):
N = input()
if N % sum([int(i) for i in str(N)]) == 0: print('Yes')
else: print('No')

Fixed submission:
N = int(input())
S =  sum((int(i) for i in str(N)))
if N % S == 0: print('Yes')
else: print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

score = N + 1
a = [S[:i].count('W') + S[i+1:].count('E') for i in range(N)]
print(min(a))


Fixed submission:
N = int(input())
S = input()

w = 0
e = S[1:].count('E')
score = w + e

for i in range(1, N):
    if S[i] == 'E':
        e -= 1
    if S[i-1] == 'W':
        w += 1
    score = min(score, w + e)

print(score)

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

score = N + 1
for i in range(N):
    l = S[:i]
    r = S[i+1:]
    score = min(score, l.count('W') + r.count('E'))

print(score)

Fixed submission:
N = int(input())
S = input()

w = 0
e = S[1:].count('E')
score = w + e

for i in range(1, N):
    if S[i] == 'E':
        e -= 1
    if S[i-1] == 'W':
        w += 1
    score = min(score, w + e)

print(score)
Buggy python submission (verdict: Runtime Error):
A, B, C, X, Y = map(int, input().split())

if A + B > 2 * C:
    if A < B:
        ans = 2 * C * Y + min(A, 2 * C) * max((X - Y), 0)
    else:
        ans = 2 * C * X + min(B, 2 * C) * max((Y - X), 0)
else:
    ans = A * X + B * Y

print(ans)

Fixed submission:
S = input()
ans = 700 + S.count('o') * 100
print(ans)
Buggy python submission (verdict: Runtime Error):
print('Yes' len(set(input())) == 3 else 'No')

Fixed submission:
S = sorted(input())
if S[0] == 'a' and S[1] == 'b' and S[2] == 'c': print('Yes')
else: print('No')
Buggy python submission (verdict: Time Limit Exceeded):
A, B, K = map(int, input().split())

tmp = [i for i in range(A, B+1)]
for i in sorted(set(tmp[:K] + tmp[B-A-K+1:])):
    print(i)

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

i = 0
tmp = A
while i < K and tmp <= B:
    ans.add(tmp)
    tmp += 1
    i += 1

i = 0
tmp = B
while i < K and A <= tmp:
    ans.add(tmp)
    tmp -= 1
    i += 1

for i in sorted(ans):
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    A, B, K = map(int, input().split(' '))
    l = B + 1 - A
    for i, x in enumerate(range(A, B+1), 1):
        if i <= K or l - i < K:
            print(x)

if __name__ == '__main__':
    main()


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

i = 0
tmp = A
while i < K and tmp <= B:
    ans.add(tmp)
    tmp += 1
    i += 1

i = 0
tmp = B
while i < K and A <= tmp:
    ans.add(tmp)
    tmp -= 1
    i += 1

for i in sorted(ans):
    print(i)