peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import bisect
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
memo = [0]*(n+1)
for i in range(n):
    memo[bisect.bisect_left(b,c[i])] += 1
for i in range(n-1,-1,-1):
    memo[i] += memo[i+1]
for i in range(n-1,-1,-1):
    memo[i] += memo[i+1]
memo = memo[1:]+[0]
ans = 0

for i in range(n):
    ans += memo[bisect.bisect_right(b,a[i])]
print(ans)
# Judge status: Wrong Answer
import math

A,B,H,M = map(int, input().split())
##Aは短針の長さ、Bは長針の長さ
##ARは短針の進んだ針の角度、BRは長針の進んだ針の角度
AR = 360*H/12+30*M/60
BR = 360*M/60

if abs(AR-BR)<180:
  X = abs(AR-BR)
elif abs(AR-BR)>180:
  X = abs(AR-BR)-180
else :
  X = 0

C = A*A+B*B-abs(2*A*B*math.cos(math.radians(X)))

if X ==0:
  print(A+B)
else:
  print(C**0.5)
# Judge status: Wrong Answer
N = input()
end = int(N[-1])
for end in range(10):
    print(end)
    if end == 3:
        print('bon')
    elif end in [0, 1, 6, 8]:
        print('pon')
    else:
        print('hon')
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
if a+b+c <= 22:
  print("bust")
else:
  print("win")
# Judge status: Accepted
a = input()
rev_a = ''.join(list(reversed(a)))
# join    iterator to list and  join them into one string
# we cannot change iterator into string directly

length = len(a)
#palindrome_check
if a == rev_a:
    a1 = a[0:length//2]
    rev_a1 = ''.join(list(reversed(a1)))
    
    a2 = a[length//2+1:length]
    rev_a2 = ''.join(list(reversed(a2)))
    
    if a1 == rev_a1 and a2 == rev_a2:
        print('Yes')
    else:
        print('No')
else:
    print('No')
# Judge status: Accepted
n, m = map(int, input().split())
N = [list(map(int, input().split())) for _ in range(n)]
M = [list(map(int, input().split())) for _ in range(m)]


for i in range(n):
    ans = 0
    d = 9999999999999999999999
    for j in range(m):
        tmp = abs(N[i][0]-M[j][0]) + abs(N[i][1]-M[j][1])
        if tmp < d:
            d = tmp
            ans = j
    print(ans+1)
# Judge status: Wrong Answer
def p(S):
    str = ""
    for s in S:
        str += chr(ord("a")+int(s))
    print(str)

N = int(input())
S = [0]*N
T = [2]*N

def up(i):
    if i == 0:
        return True
    S[i] += 1
    if S[i] == T[i]:
        S[i] = 0
        T[i] += 1
        return up(i-1)
    return False

while True:
    p(S)
    if up(N-1):
        break
# Judge status: Wrong Answer
[n,k] = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a_p = a.index(1)
#print(a_p)
if a_p  % (k-1) == 0 and (n - a_p - 1) % (k-1) == 0:
    print(a_p//(k-1) + (n - a_p - 1) // (k-1) )
elif a_p % (k-1) == 0:
    print(a_p//(k-1) + (n - a_p - 1) // (k-1) + 1)
else:
    print((a_p-1)//(k-1) + (n - a_p - 1) // (k-1))
# Judge status: Accepted
S = input()
if S == 'SUN':
    A = 7
elif S == 'MON':
    A = 6
elif S == 'TUE':
    A = 5
elif S == 'WED':
    A = 4
elif S == 'THU':
    A = 3
elif S == 'FRI':
    A = 2
elif S == 'SAT':
    A = 1
print(A)
# Judge status: Wrong Answer
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]

x,y= map(int, input().split())
if (x,y in A) or (x,y in B):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
w, a, b = map(int, input().split())
if a <= b and b <= a+w:
    print(0)
elif b <= a+w and a <= b:
    print(0)
elif b + w < a:
    print(min(abs(a-b-w), abs(a+w-b)))
# Judge status: Wrong Answer
N = int(input())
nowt = 0
nowx = 0
nowy = 0
for i in range(N):
  t, x, y = map(int, input().split())
  ti = t - nowt
  xi = x - nowx
  yi = y - nowy
  if ti < abs(xi) + abs(yi):
    print('No')
    exit()
  if ti%2 != (xi+yi)%2:
    print('No')
    exit()
    
print('Yes')
# Judge status: Accepted
a, b, t = map(int, input().split())
tmp = t//a
print(tmp*b)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))

cnt = 0
for i in set(A):
  if i > 10**5:
    break
  I = A.count(i)
  if I == i:
    continue
  elif I > i:
    cnt += I - i
  else:
    cnt += I
  
print(cnt)
# Judge status: Accepted
a, b = input().split()

aa = ''.join([a for _ in range(int(b))])
bb = ''.join([b for _ in range(int(a))])

print(sorted([aa, bb])[0])
# Judge status: Accepted
print(int(int(input()) ** .5) ** 2)
# Judge status: Wrong Answer
n, p = map(int, input().split())
a = [int(i)&1 for i in input().split()]
odd = sum(a)
ans = 0
if odd:
    ans = 2**(n-1)
else:
    ans = 2**n

print(ans)
# Judge status: Wrong Answer
S=input()
if S==25:
  print("Crisitmas")
if S==24:
  print("Christmas Eve")
if S==23:
  print("Christmas Eve Eve")
if S==22:
  print("Christmas Eve Eve Eve")
# Judge status: Accepted
def biserch(n,List):
    left = 0
    right = len(List)
    while left < right:
        mid = (left+right)//2
        if n <= List[mid]:
            right = mid
        else:
            left = mid + 1
    
    return left
    
N = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0
for i in range(N):
    for j in range(i+1,N):
        key = L[i] + L[j]
        anchor = biserch(key,L)
        
        ans += max(anchor - (j+1),0)

print(ans)
# Judge status: Accepted
from itertools import permutations
from functools import reduce

n = int(input())

rn = int(n **.5) + 1

ptn = permutations([i for i in range(1, rn + 1)], 3)

ans = [0] * (n + 1)
for i in range(1, rn + 1):
  for j in range(1, rn + 1):
    for k in range(1, rn + 1):
      idx = i**2 + j**2 + k**2 + i*j + j*k + k*i
      if idx <= n: 
        ans[i**2 + j**2 + k**2 + i*j + j*k + k*i] += 1

for an in ans[1:]:
  print(an)
# Judge status: Accepted
a ,b= map(int,input().split())
#S = int(input())

if a > b:
    ans = [str(b)]*a
    ans = "".join(ans)
else:
    ans = [str(a)]*b
    ans = "".join(ans)
print(ans)
# Judge status: Accepted
k=int(input())
print((k//2)*(k-k//2))
# Judge status: Accepted
n = int(input())
ans = 0
for i in range(7):
    if 2**i <=n:
        ans=2**i
print(ans)
# Judge status: Accepted
import math

As,Bs=input().split()
if As=="0" or Bs=="0.00":
    print("0")
else:
    A=int(As)
    Bs=Bs.replace('.','')
    B=int(Bs)
    ans=int(A)*int(B)
    anss=str(ans)
    if len(anss)<3:
        print("0")
    else:
        print(anss[:-2])
# Judge status: Accepted
n = int(input())
b = list(map(int, input().split()))

ans = 0
for i in range(n - 1):
    if i == 0:
        ans += b[0]
        continue

    ans += min(b[i], b[i - 1])

ans += b[-1]
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
BC = [list(map(int,input().split())) for _ in range(Q)]

import collections
sum_temp = sum(A)
c = collections.Counter(A)
for q in range(Q):
  B = BC[q][0]
  C = BC[q][1]
  sum_temp += c[B]*(C-B)
  c[B],c[C] = 0,c[B]+c[C]
  print(sum_temp)
# Judge status: Accepted
import numpy as np
N = np.array(list(str(input()))).astype(np.int8)
N = np.sum(N)
if N%9 == 0:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
x = int(input())

for i in range(1, 361):
  if x*i % 360 == 0:
    print(i)
    break
# Judge status: Accepted
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
import numpy as np
#======================================================#
MOD=10**9+7
def main():
    n = II()
    aa = np.array(MII())
    ans = 0
    for i in range(60):
        cnt1 = int((aa&1).sum())
        ans += (cnt1*(n-cnt1)*(2**i))%MOD
        aa >>= 1
    print(ans%MOD)

if __name__ == '__main__':
    main()
# Judge status: Accepted
x, a, b = map(int, input().split())

if b-a <= 0:
    print('delicious')
elif b-a <= x:
    print('safe')
else:
    print('dangerous')
# Judge status: Accepted
# C - Splitting Pile
N = int(input())
A = list(map(int,input().split()))

s = [0]*(N+1)
for i in range(N-1):
    s[i+1] = s[i] + A[i]

ans = 10**10
for i in range(1,N):
    diff = abs((s[N-1] + A[-1] - s[i]) - s[i])
    ans = min(ans,diff)
print(ans)
# Judge status: Wrong Answer
N=int(input())
a = sorted(list(map(int,input().split())))
ans=0
for i in range(2*N):
  tmp=a.pop(0)
  if i%2==1:
    ans+=tmp
print(ans)
# Judge status: Accepted
A_interval, B_mai, T_limit = map(int, input().split())

times = T_limit // A_interval

ans = B_mai * times
print(ans)
# Judge status: Accepted
n=int(input())
if n<=999:
  print("ABC")
else:
  print("ABD")
# Judge status: Accepted
# coding: utf-8

a, b, c = map(int,input().split())
print(a*b//2)
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
if (a + b + (a*b)**0.5) < c**0.5:
  print("Yes")
else:print("No")
# Judge status: Accepted
a, b, c = map(int, input().split())
if a < c < b:
    print('Yes')
elif b < c < a:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n = int(input())
divs = []
for i in range(1, int(n ** 0.5) + 1):
  if n % i == 0:
    divs.append(i)
    if i != n // i:
      divs.append(n // i)
a = sorted(divs)
ea = a[1:]
count = 0
for i in range(len(ea)):
  t = n / ea[i]
  if t.is_integer() == False:
    continue
  else:
    n /= ea[i]
    count += 1
  if n == 1:
    break
print(count)
# Judge status: Accepted
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    L = list(map(int, input().split()))

    if max(L) < sum(L) - max(L):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()
# Judge status: Accepted
import collections
N=int(input())
A=list(map(int,input().split()))
l=[]
c=collections.Counter(A)
a=[]
values=list(c.values())
key=list(c.keys())
b=[]
for i in range(len(key)):
    l.append([key[i],values[i]])
l.sort(key=lambda x:x[1],reverse=True)
for i in range(len(l)):
    if l[i][1]>=2:
        num=l[i][0]
        b=[num]*((l[i][1])//2)
        a.extend(b)
if len(a)<2:
    print("0")
else:
    a.sort(reverse=True)
    print(a[0]*a[1])
# Judge status: Wrong Answer
import bisect
N=int(input())
d=list(map(int,input().split()))
d=sorted(d)
num=len(d)
ans=0
for i in range(N+1):
  tmp=bisect.bisect_left(d,i)
  if tmp==num-tmp:
    ans+=1
print(ans)
# Judge status: Accepted
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
  if a[i]==1:
    x=i
    y=n-1-i
import math

print(math.ceil((n-1)/(k-1)))
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    x,y=map(int, input().split())
    cnt=0
    while x<=y:
        x=x*2
        cnt+=1
    print(cnt)
resolve()
# Judge status: Accepted
def resolve():
    X = int(input())
    ans = 0
    ans += (X // 500) * 1000
    X = X - (X // 500) * 500
    ans += (X // 5) * 5
    print(ans)

    return

resolve()
# Judge status: Accepted
li_o = input()
li_e = input()
an = ''
for i in range(len(li_o)):
    an += li_o[i]
    if i != len(li_e):
        an += li_e[i]
    else:
        break
print(an)
# Judge status: Wrong Answer
k=int(input())
s=input()
if int(len(s))<=k:
  print(s)
else:
  print(s[0:7]+'...')
# Judge status: Accepted
s = input()
K = int(input())
after = []
rem = K
for i in range(len(s)-1):
    if s[i] == 'a':
        after.append('a')
        continue
    c = ord('z') - ord(s[i]) + 1
    if c <= rem:
        rem -= c
        after.append('a')
    else:
        after.append(s[i])

last = ord(s[-1])
if rem > 0:
    last += rem%26
    if last > ord('z'):
        last -= 26
after.append(chr(last))

print(''.join(after))
# Judge status: Accepted
n,k = map(int,input().split())
a = list(map(int,input().split()))
import math
print(math.ceil((n-1)/(k-1)))
# Judge status: Wrong Answer
C = input()
letters = "abcdefghijklmnopqrstuvwz"
list_letters = list(letters)
print(list_letters[letters.find(C)+1])
# Judge status: Wrong Answer
A, B, C = map(int,input().split())
c = 0

if A == B == C and ((A % 2 != 0) or (B % 2 != 0) or (C % 2 != 0)):
    c = -1
else:
    while (A % 2 == 0) and (B % 2 == 0) and (C % 2 == 0):
        A, B, C = B/2+C/2, C/2+A/2, A/2+B/2
        c += 1

print(c)
# Judge status: Accepted
from fractions import *
n,*a=map(int,open(0).read().split())
l=[0]+[a[0]]*(n-1)
r=[a[-1]]*(n-1)+[0]
ans=0
for i in range(2,n):
  l[i]=gcd(l[i-1],a[i-1])
for i in range(n-3,-1,-1):
  r[i]=gcd(r[i+1],a[i+1])
ans=max(l[n-1],r[0])
for i in range(1,n-1):
  ans=max(ans,gcd(l[i],r[i]))
print(ans)
# Judge status: Wrong Answer
n,a,b=map(int,input().split())
mod = 1000000007
ans = pow(2,n,mod) - 1

def solve(nu):
    res = 1
    for i in range(nu):
        res *= n-i
        res/=i+1
        res%=mod
    return res

ans -=solve(a)
ans %= mod
ans -= solve(b)
ans %= mod

print(ans)
# Judge status: Wrong Answer
N = int(input())
As = [int(input()) for _ in range(N)]
from bisect import bisect_left
from collections import deque

def LIS(L):
    dp = deque([L[0]])
    length = len(L)
    for i in range(1, length):
        a = L[i]
        if a >= dp[-1]:
            dp.append(a)
        else:
            dp[bisect_left(dp, a)] = a
    return dp

print(len(LIS(As[::-1])))
# Judge status: Accepted
w,a,b=map(int,input().split())
if a<b:
    dis=b-(a+w)
else:
    dis=a-(b+w)
print(dis if dis>=0 else 0)
# Judge status: Accepted
n = int(input())
ab = [list(map(int, input().split())) for i in range(n)]
ab = sorted(ab, key=lambda x: x[1])
a = 0
for i, j in ab:
    a += i
    if a > j:
        print("No")
        exit()
print("Yes")
# Judge status: Accepted
H=int(input())
W=int(input())
N=int(input())

large=max(H,W)

if (N/large).is_integer():
    print(int(N/large))
else:
    print(int(N/large)+1)
# Judge status: Accepted
n=int(input())
T=list(map(int,input().split()))
S=list(map(int,input().split()))
C=list(map(int,input().split()))
SUM=sum(S)
for i in range(n-1):
    if T[i+1]==T[i]+1:
        SUM+=C[T[i]-1]
print(SUM)
# Judge status: Wrong Answer
l = [int(x) for x in input().split()]

l.sort(reverse=True)
for x in l:
    if x % 2 != 0:
        odd = x
        break
else:
    odd = 0

if odd == 0:
    print(0)
else:
    ans = ((odd//2+1) - (odd//2)) * l[1] * l[2]
    print(ans)
# Judge status: Accepted
S = input().strip()
if S=="keyence":
    print("YES")
else:
    flag = 0
    for i in range(len(S)):
        for j in range(i,len(S)):
            x = S[:i]+S[j+1:]
            if x=="keyence":
                flag = 1
                break
        if flag==1:break
    if flag==1:
        print("YES")
    else:
        print("NO")
# Judge status: Accepted
import math
N,D = map(int,input().split())
xys = []
for i in range(N):
    x, y = map(int, input().split())
    xys.append([x,y])
c = 0
for x, y in xys:
  t = math.sqrt(x ** 2 + y ** 2)
  if t <= D:
      c += 1
print(c)
# Judge status: Wrong Answer
a,b,c = input()
"Yes" if(a=='7' or b=='7' or c=='7') else "No"
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
l=[0]*(n)
l1=[0]*(n)
for i in range(n):
    l[a[i]-1]+=1
    
for i in range(n):
    if l[i]>=2:
        l1[i]+=(l[i]*(l[i]-1))//2

l1sum=sum(l1)
for i in range(n):
    if l[a[i]-1]-1>=2:print(l1sum-l1[a[i]-1]+(l[i]*(l[i]-1))//2)
    else:print(l1sum-l1[a[i]-1])
# Judge status: Accepted
n,m,k=map(int,input().split())
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
acum1=[0]
for i in range(n):
  acum1.append(acum1[-1]+arr1[i])
acum2=[0]
for i in range(m):
  acum2.append(acum2[-1]+arr2[i])
ans=0
j=m
for i in range(n+1):
  if acum1[i]>k:
    break
  while acum2[j]>k-acum1[i] and j>0:
    j-=1
  ans=max(ans,i+j)
print(ans)
# Judge status: Accepted
N=int(input())
S = [input() for i in range(N)]
import collections
c = collections.Counter(S)
values, counts = zip(*c.most_common())

n=0
for i in range(len(counts)-1):
  if counts[i]==counts[i+1]:
    n=n+1
  else:
    break
answer=[]    
for i in range(n+1):
  answer.append(values[i])
answer=sorted(answer)

for i in answer:
  print(i)
# Judge status: Wrong Answer
N,L=map(int,input().split())
s=0
l=[]
for i in range(N):
    s+=L+i
    l.append(abs(L+i))
l=sorted(l)
print(l)
s-=abs(l[0])
print(s)
# Judge status: Accepted
L,R = map(int,input().split())
ls = list(range(L,min(L+2019, R+1)))
ans = 2019
for i in range(len(ls)):
    for j in range(i+1,len(ls)):
        ans = min(ans, (ls[i]*ls[j]) % 2019)
print(ans)
# Judge status: Accepted
s = str(input())

if s == 'ABC':
    print('ARC')
else:
    print('ABC')
# Judge status: Accepted
from math import floor
a,b,n = map(int,input().split())
if a == 1 or b == 1:
    print(0)
    exit()

prev = 0

for x in range(min(b-1,n),n+1, b):
    val = floor(a*x/b) - a*floor(x/b)
    if val < prev:
        print(prev)
        exit()
    prev = val

val = floor(a*n/b) - a*floor(n/b)
print(max(prev,val))
# Judge status: Accepted
N, K = map(int, input().split())
b=0
while N>0:
  N=N//K
  b+=1
print(b)
# Judge status: Accepted
n = int(input())
s = input()

if len(s) % 2 == 1:
    print('No')

else:
    mid = len(s)//2
    if s[:mid] == s[mid:]:
        print('Yes')
    else:
        print('No')
# Judge status: Wrong Answer
W, H, x, y = [int(i) for i in input().split()]
print(W*H / 2, int(x == y))
# Judge status: Wrong Answer
A, B, K = map(int, input().split())

for num in range(A, min(B, A+K)):
    print(num)
for num in range(max(A+K, B-K+1), B+1):
    print(num)
# Judge status: Accepted
import math
from functools import reduce


n = int(input())
tt = [int(input()) for i in range(n)]

x = 1

def lcm_base(x,y):
  return (x*y) // math.gcd(x,y)
def lcm(*numbers):
  return reduce(lcm_base, numbers, 1)

print(lcm(*tt))
# Judge status: Wrong Answer
R, G, B=map(int,input().split())

if R*G*B % 4 == 0:
  print("YES")
  
else:
  print("NO")
# Judge status: Accepted
string_1, string_2 = input("").split()
print(string_2+string_1)
# Judge status: Wrong Answer
x,y = map(int,input().split())
print(x + y / 2)
# Judge status: Accepted
n,m,X,Y = map(int,input().split())
x = sorted(list(map(int,input().split())))
y = sorted(list(map(int,input().split())))
if x[n-1] < y[0] and X < y[0] and x[n-1] < Y:
  print("No War")
else:
  print("War")
# Judge status: Accepted
S = list(input())
Sd = {i:S[i] for i in range(len(S))}
check = {i:0 for i in range(26)}
ans = -1

for k,v in Sd.items():
    check[ord(v)-ord('a')] = 1
    
for k,v in check.items():
    if v == 0:
        ans = k
        break
        
if ans == -1:
    print('None')
else:
    print(chr(ans+ord('a')))
# Judge status: Accepted
k, s = map(int, input().split())
ans = 0

for x in range(0, k+1):
    for y in range(0, k+1):
        if 0 <= s-x-y <= k:
            ans += 1

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

ans = max(a*c,a*d,b*c,b*d)

print(ans)
# Judge status: Accepted
s = sorted(input())
t = sorted(input())

print("Yes" if s < t[::-1] else "No")
# Judge status: Accepted
x = int(input())

for i in range(-1000, 1000):
    for j in range(-1000, 1000):
        if i ** 5 - j ** 5 == x:
            print(i, j)
            exit()
# Judge status: Accepted
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]

max = 0
for c in S:
    money = S.count(c) - T.count(c)
    if money > max:
        max = money
print(max)
# Judge status: Accepted
def main():
    N = int(input())
    if N%2 != 0:
        print(0)
        return
    output = 0
    T = 10
    while N//T > 0:
        output += N//T
        T *= 5
    print(output)
    return

if __name__ == '__main__':
    main()
# Judge status: Accepted
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: map(str, sys.stdin.buffer.readline().split())
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, m = rm()
l = 0
r = inf
for _ in range(m):
  a, b = rm()
  l = max(a, l)
  r = min(b, r)
c = r-l+1
if c >= 1:
  print(c)
else:
  print(0)
# Judge status: Wrong Answer
import math
n = int(input())
ans = 0
for i in range(1,n):
  for j in range(1, n):
    for k in range(1, n):
      ans += math.gcd(i, math.gcd(j, k))
print(ans)
# Judge status: Accepted
# -*- coding: utf-8 -*-
N = int(input())

counter = 0
for i in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        counter += 1
    else:
        counter = 0
    if counter == 3:
        break

print("Yes" if counter == 3 else "No")
# Judge status: Wrong Answer
a, b, c, x, y = map(int, input().split())
ans = 0

z = min(x, y)
if (a + b) // 2 > c:
    ans += z * c * 2
    x, y = x - z, y - z

for i, j in ((a, x), (b, y)):
    if a // 2 > c:
        ans += j * c * 2
    else:
        ans += i * j

print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
sum = 0
for i in range(len(a)):
  sum += b[a[i]-1]
  if i>0:
    if a[i]-1 == a[i-1]:
      sum += c[a[i-1]-1]
print(sum)
# Judge status: Accepted
a = int(input())
lis = []
for i in range(1, a+1):
    lis.append(i)
for j in range(len(lis)):
    b = lis[j]
    if b % 3 ==0:
        lis[j] = 0
    if b % 5 ==0:
        lis[j] = 0
print(sum(lis))
# Judge status: Accepted

import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    s=input()
    s1=s[:2]
    s2=s[2:]
    l=['01','02','03','04','05','06','07','08','09','10','11','12']
    if s1 in l and s2 in l:
        print('AMBIGUOUS')
    elif s1 in l and s2 not in l:
        print('MMYY')
    elif s1 not in l and s2 in l:
        print('YYMM')
    else:
        print('NA')
resolve()
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
left = 0
right = sum(A)
ans = 0

for i in range(N-1):
  left += A[i]
  right -= A[i]
  sa = abs(left-right)
  if i == 0:
    ans = sa
  elif ans > sa:
    ans = sa

print(ans)
# Judge status: Wrong Answer
import heapq
N = int(input())
A = list(int(input()) for _ in range(N))

S = [A[0]]
for i in range(1, N):
    if A[i] <= S[0]:
        S.insert(0, A[i])
        continue
    ok = 0
    ng = len(S)
    tmp = (ok+ng)//2
    while ok+1 < ng:
        tmp = (ok+ng)//2
        if A[i] > S[tmp]:
            ok = tmp
        else:
            ng = tmp
    S[tmp] = A[i]
print(len(S))
# Judge status: Wrong Answer
n = int(input())
#5
A1 = [int(i) for i in input().split()]
#3 2 2 4 1
A2 = [int(i) for i in input().split()]
#1 2 2 2 1

for i in range(n):
	#print(sum(A1[i+1:]),sum(A2[i:-1]))
	if sum(A1[i+1:]) <= sum(A2[i:-1]):
		print(sum(A1[:i+1]) + sum(A2[i:]))
		break
# Judge status: Accepted
s = input()

if int(s[5:7])<= 4:
    print("Heisei")
else:
    print("TBD")
# Judge status: Accepted
n=int(input())
l=list(int(i) for i in input().split())
a=0
for i in range(n-2):
  if sorted(l[i:i+3])[1]==l[i+1]:
    a+=1
print(a)
# Judge status: Accepted
mod = 998244353
n = int(input())
d = list(map(int, input().split()))
if d[0] != 0:
    print(0)
    exit()
lis = [0] * n
for i in d:
    lis[i] += 1
if lis[0] != 1:
    print(0)
    exit()
ans = 1
for i in range(1, n):
    ans *= pow(lis[i-1], lis[i], mod)
    ans %= mod
print(ans)
# Judge status: Accepted
n, x, t = map(int, input().split())
print(((n - 1) // x + 1) * t)
# Judge status: Wrong Answer
import math

a, b = list(map(float, input().split()))
print(math.floor(a * b))
# Judge status: Wrong Answer
s=list(map(int,list(input())))
#print(s)
print("Yes" if sum(s)%9==0 else "NO")
# Judge status: Wrong Answer
N, M = map(int, input().split())
D = [[] for i in range(N)]

for i in range(M):
  p, y = map(int, input().split())
  D[p-1].append((y, i)) 

ans = [None]*M

for i, d in enumerate(D): 
  d.sort()
  print(d)
  for k, (y, j) in enumerate(d): 
    ans[j] = str(i+1).zfill(6) + str(k+1).zfill(6)
print(*ans, sep = '\n')
# Judge status: Accepted
import sys
#sys.exit()
#sorted( ,reverse=True)
#N = int(input())
S,W = map(int, input().split())
#A = list(map(int, input().split()))
if W >= S:
    print('unsafe')
else:
    print('safe')
# Judge status: Wrong Answer
K = int(input())
A, B = map(int, input().split())

result = 'OK'
if (A%K != 0)&(B%K != 0):
    A = A//K + 1
    B = B//K
    if B-A<=0:
        result = 'NG'
        
print(result)