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

H, W = map(int, input().split())
S = [''] * H
M = [[0 for w in range(W)] for h in range(H)]
for i in range(H):
  S[i] = input()
  n = H * W
  for j in range(W):
    if S[i][j] == '#':
      M[i][j] = 0
      n = 0
    else:
      n += 1
      M[i][j] = n
  n = H * W
  for j in range(W - 1, -1, -1):
    if S[i][j] == '#':
      n = 0
    else:
      n = min(n + 1, M[i][j])
      M[i][j] = n
for j in range(W):
  n = H * W
  for i in range(H):
    if S[i][j] == '#':
      n = 0
    else:
      n = min(n + 1, M[i][j])
      M[i][j] = n
  n = H * W
  for i in range(H - 1, -1, -1):
    if S[i][j] == '#':
      n = 0
    else:
      n = min(n + 1, M[i][j])
      M[i][j] = n
print(max([max(m) for m in M]))

### FIXED CODE ###

H, W = map(int, input().split())
S = [''] * H
M = [[0 for w in range(W)] for h in range(H)]
for i in range(H):
  S[i] = input()
  n = H * W
  for j in range(W):
    if S[i][j] == '#':
      M[i][j] = 0
      n = 0
    else:
      n += 1
      M[i][j] = n
  n = H * W
  for j in range(W - 1, -1, -1):
    if S[i][j] == '#':
      n = 0
    else:
      n = min(n + 1, M[i][j])
      M[i][j] = n
for j in range(W):
  n = H * W
  for i in range(H):
    if S[i][j] == '#':
      n = 0
    else:
      n = min(n + 1, M[i][j])
      M[i][j] = n
  n = H * W
  for i in range(H - 1, -1, -1):
    if S[i][j] == '#':
      n = 0
    else:
      n = min(n + 1, M[i][j])
      M[i][j] = n
print(max([max(m) for m in M]))
### BUGGY CODE ###

from math import gcd

if __name__ == '__main__':

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

    gcd_ = gcd(A[0], A[1])
    for i in range(2, len(A)):
        gcd_ = gcd(gcd_, A[i])

    set_wise = False
    if gcd_ == 1:
        set_wise = True

    pairwise = True
    for i in range(n):
        for j in range(i+1, n):
            gcd_ = gcd(A[i], A[j])
            if gcd_ != 1:
                pairwise = False

    if pairwise:
        print("pairwise coprime")
    elif set_wise:
        print("setwise coprime")
    else:
        print("not coprime")


### FIXED CODE ###

import math


def divisorGenerator(n):

    large_divisors = []
    for i in range(1, int(math.sqrt(n) + 1)):
        if n % i == 0:
            yield i
            if i*i != n:
                large_divisors.append(n // i)
    for divisor in reversed(large_divisors):
        yield divisor

if __name__ == '__main__':

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

    gcd_ = math.gcd(A[0], A[1])
    for i in range(2, len(A)):
        gcd_ = math.gcd(gcd_, A[i])

    set_wise = False
    if gcd_ == 1:
        set_wise = True
    if not(set_wise):
        print("not coprime")
    else:
        pairwise = True
        divs = dict()
        for i in A:
            res = list(divisorGenerator(i))
            for el in res:
                if el != 1:
                    if not(el in divs):
                        divs[el] = 0
                    divs[el] += 1
                    if divs[el] > 1:
                        print("setwise coprime")
                        exit()
        print("pairwise coprime")
        # for value in divs.values():
        #     if value > 1:
        #         pairwise = False
        #         break
        # if pairwise:
        #     print("pairwise coprime")
        # else:
        #
        #
### BUGGY CODE ###

import copy as cp
n,k = map(int,input().split())
lamps = list(map(int,input().split()))
for j in range(k):
    lamp_io = [0]*n
    for i in range(len(lamps)):
        if(i == 0):
            for k in range(1,lamps[i]+1):
                if(i+k <= n-1):
                    lamp_io[k] += 1
                else:
                    break
            lamp_io[i] += 1
        elif(i == n-1):
            for k in range(1,lamps[i]+1):
                if(i-k >= 0):
                    lamp_io[i-k] += 1
                else:
                    break
            lamp_io[i] += 1
        else:
            for k in range(1,lamps[i]+1):
                a = 0
                b = 0
                if(i+k <= n-1):
                    lamp_io[i+k] += 1
                else:
                    a = 1
                if(i-k >= 0):
                    lamp_io[i-k] += 1
                else:
                    b = 1
                if(a == 1 and b == 1):
                    break
            lamp_io[i] += 1
        # print(lamp_io)    
    lamps = cp.copy(lamp_io)
ans = ""
for i in range(len(lamp_io)):
    ans += str(lamp_io[i]) +" "
print(ans.rstrip())

### FIXED CODE ###

from numba import jit
@jit
def main():
    n,k = map(int,input().split())
    lamps = list(map(int,input().split()))
    for ki in range(k):
        lamplog = [0]*(n+1)
        for i in range(n):
            lamplog[max(0,i-lamps[i])  ] += 1   #先端を出す
            lamplog[min(i+lamps[i]+1,n)] -= 1   #末尾を出す
        # print(lamplog)
        for i in range(n):                      #累積和を計算
            lamplog[i+1] += lamplog[i]
        # print(lamplog)
        lamplog.pop()
        if(lamplog == lamps):                   #１つ前の結果と今回の結果が同じだったら。
            break
        lamps = lamplog                         #今回の結果を記録
    return lamplog

lamplog = main()
ans = ""
for i in range(len(lamplog)):
    ans += str(lamplog[i]) +" "
print(ans.rstrip())
### BUGGY CODE ###

#----------------------------------------------------------
P = 10**9 + 7
N = 100001 #使う最大値+1以上にする、値に注意3*10^5とかにしとくと安心
inv = [0] + [1] # 1/x
finv = [1] + [1] # 1/x!
fac = [1] + [1] # x!
for i in range(2,N):
  inv += [inv[P % i] * (P - int(P / i)) % P]
  fac += [(fac[i-1] * i) % P]
  finv += [(finv[i-1] * inv[i]) % P]

def comb(a, b):
    if a<b or a<0 or b<0:
        return 0 # error
    return (fac[a] * ((finv[b] * finv[a-b]) % P)) %P
#----------------------------------------------------------

n=int(input())
x=list(map(int,input().split()))
ans=0
for i in range(n-1):
    t = (x[n-1]-x[i])%P
    o =(fac[i]*fac[n-2-i])%P
    g = (comb(n-1,n-1-i)*o)%P
    t = (t * g)%P
    ans=(ans+t)%P

for i in range(n-1):
    for j in range(i+1,n-1):
        t = (x[j]-x[i])%P
        o =(fac[n-1-j+i-1]*fac[j-i-1])%P
        g = (comb(n-1,j-i+1)*o)%P
        t = (t * g)%P
        ans=(ans + t)%P
print(ans%P)


### FIXED CODE ###

#----------------------------------------------------------
P = 10**9 + 7
N = 100001 #使う最大値+1以上にする、値に注意3*10^5とかにしとくと安心
inv = [0] + [1] # 1/x
finv = [1] + [1] # 1/x!
fac = [1] + [1] # x!
for i in range(2,N):
  inv += [inv[P % i] * (P - int(P / i)) % P]
  fac += [(fac[i-1] * i) % P]
  finv += [(finv[i-1] * inv[i]) % P]

def comb(a, b):
    if a<b or a<0 or b<0:
        return 0 # error
    return (fac[a] * ((finv[b] * finv[a-b]) % P)) %P
#----------------------------------------------------------

n=int(input())
x=list(map(int,input().split()))
s = [0] * n
for i in range(n):
    s[i] = x[i] + (s[i-1] if i>0 else 0)
ans=0

for i in range(n-1):
    t = (x[n-1]-x[n-2-i])%P
    t = (t * (fac[n-1]*inv[i+1])%P)%P
    ans=(ans+t)%P
for i in range(1, n-1):
    t = (s[n-2] - s[i-1] - s[n-2-i])%P
    p = (((fac[n-1] * inv[i])%P) * inv[i+1])%P
    ans = (ans + (t*p)%P)%P

print(ans%P)
### BUGGY CODE ###

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    mod = 10**9+7
    dp = [0]*k
    dp[0] = 1
    for i in range(n):
        aa = a[i]
        if aa >= k:
            continue
        for j in range(k-aa-1, -1, -1):
            dp[aa+j] = (dp[aa+j]+dp[j]) % mod
    b = [1]*n
    for i in range(n):
        if a[i] >= k:
            b[i] = 0
            continue
        aa = a[i]
        dp2 = [0]*k
        for j in range(aa):
            dp2[j] = dp[j]
        for j in range(aa, k):
            dp2[j] = (dp[j]-dp2[j-aa]) % mod
        for j in range(k-aa, k):
            if dp2[j] != 0:
                b[i] = 0
                break
    print(sum(b))


main()

### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    mod = 10**9+7
    dp = [0]*k
    dp[0] = 1
    for i in range(n):
        aa = a[i]
        if aa >= k:
            continue
        for j in range(k-aa-1, -1, -1):
            dp[aa+j] = (dp[aa+j]+dp[j]) % mod
    b = [1]*n
    for i in range(n):
        if a[i] >= k:
            b[i] = 0
            continue
        aa = a[i]
        dp2 = [0]*k
        for j in range(aa):
            dp2[j] = dp[j]
        for j in range(aa, k):
            dp2[j] = (dp[j]-dp2[j-aa]) % mod
        for j in range(k-aa, k):
            if dp2[j] != 0:
                b[i] = 0
                break
    print(sum(b))


main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline

x, y  = map(int, input().split())
li =[]
for i in range(x):
    l = list(map(int, input().split()))
    li.append(l)
dp = [[0]*(y+1) for _ in range(x+1)]
for i in range(x):
    for j in range(1, y+1):
        if j - li[i][0] >= 0:
            dp[i+1][j] = max(dp[i][j],dp[i][j - li[i][0] ]+ li[i][1])
        else:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j])
print(dp[x][y])


### FIXED CODE ###

import sys
input = sys.stdin.readline

x, y  = map(int, input().split())
li =[]
for i in range(x):
    l = list(map(int, input().split()))
    li.append(l)
dp = [[0]*(y+1) for _ in range(x+1)]
for i in range(x):
    for j in range(1, y+1):
        if j - li[i][0] >= 0:
            dp[i+1][j] = max(dp[i][j],dp[i][j - li[i][0] ]+ li[i][1])
        else:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j])
print(dp[x][y])
### BUGGY CODE ###

h,n=map(int,input().split())
attack=[list(map(int,input().split())) for _ in range(n)]

max_attack=max(at[0] for at in attack)

dp = [0]*(h+max_attack)
for i in range(1,h+max_attack):
    at=[]
    for a,b in attack:
        at.append(dp[i-a]+b)
    dp[i]=min(at)
print(min(dp[h:]))


### FIXED CODE ###

h,n=map(int,input().split())
attack=[list(map(int,input().split())) for _ in range(n)]

max_attack=max(at[0] for at in attack)

dp = [0]*(h+max_attack)
for i in range(1,h+max_attack):
    at=[]
    for a,b in attack:
        at.append(dp[i-a]+b)
    dp[i]=min(at)
print(min(dp[h:]))
### BUGGY CODE ###

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

bin_digit = [0]*50
for ai in a:
    i = 0
    while ai>0:
        bin_digit[i] += int(bin(ai)[-1])
        i += 1
        ai = ai>>1

length_k = len(bin(k))-2
x_k = [0]*length_k
for i in range(length_k):
    if bin_digit[i]>=n-bin_digit[i]:
        x_k[i] = 0
    else:
        x_k[i] = 1

bin_k = bin(k)[-1:1:-1]
for i in range(length_k-1,-1,-1):
    if x_k[i]>int(bin_k[i]):
        x_k[i] = 1-x_k[i]
    elif x_k[i]<int(bin_k[i]):
        break

x = sum(x_k[i]*2**i for i in range(len(x_k)))
ans = sum(x^ae for ae in a)
print(ans)


### FIXED CODE ###

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

bin_digit = [0]*50
for ai in a:
    i = 0
    bin_ai = bin(ai)
    for i in range(len(bin_ai)-2):
        if bin_ai[-1-i] == '1':
            bin_digit[i] += 1
        i += 1

bin_k = list(map(int, bin(k)[-1:1:-1]))
length_k = len(bin_k)
x_k = [None]*length_k
for i in range(length_k):
    if 2*bin_digit[i]>=n:
        x_k[i] = 0
    else:
        x_k[i] = 1

for i in range(length_k-1,-1,-1):
    if x_k[i]>bin_k[i]:
        x_k[i] = 1-x_k[i]
    elif x_k[i]<bin_k[i]:
        break

x = sum(x_k[i]*2**i for i in range(len(x_k)))
ans = sum(x^ae for ae in a)
print(ans)
### BUGGY CODE ###

N, W = map(int, input().split())
w = []
for _ in range(N):
	w.append(list(map(int, input().split())))

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

for i in range(1, N+1):
	for j in range(1, W+1):
		if j >= w[i-1][0]:
			dp[i][j] = max(dp[i-1][j-w[i-1][0]] + w[i-1][1], dp[i-1][j])
		else:
			dp[i][j] = dp[i-1][j]
print(dp[-1][-1])

### FIXED CODE ###

import numpy as np
N, W = map(int, input().split())

dp = np.zeros(W+1, dtype=np.int64)
for i in range(N):
	w, v = map(int, input().split())
	np.maximum(dp[w:], dp[:-w] + v, out= dp[w:])
print(dp[-1])
### BUGGY CODE ###

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

import math
import fractions
from functools import reduce

def gcd(numbers):
    return reduce(fractions.gcd, numbers)
ans = 0
for idx, num in enumerate(A):
  result = gcd(A[:idx:]+A[idx+1::])
  if result > ans:
    ans = result
print(ans)

### FIXED CODE ###

import fractions

N = int(input())
A = list(map(int, input().split()))
L = [0] * (N+1)
R = [0] * (N+2)
M = [0] * (N+1)

for i in range(1, N+1):
  L[i] = fractions.gcd(L[i-1], A[i-1])
  R[N-i+1] = fractions.gcd(R[N-i+2], A[N-i])

for i in range(1, N+1):
  M[i] = fractions.gcd(L[i-1], R[i+1])
print(max(M[1:]))
### BUGGY CODE ###

import copy
from functools import reduce

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

def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a%b)
def gcd_array(a):#aは配列
  return reduce(gcd, a)

ans = []
lst_t = []
for i in range(n):
  lst_t = copy.deepcopy(lst)
  del lst_t[i]
  x = gcd_array(lst_t)
  ans.append(x)
  
print(max(ans))

### FIXED CODE ###

import fractions

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

ans = 0
left = [0]
right = [0] * (n+1)

for i in range(n):
  left.append(fractions.gcd(left[-1],lst[i]))
  right[n-1-i] = fractions.gcd(right[n-i],lst[n-1-i])

for i in range(n):
  x = fractions.gcd(left[i], right[i+1])
  if ans < x:
    ans = x
print(ans)
### BUGGY CODE ###

from functools import reduce
from math import gcd
K = int(input())
ans = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            ans += reduce(gcd, [i, j, k])
print(ans)

### FIXED CODE ###

from functools import reduce
from math import gcd
K = int(input())
ans = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            ans += reduce(gcd, [i, j, k])
print(ans)
### BUGGY CODE ###

n, m = map(int, input().split())
a = list(int(input()) for _ in range(m))
M = 10**9+7
dp = [0]*(n+1)
dp[0] = 1
for i in range(1, n+1):
    if i not in a:
        dp[i] = (dp[i-1] + dp[i-2])%M
print(dp[n])


### FIXED CODE ###

n, m = map(int, input().split())
b = [False]*(n+2)
for _ in range(m):
    i = int(input())
    b[i] = True
M = 10**9+7
dp = [0]*(n+1)
dp[0] = 1
for i in range(1, n+1):
    if b[i] == False:
        dp[i] = (dp[i-1] + dp[i-2])%M
print(dp[n])
### BUGGY CODE ###

n=int(input())
l=list(map(int,input().split()))
k=[0]*n
for i in range(1,n+1):
  k[i-1]=str(l.index(i)+1)
print(" ".join(k))

### FIXED CODE ###

def main():
  n=int(input())
  l=list(map(int,input().split()))
  k=[0]*n
  for i in range(1,n+1):
    k[l[i-1]-1]=str(i)
  print(" ".join(k))


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

n = int(input())
l = list(map(int, input().split()))
b = 1
for i in range(n):
    b = b * l[i] 
if b > 10 ** 18:
    b = -1
print(b)


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

def input():
    return sys.stdin.readline()[:-1]
n = int(input())
l = list(map(int, input().split(" ")))
output = 1

if 0 in l:
    print(0)
    sys.exit()

for i in range(n):
    output = output * int(l[i])
    if output > 10 ** 18:
        output = -1
        break
print(output)
### BUGGY CODE ###

#B
n,a,b=map(int,input().split())
aa=0
for i in range(n//(a+b)+1):
    if n<a:
        aa+=n
        break
    else:
        aa+=a
    n-=a+b
print(aa)

### FIXED CODE ###

#B
import sys
n,a,b=map(int,input().split())
if a==0:
    print(0)
    sys.exit()
else:
    s=int(n/(a+b))
    if s==0:
        m=n
    else:
        absum=(a+b)*s
        m=n%(absum)#余り
    if m<a:
        print(s*a+m)
    else:
        print((s+1)*a)
### BUGGY CODE ###

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

flg = True
for q in Q:
    if q[0] == "1":
        flg = not flg
    else:
        if q[1] == "1" and flg:
            S = q[2] + S
        elif q[1] == "1" and not flg:
            S = S + q[2]
        elif q[1] == "2" and flg:
            S = S + q[2]
        else:
            S = q[2] + S

if not flg:
    S = S[::-1]
print(S)

### FIXED CODE ###

s = input()
q = int(input())
Q = [list(map(str, input().split())) for _ in range(q)]

t = ''
for qi in Q:
  if int(qi[0]) == 1:
    s, t = t, s
  else:
    if int(qi[1])  == 1:
      t += qi[2]
    else:
      s += qi[2]
      
t = t[::-1]
t += s
print(t)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Sep  6 00:28:43 2020

@author: liang
"""


H, W = map(int, input().split())
sh, sw = map(int, input().split())
sh -= 1
sw -= 1

gh, gw = map(int, input().split())
gh -= 1
gw -= 1

field = [input() for i in range(H)]

d = [[-1]*W for _ in range(H)]
visited = [[False]*W for _ in range(H)]
adj1 = [(1,0), (-1,0), (0,1), (0,-1)]
adj2 = [(x,y) for x in range(-2,3) for y in range(-2,3)]

from collections import deque

def BFS():
    def isValid(p):
        if p[0] < 0 or p[0] >= H or p[1] < 0 or p[1] >= W:
            return False
        if field[p[0]][p[1]] == "#":
            return False
        if visited[p[0]][p[1]] :
            return False
        return True
    
    q = deque()
    q.append((sh, sw))
    d[sh][sw] = 0
    visited[sh][sw] = True
    while q:
        cur = q.popleft()
        #normal move
        for a in adj1:
            nex = (cur[0] + a[0], cur[1] + a[1])
            if isValid(nex) and (d[nex[0]][nex[1]] == -1 or d[nex[0]][nex[1]] > d[cur[0]][cur[1]]):
                 d[nex[0]][nex[1]] = d[cur[0]][cur[1]]
                 visited[nex[0]][nex[1]] = True
                 q.append((nex[0], nex[1]))
        #warp
        for a in adj2:
            nex = (cur[0] + a[0], cur[1] + a[1])
            if isValid(nex):
                d[nex[0]][nex[1]] = d[cur[0]][cur[1]] + 1
                q.append((nex[0], nex[1]))
                    
BFS()
#print(d)
#print(visited)
print(d[gh][gw])
    
            
                 

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Fri Sep 11 11:57:24 2020

@author: liang
"""

H, W = map(int, input().split())
sy, sx = map(int, input().split())
sy -= 1
sx -= 1
gy, gx = map(int, input().split())
gy -= 1
gx -= 1
field = [input() for _ in range(H)]

from collections import deque
q = deque()
adj1 = [(0,1), (0,-1), (1,0), (-1,0)]
visited = [[False]*W for _ in range(H)]

q.append((sy, sx, 0))

while q:
    cy, cx, cost = q.popleft()
    #print(cy,cx,cost)
    if (cy,cx) == (gy,gx):
        print(cost)
        break
    if not visited[cy][cx]:
        #print("visit!")
        visited[cy][cx] = True
        #cost 0
        for a in adj1:
            ny, nx = cy + a[0], cx + a[1]
            if ny >= H or ny < 0:
                continue
            if nx >= W or nx < 0:
                continue
            if field[ny][nx] == "#":
                continue
            if not visited[ny][nx]:
                q.appendleft((ny, nx, cost))
        #cost 1
        for i in range(-2,3):
            for j in range(-2,3):
                ny, nx = cy + i, cx + j
                if ny >= H or ny < 0:
                    continue
                if nx >= W or nx < 0:
                    continue
                if field[ny][nx] == "#":
                    continue
                if not visited[ny][nx]:
                    q.append((ny, nx, cost+1))
else:
    print(-1)
### BUGGY CODE ###

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

tere = {}
for i in range(n):
    tere[i+1] = a[i]

mati = [1]
tugi = 1
for i in range(1, k+1):
    if tere[tugi] not in mati:
        mati.append(tere[tugi])
    else:
        mati.append(tere[tugi])
        break
    tugi = tere[tugi]
else:
    print(tugi)
    exit()


cnta = len(mati)-1
i = mati.index(mati[-1]) + 1
cntroop = cnta - i + 1
roop = mati[i:]

print(roop[(k-cnta)%cntroop-1])

### FIXED CODE ###

from collections import deque

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

tere = {}
for i in range(n):
    tere[i+1] = a[i]

mati = deque([1])
mark = set([1])
tugi = 1
for i in range(1, k+1):
    if tere[tugi] not in mark:
        mati.append(tere[tugi])
        mark.add(tere[tugi])
    else:
        mati.append(tere[tugi])
        mark.add(tere[tugi])
        break
    tugi = tere[tugi]
else:
    print(tugi)
    exit()

mati = list(mati)
cnta = len(mati)-1
i = mati.index(mati[-1]) + 1
cntroop = cnta - i + 1
roop = mati[i:]

print(roop[(k-cnta)%cntroop-1])
### BUGGY CODE ###

import fractions
from functools import reduce

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

K = int(input())
ans = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans += gcd([i,j,k])

print(ans)

### FIXED CODE ###

n = input()
if n[0] == "7" or n[1] == "7" or n[2] == "7":
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

# -*- coding:utf-8 -*-
S = list(input())

loop_idx = 0
cnt = 0

if len(S) == 1:
    pass
else:
    while loop_idx < -(-len(S)//2):
        for i in range(len(S)-1,0,-1):
            if S[i]=="W" and S[i-1] == "B":
                cnt += 1
                S[i],S[i-1] = "B","W"
        loop_idx += 1
print(cnt)

### FIXED CODE ###

# -*- coding:utf-8 -*-
S = list(input())

cnt_b = 0 
ans = 0

for i in range(len(S)):
    if S[i] == "B":
        cnt_b += 1
    if S[i] == "W":
        ans += cnt_b
print(ans)
### BUGGY CODE ###

import sys
import numpy as np

input = sys.stdin.readline
n = int(input())
s = list(int(input()) for _ in range(n))
i = 0
maxn = 0
s2 = []
for i in range(n):
    s2 = s.copy()
    del s2[i]
    print(np.max(np.array(s2)))
    i += 1


### FIXED CODE ###

n = int(input())
s = list(int(input()) for _ in range(n))
i = 0
sort_s = sorted(s)

for i in s:
    if i == sort_s[-1]:
        print(sort_s[-2])
    else:
        print(sort_s[-1])
### BUGGY CODE ###

n = int(input())
s = input()
pattern = [tuple(s[:3])]
for c in s[3:]:
    for i in range(len(pattern)):
        p1, p2, p3 = pattern[i]
        if (p1, p2, c) not in pattern:
            pattern.append((p1, p2, c))
        if (p1, p3, c) not in pattern:
            pattern.append((p1, p3, c))
        if (p2, p3, c) not in pattern:
            pattern.append((p2, p3, c))
print(len(pattern))


### FIXED CODE ###

n = int(input())
s = input()
cnt = 0

for i in range(1000):
    p = str(i).zfill(3)
    p1 = s.find(p[0])
    if p1 == -1: continue
    p2 = s.find(p[1], p1 + 1)
    if p2 == -1: continue
    p3 = s.find(p[2], p2 + 1)
    if p3 == -1: continue
    cnt += 1
print(cnt)
### BUGGY CODE ###

n=int(input())
d=[list(map(int,input().split())) for i in range(n)]
def fill(l,x):
    w=len(l[0])
    return [[x]*(w+2)]+[[x]+i+[x] for i in l]+[[x]*(w+2)]
def swap(a,b):
    if a>b:
        return b,a
    return a,b
d=fill(d,0)
edge=[{} for i in range(n+1)]
for j in range(1,n+1):
    for i in range(j+1,n+1):
        edge[j][i]=d[i][j]
for k in range(1,n+1):
    for i in range(1,n+1):
        for j in range(1,n+1):
            if  d[i][j]>d[i][k]+d[k][j]:
                print(-1)
                quit()
            elif d[i][j]==d[i][k]+d[k][j]:
                if k==i or k==j:
                    continue
                x,y=swap(i,j)
                if y in edge[x]:
                    del edge[x][y]
ans=0
for i in edge:
    ans+=sum(i.values())
print(ans)

### FIXED CODE ###

n=int(input())
d=[list(map(int,input().split())) for i in range(n)]
def fill(l,x):
    w=len(l[0])
    return [[x]*(w+2)]+[[x]+i+[x] for i in l]+[[x]*(w+2)]
def swap(a,b):
    if a>b:
        return b,a
    return a,b
d=fill(d,0)
edge=[{} for i in range(n+1)]
for j in range(1,n+1):
    for i in range(j+1,n+1):
        edge[j][i]=d[i][j]
for k in range(1,n+1):
    for i in range(1,n+1):
        for j in range(1,n+1):
            if  d[i][j]>d[i][k]+d[k][j]:
                print(-1)
                quit()
            elif d[i][j]==d[i][k]+d[k][j]:
                if k==i or k==j:
                    continue
                x,y=swap(i,j)
                if y in edge[x]:
                    del edge[x][y]
ans=0
for i in edge:
    ans+=sum(i.values())
print(ans)
### BUGGY CODE ###

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

for i in lst:
    mult *= i

if mult <= 10 ** 18:
    print(mult)
else:
    print("-1")

### FIXED CODE ###

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

for i in lst:
    mult *= i
    if 10**18 < mult:
        print(-1)
        exit()
else:
    print(mult)