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(" ")))
a1 = []
a2 = []
a3 = []
b1 = []
b2 = []
b3 = []
judge1 = False
judge2 = False
judge3 = False
judge4 = False
for i in range(c1[0]+1):
    a1.append(i)
b1 = sorted(a1,reverse = True)
for i in b1:
    a2.append(c2[0]-i)
for i in b1:
    a3.append(c3[0]-i)

for i in a1:
    b2.append(c1[1]-i)
for i in a1:
    b3.append(c1[2]-i)

for i in range(len(a1)):
    if c2[1] == a2[i]+b2[i]:
        judge1 = True
    if c3[2] == a3[i]+b3[i]:
        judge2 = True
    if c2[2] == a2[i]+b3[i]:
        judge3 = True
    if c3[1] == a3[i]+b2[i]:
        judge4 = True 
if judge1 and judge2 and judge3 and judge4 :
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np
list1 = np.array(map(int,raw_input().split()))
list2 = np.array(map(int,raw_input().split()))
list3 = np.array(map(int,raw_input().split()))
list4 = list1 - list2
list5 = list1 - list3
list6 = [list1[0] - list1[1],list2[0] - list2[1],list3[0] - list3[1]]
list7 = [list1[0] - list1[2],list2[0] - list2[2],list3[0] - list3[2]]
def checkline(list):
    return (list[0] - list[1])**2 + (list[0] - list[2])**2

if checkline(list4) == 0 and checkline(list5) == 0 and checkline(list6) == 0 and checkline(list7) == 0:
        print 'Yes'
else:
    print 'No'

Solution (Python):



import sys

def main():
    c = tuple(tuple(map(int, line.split())) for line in sys.stdin.readlines())
    csum = sum((sum(ci) for ci in c))
    trace = sum((cij for i, ci in enumerate(c) for j, cij in enumerate(ci) if i == j))
    if csum == 3 * trace:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    main()

Solution (Python):
A=input().split(" ")
A = list(map(int, A))
B=input().split(" ")
B = list(map(int, B))
C=input().split(" ")
C = list(map(int, C))


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

Solution (Python):
import sys

nS = [0 for i in range(3)]
nA = [0 for i in range(3)]
nB = [0 for i in range(3)]
nC = [0 for i in range(3)]

N = 3

nS  = input().rstrip().split(' ')
for i in range(N):
    nA[i] = int(nS[i])

nS  = input().rstrip().split(' ')
for i in range(N):
    nB[i] = int(nS[i])

nS  = input().rstrip().split(' ')
for i in range(N):
    nC[i] = int(nS[i])

Tmp = nC[0]-nA[0]
nTmp = nC[1]-nA[1]
if Tmp != nTmp:
    print('No')
    sys.exit()

nTmp = nC[2]-nA[2]
if Tmp != nTmp:
    print('No')
    sys.exit()

Tmp = nB[0]-nA[0]
nTmp = nB[1]-nA[1]
if Tmp != nTmp:
    print('No')
    sys.exit()

nTmp = nB[2]-nA[2]
if Tmp != nTmp:
    print('No')
    sys.exit()


Tmp = nA[1]-nA[0]
nTmp = nB[1]-nB[0]
if Tmp != nTmp:
    print('No')
    sys.exit()

nTmp = nC[1]-nC[0]
if Tmp != nTmp:
    print('No')
    sys.exit()

Tmp = nA[2]-nA[0]
nTmp = nB[2]-nB[0]
if Tmp != nTmp:
    print('No')
    sys.exit()

nTmp = nC[2]-nC[0]
if Tmp != nTmp:
    print('No')
    sys.exit()

Tmp = nA[0]+ nC[2]
nTmp = nA[2]+ nC[0]
if Tmp != nTmp:
    print('No')
    sys.exit()
    
print('Yes')

Solution (Python):
def c_takahashi_information(C):
    a = [min(C[0]), min(C[1]), min(C[2])]
    tmp = [[C[i][j] - a[i] for j in range(3)] for i in range(3)]
    b = list(map(list, set(map(tuple, tmp))))
    for bb in b:
        f = True
        for i in range(3):
            for j in range(3):
                if a[i] + bb[j] != C[i][j]:
                    f = False
                    break
            if not f:
                break
        if f:

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

Solution (Python):
import sys

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

C = []

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

a = [0,0,0]
b = [0,0,0]
for b1 in range(101):
    b[0] = b1
    a[0] = C[0][0] - b1
    a[1] = C[1][0] - b1
    a[2] = C[2][0] - b1
    a_s = sum(a)

    b[1] = (C[0][1] + C[1][1] + C[2][1] - a_s) / 3
    b[2] = (C[0][2] + C[1][2] + C[2][2] - a_s) / 3

    if (check(a,b,C)):
        print('Yes')
        sys.exit()
print('No')

Solution (Python):
mt = []
for _ in range(3):
    mt.append(list(map(int, input().split())))
b1b2, b2b3, a1a2, a2a3 = [],[],[],[]
for i in range(3):
    b1b2.append(mt[i][0]-mt[i][1])
    b2b3.append(mt[i][1]-mt[i][2])
    a1a2.append(mt[0][i]-mt[1][i])
    a2a3.append(mt[1][i]-mt[2][i])
array = [b1b2,b2b3,a1a2,a2a3]
def sl(es):
    return len(list(set(es))) == 1
if all([sl(es) for es in array]):
    print('Yes')
else:
    print('No')

Solution (Python):
C0 = map(int, input().split())
C0 = list(C0)

C1 = map(int, input().split())
C1 = list(C1)

C2 = map(int, input().split())
C2 = list(C2)


if (C0[0] - C0[1] == C1[0]-C1[1] == C2[0]-C2[1] and C0[0] - C0[2] == C1[0]-C1[2] == C2[0]-C2[2] and C0[0] - C1[0] == C0[1] - C1[1] == C0[2] - C1[2] and C0[0] - C2[0] == C0[1] - C2[1] == C0[2] - C2[2] ):

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

Solution (Python):
d0 = [int(i) for i in input().split()]
d1 = [int(i) for i in input().split()]
d2 = [int(i) for i in input().split()]


x0 = d1[0]-d0[0]
x1 = d2[0]-d0[0]

y0 = d1[1]-d0[1]
y1 = d2[1]-d0[1]

z0 = d1[2]-d0[2]
z1 = d2[2]-d0[2]


i0 = d0[1]-d0[0]
i1 = d0[2]-d0[0]

j0 = d1[1]-d1[0]
j1 = d1[2]-d1[0]

k0 = d2[1]-d2[0]
k1 = d2[2]-d2[0]

if (x0 == y0) and (x0 == z0) and (x1 == y1) and (x1 == z1):
    if (i0 == j0) and (i0 == k0) and (i1 == j1) and (i1 == k1):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
c = [c1, c2, c3]
Takahashi = True
for i in range(3):
    for j in range(3):
        for k in range(3):
            for l in range(3):
                if c[i][k] - c[j][k] != c[i][l] - c[j][l]:
                    Takahashi = False
                    break
for i in range(3):
    for j in range(3):
        for k in range(3):
            for l in range(3):
                if c[i][k] - c[i][l] != c[j][k] - c[j][l]:
                    Takahashi = False
                    break
if Takahashi == True:
    print("Yes")
else:
    print("No")

Solution (Python):
g = [[int(i) for i in input().split()] for i in range(3)]
res = 'No'

for a1 in range(101):
    b1 = g[0][0] - a1
    b2 = g[0][1] - a1
    b3 = g[0][2] - a1
    for a2 in range(101):
        if (a2 + b1) == g[1][0] and (a2 + b2) == g[1][1] and (a2 + b3) == g[1][2]:
            for a3 in range(101):
                if (a3 + b1) == g[2][0] and (a3 + b2) == g[2][1] and (a3 + b3) == g[2][2]:
                    res = 'Yes'
print(res)

Solution (Python):
def main():
    C = tuple(tuple(map(int, input().split())) for _ in [0] * 3)

    c = [[0 for _ in [0] * 4] for _ in [0] * 4]
    for i, n in enumerate(C):
        for j, m in enumerate(n):
            c[i+1][j+1] = m

    a, b = [0] * 4, [0] * 4
    for n in range(c[1][1] + 1):
        a[1] = n
        b[1] = c[1][1] - n
        a[2] = c[2][1] - b[1]
        b[2] = c[1][2] - a[1]
        a[3] = c[3][1] - b[1]
        b[3] = c[1][3] - a[1]

        flag = 0
        for i in range(1, 4):
            for j in range(1, 4):
                if c[i][j] != a[i] + b[j]:
                    flag = 1
                    break
            if flag:
                break
        else:
            print('Yes')
            break
    else:
        print('No')

main()

Solution (Python):
import sys
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    C = 0
    C_diag = 0
    for i in range(3):
        input_raw = read_func().strip().split()
        C += int(input_raw[0]) + int(input_raw[1]) + int(input_raw[2])
        C_diag += int(input_raw[i])
    if C % 3 == 0 and C/3 == C_diag :
        print "Yes"
    else:
        print "No"



if __name__ == '__main__':
    main()

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a = [LI() for _ in range(3)]
    for i in range(3):
        a[i][2] -= a[i][1]
        a[i][1] -= a[i][0]
    if a[0][1] != a[1][1] or a[0][1] != a[2][1] or a[0][2] != a[1][2] or a[0][2] != a[2][2]:
        return 'No'

    return 'Yes'


print(main())

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

Solution (Python):
import numpy as np

C = []

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

C = np.array(C)

row = [np.unique(C[i,:] - C[i+1, :]).shape[0] for i in range(2)]
column = [np.unique(C[:,i] - C[:, i+1]).shape[0] for i in range(2)]

if sum(np.concatenate((row, column), axis = 0)) == 4:
    print("Yes")
else:
    print("No")

Solution (Python):
L1 = input().split(" ")
L2 = input().split(" ")
L3 = input().split(" ")
lis1 = list(map(int, L1))
lis2 = list(map(int, L2))
lis3 = list(map(int, L3))

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

Solution (Python):


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



if(c21 - c11 == c22 - c12 == c23 - c13 and c31 - c11 == c32 - c12 == c33 - c13 and c12 - c11 == c22 - c21 == c32 - c31 and c13 - c11 == c23 - c21 == c33 - c31 ):
    if(isinstance(c21 - c11, int) and isinstance(c31-c11, int) and isinstance(c22-c12, int) and isinstance(c32-c12, int) and isinstance(c23-c13, int) and isinstance(c33-c13, int) and isinstance(c12-c11, int) and isinstance(c13-c11, int) and isinstance(c22-c21, int) and isinstance(c23-c21, int) and isinstance(c32-c31, int) and isinstance(c33-c31, int) ):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):

num = input().split()
firstList = list( map((lambda x:int(x)),num))
num = input().split()
secoundList = list( map((lambda x:int(x)),num))
num = input().split()
thirdList = list( map((lambda x:int(x)),num))

t = firstList + secoundList + thirdList

flag = 0

if (t[0]-t[3]) == (t[1]-t[4]) == (t[2]-t[5]):
    if (t[6]-t[3]) == (t[7]-t[4]) == (t[8]-t[5]):
        if (t[6]-t[0]) == (t[7]-t[1]) == (t[8]-t[2]):
            if (t[1]-t[0]) == (t[4]-t[3]) == (t[7]-t[6]):
                if (t[1]-t[2]) == (t[4]-t[5]) == (t[7]-t[8]):
                    if (t[0]-t[2]) == (t[3]-t[5]) == (t[6]-t[8]):
                        flag = 1

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

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

flag = 0
b = c[0]
for i in range(2):
   if (c[i+1][0]-b[0])==(c[i+1][1]-b[1])==(c[i+1][2]-b[2]):
      flag = flag+1

if flag == 2:
   print("Yes")

else:
   print("No")

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

ans = []
ans1 = [0, 0, 0]
for i in range(3):
    ans1 = [0, 0, 0]
    for j in range(3):
        ans1[j] = a[i]+b[j]
    ans.append(ans1)

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

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

ans = "Yes"
cnt = {i: [] for i in range(6)}
for i in range(3):
    for j in range(3):
        cnt[i].append(c[i][j] - c[(i + 1) % 3][j])
        cnt[i + 3].append(c[j][i] - c[j][(i + 1) % 3])
for ls in cnt.values():
    if min(ls) < max(ls):
        ans = "No"

print(ans)

Solution (Python):

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

s = c[0][1]-c[0][0]
t = c[0][2]-c[0][0]

A = c[1][1]-c[1][0]-s
B = c[1][2]-c[1][0]-t
C = c[2][1]-c[2][0]-s
D = c[2][2]-c[2][0]-t

if (A == 0) & (B == 0) & (C == 0) & (D == 0):
	print("Yes")
else:print("No")

Solution (Python):
grid = [[int(i) for i in input().split()] for i in range(3)] 
ans = "No"
for i in range(1,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
    res = 1
    if(a2 + b2 != grid[1][1]):
        res*=0
    if(a2 + b3 != grid[1][2]):
        res*=0
    if(a3 + b2 != grid[2][1]):
        res*=0
    if(a3 + b3 != grid[2][2]):
        res*=0
    if(res):
        ans = "Yes"
        break
print(ans)

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

    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):
c = []
for i in range(3):
    c.append(list(map(int, input().split())))

ans = 'Yes'

for i in range(2):
    a0 = c[0][i] - c[0][i + 1]
    a1 = c[1][i] - c[1][i + 1]
    a2 = c[2][i] - c[2][i + 1]
    if not (a0 == a1 == a2):
        ans = 'No'
        break

print(ans)

Solution (Python):

import numpy as np

C0=list(map(int,input().split()))
C1=list(map(int,input().split()))
C2=list(map(int,input().split()))
k=0
C=np.zeros(4)
for a1 in range(101):
    for b1 in range(101):
        if C0[0]==a1+b1:
            a1_solid=a1
            b1_solid=b1
            b2=C0[1]-a1_solid
            b3=C0[2]-a1_solid
            a2=C1[0]-b1_solid
            a3=C2[0]-b1_solid
            if C1[1]==a2+b2 and C1[2]==a2+b3 and C2[1]==a3+b2 and C2[2]==a3+b3 and k==0:
                print("Yes")
                k+=1
        if a1==99 and b1==99  and k==0:
                print("No")
                k+=1

Solution (Python):
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

ra=[p,q,r]

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



ans=[]

for n in range(1,3):
    if ra[n][1]-ra[n][0] == x and ra[n][2]-ra[n][0] == y:
        ans.append(True)
    else:
        ans.append(False)

if ans[0] and ans[1]:
    print('Yes')
else:
    print('No')

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

flag = False
for i in range(101):
    a[0], b[0] = i, C[0][0] - i
    if a[0] < 0 or b[0] < 0:
        continue

    for m in range(1, 3):
        a[m] = C[m][0] - b[0]

    for n in range(1, 3):
        b[n] = C[0][n] - a[0]

    if min(a) < 0 or min(b) < 0:
        continue

    rec = True
    for j in range(3):
        for k in range(3):
            if a[j] + b[k] != C[j][k]:
                rec = False

    if rec:
        flag = True
        break


if flag:
    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()))

for i in range(100+1):
  a1 = c1[0] - i
  a2 = c2[0] - i
  a3 = c3[0] - i
  if c1[1] - a1 == c2[1] - a2 == c3[1] - a3 and c1[2] - a1 == c2[2] - a2 == c3[2] - a3:
    print('Yes')
    exit(0)
print('No')

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



for x in range(d[0]+1):
    for y in range(d[1]+1):
        for z in range(d[2]+1):
            for i in range(3):
                if(c[0][i]-x+1==c[1][i]-y+1):
                    if(c[1][i]-y+1==c[2][i]-z+1):
                        pass                        
                    else:
                        break
                else:
                    break
            else:
                print('Yes')
                exit()
else:
    print('No')

Solution (Python):
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
c=i2()
s="Yes"
b=[c[0]-c[1],c[1]-c[2]]
c=i2()
if not (b[0]==c[0]-c[1] and b[1]==c[1]-c[2]):s="No"
c=i2()
if not (b[0]==c[0]-c[1] and b[1]==c[1]-c[2]):s="No"
print(s)

Solution (Python):


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


a1=0

t21=[x-y for x,y in zip(c2,c1)]
t32=[x-y for x,y in zip(c3,c2)]
t31=[x-y for x,y in zip(c3,c1)]

tmp1=t21[0]
tmp2=t32[0]
tmp3=t31[0]


for i in range(1,3):
    if tmp1!=t21[i] or tmp2!=t32[i] or tmp3!=t31[i]:
        print("No")
        exit()

print("Yes")

Solution (Python):
def solve():
    c = []
    c.append(list(map(int, input().split())))
    c.append(list(map(int, input().split())))
    c.append(list(map(int, input().split())))

    a0_list = range(c[0][0]+1)

    for a0 in a0_list:
        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 c[1][1] != a1 + b1:
            continue
        if c[1][2] != a1 + b2:
            continue
        if c[2][1] != a2 + b1:
            continue
        if c[2][2] != a2 + b2:
            continue
        print("Yes")
        return

    print("No")
    return

solve()

Solution (Python):
import random
import numpy
import sys

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

grid[0]=list(map(int, input().split(" ")))
grid[1]=list(map(int, input().split(" ")))
grid[2]=list(map(int, input().split(" ")))

for a[0] in range(100):
  for b[0] in range(100):
    if (a[0]+b[0]) == grid[0][0]:
      testgrid[0][0] = a[0]+b[0]
      b[1] = grid[0][1]-a[0]
      b[2] = grid[0][2]-a[0]
      testgrid[0][1] = a[0]+b[1]
      testgrid[0][2] = a[0]+b[2]
      if testgrid[0] == grid[0]:
        a[1] = grid[1][0]-b[0]
        testgrid[1][0] = a[1]+b[0]
        testgrid[1][1] = a[1]+b[1]
        testgrid[1][2] = a[1]+b[2]
        if testgrid[1] == grid[1]:
          a[2] = grid[2][0]-b[0]
          testgrid[2][0] = a[2]+b[0]
          testgrid[2][1] = a[2]+b[1]
          testgrid[2][2] = a[2]+b[2]
          if testgrid == grid:
            print("Yes")
            exit()
print("No")

Solution (Python):
c = [[int(x) for x in input().split()] for _ in range(3)]
f = True
from itertools import product
for i,j in product(range(1,3), range(1,3)):
        if c[0][0]+c[i][j] != c[i][0]+c[0][j]:
            f = False
            break

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

Solution (Python):
c = [[int(_) for _ in input().split()] for i in range(3)]
ans = True
for x in range(2):
    c0 = c[x+1][0] - c[x][0]
    c1 = c[x+1][1] - c[x][1]
    c2 = c[x+1][2] - c[x][2]
    if c0 != c1 or c1 != c2 or c2 != c0:
        ans = False
for y in range(2):
    c0 = c[0][y+1] - c[0][y]
    c1 = c[1][y+1] - c[1][y]
    c2 = c[2][y+1] - c[2][y]
    if c0 != c1 or c1 != c2 or c2 != c0:
        ans = False
if(ans):
    print('Yes')
else:
    print('No')

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

frag = 0
x = c4 - c1
y = c5 - c2
z = c6 - c3
if x != y or y != z:
    frag = 1
x = c4 - c7
y = c5 - c8
z = c6 - c9
if x != y or y != z:
    frag = 1
x = c2 - c1
y = c5 - c4
z = c8 - c7
if x != y or y != z:
    frag = 1
x = c2 - c3
y = c5 - c6
z = c8 - c9
if x != y or y != z:
    frag = 1
if frag == 1:
    print("No")
else:
    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())

judge = 0
for i in range(0,101):
    a1 = i

    b1 = c11 - a1
    b2 = c12 - a1
    b3 = c13 - a1
    
    if c21 - b1 == c22 - b2 and c22 - b2 == c23 -b3:
        if c31 - b1 == c32 - b2 and c32 - b2 == c33 -b3:
            print("Yes")
            judge = 1
            break
        else:
            pass
    else:
        pass

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

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

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

Solution (Python):
grid = [list(map(int,input().split())) for _ in range(3)]
a1 = min(grid[0])
a2 = min(grid[1])
a3 = min(grid[2])


flag = False

while True:
    if a1 < 0 or a2 < 0 or a3 < 0:
        break
    b1 = grid[0][0] - a1
    c1 = grid[1][0] - a2
    d1 = grid[2][0] - a3
    
    b2 = grid[0][1] - a1
    c2 = grid[1][1] - a2
    d2 = grid[2][1] - a3
    
    b3 = grid[0][2] - a1
    c3 = grid[1][2] - a2
    d3 = grid[2][2] - a3

    if b1 == c1 == d1 and b2 == c2 == d2 and b3 == c3 == d3:
        flag = True
        break
    a1 -= 1
    a2 -= 1
    a3 -= 1
    
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):
row1 = input().split(' ')
row2 = input().split(' ')
row3 = input().split(' ')

index = []
index.append(row1)
index.append(row2)
index.append(row3)

a = [] 
b = []

Ans = 'Yes'
for j in range(2):
    for i in range(3):
        a.append(int(index[i][j]) - int(index[i][j+1]))
    if max(a) != min(a):   
        Ans = 'No'
    a = []

for i in range(2):
    for j in range(3):
        b.append(int(index[i][j]) - int(index[i+1][j]))
    if max(b) != min(b):   
        Ans = 'No'
    b = []
    
print(Ans)

Solution (Python):
def solve(a,b,c):
  x=sum(a)
  y=sum(b)
  z=sum(c)
  if abs(x-y)%3!=0 or abs(y-z)%3!=0 or abs(z-x)%3!=0:
    return False
  for i in range(101):
    for j in range(101):
      for k in range(101):
        if (i-j)*3==(x-y) and (j-k)*3==(y-z) and (k-i)*3==(z-x):
          return True
  return False

A1=[int(x) for x in input().split()]
A2=[int(x) for x in input().split()]
A3=[int(x) for x in input().split()]

B1=[A1[0],A2[0],A3[0]]
B2=[A1[1],A2[1],A3[1]]
B3=[A1[1],A2[1],A3[1]]

if solve(A1,A2,A3) and solve(B1,B2,B3):
  print("Yes")
else:
  print("No")

Solution (Python):


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

flag = 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]:
            flag = False

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

Solution (Python):


def solve():
    c = [list(map(int, input().split())) for _ in range(3)]
    for a0 in range(-100, 101) :
        b = [c[0][i] - a0 for i in range(3)]
        if any(c[1][0] - b[0] != c[1][i] - b[i] for i in range(3)):
            continue
        if any(c[2][0] - b[0] != c[2][i] - b[i] for i in range(3)):
            continue
        return True
    return False


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

Solution (Python):
n=3
c=[]

for i in range(n):
    c.append([int(i) for i in input().split()])

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

e=c[0][0]-c[1][0]
f=c[1][0]-c[2][0]
g=c[2][0]-c[0][0]

for i in range(n):
    if c[i][0]-c[i][1]==a and c[i][1]-c[i][2]==b and c[i][2]-c[i][0]==d:
        if c[0][i]-c[1][i]==e and c[1][i]-c[2][i]==f and c[2][i]-c[0][i]==g: 
            pass

    else:
              print("No")
              break  

else:
    print("Yes")

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

for i in range(2):
	s=set()
	for x1,x2 in zip(C[i],C[i+1]):
		s.add(x1-x2)

	if len(s)>1:
		print "No"
		quit()

C1=[[] for i in range(3)]
for i in range(3):
	C1[i].append(C[i][0]-C[i][1])
	C1[i].append(C[i][1]-C[i][2])

if C1[0]==C1[1]==C1[2]:
	print "Yes"
else:
	print "No"

Solution (Python):
def main():
    N = 3
    c = []
    for i in range(N):
        c.append([int(j) for j in input().split()])
    for i in range(N-1):
        for j in range(N-1):
            if c[i][j] + c[i+1][j+1] != c[i][j+1] + c[i+1][j]:
                print('No')
                return
    print('Yes')


if __name__ == '__main__':
    main()

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
for i in range(-int(1e4),100):
    if (calc(i,c)): 
        print('Yes')
        flag=True
        break
if not flag: print('No')

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

for i in range(3):
    a[i] = min(c[i][0], c[i][1], c[i][2])
    for j in range(3):
        c[i][j] -= a[i]

for i in range(3):
    if min(c[0][i], c[1][i], c[2][i]) != \
        max(c[0][i], c[1][i], c[2][i]):

        print('No')
        exit()
print('Yes')

Solution (Python):
list_c = []

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

is_success = True

c0 = sum(list_c[0])
c1 = sum(list_c[1])
c2 = sum(list_c[2])
if c0 % 3 != c1 % 3 \
        or c1 % 3 != c2 % 3 \
        or c2 % 3 != c0 % 3:
    is_success = False

c0 = sum([list_c[i][0] for i in range(3)])
c1 = sum([list_c[i][1] for i in range(3)])
c2 = sum([list_c[i][2] for i in range(3)])
if c0 % 3 != c1 % 3 \
        or c1 % 3 != c2 % 3 \
        or c2 % 3 != c0 % 3:
    is_success = False

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

Solution (Python):
import sys,collections;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

mat = []
for i in range(3):
    mat.append(Is())
if mat[0][0] - mat[0][1] == mat[1][0] - mat[1][1] == mat[2][0] - mat[2][1]:
    if mat[0][1] - mat[0][2] == mat[1][1] - mat[1][2] == mat[2][1] - mat[2][2]:
        if mat[0][0] - mat[1][0] == mat[0][1] - mat[1][1] == mat[0][2] - mat[1][2]:
            if mat[1][0] - mat[2][0] == mat[1][1] - mat[2][1] == mat[1][2] - mat[2][2]:
                print("Yes")
                exit()
print("No")

Solution (Python):
c = [0,0,0]
c[0] = [int(i) for i in input().split()]
c[1] = [int(i) for i in input().split()]
c[2] = [int(i) for i in input().split()]
for i in range(3):
    for j in range(3):
        d = [c[i][k] - c[j][k] for k in range(3)]
        if sum(d) != 3*d[0]: 
            print('No')
            exit()
print('Yes')

Solution (Python):
import numpy as np

v = []
for i in range(3):
    v.extend(input().split())

v = np.array([int(x) for x in v])



coeffs = np.array([
    [1, 0, 0, 1, 0, 0, v[0]],
    [1, 0, 0, 0, 1, 0, v[1]],
    [1, 0, 0, 0, 0, 1, v[2]],
    [0, 1, 0, 1, 0, 0, v[3]],
    [0, 1, 0, 0, 1, 0, v[4]],
    [0, 1, 0, 0, 0, 1, v[5]],
    [0, 0, 1, 1, 0, 0, v[6]],
    [0, 0, 1, 0, 1, 0, v[7]],
    [0, 0, 1, 0, 0, 1, v[8]],
])

rank = np.linalg.matrix_rank(coeffs)
if rank < 6:
    print("Yes")
else:
    print("No")

Solution (Python):
import math
import numpy as np
from operator import mul



















tmp = [list(map(int, input().split())) for i in range(3)]
C = np.array(tmp)
a = 0

div = C[0] - C[1]
if div[0] == div[1] and div[0] == div[2]:
    a += 1
    
div = C[1] - C[2]
if div[0] == div[1] and div[0] == div[2]:
    a += 1

div = C[0] - C[2]
if div[0] == div[1] and div[0] == div[2]:
    a += 1

C.T

div = C[0] - C[1]
if div[0] == div[1] and div[0] == div[2]:
    a += 1
    
div = C[1] - C[2]
if div[0] == div[1] and div[0] == div[2]:
    a += 1

div = C[0] - C[2]
if div[0] == div[1] and div[0] == div[2]:
    a += 1

if a == 6:
    print("Yes")
else:
    print("No")

Solution (Python):

"""
https://abc088.contest.atcoder.jp/tasks/abc088_c

"""
import sys
from sys import stdin
input = stdin.readline


def solve(M):
    for a1 in range(100+1):
        b1 = M[0][0] - a1
        a2 = M[1][0] - b1
        a3 = M[2][0] - b1
        b2 = M[0][1] - a1
        b3 = M[0][2] - a1
        if a2+b2 == M[1][1] and a2+b3==M[1][2] and a3+b2==M[2][1] and a3+b3==M[2][2]:
            return 'Yes'
    return 'No'


def main(args):
    M = []
    for _ in range(3):
        M.append([int(x) for x in input().split()])
    ans = solve(M)
    print(ans)


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

Solution (Python):

import numpy as np
c = []
c.append (list(map(int, input().split())))
c.append (list(map(int, input().split())))
c.append (list(map(int, input().split())))
c = np.array(c)
if np.sum(c)/3 == c[0][0]+c[1][1]+c[2][2]:
    print("Yes")
else:
    print("No")