Problem:
 Score: 300 points    Problem Statement  We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j) , where (i, j) denotes the square at the i -th row from the top and the j -th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j . Determine if he is correct.      Constraints   c_{i, j} \ (1 \leq i \leq 3, 1 \leq j \leq 3) is an integer between 0 and 100 (inclusive).         Input  Input is given from Standard Input in the following format:  c_{1,1}  c_{1,2}  c_{1,3}  c_{2,1}  c_{2,2}  c_{2,3}  c_{3,1}  c_{3,2}  c_{3,3}       Output  If Takahashi's statement is correct, print Yes ; otherwise, print No .        Sample Input 1 1 0 1
2 1 2
1 0 1      Sample Output 1 Yes  Takahashi is correct, since there are possible sets of integers such as: a_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1 .       Sample Input 2 2 2 2
2 1 2
2 2 2      Sample Output 2 No  Takahashi is incorrect in this case.       Sample Input 3 0 8 8
0 8 8
0 8 8      Sample Output 3 Yes       Sample Input 4 1 8 6
2 9 7
0 7 7      Sample Output 4 No

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

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

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

a1_a2 = c1[0] - c2[0]
a2_a3 = c2[0] - c3[0]
b1_b2 = c1[0] - c1[1]
b2_b3 = c1[1] - c1[2]

cnt = 0
if a1_a2 == c1[1]-c2[1] == c1[2]-c2[2]:
    cnt += 1
if a2_a3 == c2[1]-c3[1] == c2[2]-c3[2]:
    cnt += 1
if b1_b2 == c2[0]-c2[1] == c3[0]-c3[1]:
    cnt += 1
if b2_b3 == c2[1]-c2[2] == c3[1]-c3[2]:
    cnt += 1

if cnt == 4:
    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()))

f = 0
for a1 in range(min(c1)+1):
    b1 = c1[0]-a1
    b2 = c1[1]-a1
    b3 = c1[2]-a1

    a2_1 = c2[0]-b1
    a2_2 = c2[1]-b2
    a2_3 = c2[2]-b3
    if not (a2_1==a2_2 and a2_2==a2_3):
        continue

    a3_1 = c3[0]-b1
    a3_2 = c3[1]-b2
    a3_3 = c3[2]-b3
    if not (a3_1==a3_2 and a3_2==a3_3):
        continue

    print("Yes")
    f=1
    break

if not f:
    print("No")

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

Solution (Python):
field=[]
result="Yes"
for i in range(3):
  field.append(list(map(int,input().split())))
for i in range(3):
  for j in range(3):
    if not (field[i][j]>=0 and field[i][j]<=100*2):
      result="No"
    if j ==0:
      pos_i0=field[i][j]
    field[i][j]-=pos_i0
for j in range(3):
  if not (field[0][j]==field[1][j] and field[0][j]==field[2][j]):
    result="No"
print(result)

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+i == b+f+g == c+d+h:
  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+i == b+f+g == c+d+h == a+f+h == c+e+g == b+d+i:
  print("Yes")
else:
  print("No")

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

s=0
for i in range (3):
    for j in range(3):
        if i==j:
            s+=c[i][j]*2
        else:s-=c[i][j]

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

Solution (Python):
import numpy as np

M = np.array(list(map(int,open(0).read().split()))).reshape(3,3)

hSum = M.sum(axis=0)
vSum = M.sum(axis=1)

f=True
for i in range(3):
  if (hSum[i]-hSum[(i+1)%3])%3!=0:
    f = False

for i in range(3):
  if (vSum[i]-vSum[(i+1)%3])%3!=0:
    f = False
    
print("Yes" if f else "No")

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

for a1 in range(0, 101):
    b1 = c[0][0] - a1
    b2 = c[0][1] - a1
    b3 = c[0][2] - a1
    for a2 in range(0, 101):
        if not (b1 == (c[1][0] - a2) and b2 == (c[1][1] - a2) and b3 == (c[1][2] - a2)):
            continue
        for a3 in range(0, 101):
            if (b1 == (c[2][0] - a3) and b2 == (c[2][1] - a3) and b3 == (c[2][2] - a3)):
                print('Yes')
                sys.exit(0)
print('No')

Solution (Python):
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    c = [i_list() for i in range(3)]

    for i in range(1,3):
        t = c[i][0] - c[0][0]
        if c[i][1] - c[0][1] == t and  c[i][2] - c[0][2] == t:
            pass
        else:
            print("No")
            exit()

    for j in range(1,3):
        t = c[0][i] - c[0][0]
        if c[1][i] - c[1][0] == t and c[2][i] - c[2][0] == t:
            pass
        else:
            print("No")
            exit()
    print("Yes")




if __name__=="__main__":
    main()

Solution (Python):

"""
Created on Tue Sep 22 04:07:05 2020

@author: liang
"""

C = [[int (x) for x in input().split()] for _ in range(3)]
A = [0]*3
B = [0]*3

ans = False
for a1 in range(C[0][0]+1):
    tmp = True
    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:
        tmp = False
    if C[1][2] != a2+b3:
        tmp = False
    if C[2][1] != a3+b2:
        tmp = False
    if C[2][2] != a3+b3:
        tmp = False
    if tmp == True:
        ans = True
if ans:
    print("Yes")
else:
    print("No")

Solution (Python):
L = [list(map(int, input().split())) for _ in range(3)]
T = sum([sum(i) for i in L])
print('Yes' if L[0][0] + L[1][1] + L[2][2] == (T / 3) else 'No')

Solution (Python):
r1 = list(map(int, input().split()))
r2 = list(map(int, input().split()))
r3 = list(map(int, input().split()))
a = [0]*3
b = [0]*3
for i in range(101):
  a[0] = i
  for j in range(3):
    b[j] = r1[j]-a[0]
    
  a[1] = r2[0] - b[0]
  a[2] = r3[0] - b[0]

  flag = False
  for j in range(3):
    if r1[j]==a[0]+b[j] and r2[j]==a[1]+b[j] and r3[j] == a[2]+b[j]:
      flag = True
    else:
      flag = False
      break
  if flag:
    break
    
print("Yes") if flag else print("No")

Solution (Python):
l = []
for i in range(3):
    c1,c2,c3 = map(int, input().split())
    l.append([c1,c2,c3])


b1 = l[0][0]
b2 = l[1][0]
b3 = l[2][0]

flag = 0
for i in range(3):
    if not (l[0][1]-b1 == l[1][1]-b2 == l[2][1]-b3):
        flag = 1
    if not (l[0][2]-b1 == l[1][2]-b2 == l[2][2]-b3):
        flag = 1
if flag == 1:
    print('No' , flush=True)
else:
    print('Yes' , flush=True)

Solution (Python):



import sys


import pprint as pp

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]



MAXSIZE = ( 1 << 31 ) -1
MINSIZE = -( 1 << 31) + 1
yes = "Yes"
no = "No"

def solver(line00,line01,line02,
           line10,line11,line12,
           line20,line21,line22):

    result = no
    a0 = 0
    b0 = line00
    b1 = line01 - a0
    b2 = line02 - a0
    a1 = line10 -line00
    a2 = line20 - line00
    if (( a1 + b1 ) == line11) and (( a1 + b2 ) == line12
    ) and (( a2 + b1 ) == line21) and (( a2 + b2 ) == line22):
        result = yes
    return result


if __name__ == "__main__":
    line00 , line01, line02 = MI()
    line10 , line11, line12 = MI()
    line20 , line21, line22 = MI()
    print("{}".format(solver(line00, line01, line02,
                             line10, line11, line12,
                             line20, line21, line22)))

Solution (Python):
with open(0) as f:
    C = [list(map(int, line.split())) for line in f.readlines()]
b = [(C[i][1]-C[i][0], C[i][2]-C[i][1]) for i in range(3)]
a = [(C[1][j]-C[0][j], C[2][j]-C[1][j]) for j in range(3)]
print('Yes' if a[0]==a[1]==a[2] and b[0]==b[1]==b[2] else 'No')

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

if L[0][0] + L[1][1] != L[0][1] + L[1][0]: ans = 'No'
if L[0][1] + L[1][2] != L[0][2] + L[1][1]: ans = 'No'
if L[1][0] + L[2][1] != L[1][1] + L[2][0]: ans = 'No'
if L[1][1] + L[2][2] != L[1][2] + L[2][1]: ans = 'No'

print(ans)

Solution (Python):
import sys

input = sys.stdin.readline






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

for i in range(N):
    c1, c2, c3 = map(int, input().split())
    c[i][0] = c1
    c[i][1] = c2
    c[i][2] = c3


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

flag = True
for i in range(N):
   for j in range(N):
       numx = x[i]
       numy = y[j]
       if not numx + numy == c[i][j]:
           flag = False
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):

import sys
c = [list(map(int,input().split())) for i 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")
    sys.exit()
if not(c[0][0] - c[0][2] == c[1][0] - c[1][2] == c[2][0] - c[2][2]):
    print("No")
    sys.exit()
if not(c[0][1] - c[0][2] == c[1][1] - c[1][2] == c[2][1] - c[2][2]):
    print("No")
    sys.exit()
if not(c[0][0] - c[1][0] == c[0][1] - c[1][1] == c[0][2] - c[1][2]):
    print("No")
    sys.exit()
if not(c[0][0] - c[2][0] == c[0][1] - c[2][1] == c[0][2] - c[2][2]):
    print("No")
    sys.exit()
if not(c[1][0] - c[2][0] == c[1][1] - c[2][1] == c[1][2] - c[2][2]):
    print("No")
    sys.exit()
print("Yes")

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

for a1 in range(0, 101):
    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
    a2 = C[1][0] - b1
    if a2 < 0 or C[1][1] - b2 != C[1][2] - b3 or C[1][1] - b2 != a2:
        continue
    a3 = C[2][0] - b1
    if a3 < 0 or a3 != C[2][1]- b2 or a3 != C[2][2] - b3:
        continue
    print ("Yes")
    exit()
print ("No")

Solution (Python):
C1 = list(map(int,input().split()))
C2 = list(map(int,input().split()))
C3 = list(map(int,input().split()))

if C1[0]-C1[1]==C2[0]-C2[1]==C3[0]-C3[1] and C1[1]-C1[2]==C2[1]-C2[2]==C3[1]-C3[2] and C1[0]-C2[0]==C1[1]-C2[1]==C1[2]-C2[2] and C2[0]-C3[0]==C2[1]-C3[1]==C2[2]-C3[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()))

diff0 = [x - y for x, y in zip(c[0], c[1])]
diff1 = [x - y for x, y in zip(c[0], c[2])]
 
if diff0[0] == diff0[1] and diff0[0] == diff0[2] and diff1[0] == diff1[1] and diff1[0] == diff1[2]:
    print('Yes')
else:
    print('No')

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

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

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

diff0 = [x - y for x, y in zip(c[0], c[1])]
diff1 = [x - y for x, y in zip(c[0], c[2])]

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

Solution (Python):


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


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

check = []
check.append(c[1][1] == a2+b2)
check.append(c[2][1] == a3+b2)
check.append(c[1][2] == a2+b3)
check.append(c[2][2] == a3+b3)

if sum(check) == 4:
    print("Yes")
else:
    print("No")

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

ans = "Yes"

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

print(ans)

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

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

Solution (Python):
x=list(map(int, input().split()))
y=list(map(int, input().split()))
z=list(map(int, input().split()))
if x[1]-x[0] != y[1]-y[0] or y[1]-y[0] != z[1]-z[0] or x[2]-x[0] != y[2]-y[0] or y[0]-x[0] !=y[1]-x[1] or z[1]-x[1] !=z[2]-x[2] or z[0]-x[0] !=z[1]-x[1] or z[1]-x[1] !=z[2]-x[2] :
    print('No')
else:
    print('Yes')

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

if sum(tc) % 3 != 0:
  print('No')
else:
  cnt = 0
  for i in range(3):
    cnt  += cc[i][i]
  if cnt == sum(tc)//3:
    print('Yes')
  else:
    print('No')

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

ans = False
for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            ok = True
            b1 = c[0][0] - a1
            b2 = c[0][1] - a1
            b3 = c[0][2] - a1
            if c[1][0] != a2 + b1 or \
               c[1][1] != a2 + b2 or \
               c[1][2] != a2 + b3 or \
               c[2][0] != a3 + b1 or \
               c[2][1] != a3 + b2 or \
               c[2][2] != a3 + b3:
               ok = False
            if ok:
                ans = True

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

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

f = True
for j in range(2):
    x = c[j][0] - c[j + 1][0]
    y = c[0][j] - c[0][j + 1]
    for i in range(3):
        if c[j][i] - c[j + 1][i] != x:
            f = False
        if c[i][j] - c[i][j + 1] != y:
            f = False
print(['No', 'Yes'][int(f)])

Solution (Python):
A = list(map(int, input().split()))
x = A[1] - A[0]
y = A[2] - A[1]
f = 0
for i in range(2):
  B = list(map(int, input().split()))
  if B[1] - B[0] != x or B[2] - B[1] != y:
    f = 1
    break
if f == 0:
  print("Yes")
else:
  print("No")

Solution (Python):
mycode = r'''





ctypedef long long LL
from libc.stdio cimport scanf, printf

cdef LL a,b,c,_,i
cdef LL[3][3] C
for i in range(3):
    scanf('%lld %lld %lld', &C[i][0],&C[i][1],&C[i][2])

    
cdef LL a0,a1,a2,b0,b1,b2
cdef bint flg=0
for a0 in range(101):
    b0=C[0][0]-a0
    b1=C[0][1]-a0
    b2=C[0][2]-a0
    for a1 in range(101):
        for a2 in range(101):
            if b0 == C[1][0]-a1 and b1==C[1][1]-a1 and b2==C[1][2]-a1 and b0 == C[2][0]-a2 and b1==C[2][1]-a2 and b2==C[2][2]-a2:
                if flg==0:
                   printf("Yes")
                flg=1
if flg==0:
    printf('No')

'''

import sys
import os
if sys.argv[-1] == 'ONLINE_JUDGE':  
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode

Solution (Python):
mycode = r'''





ctypedef long long LL
from libc.stdio cimport scanf

cdef LL a,b,c,_,i
cdef LL[3][3] C
for i in range(3):
    scanf('%lld %lld %lld', &C[i][0],&C[i][1],&C[i][2])

    
cdef LL a0,a1,a2,b0,b1,b2
cdef bint flg=0
for a0 in range(101):
    b0=C[0][0]-a0
    b1=C[0][1]-a0
    b2=C[0][2]-a0
    for a1 in range(101):
        for a2 in range(101):
            if b0 == C[1][0]-a1 and b1==C[1][1]-a1 and b2==C[1][2]-a1 and b0 == C[2][0]-a2 and b1==C[2][1]-a2 and b2==C[2][2]-a2:
                print("Yes")
                exit()
print('No')


'''

import sys
import os
if sys.argv[-1] == 'ONLINE_JUDGE':  
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode

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

for i in range(1,3,1):
    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):

import numpy as np



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

arr_c = np.array(c)
a_max = np.amax(arr_c, axis=1)
b_max = np.amax(arr_c, axis=0)

a = []
b = []
for i in range(3):
    if len(list(range(0, a_max[i]+1, 1)))==0:
        a.append([0])
    else:
        a.append(list(range(0, a_max[i]+1, 1)))
    
    if len(list(range(0, b_max[i]+1, 1)))==0:
        b.append([0])
    else:
        b.append(list(range(0, b_max[i]+1, 1)))

ans = 'No'
cnt = 0
for a0 in a[0]:
    for b0 in b[0]:
        if c[0][0] != a0 + b0:
            continue
        for a1 in a[1]:
            if c[1][0] != a1 + b0:
                continue
            for b1 in b[1]:
                if c[0][1] != a0 + b1 or c[1][1] != a1 + b1:
                    continue   
                for a2 in a[2]:
                    if c[2][0] != a2 + b0 or c[2][1] != a2 + b1:
                        continue
                    for b2 in b[2]:
                        if c[0][2] != a0 + b2 or c[1][2] != a1 + b2 or c[2][2] != a2 + b2:
                            continue

                        print("Yes")
                        exit(0)

print(ans)

Solution (Python):

import numpy as np



def check(a, b, c):
    flag = True
    for i in range(3):
        for j in range(3):
           if c[i][j]!=a[i]+b[j]:
               flag = False
               return flag

    return flag

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

arr_c = np.array(c)
a_max = np.amax(arr_c, axis=1)
b_max = np.amax(arr_c, axis=0)

a = []
b = []
for i in range(3):
    if len(list(range(0, a_max[i]+1, 1)))==0:
        a.append([0])
    else:
        a.append(list(range(0, a_max[i]+1, 1)))
    
    if len(list(range(0, b_max[i]+1, 1)))==0:
        b.append([0])
    else:
        b.append(list(range(0, b_max[i]+1, 1)))

ans = 'No'
cnt = 0
for a0 in a[0]:
    for b0 in b[0]:
        if c[0][0] != a0 + b0:
            continue
        for a1 in a[1]:
            if c[1][0] != a1 + b0:
                continue
            for b1 in b[1]:
                if c[0][1] != a0 + b1 or c[1][1] != a1 + b1:
                    continue   
                for a2 in a[2]:
                    if c[2][0] != a2 + b0 or c[2][1] != a2 + b1:
                        continue
                    for b2 in b[2]:
                        if c[0][2] != a0 + b2 or c[1][2] != a1 + b2 or c[2][2] != a2 + b2:
                            continue

                        print("Yes")
                        exit(0)

print(ans)

Solution (Python):
def LIHW(h):
    return [list(map(int, input().split())) for _ in range(h)]
 
 
masu = LIHW(3)
ans = "Yes"
for i in range(2):
    if masu[i+1][1]-masu[i+1][0] != masu[0][1]-masu[0][0]:
        ans = "No"
    if masu[i+1][2]-masu[i+1][1] != masu[0][2]-masu[0][1]:
        ans = "No"
for i in range(2):
    if masu[1][i+1]-masu[0][i+1] != masu[1][0]-masu[0][0]:
        ans = "No"
    if masu[2][i+1]-masu[1][i+1] != masu[2][0]-masu[1][0]:
        ans = "No"
print(ans)

Solution (Python):
def LIHW(h):
    return [list(map(int, input().split())) for _ in range(h)]


masu = LIHW(3)
ans = "Yes"
for i in range(2):
    if masu[i+1][1]-masu[i+1][0] != masu[0][1]-masu[0][0]:
        ans = "No"
    if masu[i+1][2]-masu[i+1][1] != masu[0][2]-masu[0][1]:
        ans = "No"
for i in range(2):
    if masu[1][i+1]-masu[0][i+1] != masu[1][0]-masu[0][0]:
        ans = "No"
    if masu[2][i+1]-masu[1][i+1] != masu[2][0]-masu[1][0]:
        ans = "No"
print(ans)

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

check = False
for i in range(101):
  for j in range(101):
    for k in range(101):
      o = c[0][0] - i
      p = c[1][1] - j
      q = c[2][2] - k
      
      if o < 0 or p < 0 or q < 0:
        continue
      
      ls = [[i+o,i+p,i+q],[j+o,j+p,j+q],[k+o,k+p,k+q]]
      if ls == c:
        check = True
        break
        
print("Yes" if check else "No")

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

Solution (Python):
xy = [list(map(int, input().split())) for i in range(3)]
result = sum(map(sum, xy))
if result % 3 != 0:
    print("No")
    exit()
if result != (xy[0][0]+xy[1][1]+xy[2][2]) * 3:
    print("No")
    exit()
if result != (xy[0][2]+xy[1][1]+xy[2][0]) * 3:
    print("No")
    exit()
else:
    print("Yes")

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate, product 

from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect














import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7


from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
C = [readInts() for _ in range(3)]
A = [0] * 3
B = [0] * 3
A[0] = 0
for i in range(3):
    B[i] = C[0][i]
for j in range(3):
    A[j] = C[j][0] - B[0]
for i in range(3):
    for j in range(3):
        if A[i] + B[j] == C[i][j]:
            pass
        else:
            print('No')
            exit()
print('Yes')

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



b1, b2, b3 = c[0][0], c[0][1], c[0][2]

if c[1][0] - b1 == c[1][1] - b2 == c[1][2] - b3 and c[2][0] - b1 == c[2][1] - b2 == c[2][2] - b3:
    print('Yes')
else:
    print('No')

Solution (Python):
c = [list(map(int, input().split())) for _ in range(3)]
flag = True
for i in range(3):
  x = [0]*3
  y = [0]*3
  for j in range(3):
    x[j] = c[i-1][j] - c[i][j]
    y[j] = c[j][i-1] - c[j][i]
  if len(set(x)) != 1 or len(set(y)) != 1:
    flag = False
if flag:
  print("Yes")
else:
  print("No")

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

Solution (Python):
from sys import exit
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")
    exit()
if not (C[0][0] - C[0][2] == C[1][0] - C[1][2] == C[2][0] - C[2][2]):
    print("No")
    exit()
if not (C[0][2] - C[0][1] == C[1][2] - C[1][1] == C[2][2] - C[2][1]):
    print("No")
    exit()

print("Yes")

Solution (Python):
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial

from functools import reduce
from pprint import pprint
from statistics import mean,median,mode
import sys
sys.setrecursionlimit(10 ** 6)

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

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

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

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

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]







c = LI(3)

for a1 in range(c[0][0]+1):
    
    a = []
    b = []
    a.append( a1 )
    b.append( c[0][0] - a1 )
    b.append( c[0][1] - a1 )
    b.append( c[0][2] - a1 )
    a.append( c[1][0] - b[0] )
    a.append( c[2][0] - b[0] )
    if a[1]+b[1]==c[1][1] and a[1]+b[2]==c[1][2] and a[2]+b[1]==c[2][1] and a[2]+b[2]==c[2][2]:
        print("Yes")
        exit()
print("No")
exit()

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

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

flag = 1

for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            if c[0][0] - a1 == c[1][0] - a2 and c[1][0] - a2 == c[2][0] - a3:
                if c[0][1] - a1 == c[1][1] - a2 and c[1][1] - a2 == c[2][1] - a3:
                    if c[0][2] - a1 == c[1][2] - a2 and c[1][2] - a2 == c[2][2] - a3:
                        flag = 0

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

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

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

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

            a = [a1, a2, a3]
            b = [b1, b2, b3]

            cnt = 0
            for i in range(3):
                for j in range(3):
                    if l[i][j] == a[i] + b[j]:
                        cnt += 1
            if cnt == 9:
                print("Yes")
                exit()
print("No")

Solution (Python):
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right 
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

c = [lint() for _ in range(3)]
judge(
    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[2][0]-c[1][0]==c[2][1]-c[1][1]==c[2][2]-c[1][2]
)

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

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


def solve(c: "List[List[int]]"):
    from itertools import product
    for a1, b1 in product(range(101), repeat=2):
        a2 = c[1][0] - b1
        a3 = c[2][0] - b1
        b2 = c[0][1] - a1
        b3 = c[0][2] - a1
        if a2 < 0 or a3 < 0 or b2 < 0 or b3 < 0:
            continue
        a = [a1, a2, a3]
        b = [b1, b2, b3]
        if all((a[i]+b[j])==c[i][j] for i, j in product(range(3), repeat=2)):
            return YES
    return NO


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    c = [[int(next(tokens)) for _ in range(3)] for _ in range(3)]  
    print(solve(c))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    
    main()

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

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