Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

N = int(input())
D = {}
for _ in range(N):
  s = input()
  if s in D:
    D[s] += 1
  else:
    D[s] = 1
L = [d[0] for d in D.items() if d[1] == max(D.values())]
for l in sorted(L):
  print(l)

### FIXED CODE ###

N = int(input())
D = {}
for _ in range(N):
  s = input()
  if s in D:
    D[s] += 1
  else:
    D[s] = 1
m = max(D.values())
for k, v in sorted(D.items()):
  if v==m:
    print(k)
### BUGGY CODE ###

#coding: utf-8

def getInput():
    in_row = [ int(x) for x in input().split(" ") ]
    return in_row

def judgeTakahashi(in_row):
    A = in_row[0] # initial stock
    B = in_row[1] # initial Takahashi
    C = in_row[2]
    D = in_row[3]
    loop = []

    if A < B:
        return False

    # daytime - purchase
    while A not in loop:
        loop.append(A)
        A %= B

        # night - fill
        if A <= C:
            A += D

        if A < B:
            return False
    
    return True
    
    
if __name__ == "__main__":
    N = int(input())
    for i in range(N):
        in_row = getInput()
        result = "Yes" if judgeTakahashi(in_row) else "No"
        print(result)
    


### FIXED CODE ###

#coding: utf-8

def getInput():
    in_row = [ int(x) for x in input().split(" ") ]
    return in_row

def gcd(n1, n2):
    while n1 % n2 != 0:
        if n1 < n2:
            n1, n2 = n2, n1
        n1 %= n2
    return n2
            
def judgeTakahashi(in_row):
    A = in_row[0]
    B = in_row[1]
    C = in_row[2]
    D = in_row[3]
    g = gcd(B, D)

    if B > A:
        return False
    if B > D:
        return False
    if C >= B:
        return True
    
    if B-g+(A%g) > C:
        return False
    else:
        return True

if __name__ == "__main__":
    N = int(input())
    assert gcd(1071, 1029) == 21, "error"
    assert not(judgeTakahashi([1, 10, 1, 1])), "error"
    for i in range(N):
        in_row = getInput()
        result = "Yes" if judgeTakahashi(in_row) else "No"
        print(result)
### BUGGY CODE ###

n,k=map(int, input().split())
p=list(map(int,input().split()))

max=p[0:k]
for i in range(n):
  if sum(p[i:i+k]) >= sum(max):
    max=p[i:i+k]

ans=0.0
#print(max,k)
for i in max:
  x=float(1/i)
  for j in range(1,i+1):
    ans+=float(j*x)
print(ans)

### FIXED CODE ###

import numpy as np
n,k=map(int, input().split())
p=list(map(int,input().split()))


s=[]
p=np.array(p)
sum=0
for i in range(n):
  sum+=(1+p[i])/2
  s.append(sum)
#print(s)
if k==n:
  print(s[-1])
  exit()
max=s[k-1]-s[0]
for j in range(1,n-k):
  #print(j)
  if max<= s[j+k]-s[j]:
    max=s[j+k]-s[j]
  
print(max)
### BUGGY CODE ###

def main():
    mn = int(input())
    j = [int(x) for x in input().split()]
    [print(j.count(x)) for x in range(1, mn + 1)]


if __name__ == '__main__':
    main()

### FIXED CODE ###

N = int(input())
from collections import Counter as C
l = dict(C((int(x) for x in input().split())))
for x in range(1,N+1):
    print(l.get(x,0))
### BUGGY CODE ###

import itertools
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,MOD = map(int,input().split())
if N == 1:
    print(1)
    exit()
graph = [[] for _ in range(N+1)]
for _ in range(N-1):
    x,y = map(int,input().split())
    graph[x].append(y)
    graph[y].append(x)

def dfs_1(v=1,parent=None):
    # 子ごとに、そこを黒くして適切 or 完全白
    # dp_1 + 1 の積
    x = 1
    for w in graph[v]:
        if w == parent:
            continue
        x *= (dfs_1(w,v) + 1)
    dp_1[v] = x
    return x

dp_1 = [0] * (N+1) # 自分を黒く塗って、子側の部分木を適切に塗る方法
dfs_1()

def dfs_2(v=1,parent=None,x=1):
    # それぞれの子以外の情報をマージして、子に渡さなければいけない
    arr = [1 + dp_1[w] if w != parent else x for w in graph[v]]
    L = [1] + list(itertools.accumulate(arr[:-1], lambda x,y: x*y%MOD))
    R = list(itertools.accumulate(arr[::-1][:-1], lambda x,y: x*y%MOD))[::-1] + [1]
    products = [x*y%MOD for x,y in zip(L,R)]
    dp[v] = arr[0] * products[0] % MOD
    for w,p in zip(graph[v],products):
        if w==parent:
            continue
        dfs_2(w,v,p+1)

dp = [0] * (N+1)
dfs_2()

print('\n'.join(map(str,dp[1:])))

### FIXED CODE ###

import itertools
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,MOD = map(int,input().split())
if N == 1:
    print(1)
    exit()
graph = [set() for _ in range(N)]
for row in sys.stdin.readlines():
    x,y = map(int,row.split())
    graph[x-1].add(y-1)
    graph[y-1].add(x-1)

ldp = [None] * N
rdp = [None] * N

def dfs_1(v=0,parent=None):
    # 子ごとに、そこを黒くして適切 or 完全白
    graph[v].discard(parent)
    ldp[v] = [1] * (len(graph[v])+1)
    rdp[v] = [1] * (len(graph[v])+1)
    vals = [dfs_1(w,v)+1 for w in graph[v]]
    for i,x in enumerate(vals,1):
        ldp[v][i] = ldp[v][i-1] * x % MOD
    for i,x in enumerate(reversed(vals),1):
        rdp[v][-i-1] = rdp[v][-i] * x % MOD
    return ldp[v][-1]

dfs_1()

dp = [None] * N
q = [(0,1)]
while q:
    v,x = q.pop()
    dp[v] = x*ldp[v][-1]%MOD
    for w,L,R in zip(graph[v],ldp[v][:-1],rdp[v][1:]):
        q.append((w,x*L*R%MOD+1))

print('\n'.join(map(str,dp)))
### BUGGY CODE ###

n = int(input())

dam = list(map(int,input().split()))

yama = [10**8 for _ in range(n)]

ans = [10**8 for _ in range(n)]

for i in range(n):
    if i == 0:
        yama[i] = min(dam[i], dam[-1]) * 2
    else:
        yama[i] = min(dam[i-1], dam[i]) * 2


for i in range(0,yama[0]+1,2):
    for j in range(n):
        if j == 0:
            ans[j] = i
        else:
            ans[j] = (dam[j-1] - ans[j-1]//2) * 2
            if ans[j] > yama[j]:
                break
    else:
        if (ans[0] + ans[-1])//2 == dam[-1]:
            print(*ans)
            exit()

### FIXED CODE ###

n = int(input())
li = list(map(int,input().split()))

x = 0

for i in range(n):
    if i%2 == 0:
        x += li[-i-1]
    else:
        x -= li[-i-1]

ans = [x]

tmp = x

for i in range(n-1):
    s = 2*li[i] - tmp
    ans.append(s)
    tmp = s
    
print(*ans)
### BUGGY CODE ###

def func(S,N):
    dic = {'a':'','b':'','c':'','d':'','e':'','f':'','g':'','h':'','i':'','j':'','k':'','l':'','m':'','n':'','o':'','p':'','q':'','r':'','s':'','t':'','u':'','v':'','w':'','x':'','y':'','z':''}
    for i in range(N):
        dic[S[i]] = dic[S[i]] + str(i)
    tmp = []
    for value in dic.values():
        if value == '':
            continue
        tmp.append(int(value))
    tmp.sort()
    return tmp
S = input()
T = input()
N = len(S)
if func(S,N) == func(T,N):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

s = input()
t = input()
dict_st = {}
dict_ts = {}
for x, y in zip(s, t):
    if x not in dict_st:
        dict_st[x] = y
    else:
        if dict_st[x] != y:
            print("No")
            break
    if y not in dict_ts:
        dict_ts[y] = x
    else:
        if dict_ts[y] != x:
            print("No")
            break
else:
    print("Yes")
### BUGGY CODE ###

A,B,K = map(int, input().split())
for i in range(K):
    if A!=0:
        A=A-1
    else:
        B=B-1
print(A,B)

### FIXED CODE ###

A,B,K = map(int, input().split())
if K>(A+B):
    print(0,0)
elif K>=A:
    print(0, B-(K-A))
else:
    print(A-K,B)
### BUGGY CODE ###

import sys
input=sys.stdin.readline
H,W,D = map(int,input().split())
MP = [None]*(H*W)
for h in range(H):
  X = list(map(int,input().split()))
  for w in range(W):
    MP[X[w]-1]=[h+1,w+1]
Q = int(input())
for h in range(Q):
  L,R = map(int,input().split())
  ans = 0
  for l in range(L,R,D):
    lD = l+D
    ans += abs(MP[lD-1][0]-MP[l-1][0])+abs(MP[lD-1][1]-MP[l-1][1])
  print(ans)

### FIXED CODE ###

import sys
input=sys.stdin.readline
H,W,D = map(int,input().split())
A = []
for h in range(H):
  A = A + list(map(int,input().split()))
for i in range(H*W):
  A[i]=(A[i], i%W, i//W)
A.sort()
Dist=[0]*(H*W)
for i in range(H*W):
  if i>=D:
    Dist[i] = Dist[i-D] + abs(A[i][1]-A[i-D][1]) + abs(A[i][2]-A[i-D][2])
Q = int(input())
for q in range(Q):
  L,R = map(int,input().split())
  ret = Dist[R-1]-Dist[L-1]
  print(ret)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n, m = [int(x) for x in input().split()]
g = [[] for _ in range(n)]

for _ in range(m):
    l, r, d = [int(x) for x in input().split()]
    l -= 1
    r -= 1
    g[l].append([r, d])
    g[r].append([l, -d])

visited = [0] * n

for i in range(n):
    if visited[i] != 0:
        continue
    d = [0] * n
    d[i] = 0
    stack = [i]
    while stack:
        u = stack.pop()
        visited[u] = 1
        for v, d_ in g[u]:
            visited[v] = 1
            if d[v] == 0:
                d[v] = d[u] + d_
                stack.append(v)
            else:
                if d[v] != d[u] + d_:
                    print("No")
                    sys.exit()
print("Yes")


### FIXED CODE ###

n, m = map(int, input().split())
ed = [[] for _ in range(n)]  # グラフ
v = [None] * n
for _ in range(m):
  l, r, d = map(int, input().split())
  ed[l-1].append((r-1, d))  # l -> r
  ed[r-1].append((l-1, -d))  # r -> l

visited = [False] * n  # 訪問フラグ（非連結の可能性の為）

def dfs(start):
  s = [start]
  v[start] = 0
  while s:
    label = s.pop()
    if visited[label] == False:
      visited[label] = True
      for to, dist in ed[label]:
        if v[to] is None:
          v[to] = v[label] + dist
          s.append(to)
        else:
          if v[to] != v[label] + dist:
            return False
  return True

is_exist = True
for i in range(n):
  if v[i] is None:
    if not dfs(i):
      print('No')
      is_exist = False
      break
if is_exist:
  print("Yes")
### BUGGY CODE ###

# diverta 2019 Programming Contest: B – RGB Boxes
R, G, B, N = [int(i) for i in input().split()]

bingo = 0

for r in range(0, 3001):
    for g in range(0, 3001):
        b = (N -(R * r + G * g)) // B
        if b < 0:
            break
        elif R * r + G * g + B * b == N:
            bingo += 1

print(bingo)

### FIXED CODE ###

# diverta 2019 Programming Contest: B – RGB Boxes
R, G, B, N = [int(i) for i in input().split()]

bingo = 0

for r in range(0, 3001):
    if R * r > N:
        break
    else:
        for g in range(0, 3001):
            b = (N -(R * r + G * g)) // B
            if b < 0:
                break
            elif R * r + G * g + B * b == N:
                bingo += 1

print(bingo)
### BUGGY CODE ###

from collections import Counter
s=list(input())
lst=[]  #sのリバース
lst2=[] #累積和を2019で割ったあまり
for i in range(len(s)):
    lst.append(s.pop())

num=0
for j in range(len(lst)):
    lst2.append(num)
    num+=int(lst[j])*10**(j)
lst2.append(num)
for k in range(len(lst2)):
    lst2[k]=lst2[k]%2019
ans=0
cou=dict(Counter(lst2))
for x in cou.values():
    ans+=x*(x-1)/2
print(int(ans))

### FIXED CODE ###

from collections import Counter

s=input()[::-1]
ans=0
lst=[0]
num=0
p=1
for i in s:
    lst.append((int(i)*p+lst[-1])%2019)
    p=p*10%2019

ans=sum(x*(x-1)//2 for x in Counter(lst).values())
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3
n, m, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))
for i in range(1, n + 1):
    a[i] = a[i - 1] + a[i]

for i in range(1, m + 1):
    b[i] = b[i - 1] + b[i]
ans = 0
t = 0
j = m
for i in range(n + 1):
    while k - a[i] < b[j] and j > 0:
        j -= 1
    if k - a[i] >= b[j]:
        ans = max(ans, j + i)
    j = m

print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
A = [0]
B = [0]
for i in range(n):
    A.append(A[i] + a[i])
for i in range(m):
    B.append(B[i] + b[i])
ans = 0
j = m
for i in range(n + 1):
    if A[i] > k:
        break
    while j > 0 and k - A[i] < B[j]:
        j -= 1
    ans = max(ans, i + j)

print(ans)
### BUGGY CODE ###

N,K = map(int, input().split())

c = []

for i in range(N):
	c.append(input().split())

d = []
e = []

for j in range(N):
	e.append(c[j][0])
	e = e * int(c[j][1])
	d = d + e
	e = []

d.sort()

print(d[K-1])

### FIXED CODE ###

#N,Kの取得
N,K = list(map(int,input().split()))

#[(a_1,b_1),(a_2,b_2),...]の形でリストを作成
numList = []
for a,b in [ map(int,input().split()) for _ in range(N) ]:
	numList.append((a,b))

#作成したリストを、aの大きさで昇順ソート
numList = sorted(numList,key=lambda x:x[0])

#小さい順に要素数bを足していき、Kを超えた段階で出力、終了
count = 0
for a,b in numList:
	count += b
	if count>=K:
		print(a)
		quit()
### BUGGY CODE ###

def run(N, C, D, c):
    '''
    マス番号に応じて3色に塗る必要がある
    (i+j)%3が0, 1, 2それぞれに対して、ある色に塗るコストを計算する
    0, 1, 2それぞれのC色のコストのパターンができる
    上記コストに対してC色から3色を選択する全パターンのうち最小のコストを求める
    '''
    cost0 = {}
    cost1 = {}
    cost2 = {}
    for k in range(C):
        cost0[k] = 0
        cost1[k] = 0
        cost2[k] = 0
        for i in range(N):
            for j in range(N):
                if (i+j+2) % 3 == 0:
                    color = c[i][j] - 1
                    cost = D[color][k]
                    cost0[k] += cost
                elif (i+j+2) % 3 == 1:
                    color = c[i][j] - 1
                    cost = D[color][k]
                    cost1[k] += cost
                elif (i+j+2) % 3 == 2:
                    color = c[i][j] - 1
                    cost = D[color][k]
                    cost2[k] += cost
    ret = max(cost0.values()) + max(cost1.values()) + max(cost2.values())
    for i in range(C):
        for j in range(C):
            for k in range(C):
                if i == j or j == k or k == i:
                    continue
                else:
                    ret = min(ret, cost0[i]+cost1[j]+cost2[k])
    return ret


def main():
    N, C = map(int, input().split())
    D = []
    for i in range(C):
        D.append(list(map(int, input().split())))
    c = []
    for i in range(N):
        c.append(list(map(int, input().split())))
    print(run(N, C, D, c))


if __name__ == '__main__':
    main()

### FIXED CODE ###

def run(N, C, D, c):
    '''
    マス番号に応じて3色に塗る必要がある
    (i+j)%3が0, 1, 2それぞれに対して、何色が何個あるか計算しておく
    ある色に塗るコストを計算する
    0, 1, 2それぞれのC色のコストのパターンができる
    上記コストに対してC色から3色を選択する全パターンのうち最小のコストを求める
    '''
    color0 = {}
    color1 = {}
    color2 = {}
    for k in range(C):
        color0[k] = 0
        color1[k] = 0
        color2[k] = 0
    for i in range(N):
        for j in range(N):
            color = c[i][j] - 1
            if (i+j+2) % 3 == 0:
                color0[color] += 1
            elif (i+j+2) % 3 == 1:
                color1[color] += 1
            elif (i+j+2) % 3 == 2:
                color2[color] += 1
    cost0 = {}
    cost1 = {}
    cost2 = {}
    for k in range(C):
        cost0[k] = 0
        cost1[k] = 0
        cost2[k] = 0
        for i in range(C):
            cost = D[i][k]
            cost0[k] += cost * color0[i] 
            cost1[k] += cost * color1[i] 
            cost2[k] += cost * color2[i] 
    ret = max(cost0.values()) + max(cost1.values()) + max(cost2.values())
    for i in range(C):
        for j in range(C):
            for k in range(C):
                if i == j or j == k or k == i:
                    continue
                else:
                    ret = min(ret, cost0[i]+cost1[j]+cost2[k])
    return ret


def main():
    N, C = map(int, input().split())
    D = []
    for i in range(C):
        D.append(list(map(int, input().split())))
    c = []
    for i in range(N):
        c.append(list(map(int, input().split())))
    print(run(N, C, D, c))


if __name__ == '__main__':
    main()
### BUGGY CODE ###

import math
import collections
n=int(input())
a=list(map(int,input().split()))

l=[]
d=collections.Counter(a)
count=0

for i in range(n):
    c=0
    d[a[i]]-=1
    if d[a[i]]==0:
        del d[a[i]]
    for j in range(1,math.floor(math.sqrt(a[i]))+1):
        if a[i]%j==0:
            if j in d:
                c=1
                break
            if a[i]%(a[i]//j)==0:
                if (a[i]//j) in d:
                    c=1
                    break
    
    if c==0:
        count+=1
    if a[i] not in d:
        d[a[i]]=1
    else:
        d[a[i]]+=1
print(count)

### FIXED CODE ###

n = int(input())
a = sorted(list(map(int,input().split())))
am = a[-1]+1
b = [0]*am
for i in a:
    b[i]+=1
    if b[i]==1:
        for j in range(i*2,am,i):
            b[j]=2
print(b.count(1))
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
for i in range(1,n+1):
    print(a.count(i))

### FIXED CODE ###

import collections
n=int(input())
a=list(map(int,input().split()))
c=collections.Counter(a)
for i in range(1,n+1):
    print(c[i])
### BUGGY CODE ###

import sys
input = sys.stdin.readline
def main():
	N,W = map(int, input().split())
	dp = [0 for _ in range(W+1)]
	for _ in range(N):
		w,v = map(int, input().split())
		for i in range(W,0,-1):
			if i>=w:
				dp[i] = max(dp[i],dp[i-w]+v)
		
	print(dp[-1])

if __name__ == '__main__':
	main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
def main():
	N,W = map(int, input().split())
	dp = [0 for _ in range(W+1)]
	for _ in range(N):
		w,v = map(int, input().split())
		for i in range(W,0,-1):
			if i>=w:
				a = dp[i]
				b = dp[i-w]+v
				if a>b:
					dp[i] = a
				else:
					dp[i] = b
		
	print(dp[-1])

if __name__ == '__main__':
	main()
### BUGGY CODE ###

A = list(input())
N = int(input())
L = []
for i in range(len(A)):
    tmp = A[i:]
    while tmp:
        L.append(''.join(tmp))
        tmp.pop()
L = list(set(L))
L.sort()
print(L[N-1])

### FIXED CODE ###

A = list(input())
K = int(input())
L = []
for i in range(len(A)):
    for j in range(i+1, i+K+1):
        L.append(''.join(A[i:j]))
L = list(set(L))
L.sort()
print(L[K-1])
### BUGGY CODE ###

n=int(input())
a=map(int,input().split())
h=list(a)
b=range(n)
c=list(b)
for x in range(n):
 c[x]=str(h.index(x+1)+1)
print(" ".join(c))

### FIXED CODE ###

n=int(input())
a=map(int,input().split())
h=list(a)
for m in range(n):
 h[m]=h[m]*1000000+m+1
h.sort()
for m in range(n):
 h[m]=str(h[m]%1000000)
print(" ".join(h))
### BUGGY CODE ###

N, Q = list(map(int, input().split()))
S = input()
T = [list(map(int, input().split())) for _ in range(Q)]

index = {i for i in range(N-1) if (S[i] == 'A') and (S[i+1] == 'C')}

for i in range(Q):
  l, r = T[i][0], T[i][1]
  print(len(index & set(range(l-1, r-1))))

### FIXED CODE ###

N, Q = list(map(int, input().split()))
S = input()
T = [list(map(int, input().split())) for _ in range(Q)]

total_list = []
total = 0
try:
  for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
      total += 1
    total_list.append(total)

  for i in range(Q):
    l, r = T[i][0], T[i][1]
    if l != 1:
      print(total_list[r-2]-total_list[l-2])
    else:
      print(total_list[r-2])
except IndexError:
  print(0)
### BUGGY CODE ###

n,k = map(int, input().split())
a = list(map(int, input().split()))

a = [i for i in a if i <k]
n = len(a)

DP1 = [[False]*(k+1) for i in range(n+1)]
DP1[0][0] = True
DP2 = [[False]*(k+1) for i in range(n+1)]
DP2[0][0] = True
b = a[::-1]

for i in range(n):
    for j in range(k+1):
        if DP1[i][j]:
            DP1[i+1][j] = True
            if a[i]+j <= k:
                DP1[i+1][a[i]+j] = True
        if DP2[i][j]:
            DP2[i+1][j] = True
            if b[i]+j <= k:
                DP2[i+1][b[i]+j] = True

for i in range(n+1):
    q = [0]
    for j in range(k+1):
        q.append(q[-1]+int(DP2[i][j]))
    DP2[i] = q

ans = 0
for i in range(n):
    use = False
    for j in range(k+1):
        if not DP1[i][j]:
            continue
        left = max(0, k-a[i]-j)
        right = k-j
        if DP2[n-i-1][right] - DP2[n-i-1][left]:
            use = True
            break
    if not use:
        ans += 1

print(ans)

### FIXED CODE ###

import numpy as np

def main():
    def check(m):
        DP = np.full(k+1, False)
        DP[0] = True
        for i in range(n):
            if i == m:
                continue
            DP[a[i]:] = np.logical_or(DP[a[i]:], DP[:k+1-a[i]])
        return any(DP[i] for i in range(k-a[m], k))

    n,k = map(int, input().split())
    a = list(map(int, input().split()))

    a = [i for i in a if i <k]
    a.sort()
    n = len(a)

    left = -1
    right = n

    while right-left > 1:
        mid = (right+left)//2
        if check(mid):
            right = mid
        else:
            left = mid

    print(right)

main()
### BUGGY CODE ###

N=int(input())
S=input()
out=0
n1=0
n2=0
for i in range (0,N-3):
    mark1=i
    mark2=i
    n1=0
    n2=0
    if S[i]=="R":
        def1="G"
        def2="B"
    if S[i]=="G":
        def1="R"
        def2="B"
    if S[i]=="B":
        def1="G"
        def2="R"
    for j in range (i+3,N):
        if def1==S[j]:
            for k in range (mark1+1,j):
                if S[k]==def2:
                    n1 = n1 + 1
            mark1=j
            out = out+n1
            if (i+j)%2==0:
                if S[int((i+j)/2)]==def2:
                    out =out -1
        elif def2==S[j]:
            for k in range (mark2+1,j):
                if S[k]==def1:
                    n2 = n2 + 1
            mark2=j
            out = out+n2
            if (i+j)%2==0:
                if S[int((i+j)/2)]==def1:
                    out =out -1
print(out)

### FIXED CODE ###

N=int(input())
S=input()
r = S.count("R")
g = S.count("G")
b = S.count("B")
out =r*g*b

for i in range(0,N):
    w = 1
    while i+w*2<N:
        if S[i]!=S[i+w] and S[i]!=S[i+2*w] and S[i+w]!=S[i+2*w]:
            out = out -1
        w = w+1
        
print(out)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def dijkstra(s,n,cost,l):
    d = [float("inf")] * n
    used = [False] * n
    d[s] = 0
    
    while True:
        v = -1
        for i in range(n):
            if (not used[i]) and (v == -1):
                v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
            break
        used[v] = True
        dist_v = d[v]
        for j in range(n):
            weight = cost[v][j]
            alt = dist_v + weight
            if ((dist_v - 1) // l) != ((alt - 1) // l) and dist_v != 0:
                alt = ((dist_v - 1) // l + 1) * l + weight         
            d[j] = min(d[j],alt)
    return d
 
n,m,l = map(int, input().split())
abc = [list(map(int, input().split())) for i in range(m)]
q = int(input())
st = [list(map(int, input().split())) for i in range(q)]
path = [[float("inf") for i in range(n)] for i in range(n)]
ans_list = []
for i in abc:
  a,b,cost = i[0]-1, i[1]-1, i[2]
  if cost <= l:
    path[a][b] = cost
    path[b][a] = cost
for s in range(n):
  ans_list.append(dijkstra(s,n,path,l))
for i in st:
  s, t = i[0] - 1, i[1] - 1
  ans = ans_list[s][t]
  if ans == float("inf"):
    ans = -1
  else:
    ans = (ans - 1) // l
  print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

def dijkstra(s,n,cost,l):
    d = [float("inf")] * n
    used = [False] * n
    d[s] = 0
    
    while True:
        v = -1
        for i in range(n):
            if (not used[i]) and (v == -1):
                v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
            break
        used[v] = True
        dist_v = d[v]
        for j, weight in enumerate(cost[v]):
            alt = dist_v + weight
            r = (dist_v - 1) // l
            if r != ((alt - 1) // l) and dist_v != 0:
                alt = (r + 1) * l + weight         
            d[j] = min(d[j],alt)
    return d

n,m,l = map(int, input().split())
path = [[float("inf") for i in range(n)] for i in range(n)]
ans_list = []
for i in range(m):
  a,b,cost = map(int, input().split())
  a -= 1
  b -= 1
  if cost <= l:
    path[a][b] = cost
    path[b][a] = cost
for s in range(n):
  ans_list.append(dijkstra(s,n,path,l))
q = int(input())

for i in range(q):
  s,t = map(int, input().split())
  ans = ans_list[s-1][t-1]
  if ans == float("inf"):
    ans = -1
  else:
    ans = (ans - 1) // l
  print(ans)
### BUGGY CODE ###

n = int(input())
s = list(input())

num_eas = s.count('E')



minres = 1000000
for i in range(n):
    a = s[:i].count("W")
    res = 2*a + num_eas - i
    if res < minres:
        minres = res

print(minres)


### FIXED CODE ###

n = int(input())
s = list(input())

num_eas = s.count('E')


res = []
res += [num_eas - s[0].count("E")]

for i in range(1,n):
    res += [res[i-1] + s[i-1].count("W") - s[i].count("E")]
    
print(min(res))