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=[]
for _ in range(3):
    C_list.append(list(map(int,input().split())))

from itertools import combinations

ans='Yes'
for r in combinations(range(3),2):
    for c in combinations(range(3),2):
        if C_list[r[0]][c[0]]-C_list[r[1]][c[0]] != C_list[r[0]][c[1]]-C_list[r[1]][c[1]]:
            ans='No'
            break
        if C_list[r[0]][c[0]]-C_list[r[0]][c[1]] != C_list[r[1]][c[0]]-C_list[r[1]][c[1]]:
            ans='No'
            break
print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

C = [inl() for _ in range(3)]


def solve():
    a10 = C[1][0] - C[0][0]
    if C[1][1] - C[0][1] != a10 or C[1][2] - C[0][2] != a10:
        return False
    a21 = C[2][0] - C[1][0]
    if C[2][1] - C[1][1] != a21 or C[2][2] - C[1][2] != a21:
        return False
    b10 = C[0][1] - C[0][0]
    if C[1][1] - C[1][0] != b10 or C[2][1] - C[2][0] != b10:
        return False
    b21 = C[0][2] - C[0][1]
    if C[1][2] - C[1][1] != b21 or C[2][2] - C[2][1] != b21:
        return False
    return True


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

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

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 a1 in range(0,101):
    b1 = c11-a1
    b2 = c12-a1
    b3 = c13-a1
    a2 = c21-b1
    a3 = c31-b1
    if a2+b2 == c22 and a3+b2 == c32 and a2+b3 == c23 and a3+b3 == c33:
        print('Yes')
        exit()

print('No')

Solution (Python):
import numpy as np
c1 = list(map(int,input().split()))
c2 = list(map(int,input().split()))
c3 = list(map(int,input().split()))
C = np.array([c1,c2,c3])
Ct = np.transpose(C)
ans = C + Ct
fact = "Yes"
for i in range(3):
    for j in range(3):
        if not(ans[i,j] == C[i,i] + C[j,j]):
            fact = "No"
            break
print(fact)

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

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

import numpy as np

A = np.array([
    [1, 0, 0, 1, 0, 0],
    [1, 0, 0, 0, 1, 0],
    [1, 0, 0, 0, 0, 1],
    [0, 1, 0, 1, 0, 0],
    [0, 1, 0, 0, 1, 0],
    [0, 1, 0, 0, 0, 1],
    [0, 0, 1, 1, 0, 0],
    [0, 0, 1, 0, 1, 0],
    [0, 0, 1, 0, 0, 1]])

B=np.array([
    [1, 0, 0, 1, 0, 0, c[0][0]],
    [1, 0, 0, 0, 1, 0, c[0][1]],
    [1, 0, 0, 0, 0, 1, c[0][2]],
    [0, 1, 0, 1, 0, 0, c[1][0]],
    [0, 1, 0, 0, 1, 0, c[1][1]],
    [0, 1, 0, 0, 0, 1, c[1][2]],
    [0, 0, 1, 1, 0, 0, c[2][0]],
    [0, 0, 1, 0, 1, 0, c[2][1]],
    [0, 0, 1, 0, 0, 1, c[2][2]]])

rankA = np.linalg.matrix_rank(A)
rankB = np.linalg.matrix_rank(B)

if rankA == rankB:
    print("Yes")
else:
    print("No")

Solution (Python):
from itertools import permutations

C = [list(map(int, input().split())) for _ in range(3)]
A = [0, 1, 2]

ans = []

for x in permutations(A, 3):
  temp = 0
  for j in range(3):
    temp += C[j][x[j]]
  ans.append(temp)
    
if len(set(ans)) == 1:
  print("Yes")
else:
  print("No")

Solution (Python):
C = [list(map(int,input().split())) for _ in range(3)]
for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            b1 = C[0][0]-a1 == C[1][0]-a2 == C[2][0]-a3
            b2 = C[0][1]-a1 == C[1][1]-a2 == C[2][1]-a3
            b3 = C[0][2]-a1 == C[1][2]-a2 == C[2][2]-a3
            if b1 and b2 and b3:
                print('Yes')
                exit()
print('No')

Solution (Python):
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:
    if b+f==c+e:
        if d+h==e+g:
            if e+i==f+h:
                print('Yes')
                exit()
print('No')

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


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

Solution (Python):
import sys
import itertools

import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines



C = [0] * 3

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

for i in range(1, 3):
    x = C[i][0] - C[i - 1][0]
    for j in range(1, 3):
        if C[i][j] - C[i - 1][j] != x:
            print("No")
            exit()

for j in range(1, 3):
    x = C[0][j] - C[0][j - 1]
    for i in range(1, 3):
        if C[i][j] - C[i][j - 1] != x:
            print("No")
            exit()
print("Yes")

Solution (Python):
c11, c12,c13=[int(i) for i in input().split()]
c21, c22,c23=[int(i) for i in input().split()]
c31, c32,c33=[int(i) for i in input().split()]

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

if ans==0:
    print("No")

Solution (Python):
y1_list = list(map(int,input().split()))
y2_list = list(map(int,input().split()))
y3_list = list(map(int,input().split()))
L = [y1_list,y2_list,y3_list]
 
a1 = list()
a2 = list()
b1 = list()
b2 = list()
 
for i in range(3):
    a1.append(y1_list[i] - y2_list[i])
    a2.append(y2_list[i] - y3_list[i])

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

Solution (Python):
y1_list = list(map(int,input().split()))
y2_list = list(map(int,input().split()))
y3_list = list(map(int,input().split()))
L = [y1_list,y2_list,y3_list]
 
a1 = list()
a2 = list()
b1 = list()
b2 = list()
 
for i in range(3):
    a1.append(y1_list[i] - y2_list[i])
    a2.append(y2_list[i] - y3_list[i])
    b1.append(L[i][0] - L[i][1])
    b2.append(L[i][1] - L[i][2])
 
 
if (a1[0] == a1[1] and a1[2] == a1[0])and(b1[0] == b1[1] and b1[2] == b1[0]):
    if (a2[0] == a2[1] and a2[2] == a2[0])and(b2[0] == b2[1] and b2[2] == b2[0]):
        print("Yes")
        
    else:
        print("No")
else:
    print("No")

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

bl=c[0]
a2=c[1][0]-bl[0]
a3=c[2][0]-bl[0]
al=[0,a2,a3]
flag='Yes'
for i in range(3):
    for j in range(3):
        if c[i][j]!=al[i]+bl[j]:
            flag='No'
            break
print(flag)

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

d = [0, 1, 2, 0, 1]
x = c[0][0] + c[1][1] + c[2][2]
ok = True
for i in range(3):
    a = c[d[i]][0] + c[d[i+1]][1] + c[d[i+2]][2]
    b = c[d[i]][2] + c[d[i+1]][1] + c[d[i+2]][0]

    if x != a or x != b:
        ok = False

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

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

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

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


if __name__ == "__main__":
    main()

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

for a1 in range(101):
    b1 = int(c[0][0]) - a1
    if b1 < 0:
        continue

    b2 = int(c[0][1]) - a1
    if b2 < 0:
        continue

    b3 = int(c[0][2]) - a1
    if b3 < 0:
        continue

    a2 = int(c[1][0]) - b1
    if a2 < 0:
        continue

    a3 = int(c[2][0]) - b1
    if a3 < 0:
        continue

    if int(c[1][1]) != (a2 + b2):
        continue

    if int(c[1][2]) != (a2 + b3):
        continue

    if int(c[2][1]) != (a3 + b2):
        continue

    if int(c[2][2]) != (a3 + b3):
        continue

    print("Yes")
    break

else:
    print("No")

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

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

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



c_11=c_list[0][0]
ans=0
for a_1 in range(c_11+1):
    b_1=c_11-a_1
    b_2=c_list[0][1]-a_1
    b_3=c_list[0][2]-a_1
    if c_list[1][0]-b_1==c_list[1][1]-b_2==c_list[1][2]-b_3 and c_list[2][0]-b_1==c_list[2][1]-b_2==c_list[2][2]-b_3:
        print("Yes")
        ans=1
        exit()

if ans==0:
    print("No")

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

for i in range(2):
    for j in range(2):
        if c[j][i + 1] - c[j][i] != c[j + 1][i + 1] - c[j + 1][i]:
            print("No")
            sys.exit()
print("Yes")

Solution (Python):
from sys import exit

c = [list(map(int, input().split())) for _ in range(3)]
l_1 = [0, 1, 2]
l_2 = [1, 2, 0]

for i in range(3):
    if not c[l_1[i]][0] - c[l_2[i]][0] == c[l_1[i]][1] - c[l_2[i]][1] == c[l_1[i]][2] - c[l_2[i]][2]:
        print('No')
        exit()
    
    if not c[0][l_1[i]] - c[0][l_2[i]] == c[1][l_1[i]] - c[1][l_2[i]] == c[2][l_1[i]] - c[2][l_2[i]]:
        print('No')
        exit()

print('Yes')

Solution (Python):
from pprint import pprint








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

diff_v = [[0] * 3 for i in range(3)]
diff_h = [[0] * 3 for i in range(3)]

for i in range(0, 3):
    for j in range(0, 3):
        if i > 0:
            diff_v[i][j] = c[i][j] - c[i - 1][j]

for j in range(0, 3):
    for i in range(0, 3):
        if j > 0:
            diff_h[j][i] = c[i][j] - c[i][j - 1]


def map_all(es):
    return all([e == es[0] for e in es[1:]]) if es else False


eq_v = all([map_all(d) for d in diff_v])
eq_h = all([map_all(d) for d in diff_h])

if eq_v and eq_h:
    print('Yes')
else:
    print('No')

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

l1 = []
for i in range(3):
    l1.append(tuple(j - min(l[i]) for j in l[i]))
if len(set(l1)) != 1:
    print('No')
    exit()

k = [[0]*3 for _ in range(3)]
for i in range(3):
    for j in range(3):
        k[j][i] = l[i][j]
k1 = []
for i in range(3):
    k1.append(tuple(j - min(k[i]) for j in k[i]))
if len(set(k1)) != 1:
    print('No')
    exit()

print('Yes')

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

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

for i in range(3):
    b[i]=c[0][i]-a[0]
a[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"
            break
print(ans)

Solution (Python):
import sys

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

Solution (Python):


import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    c = na()
    dif1, dif2 = c[1] - c[0], c[2] - c[1]
    for i in range(2):
        cn = na()
        if cn[1] - cn[0] != dif1 or cn[2] - cn[1] != dif2:
            print("No")
            quit()
    print("Yes")

if __name__ == "__main__":
    main()

Solution (Python):
c = [list(map(int, input().split())) for i in range(3)]
x = c[0][2]-c[0][1]
y = c[0][1]-c[0][0]
for i in range(1, 3):
    if c[i][1]-c[i][0] != y:
        print('No')
        break
    if c[i][2]-c[i][1] != x:
        print('No')
        break

else:
    print('Yes')

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

def f():
    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]:
                return False
            if C[j][i]-C[j+1][i] != C[j][i+1]-C[j+1][i+1]:
                return False
    return True

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

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

a1 = 0
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

ans = [
    [a1+b1, a1+b2, a1+b3],
    [a2+b1, a2+b2, a2+b3],
    [a3+b1, a3+b2, a3+b3]
]

for i in range(3):
    for j in range(3):
        if c[i][j] == ans[i][j]:
            pass
        else:
            print('No')
            exit()
print('Yes')

Solution (Python):

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


base = [C[0][0], C[1][1], C[2][2]]
case_AB = [
    1
    for a in range(base[0] + 1)
    for b in range(base[1] + 1)
    for c in range(base[2] + 1)
    if [
        [base[0], b + (base[0] - a), c + (base[0] - a)],
        [a + (base[1] - b), base[1], c + (base[1] - b)],
        [a + (base[2] - c), b + (base[2] - c), base[2]]
    ] == C
]

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

Solution (Python):
c = [list(map(int, input().split())) for _ in range(3)]
a = [None, None, None]
b = [None, None, None]
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 c[i][j] != a[i]+b[j]:
            print("No")
            exit()
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())
ans = 'No'
if c11 - c21 == c12 - c22 & c12 - c22 == c13 - c23:
    if c21 - c31 == c22 - c32 & c22 - c32 == c23 - c33:
        if c11 - c12 == c21 - c22 & c21 -c22 == c31 - c32:
            if c12 - c13 == c22 - c23 & c22 - c23 == c32 - c33:
                ans = 'Yes'
print(ans)

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

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

print("No")

Solution (Python):
import sys
import timeit


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


def main():
    c = LIR(3)
    a = [0] * 3
    b = [0] * 3
    ans = 'No'
    for i in range(101):
        a[0] = i
        b[0] = c[0][0] - a[0]
        for j in range(101):
            a[1] = j
            b[1] = c[1][1] - a[1]
            for k in range(101):
                a[2] = k
                b[2] = c[2][2] - a[2]
                current = [[a[i] + b[j] for j in range(3)] for i in range(3)]
                if c == current:
                    ans = 'Yes'
                    break
    print(ans)




main()

Solution (Python):
C = [list(map(int,input().split())) for _ in range(3)]
D1 = [[] for _ in range(3)]
D2 = [[] for _ in range(3)]
for i in range(3):
    for j in range(2):
        D1[i].append(C[i][j] - C[i][j + 1])
for j in range(3):
    for i in range(2):
        D2[j].append(C[i][j] - C[i + 1][j])
print('Yes' if D1[0] == D1[1] == D1[2] and D2[0] == D2[1] == D2[2] else 'No')

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

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

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

"""
a0 = 0 とする
すると
b0 = c00 - a0
b1 = c01 - a0
b2 = c02 - a0
"""

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

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

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

Solution (Python):

c = [[0,0,0],[0,0,0],[0,0,0]];
c[0] = [int(x) for x in input().split()];
c[1] = [int(x) for x in input().split()];
c[2] = [int(x) for x in input().split()];

ans = 'true';

for i in range(1,3) :
    hdiff =  c[0][i] - c[0][i-1];
    for j in range(1,3) :
        if  c[j][i] - c[j][i-1] != hdiff :
            ans = 'false';
            break;

for i in range(1,3) :
    vdiff =  c[i][0] - c[i-1][0];
    for j in range(1,3) :
        if  c[i][j] - c[i-1][j] != vdiff :
            ans = 'false';
            break;            

if(ans == 'true') :
    print('Yes');
else :
    print('No');

Solution (Python):
import sys

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    c = [list(mi()) for i in range(3)]
    if c[0][0]+c[1][1] == c[0][1]+c[1][0] \
        and c[1][1]+c[2][2] == c[1][2]+c[2][1] \
        and c[2][2]+c[0][0] == c[2][0]+c[0][2]:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

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

diff1 = mtx[0][0] - mtx[1][0]
diff2 = mtx[0][0] - mtx[2][0]

diff3 = mtx[0][0] - mtx[0][1]
diff4 = mtx[0][0] - mtx[0][2]

if mtx[0][1] - mtx[1][1] != diff1:
    print('No')
elif mtx[0][2] - mtx[1][2] != diff1:
    print('No')
elif mtx[0][1] - mtx[2][1] != diff2:
    print('No')
elif mtx[0][2] - mtx[2][2] != diff2:
    print('No')
elif mtx[1][0] - mtx[1][1] != diff3:
    print('No')
elif mtx[2][0] - mtx[2][1] != diff3:
    print('No')
elif mtx[1][0] - mtx[1][2] != diff4:
    print('No')
elif mtx[2][0] - mtx[2][2] != diff4:
    print('No')
else:
    print('Yes')

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

Solution (Python):


if __name__ == "__main__":
    c1 = list(map(int, input().split()))
    c2 = list(map(int, input().split()))
    c3 = list(map(int, input().split()))
    c = [c1, c2, c3]
    a = [0, 0, 0]
    b = [c1[0], c1[1], c1[2]]
    a[1] = c2[1] - b[1]
    a[2] = c3[1] - b[1]
    flg = True
    for i in range(3):
        for j in range(3):
            flg = flg&(a[i]+b[j] == c[i][j])
    if flg:
        print('Yes')
    else:
        print('No')

Solution (Python):
lst=[]
for i in range(3):
    a=map(int,input().split())
    for j in a:
        lst.append(j)
for i in range(lst[0]+1):
    a,d=i,lst[0]-i
    b=lst[3]-lst[0]+a
    c=lst[6]-lst[0]+a
    e=lst[1]-lst[0]+d
    f=lst[2]-lst[0]+d
    if lst[4]==b+e and lst[5]==b+f and lst[7]==c+e and lst[8]==c+f:
        print("Yes")
        exit()
print("No")

Solution (Python):
l=[list(map(int,input().split())) for i in range(3)]
x=l[0][0]
y=l[0][1]
z=l[0][2]
a=0
b=l[1][0]-x
c=l[2][0]-x
if b+y==l[1][1] and b+z==l[1][2] and c+y==l[2][1] and c+z==l[2][2]:
  print('Yes')
else:
  print('No')

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

Solution (Python):
lst = []
for i in range(3):
  l = list(map(int, input().split()))
  lst.append(l)
for i in range(1, 3):
  diff = lst[i][0] - lst[0][0]
  for j in range(3):
    lst[i][j] -= diff
  if lst[i] != lst[0]:
    print('No')
    exit()
print('Yes')

Solution (Python):
import numpy as np
c = [list(map(int, input().split())) for i in range(3)]
C = np.array(c)
check = np.zeros((3, 3))

for i in range(min(c[0])+1):
    check[0] = C[0] - i
    for j in range(min(c[1])+1):
        check[1] = C[1] - j
        for k in range(min(c[2])+1):
            check[2] = C[2] - k
            if list(check[0]) == list(check[1]) and list(check[0]) == list(check[2]):
                print("Yes")
                exit()

print("No")

Solution (Python):
import sys
c = []

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

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

for l, m in enumerate(c[1:]):
    for j, k in enumerate(m):
        if j == 0:
            a[l+1] = k - b[j] 
        else:
            if k != a[l+1] + b[j]:
                print('No')
                sys.exit()
print('Yes')

Solution (Python):









import os
import sys




def main():
    c = []
    for _ in range(3):
        c.append(list(map(int, input().split())))
    a_12 = c[0][0]-c[1][0]
    a_13 = c[0][0]-c[2][0]
    a_23 = c[1][0]-c[2][0]
    b_12 = c[0][0]-c[0][1]
    b_13 = c[0][0]-c[0][2]
    b_23 = c[0][1]-c[0][2]

    for i in range(1, 3):
        if b_12 != c[i][0]-c[i][1] or b_13 != c[i][0]-c[i][2] or b_23 != c[i][1]-c[i][2]:
            print("No")
            return
        if a_12 != c[0][i]-c[1][i] or a_13 != c[0][i]-c[2][i] or a_23 != c[1][i]-c[2][i]:
            print("No")
            return
    print("Yes")



        


if __name__ == "__main__":
    main()

Solution (Python):
c = [[int(i) for i in input().split()] for j in range(3)]
b2 = c[0][1]-c[0][0]
b3 = c[0][2]-c[0][0]
a2 = c[1][0]-c[0][0]
a3 = c[2][0]-c[0][0]

d = 0
for i in range(2):
    if c[i+1][1] - c[i+1][0] == b2:
        d += 1
    if c[i+1][2] - c[i+1][0] == b3:
        d += 1
for j in range(2):
    if c[1][i+1] - c[0][i+1] == a2:
        d += 1
    if c[2][i+1] - c[0][i+1] == a3:
        d += 1
if d == 8:
    print("Yes")
else:
    print("No")

Solution (Python):

A = [None, None, None]
B = [0, None, None]
C = [None, None, None]

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

flag = True

for i in range(3):
	for j in range(3):
		
		if B[i] == None:
			B[i] = A[i][j] - C[j]
		elif C[j] == None:
			C[j] = A[i][j] - B[i]
		elif A[i][j] != B[i] + C[j]:
			flag = False
		
if flag == True :
	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+1][j] - C[i][j] != C[i+1][j+1] - C[i][j+1]:
            print('No')
            exit()
print('Yes')

Solution (Python):
import numpy as np

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

for i in range(2):
    if not c[0,i]-c[0,i+1] == c[1,i]-c[1,i+1] == c[2,i]-c[2,i+1]:
        flg = False
        break
    if not c[i,0]-c[i+1,0] == c[i,1]-c[i+1,1] == c[i,2]-c[i+1,2]:
        flg = False
        break
print('Yes') if flg else 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 \
   (c2[2]-c2[1] == c2[2]-c2[1] == c3[2]-c3[1]) and \
   (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):

 

 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools


 








C = [list(map(int, input().split())) for _ in range(3)]
 
Dif_H = [[] for _ in range(3)]
Dif_V = [[] for _ in range(3)]
 
for i in range(3):
    Dif_H[i] = [C[i][0] - C[i][1], C[i][1] - C[i][2], C[i][2] - C[i][0]]
for i in range(3):
    Dif_V[i] = [C[0][i] - C[1][i], C[1][i] - C[2][i], C[2][i] - C[0][i]]
 
if Dif_H[0] == Dif_H[1] == Dif_H[2] and Dif_V[0] == Dif_V[1] == Dif_V[2]:
    print('Yes')
else:
    print('No')

Solution (Python):
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:
  if b+f==c+e:
    if d+h==e+g:
      if e+i==f+h:
        print('Yes')
        exit()
print('No')

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

x1 = c[0][0]-c[1][0]
x2 = c[0][1]-c[1][1] 
x3 = c[0][2]-c[1][2]

x4 = c[1][0]-c[2][0]
x5 = c[1][1]-c[2][1]
x6 = c[1][2]-c[2][2]

if x1==x2 and x2==x3:
    pass
else:
    print('No')
    exit()
if x4==x5 and x5==x6:
    pass 
else:
    print('No')
    exit()

x1 = c[0][0]-c[0][1]
x2 = c[1][0]-c[1][1] 
x3 = c[2][0]-c[2][1]

x4 = c[0][1]-c[0][2]
x5 = c[1][1]-c[1][2]
x6 = c[2][1]-c[2][2]

if x1==x2 and x2==x3:
    pass
else:
    print('No')
    exit()
if x4==x5 and x5==x6:
    pass 
else:
    print('No')
    exit()
print('Yes')

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

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

Dif_H = [[] for _ in range(3)]
Dif_V = [[] for _ in range(3)]

for i in range(3):
    Dif_H[i] = [C[i][0] - C[i][1], C[i][1] - C[i][2], C[i][2] - C[i][0]]
for i in range(3):
    Dif_V[i] = [C[0][i] - C[1][i], C[1][i] - C[2][i], C[2][i] - C[0][i]]

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

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

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

Solution (Python):
c11, c12, c13 = map(int, input().split())

for i in range(2):
    c1, c2, c3 = map(int, input().split())
    if (c1-c11) == (c2-c12) and (c2-c12) == (c3-c13):
        c11, c12, c13 = c1, c2, c3
    else:
        print('No')
        exit()
print('Yes')

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

    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')
    else:
        print('No')
    exit()

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

if L[1][1]!=L[1][0]-L[0][0]+L[0][1]:
    s=False
if L[1][2]!=L[1][0]-L[0][0]+L[0][2]:
    s=False
if L[2][1]!=L[2][0]-L[0][0]+L[0][1]:
    s=False
if L[2][2]!=L[2][0]-L[0][0]+L[0][2]:
    s=False
if s:
    print('Yes')
else:
    print('No')

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

Solution (Python):
G1 = list(map(int, input().split()))
G2 = list(map(int, input().split()))
G3 = list(map(int, input().split()))
sub_G1 = []
sub_G2 = []
sub_G3 = []
sub_R12 = []
sub_R23 = []
for i in range(2):
  sub_G1.append(G1[i+1] - G1[i])
  sub_G2.append(G2[i+1] - G2[i])
  sub_G3.append(G3[i+1] - G3[i])
for k in range(3):
  sub_R12.append(G2[i]-G1[i])
  sub_R23.append(G3[i]-G2[i])
condition1 = bool(sub_G1[0] == sub_G2[0] == sub_G3[0])
condition2 = bool(sub_G1[1] == sub_G2[1] == sub_G3[1])
condition3 = bool(len(set(sub_R12)) == 1)
condition4 = bool(len(set(sub_R23)) == 1)
if condition1 and condition2 and condition3 and condition4:
  print("Yes")
else:
  print("No")

Solution (Python):
a,b,c = map(int, input().split())
d,e,f = map(int, input().split())
g,h,i = map(int, input().split())

if a-b == d-e:
    if d-e == g-h:
        if b-c == e-f:
            if e-f == h-i:
                if a-d == b-e:
                    if b-e ==c-f:
                        if d-g == e-h:
                            if e-h ==f-i:
                                print("Yes")
                                exit()

print("No")

Solution (Python):
a = [list(map(int,input().split()))for i in range(3)]
x = [10,0,0]
y = [0,0,0]

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

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

flag = True

for i in range(3):
    for j in range(3):
        if a[i][j] != x[i]+y[j]:
            flag=False

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