CodeEff/ECCO huggingface dataset:
# Original solution
from itertools import product
n,a,b,c=list(map(int,input().split()))
abc=[a,b,c]
l=tuple(int(eval(input())) for _ in range(n))

ans=10**18
for a in product(list(range(4)), repeat=n):
    MP=0
    take=[[] for _ in range(4)]

    for i in range(n):
        take[a[i]].append(l[i])
    
    if take[0] and take[1] and take[2]:
        for i,t in enumerate(take[:-1]):
            MP+=max(0, 10*(len(t)-1))
            MP+=abs(abc[i] - sum(t))
    else:
        continue

    ans=min(ans, MP) 

print(ans)


# Optimized solution
from itertools import product
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, A, B, C = list(map(int, input().split()))
L = [int(eval(input())) for _ in range(N)]

ans = 10 ** 18
for alloc in product(list(range(4)), repeat=N):
    La = 0
    Lb = 0
    Lc = 0
    use_a = 0
    use_b = 0
    use_c = 0
    for i, f in enumerate(alloc):
        if f == 0:
            La += L[i]
            use_a += 1
        elif f == 1:
            Lb += L[i]
            use_b += 1
        elif f == 2:
            Lc += L[i]
            use_c += 1
        else:
            pass

    if not all([use_a, use_b, use_c]):
        continue

    score = 0
    score += 10 * (use_a - 1)
    score += 10 * (use_b - 1)
    score += 10 * (use_c - 1)
    score += abs(A - La)
    score += abs(B - Lb)
    score += abs(C - Lc)
    ans = min(ans, score)

print(ans)
# Original solution
INF = 10 ** 18

N, A, B, C = list(map(int,input().split()))
ls = [int(eval(input())) for i in range(N)]

def func(pos, a, b, c):return abs(a - A) + abs(b - B) + abs(c - C) - 30 + INF * max(0, 1 - a * b * c) if pos == N else min(func(pos + 1, a + ls[pos] * (i == 0), b + ls[pos] * (i == 1), c + ls[pos] * (i == 2)) + 10 * (i < 3) for i in range(4))
print((func(0, 0, 0, 0)))

# Optimized solution
N, A, B, C = list(map(int,input().split()))
ls = [int(eval(input())) for i in range(N)]
def func(pos, a, b, c):return abs(a - A) + abs(b - B) + abs(c - C) - 30 + 10000 * max(0, 1 - a * b * c) if pos == N else min(func(pos + 1, a + ls[pos] * (i == 0), b + ls[pos] * (i == 1), c + ls[pos] * (i == 2)) + 10 * (i < 3) for i in range(4))
print((func(0, 0, 0, 0)))
# Original solution
N, A, B, C = list(map(int,input().split()))
ans = [[0, 0, 0, 0]]
for i in range(N):
    l = int(eval(input()))
    ans = [[p[j] + l * (i == j) for j in [0, 1, 2]] + [p[3]+(i < 3)] for p in ans for i in range(4)]
print((min(abs(p[0] - A) + abs(p[1] - B) + abs(p[2] - C) + p[3] * 10 - 30 for p in ans if min(p[:3]) > 0)))

# Optimized solution
N, A, B, C = list(map(int,input().split()))
ans = [[0, 0, 0, -30]]
for i in range(N):
    l = int(eval(input()))
    ans = [[p[j] + l * (i == j) for j in [0, 1, 2]] + [p[3] + (i < 3) * 10] for p in ans for i in range(4)]
print((min(abs(p[0] - A) + abs(p[1] - B) + abs(p[2] - C) + p[3] for p in ans if min(p[:3]) > 0)))
# Original solution
N, A, B, C = list(map(int,input().split()))
ans = [[0, 0, 0, -30]]
for i in range(N):
    l = int(eval(input()))
    ans = [[p[j] + l * (i == j) for j in [0, 1, 2]] + [p[3] + (i < 3) * 10] for p in ans for i in range(4)]
print((min(abs(p[0] - A) + abs(p[1] - B) + abs(p[2] - C) + p[3] for p in ans if min(p[:3]) > 0)))

# Optimized solution
N,A,B,C=list(map(int,input().split()));a=[[0,0,0,-30]]
for i in range(N):l=int(eval(input()));a=[[p[j]+l*(i==j)for j in[0,1,2]]+[p[3]+(i<3)*10]for i in range(4)for p in a]
print((min(abs(p[0]-A)+abs(p[1]-B)+abs(p[2]-C)+p[3]for p in a if min(p[:3])>0)))
# Original solution
N,*A=list(map(int,input().split()));a=[[0]*4];r=[0,1,2]
for i in range(N):l=int(eval(input()));a=[[p[j]+l*(i==j)for j in r]+[p[3]+(i<3)*10]for i in r+[3]for p in a]
print((min(sum(abs(p[i]-A[i])for i in r)-30+p[3]for p in a if min(p[:3])>0)))

# Optimized solution
N,*A=list(map(int,input().split()));a=[[0]*4];r=[0,1,2]
for i in range(N):l=int(eval(input()));a+=[[p[j]+l*(i==j)for j in r]+[p[3]+10]for i in r for p in a]
print((min(sum(abs(p[i]-A[i])for i in r)-30+p[3]for p in a if min(p[:3])>0)))
# Original solution
import sys
check_ary = [[0 for i in range(3)]for i in range(2)]
num_ary = [[0 for i in range(3)]for i in range(3)]
check_minus = False

for i in range(3):
    num_ary[i] = list(map(int,input().split()))

for i in range(num_ary[0][0]+1):

    for x in range(3):
        check_ary[1][x] = num_ary[0][x] - i

    for a in range(3):
        check_ary[0][a] = num_ary[a][0] - check_ary[1][0]

    for x in range(3):
        for y in range(3):
            if not check_ary[0][x] + check_ary[1][y] == num_ary[x][y]:
                break
        else:
            continue
        break
    else :
        print("Yes")
        sys.exit()

print("No")

# Optimized solution
ary = [list(map(int,input().split())) for _ in range(3)]
for i in range(ary[0][0]+1):
    a = [ary[0][0]-i,ary[0][1]-i,ary[0][2]-i]
    a2 = ary[1][0] - a[0]
    a3 = ary[2][0] - a[0]
    b = [a2+a[0],a2+a[1],a2+a[2]]
    c = [a3+a[0],a3+a[1],a3+a[2]]
    if ary == [a,b,c]:print("Yes");exit()
else:print("No")
# Original solution
lis1 = []
lis2 = []
lis3 = []
count = 0
for num in input().split():
    lis1.append(int(num))
for num in input().split():
    lis2.append(int(num))
for num in input().split():
    lis3.append(int(num))
for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            count = 0
            if lis1[0] - a1 == lis2[0] - a2 == lis3[0] - a3:
                count += 1
            if lis1[1] - a1 == lis2[1] - a2 == lis3[1] - a3:
                count += 1
            if lis1[2] - a1 == lis2[2] - a2 == lis3[2] - a3:
                count += 1
            if count == 3:
                print("Yes")
                break
        if count == 3:
          	break
    if count == 3:
      break
    if a1 == 100 and count != 3:
      	print("No")

# Optimized solution
lis1 = []
lis2 = []
lis3 = []
count = 0
flag = 0
for num in input().split():
    lis1.append(int(num))
for num in input().split():
    lis2.append(int(num))
for num in input().split():
    lis3.append(int(num))
for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            if lis1[0] - a1 == lis2[0] - a2 == lis3[0] - a3:
        	    if lis1[1] - a1 == lis2[1] - a2 == lis3[1] - a3:
		            if lis1[2] - a1 == lis2[2] - a2 == lis3[2] - a3:
             	 		print("Yes")
             	 		flag = 1
             	 		break
        if flag == 1:
            break
    if flag == 1:
        break
    if a1 == 100 and flag == 0:
      	print("No")
# Original solution
cij =[]
for i in range(3):
    cij.append(list(map(int, input().split(" "))))

bi_list = []
for b1 in range(-500000, 500000):
    b2 = b1 - (cij[0][0] - cij[0][1])
    b3 = b1 - (cij[0][0] - cij[0][2])

    a1 = cij[0][0]+cij[0][1]+cij[0][2] -b1-b2-b3
    a2 = cij[1][0]+cij[1][1]+cij[1][2] -b1-b2-b3
    a3 = cij[2][0]+cij[2][1]+cij[2][2] -b1-b2-b3
    if a1/3+b1 ==cij[0][0] and a1/3+b2 ==cij[0][1] and a1/3+b3 ==cij[0][2] and a2/3+b1 ==cij[1][0] and a2/3+b2 ==cij[1][1] and a2/3+b3 ==cij[1][2] and a3/3+b1 ==cij[2][0] and a3/3+b2 ==cij[2][1] and a3/3+b3 ==cij[2][2]:
            print("Yes")
            exit()

print("No")

# Optimized solution
cij =[]
for i in range(3):
    cij.append(list(map(int, input().split(" "))))

bi_list = []
for b1 in range(-50000, 50000):
    b2 = b1 - (cij[0][0] - cij[0][1])
    b3 = b1 - (cij[0][0] - cij[0][2])

    a1 = cij[0][0]+cij[0][1]+cij[0][2] -b1-b2-b3
    a2 = cij[1][0]+cij[1][1]+cij[1][2] -b1-b2-b3
    a3 = cij[2][0]+cij[2][1]+cij[2][2] -b1-b2-b3
    if a1/3+b1 ==cij[0][0] and a1/3+b2 ==cij[0][1] and a1/3+b3 ==cij[0][2] and a2/3+b1 ==cij[1][0] and a2/3+b2 ==cij[1][1] and a2/3+b3 ==cij[1][2] and a3/3+b1 ==cij[2][0] and a3/3+b2 ==cij[2][1] and a3/3+b3 ==cij[2][2]:
            print("Yes")
            exit()

print("No")
# Original solution
c=[list(map(int,input().split())) for i in range(3)]
x=c[0][2]-c[0][1]
y=c[0][1]-c[0][0]
for i in range(1,3):
    if c[i][1]-c[i][0]!=y:
        print("No")
        break
    if c[i][2]-c[i][1]!=x:
        print("No")
        break
else:
    print("Yes")

# Optimized solution
c = [list(map(int, input().split())) for i in range(3)]
x = c[0][2] - c[0][1]
y = c[0][1] - c[0][0]
ans = 'Yes'
for i in range(1, 3):
  if c[i][2] - c[i][1] != x or c[i][1] - c[i][0] != y:
    ans = "No"
    break

print(ans)
# Original solution
# ABC088C - Takahashi's Information
def main():
    arr = [list(map(int, input().rstrip().split())) for _ in range(3)]
    memo = []
    for i, j, k in arr:
        memo += [(i - j, j - k)]
    print(("Yes" if len(set(memo)) == 1 else "No"))


if __name__ == "__main__":
    main()

# Optimized solution
# ABC088C - Takahashi's Information
def main():
    *C, = list(map(int, open(0).read().split()))
    memo = {(i - j, j - k) for i, j, k in zip(*[iter(C)] * 3)}
    flg = len(memo) == 1
    print(("Yes" if flg else "No"))


if __name__ == "__main__":
    main()
# Original solution
def calc(a1,c):
    As=[a1]
    Bs=[]
    Bs.append(c[0][0]-As[0])
    As.append(c[1][0]-Bs[0])
    As.append(c[2][0]-Bs[0])
    Bs.append(c[0][1]-As[0])
    Bs.append(c[0][2]-As[0])
    for a in range(3):
        for b in range(3):
            if As[a]+Bs[b]!=c[a][b]: return False
    return True

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

flag=False
for i in range(-int(1e4),100):
    if (calc(i,c)): 
        print('Yes')
        flag=True
        break
if not flag: print('No')

# Optimized solution
def calc(a1,c):
    As=[a1]
    Bs=[]
    Bs.append(c[0][0]-As[0])
    As.append(c[1][0]-Bs[0])
    As.append(c[2][0]-Bs[0])
    Bs.append(c[0][1]-As[0])
    Bs.append(c[0][2]-As[0])
    for a in range(3):
        for b in range(3):
            if As[a]+Bs[b]!=c[a][b]: return False
    return True

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

flag=False
if (calc(0,c)): 
    print('Yes')
else: print('No')
# Original solution
def confirm(a, b, c):
    for i in range(3):
        for j in range(3):
            if a[i] + b[j] != c[i][j]:
                return False
    return True


def main():
    c = [list(map(int, input().split())) for i in range(3)]

    for a1 in range(101):
        for a2 in range(101):
            for a3 in range(101):
                a = (a1, a2, a3)
                b = (c[0][0] - a1, c[0][1] - a1, c[0][2] - a1)
                if confirm(a, b, c):
                    return 'Yes'
    return 'No'


if __name__ == '__main__':
    ans = main()
    print(ans)


# Optimized solution
def main():
    c = [list(map(int, input().split())) for i in range(3)]
    for x in range(101):
        b = (c[0][0] - x, c[0][1] - x, c[0][2] - x)
        a = (x, c[1][0] - b[0], c[2][0] - b[0])
        flag = True
        for i in (1, 2):
            for j in (1, 2):
                if a[i] + b[j] != c[i][j]:
                    flag = False
        if flag:
            return 'Yes'
    return 'No'

  
if __name__ == "__main__":
    print((main()))
# Original solution
c=[[int(i) for i in input().split()]for i in range(3)]
a=[0]*3
b=[0]*3
for i in range(3):
    for j in range(3):
        b[j]=c[i][j]-a[0]
for i in range(3):
    for j in range(3):
        a[j]=c[j][0]-b[0]
judge=True
for i in range(3):
    for j in range(3):
        if a[j]+b[i]!=c[j][i]:
            judge=False
if judge:
    print("Yes")
else:
    print("No")
        


# Optimized solution
s=[list(map(int,input().split()))for i in range(3)]
a=[0]*3
b=[0]*3
for i in range(3):
    b[i]=s[0][i]-a[0]
for i in range(3):
    a[i]=s[i][0]-b[0]
for i in range(3):
    for j in range(3):
        if a[i]+b[j]!=s[i][j]:
            print("No")
            exit()
print("Yes")
# Original solution
#import collections
#aa = collections.Counter(a) # list to list
#mod = 10**9 + 7
def readInts():
  return list(map(int,input().split()))
def main():
    C = [readInts() for _ in range(3)]
    a = [0] * 3
    b = [0] * 3
    # a[0] = 0としとく
    # 1つ適当に決めることでほかのものが決まる
    # それでちょいちょいやればよーい!
    for i in range(3):
        b[i] = C[0][i] - a[0]
    for i in range(1,3):
        a[i] = C[i][0] - b[0]
    for i in range(3):
        for j in range(3):
            if C[j][i] == a[j] + b[i]:
                pass
            else:
                print('No')
                exit()
    print('Yes')
if __name__ == '__main__':
  main()


# Optimized solution
c = [list(map(int,input().split())) for _ in range(3)]
#print(LIST)
# a1 = 0 とする
a,b= [0,0,0],[0,0,0]
for i in range(3):
    b[i] = c[0][i] - a[0]
for j in range(1,3):
    a[j] = c[j][0] - b[0]
for i in range(1,3):
    for j in range(1,3):
        #print(a,b)
        if c[j][i] == a[j] + b[i]:
            pass
        else:
            print('No')
            exit()
print('Yes')
# Original solution
from itertools import product
c = [tuple(map(int, input().split())) for _ in range(3)]

maxNum = max(max(c))
for i in product(list(range(maxNum+1)),repeat=3):
  if max(i) > maxNum: continue
  for x in range(maxNum+1):
    row1 = (i[0]+x,i[1]+x,i[2]+x)
    if row1 == c[0]:
      for y in range(maxNum+1):
        row2 = (i[0]+y,i[1]+y,i[2]+y)
        if row2 == c[1]:
          for z in range(maxNum+1):
            row3 = (i[0]+z,i[1]+z,i[2]+z)
            if row3 == c[2]:
              print("Yes")
              exit()
print("No")

# Optimized solution
c = [list(map(int, input().split())) for _ in range(3)]

# 斜め同士を足し合わせ比較をする
if c[0][0] + c[1][1] == c[0][1] + c[1][0]:
  if c[0][1] + c[1][2] == c[0][2] + c[1][1]:
    if c[1][0] + c[2][1] == c[1][1] + c[2][0]:
      if c[1][1] + c[2][2] == c[1][2] + c[2][1]:
        print("Yes")
        exit()
print("No")
# Original solution
def main():
    A = [[int(i) for i in input().split()] for j in range(3)]
    from itertools import product
    for a1, a2, a3 in product(range(101), repeat=3):
        c1 = A[0][0] - a1 == A[1][0] - a2 == A[2][0] - a3
        c2 = A[0][1] - a1 == A[1][1] - a2 == A[2][1] - a3
        c3 = A[0][2] - a1 == A[1][2] - a2 == A[2][2] - a3
        if c1 and c2 and c3:
            return print("Yes")
    print("No")


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    A = [[int(i) for i in input().split()] for j in range(3)]
    for i in range(1, 3):
        for j in range(3):
            A[i][j] -= A[0][j]
    if (A[1][0] == A[1][1] == A[1][2]) and (A[2][0] == A[2][1] == A[2][2]):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()
# Original solution
c = [list(map(int,input().split())) for _ in range(3)]

ok = True

lis = [[0,1],[1,2],[2,0]]

d = [[c[l[0]][i]-c[l[1]][i] for i in range(3)]for l in lis]
e = [[c[i][l[0]]-c[i][l[1]] for i in range(3)]for l in lis]

for i in range(3):
    if d[i].count(d[i][0])!=3:
        ok = False
    if e[i].count(e[i][0])!=3:
        ok = False
        
if ok:
    print('Yes')
else:
    print('No')


# Optimized solution
c = [list(map(int,input().split())) for _ in range(3)]
a = [0]*3
b = [0]*3
ok = True

b = c[0]

a[1] = c[1][0]-b[0]
a[2] = c[2][0]-b[0]

for i in range(3):
    for j in range(3):
        if c[i][j]!=a[i]+b[j]:
            ok = False
        
if ok:
    print('Yes')
else:
    print('No')
# Original solution
c = []
for _ in range(3):
    c.append(list(map(int, input().split())))
a = []
for i in range(3):
    tmp = []
    for j in range(3):
        tmp.append(c[i][j%3] - c[i][(j+1)%3])
    a.append(tmp)
for i in range(2):
    for j in range(3):
        if a[i][j]!=a[i+1][j]:
            print('No')
            break
    else:
        continue
    break
else:
    print('Yes')

# Optimized solution
c = []
for _ in range(3):
    c.append(list(map(int, input().split())))

for i in range(2):
    if c[i][0]-c[i][1]!=c[i+1][0]-c[i+1][1]:
        print('No')
        break
    if c[i][1]-c[i][2]!=c[i+1][1]-c[i+1][2]:
        print('No')
        break
    if c[i][2]-c[i][0]!=c[i+1][2]-c[i+1][0]:
        print('No')
        break
else:
    print('Yes')
# Original solution
c=[0]*3
c_max=0
for i in range(3):
    c[i]=list(map(int,input().split()))
    c_max=max(c_max,max(c[i]))
c_max+=1
for a1 in range(c_max):
    for a2 in range(c_max):
        for a3 in range(c_max):
            for b1 in range(c_max):
                for b2 in range(c_max):
                    for b3 in range(c_max):
                        if a1+b1==c[0][0] and a1+b2==c[0][1] and a1+b3==c[0][2] and a2+b1==c[1][0] and a2+b2==c[1][1] and a2+b3==c[1][2] and a3+b1==c[2][0] and a3+b2==c[2][1] and a3+b3==c[2][2]:
                            print('Yes')
                            exit()
print('No')


# Optimized solution
c=[0]*3
c_max=0
for i in range(3):
    c[i]=list(map(int,input().split()))
    c_max=max(c_max,max(c[i]))
c_max+=1
for a1 in range(c_max):
    b1 = c[0][0] - a1
    b2 = c[0][1] - a1
    b3 = c[0][2] - a1
    a2 = c[1][0] - b1
    a3 = c[2][0] - b1
    if a1+b1==c[0][0] and a1+b2==c[0][1] and a1+b3==c[0][2] and a2+b1==c[1][0] and a2+b2==c[1][1] and a2+b3==c[1][2] and a3+b1==c[2][0] and a3+b2==c[2][1] and a3+b3==c[2][2]:
        print('Yes')
        exit()
print('No')
# Original solution
area=[list(map(int,input().split())) for i in range(3)]
count=0
for a1 in range(area[0][0]+1):
  b1=area[0][0]-a1
  b2=area[0][1]-a1
  b3=area[0][2]-a1
  a2=area[1][0]-b1
  a3=area[2][0]-b1
  if b1>=0 and b2>=0 and b3>=0 and a2>=0 and a3>=0:
    if a2+b2== area[1][1]:
      if a2+b3==area[1][2]:
        if a3+b1==area[2][0]:
          if a3+b2==area[2][1]:
            if a3+b3==area[2][2]:
              print('Yes')
              exit()
print('No')

# Optimized solution
C=[list(map(int,input().split())) for i in range(3)]
for a1 in range(101):
  b1=C[0][0]-a1
  b2=C[0][1]-a1
  b3=C[0][2]-a1
  a2=C[1][0]-b1
  a3=C[2][0]-b1
  if b1>=0 and b2>=0 and b3>=0 and a2>=0 and a3>=0:
    if a2+b2==C[1][1]:
      if a2+b2==C[1][1]:
        if a2+b3==C[1][2]:
          if a3+b1==C[2][0]:
            if a3+b2==C[2][1]:
              if a3+b3==C[2][2]:
                print('Yes')
                exit()
print('No')
# Original solution
grid = []
for _ in range(3):
    grid.append((list)(list(map(int, input().split()))))

for i in range(3):
    j = (i+1) % 3
    diff1 = grid[i][0] - grid[j][0]
    diff2 = grid[i][1] - grid[j][1]
    diff3 = grid[i][2] - grid[j][2]

    if diff1 != diff2 or diff2 != diff3 or diff1 != diff3:
        print("No")
        exit()

for i in range(3):
    j = (i+1) % 3
    diff1 = grid[0][i] - grid[0][j]
    diff2 = grid[1][i] - grid[1][j]
    diff3 = grid[2][i] - grid[2][j]

    if diff1 != diff2 or diff2 != diff3 or diff1 != diff3:
        print("No")
        exit()

print("Yes")


# Optimized solution
grid = []
for _ in range(3):
    grid.append((list)(list(map(int, input().split()))))

for i in range(3):
    j = (i+1) % 3
    diff1 = grid[i][0] - grid[j][0]
    diff2 = grid[i][1] - grid[j][1]
    diff3 = grid[i][2] - grid[j][2]

    if diff1 != diff2 or diff2 != diff3:
        print("No")
        exit()

print("Yes")
# Original solution
def main():
    c = [list(map(int, input().split())) for _ in range(3)]
    N = 100
    for i in range(-N, N+1):
        for j in range(-N, N+1):
            for k in range(-N, N+1):
                if c[0][0] - i == c[0][1] - j == c[0][2] - k:
                    if c[1][0] - i == c[1][1] - j == c[1][2] - k:
                        if c[2][0] - i == c[2][1] - j == c[2][2] - k:
                            print('Yes')
                            return
    print('No')
main()

# Optimized solution
a, b, c = list(map(int, input().split()))
d, e, f = list(map(int, input().split()))
g, h, i = list(map(int, input().split()))
if a - b == d - e == g - h and b - c == e - f == h - i:
    print('Yes')
else:
    print('No')
# Original solution
c = [list(map(int, input().split())) for i in range(3)]

q1 = c[0][0] - c[0][1] == c[1][0] - c[1][1] == c[2][0] - c[2][1]
q2 = c[0][0] - c[0][2] == c[1][0] - c[1][2] == c[2][0] - c[2][2]
q3 = c[0][0] - c[1][0] == c[0][1] - c[1][1] == c[0][2] - c[1][2]
q4 = c[0][0] - c[2][0] == c[0][1] - c[2][1] == c[0][2] - c[2][2]

print(("Yes" if q1 and q2 and q3 and q4 else "No"))


# Optimized solution
[(a, b, c), (d, e, f), (g, h, i)] = [
    list(map(int, input().split())) for i in range(3)]

q1 = a - b == d - e== g - h
q2 = a - c == d - f == g - i
q3 = a - d == b - e== c - f
q4 = a - g == b - h == c - i

print(("Yes" if q1 and q2 and q3 and q4 else "No"))
# Original solution
def resolve():
	g = [list(map(int, input().split())) for _ in range(3)]
	t = [[None]*3 for _ in range(3)]
	m = max(list(map(max, g)))
	for a in range(m+1):
		for b in range(m+1):
			for c in range(m+1):
				for d in range(m+1):
					for e in range(m+1):
						for f in range(m+1):
							y = [a, b, c]
							x = [d, e, f]
							ans = True
							for i in range(3):
								for j in range(3):
									if g[i][j] != y[i] + x[j]:
										ans = False
							if ans:
								print('Yes')
								return
	print('No')
resolve()

# Optimized solution
def resolve():
	g = [list(map(int, input().split())) for _ in range(3)]
	m = max(list(map(max, g)))
	for a in range(m+1):
		for b in range(m+1):
			for c in range(m+1):
				y = [a, b, c]
				x = [g[i][i] - y[i] for i in range(3)]
				ans = True
				for i in range(3):
					for j in range(3):
						v = y[i] + x[j]
						if g[i][j] != v:
							ans = False
				if ans:
					print('Yes')
					return

	print('No')
resolve()
# Original solution
c = [list(map(int, input().split())) for i in range(3) ]

ans = False

for i in range(101) :
    for j in range(101) :
        for k in range(101) :
            b1 = c[0][0] - i
            b2 = c[1][0] - i
            b3 = c[2][0] - i
            if j + b1 != c[0][1] :
                continue
            elif j + b2 != c[1][1] :
                continue
            elif j + b3 != c[2][1] :
                continue
            elif k + b1 != c[0][2] :
                continue
            elif k + b2 != c[1][2] :
                continue
            elif k + b3 != c[2][2] :
                continue
            ans = True

if ans :
    print('Yes')
else :
    print('No')


# Optimized solution
c = [list(map(int, input().split())) for i in range(3) ]

ans = False

for i in range(101) :
    a1 = 0
    b1 = c[0][0]
    b2 = c[0][1]
    b3 = c[0][2]
    a2 = c[1][0] - b1
    a3 = c[2][0] - b1
    a = []
    a.append(a1)
    a.append(a2)
    a.append(a3)
    if a2 + b2 != c[1][1] :
        continue
    elif a3 + b2 != c[2][1] :
        continue
    elif a2 + b3 != c[1][2] :
        continue
    elif a3 + b3 != c[2][2] :
        continue
    ans = True
    break

if ans :
    print('Yes')
else :
    print('No')
# Original solution
c = [list(map(int, input().split())) for i in range(3) ]

ans = False

for i in range(101) :
    a1 = 0
    b1 = c[0][0]
    b2 = c[0][1]
    b3 = c[0][2]
    a2 = c[1][0] - b1
    a3 = c[2][0] - b1
    a = []
    a.append(a1)
    a.append(a2)
    a.append(a3)
    if a2 + b2 != c[1][1] :
        continue
    elif a3 + b2 != c[2][1] :
        continue
    elif a2 + b3 != c[1][2] :
        continue
    elif a3 + b3 != c[2][2] :
        continue
    ans = True
    break

if ans :
    print('Yes')
else :
    print('No')


# Optimized solution
c = [list(map(int, input().split())) for i in range(3) ]

ans = True

X = 0
b = [c[i][0] - X for i in range(3)]
a = [c[0][i] - b[0] for i in range(3)]

for i in range(3) :
    for j in range(3) :
        if a[j] + b[i] != c[i][j] :
            ans = False

if ans :
    print('Yes')
else :
    print('No')
# Original solution
from itertools import product

C = [0 for _ in range(3)]
for i in range(3):
    C[i] = list(map(int, input().split()))

x = [0] * 3
y = [0] * 3
for i in range(3):
    y[i] = C[0][i] - x[0]
    x[i] = C[i][0] - y[0]

ans = 'Yes'
for i, j in product(list(range(3)), list(range(3))):
    if(x[i] + y[j] != C[i][j]):
        ans = 'No'
        break
print(ans)


# Optimized solution
C = [[int(x) for x in input().split()] for _ in range(3)]

a = [0] * 3
b = [0] * 3
for i in range(3):
    b[i] = C[0][i] - a[0]
    a[i] = C[i][0] - b[0]

ans = 'Yes'
for i in range(3):
    for j in range(3):
        if C[i][j] != a[i] + b[j]:
            ans = 'No'
            break
print(ans)