Problem:
 Score: 300 points    Problem Statement  We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j) , where (i, j) denotes the square at the i -th row from the top and the j -th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j . Determine if he is correct.      Constraints   c_{i, j} \ (1 \leq i \leq 3, 1 \leq j \leq 3) is an integer between 0 and 100 (inclusive).         Input  Input is given from Standard Input in the following format:  c_{1,1}  c_{1,2}  c_{1,3}  c_{2,1}  c_{2,2}  c_{2,3}  c_{3,1}  c_{3,2}  c_{3,3}       Output  If Takahashi's statement is correct, print Yes ; otherwise, print No .        Sample Input 1 1 0 1
2 1 2
1 0 1      Sample Output 1 Yes  Takahashi is correct, since there are possible sets of integers such as: a_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1 .       Sample Input 2 2 2 2
2 1 2
2 2 2      Sample Output 2 No  Takahashi is incorrect in this case.       Sample Input 3 0 8 8
0 8 8
0 8 8      Sample Output 3 Yes       Sample Input 4 1 8 6
2 9 7
0 7 7      Sample Output 4 No

Solution (Python):
import sys

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

c = []
for _ in range(3):
    c.append(LI())
a1_range = min(c[0])
for a1 in range(a1_range+1):
    a = [0]*3
    b = [0]*3
    a[0] = a1
    b[0] = c[0][0] - a[0]
    b[1] = c[0][1] - a[0]
    b[2] = c[0][2] - a[0]
    a[1] = c[1][0] - b[0]
    a[2] = c[2][0] - b[0]
    flag = True
    for i in range(3):
        for j in range(3):
            if c[i][j] != a[i] + b[j]:
                flag = False
                break
        if not flag:
            break
    if flag:
        print("Yes")
        sys.exit()
print("No")

Solution (Python):
c1,c2,c3=map(int,input().split())
c4,c5,c6=map(int,input().split())
c7,c8,c9=map(int,input().split())

if c7-c4==c8-c5==c9-c6 and c4-c1==c5-c2==c6-c3 and c3-c2==c6-c5==c9-c8 and c2-c1==c5-c4==c8-c7:
    print("Yes")
else:
    print("No")

Solution (Python):
"""
・全探索してもよい
・ある値（例えばa1）を決めたら他の値は全部決まってしまう
→ a1に適当な値を入れて後は全部できているかチェックすればよい
"""
import sys

c = [[int(i) for i in input().split()] for j in range(3)]
a = [0] * 3
b = [0] * 3

max_val = 100


a[0] = 0


b[0] = c[0][0] - a[0]
b[1] = c[0][1] - a[0]
b[2] = c[0][2] - a[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):
        left = a[i] + b[j]
        right = c[i][j]
        
        if(left != right):
            ans = False
            print("No")
            sys.exit()


print("Yes")

Solution (Python):
import copy

line = [[int(i) for i in input().split()] for _ in range(3)]
ansB = copy.copy(line[0])
ansA = [0, line[1][0]-ansB[0], line[2][0]-ansB[0]]

for i in range(1, 3):
    for j in range(1, 3):
        if ansA[i] + ansB[j] != line[i][j]:
            print("No")
            exit()

print("Yes")

Solution (Python):
import numpy as np
from itertools import product
import sys
read = sys.stdin.buffer.read


C = np.array(read().split(), np.int32).reshape(3, 3)

a, b, c = np.max(C + 1, axis=1)
N = []
for i, j in product(range(a), range(b)):
    x = C[0, :] - i
    y = C[1, :] - j

    if np.all(x == y):
        N.append(x)

flag = 0
z = C[2, :]
for n in N:
    for k in range(c):
        if np.all(z - k == n):
            flag = 1
            break
    
    if flag:
        break

print(['No', 'Yes'][flag])

Solution (Python):
c = [list(map(int,input().split())) for _ in range(3)]
a = []
b = []
for i in range(3):
    a.append(abs(c[i][0]-c[i][1]))
    a.append(abs(c[i][1]-c[i][2]))
for i in range(3):
    b.append(abs(c[0][i]-c[1][i]))
    b.append(abs(c[1][i]-c[2][i]))
if a[0] == a[2] and a[2] == a[4] and b[0] == b[2] and b[2] == b[4] \
    and a[1] == a[3] and a[3] == a[5] and b[1] == b[3] and b[3] == b[5]:
    print('Yes')
    exit()
print('No')

Solution (Python):
c = [list(map(int, input().split())) for _ in range(3)]

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

flag = True
for i in range(3):
  for j in range(3):
    if c[i][j] != a[i] + b[j]:
      flag = False
      
print("Yes" if flag else "No")

Solution (Python):
c = [list(map(int, input().split())) for _ in range(3)]

for a1 in range(min(c[0])+1):
    for a2 in range(min(c[1])+1):
        for a3 in range(min(c[2])+1):
            b1 = c[0][0] - a1
            b2 = c[0][1] - a1
            b3 = c[0][2] - a1

            if c[1][0] == a2+b1 and c[1][1] == a2 + b2  and c[1][2] == a2 + b3 and c[2][0] == a3+b1 and c[2][1] == a3 + b2  and c[2][2] == a3 + b3:
                print('Yes')
                exit()
print('No')

Solution (Python):
C1 = list(map(int,input().split()))
C2 = list(map(int,input().split()))
C3 = list(map(int, input().split()))

if C1[1] - C1[0] == C2[1] - C2[0] == C3[1] - C3[0] and C1[2] - C1[1] == C2[2] - C2[1] == C3[2] - C3[1] :
  if C2[0] - C1[0] == C2[1] - C1[1] == C2[2] - C1[2] and C3[0] - C2[0] == C3[1] - C2[1] == C3[2] - C2[2]:
    print("Yes")
  else:
    print("No")
  
else:
  print("No")

Solution (Python):
apple = []
for _ in range(3):
    apple.append(list(map(int, input().split())))
a = apple[0]
b = apple[1]
c = apple[2]
if a[0]-a[1]==b[0]-b[1]==c[0]-c[1] and a[0]-a[2]==b[0]-b[2]==c[0]-c[2] and a[1]-a[2]==b[1]-b[2]==c[1]-c[2]:
    if a[0]-b[0]==a[1]-b[1]==a[2]-b[2] and a[0]-c[0]==a[1]-c[1]==a[2]-c[2] and c[0]-b[0]==c[1]-b[1]==c[2]-b[2]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
import sys

c = [input().split() for i in range(3)]
num = [int(c[i][j]) for i in range(3) for j in range(3)]

if num[0] + num[4] != num[1] + num[3]:
    print('No')
    sys.exit()
elif num[4] + num[8] != num[5] + num[7]:
    print('No')
    sys.exit()
elif num[0] + num[8] != num[2] + num[6]:
    print('No')
    sys.exit()

print('Yes')

Solution (Python):
import sys
C11,C12,C13 = map(int, input().split())
C21,C22,C23 = map(int, input().split())
C31,C32,C33 = map(int, input().split())





if (C11+C22==C12+C21) and (C12+C23==C13+C22) and (C21+C32==C22+C31) and (C22+C33==C23+C32):
    print('Yes')
    sys.exit()


print("No")

Solution (Python):
c = [[int(i) for i in input().split()] for _ in range(3)]

if c[0][0] + c[1][1] != c[0][1] + c[1][0] :
    print('No')
    exit()
if c[0][1] + c[1][2] != c[0][2] + c[1][1] :
    print('No')
    exit()
if c[1][0] + c[2][1] != c[2][0] + c[1][1] :
    print('No')
    exit()
if c[1][1] + c[2][2] != c[2][1] + c[1][2] :
    print('No')
    exit()

print('Yes')

Solution (Python):
import numpy as np
C= [[0] * 3 for i in range(3)]
for i in range(3):
  C[i]=list(map(int, input().split()))
C=np.array(C)
answer='Yes'
 
S=C.sum()
trace=np.diag(C).sum()
S_row0=C[0,:].sum()
S_row1=C[1,:].sum()
S_row2=C[2,:].sum()

S_col0=C[:,0].sum()
S_col1=C[:,1].sum()
S_col2=C[:,2].sum()

if S != 3*trace:
  answer = 'No'
elif S_row0-3*C[0,0] != trace-S_col0:
  answer = 'No'
elif S_row1-3*C[1,0] != trace-S_col0:
  answer = 'No'



print(answer)

Solution (Python):
import sys
c=[list(map(int,input().split())) for _ in range(3)]

for i in range(min(c[0])+1):
  b=[c[0][k]-i for k in range(3)]
  a=[c[i][0]-b[0] for i in range(3)]
  for i in range(1,3):
    if c[i][1]!=a[i]+b[1] or c[i][2]!=a[i]+b[2]:
        break
  else:
    print('Yes')
    sys.exit()
print('No')

Solution (Python):
c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())

ans = 'No'





for i in range(c11+1):
  a1 = i
  b1 = c11 - a1
  a2 = c21 - b1
  b2 = c12 - a1
  a3 = c31 - b1
  b3 = c13 - a1
  
  
  
  if (a2+b2 == c22) and (a2+b3 == c23) and (a3+b2 == c32) and (a3+b3 == c33):
    ans = 'Yes'
    break
print(ans)

Solution (Python):
C=[]
for _ in range(3):
    a = list(map(int, input().split()))
    b = min(a)
    for i in range(3):
        a[i] -= b
    C.append(a)
if C[0] == C[1] == C[2]:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
import numpy as np
input = sys.stdin.readline

 
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TL(mylist):
    return np.array(mylist).T.tolist()

mylist1 = [list(map(int, input().rstrip().split())) for i in range(3)]
mylist2 = TL(mylist1)

def chech(mylist):
    result = True
    b1 = mylist[0][0] - mylist[0][1]
    c1 = mylist[0][0] - mylist[0][2]
    for i in range(1, 3):
        if (mylist[i][0] -  mylist[i][1]) != b1 or (mylist[i][0] -  mylist[i][2]) != c1:
            result = False
            break
    return result
    
if chech(mylist1) and chech(mylist2):
    print("Yes")
else:
    print("No")

Solution (Python):
C=[]
for _ in range(3):
    a=list(map(int,input().split()))
    b=min(a)
    for i in range(3):
        a[i]-=b
    C.append(a)
if C[0]==C[1] and C[1]==C[2] and C[0]==C[2]:
    print("Yes")
else:
    print("No")

Solution (Python):
grid = []
for i in range(3):
    grid.append(list(map(int, input().split())))
b = grid[0]
a = (0, grid[1][1]-b[1], grid[2][2]-b[2])

for i in range(3):
    for j in range(3):
        if a[i]+b[j] != grid[i][j]:
            print('No')
            exit(0)

print('Yes')

Solution (Python):
C = [[int(_) for _ in input().split()] for _ in range(3)]

B = C[0]
A = (0, C[1][1] - B[1], C[2][2] - B[2])

for i in range(3):
    for j in range(3):
        v = A[i] + B[j]
        if not v == C[i][j]:
            print("No")
            exit(0)
print("Yes")

Solution (Python):
C = []
for _ in range(3):
    c = list(map(int, input().split()))
    C.append(c)

ans = 'Yes'
for i in range(2):
    d = C[2][i+1] - C[2][i]
    for j in range(2):
        if C[j][i+1] - C[j][i] != d:
            ans = 'No'
print(ans)

Solution (Python):
c = [[int(i) for i in input().split()] for j in range(3)]
f = True
a, b = c[0][0] - c[0][1], c[0][1] - c[0][2]
for i in range(1, 3):
    if not(c[i][0] - c[i][1] == a and c[i][1] - c[i][2] == b):
        f = False
a, b = c[0][0] - c[1][0], c[1][0] - c[2][0]
for i in range(1, 3):
    if not(c[0][i] - c[1][i] == a and c[1][i] - c[2][i] == b):
        f = False
print("Yes" if f else "No")

Solution (Python):
c = [list(map(int, input().split())) for _ in range(3)]
a = [0, 0, 0]
b = [0, 0, 0]
b[0] = c[0][0] - a[0]
b[1] = c[0][1] - a[0]
b[2] = c[0][2] - a[0]
a[1] = c[1][0] - b[0]
a[2] = c[2][0] - b[0]

cnt = 0
for i in range(3):
    for j in range(3):
        if c[i][j] == a[i]+b[j]:
            cnt += 1

print('Yes' if cnt == 9 else 'No')

Solution (Python):
c = [list(map(int, input().split())) for _ in range(3)]
a = [0] * 3
b = [0] * 3
b[0] = c[0][0]
for i in range(1, 3):
    a[i] = c[i][0] - b[0]
for i in range(1, 3):
    b[i] = c[0][i] - a[0]
for i in range(3):
    for j in range(3):
        if a[i] + b[j] != c[i][j]:
            print('No')
            exit(0)
print('Yes')

Solution (Python):
def main():

    c = [list(map(int, input().split())) for _ in range(3)]
    if (c[0][0]-c[1][0]) != (c[0][1]-c[1][1]) or (c[0][0]-c[1][0]) != (c[0][2]-c[1][2]) or (c[0][1]-c[1][1]) != (c[0][2]-c[1][2]):
        print('No')
        return

    if (c[1][0]-c[2][0]) != (c[1][1]-c[2][1]) or (c[1][0]-c[2][0]) != (c[1][2]-c[2][2]) or (c[1][1]-c[2][1]) != (c[1][2]-c[2][2]):
        print('No')
        return

    if (c[0][0]-c[2][0]) != (c[0][1]-c[2][1]) or (c[0][0]-c[2][0]) != (c[0][2]-c[2][2]) or (c[0][1]-c[2][1]) != (c[0][2]-c[2][2]):
        print('No')
        return

    if (c[0][0]-c[0][1]) != (c[1][0]-c[1][1]) or (c[0][0]-c[0][1]) != (c[2][0]-c[2][1]) or (c[1][0]-c[1][1]) != (c[2][0]-c[2][1]):
        print('No')
        return

    if (c[0][0]-c[0][2]) != (c[1][0]-c[1][2]) or (c[0][0]-c[0][2]) != (c[2][0]-c[2][2]) or (c[1][0]-c[1][2]) != (c[2][0]-c[2][2]):
        print('No')
        return

    if (c[0][1]-c[0][2]) != (c[1][1]-c[1][2]) or (c[0][1]-c[0][2]) != (c[2][1]-c[2][2]) or (c[1][1]-c[1][2]) != (c[2][1]-c[2][2]):
        print('No')
        return

    print('Yes')

main()

Solution (Python):
def main():
    G = [[int(x) for x in input().split()] for _ in range(3)]

    def is_ok(rs, cs):
        for r, ri in enumerate(rs, start=1):
            for c, ci in enumerate(cs):
                if G[r][c] != ri + ci:
                    return False
        return True

    for r0 in range(G[0][0] + 1):
        c0 = G[0][0] - r0
        c1 = G[0][1] - r0
        c2 = G[0][2] - r0

        r1 = G[1][0] - c0
        r2 = G[2][0] - c0

        rs = (r1, r2)
        cs = (c0, c1, c2)
        if is_ok(rs, cs):
            print('Yes')
            return

    print('No')


if __name__ == '__main__':
    main()

Solution (Python):
def l(): return list(map(int, input().split()))
def m(): return map(int, input().split())

def main():
  c = [0]*3
  for i in range(3):
    c[i] = l()
  
  
  
  
  
  
  

  a = [0]*3
  b = [0]*3
  b[0] = min(c[0])
  for i in range(3):
    a[i] = c[0][i] - b[0]
  for i in range(1,3):
    b[i] = c[i][0] - a[0]
  
  for i in range(3):
    for j in range(3):
      if c[i][j] != a[j] + b[i]:
        print('No')
        exit()
  print('Yes')

  
if __name__ == '__main__':
  main()

Solution (Python):
def l(): return list(map(int, input().split()))
def m(): return map(int, input().split())

def main():
  c = [0]*3
  for i in range(3):
    c[i] = l()
  for i in range(2):
    x = c[2][i+1] - c[2][i]
    for j in range(2):
      if c[j][i+1] - c[j][i] != x:
        print('No')
        exit()
  print('Yes')

  
if __name__ == '__main__':
  main()

Solution (Python):
li = [list(map(int,input().split())) for i in range(3)]
ans = li[0]

for i in li:
    for j in range(-100,102):
        if j == 101:
            print("No")
            exit()
        if [i+j for i in ans] == i:
            break

print("Yes")

Solution (Python):
C=[list(map(int,input().split()))for _ in range(3)]
ans='Yes'

if C[1][0]-C[0][0]!=C[1][1]-C[0][1]:
    ans='No'
elif C[1][2]-C[0][2]!=C[1][1]-C[0][1]:
    ans='No'
elif C[2][0]-C[1][0]!=C[2][1]-C[1][1]:
    ans='No'
elif C[2][2]-C[1][2]!=C[2][1]-C[1][1]:
    ans='No'

print(ans)

Solution (Python):
C=[list(map(int,input().split())) for i in range(3)]
a1=0
b=C[0]
a=[C[i][0]-b[0] for i in range(3)]
for i in range(3):
    for j in range(3):
        if C[i][j]!=a[i]+b[j]:
            print("No")
            exit()
print("Yes")

Solution (Python):
c = [list(map(int, input().split())) for _ in range(3)]

for i in range(2):
  if c[0][i+1]-c[0][i] != c[1][i+1]-c[1][i]:
    print('No')
    exit()
  if c[0][i+1]-c[0][i] != c[2][i+1]-c[2][i]:
    print('No')
    exit()
  if c[i+1][0]-c[i][0] != c[i+1][1]-c[i][1]:
    print('No')
    exit()
  if c[i+1][0]-c[i][0] != c[i+1][2]-c[i][2]:
    print('No')
    exit()
    
print('Yes')

Solution (Python):
C = [list(map(int, input().split())) for i in range(3)]
A = []
B = []
for i in range(3):
  A.append([C[0][i] - C[1][i], C[1][i] - C[2][i], C[2][i] - C[0][i]])
for i in range(3):
  B.append([C[i][0] - C[i][1], C[i][1] - C[i][2], C[i][2] - C[i][0]])
ans = 'Yes'
if A[0] != A[1]:
  ans = 'No'
elif A[1] != A[2]:
  ans = 'No'
elif B[0] != B[1]:
  ans = 'No'
elif B[1] != B[2]:
  ans = 'No'
print(ans)

Solution (Python):
C=list(list(map(int,input().split())) for i in range(3))
for a in range(3):
    if (C[a][0]-C[a][1]!=C[0][0]-C[0][1] or C[a][1]-C[a][2]!=C[0][1]-C[0][2]):
        print("No")
        exit()
for b in range(3):
    if (C[0][b]-C[1][b]!=C[0][0]-C[1][0] or C[1][b]-C[2][b]!=C[1][0]-C[2][0]):
        print("No")
        exit()
print("Yes")

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    c0=list(map(int,input().split()))
    c1=list(map(int,input().split()))
    c2=list(map(int,input().split()))
    a=[0]*3
    b=[0]*3
    b[0]=c0[0]
    b[1]=c1[0]
    b[2]=c2[0]
    a[1]=c0[1]-b[0]
    a[2]=c0[2]-b[0]
    if a[1]+b[1]==c1[1] and a[1]+b[2]==c2[1] and\
            a[2]+b[1]==c1[2] and a[2]+b[2]==c2[2]:
        print('Yes')
    else:
        print('No')

resolve()

Solution (Python):
l = list(list(map(int,input().split())) for i in range(3))
first = l[0][0]-l[0][1]
second = l[0][1]-l[0][2]
first1 = l[0][0]-l[1][0]
second2 = l[1][0]-l[2][0]

for k in range(3):
    if (l[k][0]-l[k][1] != first or l[k][1]-l[k][2] != second):
        print("No")
        exit()
for j in range(3):
    if (l[0][k]-l[1][k] != first1  or l[1][k]-l[2][k] != second2):
        print("No")
        exit()     
print("Yes")

Solution (Python):
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))

for b1 in range(101):
    for b2 in range(101):
        for b3 in range(101):
            if c1[0] - b1 == c1[1] - b2 == c1[2] - b3:
                if c2[0] - b1 == c2[1] - b2 == c2[2] - b3:
                    if c3[0] - b1 == c3[1] - b2 == c3[2] - b3:
                        print("Yes")
                        exit()
else:
    print("No")

Solution (Python):

c1 = tuple(map(int,input().split()))
c2 = tuple(map(int,input().split()))
c3 = tuple(map(int,input().split()))

q = 0

adif = [c1[1]-c1[0],c1[2]-c1[1]]

bdif1 = int(c2[0]-c1[0])

bdif2 = int(c3[0]-c2[0])

acnt = 0

bdif = 0

if c2[1]-c2[0] != adif[0]:
    q = 1
    
if c2[2]-c2[1] != adif[1]:
    q = 1
    
if c3[1]-c3[0] != adif[0]:
    q = 1
    
if c3[2]-c3[1] != adif[1]:
    q = 1
    
if int(c2[1]-c1[1]) != bdif1:
    q = 1
    
if c2[2]-c1[2] != bdif1:
    q = 1
    
if c3[1]-c2[1] != bdif2:
    q = 1
    
if c3[2]-c2[2] != bdif2:
    q = 1
    
if q == 1:
    print("No")
else:
    print("Yes")

Solution (Python):
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
if (sum(A)+sum(B)+sum(C))/3 == A[0]+B[1]+C[2] == A[2]+B[1]+C[0]:
    print('Yes')
else:
    print('No')

Solution (Python):
c = [list(map(int,input().split())) for i in range(3)]
a = [0]*3
b = [0]*3
b[0] = c[0][0]
b[1] = c[0][1]
b[2] = c[0][2]
a[1] = c[1][1]-b[1]
a[2] = c[2][2]-b[2]

for i in range(3):
    for j in range(3):
        if c[i][j] != a[i]+b[j]:
            print("No")
            exit()
print("Yes")

Solution (Python):
C = [list(map(int,input().split())) for _ in range(3)]
if C[1][0]-C[0][0]==C[1][1]-C[0][1]==C[1][2]-C[0][2] and C[2][0]-C[0][0]==C[2][1]-C[0][1]==C[2][2]-C[0][2] \
and C[0][1]-C[0][0]==C[1][1]-C[1][0]==C[2][1]-C[2][0] and C[0][2]-C[0][0]==C[1][2]-C[1][0]==C[2][2]-C[2][0]:
    print("Yes")
else:
    print("No")

Solution (Python):
A = []
for i in range(3):
  temp = list(map(int,input().split()))
  A.append(temp)

if A[0][0]+A[1][1] == A[0][1]+A[1][0] and \
A[0][1]+A[1][2] == A[0][2]+A[1][1] and \
A[1][0]+A[2][1] == A[1][1]+A[2][0] and \
A[1][1]+A[2][2] == A[1][2]+A[2][1]:
  print("Yes")
else:
  print("No")

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    A = [0] * 3
    B = [0] * 3
    for i in range(3):
        B[i] = C[0][i] - A[0]

    for j in range(3):
        A[j] = C[j][0] - B[0]

    for i in range(3):
        for j in range(3):
            if A[i] + B[j] != C[i][j]:
                print("No")
                break
        else:
            continue
        break
    else:
        print("Yes")


if __name__ == '__main__':
    resolve()

Solution (Python):
c = [list(map(int, input().split())) for _ in range(3)]
dif_1 = c[0][1] - c[0][0]
dif_2 = c[0][2] - c[0][1]
dif_3 = c[1][0] - c[0][0]
dif_4 = c[2][0] - c[1][0]

if c[1][1] - c[1][0] != dif_1 or c[2][1] - c[2][0] != dif_1:
    print("No")
    exit()
elif c[1][2] - c[1][1] != dif_2 or c[2][2] - c[2][1] != dif_2:
    print("No")
    exit()
elif c[1][1] - c[0][1] != dif_3 or c[1][2] - c[0][2] != dif_3:
    print('No')
    exit()
elif c[2][2] - c[1][2] != dif_4 or c[2][1] - c[1][1] != dif_4:
    print('No')
    exit()
print('Yes')

Solution (Python):
c1,c2,c3=map(int,input().split())
c4,c5,c6=map(int,input().split())
c7,c8,c9=map(int,input().split())
k=c2-c1
failflag=0
if (c5-c4)!=k or (c8-c7)!=k:
  failflag=1
k=c3-c2
if (c6-c5)!=k or (c9-c8)!=k:
  failflag=1
k=c4-c1
if (c5-c2)!=k or (c6-c3)!=k:
  failflag=1
k=c7-c4
if (c8-c5)!=k or (c9-c6)!=k:
  failflag=1
if failflag==0:
  print('Yes')
else:
  print('No')

Solution (Python):
c1,c2,c3=map(int,input().split())
c4,c5,c6=map(int,input().split())
c7,c8,c9=map(int,input().split())
if c3-c2==c6-c5 and c6-c5==c9-c8 and c2-c1==c5-c4 and c5-c4==c8-c7 and c4-c1==c5-c2 and c5-c2==c6-c3 and c7-c4==c8-c5 and c8-c5==c9-c6:
    print("Yes")
else:
    print("No")

Solution (Python):
c = [list(map(int,input().split())) for x in range(3)]

a = [0]*3
b = [0]*3

for i in range(3):
    b[i] = c[0][i] - a[0]
a[1] = c[1][1] - b[1]
a[2] = c[2][2] - b[2]

for i in range(3):
    for j in range(3):
        if c[i][j] != a[i]+b[j]:
            print('No')
            exit()

print('Yes')

Solution (Python):
c=[list(map(int,input().split())) for i in range(3)]
for i in range(min(c[0])+1):
  b1=c[0][0]-i
  b2=c[0][1]-i
  b3=c[0][2]-i
  if c[1][0]-b1==c[1][1]-b2==c[1][2]-b3:
    if c[2][0]-b1==c[2][1]-b2==c[2][2]-b3:
      print("Yes")
      break
    else:
      continue
  else:
    continue
else:
  print("No")

Solution (Python):

grid = [list(map(int,input().split())) for _ in range(3)]
flg = True
b1 = grid[0][0]
b2 = grid[0][1]
b3 = grid[0][2]
if grid[1][0] - b1 == grid[1][1] - b2 == grid[1][2] - b3:
    a2 = grid[1][0] - b1
else:
    flg = False
if grid[2][0] - b1 == grid[2][1] - b2 == grid[2][2] - b3:
    a3 = grid[2][0] - b1
else:
    flg = False
    
if flg:
    print('Yes')
else:
    print('No')

Solution (Python):
c = [list(map(int, input().split())) for _ in range(3)]
if c[0][1]-c[0][0]!=c[1][1]-c[1][0]:
    print("No")
    exit()
if c[0][2]-c[0][0]!=c[1][2]-c[1][0]:
    print("No")
    exit()
if c[0][2]-c[0][1]!=c[1][2]-c[1][1]:
    print("No")
    exit()
if c[0][1]-c[0][0]!=c[2][1]-c[2][0]:
    print("No")
    exit()
if c[0][2]-c[0][0]!=c[2][2]-c[2][0]:
    print("No")
    exit()
if c[0][2]-c[0][1]!=c[2][2]-c[2][1]:
    print("No")
    exit()
    
if c[1][0]-c[0][0]!=c[1][1]-c[0][1]:
    print("No")
    exit()
if c[2][0]-c[0][0]!=c[2][1]-c[0][1]:
    print("No")
    exit()
if c[2][0]-c[1][0]!=c[2][1]-c[1][1]:
    print("No")
    exit()
if c[1][0]-c[0][0]!=c[1][2]-c[0][2]:
    print("No")
    exit()
if c[2][0]-c[0][0]!=c[2][2]-c[0][2]:
    print("No")
    exit()
if c[2][0]-c[1][0]!=c[2][2]-c[1][2]:
    print("No")
    exit() 
  
print("Yes")

Solution (Python):
s=[]
yoko=[]
ans="Yes"
for i in range(3):
  a, b, c=map(int, input().split())
  s.append([a,b,c])
  yoko.append([a-b, b-c, c-a])
if yoko[0]!=yoko[1] or yoko[1]!=yoko[2]:
  ans="No"
tate=[]
for i in range(3):
  tate.append([s[i][0]-s[i][1], s[i][1]-s[i][2], s[i][2]-s[i][0]])
if tate[0]!=tate[1] or tate[1]!=tate[2]:
  ans="No"
print(ans)

Solution (Python):
c11,c12,c13=list(map(int,input().split()))
c21,c22,c23=list(map(int,input().split()))
c31,c32,c33=list(map(int,input().split()))
for i in range(min(c11,c12,c13)+1):
  t1=c11-i
  t2=c12-i
  t3=c13-i
  if c21-t1==c22-t2 and c21-t1==c23-t3 and c31-t1==c32-t2 and c31-t1==c33-t3:
    print("Yes")
    break
else:
  print("No")

Solution (Python):
def main():
    c = [list(map(int, input().split())) for _ in range(3)]
    s1 = c[0][0] + c[1][1] + c[2][2]
    s2 = c[1][0] + c[2][1] + c[0][2]
    s3 = c[2][0] + c[0][1] + c[1][2]
    s4 = c[0][0] + c[1][2] + c[2][1]
    s5 = c[1][0] + c[2][2] + c[0][1]
    s6 = c[2][0] + c[0][2] + c[1][1]
    
    if s1 == s2 == s3 == s4 == s5 == s6:
        print('Yes')
    else:
        print('No')
    
    
if __name__ == '__main__':
    main()

Solution (Python):
r=range
M=[list(map(int,input().split())) for _ in r(3)]
for i in r(2):
  x=M[0][i]-M[0][i+1]
  y=M[i][0]-M[i+1][0]
  for j in r(3):
    if x!=M[j][i]-M[j][i+1] or y!=M[i][j]-M[i+1][j]:
      print('No')
      exit()
print('Yes')

Solution (Python):
c = [[int(i) for i in input().split()] for _ in range(3)]
x = 0
for i in range(2):
    if c[0][i] - c[0][i + 1] == c[1][i] - c[1][i + 1] == c[2][i] - c[2][i + 1]:
        x += 1
for i in range(2):
    if c[i][0] - c[i + 1][0] == c[i][1] - c[i + 1][1] == c[i][2] - c[i + 1][2]:
        x += 1
if x == 4:
    print("Yes")
else:
    print("No")

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

if c[0][0]+c[1][0]-2*c[2][0]+c[0][1]+c[1][1]-2*c[2][1]-2*c[0][2]-2*c[1][2]+4*c[2][2] == 0:
  print("Yes")
else:
  print("No")

Solution (Python):
C = [list(map(int, input().split())) for _ in range(3)]
if sum(sum(row) for row in C) == 3 * sum(C[i][i] for i in range(3)):
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

if __name__  == "__main__":
    c1 = list(map(int,input().split()))
    c2 = list(map(int,input().split()))
    c3 = list(map(int,input().split()))
    a1 = 0
    b1 = c1[0]
    b2 = c1[1]
    b3 = c1[2]
    b = [b1,b2,b3]
    a2 = c2[0] - b1 
    for i in range(3):
        d = c2[i] - b[i]
        if a2 != d:
            print("No")
            sys.exit()
    a3 = c3[0] - b1
    for i in range(3):
        d = c3[i] - b[i]
        if a3 != d:
            print("No")
            sys.exit()
    print("Yes")

Solution (Python):
cmatrix = []
for i in range(3):
  cmatrix.append(list(map(int, input().split())))
  
if(cmatrix[0][0]+ cmatrix[1][1] == cmatrix[0][1]+ cmatrix[1][0] and \
  cmatrix[0][1]+ cmatrix[1][2] == cmatrix[0][2]+ cmatrix[1][1] and \
  cmatrix[1][0]+ cmatrix[2][1] == cmatrix[1][1]+ cmatrix[2][0] and \
  cmatrix[1][1]+ cmatrix[2][2] == cmatrix[1][2]+ cmatrix[2][1]):
  print("Yes")
else:
  print("No")

Solution (Python):
m = [[0 for i in range(3)] for j in range(3)]
for i in range(3):
    m[i] = list(map(int, input().split()))

a1 = a2 = a3 = 0
b1, b2, b3 = m[0]
a2 = m[1][0] - b1
a3 = m[2][0] - b1

if ((m[1][1] != a2 + b2) or
    (m[1][2] != a2 + b3) or
    (m[2][1] != a3 + b2) or
    (m[2][2] != a3 + b3)):
    print('No')
else:
    print('Yes')

Solution (Python):
def solve(c1_list, c2_list, c3_list):

    a1 = 0
    ans = "No"
    while a1 <= 100:
        b_list = [c - a1 for c in c1_list]

        a2 = len(set([c - b for c, b in zip(c2_list, b_list)]))
        a3 = len(set([c - b for c, b in zip(c3_list, b_list)]))

        if a2 == 1 and a3 == 1:
            ans = "Yes"
            break
        else:
            a1 += 1

    return ans

if __name__ == "__main__":
    c1_list = [int(i) for i in input().split()]
    c2_list = [int(i) for i in input().split()]
    c3_list = [int(i) for i in input().split()]
    print(solve(c1_list, c2_list, c3_list))

Solution (Python):
A = [tuple(map(int, input().split())) for i in range(3)]
for x, y in zip(A, A[1:]):
	if not (y[0] - x[0] == y[1] - x[1] == y[2] - x[2]):
		print("No")
		exit()
for x in range(2):
	if not (A[0][x+1] - A[0][x] == A[1][x+1] - A[1][x] == A[2][x+1] - A[2][x]):
		print("No")
		exit()
if A[0][0] + A[2][2] != A[0][2] + A[2][0]:
	print("No")
	exit()
print("Yes")

Solution (Python):
def main():
    a = [list(map(int, input().split())) for i in range(3)]
    if (a[1][0] - a[0][0] == a[1][1] - a[0][1]) \
        and (a[1][1] - a[0][1] == a[1][2] - a[0][2]) \
        and (a[2][0] - a[1][0] == a[2][1] - a[1][1]) \
        and (a[2][1] - a[1][1] == a[2][2] - a[1][2]) \
        and (a[0][1] - a[0][0] == a[1][1] - a[1][0]) \
        and (a[1][1] - a[1][0] == a[2][1] - a[2][0]) \
        and (a[0][2] - a[0][1] == a[1][2] - a[1][1]) \
        and (a[1][2] - a[1][1] == a[2][2] - a[2][1]):
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    main()

Solution (Python):
c = [list(map(int, input().split())) for i in range(3)]
s = sum([sum(l) for l in c])
print('Yes' if s/3 == c[0][0] + c[1][1] + c[2][2] else 'No')

Solution (Python):
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
b = [0]*3
b[0] = c1[0]
b[1] = c1[1]
b[2] = c1[2]
C = c1+c2+c3

a = [0]*3

a[0] = 0
a[1] = C[3] - b[0]
a[2] = C[6] - b[0]



z = 0
for x in a:
    for y in b:
        if C[z] != x + y:
            print("No")
            exit()
        z += 1

print("Yes")

Solution (Python):
c11,c12,c13 = map(int,input().split())
c21,c22,c23 = map(int,input().split())
c31,c32,c33 = map(int,input().split())
if c11-c12  == c21-c22 and c11-c12 == c31-c32 and c12-c13 == c22-c23 and c12-c13 == c32-c33:
    print("Yes")
else:
    print("No")

Solution (Python):


import sys






























def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    grid = [lmi() for _ in range(3)]
    vertical = [[grid[i+1][j] - grid[i][j] for j in range(3)] for i in range(2)]
    horizontal = [[grid[i][j+1] - grid[i][j] for i in range(3)] for j in range(2)]
    
    
    if len(list(set(vertical[0]))) == 1 and len(list(set(vertical[1]))) == 1 and len(list(set(horizontal[0]))) == 1 and len(list(set(horizontal[1]))) == 1:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()

Solution (Python):
c = [list(map(int,input().split())) for i in range(3)]
a1 = 0
a2 = 0
a3 = 0
b1 = 0
b2 = 0
b3 = 0
m = min(c[0])
for i in range(m+1):
    a1 = i
    b1 = c[0][0]-a1
    b2 = c[0][1]-a2
    b3 = c[0][2]-a3
    if c[1][0]-b1 == c[1][1]-b2 == c[1][2]-b3:
        a2 = c[1][0]-b1
    else:
        continue
    if c[2][0]-b1 == c[2][1]-b2 == c[2][2]-b3:
        print('Yes')
        exit()
print('No')

Solution (Python):
C1 = list(map(int, input().split()))
C2 = list(map(int, input().split()))
C3 = list(map(int, input().split()))

if C1[1] + C2[0] - C1[0] == C2[1] and C1[1] + C3[0] - C1[0] == C3[1] and \
   C1[2] + C3[0] - C1[0] == C3[2] and C1[2] + C2[0] - C1[0] == C2[2] :
    print("Yes")
else:
    print("No")

Solution (Python):
c = [list(map(int, input().split())) for _ in range(3)]
 
for i in range(2):
  for j in range(2):
    if c[i][j] - c[i][j+1] == c[i+1][j] - c[i+1][j+1]:
      pass
    else:
      print('No')
      exit()
      
print('Yes')

Solution (Python):


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

for i in range(2):
  for j in range(2):
    if c[i][j] - c[i][j+1] == c[i+1][j] - c[i+1][j+1]:
      pass
    else:
      print('No')
      exit()
      
print('Yes')

Solution (Python):
from itertools import chain, groupby


def flatten(list_of_lists):
    return chain.from_iterable(list_of_lists)


def all_equal(iterable):
    g = groupby(iterable)
    return next(g, True) and not next(g, False)


C = [list(map(int, input().split())) for _ in range(3)]
s = sum(flatten(C))

x = all_equal([C[1][i] - C[0][i] for i in range(3)])
y = all_equal([C[2][i] - C[0][i] for i in range(3)])
z = all_equal([C[2][i] - C[1][i] for i in range(3)])

if all((x, y, z)) and s % 3 == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
input = sys.stdin.readline

c = [[int(x) for x in input().split()] for _ in range(3)]

for i in range(101):
    for j in range(101):
        for k in range(101):
            b1, b2, b3 = [x - i for x in c[0]]
            if [b1 + j, b2 + j, b3 + j] == c[1] and [b1 + k, b2 + k, b3 + k] == c[2]:
                print("Yes")
                sys.exit()
print("No")