Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve( lst_a, lst_b,n):
    if n.count("-")>=2:
        return "No"
    else:
        N,NN=n.split("-")
        if lst_a == len(N) and lst_b == len(NN):
            answer = "Yes"
        else:
            answer = "No"
    return answer
# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line1 = sys.stdin.readline().rstrip()
    [str_n, str_i] = line1.split(' ')
    line2 = sys.stdin.readline().rstrip()
    return (int(str_n), int(str_i), line2)

def main():
    n, i, s = readQuestion()
    answer = solve(n, i, s)
    print(answer)
    
if __name__ == '__main__':
    main()
    

Fixed submission:
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(a,b,c):
    if len(c) == a+b+1:
        if  c.count("-")!=1:
            return "No"
        elif c[a]==("-"):
            return "Yes"
        else:
            return "No"
    else:
        return "No"
# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line1 = sys.stdin.readline().rstrip()
    [str_n, str_i] = line1.split(' ')
    line2 = sys.stdin.readline().rstrip()
    return (int(str_n), int(str_i), line2)

def main():
    n, i, s = readQuestion()
    answer = solve(n, i, s)
    print(answer)
    
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
##N T
#t1 t2 ... tN
N, T = map(int,input().split())
a = list(map(int, input().split()))
b = []
"""
for i in range(N):
    set1 = set()
    for j in range(T):
        set1.add(a[i] + j)
    b.append(set1)
d = set()
for n in range(len(b)):
    d = d | b[n]
"""
d = set()
for i in range(N):
    d = d | set(range(a[i], a[i] + T))


print(len(d))

Fixed submission:
a, b, c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())
if abs(x-y)<=1:
    print("Brown")
else:
    print("Alice")



Fixed submission:
a, b, c = input().split()
d = ""
d += a.upper()[0]
d += b.upper()[0] 
d += c.upper()[0]
print(d)

Buggy python submission (verdict: Runtime Error):
a, b, c = input().split()
d = ""
d += a.upper()[0]
d += b.upper()[0] j
d += c.upper()[0]
print(d)

Fixed submission:
a, b, c = input().split()
d = ""
d += a.upper()[0]
d += b.upper()[0] 
d += c.upper()[0]
print(d)
Buggy python submission (verdict: Time Limit Exceeded):
x, y = map(int, input().split())
count = 0
while x > 2 or y > 2:
    if (x % 2 == 1 and y % 2  == 1) or (x % 2 == 0 and y % 2  == 0)  : 
    
        if x >= y:
            a = (x / 2) * 2
            x -= a
            y += a / 2
            count += 1
    
        else:
            a = (y / 2) * 2
            y -= a
            x += a / 2
            count += 1
    elif x % 2 == 0:
        a = (x / 2) * 2
        x -= a
        y += a / 2
        count += 1
    elif y % 2 == 0:
        a = (y / 2) * 2
        y -= a
        x += a / 2
        count += 1
        
        

if count % 2 == 0:
    print("Brown")
else:
    print("Alice")

Fixed submission:
x, y = map(int, input().split())
if abs(x-y)<=1:
    print("Brown")
else:
    print("Alice")
Buggy python submission (verdict: Runtime Error):
import fileinput

def process(A, B):
	if A <= B*2:
      return 0
    else:
      return A - B*2

for line in fileinput.input():
    print(process(map(int, line.split()))


Fixed submission:
import fileinput

def process(A, B):
    if A <= B*2:
        return 0
    else:
        return A - B*2

for line in fileinput.input():
    print(process(*map(int, line.split())))

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

def process(A, B):
	if A =< B*2:
      return 0
    else:
      return A - B*2

for line in fileinput.input():
    print(process(map(int, line.split()))

Fixed submission:
import fileinput

def process(A, B):
    if A <= B*2:
        return 0
    else:
        return A - B*2

for line in fileinput.input():
    print(process(*map(int, line.split())))
Buggy python submission (verdict: Runtime Error):
is_odd = lambda x: x % 2 == 0

import fileinput
for line in fileinput.input():
	print(sum([1 for x in range(1, x) if is_odd(x)]/x)

Fixed submission:
num_odd = lambda x: x/2 if x % 2 == 0 else x/2 + 1 
 
import fileinput
for line in fileinput.input():
    try:
        N = int(line.strip())
    except:
        continue
 
    print(1.0 * num_odd(N) / N)
Buggy python submission (verdict: Runtime Error):
N = int(input())
l = list(input())
h = []
for i, s in enumerate(l):
    if i + 1 == N:
        h.append(s)
        print(len(h))
    if s != l[i + 1]:
        h.append(s)

Fixed submission:
length = int(input())
li = list(input())
i = 0
for n in li[:]:
    if i + 1 == len(li):
        print(len(li))
        break
    if li[i] == li[i + 1]:
       del (li[i + 1])
    else:
        i = 1 + i
        continue

Buggy python submission (verdict: Runtime Error):
length = int(input())
li = list(input())
li2 = []
i = 0
for str in li[:]:
    i = 1 + i
    if i + 1 == len(li):
        li2.append(li[i])
        print(len(li2))
        break
    if li[i] != li[i + 1]:
        li2.append(li[i])
        continue

Fixed submission:
length = int(input())
li = list(input())
i = 0
for n in li[:]:
    if i + 1 == len(li):
        print(len(li))
        break
    if li[i] == li[i + 1]:
       del (li[i + 1])
    else:
        i = 1 + i
        continue
Buggy python submission (verdict: Runtime Error):
import math
from fractions import gcd


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


s = int(math.sqrt(g))

f = {}
for i in range(2, s+1):
    while g % i == 0:
        f[i] = f.get(i, 0) + 1
        g = g/i
if g != 1:
    f[g] = f.get(g, 0) + 1

print(len(f)+1)

Fixed submission:
n = int(input())
p = 0
for i in range(n+1):
    if i % 2 == 1:
        p += 1
print('{:.10}'.format(p/n))

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


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


a, b = list(map(int, input().split()))
g = math.gcd(a, b)
if g == 1:
    print(factorization(g))
    print('1')
else:
    print(factorization(g))
    print(len(factorization(g))+1)

Fixed submission:
n = int(input())
p = 0
for i in range(n+1):
    if i % 2 == 1:
        p += 1
print('{:.10}'.format(p/n))

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


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


a, b = list(map(int, input().split()))
g = math.gcd(a, b)
if g == 1:
    print(factorization(g))
    print('1')
else:
    print(factorization(g))
    print(len(factorization(g))+1)

Fixed submission:
n = int(input())
p = 0
for i in range(n+1):
    if i % 2 == 1:
        p += 1
print('{:.10}'.format(p/n))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = [a.index(i+1)+1 for i in range(n)]
ans = ''
for i in b:
    ans += str(i) + ' '
print(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [[a[i], i+1] for i in range(n)]
b.sort()
c = [b[i][1] for i in range(n)]
print(*c)
Buggy python submission (verdict: Runtime Error):
import math


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


a, b = list(map(int, input().split()))
g = math.gcd(a, b)
if g == 1:
    print('1')
else:
    print(len(factorization(g))+1)

Fixed submission:
from fractions import gcd


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


a, b = list(map(int, input().split()))
g = gcd(a, b)
if g == 1:
    print('1')
else:
    print(len(factorization(g))+1)

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


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


a, b = list(map(int, input().split()))
g = math.gcd(a, b)
if g == 1:
    print('1')
else:
    print(len(factorization(g))+1)

Fixed submission:
from fractions import gcd


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


a, b = list(map(int, input().split()))
g = gcd(a, b)
if g == 1:
    print('1')
else:
    print(len(factorization(g))+1)
Buggy python submission (verdict: Runtime Error):
n = int(inout())
if n//100 == n%10:
  print('YES')
else:
  print('NO')

Fixed submission:
n = int(input())
if n//100 == n%10:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [int(input()) for _ in range(n)]

sum = [0]
for i in range(n):
    temp = []
    for x in sum:
        temp.append(x)
        temp.append(x+s[i])
        sum = temp[::]

dp = [i for i in sum if i % 10 != 0]
print(max(dp) if dp != [] else '0')

Fixed submission:
n = int(input())
s = sorted([int(input()) for _ in range(n)])
if sum(s) % 10 != 0:
    print(sum(s))
    quit()
else:
    for i in s:
        if i % 10 != 0:
            s.remove(i)
            print(sum(s))
            quit()
print('0')
Buggy python submission (verdict: Runtime Error):
b=input().split
print("A"+b[1]+"c")

Fixed submission:
a,b,c=map(str,input().split())
print('{}{}{}'.format(a[0],b[0],c[0]))
Buggy python submission (verdict: Runtime Error):
n,k,x,y=[int(input()) for_ in range(4)]
print(min(n, k)*x+max(n-k,0)*y)

Fixed submission:
n=int(input())
k=int(input())
x=int(input())
y=int(input())
print(k*x+(n-k)*y if n-k>=0 else n*x)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
s=input()
s_list=list(s)

count=1

while count!=0:
  count=0
  for j in range(0,len(s_list)-1):
    if s_list[j] == s_list[j+1]:
      s_list.pop(j+1)
      count=1
      break
  
print(len(s_list))

Fixed submission:
N=int(input())
s=input()
s_list=list(s)
import itertools as itl
list2=[k for k, v in itl.groupby(s_list)]
print(len(list2))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
s=input()
s_list=list(s)
count=0
for i in range(0,N):
  for j in range(0,len(s_list)-1):
    if s_list[j] == s_list[j+1]:
      s_list.pop(j+1)
      count=1
      break
  if count==0:
    break
print(len(s_list))

Fixed submission:
N=int(input())
s=input()
s_list=list(s)
import itertools as itl
list2=[k for k, v in itl.groupby(s_list)]
print(len(list2))
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
h_i=(int(x) for x in input().split())
count=0
for i in range(N):
  if h_i[i] >= K:
    count+=1
print(count)

Fixed submission:
N,K=map(int,input().split())
h_i=list(int(x) for x in input().split())
count=0

for i in range(N):
  if h_i[i] >= K:
    count+=1
print(count)

Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
h_i=(int(x) for x in input().split())
count=0
for i in range(N):
  if h_i[i] => K:
    count+=1
print(count)

Fixed submission:
N,K=map(int,input().split())
h_i=list(int(x) for x in input().split())
count=0

for i in range(N):
  if h_i[i] >= K:
    count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
a = [int(input()) for _ in range(5)]
b = 10-min([a[i]%10 for i in range(5) if 0 < a[i]%10] or 10)
print(sum([(-(-a[i]//10)) for i in range(5)])*10-b)

Fixed submission:
a = [ int(input()) for _ in range(5)]
n = float("inf")
for i in range(5):
    if 0 < a[i] % 2 < 10:
        n = min(n,a[i] % 10)
else:
    if n == float("inf"):
        n = 10
print(sum([(-a[i]//10)*-10 for i in range(5)]) -(10-n))

Buggy python submission (verdict: Runtime Error):
a = [int(input()) for _ in range(5)]
b = 10-min([a[i]%10 for i in range(5) if 0 <a[i]%10])
print(sum([(-(-a[i]//10)) for i in range(5)])*10-b)

Fixed submission:
a = [ int(input()) for _ in range(5)]
n = float("inf")
for i in range(5):
    if 0 < a[i] % 2 < 10:
        n = min(n,a[i] % 10)
else:
    if n == float("inf"):
        n = 10
print(sum([(-a[i]//10)*-10 for i in range(5)]) -(10-n))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int,input().split())
s = input()
a = [0 for _ in range(m)]
for i in range(m):
    x, y = map(int,input().split())
    a[i] = s[x-1:y].count("AC")
print(*a,sep="\n")

Fixed submission:
n, m = map(int,input().split())
dp = [0 for _ in range(n+1)]
S = input()
a = [0 for _ in range(m)]
for i in range(1,n):
    if S[i-1:i+1] == "AC":
        dp[i] = dp[i-1]+1
    else:dp[i] = dp[i-1]
for i in range(m):
    x, y = map(int,input().split())
    a[i] = dp[y-1] - dp[x-1]
print(*a,sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int,input().split())
s = input()
a = [0 for _ in range(m)]
for i in range(m):
    x, y = map(int,input().split())
    a[i] = s[x-1:y].count("AC")
print(*a,sep="\n")

Fixed submission:
n, m = map(int,input().split())
dp = [0 for _ in range(n+1)]
S = input()
a = [0 for _ in range(m)]
for i in range(1,n):
    if S[i-1:i+1] == "AC":
        dp[i] = dp[i-1]+1
    else:dp[i] = dp[i-1]
for i in range(m):
    x, y = map(int,input().split())
    a[i] = dp[y-1] - dp[x-1]
print(*a,sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int,input().split())
s = input()
for _ in range(m):
    x, y = map(int,input().split())
    print(s[x-1:y].count("AC"))

Fixed submission:
n, m = map(int,input().split())
dp = [0 for _ in range(n+1)]
S = input()
a = [0 for _ in range(m)]
for i in range(1,n):
    if S[i-1:i+1] == "AC":
        dp[i] = dp[i-1]+1
    else:dp[i] = dp[i-1]
for i in range(m):
    x, y = map(int,input().split())
    a[i] = dp[y-1] - dp[x-1]
print(*a,sep="\n")
Buggy python submission (verdict: Runtime Error):
def f(i):
    if memo[i] != float("Inf"):return memo[i]

    memo[i] = min(memo[i],f(i-1)+abs(ary[i-1]-ary[i]))
    if i > 1:memo[i] = min(memo[i],f(i-2)+abs(ary[i-2]-ary[i]))

    return memo[i]
n = int(input())
ary = list(map(int,input().split()))
memo = [float("Inf") for _ in range(n)]
memo[0] = 0
print(f(n-1))

Fixed submission:
nums = int(input())
ary = list(map(int,input().split()))
dp = [0 for i in range(nums)]
for i in range(1,nums):
    dp[i] = float("inf")
jump_min = 0
for i in range(1,nums):
    for x in range(1,3):
        jump = i-x
        if i-x < 0: continue
        jump = dp[i-x] + abs(ary[i-x] - ary[i])
        if jump < dp[i]:
            dp[i] = jump
print(dp[nums-1])
Buggy python submission (verdict: Time Limit Exceeded):
n,w = map(int,input().split())
dp = [[0]*(w+1) for _ in range(n+1)]
ary = [list(map(int,input().split())) for _ in range(n)]
for i in range(n):
    for j in range(w+1):
        if j >= ary[i][0]:
            dp[i+1][j] = max(dp[i][j],dp[i][j-ary[i][0]]+ary[i][1])
        else:dp[i+1][j] = dp[i][j]
print(dp[n][w])

Fixed submission:
nums, weight = map(int,input().split())
ary  = [0 for i in range(nums)]
for i in range(nums):
    ary[i] = list(map(int,input().split()))
dp =[[0 for i in range(weight+1)]for i in range(nums+1)]
 
check = 0
for i in range(nums):
    for x in range(weight+1):
        if x - ary[i][0] >= 0:
            check = dp[i][x -ary[i][0]] + ary[i][1]
            if check > dp[i+1][x]:
                dp[i+1][x] = check
 
        check = dp[i][x]
        if check > dp[i+1][x]:
            dp[i+1][x] = check
 
print(dp[nums][weight])

Buggy python submission (verdict: Time Limit Exceeded):
n,w = map(int,input().split())
value = []
weight = []
dp = [[0]*(w+1) for _ in range(n+1)]
for i in range(n):
    x,y = map(int,input().split())
    value += [y]
    weight += [x]
for i in range(n):
    for j in range(w+1):
        if j - weight[i] >= 0:
            dp[i+1][j] = max(dp[i+1][j],dp[i][j-weight[i]]+value[i])
        dp[i+1][j] = max(dp[i+1][j],dp[i][j])
print(dp[n][w])

Fixed submission:
nums, weight = map(int,input().split())
ary  = [0 for i in range(nums)]
for i in range(nums):
    ary[i] = list(map(int,input().split()))
dp =[[0 for i in range(weight+1)]for i in range(nums+1)]
 
check = 0
for i in range(nums):
    for x in range(weight+1):
        if x - ary[i][0] >= 0:
            check = dp[i][x -ary[i][0]] + ary[i][1]
            if check > dp[i+1][x]:
                dp[i+1][x] = check
 
        check = dp[i][x]
        if check > dp[i+1][x]:
            dp[i+1][x] = check
 
print(dp[nums][weight])

Buggy python submission (verdict: Time Limit Exceeded):
nums, weight = map(int,input().split())
ary  = [0 for i in range(nums)]
for i in range(nums):
    ary[i] = list(map(int,input().split()))
dp =[[0 for i in range(weight+1)]for i in range(nums+1)]

check = 0
for i in range(nums):
    for x in range(weight+1):
        if x - ary[i][0] >= 0:
            check = dp[i][x -ary[i][0]] + ary[i][1]
            if check > dp[i+1][x]:
                dp[i+1][x] = check

        check = dp[i][x]
        if check > dp[i+1][x]:
            dp[i+1][x] = check

print(dp[nums][weight])

Fixed submission:
nums, weight = map(int,input().split())
ary  = [0 for i in range(nums)]
for i in range(nums):
    ary[i] = list(map(int,input().split()))
dp =[[0 for i in range(weight+1)]for i in range(nums+1)]
 
check = 0
for i in range(nums):
    for x in range(weight+1):
        if x - ary[i][0] >= 0:
            check = dp[i][x -ary[i][0]] + ary[i][1]
            if check > dp[i+1][x]:
                dp[i+1][x] = check
 
        check = dp[i][x]
        if check > dp[i+1][x]:
            dp[i+1][x] = check
 
print(dp[nums][weight])
Buggy python submission (verdict: Runtime Error):
import fractinos
N, X = map(int, input().split())
ary = list(map(int, input().split()))
arr = [i - X for i in ary]
ans = arr[0]
for i in range(1,N-1):
    ans = fractions.gcd(ans,arr[i])
print(ans)

Fixed submission:
import fractions
N, X = map(int, input().split())
ary = list(map(int, input().split()))
arr = [abs(i - X) for i in ary]
ans = arr[0]
for i in range(1,N):
    ans = fractions.gcd(ans, arr[i])
print(ans)

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

N, X = map(int, input().split())
ary = list(map(int, input().split()))
arr = [i - X for i in ary]
ans = arr[0]
for i in range(1,N-1):
    ans = math.gcd(ans,arr[i])
print(ans)

Fixed submission:
import fractions
N, X = map(int, input().split())
ary = list(map(int, input().split()))
arr = [abs(i - X) for i in ary]
ans = arr[0]
for i in range(1,N):
    ans = fractions.gcd(ans, arr[i])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
import collections
def f(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n = n//f
        else:f += 2
    if n != 1:
        a.append(n)
    return a

ans = 0
n = int(input())
for i in map(int,input().split()):
    c = collections.Counter(f(i))
    ans += c[2]
print(ans)

Fixed submission:
n = int(input())
ans = 0
for i in map(int,input().split()):
    a = i
    while a % 2 == 0:
        ans += 1
        a = a // 2
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
dp = [float("Inf")]*(n+1)
for i in range(6):
    dp[i] = i
for i in range(n+1):
    power = 1
    while i >= 6 ** power:
        dp[i] = min(dp[i],dp[i-6**power]+1)
        power += 1
    power = 1
    while i >= 9 ** power:
        dp[i] = min(dp[i],dp[i-9**power]+1)
        power += 1
print(dp[n])

Fixed submission:
n = int(input())
dp = [i for i in range(n+1)]
for i in range(n+1):
    power = 1
    while 6**power <= i:
        dp[i] = min(1+dp[i-6**power],dp[i])
        power += 1
    power = 1
    while 9**power <= i:
        dp[i] = min(1+dp[i-9**power],dp[i])
        power += 1
print(dp[n])
Buggy python submission (verdict: Time Limit Exceeded):
nums = int(input())
direct = list(input())
ary = [0 for i in range(nums)]

for i in range(nums):
    count = 0
    for x in range(nums):
        if x < i and direct[x] == "W":
            count += 1
        elif x > i and direct[x] == "E":
            count += 1
    ary[i] = count

print(min(ary))

Fixed submission:
nums = int(input())
direct = list(input())
ary_w = [0 for i in range(nums)]
ary_e = [0 for i in range(nums)]
count_w = 0
count_e = 0
count = 0
result = 100000000

for i in range(nums):
    if direct[i] == "W":
        count_w += 1
    elif direct[i] == "E":
        count_e += 1

    ary_w[i] = count_w
    ary_e[i] = count_e

for i in range(nums):
    w = ary_w[i-1]
    e = ary_e[-1] - ary_e[i]
    if i == 0:
        w = 0
        e = ary_e[-1]
    count = w+e
    if count < result:
        result = count
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
nums = int(input())
direct = list(input())
max = 0

for i in range(nums):
    count = 0
    for x in range(nums):
        if x == i: continue
        if x < i  and direct[x] == "E":
            count += 1
        elif i < x and direct[x] == "W":
            count += 1

    if count > max:
        max = count
print(nums - max-1)

Fixed submission:
nums = int(input())
direct = list(input())
ary_w = [0 for i in range(nums)]
ary_e = [0 for i in range(nums)]
count_w = 0
count_e = 0
count = 0
result = 100000000

for i in range(nums):
    if direct[i] == "W":
        count_w += 1
    elif direct[i] == "E":
        count_e += 1

    ary_w[i] = count_w
    ary_e[i] = count_e

for i in range(nums):
    w = ary_w[i-1]
    e = ary_e[-1] - ary_e[i]
    if i == 0:
        w = 0
        e = ary_e[-1]
    count = w+e
    if count < result:
        result = count
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ary = list(map(int,input().split()))
a = sorted(ary)
c = (len(ary)+1)//2-1
for i in range(n):
    b = a.copy()
    b.remove(ary[i])
    print(b[c])

Fixed submission:
n = int(input())
ary = list(map(int,input().split()))
a = sorted(ary)
b = (len(ary)+1)//2-1
for i in range(n):
    if a[b] < ary[i]:
        print(a[b])
    elif a[b] == ary[i]:
        print(a[b+1])
    elif a[b] > ary[i]:
        print(a[b+1])

Buggy python submission (verdict: Runtime Error):
n = int(input())
ary = list(map(int,input().split()))
a = sorted(ary)
c = (len(ary)+1)//2-1
for i in range(n):
    b = a.copy()
    b.remove(ary[i])
    print(b[c])

Fixed submission:
n = int(input())
ary = list(map(int,input().split()))
a = sorted(ary)
b = (len(ary)+1)//2-1
for i in range(n):
    if a[b] < ary[i]:
        print(a[b])
    elif a[b] == ary[i]:
        print(a[b+1])
    elif a[b] > ary[i]:
        print(a[b+1])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ary = list(map(int,input().split()))
b = (len(ary)+1)//2-1
for i in range(n):
    a = ary.copy()
    del a[i]
    a.sort()
    print(a[b])

Fixed submission:
n = int(input())
ary = list(map(int,input().split()))
a = sorted(ary)
b = (len(ary)+1)//2-1
for i in range(n):
    if a[b] < ary[i]:
        print(a[b])
    elif a[b] == ary[i]:
        print(a[b+1])
    elif a[b] > ary[i]:
        print(a[b+1])