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

Solution (Python):
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
total = 0
div = c1[0]+c2[1]+c3[2]
for (x,y,z) in zip(c1,c2,c3):
    total = total + x + y + z

print ('Yes' if total / 3 == div else 'No')

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

isCorrect = True

for a, b in [(0, 1), (0, 2), (1, 2)]:
    if ((C[a][0] - C[b][0]) != (C[a][1] - C[b][1])) or ((C[a][1] - C[b][1]) != (C[a][2] - C[b][2])):
       isCorrect = False
    if ((C[0][a] - C[0][b]) != (C[1][a] - C[1][b])) or ((C[1][a] - C[1][b]) != (C[2][a] - C[2][b])):
       isCorrect = False

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

Solution (Python):


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

ans = 0
A = []
B = []

for i in range(-200, 200):
   
    b1 = C[0][0] - i
    b2 = C[0][1] - i
    b3 = C[0][2] - i

    B.append(b1)
    B.append(b2)
    B.append(b3)

    A.append(i)
    A.append(C[1][0] - b1)
    A.append(C[2][0] - b1)

    for j in range(3):
        for k in range(3):
            
            if C[j][k] == A[j] + B[k]:
                continue
            else:
                ans = 1

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

Solution (Python):

import sys

c=[map(int,raw_input().split()) for i in xrange(3)]
a=[0,0,0]
b=[0,0,0]
b[0],b[1],b[2]=c[0][0]-a[0],c[0][1]-a[0],c[0][2]-a[0]
a[1],a[2]=c[1][0]-b[0],c[2][0]-b[0]
for i in xrange(3):
 for j in xrange(3):
  if c[i][j]!=a[i]+b[j]:
   print 'No'
   sys.exit()
print 'Yes'

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

Solution (Python):


"""One line explanation of c.py.

More explanations of c.py."""

import sys


def reader(fin):
    result = []
    for i in xrange(3):
        result.append([int(c) for c in fin.readline().strip().split(' ')])
    return result


def check_one_dir(m):
    for i in xrange(1, 3):
        d = m[i][0] - m[0][0]
        for j in xrange(1, 3):
            if m[i][j] - m[0][j] != d:
                return False
    return True

def trans(m):
    result = [[0, 0, 0] for i in xrange(3)]
    for i in xrange(3):
        for j in xrange(3):
            result[i][j] = m[j][i]
    return result

def checker(m):
    return check_one_dir(m) and check_one_dir(trans(m))

def main(argv):
    m = reader(sys.stdin)
    ans= 'No'
    if checker(m):
        ans = 'Yes'
    sys.stdout.write('%s\n' % ans)

if __name__ == '__main__':
    main(sys.argv)

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

d1 = c1[1] - c2[1]
d2 = c1[1] - c3[1]
ans = 0

for i in range(3):
    if c1[i] - c2[i] != d1:
        ans = 1
        break
    if c1[i] - c3[i] != d2:
        ans = 1
        break

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

Solution (Python):

import numpy as np

c1 = np.zeros((3,3),dtype=np.int64)
c2 = np.zeros((3,3),dtype=np.int64)

c1[0] = np.array(map(int, raw_input().split()))
c1[1] = np.array(map(int, raw_input().split()))
c1[2] = np.array(map(int, raw_input().split()))

c2[0] = c1[0] - c1[2]
c2[1] = c1[1] - c1[2]
c2[2] = c1[2] - c1[1]

b0 = ((c2[0,0] == c2[0,1]) and (c2[0,1] == c2[0,2]))
b1 = ((c2[1,0] == c2[1,1]) and (c2[1,1] == c2[1,2]))
b2 = ((c2[2,0] == c2[2,1]) and (c2[2,1] == c2[2,2]))

if (b0 and b1 and b2):
  print 'Yes'
else:
  print 'No'

Solution (Python):
c = [map(int, raw_input().split()) for i in range(3)]
ok = True
for i in range(2):
    for j in range(2):
        if c[i][j] - c[i+1][j] != c[i][j+1] - c[i+1][j+1]:
            ok = False
        if c[i][j] - c[i][j+1] != c[i+1][j] - c[i+1][j+1]:
            ok = False
print "Yes" if ok else "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())))
b = [c[0][0], c[0][1], c[0][2]]
if (c[1][0] - b[0] == c[1][1] - b[1]) and (c[1][1] - b[1] == c[1][2] - b[2]) and \
   (c[2][0] - b[0] == c[2][1] - b[1]) and (c[2][1] - b[1] == c[2][2] - b[2]) :
   print('Yes')
else :
    print('No')

Solution (Python):
c = []
for i in range(3):
	ctemp = list(map(int,input().split()))
	c.append(ctemp)
temp = [c[0][0],c[1][0],c[2][0]]
a = [-100000,0,0]
b = [0,0,0]
check = False
while a[0] <= 100000:
	tempcheck = True
	b[0] = c[0][0] - a[0]
	b[1] = c[0][1] - a[0]
	b[2] = c[0][2] - a[0]
	a[1] = c[1][0] - b[0]
	a[2] = c[2][0] - b[0]
	for i in range(3):
		for k in range(3):
			if c[i][k] != a[i] + b[k]:
				tempcheck = False
	if tempcheck:
		check = True
	a[0] += 1

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

Solution (Python):
grid = []
for i in range(0, 3):
    grid.extend(map(int, input().split(' ')))
a_1 = 0
b_1 = grid[3*0+0] - a_1
b_2 = grid[3*0+1] - a_1
b_3 = grid[3*0+2] - a_1
a_2 = grid[3*1+0] - b_1
a_3 = grid[3*2+0] - b_1

from itertools import product

temp = [a + b for a, b in product([a_1, a_2, a_3], [b_1, b_2, b_3])]

print("Yes" if all([x == y for x, y in zip(grid, temp)]) else "No")

Solution (Python):
import numpy as np
C = np.array([[int(i) for i in input().split()] for i in range(3)])
a=0
if(C[0,0]-C[0,1] == C[1,0]-C[1,1] == C[2,0]-C[2,1]):
    a +=1
if(C[0,1]-C[0,2] == C[1,1]-C[1,2] == C[2,1]-C[2,2]):
    a +=1
if(C[0,0]-C[1,0] == C[0,1]-C[1,1] == C[0,2]-C[1,2]):
    a +=1
if(C[1,0]-C[2,0] == C[1,1]-C[2,1] == C[1,2]-C[2,2]):
    a +=1
if(a == 4):
    print('Yes')
else:
    print('No')

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

A = list(map(lambda x: x-min(a), a))
B = list(map(lambda x: x-min(b), b))
C = list(map(lambda x: x-min(c), c))

if A==B==C:
    print('Yes')
else:
    print('No')

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

A = list(map(lambda x: x-min(a), a))
B = list(map(lambda x: x-min(b), b))
C = list(map(lambda x: x-min(c), c))

A.sort()
B.sort()
C.sort()

if A==B==C:
    print('Yes')
else:
    print('No')

Solution (Python):
def main():
    """
    0 <= c <= 100
    c(i,j) = a(i) + b(j)
    a: 整数 -> 負もあるのでc特定の数不明

    c1,1 = a1 + b1
    c1,2 = a1 + b2
    c1,3 = a1 + b3

    c2,1 = a2 + b1
    c2,2 = a2 + b2
    c2,3 = a2 + b3

    c3,1 = a3 + b1
    c3,2 = a3 + b2
    c3,3 = a3 + b3

    a or b だけの式にできる
    →等しいか試す
    """
    N = 3
    C = [
        tuple(map(int, input().split()))
        for _ in range(N)
    ]

    editorial(C, N)


def editorial(C, N):
    a = [None] * N
    b = [None] * N

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

    for i in range(N):
        for j in range(N):
            if C[i][j] != a[i] + b[j]:
                print("No")
                return

    print("Yes")


def editorial2(C, N):
    """
    3 x 3:
    abc
    def
    ghi

    a+e=b+d => (a1+b1)+(a2+b2)=(a1+b2)+(a2+b1)
    b+f=c+e
    d+h=e+g
    e+i=f+h

    2 x 2のgridをつくり、その対角要素の和/逆対角要素の和が等しい
    """
    pass


def AC(C, N):
    a = is_valid_a(C, N)
    if not a:
        print("No")
        return

    b = is_valid_b(C, N)
    if not b:
        print("No")
        return

    print("Yes")


def is_valid_a(C, N):
    """
    c1,1 - c2,1: a1 - a2
    c1,2 - c2,2: a1 - a2
    c1,3 - c2,3: a1 - a2
    --------------
    ci,1 - c(i+1),1: ai - a(i+1)
    ci,2 - c(i+1),2: ai - a(i+1)
    ci,3 - c(i+1),3: ai - a(i+1)
    """
    from itertools import combinations
    for x, y in combinations([0, 1, 2], 2):
        valid = C[x][0] - C[y][0] == C[x][1] - C[y][1] == C[x][2] - C[y][2]
        if not valid:
            return False

    return True


def is_valid_b(C, N):
    """
    c1,1 - c1,2: b1 - b2
    c1,2 - c1,3: b2 - b3
    c1,3 - c1,1: b3 - b1
    --------------
    ci,1 - ci,2: b1 - b2
    ci,2 - ci,3: b2 - b3
    ci,3 - ci,1: b3 - b1
    """
    b1_m_b2 = set()
    b2_m_b3 = set()
    b3_m_b1 = set()
    for i in range(N):
        b1_m_b2.add(C[i][0] - C[i][1])
        b2_m_b3.add(C[i][1] - C[i][2])
        b3_m_b1.add(C[i][2] - C[i][0])

    return len(b1_m_b2) == 1 and len(b2_m_b3) == 1 and len(b3_m_b1) == 1


if __name__ == '__main__':
    main()

Solution (Python):
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
ok = 0
if ((p[2] -p[0]) == (q[2]-q[0]) == (r[2]-r[0])):
    if ((p[2] -p[1]) == (q[2]-q[1]) == (r[2]-r[1])):
        if ((p[1] -p[0]) == (q[1]-q[0]) == (r[1]-r[0])):
            ok +=1
if((q[0]-p[0]) == (q[1]-p[1]) == (q[2]-p[2])):
    if((r[0]-p[0]) == (r[1]-p[1]) == (r[2]-p[2])):
        if((r[0]-q[0]) == (r[1]-q[1]) == (r[2]-q[2])):
            ok +=1
if (ok==2):
    print('Yes')
else :
    print('No')

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

tmp1=c[0][1]-c[0][0]
tmp2=c[0][2]-c[0][1]

tmp3=c[1][1]-c[1][0]
tmp4=c[1][2]-c[1][1]

tmp5=c[2][1]-c[2][0]
tmp6=c[2][2]-c[2][1]

if tmp1==tmp3==tmp5 and tmp2==tmp4==tmp6:
	print("Yes")
else:
	print("No")

Solution (Python):
import numpy as np
c0= list(map(int, input().split(' ')))
c1= list(map(int, input().split(' ')))
c2= list(map(int, input().split(' ')))
 
C = np.array([c0, c1, c2])
if C[1][0] - C[0][0] == C[1][1]-C[0][1] == C[1][2] - C[0][2] and C[2][0] - C[0][0] == C[2][1]-C[0][1 ]== C[2][2] - C[0][2]  :
 print('Yes')
else:
 print('No')

Solution (Python):
def main():
    tables = []
    tables.append([int(x) for x in input().strip().split()])
    tables.append([int(x) for x in input().strip().split()])
    tables.append([int(x) for x in input().strip().split()])
    a = [min(tables[0]), min(tables[1]), min(tables[2])]
    b = [tables[0][0]-a[0], tables[0][1]-a[0], tables[0][2]-a[0]]

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

if __name__ == '__main__':
    print(main())

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


x = a[0][0] - a[0][1]
y = a[0][1] - a[0][2]

for i in range(3):
    if a[i][0] - a[i][1] != x or a[i][1] - a[i][2]!=y:
        print("No")
        break
    if i == 2:
        print("Yes")

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

Solution (Python):
a = [[], [], []]
line = input().split(" ")
a[0] = list(map(int, line))
line2 = input().split(" ")
a[1] = list(map(int, line2))
line3 = input().split(" ")
a[2] = list(map(int, line3))
ans = []
anss = "No"
for i in range(min(a[0])+1):
    ans = list(map(lambda x: x - i, a[0]))
    if min(ans) < 0:
        continue
    for j in range(min(a[1])+1):
        if ans != list(map(lambda x: x - j, a[1])):
            continue
        for k in range(min(a[2])+1):
            if ans == list(map(lambda x: x - k, a[2])):
                anss = "Yes"
                break
        else:
            continue
        break
    else:
        continue
    break
print(anss)

Solution (Python):
def ans():
    C = []
    C.append([])
    C.append(list(map(int, ('0 ' + input()).split())))
    C.append(list(map(int, ('0 ' + input()).split())))
    C.append(list(map(int, ('0 ' + input()).split())))

    A = [0] * 4
    B = [0] * 4
    A[1] = 0

    for i in range(1,4):
        B[i] = C[1][i] - A[1]

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

    for i in range(1,4):
        for j in range(1, 4):
            if C[i][j] == (A[i] + B[j]):
                pass
            else:
                return print('No')
    return print('Yes')
ans()

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

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

Solution (Python):
l = []

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

for i in range(2):
    for j in range(2):
        a = l[i][j] - l[i][j+1]
        b = l[i+1][j] - l[i+1][j+1]
        if a != b:
            print("No")
            exit(0)

print("Yes")

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

flag = True
if((c21 - c11) != (c22 - c12) or (c21 - c11) != (c23 - c13)):
    flag = False
if((c31 - c11) != (c32 - c12) or (c31 - c11) != (c33 - c13)):
    flag = False
if((c12 - c11) != (c22 - c21) or (c12 - c11) != (c32 - c31)):
    flag = False
if((c13 - c11) != (c23 - c21) or (c13 - c11) != (c33 - c31)):
    flag = False
if(flag):
    print('Yes')
else:
    print('No')

Solution (Python):
import itertools                                               
import sys                                                     
                                                               
                                                               
def solve(C):                                                  
    for cc, cn in itertools.combinations(C, 2):                
        for c_c, c_n in itertools.combinations(zip(cc, cn), 2):
            if c_c[0] + c_n[1] != c_c[1] + c_n[0]:             
                return "No"                                    
    else:                                                      
        return "Yes"                                           
                                                               
if __name__ == "__main__":                                     
    C = [list(map(int, input().split())) for _ in range(3)]    
    print(solve(C))

Solution (Python):
def solve():
    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())

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

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

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

a[0] = 0

b[0] = c[0][0]
b[1] = c[0][1]
b[2] = c[0][2]
a[1] = c[1][0] - b[0]
a[2] = c[2][0] - b[0]

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

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

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

a[0] = 0

b[0] = c[0][0]
b[1] = c[0][1]
b[2] = c[0][2]
a[1] = c[1][0] - b[0]
a[2] = c[2][0] - b[0]

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

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

if c1[1]-c1[0] != c2[1]-c2[0] or c3[1]-c3[0] != c1[1]-c1[0] or c2[1]-c2[0] != c3[1]-c3[0]:
    print("No")
elif  c1[2]-c1[1] != c2[2]-c2[1] or c3[2]-c3[1] != c1[2]-c1[1] or c2[2]-c2[1] != c3[2]-c3[1]:
    print("No")
elif  c2[1]-c1[0] != c2[1]-c1[0] or c3[1]-c2[0] != c3[1]-c2[0] or c1[1]-c3[0] != c1[1]-c3[0]:
    print("No")
elif  c2[2]-c1[1] != c2[2]-c1[1] or c3[2]-c2[1] != c3[2]-c2[1] or c1[2]-c3[1] != c1[2]-c3[1]:
    print("No")
else:
    print("Yes")

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

for i, c_list in enumerate(grid_data):
    grid_data[i] = [c - max(grid_data[i]) for c in c_list]

if all([True if grid_data[0] == c_list else False for c_list in grid_data]):
    print("Yes")
else:
    print("No")

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

if C[0][1] - C[0][0] != C[1][1] - C[1][0] or C[1][1] - C[1][0] != C[2][1] - C[2][0]:
    print("No")
elif C[0][2] - C[0][1] != C[1][2] - C[1][1] or C[1][2] - C[1][1] != C[2][2] - C[2][1]:
    print("No")
elif C[0][2] - C[0][0] != C[1][2] - C[1][0] or C[1][2] - C[1][0] != C[2][2] - C[2][0]:
    print("No")
elif C[1][0] - C[0][0] != C[1][1] - C[0][1] or C[1][1] - C[0][1] != C[1][2] - C[0][2]:
    print("No")
elif C[2][0] - C[1][0] != C[2][1] - C[1][1] or C[2][1] - C[1][1] != C[2][2] - C[1][2]:
    print("No")
elif C[2][0] - C[0][0] != C[2][1] - C[0][1] or C[2][1] - C[0][1] != C[2][2] - C[0][2]:
    print("No")
else:
    print("Yes")

Solution (Python):
s1=raw_input().split(' ')
s2=raw_input().split(' ')
s3=raw_input().split(' ')
l=[0 for i in range(9)]
for i in range(3):
    l[i]=int(s1[i])
    l[i+3]=int(s2[i])
    l[i+6]=int(s3[i])
    
if l[2]-l[1]==l[5]-l[4]==l[8]-l[7] and l[1]-l[0]==l[4]-l[3]==l[7]-l[6] and l[6]-l[3]==l[7]-l[4]==l[8]-l[5] and l[3]-l[0]==l[4]-l[1]==l[5]-l[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 and c23-c13==c21-c11 and c31-c21==c32-c22 and c33-c23 ==c31-c21 and c12-c11==c22-c21 and c32-c31==c22-c21 and c33-c32==c23-c22 and c23-c22==c13-c12:
    print('Yes')
else:
    print('No')

Solution (Python):
l1 = list(map(int,input().split()))
l2 = list(map(int,input().split()))
l3 = list(map(int,input().split()))
if l1[0]-l2[0]==l1[1]-l2[1]==l1[2]-l2[2] and l2[0]-l3[0]==l2[1]-l3[1]==l2[2]-l3[2]:
    if l1[0]-l1[1]==l2[0]-l2[1]==l3[0]-l3[1] and l1[1]-l1[2]==l2[1]-l2[2]==l3[1]-l3[2]:
        print("Yes")
        exit()
print("No")

Solution (Python):
C_0 = [int(num) for num in raw_input().split()]
C_1 = [int(num) for num in raw_input().split()]
C_2 = [int(num) for num in raw_input().split()]
C_s = [C_0, C_1, C_2]
flag = 1
if ((C_1[0] - C_0[0]) == (C_1[1] - C_0[1]) == (C_1[2] - C_0[2])) == False:
   flag = 0
   
if ((C_2[0] - C_0[0]) == (C_2[1] - C_0[1]) == (C_2[2] - C_0[2]))== False:
   flag = 0
   
if ((C_2[0] - C_1[0]) == (C_2[1] - C_1[1]) == (C_2[2] - C_1[2]))== False:
   flag = 0
   
if ((C_s[0][0] - C_s[0][1]) == (C_s[1][0] - C_s[1][1]) == (C_s[2][0] - C_s[2][1]))== False:
   flag = 0
   
if ((C_s[0][0] - C_s[0][2]) == (C_s[1][0] - C_s[1][2]) == (C_s[2][0] - C_s[2][2]))== False:
   flag = 0  

if ((C_s[0][1] - C_s[0][2]) == (C_s[1][1] - C_s[1][2]) == (C_s[2][1] - C_s[2][2]))== False:
   flag = 0  

if flag == 1:
   print "Yes"
else:
   print "No"

Solution (Python):
a = [map(int, raw_input().split()) for _ in xrange(3)]
h0 = sum(a[0])
h1 = sum(a[1])
h2 = sum(a[2])
w0 = sum([a[i][0] for i in xrange(3)])
w1 = sum([a[i][1] for i in xrange(3)])
w2 = sum([a[i][2] for i in xrange(3)])

if (h0-h1)%3 or (h1-h2)%3 or (h2-h0)%3 or (w0-w1)%3 or (w1-w2)%3 or (w2-w0)%3:
    print "No"
else:
    print "Yes"

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

Solution (Python):
C = [[] for i in range(3)]
for i in range(3) :
    C[i] = list(map(int, input().split()))
f = True
for i0 in range(3) :
    for i1 in range(3) :
        for j0 in range(3) :
            for j1 in range(3) :
                if C[i0][j0] - C[i1][j0] != C[i0][j1] - C[i1][j1] or C[i0][j0] - C[i0][j1] != C[i1][j0] - C[i1][j1] :
                    f = False
print("Yes" if f else "No")

Solution (Python):
c = []
for i in range(3):
    c.append([int(i) for i in input().split()])
b1 = 0
a1 = c[0][0]
a2 = c[1][0]
a3 = c[2][0]
b2 = c[0][1] - a1
b3 = c[0][2] - a1
if a2 + b2 == c[1][1] and a3 + b2 == c[2][1] \
    and a2 + b3 == c[1][2] and a3 + b3 == c[2][2]:
    print("Yes")
else:
    print("No")

Solution (Python):
c = []
for i in range(0,3):
    sub  = str(input()).split()
    c.append(sub)

indicater = 0
for i in range(1,3):
    for j in range(1,3):
        if  int(c[i][j]) != int(c[i][j-1]) + int(c[i-1][j]) - int(c[i-1][j-1]):
            indicater = 1

if indicater == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
def c_takahashi_information(C):
    b = [C[0][i] - 0 for i in range(3)]
    a = [0] + [C[i][0] - b[0] for i in range(1, 3)]  
    for i in range(3):
        for j in range(3):
            if a[i] + b[j] != C[i][j]:
                return 'No'
    return 'Yes'

C = [[int(i) for i in input().split()] for j in range(3)]
print(c_takahashi_information(C))

Solution (Python):
def calc(a1,c):
    As=[a1]
    Bs=[]
    Bs.append(c[0][0]-As[0])
    As.append(c[1][0]-Bs[0])
    As.append(c[2][0]-Bs[0])
    Bs.append(c[0][1]-As[0])
    Bs.append(c[0][2]-As[0])
    for a in range(3):
        for b in range(3):
            if As[a]+Bs[b]!=c[a][b]: return False
    return True

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

flag=False
if (calc(0,c)): 
    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] and c[0][1] - c[0][2] == c[1][1] - c[1][2] and c[1][0] - c[1][1] == c[2][0] - c[2][1] and 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] and c[1][0] - c[2][0] == c[1][1] - c[2][1] and c[0][1] - c[1][1] == c[0][2] - c[1][2] and c[1][1] - c[2][1] == c[1][2] - c[2][2]:
    print("Yes")
else:
    print("No")

Solution (Python):
def solve():
    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())
 
print('Yes' if solve() else 'No')

Solution (Python):
import sys

if __name__ == "__main__":
    C1 = list(map(int, (input().split(' '))))
    C2 = list(map(int, (input().split(' '))))
    C3 = list(map(int, (input().split(' '))))

    for i in range(101):
        for j in range(101):
            for k in range(101):
                col1 = C1[0] - i
                if col1 < 0:
                    break
                if col1 > 100:
                    break
                if (C2[0] - j) != col1:
                    break
                if (C3[0] - k) != col1:
                    continue
                col2 = C1[1] - i
                if col2 < 0:
                    break
                if col2 > 100:
                    break
                if (C2[1] - j) != col2:
                    break
                if (C3[1] - k) != col2:
                    continue
                col3 = C1[2] - i
                if col3 < 0:
                    break
                if col3 > 100:
                    break
                if (C2[2] - j) != col3:
                    break
                if (C3[2] - k) != col3:
                    continue
                print('Yes')
                sys.exit()
    print('No')

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

flag = True
for i in range(1, 3):
    tmp_del = c[i][0] - c[i-1][0]
    for j in range(1, 3):
        if c[i-1][j]+tmp_del==c[i][j]:
            continue
        else:
            flag = False
            break

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

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

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

Solution (Python):

import sys
a = []
for i in range(3):
    a.append(map(int, raw_input().split()))
A = 1
B = 1
while B < 3:
    A = 1
    while A < 3:
        if not a[B][A]-a[B-1][A] == a[B][0]-a[B-1][0]:
            print "No"
            sys.exit()
        if not a[B][A]-a[B][A-1] == a[0][A]-a[0][A-1]:
            print "No"
            sys.exit()
        A += 1
    B += 1
print "Yes"

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


c0 = C[0][0]-C[1][0]
c1 = C[0][1]-C[1][1]
c2 = C[0][2]-C[1][2]

d0 = C[1][0]-C[2][0]
d1 = C[1][1]-C[2][1]
d2 = C[1][2]-C[2][2]

e0 = C[0][1]-C[0][2]
e1 = C[1][1]-C[1][2]
e2 = C[2][1]-C[2][2]

if (c0 == c1 and c1 == c2) and (d0 == d1 and d1 == d2) and (e0 == e1 and e1 == e2):
    print('Yes')
else:
    print('No')

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

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

    if len(set(d)) > 1:
        print('No')
        exit()

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

    if len(set(d)) > 1:
        print('No')
        exit()

print('Yes')

Solution (Python):
c = []
for i in range(3):
    c.append(list(map(int, input().split())))
tmp = [[] for i in range(4)]
for i in range(3):
    for j in range(2):
        tmp[j].append(c[j+1][i] - c[0][i])
        tmp[j+2].append(c[i][j+1] - c[i][0])
if set([len(set(i)) for i in tmp]) == {1}:
    print('Yes')
else:
    print('No')

Solution (Python):
c = []
for i in range(3):
    c.append(list(map(int, input().split())))
tmp = [[] for i in range(4)]
for i in range(3):
    tmp[0].append(c[1][i] - c[0][i])
    tmp[1].append(c[2][i] - c[0][i])
    tmp[2].append(c[i][1] - c[i][0])
    tmp[3].append(c[i][2] - c[i][0])
if set([len(set(i)) for i in tmp]) == {1}:
    print('Yes')
else:
    print('No')

Solution (Python):
grid = [list(map(int,input().split(' ')))]
grid.append(list(map(int,input().split(' '))))
grid.append(list(map(int,input().split(' '))))

flg =False
for i in range(100):
    b0,b1,b2  = grid[0][0]-i,grid[0][1]-i,grid[0][2]-i
    a1,a2 = grid[1][0]-b0,grid[2][0]-b0
    if grid[1][1] == a1+b1 and grid[1][2] == a1+b2 and grid[2][1] == a2+b1 and grid[2][2] == a2+b2:
        if grid[0][0] == i+b0 and grid[0][1] == i+b1 and grid[0][2] == i+b2 and grid[1][0] == a1+b0 and grid[2][0] == a2+b0:
            flg =True
            break
    if min([b0,b1,b2]) < 0:
        break
    
if flg:
    print('Yes')
    
else:
    print('No')

Solution (Python):
C = [[int(i) for i in input().split()] for i in range(3)]
res = 'No'
for i in range(100) :
  a1 = i
  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 :
    continue
  if C[1][2] != a2 + b3 :
    continue
  if C[2][1] != a3 + b2 :
    continue
  if C[2][2] != a3 + b3 :
    continue
  res = 'Yes'
  break
print(res)

Solution (Python):


adan = input().split()
bdan = input().split()
cdan = input().split()
aken = int(int(adan[int(1)])-int(bdan[int(1)]))
bken = int(int(adan[int(2)])-int(bdan[int(2)]))
cken = int(int(adan[int(0)])-int(bdan[int(0)]))
dken = int(int(adan[int(1)])-int(cdan[int(1)]))
eken = int(int(adan[int(2)])-int(cdan[int(2)]))
fken = int(int(adan[int(0)])-int(cdan[int(0)]))
if aken == bken == cken:
    if dken == eken == fken:
        print("Yes")
    else:
        print("No")
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 (c11-c12==c21-c22==c31-c32 and c12-c13==c22-c23==c32-c33 \
and c13-c11==c23-c21==c33-c31 and c11-c21==c12-c22==c13-c23 \
and c21-c31==c22-c32==c23-c33 and c31-c11==c32-c12==c33-c13) :
    print("Yes")
else:
    print("No")

Solution (Python):

import numpy as np


def main(a):
    a = np.diff(a)
    a = np.diff(a, axis=-1)
    a = np.diff(a, axis=0)
    a = np.diff(a, axis=0)
    if int(a[0]) == 0:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    a = np.empty(0)

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

Solution (Python):


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



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

ans_flag = 'No'
a1_flag = False
a2_flag = False
a3_flag = False

def check_b(_b):
    b_count = 0
    for i_b in _b:
        if i_b >= 0 and i_b <= 100:
            b_count += 1
    
    if b_count >= 3:
        return True
    else:
        return False

def check_succes(a_val,b, c):
    b_count2 = 0
    i = 0
    for i_b in b:
        if i_b == c[i] - a_val:
            b_count2 += 1
        i += 1
    if b_count2 >= 3:
        return True
    else:
        return False

main_count = 0

for a_1 in range(101):
    a[0] = a_1
    for x in range(len(b)):
        b[x] = C[0][x] - a[0]
    
    
        

    if check_b(b):
        a1_flag = True
        for a_2 in range(101):
            a[1] = a_2
            if check_succes(a[1], b, C[1]):
                a2_flag = True
                for a_3 in range(101):
                    a[2]= a_3
                    if check_succes(a[2], b, C[2]):
                        a3_flag = True
                        ans_flag = 'Yes'



print(ans_flag)








def check_succes(a_val,b, c):
    b_count2 = 0
    i = 0
    for i_b in _b:
        if i_b == c[i] - a_val:
            b_count2 += 1
        i += 1
    if b_count2 >= 3:
        return True
    else:
        return False

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



if abs(c[0][1]-c[0][0]) == abs(c[1][0]-c[1][1]) == abs(c[2][0]-c[2][1]) and abs(c[0][1]-c[0][2]) == abs(c[1][1]-c[1][2]) == abs(c[2][1]-c[2][2]) and abs(c[0][0]-c[1][0]) == abs(c[0][1]-c[1][1]) == abs(c[0][2]-c[1][2]) and abs(c[1][0]-c[2][0]) == abs(c[2][1]-c[1][1]) == abs(c[1][2]-c[2][2]):
    print("Yes")

else:
    print("No")