Input:
#coding: UTF-8

import math

N=int(input())

def prime_list(k):

    lis=[True for i in range(1,k+1)]

    lis[0]=False

    for i in range(2,k+1):

        j=2

        while j*j<=i:

            if i%j==0:

                lis[i-1]=False

                break

            else:

                j+=1

    return lis

#    print(lis)

def p_fact(k,N):

    plist=prime_list(k)

    lis=[0]*N

    for i in range(0,k):

        n=0

        if plist[i]:

            while k%(i+1)==0:

                n+=1

                k=k/(i+1)

        lis[i]=n

    return lis

out_lis=[0]*N

for i in range(1,N+1):

    input_lis=p_fact(i,N)

    out_lis=[out_lis[j]+input_lis[j] for j in range(0,N)]

#print(out_lis)

out=1

for i in range(0,N):

    out=out*(out_lis[i]+1)

print((out%1000000007))

#coding: UTF-8

import math

N=int(input())

def prime_list(k):

    lis=[True for i in range(1,k+1)]

    lis[0]=False

    for i in range(2,k+1):

        j=2

        while j*j<=i:

            if i%j==0:

                lis[i-1]=False

                break

            else:

                j+=1

    return lis

#    print(lis)

def p_fact(k,N,plist):

#    plist=prime_list(k)

    lis=[0]*N

    for i in range(0,k):

        n=0

        if plist[i]:

            while k%(i+1)==0:

                n+=1

                k=k/(i+1)

        lis[i]=n

    return lis

#    print(lis)

out_lis=[0]*N

plist=prime_list(N)

for i in range(1,N+1):

    input_lis=p_fact(i,N,plist)

    out_lis=[out_lis[j]+input_lis[j] for j in range(0,N)]

#print(out_lis)

out=1

for i in range(0,N):

    out=out*(out_lis[i]+1)

#print(out%1000000007)

print((out%(10**9+7)))

# coding: UTF-8
import math

N = int(input())

def prime_list(k):
    lis = [True for i in range(1, k + 1)]
    lis[0] = False
    for i in range(2, k + 1):
        j = 2
        while j * j <= i:
            if i % j == 0:
                lis[i - 1] = False
                break
            else:
                j += 1
    return lis

#    print(lis)
def p_fact(k, N):
    plist = prime_list(k)
    lis = [0] * N
    for i in range(0, k):
        n = 0
        if plist[i]:
            while k % (i + 1) == 0:
                n += 1
                k = k / (i + 1)
        lis[i] = n
    return lis

out_lis = [0] * N
for i in range(1, N + 1):
    input_lis = p_fact(i, N)
    out_lis = [out_lis[j] + input_lis[j] for j in range(0, N)]
# print(out_lis)
out = 1
for i in range(0, N):
    out = out * (out_lis[i] + 1)
print((out % 1000000007))

# coding: UTF-8
import math

N = int(input())

def prime_list(k):
    lis = [True for i in range(1, k + 1)]
    lis[0] = False
    for i in range(2, k + 1):
        j = 2
        while j * j <= i:
            if i % j == 0:
                lis[i - 1] = False
                break
            else:
                j += 1
    return lis

#    print(lis)
def p_fact(k, N, plist):
    #    plist=prime_list(k)
    lis = [0] * N
    for i in range(0, k):
        n = 0
        if plist[i]:
            while k % (i + 1) == 0:
                n += 1
                k = k / (i + 1)
        lis[i] = n
    return lis

#    print(lis)
out_lis = [0] * N
plist = prime_list(N)
for i in range(1, N + 1):
    input_lis = p_fact(i, N, plist)
    out_lis = [out_lis[j] + input_lis[j] for j in range(0, N)]
# print(out_lis)
out = 1
for i in range(0, N):
    out = out * (out_lis[i] + 1)
# print(out%1000000007)
print((out % (10**9 + 7)))

-def p_fact(k, N):
-    plist = prime_list(k)
+def p_fact(k, N, plist):
+    #    plist=prime_list(k)
+#    print(lis)
+plist = prime_list(N)
-    input_lis = p_fact(i, N)
+    input_lis = p_fact(i, N, plist)
-print((out % 1000000007))
+# print(out%1000000007)
+print((out % (10**9 + 7)))


Input:
import sys

import queue

N = 3

f= ''.join(sys.stdin.readline().split())

f+= ''.join(sys.stdin.readline().split())

f+= ''.join(sys.stdin.readline().split())

dd = [[-1, 0], [0, -1], [1, 0], [0, 1]]

Q = queue.Queue()

V = dict()

Q.put([f,f.index('0'),0])

V[f] = True

while not Q.empty():

    u = Q.get()

    if u[0] == '123456780':  break

    sx, sy = u[1]//N, u[1]%N

    for dx, dy in dd:

        tx, ty = sx+dx, sy+dy

        if tx<0 or ty<0 or tx>=N or ty>=N: continue

        v = u[:]

        n1, n2 = u[1], tx*N+ty

        v[1] = n2

        if n1>n2: n1, n2 = n2, n1

        v[0] = v[0][0:n1]+v[0][n2]+v[0][n1+1:n2]+v[0][n1]+v[0][n2+1:]

        if not V.get(v[0], False):

            V[v[0]] = True

            v[2] += 1

            Q.put(v)

print((u[2]))

import sys

import queue

N = 3

f = ''.join(sys.stdin.readline().split())

f += ''.join(sys.stdin.readline().split())

f += ''.join(sys.stdin.readline().split())

dd = [[-1, 0], [0, -1], [1, 0], [0, 1]]

Q = [[f,f.index('0'),0]]

V = { f: True }

while len(Q)>0:

    u = Q.pop(0)

    if u[0] == '123456780':  break

    sx, sy = u[1]//N, u[1]%N

    for dx, dy in dd:

        tx, ty = sx+dx, sy+dy

        if tx<0 or ty<0 or tx>=N or ty>=N: continue

        v = u[:]

        n1, n2 = u[1], tx*N+ty

        v[1] = n2

        if n1>n2: n1, n2 = n2, n1

        v[0] = v[0][0:n1]+v[0][n2]+v[0][n1+1:n2]+v[0][n1]+v[0][n2+1:]

        if not V.get(v[0], False):

            V[v[0]] = True

            v[2] += 1 # dir[r]

            Q.append(v)

print((u[2]))

import sys
import queue

N = 3
f = "".join(sys.stdin.readline().split())
f += "".join(sys.stdin.readline().split())
f += "".join(sys.stdin.readline().split())
dd = [[-1, 0], [0, -1], [1, 0], [0, 1]]
Q = queue.Queue()
V = dict()
Q.put([f, f.index("0"), 0])
V[f] = True
while not Q.empty():
    u = Q.get()
    if u[0] == "123456780":
        break
    sx, sy = u[1] // N, u[1] % N
    for dx, dy in dd:
        tx, ty = sx + dx, sy + dy
        if tx < 0 or ty < 0 or tx >= N or ty >= N:
            continue
        v = u[:]
        n1, n2 = u[1], tx * N + ty
        v[1] = n2
        if n1 > n2:
            n1, n2 = n2, n1
        v[0] = v[0][0:n1] + v[0][n2] + v[0][n1 + 1 : n2] + v[0][n1] + v[0][n2 + 1 :]
        if not V.get(v[0], False):
            V[v[0]] = True
            v[2] += 1
            Q.put(v)
print((u[2]))

import sys
import queue

N = 3
f = "".join(sys.stdin.readline().split())
f += "".join(sys.stdin.readline().split())
f += "".join(sys.stdin.readline().split())
dd = [[-1, 0], [0, -1], [1, 0], [0, 1]]
Q = [[f, f.index("0"), 0]]
V = {f: True}
while len(Q) > 0:
    u = Q.pop(0)
    if u[0] == "123456780":
        break
    sx, sy = u[1] // N, u[1] % N
    for dx, dy in dd:
        tx, ty = sx + dx, sy + dy
        if tx < 0 or ty < 0 or tx >= N or ty >= N:
            continue
        v = u[:]
        n1, n2 = u[1], tx * N + ty
        v[1] = n2
        if n1 > n2:
            n1, n2 = n2, n1
        v[0] = v[0][0:n1] + v[0][n2] + v[0][n1 + 1 : n2] + v[0][n1] + v[0][n2 + 1 :]
        if not V.get(v[0], False):
            V[v[0]] = True
            v[2] += 1  # dir[r]
            Q.append(v)
print((u[2]))

-Q = queue.Queue()
-V = dict()
-Q.put([f, f.index("0"), 0])
-V[f] = True
-while not Q.empty():
-    u = Q.get()
+Q = [[f, f.index("0"), 0]]
+V = {f: True}
+while len(Q) > 0:
+    u = Q.pop(0)
-            v[2] += 1
-            Q.put(v)
+            v[2] += 1  # dir[r]
+            Q.append(v)


Input:
#!usr/bin/env python3

from collections import defaultdict

from collections import deque

from heapq import heappush, heappop

import sys

import math

import bisect

import random

def LI(): return list(map(int, sys.stdin.readline().split()))

def I(): return int(sys.stdin.readline())

def LS():return list(map(list, sys.stdin.readline().split()))

def S(): return list(sys.stdin.readline())[:-1]

def IR(n):

    l = [None for i in range(n)]

    for i in range(n):l[i] = I()

    return l

def LIR(n):

    l = [None for i in range(n)]

    for i in range(n):l[i] = LI()

    return l

def SR(n):

    l = [None for i in range(n)]

    for i in range(n):l[i] = S()

    return l

def LSR(n):

    l = [None for i in range(n)]

    for i in range(n):l[i] = SR()

    return l

mod = 1000000007

#A

def A():

    s = S()

    t = S()

    if s+t == t[::-1]+s[::-1]:

        print("YES")

    else:

        print("NO")

#B

def B():

    n = I()

    for i in range(int(n**0.5)+2)[::-1]:

        if i*i <= n:

            print((i*i))

            quit()

#C

def C():

    n = I()

    a = LI()

    b = LI()

    c = LI()

    q = [0 for i in range(n)]

    ans = 0

    a.sort()

    b.sort()

    c.sort()

    for i in range(n):

        j = bisect.bisect_left(a,b[i])

        q[i] = j

    for i in range(n-1):

        q[i+1] += q[i]

    q.insert(0,0)

    for i in range(n):

        j = bisect.bisect_left(b,c[i])

        ans += q[j]

    print(ans)

#D

def D():

    def dijkstra():

        d = [float("inf") for i in range(k)]

        q = [[0,1]]

        d[1] = 0

        while q:

            dx,x = heappop(q)

            for y,dy in v[x]:

                if d[y] > dx+dy:

                    d[y] = dx+dy

                    heappush(q,[d[y],y])

        print((d[0]+1))

    k = I()

    if k == 1:

        print((1))

        quit()

    v = [[] for i in range(k)]

    for i in range(1,k):

        v[i].append([(i+1)%k,1])

        v[i].append([i*10%k,0])

    dijkstra()

#E

def E():

    return

#F

def F():

    return

#G

def G():

    return

#H

def H():

    return

#Solve

if __name__ == "__main__":

    D()

#!usr/bin/env python3

from collections import defaultdict,deque

from heapq import heappush, heappop

from itertools import permutations

import sys

import math

import bisect

def LI(): return [int(x) for x in sys.stdin.readline().split()]

def I(): return int(sys.stdin.readline())

def LS():return [list(x) for x in sys.stdin.readline().split()]

def S():

    res = list(sys.stdin.readline())

    if res[-1] == "\n":

        return res[:-1]

    return res

def IR(n):

    return [I() for i in range(n)]

def LIR(n):

    return [LI() for i in range(n)]

def SR(n):

    return [S() for i in range(n)]

def LSR(n):

    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)

mod = 1000000007

def solve():

    def v(n):

        return [n*10%k, (n+1)%k]

    k = I()

    d = [float("inf")]*k

    d[1] = 1

    q = deque([1])

    while q:

        x = q.popleft()

        vx = v(x)

        dx = d[x]

        for c in range(2):

            nd = dx+c

            y = vx[c]

            if nd < d[y]:

                d[y] = nd

                if c:

                    q.append(y)

                else:

                    q.appendleft(y)

    print((d[0]))

    return

#Solve

if __name__ == "__main__":

    solve()

#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random

def LI():
    return list(map(int, sys.stdin.readline().split()))

def I():
    return int(sys.stdin.readline())

def LS():
    return list(map(list, sys.stdin.readline().split()))

def S():
    return list(sys.stdin.readline())[:-1]

def IR(n):
    l = [None for i in range(n)]
    for i in range(n):
        l[i] = I()
    return l

def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):
        l[i] = LI()
    return l

def SR(n):
    l = [None for i in range(n)]
    for i in range(n):
        l[i] = S()
    return l

def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):
        l[i] = SR()
    return l

mod = 1000000007
# A
def A():
    s = S()
    t = S()
    if s + t == t[::-1] + s[::-1]:
        print("YES")
    else:
        print("NO")

# B
def B():
    n = I()
    for i in range(int(n**0.5) + 2)[::-1]:
        if i * i <= n:
            print((i * i))
            quit()

# C
def C():
    n = I()
    a = LI()
    b = LI()
    c = LI()
    q = [0 for i in range(n)]
    ans = 0
    a.sort()
    b.sort()
    c.sort()
    for i in range(n):
        j = bisect.bisect_left(a, b[i])
        q[i] = j
    for i in range(n - 1):
        q[i + 1] += q[i]
    q.insert(0, 0)
    for i in range(n):
        j = bisect.bisect_left(b, c[i])
        ans += q[j]
    print(ans)

# D
def D():
    def dijkstra():
        d = [float("inf") for i in range(k)]
        q = [[0, 1]]
        d[1] = 0
        while q:
            dx, x = heappop(q)
            for y, dy in v[x]:
                if d[y] > dx + dy:
                    d[y] = dx + dy
                    heappush(q, [d[y], y])
        print((d[0] + 1))

    k = I()
    if k == 1:
        print((1))
        quit()
    v = [[] for i in range(k)]
    for i in range(1, k):
        v[i].append([(i + 1) % k, 1])
        v[i].append([i * 10 % k, 0])
    dijkstra()

# E
def E():
    return

# F
def F():
    return

# G
def G():
    return

# H
def H():
    return

# Solve
if __name__ == "__main__":
    D()

#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect

def LI():
    return [int(x) for x in sys.stdin.readline().split()]

def I():
    return int(sys.stdin.readline())

def LS():
    return [list(x) for x in sys.stdin.readline().split()]

def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res

def IR(n):
    return [I() for i in range(n)]

def LIR(n):
    return [LI() for i in range(n)]

def SR(n):
    return [S() for i in range(n)]

def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def v(n):
        return [n * 10 % k, (n + 1) % k]

    k = I()
    d = [float("inf")] * k
    d[1] = 1
    q = deque([1])
    while q:
        x = q.popleft()
        vx = v(x)
        dx = d[x]
        for c in range(2):
            nd = dx + c
            y = vx[c]
            if nd < d[y]:
                d[y] = nd
                if c:
                    q.append(y)
                else:
                    q.appendleft(y)
    print((d[0]))
    return

# Solve
if __name__ == "__main__":
    solve()

+from collections import defaultdict, deque

-    return list(map(int, sys.stdin.readline().split()))

+    return [int(x) for x in sys.stdin.readline().split()]

-    return list(map(list, sys.stdin.readline().split()))

+    return [list(x) for x in sys.stdin.readline().split()]

-    return list(sys.stdin.readline())[:-1]

-        j = bisect.bisect_left(a, b[i])

-        j = bisect.bisect_left(b, c[i])

-        d = [float("inf") for i in range(k)]

-                    heappush(q, [d[y], y])


Input:
import sys

input = sys.stdin.buffer.readline

from collections import defaultdict

import copy

def main():

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

    d = defaultdict(int)

    MOD = 10**9+7

    R = 10**5+100

    fac = [0 for _ in range(R+1)]

    fac[0],fac[1] = 1,1

    inv = copy.deepcopy(fac)

    invfac = copy.deepcopy(fac)

    for i in range(2,R+1):

        fac[i] = (fac[i-1]*i)%MOD

        inv[i] = MOD-(MOD//i)*inv[MOD%i]%MOD

        invfac[i] = (invfac[i-1]*inv[i])%MOD

    def coef(x,y):

        num = (((fac[x+y]*invfac[y])%MOD)*invfac[x]%MOD)

        return num

    while M%2 == 0:

        d[2] += 1

        M //= 2

    f = 3

    while f ** 2 <= M:

        if M % f == 0:

            d[f] += 1

            M //= f

        else:

            f += 2

    if M != 1:

        d[M] += 1

    l = list(d.values())

    ans = 1

    for num in l:

        ans *= coef(num,N-1)

        ans %= MOD

    print(ans)

if __name__ == "__main__":

    main()

import sys

input = sys.stdin.buffer.readline

def main():

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

    MOD = 10**9+7

    def factorization(n):

        arr = []

        temp = n

        for i in range(2, int(-(-n**0.5//1))+1):

            if temp%i==0:

                cnt=0

                while temp%i==0:

                    cnt+=1

                    temp //= i

                arr.append([i, cnt])

        if temp!=1:

            arr.append([temp, 1])

        return arr

    cl = factorization(M)

    def combinations(x,y,N):

        fac = [0]*(N+1)

        fac[0],fac[1] = 1,1

        for i in range(2,N+1):

            fac[i] = (fac[i-1]*i)%MOD

        return (fac[x+y]*pow(fac[x],MOD-2,MOD)*pow(fac[y],MOD-2,MOD))%MOD

    ans = 1

    for pr,num in cl:

        ans *= combinations(N-1,num,N+num)

        ans %= MOD

    print(ans)

if __name__ == "__main__":

    main()

import sys

input = sys.stdin.buffer.readline
from collections import defaultdict
import copy

def main():
    N, M = list(map(int, input().split()))
    d = defaultdict(int)
    MOD = 10**9 + 7
    R = 10**5 + 100
    fac = [0 for _ in range(R + 1)]
    fac[0], fac[1] = 1, 1
    inv = copy.deepcopy(fac)
    invfac = copy.deepcopy(fac)
    for i in range(2, R + 1):
        fac[i] = (fac[i - 1] * i) % MOD
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        invfac[i] = (invfac[i - 1] * inv[i]) % MOD

    def coef(x, y):
        num = ((fac[x + y] * invfac[y]) % MOD) * invfac[x] % MOD
        return num

    while M % 2 == 0:
        d[2] += 1
        M //= 2
    f = 3
    while f**2 <= M:
        if M % f == 0:
            d[f] += 1
            M //= f
        else:
            f += 2
    if M != 1:
        d[M] += 1
    l = list(d.values())
    ans = 1
    for num in l:
        ans *= coef(num, N - 1)
        ans %= MOD
    print(ans)

if __name__ == "__main__":
    main()

import sys

input = sys.stdin.buffer.readline

def main():
    N, M = list(map(int, input().split()))
    MOD = 10**9 + 7

    def factorization(n):
        arr = []
        temp = n
        for i in range(2, int(-(-(n**0.5) // 1)) + 1):
            if temp % i == 0:
                cnt = 0
                while temp % i == 0:
                    cnt += 1
                    temp //= i
                arr.append([i, cnt])
        if temp != 1:
            arr.append([temp, 1])
        return arr

    cl = factorization(M)

    def combinations(x, y, N):
        fac = [0] * (N + 1)
        fac[0], fac[1] = 1, 1
        for i in range(2, N + 1):
            fac[i] = (fac[i - 1] * i) % MOD
        return (
            fac[x + y] * pow(fac[x], MOD - 2, MOD) * pow(fac[y], MOD - 2, MOD)
        ) % MOD

    ans = 1
    for pr, num in cl:
        ans *= combinations(N - 1, num, N + num)
        ans %= MOD
    print(ans)

if __name__ == "__main__":
    main()

-        fac[i] = (fac[i - 1] * i) % MOD

-        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD

-        invfac[i] = (invfac[i - 1] * inv[i]) % MOD

-        num = ((fac[x + y] * invfac[y]) % MOD) * invfac[x] % MOD

+            fac[i] = (fac[i - 1] * i) % MOD

+            fac[x + y] * pow(fac[x], MOD - 2, MOD) * pow(fac[y], MOD - 2, MOD)

+        ans *= combinations(N - 1, num, N + num)


Input:
def cmb(n, r, mod):

    if ( r<0 or r>n ):

        return 0

    r = min(r, n-r)

    return g1[n] * g2[r] * g2[n-r] % mod

A=2*10**5

mod = 10**9+7

g1 = [1, 1]

g2 = [1, 1]

inverse = [0, 1]

for i in range( 2, A + 1 ):

    g1.append( ( g1[-1] * i ) % mod )

    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )

    g2.append( (g2[-1] * inverse[-1]) % mod )

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

keisuu=cmb(N*M-2,K-2,mod)

sum_=0

for i in range(N):

    a=min(abs(i),abs(N-i-1))

    b=max(abs(i),abs(N-i-1))

    sum_+=(M**2)*((a*(a+1)//2)+(b*(b+1)//2))

for i in range(M):

    a=min(abs(i),abs(M-i-1))

    b=max(abs(i),abs(M-i-1))

    sum_+=(N**2)*((a*(a+1)//2)+(b*(b+1)//2))

print(((keisuu * (sum_//2))%mod))

def power_mod(a,b,mod=10**9+7):

    i,temp,box=0,b,[]

    while(2**i<=b):

        i+=1

    for j in range(i-1,-1,-1):

        box=[[j,temp//2**j]]+box

        temp-=2**j*(temp//2**j)

    box[0].append(a)

    ans=box[0][1]*a%mod

    for j in range(1,i):

        box[j].append(box[j-1][2]**2%mod)

        if box[j][1]==1:

            ans=(ans*box[j][2])%mod

    return ans

def n_func(n,mod=10**9+7):

    ans=1

    for i in range(1,n+1):

        ans=(ans*i)%mod

    return ans

def nPr(n,r,mod=10**9+7):

    ans=n_func(n-r,mod)

    ans=power_mod(ans,mod-2,mod)

    return ans*n_func(n,mod)%mod

def nCr(n,r,mod=10**9+7):

    ans=n_func(n-r,mod)*n_func(r,mod)%mod

    ans=power_mod(ans,mod-2,mod)

    return ans*n_func(n,mod)%mod

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

keisuu=nCr(N*M-2,K-2)

mod=10**9+7

sum_=0

for i in range(N):

    a=min(abs(i),abs(N-i-1))

    b=max(abs(i),abs(N-i-1))

    sum_+=(M**2)*((a*(a+1)//2)+(b*(b+1)//2))

for i in range(M):

    a=min(abs(i),abs(M-i-1))

    b=max(abs(i),abs(M-i-1))

    sum_+=(N**2)*((a*(a+1)//2)+(b*(b+1)//2))

print(((keisuu * (sum_//2))%mod))

def cmb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod

A = 2 * 10**5
mod = 10**9 + 7
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range(2, A + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)
N, M, K = list(map(int, input().split()))
keisuu = cmb(N * M - 2, K - 2, mod)
sum_ = 0
for i in range(N):
    a = min(abs(i), abs(N - i - 1))
    b = max(abs(i), abs(N - i - 1))
    sum_ += (M**2) * ((a * (a + 1) // 2) + (b * (b + 1) // 2))
for i in range(M):
    a = min(abs(i), abs(M - i - 1))
    b = max(abs(i), abs(M - i - 1))
    sum_ += (N**2) * ((a * (a + 1) // 2) + (b * (b + 1) // 2))
print(((keisuu * (sum_ // 2)) % mod))

def power_mod(a, b, mod=10**9 + 7):
    i, temp, box = 0, b, []
    while 2**i <= b:
        i += 1
    for j in range(i - 1, -1, -1):
        box = [[j, temp // 2**j]] + box
        temp -= 2**j * (temp // 2**j)
    box[0].append(a)
    ans = box[0][1] * a % mod
    for j in range(1, i):
        box[j].append(box[j - 1][2] ** 2 % mod)
        if box[j][1] == 1:
            ans = (ans * box[j][2]) % mod
    return ans

def n_func(n, mod=10**9 + 7):
    ans = 1
    for i in range(1, n + 1):
        ans = (ans * i) % mod
    return ans

def nPr(n, r, mod=10**9 + 7):
    ans = n_func(n - r, mod)
    ans = power_mod(ans, mod - 2, mod)
    return ans * n_func(n, mod) % mod

def nCr(n, r, mod=10**9 + 7):
    ans = n_func(n - r, mod) * n_func(r, mod) % mod
    ans = power_mod(ans, mod - 2, mod)
    return ans * n_func(n, mod) % mod

N, M, K = list(map(int, input().split()))
keisuu = nCr(N * M - 2, K - 2)
mod = 10**9 + 7
sum_ = 0
for i in range(N):
    a = min(abs(i), abs(N - i - 1))
    b = max(abs(i), abs(N - i - 1))
    sum_ += (M**2) * ((a * (a + 1) // 2) + (b * (b + 1) // 2))
for i in range(M):
    a = min(abs(i), abs(M - i - 1))
    b = max(abs(i), abs(M - i - 1))
    sum_ += (N**2) * ((a * (a + 1) // 2) + (b * (b + 1) // 2))
print(((keisuu * (sum_ // 2)) % mod))

-    return g1[n] * g2[r] * g2[n - r] % mod

+        box[j].append(box[j - 1][2] ** 2 % mod)

+            ans = (ans * box[j][2]) % mod

+    ans = n_func(n - r, mod) * n_func(r, mod) % mod

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

-    inverse.append((-inverse[mod % i] * (mod // i)) % mod)

-    g2.append((g2[-1] * inverse[-1]) % mod)

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


Input:
#!usr/bin/env python3

from collections import defaultdict

from collections import deque

from heapq import heappush, heappop

import sys

import math

import bisect

import random

def LI(): return list(map(int, sys.stdin.readline().split()))

def I(): return int(sys.stdin.readline())

def LS():return list(map(list, sys.stdin.readline().split()))

def S(): return list(sys.stdin.readline())[:-1]

def IR(n):

    l = [None for i in range(n)]

    for i in range(n):l[i] = I()

    return l

def LIR(n):

    l = [None for i in range(n)]

    for i in range(n):l[i] = LI()

    return l

def SR(n):

    l = [None for i in range(n)]

    for i in range(n):l[i] = S()

    return l

def LSR(n):

    l = [None for i in range(n)]

    for i in range(n):l[i] = LS()

    return l

sys.setrecursionlimit(1000000)

mod = 1000000007

#A

def A():

    return

#B

def B():

    return

#C

def C():

    return

#D

def D():

    return

#E

def E():

    return

#F

def F():

    a,b,c,X,Y = LI()

    ans = float("inf")

    for z in range(300001):

        if z%2 == 0:

            m = c*z

            x = z//2

            y = z//2

            m += a*max(0,X-x)

            m += b*max(0,Y-y)

            if m < ans:

                ans = m

    print(ans)

    return

#G

def G():

    n = I()

    x = LI()

    f = [(i,x[i]) for i in range(n)]

    f.sort(key = lambda x:x[1])

    g = [(f[i][0],i) for i in range(n)]

    g.sort(key = lambda x:x[0])

    for i in range(n):

        if g[i][1] < n//2:

            print((f[n//2][1]))

        else:

            print((f[n//2-1][1]))

    return

#H

def H():

    return

#I

def I_():

    return

#J

def J():

    return

#Solve

if __name__ == "__main__":

    F()

#!usr/bin/env python3

from collections import defaultdict,deque

from heapq import heappush, heappop

from itertools import permutations

import sys

import math

import bisect

def LI(): return [int(x) for x in sys.stdin.readline().split()]

def I(): return int(sys.stdin.readline())

def LS():return [list(x) for x in sys.stdin.readline().split()]

def S():

    res = list(sys.stdin.readline())

    if res[-1] == "\n":

        return res[:-1]

    return res

def IR(n):

    return [I() for i in range(n)]

def LIR(n):

    return [LI() for i in range(n)]

def SR(n):

    return [S() for i in range(n)]

def LSR(n):

    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)

mod = 1000000007

def solve():

    A,B,C,x,y = LI()

    ans = float("inf")

    for c in range(200001)[::2]:

        a = b = c >> 1

        a = max(0,x-a)

        b = max(0,y-b)

        s = A*a+B*b+C*c

        if s < ans:

            ans = s

    print(ans)

    return

#Solve

if __name__ == "__main__":

    solve()

#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random

def LI():
    return list(map(int, sys.stdin.readline().split()))

def I():
    return int(sys.stdin.readline())

def LS():
    return list(map(list, sys.stdin.readline().split()))

def S():
    return list(sys.stdin.readline())[:-1]

def IR(n):
    l = [None for i in range(n)]
    for i in range(n):
        l[i] = I()
    return l

def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):
        l[i] = LI()
    return l

def SR(n):
    l = [None for i in range(n)]
    for i in range(n):
        l[i] = S()
    return l

def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):
        l[i] = LS()
    return l

sys.setrecursionlimit(1000000)
mod = 1000000007
# A
def A():
    return

# B
def B():
    return

# C
def C():
    return

# D
def D():
    return

# E
def E():
    return

# F
def F():
    a, b, c, X, Y = LI()
    ans = float("inf")
    for z in range(300001):
        if z % 2 == 0:
            m = c * z
            x = z // 2
            y = z // 2
            m += a * max(0, X - x)
            m += b * max(0, Y - y)
            if m < ans:
                ans = m
    print(ans)
    return

# G
def G():
    n = I()
    x = LI()
    f = [(i, x[i]) for i in range(n)]
    f.sort(key=lambda x: x[1])
    g = [(f[i][0], i) for i in range(n)]
    g.sort(key=lambda x: x[0])
    for i in range(n):
        if g[i][1] < n // 2:
            print((f[n // 2][1]))
        else:
            print((f[n // 2 - 1][1]))
    return

# H
def H():
    return

# I
def I_():
    return

# J
def J():
    return

# Solve
if __name__ == "__main__":
    F()

#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect

def LI():
    return [int(x) for x in sys.stdin.readline().split()]

def I():
    return int(sys.stdin.readline())

def LS():
    return [list(x) for x in sys.stdin.readline().split()]

def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res

def IR(n):
    return [I() for i in range(n)]

def LIR(n):
    return [LI() for i in range(n)]

def SR(n):
    return [S() for i in range(n)]

def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    A, B, C, x, y = LI()
    ans = float("inf")
    for c in range(200001)[::2]:
        a = b = c >> 1
        a = max(0, x - a)
        b = max(0, y - b)
        s = A * a + B * b + C * c
        if s < ans:
            ans = s
    print(ans)
    return

# Solve
if __name__ == "__main__":
    solve()

+from collections import defaultdict, deque

-    return list(map(int, sys.stdin.readline().split()))

+    return [int(x) for x in sys.stdin.readline().split()]

-    return list(map(list, sys.stdin.readline().split()))

+    return [list(x) for x in sys.stdin.readline().split()]

-    return list(sys.stdin.readline())[:-1]

-    g = [(f[i][0], i) for i in range(n)]


Input:
from collections import deque

N = 3

m = {8: {7, 5}, 7: {8, 6, 4}, 6: {7, 3}, 5: {8, 4, 2}, 4: {7, 5, 3, 1}, 3: {6, 4, 0}, 2: {5, 1}, 1: {4, 2, 0},

     0: {3, 1}}

goal = 123456780

def g(i, j, a):

    t = a // (10 ** j) % 10

    return a - t * (10 ** j) + t * (10 ** i)

def solve():

    MAP = "".join(input().replace(" ", "") for _ in range(N))

    start = 8 - MAP.find("0")

    MAP = int(MAP)

    if MAP == goal:

        return 0

    dp = deque([(0, start, MAP)])

    LOG = {MAP}

    while dp:

        cnt, yx, M = dp.popleft()

        if M == goal:

            return cnt

        cnt += 1

        for nyx in m[yx]:

            CM = g(yx, nyx, M)

            if not CM in LOG:

                dp.append((cnt, nyx, CM))

                LOG.add(CM)

def MAIN():

    print((solve()))

MAIN()

from collections import deque

N = 3

m = {8: {7, 5}, 7: {8, 6, 4}, 6: {7, 3}, 5: {8, 4, 2}, 4: {7, 5, 3, 1}, 3: {6, 4, 0}, 2: {5, 1}, 1: {4, 2, 0},

     0: {3, 1}}

goal = 123456780

def g(i, j, a):

    t = a // (10 ** j) % 10

    return a - t * (10 ** j) + t * (10 ** i)

def solve():

    MAP = "".join(input().replace(" ", "") for _ in range(N))

    zero = 8 - MAP.find("0")

    start = int(MAP)

    if start == goal:

        return 0

    dp = deque([(0, start, zero, 1), (0, goal, 0, 0)])

    TABLE = {start: (1, 0), goal: (0, 0)}

    while dp:

        cnt, M, yx, flg = dp.popleft()

        cnt += 1

        for nyx in m[yx]:

            key = g(yx, nyx, M)

            if key in TABLE:

                if TABLE[key][0] != flg:

                    return TABLE[key][1] + cnt

                continue

            TABLE[key] = (flg, cnt)

            dp.append((cnt, key, nyx, flg))

def MAIN():

    print((solve()))

MAIN()

from collections import deque

N = 3
m = {
    8: {7, 5},
    7: {8, 6, 4},
    6: {7, 3},
    5: {8, 4, 2},
    4: {7, 5, 3, 1},
    3: {6, 4, 0},
    2: {5, 1},
    1: {4, 2, 0},
    0: {3, 1},
}
goal = 123456780

def g(i, j, a):
    t = a // (10**j) % 10
    return a - t * (10**j) + t * (10**i)

def solve():
    MAP = "".join(input().replace(" ", "") for _ in range(N))
    start = 8 - MAP.find("0")
    MAP = int(MAP)
    if MAP == goal:
        return 0
    dp = deque([(0, start, MAP)])
    LOG = {MAP}
    while dp:
        cnt, yx, M = dp.popleft()
        if M == goal:
            return cnt
        cnt += 1
        for nyx in m[yx]:
            CM = g(yx, nyx, M)
            if not CM in LOG:
                dp.append((cnt, nyx, CM))
                LOG.add(CM)

def MAIN():
    print((solve()))

MAIN()

from collections import deque

N = 3
m = {
    8: {7, 5},
    7: {8, 6, 4},
    6: {7, 3},
    5: {8, 4, 2},
    4: {7, 5, 3, 1},
    3: {6, 4, 0},
    2: {5, 1},
    1: {4, 2, 0},
    0: {3, 1},
}
goal = 123456780

def g(i, j, a):
    t = a // (10**j) % 10
    return a - t * (10**j) + t * (10**i)

def solve():
    MAP = "".join(input().replace(" ", "") for _ in range(N))
    zero = 8 - MAP.find("0")
    start = int(MAP)
    if start == goal:
        return 0
    dp = deque([(0, start, zero, 1), (0, goal, 0, 0)])
    TABLE = {start: (1, 0), goal: (0, 0)}
    while dp:
        cnt, M, yx, flg = dp.popleft()
        cnt += 1
        for nyx in m[yx]:
            key = g(yx, nyx, M)
            if key in TABLE:
                if TABLE[key][0] != flg:
                    return TABLE[key][1] + cnt
                continue
            TABLE[key] = (flg, cnt)
            dp.append((cnt, key, nyx, flg))

def MAIN():
    print((solve()))

MAIN()

-                dp.append((cnt, nyx, CM))

+                if TABLE[key][0] != flg:

+                    return TABLE[key][1] + cnt

+            dp.append((cnt, key, nyx, flg))


Input:
import sys

input = sys.stdin.buffer.readline

N, Ma, Mb = list(map(int, input().split()))

ABC = [list(map(int, input().split())) for _ in range(N)]

INF = 10 ** 15

dp = [[INF for j in range(401)] for i in range(401)]

dp[0][0] = 0

for a, b, c in ABC:

  for i in range(400, -1, -1):

    for j in range(400, -1, -1):

      if dp[i][j] != INF:

        dp[i + a][j + b] = min(dp[i + a][j + b], dp[i][j] + c)

answer = INF

for i in range(1, 401):

  for j in range(1, 401):

    if dp[i][j] != INF and i / j == Ma / Mb:

      answer = min(answer, dp[i][j])

print((answer if answer != INF else -1))

import sys

input = sys.stdin.buffer.readline

N, Ma, Mb = list(map(int, input().split()))

ABC = [list(map(int, input().split())) for _ in range(N)]

sumA = sum([ABC[i][0] for i in range(N)])

sumB = sum([ABC[i][1] for i in range(N)])

INF = 10 ** 15

dp = [[INF for j in range(sumB + 1)] for i in range(sumA + 1)]

dp[0][0] = 0

for a, b, c in ABC:

  for i in range(sumA, -1, -1):

    for j in range(sumB, -1, -1):

      if dp[i][j] != INF:

        dp[i + a][j + b] = min(dp[i + a][j + b], dp[i][j] + c)

answer = INF

for i in range(1, sumA + 1):

  for j in range(1, sumB + 1):

    if dp[i][j] != INF and i / j == Ma / Mb:

      answer = min(answer, dp[i][j])

print((answer if answer != INF else -1))

import sys

input = sys.stdin.buffer.readline
N, Ma, Mb = list(map(int, input().split()))
ABC = [list(map(int, input().split())) for _ in range(N)]
INF = 10**15
dp = [[INF for j in range(401)] for i in range(401)]
dp[0][0] = 0
for a, b, c in ABC:
    for i in range(400, -1, -1):
        for j in range(400, -1, -1):
            if dp[i][j] != INF:
                dp[i + a][j + b] = min(dp[i + a][j + b], dp[i][j] + c)
answer = INF
for i in range(1, 401):
    for j in range(1, 401):
        if dp[i][j] != INF and i / j == Ma / Mb:
            answer = min(answer, dp[i][j])
print((answer if answer != INF else -1))

import sys

input = sys.stdin.buffer.readline
N, Ma, Mb = list(map(int, input().split()))
ABC = [list(map(int, input().split())) for _ in range(N)]
sumA = sum([ABC[i][0] for i in range(N)])
sumB = sum([ABC[i][1] for i in range(N)])
INF = 10**15
dp = [[INF for j in range(sumB + 1)] for i in range(sumA + 1)]
dp[0][0] = 0
for a, b, c in ABC:
    for i in range(sumA, -1, -1):
        for j in range(sumB, -1, -1):
            if dp[i][j] != INF:
                dp[i + a][j + b] = min(dp[i + a][j + b], dp[i][j] + c)
answer = INF
for i in range(1, sumA + 1):
    for j in range(1, sumB + 1):
        if dp[i][j] != INF and i / j == Ma / Mb:
            answer = min(answer, dp[i][j])
print((answer if answer != INF else -1))

+sumA = sum([ABC[i][0] for i in range(N)])

+sumB = sum([ABC[i][1] for i in range(N)])

-dp = [[INF for j in range(401)] for i in range(401)]

+dp = [[INF for j in range(sumB + 1)] for i in range(sumA + 1)]


Input:
from sys import stdin, stdout, setrecursionlimit

from collections import deque, defaultdict, Counter

from heapq import heappush, heappop

from functools import lru_cache

import math

setrecursionlimit(10**6)

rl = lambda: stdin.readline()

rll = lambda: stdin.readline().split()

rli = lambda: list(map(int, stdin.readline().split()))

rlf = lambda: list(map(float, stdin.readline().split()))

INF, NINF = float('inf'), float('-inf')

MOD = 10**9 + 7

def main():

	s = int(rl())

	@lru_cache(None)

	def dp(currsum):

		if currsum == s: return 1

		cnt = 0

		for d in range(3, 2001):

			if currsum + d <= s:

				cnt += dp(currsum + d)

				cnt %= MOD

		return cnt

	print((dp(0)))

	stdout.close()

if __name__ == "__main__":

	main()

from sys import stdin, stdout, setrecursionlimit

from collections import deque, defaultdict, Counter

from heapq import heappush, heappop

from functools import lru_cache

import math

#setrecursionlimit(10**6)

rl = lambda: stdin.readline()

rll = lambda: stdin.readline().split()

rli = lambda: list(map(int, stdin.readline().split()))

rlf = lambda: list(map(float, stdin.readline().split()))

INF, NINF = float('inf'), float('-inf')

MOD = 10**9 + 7

def main():

	s = int(rl())

	def binom_tables(n, q):

		fact = [1 for _ in range(n + 1)]

		inv = [1 for _ in range(n + 1)]

		for i in range(1, n+1):

			fact[i] = (fact[i-1] * i) % q

			inv[i] = pow(fact[i], q-2, q)

		return fact, inv

	F, I = binom_tables(s + 700, MOD)

	def binom(n, k, q):

		return (F[n]*((I[k]*I[n-k])%q))%q

	ans = 0

	for r in range(1, 700):

		objects = s - 3*r

		if objects + r - 1 < objects or objects < 0:

			break

		x = binom(objects + r - 1, objects, MOD)

		ans += x

		ans %= MOD

	print(ans)

	stdout.close()

if __name__ == "__main__":

	main()

from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math

setrecursionlimit(10**6)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: list(map(int, stdin.readline().split()))
rlf = lambda: list(map(float, stdin.readline().split()))
INF, NINF = float("inf"), float("-inf")
MOD = 10**9 + 7

def main():
    s = int(rl())

    @lru_cache(None)
    def dp(currsum):
        if currsum == s:
            return 1
        cnt = 0
        for d in range(3, 2001):
            if currsum + d <= s:
                cnt += dp(currsum + d)
                cnt %= MOD
        return cnt

    print((dp(0)))
    stdout.close()

if __name__ == "__main__":
    main()

from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math

# setrecursionlimit(10**6)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: list(map(int, stdin.readline().split()))
rlf = lambda: list(map(float, stdin.readline().split()))
INF, NINF = float("inf"), float("-inf")
MOD = 10**9 + 7

def main():
    s = int(rl())

    def binom_tables(n, q):
        fact = [1 for _ in range(n + 1)]
        inv = [1 for _ in range(n + 1)]
        for i in range(1, n + 1):
            fact[i] = (fact[i - 1] * i) % q
            inv[i] = pow(fact[i], q - 2, q)
        return fact, inv

    F, I = binom_tables(s + 700, MOD)

    def binom(n, k, q):
        return (F[n] * ((I[k] * I[n - k]) % q)) % q

    ans = 0
    for r in range(1, 700):
        objects = s - 3 * r
        if objects + r - 1 < objects or objects < 0:
            break
        x = binom(objects + r - 1, objects, MOD)
        ans += x
        ans %= MOD
    print(ans)
    stdout.close()

if __name__ == "__main__":
    main()

+        fact = [1 for _ in range(n + 1)]

+        inv = [1 for _ in range(n + 1)]

+            fact[i] = (fact[i - 1] * i) % q

+            inv[i] = pow(fact[i], q - 2, q)

+        if objects + r - 1 < objects or objects < 0:

+        x = binom(objects + r - 1, objects, MOD)