peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
# D

N = int(input())

d = [0] * (10**6 + 1) 

for a in map(int, input().split()):
  d[a] += 1

ans = 0

for i in range(1,10**6+1):
  if d[i] == 1:
    ans += 1

  if d[i] > 0:
    # d[i]の倍数は含めない
    for j in range(i*2,10**6+1,i):
      d[j] = 0

print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

ans = [0] * n
for i in range(n-1):
    ans[a[i]-1] += 1

for v in ans:
    print(v)
# Judge status: Wrong Answer
from sys import stdin,stdout

def main():
    line=stdin.readline()
    parts=line.split()
    a=int(parts[0])
    b = int(parts[1])
    if a>=b:
        stdout.write(str(a))
    else:
        stdout.write(str(a-1))
main()
# Judge status: Accepted
def main():
    import bisect
    n,m = map(int,input().split())
    d = [[] for i in range(n)]
    ans = [0 for i in range(m)]
    for i in range(m):
        p,y = map(int,input().split())
        d[p-1].append((y,i))
    for i,d_ in enumerate(d):
        d_.sort()
        for c, d__ in enumerate(d_):
            ans[d__[1]] = str(i+1).zfill(6) + str(c+1).zfill(6)
    for i in range(m):
        print(ans[i])

if __name__ == "__main__":
    main()
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
B = [0]*(N+1)
for a in A:
    B[a]+=1
for b in B[1:]:
    print(b)
# Judge status: Wrong Answer
s = input()
R_num = s.count("R")
s[:R_num].count("W")
# Judge status: Accepted
#NとLを入力
N, L = map(int, input().split())


# 空のリストを生成
S = []

#入力
for i in  range(N):
    array = input()
    S.append(array)

#辞書順に並べ替え
S.sort()

#pythonのリストの出力では[と,が出力されるので取る
S=''.join(S)

#出力
print(S)
# Judge status: Accepted
a, b = map(int, input().split())
k = 0

for i in range(a,b+1):
    if str(i) == ''.join(list(reversed(str(i)))):
        k += 1

print(k)
# Judge status: Accepted
a, b, c = map(int, input().split())

if a < c < b or b < c < a:
	print('Yes')
else:
	print('No')
# Judge status: Wrong Answer
s = list(input())

count = 0

for i in range(1, len(s)):
    if s[i-1] == s[i]:
        count += 1

        if s[i-1] == '1':
            s[i] = '0'
        else:
            s[i] = '1'

print(count)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
ans=float("inf")
s=sum(A)
k=0
for i in range(N-1):
    k+=A[i]
    ans=min(ans,abs(s-2*k))
print(ans)
# Judge status: Wrong Answer
x,y,z=map(int, input().split())
x-=z
print(x//(y+1))
# Judge status: Accepted
import math
N = int(input())

ans = 2*N*math.pi

print(ans)
# Judge status: Accepted
N, D = map(int,input().split())
x = N % (D * 2 + 1)
if x == 0:
    print(int(N /(D * 2 + 1)))
else:
    print(N // (D * 2 + 1) + 1)
# Judge status: Wrong Answer
h = int(input())
w = int(input())
n = int(input())
print(n//max(h, w))
# Judge status: Wrong Answer
import numpy as np
import math

a, b, h, m = map(int, input().split())
h_dash = (h + m / 60.0) * 30.0
m_dash = m * 6.0
theta = abs(h_dash - m_dash)

if theta > 180.0:
    theta = theta - 180.0

if theta == 0.0:
    print(abs(a - b))
    quit()

if theta == 180.0:
    print(a + b)
    quit()

c_dash = a * a + b * b - (2.0 * a * b * math.cos(math.radians(theta)))

print(math.sqrt(c_dash))
# Judge status: Wrong Answer
data = input().split()

n = int(data[0])
k = int(data[1])

hp = input().split()
hp.sort()

ans = 0
for i in range(n - k):
  ans += int(hp[i])

print(ans)
# Judge status: Accepted
T = input()
print(T.replace("?","D"))
# Judge status: Accepted
import numpy as np
import math

N, K = (int(i) for i in input().split())  
A = [int(i) for i in input().split()] 

count = 1

if (N-K) % (K-1) == 0:
  count += (N-K) // (K-1)
else:
  count += (N-K) // (K-1) + 1
  
print(count)
# Judge status: Accepted
N,K = map(int,input().split())
X = list(map(int,input().split()))

ans = float('inf')
for i in range(K-1,N):
    xl = X[i-K+1]
    xr = X[i]
    ans = min(abs(xr)+abs(xr-xl),abs(xl)+abs(xr-xl),ans)
print(ans)
# Judge status: Accepted
n = int(input())
l = list(map(int,input().split()))
ans = 0
l.sort(reverse=True)
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      if(l[i]!=l[j])and(l[j]!=l[k])and(l[i]!=l[k])and(l[i]<l[j]+l[k]):
        ans += 1
print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

min_ind = a.index(min(a))

while True:
    min_num = min(a)
    min_ind = a.index(min_num) 
    a = [n % min_num for n in (a[:min_ind] + a[min_ind+1:]) if n % min_num != 0]
    if a == []:
        print(min_num)
        exit()
    a.append(min_num)
# Judge status: Accepted
n, k = map(int, input().split())
print((((-2 + k - n)*(-6 + 2* k**2 - n - n**2 - k*(2 + n)))//6)%(10**9+7))
# Judge status: Accepted
n,k = map(int, input().split())
alist=list(map(int, input().split()))
def is_ok(arg):
    cnt=0
    for i in alist:
      cnt+=(i-1)//arg
    return cnt<=k
def nibun(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok
print(nibun(0 , 10**9 + 1))
# Judge status: Accepted
a, b = map(int, input().split())
sum = 0
for i in range(b-a):
  sum += i+1
print(sum-b)
# Judge status: Accepted
N, M = map(int, input().split())
MOD = 10**9+7

def factorial(n):
    ans=1
    for i in range(1, n+1):
        ans = (ans * i) % MOD
    return ans

if N == M:
    print((2* factorial(N) ** 2) % MOD)
elif N == M + 1:
    print((factorial(M)**2*N) % MOD)
elif M == N + 1:
    print((factorial(N)**2*M) % MOD)
else:
    print(0)
# Judge status: Accepted
n = int(input())
l = list()
for i in range(n):
    l.append(input())
if len(l) != len(set(l)):
    print("No")
    exit()
for i in range(n-1):
    if l[i][-1] != l[i+1][0]:
        print("No")
        exit()
print("Yes")
# Judge status: Accepted
def solve(N):
    ans_list = []
    for n in range(1,N+1):
        ans_list.append(n)
        if n * (n+1) // 2 == N:
            return ans_list
        elif n * (n+1) // 2 > N:
            ans_list.remove(sum(ans_list) - N)
            return ans_list
        else:
            continue

def main():
    N = int(input())

    ans = solve(N)
    for i in range(len(ans)):
        print(ans[i])

if __name__ == "__main__":
    main()
# Judge status: Accepted
n, k = map(int, input().split())
result = ''
while n != 0:
    result = str(n % k) + result
    n = n // k
result = int(result)
i = 0
while  result / 10 ** i >= 1:
    i += 1
print(i)
# Judge status: Wrong Answer
N = int(input())
ans = 0
for i in range(1, N+1):
    ans += len([j for j in range(1, i) if i % j == 0]) == 8
print(ans)
# Judge status: Wrong Answer
n = int(input())
x = input().split()
a = int(x[0])
b = int(x[1])
c = int(x[2])
count = 0
for i in range(0, n):
  if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
    count += 1
    list = []
    a = a /2
    b = b /2
    c = c /2
  else:
    break
print(count)
# Judge status: Accepted
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from math import factorial

n,p=nii()
a=lnii()

x=0
y=0
for i in a:
  if i%2==0:
    x+=1
  else:
    y+=1

def solve(q):
  num=0
  while q<=y:
    num+=factorial(y)//(factorial(q)*factorial(y-q))
    q+=2
  return num

ans=2**x
if p==0:
  num=solve(0)
else:
  num=solve(1)

print(ans*num)
# Judge status: Accepted
N,M,X,Y,*H=map(int,open(0).read().split());print('NWoa rW a r'[max(max(H[:N]),X)>=min(min(H[N:]),Y)::2])
# Judge status: Wrong Answer
X, Y, A, B, C =map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
ate = p[0:X] +q[0:Y]
# print(ate)
for x in r:
    if x > ate[-1]:
        ate[-1] = x
        ate.sort(reverse=True)
print(sum(ate))
# Judge status: Accepted
N,D = map(int,input().split())
ans = 0

for n in range(N):
  X,Y = map(int,input().split())
  d = (X**2+Y**2)**(0.5)
  if d<=D:
    ans+=1

print(ans)
# Judge status: Accepted
n, m = map( int, input().split())
 
a = [ -1 ] * n
 
ret = 0
for _ in range(m):
  s, c = map( int, input().split() )
  if ( not ( a[ s - 1 ] in [ - 1, c ] ) ) or ( ( n > 1 ) and ( s == 1 ) and ( c == 0 ) ):
    ret = -1
    break
  a[ s - 1 ] = c
if ret != -1:
  ret = ""
  for i in range( n ):
    if a[i] == -1:
      if ( n > 1 ) and ( i == 0 ):
        a[ i ] = 1
      else:
        a[ i ] = 0
    ret += str( a[ i ] )
print( ret )
# Judge status: Wrong Answer
a,b = map(int, input().split())

if (a+b)%2 == 1:
  print('IMPOSSIBLE')
else:
  print((a+b)/2)
# Judge status: Accepted
n,a,b=map(int,input().split())
c=n//(a+b)
d=n-(a+b)*c
if d>=a:
    print((c*a)+a)
else:
    print((c*a)+d)
# Judge status: Accepted
S = list(input())
T = list(input())
count = 0
for i in range(len(S)):
    if(S[i] != T[i]):
        T[i] = S[i]
        count += 1
print(count)
# Judge status: Wrong Answer
import math
a,b,x=map(int,input().split()) 
aa=2*a**2*b-2*x
bb=a**3
print(math.degrees(math.atan2(aa,bb)))
# Judge status: Accepted
x,y = map(int, input().split())
print((x+y)%24)
# Judge status: Wrong Answer
import itertools

times = [int(input()) for _ in range(5)]

p = itertools.permutations([0, 1, 2, 3, 4])

min_time = 10e9
for orders in p:
    current_time = 0
    orders = [0, 1, 2, 4, 3]
    for idx, order in enumerate(orders):
        t = times[order]
        current_time += t
        if idx < 4 and current_time % 10 != 0:
            current_time += 10 - current_time % 10

    min_time = min(min_time, current_time)

print(min_time)
# Judge status: Accepted
import collections

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

c = collections.Counter(A)

i=1

for j in range(N):
  print(c[i])
  i+=1
# Judge status: Accepted
#ABC046 A
a,b,c=map(int,input().split())
if a==b==c:
    print(1)
elif a==b or a==c or b==c:
    print(2)
else:
    print(3)
# Judge status: Accepted
x,y = map(int,input().split())
if(x<y and x*y>=0):
  print(y-x)
elif(y<x and x*y>0):
  print(2+x-y)
else:
  print(abs(abs(y)-abs(x))+1)
# Judge status: Accepted
a, b, c = map(int, input().split())
print('YES' if b-a == c-b else 'NO')
# Judge status: Wrong Answer
from bisect import bisect_right
N = int(input())
L = [1]
m = 6
n = 9
while m < N:
    L.append(m)
    m *= 6
while n < N:
    L.append(n)
    n *= 9
L.sort()
# print(L)

dp = [N]*(N+1)
dp[0] = 0

for i in range(1, N+1):
    x = bisect_right(L, i)
    for j in range(x):
        dp[i] = min(dp[i], dp[i-L[j]]+1)

# print(dp)
print(dp[N])
# Judge status: Accepted
a, b = map(int, input().split())

if a<=9 and b<=9:
    print(a*b)
else:
    print(-1)
# Judge status: Wrong Answer
a,b,c,d=map(int,input().split())
if d<abs(a-b) or d<abs(b-c):
  print("No")
else:
  print("Yes")
# Judge status: Wrong Answer
N, M = map(int, input().split())

if N == 1 and M == 1:
    print(1)
elif N == 1:
    print(M-2)
elif M == 1:
    print(N-1)
else:
    print((N-2) * (M-2))
# Judge status: Accepted
x,y = map(int, input().split())

absx = abs(x)
absy = abs(y)

ans = abs(absx - absy)

if absx < absy :
    if x < 0 :
        ans += 1
    if y < 0 :
            ans += 1
elif absx > absy :
    if x > 0 :
        ans += 1
    if y > 0 :
            ans += 1
else :
    if x != y :
        ans =1

print(ans)
# Judge status: Accepted
x,y,a,b,c=map(int,input().split())
p=sorted(list(map(int,input().split())),reverse=True)
q=sorted(list(map(int,input().split())),reverse=True)
r=sorted(list(map(int,input().split())),reverse=True)
all=sorted(p[:x]+q[:y]+r,reverse=True)
print(sum(all[:x+y]))
# Judge status: Accepted
S = input()
a = int(S[0]+S[1])
b = int(S[2]+S[3])
if a > 12 and b >12:
  print('NA')
if (a == 0 and b >12) or (b ==0 and a > 12) or (a==0 and b ==0):
  print('NA')
elif a == 0:
  print('YYMM')
elif b == 0:
  print('MMYY')
elif  a <= 12 and b <= 12:
  print('AMBIGUOUS')
elif a <= 12 and b > 12:
  print('MMYY')
elif a > 12 and b <= 12:
  print('YYMM')
# Judge status: Wrong Answer
X = list(input())
N = len(X)
s = 0
t = 0
sold = 0
ans = N
for i in range(N):
  if X[i] == 'S':
    if s == 0:
      ans -= 2 * min(sold, t)
      sold = 0
      t = 0
    s += 1
  elif t == 0:
    sold = s
    s = 0
    t += 1
  else:
    t += 1
ans -= 2 * min(sold, t)
print(ans)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))

ans=0
for i in range(n):
  ans+=a[i]-(i+1)
  
b=ans//n
b1=ans/n

if b<0:
  c=b-1
else:
  c=b+1
  
if abs(b1-b)>=abs(b1-c):
  mid=c
else:
  mid=b
  
ans1=0

for j in range(n):
  ans1+=abs(a[j]-mid-(j+1))
  
print(ans1)
# Judge status: Accepted
kMod = 1000000007

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

if (X+Y) % 3 != 0:
    print(0)
    exit()

offset = (X+Y)//3
X, Y = X-offset, Y-offset
if X < 0 or Y < 0:
    print(0)
    exit()

X, Y = max(X, Y), min(X, Y)

ans = 1
for i in range(X+1, X+Y+1):
    ans *= i
    ans %= kMod

for i in range(2, Y+1):
    ans *= pow(i, kMod-2, kMod)
    ans %= kMod

print(ans)
# Judge status: Wrong Answer
N,M=map(int, input().split())
c=[1]*(N+1)
p=[0]*(N+1)
p[1]=1
for _ in range(M):
    x,y=map(int, input().split())
    p[y]=p[x]
    c[x]-=1
    c[y]+=1
    if c[x]==0: p[x]=0
print(sum(p))
# Judge status: Accepted
#B
n, l = map(int, input().split())
min = abs(l)
s = 0
for i in range(n):
    s += l + i
    if abs(l + i) < abs(min):
        min = l + i
print(s-min)
# Judge status: Wrong Answer
a,b = map(int,input().split())

import fractions

gcd = fractions.gcd(a,b)

print(a*b*gcd)
# Judge status: Wrong Answer
a = int(input())
b = int(input())

if a == 1 and b == 2:
    print("3")
elif a == 1 and b == 3:
    print("2")
else:
    print("1")
# Judge status: Wrong Answer
a = input()
d = 'Heisei'
if int(a[0:4]) ==2019:
  if int(a[5:7]) == 4:
    if int(a[8:10]) <30:
      d = 'TBD'
  elif int(a[5:7]) <=3:
    d = 'TBD'
elif int(a[0:4]) <= 2018:
  d = 'TBD'
print(d)
# Judge status: Wrong Answer
# coding: utf-8
# Your code here!

n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[1]
i=0
while True:
    i=a[i]
    if(i in b):
        break
    b.append(i)
    i-=1


i=b.index(i)
a=b[:i]
c=b[i:]
#print(a,c)
if(k<=len(a)):
    print(a[k-1])
else:
    k-=len(a)
    k%=len(c)
    print(c[k])
# Judge status: Accepted
N,x = map(int,input().split())
a = list(map(int,input().split()))
s1 = sum(a)
for i in range(0,N-2):
    if a[i]+a[i+1] > x:
        a[i] = min(a[i],x)
        a[i+1] = x - a[i]
    else: pass
if a[N-1]+a[N-2]>x:
    a[N-1] = min(a[N-1],x)
    a[N-2] = x - a[N-1]
s2 = sum(a)
print(s1-s2)
# Judge status: Wrong Answer
X,Y,Z = map(int,input().split())
print((X-Z)/(Y+Z))
# Judge status: Accepted
a,b,c,d = map(int,input().split())
if (max(abs(b-a),abs(c-b)) <= d) or abs(c-a) <= d:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
import itertools
n = int(input())
s = input()
ans = 0
wl = []
el = []
for ss in s:
    if ss == 'W':
        wl.append(1)
        el.append(0)
    else:
        wl.append(0)
        el.append(1)
el.reverse()
wll = list(itertools.accumulate(wl))
ell = list(itertools.accumulate(el))
ell.reverse()

INF = float("inf")
ans = INF

for i in range(0, n):
    ans = min(ans, abs(wll[i-1]+ell[i-1]))

print(ans-1)
# Judge status: Accepted
N,L = map(int,input().split())
S = [input() for i in range(N)]

S.sort()
print("".join(S))
# Judge status: Wrong Answer
n , d = map(int, input().split())
count = 0

for i in range(n):
    if n >= 2*d+1:
        count += 1
        n = n - (2*d+1)
print(n)
if n != 0:
    count += 1
print(count)
# Judge status: Accepted
import numpy as np
N,M=map(int,input().split())
A=[]
for i in range(M):
  A.append(tuple(map(str,input().split())))
check=np.zeros((N,2))
for i in range(M):
  if check[int(A[i][0])-1,0]==0:
    if A[i][1]=='WA':
      check[int(A[i][0])-1,1]+=1
    elif A[i][1]=='AC':
      check[int(A[i][0])-1,0]+=1
for i in range(N):
  if check[i,0]==0:
    check[i,1]=0
sum=check.sum(axis=0)
print(int(sum[0]),int(sum[1]))
# Judge status: Accepted
S = input()
if (S[0:4]<='2019') and (S[5:7]<='04') and (S[8:10]<='30'):
    print('Heisei')
else:
    print('TBD')
# Judge status: Accepted
k = int(input())
a, b = map(int, input().split());

x = 0;
for i in range(a,b+1):
    if i % k == 0:
        x += 1;

if x == 0:
    print('NG')
else:
    print('OK')
# Judge status: Accepted
A,B,X=map(int,input().split())
if A+B<X :
  print("NO")
elif A>X :
  print("NO")
else :
  print("YES")
# Judge status: Accepted
S=input()
if S[0]=="A":
  c=0
  d=0
  for x in range(2,len(S)-1):
    if S[x].islower():
      d+=1
    if S[x]=="C":
      c+=1
  if c==1 and d==len(S)-4 and S[1].islower() and S[len(S)-1].islower():
    print("AC")
  else:
    print("WA")
else:
  print("WA")
# Judge status: Accepted
S = input().split()
ans = f'A{S[1][0]}C'
print(ans)
# Judge status: Accepted
s = input()
a = s.count('a')
b = s.count('b')
c = s.count('c')
p = [a,b,c]
if max(p) - min(p) <=1:
    print('YES')
else:print('NO')
# Judge status: Accepted
n = int(input())

xmi = 1e18
xma = -1e18
ymi = 1e18
yma = -1e18
for i in range(n):
    x, y = map(int, input().split())
    xmi = min(xmi, x+y)
    xma = max(xma, x+y)
    ymi = min(ymi, x-y)
    yma = max(yma, x-y)
ans = 0
ans = max(ans, xma - xmi)
ans = max(ans, yma - ymi)
print(ans)
# Judge status: Accepted
N, K = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
    A[i] -= 1
L = [0]
t = 0
F = [-1 for _ in range(N)]
F[0] = 0
c = 1
while F[A[t]] == -1:
    t = A[t]
    F[t] = c
    c += 1
    L.append(t)
loop = c - F[A[t]]
buffer = c - loop
if K < buffer:
    print(L[K] + 1)
else:
    NL = L[buffer:]
    amari = (K - buffer) % loop
    print(NL[amari] + 1)
# Judge status: Wrong Answer
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a.append(10000000000)
b.append(10000000000)
ans = 0
t = 0
a1,b1 = 0,0
while t<k:
    if t+min(a[a1],b[b1])>k: break
    if a[a1]<b[b1]:
        t+=a[a1]
        a1+=1
    else:
        t+=b[b1]
        b1+=1
    ans+=1
print(ans)
# Judge status: Wrong Answer
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = list(input())
for i in range(n-k):
    if t[i+k] == t[i]:
        t[i+k] == 0
x = t.count("r")*p+t.count("S")*r+t.count("p")*s
print(x)
# Judge status: Accepted
import math

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

L = [0] * (n+1)
R = [0] * (n+1)
for i in range(n):
  if L[i] == 0:
    L[i+1] = a[i]
  else:
    L[i+1] = math.gcd(L[i], a[i])
  
  #print(n, i, n-i-1)
  if R[n-i] == 0:
    R[n-i-1] = a[n-i-1]
  else:
    R[n-i-1] = math.gcd(R[n-i], a[n-i-1])
M = [0] * (n+1)
for i in range(n):
  M[i] = math.gcd(L[i], R[i+1])
print(max(M))
# Judge status: Accepted
x = int(input())

if x == 0:
    print(1)
else:
    print(0)
# Judge status: Accepted
input()
l = sorted(map(int, input().split(' ')))

answer = 0
spots = [l.pop()]
x = len(l)

for i in range(x):
	n = l.pop()
	answer += spots[i]
	spots.append(n)
	spots.append(n)

print(answer)
# Judge status: Wrong Answer
n = int(input())
H = list(map(int, input().split()))
A = []
m = H[0]
c = 0
for i in H[1:]:
    if m >= i:
        c += 1
    else:
        m = i
        A.append(c)
        c = 0
A.append(c)
print(max(A))
# Judge status: Accepted
N = int(input())

import sys
ans = 0

if N%2 == 1:
    print(0)
    sys.exit()
else:
    for i in range(1,36):
        ans += N//(2*5**i)

print(ans)
# Judge status: Wrong Answer
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))

id = A.index(1)
print(math.ceil(id / (K-1)) + math.ceil((N - id - 1)/(K-1)))
# Judge status: Accepted
D = list(input())

D[3] = 8

map = map(str,D)

print(''.join(map))
# Judge status: Accepted
s = input()

l = len(s)
ans = 1
tmp = s[0]
nxt = ""
for i in range(1,l):
    nxt += s[i]    
    if tmp == nxt:
        continue
    else:
        ans += 1
        tmp = nxt
        nxt = ""

print(ans)
# Judge status: Accepted
A, B, C, X, Y = map(int, input().split())

if C*2 < A+B:
    if X < Y:
        print(min(C*2*X + (Y-X)*B, C*2*Y))
    else:
        print(min(C*2*Y + (X-Y)*A, C*2*X))
else:
    print(A*X+B*Y)
# Judge status: Accepted
N=int(input())
x,y=0,0
time=0
for i in range(N):
  t,a,b=map(int,input().split())
  if abs(x-a)+abs(y-b)>t-time or (abs(x-a)+abs(y-b)-t+time)%2==1:
    print("No")
    exit()
  time=t
  x=a
  y=b
print("Yes")
# Judge status: Wrong Answer
a,b=map(int,input().split())
cnt=0
for i in range(a):
    for j in range(b):
        if i==j:
            cnt += 1
print(cnt)
# Judge status: Accepted
import sys
d = [int(input()) for i in range(6)]
 
def check():
    for i in range(5):
        for j in range(5):
            if abs(d[i]-d[j]) > d[5]:
                print(":(")
                sys.exit()
    print("Yay!")
         
check()
# Judge status: Accepted
N,M = map(int, input().split())

ans = {}
if M > 0:
  for _ in range(M):
    key, value = input().split()
    if key not in ans:
      ans[key] = []
    ans[key].append(value)
else:
  print(0," ",0)
  exit()

ac = 0
wa = 0

for v in ans.values():
  if 'AC' in v: # ACを出している場合
    for a in v:
      if a == 'WA':
        wa += 1
      else:
        ac += 1
        break
  else: # ACを出していない場合
    continue

print(ac, " ", wa)
# Judge status: Accepted


num = list(map(int, input().rsplit()))
print(num.index(0) + 1)
# Judge status: Accepted
r,g,b = map(str, input().split())

if int(r+g+b)%4==0:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
a, b, x = map(int, input().split())
print('YES' if a <= x <= b else 'NO')
# Judge status: Accepted
S = {}
for i in 'ABC':
    S[i] = [w for w in input()]
ans = ''
judge = True
turn = S['A'].pop(0).upper()
while judge:
    if S[turn] == []:
        ans = turn
        judge = False
    else:
        turn = S[turn].pop(0).upper()
print(ans)
# Judge status: Accepted
N, W = map(int, input().split())
wlis, vlis = [0], [0]
for i in range(N):
    w, v = map(int, input().split())
    wlis.append(w)
    vlis.append(v)
dp = [[0]*(W+1) for _ in range(N+2)]
for i in range(1, N+1):
    for j in range(W+1):
        if wlis[i] <= j:
            dp[i+1][j] = max(dp[i][j], dp[i][j-wlis[i]]+vlis[i])
        dp[i+1][j] = max(dp[i][j], dp[i+1][j])
print(dp[N+1][W])
# Judge status: Accepted
x = int(input())
def prime(n):
    for i in range(2,n):
        if n%i == 0:
            return False
    return True
while True:
    if prime(x):
        print(x)
        break
    x += 1
# Judge status: Wrong Answer
import sys

a = list(map(int,input().split()))
min = 100
for i in range(3):
  if min > a[i%3] + a[(i+1)%3]:
    min = a[i%3] + a[(i+1)%3]
print(min)
# Judge status: Accepted
import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import permutations
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

ans = -INF
for x in [a, b]:
    for y in [c,d]:
        ans = max(ans, x * y)
print(ans)
# Judge status: Accepted
n, m  = map(int,input().split())

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

a.sort()
ans = 0
for i in a:
  if m >= i[1]:  
    m -= i[1]
    ans += i[0]*i[1]
  else:
    ans += i[0]*m
    break
print(ans)
# Judge status: Accepted
A,B,K = map(int,input().split())
L = 0
ans = 0
for i in reversed(range(1,2000)):
  if A%i == 0:
    if B%i == 0:
      L += 1
    else:
      L += 0
  else:
    L += 0
  if L == K:
    ans = i
    break
print(ans)
# Judge status: Accepted
import math
x,y = map(int,input().split())

# ans = int(math.log2(y/x) + 1)
ans = 0
now = x
while now <= y:
    ans += 1
    now *= 2


print(ans)
# Judge status: Accepted
X = int(input())

s = X // 100
t = X % 100

if s * 5 >= t:
    print('1')
else:
    print('0')
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
if N <3:
  print(1)
  exit()

ans = 0
i = 0
while i < N-3:
  tmp = i
  while (A[tmp+1]-A[tmp])*(A[tmp+2]-A[tmp+1])>=0:
    tmp += 1
    if tmp == N-3:
      ans -= 1
      break
  ans += 1 
  i = tmp+2
else:
  if i == N-3:
    if (A[N-2]-A[N-3])*(A[N-1]-A[N-2])>=0:
      ans += 1
    else:
      ans += 2
  else:
    ans +=1
print(ans)
# Judge status: Accepted
A,B,K=map(int, input().split())
print(max(A-K,0),max(B+min(A-K,0),0))