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

from math import ceil
from bisect import bisect
class BIT:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        i += 1
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

N,D,A = map(int,input().split())
XH = [list(map(int,input().split())) for _ in range(N)]
XH.sort()
X = [XH[i][0] for i in range(N)]
H = [XH[i][1] for i in range(N)]

bit0 = BIT(N)
bit1 = BIT(N)

ans = 0
for i in range(N):
    x = H[i]
    bit0.add(i,-x*i)
    bit1.add(i,x)
    bit0.add(i+1,x*(i+1))
    bit1.add(i+1,-x)
    h = bit1.sum(i)*(i+1)+bit0.sum(i)
    if i != 0:
        h -= bit1.sum(i-1)*i+bit0.sum(i-1)
    if h>0:
        ans += ceil(h/A)
        x = -ceil(h/A)*A
        j = bisect(X,X[i]+2*D)-1
        bit0.add(i,-x*i)
        bit1.add(i,x)
        bit0.add(j+1,x*(j+1))
        bit1.add(j+1,-x)

print(ans)

### FIXED CODE ###

from math import ceil
from bisect import bisect
from operator import itemgetter
class BIT:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

N,D,A = map(int,input().split())
XH = [list(map(int,input().split())) for _ in range(N)]
XH.sort(key=itemgetter(0))
X = [XH[i][0] for i in range(N)]
H = [XH[i][1] for i in range(N)]

bit = BIT(N)
ans = 0
for i in range(N):
    bit.add(i+1,H[i])
    bit.add(i+2,-H[i])
    h = bit.sum(i+1)
    if h>0:
        ans += ceil(h/A)
        x = -ceil(h/A)*A
        j = bisect(X,X[i]+2*D)
        bit.add(i+1,x)
        bit.add(j+1,-x)

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

from collections import Counter

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


for i in range(N):
    kosu = Counter(A)

tempSum = 0
for v in kosu.values():
    tempSum += v * (v - 1) // 2


def C(N):
    if N <= 0:
        return 0
    else:
        return N*(N-1)//2


for a in A:
    print(tempSum - kosu[a]+1)




### FIXED CODE ###

from collections import Counter
n = int(input())
A = list(map(int, input().split()))

cnt = Counter(A)

ans = 0
for v in cnt.values():
    ans += v * (v - 1) // 2

for k in A:
    # n*(n-1)//2 - (n-1)*(n-2)//2 = n - 1
    print(ans - (cnt[k] - 1))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
N = int(input())
Ls = input().split()
L = [int(s) for s in Ls]
tri = 0

for i in range(N-2):
    for j in range(N-2):
        for k in range(N-2-i-j):
            if ((L[i] + L[i+j+1]) > L[i+j+k+2]) and ((L[i] + L[i+j+k+2]) > L[i+j+1]) and ((L[i+j+k+2] + L[i+j+1]) > L[i]):
                tri += 1
print(tri)

### FIXED CODE ###

# -*- coding: utf-8 -*-
N = int(input())
L = list(map(int, input().split()))

def main():
    tri = 0
    L.sort()
    for i in range(N-1,-1,-1): #range(初期値,終了条件,変化量)
        mn = 0
        sl = i-1
        while(mn<sl):
            if (L[mn] + L[sl]) > L[i]:
                tri += sl - mn
                sl -= 1
            else:
                mn += 1
    print(tri)
    
main()
### BUGGY CODE ###

X, Y, Z, K = list(map(int, input().split()))
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))
C_list = list(map(int, input().split()))

A_list.sort(reverse=True)
B_list.sort(reverse=True)
C_list.sort(reverse=True)

class Value():
  def __init__(self, A_list, B_list, C_list, a_idx, b_idx, c_idx):
    self.A = A_list[a_idx]
    self.B = B_list[b_idx]
    self.C = C_list[c_idx]
    self.a_idx = a_idx
    self.b_idx = b_idx
    self.c_idx = c_idx
    self.value = self.A + self.B + self.C
  def __eq__(self, other):
    return self.a_idx == other.a_idx and self.b_idx == other.b_idx and self.c_idx == other.c_idx
  def __gt__(self, other):
    return self.value > other.value
  def __ge__(self, other):
    return self.value >= other.value
    
que = []
que.append(Value(A_list, B_list, C_list, 0, 0, 0))
current_value = 10000000000 * 3
for _ in range(K):
  v = que.pop(que.index(max(que)))
  print(v.value)
  if v.a_idx < X -1:
    new_v = Value(A_list, B_list, C_list, v.a_idx + 1, v.b_idx, v.c_idx)
    if not new_v in que:
      que.append(new_v)
  if v.b_idx < Y -1:
    new_v = Value(A_list, B_list, C_list, v.a_idx, v.b_idx + 1, v.c_idx)
    if not new_v in que:
      que.append(new_v)
  if v.c_idx < Z -1:
    new_v = Value(A_list, B_list, C_list, v.a_idx, v.b_idx, v.c_idx + 1)
    if not new_v in que:
      que.append(new_v)
  #que.sort(key=lambda x: x.value, reverse=True)

### FIXED CODE ###

X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

from heapq import heapify, heappop, heappush, heappushpop
 
 
class PriorityQueue:
    def __init__(self, heap):
        '''
        heap ... list
        '''
        self.heap = heap
        heapify(self.heap)
 
    def push(self, item):
        heappush(self.heap, item)
 
    def pop(self):
        return heappop(self.heap)
 
    def pushpop(self, item):
        return heappushpop(self.heap, item)
 
    def __call__(self):
        return self.heap
 
 
heap = []  # ヒープといっても順序を工夫したただのリスト
 
q = PriorityQueue(heap)
q.push((-(A[0] + B[0] + C[0]), 0, 0, 0))
 
considered = set()
ans = []
for k_th in range(1, K+1):
    heap_max, i, j, k = q.pop()
    ans.append(-heap_max)
    for di, dj, dk in zip([1, 0, 0], [0, 1, 0], [0, 0, 1]):
        i_new, j_new, k_new = i + di, j + dj, k + dk
        if i_new >= X or j_new >= Y or k_new >= Z:
            continue
        if (i_new, j_new, k_new) in considered:
            continue
        considered.add((i_new, j_new, k_new))
        q.push((-(A[i_new] + B[j_new] + C[k_new]), i_new, j_new, k_new))
 
 
print(*ans, sep='\n')
### BUGGY CODE ###

import math
from collections import defaultdict,deque

INF=10**12+1
a=input()
a=int(a)
graph = defaultdict(list)
for i in range(a):
    graph[i].append((1,(i+1)%a))
    graph[i].append((0,(i*10)%a))
costs=[INF]*a
costs[1]=1
que = [] #後ろの方が優先度高いqueue
que.append((0,1))
while len(que)!=0:
    temp=que.pop()
    now=temp[1]
    v_now=graph[now]
    for c,n in v_now: #v nowから出てる総てのノードについて操作する c→ノードのコスト n→行き先
        if costs[n]>c+costs[now]: #改善したのでそのvは走査の余地あり
            costs[n]=c+costs[now]
            que.append((c,n))
    que=sorted(que,reverse=True)
print(costs[0])
        

### FIXED CODE ###

import math
from collections import defaultdict,deque
import numpy as np
import heapq
INF=10**12+1
a=input()
a=int(a)
graph = defaultdict(list)
for i in range(a):
    graph[i].append((1,(i+1)%a))
    graph[i].append((0,(i*10)%a))
costs=[INF]*a
costs[1]=1
que = [] #後ろの方が優先度高いqueue
que.append((0,1))
while len(que)!=0:
    temp=heapq.heappop(que)
    now=temp[1]
    v_now=graph[now]
    for c,n in v_now: #v nowから出てる総てのノードについて操作する c→ノードのコスト n→行き先
        if costs[n]>c+costs[now]: #改善したのでそのvは走査の余地あり
            costs[n]=c+costs[now]
            heapq.heappush(que,(c,n))
            
print(costs[0])
### BUGGY CODE ###

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


cnt=0
for i in range(n-1):
    for j in range(i+1,n-1):
        for h in range(j+1,n):
            a,b,c=l[i],l[j],l[h]
            if(a<b+c)and(b<a+c)and(c<a+b):
                cnt+=1
print(cnt)

### FIXED CODE ###

from bisect import bisect_left

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

l.sort()
count = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    count+=bisect_left(l,l[j]+l[i])-j-1
print(count)
### BUGGY CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
mula_prev=0
mula_now=0
tmp=1
for i in range(k):tmp*=a[i]
mula_prev=tmp
for i in range(k,n):
    mula_now=tmp*a[i]//a[i-k]
    if mula_now>mula_prev:
        print('Yes')
    else:
        print('No')
    mula_now=mula_prev
    

### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
mula_now=0
tmp=0
mula_prev=a[0]
for i in range(k,n):
    mula_now=a[i]
    if mula_now>mula_prev:
        print('Yes')
    else:
        print('No')
    tmp+=1
    mula_prev=a[tmp]
### BUGGY CODE ###

def calc():
  H,W,M = map(int, input().split())
  s = []
  hcount = [0]*H
  wcount = [0]*W
  for m in range(M):
    h,w = map(int, input().split())
    h = h - 1
    w = w - 1
    hcount[h] = hcount[h] + 1
    wcount[w] = wcount[w] + 1
    s.append([h,w])
  hmax = max(hcount)
  wmax = max(wcount)
  hmode = []
  wmode = []
  for h in range(H):
    if hcount[h] == hmax:
      hmode.append(h)
  for w in range(W):
    if wcount[w] == wmax:
      wmode.append(w)
  for h in hmode:
    for w in wmode:
      if ([h,w] in s):
        continue
      return hmax + wmax
  return hmax + wmax - 1

if __name__ == '__main__':
    print(calc())

### FIXED CODE ###

def calc():
  H,W,M = map(int, input().split())
  s = []
  hcount = [0]*H
  wcount = [0]*W
  for m in range(M):
    h,w = map(int, input().split())
    h = h - 1
    w = w - 1
    hcount[h] = hcount[h] + 1
    wcount[w] = wcount[w] + 1
    s.append((h,w))
  hmax = max(hcount)
  wmax = max(wcount)
  hmode = [h for h, x in enumerate(hcount) if x == hmax]
  wmode = [w for w, y in enumerate(wcount) if y == wmax]
  s = tuple(s)
  S = set(s)
  for h in hmode:
    for w in wmode:
      if ((h,w) not in S):
        return hmax + wmax
  return hmax + wmax - 1
  
if __name__ == '__main__':
    print(calc())
### BUGGY CODE ###

#!/usr/bin/env python3
from itertools import combinations

mod = 10 ** 9 + 7


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

    c = combinations(ls, 2)

    ans = 0

    for cc in c:
        ans += cc[0] * cc[1] % mod

    print(ans % mod)


main()


### FIXED CODE ###

#!/usr/bin/env python3
MOD = 10 ** 9 + 7


class ModInt:
    def __init__(self, x):
        if type(x) is str:
            x = int(x)
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x)
            if isinstance(other, ModInt)
            else ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x)
            if isinstance(other, ModInt)
            else ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x)
            if isinstance(other, ModInt)
            else ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(self.x * pow(other.x, MOD - 2, MOD))
            if isinstance(other, ModInt)
            else ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD))
            if isinstance(other, ModInt)
            else ModInt(pow(self.x, other, MOD))
        )

    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x)
            if isinstance(other, ModInt)
            else ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            ModInt(other.x * pow(self.x, MOD - 2, MOD))
            if isinstance(other, ModInt)
            else ModInt(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            ModInt(pow(other.x, self.x, MOD))
            if isinstance(other, ModInt)
            else ModInt(pow(other, self.x, MOD))
        )


def main():
    n = int(input())
    ls = list(map(ModInt, input().split()))

    ans = ModInt(0)

    sm = sum(ls)

    for i in range(n):
        ans += ls[i] * sm

    sub = ModInt(0)
    for i in range(n):
        sub += ls[i] * ls[i]

    ans -= sub

    ans = ans / 2

    print(ans)


main()
### BUGGY CODE ###

a=list(map(int,input().split()))
ans=0
for i in range(a[0]+1):
    for j in range(a[0]+1):
        if a[1]-i-j <= a[0] and a[1]-i-j >= 0:
            ans+=1
print(str(ans))

### FIXED CODE ###

a=list(map(int,input().split()))
ans=0
for i in range(a[0]+1):
    for j in range(a[0]+1):
        if a[1]-i-j <= a[0] and a[1]-i-j >= 0:
            ans+=1
print(str(ans))
### BUGGY CODE ###

n=input()
count=0;
lis=[]
for i in range(0,int(n)):
    s=input()
    if s in lis:
        pass
    else :
        lis.append(s)
        count+=1
print(count)

### FIXED CODE ###

n=int(input())
s = list(set([input() for i in range(n)]))
print(len(s))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

ans = []
for i in range(n):
    h = a[i]
    for j in range(0,i-a[i]-1):
        if h + a[j] == abs(j-i):
            ans.append((i,j))
            ans.append((j,i))
    for j in range(a[i]+1,n):
        if h + a[j] == abs(j-i):
            ans.append((i,j))
            ans.append((j,i))

sans = set(ans)

print(len(sans)//2)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

from collections import defaultdict
ar = defaultdict(list)
al = defaultdict(list)

for i in range(n):
    al[i+a[i]].append(i)
    ar[i-a[i]].append(i)

x = al.keys()

ans = 0
for i in x:
    ans += len(ar[i]) * len(al[i])

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

def F(Arri,S,F,C):
    k=0
    while Arri > (S+F*k):
        k+=1
    return S+F*k+C

N=int(input())
n=0
L=[]
l = [0,0,0]
while n < N-1:
    l[0],l[1],l[2] = map(int,input().split(' '))
    L.append(l.copy())
    n+=1
T = []
j = 0
while j < N-1:
    t=0
    t += L[j][0]+L[j][1]
    q=j+1
    while q < N-1:
        t = F(t,L[q][1],L[q][2],L[q][0])
        q += 1
    T.append(t)
    j += 1
T.append(0)
for i in T:
    print(i)

### FIXED CODE ###

def F(Arri,S,F,C):
    if (Arri-S) <= 0:
        k=0
    else:
        k = (Arri-S) // F
        if (Arri-S) % F !=0:
            k += 1
    return S+F*k+C

N=int(input())
n=0
L=[]
l = [0,0,0]
while n < N-1:
    l[0],l[1],l[2] = map(int,input().split(' '))
    L.append(l.copy())
    n+=1
T = []
j = 0
while j < N-1:
    t=0
    t += L[j][0]+L[j][1]
    q=j+1
    while q < N-1:
        t = F(t,L[q][1],L[q][2],L[q][0])
        q += 1
    T.append(t)
    j += 1
T.append(0)
for i in T:
    print(i)
### BUGGY CODE ###

a, b, k = map(int, input().split())
num = [i for i in range(a, b+1)]
length = len(num)
index = []

for i in range(length):
    if i <= k-1 or length-1-i<=k-1:
        index.append(i)

for i in index:
    print(num[i])

### FIXED CODE ###

a, b, k = map(int, input().split())
length = b+1 -a
num = []

for i in range(a, min(b, a+k-1)+1):
    print(i)
    num.append(i)
for i in range(max(a, b - (k-1)), b+1):
    if i not in num:
        num.append(i)
        print(i)
### BUGGY CODE ###

q = int(input())
for i in range(q):
    x = input()
    y = input()
    n = len(x)
    m = len(y)
    d = [[0 for _ in range(m+1)] for _ in range(n+1)]
    for i in range(n):
        for j in range(m):
            if x[i] == y[j]:
                d[i+1][j+1] = d[i][j]+1
            else:
                d[i+1][j+1] = max(d[i+1][j],d[i][j+1])
    print(d[n][m])


### FIXED CODE ###

def calc(x,y):
    n = len(x)
    m = len(y)
    dp1 = [0]*(m+1)
    for i in range(n):
        s = x[i]
        dp2 = dp1[:]
        for j in range(m):
            if s == y[j]:
                dp1[j+1] = dp2[j]+1
            elif dp1[j+1] < dp1[j]:
                dp1[j+1] = dp1[j]
    return dp1[-1]

q = int(input())
for i in range(q):
    x = input()
    y = input()
    print(calc(x,y))
### BUGGY CODE ###

import numpy as np

#  入力
n, w = map(int, input().split())
wvList = []
wv = np.array([list(map(int, input().split())) for i in range(n)])

#  考えるDPテーブルは
#  重さの総和と使う荷物に関するもの
#  行が重さの上限
#  列が使える荷物の数に相当
dp = np.zeros((w + 1, n + 1), dtype=np.int)
for i in range(1, n + 1):
    #  更新の発想(wに意味はない)
    #  使える荷物が増えたが，利用はしない
    #  dp[w, i] = dp[w, i - 1]
    #  荷物を新しく許可された荷物を使う
    #  dp[w, i] = dp[w - wNew, i-1] + newValue
    #  このうちの価値の大きい方を使う
    dp[:, i] = dp[:, i - 1]
    dp[wv[i - 1, 0]:, :] = np.fmax(
        dp[wv[i - 1, 0]:, :], wv[i - 1, 1] + dp[: -wv[i - 1, 0], :]
    )

print(dp[w, n])


### FIXED CODE ###

import numpy as np


def main():
    N, W = list(map(int, input().split(' ')))
    items = np.array([list(map(int, input().split(' '))) for _ in range(N)])
    dp = np.zeros((N, W + 1))
    dp[0, items[0, 0]:] = items[0, 1]
    for n in range(1, N):
        weight, value = items[n, 0], items[n, 1]
        dp[n, :] = dp[n - 1, :]
        dp[n, weight:] = np.fmax(
            dp[n, weight:],
            value + dp[n - 1, :(- weight)]
        )
    print(int(dp[N - 1, W]))


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

import sys

sys.setrecursionlimit(10 ** 9)


def dfs(v, p):
    for next_v in g[v]:
        if next_v == p:
            continue
        cnt[next_v] += cnt[v]
        dfs(next_v, v)


N, Q = map(int, input().split())

g = {i:[] for i in range(N+1)}
cnt = {i:0 for i in range(N+1)}
for i in range(N - 1):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)

for i in range(Q):
    p, x = map(int, input().split())
    cnt[p] += x

dfs(1, -1)

print(*list(cnt.values())[1:])

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)


def dfs(v, p):
    for next_v in g[v]:
        if next_v == p:
            continue
        cnt[next_v] += cnt[v]
        dfs(next_v, v)


N, Q = map(int, input().split())

g = {i:[] for i in range(N+1)}
cnt = {i:0 for i in range(N+1)}
for _ in range(N - 1):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)

for i in range(Q):
    p, x = map(int, input().split())
    cnt[p] += x

dfs(1, -1)

print(*list(cnt.values())[1:])
### BUGGY CODE ###

from heapq import heapify, heappush, heappop, heappushpop

X, Y, Z, K = map(int, input().split())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
Cs = list(map(int, input().split()))

sum12s = []
for A in As:
    for B in Bs:
        sum12s.append(A+B)
sum12s.sort(reverse=True)

PQ = [Cs[0]+sum12 for sum12 in sum12s[:K]]
heapify(PQ)
for C in Cs[1:]:
    for sum12 in sum12s[:K]:
        heappush(PQ, C+sum12)
    for _ in range(K, len(PQ)):
        heappop(PQ)

anss = []
for _ in range(K):
    anss.append(heappop(PQ))
print('\n'.join(map(str, anss[::-1])))


### FIXED CODE ###

from heapq import heapify, heappush, heappop, heappushpop

X, Y, Z, K = map(int, input().split())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
Cs = list(map(int, input().split()))

sum12s = []
for A in As:
    for B in Bs:
        sum12s.append(A+B)
sum12s.sort(reverse=True)

PQ = [Cs[0]+sum12 for sum12 in sum12s[:K]]
heapify(PQ)
for C in Cs[1:]:
    for sum12 in sum12s[:K]:
        heappush(PQ, C+sum12)
    for _ in range(K, len(PQ)):
        heappop(PQ)

anss = []
for _ in range(K):
    anss.append(heappop(PQ))
print('\n'.join(map(str, anss[::-1])))
### BUGGY CODE ###

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

import bisect

lis = []
for i in range(n):
    ind = bisect.bisect_left(lis,a[i])
    if ind==0:
        bisect.insort_left(lis,a[i])
    else:
        lis[ind-1] = a[i]

print(len(lis))


### FIXED CODE ###

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

import bisect
from collections import deque

lis = deque()
for i in range(n):
    ind = bisect.bisect_left(lis,a[i])
    if ind==0:
        lis.appendleft(a[i])
    else:
        lis[ind-1] = a[i]

print(len(lis))
### BUGGY CODE ###

N  = int(input())
S = input()
result = []
for i in range(0, N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            num = S[i] + S[j] + S[k]
            if num not in result:
                result.append(num)
print(len(result))

### FIXED CODE ###

N  = int(input())
S = input()
P = 0
count = 0
for j in range(1000):
    V = str(P).zfill(3)
    p1 = False
    p2 = False
    for i in range(N):
        if S[i] == V[0] and not p1:
            p1 = True
            continue
        if S[i] == V[1] and p1 and not p2:
            p2 = True
            continue
        if S[i] == V[2] and p2:
            count += 1
            break
    P += 1
print (count)
### BUGGY CODE ###

N = int(input())
a = list(map(int,input().split()))
res = 1
for i in a:
    res *= i
if res > 10**18:
    print(-1)
else:
    print(res)

### FIXED CODE ###

def main():    
    N = int(input())
    a = list(map(int,input().split()))
    res = 1
    if 0 in a:
        print(0)
        return
    for i in a:
        res *= i
        if res > 10**18:
            print(-1)
            return
    print(res)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

def make_Graph(N, edges):#頂点の名前はi - 1で受け付ける
    graph = [ [] for i in range(N)]
    for edge in edges:
        a, b, c = edge
        graph[a].append((b,c))
        graph[b].append((a,c))
    return graph

def BFS(N, graph, start):
    Q = []
    V = []
    d = [float("inf")] * N
    Q.append(start)
    d[start] = 0
    while len(V) < N:
        a = Q.pop(0)
        V.append(a)
        for b, c in graph[a]:
            if not b in V:
                Q.append(b)
                d[b] = d[a] + c
    return d

N = int(input())
edges = []
for i in range(N-1):
    a, b, c = (int(j) for j in input().split())
    edges.append((a-1, b-1, c))

graph = make_Graph(N, edges)

Q, K =(int(i) for i in input().split())

d = BFS(N, graph, K-1)
for i in range(Q):
    x, y = (int(a) for a in input().split())
    print(d[x-1] + d[y-1])

### FIXED CODE ###

import sys
input = sys.stdin.readline

def make_Graph(N, edges):#頂点の名前はi - 1で受け付ける
    graph = [ [] for i in range(N)]
    for edge in edges:
        a, b, c = edge
        graph[a].append((b,c))
        graph[b].append((a,c))
    return graph

def BFS(N, graph, start):
    Q = []
    V = []
    prev = [None] * N
    dd = [float("inf")] * N
    Q.append(start)
    dd[start] = 0
    while len(V) < N:
        a = Q.pop(0)
        V.append(a)
        for b, c in graph[a]:
            if b != prev[a]:
                Q.append(b)
                prev[b] = a
                dd[b] = dd[a] + c
    return dd

def DFS(N, graph, a, p, d):
    dd[a] = d
    for b, c in graph[a]:
        if b == p or dd[b] != 0:
            continue
        else:
            DFS(N, graph, b, a, d + c)

N = int(input())
graph = [ [] for i in range(N)]
for i in range(N-1):
    a, b, c = (int(j) for j in input().split())
    graph[a-1].append((b-1,c))
    graph[b-1].append((a-1,c))

Q, K =(int(i) for i in input().split())
dd = [0] * N

try:
    DFS(N, graph, K-1, -1, 0)
except:
    dd = BFS(N, graph, K-1)

for i in range(Q):
    x, y = (int(a) for a in input().split())
    print(dd[x-1] + dd[y-1])
### BUGGY CODE ###

a=1
n=input()
s=list(map(int,input().split()))
for i in s:
  a*=i
if a>10**18:
  print(-1)
else:
  print(a)

### FIXED CODE ###

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

count=0
if 0 in s:
  print(0)
  count=1
else:
  a=1
  for i in s:
    a*=i
    if a>10**18:
      print(-1)
      break
if a<=10**18 and count!=1:
  print(a)
### BUGGY CODE ###

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

def expectationF(num):
  exp = 0
  for i in range(1,num+1):
    exp += i/num
  return exp

res = 0
mid = 0
for i in range(N-K+1):
  mid=0
  for j in range(K):
    mid += expectationF(List[i+j])
  res = max(res,mid)
print(res)

### FIXED CODE ###

N,K=map(int,input().split())
List = list(map(int, input().split()))
INF = 10000000000
expList = [INF]*1001
def expectationF(num):
  if expList[num] == INF:
    exp = 0
    for i in range(1,num+1):
      exp += i/num
    expList[num] = exp
  return expList[num]

res = 0
mid = 0
midList=[]
for i in range(N):
  if i>=1:
    midList.append(expectationF(List[i])+midList[i-1])
  else:
    midList.append(expectationF(List[i]))
m=K-1
for j in range(N-m):
  if j == 0:
    mid = midList[j+m]
  else:
    mid = midList[j+m]- midList[j-1] 
  res = max(res,mid)
print(res)