Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
W, H, x, y = map(int, input().split())

area = max(min((W - x) * H, x * H), min((H - y) * W, y * W))

num = 0

if (x, y) == (0, 0) or (x, y) == (W, H) or (x, y) == (W, 0) or (x, y) == (0, H):
    print((W * H) / 2, str(0))
    sys.exit()

if (y == (W / H) * x or y == H - (H / W) * x) and (x, y) != (W / 2, H / 2):
    print(W * H / 2, str(0))
    sys.exit()

if (x, y) == (W / 2, H / 2):
  	print(W * H / 2, str(1))
    sys.exit()


if min((W - x) * H, x * H) == min((H - y) * W, y * W):
    num = 1
else:
    num = 0

print(area, str(num))

Fixed submission:
from decimal import *
import sys
W, H, x, y = map(int, input().split())
num = 0
if 2 * x == W and 2 * y == H:
    num = 1

print(W * H / 2, num)

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

area = max(min((W - x) * H, x * H), min((H - y) * W, y * W))

num = 0

if (x, y) == (0, 0) or (x, y) == (W, H) or (x, y) == (W, 0) or (x, y) == (0, H):
    print((W * H) / 2, 0)
    sys.exit()

#直線上も加えよう
if abs(W / x) == abs(H / y) or y == H - (H / W) * x:
    print(W * H / 2, 0)
    sys.exit()
    


if min((W - x) * H, x * H) == min((H - y) * W, y * W):
    num = 1
else:
    num = 0

print(area, num)

Fixed submission:
from decimal import *
import sys
W, H, x, y = map(int, input().split())
num = 0
if 2 * x == W and 2 * y == H:
    num = 1

print(W * H / 2, num)
Buggy python submission (verdict: Runtime Error):
N = int(input())

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

A_sorted = sorted(A_list)

pos_count = len([a for a in A_sorted if a >= 0])
neg_count = len([a for a in A_sorted if a < 0])

output_list = [0] * (N - 1)
count = 0
for q in range(neg_count, N - 1):
    output_list[count] = [A_sorted[0], A_sorted[q]]
    count += 1
    A_sorted[0] -= A_sorted[q]


for i in range(neg_count):
    output_list[count] = [A_sorted[N - 1], A_sorted[i]]
    count += 1
    A_sorted[N - 1] -= A_sorted[i]

print(A_sorted[N - 1])
for item in output_list:
    print(item[0], item[1])

Fixed submission:
N = int(input())

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

A_sorted = sorted(A_list)

pos_count = len([a for a in A_sorted if a >= 0])
neg_count = len([a for a in A_sorted if a < 0])

if pos_count == 0:
    pos_count = 1
    neg_count = N - 1
if neg_count == 0:
    pos_count = N - 1
    neg_count = 1

output_list = [0] * (N - 1)
count = 0
for q in range(neg_count, N - 1):
    output_list[count] = [A_sorted[0], A_sorted[q]]
    count += 1
    A_sorted[0] -= A_sorted[q]


for i in range(neg_count):
    output_list[count] = [A_sorted[N - 1], A_sorted[i]]
    count += 1
    A_sorted[N - 1] -= A_sorted[i]

print(A_sorted[N - 1])
for item in output_list:
    print(item[0], item[1])
Buggy python submission (verdict: Runtime Error):
from math import abs
N = int(input())

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

total_list = [0] * N
for i in range(N):
    list_one = weight_list[: i + 1]
    list_two = weight_list[i + 1:]
    
    abs_diff = abs(sum(list_one) - sum(list_two))
    
    total_list[i] = abs_diff
print(min(total_list))

Fixed submission:
from math import fabs
N = int(input())

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

total_list = [0] * N
for i in range(N):
    list_one = weight_list[: i + 1]
    list_two = weight_list[i + 1:]
    
    abs_diff = fabs(sum(list_one) - sum(list_two))
    
    total_list[i] = abs_diff
print(int(min(total_list)))

Buggy python submission (verdict: Runtime Error):
from math import abs
N = int(input())

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

total_list = [0] * N
for i in range(N):
    list_one = weight_list[: i + 1]
    list_two = weight_list[i + 1:]
    
    abs_diff = math.abs(sum(list_one) - sum(list_two))
    
    total_list[i] = abs_diff
print(min(total_list))

Fixed submission:
from math import fabs
N = int(input())

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

total_list = [0] * N
for i in range(N):
    list_one = weight_list[: i + 1]
    list_two = weight_list[i + 1:]
    
    abs_diff = fabs(sum(list_one) - sum(list_two))
    
    total_list[i] = abs_diff
print(int(min(total_list)))
Buggy python submission (verdict: Runtime Error):
N, A, B, C, D = map(int, input().split())
S = str(input())

new_D = [S_new[1: D], '#', S_new[D + 1: N]]
_ = ''.join(new_D)

import re
regex = r'##+'
matchobj = re.match(regex, _)
regex_dot = r'..+'
match_dot = re.match(regex_dot, _[D:])
if matchobj is not None and match_dot is None:
    print('No')
else:
    print('Yes')

Fixed submission:
#これが一番できたやつ

import sys
N, A, B, C, D = map(int, input().split())
S = str(input())

if D > C:
    if '##' in S[B:D] or '##' in S[A:C]:
        print('No')
    else:
        print('Yes')
elif C > D:
    if '...' in S[B - 2: D + 1] and '##' not in S[A: C]:
        print('Yes')
    else:
        print('No')

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

new_D = [S_new[1: D], '#', S_new[D + 1: N]]
_ = ''.join(new_D)

import re
regex = r'##+'
matchobj = re.match(regex, _)
regex_dot = r'..+'
match_dot = re.match(regex_dot, _[D:])
if matchobj is not None and match_dot is None:
    print('No')
else:
    print('Yes')

Fixed submission:
#これが一番できたやつ

import sys
N, A, B, C, D = map(int, input().split())
S = str(input())

if D > C:
    if '##' in S[B:D] or '##' in S[A:C]:
        print('No')
    else:
        print('Yes')
elif C > D:
    if '...' in S[B - 2: D + 1] and '##' not in S[A: C]:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Runtime Error):
new_D = [S_new[1: D], '#', S_new[D + 1: N]]
_ = ''.join(new_D)

import re
regex = r'##+'
matchobj = re.match(regex, _)
regex_dot = r'..+'
match_dot = re.match(regex_dot, _[D:])
if matchobj is not None and match_dot is None:
    print('No')
else:
    print('Yes')

Fixed submission:
#これが一番できたやつ

import sys
N, A, B, C, D = map(int, input().split())
S = str(input())

if D > C:
    if '##' in S[B:D] or '##' in S[A:C]:
        print('No')
    else:
        print('Yes')
elif C > D:
    if '...' in S[B - 2: D + 1] and '##' not in S[A: C]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
    print('YES')

Fixed submission:
S = str(input())

circles = 0
crosses = 0

length = len(S)
rest = 15 - length


for i in S:
    if i == 'o':
        circles += 1
    else:
        crosses += 1

if rest + circles >= 8:
    print('YES')
else:
    print('NO')

Buggy python submission (verdict: Runtime Error):
S = str(input())

circles = 0
crosses = 0

for i in S:
    if S = 'o':
        circles += 1
    else:
        crosses += 1
if circles >= 8:
    print('YES')
else:
    print('NO')

Fixed submission:
S = str(input())

circles = 0
crosses = 0

length = len(S)
rest = 15 - length


for i in S:
    if i == 'o':
        circles += 1
    else:
        crosses += 1

if rest + circles >= 8:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

N = int(input())
S = [0] * N
P = [0] * N

city_point = {}

for i in range(N):
    inp = input().split()
    S[i] = inp[0]
    P[i] = inp[1]
    city_point[i] = {'city': S[i], 'point': int(P[i])}
    
sorted_list = sorted(city_point.items(), key=lambda x: (x[1]['city'], x[1]['point']))

for item in sorted_list:
    print(item[0] + 1)


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

apple_slices = A * 3 + P

print(apple_slices // 2)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

N = int(input())
S = [0] * N
P = [0] * N

city_point = {}

for i in range(N):
    inp = input().split()
    S[i] = inp[0]
    P[i] = inp[1]
    city_point[i] = {'city': S[i], 'point': int(P[i])}
    
sorted_list = sorted(city_point.items(), key=lambda x: (x[1]['city'], x[1]['point']))

for key in sorted_list:
    print(key + 1)


Fixed submission:
N = int(input())

cookbook = [0] * N

for n in range(N):
    line = input().split()
    s = line[0]
    p = int(line[1])
    cookbook[n] = (n + 1, s, p)

l = sorted(cookbook, key = lambda x: (x[1], -x[2]))
for item in l:
    print(item[0])
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
L = [0] * M
R = [0] * M
for i in range(M):
    L[i], R[i] = map(int, input().split())

all_lists = [list(range(L[i], R[i] + 1)) for i in range(M)]

new_set = set(all_lists[0])
for i in range(len(all_lists) - 1):
    if len(new_set) == 0:
        break
    new_set = new_set & set(all_lists[i + 1])

print(len(new_set))

Fixed submission:
import sys
A, B = map(int, input().split(' '))
if A >= 13:
    print(B)
elif A <= 12 and A >= 6:
    print(int(B / 2))
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
L = [0] * M
R = [0] * M
for i in range(M):
    L[i], R[i] = map(int, input().split())

all_lists = [list(range(L[i], R[i] + 1)) for i in range(M)]

new_set = set(all_lists[0])
for i in range(len(all_lists) - 1):
    if len(new_set) == 0:
        break
    new_set = new_set & set(all_lists[i + 1])

print(len(new_set))

Fixed submission:
N, M = map(int, input().split())
L = M * [0]
R = M * [0]
for i in range(M):
    Left, Right = map(int, input().split())
    L[i] = Left
    R[i] = Right

L_max = max(L)
R_min = min(R)

count = 0
for i in range(1, N + 1):
    if i >= L_max and i <= R_min:
        count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
L = [0] * M
R = [0] * M
for i in range(M):
    L[i], R[i] = map(int, input().split())

all_lists = [list(range(L[i], R[i] + 1)) for i in range(M)]

new_set = set(all_lists[0])
for i in range(len(all_lists) - 1):
    new_set = new_set & set(all_lists[i + 1])

print(len(new_set))

Fixed submission:
N, M = map(int, input().split())
L = M * [0]
R = M * [0]
for i in range(M):
    Left, Right = map(int, input().split())
    L[i] = Left
    R[i] = Right

L_max = max(L)
R_min = min(R)

count = 0
for i in range(1, N + 1):
    if i >= L_max and i <= R_min:
        count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
L = [0] * M
R = [0] * M
for i in range(M):
    L[i], R[i] = map(int, input().split())

all_lists = [list(range(L[i], R[i] + 1)) for i in range(M)]

def get_intersect(*arg):
    
    new_set = set(arg[0][0])
    for i in range(len(arg[0]) - 1):
        new_set = new_set & set(arg[0][i + 1])
    return new_set

print(len(get_intersect(all_lists)))

Fixed submission:
N, M = map(int, input().split())
L = M * [0]
R = M * [0]
for i in range(M):
    Left, Right = map(int, input().split())
    L[i] = Left
    R[i] = Right

L_max = max(L)
R_min = min(R)

count = 0
for i in range(1, N + 1):
    if i >= L_max and i <= R_min:
        count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

N, M = map(int, input().split())
A = [int(_) for _ in input().split()]
B = [0] * M
C = [0] * M
A.sort()
#print(A)
for m in range(M):
    b, c = map(int, input().split())
    index = bisect.bisect_right(A, c)
    #print(f'index >> {index}')
    if index > 0:
        if index - b < 0:
            A[:index] = [c] * index
        else:
            A[: index - b] = A[b: index]
            A[index - b: index] = [c] * b
    #print(A)

print(sum(A))

Fixed submission:
import sys
N, M = map(int, input().split())
A = [int(_) for _ in input().split()]
A.sort()
#print(A)
BC = [0] * M
for m in range(M):
    BC[m] = list(map(int, input().split()))
BC.sort(key=lambda x: x[1], reverse=True)
#print(BC)
c = 0
for m in range(M):
    for t in range(BC[m][0]):
        if BC[m][1] > A[c]:
            A[c] = BC[m][1]
        c += 1
        if c == N:
            print(sum(A))
            sys.exit()
print(sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, M = map(int, input().split())
A = np.array([int(_) for _ in input().split()])
B = [0] * M
C = [0] * M
A.sort()
for m in range(M):
    b, c = map(int, input().split())
    A[:b] = np.where(A[:b] < c, c, A[:b])

    A.sort()
    #print(A)
print(sum(A))

Fixed submission:
import sys
N, M = map(int, input().split())
A = [int(_) for _ in input().split()]
A.sort()
#print(A)
BC = [0] * M
for m in range(M):
    BC[m] = list(map(int, input().split()))
BC.sort(key=lambda x: x[1], reverse=True)
#print(BC)
c = 0
for m in range(M):
    for t in range(BC[m][0]):
        if BC[m][1] > A[c]:
            A[c] = BC[m][1]
        c += 1
        if c == N:
            print(sum(A))
            sys.exit()
print(sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = [int(_) for _ in input().split()]
B = [0] * M
C = [0] * M
for m in range(M):
    b, c = map(int, input().split())
    B[m] = b
    C[m] = c

A.sort()

for m in range(M):
    i = 0
    while i < B[m] and A[i] < C[m]:
        A[i] = C[m]
        i += 1
    A.sort()
print(sum(A))

Fixed submission:
import sys
N, M = map(int, input().split())
A = [int(_) for _ in input().split()]
A.sort()
#print(A)
BC = [0] * M
for m in range(M):
    BC[m] = list(map(int, input().split()))
BC.sort(key=lambda x: x[1], reverse=True)
#print(BC)
c = 0
for m in range(M):
    for t in range(BC[m][0]):
        if BC[m][1] > A[c]:
            A[c] = BC[m][1]
        c += 1
        if c == N:
            print(sum(A))
            sys.exit()
print(sum(A))
Buggy python submission (verdict: Runtime Error):
S = str(input())

front = int(S[:2])
back = int(S[2:4])

if front > 12 and back > 0 and back <= 12:
    print('YYMM')
elif front <=12 and front > 0 and back > 12:
    print('MMYY')
elif front == 0 or end == 0:
    print('NA')
else:
    print('AMBIGUOUS')

Fixed submission:
S = str(input())

front = int(S[:2])
back = int(S[2:4])

if (front == 0 or front > 12) and back > 0 and back <= 12:
    print('YYMM')
elif front <= 12 and front > 0 and (back == 0 or back > 12):
    print('MMYY')
elif (front <= 12 and front > 0) and (back > 0 and back <= 12):
    print('AMBIGUOUS')
else:
    print('NA')
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
c = input()
d = input()
e = input()
k = input()
if e - a > k:
  print(':(')
else:
  print('Yay')

Fixed submission:
a = input()
b = input()
c = input()
d = input()
e = input()
k = input()
if int(e) - int(a) <= int(k):
  print('Yay!')
else:
  print(':(')
Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = str(input())

for q in range(Q):
    q_list[q] = list(map(int, input().split()))

ac_list = [0] * len(S)
count = 0
for i in range(1, len(S)):
    if S[i - 1] == 'A' and S[i] == 'C':
        count += 1
        ac_list[i] = count
    else:
        ac_list[i] = count

for item in q_list:
    l, r = item[0], item[1]
    print(ac_list[r - 1] - ac_list[l - 1])

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

q_list = [0] * Q

for q in range(Q):
    q_list[q] = list(map(int, input().split()))

ac_list = [0] * len(S)
count = 0
for i in range(1, len(S)):
    if S[i - 1] == 'A' and S[i] == 'C':
        count += 1
        ac_list[i] = count
    else:
        ac_list[i] = count

for item in q_list:
    l, r = item[0], item[1]

    print(ac_list[r - 1] - ac_list[l - 1])

Buggy python submission (verdict: Runtime Error):
import math
N, Q = map(int, input().split())
S = str(input())

for q in range(Q):
    q_list[q] = list(map(int, input().split()))

ac_list = [0] * len(S)
count = 0
for i in range(1, len(S)):
    if S[i - 1] == 'A' and S[i] == 'C':
        count += 1
        ac_list[i] = count
    else:
        ac_list[i] = count
#print(ac_list)
for item in q_list:
    l, r = item[0], item[1]

    print(ac_list[r - 1] - ac_list[l - 1])

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

q_list = [0] * Q

for q in range(Q):
    q_list[q] = list(map(int, input().split()))

ac_list = [0] * len(S)
count = 0
for i in range(1, len(S)):
    if S[i - 1] == 'A' and S[i] == 'C':
        count += 1
        ac_list[i] = count
    else:
        ac_list[i] = count

for item in q_list:
    l, r = item[0], item[1]

    print(ac_list[r - 1] - ac_list[l - 1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = str(input())

q_list = [0] * Q

for q in range(Q):
    q_list[q] = list(map(int, input().split()))

for item in q_list:
    l, r = item[0], item[1]
    count = 0
    for i in range(l, r):
        if S[i - 1] == 'A' and S[i] == 'C':
            count += 1
    print(count)

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

q_list = [0] * Q

for q in range(Q):
    q_list[q] = list(map(int, input().split()))

ac_list = [0] * len(S)
count = 0
for i in range(1, len(S)):
    if S[i - 1] == 'A' and S[i] == 'C':
        count += 1
        ac_list[i] = count
    else:
        ac_list[i] = count

for item in q_list:
    l, r = item[0], item[1]

    print(ac_list[r - 1] - ac_list[l - 1])
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())

height_list = [0] * N

for n in range(N):
    height_list[n] = int(input())
height_list = sorted(height_list, reverse=True)

diff_list = [0] * (N - 2)

for i in range(N - 2):
    diff_list[i] = height_list[i] - height_list[i + K - 1]
print(min(diff_list))

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

height_list = [0] * N

for n in range(N):
    height_list[n] = int(input())
height_list = sorted(height_list, reverse=True)

diff_list = [0] * (N - K + 1)

for i in range(N - K + 1):
    diff_list[i] = height_list[i] - height_list[i + K - 1]
print(min(diff_list))
Buggy python submission (verdict: Runtime Error):

Copy
Copy
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
xyh.sort(key=lambda x:-x[2])
for cx in range(101):
    for cy in range(101):
        H = 0
        ok = True
        for i in range(N):
            x,y,h = xyh[i]
            if h != 0:
                if H == 0:
                    H = h+abs(cx-x)+abs(cy-y)
                else:
                    ok = H==h+abs(cx-x)+abs(cy-y)
            else:
                ok = abs(cx-x)+abs(cy-y)-H>=0
            if not ok:
                break
        if ok:
            break
    if ok:
        break
    
print('{} {} {}'.format(cx,cy,H))

Fixed submission:

N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
xyh.sort(key=lambda x:-x[2])
for cx in range(101):
    for cy in range(101):
        H = 0
        ok = True
        for i in range(N):
            x,y,h = xyh[i]
            if h != 0:
                if H == 0:
                    H = h+abs(cx-x)+abs(cy-y)
                else:
                    ok = H==h+abs(cx-x)+abs(cy-y)
            else:
                ok = abs(cx-x)+abs(cy-y)-H>=0
            if not ok:
                break
        if ok:
            break
    if ok:
        break
    
print('{} {} {}'.format(cx,cy,H))
Buggy python submission (verdict: Runtime Error):
N = int(input())
a_lis = list(map(int, input().split()))

maximum = max(a_lis)
minimum = min(a_lis)


new_mx = maximum - N + 1
count = [0] * (max(new_mx, minimum) + 1 - min(new_mx, minimum))
for num in range(min(new_mx, minimum), max(new_mx, minimum) + 1):
    tmp = 0
    for i in range(N):
        tmp += abs(a_lis[i] - num - i)
    count[num - min(new_mx, minimum)] = tmp
print(min(count))

Fixed submission:
from collections import Counter
from statistics import median
N = int(input())
a_lis = list(map(int, input().split()))

new_lis = [item - i - 1 for i, item in enumerate(a_lis)]

mode = median(new_lis)

count = 0
for i in range(N):
    count += abs(a_lis[i] - mode - i - 1)
    
print(int(count))
Buggy python submission (verdict: Runtime Error):
%%time
from collections import Counter

N = int(input())
S = input()

count_E = Counter(S)['E']
count_W = Counter(S)['W']

right = 0
left = count_E
tmp = N
for i in range(N):
    if right + left < tmp:
        tmp = right + left
    if S[i] == 'W':
        right += 1
    else:
        left -= 1
print(tmp)

Fixed submission:
from collections import Counter

N = int(input())
S = input()

count_E = Counter(S)['E']
count_W = Counter(S)['W']

right = 0
left = count_E
tmp = N
for i in range(N):
    if S[i] == 'E':
        left -= 1
    if right + left < tmp:
        tmp = right + left
    if S[i] == 'W':
        right += 1
print(tmp)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

N = int(input())
S = input()

tmp = N
for i in range(N):
    count_E = Counter(S[: i])['W']
    count_W = Counter(S[i + 1:])['E']
    if count_E + count_W < tmp:
        tmp = count_E + count_W
print(tmp)

Fixed submission:
from collections import Counter

N = int(input())
S = input()

count_E = Counter(S)['E']
count_W = Counter(S)['W']

right = 0
left = count_E
tmp = N
for i in range(N):
    if S[i] == 'E':
        left -= 1
    if right + left < tmp:
        tmp = right + left
    if S[i] == 'W':
        right += 1
print(tmp)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

N = int(input())
S = input()

ans_list = [0] * N
for i in range(N):
    count_E = Counter(S[: i])['W']
    count_W = Counter(S[i + 1:])['E']
    ans_list[i] = count_E + count_W
print(min(ans_list))

Fixed submission:
from collections import Counter

N = int(input())
S = input()

count_E = Counter(S)['E']
count_W = Counter(S)['W']

right = 0
left = count_E
tmp = N
for i in range(N):
    if S[i] == 'E':
        left -= 1
    if right + left < tmp:
        tmp = right + left
    if S[i] == 'W':
        right += 1
print(tmp)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

N = int(input())
S = input()

ans_list = [0] * N
for i in range(N):
    count_E = Counter(S[: i])['W']
    count_W = Counter(S[i + 1:])['E']
    ans_list[i] = count_E + count_W
print(min(ans_list))

Fixed submission:
from collections import Counter

N = int(input())
S = input()

count_E = Counter(S)['E']
count_W = Counter(S)['W']

right = 0
left = count_E
tmp = N
for i in range(N):
    if S[i] == 'E':
        left -= 1
    if right + left < tmp:
        tmp = right + left
    if S[i] == 'W':
        right += 1
print(tmp)
Buggy python submission (verdict: Time Limit Exceeded):
from statistics import median

N = int(input())
num_lis = [int(_) for _ in input().split()]

for i in range(N):
    print(median(num_lis[:i] + num_lis[i + 1:]))

Fixed submission:

N = int(input())
X = [int(_) for _ in input().split()]
tmp = sorted(X)

one = N // 2 - 1
two = N // 2

for x in X:
    if x <= tmp[one]:
        print(tmp[two])
    else:
        print(tmp[one])

Buggy python submission (verdict: Time Limit Exceeded):
from statistics import median

N = int(input())
num_lis = [int(_) for _ in input().split()]

for i in range(N):
    tmp = num_lis.copy()
    del tmp[i]
    print(median(tmp))

Fixed submission:

N = int(input())
X = [int(_) for _ in input().split()]
tmp = sorted(X)

one = N // 2 - 1
two = N // 2

for x in X:
    if x <= tmp[one]:
        print(tmp[two])
    else:
        print(tmp[one])

Buggy python submission (verdict: Time Limit Exceeded):
from statistics import median
from itertools import combinations

N = int(input())
num_lis = [int(_) for _ in input().split()]

for i in range(N):
    tmp = num_lis.copy()
    del tmp[i]
    print(median(tmp))

Fixed submission:

N = int(input())
X = [int(_) for _ in input().split()]
tmp = sorted(X)

one = N // 2 - 1
two = N // 2

for x in X:
    if x <= tmp[one]:
        print(tmp[two])
    else:
        print(tmp[one])

Buggy python submission (verdict: Time Limit Exceeded):
from statistics import median
from itertools import combinations

N = int(input())
num_lis = [int(_) for _ in input().split()]

for i in range(N):
    tmp = num_lis.copy()
    tmp.pop(i)
    print(median(tmp))

Fixed submission:

N = int(input())
X = [int(_) for _ in input().split()]
tmp = sorted(X)

one = N // 2 - 1
two = N // 2

for x in X:
    if x <= tmp[one]:
        print(tmp[two])
    else:
        print(tmp[one])