Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N = map(int,input().split())
rmax = N // R
gmax = N // G
bmax = N // B
ans = 0
for r in range(rmax+1):
    for g in range(gmax+1):
        if (N - (R*r + G*g)) % B == 0 and 0 <= (N - (R*r + G*g) )// B <= bmax: 
            ans += 1
print(ans)

Fixed submission:
R,G,B,N = map(int,input().split())
rmax = N // R
gmax = N // G
bmax = N // B
ans = 0
for r in range(rmax+1):
    for g in range(gmax+1):
        if (N - (R*r + G*g)) % B == 0 and 0 <= (N - (R*r + G*g) )// B <= bmax: 
            ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N = map(int,input().split())
rmax = N // R
gmax = N // G
bmax = N // B
ans = 0
for r in range(rmax+1):
    for g in range(gmax+1):
        if (N - (R*r + G*g)) % B == 0:
            if 0 <= (N - (R*r + G*g) )// B <= bmax: 
                ans += 1
print(ans)

Fixed submission:
R,G,B,N = map(int,input().split())
rmax = N // R
gmax = N // G
bmax = N // B
ans = 0
for r in range(rmax+1):
    for g in range(gmax+1):
        if (N - (R*r + G*g)) % B == 0 and 0 <= (N - (R*r + G*g) )// B <= bmax: 
            ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
a.sort()
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
divs = make_divisors(a[0]) #list

divsTF = [0]*len(divs)
for i in range(len(divs)):
    j = [1 if a[_] % divs[i] else 0 for _ in range(n) ]

    if sum(j) <= 1:
        divsTF[i] = 1

ans = 1
for i in range(len(divs)):
    if divsTF[i] == 1:
        ans = max(ans,divs[i])


divs2 = make_divisors(a[1]) #list

divsTF2 = [0]*len(divs2)
for i in range(len(divs2)):
    j = [1 if a[_] % divs2[i] else 0 for _ in range(n) ]

    if sum(j) <= 1:
        divsTF2[i] = 1

aans = 1
for i in range(len(divs2)):
    if divsTF2[i] == 1:
        aans = max(aans,divs2[i])
print(max(aans,ans))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a.sort()
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
divs = list(set(make_divisors(a[0])+make_divisors(a[1]))) #list

divsTF = [0]*len(divs)
for i in range(len(divs)):
    j = [1 if a[_] % divs[i] else 0 for _ in range(n) ]

    if sum(j) <= 1:
        divsTF[i] = 1

ans = 1
for i in range(len(divs)):
    if divsTF[i] == 1:
        ans = max(ans,divs[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
S = input()
s = list(S)
j = list(S)
ans = 0
aans = 0
for i in range(n-2,-1,-1):
    if s[i] == "#" and s[i+1] == ".":
        ans += 1
        s[i+1] = "#"
for i in range(n-1):
    if j[i] == "#" and j[i+1] == ".":
        aans += 1
        j[i+1] == "#"
print(min(ans,aans))


Fixed submission:
a,b,c = map(int,input().split())
if a < c < b:
        ans = "Yes"
elif b < c < a:
        ans = "Yes"
else:
        ans = "No"
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
S = input()
a = list(S)
ans = 0

for i in range(n-2,-1,-1):

    if a[i] == "#" and a[i+1] == ".":
        bns += 1
        a[i] = "."

print(ans)

Fixed submission:
n = int(input())
s = list(input())
b = [0] * n
w = [0] * n
x,y = 0,0
ans = 0
for i in range(n):
    if s[i] == '#':
        x += 1
    else:
        y += 1
    b[i] = x
    w[i] = y

ans = float('inf')
for i in range(n):
    ans = min(ans, b[i] + w[n-1] - w[i])
print(min(ans, b[n-1], w[n-1]))
Buggy python submission (verdict: Runtime Error):
from math import*
n = int(input())
L = [int(input()) for i in range(5)]
ans = ceil(n //min(L) + 4
print(ans)


Fixed submission:
n = int(input())
L = [int(input()) for i in range(5)]
ans = -(-n //min(L)) + 4
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
L = [int(input()) for i in range(5)]
J = [_ for _ in L if _ != 1]
if min(L) != 1:
    ans = n //min(L) + 5
else:
    ans = n // min(J) + L.count(1)*n
print(ans)


Fixed submission:
n = int(input())
L = [int(input()) for i in range(5)]
ans = -(-n //min(L)) + 4
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
A,B = map(int,input().split())
ans = A
for i in range(A+1,B+1):
    ans = ans^i
print(ans)

Fixed submission:
def f(a):
    if a % 4 == 1:
        return 1
    elif a % 4 == 2:
        return a + 1
    elif a % 4 == 3 or a == 0:
        return 0
    else:
        return a
a, b = map(int, input().split())
print(f(b) ^ f(a - 1))
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
a,b,k = map(int,input().split())
mods = []
for i in range(1,min(a,b)):
    if a % i == 0 and b % i == 0:
        mods.append(i)
mods.sort(reverse=True)
if len(mods) == 1:
    print(mods[0])
else:
    print(mods[k-1])

Fixed submission:
a,b,k = map(int,input().split())
cd = []
for i in range(1,min(a,b)+1):
    if a % i == 0:
        if b % i == 0:
            cd.append(i)
cd.sort(reverse=True)
print(cd[k-1])

Buggy python submission (verdict: Runtime Error):
from fractions import gcd
a,b,k = map(int,input().split())
mods = []
for i in range(1,min(a,b)):
    if a % i == 0 and b % i == 0:
        mods.append(i)
mods.sort(reverse=True)
if len(mods) == 1:
    print(mods[0])
else:
    print(mods[k-1])

Fixed submission:
a,b,k = map(int,input().split())
cd = []
for i in range(1,min(a,b)+1):
    if a % i == 0:
        if b % i == 0:
            cd.append(i)
cd.sort(reverse=True)
print(cd[k-1])

Buggy python submission (verdict: Runtime Error):
from fractions import gcd
a,b,k = map(int,input().split())
mods = []
for i in range(1,max(a,b)):
    if a % i == 0 and b % i == 0:
        mods.append(i)
print(mods[k-1])

Fixed submission:
a,b,k = map(int,input().split())
cd = []
for i in range(1,min(a,b)+1):
    if a % i == 0:
        if b % i == 0:
            cd.append(i)
cd.sort(reverse=True)
print(cd[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int,input().split()))
while True:
    if A.count(0) == n - 1:
        print(max(A))
        exit()
    else:
        B = [ _  for _ in A if _ != 0  ]
        attack = min(B)
        sn = A.index(attack)
        
        for i in range(n):
            if A[i] == 0:
                pass
            else:
                if i != sn:
                    A[i] = A[i] - attack
                else:
                    pass


Fixed submission:
n = int(input())
A = list(map(int,input().split()))
while True:
    if A.count(0) == n - 1:
        print(max(A))
        exit()
    else:
        B = [ _  for _ in A if _ != 0  ]
        attack = min(B)
        sn = A.index(attack)
        
        for i in range(n):
            if A[i] == 0:
                pass
            else:
                if i != sn:
                    A[i] = A[i] % attack
                else:
                    pass

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int,input().split()))
while True:
    if A.count(0) == n - 1:
        print(max(A))
        exit()
    else:
        B = [ _  for _ in A if _ != 0  ]
        attack = min(B)
        sn = A.index(attack)
        
        for i in range(n):
            if A[i] == 0:
                pass
            else:
                if i != sn:
                    A[i] = A[i] - attack
                else:
                    pass


Fixed submission:
n = int(input())
A = list(map(int,input().split()))
while True:
    if A.count(0) == n - 1:
        print(max(A))
        exit()
    else:
        B = [ _  for _ in A if _ != 0  ]
        attack = min(B)
        sn = A.index(attack)
        
        for i in range(n):
            if A[i] == 0:
                pass
            else:
                if i != sn:
                    A[i] = A[i] % attack
                else:
                    pass

Buggy python submission (verdict: Time Limit Exceeded):
import copy
n = int(input())
A = list(map(int,input().split()))
while True:
    if A.count(0) == n - 1:
        print(max(A))
        exit()
    else:
        B = [ _  for _ in A if _ != 0  ]
        attack = min(B)
        sn = A.index(attack)
        
        for i in range(n):
            if A[i] == 0:
                pass
            else:
                if i != sn:
                    A[i] = A[i] - attack
                else:
                    pass


Fixed submission:
n = int(input())
A = list(map(int,input().split()))
while True:
    if A.count(0) == n - 1:
        print(max(A))
        exit()
    else:
        B = [ _  for _ in A if _ != 0  ]
        attack = min(B)
        sn = A.index(attack)
        
        for i in range(n):
            if A[i] == 0:
                pass
            else:
                if i != sn:
                    A[i] = A[i] % attack
                else:
                    pass
Buggy python submission (verdict: Runtime Error):
S = str(input())
s = input()
for i in range(len(s)):
    for j in range(i, len(s)):
        a = s[:i] + s[j:]
        if a == "keyence":
            print("YES")
            exit()
print("NO")


Fixed submission:
s = str(input())
for i in range(len(s)):
    for j in range(i, len(s)):
        a = s[:i] + s[j:]
        if a == "keyence":
            print("YES")
            exit()
print("NO")

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

while True:
    if s[0] == "k":
        break
    else:
        s = s[1:]
if len(s) < 7:
    print("NO")
else:
    middlerange = len(s) - 7
    if s[0]+s[middlerange+1:] == "keyence":
        print("YES")
    elif s[0:2]+s[middlerange+2:] == "keyence":
        print("YES")
    elif s[0:3]+s[middlerange+3:] == "keyence":
        print("YES")
    elif s[0:4]+s[middlerange+4:] == "keyence":
        print("YES")
    elif s[0:5]+s[middlerange+5:] == "keyence":
        print("YES")
    elif s[0:6]+s[middlerange+6:] == "keyence":
        print("YES")
    elif s[0:7]+s[middlerange+7:] == "keyence":
        print("YES")
    else:
        print("NO")

Fixed submission:
s = str(input())
for i in range(len(s)):
    for j in range(i, len(s)):
        a = s[:i] + s[j:]
        if a == "keyence":
            print("YES")
            exit()
print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
s = list(str(input()))
ans = 0
i = len(s) - 1 
while True:
    if i > len(s) - 1:
        i -= 2
    if i == 0:
        break
    if s[i] == "W" and s[i-1] == "B":
        s[i] = "B"
        s[i-1] = "W"
        ans += 1
        i += 1
    else:
        i -= 1
print(ans)

Fixed submission:
s = list(str(input()))
count = 0
ans = 0
for i in s:
    if i == "B":
        count += 1
    else:
        ans += count
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(str(input()))
ans = 0
i = len(s) - 1 
while True:
    if i > len(s) - 1:
        i -= 1
    if i == 0:
        break
    if s[i] == "W" and s[i-1] == "B":
        s[i] = "B"
        s[i-1] = "W"
        ans += 1
        i += 1
    else:
        i -= 1
print(ans)

Fixed submission:
s = list(str(input()))
count = 0
ans = 0
for i in s:
    if i == "B":
        count += 1
    else:
        ans += count
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B,K = map(int,input().split())
i = 1
c = 1
while i <= K:
    if c % 2 == 1:
        if A % 2 == 0:
            A_ = A // 2
            A = A_
            B = B + A_
        else:
            A -= 1
            A_ = A // 2
            A = A_
            B = B + A_

        i += 1
        c += 1
    else:
        if B % 2 == 0:
            B_ = B //2
            A = A + B_
            B = B_
        else:
            B -= 1
            B_ = B //2
            A = A + B_
            B = B_

        i += 1
        c += 1
print(A,B)


Fixed submission:
S = str(input())
if len(S) == 3:
    print(S[::-1])
else:
    print(S)
Buggy python submission (verdict: Runtime Error):
N,M,X,Y = map(int,input().split())
Lx = list(map(int,input().split()))
Ly = list(map(int,input().split()))
count = 0
for i in range(X;Y):
    if max(Lx) < i <= min(Ly):
        count += 1
if count > 0:
    print("No War")
else:
    print("War")


Fixed submission:
n,m,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
for i in range(max(x)+1,min(y)+1):
    if X < i <= Y:
        print("No War")
        exit()
print("War")

Buggy python submission (verdict: Runtime Error):
N,M,X,Y = map(int,input().split())
Lx = list(map(int,input().split()))
Ly = list(map(int,input().split()))
count = 0
for i in range(X:Y):
    if max(Lx) < i <= min(Ly):
        count += 1
if count > 0:
    print("No War")
else:
    print("War")


Fixed submission:
n,m,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
for i in range(max(x)+1,min(y)+1):
    if X < i <= Y:
        print("No War")
        exit()
print("War")
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a % 2 = 0 or b%2=0:
    print("No")
else:
    print("Yes")

Fixed submission:
a,b = map(int,input().split())
if a % 2 == 0 or b%2==0:
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
from math import gcd
n,x = map(int,input().split())
l = list(map(int,input().split()))
ll = [abs(x-i) for i in l]
ans = ll[0]
for i in range(len(ll)):
    ans = gcd(ans,ll[i])
print(ans)

Fixed submission:
from fractions import gcd
n,x = map(int,input().split())
l = list(map(int,input().split()))
ll = [abs(x-i) for i in l]
ans = ll[0]
for i in range(len(ll)):
    ans = gcd(ans,ll[i])
print(ans)

Buggy python submission (verdict: Runtime Error):
from fractions import gcd
n,x = map(int,input().split())
l = list(map(int,input().split()))
ll = []
for i in range(n-1):
    ll.append(l[i+1]-l[i])
ans = ll[0]
for i in range(len(ll)):
    ans = gcd(ans,ll[i])
print(ans)

Fixed submission:
from fractions import gcd
n,x = map(int,input().split())
l = list(map(int,input().split()))
ll = [abs(x-i) for i in l]
ans = ll[0]
for i in range(len(ll)):
    ans = gcd(ans,ll[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
N i = map(int, input().split())
print(N-i+1)

Fixed submission:
N,i = map(int, input().split())
print(N-i+1)
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
maps = []
for i in range(h):
	maps.append(str(input()))
row = [False] * h
col = [False] * w
for i in range(h):
	for j in range(w):
		if maps[i][j] == '#':
			row[i] = True
			col[j] = True

for i in range(h):
	if scr[i]:
		for j in range(w):
			if col[j]:
				print(maps[i][j], end = '')
		print()


Fixed submission:
h, w = map(int, input().split())
maps = []
for i in range(h):
	maps.append(str(input()))
row = [False] * h
col = [False] * w
for i in range(h):
	for j in range(w):
		if maps[i][j] == '#':
			row[i] = True
			col[j] = True

for i in range(h):
	if row[i]:
		for j in range(w):
			if col[j]:
				print(maps[i][j], end = '')
		print()

Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
maps = []
for i in range(h):
	maps.append(str(input()))
row = [False] * h
col = [False] * w
for i in range(h):
	for j in range(w):
		if maps[i][j] == '#':
			row[i] = True
			col[j] = True

for i in range(h):
	if scr[i]:
		for j in range(w):
			if col[j]:
				print(a[i][j], end = '')
		print()


Fixed submission:
h, w = map(int, input().split())
maps = []
for i in range(h):
	maps.append(str(input()))
row = [False] * h
col = [False] * w
for i in range(h):
	for j in range(w):
		if maps[i][j] == '#':
			row[i] = True
			col[j] = True

for i in range(h):
	if row[i]:
		for j in range(w):
			if col[j]:
				print(maps[i][j], end = '')
		print()
Buggy python submission (verdict: Runtime Error):
N = int(input())
if N >= 195:
  print("3")
elif N >= 165:
  print("2")
elif N >= 105:
  print("1")
else:
  print("0")

Fixed submission:
A,B = map(int, input().split())
print((A-1)*(B-1))
Buggy python submission (verdict: Runtime Error):
n = int(input())
c = []
for i in range(n):
    k = []
    for j in range(i):
        if i % j == 0:
            k.append(j)
    if len(k) == 8:
        c.append(i)
print(len(c))

Fixed submission:
N = int(input())
if N >= 195:
    print(5)
elif N >= 189:
    print(4)
elif N >= 165:
    print(3)
elif N >= 135:
    print(2)
elif N >= 105:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
s = str(input())
k = int(input())
for i in range(k):
    if s[k] != 1:
        print(s[k])
        exit()
print(1)

Fixed submission:
s = str(input())
k = int(input())
for i in range(k):
    if s[i] != "1":
        print(s[i])
        exit()
print(1)
Buggy python submission (verdict: Runtime Error):
N, M= map(int, input().split(" "))
A = [int(i) for i in input().split()]
count = 0
for i in range(N):
    for k in range(i,N):
        S = sum(A[i:k+1])
        if S % M ==0:
            count = count +1

print(count)


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

q = N//K
mod = N % K
if mod > 0:
    print(1)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):

Sum = int(input())

r = 0
for i in range(26):
    for k in range(15):
        if 4*i+7*k == Sum:
            r = r +1
        else:
            r = r
if r > 0:
    print("Yes")
else:
    print("No")


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

q = N//K
mod = N % K
if mod > 0:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N, M = map(int, input().split(" "))
A = [int(i) for i in input().split()]
count = 0
for i in range(N):
    for k in range(i,N):
        S = sum(A[i:k+1])
        if S % M ==0:
            count = count +1
 
print(count)


Fixed submission:
n=int(input())
s=''
while n != 0:
    s = str( n % 2 ) + s
    n = - ( n // 2 )
print(s*(s != '') or 0)
Buggy python submission (verdict: Runtime Error):
my_rate = input()
if my_rate < 1200:
        print("ABC")
elif my_rate >=1200 and my_rate < 2800:
        print("ARC")
else:
        print("AGC")


Fixed submission:
my_rate = int(input())
if my_rate < 1200:
        print("ABC")
elif my_rate >=1200 and my_rate < 2800:
        print("ARC")
else:
        print("AGC")

Buggy python submission (verdict: Runtime Error):
my_rate = input()
if my_rate < 1200:
        print("ABC")
elif my rate >=1200 and my_rate < 2800:
        print("ARC")
else:
        print("AGC")

Fixed submission:
my_rate = int(input())
if my_rate < 1200:
        print("ABC")
elif my_rate >=1200 and my_rate < 2800:
        print("ARC")
else:
        print("AGC")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
cnt = 0
for i in range(N):
    while a[i] % 2==0:
        a[i] /= 2
        cnt += 1
print(cnt)


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
cnt = 0
for i in range(n):
    while a[i] % 2==0:
        a[i] /= 2
        cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = sorted(list(map(int,input().split())),reverse=True)
count = 0
while True:
    cnt = 0
    ccnt = 0
    done = 0
    for i in range(n):
        if a[i] % 2 == 0:
            if done == 0:
                a[i] = a[i] // 2
                cnt += 1
                done += 1
            else:
                a[i] = a[i] * 3
                ccnt += 1
        else:
            a[i] = a[i] * 3
            ccnt += 1
    if cnt  == 0:
        break
    else:
        count += 1
print(count)  

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
cnt = 0
for i in range(n):
    while a[i] % 2==0:
        a[i] /= 2
        cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
n = int(input())
s = str(input())
tt = [1 if i  == "W" else 0 for i in s]
B = [0] + tt
B = list(accumulate(B))
#print(B)
ans = float('Inf')
for i in range(0,n):
    #w = s[:i].count("W")
    ##W = sum(tt[:i])
    w = B[i]
    #print(W,w)
    #e = s[i:].count("E")
    E = len(tt[i:]) - sum(tt[i:])
    e = n - i - B[-1] + B[i]
    #print(E,e)
    #ans = min(ans,W+E)
    ans = min(ans,w+e)
print(ans)

Fixed submission:
from itertools import accumulate
n = int(input())
s = str(input())
tt = [1 if i  == "W" else 0 for i in s]
B = [0] + tt
B = list(accumulate(B))
#print(B)
ans = float('Inf')
for i in range(0,n+1):
    #w = s[:i].count("W")
    ##W = sum(tt[:i])
    w = B[i]
    #print(W,w)
    #e = s[i:].count("E")
    #E = len(tt[i:]) - sum(tt[i:])
    e = n - i - B[-1] + B[i]
    #print(E,e)
    #ans = min(ans,W+E)
    ans = min(ans,w+e)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input())
tt = [1 if i  == "W" else 0 for i in s]
ans = float('Inf')
for i in range(0,n):
    #w = s[:i].count("W")
    W = sum(tt[:i])
    #e = s[i:].count("E")
    E = len(tt[i:]) - sum(tt[i:])
    ans = min(ans,W+E)
print(ans)

Fixed submission:
from itertools import accumulate
n = int(input())
s = str(input())
tt = [1 if i  == "W" else 0 for i in s]
B = [0] + tt
B = list(accumulate(B))
#print(B)
ans = float('Inf')
for i in range(0,n+1):
    #w = s[:i].count("W")
    ##W = sum(tt[:i])
    w = B[i]
    #print(W,w)
    #e = s[i:].count("E")
    #E = len(tt[i:]) - sum(tt[i:])
    e = n - i - B[-1] + B[i]
    #print(E,e)
    #ans = min(ans,W+E)
    ans = min(ans,w+e)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input())
ans = float('Inf')
for i in range(n):
    w = s[:i].count("W")
    e = s[i:].count("E")
    ans = min(ans,w+e)
print(ans)


Fixed submission:
from itertools import accumulate
n = int(input())
s = str(input())
tt = [1 if i  == "W" else 0 for i in s]
B = [0] + tt
B = list(accumulate(B))
#print(B)
ans = float('Inf')
for i in range(0,n+1):
    #w = s[:i].count("W")
    ##W = sum(tt[:i])
    w = B[i]
    #print(W,w)
    #e = s[i:].count("E")
    #E = len(tt[i:]) - sum(tt[i:])
    e = n - i - B[-1] + B[i]
    #print(E,e)
    #ans = min(ans,W+E)
    ans = min(ans,w+e)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input())
ans = float('Inf')
for i in range(n):
    w = s[:i].count("W")
    e = s[i:].count("E")
    ans = min(ans,w+e)
print(ans)

Fixed submission:
from itertools import accumulate
n = int(input())
s = str(input())
tt = [1 if i  == "W" else 0 for i in s]
B = [0] + tt
B = list(accumulate(B))
#print(B)
ans = float('Inf')
for i in range(0,n+1):
    #w = s[:i].count("W")
    ##W = sum(tt[:i])
    w = B[i]
    #print(W,w)
    #e = s[i:].count("E")
    #E = len(tt[i:]) - sum(tt[i:])
    e = n - i - B[-1] + B[i]
    #print(E,e)
    #ans = min(ans,W+E)
    ans = min(ans,w+e)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = []
for i in range(1,n+1):
    for j in range(2,i):
        if i**j <= n:
            l.append(i**j)
print(max(l))

Fixed submission:
n = int(input())
l = []
for i in range(1,n+1):
    for j in range(2,100):
        if i**j <= n:
            l.append(i**j)
print(max(l))

Buggy python submission (verdict: Runtime Error):
n = input()
for i in range(i,n+1):
    if i**2 > n:
        print((i-1)**2)
        exit()
    elif i**2 == n:
        print(i**2)
        exit()
        

Fixed submission:
n = int(input())
l = []
for i in range(1,n+1):
    for j in range(2,100):
        if i**j <= n:
            l.append(i**j)
print(max(l))
Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
l = []
n = len(s)
for i in range(n):
    for j in range(i,n):
        l.append(s[i:j+1])
l = list(set(l))
l.sort()
#print(l)
print(l[int(input())-1])

Fixed submission:
s = list(input())
n = len(s)
k = int(input())
if k > n:
    K = n
else:
    K = k
anset = set()
for lenght in range(1,K+1):
    for i in range(n - lenght + 1):
        anset.add("".join(s[i:i+lenght]))
anset = list(anset)
anset.sort()
print(anset[k-1])