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

X,Y,A,B,C = list(map(int, input().split()))
red = list(map(int, input().split()))
green = list(map(int, input().split()))
white = list(map(int, input().split()))

red = sorted(red, reverse=True)[:X]
green = sorted(green, reverse=True)[:Y]
ans = sum(red) + sum(green)

white = sorted(white, reverse=True)
while len(white) != 0:
    current = white.pop(0)
    if red[-1] < green[-1] and current > red[-1]:
        ans += current - red[-1]
        red.pop(-1)
    elif red[-1] >= green[-1] and current > green[-1]:
        ans += current - green[-1]
        green.pop(-1)
    else:
        break

print(ans)

### FIXED CODE ###

X,Y,A,B,C = list(map(int, input().split()))
red = list(map(int, input().split()))
green = list(map(int, input().split()))
white = list(map(int, input().split()))

red = sorted(red, reverse=True)[:X]
green = sorted(green, reverse=True)[:Y]
ans = sum(red) + sum(green)

white = sorted(white, reverse=True)
for i in range(len(white)):
    current = white[i]
    if len(red) != 0 and len(green) != 0:
        if red[-1] < green[-1] and current > red[-1]:
            ans += current - red[-1]
            red.pop(-1)
        elif red[-1] >= green[-1] and current > green[-1]:
            ans += current - green[-1]
            green.pop(-1)
        else:
            break
    elif len(red) != 0:
        if current > red[-1]:
            ans += current - red[-1]
            red.pop(-1)
    elif len(green) != 0:
        if current > green[-1]:
            ans += current - green[-1]
    else:
        break

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

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


### FIXED CODE ###

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

N, A, B = list(map(int, input().split()))
char_num = 0
counter = 0
while char_num < N:
  for a in range(A):
    if char_num >= N:
      break
    counter += 1
    char_num += 1
  for b in range(B):
    if char_num >= N:
      break
    char_num += 1
print(counter)

### FIXED CODE ###

N, A, B = list(map(int, input().split()))
a = N//(A+B)*A
amari = N%(A+B)

if amari >= A:
  print(a + A)
else:
  print(a + amari)
### BUGGY CODE ###

N,P=map(int,input().split())
S=input()
sn=int(S)

amari=[0]*P
amari[0]=1

if P==2:
  ans=0
  for i in range(1,N+1):
    if int(S[-i])%2==0:
      ans+=N-i+1
  print(ans)
  exit()

if P==5:
  ans=0
  for i in range(1,N+1):
    if int(S[-i])%5==0:
      ans+=N-i+1
  print(ans)
  exit()

for i in range(1,N+1):
  #amari[int(S[-i:])%P]+=1
  amari[sn%(10**i)%P]+=1
ans=0
for tmp in amari:
  ans+=tmp*(tmp-1)//2
  
print(ans)

### FIXED CODE ###

N,P=map(int,input().split())
S=input()
sn=int(S)

if P==2:
  ans=0
  for i in range(1,N+1):
    if int(S[-i])%2==0:
      ans+=N-i+1
  print(ans)
  exit()

if P==5:
  ans=0
  for i in range(1,N+1):
    if int(S[-i])%5==0:
      ans+=N-i+1
  print(ans)
  exit()

amari=[0]*P
amari[0]=1

mod=0
for i in range(1,N+1):
  mod=(mod+int(S[-i])*pow(10,i-1,P))%P
  amari[mod]+=1
ans=0
for tmp in amari:
  ans+=tmp*(tmp-1)//2
  
print(ans)
### BUGGY CODE ###

N=int(input())
S=[]
for i in range(N):
  s=input()
  if s not in S:
    S.append(s)
print(len(S))
  

### FIXED CODE ###

N=int(input())
S=[]
for i in range(N):
  S.append(input())
print(len(set(S)))
### BUGGY CODE ###

n, p = map(int, input().split())

p2 = int(p ** (1 / n)) + 1

for i in range(p2, 0, -1):
    if p % (i ** n) == 0:
        print(i)
        break

### FIXED CODE ###

n, p = map(int, input().split())

p2 = round(p ** (1 / n))

for i in range(p2, 0, -1):
    if p % (i ** n) == 0:
        print(i)
        break
### BUGGY CODE ###

from math import sqrt

x = int(input())
sqrt_x = int(x)

ans = 1

for b in range(sqrt_x):
  
  for p in range(sqrt_x-1):
  
    exp = (b+1)**(p+2)

    if exp<=x and ans<=exp:
      ans = exp

print(ans)

### FIXED CODE ###

X = int(input())

score =0
half_x = round(X/2)

answer = 0

if X < 3:
    print(1)

elif X <= 8:
    print(2)

else:
    while 1 < half_x:
        half_x -= 1
        
        for p in range(2, 10):
            
            score = pow(half_x,p)
            if score > X:
                continue
        
            if answer < score:
                answer = score
                
    print(answer)
### BUGGY CODE ###

if __name__ == '__main__':
    n = int(input())
    s = ["".join(sorted(list(input()))) for i in range(n)]

    answer = 0
    for i in range(n):
        for j in range(i+1,n):
            if s[i] == s[j]:
                answer += 1
    print(answer)


### FIXED CODE ###

import collections


if __name__ == '__main__':
    n = int(input())
    s = ["".join(sorted(list(input()))) for i in range(n)]

    c = collections.Counter(s)

    answer = 0
    for cnt in c.values():
        answer += cnt*(cnt-1)//2
    print(answer)
### BUGGY CODE ###

import sys
import math
import functools
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

h, n = na()
a, b = [], []
for _ in range(n):
    ai, bi = na()
    a.append(ai)
    b.append(bi)
inf = 10**9
dp = [[inf]* (10**4+1) for _ in range(n+1)]
for i in range(n):
    for j in range(1, 10**4+1):
        if j < a[i]:
            dp[i+1][j] = min(dp[i][j],((j-1)//a[i]+1)*b[i])
        else:
            dp[i+1][j] = min(dp[i][j],((j-1)//a[i]+1)*b[i], dp[i+1][j - a[i]] + b[i])
print(dp[n][h])



### FIXED CODE ###

import sys
import math
import functools
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

h, n = na()
a, b = [], []
for _ in range(n):
    ai, bi = na()
    a.append(ai)
    b.append(bi)
inf = 10**9
dp = [[inf]* (10**4+1) for _ in range(n+1)]
for i in range(n):
    for j in range(1, 10**4+1):
        if j < a[i]:
            dp[i+1][j] = min(dp[i][j],((j-1)//a[i]+1)*b[i])
        else:
            dp[i+1][j] = min(dp[i][j],((j-1)//a[i]+1)*b[i], dp[i+1][j - a[i]] + b[i])
print(dp[n][h])
### BUGGY CODE ###

# original submission: https://atcoder.jp/contests/tokiomarine2020/submissions/14259812
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))

if K > 4 * math.log2(N):
    for _ in range(N):
        print(N," ", end = "")
    print()
else:
    cum_sum = [0]*N
    for i in range(K):
        for i in range(N):
          cum_sum[i] = 0
        for j in range(N):
            left = j - A[j]
            right = j + A[j]
            cum_sum[left if left >= 0 else 0] += 1
            if right + 1 < N:
                cum_sum[right+1] -= 1
        A[0] = cum_sum[0]
        for j in range(N-1):
            cum_sum[j+1] += cum_sum[j]
            A[j+1] = cum_sum[j+1]
            
    for i in range(N):
        print(A[i], " ", end = "")
    print()
            


### FIXED CODE ###

# original submission: https://atcoder.jp/contests/tokiomarine2020/submissions/14259812
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))

if K > 4 * math.log2(N):
    for _ in range(N):
        print(N," ", end = "")
    print()
else:
    for i in range(K):
        cum_sum = [0]*N
        for j in range(N):
            left = max(0, j - A[j])
            right = min(N-1, j+A[j])
            cum_sum[left] += 1
            if right + 1 < N:
                cum_sum[right+1] -= 1
        A[0] = cum_sum[0]
        for j in range(N-1):
            cum_sum[j+1] += cum_sum[j]
            A[j+1] = cum_sum[j+1]

            
    for i in range(N):
        print(A[i], " ", end = "")
    print()
### BUGGY CODE ###

import itertools
import numpy as np
N, M, Q = map(int,input().split())
List = [list(map(int, input().split())) for i in range(Q)]

A_full = np.arange(1,M+1)

l_tensu = [0]
for subset in itertools.combinations_with_replacement(A_full, N):
    tensu = 0

    A = np.sort(list(subset))
    for i in range(Q):
        a = List[i][0] - 1
        b = List[i][1] - 1
        c = List[i][2]
        d = List[i][3]
        if (A[b] - A[a] == c):
            tensu += d
    l_tensu.append(tensu)
    
print(max(l_tensu))

### FIXED CODE ###

import itertools
N, M, Q = map(int,input().split())
List = [list(map(int, input().split())) for i in range(Q)]

A_full = [i for i in range(1,M+1)]

l_tensu = 0
for subset in itertools.combinations_with_replacement(A_full, N):
    tensu = 0

    A = list(subset)
    for i in range(Q):
        a = List[i][0] - 1
        b = List[i][1] - 1
        c = List[i][2]
        d = List[i][3]
        if (A[b] - A[a] == c):
            tensu += d
    if(tensu > l_tensu):
        l_tensu = tensu
    
print(l_tensu)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().rstrip().split(" ")))
b1 = []
b2 = []
ans = []
if n % 2 == 0:
    for i in range(n):
        if n % 2 == 0:
            b1.append(a[i])
        else:
            b2.append(a[i])
        b1.reverse()
        ans = b1 + b2
    print(" ".join(str(i) for i in ans))
else:
    for i in range(n):
        if n % 2 == 0:
            b1.append(a[i])
        else:
            b2.append(a[i])
        b2.reverse()
        ans = b2 + b1
    print(" ".join(str(i) for i in ans))

### FIXED CODE ###

n = int(input())
a = list(map(int,input().rstrip().split(" ")))
b1 = []
b2 = []
ans = []
if n % 2 == 0:
    for i in range(n):
        if i % 2 == 0:
            b1.append(a[i])
        else:
            b2.append(a[i])
    b2.reverse()
    ans = b2 + b1
    print(" ".join(str(i) for i in ans))
else:
    for i in range(n):
        if i % 2 == 0:
            b1.append(a[i])
        else:
            b2.append(a[i])
    b1.reverse()
    ans = b1 + b2
    print(" ".join(str(i) for i in ans))
### BUGGY CODE ###

x = input()
i = 1
while (x != '0'):
    print("Case {}: {}".format(i, x));
    i += 1;

### FIXED CODE ###

i = 1
while True:
    x = int(input().strip())
    if x == 0:
        break
    else:
        print ("Case {}: {}".format(i,x))
        i += 1
### BUGGY CODE ###

from fractions import gcd 
from functools import reduce
import itertools
k = int(input())
a = [i for i in range(1,k+1)]
s = 0
for t in itertools.product(a,repeat=3):
  s += reduce(gcd,t)
print(s)

### FIXED CODE ###

import math
from functools import reduce
import itertools
k = int(input())
a = [i for i in range(1,k+1)]
s =0
#同じ数字３つの時
s = int(k*(k+1)/2)
#同じ数字２つと違う数字一つ
for q in itertools.combinations(a,2):
  s += reduce(math.gcd,q)*3*2
for t in itertools.combinations(a,3):
  s += reduce(math.gcd,t)*6
print(s)
### BUGGY CODE ###

import math
k=int(input())
ans=0
for i in range(1,k+1):
    for g in range(1,k+1):
        for l in range(1,k+1):
            ans+=math.gcd(math.gcd(i,g),l)
print(ans)


### FIXED CODE ###

import math
k=int(input())
ans=0
for i in range(1,k+1):
    for g in range(1,k+1):
        for l in range(1,k+1):
            ans+=math.gcd(math.gcd(i,g),l)
print(ans)
### BUGGY CODE ###

N,K=list(map(int,input().split()))
dp_list=[10**10]*110000
h=[0]*110000
hh=list(map(int,input().split()))
for i in range(len(hh)):
    h[i]=hh[i]
dp_list[0]=0
for i in range(N):
    for j in range(1,K+1):
        k=i+j
        dp_list[k]=min(dp_list[k],abs(h[k]-h[i])+dp_list[i])
print(dp_list[N-1])



### FIXED CODE ###

import numpy as np
N,K=list(map(int,input().split()))
dp_list=np.full(N,10**10,dtype=int)
h=list(map(int,input().split()))
h=np.array(h)
dp_list[0]=0
for i in range(1,N):
        dp_list[i:i+K] = np.fmin(dp_list[i:i+K], dp_list[i-1] + np.abs(h[i:i+K] - h[i-1]))
print(dp_list[-1])
### BUGGY CODE ###

N = int(input())
def f(a, b, c):
    return a**2 + b**2 + c**2 + a*b + b*c + c*a

for i in range(1, N+1):
    if i < 6:
        print(0)
    else:
        x, y, z = 0, 0, 0
        ans = 0
        while True:
            x += 1
            y = 0
            z = 0
            if f(x,y,z) > i:
                break
            while True:
                y += 1
                z = 1
                if f(x,y,z) > i:
                    break
                while f(x,y,z) <= i:
                    if f(x,y,z) == i:
                        ans += 1
                        break
                    z += 1
        print(ans)

### FIXED CODE ###

N = int(input())
def f(a, b, c):
    return a**2 + b**2 + c**2 + a*b + b*c + c*a
ans = [0] * N

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            n = f(x,y,z)
            if n <= N:
                ans[n-1] += 1
for a in ans:
    print(a)
### BUGGY CODE ###

h,a,*m=open(0)
h,w,k,a,b,f,g=map(int,(h+a).split())
I=h*w
d=[I]*I
a=~w+a*w+b
d[a]=1
q=[a]
for s in q:
 for y,x in(1,0),(-1,0),(0,1),(0,-1):
  for z in range(k):
   i,j=s//w+y*~z,s%w+x*~z;t=i*w+j;p=d[s]+1
   if(h>i>-1<j<w)-1or'.'<m[i][j]:break
   if d[t]>p:q+=t,;d[t]=p
print(d[~w+f*w+g]%I-1)

### FIXED CODE ###

import sys
inf=1000002
sys.setrecursionlimit(inf)
from collections import deque
h,w,k=map(int,input().split())
x1,y1,x2,y2=map(int,input().split())
c=[input() for i in range(h)]
dp=[[inf if c[i][j]=="." else -1 for j in range(w)] for i in range(h)]
now=deque()
now.append([x1-1,y1-1])
dp[x1-1][y1-1]=0
#kの更新が遅い
def bfs(d):
    global h,w,k,dp,now,x2,y2
    l=len(now)
    if l==0:
        return
    dp_sub=deque()
    cand=set()
    for i in range(l):
        x,y=now.popleft()
        for j in range(1,min(k+1,w-y)):
            if dp[x][y+j]==inf:
                dp_sub.append([x,y+j,d])
                #dp[x][y+j]=d
                cand.add((x,y+j))
                #now.append([x,y+j])
            else:
                break
        for j in range(1,min(k+1,y+1)):
            if dp[x][y-j]==inf:
                dp_sub.append([x,y-j,d])
                #dp[x][y-j]=d
                cand.add((x,y-j))
                #now.append([x,y-j])
            else:
                break
        for j in range(1,min(k+1,h-x)):
            if dp[x+j][y]==inf:
                dp_sub.append([x+j,y,d])
                #dp[x+j][y]=d
                cand.add((x+j,y))
                #now.append([x+j,y])
            else:
                break
        for j in range(1,min(k+1,x+1)):
            if dp[x-j][y]==inf:
                dp_sub.append([x-j,y,d])
                #dp[x-j][y]=d
                cand.add((x-j,y))
                #now.append([x-j,y])
            else:
                break
    while dp_sub!=deque([]):
        e=dp_sub.popleft()
        dp[e[0]][e[1]]=e[2]
    for i in cand:
        now.append(i)
    bfs(d+1)
bfs(1)
print(dp[x2-1][y2-1] if dp[x2-1][y2-1]!=inf else -1)
### BUGGY CODE ###

s = input()
q = int(input())
query = []
t1 = 1
for i in range(q):
    t = input()
    query.append(t)

for i in range(len(query)):
    t = query[i]
    if t == '1':
        t1 *= -1
    else:
        if t1 == 1:
            if t[2] == '1':
                s = t[4] + s
            else:
                s = s + t[4]
        else:
            if t[2] == '2':
                s = t[4] + s
            else:
                s = s + t[4]
        
ans = ''
if t1 == -1:
    ans = ''.join(list(reversed(s)))
else:
    ans = s

print(ans)
    

### FIXED CODE ###

from collections import deque
s = deque(list(input()))
q = int(input())
t1 = 1
for i in range(q):
    t = input()
    if t == '1':
        t1 *= -1
    else:
        if t1 == 1:
            if t[2] == '1':
                s.appendleft(t[4])
            else:
                s.append(t[4])
        else:
            if t[2] == '2':
                s.appendleft(t[4])
            else:
                 s.append(t[4])

ans = ''
if t1 == -1:
    ans = ''.join(reversed(s))
else:
    ans = ''.join(s)

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

data = [i for i in map(int,input().split())]
for i in range(data[2]):
  if data[0] >= 1:
    data[0] -= 1
  elif data[1] >=1:
    data[1] -=1
print(f'{data[0]} {data[1]}')

### FIXED CODE ###

a,b,k = map(int, input().split())
if a <= k:
    k -= a
    if b <= k:
        k -= b
        print(0,0)
    else:
        print(0,b-k)
else:
    print(a-k,b)
### BUGGY CODE ###

import copy
N = int(input())

A, B, C, D, E = [int(input()) for i in range(5)]
Xs = [N, 0, 0, 0, 0, 0]
Fs = [A, B, C, D, E]
Fmin = min(Fs)
c = 0
while True:
    #print(Xs)
    nXs = copy.copy(Xs)
    for i in range(len(Fs)):
        if Xs[i] - Fs[i] > 0:
            nXs[i] -= Fs[i]
            nXs[i+1] += Fs[i]
        else:
            nXs[i] -= Xs[i]
            nXs[i+1] += Xs[i]
        #print(nXs)
    Xs = nXs
    c+=1
    if max(Xs[1:5]) == Fmin:
        c+=Xs[0]//Fmin
        Xs[0]%=Fmin
    if sum(Xs[0:5]) == 0:
        break

print(c)

### FIXED CODE ###

N = int(input())
min_ = min([int(input()) for i in range(5)])

suf = 1 if N%min_ != 0 else 0
print(N//min_+4+suf)
### BUGGY CODE ###

import sys

A, B, Q = map(int, input().split())
S = [int(sys.stdin.readline()) for _ in range(A)]
T = [int(sys.stdin.readline()) for _ in range(B)]
X = [int(sys.stdin.readline()) for _ in range(Q)]
INF = 10**12

def binary_search(query, arr):
    arr = [-INF] + arr + [INF]
    low = 0
    high = len(arr)
    t = (low+high)//2
    while low<high-1:
        if query>arr[t]:
            low = t
        else:
            high = t
        t = (low+high)//2
    return arr[low], arr[high]

def find(query):
    s1, s2 = binary_search(query, S)
    t1, t2 = binary_search(query, T)
    return s1, s2, t1, t2

def main():
    for x in X:
        s1, s2, t1, t2 = find(x)
        cands = [
            abs(t1-x) + abs(s2-t1),
            abs(s1-x) + abs(t2-s1),
            abs(s2-x) + abs(t1-s2),
            abs(t2-x) + abs(s1-t2),
            abs(t1-x) + abs(s1-t1),
            abs(s1-x) + abs(t1-s1),
            abs(s2-x) + abs(t2-s2),
            abs(t2-x) + abs(s2-t2)
        ]
        print(min(cands))
    return

main()

### FIXED CODE ###

A, B, Q = map(int, input().split())
INF = 10**12
S = [-INF] + [int(input()) for _ in range(A)] + [INF]
T = [-INF] + [int(input()) for _ in range(B)] + [INF]
X = [int(input()) for _ in range(Q)]


def binary_search(query, arr):
    low = 0
    high = len(arr)
    while high-low>1:
        mid = (low+high)//2
        if query>arr[mid]:
            low = mid
        else:
            high = mid
    return arr[low], arr[high]

def main():
    for x in X:
        s1, s2 = binary_search(x, S)
        t1, t2 = binary_search(x, T)
        ans = [ abs(t-s)+min(abs(t-x), abs(s-x)) \
            for t in [t1, t2] for s in [s1, s2] ]
        print(min(ans))
    return

main()
### BUGGY CODE ###

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

for i in range(n-1):
    ans.append(ans[-1]*a[i+1])
    
com=ans[k-1]
for i in range(n-k):
    if com>=ans[i+k]/ans[i]:
        print("No")
    else:
        print("Yes")
    com=ans[i+k]/ans[i]

### FIXED CODE ###

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

for i in range(n-k):
    if a[i]>=a[i+k]:
        print("No")
    else:
        print("Yes")
### BUGGY CODE ###

n = int(input())
array = []

for i in range(n):
    array.append(int(input()))

m = max(array)
c = array.count(m)

for e in array:
    sa = array[:]
    if e != m:
        print(m)
    else:
        if 1 < c:
            print(m)
        else:
            sa.remove(m)
            print(max(sa))


### FIXED CODE ###

n = int(input())
array = []

for i in range(n):
    array.append(int(input()))

m = max(array)
c = array.count(m)
sa = array[:]
sa.remove(m)
m2 = max(sa)

for e in array:

    if e != m:
        print(m)
    else:
        if 1 < c:
            print(m)
        else:
            print(m2)
### BUGGY CODE ###

N = int(input())
sticks = list(map(int, input().split()))
diffMin = sum(sticks)
for i in range(len(sticks)):
    diff = abs(sum(sticks[:i]) - sum(sticks[i:]))
    if diff < diffMin:
        diffMin = diff
print(diffMin)


### FIXED CODE ###

N = int(input())
sticks = list(map(int, input().split()))
sticksSum = sum(sticks)
diffMin = sum(sticks)
plusSticks = 0
for i in range(len(sticks)):
    plusSticks += sticks[i]
    diffMin = min(diffMin, abs(2*plusSticks-sticksSum))
print(diffMin)
### BUGGY CODE ###

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

dp = [0] * N
for i in range(1, N):
    # 現在の足場を1~K前の足場から求める
    dp[i] = min([dp[j] + abs(h[j]-h[i]) for j in range(max(0,i-Ｋ),i)])

print(dp[-1])

### FIXED CODE ###

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

dp = [0] * N
for i in range(1, N):
    dp[i] = min([dp[j] + abs(h[j]-h[i]) for j in range(max(0,i-K),i)])

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

N=int(input())
L=list(map(int,input().split()))
counter=0
L.sort()
for i in range(len(L)):
    for j in range(i+1,len(L)):
        for k in range(j+1,len(L)):
            if L[i]+L[j]>L[k]:
                counter+=1
            else:
                break
print(counter)
    



### FIXED CODE ###


N=int(input())
L=list(map(int,input().split()))
counter=0
L.sort()
for i in range(N-2):
    k=i+2
    for j in range(i+1,N-1):    
        while k < N and L[k] < L[i] + L[j]:
            k += 1
        counter += k - j -1
print(counter)
### BUGGY CODE ###

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

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=1
for i in a:
  ans*=i
  if ans>10**18:
    break
if 0 in a:
  print(0)
elif ans<=10**18:
  print(ans)
else:
  print(-1)
### BUGGY CODE ###

import numpy as np

H,n = map(int,input().split())
A = [0 for _ in range(n)]
B = [0 for _ in range(n)]
min_eff = 9999.
for i in range(n):
    A[i],B[i] = map(int,input().split())
    min_eff = min(min_eff,A[i]/B[i])

dp = np.zeros((n+1,H+1))+H/min_eff+1
dp[:,0] = 0

for i in range(n):
    for h in range(H+1):
        idx = max(0,h-A[i])
        dp[i+1][h] = min(dp[i+1][idx] + B[i],dp[i][h])

print(int(dp[n,H]))


### FIXED CODE ###


H,n = map(int,input().split())
A = [0 for _ in range(n)]
B = [0 for _ in range(n)]
min_eff = 9999.
for i in range(n):
    A[i],B[i] = map(int,input().split())
    min_eff = min(min_eff,A[i]/B[i])

dp = [[int(H/min_eff+1) for _ in range(H+1)] for _ in range(n+1)]
for i in range(n+1):
    dp[i][0] = 0


for i in range(n):
    for h in range(H+1):
        idx = max(0,h-A[i])
        dp[i+1][h] = min(dp[i+1][idx] + B[i],dp[i][h])

print(int(dp[n][H]))