Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = raw_input()
d = []
for i in range(0,n):
    c = s[0:i].count('W')+s[i+1:n].count('E')
    d.append(c)
print(min(d))

Fixed submission:
n = int(input())
s = str(input())

a = [(0,0) for _ in range(n + 1)]
b = []
for i in range(n):
    if s[i] == "W":
        a[i+1] = (a[i][0] + 1,a[i][1])
    else:
        a[i+1] = (a[i][0],a[i][1] + 1)
    b.append(a[i+1][1]-a[i+1][0])
    
ans = s[0:b.index(max(b))].count('W') + s[b.index(max(b))+1:].count('E')
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input())
d = []
for i in range(0,n):
    c = s[0:i].count('W')+s[i+1:n].count('E')
    d.append(c)
print(min(d))

Fixed submission:
n = int(input())
s = str(input())

a = [(0,0) for _ in range(n + 1)]
b = []
for i in range(n):
    if s[i] == "W":
        a[i+1] = (a[i][0] + 1,a[i][1])
    else:
        a[i+1] = (a[i][0],a[i][1] + 1)
    b.append(a[i+1][1]-a[i+1][0])
    
ans = s[0:b.index(max(b))].count('W') + s[b.index(max(b))+1:].count('E')
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input())
d = []
for i in range(0,n):
    list_1 = s[0:i]
    list_2 = s[i+1:n]
    c = list_1.count('W') + list_2.count('E')
    d.append(c)
print(min(d))

Fixed submission:
n = int(input())
s = str(input())

a = [(0,0) for _ in range(n + 1)]
b = []
for i in range(n):
    if s[i] == "W":
        a[i+1] = (a[i][0] + 1,a[i][1])
    else:
        a[i+1] = (a[i][0],a[i][1] + 1)
    b.append(a[i+1][1]-a[i+1][0])
    
ans = s[0:b.index(max(b))].count('W') + s[b.index(max(b))+1:].count('E')
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input())
m = []
for i in range(n):
    list_1 = s[0:i]
    list_2 = s[i+1:n]
    list_1_unique = list((list_1))
    list_2_unique = list((list_2))
    k = 0
    for j in list_1_unique:
        if j == 'W':
            k += 1
    for l in list_2_unique:
        if l == 'E':
            k += 1
    m.append(k)
print(min(m))

Fixed submission:
n = int(input())
s = str(input())

a = [(0,0) for _ in range(n + 1)]
b = []
for i in range(n):
    if s[i] == "W":
        a[i+1] = (a[i][0] + 1,a[i][1])
    else:
        a[i+1] = (a[i][0],a[i][1] + 1)
    b.append(a[i+1][1]-a[i+1][0])
    
ans = s[0:b.index(max(b))].count('W') + s[b.index(max(b))+1:].count('E')
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input())
m = []
for i in range(0,n):
    list_1 = s[0:i]
    list_2 = s[i+1:n]
    list_1_unique = list((list_1))
    list_2_unique = list((list_2))
    k = 0
    for j in list_1_unique:
        if j == 'W':
            k += 1
    for l in list_2_unique:
        if l == 'E':
            k += 1
    m.append(k)
print(min(m))

Fixed submission:
n = int(input())
s = str(input())

a = [(0,0) for _ in range(n + 1)]
b = []
for i in range(n):
    if s[i] == "W":
        a[i+1] = (a[i][0] + 1,a[i][1])
    else:
        a[i+1] = (a[i][0],a[i][1] + 1)
    b.append(a[i+1][1]-a[i+1][0])
    
ans = s[0:b.index(max(b))].count('W') + s[b.index(max(b))+1:].count('E')
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input())
d = []
for i in range(0,n):
    list_1 = s[0:i]
    list_2 = s[i+1:n]
    a = list_1.count('W')
    b = list_2.count('E')
    c = a+b
    d.append(c)
print(min(d))

Fixed submission:
n = int(input())
s = str(input())

a = [(0,0) for _ in range(n + 1)]
b = []
for i in range(n):
    if s[i] == "W":
        a[i+1] = (a[i][0] + 1,a[i][1])
    else:
        a[i+1] = (a[i][0],a[i][1] + 1)
    b.append(a[i+1][1]-a[i+1][0])
    
ans = s[0:b.index(max(b))].count('W') + s[b.index(max(b))+1:].count('E')
print(ans)