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

from itertools import accumulate as acc

N,K=map(int,input().split())
S=input()
First=S[0]
Last=S[N-1]
Now=First
cnt=0
Cont=[]
for s in S:    
    if Now=='1' and s=='0':
        Cont+=[cnt]
        cnt=0
        Now='0'
    elif Now=='0' and s=='1':
        Cont+=[cnt]
        cnt=0
        Now='1'
    cnt+=1
Cont+=[cnt]

lenC=len(Cont)
if First=="0":
    A1=[0]+[list(acc(Cont))[i] for i in range(lenC) if i%2==1]
    A0=[0]+[list(acc(Cont))[i] for i in range(lenC) if i%2==0]
else:
    A1=[list(acc(Cont))[i] for i in range(lenC) if i%2==0]
    A0=[0]+[list(acc(Cont))[i] for i in range(lenC) if i%2==1]

if Last=="0":
    A1+=[N]

if First=="0":
    if K<len(A1):
        print(max([A1[i+K]-A0[i] for i in range(len(A1)-K)]))
    else:
        print(A1[len(A1)-1])
else:
    if K<len(A1):
        print(max([A1[i+K]-A0[i] for i in range(len(A1)-K)]))
    else:
        print(A1[len(A1)-1])

### FIXED CODE ###

N,K=map(int,input().split())
S=input()
First=S[0]
Now=First
cnt=0
A=[0]
for s in S:
    if Now=='1' and s=='0':
        A+=[cnt]
        Now='0'
    elif Now=='0' and s=='1':
        A+=[cnt]
        Now='1'
    cnt+=1
A+=[N]
dp=2*K+1
ans=[]

if First=="0":
    p=1
    ans.append(A[min(dp-1,len(A)-1)])
else:
    p=0
    ans.append(A[min(dp,len(A)-1)])

while p+dp<len(A):
	ans.append(A[p+dp]-A[p])
	p+=2
ans.append(N-A[p])
#print(A)
print(max(ans))
### BUGGY CODE ###

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

cost=[10**9]*n
cost[0]=0
for i in range(1,n):
  for j in range(1,min(i+1,k+1)):
    cost[i]=min(cost[i],cost[i-j]+abs(h[i]-h[i-j]))
print(cost[-1])

### FIXED CODE ###

N,K=map(int,input().split())
listH=list(map(int,input().split()))
cost=[10**9]*N
cost[0]=0
for i in range(1,N):
  for k in range(1,K+1):
    if i-k>=0:
      cost[i]=min(abs(listH[i-k]-listH[i])+ cost[i-k],cost[i])
ans=cost[N-1]      
print(ans)
### BUGGY CODE ###

n, m = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
a.sort()
a.reverse()

if n == 1:
    ans = a[0]//(2**m)
    print(ans)
    exit()
while m > 0:
    for i in range(0,n):
        l = max(a)
        if a[i] > l//2:
            if m - 1 >= 0:
                a[i] = a[i]//2
            m -= 1
        else:
            break
print(sum(a))

### FIXED CODE ###

import heapq
n, m = map(int, input().split())
a = []
for i in list(map(int, input().split())):
    heapq.heappush(a,-i)

for _ in range(m):
    p = heapq.heappop(a)
    heapq.heappush(a, int(p/2))

print(-sum(a))
### BUGGY CODE ###

n,k = map(int,input().split())
x = list(map(int,input().split()))
ans = []
for i in range(n-k+1):
    x2 = x[i:i+k]
    if x2[0]*x2[-1] < 0:
        left = 2*abs(x2[0])+abs(x2[-1])
        right = 2*abs(x2[-1])+abs(x2[0])
        ans.append(min(left,right))
    else:
        ans.append(max(abs(x2[0]),abs(x2[-1])))
print(min(ans))

### FIXED CODE ###

n,k = map(int,input().split())
x = list(map(int,input().split()))
ans = 10**9
for i in range(n-k+1):
    if x[i]*x[i+k-1] < 0:
        left = 2*abs(x[i])+abs(x[i+k-1])
        right = 2*abs(x[i+k-1])+abs(x[i])
        ans= min(ans,min(left,right))
    else:
        ans = min(ans,max(abs(x[i]),abs(x[i+k-1])))
print(ans)
### BUGGY CODE ###

# coding: utf-8
# Your code here!

#保存
import heapq
import sys
import itertools
 
sys.setrecursionlimit(10**7)

def bfs(cost,node):
    root[node]=min(root[node],cost)
    visited[node]=1
    for next_n in way[node]:
        if visited[next_n]==0:
            heapq.heappush(q,[cost+1,next_n])
    return
    
N,X,Y=map(int,input().split())
r=[i for i in range(N)]

way=[[] for i in range(N)]

for i in range(N-1):
    way[i].append(i+1)
    way[i+1].append(i)

way[X-1].append(Y-1)
way[Y-1].append(X-1)

#print(way)

made=[]


#print(q)
for start in r:
    root=[10**9]*N
    visited=[0]*N
    #print(root)
    q=[[0,start]]
    heapq.heapify(q)#costとnode
    while q:
        temp=heapq.heappop(q)
        #print(temp)
        #print(temp)
        if visited[temp[1]]==0:
            bfs(temp[0],temp[1])
    made.append(root)
#print(made)

ans=[0]*(N)
for item in made:
    for num in item:
        ans[num]+=1

for a in ans[1:]:
    print(a//2)

"""
ans=10**9
for order in itertools.permutations([i for i in range(len(r))]):
    #print(order)
    temp=0
    for i in range(len(order)-1):
        fro=r[order[i]]
        aft=r[order[i+1]]
        #print("YES")
        #print(order[i]-1,order[i+1]-1)
        #print(root[order[i]-1][0])
        temp+=abs(made[order[i]][aft-1]-made[order[i]][fro-1])
    ans=min(ans,temp)
print(ans)
"""



### FIXED CODE ###

# coding: utf-8
# Your code here!
N,X,Y=map(int,input().split())
X-=1
Y-=1

ans=[0]*N
for n in range(N-1):
    for tgt in range(n+1,N):
        temp=min(abs(tgt-n),abs(n-X)+abs(Y-tgt)+1)
        #print(n,tgt,temp)
        ans[temp]+=1


for a in ans[1:]:
    print(a)
### BUGGY CODE ###

from sys import stdin
from sys import setrecursionlimit
import numpy as np
import math

setrecursionlimit(10 ** 7)

n,k = map(int,stdin.readline().rstrip().split())
a = list(map(int,stdin.readline().rstrip().split()))

a.sort()
a = np.array(a,dtype=np.int64)

low = 0
hi = 10**9
point = 0

while hi-low > 0.000000001:
    ave = (hi+low)/2
    if np.ceil(a//ave).sum() <= k:
        hi = ave
    else:
        low = ave

print(math.ceil(ave))

### FIXED CODE ###

from sys import stdin
from sys import setrecursionlimit
import numpy as np
import math

setrecursionlimit(10 ** 7)

n,k = map(int,stdin.readline().rstrip().split())
a = list(map(int,stdin.readline().rstrip().split()))

a.sort()
a = np.array(a,dtype=np.int64)

low = 0
hi = 10**9
point = 0

while point <= 100:
    ave = (hi+low)/2
    if np.ceil(a//ave).sum() <= k:
        hi = ave
    else:
        low = ave
    point += 1

print(math.ceil(ave))
### BUGGY CODE ###


N = int(input())
S = [input() for _ in range(N)]

import sys
import queue

def getVlist(x):
    reslist = []
    for i in range(N):
        if int(S[x][i]): reslist.append(i)
    return reslist

ans = 0

for kk in range(N):
    q = queue.Queue()
    visited = [False] * N
    
        
    cnt = 1
    visited[kk] = True
    q.put(kk)
    
    while sum(visited) < N:
        nextv = []
        while not(q.empty()):
            nextv.append(q.get())
        nextv = list(set(nextv))
        #子の要素同士の連結チェック
        L = len(nextv)
        for i in range(L):
            visited[nextv[i]] = True
            for j in range(i+1,L):
                if (int(S[nextv[i]][nextv[j]])):
                    print(-1)
                    sys.exit()
        
        for nv in nextv:
            for v in getVlist(nv):
                if not(visited[v]):
                    q.put(v)
    
        cnt += 1
    
    ans = max(ans,cnt-1)
        
#
print(ans)


### FIXED CODE ###


N = int(input())
S = [input() for _ in range(N)]

import sys
import copy

ans = 0
adj_list = [[]for _ in range(N)]
for i in range(N):
    for j in range(i+1,N):
        if int(S[i][j]):
            adj_list[i].append(j)
            adj_list[j].append(i)


for kk in range(N):
    q = []
    visited = [False] * N
    cnt = 1
    visited[kk] = True
    q.append(kk)
    VC = 1
    while VC < N:
        nextv = copy.copy(q)
        q = []
        nextv = list(set(nextv))
        #子の要素同士の連結チェック
        L = len(nextv)
        for i in range(L):
            if not(visited[nextv[i]]):
                visited[nextv[i]] = True
                VC += 1
            for j in range(i+1,L):
                if (int(S[nextv[i]][nextv[j]])):
                    print(-1)
                    sys.exit()
        
        for nv in nextv:
            for v in adj_list[nv]:
                if not(visited[v]):
                    q.append(v)
    
        cnt += 1
    
    ans = max(ans,cnt-1)
        
#
print(ans)
### BUGGY CODE ###

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

b=[0,0,0]
for i in a:
    b[i-1]+=1
k1,k2,k3=b
dp=[[[0]*(k3+1) for _ in range(k2+k3+1)] for _ in range(k1+k2+k3+1)]

for k in range(k3+1):
    for j in range(k2+k3+1-k):
        for i in range(k1+k2+k3+1-j-k):
            if not i+j+k:continue
            dp[i][j][k]=((dp[i-1][j][k]*i if i else 0)+(dp[i+1][j-1][k]*j if j else 0)+(dp[i][j+1][k-1]*k if k else 0)+n)/(i+j+k)

print(dp[k1][k2][k3])

### FIXED CODE ###

n=int(input())

b=[0,0,0]
for i in map(int,input().split()):
    b[i-1]+=1
k1,k2,k3=b
dp=[[[None]*(k3+1) for _ in range(k2+k3+1)] for _ in range(k1+k2+k3+1)]
dp[0][0][0]=0

for k in range(k3+1):
    for j in range(k2+k3+1-k):
        for i in range(k1+k2+k3+1-j-k):
            if not i+j+k:continue
            dp[i][j][k]=((dp[i-1][j][k]*i if i else 0)+(dp[i+1][j-1][k]*j if j else 0)+(dp[i][j+1][k-1]*k if k else 0)+n)/(i+j+k)

print(dp[k1][k2][k3])
### BUGGY CODE ###

import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

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

m = -1

for x in range(1, N+1):
    res = math.floor(A * x / B) - A * math.floor(x / B)
    if res >= m:
        m = res
    elif res == 0:
        break
    else:
        break

print(m)


### FIXED CODE ###

import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

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

# m = -1

# for x in range(1, N+1):
#     res = math.floor(A * x / B) - A * math.floor(x / B)
#     print(res)

if B > N:
    x = N
    res = math.floor(A * x / B) - A * math.floor(x / B)
    print(res)
else:
    x = B - 1
    res = math.floor(A * x / B) - A * math.floor(x / B)
    print(res)
### BUGGY CODE ###

import math

def nCr(n,r):
    f = math.factorial
    return f(n) // f(r) // f(n-r)

def distancesum(arr, n): 
      
    # sorting the array. 
    arr.sort() 
      
    # for each point, finding  
    # the distance. 
    res = 0
    sum = 0
    for i in range(n): 
        res += (arr[i] * i - sum) 
        sum += arr[i] 
      
    return res 

flatten = lambda x: [z for y in x for z in (flatten(y) if hasattr(y, '__iter__') and not isinstance(y, str) else (y,))]

div = 10**9 + 7

N, M, K = map(int, input().split())
repeat = nCr(N*M-2, K-2)
f_row = flatten([[i for _ in range(M)] for i in range(N)])
f_col = flatten([[i for i in range(M)] for _ in range(N)])

manhsum = distancesum(f_row, len(f_row)) + distancesum(f_col, len(f_col))
print(((repeat % div) * (manhsum % div))%div)


                                                  
    


### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
# 10 ** 7 might cause MLE
fac = [-1] * (10**6+1)
inv = [-1] * (10**6+1)
finv = [-1] * (10**6+1)

fac[0] = fac[1] = 1
inv[1] = 1
finv[0] = finv[1] = 1

def initNCMMod(limit):
    for i in range(2, limit):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod // i) % mod
        finv[i] = finv[i-1] * inv[i] % mod

def NCMMod(n, k):
    if n < k:
        return 0
    if (n < 0 or k < 0):
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod
initNCMMod(10**6)

def checkf(R, C):
    ans = 0
    for r1 in range(R):
        for c1 in range(C):
            for r2 in range(R):
                for c2 in range(C):
                    ans += abs(r1-r2) + abs(c1-c2)
    return ans


def main():
    R, C, K = LI()
    def f(i):
        return (i * (i+1) // 2) % mod

    ans = 0
    for i in range(C):
        ans += f(C-i-1) * R * R % mod
        ans += f(i) * R * R % mod

    for i in range(R):
        ans += f(R-i-1) * C * C % mod
        ans += f(i) * C * C % mod
    ans *= inv[2]
    ans %= mod
    ans *= NCMMod(R*C-2, K-2)
    ans %= mod

    print(ans)

main()
### BUGGY CODE ###

n, s=map(int,input().split())
q=[list(map(int, input().split())) for i in range(n)]

import numpy as np
import itertools
import pprint

bit=[0,1]

cmp=list(itertools.product(bit, repeat=n))

cp=[0]*n
qt=[0]*n
cnt=[0]*2**n

for i in range(n):
	cp[i]=100*(i+1)*q[i][0]+q[i][1]
	qt[i]=q[i][0]

for i in range(2**n):
	score=np.dot(np.array(cp),np.array(cmp[i]).T)
	cnt[i]=np.dot(np.array(qt),np.array(cmp).T)[i]
	if score<s:
		j=n-1
		while score<s and j>=0:
			if cmp[i][j]==0:
				for k in range(qt[j]):
					score+=(j+1)*100
					cnt[i]+=1
					if score>=s:
						j=0
						break
			j-=1
                
print(min(cnt))

### FIXED CODE ###

n, s=map(int,input().split())
q=[list(map(int, input().split())) for i in range(n)]

import numpy as np
import itertools
import pprint

bit=[0,1]

cmp=list(itertools.product(bit, repeat=n))

cp=[0]*n
qt=[0]*n
cnt=[0]*2**n

for i in range(n):
	cp[i]=100*(i+1)*q[i][0]+q[i][1]
	qt[i]=q[i][0]

cmp_cnt=np.dot(np.array(qt),np.array(cmp).T)

for i in range(2**n):
	score=np.dot(np.array(cp),np.array(cmp[i]).T)
	cnt[i]=cmp_cnt[i]
	if score<s:
		j=n-1
		while score<s and j>=0:
			if cmp[i][j]==0:
				for k in range(qt[j]):
					score+=(j+1)*100
					cnt[i]+=1
					if score>=s:
						j=0
						break
			j-=1
                
print(min(cnt))
### BUGGY CODE ###

import numpy as np
import math
s = str(input())
n = len(s)
ans = 0

for i in range(n):
    for j in range(i+3,n):
        if int(s[i:j+1])%2019 == 0:
            ans += 1

print(ans)


### FIXED CODE ###

import numpy as np
s = list(map(int,input()))
n = len(s)
ans = 0
mod = 2019
past = s[n-1]
ima = 0
d = dict()
d[s[n-1]] = 1
now = 10
for i in range(1,n):
    ima = (past+s[n-i-1]*now)%mod
    if ima == 0:
        ans += 1
    if ima in d:
        d[ima] += 1
    else:
        d[ima] = 1
    past = ima
    now = (now*10)%mod

for i in d.values():
    ans += i*(i-1)//2

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

h,w,m=map(int,input().split())

max_h=[0 for i in range(h+1)]
max_w=[0 for i in range(w+1)]
grid=[[0 for i in range(w)] for j in range(h)]
#pro=[list(map(int,input().split())) for i in range(m)]
#pro.sort()
for t in range(m):
    #h=pro[t][0]
   # w=pro[t][1]
    h,w=map(int,input().split())
    max_h[h]+=1
    max_w[w]+=1
    grid[h-1][w-1]=1
h_max=[i for i, x in enumerate(max_h) if x == max(max_h)]
w_max=[i for i, x in enumerate(max_w) if x == max(max_w)]

ans=0
for i in h_max:
    for j in w_max:
        cnt=0
        cnt +=list(zip(*grid))[j-1].count(1)
        cnt += grid[i-1].count(1)
        '''
        for k in range(h):
            if grid[k][j-1]==1:
                cnt += 1
        for l in range(w):
            if grid[i-1][l]==1:
                cnt += 1
        '''
        if grid[i-1][j-1]==1:
            cnt -= 1
        
        if cnt > ans:
            ans=cnt
print(ans)

### FIXED CODE ###

H, W, M = map(int, input().split())
row=[0]*H #x座標を入れるっちゅうかカウント
col=[0]*W #y座標を入れる
 
mat=[] #座標を入れる
 
for i in range(M):
    h, w = map(int, input().split())
    row[h-1]+=1
    col[w-1]+=1
    mat.append((h-1,w-1))
r=max(row)
c=max(col)
 
rr=[1 if row[i]==r else 0 for i in range(H)] #maxな列のインデックス
cc=[1 if col[i]==c else 0 for i in range(W)] #maxな行のインデックス
 
x=0 #maxな列と行の交差点にある爆弾の個数をカウント
for k in mat:
    if rr[k[0]]==1 and cc[k[1]]==1:
        x+=1
        
if sum(rr)*sum(cc)==x: #行と列の全ての交差点に爆弾があれば-1する
    print(r+c-1)
else:
    print(r+c)
### BUGGY CODE ###

h, w, m = map(int, input().split())
a = [[0 for _ in range(w)] for _ in range(h)]
for i in range(m):
    hi, wi = map(int, input().split())
    a[hi-1][wi-1] = 1

mh = [sum(a[i][:]) for i in range(h)]
mw = [sum([r[i] for r in a]) for i in range(w)]
ans = max(mh) + max(mw)

mh = [i for i, v in enumerate(mh) if v == max(mh)]
mw = [i for i, v in enumerate(mw) if v == max(mw)]

flag = 0
for i in mh:
    for j in mw:
        if a[i][j] == 0:
            print(ans)
            exit()
print(ans - 1)

### FIXED CODE ###

h, w, m = map(int, input().split())
a = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
mh = [0 for i in range(h)]
mw = [0 for j in range(w)]

for i, j in a:
    mh[i] += 1
    mw[j] += 1 

hmax = max(mh)
wmax = max(mw)
ans = hmax + wmax

flag = mh.count(hmax) * mw.count(wmax)
for i,j in a:
    if mh[i] == hmax and mw[j] == wmax:
        flag -= 1

if flag == 0:
    print(ans - 1)
else:
    print(ans)
### BUGGY CODE ###

import functools
N = int(input())
numbers = list(map(int,input().split()))
xor = ''
for i in range(len(numbers)):
    othersNumbers = numbers[:i] + numbers[i + 1:]
    currentXor = 0
    xor += str(functools.reduce(lambda x,y:x^y,othersNumbers)) + ' '
    
print(xor)

### FIXED CODE ###

N=int(input())
a=list(map(int,input().split()))
a_all=0
for i in range(N):
    a_all^=a[i]
ans=[]
for j in range(N):
    ans.append(a_all^a[j])
print(*ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
mod = 10**9 + 7

c = [n]*61
for i in range(n):
    b = str(bin(a[i]))[2:]
    b = b[::-1]
    for j, x in enumerate(b):
        if x == "1":
            c[j] -= 1

ans = 0
for i in range(60):
    ans += c[i]*(n-c[i])*pow(2,i,mod)
    ans %= mod
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
mod = 10**9 + 7

c = [n]*61
for i in range(n):
    b = str(bin(a[i]))[2:]
    b = b[::-1]
    for j, x in enumerate(b):
        if x == "1":
            c[j] -= 1

ans = 0
for i in range(60):
    ans += c[i]*(n-c[i])*pow(2,i,mod)
    ans %= mod
print(ans)
### BUGGY CODE ###

import sys 
sys.setrecursionlimit(10**5+10)
f_inf = 10 ** 9
dp = [f_inf] *(10**5 +10)
n,k  = map(int, input().split())
h = list(map(int, input().split()))
def chmin(a,b):
    if a<b:
        return a
    else:
        return b

def rec(i):
    if dp[i] < f_inf: #更新されてたらそのまま返す
        return dp[i]

    if i == 0 :
        return 0
    
    res = f_inf
    for j in range(1,k+1):
        if i-j < 0:
            continue
        else:
            res = chmin(res, rec(i-j) + abs(h[i]-h[i-j]))
        
    dp[i] = res

    return res
def main():
    
    print(rec(n-1))

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
def chmin(a, b):
    if a > b:
        return b
    else:
        return a
  
n,k = map(int,input().split())
h = [int(i) for i in input().split()]
# dpの最小値を変更する関数

# 無限大の値
f_inf = 10 ** 9 
# DP テーブルを初期化　(最小化問題なので INF に初期化)
dp = [f_inf] * (10**5+10)
# 初期条件
dp[0] = 0
# 足場 i-1 から足場 i へ移動する。コストは|h[i]−h[i-1]|
# 足場 i-2 から足場 i へと移動する コストは |h[i]−h[i-2]|
for i in range(1, n):
    for j in range(1,k+1):
        if i-j < 0 :
            continue
        else:
            dp[i] = chmin(dp[i], dp[i - j] + abs(h[i] - h[i-j]))
print(dp[n-1])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,W=map(int,input().split())
    w=[0]*(n+1)
    v=[0]*(n+1)
    for i in range(1,n+1):
        w[i],v[i]=map(int,input().split())

    def solve(i,x): # i番目の時点で残り容量x
        if(x<0): return -INF
        if(i>n): return 0
        return max(solve(i+1,x),solve(i+1,x-w[i])+v[i])

    print(solve(1,W))
resolve()

### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,w=map(int,input().split())
    W=[0]*n; V=[0]*n
    for i in range(n):
        a,b=map(int,input().split())
        W[i]=a; V[i]=b
    # dp[i][k] iまでの品物で、重さがk以下
    dp=[[0]*(w+1) for _ in range(n+1)]
    for i in range(1,n+1):
        for k in range(w+1):
            if k-W[i-1]>=0:
                dp[i][k]=max(dp[i-1][k-W[i-1]]+V[i-1],dp[i-1][k])
            else:
                dp[i][k]=dp[i-1][k]
    print(dp[n][w])
resolve()
### BUGGY CODE ###

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

exv = list()

for a in p:
    exv.append((1+a)/2)

sm = list()

for a in range(N-K+1):
    sm.append(sum(exv[a:a+K]))

print('{:.12f}'.format(max(sm)))

### FIXED CODE ###

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

from collections import deque

exv = list()

for a in p:
    exv.append((1+a)/2)

sm = 0
mx = 0

q = deque()

for a in range(N):
    sm += exv[a]
    q.appendleft(exv[a])
    if len(q) > K:
        sm -= q.pop()
    if len(q) == K:
        mx = max(mx,sm)

print('{:.12f}'.format(mx))
### BUGGY CODE ###

S = list(input())
Q = int(input())

r = False
for i in range(Q):
    x = input().split()
    
    if x[0] == "1":
        r = not r
        
    else:
        if x[1] == "1":
            if r == False :
                S.insert(0, x[2])
            else:
                S.append(x[2])
        else:
            if r == True :
                S.insert(0, x[2])
            else:
                S.append(x[2])
        
if r:
    print("".join(S[::-1]))
else:
    print("".join(S))

### FIXED CODE ###

from collections import deque
S = list(input())
Q = int(input())

day = deque(S)

r = False
for i in range(Q):
    x = input().split()
    
    if x[0] == "1":
        r = not r
        
    else:
        if x[1] == "1":
            if r == False :
                day.appendleft(x[2])
            else:
                day.append(x[2])
        else:
            if r == True :
                day.appendleft(x[2])
            else:
                day.append(x[2])
                
day = list(day)
        
if r:
    print("".join(day[::-1]))
else:
    print("".join(day))
### BUGGY CODE ###

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

l = sorted(nn)

for i in l:
  print(nn.index(i)+1)


### FIXED CODE ###

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

import numpy as np

ll = np.array(nn)
p = list(ll.argsort())

for i in p:
  print(i+1)
### BUGGY CODE ###

import math
import numpy as np
 
N, K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))

A_sort = sorted(A)
F_sort = sorted(F,reverse=True)

l = -1
r = 0
for i in range(N):
    r = max(r,A_sort[i]*F_sort[i])

def judge(c):
    s = 0
    for i in range(N):
        s += max(A_sort[i]-c//F_sort[i],0)
    return s <= K

while r-l > 1:
    c = (l+r)//2
    if judge(c):
        r = c
    else:
        l = c
print(r)


### FIXED CODE ###

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

A_sort = sorted(A)
F_sort = sorted(F,reverse=True)

l = -1
r = 0
for i in range(N):
    r = max(r,A_sort[i]*F_sort[i])

def judge(c):
    s = 0
    for i in range(N):
        s += max(A_sort[i]-c//F_sort[i],0)
    return s <= K

while r-l > 1:
    c = (l+r)//2
    if judge(c):
        r = c
    else:
        l = c
print(r)
### BUGGY CODE ###

n=int(input())
s=input()
r=[]
r2=[]
g=[]
g2=[]
b=[]
b2=[]
for i in range(n):
  if s[i]=='R':
    r.append(i)
    r2.append(i*2)
  elif s[i]=='G':
    g.append(i)
    g2.append(i*2)
  else:
    b.append(i)
    b2.append(i*2)
ans=len(r)*len(g)*len(b)
for i in g:
  for j in b:
    if i+j in r2:
      ans-=1
for i in r:
  for j in b:
    if i+j in g2:
      ans-=1
for i in g:
  for j in r:
    if i+j in b2:
      ans-=1
print(ans)

### FIXED CODE ###

import bisect
n=int(input())
s=input()
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)
r.append(n*4)
g.append(n*4)
b.append(n*4)
for i in g:
  for j in b:
    a=i+j
    if a%2==0 and r[bisect.bisect_left(r, a//2)]==a//2:
      ans-=1
for i in r:
  for j in b:
    a=i+j
    if a%2==0 and g[bisect.bisect_left(g, a//2)]==a//2:
      ans-=1
for i in g:
  for j in r:
    a=i+j
    if a%2==0 and b[bisect.bisect_left(b, a//2)]==a//2:
      ans-=1
print(ans+3)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
from collections import Counter
cnt = Counter(a)
if 0 in cnt:
    print(0)
    quit()
ans = 1
for i, j in cnt.items():
    #print(i, j)
    ans *= i ** j
if ans > 10 ** 18:
    print(-1)
else:
    print(ans) 

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
import sys
limit = 10 ** 18
if 0 in a:
    print(0)
    sys.exit()
else:
    ans = 1
    for i in range(n):
        ans *= a[i]
        if ans > limit:
            print(-1)
            sys.exit()
    print(ans)