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):
c1 = list(map(int,input().split()))
c2 = list(map(int,input().split()))
c3 = list(map(int,input().split()))

t = True
if not(c1[0]-c2[0] == c1[1]-c2[1] == c1[2]-c2[2]):
  t = False
if not(c1[0]-c3[0] == c1[1]-c3[1] == c1[2]-c3[2]):
  t = False

if not(c1[0]-c1[1] == c2[0]-c2[1] == c3[0]-c3[1]):
  t = False
if not(c1[0]-c1[2] == c2[0]-c2[2] == c3[0]-c3[2]):
  t = False

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

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

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

Solution (Python):

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

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

a[0] = 0
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 = True

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

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

Solution (Python):
c = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

for i in range(0, 3):
    c[i] = [int(j) for j in input().split(" ")]

f = True
for i in range(0, 2):
    f = f and c[i][0] - c[i][1] == c[i + 1][0] - c[i + 1][1]
    f = f and c[i][1] - c[i][2] == c[i + 1][1] - c[i + 1][2]

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

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

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

Solution (Python):
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] 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):
li = [list(map(int, input().split())) for _ in range(3)]
if li[0][0]- li[0][1] == li[1][0]- li[1][1] and li[1][0]- li[1][1] == li[2][0]- li[2][1]:
  if li[0][1]- li[0][2] == li[1][1]- li[1][2] and li[1][1]- li[1][2] == li[2][1]- li[2][2]:
    print('Yes')
  else:
    print('No')
else:
  print('No')

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


a = [0] * 3
b = [0] * 3
for i in range(100):
    a[0] = i
    for j in range(N):
        b[j] = glid[0][j] - a[0]

    for j in range(1, N):
        a[j] = glid[j][0] - b[0]

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

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

judge = 0
if a[0][1] - a[1][1] == a[0][2] - a[1][2] == a[0][0] - a[1][0]:
	if a[1][1] - a[2][1] == a[1][2] - a[2][2] == a[1][0] - a[2][0]:
		if a[1][0] - a[1][1] == a[2][0] - a[2][1] == a[0][0] - a[0][1]:
			if a[1][1] - a[1][2] == a[2][1] - a[2][2] == a[0][1] - a[0][2]:
				judge = 1

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

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

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

if np.all(c==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 c3[0]-c3[1] == c2[0]-c2[1] and c2[0]-c2[1] == c1[0]-c1[1]:
    if c3[1]-c3[2] == c2[1]-c2[2]  and c2[1]-c2[2] == c1[1]-c1[2]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
C = [a1, a2, a3]
a1 = 0
b1 = C[0][0]
b2 = C[0][1]
b3 = C[0][2]
a2 = C[1][1] - b2
a3 = C[2][2] - b3
A = [a1, a2, a3]
B = [b1, b2, b3]
for i in range(3):
    for j in range(3):
        if C[i][j] == A[i] + B[j]:
            continue
        else:
            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())

def isCorrect():
    if not (c11 - c21 == c12 - c22 == c13 - c23):
        return "No"
    if not (c11 - c31 == c12 - c32 == c13 - c33):
        return "No"
    if not (c11 - c12 == c21 - c22 == c31 - c32):
        return "No"
    if not (c11 - c13 == c21 - c23 == c31 - c33):
        return "No"
    return "Yes"
 
print(isCorrect())

Solution (Python):
import sys
c=[[int(i) for i in l.split()] for l in sys.stdin]
for i in range(2):
  stack=c[i][0]-c[i+1][0]
  for j in range(3):
    if stack!=c[i][j]-c[i+1][j]:
      print('No')
      exit()
for i in range(2):
  stack=c[0][i]-c[0][i+1]
  for j in range(3):
    if stack!=c[j][i]-c[j][i+1]:
      print('No')
      exit()
print('Yes')

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

for b1 in range(0, 101):
    for b2 in range(0, 101):
        for b3 in range(0, 101):
            if (c11 - b1 == c12 - b2 == c13 - b3) and (c21 - b1 == c22 - b2 == c23 - b3) and (c31 - b1 == c32 - b2 == c33 - b3):
                print('Yes')
                exit()

print('No')

Solution (Python):

c=[]
for i in range(3):
    c.append(list(map(int,input().split())))
a=[0]*3
b=[0]*3
a[0]=0
a[1]=c[1][1]-c[0][1]
a[2]=c[2][2]-c[0][2]
b[0]=c[0][0]
b[1]=c[0][1]
b[2]=c[0][2]
flag=True
for i in range(3):
    for j in range(3):
        if c[i][j]!=a[i]+b[j]:
            flag=False
if flag==True:
    print("Yes")
else:
    print("No")
""" 
print("Yes") if flag(is true) 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())

bs = []
for a1 in range(0, 101):
    for b1 in range(0, 101):
        if a1 + b1 == c11:
            f1 = True
            break
    for b2 in range(0, 101):
        if a1 + b2 == c12:
            f2 = True
            break
    for b3 in range(0, 101):
        if a1 + b3 == c13:
            f3 = True
            break
    if f1 and f2 and f3:
        bs.append((b1, b2, b3))

bss = []
for a2 in range(0, 101):
    for b1, b2, b3 in bs:
        if a2 + b1 == c21 and a2 + b2 == c22 and a2 + b3 == c23:
            bss.append((b1, b2, b3))

for a3 in range(0, 101):
    for b1, b2, b3 in bss:
        if a3 + b1 == c31 and a3 + b2 == c32 and a3 + b3 == c33:
            print("Yes")
            break
    else:
        continue
    break
else:
    print("No")

Solution (Python):







An = [[0 for j in range(3)] for i in range(3)]
Bn = [[0 for j in range(3)] for i in range(3)]
for i in range(3):
  a = list(map(int, input().split()))
  for j in range(3):
    An[i][j] = a[j]
    Bn[j][i] = a[j]


def check(cn):
  for i in range(2):
    dif0 = cn[i][0]-cn[i+1][0]
    dif1 = cn[i][1]-cn[i+1][1]
    dif2 = cn[i][2]-cn[i+1][2]
    if dif0 != dif1 or dif1 != dif2:
      return False
  return True

if check(An) and check(Bn):
  print("Yes")
else:
  print("No")

Solution (Python):
c1 = [int(i) for i in input().split()]
c2 = [int(i) for i in input().split()]
c3 = [int(i) for i in input().split()]
if (len(set([c1[i] - c2[i] for i in range(3)])) == 1) & ((len(set([c2[i] - c3[i] for i in range(3)])) == 1)):
    print("Yes")
else:
    print("No")

Solution (Python):
c = [list(map(int, input().split())) for i in [0,1,2]]
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][1] == c[1][1] - c[1][1] == c[2][1] - c[2][1]) and
(c[0][2] - c[0][1] == c[1][2] - c[1][1] == c[2][2] - c[2][1])
   ) == True:
  print('Yes')
else:
  print('No')

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

Solution (Python):
import sys
c = [[0]*3 for i in range(3)]
for i in range(3):
    c[i] = list(map(int, input().split()))
for i in range(101):
    b1, b2, b3 = c[0][0]-i, c[0][1]-i, c[0][2]-i
    if c[1][0]-b1 == c[1][1]-b2 and c[1][1]-b2 == c[1][2]-b3:
        if c[2][0]-b1 == c[2][1]-b2 and c[2][1]-b2 == c[2][2]-b3:
            print('Yes')
            sys.exit()
print('No')

Solution (Python):
c=[]
for i in range(3):
    c1=list(map(int,input().split()))
    c.append(c1)
ans='No'
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]:
                ans='Yes'
print(ans)

Solution (Python):
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

C = [[0,0,0,0]]
for i in range(3):
    C.append([0] + LI())

"""
yxの順
a1 + b1 = c11
a2 + b1 = c21
a3 + b1 = c31
a1 + b2 = c12
a2 + b2 = c22

b1 = b2 + c11 - c12
b2 = -a2 + c22
b1 = -a2 + c22 + c11 - c12
a2 - a2 + c22 + c11 - c12 = c21
c22+c11 = c21 + c12

"""

if (C[2][2] + C[1][1] - C[1][2] == C[2][1]) and (C[1][1] + C[3][3] == C[1][3] + C[3][1]) and (C[2][2] + C[3][3] == C[2][3] + C[3][2]):
    print("Yes")
else:
    print("No")

Solution (Python):
c = [list(map(int,input().split())) for i in range(3)]
for j in range(1,3):
    if not c[0][0]-c[j][0] == c[0][1] - c[j][1] == c[0][2] - c[j][2]:
        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(' '))
print('Yes') if c21-c11 == c22-c12 == c23-c13 and c31-c21 == c32-c22 == c33-c23 else print('No')

Solution (Python):
matrix = [list(map(int, input().split())) for _ in range(3)]
for j in range(2) :
  for i in range(3) :
    if(matrix[i][0] > 0 and matrix[i][1] > 0 and matrix[i][2] > 0) :
      matrix[i] = list(map(lambda x: x - min(matrix[i][0], matrix[i][1], matrix[i][2]), matrix[i]))
  matrix = [list(x) for x in zip(*matrix)]
if(matrix == [[0]*3]*3) : print("Yes")
else : print("No")

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

if (c12-c11 == c22-c21 == c32-c31
) and (c21-c11 == c22-c12 == c23-c13
) and (c31-c11 == c32-c12 == c33-c13):
  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]:
    if c[1][0] - c[2][0] == c[1][1] - c[2][1] == c[1][2] - c[2][2]:
        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]:
                print('Yes')
                exit()
print('No')

Solution (Python):
data = []

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



if data[0][1]-data[0][0] == data[1][1]-data[1][0] and data[1][1]-data[1][0]==data[2][1]-data[2][0] and data[0][2]-data[0][1]==data[1][2]-data[1][1] and data[1][2]-data[1][1]==data[2][2]-data[2][1]:
    x= 1
else:
    print("No")
    exit(0)



if data[1][0]-data[0][0]==data[1][1]-data[0][1] and data[1][1]-data[0][1]==data[1][2]-data[0][2] and data[2][0]-data[1][0] == data[2][1]-data[1][1] and data[2][2]-data[1][2]==data[2][1]-data[1][1]:
    x=1
else:
    print("No")
    exit(0)
print("Yes")

Solution (Python):
C=[list(map(int,input().split())) for i in range(3)]
for a1 in range(101):
  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 b1>=0 and b2>=0 and b3>=0 and a2>=0 and a3>=0:
    if a2+b2==C[1][1]:
      if a2+b2==C[1][1]:
        if a2+b3==C[1][2]:
          if a3+b1==C[2][0]:
            if a3+b2==C[2][1]:
              if a3+b3==C[2][2]:
                print('Yes')
                exit()
print('No')

Solution (Python):
def solve():
    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]==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] and \
       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]:
        return 'Yes'
    else:
        return 'No'

print(solve())

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

Solution (Python):
def solve(string):
    c11, c12, c13, c21, c22, c23, c31, c32, c33 = map(int, string.split())
    check = 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
    return "Yes" if check else "No"


if __name__ == '__main__':
    n = 3
    print(solve('\n'.join([input() for _ in range(n)])))

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

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

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

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

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


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

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

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

ans = True

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

for i in range(3) :
    for j in range(3) :
        if a[j] + b[i] != c[i][j] :
            ans = False

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

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

ans = False

for i in range(101) :
    a1 = 0
    b1 = c[0][0]
    b2 = c[0][1]
    b3 = c[0][2]
    a2 = c[1][0] - b1
    a3 = c[2][0] - b1
    a = []
    a.append(a1)
    a.append(a2)
    a.append(a3)
    if a2 + b2 != c[1][1] :
        continue
    elif a3 + b2 != c[2][1] :
        continue
    elif a2 + b3 != c[1][2] :
        continue
    elif a3 + b3 != c[2][2] :
        continue
    ans = True
    break

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

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

ans = False

for i in range(101) :
    for j in range(101) :
        for k in range(101) :
            b1 = c[0][0] - i
            b2 = c[1][0] - i
            b3 = c[2][0] - i
            if j + b1 != c[0][1] :
                continue
            elif j + b2 != c[1][1] :
                continue
            elif j + b3 != c[2][1] :
                continue
            elif k + b1 != c[0][2] :
                continue
            elif k + b2 != c[1][2] :
                continue
            elif k + b3 != c[2][2] :
                continue
            ans = True

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

Solution (Python):
c = [[int(x) for x in input().split()] for _ in range(3)]
for i in range(3):
    for j in range(3):
        ni = (i+1) % 3
        nj = (j+1) % 3
        if c[i][j] + c[ni][nj] != c[i][nj] + c[ni][j]:
            print("No")
            exit()
print("Yes")

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

def check():
  flag=True
  for i in range(2):
    for j in range(2):
      flag &= (mat[i+1][j]-mat[i][j])==(mat[i+1][j+1]-mat[i][j+1])
      flag &= (mat[i][j+1]-mat[i][j])==(mat[i+1][j+1]-mat[i+1][j])
  return flag


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

Solution (Python):
def main():
    c1 = list(map(int, input().split()))
    c2 = list(map(int, input().split()))
    c3 = list(map(int, input().split()))
    if abs(c1[0] - c1[1]) == abs(c2[0] - c2[1]) == abs(c3[0] - c3[1]) and \
            abs(c1[0] - c1[2]) == abs(c2[0] - c2[2]) == abs(c3[0] - c3[2]):
        print('Yes')
    else:
        print('No')


main()

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

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

a1 = 0
b1 = c_i_j[0][0] - a1
b2 = c_i_j[0][1] - a1
b3 = c_i_j[0][2] - a1
b = [b1, b2, b3]

flag = False
for i in range(1, 3):
    if len(set([c_i_j[i][j]-b[j] for j in range(3)])) != 1:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
def main():
    c = [[int(s) for s in input().split()] for _ in range(3)]
    if solve(c):
        print('Yes')
    else:
        print('No')

def solve(c):
    for i in range(1, 3):
        for j in range(1, 3):
            if c[i][j] - c[i][0] != c[0][j] - c[0][0]:
                return False
    
    return True

main()

Solution (Python):
import numpy as np
mat = [list(map(int, input().split())) for i in range(3)]
array = np.array(mat, dtype=np.int64)
a20 = array[2]-array[0]
a10 = array[1]-array[0]
b20 = array[:,2]-array[:,0]
b10 = array[:,1]-array[:,0]
flag  = False
if (a20==a20[0]).all() and (a10==a10[0]).all() and (b20==b20[0]).all() and (b10==b10[0]).all():
    for a1 in range(0, 101):
        a2 = a1+ a10[0]
        a3 = a1 + a20[0]
        b1 = array[0,0] - a1
        b2 = b1 + b10[0]
        b3 = b1 +b20[0]
        A = np.array([[a1, a2, a3]]).T
        B = np.array([[b1, b2, b3]])
        C = A+B
        if (C == array).all():
            flag =True
            break
if flag==True:
    print('Yes')
else:
    print('No')

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

val=0
for j in range(3):
  for i in range(3):
    val+=e[j][i]
val0=val//3

val1=e[0][0]+e[1][1]+e[2][2]
val2=e[1][0]+e[2][1]+e[0][2]
val3=e[2][0]+e[1][2]+e[0][1]
val4=e[2][0]+e[1][1]+e[0][2]
val5=e[2][2]+e[1][0]+e[0][1]
val6=e[0][0]+e[2][1]+e[1][2]

if val0==val1==val2==val3==val4==val5==val6:
  print('Yes')
else:
  print('No')

Solution (Python):
c = [list(map(int, input().split())) for i in range(3)]
vert1 = [c[1][i] - c[0][i] for i in range(3)]
vert2 = [c[2][i] - c[1][i] for i in range(3)]
horiz1 = [c[i][1]-c[i][0] for i in range(3)]
horiz2 = [c[i][2]-c[i][1] for i in range(3)]

if len(set(vert1)) == len(set(vert2)) == len(set(horiz1)) == len(set(horiz2)) == 1:
    print('Yes')
else:
    print('No')

Solution (Python):
import numpy as np
import itertools
a1row = np.array(list(map(int,input().split())))
a2row = np.array(list(map(int,input().split())))
a3row = np.array(list(map(int,input().split())))
amatrix = np.array([a1row,a2row,a3row])
a1a2row = amatrix[0,:]-amatrix[1,:]
a2a3row = amatrix[1,:]-amatrix[2,:]
a1a2col = amatrix[:,0]-amatrix[:,1]
a2a3col = amatrix[:,1]-amatrix[:,2]
flag1 = all(a1a2row == a1a2row[0])
flag2 = all(a2a3row == a2a3row[0])
flag3 = all(a1a2col == a1a2col[0])
flag4 = all(a2a3col == a2a3col[0])
if flag1*flag2*flag3*flag4:
    print('Yes')
else:
    print('No')

Solution (Python):


import itertools
import collections
import bisect

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

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

    print("No")


if __name__ == '__main__':
    main()

Solution (Python):
from sys import exit

G = [[int(n) for n in input().split()]for _ in range(3)]
ptr = [ [0,1],[1,2], [0,2]]
e1 = G[0][0] - G[1][0]
for p in ptr:
    e = G[0][p[0]] - G[0][p[1]]
    for h in range(1,3):
        if(e !=G[h][p[0]] - G[h][p[1]]):
            print("No")
            exit()
for p in ptr:
    e = G[p[0]][0] - G[p[1]][0]
    for w in range(1,3):
        if(e !=G[p[0]][w] - G[p[1]][w]):
            print("No")
            exit()
print("Yes")




exit()

Solution (Python):






C=[list(map(int,input().split())) for l in range(3)]
a=0
b=0
c=0
if C[0][0]-C[0][1]==C[1][0]-C[1][1] and C[1][0]-C[1][1]==C[2][0]-C[2][1]:
    a=1
if C[0][1]-C[0][2]==C[1][1]-C[1][2] and C[1][1]-C[1][2]==C[2][1]-C[2][2]:
    b=1
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]:
    c=1
if a==1 and b==1 and c==1:
    print('Yes')
else:
    print('No')

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

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

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


def main():
    flg = True

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

        if not flg:
            break

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


main()

Solution (Python):

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

b  = Cij[0][0] + Cij[1][1] == Cij[0][1] + Cij[1][0]
b &= Cij[1][1] + Cij[2][2] == Cij[2][1] + Cij[1][2]
b &= Cij[2][2] + Cij[0][0] == Cij[2][0] + Cij[0][2]

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

Solution (Python):
c = sum([[int(x) for x in input().split()] for _ in range(3)], [])
flag = True
if c[1]-c[0] != c[4]-c[3] or c[4]-c[3] != c[7]-c[6]:
    flag = False
elif c[2]-c[1] != c[5]-c[4] or c[5]-c[4] != c[8]-c[7]:
    flag = False
elif c[3]-c[0] != c[4]-c[1] or c[4]-c[1] != c[5]-c[2]:
    flag = False
elif c[6]-c[3] != c[7]-c[4] or c[7]-c[4] != c[8]-c[5]:
    flag = False

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

Solution (Python):
c=[list(map(int, input().split())) for i in range(3)]
def C(a,b):
    for i in range(3):
        for j in range(3):
            if c[i][j]!=a[i]+b[j]:
                return False
    return True 
def D():
    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 C([a1,a2,a3],[b1,b2,b3]):
                    return True
    return False
print('Yes' if D() else 'No')

Solution (Python):
def takahashis_information(C: list) -> bool:
    for a1 in range(C[0][0] + 1):
        b1 = C[0][0] - a1
        b2 = C[0][1] - a1
        b3 = C[0][2] - a1

        if b1 < 0 or b2 < 0 or b3 < 0:
            continue

        
        if C[1][0] - b1 != C[1][1] - b2:
            continue
        if C[1][1] - b2 != C[1][2] - b3:
            continue

        
        if C[2][0] - b1 != C[2][1] - b2:
            continue
        if C[2][1] - b2 != C[2][2] - b3:
            continue

        return True

    return False


if __name__ == "__main__":
    C = [[int(s) for s in input().split()] for _ in range(3)]
    yes = takahashis_information(C)
    print('Yes' if yes else 'No')

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

r = [sum([c[j][i] for i in range(3)]) for j in range(3)]
q = [sum([c[i][j] for i in range(3)]) for j in range(3)]
if (r[2]-r[1]) % 3 == 0 and (r[1]-r[0]) % 3 == 0 and (q[2]-q[1]) % 3 == 0 and (q[1]-q[0]) % 3 == 0:
    print('Yes')
else:
    print('No')

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

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

for i in range(2):
    a0 = c[i][0] - c[i+1][0]
    a1 = c[i][1] - c[i+1][1]
    a2 = c[i][2] - c[i+1][2]
    if a0 != a1 or a1 != a2:
        print("No")
        exit()

for i in range(2):
    a0 = c[0][i] - c[0][i+1]
    a1 = c[1][i] - c[1][i+1]
    a2 = c[2][i] - c[2][i+1]
    if a0 != a1 or a1 != a2:
        print("No")
        exit()
print("Yes")

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])  :
    print("No")
elif (C[0][1] + C[1][2]) != (C[0][2] + C[1][1])  :
    print("No")
elif (C[1][0] + C[2][1]) != (C[1][1] + C[2][0])  :
    print("No")
elif (C[1][1] + C[2][2]) != (C[1][2] + C[2][1])  :
    print("No")
else:
    print("Yes")

Solution (Python):
c = [list(map(int,input().split())) for i in range(3)]
ans = "No"
for a1 in range(100):
	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 a2+b2 == c[1][1] and a2+b3 == c[1][2] and a3+b2 == c[2][1] and a3+b3 == c[2][2]:
		ans = "Yes"
print(ans)

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

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

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):
c = []
for _ in range(3):
    ci = list(map(int, input().split()))
    c.append(ci)
row_list = [[0, 1], [1, 2], [0, 2], [0, 1]]
for i in range(len(row_list)-1):
    if c[row_list[i][0]][0] - c[row_list[i][1]][0] == c[row_list[i][0]][1] - c[row_list[i][1]][1] == c[row_list[i][0]][2] - c[row_list[i][1]][2] \
    and c[row_list[i+1][0]][0] - c[row_list[i+1][1]][0] == c[row_list[i+1][0]][1] - c[row_list[i+1][1]][1] == c[row_list[i+1][0]][2] - c[row_list[i+1][1]][2]:
        print("Yes")
        exit()
print("No")

Solution (Python):
[(a,b,c),(d,e,f),(g,h,i)]=[map(int,input().split())for _ in [0]*3]
print('Yes'if a-b==d-e==g-h and b-c==e-f==h-i else'No')

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

Solution (Python):
import sys

def main():
    input = sys.stdin.readline
    C = []
    s = 0
    for _ in range(3):
        c = list(map(int, input().split()))
        C.append(c)
        s += sum(c)
    if s % 3 != 0:
        print('No')
    else:
        p1 = C[0][0] - C[1][0] == C[0][1] - C[1][1] == C[0][2] - C[1][2]
        p2 = C[0][0] - C[2][0] == C[0][1] - C[2][1] == C[0][2] - C[2][2]
        p3 = C[1][0] - C[2][0] == C[1][1] - C[2][1] == C[1][2] - C[2][2]
        p4 = C[0][0] - C[0][1] == C[1][0] - C[1][1] == C[2][0] - C[2][1]
        p5 = C[0][0] - C[0][2] == C[1][0] - C[1][2] == C[2][0] - C[2][2]
        p6 = C[0][1] - C[0][2] == C[1][1] - C[1][2] == C[2][1] - C[2][2]

        if all([p1, p2, p3, p4, p5, p6]):
            print('Yes')
        else:
            print('No')



if __name__ == '__main__':
    main()

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

Solution (Python):

import copy
import numpy as np
import random

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

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



c = np.array(c)

for i in range(3):
    min_row = min(c[:,i])
    for j in range(3):
        c[j,i] -= min_row

if np.all(c==0):
    ans = True
else:
    ans = False
    
if ans:
    print("Yes")
else:
    print("No")

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

if __name__ == "__main__":
    main()

Solution (Python):
c = [list(map(int,input().split())) for _ in range(3)]
a = c[0][1]-c[0][0]
b = c[0][2]-c[0][1]
cc = c[1][0]-c[0][0]
d = c[2][0]-c[1][0]
for i in range(1,3):
    if not (c[i][1]-c[i][0])==a or not (c[i][2]-c[i][1])==b:
        print('No')
        exit()
    if not c[1][i]-c[0][i]==cc or not c[2][i]-c[1][i]==d:
        print('No')
        exit()
print('Yes')