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):
lc = [[int(w) for w in input().split()] for i in range(3)]
cond = True

lb = lc[0]
a2 = lc[1][0]-lb[0]
a3 = lc[2][0]-lb[0]
la = [0, a2, a3]
for i in range(3):
    for j in range(3):
        if lc[i][j] != la[i]+lb[j]:
            cond = False
            break

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

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

ians = [c[0][0]-c[0][0], c[0][1]-c[0][0], c[0][2]-c[0][0]]
jans = [c[0][0]-c[0][0], c[1][0]-c[0][0], c[2][0]-c[0][0]]

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

for i in range(1, 3):
    for j in range(3):
        
        if jans[j] != c[j][i]-c[0][i]:
            ok = False

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

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

for i in range(3):
    minint = min(C[i])
    for j in range(3):
        C[i][j] -= minint

ans = True

for j in range(3):
    t = C[0][j]
    for i in range(3):
        if t != C[i][j]:
            ans = False
            break

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

Solution (Python):
import sys
c=[list(map(int,l.split())) for l in sys.stdin.read().splitlines()]
for i in range(2):
  c[2-i]=[x-y for x, y in zip(c[2-i],c[1-i])]
for i in range(2):
  for j in range(3):
    c[j][2-i]-=c[j][1-i]

if c[1][1:]==c[2][1:]==[0,0]:
  print('Yes')
else:
  print('No')

Solution (Python):
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007



def main():
	
	
	
	vl = [lin() for _ in range(3)]
	for f, t in [(0,1), (1,2), (2,0)]:
		is_same = set()
		for i in range(3):
			is_same.add(vl[f][i] - vl[t][i])
		if len(is_same) != 1:
			return 'No'
		
	for f, t in [(0,1), (1,2), (2,0)]:
		is_same = set()
		for i in range(3):
			is_same.add(vl[i][f] - vl[i][t])
		if len(is_same) != 1:
			return 'No'
	return 'Yes'
	
			
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

Solution (Python):
C11, C12, C13 = map(int, input().split());
C21, C22, C23 = map(int, input().split());
C31, C32, C33 = map(int, input().split());


b1 = C11;
b2 = C12;
b3 = C13;

a2 = C21 - b1;
a3 = C31 - b1;

if (C22 == a2 + b2 and
    C23 == a2 + b3 and
    C32 == a3 + b2 and
    C33 == a3 + b3):
  print("Yes");
else:
  print("No");

Solution (Python):
vals = []
for line in range(3):
  s = input().split()
  val = []
  for v in s:
    val.append(int(v))
  vals.append(val)

info = True

a = [0,]
b = vals[0]
a.append(vals[1][0]-b[0])
a.append(vals[2][0]-b[0])

for i in range(3):
  for j in range(3):
    if vals[i][j] != a[i] + b[j]:
      info = False
print('Yes' if info else 'No')

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

a1 = 0
b1 = c[0][0]

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

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

A = [[a1,a1,a1],[a2,a2,a2],[a3,a3,a3]]
B = [[b1,b2,b3],[b1,b2,b3],[b1,b2,b3]]

C = c

ans = "Yes"

for x in range(3):
  for y in range(3):
    if A[x][y] + B[x][y] != C[x][y]:
      ans = "No"
      break
print(ans)

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

Solution (Python):
def solve():
    import sys
    s = list(map(int, sys.stdin.read().split()))
    x, y, z = s[0] + s[4] + s[8], s[1] + s[5] + s[6], s[2] + s[3] + s[7]
    if x == y == z:
        print("Yes")
    else:
        print("No")


solve()

Solution (Python):
def solve():
    import sys
    s = list(map(int, sys.stdin.read().split()))
    x, y, z = s[0] + s[4] + s[8], s[1] + s[5] + s[6], s[2] + s[3] + s[7]
    if x == y == z:
        print("Yes")
    else:
        print("No")


solve()

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


YES = "Yes"
NO  = "No"


def solver(grid):
    result = NO
    
    a0 = 0
    b0 = grid[0][0]
    b1 = grid[0][1]
    b2 = grid[0][2]
    a1 = grid[1][0] - b0
    a2 = grid[2][0] - b0
    if a1+b1 == grid[1][1] and a1+b2 == grid[1][2] \
        and a2 + b1 == grid[2][1] and a2+b2 == grid[2][2]:
        result = YES
    return result


if __name__ == "__main__":
    grid_c = [ [0] * 3 for j in range(0, 3)]
    
    for j in range(0, 3):
        grid_c[j][0], grid_c[j][1], grid_c[j][2] = MI()
    
    print("{}".format(solver(grid_c)))

Solution (Python):
c = [list(map(int, input().split())) for _ in range(3)]
flg = 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(["No", "Yes"][flg])

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

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")
  exit()
if c[0][1]+c[1][2] != c[0][2]+c[1][1]:
  print("No")
  exit()
if c[1][0]+c[2][1] != c[1][1]+c[2][0]:
  print("No")
  exit()
if c[1][1]+c[2][2] != c[1][2]+c[2][1]:
  print("No")
  exit()
print("Yes")

Solution (Python):
c = [list(map(int, input().split())) for _ in range(3)]
flg = True
s = sum(c[0]) % 3
t = sum(c[i][0] for i in range(3)) % 3
for i in range(1, 3):
  if sum(c[i]) % 3 != s:
    flg = False
  if sum(c[j][i] for j in range(3)) % 3 != t:
    flg = False
if flg:
  print("Yes")
else:
  print("No")

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

D = [[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
    for j in range(3):
        D[i][j] = C[i][j] - C[i][j-1]

if D[0] == D[1] == D[2]:
    print("Yes")
else:
    print("No")

Solution (Python):
A = list(map(int, input().split()))
A += list(map(int, input().split()))
A += list(map(int, input().split()))
flag=0
for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            b1=A[6]-a1
            b2=A[7]-a1
            b3=A[8]-a1
            if b1<0 or b2<0 or b3<0:
                break
            if a3+b1==A[0] and a3+b2==A[1] and a3+b3==A[2] and a2+b1==A[3] and a2+b2==A[4] and a2+b3==A[5]:
                flag=1
print("Yes" if flag==1 else "No")

Solution (Python):
A = list(map(int, input().split()))
A += list(map(int, input().split()))
A += list(map(int, input().split()))
flag=0
for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            b1=A[6]-a1
            b2=A[7]-a1
            b3=A[8]-a1
            if b1<0 or b2<0 or b3<0:
                break
            if a3+b1==A[0] and a3+b2==A[1] and a3+b3==A[2] and a2+b1==A[3] and a2+b2==A[4] and a2+b3==A[5]:
                flag=1
print("Yes" if flag==1 else "No")

Solution (Python):
A = list(map(int, input().split()))
A += list(map(int, input().split()))
A += list(map(int, input().split()))
flag=0
for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            b1=A[6]-a1
            b2=A[7]-a1
            b3=A[8]-a1
            if b1<0 or b2<0 or b3<0:
                break
            if a3+b1==A[0] and a3+b2==A[1] and a3+b3==A[2] and a2+b1==A[3] and a2+b2==A[4] and a2+b3==A[5]:
                flag=1
print("Yes" if flag==1 else "No")

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

flag=1
for i in range(2):
    if not(x[i+1][0]-x[i][0]==x[i+1][1]-x[i][1]==x[i+1][2]-x[i][2]):
        flag = 0
        break
if flag==1:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

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

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

    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')
                return

    print('Yes')
    return


if __name__ == '__main__':
    main()

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

    for i in range(3):
        if (
            not C[(i + 1) % 3][0] - C[i][0]
            == C[(i + 1) % 3][1] - C[i][1]
            == C[(i + 1) % 3][2] - C[i][2]
        ):
            print('No')
            return
        if (
            not C[0][(i + 1) % 3] - C[0][i]
            == C[1][(i + 1) % 3] - C[1][i]
            == C[2][(i + 1) % 3] - C[2][i]
        ):
            print('No')
            return

    print('Yes')
    return


if __name__ == '__main__':
    main()

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

if c[0]-b[0]==c[1]-b[1]==c[2]-b[2] and b[0]-a[0]==b[1]-a[1]==b[2]-a[2] and a[2]-a[1]==b[2]-b[1]==c[2]-c[1] and a[1]-a[0]==b[1]-b[0]==c[1]-c[0]:
  print('Yes')
else:
  print('No')

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

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

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

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

Solution (Python):
g = []

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

for i in range(1,3):
    offset = g[i][0] - g[0][0]
    if not ((g[i][1] - g[0][1] == offset) and (g[i][2] - g[0][2] == offset)):
        print("No")
        exit()

print("Yes")

Solution (Python):
def m(a,b):
    n=3
    L=[0]*3
    for i in range(n):
        L[i]=a[i]-b[i]
    return L

def f(L):
    return len(set(L))==1

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

F=True
for i,j in [(0,1),(1,2),(2,0)]:
    F&=f(m(C[i],C[j]))

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

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

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

a0=0
b0=c[0][0]-a0
b1=c[0][1]-a0
b2=c[0][2]-a0

a1= c[1][0]-b0
a2= c[2][0]-b0
if a1 == c[1][1]-b1 == c[1][2]-b2\
and a2 == c[2][1]-b1 == c[2][2]-b2:
  print("Yes")
else:
  print("No")

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

for a0 in range(101):
  b0=c[0][0]-a0
  b1=c[0][1]-a0
  b2=c[0][2]-a0
  
  a1= c[1][0]-b0
  if a1 != c[1][1]-b1 or a1 != c[1][2]-b2:
    continue
  a2= c[2][0]-b0
  if a2 != c[2][1]-b1 or a2 != c[2][2]-b2:
    continue
  print("Yes")
  exit()
print("No")

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

a = sum(c[0]) + sum(c[1]) + sum(c[2])
b = c[0][0] + c[1][1] + c[2][2]

print('Yes' if a == 3 * b else 'No')

Solution (Python):
mat = [map(int ,raw_input().split()) for _ in range(3)]
def f(m):
	return (m[1] - m[0], m[2] - m[1])
b = True
s =set([])
for l in mat:
	s.add(f(l))
if len(s) >1:
	b = False
s = set([])
for j in range(3):
	c = [mat[i][j] for i in range(3)]
	s.add(f(c))
if len(s) >1:
	b = False
print 'Yes' if b else 'No'

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

c0 = [c[0][0]-c[0][1], c[0][0]-c[0][2], c[0][1]-c[0][2]]
c1 = [c[1][0]-c[1][1], c[1][0]-c[1][2], c[1][1]-c[1][2]]
c2 = [c[2][0]-c[2][1], c[2][0]-c[2][2], c[2][1]-c[2][2]]

if c0 == c1 == c2:
    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()))
print ("Yes") 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] else print ("No")

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

Solution (Python):
c = [list(map(int, input().split())) for i 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]:
  print("Yes")
else:
  print("No")

Solution (Python):
C = [[int(i) for i in input().split()] for j in range(3)]
a = [sum(C[i]) - sum(C[i-1]) for i in range(3)]
b = [sum([C[j][i] for j in range(3)]) - sum([C[j][i-1] for j in range(3)]) for i in range(3)]
for i in range(3):
    if not (a[i]/3).is_integer() or not (b[i]/3).is_integer():
        print("No")
        break
else:
    print("Yes")

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

d = []
for i in range(3):
  d.append([])
  for j, k in zip([0, 1, 2], [1, 2, 0]):
    d[i].append(c[i][j]-c[i][k])

if d[0] == d[1] == d[2]:
  print('Yes')
else:
  print('No')

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

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)]
yes = "Yes"
no = "No"


def solver(c_grid):
    result = no
    a_list=[0, c_grid[1][0] - c_grid[0][0], c_grid[2][0] - c_grid[0][0]]
    b_list=[c_grid[0][0], c_grid[0][1], c_grid[0][2]]
    if (c_grid[1][1] == a_list[1] + b_list[1]) and \
        (c_grid[1][2] == a_list[1] + b_list[2]) and \
            ( c_grid[2][1] == a_list[2] + b_list[1]) and \
                ( c_grid[2][2] == a_list[2] + b_list[2]):
                    result = yes
    return result


if __name__ == "__main__":
    c_grid = list()
    for _ in range(3):
        c_grid.append(LI())
    
    print("{}".format(solver(c_grid)))

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

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

Solution (Python):
import numpy as np
Num = np.zeros((3,3),dtype=int)
Flag = False
for T in range(0,3):
    Num[T,:] = np.array([int(X) for X in input().split()])
for T in range(0,3):
    Num[:,T] -= Num[0,T]
for A2 in range(min(Num[1,:]),max(Num[1,:])+1):
    AB2 = np.array([A2+Num[0,0],A2+Num[0,1],A2+Num[0,2]])
    if np.all(AB2==Num[1,:]):
        for A3 in range(min(Num[2,:]),max(Num[2,:])+1):
            AB3 = np.array([A3+Num[0,0],A3+Num[0,1],A3+Num[0,2]])
            if np.all(AB3==Num[2,:]):
                Flag = True
                break
    if Flag:
        break     
if Flag:
    print('Yes')
else:
    print('No')

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

ans = True
for i in range(3):
        for j in range(3):
            if c[i][j]-c[i][(j+1)%3] != c[(i+1)%3][j]-c[(i+1)%3][(j+1)%3]:
                ans = False
                break

for i in range(3):
        for j in range(3):
            if c[j][i]-c[(j+1)%3][i] != c[j][(i+1)%3]-c[(j+1)%3][(i+1)%3]:
                ans = False
                break

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

Solution (Python):
c = [list(map(int, input().split())) for _ in range(3)]
a1 = 0
b1 = c[0][0]
a2 = c[1][0] - b1
a3 = c[2][0] - b1
b2 = c[1][1] - a2
b3 = c[2][2] - a3
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]:
            print("No")
            exit(0)

print("Yes")

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

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

sum = sum(list(itertools.chain.from_iterable(grid)))
if sum % 3 != 0:
    print('No')
    exit()

for i in range(-100,101):
    a1 = i
    b1 = grid[0][0] - a1
    b2 = grid[0][1] - a1
    b3 = grid[0][2] - a1
    a2 = grid[1][0] - b1
    a3 = grid[2][0] - b1
    if a1 + a2 + a3 + b1 + b2 + b3 == sum // 3:
        print('Yes')
        exit()
print('No')

Solution (Python):
c = {}
for i in range(3):
  c[i] = list(map(int, input().split()))
tfc = 0
for i in range(101):
  if tfc == 3:
    break
  else:
    tfc = 0
  cx = []
  for j in c.values():
    for k in j:
      cx.append(k)
  if i > max(cx):
    break
  b = []
  for j in range(3):
    b.append(c.get(0)[j] - i)
  for j in range(3):
    p = []
    for k in range(3):
      p.append(c.get(j)[k] - b[k])
    if min(p) == max(p):
      tfc += 1
if tfc == 3:
  print('Yes')
else:
  print('No')

Solution (Python):

import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left, bisect_right 
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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

for i in range(3):
    for j in range(3):
        lu = C[i][j]
        for ii in range(3):
            if i == ii:
                continue
            for jj in range(3):
                if j == jj:
                    continue
                rd = C[ii][jj]
                ld = C[ii][j]
                ru = C[i][jj]

                if lu + rd != ld + ru:
                    print('No')
                    exit()
print('Yes')

Solution (Python):
c = [list(map(int,input().split())) for _  in range(3)]
d = set()
e = set()
for i in range(3):
    d.add(c[i][0] - c[i][1])
    e.add(c[i][1] - c[i][2])
print("Yes" if len(d) == len(e) == 1 else "No")

Solution (Python):
c = [list(map(int,input().split())) for _  in range(3)]
d = set()
e = set()
f = set()
g = set()
for i in range(3):
    d.add(c[i][0] - c[i][1])
    e.add(c[i][1] - c[i][2])
    f.add(c[0][i] - c[1][i])
    g.add(c[1][i] - c[2][i])
if len(d) == len(e) == len(f) == len(g) == 1:
    print("Yes")
else:
    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 a[i] + b[j] != c[i][j]:
            print('No')
            exit()

print('Yes')

Solution (Python):
[(a,b,c),(d,e,f),(g,h,i)] = [map(int,input().split()) for i in range(3)]

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

Solution (Python):
c_1 = list(map(int, input().split()))
c_2 = list(map(int, input().split()))
c_3 = list(map(int, input().split()))

diff = []

for i in range(2):
    diff.append(c_1[i] - c_1[i+1])

if c_2[0] - c_2[1] != diff[0] or c_2[1] - c_2[2] != diff[1]:
    print("No")
    exit()

if c_3[0] - c_3[1] != diff[0] or c_3[1] - c_3[2] != diff[1]:
    print("No")
    exit()

print("Yes")

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

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

print('Yes')

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

for a1 in range(101):
    b1 = c1[0] - a1
    b2 = c1[1] - a1
    b3 = c1[2] - a1
    
    a2 = c2[0] - b1
    a3 = c3[0] - b1
    
    if c2[1] == a2+b2 and c2[2] == a2+b3 and c3[1] == a3+b2 and c3[2] == a3+b3:
        print('Yes')
        exit()
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):
  c0 = c[0][i] - c[0][i + 1]
  c1 = c[1][i] - c[1][i + 1]
  c2 = c[2][i] - c[2][i + 1]
  if not (c0 == c1 == c2):
    print("No")
    exit(0)


for i in range(2):
  r0 = c[i][0] - c[i + 1][0]
  r1 = c[i][1] - c[i + 1][1]
  r2 = c[i][2] - c[i + 1][2]
  if not (c0 == c1 == c2):
    print("No")
    exit(0)

print("Yes")

Solution (Python):
(*c, ) = map(int, open(0).read().split())
print("YNeos"[sum(c) % 3 > 0 or sum(c)//3 != c[0]+c[4]+c[8]::2])

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

c1_m=c1[0]
c2_m=c2[1]
c3_m=c3[2]

for a_1 in range(c1_m+1):
    b_1=c1_m-a_1
    
    for a_2 in range(c2_m+1):
        b_2 = c2_m-a_2

        for a_3 in range(c3_m+1):
            b_3 = c3_m-a_3

            flg=0

            if c1[0]!=(a_1+b_1):
                flg+=1
            if c1[1]!=(a_1+b_2):
                flg+=1
            if c1[2]!=(a_1+b_3):
                flg+=1
            if c2[0]!=(a_2+b_1):
                flg+=1
            if c2[1]!=(a_2+b_2):
                flg+=1
            if c2[2]!=(a_2+b_3):
                flg+=1
            if c3[0]!=(a_3+b_1):
                flg+=1
            if c3[1]!=(a_3+b_2):
                flg+=1
            if c3[2]!=(a_3+b_3):
                flg+=1
            
            if flg==0:
                print('Yes')
                exit(0)

print('No')

Solution (Python):

(*c, ) = map(int, open(0).read().split())
print("YNeos"[sum(c) % 3 > 0 or sum(c)//3 != c[0]+c[4]+c[8]::2])

Solution (Python):
c_grid = [0]*3
for i in range(3):
    c_grid[i] = list(map(int, input().split()))
res = 'No'
for a1 in range(101):
    b1 = c_grid[0][0] - a1
    b2 = c_grid[0][1] - a1
    b3 = c_grid[0][2] - a1
    if b1 < 0 or b2 < 0 or b3 < 0:
        continue
    if b1 > 100 or b2 > 100 or b3 > 100:
        continue
    a2 = c_grid[1][0] - b1
    if a2 < 0 or a2 > 100 or a2 != c_grid[1][1] - b2 or a2 != c_grid[1][2] - b3:
        continue
    a3 = c_grid[2][0] - b1
    if a3 < 0 or a3 > 100 or a3 != c_grid[2][1] - b2 or a3 != c_grid[2][2] - b3:
        continue
    res = 'Yes'
print(res)

Solution (Python):

def taka(A):
  t = 0
  for a1 in range(101):
    b1 = A[0][0] - a1
    b2 = A[0][1] - a1
    b3 = A[0][2] - a1
    a2 = A[1][0] - b1
    a3 = A[2][0] - b1
    if a2 + b2 != A[1][1]:
      t = 1
    if a2 + b3 != A[1][2]:
      t = 1    
    if a3 + b2 != A[2][1]:
      t = 1      
    if a3 + b3 != A[2][2]:
      t = 1
    
    if t == 0:
      return "Yes"
    
  return "No"  

if __name__ == "__main__":
  C = [0] * 3
  for i in range(3):
    C[i] = list(map(int, input().split()))
  print(taka(C))

Solution (Python):
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans='Yes'
if A[0]+C[2]!=A[2]+C[0]:
  ans='No'
elif abs(A[0]-A[1])!=abs(B[0]-B[1]) or abs(B[0]-B[1])!=abs(C[0]-C[1]):
  ans='No'
elif abs(A[1]-A[2])!=abs(B[1]-B[2]) or abs(B[1]-B[2])!=abs(C[1]-C[2]):
  ans='No'
elif abs(A[0]-B[0])!=abs(A[1]-B[1]) or abs(A[1]-B[1])!=abs(A[2]-B[2]):
  ans='No'
elif abs(B[0]-C[0])!=abs(B[1]-C[1]) or abs(B[1]-C[1])!=abs(B[2]-C[2]):
  ans='No'
print(ans)

Solution (Python):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    c = []
    for _ in range(3):
        c.append(tuple(map(int, input().split())))
    for i1 in range(101):
        for i2 in range(101):
            if i1 - c[0][0] == i2 - c[0][1]:
                i3 = c[0][2] - (c[0][0] - i1)
                if i1 - c[1][0] == i2 - c[1][1] == i3 - c[1][2]:
                    if i1 - c[2][0] ==i2 -c[2][1] == i3 - c[2][2]:
                        print('Yes')
                        sys.exit()
    print('No')
if __name__ == '__main__':
    main()

Solution (Python):
c=[list(map(int,input().split())) for _ in range(3)]
for a0 in range(-100,201):
    for a1 in range(-100,201):
        for a2 in range(-100,201):
            if c[0][0]-a0==c[1][0]-a1==c[2][0]-a2:
                if c[0][1]-a0==c[1][1]-a1==c[2][1]-a2:
                    if c[0][2]-a0==c[1][2]-a1==c[2][2]-a2:
                        print("Yes")
                        exit()
print("No")

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

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

print(f)

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

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

a1 = 0
a2 = c2[0] - c1[0]
a3 = c3[0] - c1[0]
b1 = c1[0]
b2 = c1[1]
b3 = c1[2]

if c1[0] == a1 + b1 and c1[1] == a1 + b2 and c1[2] == a1 + b3 and c2[0] == a2 + b1 and c2[1] == a2 + b2 and c2[2] == a2 + b3 and c3[0] == a3 + b1 and c3[1] == a3 + b2 and c3[2] == a3 + b3:
  print('Yes')
else:
  print('No')

Solution (Python):
c = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
c.extend(c2)
c.extend(c3)
for a1 in range(c[0]+1):
  b1 = c[0]-a1
  b2 = c[1]-a1
  b3 = c[2]-a1
  a2 = c[3]-b1
  a3 = c[6]-b1
  ab = [a1,a2,a3,b1,b2,b3]
  for i in ab:
    if i < 0:
      break
  if (c[4]==a2+b2) & (c[5]==a2+b3) & (c[7]==a3+b2) & (c[8]==a3+b3):
    print("Yes")
    break
else:
  print("No")

Solution (Python):
cs=[list(map(int,input().split())) for _ in range(3)]
a=[i-j for i,j in zip(cs[0],cs[1])]
b=[i-j for i,j in zip(cs[1],cs[2])]
print('Yes'if a[0]==a[1]==a[2] and b[0]==b[1]==b[2]else'No')

Solution (Python):

import sys
from collections import deque, defaultdict
from math import sqrt, factorial





def solve():
    c = []
    ok = 1
    for i in range(3):
        c.append([int(x) for x in input().split()])
        if i:
            if c[i] != c[i-1]:
                d = c[i][0] - c[i-1][0]
                c[i] = [x - d for x in c[i]]
            if c[i] != c[i-1]:
                ok = 0
    if ok:
        print("Yes")
    else:
        print("No")
    

t = 1

for case in range(1,t+1):
    ans = solve()


"""

1 + k



"""

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

c1_2 = []
for i in range(3):
    c1_1 = []
    for j in range(2):
        c1_1.append(c[i][j] - c[i][j+1])
    c1_2.append(c1_1)
c1_1 = []
for i in range(3):
    for j in range(1):
        c1_1.append(c1_2[i][j] - c1_2[i][j+1])
if(len(set(c1_1))==1):
    print("Yes")
else:
    print("No")

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

a = [0, (c[1][0]-c[0][0]),(c[2][0]-c[0][0]) ]
b = [c[0][0], c[0][1], c[0][2]]
ans = "Yes"

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

print(ans)

Solution (Python):
import numpy as np
X = np.array([list(map(int, input().split())) for _ in range(3)])
T = True
if X[0][0]-X[0][1]==X[1][0]-X[1][1]==X[2][0]-X[2][1]\
   and X[0][1]-X[0][2]==X[1][1]-X[1][2]==X[2][1]-X[2][2]:
    pass
else:
  T = False

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

Solution (Python):
c = []
for i in range(3):
    c.append(list(map(int, input().split())))
jud = True
h1 = c[0][0] - c[1][0]
h2 = c[1][0] - c[2][0]
w1 = c[0][0] - c[0][1]
w2 = c[0][1] - c[0][2]
for i in range(3):
    if c[0][i] - c[1][i] != h1:
        jud = False
    if c[1][i] - c[2][i] != h2:
        jud = False
for i in range(3):
    if c[i][0] - c[i][1] != w1:
        jud = False
    if c[i][1] - c[i][2] != w2:
        jud = False
if jud:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()


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

if __name__ == "__main__":
    main()