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

#https://atcoder.jp/contests/dp/tasks/dp_b
n, k = map(int,input().split())
h = [int(i) for i in input().split()]

dp = [0 for _ in range(n)]
dp[0] = 0

for i in range(1, n): #段数
    tmp = pow(2, 100)
    for j in range(1, k + 1): #一度に登る段数
        if i - j >= 0:
            tmp = min(tmp, dp[i - j] + abs(h[i] - h[i - j]))
    dp[i] = tmp

print(dp[n - 1])

### FIXED CODE ###

#https://atcoder.jp/contests/dp/tasks/dp_b
import sys
inf = sys.maxsize

n, k = map(int,input().split())
h = [int(i) for i in input().split()]

dp = [0 for _ in range(n)]
dp[0] = 0

for i in range(1, n): #段数
    tmp = min(k, i)
    dp[i] = min([dp[i - j] + abs(h[i] - h[i - j]) for j in range(1, tmp + 1)])
    '''
    tmp = inf
    for j in range(1, k + 1): #一度に登る段数
        if i - j >= 0:
            tmp = min(tmp, dp[i - j] + abs(h[i] - h[i - j]))
    dp[i] = tmp
    '''

print(dp[n - 1])
### BUGGY CODE ###

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

for _ in range(1, k+1):
    a, b, c = b+c, a+c, a+b

ans = 'Unfair' if len(str(abs(a-b))) > 18 else a-b
print(ans)


### FIXED CODE ###

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

if len(str(abs(a-b))) > 18:
    ans = 'Unfair'
else:
    ans = (a-b) * (-1)**(k%2)

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

n,ma,mb=map(int,input().split())
subs=[list(map(int,input().split())) for _ in range(n)]
infi=10**18
dp=[[[infi]*401 for _ in range(401)] for _ in range(n+1)]
dp[0][0][0]=0
for i in range(1,n+1):
    a,b,c=subs[i-1]
    for j in range(401):
        for k in range(401):
            if j+a<=400 and k+b<=400:
                dp[i][j+a][k+b]=min(dp[i][j+a][k+b],dp[i-1][j][k]+c)
            dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][k])
ans=infi
for i in range(1,401):
    for j in range(1,401):
        if i%ma==0 and j%mb==0:
            if i//ma==j//mb:
                ans=min(ans,dp[n][i][j])
if ans==infi:
    ans=-1
print(ans)

### FIXED CODE ###

n,ma,mb=map(int,input().split())
subs=[list(map(int,input().split())) for _ in range(n)]
infi=10**18
dp=[[[infi]*401 for _ in range(401)] for _ in range(n+1)]
dp[0][0][0]=0
for i in range(1,n+1):
    a,b,c=subs[i-1]
    for j in range(401):
        for k in range(401):
            if j+a<=400 and k+b<=400:
                dp[i][j+a][k+b]=min(dp[i][j+a][k+b],dp[i-1][j][k]+c)
            dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][k])
ans=infi
for i in range(1,401):
    for j in range(1,401):
        if i%ma==0 and j%mb==0:
            if i//ma==j//mb:
                ans=min(ans,dp[n][i][j])
if ans==infi:
    ans=-1
print(ans)
### BUGGY CODE ###

from collections import deque

h,w = map(int,input().split())
maze=[]

for _ in range(h):
    maze.append(input())

ans = 0

move = [[1,0],[-1,0],[0,1],[0,-1]]

for i in range(h):
    for j in range(w):
        if(maze[i][j]=="."):
            dist = [[999999]*w for _ in range(h)]
            
            dq = deque()
            y=i
            x=j
            d=0
            
            dq.append((y,x,d))
            
            while(len(dq)):
                
                y,x,d = dq.popleft()
                dist[y][x]=d
                for m in move:
                    if((0<=x+m[0]<w) and (0<=y+m[1]<h)):
                        if(dist[y+m[1]][x+m[0]] > d+1):
                            if(maze[y+m[1]][x+m[0]] == "."):
                                dq.append((y+m[1],x+m[0],d+1))
                                
            ans = max(ans,d)
            # print(d,i,j)
print(ans)

### FIXED CODE ###

from collections import deque

h,w = map(int,input().split())
maze = []

for _ in range(h):
    maze.append(input())

ans = 0

move = [[1,0],[-1,0],[0,1],[0,-1]]

for i in range(h):
    for j in range(w):
        if(maze[i][j]=="."):
            dist = [ [99999999]*w for _ in range(h) ]
            
            dq = deque()
            y=i
            x=j
            d=0
            dist[y][x]=0
            dq.append((y,x,d))
            
            while(len(dq)):
                
                y,x,d = dq.popleft()
                
                for m in move:
                    if((0<=x+m[0]<w) and (0<=y+m[1]<h) and
                        (dist[y+m[1]][x+m[0]] > d+1) and
                            (maze[y+m[1]][x+m[0]] == ".")):
                                dist[y+m[1]][x+m[0]]=d+1
                                dq.append((y+m[1],x+m[0],d+1))
                                
            ans = max(ans,d)
            # print(d,i,j)
print(ans)
### BUGGY CODE ###

n,m = map(int, input().split())
gates = []
for i in range(m):
    l,r = map(int, input().split())
    gates.append((l-1,r-1))

checker = [0 for i in range(n)]
for i in gates:
    for j in range(i[0],i[1]+1):
        checker[j] += 1

ans = 0
for i in checker:
    if i == m:
        ans += 1

print(ans)


### FIXED CODE ###

n,m = map(int, input().split())
l,r = 0,n
for i in range(m):
    L,R = map(int, input().split())
    l = max(l,L)
    r = min(r,R)

print(r-l+1 if l<=r else 0)
### BUGGY CODE ###

N, X, Y = map(int, input().split(' '))

dct = {X : Y}
short = Y - X - 1

dist_list = []

for i in range(1,N):
    for j in range(i+1,N+1):
        d1 = abs(X - i) + 1 + abs(Y - j)
        d2 = j - i
        dist = min(d1,d2)
        dist_list.append(dist)

for k in range(1,N):
    print(dist_list.count(k))

### FIXED CODE ###

N, X, Y = map(int, input().split(' '))

dist_list = [0] * N

for i in range(1,N):
    for j in range(i+1,N+1):
        d1 = abs(X - i) + 1 + abs(Y - j)
        d2 = j - i
        dist = min(d1,d2)
        dist_list[dist] += 1

for k in range(1,N):
    print(dist_list[k])
### BUGGY CODE ###

n,m = map(int,input().split())
a,b = [0 for _ in range(n)],[0 for _ in range(n)]

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

bought = 0
ans = 0

if len(a) == 1:
    print(a[0]*m)
    exit()
    
while(bought <= m):
    remain = m - bought
    if b[a.index(min(a))] <= remain:
        ans += min(a)*b[a.index(min(a))]
        bought += b[a.index(min(a))]
        b.remove(b[a.index(min(a))])
        a.remove(min(a))
    else:
        ans += min(a)*remain
        break
print(ans)

### FIXED CODE ###

n,m = map(int,input().split())
a = []
for i in range(n):
    a.append(list(map(int,input().split())))
a.sort(key = lambda a:a[0])
bought = 0
price = 0
for i in range(n):
    remain = m - bought
    if a[i][1] < remain:
        bought += a[i][1]
        price += a[i][0] * a[i][1]
    else:
        price += a[i][0]*remain
        print(price)
        exit()
### BUGGY CODE ###

import math
def gcd(a,b):
    if b>a:
        a,b=b,a
    while b:
        a,b=b, a%b
    return a

a,b=map(int,input().split())
x=gcd(a,b)
s=set()
while x>1:
    for i in range(2, min(x+1,int(math.sqrt(x))+2) ):
        while x%i==0:
            x=x//i
            s.add(i)
print(len(s)+1)

### FIXED CODE ###

import math
def gcd(a,b):
    if b>a:
        a,b=b,a
    while b:
        a,b=b, a%b
    return a

a,b=map(int,input().split())
x=gcd(a,b)
s=set()
for i in range(2, min(x+1,int(math.sqrt(x))+2) ):
    while x%i==0:
        x=x//i
        s.add(i)
    if x==1: break
if x>1: s.add(x)
print(len(s)+1)
### BUGGY CODE ###

import collections
from numpy.ma.core import sort
N = int(input())
arr = [input() for i in range(N)]
c = collections.Counter(arr)
# print(max(c.values()))
# ans = [c[x] for x in c]
ans = sorted([x for x in c if c[x] == max(c.values())])
# ans = [x for x in c]
for i in ans:
    print(i)

### FIXED CODE ###

import collections
N = int(input())
arr = [input() for i in range(N)]
c = collections.Counter(arr)
# print(max(c.values()))
# ans = [c[x] for x in c]
MAX = max(c.values())
ans = sorted([x for x in c if c[x] == MAX])
# ans = [x for x in c]
for i in ans:
    print(i)
### BUGGY CODE ###

d = {}
def popcount(n):
    if n not in d:
        d[n] = sum(x == '1' for x in bin(n))
    return d[n]
def f(n):
    c = 0
    while n != 0:
        n %= popcount(n)
        c += 1
    return c

n, X = open(0).read().split()
n = int(n)
x = int(X, 2)
X = list(map(int, X))
c = popcount(x)
for i in range(n):
    if X[i]:
        y = x - 2**(n-i-1)
        t = c-1
    else:
        y = x + 2**(n-i-1)
        t = c+1
    if y != 0:
        y %= t
        print(f(y)+1)
    else:
        print(0)

### FIXED CODE ###

n, X = open(0).read().split()
n = int(n)
x = int(X, 2)
X = list(map(int, X))

def popcount(n):
    return bin(n).count('1')

ma = 2 * 10**5 + 1
dp = [0] * ma
for i in range(1, ma):
    dp[i] = dp[i % popcount(i)] + 1

c = popcount(x)
a = x % (c+1)
if c == 1:
    for i in range(n):
        if X[i]:
            print(0)
        else:
            print(dp[(a + pow(2, n-i-1, c+1)) % (c+1)] + 1)
else:
    b = x % (c-1)
    for i in range(n):
        if X[i]:
            print(dp[(b - pow(2, n-i-1, c-1)) % (c-1)] + 1)
        else:
            print(dp[(a + pow(2, n-i-1, c+1)) % (c+1)] + 1)
### BUGGY CODE ###

from itertools import accumulate
import sys
input = sys.stdin.readline

n,c = map(int,input().split())
x1,v1 = [0],[0]
x2,v2 = [],[]
for _ in range(n):
  a,b = map(int, input().split())
  x1.append(a)
  x2 = [c-a] + x2
  v1.append(b)
  v2 = [b] + v2
x2 = [0] + x2
v2 = [0] + v2

v1, v2 = list(accumulate(v1)), list(accumulate(v2))
res = 0
for i in range(n+1):
  for j in range(n+1-i):
    cost = v1[i] + v2[j] - x1[i] - x2[j] - min(x1[i],x2[j])
    if cost > res:
      res = cost
print(res)

### FIXED CODE ###

from itertools import accumulate
import sys
input = sys.stdin.readline

def main():
    n,c = map(int,input().split())
    x1,v1 = [0],[0]
    for _ in range(n):
        a,b = map(int, input().split())
        x1.append(a)
        v1.append(b)
    x2 = [0]
    v2 = [0]
    for i in range(n,0,-1):
        x2.append(c-x1[i])
        v2.append(v1[i])

    v1, v2 = list(accumulate(v1)), list(accumulate(v2))
    g1,g2 = [v2[0]-x2[0]],[v2[0]-2*x2[0]]
    for i in range(1,n+1):
        f = v2[i] - x2[i]
        f2 = v2[i] - 2*x2[i]
        g1.append(max(g1[i-1],f))
        g2.append(max(g2[i-1],f2))
    val = max(v1[n]-x1[n] + g2[0], v1[n]-2*x1[n] + g1[0])
    for i in range(1,n+1):
        val = max(val, v1[n-i]-x1[n-i] + g2[i], v1[n-i]-2*x1[n-i] + g1[i])

    print(val)

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

mod=[]
answer = 2018
count = 0
sub=0
mod = [int(i) for i in input().split()]
if(mod[0]==mod[1]):
    answer = (mod[0]*mod[1])%2019

for i in range(mod[0],mod[1]+1):
    for j in range(i+1,mod[1]+1):
        sub = (i*j)%2019
        if sub<answer:
            answer = sub
    if count == 2018:
        break
    count = count + 1
print(answer)

### FIXED CODE ###

mod=[]
answer = 2018
count = 0
sub=0
mod = [int(i) for i in input().split()]
if(mod[0]==mod[1]):
    answer = (mod[0]*mod[1])%2019

for i in range(mod[0],mod[1]+1):
    if 2019<=mod[1]-mod[0]:
        answer = 0
        break
    for j in range(i+1,mod[1]+1):
        sub = (i*j)%2019
        if sub<answer:
            answer = sub
    if count == 2018:
        break
    count = count + 1
print(answer)
### BUGGY CODE ###

import sys
from collections import deque

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

N, M = lr()
AB = [lr() for _ in range(N)]
#Bが報酬
AB = [(a, b) for a, b in AB if a<=M]
AB.sort(reverse=True, key=lambda x: x[1])
AB = deque(AB)
answer = 0
used = set()
out = set()
while AB:
    x, y = AB.popleft()
    if x > M or x in out:
        continue
    else:
        z = x
        while z in used:
            z += 1
        if z > M:
            out = out.union(set(range(x, z)))
            continue
        used.add(z)
        answer += y

print(answer)
        


### FIXED CODE ###

import heapq

n,m=map(int,input().split())
jobs=[[] for _ in range(m)]
for i in range(n):
    d,r=map(int,input().split())
    if d-1<m:
        jobs[d-1].append(-r)
rewards=0
heap=[]
for i in range(m):
    for reward in jobs[i]:
        heapq.heappush(heap,reward)
    if len(heap)>0:
        rewards+=-heapq.heappop(heap)

print(rewards)
### BUGGY CODE ###

import copy
[n,x]=list(map(int,input().split()))
a=list(map(int,input().split()))
a0=copy.copy(a)
ans=0
for i in range(n-1):
	while a[i]+a[i+1]>x:
		a[i+1]-=1
		ans+=1
print(ans)

### FIXED CODE ###

import copy
[n,x]=list(map(int,input().split()))
a=list(map(int,input().split()))
a0=copy.copy(a)
ans=0
if a[0]+a[1]>x and a[0]>x:
	ans+=a[0]-x
	a[0]-=a[0]-x
	if a[0]+a[1]>x:
		ans+=a[1]
		a[1]=0	
for i in range(n-1):
	if a[i]+a[i+1]>x:
		ans+=a[i]+a[i+1]-x
		a[i+1]-=a[i]+a[i+1]-x
		
print(ans)
### BUGGY CODE ###

import itertools

l,r=map(int, input().split())
lis1 = []

for i in range(l,r+1):
      lis1.append(i)

lis2=[]

for v in itertools.permutations(lis1, 2):
    lis2.append(v[0]*v[1]%2019)
    
print(min(lis2))

### FIXED CODE ###

import sys
l,r = map(int,input().split())
a=[]

for i in range(l,r):
	for j in range(i+1,r+1):
		a.append((i*j)%2019)

		if (i*j)%2019 == 0:
			print(0)
			sys.exit()
print(min(a))
### BUGGY CODE ###

N, K =map(int, input().split())
lst=list(map(int, input().split()))
mx=0
for i in range(0, N-K+1):
	S=sum(lst[i:i+K])
	if mx<S:
		mx=S
print((mx+K)/2)


### FIXED CODE ###

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

expect=[(dice+1)/2 for dice in p]
#print(expect)
#plus_p=[sum(expect[i:i+K]) for i in range(N-K+1)]

first=sum(expect[0:K])
plus_p=[first]
for i in range(1, N-K+1):
	plus_p.append(plus_p[i-1]-expect[i-1]+expect[i-1+K])
#print(plus_p)
print(max(plus_p))
### BUGGY CODE ###

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

b = []
for i in range(n):
    if i % 2 == 0:
        b.append(arr[i])
    else:
        b.insert(0,arr[i])

if n % 2 == 0:
    pass
else:
    b.reverse()

for i in range(n-1):
    print(b[i], end = ' ')
print(b[-1])


### FIXED CODE ###

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

b = [0] * n
center = n // 2
for i in range(n):
    if i % 2 == 0:
        b[center + (i//2)] = arr[i]
    else:
        b[center - ((i+1)//2)] = arr[i]

if n % 2 == 0:
    pass
else:
    b.reverse()

for i in range(n-1):
    print(b[i], end = ' ')
print(b[-1])
### BUGGY CODE ###

S = list(input())
ans = 0
for _ in range(len(S)):
    check = S[0]
    tmp = ans
    for i in range(1,len(S)):
        if check != S[i]:
            count = 1
            for _ in range(len(S)):
                if i-1-count > 0 and i+count < len(S):
                    if S[i-1-count] != S[i+count]:
                        count += 1
                    else:
                        break
                else:
                    break
            ans += 2 * count
            del S[i-count:i+count]
            break
        check = S[i]
    if len(S) == 0:
        break
    if tmp == ans:
        break
print(ans)

### FIXED CODE ###

S = list(input())
c0 = 0
c1 = 0
for i in S:
    if i == '0':
        c0 += 1
    else:
        c1 += 1
ans = min(c0,c1) * 2
print(ans)
### BUGGY CODE ###

Q = int(input())
LR = [list(map(int,input().split())) for _ in [0]*Q]

N = max(r for l,r in LR)

p = set()
for i in range(3,N+1,2):
    for j in p:
        if i%j==0:break
    else:
        p.add(i)
p.add(2)

c = [0]*(N+1)
for i in p:
    if (i+1)//2 in p:c[i] = 1

#累積和
class cumulative_sum:
    def __init__(self,A):
        N = len(A)
        self.S = [0]*(N+1)
        for i in range(N):
            self.S[i+1] = self.S[i] + A[i]
    def get(self,i,j=None):
        if j==None:j=len(self.S)-1
        if j<=i:return 0
        return self.S[j]-self.S[i]

Sc = cumulative_sum(c)

for l,r in LR:
    print(Sc.get(l,r+1))

### FIXED CODE ###

def isPrime(n):
    for p in primes:
        if n%p == 0:
            return False
        elif n < p*p:
            return True

primes = [2,3,5,7]
for i in range(11,10**5,2):
    if isPrime(i):
        primes.append(i)
n2017s = [0]
for p in primes[1:]:
    if (p+1)//2 in primes:
        n2017s.append(p)
n2017s.append(10**6)
        
def binary_search(n):
    l=0
    r=len(n2017s)-1
    while l+1<r:
        i = (l+r)//2
        if n2017s[i] > n:
            r = i
        else:
            l = i
    return l

Q = int(input())
for i in range(Q):
    l,r = map(int,input().split())
    print(binary_search(r+1)-binary_search(l-1))
### BUGGY CODE ###

N, W = map(int,input().split(" "))
v = [0] * N
w =[0] * N
dp = [[0 for i in range(W+1)] for j in range(N+1)]
for i in range(N):
    v[i],w[i] = map(int,input().split(" "))
    for i in range(N-1,-1,-1):
        for j in range(W+1):
            if j < w[i]:
                dp[i][j] = dp[i+1][j]
            else :
                dp[i][j] = max(dp[i+1][j],dp[i+1][j-w[i]] + v[i])
print(dp[0][W])

### FIXED CODE ###

N, W = map(int, input().split(" "))

v = [0] * N
w = [0] * N
dp = [[-1 for i in range(W + 1)] for j in range(N + 1)]

for i in range(N):
    v[i], w[i] = map(int, input().split(" "))

def rec(i, j):
    if dp[i][j] != -1:
        return dp[i][j]

    if i == N:
        res = 0
    elif j < w[i]: 
        res = rec(i + 1, j) 
    else: 
        res = max(rec(i + 1, j), rec(i + 1, j - w[i]) + v[i]) 
        dp[i][j] = res 
    return res 
print(rec(0, W))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from collections import *
import math
from bisect import *
import functools
INF = float('inf')
mod = 10**9+7

def mat(A, B):
    n = len(A)
    C = [[0] * n for i in range(n)]
    for i in range(n):
        for j in range(n):
            for k in range(n):
                C[i][j] += A[i][k]*B[k][j]
            C[i][j] %= mod
    return C

N, K = map(int, input().split())
a = [[int(x) for x in input().split()] for i in range(N)]
b = [[0] * N for i in range(N)]
for i in range(N):
    b[i][i] = 1
while K > 0:
    if K % 2:
        b = mat(b, a)
    a = mat(a, a)
    K //= 2
print(sum([sum(_b) for _b in b])%mod)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from collections import *
import math
from bisect import *
import functools
INF = float('inf')
mod = 10**9+7

def mat(A, B):
    n = len(A)
    C = [[0] * n for i in range(n)]
    for i in range(n):
        for j in range(n):
            for k in range(n):
                C[i][j] += A[i][k]*B[k][j]
            C[i][j] %= mod
    return C

N, K = map(int, input().split())
a = [[int(x) for x in input().split()] for i in range(N)]
b = [[0] * N for i in range(N)]
for i in range(N):
    b[i][i] = 1
while K > 0:
    if K % 2:
        b = mat(b, a)
    a = mat(a, a)
    K //= 2
print(sum([sum(_b) for _b in b])%mod)
### BUGGY CODE ###

N = int(input())

A = []
for i in range(N):
    A.append(int(input()))

list_max = max(A)

import copy

for i in range(N):
    if A[i] != list_max:
        print(list_max)
    else:
        _tmp = copy.copy(A)
        _tmp.pop(i)
        print(max(_tmp))

### FIXED CODE ###

N = int(input())

A = []
for i in range(N):
    A.append(int(input()))

_A = sorted(A)

list_max = _A[N-1]
list_second_max = _A[N-2]

import copy

for i in range(N):
    if A[i] != list_max:
        print(list_max)
    else:
        print(list_second_max)
### BUGGY CODE ###

s = input()
N = int(input())
l = len(s)
li=[]
for scope in range(1,l+1):
    for first in range(l-scope+1):
        if not s[first:first+scope] in li:
            li.append(s[first:first+scope])

li.sort()
print(li[N-1])









### FIXED CODE ###

str=input()
K=int(input())
s=set()
for scope in range(1,K+1):
    for f in range(len(str)-scope+1):
        s.add(str[f:f+scope])
print(sorted([x for x in s])[K-1])
### BUGGY CODE ###

N, M, Q = list(map(int, input().strip().split()))
pattern_list = []
shortest = []
for _ in range(Q):
	pattern = tuple(map(int, input().strip().split()))
	shortest += [pattern[0], pattern[1]]
	pattern_list.append(pattern)
shortest = max(shortest)

def create(N,M):
	S = [[] for _ in range(N+1)]
	for m in range(1,M+1):
		S[1].append([m])
	for n in range(1,N):
		for s in S[n]:
			Max = s[-1]
			for i in range(Max, M+1):
				S[n+1].append(s+[i])
	return S

highest = 0
for n, n_letters in enumerate(create(N, M)):
	if n < shortest: continue
	for letters in n_letters:
		point = 0
		for a,b,c,d in pattern_list:
			if int(c) == letters[int(b-1)]-letters[int(a-1)]:
				point += d
		highest = max([highest, point])

print(highest)

### FIXED CODE ###

N, M, Q = list(map(int, input().strip().split()))
pattern_list = []
for _ in range(Q):
    pattern = tuple(map(int, input().strip().split()))
    pattern_list.append(pattern)

def create(N,M):
    S = [[] for _ in range(N+1)]
    for m in range(1,M+1):
        S[1].append([m])
    for n in range(1,N):
        for s in S[n]:
            Max = s[-1]
            for i in range(Max, M+1):
                S[n+1].append(s+[i])
    return S

highest = 0
for letters in create(N,M)[N]:
    point = 0
    for a,b,c,d in pattern_list:
        if c == letters[b-1]-letters[a-1]:
            point += d
    highest = max([highest, point])

print(highest)
### BUGGY CODE ###

import re
import sys

from collections import *
ddict=defaultdict

from functools import lru_cache
cache=lru_cache(None)

from heapq import *
from itertools import *
from statistics import *

from string import (
    ascii_letters as letters,
    ascii_lowercase as ucletters,
    ascii_uppercase as lcletters,
    digits
)
alnum=letters+digits
xdigits='01234567890abcdefabcdef'

from pprint import pprint

inf=float('inf')
ansmod=1000000007
int8_min=-128
int16_min=-32768
int32_min=-2147483648
int64_min=-9223372036854775808
int8_max=127
int16_max=32767
int32_max=2147483647
int64_max=9223372036854775807
uint8_max=255
uint16_max=65535
uint32_max=4294967295
uint64_max=18446744073709551615

rfs=lambda:rl().split()
ri=lambda:int(rl())
ris=lambda:list(map(int,rfs()))
rl=lambda:next(sys.stdin)
rrs=lambda:list(map(str.strip,sys.stdin))
rs=lambda:rl().strip()
rt=lambda:sys.stdin.read()
rg=lambda:list(map(list,rrs()))
rig=lambda:[[*map(int,x.split())] for x in rls()]

def nbs4(i,j):
    return [
                (i-1,j),
        (i,j-1),        (i,j+1),
                (i+1,j),
    ]

def nbs8(i,j):
    return [
        (i-1,j-1),(i-1,j),(i-1,j+1),
        (  i,j-1),        (  i,j+1),
        (i+1,j-1),(i+1,j),(i+1,j+1),
    ]

inb=lambda i,j,m,n:0<=i<m and 0<=j<n

sys.setrecursionlimit(int32_max)

################################################

H,W=ris()
S=rg()

def count(i,j,di,dj):
    ct=0
    while 0<=i<H and 0<=j<W and S[i][j]!='#':
        ct,i,j=ct+1,i+di,j+dj
    return ct

ans=0
for i in range(H):
    for j in range(W):
        if S[i][j]!='#':
            k=1
            k+=count(i-1,j,-1,0)
            k+=count(i,j+1,0,+1)
            k+=count(i+1,j,+1,0)
            k+=count(i,j-1,0,-1)
            ans=max(ans,k)

print(ans)


### FIXED CODE ###

import sys

H,W=map(int,next(sys.stdin).split())

xs=[[0]*(W+2) for _ in range(H+2)]
ys=[[0]*(W+2) for _ in range(H+2)]
for i in range(1,H+1):
    row=next(sys.stdin)
    for j in range(1,W+1):
        if row[j-1]!='.': continue
        xs[i][j]=1+xs[i][j-1]
        ys[i][j]=1+ys[i-1][j]

ans=0
for i in range(H,0,-1):
    for j in range(W,0,-1):
        if xs[i][j]==0: continue
        x=xs[i][j]=max(xs[i][j],xs[i][j+1])
        y=ys[i][j]=max(ys[i][j],ys[i+1][j])
        ans=max(ans,x+y-1)

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

big = 10**18
n = int(input())
things = list(map(int, input().split()))
result = 1
for x in things:
	result *= x

print(-1) if result > big else print(result)

### FIXED CODE ###

big = 10**18
n = int(input())
things = list(map(int, input().split()))
result = 1
good = True
if 0 in things:
	print(0)
else:
	for x in things:
		result *= x
		if result > big:
			print(-1)
			good = False
			break
	if good:
		print(result)