Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

ans = N
for n in range(0, N):
  west_side = S[:n].count('W')
  east_side = S[n+1:].count('E')
  
  ans = min(ans, west_side+east_side)
  
print(ans)

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

w_cusum_list = []
w = 0
for i in range(N):
  if S[i] == 'W':
    w += 1
  w_cusum_list.append(w)
    
e_cusum_list = []
e = 0
for i in range(1, N):
  if S[-i] == 'E':
    e += 1
  e_cusum_list.append(e)

minn = min(w_cusum_list[-1], e_cusum_list[-1])
for i in range(1, N):
  sumn = w_cusum_list[i-1] + e_cusum_list[N-i-1]
  if minn > sumn:
    minn = sumn

print(minn)

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

ans = N
for n in range(0, N):
  leader = S[n]
  west_side = [s for s in S[:n] if s == 'W']
  east_side = [s for s in S[n+1:] if s == "E"]
  
  ans = min(ans, (len(west_side) + len(east_side)))
  
print(ans)

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

w_cusum_list = []
w = 0
for i in range(N):
  if S[i] == 'W':
    w += 1
  w_cusum_list.append(w)
    
e_cusum_list = []
e = 0
for i in range(1, N):
  if S[-i] == 'E':
    e += 1
  e_cusum_list.append(e)

minn = min(w_cusum_list[-1], e_cusum_list[-1])
for i in range(1, N):
  sumn = w_cusum_list[i-1] + e_cusum_list[N-i-1]
  if minn > sumn:
    minn = sumn

print(minn)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = list(input())

ans = n
for i in range(len(s)):
	ans = min(ans, s[:i][:-1].count("W") + s[i:].count("E"))
	
print(ans)

Fixed submission:
a, b = map(int, input().split())
print(max(a+b, a-b, a*b))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())

ans = n
for i in range(len(s)):
	ans = min(ans, s[:i][:-1].count("W") + s[i:].count("E"))
	
print(ans)

Fixed submission:
n=int(input())
s=input()
m=n+5
w=0
e=0
for i in range(1,n):
    if s[i]=='E':
        e+=1
m=min(m,w+e)
for i in range(1,n):
    if s[i-1]=='W':
        w+=1
    if s[i]=='E':
        e-=1
    m=min(m,w+e)
print(m)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = n
for i in range(n):
	ans = min(ans, s[:i][:-1].count("W") + s[i:].count("E"))
	
print(ans)


Fixed submission:
n=int(input())
s=input()
m=n+5
w=0
e=0
for i in range(1,n):
    if s[i]=='E':
        e+=1
m=min(m,w+e)
for i in range(1,n):
    if s[i-1]=='W':
        w+=1
    if s[i]=='E':
        e-=1
    m=min(m,w+e)
print(m)
Buggy python submission (verdict: Runtime Error):
x,y = map(int, input().split())
if a*b %2 = 0: print("Even")
if a*b %2 = 1: print("Odd")

Fixed submission:
a,b = map(int, input().split())
if a*b %2 == 0: print("Even")
if a*b %2 == 1: print("Odd")
Buggy python submission (verdict: Runtime Error):
# input
a, b = (int(i) for i in input().split())

def calc(a, b):
    r1 = a + b
    r2 = a - b
    r3 = a * b

    if r1 >= r2 and r1 >= r3:
        return r1
    elif r1 =< r2 and r2 >= r3:
        return r2
    elif r1 =< r3 and r2 =< r3:
        return r3

# output
print(calc(a, b))

Fixed submission:
# input
a, b = (int(i) for i in input().split())

# output
print(max(a+b,a-b,a*b))
Buggy python submission (verdict: Runtime Error):
# input
x, y = map(int, input().split())

# main
c = 0
while x <= y:
    x *= 2
    c += 1

print(count)

Fixed submission:
# coding: utf-8

# input
x, y = map(int, input().split())

# main
li = []
while x <= y:
    li.append(x)
    x *= 2

print(len(li))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split()]

ans = 0
r=0
xor_temp = 0
sum_temp = 0
for l in range(N):
	while r<N and (xor_temp^A[r] == sum_temp+A[r]):
		xor_temp = xor_temp^A[r]
		sum_temp = sum_temp+A[r]
		r += 1
	xor_temp = xor_temp^A[l]
	sum_temp = sum_temp-A[l]
	ans += r-l
print (ans)


Fixed submission:
a, b = map(int,input().split())
sum=a+b
sub=a-b
mul=a*b
if (sum>sub):
    if (sum>mul):
        print(sum)
    else:
       print(mul)
else: 
    if (sub>mul):
        print(sub)
    else:
        print(mul)
Buggy python submission (verdict: Time Limit Exceeded):
num=int(input())
word=str(input())
n_th = 3*10^5
for i in range(num):
	n=word[:i].count('W')+word[i+1:].count('E')
	if n_th > n:
		n_th = n
print ( n_th)


Fixed submission:
num=int(input())
word=str(input())
w=[0]
e=[0]
if word[0]=='W':
	w=[1]
	e=[0]
else:
	w=[0]
	e=[1]
for i in range(1,num):
	if word[i]=='W':
		w.append(w[i-1]+1)
		e.append(e[i-1])
	else:
		w.append(w[i-1])
		e.append(e[i-1]+1)
n_th=e[num-1]
for i in range(1,num):
	n=w[i-1]+e[num-1]-e[i]
	if n_th>n:
		n_th=n

print (n_th)

Buggy python submission (verdict: Time Limit Exceeded):
num=int(input())
word=str(input())
n_th = 3*10^5
for i in range(num):
	n=0
	for a in word[:i]:
		if a == 'W':
			n += 1
	for a in word[i+1:]:
		if a == 'E':
			n +=1
	if n_th > n:
		n_th = n
print ( n_th)

Fixed submission:
num=int(input())
word=str(input())
w=[0]
e=[0]
if word[0]=='W':
	w=[1]
	e=[0]
else:
	w=[0]
	e=[1]
for i in range(1,num):
	if word[i]=='W':
		w.append(w[i-1]+1)
		e.append(e[i-1])
	else:
		w.append(w[i-1])
		e.append(e[i-1]+1)
n_th=e[num-1]
for i in range(1,num):
	n=w[i-1]+e[num-1]-e[i]
	if n_th>n:
		n_th=n

print (n_th)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split())

ans = 0
r=0
xor_temp = 0
sum_temp = 0
for l in range(N):
	while r<N and (xor_temp^A[r] == sum_temp+A[r]):
		xor_temp = xor_temp^A[r]
		sum_temp = sum_temp+A[r]
		r += 1
	xor_temp = xor_temp^A[l]
	sum_temp = sum_temp-A[l]
	ans += r-l
print (ans)


Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]

ans = 0
r=0
xor_temp = 0
sum_temp = 0
for l in range(N):
	while r<N and (xor_temp^A[r] == sum_temp+A[r]):
		xor_temp = xor_temp^A[r]
		sum_temp = sum_temp+A[r]
		r += 1
	xor_temp = xor_temp^A[l]
	sum_temp = sum_temp-A[l]
	ans += r-l
print (ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(x) for x in input().split()]
 
ans = 0
for l in range(N):
	xor_temp = A[l]
	sum_temp = A[l]
	ans += 1
	r=l+1
	while r<N and (xor_temp^A[r] == sum_temp+A[r]):
		xor_temp = xor_temp^A[r]
		sum_temp = sum_temp+A[r]
		ans += 1
		r += 1
print (ans)

Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]

ans = 0
r=0
xor_temp = 0
sum_temp = 0
for l in range(N):
	while r<N and (xor_temp^A[r] == sum_temp+A[r]):
		xor_temp = xor_temp^A[r]
		sum_temp = sum_temp+A[r]
		r += 1
	xor_temp = xor_temp^A[l]
	sum_temp = sum_temp-A[l]
	ans += r-l
print (ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split())

ans = 0
for l in range(N):
	xor_temp = A[l]
	sum_temp = A[l]
	ans += 1
	r=l+1
	while r<N and (xor_temp^A[r] == sum_temp+A[r]):
		xor_temp = xor_temp^A[r]
		sum_temp = sum_temp+A[r]
		ans += 1
		r += 1
print (ans)


Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]

ans = 0
r=0
xor_temp = 0
sum_temp = 0
for l in range(N):
	while r<N and (xor_temp^A[r] == sum_temp+A[r]):
		xor_temp = xor_temp^A[r]
		sum_temp = sum_temp+A[r]
		r += 1
	xor_temp = xor_temp^A[l]
	sum_temp = sum_temp-A[l]
	ans += r-l
print (ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
p=[]
for i in range (n):
	p.append(int(input()))
pos=0
num=0
n_th = 0
s={}
for i in p:
	if i-1 in s:
		s[i]=s[i-1]+1
	else:
		s[i]=1
print(n-max(s.values()))

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

if k%2==1:
    print(b-a)
else:
    print(a-b)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,k =map(int,input().split())
for i in range(k):
	d = c
	c = b+a
	b = a+d
	a = b+c-2*a
r =a-b
if abs(a-b)>10^18:
	print('Unfair')
else:
	print(a-b)


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

if k%2==1:
    print(b-a)
else:
    print(a-b)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,k =map(int,input().split())
for i in range(k):
	e = b+c
	f = a+b
	g = a+c
	a = e
	c = f
	b = g
r =a-b
if abs(a-b)>10^18:
	print('Unfair')
else:
	print(a-b)


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

if k%2==1:
    print(b-a)
else:
    print(a-b)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
p=[]
for i in range (n):
	p.append(int(input()))
pos=0
num=0
n_th = 0
for i in range(n):
	if i+1 in p[pos:]:
		num += 1
		pos = p[pos:].index(i+1)+pos
	else:
		if num>n_th:
			n_th = num
		if i+1 in p:
			num = 1
			pos = p.index(i+1)
if num >n_th:
	print (n-num)
else:
	print(n-n_th)


Fixed submission:
n=int(input())
p=[]
for i in range (n):
	p.append(int(input()))
pos=0
num=0
n_th = 0
s={}
for i in p:
	if i-1 in s:
		s[i]=s[i-1]+1
	else:
		s[i]=1
print(n-max(s.values()))

Buggy python submission (verdict: Runtime Error):
n=int(input())
p=[]
for i in range (n):
	p.append(int(input()))
pos=0
num=0
n_th = 0
for i in range(n)
	if i+1 in p[pos:]:
		num += 1
		pos = p[pos:].index(i+1)+pos
	else:
		if num>n_th:
			n_th = num
		if i+1 in p:
			num = 1
			pos = p.index(i+1)
if num >n_th:
	print (n-num)
else:
	print(n-n_th)

Fixed submission:
n=int(input())
p=[]
for i in range (n):
	p.append(int(input()))
pos=0
num=0
n_th = 0
s={}
for i in p:
	if i-1 in s:
		s[i]=s[i-1]+1
	else:
		s[i]=1
print(n-max(s.values()))
Buggy python submission (verdict: Runtime Error):
S = str(input())
K = int(input())

sub = set()
for i in range(1,min(K, len(S))+1):
    for j in range(len(S)-K+1):
        sub.add(S[j:j+i])
m=list(sub)
m.sort()
print(m[K-1])

Fixed submission:
S = str(input())
K = int(input())
 
sub = set()
for i in range(1,min(K, len(S))+1):
    for j in range(len(S)-i+1):
        sub.add(S[j:j+i])
m=list(sub)
m.sort()
print(m[K-1])

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

sub = set()
for i in range(len(S)):
    for j in range(i,len(S)):
        sub.add(S[i:j+1])
m=list(sub)
m.sort()
print(m[K-1])

Fixed submission:
S = str(input())
K = int(input())
 
sub = set()
for i in range(1,min(K, len(S))+1):
    for j in range(len(S)-i+1):
        sub.add(S[j:j+i])
m=list(sub)
m.sort()
print(m[K-1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(int(i) for i in input().split())
B = []
B.append(0)
n = 1
cnt = 0

for i in A:
    B[0] += i
    B.append(B[0])
B[0] = 0
B.sort()

for i in range(1,N+1):
    if B[i] == B[i-1]:
        n += 1
    else:
        cnt += int(n*(n-1)/2)
        n = 1

cnt += int(n*(n-1)/2)6

print(cnt)

Fixed submission:
N = int(input())
A = list(int(i) for i in input().split())
B = []
B.append(0)
n = 1
cnt = 0

for i in A:
    B[0] += i
    B.append(B[0])
B[0] = 0
B.sort()

for i in range(1,N+1):
    if B[i] == B[i-1]:
        n += 1
    else:
        cnt += int(n*(n-1)/2)
        n = 1

cnt += int(n*(n-1)/2)

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(int(i) for i in input().split())
cnt = 0
n = 0

for i in range(N):
    for j in range(i, N):
        n += A[j]
        if n == 0:
            cnt += 1
    n = 0

print(cnt)
    

Fixed submission:
N = int(input())
A = list(int(i) for i in input().split())
B = []
B.append(0)
n = 1
cnt = 0

for i in A:
    B[0] += i
    B.append(B[0])
B[0] = 0
B.sort()

for i in range(1,N+1):
    if B[i] == B[i-1]:
        n += 1
    else:
        cnt += int(n*(n-1)/2)
        n = 1

cnt += int(n*(n-1)/2)

print(cnt)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(int(i) for i in input().split())
A.insert(0, 0)
A.append(0)
Q = 0
j=0

for i in range(N):
    while j < N + 1:
        if j == i:
            Q += abs(A[j] - A[j+2])
            j += 1
        else:
            Q += abs(A[j] - A[j+1])
        j += 1
    print("%d" % (Q))
    Q = 0
    j = 0

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
D = int(input())

if A > B:
    if C > D:
        print("%d" % (B+D))
    else:
        print("%d" % (B+C))
else:
    if C > D:
        print("%d" % (A+D))
    else:
        print("%d" % (A+C))

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

N = int(input())
A = list(int(i) for i in input().split())
A.insert(0, 0)
A.append(0)
B = copy.deepcopy(A)
Q = 0

for i in range(N):
    A.pop(i+1)
    for j in range(N):            
        Q += abs(A[j] - A[j+1])
    print("%d" % (Q))
    Q = 0
    A = copy.deepcopy(B)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
D = int(input())

if A > B:
    if C > D:
        print("%d" % (B+D))
    else:
        print("%d" % (B+C))
else:
    if C > D:
        print("%d" % (A+D))
    else:
        print("%d" % (A+C))
Buggy python submission (verdict: Time Limit Exceeded):
import copy

N = int(input())
A = list(int(i) for i in input().split())
A.insert(0, 0)
A.append(0)
B = copy.deepcopy(A)
Q = 0

for i in range(N):
    A.pop(i+1)
    for j in range(N):            
        Q += abs(A[j] - A[j+1])
    print("%d" % (Q))
    Q = 0
    A = copy.deepcopy(B)

Fixed submission:
N = int(input())
A = list(int(i) for i in input().split())
A.insert(0, 0)
A.append(0)

Sum = 0
Ans = 0

for i in range(len(A) - 1):
    Sum += abs(A[i+1] - A[i])

for i in range(N):
    Ans = Sum
    Ans = Ans - abs(A[i+1] - A[i]) - abs(A[i+2] - A[i+1]) + abs(A[i+2] - A[i])
    print("%d" % (Ans))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(int(i) for i in input().split())
A.insert(0, 0)
A.append(0)
Q = 0
j=0

for i in range(N):
    while j < N + 1:
        if j == i:
            Q += abs(A[j] - A[j+2])
            j += 1
        else:
            Q += abs(A[j] - A[j+1])
        j += 1
    print("%d" % (Q))
    Q = 0
    j = 0

Fixed submission:
N = int(input())
A = list(int(i) for i in input().split())
A.insert(0, 0)
A.append(0)

Sum = 0
Ans = 0

for i in range(len(A) - 1):
    Sum += abs(A[i+1] - A[i])

for i in range(N):
    Ans = Sum
    Ans = Ans - abs(A[i+1] - A[i]) - abs(A[i+2] - A[i+1]) + abs(A[i+2] - A[i])
    print("%d" % (Ans))
Buggy python submission (verdict: Runtime Error):
a, b map(int, input().split())
c=a+b
d=a-b
e=a*b
print(max([c,d,e]))

Fixed submission:
a, b = map(int, input().split())
c=a+b
d=a-b
e=a*b
print(max([c,d,e]))

Buggy python submission (verdict: Runtime Error):
C = A+B
D = A-B
E = A*B
print (max([C,D,E]))

Fixed submission:
a, b = map(int, input().split())
c=a+b
d=a-b
e=a*b
print(max([c,d,e]))

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(input().rstrip())

count_list = []
for i in range(N):
    count = 0
    for j in range(i):
        if S[j] == 'W':
            count += 1
    for j in range(N-i-1):
        if S[i+j+1] == 'E':
            count += 1

    
    count_list.append(count)

print(min(count_list))

Fixed submission:
a = input().rstrip().split()
A = int(a[0])
B = int(a[1])

print(max(A+B, A-B,A*B))
Buggy python submission (verdict: Runtime Error):
numbers = map(int, raw_input().split())
a = numbers[0]
b = numbers[1]
i = 1
while True:
    if a != i:
        i += 1
        continue
    else:
        if b < i:
            print(i - 1)
            break
        else:
            print(i)
            break

Fixed submission:
numbers = input().split()
a = int(numbers[0])
b = int(numbers[1])
i = 1
while True:
    if a != i:
        i += 1
        continue
    else:
        if b < i:
            print(i - 1)
            break
        else:
            print(i)
            break

Buggy python submission (verdict: Time Limit Exceeded):
numbers = input().split()
a = numbers[0]
b = numbers[1]
i = 1
while True:
    if a != i:
        i += 1
        continue
    else:
        if b < i:
            print(i - 1)
            break
        else:
            print(i)
            break


Fixed submission:
numbers = input().split()
a = int(numbers[0])
b = int(numbers[1])
i = 1
while True:
    if a != i:
        i += 1
        continue
    else:
        if b < i:
            print(i - 1)
            break
        else:
            print(i)
            break

Buggy python submission (verdict: Time Limit Exceeded):
numbers = input().split()
a = numbers[0]
b = numbers[1]
i = 1
while True:
    if a != i:
        i += 1
        continue
    else:
        if b < i:
            print(i - 1)
        else:
            print(i)
        
        break

Fixed submission:
numbers = input().split()
a = int(numbers[0])
b = int(numbers[1])
i = 1
while True:
    if a != i:
        i += 1
        continue
    else:
        if b < i:
            print(i - 1)
            break
        else:
            print(i)
            break
Buggy python submission (verdict: Runtime Error):
import sys 
import numpy as np

N = int(sys.stdin.readline())
P = np.array([int(x) for x in sys.stdin.readline().split()])

SUM = np.sum([np.sum([min(P[l:r+1]) for r in range(l, N)]) for l in range(N)])

print(SUM)  

Fixed submission:
line = input()

ori = len(line)

count = 0 

T = 0 
S = 0 

for i in line:
    if i is "S":
        S += 1
    else:
        if S is not 0:
            S -= 1
            count += 1

print(ori - count * 2)

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

N = int(sys.stdin.readline())
P = np.array([int(x) for x in sys.stdin.readline().split()])

SUM = np.sum([np.sum([np.min(P[l:r+1]) for r in range(l, N)]) for l in range(N)])

print(SUM)

Fixed submission:
line = input()

ori = len(line)

count = 0 

T = 0 
S = 0 

for i in line:
    if i is "S":
        S += 1
    else:
        if S is not 0:
            S -= 1
            count += 1

print(ori - count * 2)

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

N = int(sys.stdin.readline())
P = np.array([int(x) for x in sys.stdin.readline().split()])

SUM = np.sum([np.sum([min(P[l:r+1]) for r in range(l, N)]) for l in range(N)])

print(SUM)

Fixed submission:
line = input()

ori = len(line)

count = 0 

T = 0 
S = 0 

for i in line:
    if i is "S":
        S += 1
    else:
        if S is not 0:
            S -= 1
            count += 1

print(ori - count * 2)

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

ori = len(line)

count = 0 

while line.count("ST") is not 0:
    line = line.replace("ST", "") 

print(len(line))

Fixed submission:
line = input()

ori = len(line)

count = 0 

T = 0 
S = 0 

for i in line:
    if i is "S":
        S += 1
    else:
        if S is not 0:
            S -= 1
            count += 1

print(ori - count * 2)
Buggy python submission (verdict: Runtime Error):
c500 = int(input())
c100 = int(input())
c500 = int(input())
t = int(input())
s = 0

for a in range(0, c500 + 1):
    for b in range(0, c100 + 1):
        for c in range(0, c50 + 1):
            if 500*a + 100*b + 50*c == t:
                s = s + 1
print(s)


Fixed submission:
c500 = int(input())
c100 = int(input())
c50 = int(input())
t = int(input())
s = 0

for a in range(0, c500 + 1):
    for b in range(0, c100 + 1):
        for c in range(0, c50 + 1):
            if 500*a + 100*b + 50*c == t:
                s = s + 1
print(s)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# input separated integers
a, b = map(int, input().split())
if a*b % 2 == 1:
  print '0dd'
else:
  print 'Even'


Fixed submission:
a, b = map(int, input().split())
if a*b % 2 == 1:
    print('Odd')
else:
    print('Even')
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
a2 = 0
l = []

while a > 0:
    a1 = a
    while a1 > 1:
        l.append(int(a1 % 10))
        a1 = a1 / 10
    if sum(l) >= b and sum(l) <= c:
        a2 = a2 + a
    l = []
    a = a - 1
print(a2)

Fixed submission:
a, b, c = map(int, input().split())
a2 = 0

while a > 0:
    a1 = a
    l = []
    while a1 >= 1:
        l.append(int(a1 % 10))
        a1 = a1 / 10
    if sum(l) >= b and sum(l) <= c:
        a2 = a2 + a

    a = a - 1
print(a2)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = 1
for i in range(N):
    P = P * (i+1)
print(P % 1000000007)

Fixed submission:
N = int(input())
P = 1
for i in range(N):
    P = (P * (i+1)) % 1000000007
print(P)
Buggy python submission (verdict: Time Limit Exceeded):

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

total = 0

total_list = []

for i in range(N):
    to_E = S.count('W', 0, i)
    to_W = S.count('E', i + 1, N + 1)
    total_list.append(to_E + to_W)

print(min(total_list))


Fixed submission:

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

count_W = []
count = 0
for i in range(N):
    if i == 0:
        count_W.append(0)
    else:
        if S[i-1:i] == 'W':
            count += 1
        count_W.append(count)

count_E = []
for i in range(N):
    count_E.append(0)
count = 0
for i in range(N - 1, -1, -1):
    if S[i+1:i+2] == 'E':
        count += 1
    count_E[i] = count

total_list = []
for i in range(N):
    to_E = count_W[i]
    to_W = count_E[i]
    total_list.append(to_E + to_W)

print(min(total_list))

Buggy python submission (verdict: Time Limit Exceeded):

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

total = 0

for i in range(N):
    to_E = S.count('W', 0, i)
    to_W = S.count('E', i + 1, N + 1)
    total_temp = to_E + to_W

    if i == 0:
        total = total_temp
    elif total_temp < total:
        total = total_temp

print(total)


Fixed submission:

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

count_W = []
count = 0
for i in range(N):
    if i == 0:
        count_W.append(0)
    else:
        if S[i-1:i] == 'W':
            count += 1
        count_W.append(count)

count_E = []
for i in range(N):
    count_E.append(0)
count = 0
for i in range(N - 1, -1, -1):
    if S[i+1:i+2] == 'E':
        count += 1
    count_E[i] = count

total_list = []
for i in range(N):
    to_E = count_W[i]
    to_W = count_E[i]
    total_list.append(to_E + to_W)

print(min(total_list))
Buggy python submission (verdict: Runtime Error):

a = int(input())
b = int(input())

if (a * b) % 2 == 0:
    print('Even')
else:
    print('Odd')


Fixed submission:

a, b = map(int, input().split())

if (a * b) % 2 == 0:
    print('Even')
else:
    print('Odd')

Buggy python submission (verdict: Runtime Error):

a = int(input())
b = int(input())

if (a * b) % 2 == 0:
    print('even')
else:
    print('Odd')


Fixed submission:

a, b = map(int, input().split())

if (a * b) % 2 == 0:
    print('Even')
else:
    print('Odd')