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

from collections import deque

h,w = map(int,input().split())
hw = [input() for i in range(h)]
#for i in range(h):
#    hw.append(input())

# used = [True]*h*w
isWhite = [[True]*w for i in range(h)]

queue = deque([])
for i in range(h):
    for j in range(w):
        if hw[i][j] == '#':
            queue.append([i,j,0])# h, w, step count
            isWhite[i][j] = False

res = 0
while len(queue) > 0:
    pos = queue.popleft()
    if pos[0] > 0 and isWhite[pos[0]-1][pos[1]]:
        queue.append([pos[0]-1, pos[1], pos[2]+1])
        isWhite[pos[0]-1][pos[1]] = False
    if pos[0] < h-1 and isWhite[pos[0]+1][pos[1]]:
        queue.append([pos[0]+1, pos[1], pos[2]+1])
        isWhite[pos[0]+1][pos[1]] = False
    if pos[1] > 0 and isWhite[pos[0]][pos[1]-1]:
        queue.append([pos[0], pos[1]-1, pos[2]+1])
        isWhite[pos[0]][pos[1]-1] = False
    if pos[1] < w-1 and isWhite[pos[0]][pos[1]+1]:
        queue.append([pos[0], pos[1]+1, pos[2]+1])
        isWhite[pos[0]][pos[1]+1] = False
#        print(queue)
    res = pos[2]
print(res)


### FIXED CODE ###

from collections import deque
h, w = map(int, input().split())

field = [] # 白黒情報を持つリスト
mark = [] # 操作回数を保持するリスト
INF = 10**6

for i in range(h):
    field.append(list(input()))
    mark.append([0 for i in range(w)])

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

queue = deque()
for i in range(h):
    for j in range(w):
        if field[i][j] == "#":
            queue.append([i, j])

while len(queue) > 0:
    y, x = queue.popleft()
    for k in range(4):
        nx = x + dx[k]
        ny = y + dy[k]
        if 0 <= ny < h and 0 <= nx < w:
            if field[ny][nx] == ".":
                mark[ny][nx] = mark[y][x] + 1
                queue.append([ny, nx])
                field[ny][nx] = "#"

ans=0

for i in mark:
    ans = max(ans, max(i))

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

s = input()
n = len(s)
ss = list(s)
ans = 0
i = 0
while i < n-2:  # 3文字なので
    if ss[i:i+3] == ['A', 'B', 'C']:
        ss[i:i+3] = ['B', 'C', 'A']
        ans += 1
        i = max(i-1, 0)   # 1つ前がAの場合をチェック
    else:
        i += 1

print(ans)


### FIXED CODE ###

s = input()
n = len(s)
ans = 0
numa = 0
i = 0
while i < n-1:  # 最後'BC'以外は、最後の文字は関係ないので s[n-1]は不要
    if s[i] == 'A':
        numa += 1   # Aが連続で続く場合は数える
    elif s[i:i+2] == 'BC':
        ans += numa # AAAA と BC を入れ替える回数。またBCが来たら加算する
        i += 1  # BCの場合は、2文字進めるので+1
    else:
        numa = 0
    i += 1
print(ans)
### BUGGY CODE ###

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


def primes(n):
    is_prime = [True] * (n + 1)
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return {i: True for i in range(n + 1) if is_prime[i]}

import fractions
def common_divisors(a, b):
    a = fractions.gcd(a, b)
    divisors =  [d for d in range(2, a // 2 + 1) if a % d == 0] + [a]
    if not 1 in divisors:
        divisors.append(1) 
    return divisors

import math

def is_prime(n):
    if n == 1: return True

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

d = common_divisors(A, B)

ans = 0
for x in d:
    if is_prime(x):
        ans += 1
#print(p)
#print(d)
print(ans)

### FIXED CODE ###

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


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)

    return divisors

import math

def is_prime(n):
    if n == 1: return True

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

import fractions
x = fractions.gcd(A, B)
divisors = make_divisors(x)
ans = 0
for d in divisors:
    if is_prime(d):
        ans += 1
print(ans)
### BUGGY CODE ###

n = int(input())
S = tuple(input())
ans = 0
anset = set()
for i in range(n):
    a = S[i]
    for j in range(i):
        b = S[j]
        if a == b:
            continue
        else:
            for d in ['R','G','B']:
                if d ==a or d == b:
                    continue
                else:
                    c = d
            ans += S.count(c)
            if (2*j-i)<0 :
                pass
            elif S[2*j-i] == c :
                ans -=1
            if (2 * i - j) >= n:
                pass
            elif S[2*i-j] ==c:
                ans -=1
            if (i+j)%2 == 0:
                if S[(i+j)//2] == c:
                    ans -=1
ans /=3
print(int(ans))

### FIXED CODE ###

n = int(input())
S = tuple(input())
ans = 0
R = S.count('R')
G = S.count('G')
B = S.count('B')
for i in range(n):
    a = S[i]
    for j in range(i):
        b = S[j]
        if a == b:
            continue
        else:
            for d in ['R','G','B']:
                if d ==a or d == b:
                    continue
                else:
                    c = d
            if c == 'R':
                ans+=R
            elif c =='G':
                ans+=G
            else:
                ans+=B
            if (2*j-i)<0 :
                pass
            elif S[2*j-i] == c :
                ans -=1
            if (2 * i - j) >= n:
                pass
            elif S[2*i-j] ==c:
                ans -=1
            if (i+j)%2 == 0:
                if S[(i+j)//2] == c:
                    ans -=1
ans /=3
print(int(ans))
### BUGGY CODE ###

R,G,B,N=map(int,input().split())
ans=0
naxR=N//R
naxG=N//G
for r in range(naxR+1):
    for g in range(naxG+1):
        if (N-r*R-g*G)/B>=0 and (N-r*R-g*G)%B==0:
            ans+=1
print(ans)

### FIXED CODE ###

R,G,B,N=map(int,input().split())
ans=0
naxR=N//R
naxG=N//G
for r in range(naxR+1):
    for g in range(naxG+1):
        if (N-r*R-g*G)/B>=0 and (N-r*R-g*G)%B==0:
            ans+=1
print(ans)
### BUGGY CODE ###

N = int(input())
power = 1

for i in range(1, N+1):
    power *= i
    
amari = power % (10**9 + 7)

print(amari)

### FIXED CODE ###

N = int(input())
power = 1

for i in range(1, N+1):
  power *= i
  power %= 10**9 + 7

print(power)
### BUGGY CODE ###

N = int(input())
li = [input() for x in range(N)]
ans = 0
wli = list()
for k in li:
    wli.append(sorted(list(k)))
for i in range(N):
    word = wli[i]
    for j in range(i+1, N):
        comp = wli[j]
        if word == comp:
            ans += 1
print(ans)            

### FIXED CODE ###

import collections
N = int(input())
li = [input() for x in range(N)]
ans = 0
di = dict()
for k in li:
    word = ''.join(sorted(list(k)))
    if word in di.keys():
        ans += di[word]
        di[word] += 1
    else:
        di[word] = 1
print(ans)
### BUGGY CODE ###

def max_heapify(A, i, pt):
    l = (i+1)*2-1
    r = (i+1)*2
    largest = i
    if l <= pt and A[largest] < A[l]:
        largest = l
    if r <= pt and A[largest] < A[r]:
        largest = r

    if largest != i:
        A[largest],A[i] = A[i],A[largest]
        max_heapify(A,largest,pt)

heap = [0]*2000000
pt = -1
while True:
    c = raw_input()
    if c[0] == 'i':
        pt += 1
        heap[pt] = int(c[7:])
        i = pt
        p = (i+1)/2-1
        while p >= 0 and heap[p] < heap[i]:
            heap[p],heap[i] = heap[i],heap[p]
            i = p
            p = (i+1)/2-1
    elif c[1] == 'x':
        print heap[0]
        heap[0] = heap[pt]
        pt -= 1
        max_heapify(heap,0,pt)
    else:
        break

### FIXED CODE ###

from sys import stdin

def max_heapify(A, i):
    l = i*2
    r = i*2+1
    largest = i
    if l <= A[0] and A[i] < A[l]:
        largest = l
    else:
        largest = i
    if r <= A[0] and A[largest] < A[r]:
        largest = r

    if largest != i:
        A[largest],A[i] = A[i],A[largest]
        max_heapify(A,largest)

heap = [0]*2000000
for c in stdin:
    if c[0] == 'i':
        heap[0] += 1
        heap[heap[0]] = int(c[7:])
        i = heap[0]
        p = i/2
        while p > 0 and heap[p] < heap[i]:
            heap[p],heap[i] = heap[i],heap[p]
            i = p
            p = i/2
    elif c[1] == 'x':
        print heap[1]
        heap[1] = heap[heap[0]]
        heap[0] -= 1
        max_heapify(heap,1)
    else:
        break
### BUGGY CODE ###

import math
A,B,N = map(int,input().split())
maxn = 0
sec =False
pp =False
for x in range(1,N+1):
    tmp = math.floor((A*x)/B)-A*(math.floor(x/B))
    if maxn < tmp:
        maxn = tmp
    if sec == True and tmp != 0:
        pp =True
    if tmp == 0:
        if sec ==True and pp ==True:
            break
        else:
            sec =True
    
print(maxn)

### FIXED CODE ###

import math
A,B,N = map(int,input().split())
s = min(B-1,N)
print(math.floor((A*s)/B)-A*(math.floor(s/B)))
### BUGGY CODE ###

def comp(ext,list0,dev):
    c=int((ext[0]+ext[1])/2)
    if list0[int((ext[0]+ext[1])/2)]>dev:
        return ext[0],int((ext[0]+ext[1])/2)
    else:
        return int((ext[0]+ext[1])/2),ext[1]
def bis(a,b,list0,dev):
    ls=[a,b]
    while ls[0]+1<ls[1]:
        ls=comp(ls,list0,dev)
    if list0[ls[0]]==dev:
        return ls[0]-1
    elif list0[ls[1]]==dev:
        return ls[1]-1
    else:
        return ls[0]
n=int(input())
l=[int(x) for x in input().split()]
l.sort()
s=0
for a in range(0,n-2):
    for b in range(a+1,n-1):
        if l[a]+l[b]>l[n-1]:
            c=n-1
        elif l[a]+l[b]<l[b+1]:
            c=b
        else:
            c=bis(b+1,n-1,l,l[a]+l[b])
        s=s+c-b
print(s)

### FIXED CODE ###

def bis_right(lis,dev):
    a=0
    b=len(lis)-1
    while a<b:
        c=(a+b)//2
        if lis[c]>dev:
            b=c
        else:
            a=c+1
    if lis[a]<=dev:
        return a
    return a-1



n=int(input())
l=[int(x) for x in input().split()]
l.sort()
s=0
for a in range(n-2):
    for b in range(a+1,n-1):
        c=bis_right(l[b+1:],l[a]+l[b]-1)
        s+=c+1
print(s)
### BUGGY CODE ###

S=input()
mem_mod = [0 for i in range(0,2019,1)]
N = len(S)
counter = 0
S_num_tmp = list(S)
S_num = list(map(int, S_num_tmp))
tmp=10
for i in range(1,N,1):
    S_num[N-i-1] = S_num[N-i] + (tmp)*S_num[N-i-1]
    tmp=tmp*10
for i in range(0,N,1):
    X = S_num[N-i-1] % 2019
    if X==0:
        counter+=1
    counter += mem_mod[X]
    mem_mod[X] += 1
print(counter)

### FIXED CODE ###

import collections
p = 2019
s=input()
n=len(s)
arr=[int(s[i]) for i in range(len(s))] #文字列の各文字をそれぞれ数字に変換しておく
if p==2 or p==5: #P=2,5のときは10を割り切るので連続部分列の右端のみを見ればよい
 ans=0
 for i in range(n):
   if arr[i]%p==0:
     ans+=i+1
 print(ans)
else: #Pが2でも5でもないとき
 dic=collections.defaultdict(int)
 tmp=0
 for i in range(n-1,-1,-1): #右端の要素を右端とする連続部分列のあまりを順に求める
   tmp+=arr[i]*pow(10,n-1-i,p)
   tmp%=p
   dic[tmp]+=1
 ans=0
 rem=0 #調べるあまりの値(初期値は0)
 for i in range(n-1,-1,-1):
   ans+=dic[rem]
   rem+=arr[i]*pow(10,n-1-i,p) #調べるあまりの値に(i番目の要素)*10^(n-1-i)を加える
   rem%=p
   dic[rem]-=1 #右端の要素が右端、i番目の要素が左端となる連続部分列のあまりの個数を1減らす
 print(ans)
### BUGGY CODE ###

N,M = map(int, input().split())
L = []
for i in range(1,M+1):
    if M % i == 0:
        L.append(i)
L1 = [i for i in L if M / i >= N]
print(max(L1))

### FIXED CODE ###

import math
N,M = map(int, input().split())
L = []
 
for i in range(1,math.floor(math.sqrt(M))+1):
    if M % i == 0:
        L.append(i)
        L.append(int(M / i))
L1 = [i for i in L if M / i >= N]
print(max(L1))
### BUGGY CODE ###

import numpy as np
N = int(input())
A = np.array([int(i) for i in input().split()])
ret_arr = [0]*N

def ca(n):
    if n == 1:
        array = np.zeros(N - n + 1)
        array[0] = sum([A[i] for i in range(n)])
        for i in range(1, N - n + 1):
            array[i] = array[i - 1] + A[n + i - 1] - A[i - 1]
        ret_arr[0] = array
    else:
        array = A[n-1:N] + np.array(ret_arr[n-2][0:N-n+1])
        ret_arr[n-1] = array
    return array


count = 0
for j in range(1, N+1):
    count += sum([1 if k == 0 else 0 for k in ca(j)])

print(count)


### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]
ca = [A[0]] + [0]*(N-1)

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

count = 1
number = 0
number += ca.count(0)
sca = sorted(ca) + ['hoge']
for i in range(1,N+1):
    if sca[i] == sca[i-1]:
        count += 1
    else:
        number += count*(count - 1)/2
        count = 1


print(int(number))
### BUGGY CODE ###

n = int(input())
s = input()
count = 0
for i in range(1,n-1):
    for j in range((i+1),n):
        if i<j:
            for k in range((j+1),n+1):
                if j<k:
                    if not j-i == k-j:
                        if not s[i-1] == s[j-1] and not \
                        s[i-1] == s[k-1] and not s[j-1] == s[k-1]:
                            count +=1
print(count)

### FIXED CODE ###

n = int(input())
s = input()
all = s.count("R")*s.count("G")*s.count("B")
for x in range(n-1):
    for y in range(1,(n-1-x)//2+1):
        if s[x] != s[x+y] and s[x]!= s[x+2*y]\
        and s[x+y]!=s[x+2*y]:
            all -=1
print(all)
### BUGGY CODE ###

import bisect
n=int(raw_input())
a=map(int,raw_input().split())
b=sorted([(a[i],i+1) for i in range(n)])
s=[0,n+1]
ans=0
for c,j in b:
    k=bisect.bisect(s,j)
    ans+=c*(s[k]-j)*(j-s[k-1])
    s.insert(k,j)
print ans


### FIXED CODE ###

n=int(raw_input())
a=map(int,raw_input().split())
def f():
    s=[(0,-1)]
    x=[0]*(n+1)
    for i,j in enumerate(a):
        while s[-1][0]>j:s.pop()
        x[j]=i-s[-1][1]
        s.append((j,i))
    return x
l=f()
a.reverse()
r=f()
print sum([i*l[i]*r[i] for i in a])
### BUGGY CODE ###

from decimal import Decimal
from numba import njit, i4, i8


@njit(i8(i8, i4), cache=True)
def div(n, d):
    cnt = 0
    while n % d == 0:
        n //= d
        cnt += 1
    return cnt


@njit(cache=True)
def solve(arr):
    ans = 0
    for i in range(len(arr)):
        for j in range(i + 1, len(arr)):
            (a, b), (c, d) = arr[i], arr[j]
            if a + c >= 18 and b + d >= 18:
                ans += 1
    return ans


n = int(input())
arr = [int(Decimal(input()) * 10**9) for _ in range(n)]
arr = [(div(x, 2), div(x, 5)) for x in arr]

print(solve(arr))

### FIXED CODE ###

def div(n, d):
    cnt = 0
    while n % d == 0 and cnt < 18:
        n //= d
        cnt += 1
    return cnt


n = int(input())
dp = [[0]*19 for _ in range(19)]

ans = 0
for _ in range(n):
    x = round(float(input()) * pow(10, 9))
    two = div(x, 2)
    five = div(x, 5)
    ans += dp[18 - two][18 - five]
    for i in range(two + 1):
        for j in range(five + 1):
            dp[i][j] += 1

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

from functools import reduce

def xor(a,b):
    return a^b

#1. input
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

#2. conduct a+b
sum_list = []
for a_i in a:
    for b_j in b:
        sum_list.append(a_i+b_j)

#3. calculate xor
ans = reduce(xor, sum_list)
print(ans)

### FIXED CODE ###

import sys
sdin = sys.stdin.readline


# 入力
n = int(sdin())
a = list(map(int, sdin().split()))
b = list(map(int, sdin().split()))

ans = 0

# バケットソートする
for k in range(29):
    a_nex = [[],[]]
    b_nex = [[],[]]
    for ai in a:
        a_nex[(ai & (1<<k)) >> k].append(ai)
            
    for bj in b:
        b_nex[(bj & (1<<k)) >> k].append(bj)
    

    a = []
    b = []
    for i in range(2):
        a = a + a_nex[i]
        b = b + b_nex[i]
        
    mask = pow(2,k+1) - 1
    a_mask = [ai & mask for ai in a]
    b_mask = [bj & mask for bj in b]
    
    base = pow(2,k)
    itr = [n]*4
    count = 0
    for ai in a_mask:
        border = [
                base - ai,
                2*base - ai,
                3*base - ai,
                4*base - ai
        ]
        
        for i in range(4):
            while 0 < itr[i] and border[i] <= b_mask[itr[i] - 1]:
                itr[i] -= 1
            
            
        count += ((itr[1] - itr[0]) + (itr[3]) - itr[2])
    
    if count & 1:
        ans += base
    
    
print(ans)
### BUGGY CODE ###

num = int(input())
line = input().rstrip().split()
x = 1

for i in range(num):
  x = x * int(line[i])
if x > 10 ** 18:
    print("-1")
else:
  print(x)

### FIXED CODE ###

num = int(input())
line = input().split()

if "0" in line:
  x = 0
else:
  x = 1
  for i in range(num):
    x = x * int(line[i])
    
    if x > 10 ** 18:
      x = -1
      break
  
print(x)
### BUGGY CODE ###

n,q=map(int,input().split())
s=input();a=[]
for i in range(n+1):
 a+=[s[:i].count("AC")]
for _ in range(q):
 l,r=map(int,input().split())
 print(a[r]-a[l])

### FIXED CODE ###

n,q=map(int,input().split())
s=input();a=[0]*2
for i in range(2,n+1):
 a+=[a[i-1]+s[i-2:i].count("AC")]
for _ in range(q):
 l,r=map(int,input().split())
 print(a[r]-a[l])
### BUGGY CODE ###

s=input()
flag=1
length=len(s)
while flag:
    l=len(s)
    if l<=1:
        break
    pre=s[0]
    for i in range(1,l):
        if pre!=s[i]:
            s=s[:i-1]+s[i+1:]
            break
        else:
            pre=s[i]
            if i==l-1:
                flag=0
print(length-len(s))


### FIXED CODE ###


s=input()
length=len(s)
cnt=[0,0]
for i in range(length):
    if s[i]=='0':
        cnt[0]+=1
    else:
        cnt[1]+=1
print(min(cnt)*2)
### BUGGY CODE ###

n = int(input())
s = list(input())
ans = 0
for k in range(n):
    for j in range(k):
        for i in range(j):
            if s[i]!=s[k] and s[j]!=s[k] and s[i] !=s[j] and j-i!=k-j:
                ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
s = list(input())
ans = 0
r = []
g = []
b = []
for i in range(n):
    if s[i]=='R':r.append(i)
    elif s[i]=='G':g.append(i)
    else:b.append(i)
ans = len(r)*len(g)*len(b)
d = 0
for i in range(n-2):
    for j in range(i,n-1):
        k = j+j-i
        if k < n and s[i] != s[j] and s[k] != s[i] and s[k]!=s[j]:
            d+=1
print(ans-d)
### BUGGY CODE ###

r, l = map(int, (input().split()))

ans = 0 if l - r >= 2019 else 2018

for i in range(r, l):
    for j in range(i+1, l+1):
        ans = min((i * j) % 2019, ans)
    
        if ans == 0:
            break
    
print(ans)

### FIXED CODE ###

r, l = map(int, (input().split()))

ans = 0 if l - r >= 2019 else 2018
max_l = min(l, (r//2019+1)*2019)

for i in range(r, max_l):
    for j in range(i+1, max_l+1):
        ans = min((i * j) % 2019, ans)
    
        if ans == 0:
            break
    
print(ans)
### BUGGY CODE ###

x,y,z,k=map(int,input().split())
*a,=map(int,input().split())
*b,=map(int,input().split())
*c,=map(int,input().split())
 
def merge_sort(array):
    if len(array) <= 1:
        return array
    cnt=len(array)//2
    left=array[:cnt]
    right=array[cnt:]
    left = merge_sort(left)
    right = merge_sort(right)
    return merge(left, right)

def merge(left, right):
    array = [0]*3000
    l,r,ind=0,0,0
    while l < len(left) and r < len(right):
        if left[l] >= right[r]:
            array[ind]=left[l]
            l+=1
            ind+=1
        else:
            array[ind]=right[r]
            r+=1
            ind+=1
        if ind>=3000:
            return array
    if l < len(left):
        return array[:ind]+left[l:3000-ind+l]
    if r < len(right):
        return array[:ind]+right[r:3000-ind+r]

a=merge_sort(a)
b=merge_sort(b)
c=merge_sort(c)
l,r=[],[]
for i in a:
    for j in b:
        l.append(i+j)
l=merge_sort(l)
for i in l:
    for j in c:
        r.append(i+j)
r=merge_sort(r)
for i in range(k):
    print(r[i])

### FIXED CODE ###

x,y,z,q=map(int,input().split())
a=sorted(map(int,input().split()),reverse=True)
b=sorted(map(int,input().split()),reverse=True)
c=sorted(map(int,input().split()),reverse=True)
 
def bisect(l,r):
  cnt=(l+r)//2
  if cnt==l:
    return l-1+judge(l)
  if judge(cnt):
    return bisect(cnt+1,r)
  else:
    return bisect(l,cnt)
def judge(thr):
  m=0
  for i in range(x):
    for j in range(y):
      if i*j>q:
        break
      for k in range(z):
        if i*j*k>q or a[i]+b[j]+c[k]<thr:
          break
        m+=1
        if m>=q:
          return True
  return False
def make(thr):
  m=0
  l=[]
  for i in a:
    for j in b:
      for k in c:
        n=i+j+k
        if n<thr+1:
          break
        m+=1
        l+=[n]
  l.sort(reverse=True)
  return l+[thr]*(q-len(l))
thr=bisect(0,a[0]+b[0]+c[0]+1)
ans=make(thr)
for w in ans:
  print(w)
### BUGGY CODE ###

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

# print(N, S)
ans = N

for i, h in enumerate(range(N)):
    skipflg = False
    f = S[0: i]
    l = S[i]
    s = S[i+1:]
    # print(f, l, s)
    nw = 0
    ne = 0
    # nw = f.count('W')
    # ne = s.count('E')
    # print(nw, ne)
    for r in f:
        if r != 'E':
            nw += 1
            if nw >= ans:
                skipflg = True
                break
            # print('not e')

    if skipflg:
        # print('break 1')
        continue

    for w in s:
        if w != 'W':
            ne += 1
            if nw+ne >= ans:
                skipflg = True
                break
            # print('not w')

    if skipflg:
        # print('break 2')
        continue

    ans = min(ans, nw+ne)

print(ans)


### FIXED CODE ###

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

# print(N, S)
ans = N

f = S[0]
s = S[1:]

nw = 0
ne = 0

for w in s:
    if w != 'W':
        ne += 1

ans = nw+ne
for i in range(1, N):
    # skipflg = False
    # f = S[0: i]
    # l = S[i]
    # s = S[i+1:]
    # # print(i, f, l, s)
    # nw = f.count('W')
    # ne = s.count('E')
    # print(nw, ne)

    if S[i-1] != 'E':
        nw += 1

    if S[i] != 'W':
        ne -= 1
    # print(nw, ne)
    ans = min(ans, nw+ne)

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

import numpy as np
import heapq
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
ab=np.array(ab)
cand=[]
ans=0
for i in range(1,m+1):
  t=ab[ab[:,0]==i][:,1].tolist()
  for j in range(len(t)):
    heapq.heappush(cand,-t[j])
  if len(cand)==0:
    continue
  ans-=heapq.heappop(cand)

print(ans)

### FIXED CODE ###

import heapq
n,m=map(int,input().split())
ab=[[] for _ in range(m+1)]
for i in range(n):
  a,b=map(int,input().split())
  if a<=m:
    ab[a].append(-b)

cand=[]
heapq.heapify(cand)
ans=0
for i in range(1,m+1):
  for j in range(len(ab[i])):
    heapq.heappush(cand,ab[i][j])
  if len(cand)>0:
    ans-=heapq.heappop(cand)

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

import sys #追加
sys.setrecursionlimit(50000000) #追加
N,M=map(int,input().split())
a=[]
for i in range(0,M):
    a.append(int(input()))
if M==0:
    a=[-1]
ans=1
s=[-1]*(N+1)
s[0]=1
def dp(n):
    if n==0:
        return 1
    elif n==1:
        return 0 if 1 in a else 1
    if s[n-1]!=-1:
        c=s[n-1]
    elif n-1 in a:
        s[n-1]=0
        c=0
    else:
        c=dp(n-1)%1000000007
        s[n-1]=c
    if s[n-2]!=-1:
        b=s[n-2]
    elif n-2 in a:
        s[n-2]=0
        b=0
    else:
        b=dp(n-2)%1000000007
        s[n-2]=b
    return (c+b)%1000000007
print(dp(N)%1000000007)

### FIXED CODE ###

import sys #追加
sys.setrecursionlimit(50000000) #追加
N,M=map(int,input().split())
a=[]
for i in range(0,M):
    a.append(int(input()))
a=set(a)
if M==0:
    a=[-1]
ans=1
s=[-1]*(N+1)
s[0]=1
def dp(n):
    if n==0:
        return 1
    elif n==1:
        return 0 if 1 in a else 1
    if s[n-1]!=-1:
        c=s[n-1]
    elif n-1 in a:
        s[n-1]=0
        c=0
    else:
        c=dp(n-1)%1000000007
        s[n-1]=c
    if s[n-2]!=-1:
        b=s[n-2]
    elif n-2 in a:
        s[n-2]=0
        b=0
    else:
        b=dp(n-2)%1000000007
        s[n-2]=b
    return (c+b)%1000000007
print(dp(N)%1000000007)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
from functools import reduce
import fractions


def gcd(*numbers):
  return reduce(fractions.gcd, numbers)


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

max_gcd = 0
for i in range(n):
  arr = lst[:i] + lst[i + 1:len(lst)]
  # if min(arr) < max_gcd:
  #   break
  wk_gcd = gcd(*arr)
  max_gcd = wk_gcd if wk_gcd > max_gcd else max_gcd

print(max_gcd)


### FIXED CODE ###

import fractions
from functools import reduce

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

# 累積GCD
left = [0] * (n + 1)
right = [0] * (n + 1)
for i in range(n):
  left[i + 1] = (fractions.gcd(left[i], a[i]))
  right[n - i - 1] = (fractions.gcd(right[n - i], a[n - 1 - i]))

ans = 0
for i in range(n):
  ans = max(ans, fractions.gcd(left[i], right[i + 1]))
print(ans)