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):
import sys
check_ary = [[0 for i in range(3)]for i in range(2)]
num_ary = [[0 for i in range(3)]for i in range(3)]
check_minus = False

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

for i in range(num_ary[0][0]+1):

    for x in range(3):
        check_ary[1][x] = num_ary[0][x] - i

    for a in range(3):
        check_ary[0][a] = num_ary[a][0] - check_ary[1][0]

    for x in range(3):
        for y in range(3):
            if not check_ary[0][x] + check_ary[1][y] == num_ary[x][y]:
                break
        else:
            continue
        break
    else :
        print("Yes")
        sys.exit()

print("No")

Solution (Python):
nums_ary = [[0 for i in range(3)] for i in range(3)]
check_ary = [[0 for i in range(3)] for i in range(2)]
good = True

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

check_ary[0][0] = 0

for x in range(3):
    check_ary[1][x] = nums_ary[0][x] - check_ary[0][0]

for y in range(3):
    check_ary[0][y] = nums_ary[y][0] - check_ary[1][0]

for x in range(3):
    for y in range(3):
        if not check_ary[0][x] + check_ary[1][y] == nums_ary[x][y]:
            good = False

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

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

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

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

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

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

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

print('Yes')

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

Q=[]
a1=0
b1=Z[0][0]-a1
b2=Z[0][1]-a1
b3=Z[0][2]-a1
a2=Z[1][0]-b1
a3=Z[2][0]-b1
c1=[a1+b1,a1+b2,a1+b3]
c2=[a2+b1,a2+b2,a2+b3]
c3=[a3+b1,a3+b2,a3+b3]
Q.append(c1)
Q.append(c2)
Q.append(c3)

if Z==Q:
    print("Yes")
else:
    print("No")

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

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

def exit_if_not_eq(i, j):
    if i != j:
        print("No")
        exit()

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


for i in range(C[0][0]+1):
    a1 = i
    b1 = C[0][0] - a1
    if b1 < 0:
        continue
    b2 = C[0][1] - a1
    if b2 < 0:
        continue
    b3 = C[0][2] - a1
    if b3 < 0:
        continue
    a2 = C[1][0] - b1
    if a2 < 0:
        continue
    if C[1][1] != a2 + b2:
        continue
    if C[1][2] != a2 + b3:
        continue
    a3 = C[2][0] - b1
    if a3 < 0:
        continue
    if C[2][1] != a3 + b2:
        continue
    if C[2][2] != a3 + b3:
        continue
    print("Yes")
    exit()
print("No")

Solution (Python):
import numpy as np
A= np.array([list(map(int,input().split())) for I in range (3)])

for I in range (3):
    j,k,l = A[1]-A[0]
    if not (j==k and k==l):
        print ( "No")
        quit()
    j,k,l = A[2]-A[0]
    if not (j==k and k==l):
        print ( "No")
        quit()
print("Yes")

Solution (Python):
import numpy as np
A= np.array([list(map(int,input().split())) for I in range (3)])

for I in range (2):
    j,k,l = A[1]-A[0]
    if not (j==k and k==l):
        print ( "No")
        quit()
    j,k,l = A[2]-A[0]
    if not (j==k and k==l):
        print ( "No")
        quit()
print("Yes")

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

ans = "No"

for a_1 in range(101):
  b_1 = c[0][0] - a_1
  b_2 = c[0][1] - a_1
  b_3 = c[0][2] - a_1
  a_2 = c[1][0] - b_1
  a_3 = c[2][0] - b_1
  if a_2+b_2==c[1][1] and a_2+b_3==c[1][2] and a_3+b_2==c[2][1] and a_3+b_3==c[2][2]:
    ans = "Yes"
    break

print(ans)

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

ans = False

for a_1 in range(101):
	b_1 = c[0][0] - a_1
	b_2 = c[0][1] - a_1
	b_3 = c[0][2] - a_1
	a_2 = c[1][0] - b_1
	a_3 = c[2][0] - b_1
	if 	a_2+b_2==c[1][1] and a_2+b_3==c[1][2] and a_3+b_2==c[2][1] and a_3+b_3==c[2][2]:
		ans = True
		break

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

Solution (Python):
def divisors(n, sort=False):
    """
    nの約数をO(√n)で列挙する
    """
    d = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            d.append(i)
            if i != n // i:
                d.append(n//i)
    if sort:
        d.sort()
    return d


C = [list(map(int, input().split())) for _ in range(3)]
if sum([sum(r) for r in C]) == 0:
    print('Yes')
    exit(0)
    
for a0 in divisors(sum(C[0])):
    a = [a0, None, None]
    b = [None, None, None]
    b[0] = C[0][0] - a[0]
    a[1] = C[1][0] - b[0]
    a[2] = C[2][0] - b[0]
    b[1] = C[0][1] - a[0]
    b[2] = C[0][2] - a[0]
    ok = True
    for i in range(3):
        for j in range(3):
            if C[i][j] != a[i] + b[j]:
                ok = False
    if ok:
        print('Yes')
        exit(0)
print('No')

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

ans = False

for a_1 in range(101):
	b_1 = c[0][0] - a_1
	b_2 = c[0][1] - a_1
	b_3 = c[0][2] - a_1
	a_2 = c[1][0] - b_1
	a_3 = c[2][0] - b_1
	if 	a_2+b_2==c[1][1] and a_2+b_3==c[1][2] and a_3+b_2==c[2][1] and a_3+b_3==c[2][2]:
		ans = True
		break

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

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



def chk(al,bl,li) :
  for i in range(3) :
    for j in range(3) :
      if li[i][j]!=al[i]+bl[j] :
        return False
  return True
        
        
  

flag=True
for a1 in range(max(li[0])+1):
  al=[]
  bl=[]
  
  bl=[li[0][0]-a1,li[0][1]-a1,li[0][2]-a1]
  
  al.append(a1)
  al.append(li[1][0]-bl[0])
  al.append(li[2][0]-bl[0])
  
  if chk(al,bl,li) :
    print("Yes")
    exit()
print("No")

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

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

a_list = [0]
b_list = []

for c in c_list[0]:
    b = c - a_list[0]
    b_list.append(b)

for i in range(1,3):
    c = c_list[i][0]
    b = b_list[0]
    a = c - b
    a_list.append(a)

def check():
    for i in range(3):
        for j in range(3):
            a = a_list[i]
            b = b_list[j]
            c = c_list[i][j]
            if not c == a + b:
                return False
    return True

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

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

if A[0][0]-A[1][0]!=A[0][1]-A[1][1]:
    print('No')
    exit(0)

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

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

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

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())
o = p = q = r = 0
if (a - b) == (d - e) == (g - h):
  o = 1
if (b - c) == (e - f) == (h - i):
  p = 1
if (a - d) == (b - e) == (c - f):
  q = 1
if (d - g) == (e - h) == (f - i):
  r = 1
if o == p == q == r == 1:
  print("Yes")
else:
  print("No")

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

d = []
for i in range(3):
  sum = 0
  d.append([])
  for j in range(3):
    sum += c[i][j]
  for j in range(3):
    d[i].append(3*c[i][j] - sum)
    
for i in range(3):
  if d[0][i]==d[1][i] and d[0][i]==d[2][i]:
    pass
  else:
    print('No')
    break
else:
  print('Yes')

Solution (Python):
c = list
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
c=[p,q,r]
br = 0
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]):
      None
    else:
      br+=1
      break
if(br==0):
  print("Yes")
else:
  print("No")

Solution (Python):







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


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


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

print('Yes')

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

for i in range(2):
    dist = c[i+1][0] - c[i][0]
    if c[i+1][1] - c[i][1] == dist and c[i+1][2] - c[i][2] == dist:
        continue
    else:
        print('No')
        exit()

for i in range(2):
    dist = c[0][i+1] - c[0][i]
    if c[1][i+1] - c[1][i] == dist and c[2][i+1] - c[2][i] == dist:
        continue
    else:
        print('No')
        exit()

print('Yes')

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]) and (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]) and (c[1][1]-c[1][2] == c[2][1]-c[2][2]):
  print('Yes')
else:
  print('No')

Solution (Python):
import numpy as np

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

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

Aplus = np.array([
    [1, 0, 0, 1, 0, 0, C[0][0]],
    [0, 1, 0, 1, 0, 0, C[1][0]],
    [0, 0, 1, 1, 0, 0, C[2][0]],
    [1, 0, 0, 0, 1, 0, C[0][1]],
    [0, 1, 0, 0, 1, 0, C[1][1]],
    [0, 0, 1, 0, 1, 0, C[2][1]],
    [1, 0, 0, 0, 0, 1, C[0][2]],
    [0, 1, 0, 0, 0, 1, C[1][2]],
    [0, 0, 1, 0, 0, 1, C[2][2]],
])

rankA = np.linalg.matrix_rank(A)
rankAp = np.linalg.matrix_rank(Aplus)

if rankA == rankAp:
    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())))
ans = "Yes"
for i in range(3):
    a1 = c[1][i]-c[0][i]
    a2 = c[2][i]-c[1][i]
    a3 = c[i][2]-c[i][1]
    a4 = c[i][1]-c[i][0]
    l = [a1,a2,a3,a4]
    if i == 0:
        p = l
    else:
        if p!=l:
            ans = "No"
print(ans)

Solution (Python):
def main():
    c = [[0] * 3] * 3

    for i in range(3):
        c[i] = 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[2][0]) == (c[0][1] - c[2][1]) == (c[0][2] - c[2][2]):
                print('Yes')
                exit()
    print('No')

main()

Solution (Python):

import collections
import itertools

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

grid = [getints() for i in range(3)]


def normalize(grid):
    if not grid:
        return
    line = grid[0]
    mx = min(line)
    for j in range(3):
        line[j] -= mx
    normalize(grid[1:])

normalize(grid)

ok = grid[0] == grid[1] and grid[1] == grid[2]

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

Solution (Python):
n = [[0 for i in range(3)] for j in range(3)]

for i in range(3):
  x,y,z = input().split()
  n[i][0] = int(x)
  n[i][1] = int(y)
  n[i][2] = int(z)
  
a = [0,0,0]
b = [0,0,0]



isCmp = False

for j in range(100 +1):
  b[0] = j
  
  a[0] = n[0][0] -b[0]
  a[1] = n[1][0] -b[0]
  a[2] = n[2][0] -b[0]
  b[1] = n[0][1] -a[0]
  b[2] = n[0][2] -a[0]
  
  isCmp = True
  
  for l in range(3):
    for m in range(3):
      if n[l][m] != a[l] + b[m]:
        isCmp = False
        
    if isCmp == False:
      break
      
  if isCmp == True:
    print('Yes')
    isCmp = True
    break
    
if isCmp == False:
  print('No')

Solution (Python):
mat=[]
for _ in range(3):
    c=list(map(int,input().split()))
    mat.append([
        c[1]-c[0],
        c[2]-c[1],
        c[0]-c[2]
    ])
for v in zip(*mat):
    if v[0]!=v[1] or v[1]!=v[2]:
        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()))

if 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):
grid = [list(map(int, input().split())) for i in range(3)]
b0_1 = set()
b1_2 = set()
a0_1 = set()
a1_2 = set()

for a in range(3):
    b0_1.add(grid[a][0] - grid[a][1])
    b1_2.add(grid[a][1] - grid[a][2])

for b in range(3):
    a0_1.add(grid[0][b] - grid[1][b])
    a1_2.add(grid[1][b] - grid[2][b])

if len(b0_1) == 1 and len(b1_2) == 1 and len(a0_1) == 1 and len(a1_2) == 1:
    print('Yes')
else:
    print('No')

Solution (Python):
box=[list(map(int,input().split())) for i in range(3)]
flag=1
for j in range(3):
    checker=[]
    for i in range(3):
        if j==2:
            a11=box[j][i]-box[0][i]
        else:
            a11=box[j][i]-box[j+1][i]
        checker.append(a11)
    if checker.count(checker[0])==3:
        continue
    else:
        flag=0
        break

for j in range(3):
    checker=[]
    for i in range(3):
        if j==2:
            a11=box[i][j]-box[i][0]
        else:
            a11=box[i][j]-box[i][j+1]
        checker.append(a11)
    if checker.count(checker[0])==3:
        continue
    else:
        flag=0
        break
if flag:print("Yes")
else:print("No")

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

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

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

for i in range(3):
    if a != c[i][1] -c[i][0]:
        print("No")
        break
    if b != c[i][2]-c[i][1]:
        print("No")
        break
else:
    print("Yes")

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  

def solve(c: "List[List[int]]"):

    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(a1+b1 == c[0][0] and a2+b1 == c[1][0] and a3+b1 == c[2][0] and 
        a1+b2 == c[0][1] and a2+b2 == c[1][1] and a3+b2 == c[2][1] and 
        a1+b3 == c[0][2] and a2+b3 == c[1][2] and a3+b3 == c[2][2]):
            print(YES)
            exit()

    print(NO)

    return



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) ]  
    solve(c)

if __name__ == '__main__':
    main()

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

Solution (Python):
*m,=map(int,open(0).read().split())
b=m[:3]
a=[0,m[3]-b[0],m[6]-b[0]]
for i in range(9):
  if m[i]!=a[i//3]+b[i%3]:
    print("No")
    exit()
print("Yes")

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

if (lst[1][0] - lst[0][0] == lst[1][1] - lst[0][1] == lst[1][2] - lst[0][2] and\
    lst[2][0] - lst[0][0] == lst[2][1] - lst[0][1] == lst[2][2] - lst[0][2]):
    print('Yes')
else:
    print('No')

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

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

    r1max = max([c11, c12, c13])
    r2max = max([c21, c22, c23])
    r3max = max([c31, c32, c33])
    c1max = max([c11, c21, c31])
    c2max = max([c12, c22, c32])
    c3max = max([c13, c23, c33])
    for a1 in range(0, r1max + 1):
        for a2 in range(0, r2max + 1):
            for a3 in range(0, r3max + 1):
                m = max([a1, a2, a3])
                for b1 in range(0, c1max - m + 1):
                    if a1 + b1 == c11 and a2 + b1 == c21 and a3 + b1 == c31:
                        for b2 in range(0, c2max - m + 1):
                            if a1 + b2 == c12 and a2 + b2 == c22 and a3 + b2 == c32:
                                for b3 in range(0, c3max - m + 1):
                                    if a1 + b3 == c13 and a2 + b3 == c23 and a3 + b3 == c33:
                                        print('Yes')
                                        return

    print('No')
    return


if __name__ == '__main__':
    main()

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

    r1max = max([c11, c12, c13])
    r2max = max([c21, c22, c23])
    r3max = max([c31, c32, c33])
    c1max = max([c11, c21, c31])
    c2max = max([c12, c22, c32])
    c3max = max([c13, c23, c33])
    for a1 in range(0, r1max + 1):
        for a2 in range(0, r2max + 1):
            for a3 in range(0, r3max + 1):
                m = max([a1, a2, a3])
                for b1 in range(0, c1max - m + 1):
                    C11 = a1 + b1
                    C21 = a2 + b1
                    C31 = a3 + b1
                    if C11 == c11 and C21 == c21 and C31 == c31:
                        for b2 in range(0, c2max - m + 1):
                            C12 = a1 + b2
                            C22 = a2 + b2
                            C32 = a3 + b2
                            if C12 == c12 and C22 == c22 and C32 == c32:
                                for b3 in range(0, c3max - m + 1):
                                    C13 = a1 + b3
                                    C23 = a2 + b3
                                    C33 = a3 + b3
                                    if C13 == c13 and C23 == c23 and C33 == c33:
                                        print('Yes')
                                        return

    print('No')
    return


if __name__ == '__main__':
    main()

Solution (Python):

import sys, math, fractions, itertools

YES = "Yes"  
NO = "No"  

def solve(c: "List[List[int]]"):
    flag = True
    for i in range(2):
        D = []
        for j in range(3):
            d = c[i+1][j] - c[i][j]
            D.append(d)
        if len(set(D)) != 1:
            flag = False
    for i in range(2):
        D = []
        for j in range(3):
            d = c[j][i+1] - c[j][i]
            D.append(d)
        if len(set(D)) != 1:
            flag = False
    if flag:
        print('Yes')
    else:
        print('No')
    return



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) ]  
    solve(c)

if __name__ == '__main__':
    main()

Solution (Python):
a = [list(map(int,input().split())) for i in range(3)]
x = [0]*3
y = [0]*3
flag = 0
for i in range(3):
    y[i] = a[0][i]
    x[i] = a[i][0] - y[0]
for j in range(3):
    for k in range(3):
        if not a[j][k] == (x[j] + y[k]):
            flag = 1
            break
if flag == 0:
    print('Yes')
else:
    print('No')

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

if (X[1][0] - X[0][0] == X[1][1] - X[0][1] == X[1][2] - X[0][2] and\
	X[2][0] - X[0][0] == X[2][1] - X[0][1] == X[2][2] - X[0][2]):
	print("Yes")
else:
	print("No")

Solution (Python):

li = [list(map(int, input().split())) for _ in range(3)]
sum1 = li[0][0] + li[1][1] + li[2][2]
sum2 = li[1][0] + li[2][1] + li[0][2]
sum3 = li[2][0] + li[0][1] + li[1][2]
if sum1 ==sum2 and sum2 == sum3:
    print("Yes")
else:
    print("No")

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

a = [0]*3
b = [0]*3
a[0] = 0
b[0] = c[0]
a[1] = c[3] - b[0]
b[1] = c[4] - a[1]
a[2] = c[6] - b[0]
b[2] = c[8] - a[2]

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

Solution (Python):
c=[[0 for i in range(3)] for j in range(3)]


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

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

def validation(lol):
    ans = True
    for i in range(len(lis)):
        for j in range(len(lis)):
            if i == j:
                break
            x = list(map(lambda x, y: x-y, c[i], c[j]))
            if len(set(x)) != 1:
              ans = False
            
    return ans

lis = []

for i in range(3):
    temp = []
    for j in range(3):
        temp.append(c[j][i])
    lis.append(temp)

if validation(c) and validation(lis):
    print("Yes")
else:
    print("No")

Solution (Python):
a,b,c=map(int,input().split())
s='Yes'
for _ in [0]*2:
    x,y,z=map(int,input().split())
    if not x-a==y-b==z-c:s='No'
print(s)

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

for j in range(3):
    if j+1 == 3:
        p = 0
    else:
        p = j+1
    tmp = C[j][2]-C[p][2]
    for i in range(2):
        if C[j][i]-C[p][i] != tmp:
            print('No')
            exit()

print('Yes')

Solution (Python):


from collections import deque

def resolve():
    def all_same(a, b, c):
        if a ==b and b ==c:
            return True
        return False

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

    if not all_same(c[0][0]-c[1][0], c[0][1] - c[1][1], c[0][2]-c[1][2]):
        ans = False
    if not all_same(c[0][0]-c[2][0], c[0][1] - c[2][1], c[0][2]-c[2][2]):
        ans = False
    if not all_same(c[0][0] - c[0][1], c[1][0] - c[1][1], c[2][0] - c[2][1]):
        ans = False
    if not all_same(c[0][0] - c[0][2], c[1][0] - c[1][2], c[2][0] - c[2][2]):
        ans = False

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


if __name__ == "__main__":
    resolve()

Solution (Python):
c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())
s = c11 + c22 + c33
if s - c12 - c23 != c31 or s - c13 - c32 != c21:
    print("No")
else:
    print("Yes")

Solution (Python):
c1, c2, c3 = map(int, input().split())
c4, c5, c6 = map(int, input().split())
c7, c8, c9 = map(int, input().split())

if c1+c5+c9 == c1+c8+c6 == c4+c2+c9 == c4+c8+c3 == c7+c2+c6 == c7+c5+c3:
    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()]
flag = 0
for i in range(2):
    if not (c1[i+1] - c1[i] == c2[i+1] - c2[i] == c3[i+1] - c3[i]):
        flag = 1
print('Yes' if flag == 0 else 'No')

Solution (Python):
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
if c1[0] + c2[1] + c3[2] == c1[1] + c2[2] + c3[0] == c1[2] + c2[0] + c3[1]:
    print('Yes')
else:
    print('No')

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

for j in range(3):
  B[j] = C[0][j] -A[0]
A[1] = C[1][0] -B[0]
A[2] = C[2][0] -B[0]

for k in range(3):
  for l in range(3):
    if C[k][l] != A[k] + B[l]:
      print('No')
      exit()
      
print('Yes')

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    n, a = IR(2)
    n %= 500
    if a >= n:
        print("Yes")
    else:
        print("No")
    return


def B():
    _ = II()
    a = LI()
    a.sort(reverse=True)
    op = 0
    ans = 0
    for ai in a:
        ans += -ai * op or ai
        op ^= 1
    print(ans)
    return


def C():
    c = LIR(3)
    for x in range(c[0][0] + 1):
        b = (c[0][0] - x, c[0][1] - x, c[0][2] - x)
        if (c[1][0] - b[0]) == (c[1][1] - b[1]) == (c[1][2] - b[2]):
            if (c[2][0] - b[0]) == (c[2][1] - b[1]) == (c[2][2] - b[2]):
                print("Yes")
                return
    print("No")
    return

def D():
    return


if __name__ == '__main__':
    C()

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

A = [0] * (3)
B = [0] * (3)

for i in range(3):
  B[i] = C[0][i] - A[0]
A[1] = C[1][0] - B[0]
A[2] = C[2][0] - B[0]

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 = [[0, 0, 0] for _ in range(3)]

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

success = False

for a1 in range(max([max(i) for i in c])+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) 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):
            success = True
            break

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

Solution (Python):


import sys

tmp = input().split()
a = list(map(lambda a: int(a), tmp))
tmp = input().split()
b = list(map(lambda a: int(a), tmp))
tmp = input().split()
c = list(map(lambda a: int(a), tmp))

if(a[0]-b[0]==a[1]-b[1])and(a[1]-b[1]==a[2]-b[2]):
	if(a[0]-c[0]==a[1]-c[1])and(a[1]-c[1]==a[2]-c[2]):
		if(c[0]-b[0]==c[1]-b[1])and(c[1]-b[1]==c[2]-b[2]):
			if(a[0]-a[1]==b[0]-b[1])and(b[0]-b[1]==c[0]-c[1]):
				if(a[2]-a[1]==b[2]-b[1])and(b[2]-b[1]==c[2]-c[1]):
					if(a[0]-a[2]==b[0]-b[2])and(b[0]-b[2]==c[0]-c[2]):
						print("Yes")
						sys.exit()
print("No")

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

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

ans = 'Yes'
for i in range(1, 3):
    if C[0][i] - C[1][i] != C[0][0] - C[1][0]:
        ans = 'No'
        break
    if C[0][i] - C[2][i] != C[0][0] - C[2][0]:
        ans = 'No'
        break
    if C[i][0] - C[i][1] != C[0][0] - C[0][1]:
        ans = 'No'
        break
    if C[i][0] - C[i][2] != C[0][0] - C[0][2]:
        ans = 'No'
        break
print(ans)

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

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

flag = Infomation()

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

Solution (Python):
import numpy as np

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

db1 = grid[0][1]-grid[0][0]
db2 = grid[0][2]-grid[0][1]

flag = True

for i in range(1,3):
    d1 = grid[i][1]-grid[i][0]
    d2 = grid[i][2]-grid[i][1]

    if d1 == db1 and d2 == db2:
        continue
    else:
        flag = False

db1 = grid[1][0] - grid[0][0]
db2 = grid[2][0] - grid[1][0]

for i in range(1, 3):
    d1 = grid[1][i] - grid[0][i]
    d2 = grid[2][i] - grid[1][i]

    if d1 == db1 and d2 == db2:
        continue
    else:
        flag = False

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

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