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 = []
for i in range(3):
	C.append([int(i) for i in input().split()])

D_h = [[C[idx][jdx+1]-C[idx][jdx] for idx in range(3)] for jdx in range(2)]
D_v = [[C[idx+1][jdx]-C[idx][jdx] for idx in range(2)] for jdx in range(3)]

for idx in range(2):
	if D_h[idx][0] != D_h[idx][1]:
		print("No")
		exit(0)
	elif D_h[idx][0] != D_h[idx][2]:
		print("No")
		exit(0)

for idx in range(2):
	if D_v[0][idx] != D_v[1][idx]:
		print("No")
		exit(0)
	elif D_v[0][idx] != D_v[2][idx]:
		print("No")
		exit(0)

print("Yes")

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

b2b0_0 = c[0][2] - c[0][0]
b2b0_1 = c[1][2] - c[1][0]
b2b0_2 = c[2][2] - c[2][0]

a1a0_0 = c[1][0] - c[0][0]
a1a0_1 = c[1][1] - c[0][1]
a1a0_2 = c[1][2] - c[0][2]

a2a0_0 = c[2][0] - c[0][0]
a2a0_1 = c[2][1] - c[0][1]
a2a0_2 = c[2][2] - c[0][2]

b = (b1b0_0 == b1b0_1) and (b1b0_0 == b1b0_2) and (b2b0_0 == b2b0_1) and (b2b0_0 == b2b0_2)
a = (a1a0_0 == a1a0_1) and (a1a0_0 == a1a0_2) and (a2a0_0 == a2a0_1) and (a2a0_0 == a2a0_2)

if a and b:
	print("Yes")
else:
	print("No")

Solution (Python):


c = []

for _ in range(3):
    line = list(map(lambda x:int(x), input().split(" ")))
    c.append(line)

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

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

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

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

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

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

print("Yes")

Solution (Python):
c1 = [int(x) for x in input().split()]
c2 = [int(x) for x in input().split()]
c3 = [int(x) for x in input().split()]

a2 = None
a3 = None
for i in range(c1[0]+1):
    a1 = i
    b1 = c1[0]-a1
    b2 = c1[1]-a1
    b3 = c1[2]-a1
    if c2[0]-b1 == c2[1]-b2 == c2[2]-b3:
        a2 = c2[0]-b1
    else:
        pass
    if c3[0]-b1 == c3[1]-b2 == c3[2]-b3:
        a3 = c3[0]-b1
    else:
        pass

print("Yes" if a2 is not None and a3 is not None else "No")

Solution (Python):
import numpy as np

def slove(c):
    diff1_1 = c[0,0] - c[0,1]
    diff1_2 = c[0,1] - c[0,2]
    diff2_1 = c[1,0] - c[1,1]
    diff2_2 = c[1,1] - c[1,2]
    diff3_1 = c[2,0] - c[2,1]
    diff3_2 = c[2,1] - c[2,2]

    if not(diff1_1 == diff2_1 == diff3_1):
        return "No"

    if not(diff1_2 == diff2_2 == diff3_2):
        return "No"

    return "Yes"


if __name__ == "__main__":
    c_lst = []
    for i in range(3):
        c_lst.append(input().split(" "))
    c = np.array(c_lst, dtype=int)
    print(slove(c))

Solution (Python):

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



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

if C[1][0]-C[2][0]!=C[1][1]-C[2][1] or C[1][1]-C[2][1]!=C[1][2]-C[2][2]:
    print('No')
    exit()
if C[0][0]-C[0][1]!=C[1][0]-C[1][1] or C[1][0]-C[1][1]!=C[2][0]-C[2][1]:
    print('No')
    exit()
if C[0][1]-C[0][2]!=C[1][1]-C[1][2] or C[1][1]-C[1][2]!=C[2][1]-C[2][2]:
    print('No')
    exit()
print('Yes')

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

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

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

if c[0][0] - c[0][1] == 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] == c[2][1] - c[2][2] and \
    c[0][0] - c[1][0] == c[0][1] - c[1][1] == c[0][2] - c[1][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):


import numpy as np 

import copy 
import math

a = []
for i in range(3):
  b = list(map(int, input().strip().split(' ')))
  a.append(b)

flag = 0

for i in range(2):
  for j in range(2):
    if (a[i + 1][j] - a[i][j]) != (a[i + 1][j + 1] - a[i][j + 1]):
      flag = 1
  
for i in range(2):
  for j in range(2):
    if (a[i][j + 1] - a[i][j]) != (a[i + 1][j + 1] - a[i + 1][j]):
      flag = 1

if flag == 0:
  print("Yes")
else:
  print("No")

Solution (Python):
import sys

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

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

	ok = True
	for i in range(0, 3):
		for j in range(0, 3):
			if c[i][j] != a[i] + b[j]:
				ok = False

	if ok:
		print("Yes")
		sys.exit(0)

print("No")

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

flag = True
for i in range(3):
    if abs(sum(c[i - 1]) - sum(c[i])) % 3 != 0:
        flag = False
        break

if flag:
    SUM = [
        c[0][0] + c[1][0] + c[2][0],
        c[0][1] + c[1][1] + c[2][1],
        c[0][2] + c[1][2] + c[2][2],
    ]
    for i in range(3):
        if abs(SUM[i - 1] - SUM[i]) % 3 != 0:
            flag = False
            break

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

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

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

ok = False
d1 = c[0][0] - c[0][1]
d2 = c[0][0] - c[0][2]
d3 = c[0][1] - c[0][2]
if c[1][0] - c[1][1] == c[2][0] - c[2][1] == d1:
  if c[1][0] - c[1][2] == c[2][0] - c[2][2] == d2:
    if c[1][1] - c[1][2] == c[2][1] - c[2][2] == d3:
      ok = True
if ok:
  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()))
if((a[0]+b[1] == a[1]+b[0])
  and (a[0]+c[1] == a[1]+c[0])
  and (a[0]+b[2] == a[2]+b[0])
  and (a[0]+c[2] == a[2]+c[0])
  and (a[1]+b[2] == a[2]+b[1])
  and (a[1]+c[2] == a[2]+c[1])
  and (b[0]+c[1] == b[1]+c[0])
  and (b[0]+c[2] == b[2]+c[0])):
    print("Yes")
else:
    print("No")

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

ok = True

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]):
        pass
    else:
        ok = False

for j in range(2):
    if (c[0][j] - c[0][j + 1]) == (c[1][j] - c[1][j + 1]) == (c[2][j] - c[2][j + 1]):
        pass
    else:
        ok = False

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

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

x = 0
for i in range(3):
    if i == 0:
        a00 = a[i][0]
        a01 = a[i][1]
        a02 = a[i][2]
    else:
        if a[i][0] - a00 != a[i][1] - a01 or a[i][0] - a00 != a[i][2] - a02:
            x = 1
        if a[i][1] - a01 != a[i][0] - a00 or a[i][1] - a01 != a[i][2] - a02:
            x = 1
        if a[i][2] - a02 != a[i][0] - a00 or a[i][2] - a02 != a[i][1] - a01:
            x = 1

for i in range(3):
    if i == 0:
        a00 = a[0][i]
        a01 = a[1][i]
        a02 = a[2][i]
    else:
        if a[0][i] - a00 != a[1][i] - a01 or a[0][i] - a00 != a[2][i] - a02:
            x = 1
        if a[1][i] - a01 != a[0][i] - a00 or a[1][i] - a01 != a[2][i] - a02:
            x = 1
        if a[2][i] - a02 != a[0][i] - a00 or a[2][i] - a02 != a[1][i] - a01:
            x = 1

if x == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
first = list(map(int,input().split()))
second = list(map(int,input().split()))
third = list(map(int,input().split()))

kekka = "Yes"

for i in range(2):
    fsa = first[i+1] - first[i]
    ssa = second[i+1] - second[i]
    tsa = third[i+1] - third[i]
    if fsa == ssa and fsa == tsa:
        pass
    else:
        kekka = "No"

zentai = [first,second,third]

for i in range(2):
    fsa = zentai[i][0] - zentai[i+1][0]
    ssa = zentai[i][1] - zentai[i+1][1]
    tsa = zentai[i][2] - zentai[i+1][2]
    if fsa == ssa and fsa == tsa:
        pass
    else:
        kekka = "No"

print(kekka)

Solution (Python):


def solve():
    c = [list(map(int, input().split())) for _ in range(3)]
    for a0 in range(-100, 101) :
        b = [c[0][i] - a0 for i in range(3)]
        if any(c[1][0] - b[0] != c[1][i] - b[i] for i in range(3)):
            continue
        if any(c[2][0] - b[0] != c[2][i] - b[i] for i in range(3)):
            continue
        return True


if __name__ == '__main__':
    if solve() :
        print("Yes")
    else :
        print("No")

Solution (Python):
import numpy as np

if __name__=='__main__':
    a = []
    for i in range(3):
        m = list(map(int, input().split(' ')))
        a.append(m)

    a = np.array(a).T
    for i in range(3):
        a[i] -= a[i][0]

    if np.allclose(a[0], a[1]) and np.allclose(a[0], a[2]):
        print('Yes')
    else:
        print('No')

Solution (Python):
c1 = input().split()
c2 = input().split()
c3 = input().split()

c1 = list(map(int,c1))
c2 = list(map(int,c2))
c3 = list(map(int,c3))

for i in range(2):
	c1[i+1] = c1[i+1] - c1[0]
	c2[i+1] = c2[i+1] - c2[0]
	c3[i+1] = c3[i+1] - c3[0]

c1 = c1[1:]
c2 = c2[1:]
c3 = c3[1:]

if c1 == c2 == c3:
	print("Yes")

else:
	print ("No")

Solution (Python):
a,b,c=[int(i) for i in input().split()]
m,n=b-a,c-b
a,b,c=[int(i) for i in input().split()]
o,p=b-a,c-b
if m!=o or n!=p:
    print('No')
    exit()
m,n=o,p
a,b,c=[int(i) for i in input().split()]
o,p=b-a,c-b
if m!=o or n!=p:
    print('No')
    exit()
print('Yes')

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

def f(i):
    return C[i+1][0] - C[i][0] ==  C[i+1][1] - C[i][1] ==  C[i+1][2] - C[i][2]

def g(i):
    return C[0][i+1] - C[0][i] ==  C[1][i+1] - C[1][i] ==  C[2][i+1] - C[2][i]

print('Yes' if f(1) and f(0) and g(1) and g(0) else 'No')

Solution (Python):
import numpy as np

cs = []
cs.append([int(a) for a in input().split()])
cs.append([int(a) for a in input().split()])
cs.append([int(a) for a in input().split()])

cs = np.array(cs)

a1a2 = cs[0] - cs[1]
a2a3 = cs[1] - cs[2]
b1b2 = cs[:,0] - cs[:,1]
b2b3 = cs[:,1] - cs[:,2]

if np.all((a1a2 - a1a2[0]) == 0) and np.all((a2a3 - a2a3[0]) == 0) and np.all((b1b2 - b1b2[0]) == 0) and np.all((b2b3 - b2b3[0]) == 0):
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np
c1j = np.array(list(map(int, input().split())))
c2j = np.array(list(map(int, input().split())))
c3j = np.array(list(map(int, input().split())))
grids = np.vstack([c1j, c2j, c3j])
ci1 = grids[:,0]
ci2 = grids[:,1]
ci3 = grids[:,2]
if len(set(c1j - c2j)) == 1 and len(set(c2j - c3j)) == 1 and len(set(c3j-c1j)) \
        and len(set(ci1 - ci2)) == 1 and len(set(ci2 - ci3)) == 1 and len(set(ci3 - ci1)) == 1:
    print('Yes')
else:
    print('No')

Solution (Python):
matrix = []
crow = []
for i in range(3):
    row = input().split()
    for j in row:
        crow.append(int(j))
    matrix.append(crow)
    crow = []

ans = 'Yes'

test = []
for i in range(2):
    for j in range(3):
        test.append(matrix[i][j]-matrix[i+1][j])
        if len(set(test))!=1:
            ans = 'No'
    test = []
    
for j in range(2):
    for i in range(3):
        test.append(matrix[i][j]-matrix[i][j+1])
        if len(set(test))!=1:
            ans = 'No'
        test = []
        

print(ans)

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

if(c1[0]-c2[0]==c1[1]-c2[1] and c1[1]-c2[1]==c1[2]-c2[2] and c3[0]-c2[0]==c3[1]-c2[1] and c3[1]-c2[1]==c3[2]-c2[2] and c1[0]-c3[0]==c1[1]-c3[1] and c1[1]-c3[1]==c1[2]-c3[2]):
    print("Yes")
else:
    print("No")

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

def solve():
    def_x = C[0][0] - C[0][1]
    if def_x != (C[1][0] - C[1][1]) or def_x != (C[2][0] - C[2][1]):
        print("No")
        return
    def_x = C[0][1] - C[0][2]
    if def_x != (C[1][1] - C[1][2]) or def_x != (C[2][1] - C[2][2]):
        print("No")
        return
    def_y = C[0][0] - C[1][0]
    if def_y != (C[0][1] - C[1][1]) or def_y != (C[0][2] - C[1][2]):
        print("No")
        return
    def_y = C[0][0] - C[2][0]
    if def_y != (C[0][1] - C[2][1]) or def_y != (C[0][2] - C[2][2]):
        print("No")
        return
    print("Yes")
    
    
    
solve()

Solution (Python):
C = []
C.append(list(map(int, input().split())))
C.append(list(map(int, input().split())))
C.append(list(map(int, input().split())))

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

Solution (Python):
a=[]
for i in range(3):
	b=list(map(int,input().split()))
	a.append(b)
k=0	
for i in range(101):
	b1=a[0][0]-i
	for j in range(101):
		b2=a[1][1]-j
		for k in range(101):
			b3=a[2][2]-k
			if(3*i+b1+b2+b3==sum(a[0]) and 3*j+b1+b2+b3==sum(a[1]) and 3*k+b1+b2+b3==sum(a[2])):
				k=1
				break
		if(k==1):
			break
	if(k==1):
		break
if(k==1):
	print("Yes")
else:
	print("No")

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

isValid = False
if c[0][0] - c[0][1] == c[1][0] - c[1][1] == c[2][0] - c[2][1]:
    if c[0][0] - c[0][2] == c[1][0] - c[1][2] == c[2][0] - c[2][2]:
        if c[0][0] - c[1][0] == c[0][1] - c[1][1] == c[0][2] - c[1][2]:
            if c[0][0] - c[2][0] == c[0][1] - c[2][1] == c[0][2] - c[2][2]:
              isValid = True

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

Solution (Python):
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):
            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):
                        print("Yes")
                        exit()
print("No")

Solution (Python):
c0=list(map(int,input().split(' ')))
c1=list(map(int,input().split(' ')))
c2=list(map(int,input().split(' ')))
f=0
if (c0[0]-c1[0]) != (c0[1] - c1[1]) or (c0[0]-c1[0]) != (c0[2]-c1[2]):
    f=1
if (c0[0]-c2[0]) != (c0[1] - c2[1]) or (c0[0]-c2[0]) != (c0[2]-c2[2]):
    f=1
if (c0[0]-c0[1]) != (c1[0] - c1[1]) or (c0[0]-c0[1]) != (c2[0]-c2[1]):
    f=1
if (c0[2]-c0[1]) != (c1[2] - c1[1]) or (c0[2]-c0[1]) != (c2[2]-c2[1]):
    f=1
if f == 1:
    print('No')
else:
    print('Yes')

Solution (Python):
def C_Takahashis_Information():
    a,b,c= map(int, input().split())
    d,e,f= map(int, input().split())
    g,h,i= map(int, input().split())
    if (a+e==b+d) and (b+f==c+e) and (d+h==e+g) and (e+i==f+h):
        print('Yes')
    else:
        print('No')
    
C_Takahashis_Information()

Solution (Python):
import sys
import math
import collections
import itertools
import array
import inspect


sys.setrecursionlimit(10000)


def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))


def to_bin(x):
    return bin(x)[2:]


def dim2input(N):
    li = []
    for _ in range(N):
        li.append(list(map(int, input())))
    return li

""" input template
S = input()
N = int(input())
L = list(map(int, input().split()))
a, b = list(map(int, input().split()))
SL = list(input())
"""



dp = None

def main():
    C = []

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

    a1_limit = min(C[0])+1
    a2_limit = min(C[1])+1
    a3_limit = min(C[2])+1
    b1_limit = min(C[0][0], C[1][0], C[2][0])+1
    b2_limit = min(C[0][1], C[1][1], C[2][1])+1
    b3_limit = min(C[0][2], C[1][2], C[2][2])+1

    A1, A2, A3, B1, B2, B3 = [], [], [], [], [], []
    for i in range(a1_limit):
        A1.append(i)
    for i in range(a2_limit):
        A2.append(i)
    for i in range(a3_limit):
        A3.append(i)
    for i in range(b1_limit):
        B1.append(i)
    for i in range(b2_limit):
        B2.append(i)
    for i in range(b3_limit):
        B3.append(i)

    for a1, a2, a3 in itertools.product(A1, A2, A3):
        b1 = C[0][0] - a1
        b2 = C[1][1] - a2
        b3 = C[2][2] - a3

        if a1 + b1 != C[0][0]:
            continue
        if a2 + b1 != C[1][0]:
            continue
        if a3 + b1 != C[2][0]:
            continue
        if a1 + b2 != C[0][1]:
            continue
        if a2 + b2 != C[1][1]:
            continue
        if a3 + b2 != C[2][1]:
            continue
        if a1 + b3 != C[0][2]:
            continue
        if a2 + b3 != C[1][2]:
            continue
        if a3 + b3 != C[2][2]:
            continue

        print("Yes")
        return

    print("No")

main()

Solution (Python):
rows = []
for _ in range(3):
  rows.append(list(map(int, input().split())))
for i in range(3):
  for j in range(2, -1, -1):
    rows[i][j] -= rows[i][0]
ok = True
for j in range(3):
  for i in range(3):
    if rows[i][j] != rows[0][j]:
      ok = False
if ok: print("Yes")
else: print("No")

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

temp1, temp2 = [], []
temp3, temp4 = [], []
for i in range(3):
    temp1.append(c[1][i] - c[0][i])
    temp2.append(c[2][i] - c[0][i])
    temp3.append(c[i][1] - c[i][0])
    temp4.append(c[i][2] - c[i][0])
if len(set(temp1)) == len(set(temp2)) == len(set(temp3)) == len(set(temp4)) == 1:
    print('Yes')
else:
    print('No')

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

Solution (Python):
c = []
c.append(list(map(int, input().split())))
c.append(list(map(int, input().split())))
c.append(list(map(int, input().split())))

if c[0][0] - c[1][0] == c[0][1] - c[1][1] == c[0][2] - c[1][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 = [[int(i) for i in input().split()] for i in range(3)]
flag = 1
for i in range(3):
    for j in range(3):
        if c[(i+1)%3][j] + c[i][(j+1)%3] != c[i][j] + c[(i+1)%3][(j+1)%3]:
           flag = 0
if flag == 0:
    print("No")
else:
    print("Yes")

Solution (Python):
c=[]
for i in range(3):
  c.append( list(map(int,input().split())) )
flag=0
for i in range(3):
  if c[i][0]-c[(i+1)%3][0] == c[i][1]-c[(i+1)%3][1] == c[i][2]-c[(i+1)%3][2]:
    flag+=1
for i in range(3):
  if c[0][i]-c[0][(i+1)%3] == c[1][i]-c[1][(i+1)%3] == c[2][i]-c[2][(i+1)%3]:
    flag+=1
if flag==6:
  print('Yes')
else:
  print('No')

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

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

Solution (Python):


def document_it(func):
    def new_function(*args,**kwargs):
        print('Running function:', func.__name__)
        print('Positional arguments:', args)
        print('Kewword arguments:', kwargs)
        result = func(*args,**kwargs)
        print('Result:', result)
        return result
    return new_function


def exe():
    C11,C12,C13 = map(int,input().split())
    C21,C22,C23 = map(int,input().split())
    C31,C32,C33 = map(int,input().split())
    
    C = C11
    A2 = C21 - C
    A3 = C31 - C
    B2 = C12 - C
    B3 = C13 - C
    C22 -= C
    C23 -= C
    C32 -= C
    C33 -= C
    
    if C22 == A2+B2 and C23 == A2+B3 and C32 == A3+B2 and C33 == A3+B3:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    exe()

Solution (Python):
import numpy as np
u = np.array(list(map(int, input().split())))
c = np.array(list(map(int, input().split())))
b = np.array(list(map(int, input().split())))
for l1 in range(u[0] + 1):
    u1 = u[0] - l1
    l2 = c[0] - u1
    l3 = b[0] - u1
    u2 = u[1] - l1
    u3 = u[2] - l1
    if c[1] == u2 + l2 and c[2] == u3 + l2 and b[1] == u2 + l3 and b[2] == u3 + l3:
        print("Yes")
        exit()
else:
    print("No")

Solution (Python):
def main():
    arr = []
    for i in range(3):
        arr.append(list(map(int, input().split())))
    b1 = arr[0][0] - arr[0][1]
    b2 = arr[0][1] - arr[0][2]
    a1 = arr[1][0] - arr[0][0]
    a2 = arr[2][0] - arr[1][0]
    for i in range(3):
        if arr[i][0] - arr[i][1] != b1 or arr[i][1] - arr[i][2] != b2 or arr[1][i] - arr[0][i] != a1 or arr[2][i] - \
                arr[1][i] != a2:
            print("No")
            return
    print("Yes")

if __name__ == '__main__':
    main()

Solution (Python):

def inpl(): return list(map(int, input().split()))

C = [inpl() for i in range(3)]

ok = True
for i in range(3):
    X = [C[i][j] - C[(i+1)%3][j] for j in range(3)]
    if X[0] == X[1] == X[2]:
        pass
    else:
        ok = False

for j in range(3):
    X = [C[i][j] - C[i][(j+1)%3] for i in range(3)]
    if X[0] == X[1] == X[2]:
        pass
    else:
        ok = False

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

Solution (Python):
C = [list(map(int, input().split())) for _ in range(3)]
ans = 1
for i in range(2):
  if C[i+1][0] - C[i][0] ==  C[i+1][1] - C[i][1]  and C[i+1][2] - C[i][2] ==  C[i+1][1] - C[i][1] :
    continue
  else: ans = 0
for i in range(2):
  if C[0][i+1] - C[0][i] ==  C[1][i+1] - C[1][i]  and C[2][i+1] - C[2][i] ==  C[1][i+1] - C[1][i]:
    continue
  else: ans = 0

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

Solution (Python):
x1,x2,x3 = map(int,input().split())
y1,y2,y3 = map(int,input().split())
z1,z2,z3 = map(int,input().split())
ans="No"
if((x1-y1)==(x2-y2)==(x3-y3) and (y1-z1)==(y2-z2)==(y3-z3) and (x1-x2)==(y1-y2)==(z1-z2) and (x2-x3)==(y2-y3)==(z2-z3)):
    ans = "Yes"
print(ans)

Solution (Python):
def f(c):
    for a1 in range(101):
        for a2 in range(101):
            for a3 in range(101):
                b1 = c[0][0] - a1
                b2 = c[0][1] - a1
                b3 = c[0][2] - a1
                if b1 == c[1][0] - a2 and b1 == c[2][0] - a3 and \
                   b2 == c[1][1] - a2 and b2 == c[2][1] - a3 and \
                   b3 == c[1][2] - a2 and b3 == c[2][2] - a3:
                    return True
    return False
                
c = [map(int, raw_input().split()) for _ in range(3)]
if f(c): print 'Yes'
else: print 'No'

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

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

temps = []
for i in range(3):
    temp = []
    temp.append(matrix[i][1] - matrix[i][0])
    temp.append(matrix[i][2] - matrix[i][1])
    temp.append(matrix[i][2] - matrix[i][0])
    temps.append(temp)
    
if temps[0] == temps[1] and temps[0] == temps[2]:
    print('Yes')
else:
    print('No')

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

def solve():
    if not (s[0][1] - s[0][0] == s[1][1] - s[1][0] == s[2][1] - s[2][0]): return False
    if not (s[0][2] - s[0][1] == s[1][2] - s[1][1] == s[2][2] - s[2][1]): return False
    if not (s[1][0] - s[0][0] == s[1][1] - s[0][1] == s[1][2] - s[0][2]): return False
    if not (s[2][0] - s[1][0] == s[2][1] - s[1][1] == s[2][2] - s[1][2]): return False
    return True

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

Solution (Python):



c11, c12, c13 = map(int, input().strip().split(" "))
c21, c22, c23 = map(int, input().strip().split(" "))
c31, c32, c33 = map(int, input().strip().split(" "))
if c11 - c12 == c21 - c22 == c31 - c32 and c12 - c13 == c22 - c23 == c32 - c33 and c13 - c11 == c23 - c21 == c33 - c31 and c11 - c21 == c12 - c22 == c13 - c23 and c21 - c31 == c22 - c32 == c23 - c33 and c31 - c11 == c32 - c12 == c33 - c13:
    print("Yes")
else:
    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())

if not(c12 - c11 == c22 - c21 == c32 - c31):
    print("No")
    quit()
if not(c13 - c12 == c23 - c22 == c33 - c32):
    print("No")
    quit()
if not(c21 - c11 == c22 - c12 == c23 - c13):
    print("No")
    quit()
if not(c31 - c21 == c32 - c22 == c33 - c23):
    print("No")
    quit()

print("Yes")

Solution (Python):
c = [map(int, raw_input().split()) for _ in range(3)]
a = [0]*3
b = [0]*3
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]
ans = "Yes"
for i in range(3):
  for j in range(3):
    if c[i][j] != a[i]+b[j]:
      ans = "No"
print ans

Solution (Python):

def solve(c):
    def check(xs):
        xs = [[e - es[0] for e in es] for es in xs]
        return xs[0] == xs[1] and xs[0] == xs[2]
    return check(c) and check(list(zip(*c)))

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

if solve(c):
    print("Yes")
else:
    print("No")

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

for i in range(2):
	if c1[i+1] - c1[i] == c2[i+1] - c2[i] == c3[i+1] - c3[i]:
		flg = True
	else:
		flg = False

if flg == False:
	print("No")
	exit(0)

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

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

ok = True

for x in range(2):
  ok = ok and (c[x][0]-c[x+1][0] == c[x][1]-c[x+1][1] == c[x][2]-c[x+1][2])

for x in range(2):
  ok = ok and (c[0][x]-c[0][x+1] == c[1][x]-c[1][x+1] == c[2][x]-c[2][x+1])

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

Solution (Python):
C = [list(map(int, input().split())) for i in range(3)]
N = 100
ok = 0
for a1 in range(N+1):
    b1 = C[0][0] - a1
    b2 = C[0][1] - a1
    b3 = C[0][2] - a1
    for a2 in range(N+1):
        if not (b1 == C[1][0] - a2) or not (b2 == C[1][1] - a2) or not (b3 == C[1][2] - a2):
            continue
        for a3 in range(N+1):
            if not (b1 == C[2][0] - a3) or not (b2 == C[2][1] - a3) or not (b3 == C[2][2] - a3):
                continue
            ok = 1
            break
        else:
            continue
        break
    else:
        continue
    break
print("Yes"*ok or "No")

Solution (Python):
def solve():
    if not (c11 - c21 == c12 - c22 == c13 - c23):
        return False
    if not (c11 - c31 == c12 - c32 == c13 - c33):
        return False
    if not (c11 - c12 == c21 - c22 == c31 - c32):
        return False
    if not (c11 - c13 == c21 - c23 == c31 - c33):
        return False
    return True


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

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