Harryxun/stf_run huggingface dataset:
import numpy as np

n, m, q = map(int, input().split())
a = list(range(q))
b = list(range(q))
c = list(range(q))
d = list(range(q))
for i in range(q):
    a[i], b[i], c[i], d[i] = map(int, input().split())

A = np.sort(np.random.randint(1, m+1, n))


def calc_energy(A):
    energy = 0.
    for i in range(q):
        if (A[b[i]-1] - A[a[i]-1]) == c[i]:
            energy += d[i]
    return energy


T = 20000
temperature_init = 10
for t in range(T):
    A_prev = np.copy(A)
    energy_prev = calc_energy(A_prev)

    idx = np.random.randint(0, n)
    A[idx] = np.random.randint(1, m+1)
    energy = calc_energy(A)

    if np.random.rand() < (energy - energy_prev)/temperature:
        pass
    else:
        A = np.copy(A_prev)
    temperature  = temperature_init*(1/(1+t**4))

print(np.int(calc_energy(A)))


### FIXED CODE ###

import numpy as np

n, m, q = map(int, input().split())
a = list(range(q))
b = list(range(q))
c = list(range(q))
d = list(range(q))
for i in range(q):
    a[i], b[i], c[i], d[i] = map(int, input().split())

A = np.sort(np.random.randint(1, m+1, n))


def calc_energy(A):
    energy = 0.
    for i in range(q):
        if (A[b[i]-1] - A[a[i]-1]) == c[i]:
            energy += d[i]
    return energy


T = 20000
temperature = 100
for t in range(T):
    A_prev = np.copy(A)
    energy_prev = calc_energy(A_prev)

    idx = np.random.randint(0, n,3)
    A[idx] = np.random.randint(1, m+1,3)
    A = np.sort(A)
    energy = calc_energy(A)

    if np.random.rand() < (energy - energy_prev)/temperature:
        pass
    else:
        A = np.copy(A_prev)
    temperature  = temperature*0.999#temperature_init*(1/(1+t**4))

print(np.int(calc_energy(A)))
whlie True:
  HW=input().split()
  HW=[int(x) for x in HW]
  if HW[0] == 0: break
  print('#'*HW[1])
  for i in range(HW[0]-2):
    print('#',end='')
    print('.'*(HW[1]-2),end='#')
  print('#'*HW[1])
  print()

### FIXED CODE ###

while True:
  HW=input().split()
  HW=[int(x) for x in HW]
  if HW[0] == 0: break
  print('#'*HW[1])
  for i in range(HW[0]-2):
    print('#',end='')
    print('.'*(HW[1]-2),end='#')
    print()
  print('#'*HW[1])
  print()
M, D = map(int, input().split())

result = 0

if D < 22:
    print(0)
else:
    for m in range(1, M+1):
        for d in range(22, D+1):
            d1 = d%10
            d10 = d//10
            if d1 > 1 and d1*d10 == m:
                result += 1
	print(result)

### FIXED CODE ###

M, D = map(int, input().split())

result = 0

if D < 22:
    print(0)
else:
    for m in range(1, M+1):
        for d in range(22, D+1):
            d1 = d%10
            d10 = d//10
            if d1 > 1 and d1*d10 == m:
                result += 1
    print(result)
H,W=map(int,raw_input().split())

while 1:
	if H==0 and W==0:
		break
	for i in H
		print "#"*W 
		print "/n"

### FIXED CODE ###

while 1:
	H,W=map(int,raw_input().split())

	if H==0 and W==0:
		break

	for i in range(H):
		print "#"*W 
	print ""
c=0
m=0
for _ in range(int(input())):
	n=int(input())
	if n>=m:
		c+=1
		m=n
print(c)

### FIXED CODE ###

c=0
m=0
n=int(input())
a=input().split()
for i in range(n):
	if int(a[i])>=m:
		c+=1
		m=int(a[i])
print(c)
n,q = map(int, input().split())
graph = [[] for _ in range(n+1)]
ans=[0]*(n+1)
def main():
  for i in range(n-1):
    a,b = map(int, input().split())
    graph[a].append(b)

  for i in range(q):
    p,x = map(int, input().split())
    ans[p] += x
  dfs(1) 
  print(' '.join([str(i) for i in ans[1:]]))

def dfs(i):
  for j in graph[i]:
    ans[j] += ans[i]
    dfs(j)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(200000000)
n,q = map(int, input().split())
graph1 = [[] for _ in range(n+1)]
graph2 = [[] for _ in range(n+1)]
ans=[0]*(n+1)
reached=[0]*(n+1)
def main():
  for i in range(n-1):
    a,b = map(int, input().split())
    graph1[a].append(b)
    graph2[b].append(a)

  for i in range(q):
    p,x = map(int, input().split())
    ans[p] += x
  dfs(1) 
  print(' '.join([str(i) for i in ans[1:]]))

def dfs(i):
  if reached[i] == 1:
    return
  reached[i] = 1
  for g in graph1[i], graph2[i]:
    for j in g:
      if reached[j] == 1:
        continue
      ans[j] += ans[i]
      dfs(j)

if __name__ == '__main__':
  main()
a=int(input())
b,c=map(int,input())
if c-b>=c%a:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a=int(input())
b,c=map(int,input().split())
if c-b>=c%a:
  print("OK")
else:
  print("NG")
from scipy.sparse import*;(n,m),*t=[map(int,t.split())for t in open(0)];*b,a=zip(*[(i,j+n-1,1)for i,(_,*t)in enumerate(t)for j in t]);print("YNEOS"[1in csgraph.connected_components(csr_matrix(((a,t)),[n+m]*2))[1][:n]::2])

### FIXED CODE ###

from scipy.sparse import*
(n,m),*p=[map(int,t.split())for t in open(0)]
a,b,c=zip(*[(i,j+n-1,1)for i,q in enumerate(p)for j in list(q)[1:]])
print('YNEOS'[1in csgraph.connected_components(csr_matrix(((c,(a,b))),[n+m]*2))[1][:n]::2])
from collections import defaultdict
n = int(input())
cs = [0] + [int(c) for c in input().split()]
ns = defaultdict(set)
for _ in range(n-1):
    a,b = [int(c) for c in input().split()]
    ns[a].add(b)
    ns[b].add(a)

toru = [0] * (n+1)
def dfs(ns, prev, now, toru):
    end = defaultdict(int)
    k = cs[now]
    end[k] = 1
    s = 1 # nowで終わるパスの種類
    for u in ns[now]:
        if u==prev:
            continue
        tmp_end, tmp_toru, tmp_s = dfs(ns, now, u, toru)
        # toruの更新
        for kk, vv in tmp_end.items():
            if kk not in end:
                toru[kk] += vv * s
            else:
                toru[kk] += vv * s + end[kk] * (tmp_s+1) - ((vv+1) * end[kk])
        for kk, vv in end.items():
            if kk not in tmp_end:
                toru[kk] += vv * tmp_s
        # end, sの更新
        end[k] += tmp_s
        for kk,vv in tmp_end.items():
            if k!=kk:
                end[kk] += tmp_end[kk]
        s += tmp_s
    toru[k] += 1
#     print(now, prev, end, toru, s)
    return end, toru, s
end, toru, s = dfs(ns, prev=-1, now=1, toru=toru)

for item in toru[1:]:
    print(item)

### FIXED CODE ###


import sys
# 小さすぎても怒られるので
from collections import defaultdict
n = int(input())
sys.setrecursionlimit(max(1000, 2*n))

cs = [0] + [int(c) for c in input().split()]
ns = defaultdict(set)
for _ in range(n-1):
    a,b = [int(c) for c in input().split()]
    ns[a].add(b)
    ns[b].add(a)

ans = [0] * (n+1) # kを通らないパスの総数
minus = [0] * (n+1) # uの部分木のうち
minus0 = defaultdict(int)
st = {k: [] for k in range(1, n+1)}
nextu = {}
def dfs(u, prev, ans):
    global minus, st, minus0
    k = cs[u]
    st[k].append(u)
    ss = 1
    for v in ns[u]:
        if v==prev:
            continue
        nextu[u] = v
        s = dfs(v, u, ans)
        ss += s
        tmp = s - minus[v]
        ans[k] += (int(tmp * (tmp - 1) / 2) + tmp)
    st[k].pop()
    if st[k]:
        minus[nextu[st[k][-1]]] += ss
    else:
        minus0[k] += ss
#     print(ss)
    return ss

dfs(1, -1, ans)
for k in range(1, n+1):
    tmp = n - minus0[k]
    ans[k] += (int(tmp * (tmp - 1) / 2) + tmp)
    
total = int(n * (n+1) / 2)
for i in range(1, n+1):
    print(total - ans[i])
import fractions
from functools import reduce

def main():
    n,m=map(int,input().split())
    a=list(map(int,input().split()))

    for i,aa in enumerate(a):
        a[i] = aa//2
    tmp = lcm(*a)
    # print(tmp)
    cnt =0
    # print(a)

    up = m//tmp
    if up % 2 == 0:
        up = up//2
    else:
        up = up//2 + 1

    nowtmp = tmp
    cnt = 0
    ans = 0
    a.sort()
    # print(nowtmp)
    # print(up)
    before = 0
    before_aa = 0
    for i, aa in enumerate(a):
        if before_aa == aa:
            continue
        if aa == 1:
            print(up)
            return
        if aa <= nowtmp and aa>before:
            cnt += 1

        elif aa> nowtmp :
            ans += cnt * up
            up -=1
            cnt = 0
            nowtmp += tmp
            before += tmp
    ans += cnt * up
    print(ans)

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
if __name__=='__main__':
    main()


### FIXED CODE ###

import fractions
from functools import reduce

def main():
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    
    for i,aa in enumerate(a):
        j = 0

        while aa % 2 == 0:
            aa //= 2
            j+=1
        if i == 0:
            modtmp = j
        else:
            if modtmp != j:
                print(0)
                return

    for i,aa in enumerate(a):
        a[i] = aa//2
    tmp = lcm(*a)
    # print(tmp)
    cnt =0
    # print(a)

    up = m//tmp
    if up % 2 == 0:
        up = up//2
    else:
        up = up//2 + 1

    nowtmp = tmp
    cnt = 0
    ans = 0
    a.sort()
    # print(nowtmp)
    # print(up)
    before = 0
    before_aa = 0
    print(up)
    return
    for i, aa in enumerate(a):
        if before_aa == aa:
            continue
        if aa == 1:
            print(up)
            return
        if aa <= nowtmp and aa>before:
            cnt += 1

        elif aa> nowtmp :
            ans += cnt * up
            up -=1
            cnt = 0
            nowtmp += tmp
            before += tmp
    ans += cnt * up
    print(ans)

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
if __name__=='__main__':
    main()
print(0.5*N*(N+1))

### FIXED CODE ###

N=int(input())
print(N*(N+1)//2)
n, m = [int(i) for i in input().split()]

matrix = []
for ni in range(n):
    matrix.append([int(a) for a in input().split()])

vector = []
for mi in range(n):
    vector.append(int(input()))

b = []
for ni in range(n):
    sum = 0
    for mi in range(m):
        sum += matrix[ni][mi] * vector[mi]

    print(sum)

### FIXED CODE ###

n, m = [int(i) for i in input().split()]

matrix = []
for ni in range(n):
    matrix.append([int(a) for a in input().split()])

vector = []
for mi in range(m):
    vector.append(int(input()))

for ni in range(n):
    sum = 0
    for mi in range(m):
        sum += matrix[ni][mi] * vector[mi]

    print(sum)
N = int(input())
A = map(int.input().split())
ans = 1/sum(1/x for x in A)
print(ans)

### FIXED CODE ###

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

num=0
for i in A:
   num+=1/i
    
print(1/num)
print(sum[map(int, input())])

### FIXED CODE ###

print(sum(map(int, input())))
H,W = map(int,input().split())
S = []
for i in range(H):
    S.append(list(input()))
L = [[] for _ in range(H)]
R = L.copy
D = L.copy
U = L.copy
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            L[i].append(0)
        elif j == 0:
            L[i].append(1)
        else:
            L[i].append(L[i][-1] + 1)
for i in range(H):
    for j in range(-1,-W-1,-1):
        if S[i][j] == '#':
            R[i].insert(0,0)
        elif j == -1:
            R[i].append(1)
        else:
            R[i].insert(0,R[i][0] + 1)
for i in range(W):
    for j in range(H):
        if S[j][i] == '#':
            U[j].append(0)
        elif j == 0:
            U[j].append(1)
        else:
            U[j].append(U[j-1][-1] + 1)
for i in range(W):
    for j in range(-1,-H-1,-1):
        if S[j][i] == '#':
            D[j].append(0)
        elif j == -1:
            D[j].append(1)
        else:
            D[j].append(D[j+1][-1] + 1)
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans,U[i][j]+D[i][j]+L[i][j]+R[i][j]-3)
print(ans)

### FIXED CODE ###

H,W = map(int,input().split())
S = []
for i in range(H):
    S.append(list(input()))
L = [[0 for _ in range(W)] for _ in range(H)]
R = [[0 for _ in range(W)] for _ in range(H)]
D = [[0 for _ in range(W)] for _ in range(H)]
U = [[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        elif j == 0:
            L[i][j] += 1
        else:
            L[i][j] += L[i][j-1] + 1
for i in range(H):
    for j in range(-1,-W-1,-1):
        if S[i][j] == '#':
            continue
        elif j == -1:
            R[i][j] += 1
        else:
            R[i][j] += R[i][j+1] + 1
for i in range(W):
    for j in range(H):
        if S[j][i] == '#':
            continue
        elif j == 0:
            U[j][i] += 1
        else:
            U[j][i] += U[j-1][i] + 1
for i in range(W):
    for j in range(-1,-H-1,-1):
        if S[j][i] == '#':
            continue
        elif j == -1:
            D[j][i] += 1
        else:
            D[j][i] += D[j+1][i] + 1
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans,U[i][j]+D[i][j]+L[i][j]+R[i][j]-3)
print(ans)
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]
A.sort()
BC.sort(key = lambda x:-x[1])
i = 0
for b, c in BC:
    for j in range(b):
            if A[i] < c:
                A[i] = c
                i += 1
            else:
                break
print(sum(A))


### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]
A.sort()
BC.sort(key = lambda x:-x[1])
i = 0
for b, c in BC:
    for j in range(b):
        if A[i] < c:
            A[i] = c
            i += 1
        else:
            break
        if i >= N:
            break
    if i >= N:
        break
print(sum(A))
a , b = map(int, input().split())

if b==1:
	print(0)
else:
	for i in range(20):
		if (a-1)*(i+1)>=b:
			print(i)
			brea

### FIXED CODE ###

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

if b==1:
	print(0)
else:
	for i in range(100):
		if a+(a-1)*i>=b:
			print(i+1)
			break
a,b,c,d = input('').split()
a=int(a)
b=int(b)
c=int(c)
d=int(d)
while 1:
	c=c-b
	if c<=0:
		print('Yes')
		break
	a=a-d
	if a<=0:
		print('No')
		break

### FIXED CODE ###

s, w = input('').split()
s= int(s)
w=int(w)
if s > w:
	print('safe')
else:
	print('unsafe')
s=input()
if int(s[:4])<2019:
  print("Heisei")
  exit()
if int(s[:4])=2019 and int(s[5])<=4:
  print("Heisei")
  exit()
print("TBD")

### FIXED CODE ###

s=input()
a=list(map(int,s.split("/")))
if a[0]<2019:
  print("Heisei")
  exit()
if a[0]==2019 and a[1]<=4:
  print("Heisei")
  exit()
print("TBD")
a=[]
for i in range(5):
    a.append(int(input()))

zako=9
for i in range(5):
    b=a[i]%10
    if b<zako and b!=0:
        zako=b
        memory=i
x=a.pop(memory)

lst=[]

for i in range(4):
    c=a[i]//10
    c=c*10
    if a[i]%10!=0:
        c+=10
    lst.append(c)

print(x+sum(lst))

### FIXED CODE ###

a=[]
for i in range(5):
    a.append(int(input()))

zako=9
switch=0
for i in range(5):
    b=a[i]%10
    if b<=zako and b!=0:
        zako=b
        memory=i
        switch=1

if switch==0:
    memory=1
x=a.pop(memory)

lst=[]

for i in range(4):
    c=a[i]//10
    c=c*10
    if a[i]%10!=0:
        c+=10
    lst.append(c)

print(x+sum(lst))
a=int(input())

b=list(map(int, input().split()))
b.sort(reverse=True)
alice=0
bob=0
c=iter(b)
for i in c:
    alice+=i
    bob+=next(c)
print(alice-bob)

### FIXED CODE ###

a=int(input())

b=list(map(int, input().split()))
b.sort(reverse=True)
alice=0
bob=0
c=iter(b)
for i in c:
    alice+=i
    try:
    	bob+=next(c)
    except:
      break
print(alice-bob)
x,k,d= map(int,input().split())
x=abs(x)
if x>d*k:
  print(x-d*k)
else:
  m=x//d
  k=(k-m)%2
  print(abs((x%d)-k*d))

### FIXED CODE ###

s=list(input())
count=0

if 'R' in s:
  count+=1
for i in range(len(s)-1):
  if s[i]==s[i+1] and s[i]=='R':
    count+=1
print(count)
(a, b) = [int(i) for i in input().split()]
  d = int(a / b)
  r = a % b
  f = a / b
  print('%s %s %.5f' % (d, r, f))

### FIXED CODE ###

(a, b) = [int(i) for i in input().split()]
d = int(a / b)
r = a % b
f = a / b
print('%s %s %.5f' % (d, r, f))
A,B = map(int,input().split)
X = A + B
Y = A - B
Z = A * B
if X > Y and X > Z : print(X)
elif Y > Z and Y > X : print(Y)
elif Z > X and Z > Y : print(Z)

### FIXED CODE ###

A,B = map(int,input().split())
X = A + B
Y = A - B
Z = A * B
if X >= Y and X >= Z:
     print(X)
elif Y >= Z and Y >= X:
     print(Y)
elif Z >= X and Z >= Y:
     print(Z)
import numpy as np
N=int(input())
P=np.array(list(map(int, input().split())))



mini=1
count=1
index_min=P.argmin()
while P[0]>mini:
  if P==np.sort(a)[::-1]:
    count+=P.shape[0]
    break
  P=P[:index_min]
  mini=min(P)
  index_min=P.argmin()
  count+=1
"""
count=1
for i in range(1,N):
  if min(P[:i+1])==P[i]:
    count+=1
"""
print(count)



### FIXED CODE ###

n=int(input())
p=list(map(int, input().split()))
ans=1
l=[p[0]]
buf=p[0]
for i in range(1,n):
    l.append(p[i])
    if p[i]<=buf:
        ans+=1
        buf=p[i]
print(ans)
N, K = list(map(int, input().split()))
A_list = list(map(int, input().split()))

l = [-1] * N
loopcnt = 0
inicnt = 0
place = 1
i = 0
l[place - 1] = 0

while i <= K:
    i += 1
    next_place = A_list[place - 1]
    place = next_place
    if l[next_place - 1] != -1:
        loopcnt = i - l[next_place - 1]
        inicnt = l[next_place - 1]
        break
    else:
        l[next_place - 1] = i

last_move_cnt = (K - inicnt) % loopcnt

j = 1
while j <= last_move_cnt:
    j += 1
    next_place = A_list[place - 1]
    place = next_place
    
print(place)

### FIXED CODE ###

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

l = [-1] * N
loopcnt = 0
inicnt = 0
place = 1
i = 0
l[place - 1] = 0

while i < K:
    i += 1
    next_place = A_list[place - 1]
    place = next_place
    if l[next_place - 1] != -1:
        loopcnt = i - l[next_place - 1]
        inicnt = l[next_place - 1]
        break
    else:
        l[next_place - 1] = i
if i >= K:
    print(place)

else:
    last_move_cnt = (K - inicnt) % loopcnt

    j = 1
    while j <= last_move_cnt:
        j += 1
        next_place = A_list[place - 1]
        place = next_place
    print(place)
import sys
from collections import deque
H,W=map(int,input().split())
map = [[i for i in map(str,sys.stdin.readline().rstrip())] for _ in range(H)]
count_dot = 0
dist = [[0]*W for _ in range(H)]
for i in range(H):
  for j in range(W):
    if map[i][j] == '.':
      count_dot +=1
def bfs():
  while True:
    x,y = q.popleft()
    if x == H-1 and y ==W-1:
      break
    dx = [0,1,0,-1]
    dy = [1,0,-1,0]
    for i in range(4):
      nx = x + dx[i]
      ny = y + dy[i]
      if 0 <= nx < H and 0 <= ny < W and map[nx][ny]=='.' and dist[nx][ny] == 0:
        q.append((nx,ny))
        dist[nx][ny] = dist[x][y] + 1
q = deque()
q.append((0,0))
bfs()
dist_min = dist[H-1][W-1]
print(count_dot-dist_min-1)

### FIXED CODE ###

import sys
from collections import deque
H,W=map(int,input().split())
map = [[i for i in map(str,sys.stdin.readline().rstrip())] for _ in range(H)]
count_dot = 0
dist = [[0]*W for _ in range(H)]
for i in range(H):
  for j in range(W):
    if map[i][j] == '.':
      count_dot +=1
def bfs():
  while q:
    x,y = q.popleft()
    if x == H-1 and y ==W-1:
      break
    dx = [0,1,0,-1]
    dy = [1,0,-1,0]
    for i in range(4):
      nx = x + dx[i]
      ny = y + dy[i]
      if 0 <= nx < H and 0 <= ny < W and map[nx][ny]=='.' and dist[nx][ny] == 0:
        q.append((nx,ny))
        dist[nx][ny] = dist[x][y] + 1
q = deque()
q.append((0,0))
bfs()
dist_min = dist[H-1][W-1]
if dist_min ==0:
  print(-1)
else:
  print(count_dot-dist_min-1)
N, M = map(int, input().split())

G = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    G[a-1][b - 1] = 1
    G[b-1][a - 1] = 1

visited = [0]*N
visited[0] = 1

def dfs(v, visited):
    if 0 not in visited:
        return 1

    ans = 0
    for i in G[x]:
        if visited[i] == 0:
            visited[i] = 1
            ans += dfs(i, visited)
            visited[i] = 0

    return ans

print(dfs(0, visited))

### FIXED CODE ###


import itertools

N, M = map(int, input().split())
adj_matrix = [[0]* N for _ in range(N)]

for i in range(M): #隣接行列
    a, b = map(int, input().split())
    adj_matrix[a-1][b-1] = 1
    adj_matrix[b-1][a-1] = 1

cnt = 0

for each in itertools.permutations(range(N)):
    if each[0] != 0:
        break
    factor = 1
    for i in range(N-1):
        factor *= adj_matrix[each[i]][each[i+1]]
    cnt += factor

print(cnt)
yandy
N, M = map(int, input().split())
A = [''] * N
B = [''] * M

for i in range(N):
    A[i] = input()
for j in range(M):
    B[j] = input()

for i in range(N-M+1):
    for j in range(N-M+1):
        NO = False
        for x in range(M):
            a = A[i+x][j:j+M]
            if a != B[x]:
                NO = True
                break
        if not NO:
            print('Yes')
            exit()

print('No')


### FIXED CODE ###

n, m = map(int, input().split())
a = [input() for i in range(n)]
b = [input() for i in range(m)]
for k in range(n-m+1):
  for j in range(n-m+1):
    h="true"
    for i in range(m):
      if a[k+i][j:j+m]!=b[i]:
        h="false"    
    if h=="true":
      print("Yes")
      exit()
else:
  print("No")
N = int(raw_input())
S = raw_input()

num = S[1:].count('E')
score_list = []
score_list.append(num)

for i in range(N-1):
	if i==0:
	
		if S[i]=='W':
			num+=1
	else:
		if S[i]=='W':
			num+=1
		else:
			num-=1
	score_list.append(num)
	
print min(score_list)

### FIXED CODE ###

A, B = map(int,raw_input().split())

M = max([A+B,A-B,A*B])
print M
#from functools import lru_cache
import sys
import math
def vfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:f(*x,**kwargs),*lst))

def rvfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:rvfunc(f)(*x,**kwargs) if all(vfunc(lambda y:isinstance(y,list))(x)) else f(*x,**kwargs),*lst))

def reader():return vfunc(lambda l:l.split())(sys.stdin.readlines())

ls = rvfunc(int)(reader())
n,k=ls[0]
a=ls[1]

def reqk(num):
    return sum(vfunc(lambda aa:(math.ceil(aa/float(num))-1) if math.ceil(aa/float(num))!= 0 else 0)(a))
def binary_search(imin=None,imax=None):
    if [imin,imax]==[None]*2: imin,imax=0,10**9
    if (imax < imin):
        return imin
    else:
        imid = int(imin + (imax - imin) / 2)
        if (reqk(imid)<k):return binary_search(imin, imid - 1)
        elif (reqk(imid)>k):return binary_search(imid + 1, imax)
        else:return imid
print(binary_search() if k!=0 else max(a))


### FIXED CODE ###

#from functools import lru_cache
import sys
from itertools import product
from itertools import combinations
from functools import reduce

def vfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:f(*x,**kwargs),*lst))

def rvfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:rvfunc(f)(*x,**kwargs) if all(vfunc(lambda y:isinstance(y,list))(x)) else f(*x,**kwargs),*lst))

def reader():return vfunc(lambda l:l.split())(sys.stdin.readlines())

k=int(input())
t=0
m=7%k
md=7%k
for i in range(k+1):
    if m==0:break
    else:
        md=(md*10)%k
        m=(m+md)%k
if i==k: i=-2
print(i+1)
A, B, C = map(int, input().split())
m = max(A, B, C)
print(m * 9 + sum(A, B, C))

### FIXED CODE ###

A, B, C = map(int, input().split())
m = max(A, B, C)
print(m * 9 + sum((A, B, C)))
S,T = open(0).sprit()

if T.startswith(S):
  print("Yes")
else:
  print("No")


### FIXED CODE ###

S = str(input())
T = str(input())

if T.startswith(S):
  print("Yes")
else:
  print("No")
n = int(input())
lst = list(map(int, input().split()))
ans = 1
for a in lst: 
    ans *= a
	if ans > 1000000000000000000:
		print(-1)
		return
if(ans>1000000000000000000): 
    print(-1)
else:
    print(ans)


### FIXED CODE ###

n = int(input())
lst = list(map(int, input().split()))
lst.sort()
ans = 1
for a in lst: 
    ans *= a
    if ans > 1e18:
        print(-1)
        break
else:
    print(ans)
# AOJ 1566 Movie
# Python3 2018.7.13 bal4u

n = int(input())
tbl = []
for i in range(n):
	a, b = map(int, input().split())
	tbl.append([b, a])
tbl.sort()
ans = saw = 0
seen = [0]*32
for i in range(1, 32):
	for j in range(n):
		if i < tbl[j][1] or tbl[j][0] < i: continue
		if seen[j]: continue
		ans += 100; seen[j] = 1; saw += 1
		break;
print(ans+(31-saw)*50)


### FIXED CODE ###

# AOJ 1566 Movie
# Python3 2018.7.13 bal4u

n = int(input())
tbl = []
for i in range(n):
	a, b = map(int, input().split())
	tbl.append([b, a])
tbl.sort()
ans = saw = 0
seen = [0]*101
for i in range(1, 32):
	for j in range(n):
		if i < tbl[j][1] or tbl[j][0] < i: continue
		if seen[j]: continue
		ans += 100; seen[j] = 1; saw += 1
		break;
print(ans+(31-saw)*50)