peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

n=II()
aa=LI()
ans=0
for i,a in enumerate(aa,1):
    if i&1 and a&1:ans+=1
print(ans)
# Judge status: Accepted
from numpy import cumsum

N = int(input())
A = list(map(int, input().split()))
a_cum = cumsum(A)
cand = [abs(a_cum[i] - (a_cum[-1] - a_cum[i])) for i in range(N)]
print(min(cand))
# Judge status: Accepted
S = input()

if 'N' in S and 'S' not in S:
    print('No')
elif 'S' in S and 'N' not in S:
    print('No')
elif 'W' in S and 'E' not in S:
    print('No')
elif 'E' in S and 'W' not in S:
    print('No')
else:
    print('Yes')
# Judge status: Wrong Answer
from collections import Counter

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

C = Counter(S)
count = 1
for i in C.values():
    count *= i+1
print(count-1)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

highest, ans = 0, 0

for l in a:
    if highest > l:
        ans += highest - l
    elif highest < l:
        highest = l
    else:
        pass
print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
s = input()
print(s[:k-1]+s[k-1].lower()+s[k:])
# Judge status: Wrong Answer
import collections

n = int(input())
s = [input() for _ in range(n)]

c = collections.Counter(s)

b, most = c.most_common(1)[0]

for i,j in c.most_common():
  if j != most:
    break
  print(i)
# Judge status: Accepted
N, M = map(int, input().split())
A = list(map(int, input().split()))

count = 0
for a in A:
  if (a < (sum(A) / (4 * M))):
    continue
  count += 1

result  = 'Yes' if (count >= M) else 'No'
print(result)
# Judge status: Wrong Answer
n=int(input())
s={}
for _ in range(n):
    i=input()
    if i in s:
        s[i]+=1
    else:
        s[i]=1
m=int(input())
for _ in range(m):
    j=input()
    if j in s:
        s[j]-=1
print(max(s.values()))
# Judge status: Wrong Answer
from collections import Counter
c = Counter(input())
if len(c) == 2:
    print("NO")
else:
    for vi in c.values():
        for vj in c.values():
            if abs(vi-vj) > 1:
                print("NO")
                quit(0)
    print("YES")
# Judge status: Wrong Answer
n, m = map(int, input().split())

drink = {}
for i in range(n):
  a, b = map(int, input().split())
  drink[a] = b

ans = 0
for ai, bi in sorted(drink.items(), key=lambda x:x[0]):
  ans += ai * min(drink[ai], m)
  m -= drink[ai]
  if m < 0:
    break
print(ans)
# Judge status: Accepted
def digit_sum2(num):
    total = 0
    for digit in str(num):
        total += int(digit)
    return total
    
n = input()
l = len(n)
n = int(n)

if n == 10 ** l -1:
    print( 9 * l )
elif 1 <= n <= 9:
    print(n)
else:
    print(max(digit_sum2(n), n // (10 ** (l-1)) - 1 + 9 * (l-1)))
# Judge status: Accepted
A, B, C, K = [int(_) for _ in input().split()]

if abs(A - B) > 10 ** 18:
    print("Unfair")
else:
    if K % 2 == 0:
        print(A - B)
    else:
        print(B - A)
# Judge status: Wrong Answer
n,m=map(int,input().split())
data=[1]*n
res=[1]+[0]*(n-1)
for i in range(m):
  x,y=map(int,input().split())
  data[x-1]-=1
  data[y-1]+=1
  if data[x-1]==0 and res[x-1]==1:
    res[y-1]=1
    res[x-1]=0
  else:
    res[y-1]=res[x-1]
ans=0
for i in range(n):
  if data[i]!=0 and res[i]!=0:
    ans+=1
print(ans)
# Judge status: Accepted
def resolve():
    S = input()
    while True:
        S = S[:-2]
        if S[:len(S)//2] == S[len(S)//2:]:
            print(len(S))
            return



if '__main__' == __name__:
    resolve()
# Judge status: Accepted
print('NO' if input().replace('eraser','').replace('erase','').replace('dreamer','').replace('dream','') else 'YES')
# Judge status: Accepted
x, y = map(int, input().split())

if x == y:
	res = 0
elif x < y:
	if (0 <= x and 0 <= y) or (x <= 0 and y <= 0):
		res = y - x
	else:
		if abs(x) >= y:
			res = abs(x) - y + 1
		else:
			res = y - abs(x) + 1
else:
	if 0 < x and 0 < y:
		res = x - y + 2
	elif x < 0 and y < 0:
		res = abs(y) - abs(x) + 2
	else:
		if x >= abs(y):
			res = x - abs(y) + 1
		else:
			res = abs(y) - x + 1
		
print(res)
# Judge status: Accepted
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    XY = [[int(x) for x in input().split()] for _ in range(N)]

    arr1 = []
    arr2 = []
    for x, y in XY:
        arr1.append(x - y)
        arr2.append(x + y)

    print(max(abs(max(arr1) - min(arr1)), abs(max(arr2) - min(arr2))))





if __name__ == '__main__':
    main()
# Judge status: Accepted
x=input()
sum=0
for i in x:
    sum+=int(i)
if(sum%9==0):print("Yes")
else:print("No")
# Judge status: Accepted
a,b=map(int, input().split())
n = b-a
bb = 0
for i in range(1,n+1):
  bb += i
print(bb-b)
# Judge status: Accepted
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

a,b,k = map(int,input().split())
ans = []
if b-a<=k:
    for i in range(a,b+1):
        print(i)
else:
    for i in range(a,a+k):
        ans.append(i)
    for i in range(b-k+1,b+1):
        ans.append(i)
    ans = set(ans)
    ans = list(ans)
    ans.sort()
    for i in range(len(ans)):
        print(ans[i])
# Judge status: Accepted
input()
print(sum([int(x) % 2 for x in input().split()[::2]]))
# Judge status: Accepted
import math

x = int(input())

f = False
for a in range(-200,200):
    for b in range(-200, 200):
        if a ** 5 - b ** 5 == x:
            print(a, b)
            f = True
            break
    if f == True:
        break
# Judge status: Wrong Answer
N = int(input())
A = []
for _ in range(5):
    A.append(int(input()))
print(N//(min(A))+5)
# Judge status: Accepted
n = int(input())
s = input()
a = s[:n//2]
b = s[n//2:]
if a == b:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n=int(input())
r=0
l=[]
for i in range(n):
  l.append(input())
l.sort()
for i in range(n-1):
  if l[i]!=l[i+1]:
    r+=1
  
print(r)
# Judge status: Accepted
import sys

# import bisect
# import numpy as np
from collections import deque
# map(int, sys.stdin.read().split())



def input():
    return sys.stdin.readline().rstrip()


def main():
    N =int(input())
    H = list(map(int,input().split()))

    con = 0
    ans =0
    for i in range(N-1):
        if H[i] >=H[i+1]:
            con +=1
            ans =max(ans,con)
        else:
            con =0

    print(ans)



if __name__ == "__main__":
    main()
# Judge status: Accepted
a = [list(map(int,input().split()))for i in range(3)]
x = [10,0,0]
y = [0,0,0]

for i in range(3):
    y[i] = a[0][i]-x[0]

for i in range(3):
    x[i] = a[i][0]-y[0]

flag = True

for i in range(3):
    for j in range(3):
        if a[i][j] != x[i]+y[j]:
            flag=False

if flag:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N = int(input())
hight = list(map(int, input().split()))

def smaller(n,m):
  if n >= m:
    return m
  else:
    return n

a = 0

for i in range(0,N):
  for j in range(i+1,smaller(N,i+50)):
    if j-i == hight[i] + hight[j]:
      a = a+1

print(a)
# Judge status: Accepted
from math import gcd as gcd
import numpy as np
N = int(input())
A = list(map(int,input().split()))

A = [0] + A + [0]

fromleft = np.array([0]*N)
fromright = np.array([0]*N)

for i in range(1,N):
    fromleft[i] = gcd(A[i],fromleft[i-1])
    fromright[-(i+1)] = gcd(A[-(i+1)],fromright[-i])

#print(fromleft)
#print(fromright)

ansgcd = [0]*N

for i in range(N):
    ansgcd[i] = gcd(fromright[i], fromleft[i])

print(max(ansgcd))
# Judge status: Accepted
a, b = map(int, input().split())

if a > b:
    print('safe')
else:
    print('unsafe')
# Judge status: Accepted
import collections
n = int(input())
s = input()
l = s.count("W")
r = s.count("E")
ans = 0
keep = r
minn = keep
if s[0] == "E":
    ans = 1
for i in range(1, n):
    if s[i - 1:i + 1] == "WW":
        keep += 1
    elif s[i - 1:i + 1] == "WE":
        keep += 0
    elif s[i - 1:i + 1] == "EW":
        keep += 0
    elif s[i - 1:i + 1] == "EE":
        keep -= 1
    if minn > keep:
        minn = keep
print([minn, minn - 1][ans])
# Judge status: Wrong Answer
A, B, K = map(int, input().split())

if K<=A:
  print(A-K, B)
elif A<K<=B:
  print(0, B-(K-A))
else:
  print(0,0)
"""
for k in range(K):
  if A>0 and B!=0:
    A+=-1
  elif A==0 and B>0:
    B+=-1
  elif A==0 & B==0:
    break
print(A, B)
"""
# Judge status: Accepted
N, A, B = map(int, input().split())

x = N // (A + B)
y = N % (A + B)


if y <= A:
    print(x * A + y)
else:
    print(x*A+A)
# Judge status: Wrong Answer
a=int(input())
if a>10:
    while a>100:
        a-=100
    while a>10:
        a-=10
if a==3:
    print("bon")
elif a==1 or a==6 or a==8:
    print("pon")
else:
    print("hon")
# Judge status: Wrong Answer
#!/use/bin/env python3

(n, k) = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]

like = []

for i in range(0, 10):
    if i not in a:
        like.append(i)

b = sorted(like)
k = b[0] if b[0] != 0 else b[1]

ans = k * n

print(ans)
# Judge status: Accepted
K,X=map(int,input().split())
if X<=K*500:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
a, b, c = input().split()
left = int(a+b) + int(c)
right = int(a) + int(b+c)
print(max(left, right))
# Judge status: Accepted
import sys
n = int(input())
for i in range(n):
  for j in range(n):
    if 4 * i + 7 * j == n:
      print('Yes')
      sys.exit()
print('No')
# Judge status: Accepted


n = int(input())
lst = []
for i in range(n):
  lst.append(int(input()))

not10nums = [i for i in lst if i%10!=0]
subnum=0
if len(not10nums)>0:
  subnum=min(not10nums)
  
sm =sum(lst)
if sm%10==0:
  sm-=subnum
if sm%10==0:
  sm=0
print(sm)
# Judge status: Accepted
s = input()
print("ARC" if s == "ABC" else "ABC")
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
B = []
for a in A:
  B.append(a%4)

ans = 'No'
if B.count(0) >= B.count(1)+B.count(3):
  ans = 'Yes'
if B.count(2) == 0 and B.count(0) == B.count(1)+B.count(3)-1:
  ans = 'Yes'
print(ans)
# Judge status: Wrong Answer
def invr():
    return(map(int, input().split()))


A, B, C, K = invr()

a = B + C
b = A + C
c = A + B
res = a - b
if K == 0:
    res = A - B
if abs(res) > 1000000000000000000:
    print(" Unfair ")
else:
    print(res)
# Judge status: Accepted
def factorial(n, r, p):
    ret = 1
    for i in range(n, n - r, -1):
        ret = (ret * i) % p
    return ret


def comb(n, r, p):
    r = min(r, n - r)
    return (factorial(n, r, p) * pow(factorial(r, r, p), p - 2, p)) % p


mod = 10 ** 9 + 7
x, y = map(int, input().split())
a = (2 * y - x) // 3
b = (2 * x - y) // 3
if (x + y) % 3 != 0 or a < 0 or b < 0:
    ans = 0
else:
    ans = comb(a + b, a, mod)
print(ans)
# Judge status: Wrong Answer
N = int(input())

A = []
B = []
for _ in range(N):
    a, b = [int(_) for _ in input().split()]
    A.append(a)
    B.append(b)
A.sort()
B.sort()

if N % 2 == 1:
    print(B[N//2] - A[N//2] + 1)
else:
    sa, ea = A[N//2 - 1], A[N//2]
    sb, eb = B[N//2 - 1], B[N//2]
    print(eb+ea - (sa+sb) + 1)
# Judge status: Accepted
print("Christmas" + " Eve" * (25 - int(input())))
# Judge status: Wrong Answer
n=int(input())
for i in range(n):
    if i**2<=n:c=i**2
print(c)
# Judge status: Accepted
s = input()
mods = [0]*2019
mods[0] = 1
accu = 0
for i, j in enumerate(reversed(s)):
    accu += int(j)*pow(10, i, 2019)
    accu %= 2019
    mods[accu] += 1
ans = 0
for i in mods:
    ans += i*(i-1)//2
print(ans)
# Judge status: Accepted
n,k = map(int , raw_input().split())
c = n - k 
p = k - 1
print 1 + (c + p-1)/p
# Judge status: Accepted
n = int(input())
arr = [int(j) for j in input().split()]

ans = 0
for i in range(1, n):
	ans += max(0, arr[i-1] - arr[i])
	if arr[i-1] > arr[i]:
		arr[i] = arr[i-1]

print(ans)
# Judge status: Wrong Answer
N = int(input())
A = [int(i) for i in input().split()]
count = {i:0 for i in range(9)}
for a in A:
    if a < 3200:
        count[a//400] = 1
    else:
        count[8] += 1
hp = sum([count[i] for i in count if i != 8])
print(hp + int(count[8] != 0 and hp == 0), min(8, hp + count[8]))
# Judge status: Accepted
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if K < N:
    print(K * X + (N - K) * Y)
else:
    print(N * X)
# Judge status: Accepted
S=input()
cnt=0
pre=''
tmp=''
for s in S:
    tmp+=s
    if tmp!=pre:
        pre=tmp
        tmp=''
        cnt+=1
print(cnt)
# Judge status: Wrong Answer
idade = int(input())

if idade in range(1 ,9):
    if idade == 3 :
        print("YES")
    elif idade == 5 :
        print("YES")
    elif idade == 7 :
        print("YES")
    else :
        print("NO")
else:
    exit()
# Judge status: Wrong Answer
x, y, z = map(int, input().split())
ans = 0
for i in range(z, x):
    if (x-i) % (y+i) == 0:
        count = (x-i) / (y+i)
        if count >= ans:
            ans = count
print(int(ans))
# Judge status: Accepted
N=int(input())

if N%9==0:
  print("Yes")

else:
  print("No")
# Judge status: Accepted
import math
H = int(input())
W = int(input())
N = int(input())
if W >= H:
  print(math.ceil(N/W))
else:
  print(math.ceil(N/H))
# Judge status: Accepted
X,Y= map(int,input().split())
b=(Y-2*X)%2
a=(4*X-Y)%2
B=(Y-2*X)/2
A=(4*X-Y)/2
if (b==0 and a==0 and A>=0 and B>=0):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n,k = map(int,input().split())
p = list(map(int,input().split()))
ans = 0
p.sort()

for i in range(k):
    ans += p[i]

print(ans)
# Judge status: Accepted
a,b,c =map(int,input().split())
if a ==5 and b ==5 and c ==7:
  print('YES')
elif a ==5 and b ==7 and c ==5:
  print('YES')
elif a ==7 and b ==5 and c ==5:
  print('YES')
else:
  print('NO')
# Judge status: Wrong Answer
a=int(input())
b=int(input())
h=int(input())

print((a+b)*h/2)
# Judge status: Wrong Answer
a, b = map(int, input().split())

n = 2
total = 0
while n > 0:
  if a > b:
    total=total+a
  else:
    total=total+b
  n-=1
print(total)
# Judge status: Accepted
import math

N = int(input())
NMAX = 100010
dp = [float('inf')] * NMAX
dp[0] = 0
for i in range(1, N + 1):
    dp[i] = i
    if i >= 6:
        for j in range(1, int(math.log(NMAX, 6)) + 1):
            dp[i] = min(dp[i], dp[i - 6 ** j] + 1)

    if i >= 9:
        for j in range(1, int(math.log(NMAX, 9)) + 1):
            dp[i] = min(dp[i], dp[i - 9 ** j] + 1)
# print(dp)
print(dp[N])
# Judge status: Wrong Answer
k=int(input());l=list(range(1,10))
for i in l:
  if len(l)==k: print(i); break
  for j in range(max(i%10-1,0),min(i%10+2,10)): l+=[i*10+j]
# Judge status: Wrong Answer
x, k, d = map(int, input().split())

y = max(0, x)
t = abs(y)//d
ans = 0

if k <= t:
    ans = y - d*k
 
else:
    ans = y - d*t
    if k>t:
        if (k-t)%2 == 1:
            ans = abs(ans - d)

if x < 0:
    ans += x  
print(abs(ans))
# Judge status: Accepted
n = int(input())
print("ABC" if n<1000 else "ABD")
# Judge status: Accepted
N = int(input())

for i in range(1,10):
    if N % i == 0 and N // i < 10:
        print('Yes')
        exit()
print('No')
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))
cnt = [0] * 10**5
for a in A:
    cnt[a] += 1
print(max(map(sum, zip(cnt, cnt[1:], cnt[2:]))))
# Judge status: Accepted
from math import *
S = int(input())
y = ceil(S/10**9)
x = (10**9*y)-S
print(0,0,10**9,1,x,y)
# Judge status: Accepted
#abc066_b
def is_odd_str(str):
    length=len(str)
    if length%2==1:
        return False
    else:
        if str[:length//2]==str[length//2:]:
            return True
        else :
            return False
S = input()
rep = len(S)
for i in range(rep):
    S = S[:-1]
    if is_odd_str(S):
        print(len(S))
        break
# Judge status: Accepted
X=int(input())
K=0
B=0
C=0
for i in range(0,360):
    B=B+X
    C=B%360
    K=K+1
    if C==0:
        print(K)
        break
# Judge status: Wrong Answer
N, M = map(int, input().split())
AC = [0]*N
WA = [0]*N

for i in range(M):
    p, S = input().split()
    p = int(p) 

    if S == "AC":
        AC[p-1] = 1
    elif S == "WA":
        if not AC[p-1]:
            WA[p-1] = 1

for j in range(N):
    if AC[j]==0:
        WA[j]==0
            
print(sum(AC), sum(WA))
# Judge status: Accepted
N = int(input())
ans = 0
for i in range(1, N + 1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    ans += i
print(ans)
# Judge status: Accepted
a, b = map(int, input().split())

ans = ""
if a < 0 and b > 0:
    ans = "Zero"
elif a > 0:
    ans = "Positive"
else:
    ans = "Positive" if abs(a - b + 1) % 2 == 0 else "Negative"

print(ans)
# Judge status: Accepted
import sys

# C - Walking Takahashi
X, K, D = map(int, input().split())

if D * K <= abs(X):
	print(abs(X) - D * K)
else:
	distance = abs(X) % D

	# 残りの移動回数
	count = K - (abs(X) // D)

	if count % 2 == 1:
		print(abs(D - distance))
	else:
		print(distance)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
l=[0]*n
for i in a:
  l[i-1]+=1
for i in range(n):
  print(l[i])
# Judge status: Wrong Answer
import bisect


def main():
    n = int(input())
    l = list(int(i) for i in input().split())
    l = sorted(l, reverse=True)

    cnt = 0

    for i in range(n - 2):
        a = l[i]
        for j in range(i + 1, n-1):
            b = l[j]
            cnt += bisect.bisect_right(l, a-b)-(j+1)

    print(cnt)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
k,x=map(int,input().split())
print([num for num in range(x-k+1,x+k)])
# Judge status: Accepted
a,b=map(int,input().split())
print(min(1,int(a%b)))
# Judge status: Wrong Answer
A, H = map(int,input().split())

if H % A == 0:
	print(H//A)
else:
	print(H//A+1)
# Judge status: Accepted
n,k=map(int,input().split())
P=list(map(int,input().split()))
S=[0]*(n+1)
S[1]=P[0]

for i in range(1,n):
    S[i+1]=S[i]+P[i]

ma=0
for i in range(k,n+1):
    s=S[i]-S[i-k]
    ma=max(ma,s)
print((ma+k)/2)
# Judge status: Accepted
S = input()

odd = len(S) % 2
little = odd + (1-odd)*2
start = len(S)-1-little

ans = 0
for i in range(start,0,-2):
  half = (i+1)//2
  a = S[:half]
  b = S[half:half*2]
  if a == b:
    #print(a,b)
    ans = len(a)*2
    break
    
    
print(ans)
# Judge status: Wrong Answer
a=input()
b=753
for i in range(len(a)-2):
  if abs(int(a[i]+a[i+1]+a[i+2])-753)<b:
    b=abs(int(a[i]+a[i+1]+a[i+2]))
print(b)
# Judge status: Wrong Answer
import bisect

N = int(input())
L = list(map(int, input().split()))

L.sort()
print(L)
ans = 0
for ai in range(N):
    for bi in range(ai+1, N):
        ci = bisect.bisect_left(L, L[ai]+L[bi])
        print(ai, bi, ci)
        if ci > bi:
            ans += ci - bi - 1
            print(ci - bi - 1)
        else:
            pass

print(ans)
# Judge status: Accepted
sx,sy,tx,ty=map(int,input().split())

s=""

s += "R"*(tx-sx)+"U"*(ty-sy)
s += "R"
s += "D"*(ty-sy+1)+"L"*(tx-sx+1)
s += "U"
s += "U"*(ty-sy)+"R"*(tx-sx)
s += "U"
s += "L"*(tx-sx+1)+"D"*(ty-sy+1)
s += "R"

print(s)
# Judge status: Accepted
s =input()
r =int(s[0:2])
l =int(s[2:4])

if 0 <r <13:
    if 0 <l <13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif 0 <l <13:
    if 0 <r <13:
        print('AMBIGUOUS')
    else:
        print('YYMM')
else:
    print('NA')
# Judge status: Accepted
n = int(input())
l = list(map(int,input().split()))
sorted_l = sorted(l)
left_med,right_med = sorted_l[int(n/2)-1], sorted_l[int(n/2)]

for i in l:
    if i <= left_med:
        print(right_med)
    
    else:
        print(left_med)
# Judge status: Wrong Answer
from collections import deque
N=int(input())
A=list(map(int,input().split()))
l=[]
r=[]
for i in range(N):
  if i%2==0:
    r.append(A[i])
  else:
    l.append(A[i])
l=list(reversed(l))
r=list(r)
print(*l,end=" ")
print(*r)
# Judge status: Accepted
A, B, C, D = map(int, input().split())

while True:
    C -= B
    if C <= 0:
        print("Yes")
        exit()
    A -= D
    if A <= 0:
        print("No")
        exit()
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))
m=sorted(l)
cnt=0
for i in range(n):
  if l[i]!=m[i]:
    cnt+=1
  if cnt>=3:
    print("NO")
    break
else:print("YES")
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
S = list(input())
from itertools import accumulate

Es = [0]*(N+1)
Ws = [0]*(N+1)
for i, s in enumerate(S, 1):
    if s=='E':
        Es[i] = 1
    else:
        Ws[i] = 1
Es = list(accumulate(Es))
Ws = list(accumulate(Ws))

ans = 10**18
for i in range(1, N+1):
    w = Ws[i-1]
    e = (Es[-1]-Es[i])
    ans = min(ans, w+e)
print(ans)
# Judge status: Accepted
t = input()


print(t.replace('?', 'D'))
# Judge status: Accepted
n = int(input())
l = []
for i in range(n):
    s, p = input().split()
    l.append((s, -int(p), int(i+1)))
    
L = sorted(l)
for s, p, i in L:
    print(i)
# Judge status: Accepted
import math
m,n = map(int,input().strip().split())
if n==1 or m==1:
    print("1")
else:
    print(math.ceil((m*n)/2))
# Judge status: Accepted
k,n=map(int,input().split())
a=list(map(int,input().split()))
d=[]

for i in range(n):
    if i!=0:
        d.append(abs(a[i]-a[i-1]))
    else:
        d.append(abs(a[i]-a[i-1]+k))
d.sort()

ans=sum(d)-max(d)
print(ans)
# Judge status: Accepted
n = int(input())
h = tuple(map(int, input().split()))
dp = [0]*n
dp[1] = abs(h[1] - h[0])
for i in range(2,n):
    dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]))
print(dp[-1])
# Judge status: Accepted
N = int(input())
mod = 10**9 + 7
u = 1
a = 1
b = 1
for i in range(N):
    u = u * 10
    a = a * 9
    b = b * 8
    u = u%mod
    a = a%mod
    b = b%mod
print((u-2*a+b)%mod)
# Judge status: Accepted
k,s = map(int,input().split())
c = 0

for x in range(k+1):
    for y in range(k+1):
        if k >= s-(x+y) >= 0:
            c += 1
print(c)
# Judge status: Wrong Answer
n=int(input())
s=input()
if n%2!=0:
  print('NO')
else:
  if s[0:n//2]==s[n//2:n]:
    print('Yes')
  else:
    print('No')
# Judge status: Accepted
def binarySearch(A, K):
    left = 1
    # right = n
    right = max(A)
    while left < right:
        mid = (left + right) // 2
        cost = sum(map(lambda x: (x-1)//mid, A))
        # print(left, right, mid)
        # print(K, cost)
        if K >= cost:
            right = mid
        else:
            left = mid + 1
    # return NOT_FOUND
    # return mid
    
    return left


N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))
# print(sorted(A))
print(binarySearch(A, K))
# Judge status: Wrong Answer
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

X, Y = lr()
answer = 10 ** 10
if X <= Y:
    answer = Y-X
if -X < Y:
    answer = min(answer, 1+X+Y)
if X < -Y:
    answer = min(answer, 1-Y-X)
if -X < -Y:
    answer = min(answer, 2-Y+X)

print(answer)
# Judge status: Wrong Answer
s=input()
a=int(s[0:2])
b=int(s[2:])
if 1<=a<=99 and 1<=b<=31:
    if 1<=a<=12 and 1<=b<=12:
        print('AMBIGUOUS')
    else:
        print('YYMM')
elif 1<=b<=99 and 1<=a<=31:
    print('MMYY')
else:
    print('NA')
# Judge status: Wrong Answer
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

S = list(readline().rstrip())
K = int(readline())
N = len(S)
for i,s in enumerate(S):
    t = ord(s)-97
    if 26 - t <= K:
        S[i] = 'a'
        K -= 26-t
S[-1] = chr((ord(S[i]) + K%26)%97+97)
print(''.join(S))
# Judge status: Accepted
n,m=map(int,input().split())
if n%2==1 or n==4:
    for i in range(1,m+1):
        print(i,n+1-i)
else:
    b=0
    for i in range(1,m+1):
        if i>=(n//2+1)/2:
            b=1
        print(i+b,n+1-i)
# Judge status: Wrong Answer
N = int(input())
X = list(map(int, input().split()))
Xc = X.copy()
Xc.sort()

d = N // 2
dn = X[d]

for i in range(N):
    if X[i] < dn:
        print(Xc[d])
    else:
        print(Xc[d-1])
# Judge status: Accepted
s=input()
counter1=0
counter0=0
for i in range(len(s)):
  if s[i]=='0':
    counter0+=1
  else:
    counter1+=1
print(2*min(counter1,counter0))