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=[[0 for i in range(3)] for j in range(3)]
a=[0]*3
b=[0]*3

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

for i in range(-500,500):
  a[0]=i
  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]
  
  if c[1][1]==a[1]+b[1] and c[1][2]==a[1]+b[2] and c[2][1]==a[2]+b[1] and (c[2][2]==a[2]+b[2]):
    print("Yes")
   
    break
    
  if c[1][1]!=a[1]+b[1] or c[1][2]!=a[1]+b[2] or c[2][1]!=a[2]+b[1] or (c[2][2]!=a[2]+b[2]):
    if i==499:
      print("No")

Solution (Python):
C=[0]*3;A=[0]*3
d1=0;d2=0;e1=0;e2=0;z=0;p=0
for i in range(3):
  c1,c2,c3=map(int,input().split())
  C[i]=[c1,c2,c3]
  A[i]=[0,0,0]
 
d1=C[1][0]-C[0][0];d2=C[2][0]-C[0][0]
e1=C[0][1]-C[0][0];e2=C[0][2]-C[0][0]
z=C[0][0]
A[0][0]=z;A[0][1]=z+e1;A[0][2]=z+e2
A[1][0]=z+d1;A[1][1]=z+e1+d1;A[1][2]=z+d1+e2
A[2][0]=z+d2;A[2][1]=z+d2+e1;A[2][2]=z+d2+e2
 

for i in range(3):
  for j in range(3):
    if C[i][j]==A[i][j]:
      p=p+1
print("Yes" if p==9 else "No")

Solution (Python):
a = []

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

sa1 = a[0][0] - a[1][0]
sa2 = a[0][0] - a[2][0]

if sum(a[0]) == sum(a[1]) + 3 * sa1 == sum(a[2]) + 3 * sa2:
    print("Yes")
else:
    print("No")

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

if list_C[0][0] - list_C[0][1] != list_C[1][0] - list_C[1][1] or list_C[0][0] - list_C[0][1] != list_C[2][0] - list_C[2][1]:
    ans = "No"

if list_C[0][0] - list_C[0][2] != list_C[1][0] - list_C[1][2] or list_C[0][0] - list_C[0][2] != list_C[2][0] - list_C[2][2]:
    ans = "No"

if list_C[0][1] - list_C[0][2] != list_C[1][1] - list_C[1][2] or list_C[0][1] - list_C[0][2] != list_C[2][1] - list_C[2][2]:
    ans = "No"

if list_C[0][0] - list_C[1][0] != list_C[0][1] - list_C[1][1] or list_C[0][0] - list_C[1][0] != list_C[0][2] - list_C[1][2]:
    ans = "No"

if list_C[0][0] - list_C[2][0] != list_C[0][1] - list_C[2][1] or list_C[0][0] - list_C[2][0] != list_C[0][2] - list_C[2][2]:
    ans = "No"

if list_C[1][0] - list_C[2][0] != list_C[1][1] - list_C[2][1] or list_C[1][0] - list_C[2][0] != list_C[1][2] - list_C[2][2]:
    ans = "No"

print(ans)

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

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

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

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

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

Solution (Python):
c = [list(map(int,input().split())) for _ in range(3)]
a1 = []
a2 = []
b1 = []
b2 = []
for i in range(3):
  a1.append(c[1][i] - c[0][i])
  a2.append(c[2][i] - c[1][i])
  b1.append(c[i][1] - c[i][0])
  b2.append(c[i][2] - c[i][1])
def l(x):
  return len(list(set(x)))
if (l(a1) == 1) and (l(a2) == 1) and (l(b1) == 1) and (l(b2) == 1):
  print('Yes')
else:
  print('No')

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

c_1 = list(map(int, readline().split()))
c_2 = list(map(int, readline().split()))
c_3 = list(map(int, readline().split()))
c = [c_1, c_2, c_3]
a = [min(c_1), min(c_2), min(c_3)]
b = [c_1[0] - a[0], c_2[1] - a[1], c_3[2] - a[2]]
for i in range(3):
    for j in range(3):
        if a[i] + b[j] != c[i][j]:
            print('No')
            exit()
print('Yes')

Solution (Python):
import numpy as np
import copy
c = [0]*3
for i in range(3):
  c[i] = [int(x) for x in input().split()]

ans = False
while c[0][0] >= 0 and c[0][1] >= 0 and c[0][2] >= 0:
  a = copy.deepcopy(c[1])
  b = copy.deepcopy(c[2])
  for i in range(3):
    a[i] -= c[0][i]
    b[i] -= c[0][i]
  if a[0] == a[1] == a[2] and b[0] == b[1] == b[2]:
    ans = True
    break
  for i in range(3):
    c[0][i] -= 1

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

Solution (Python):
c_list = []
for i in range(3):
    c = list(map(int, input().split()))
    c_list.append(c)
a_ans = [0 for i in range(3)]
b_ans = [0 for i in range(3)]
a_ans[0] = ((c_list[0][0]-c_list[1][0])+(c_list[0][1]-c_list[1][1]))//2
a_ans[1] = a_ans[0] - (c_list[0][0]-c_list[1][0])
a_ans[2] = c_list[2][0]-c_list[0][0] + a_ans[0]
b_ans[0] = c_list[0][0] - a_ans[0]
b_ans[1] = c_list[0][1] - a_ans[0]
b_ans[2] = c_list[0][2] - a_ans[0]
ans = "Yes"
for i in range(3):
    for j in range(3):
        if c_list[i][j]!=a_ans[i]+b_ans[j]:
            ans = "No"
            break
print(ans)

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

Solution (Python):
import numpy as np
 
c = np.array([list(map(int, input().split())) for i in range(3)])
 
flag = True
for a1 in range(c.max()+1):
  b1, b2, b3 = c[0, :] - a1
  if (c[1, 0] - b1 != c[1, 1] - b2) or (c[1, 2] - b3 != c[1, 0] - b1):
    flag = False
    break
    
  if (c[2, 0] - b1 != c[2, 1] - b2) or (c[2, 2] - b3 != c[2, 0] - b1):
    flag = False
    break

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

Solution (Python):
grid = []
for i in range(3):
    grid.append(list(map(int,input().split())))
for i in range(101):
    a1 = i
    b = [grid[0][0]-a1, grid[0][1]-a1, grid[0][2]-a1]
    flag = True
    for j in range(1,3):
        for k in range(2):
            if grid[j][k] - b[k] != grid[j][k+1] - b[k+1]:
                flag = False
    if flag:
        print("Yes")
        exit()
print("No")

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



for a1 in range(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]==a2+b2 and c[1][2]==a2+b3 and c[2][1]==a3+b2 and c[2][2]==a3+b3:
        print('Yes')
        
        break
else:
    print('No')

Solution (Python):
import numpy as np

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

flag = True
for a1 in range(c.max()+1):
  b1 = c[0][0] - a1
  b2 = c[0][1] - a1
  b3 = c[0][2] - a1
  if (c[1][0] - b1 != c[1][1] - b2 or c[1][0] - b1 != c[1][2] - b3):
    flag = False
  
  if (c[2][0] - b1 != c[2][1] - b2 or c[2][0] - b1 != c[2][2] - b3):
   	flag = False
  
print("Yes" if flag else "No")

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


b = []
a = [0]
for i in range(3):
    b.append(c[0][i])

for i in range(3):
    if i == 0:
        continue
    else:
        a.append(c[i][i] - b[i])

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

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

count = 0
x = c[0][1] - c[0][0]
y = c[0][2] - c[0][1]
z = c[0][0] - c[0][2]

for i in range(1,3):
    if (c[i][1] - c[i][0] != x):
        count += 1
    if (c[i][2] - c[i][1] != y):
        count += 1
    if (c[i][0] - c[i][2] != z):
        count += 1
        
X = c[0][0] - c[1][0]
Y = c[1][0] - c[2][0]
Z = c[2][0] - c[0][0]

for j in range(1,3):
    if (c[0][i] - c[1][i] != X):
        count += 1
    if (c[1][i] - c[2][i] != Y):
        count += 1
    if (c[2][i] - c[0][i] != Z):
        count += 1
        
if (count == 0):
    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()))

if c1[1]-c1[0]==c2[1]-c2[0]==c3[1]-c3[0] and c1[2]-c1[1]==c2[2]-c2[1]==c3[2]-c3[1]:
    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 c21-c11==c22-c12==c23-c13 and c31-c21==c32-c22==c33-c23:
    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 c21-c11!=c22-c12 or c21-c11!=c23-c13 or c31-c11!=c32-c12 or c31-c11!=c33-c13:
    print("No")
else:
    print("Yes")

Solution (Python):
data = [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):
            b1 = data[0][0] - a1
            b2 = data[0][1] - a1
            b3 = data[0][2] - a1

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

print("No")

Solution (Python):
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
l3 = list(map(int, input().split()))

for a1 in range(101):
    b1 = [l1[0]-a1, l1[1]-a1, l1[2]-a1]
    for a2 in range(101):
        b2 = [l2[0] - a2, l2[1] - a2, l2[2] - a2]
        for a3 in range(101):
            b3 = [l3[0] - a3, l3[1] - a3, l3[2] - a3]
            if b1 == b2 == b3:
                print("Yes")
                exit()
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):
            b1 = c[0][0] - a1
            b2 = c[0][1] - a1
            b3 = c[0][2] - a1
            
            if a2 + b1 == c[1][0] and a2 + b2 == c[1][1] and a2 + b3 == c[1][2]:
                if a3 + b1 == c[2][0] and a3 + b2 == c[2][1] and a3 + b3 == c[2][2]:
                    print('Yes')
                    quit()
print('No')

Solution (Python):



c = [list(map(int, input().split())) for i in range(3)]
result = True
perm = ((0,1), (0,2), (1,2))
for p in perm:
  x0 = c[p[0]][0] - c[p[1]][0]
  x1 = c[p[0]][1] - c[p[1]][1]
  x2 = c[p[0]][2] - c[p[1]][2]
  if not (x0 == x1 and x1 == x2):
    result = False
    break
  y0 = c[0][p[0]] - c[0][p[1]]
  y1 = c[1][p[0]] - c[1][p[1]]
  y2 = c[2][p[0]] - c[2][p[1]]
  if not (y0 == y1 and y1 == y2):
    result = False
    break
if result: print('Yes')
else: print('No')

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

row = [[0] * 3 for _ in range(2)]

for i in range(2):
    for j in range(3):
        row[i][j] = c[i+1][j] - c[i][j]

ans = "Yes"
for i in row:
    if any(x != y for x, y in combinations(i, 2)):
        ans = "No"

print(ans)

Solution (Python):
c = list(map(int, input().split()))
c += list(map(int, input().split()))
c += list(map(int, input().split()))

if (c[0]-c[1] == c[3]-c[4] == c[6]-c[7]) and (c[1]-c[2] == c[4]-c[5] == c[7]-c[8]) and (c[0]-c[3] == c[1]-c[4] == c[2]-c[5]) and (c[3]-c[6] == c[4]-c[7] == c[5]-c[8]):
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

def ok(c):
    if c[0][0] - c[0][1] == c[1][0] - c[1][1] == c[2][0] - c[2][1] \
            and c[0][0] - c[0][2] == c[1][0] - c[1][2] == c[2][0] - c[2][2] \
            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[0][0] - c[2][0] == c[0][1] - c[2][1] == c[0][2] - c[2][2] \
            and c[1][0] - c[2][0] == c[1][1] - c[2][1] == c[1][2] - c[2][2]:
        return True
    return False

print("Yes" if ok([c1, c2, c3]) else "No")

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

a = [None for _ in range(3)]
b = [None for _ in range(3)]

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

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

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

print(ans)

Solution (Python):
from itertools import product
flag = True
c_list = []
for _ in range(3):
    c_list.append(list(map(int, input().split())))
min_n = min(sum(c_list, []))
new_list = []
for i in c_list:
    new_list.append([j-min_n for j in i])
a = [None, None, None]
b = [None, None, None]
for i in range(3):
    for j in range(3):
        if new_list[i][j] == 0:
            a[i] = 0
            a_other = [num for num in [0, 1, 2] if i!=num]
            b[j] = 0
            b_other = [num for num in [0, 1, 2] if j!=num]
            for k in a_other:
                a[k] = new_list[k][j]
            for k in b_other:
                b[k] = new_list[i][k]
            break
for i, j in product([0, 1, 2], repeat=2):
    if new_list[i][j] != a[i]+b[j]:
        print('No')
        flag = False
        break
if flag:
    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())
count = 0
if c11-c12 == c21-c22 == c31-c32:
  count += 1
  if c12-c13 == c22-c23 == c32-c33:
    count += 1
    if c21-c11 == c22-c12 == c23-c13:
      count += 1
      if c21-c31 == c22-c32 == c23-c33:
        count += 1
if count == 4:
  print("Yes")
else:
  print("No")

Solution (Python):
c=[[int(x) for x in input().split()] for _ in range(3)]
ans="No"
for a1 in c[0]:
    for a2 in c[1]:
        for a3 in c[2]:
            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]:
                ans = "Yes"
                break
print(ans)

Solution (Python):
c=[[int(x) for x in input().split()] for _ in range(3)]
ans="No"
for a1 in c[0]:
    for a2 in c[1]:
        for a3 in c[2]:
            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]:
                ans = "Yes"
                break
        if ans=="Yes":break
    if ans=="Yes":break
print(ans)

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):
import sys

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

for a1 in range(min(c[0] + [100]) + 1):
    for a2 in range(min(c[1] + [100]) + 1):
        for a3 in range(min(c[2] + [100]) + 1):
            x1 = [c[0][0] - a1, c[0][1] - a1, c[0][2] - a1]
            x2 = [c[1][0] - a2, c[1][1] - a2, c[1][2] - a2]
            x3 = [c[2][0] - a3, c[2][1] - a3, c[2][2] - a3]
            if x1 == x2 == x3:
                print("Yes")
                sys.exit()
print("No")

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

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

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

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

for i in range(0,a1_max+1):
    a1 = i
    b1 = s[0][0] - a1
    b2 = s[0][1] - a1
    b3 = s[0][2] - a1
    a2 = s[1][0] - b1
    a3 = s[2][0] - b1
    if b1 >= 0 and b2 >= 0 and b3 >= 0 and a2 >= 0 and a3 >= 0:
        if s[1][1] == a2 + b2 and s[1][2] == a2 + b3 and s[2][1] == a3 + b2 and s[2][2] == a3 + b3:
            print("Yes")
            exit()
        
print("No")

Solution (Python):
import sys
from math import sqrt
from collections import Counter

input = sys.stdin.readline


def I():
    return int(input())


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


def LI():
    return list(MI())


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    c1 = LI()
    c2 = LI()
    c3 = LI()

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

    print("No")

    pass


if __name__ == "__main__":
    main()

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

Solution (Python):


import numpy as np
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def resolve():

    G=np.array([list(map(int,input().split())) for _ in range(3)])
    G[1]-=G[0]
    G[2]-=G[0]
    if len(set(G[1]))==1 and len(set(G[2]))==1:
        print('Yes')
    else:
        print('No')


resolve()

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

for i in range(2):
    if C[i][0] - C[i+1][0] != C[i][1] - C[i+1][1] or \
        C[i][0] - C[i+1][0] != C[i][2] - C[i+1][2]:
        ans = 'No'

        
for j in range(2):
    if C[0][j] - C[0][j+1] != C[1][j] - C[1][j+1] or \
        C[0][j] - C[0][j+1] != C[2][j] - C[2][j+1]:
        ans = 'No'

print(ans)

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

ans = "No"
for i in range(min(l[0])+1): 
    for j in range(min(l[1])+1): 
        for k in range(min(l[2])+1):
            if (l[0][0] - i) == (l[1][0] - j) and (l[0][0] - i) == (l[2][0] - k) and\
                (l[0][1] - i) == (l[1][1] - j) and (l[0][1] - i) == (l[2][1] - k) and\
                (l[0][2] - i) == (l[1][2] - j) and (l[0][2] - i) == (l[2][2] - k):
                ans = "Yes"
print(ans)

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

Solution (Python):
import sys

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

line_max = []
for i in range(len(c)):
    line_max.append(max(c[i]))

flag = False

for i in range(line_max[0] + 1):
    for j in range(line_max[1] + 1):
        for k in range(line_max[2] + 1):
            cnt = 0
            for l in range(3):
                x = c[0][l] - i
                y = c[1][l] - j
                z = c[2][l] - k
                if x >= 0 and y >= 0 and z >= 0:
                    if x == y and y == z and z == x:
                        cnt += 1
            
            if cnt == 3:
                flag = True

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

Solution (Python):
c = [list(map(int, input().split())) for _ in range(3)]
a = [0] * 3
b = c[0]
a[1] = c[1][0] - b[0]
a[2] = c[2][0] - b[0]
flag = False
for i in range(3):
    if flag:
        break
    for j in range(3):
        if c[i][j] != a[i] + b[j]:
            flag = True
            break

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

Solution (Python):
c=[list(map(int,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][1]-b[1]
a[2]=c[2][2]-b[2]

f=0

for i in range(3):
    for j in range(3):

        if a[i]+b[j]==c[i][j]:
            f+=1
if f==9:
    print('Yes')
else:
    print('No')

Solution (Python):
def main():
    import numpy as np
    c = [list(map(int, input().split())) for _ in range(3)]
    f = [[x[0] - x[1], x[1] - x[2], x[2] - x[0]] for x in c]
    g = f[0] == f[1] == f[2]
    print('Yes' if g else 'No')


if __name__ == '__main__':
    main()

Solution (Python):




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

    b2_1 = C[0][1] - C[0][0]
    b3_1 = C[0][2] - C[0][0]

    if (any([b2_1 != C[x][1] - C[x][0] for x in [1, 2]]) or
            any([b3_1 != C[x][2] - C[x][0] for x in [1, 2]])):
        print("No")
    else:
        print("Yes")


if __name__ == "__main__":
    main()

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

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


for i in range(3):
    c = grid[i][0]
    for j in range(3):
        grid[i][j] -= c

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

Solution (Python):
c = []
for i in range(3):
    c.append(list(map(int, input().split())))
f = True
for i in range(2):
    tmp = []
    for j in range(3):
        tmp.append(c[i + 1][j] - c[i][j])
    if (tmp[0] == tmp[1]) and (tmp[1] == tmp[2]):
        pass
    else:
        f = False

for i in range(2):
    tmp = []
    for j in range(3):
        tmp.append(c[j][i+1] - c[j][i])
    if (tmp[0] == tmp[1]) and (tmp[1] == tmp[2]):
        pass
    else:
        f = False

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

Solution (Python):
c = [list(map(int, input().split())) for _ in range(3)]
a = [0] * 3
b = c[0]
a[1] = c[1][0] - b[0]
a[2] = c[2][0] - b[0]
flag = False
for i in range(3):
    if flag:
        break
    for j in range(3):
        if c[i][j] != a[i] + b[j]:
            flag = True
            break

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

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

import sys
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 and c[0][1]-a1 == c[1][1]-a2 == c[2][1]-a3 and c[0][2]-a1 == c[1][2]-a2 == c[2][2]-a3:
                print('Yes')
                sys.exit()

print('No')

Solution (Python):
m=lambda:map(int,input().split())
a,b,c=m();d,e,f=m();g,h,i=m()
print(['No','Yes'][d-a==e-b==f-c and g-a==h-b==i-c])

Solution (Python):
l=lambda:list(map(int,input().split()))
a,b,c=l()
d,e,f=l()
g,h,i=l()
print(['No','Yes'][d-a==e-b==f-c and g-d==h-e==i-f])

Solution (Python):
ii=3
s=[]
icase=0
if icase==0:
    for i in range(ii):
        s.append(list(map(int,input().split())))  
elif icase==1:
    s.append([1,0,1])
    s.append([2,1,2])
    s.append([1,0,1])

yn=1
for i in range(ii-1):
    if (s[i][1]-s[i][0])!=(s[i+1][1]-s[i+1][0]):
        yn=0
for i in range(ii-1):
    if (s[i][2]-s[i][0])!=(s[i+1][2]-s[i+1][0]):
        yn=0
for j in range(ii-1):
    if (s[1][j]-s[0][j])!=(s[1][j+1]-s[0][j+1]):
        yn=0
for j in range(ii-1):
    if (s[2][j]-s[0][j])!=(s[2][j+1]-s[0][j+1]):
        yn=0

if yn==1:
    print("Yes")
else:
    print("No")

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

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

Solution (Python):
S1 = list(map(int,input().split()))
S2 = list(map(int,input().split()))
S3 = list(map(int,input().split()))
List = []
if S3[2]-S3[1] == S2[2]-S2[1] == S1[2]-S1[1]:
        List.append(1)
if S3[1]-S3[0] == S2[1]-S2[0] == S1[1]-S1[0]:
        List.append(1)
if S2[0]-S1[0] == S2[1]-S1[1] == S2[2]-S1[2]:
        List.append(1)
if S2[0]-S3[0] == S2[1]-S3[1] == S2[2]-S3[2]:
        List.append(1)
print("Yes" if sum(List)==4 else "No")

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

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

Solution (Python):
c = [[],[],[]]
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 = "Yes"
for i in range(3):
    for j in range(3):
        if c[(i+1)%3][(j+1)%3] + c[(i+2)%3][(j+2)%3] != c[(i+2)%3][(j+1)%3] + c[(i+1)%3][(j+2)%3]:
            ans = "No"
            break
    if ans == "No":
        break
print(ans)

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

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

Solution (Python):
import numpy as np


















arr = []
for i in range(3):
    arr.append([int(s) for s in input().split(" ")])





def calculate(arr):
        arr = np.array(arr)

        minValPerRow = min(arr[0])

        result = False

        for sa in range(minValPerRow+1):
            mrr = arr[0] - sa

            mrr1 = arr[1] - mrr
            mrr2 = arr[2] - mrr


            s1 = mrr1[0] == mrr1[1] == mrr1[2]
            s2 = mrr2[0] == mrr2[1] == mrr2[2]

            if s1 == True and s2 == True:
                result = True
                break


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


calculate(arr)

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


if __name__ == '__main__':
    solve()

Solution (Python):
def is_correct(grids):
    for a1 in range(min(101, grids[0][0]+1)):
        b_list = grids[0][0] - a1, grids[0][1] - a1, grids[0][2] - a1
        a2, a3 = grids[1][0] - b_list[0], grids[2][0] - b_list[0]
        a_list = [a1, a2, a3]
        temp_grids = []
        for an in a_list:
            row = []
            for bn in b_list:
                row.append(an+bn)
            temp_grids.append(row)
        if grids == temp_grids:
            return True

    return False


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

print("Yes" if is_correct(grids) else "No")

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

Solution (Python):
c=[[int(i) for i in input().split()]for j in range(3)]
for i in range(2):
    if not c[i+1][0]-c[i][0]==c[i+1][1]-c[i][1]==c[i+1][2]-c[i][2]:
        print('No')
        exit()
for i in range(2):
    if not c[0][i+1]-c[0][i]==c[1][i+1]-c[1][i]==c[2][i+1]-c[2][i]:
        print('No')   
        exit()
print('Yes')

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

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

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

Solution (Python):
a=input().split()
b=input().split()
c=input().split()
lista=[int(d) for d in a]
listb=[int(e) for e in b]
listc=[int(f) for f in c]
b1=lista[0]
b2=lista[1]
b3=lista[2]
a2=listb[0]-b1
a3=listc[0]-b1
if a2+b2==listb[1] and a2+b3==listb[2] and a3+b2==listc[1] and a3+b3==listc[2]:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
c = []
for i in range(3):
  c.append(list(map(int, input().split())))
  
for i in range(2):
  arr1 = c[i]
  arr2 = c[i+1]
  
  d = arr1[2] - arr2[2]
  for j in range(2):
    if d != arr1[j]-arr2[j]:
      print('No')
      sys.exit(0)
  
for i in range(2):
  d = c[2][i] - c[2][i+1]
  for j in range(2):
    if d != c[j][i]-c[j][i+1]:
      print('No')
      sys.exit(0)
  
      
    
print('Yes')

Solution (Python):
C = [list(map(int, input().split())) for _ in range(3)]
a = C[1][0]-C[0][0] == C[1][1]-C[0][1] == C[1][2]-C[0][2]
b = C[2][0]-C[0][0] == C[2][1]-C[0][1] == C[2][2]-C[0][2]
if a and b:
    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()))
 
d1 = [c2[i] - c1[i] for i in range(3)]
d2 = [c3[i] - c1[i] for i in range(3)]
 
if(d1[0] == d1[1] and d1[0] == d1[2] and d2[0] ==d2[1] and d2[0] == d2[2]):
  print("Yes")
else:
  print("No")

Solution (Python):
c = [[] for _ in range(3)]
for i in range(3):
    c[i] = list(map(int, input().split()))
    
flag = 0
a = [0]*6
b = [0]*6
    
for i in range(3):
    for j in range(2):
        a[i*2+j] = c[i][j+1] - c[i][j]
        b[i*2+j] = c[j+1][i] - c[j][i]
        
if a[0] == a[2] == a[4]:
    flag += 1
if a[1] == a[3] == a[5]:
    flag += 1    
if b[0] == b[2] == b[4]:
    flag += 1
if b[1] == b[3] == b[5]:
    flag += 1
    
if flag == 4:
    print("Yes")
else:
    print("No")

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

Solution (Python):

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

Solution (Python):
c = []
for _ in range(3):
    c.append(list(map(int, input().split())))
A, B, C, D, E, F, G, H, I = c[0][0], c[0][1], c[0][2], c[1][0], c[1][1], c[1][2], c[2][0], c[2][1], c[2][2]

if max(A+E+I, A+F+H, B+D+I, B+F+G, C+D+H, C+E+G) == min(A+E+I, A+F+H, B+D+I, B+F+G, C+D+H, C+E+G):
    print("Yes")
else:
    print("No")