Buggy python submission (verdict: Runtime Error):
//https://qiita.com/minemine0505/items/9aeae0f651f19f2ac1e2
N = int(input())
S = input()
min = S[1:N].count("E") #最小値を保存しておく
now = S[1:N].count("E") #i-1 を見ているときのそっぽ向いてる子の数

for i in range (1,N):
    if S[i-1] == "E" and S[i] == "E":
        now -= 1
    if S[i-1] == "W" and S[i] == "W":
        now += 1
    if now < min:
        min = now
print(min)

Fixed submission:
#https://qiita.com/minemine0505/items/9aeae0f651f19f2ac1e2
N = int(input())
S = input()
min = S[1:N].count("E") #最小値を保存しておく
now = S[1:N].count("E") #i-1 を見ているときのそっぽ向いてる子の数

for i in range (1,N):
    if S[i-1] == "E" and S[i] == "E":
        now -= 1
    if S[i-1] == "W" and S[i] == "W":
        now += 1
    if now < min:
        min = now
print(min)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(raw_input())
S = str(raw_input())
opt_cnt = N
for i in range(N):
    first = S[:i]
    second = S[i+1:]
    cnt = first.count('W') + second.count('E')
    if opt_cnt > cnt:
        opt_cnt = cnt
print(opt_cnt)


Fixed submission:
def opt(N, S):
    if N == 1:
        return 0
    else:
        split = int(N/2)
        return min(opt(split,S[:split])+S[split:].count('E'),S[:split].count('W')+opt(N - split,S[split:]))

Num = int(raw_input())
Str = str(raw_input())
print(opt(Num, Str))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(raw_input())
S = str(raw_input())
opt_cnt = N
for i in range(N):
    first = S[:i]
    second = S[i+1:]
    cnt = 0
    for f in first:
        if f is not 'E':
            cnt = cnt + 1
        if cnt >= opt_cnt:
            break
    for s in second:
        if s is not 'W':
            cnt = cnt + 1
        if cnt >= opt_cnt:
            break
    if opt_cnt > cnt:
        opt_cnt = cnt
print(opt_cnt)


Fixed submission:
def opt(N, S):
    if N == 1:
        return 0
    else:
        split = int(N/2)
        return min(opt(split,S[:split])+S[split:].count('E'),S[:split].count('W')+opt(N - split,S[split:]))

Num = int(raw_input())
Str = str(raw_input())
print(opt(Num, Str))

Buggy python submission (verdict: Runtime Error):
N = int(raw_input())
S = str(raw_input())
opt_cnt = N
for i in range(N):
    first = S[:i]
    second = S[i+1:]
    cnt = 0
    for f in first:
        if f is not 'E':
            cnt = cnt + 1
        if cnt >= opt_cnt
            break
    for s in second:
        if s is not 'W':
            cnt = cnt + 1
        if cnt >= opt_cnt
            break
    if opt_cnt > cnt:
        opt_cnt = cnt
print(opt_cnt)


Fixed submission:
def opt(N, S):
    if N == 1:
        return 0
    else:
        split = int(N/2)
        return min(opt(split,S[:split])+S[split:].count('E'),S[:split].count('W')+opt(N - split,S[split:]))

Num = int(raw_input())
Str = str(raw_input())
print(opt(Num, Str))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(raw_input())
S = str(raw_input())
opt_cnt = N
for i in range(N):
    first = S[:i]
    second = S[i+1:]
    cnt = 0
    for f in first:
        if f is not 'E':
            cnt = cnt + 1
    for s in second:
        if s is not 'W':
            cnt = cnt + 1
    if opt_cnt > cnt:
        opt_cnt = cnt
print(opt_cnt)


Fixed submission:
def opt(N, S):
    if N == 1:
        return 0
    else:
        split = int(N/2)
        return min(opt(split,S[:split])+S[split:].count('E'),S[:split].count('W')+opt(N - split,S[split:]))

Num = int(raw_input())
Str = str(raw_input())
print(opt(Num, Str))