peterverebics/CodeNet_Python_118 huggingface dataset:
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 d, z in ((a, x), (b, y)):
    if d // 2 > c:
        ans += z * c * 2
    else:
        ans += d * z

print(ans)
A,B,C,X,Y = map(int,input().split())

plan_P = A*X + B*Y

if X >= Y :
  plan_Q = A*(X-Y) + C * 2 * Y
else:
  plan_Q = B *(Y-X) + C * 2 * X

if (A + B) <= 2 * C:
  print(plan_P)
else:
  print(plan_Q)
a,b,c,x,y = list(map(int, input().split()))

if a + b < 2*c :
    print(x*a + y*b)
else :
    if x >= y :
        if a >= 2*c:
            print(y*2*c + (y-x)*2*c)
        else :
            print(y*2*c + (y-x)*a)

    else :
        if b >= 2*c:
            print(x*2*c + (x-y)*2*c)
        else:
            print(x*2*c + (x-y)*b)
A,B,C,X,Y=map(int,input().split())

P=X*A+B*Y
if X>Y:
    Q=C*2*Y+(X-Y)*A
    L=X*2*C
elif Y>X:
    Q=C*2*Y+(Y-X)*B
    L=Y*2*C
elif X==Y:
    Q=min(C*2*Y, C*2*X)
    L=min(X*2*C, Y*2*C)



print(min(P,Q,L))
A,B,C,X,Y=map(int,input().split())
if A>=2*C:
  if B>=2*C:
    print(2*C*max(X,Y))
    exit()
  else:
    print(2*C*X+B*max(0,(Y-X)))
    exit()
elif B>=2*C:
  print(2*C*Y+A*max(0,(X-Y)))
  exit()
else:
  ans=A*X+B*Y
  for i in range(1,max(X,Y)):
    p=A*(X-i)+B*(Y-i)+2*C*i
    ans=min(ans,p)
  print(ans)
A, B, C, X, Y = map(int, input().split())
minim = 1e10
for i in range(max(X, Y)):
    bill = i*2*C + A*max(0, X-i) + B*max(0, Y-i)
    minim = min(minim, bill)
print(minim)
a,b,c,x,y = map(int, input().split())
kei = 0
if c >= a/2 + b/2:
    kei = a * x + b*y

elif c*2 <= a+ b and a >= c * 2 and b >= c * 2 :
    kei += c * (min(x,y)*2)
    if x > y:
        kei += c * ((x - y)*2)
    else:
        kei += c * ((y - x)*2)

elif c <= a/2 + b/2:
    kei += c * (min(x,y)*2)
    if x > y:
        kei += a * (x -y)
    else:
        kei += b *(y-x)


print(kei)
a, b, c, x, y = map(int, input().split())
if (a >= 2 * c and b >= 2 * c): print(max(x, y) * 2 * c)
elif (a + b <= 2 * c): print(a * x + b * y)
elif (x > y): print((x - 1) * 2 * c + a)
elif (y < x): print((y - 1) * 2 * c + b)
else: print(2 * c * x)
A,B,C,X,Y=map(int,input().split())
if A+B<=C*2:
  print(A*X+B*Y)
elif min(A,B)<=2*C:
  if X>=Y:
    print(Y*2*C+(X-Y)*A)
  else:
    print(X*2*C+(Y-X)*B)
else:
  print(2*Y*C)
# 18:32
a, b, c, x, y = map(int, input().split())

mxy = max(x, y)
sxy = min(x, y)
sum = 0
if a+b-2*c > 0:
    sum += c*min(x, y)*2
    if x > y and a < 2*c:
        sum += (max(x, y)-min(x, y))*a
    elif x > y:
        sum += (max(x, y)-min(x, y))*2*c
    elif x <= y and a < 2*c:
        sum += (max(x, y)-min(x, y))*b
    elif x <= y:
        sum += (max(x, y)-min(x, y))*2*c

else:
    sum = a*x+b*y
print(sum)
INF = int(1e5)+5

def main():
    a, b, c, x, y = map(int, input().split())
    ans = INF*max(a, b, c)
    for i in range(INF):
        tmp = 2*i*c + a*max(x-i, 0) + b*max(y-i, 0) 
        ans = min(tmp, ans)
    print(ans)
main()
A,B,C,X,Y=map(int,input().split())
if A+B>2*C:
  if X>=Y:
    print(min(C*A,Y*2*C+((X-Y)*A)))
  else:
    print(min(C*B,X*2*C+((Y-X)*B)))
else:
  print(A*X+B*Y)
A, B, C, X, Y = map(int, input().split())
ans = 1 << 30
# ABピザを全探索して考える
for i in range(max(2*X,2*Y)+1, 2):
    x = X - i // 2
    y = Y - i // 2
    ans = min(ans, A * max(0,x) + B * max(0,y) + C * i)

print(ans)
a,b,c,x,y = map(int,input().split())

price = a * x + b * y


for i in range(max(a,b) + 1):
    ab = 2 * i
    cand = ab * c + a * max(0, x - i) + b * max(0, y-i)

    price = min(price, cand)

print(price)
def solve(a,b,c,x,y):
  k_max = min(x,y)
  l = []
  for i in range(k_max+1):
    s = a*(min(x-i,0))+b*(min(y-i,0))+c*i*2
    l.append(s)
  return min(l)   

A,B,C,X,Y = map(int,input().split())
print(solve(A,B,C,X,Y))
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

a,b,c,x,y = i2()
if a+b > 2*c:
	z = min(x,y)
	print( a*(x-z)+b*(y-z)+c*2*z)
else:
	print( a*x+b*y )
a, b, c, x, y = map(int, input().split())
dc = c * 2
if dc <= a + b:
    if dc <= a or dc <= b:
        ans = dc * max(x, y)
    else:
        ans = dc * min(x, y)
        if x > y:
            ans += a * abs(y - x)
        elif x < y:
            ans += b * abs(y - x)
else:
    ans = a * x + b * y
print(ans)
a,b,c,x,y=map(int,input().split())
m=10**10
for i in range(x+y+1):
  p=2*i
  m=min(m,(x-i)*a+(y-i)*b+p*c)
print(m)
a, b, c, x, y = map(int, input().split())
ans = 0
if c <= a <= b or c <= b <= a:
  ans += c * max(x, y)*2
  print(ans)
  exit()
if 2*c-a-b > 0:
  ans += a*x + b*y
else:
  s = min(x, y)
  ans += min(c*s*2 + a*(x-s) + b*(y-s), c*max(x, y)*2)
print(ans)
#C
a, b, c, x, y = map(int,input().split())
ans = 0
if a + b <= 2*c:
    print(a*x + b*y)
else:
    ans = min(x,y) * 2*c
    r = max(x,y) - min(x,y)
    if max(x,y) == x:
        if a <= 2*c:
            ans += a*r
        else:
            ans += 2*c*r
    else:
        if b <= 2*c:
            ans += c*r
        else:
            ans += 2*c*r
print(ans)
def resolve():
    a, b, c, x, y = map(int, input().split())
    ans = 0
    if a+b > 2*c:
        com = min(x, y)
        ans += 2*c*com
        if 2*c <= a or 2*c <= b:
            ans += max(x-com, y-com)*2*c
        else:
            ans += a*(x-com) + b*(y-com)
    else:
        ans += a*x + b*y

    print(ans)

if __name__ == '__main__':
    resolve()
a,b,c,x,y = map(int,input().split())
# print(a,b,c,x,y)

v1 = max(x*2,y*2)*c
v2 = a*x+b*y
v3 = min(x,y)*c*2 + abs(x-y)*min(a,b)

# print(v1,v2,v3)
print(min(v1,v2,v3))
a, b, c, x, y = [int(i) for i in input().split(" ")]

s = [x, y, 0]
charge = s[0]*a+s[1]*b+s[2]*c
for i in range(min(x, y), 0, -1):
  s = [s[0]-1, s[1]-1, s[2]+2]
  charge = min(charge, s[0]*a+s[1]*b+s[2]*c)
print(charge)
A, B, C, X, Y = map(int,input().split())

def best_pizza_cost(ln, hn):
    if ln == X: lp = A
    else: lp = B

    if hn == Y: hp = B
    else: hp = A

    fnp = lp * ln + hp * ln
    fhp = C * ln * 2

    left = hn-ln
    snp = hp * left
    shp = C * left * 2
    print(fnp, fhp, snp, shp)
    return min(fnp, fhp) + min(snp, shp)

print(best_pizza_cost(min(X, Y), max(X, Y)))
a, b, c, x, y = map(int, input().split())
ab = min(x, y)//2 * 2
ans1 = ab*2*c + max(0, x-ab)*a + max(0, y-ab)*b

ans2 = x*a + y*b

ab = max(x, y)//2 * 2
ans3 = ab*2*c + max(0, x-ab)*a + max(0, y-ab)*b

ab = max(x, y)/2 * 2
ans4 = ab*2*c + max(0, x-ab)*a + max(0, y-ab)*b
print(min(ans1, ans2, ans3, ans4))
def half_and_half(a,b,c,x,y):
    z = x   if a > b else y
    can = []
    
    for n in range(z+1):
        p = x - n if x > n else 0
        q = y - n if y > n else 0
        amount = p*a + q*b + n*c*2
        #print("%d = %d x %d + %d x %d + %d x %d " %(amount,p,a,q,b,n,c))
        can.append(amount)

    print(min(can))

if __name__ == '__main__':
    a,b,c,x,y = map(int,input().split())
    half_and_half(a,b,c,x,y)
A, B, C, X, Y = map(int, input().split())
total = 0
ans = 10**10

for i in range(2, max(X, Y)*2, 2):
  total = A*(X-(i/2)) + B*(Y-(i/2)) + C*i
  ans = min(ans, total)
  
print(int(ans))
A,B,C,X,Y=map(int,input().split())
ans=5000*(10**5)+1

for i in range(max(X,Y)):
  total=0
  total=2*C*i+A*max(X-i,0)+B*max(Y-i,0)
  if ans>=total:
    ans=total
print(ans)
# ABC095C

a, b, c, x, y = map(int, input().split())
if a > c or b > c:
    t = min(x, y)
    print("(1)", (x - t)*a + (y - t)*b + t*2*c)
else:
    print("(2)", a*x + b*y)
a, b, c, x, y = map(int, input().split())
if a+b < 2*c:
    print(a*x + b*y)
else:
    if x > y:
        if a < c:
            print(2*y*c + (x-y)*a)
        else:
            print(2*x*c)
    else:
        if b < c:
            print(2*x*c + (y-x)*b)
        else:
            print(2*y*c)
a, b, ab, x, y = map(int, input().split())
if a+b <= 2*ab:
    print(a*x+b*y)
    exit()
if a >= 2*ab and b >= 2*ab:
    print(max(x,y)*2*ab)
    exit()
mix = min(x,y)*2*ab
f = lambda x, y: a if x - y >= 0 else b
print(mix+f(x, y)*abs(x-y))
import sys
input = sys.stdin.readline
a,b,c,x,y=map(int,input().split())

c1=a*x+b*y
if x>=y:
    c2=2*y*c+(x-y)*x
else:
    c2=2*x*c+(y-x)*y
c3=2*max(x,y)*c
print(min(c1,c2,c3))
a, b, c, x, y = map(int, input().split())
ans = 0
if c < a and c < b:
  ans += c * max(x, y)*2
  print(ans)
  exit()
if (c-a+c-b) > 0:
  ans += a*x + b*y
else:
  s = min(x, y)
  ans += min(c*s*2 + a*(x-s) + b*(y-s), c*max(x, y)*2)
print(ans)
A, B, C, X, Y = [int(x) for x in input().split(' ')]
if (A + B) / 2 > C:
  p = 10**6
  for i in range(min(X, Y), max(X, Y)+1):
    p = min(p, A * max(0, X-i) + B * max(0, Y-i) + C * i * 2)
  print(p)
else:
  print(A * X + B * Y)
A,B,C,X,Y = map(int, input().split())

n = min(X,Y)

sum = 0

sum = min(n*2*C, A*n+B*n)

if X>Y:
    n = X-n
    sum = sum + n*A
else:
    n = Y - n
    sum = sum + n*B

print(sum)

s = (X+Y)*2*C

if sum>s:
    print(s)
else:
    print(sum)
A,B,C,X,Y = map(int,input().split())

ans = 0

if 4 * C <= (A + B):
  ans = C * max(X,Y) * 2
elif 2 * C <= A + B:
  if X > Y:
    ans = Y * 2 * C + (X - Y) * A
  else:
    ans = X * 2 * C + (Y - X) * B
else:
  ans = A * X + B * Y
  
print(ans)
def LI(): return list(map(int,input().split()))
A,B,C,X,Y = LI()
ans = min(A*X+B*Y,C*(max(X,Y)*2))
if min(X,Y)%2==0:
    temp = (min(X,Y)*2)*C + (max(X,Y)-min(X,Y))*(A if X>Y else B)
    ans = min(temp,ans)
print(ans)
a, b, c, x, y = map(int, input().split())
A = (a, x)
B = (b, y)
ans = 0
if A[0]+B[0] > 2*c:
    mn = min(A, B, key=lambda x: x[1])
    mx = max(A, B, key=lambda x: x[1])
    q, r = divmod(mn[1], 2)
    e1 = 2*q * 2*c + mn[0] * r + (mx[1]-2*q) * mx[0]
    e2 = mx[1] * 2*c
    ans = min(e1, e2)
else:
    ans += A[0]*A[1] + B[0]*B[1]

print(ans)
import math
A,B,C,x,y=map(int,input().split())
price=5000*(10**5)
for c in range(1+max([2*x,2*y])):
    a=0
    b=0
    if x>c/2:
        a=math.ceil(x-(c/2))
    if y>c/2:
        b=math.ceil(y-(c/2))
    if A*a+B*b+C*c<price:
        price=A*a+B*b+C*c
print(price)
a,b,c,x,y = map(int,input().split())
c = c*2
n = max(x,y)
ans = 10**25
for i in range(n*2):
    x1,y1 = i,i
    p = c*i
    if x > x1:
        if y > y1:
            p += a*(x-x1) + b*(y-y1)
        else:
            p += a*(x-x1)
    else:
        if y > y1:
            p += b*(y+y1)
    if ans > p:
        ans = p

print(ans)
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

if a // 2 <= c and b // 2 > c:
    ans += y * c * 2
    x = max(0, x - y)
    ans += x * a
elif a // 2 > c and b // 2 <= c:
    ans += x * c * 2
    y = max(0, y - x)
    ans += y * b
elif a //2 > c and b // 2 > c:
    ans += max(x, y) * c * 2
else:
    ans += x * a + y * b

print(ans)
a,b,c,x,y = map(int,input().split())
print( min(x,y)*min(a+b,2*c) + (max(x,y)-min(x,y))*(max(x,y)==y)*b + (max(x,y)-min(x,y))*(max(x,y)==x)*a)
A,B,C,X,Y=map(int,input().split())
if A+B<=2*C:
    print(A*X+B*Y)
elif min([A,B,C])==C:
    print(2*C*max(X,Y))
elif X<=Y:
    print(2*X*C+B*(Y-X))
else:
    print(2*Y*C+A*(X-Y))
a, b, c, x, y = map(int,input().split())

if (a+b)//2 <= c:
    print(x*a + y*b)
    exit()
    
ans = 0

ans += min(x,y) * c * 2

if x >= y:
    ans += min((x-y)*a, (x-y)*2*c)
else:
    ans += min((y-x)*b, (y-x)*2*c)
    
print(ans)
a,b,c,x,y  = map(int,input().split())
if a+b > c*2:
    mmm = min(x,y)
    aaa = max(x,y)
    if (x > y and x<=2*c):
        print(c*2*mmm + a*(aaa-mmm))
    elif (x > y and x>2*c):
        print(c*2*aaa)
    elif (x <= y and y<=2*c):
        print(c*2*mmm + b*(aaa-mmm))
    elif (x <= y and y>2*c):
        print(c*2*aaa)
else:
    print(a*x + b*y)
a,b,c,x,y=map(int,input().split())
c=min(c*2,a+b)
ans=min(x,y)*c
if x>y:ans+=min(a,c)*(y-x)
else:ans+=min(b,c)*(x-y)
print(ans)
a,b,c,x,y=[int(i)  for i in input().split()]
ans=1000000
for k in range(10**5):
	money=2*c*k + max(x-k,0)*a + max(y-k,0)*b
	if(ans>money):
		ans=money
print(ans)
a,b,c,x,y = map(int,input().split())
p = 0

if x > y:
    p += (x - y) * a
    x = y
if x < y:
    p += (y - x) * b
    y = x
if x % 2 == 1:
    p += x + y
    x -= 1
    y -= 1
if x > 0:
    n = x // 2 * c
    m = x * a + y * b
    p += min(n,m)

print(p)
a , b , c , x , y = map(int,input().split())

k = max(x,y)
minman = 9999999999999

k = k // 2
for i in range(k,-1,-1):
    now_x = x
    now_y = y
    ans = c * (i * 4)
    now_x = now_x - (i * 2)
    now_y = now_y - (i * 2)
    if now_x < 0:
        now_x = 0
    if now_y < 0:
        now_y = 0
    ans +=( now_x * a ) + ( now_y * b)
    if minman > ans:
        minman = ans
print(minman)
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 11:16:07 2020

@author: liang
"""

A, B, C, X, Y = map(int,input().split())
if A + B > 2*C:
    if X > Y :
        ans = Y * C * 2 + abs(X-Y) * A
    else:
        ans = X * C * 2 + abs(X-Y) * B
else:
    ans = X * A + Y * B 
print(ans)
a,b,c,x,y=map(int,input().split())
if a+b<=c:
    print(a*x+b*y)
else:
    c*2*min(x,y)+min(max(a*min(x,y),b*min(x,y)),c*2*abs(x-y))
a, b, c, x, y = map(int, input().split())

pat1 = 0
pat2 = 0
pat3 = 0
pat4 = 0
pat5 = 0

ans = []

if a+b >= c*2:
  if x >= y:
    pat1 = y * 2 * c
    x -= y
    pat1 += x * a 
    x += y
    
    pat2 = x * 2 * c
    
  else:
    pat3 = x * 2 * c
    y -= x
    pat3 += x * a + y * b
    y += x
    
    pat4 = y * 2 * c
else:
  pat5 += x * a + y * b

ans.extend([pat1, pat2, pat3, pat4, pat5])
ans = [i for i in ans if i!= 0]
  
print(min(ans))
a , b , c , x , y = map(int,input().split())
ans = 10*10

for i in range(10**8):
    ans = min(ans, a * max(x -i,0) + b * max (y - i , 0  + (2 * c * i)  ))

print(ans)
cost_a,cost_b,cost_ab,num_a,num_b = map(int,input().split())
num = max(num_a,num_b)
cost1 = num * 2 * cost_ab
cost2 = cost_a * num_a + cost_b * num_b
if cost1 > cost2:
  print(cost2)
else:
  print(cost1)
a,b,c,x,y=map(int,input().split())
if a>=c*2 and b>=c*2:
    print(c*2*max(x,y))
elif a<=c*2 and b>=c*2:
    print(c*2*y+a*x)
elif b<=c*2 and a>=c*2:
    print(c*2*x+b*y)
elif (a+b)>=c*2:
    z=min(x,y)
    x-=z
    y-=z
    print(c*2*z+a*x+b*y)
else:
    print(a*x+b*y)
A, B, C, X, Y = map(int, input().split())
total = 0
ans = 10**10

for i in range(0, max(X, Y)*2, 2):
  total = A*(X-(i/2)) + B*(Y-(i/2)) + C*i
  ans = min(ans, total)
  
print(int(ans))
a,b,c,x,y = map(int,input().split())
c *= 2
ans = 10 ** 16
for i in range(max(x,y)):
    m = 0
    m += (a*(x-i))+(b*(y-i))+(c*i)
    ans = min(ans,m)
print(ans)
a,b,c,x,y = map(int, input().split())
mix_price = min(a+b,c*2)
if a > 2 * c or b > 2 * c:
  print(max(x,y) * 2 * c)
elif a + b > 2 * c and x > y:
  print(y * mix_price + (x - y) * a)
elif a + b > 2 * c and x < y:
  print(x * mix_price + (y - x) * b)
else:
  print(x * a + y * b)
a,b,c,x,y=map(int,input().split())
ans=a*x+b*y
for ab in range(1,max(a,b)):
    if 2*ab*c+a*(max(x-ab,0))+b*(max(0,y-ab))<ans:
        ans=2*ab*c+a*(max(x-ab,0))+b*(max(0,y-ab))
print(ans)
a,b,c,x,y = map(int, input().split())
mix_price = min(a+b,c*2)
if a > 2 * c and b > 2 * c:
  print(2 * c * max(x,y))
elif a > 2 * c and x > y:
  print(x * 2 * c)
elif a > 2 * c and x < y:
  print(x * 2 * c + (y - x) * b)
elif b > 2 * c and x < y:
  print(y * 2 * c)
elif b > 2 * c and x > y:
  print(y * 2 * c + (x - y) * a)
elif a + b > 2 * c and x > y:
  print(y * mix_price + (x - y) * a)
elif a + b > 2 * c and x < y:
  print(x * mix_price + (y - x) * b)
else:
  print(x * a + y * b)
a,b,c,x,y = map(int,input().split())
ans = 10**20
for i in range(min(x,y)*2+1):
    ans = min(ans,c*i+a*max(0,x-i//2)+b*max(0,y-i//2))

print(ans)
#pattern1:Only A-pizza/B-pizza
#pattern2:Only C-pizza
#pattern2:C-pizza & A or B-pizza

a,b,c,x,y = map(int, input().split())

min_price = 1000000000000
for i in range(1, 10**5 + 1):
    price = i*2*c + max(0, x-i)*a + max(0, y-i)*b
    min_price = min(min_price, price)

print(min_price)
a, b, c, x, y = map(int, input().split())
ans = 10000000
for i in range(min(x, y) + 1):
    nc = 2 * i * c
    na = max(0, (a * (x - i)))
    nb = max(0, (b * (y - i)))
    ans = min(ans, nc + na + nb)
print(ans)
[A,B,C,X,Y] = list(map(int,input().split()))

out=10**6
for c in range(2*(10**5)+1):
    if c%2==0:
        a = X - c//2
        b = Y - c//2
        cost = A*a + B*b + C*c

        if cost>=0 and a>=0 and b>=0:
            # print('a,b,c,cost:',a,b,c,cost)
            out=min(out,cost)
print(out)
a, b, c, x, y = map(int, input().split())
ab = min(x, y)//2 * 2
ans1 = ab*2*c + max(0, x-ab)*a + max(0, y-ab)*b

ans2 = x*a + y*b

ab = max(x, y)/2 * 2
ans3 = ab*2*c + max(0, x-ab)*a + max(0, y-ab)*b
print(min(ans1, ans2, ans3))
import sys

input = sys.stdin.readline


def main():
    A, B, C, X, Y = [int(x) for x in input().split()]
    ans = []
    ans.append(A * X + B * Y)
    ans.append(C * 2 * (max(X, Y)))
    if X > Y:
        ans.append(C * 2 * Y + (X - Y) * A)
    else:
        ans.append(C * 2 * Y + (Y - X) * B)

    print(min(ans))


    

if __name__ == '__main__':
    main()
a , b , c , x , y = map(int,input().split())

k = max(x,y)
minman = 999999999999999999999
ans = 999999999999999999999999
k = k // 2
for i in range(k,-1,-1):
    now_x = x
    now_y = y
    ans = c * (i * 4)
    now_x = now_x - (i * 2)
    now_y = now_y - (i * 2)
    if now_x < 0:
        now_x = 0
    if now_y < 0:
        now_y = 0
    ans +=( now_x * a ) + ( now_y * b)
    if minman > ans:
        minman = ans
print(minman)
a,b,c,x,y = map(int,input().split())

ans=float("inf")
for i in range(0,max(x,y)*2+1,2):
    ans = min(ans, a*max(0,x-i/2)+b*max(0,y-i/2)+c*i)
print(ans)
# AtCoder Beginner Contest 095 C - Half and Half
import sys

A, B, C, X, Y = map(int, sys.stdin.readline().strip().split())

ans = A * X + B * Y
for z in range(2, 10 ** 5 + 1, 2):
    x = max(X - int(z / 2), 0)
    y = max(Y - int(z / 2), 0)

    price = A * x + B * y + C * z
    ans = min(price, ans)

print(ans)
N = int(input())
TXY = [list(map(int,input().split())) for _ in range(N)]
t = 0
x = 0
y = 0
for txy in TXY:
    T = txy[0]
    X = txy[1]
    Y = txy[2]
    if (T-t) - abs(X-x) - abs(Y-y) >= 0 and ((T-t) - abs(X-x) - abs(Y-y)) % 2 == 0:
        t = T
        x = X
        y = Y
    else:
        print('No')
        exit()
print('Yes')
n=int(input())
txy=[list(map(int,input().split())) for _ in range(n)]
u,v,w=0,0,0
for t,x,y in txy:
  p=t-u
  q=abs(v-x)+abs(w-y)
  if p<q or p%2!=q%2:
    print("No")
    break
else:
  print("Yes")
N=int(input())
t=[0]*100003
x=[0]*100003
y=[0]*100003

for i in range(1,N+1):
    t[i],x[i],y[i]=map(int, input().split())
count=0

for i in range(1,N+1):
    dt=t[i]-t[i-1]
    dist=abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
    if dist>dt:
        break
    else:
        pass
    if dist%2==dt%2:
        pass
    else:
        break
    count+=1
if count==N:
    print('Yes')
else:
    print('No')
N = int(input())
A = [list(map(int,input().split())) for _ in range(N)]
A.insert(0,[0,0,0])
for i in range(len(A)-1):
    dt = A[i+1][0]-A[i][0]
    dist = abs(A[i+1][1]-A[i][1])+abs(A[i+1][2]-A[i][2])
    if dist>dt:
        print("No")
        quit()
    if dist%2!=dt%2:
        print("No")
        quit()
print("Yes")
n = int(input())

now = [0,0,0]
for i in range(n):
    s = list(map(int,input().split()))
    time = s[0] - now[0]
    dis = abs(s[1] - now[1]) + abs(s[2] - now[2])
    if time < dis or (time-dis)%2 == 1:
        print("No")
        exit()
    now = s

print("Yes")
N=int(input())
flag=0

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



for i in range(N):
  if abs(x[i][0]-x[i+1][0])<(abs(x[i][1]-x[i+1][1])+abs(x[i][2]-x[i+1][2])):
    flag=1
  if x[i][1]==x[i+1][1] and x[i][2]==x[i+1][2]:
    flag=1
  if abs(x[i][0]-x[i+1][0])%2!=(abs(x[i][1]-x[i+1][1])+abs(x[i][2]-x[i+1][2]))%2:
    flag=1

if flag==0:
  print("Yes")
else:
  print("No")
import sys
input=sys.stdin.readline

n=int(input())

pt=0
pxy=0
for i in range(n):
    t,x,y=map(int,input().split())
    dt=t-pt
    dxy=abs(x+y-pxy)
    if dxy>dt or dt%2!=dxy%2:
        print('No')
        exit()
else:
    print('Yes')
n = int(input())
d = [list(map(int, input().split())) for i in range(n)]

t, x, y = 0, 0, 0

flag = True
for ti, xi, yi in d:
  if ti >= xi + yi:
    if (ti - t) % 2 != (abs(xi - x) + abs(yi - y)) % 2:
    	flag = False
    	break
    t = ti
    x = xi
    y = yi
    
  else:
    flag = False
    break
    
print("Yes" if flag else "No")
n=int(input())
txy=[]
txy.append([0,0,0])
for _ in range(n):
    txy.append(list(map(int,input().split())))
ans = 'Yes'
for i in range(1,len(txy)):
    t_=txy[i][0]-txy[i-1][0]
    d_=abs(txy[i][1]-txy[i-1][1])+abs(txy[i][2]-txy[i-1][2])
    if t_ >= d_ and (t_ - d_) % 2 == 0:
        pass
    else:
        ans='No'
        break
print(ans)
from collections import deque

N = int(input())
t = deque([0] * N)
x = deque([0] * N)
y = deque([0] * N)

for i in range(N):
    t[i], x[i], y[i] = map(int, input().split())

N += 1
t.appendleft(0)
x.appendleft(0)
y.appendleft(0)

for i in range(N-1):
    t_sub = t[i+1] - t[i]
    x_sub = abs(x[i+1] - x[i])
    y_sub = abs(y[i+1] - y[i])
    dist = x_sub + y_sub
    if dist > t_sub or t_sub % 2 != dist % 2:
        print('No')
        exit()

print('Yes')
n = int(input())
txy = [list(map(int, input().split())) for i in range(n)]
T, X, Y = 0, 0, 0
result = "Yes"
for t, x, y in txy:
    d =  (x-X) + (y-Y)
    if t<d or (t-d)%2==1:
        result = "No"
        break
print(result)
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
x = 0
y = 0
t = 0
for i in range(n):
    if abs(a[i][1] - x) + abs(a[i][2] - y) > abs(a[i][0] - t) or (a[i][1] - x + a[i][2] - y) % 2 != (a[i][0] - t) % 2:
        print('No')
        exit()
    else:
        x = a[i][1]
        y = a[i][2]
        t = a[i][0]
print('Yes')
n = int(input())
 
s = 0
p = 0
for _ in range(n):
  t,x,y = map(int, input().split())
  s = t - s
  p = abs((x+y)-p)
  if s < p:
    print("No")
    exit()
  elif s%2 != p%2:
    print("No")
    exit()
print("Yes")
N = int(input())

locx = 0
locy =0
time = 0
for i in range(N):
  t,x,y = map(int,input().split())
  nowtime = t-time
  dis = abs(locx-x)+abs(locy-y)
  if (nowtime-dis)<0 :
    print("No")
    exit()
  if (nowtime-dis)%2 == 1:
    print("No")
    exit()
    
  
  time = t
  locx = x
  locy = y
    
  
else :
  print("Yes")
N=int(input())
x=0
y=0
t=0
for i in range(N):
    tt,xx,yy=map(int,input().split())
    if abs(xx-x)+abs(yy-y)<=tt-t:
        if (abs(xx-x)+abs(yy-y))%2!=(tt-t)%2:
            print("No")
            exit()
    else:
        print("No")
        exit()
    t,x,y=tt,xx,yy
print("Yes")
n=int(input())
arr=[[0,0,0]]+[list(map(int,input().split())) for _ in range(n)]
for i in range(n):
  t1,x1,y1=arr[i]
  t2,x2,y2=arr[i+1]
  if abs(x1-x2)+abs(y1-y2)>t2-t1:
    print('No')
    exit()
  if (abs(x1-x2)+abs(y1-y2))%2!=(t2-t1)%2:
    print('No')
    exit()
print('Yes')
n = int(input())
now = [0, 0, 0]
def ng():
  print('No')
  exit()
for i in range(n):
  t, x, y = map(int, input().split())
  if t % 2 != (x + y) % 2:
    ng()
  if abs(x - now[1]) + abs(y - now[2]) > t - now[0]:
    ng()
  now = [t, x, y]
print('Yes')
import sys
n=int(input())
l=[list(map(int,input().split())) for i in range(n)] 
t=0
x=0
y=0
for i in range(n):
    
    t1=l[i][0]
    x1=l[i][1]
    y1=l[i][2]
    dt=t1-t
    md=abs(x-x1)+abs(y-y1)

    if dt >= md and (dt - md) % 2 == 0:
        t=t1
        x=x1
        y=y1
    else:
        print("No")
        sys.exit()

print("Yes")
import sys
input = sys.stdin.readline

n = int(input())
t = 0
x = 0
y = 0
judge = True

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

for t1, x1, y1 in l:
    if (abs(x1 - x) + abs(y1 - y))/(t1 - t) > 1 or (abs(x1 - x) + abs(y1 - y))%2 != (t1 - t)%2:
        print("No")
        exit()
    x = x1
    y = y1
    t = t1

print("Yes")
N = int(input())
P = [(0,0,0)] + [tuple(int(x) for x in input().split()) for _ in range(N)]

def travelable(p,q):
    time = q[0] - p[0]
    dist = abs(q[1]-p[1]) + abs(q[2]-p[2])
    if dist <= time and time%2 == dist%2:
        return True
    else:
        return False
from itertools import zip_longest
print('Yes' if all(travelable(p,q) for p,q in zip_longest(P[:N],P[1:])) else 'No')