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):
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")

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

ans = "Yes"

for i in range(1, -1, -1):
    C0j = C[0][2] - C[0][i]
    C1j = C[1][2] - C[1][i]
    C2j = C[2][2] - C[2][i]
    
    if C0j != C1j or C0j != C2j:
        ans = "No"
        
print(ans)

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

ans = "Yes"

for i in range(1, -1, -1):
    C0i = C[0][2] - C[0][i]
    C1i = C[1][2] - C[1][i]
    C2i = C[2][2] - C[2][i]
    
    if C0i != C1i or C0i != C2i:
        ans = "No"
        
print(ans)

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

for i in range(2):
    for j in range(2):
        d = c[i][j] - c[i+1][j]
        e = c[i][j+1] - c[i+1][j+1]
        if d != e:
            print("No")
            exit(0)

for i in range(2):
    for j in range(2):
        d = c[i][j] - c[i][j+1]
        e = c[i+1][j] - c[i+1][j+1]
        if d != e:
            print("No")
            exit(0)

print("Yes")

Solution (Python):

B = list(map(int, input().strip().split(' ')))
for _ in range(2):
  C = list(map(int, input().strip().split(' ')))
  if B[0]-C[0] == B[1]-C[1] == B[2]-C[2]:
    continue
  else:
    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())
if c1 - c2 == c4 - c5 == c7 - c8 and c3 - c2 == c6 - c5 == c9 - c8:
  print("Yes")
else:
  print("No")

Solution (Python):
cnt = 0
c1, c2, c3 = map(int, input().split())
try :
  for j in range(c1+1):
    for k in range(c2+1):
      for l in range(c3+1):
        if c1-j == c2-k == c3-l:
          c4, c5, c6 = map(int, input().split())
          if c4 - j == c5 -k == c6 -l:
              c7, c8, c9 = map(int, input().split())
              if c7 - j == c8 -k == c9 -l:
                cnt += 1
                break
except EOFError:
  pass
if cnt != 0:
  print("Yes")
else:
  print("No")

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


res=0
for i in range(2):
  if c[i][0]-c[i+1][0]==c[i][1]-c[i+1][1] and c[i][2]-c[i+1][2]==c[i][1]-c[i+1][1]:
    res+=1

for j in range(2):
  if c[0][j]-c[0][j+1]==c[1][j]-c[1][j+1] and c[2][j]-c[2][j+1]==c[1][j]-c[1][j+1]:
    res+=1
print("Yes" if res==4 else "No")

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

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

D = [[0,0,0] for i in range(3)]
for i in range(3):
    for j in range(3):
        D[i][j] = a[i]+b[j]

        
if C == D:
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np

cs = np.zeros((3,3))

cs[0,:] = input().split()
cs[1,:] = input().split()
cs[2,:] = input().split()

cs = cs.astype(int)

flag = True
x1 = cs[0,0]-cs[1,0]
x2 = cs[0,1]-cs[1,1]
x3 = cs[0,2]-cs[1,2]

y1 = cs[0,0]-cs[2,0]
y2 = cs[0,1]-cs[2,1]
y3 = cs[0,2]-cs[2,2]

if (x1!=x2)|(x2!=x3)|(y1!=y2)|(y2!=y3):
  flag = False

if flag:
  for a1 in range(0,100+1):
    a2 = a1 - (cs[0,0] - cs[1,0])
    a3 = a1 - (cs[0,0] - cs[2,0])
    x1 = cs[0,0] - a1
    x2 = cs[1,0] - a2
    x3 = cs[2,0] - a3

    y1 = cs[0,1] - a1
    y2 = cs[1,1] - a2
    y3 = cs[2,1] - a3

    z1 = cs[0,2] - a1
    z2 = cs[1,2] - a2
    z3 = cs[2,2] - a3

    if (x1!=x2)|(x2!=x3)|(y1!=y2)|(y2!=y3)|(z1!=z2)|(z2!=z3):
      flag = False
    else:
      flag = True
      break

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

Solution (Python):
C=[list(map(int,input().split())) for i in range(3)]
for n in range(0,2):
  x=C[0][2]-C[0][n]
  y=C[1][2]-C[1][n]
  z=C[2][2]-C[2][n]
  if x!=y or y!=z :
    print('No')
    exit()
else:
  print('Yes')

Solution (Python):
if __name__ == '__main__':
    C = [list(map(int, input().split())) for _ in range(3)]
    flag = True
    for i in range(2):
            for ni in range(i+1,3):
                for j in range(2):
                    if C[i][j] - C[i][j+1] != C[ni][j] - C[ni][j+1]:
                        flag = False
                        break

    for i in range(2):
            for ni in range(i+1,3):
                for j in range(2):
                    if C[j][i] - C[j+1][i] != C[j][ni] - C[j+1][ni]:
                        flag = False
                        break
    
    if flag:
        print('Yes')
    else:
        print('No')

Solution (Python):
import numpy as np

c = [list(map(int, input().split())) for i in range(3)]
c = np.array(c)
b = c[0]
a1 = [0] * 3
a2 = c[1] - b
a3 = c[2] - b

if len(set(a2)) == 1 and len(set(a3)) == 1:
    print('Yes')
else:
    print('No')

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

a = [0, 0, 0]
b = [0, 0, 0]

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

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




ans_date = []
for i in a:
  date = []
  for j in b:
    num = i +j
    date.append(num)
  ans_date.append(date)


if grid == ans_date:
  print("Yes")
else:
  print("No")

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

Solution (Python):
C = [list(map(int,input().split())) for i in range(3)]
check = [[0]*3]*3
flag = "True"
while(flag=="True"):
    flag = "false"
    for i in range(3):
        if min(C[i][0],C[i][1],C[i][2])!=0:
            C[i][0] -= 1
            C[i][1] -= 1
            C[i][2] -= 1
            flag = "True"
            break
        elif min(C[0][i],C[1][i],C[2][i])!=0:
            C[0][i] -= 1
            C[1][i] -= 1
            C[2][i] -= 1
            flag = "True"
            break
if C == check:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007



def main():
    flag = True
    L = LIR(3)
    diff_list = [[0] * 3 for _ in range(3)]
    for x in range(3):
        for y in range(3):
            diff_list[y][x] = L[y][x] - L[y - 1][x]


    for i, j, k in diff_list:
        if not i == j == k:
            flag = False


    diff_list = [[0] * 3 for _ in range(3)]
    for y in range(3):
        for x in range(3):
            diff_list[x][y] = L[y][x] - L[y][x - 1]


    for i, j, k in diff_list:
        if not i == j == k:
            flag = False


    if flag:
        return 'Yes'
    else:
        return 'No'


print(main())

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

h1 = c[1][0] - c[0][0] == c[1][1] - c[0][1] == c[1][2] - c[0][2]
h2 = c[2][0] - c[1][0] == c[2][1] - c[1][1] == c[2][2] - c[1][2]
w1 = c[0][1] - c[0][0] == c[1][1] - c[1][0] == c[2][1] - c[2][0]
w2 = c[0][2] - c[0][1] == c[1][2] - c[1][1] == c[2][2] - c[2][1]

if h1 and h2 and w1 and w2 :
    print('Yes')
else :
    print('No')

Solution (Python):
Cij = [list(map(int,input().split())) for _ in range(3)]
b1,b2,b3 = Cij[0][0],Cij[0][1],Cij[0][2]
a2,a3 = Cij[1][0]-b1,Cij[2][0]-b1

if Cij[1][1] != a2+b2:
  print("No")
  exit()
  
if Cij[1][2] != a2+b3:
  print("No")
  exit()
  
if Cij[2][1] != a3+b2:
  print("No")
  exit()
  
if Cij[2][2] != a3+b3:
  print("No")
  exit()
  
print("Yes")

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

a = [0] * 3
b = [0] * 3
ans = "Yes"
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):
        if a[i] + b[j] != c[i][j]:
            ans = "No"

print(ans)

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

a = [0] * 3
b = [0] * 3
ans = "Yes"
for a1 in range(101):
    a[0] = a1
    b[0] = c[0][0] - a1
    b[1] = c[0][1] - a1
    b[2] = c[0][2] - a1
    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 a[i] + b[j] != c[i][j]:
                ans = "No"

print(ans)

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

ans = "Yes"

for i in range(2):
    x = grid[0][2] - grid[0][i]
    y = grid[1][2] - grid[1][i]
    z = grid[2][2] - grid[2][i]

    if x != y or x != z:
        ans = "No"
        
print(ans)

Solution (Python):
grid = [list(map(int, input().split())) for _ in range(3)]
ds = []
for c1, c2, c3 in grid:
    ds.append([c1-c2, c2-c3, c3-c1])
count = 0
for i in range(3):
    if ds[0][i] == ds[1][i] == ds[2][i]:
        count += 1
print('Yes' if count == 3 else 'No')

Solution (Python):
if __name__ == '__main__':
    c = [[], [], []]
    for i in range(3):
        c[i] = list(map(int, input().split()))
    
    ans = "Yes"
    for i in range(2):
        d0 = c[0][2] - c[0][i]
        d1 = c[1][2] - c[1][i]
        d2 = c[2][2] - c[2][i]
        
        if d0 != d1 or d0 != d2:
            ans = "No"
    
    print(ans)

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


if __name__ == "__main__":
    resolve()

Solution (Python):

import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        c = [list(map(int, input().split())) for _ in range(3)]
        for a1 in range(101):
            for b1 in range(101 - a1):
                a2 = c[1][0] - b1
                a3 = c[2][0] - b1
                b2 = c[0][1] - a1
                b3 = c[0][2] - a1
                if c[0][0] == a1 + b1 and c[1][1] == a2 + b2 and c[1][2] == a2 + b3 and c[2][1] == a3 + b2 and c[2][2] == a3 + b3:
                    print('Yes')
                    exit()
        print('No')



if __name__ == '__main__':
    AtCoder().main()

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

ans=True
for i in range(2):
    check=c[i+1][0]-c[i][0]
    for j in range(1,3):
        if check !=c[i+1][j]-c[i][j]:
            ans=False
            break
for i in range(2):
    check=c[0][i+1]-c[0][i]
    for j in range(1,3):
        if check !=c[j][i+1]-c[j][i]:
            ans=False
            break

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

Solution (Python):
import sys
import math
from fractions import gcd





def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""


 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())


 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

L =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(3)]


for a1 in range(101):
    b1 = L[0][0] - a1
    b2 = L[0][1] - a1
    b3 = L[0][2] - a1
    a2 = L[1][1] - b2
    a3 = L[2][2] - b3
    
    
    if (a2 + b1) == L[1][0] and (a3 + b1) == L[2][0] and (a3 + b2) == L[2][1] and (a2 + b3) == L[1][2]:
        print("Yes")
        exit()

print("No")

Solution (Python):
import numpy as np

list_ = [np.array(list(map(int, input().rstrip("\n").split()))) for _ in range(3)]
bool_ = (len(set(list_[1] - list_[0])) == len(set(list_[2] - list_[0])) == 1)

print("Yes" if bool_ else "No")

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

a2 = c[1][0] - c[0][0]
a3 = c[2][0] - c[0][0]

if any(c[1][x] != a2 + c[0][x] for x in [1, 2]) or any(c[2][x] != a3 + c[0][x] for x in [1, 2]):
	print('No')
else:
	print('Yes')

Solution (Python):
from sys import exit
c = [list(map(int, input().split())) for _ in range(3)]
a = [None] * 3
b = [None] * 3
a[0] = 0
for j in range(3):
  b[j] = c[0][j] - 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[i][j] != a[i] + b[j]:
      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()))
print('Yes' if c1[0]-c1[1]==c2[0]-c2[1]==c3[0]-c3[1] and c1[2]-c1[1]==c2[2]-c2[1]==c3[2]-c3[1] and c2[0]-c3[0]==c2[1]-c3[1]==c2[2]-c3[2] and c1[0]-c2[0]==c1[1]-c2[1]==c1[2]-c2[2] else 'No')

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

flag = True
for i in range(2):
	if C[0][i+1] - C[0][i] != C[1][i+1] - C[1][i]:
		flag = False
		break
	elif C[1][i+1] - C[1][i] != C[2][i+1] - C[2][i]:
		flag = False
		break

if flag:
	for i in range(2):
		if C[i+1][0] - C[i][0] != C[i+1][1] - C[i][1]:
			flag = False
			break
		elif C[i+1][1] - C[i][1] != C[i+1][2] - C[i][2]:
			flag = False
			break

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

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

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

x = [0] * 3
y = [0] * 3

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

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

print('Yes')

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

Solution (Python):
J=lambda:map(int,input().split());A,B,C=J();D,E,F=J();G,H,I=J();print("YNeos"[any([A-B-D+E,A-C-G+I,E-F-H+I])::2])

Solution (Python):
import sys

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

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

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

Solution (Python):

import sys
import math
from collections import defaultdict


sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]


mod = 10**9 + 7


def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))



c = []
for _ in range(3):
    c.append(III())

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

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

Solution (Python):
num = list(input().split() for l in range(3))
flg = 0
for i in range(0,101):
    d = int(num[0][0]) - i
    e = int(num[1][0]) - i
    f = int(num[2][0]) - i
    b = int(num[0][1]) - d
    c = int(num[0][2]) - d
    if int(num[1][1]) == b + e and int(num[1][2]) == c + e and int(num[2][1]) == b + f and int(num[2][2]) == c + f:
        flg = 1

if flg:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
from statistics import *
from collections import *
from operator import itemgetter

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

ct = 0
li = []
for i in range(3):
    li.append(na())

bbb = li[0]
aaa = [0, li[1][0] - li[0][0], li[2][0] - li[0][0]]
ans = "Yes"
for i in range(3):
    for j in range(3):
        if li[i][j] != aaa[i] + bbb[j]:
            ans = 'No'
            break
print(ans)

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

n1 = max(c[0])
n2 = max(c[1])
n3 = max(c[2])
ans = 'No'

for a1 in range(n1+1):
	for a2 in range(n2+1):
		for a3 in range(n3+1):
			if c[0][0] - a1 == c[1][0] - a2 == c[2][0] - a3 :
				if c[0][1] - a1 == c[1][1] - a2 == c[2][1] - a3 :
					if c[0][2] - a1 == c[1][2] - a2 == c[2][2] - a3 :
						ans = 'Yes'
						break


print(ans)

Solution (Python):
import sys

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

for a in range(-1000, 1001):
    b_1 = m[0][0] - a
    b_2 = m[0][1] - a
    b_3 = m[0][2] - a
    if (m[1][0] - b_1 ==
        m[1][1] - b_2 ==
        m[1][2] - b_3) and \
        (m[2][0] - b_1 ==
         m[2][1] - b_2 ==
         m[2][2] - b_3):
        print('Yes')
        sys.exit()
print('No')

Solution (Python):
sa = []
cnt = 0
for i in range(3):
    x,y,z = map(int,input().split())
    sa.append([x-y,y-z,z-x])
for i in range(3):
    if sa[0][i] == sa[1][i] == sa[2][i]:
        cnt += 1
if cnt==3:
    print('Yes')
else:
    print('No')

Solution (Python):
"""
【ABC088】
C_Takahashi's Information



import sys
from collections import Counter


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

c = []
x = []
y = []
for _ in range(3):
    c.append(LI())
x.append(0) 

for j in range(3):
    y.append(c[0][j] - x[0])

for i in range(1, 3):
    x.append(c[i][0]-y[0])

OK = True
for i in range(3):
    for j in range(3):
        if c[i][j] != x[i]+y[j]:
            OK = False
if OK == True:
    print("Yes")
else:
    print("No")

Solution (Python):
C = []
for i in range(3):
  Cs = list(map(int, input().split()))
  C.append(Cs)
As = [0]*3
Bs = [0]*3
As[0] = 0
Bs[0] = C[0][0]-As[0]
for i in range(3):
  As[i] = C[i][0]-Bs[0]
for j in range(3):
  Bs[j] = C[0][j]-As[0]
ok = True
for i in range(3):
  for j in range(3):
    if C[i][j] != As[i]+Bs[j]:
      ok = False
if ok:
  print("Yes")
else:
  print("No")

Solution (Python):
c = []
for _ in range(3):
    c.append(list(map(int, input().split())))
ans = False
for a1 in range(min(c[0]) + 1):
    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 c[1][1] - b2 == a2 and c[1][2] - b3 == a2:
        if c[2][1] - b2 == a3 and c[2][2] - b3 == a3:
            ans = True
            break
if ans == True:
    print("Yes")
else:
    print("No")

Solution (Python):


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)





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

if(C[0][0] - C[0][1] == C[1][0] - C[1][1] and 
   C[1][0] - C[1][1] == C[2][0] - C[2][1] and 
   C[0][1] - C[0][2] == C[1][1] - C[1][2] and 
   C[1][1] - C[1][2] == C[2][1] - C[2][2]):   
    print('Yes')
else:
    print('No')

Solution (Python):
C = []

for i in range(3):
    C.append(list(map(int, input().split())))

flg = True

for i in range(2):
    for j in range(2):
        if C[i][j+1] - C[i][j] != C[i+1][j+1] - C[i+1][j]:
            flg = False
            break
        elif C[i+1][j] - C[i][j] != C[i+1][j+1] - C[i][j+1]:
            flg = False
            break

if flg:
    print("Yes")
else:
    print("No")

Solution (Python):
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
x = b[0]-a[0]
y = c[0]-a[0]
if ((b[1]-a[1])==x)and((b[2]-a[2])==x)and((c[1]-a[1])==y)and((c[2]-a[2])==y):
    print("Yes")
else:print("No")

Solution (Python):
tbl = [[int(_) for _ in input().split()] for _ in range(3)]
for a1 in range(100):
    B = [tbl[0][i] - a1 for i in range(3)]
    A = [a1, tbl[1][0] - B[0], tbl[2][0] - B[0]]

    flg = True
    for i in range(3):
        for j in range(3):
            if tbl[i][j] != A[i] + B[j]:
                flg = False
                break
        if not flg: break
    if flg:
        print('Yes')
        exit()
print('No')

Solution (Python):
import numpy as np

n1 = list(map(int , input().split()))
n2 = list(map(int , input().split()))
n3 = list(map(int , input().split()))
A = np.array([n1,n2,n3])

def check(b1, b2, b3):
    if b1==b2 and b2 ==b3:
        return True
    else:
        return False
      
flg = False
for i in range(max(A[0])+1):
    diff_n1 =  A[0] - i
    b1 = A[1][0] - diff_n1[0]
    b2 = A[1][1] - diff_n1[1]
    b3 = A[1][2] - diff_n1[2]
    c1 = A[2][0] - diff_n1[0]
    c2 = A[2][1] - diff_n1[1]
    c3 = A[2][2] - diff_n1[2]
    if check(b1, b2, b3) and check(c1, c2, c3):
        flg = True
if flg:
    print('Yes')
else:
    print('No')

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

ans = "Yes"
if not(c[0][0] - c[1][0] == c[0][1] - c[1][1] == c[0][2] - c[1][2]):
  ans = "No"
elif not(c[1][0] - c[2][0] == c[1][1] - c[2][1] == c[1][2] - c[2][2]):
  ans = "No"
elif not(c[0][0] - c[0][1] == c[1][0] - c[1][1] == c[2][0] - c[2][1]):
  ans = "No"
elif not(c[0][1] - c[0][2] == c[1][1] - c[1][2] == c[2][1] - c[2][2]):
  ans = "No"
  
print(ans)

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

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

Solution (Python):
import numpy as np

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

    for i in range(3):
        c[i] -= min(c[i])
    
    for i in range(3):
        c[:,i] -= min(c[:,i])
    
    if np.sum(c) == 0:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

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

r_sum = [sum(l) for l in cs]
total = sum(r_sum)

ok = True
for i in range(3):
    diffs = [cs[i][j] - cs[(i + 1) % 3][j] for j in range(3)]
    d0 = diffs[0]
    for j in range(1, 3):
        if diffs[j] != d0:
            ok = False
            break
    if not ok:
        break
if ok:
    print('Yes')
else:
    print('No')

Solution (Python):



c_matrix = []
for _ in range(3):
    c_list = list(map(int, input().split()))
    c_matrix.append(c_list)

a_matrix = []
a_list = []
b_list = []
a_list.append(0) 
b_list.append(c_matrix[0][0])
b_list.append(c_matrix[0][1])
b_list.append(c_matrix[0][2])
a_list.append(c_matrix[1][0] - b_list[0])
a_list.append(c_matrix[2][0] - b_list[0])

is_ok = True

for i in range(3):
    for j in range(3):
        if a_list[i] + b_list[j] != c_matrix[i][j]:
            is_ok = False
            break

    if not is_ok:
        break

ans = 'Yes' if is_ok else 'No'
print(ans)

Solution (Python):
c1=list(map(int,input().split()))
c2=list(map(int,input().split()))
c3=list(map(int,input().split()))
 
 
if (sum(c1)+sum(c2)+sum(c3))%3!=0:
    print("No")
    exit()
elif c2[0]-c1[0]!=c2[1]-c1[1] or c2[0]-c1[0]!=c2[2]-c1[2] or c2[2]-c1[2]!=c2[1]-c1[1]:
    print("No")
    exit()
elif c3[0]-c1[0]!=c3[1]-c1[1] or c3[0]-c1[0]!=c3[2]-c1[2] or c3[2]-c1[2]!=c3[1]-c1[1]:
    print("No")
    exit()
elif c3[0]-c2[0]!=c3[1]-c2[1] or c3[0]-c2[0]!=c3[2]-c2[2] or c3[0]-c2[0]!=c3[1]-c2[1]:
    print("No")
    exit()   
    
elif c1[1]-c1[0]!=c2[1]-c2[0] or c3[1]-c3[0]!=c2[1]-c2[0] or c1[1]-c1[0]!=c3[1]-c3[0]:
    print("No")
    exit()
elif c1[2]-c1[0]!=c2[2]-c2[0] or c3[2]-c3[0]!=c2[2]-c2[0] or c1[2]-c1[0]!=c3[2]-c3[0]:
    print("No")
    exit()    
elif c1[2]-c1[1]!=c2[2]-c2[1] or c3[2]-c3[1]!=c2[2]-c2[1] or c1[2]-c1[1]!=c3[2]-c3[1]:
    print("No")
    exit()      
    
else:
    print("Yes")

Solution (Python):
import numpy as np
c=np.array([[int(i) for i in input().split()] for _ in range(3)])

b123=c[0]
a123=np.array([
    0,
    c[1][1]-b123[1],
    c[2][2]-b123[2],
])

isOk=True
for i in range(3):
    for j in range(3):
        if c[i][j]!=a123[i]+b123[j]:
            isOk=False

ans="Yes" if isOk else "No"
print(ans)

Solution (Python):
s = []

for i in range(3):
    array = list(map(int, input().split()))
    s.append(array)

sum_num = 0
for i in range(3):
    for j in range(3):
        sum_num += s[i][j]


magic_num = s[0][0] + s[1][1] + s[2][2]

if sum_num % 3 == 0 and magic_num * 3 == sum_num:
    print('Yes')
else:
    print('No')

Solution (Python):
def main():
    mat = []
    for _ in range(3):
        mat.append([int(c) for c in input().split()])
    for j in range(2):
        ref = mat[0][j+1] - mat[0][j]
        if ref != mat[1][j+1] - mat[1][j] or ref != mat[2][j+1] - mat[2][j]:
            return "No"
    for i in range(2):
        ref = mat[i+1][0] - mat[i][0]
        if ref != mat[i+1][1] - mat[i][1] or ref != mat[i+1][2] - mat[i][2]:
            return "No"
    return "Yes"


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

Solution (Python):
def find_numbers(grid):
    for a1 in range(0, 101):
        for a2 in range(0, 101):
            if (grid[0] + grid[3] + grid[6]) - 3 * a1 == (grid[1] + grid[4] + grid[7]) - 3 * a2:
                for a3 in range(0, 101):
                    if (grid[0] + grid[3] + grid[6]) - 3 * a1 == (grid[2] + grid[5] + grid[8]) - 3 * a3:
                        return True
    return False


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

print("Yes" if find_numbers(grid) else "No")

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

lia = li[0]
lib = li[1]
lic = li[2]

if lia[0]-lia[1]==lib[0]-lib[1]==lic[0]-lic[1] and lia[1]-lia[2]==lib[1]-lib[2]==lic[1]-lic[2]\
and lia[0]-lib[0]==lia[1]-lib[1]==lia[2]-lib[2] and lib[0]-lic[0]==lib[1]-lic[1]==lib[2]-lic[2]:
    print("Yes")
else:
    print("No")

Solution (Python):


import sys

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

for a in range(-1000, 1001):
    b_1 = m[0][0] - a
    b_2 = m[0][1] - a
    b_3 = m[0][2] - a
    if (m[1][0] - b_1 ==
        m[1][1] - b_2 ==
        m[1][2] - b_3) and \
        (m[2][0] - b_1 ==
         m[2][1] - b_2 ==
         m[2][2] - b_3):
        print('Yes')
        sys.exit()
print('No')

Solution (Python):
c = [[]]*3

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


arr = [0]*3
sum = 0
for i in range(3):
    arr[0] += c[i][i]
for i in range(3):
    if i + 1 < 3:
        arr[1] += c[i][i+1]
    else:
        arr[1] += c[i][0]
for i in range(3):
    if i + 2 < 3:
        arr[2] += c[i][i+2]
    else:
        arr[2] += c[i][i-1]

if arr[0] != arr[1] or arr[0] != arr[2]:
    print("No")
    exit(0)

print("Yes")
exit(0)

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

for i in range(3):
    D = []
    for j in range(3):
        D.append(X[i][j]-X[i-1][j])
    if len(set(D)) > 1:
        print('No')
        break
else:
    print('Yes')

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

Solution (Python):
c = [[]]*3

for i in range(3):
    c[i] = list(map(int, input().split()))
ans = 0
for i in range(3):
    ans += sum(c[i])

if ans % 3 == 0:
    

    arr = [0]*3
    sum = 0
    for i in range(3):
        arr[0] += c[i][i]
    for i in range(3):
        if i + 1 < 3:
            arr[1] += c[i][i+1]
        else:
            arr[1] += c[i][0]
    for i in range(3):
        if i + 2 < 3:
            arr[2] += c[i][i+2]
        else:
            arr[2] += c[i][i-1]
    
    if arr[0] != arr[1] or arr[0] != arr[2]:
        print("No")
        exit(0)

    print("Yes")
    exit(0)

print("No")

Solution (Python):
c = [[]]*3

for i in range(3):
    c[i] = list(map(int, input().split()))
ans = 0
for i in range(3):
    ans += sum(c[i])

if ans % 3 == 0:
    arr = [[0]* 6]*3
    for i in range(3):
        arr[i][0] = c[i][0] - c[i][1]
        arr[i][1] = c[i][0] - c[i][2]
        arr[i][2] = c[i][1] - c[i][0]
        arr[i][3] = c[i][1] - c[i][2]
        arr[i][4] = c[i][2] - c[i][0]
        arr[i][5] = c[i][2] - c[i][1]
    for i in range(6):
        if arr[0][i] == arr[1][i] and arr[0][i] == arr[2][i]:
            continue
        else:
            print("No")
            exit(0)

    for i in range(3):
        arr[i][0] = c[0][i] - c[1][i]
        arr[i][1] = c[0][i] - c[2][i]
        arr[i][2] = c[1][i] - c[0][i]
        arr[i][3] = c[1][i] - c[2][i]
        arr[i][4] = c[2][i] - c[1][i]
        arr[i][5] = c[2][i] - c[0][i]
          

    for i in range(6):
        if arr[0][i] == arr[1][i] and arr[0][i] == arr[2][i]:
            continue
        else:
            print("No")
            exit(0)

    arr = [0]*3
    sum = 0
    for i in range(3):
        arr[0] += c[i][i]
    for i in range(3):
        if i + 1 < 3:
            arr[1] += c[i][i+1]
        else:
            arr[1] += c[i][0]
    for i in range(3):
        if i + 2 < 3:
            arr[2] += c[i][i+2]
        else:
            arr[2] += c[i][i-1]
    
    if arr[0] != arr[1] or arr[0] != arr[2]:
        print("No")
        exit(0)

    print("Yes")
    exit(0)

print("No")