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



Sample input:
1 0 1
2 1 2
1 0 1


Sample output:
Yes

Submission status: Accepted

Solution code:
arr = [list(map(int,input().split())) for i in range(3)]
flg = 0
for i in range(2):
    for j in range(2):
        if arr[i][j] + arr[i+1][j+1] - arr[i+1][j] - arr[i][j+1] == 0:
            flg += 1
        else:
            break
if flg == 4:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

a,b,c = C[0],C[1],C[2]

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

else:
   print('No')

Submission status: Accepted

Solution code:
import numpy as np

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

b1 = c11
b2 = c12
b3 = c13
a1 = 0
a2 = c21 - b1
a3 = c31 - b1

if(c11 == a1 + b1):
    if(c12 == a1 + b2):
        if(c13 == a1 + b3):
            if(c21 == a2 + b1):
                if(c22 == a2 + b2):
                    if(c23 == a2 + b3):
                        if(c31 == a3 + b1):
                            if(c32 == a3 + b2):
                                if(c33 == a3 + b3):
                                    result = 1
if(result == 1):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

res = False

for b0 in range(0,100):
	a0 = c[0][0] - b0
	a1 = c[1][0] - b0
	a2 = c[2][0] - b0

	b1 = set()
	b2 = set()
	b1.add(c[0][1] - a0)
	b1.add(c[1][1] - a1)
	b1.add(c[2][1] - a2)
	b2.add(c[0][2] - a0)
	b2.add(c[1][2] - a1)
	b2.add(c[2][2] - a2)
	if (len(b1) == 1 and len(b2) == 1):
		res = True
		break

print("Yes" if res == True else "No")

Submission status: Accepted

Solution code:
C = [list(map(int, input().split())) for i in range(3)]
X = [[0 for j in range(3)] for i in range(3)]
result = 'Yes'
for i in range(3):
    X[i][0] = C[i][0] - C[i][1]
    X[i][1] = C[i][1] - C[i][2]
    X[i][2] = C[i][2] - C[i][0]
for i in range(3):
    if X[0][i] != X[1][i] or X[0][i] != X[2][i]:
        result = 'No'
        break
for j in range(3):
    X[0][j] = C[0][j] - C[1][j]
    X[1][j] = C[1][j] - C[2][j]
    X[2][j] = C[2][j] - C[0][j]
for j in range(3):
    if X[j][0] != X[j][1] or X[j][0] != X[j][2]:
        result = 'No'
        break
print(result)

Submission status: Accepted

Solution code:
import numpy as np
import pprint
import itertools

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

C = np.asarray(c)

A = np.asarray([0, -1, -1])
B = C[0]

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

yes = True
for i, j in itertools.product(range(3), range(3)):
    if A[i] + B[j] != C[i][j]:
        yes = False
        break

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

Submission status: Accepted

Solution code:
import sys

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

Submission status: Accepted

Solution code:
C = [list(map(lambda x:int(x),input().split())) for i in range(3)]
#print(C)
a,b,c = C[0],C[1],C[2]
if ((a[0]-a[1])==(b[0]-b[1]) and (b[0]-b[1])==(c[0]-c[1])) and\
   ((a[2]-a[1])==(b[2]-b[1]) and (b[2]-b[1])==(c[2]-c[1])):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
c1_c1 = [0] * 3
c2_c1 = [0] * 3
c3_c1 = [0] * 3

for i in range(3):
   c1_c1[i] = c1[i] - c1[i]
   c2_c1[i] = c2[i] - c1[i]
   c3_c1[i] = c3[i] - c1[i]

if(c1_c1[0] == c1_c1[1] and c1_c1[1] == c1_c1[2] and c2_c1[0] == c2_c1[1] and c2_c1[1] == c2_c1[2] and c3_c1[0] == c3_c1[1] and c3_c1[1] == c3_c1[2] ):
   print("Yes")
else:
   print("No")

Submission status: Accepted

Solution code:
temp1 = input()
r1 = temp1.split()
for j in range(len(r1)):
    r1[j] = int(r1[j])
temp2 = input()
r2 = temp2.split()
for j in range(len(r2)):
    r2[j] = int(r2[j])
temp3 = input()
r3 = temp3.split()
for j in range(len(r3)):
    r3[j] = int(r3[j])

r_d1 = [i for i in range(3)]
r_d2 = [i for i in range(3)]
for i in range(3):
    r_d1[i] = r2[i]-r1[i]
    r_d2[i] = r3[i]-r1[i]
if r_d1.count(r_d1[0]) == 3:
    flag = 1
else:flag = 0

if r_d2.count(r_d2[0]) == 3:
    flag = flag*1
else:flag = flag*0

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

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
#coding:utf-8

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):
            #print(C[j][k], A[j] + B[k])
            if C[j][k] == A[j] + B[k]:
                continue
            else:
                ans = 1

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

Submission status: Accepted

Solution code:
#ABC088C
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'

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""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)

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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'

Submission status: Accepted

Solution code:
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"

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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):
        # c - a[0]だけど0なので省略
        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()

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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())

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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'

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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"

Submission status: Accepted

Solution code:
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"

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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)]  # a_1=0と仮定してよい
    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))

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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"