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:
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    c = [list(map(int, input().rstrip('\n').split())) for _ in range(3)]
    for i in range(3):
        m = min(c[i])
        for j in range(3):
            c[i][j] -= m
    for i in range(3):
        m = 10 ** 10
        for j in range(3):
            m = min(c[j][i], m)
        for j in range(3):
            c[j][i] -= m
    mt = 0
    for i in range(3):
        for j in range(3):
            mt = max(mt, c[i][j])
    print("Yes" if mt == 0 else "No")


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
grid = [[], [], []]
for i in range(3):
    grid[i] = [int(i) for i in input().split()]
x = [0] * 3
y = []
ret = True
for i in range(3):
    y.append(grid[0][i] - x[0])
for i in range(3):
    x[i] = grid[i][0] - y[0]
for i in range(3):
    for j in range(3):
        if not x[i] + y[j] == grid[i][j]:
            ret = False
    else:
        continue
    break
print("Yes" if ret else "No")

Submission status: Accepted

Solution code:
s=[];
for i in range(3):
  s.append(list(map(int,input().split())))
sum=0
for i in range(3):
  for j in range(3):sum+=s[i][j]
c1=s[0][0]+s[1][1]+s[2][2]
c2=s[0][2]+s[1][1]+s[2][0]
print('Yes'if sum==c1*3 and sum==c2*3 else 'No')

Submission status: Accepted

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

c = c1 + c2 + c3

if sum(c) % 3 == 0 and c[0] + c[4] + c[8] == c[1] + c[3] + c[8]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import collections
import math
import numpy as np

# = input()
# = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
#
is_true = True
field = []
for i in range(3):
  field.append(list(map(int, input().split())))

field = np.array(field)
for i in range(3):
  field[i] -= min(field[i])

is_true = np.where(field==field[0], True, False).all()

field = np.array(field).T
for i in range(3):
  field[i] -= min(field[i])

is_true2 = np.where(field==field[0], True, False).all()

print('Yes' if is_true * is_true2 else 'No')

Submission status: Accepted

Solution code:
C1 = list(map(int, input().split()))
C2 = list(map(int, input().split()))
C3 = list(map(int, input().split()))

if (C1[0]-C1[1]==C2[0]-C2[1] and C2[0]-C2[1] ==C3[0]-C3[1]) and (C1[0]-C1[2]==C2[0]-C2[2] and C2[0]-C2[2]==C3[0]-C3[2]):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

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

c1 = many_int()
c2 = many_int()
c3 = many_int()

import numpy as np
temp_array=np.asarray([c1,c2,c3])
temp = temp_array.T

same_flg=True

same = c1[0]-c2[0]
for a,b in zip(c1[1:],c2[1:]):
    if a-b != same:
        same_flg=False
        
same = c1[0]-c3[0]
for a,b in zip(c1[1:],c3[1:]):
    if a-b != same:
        same_flg=False
        
same = c2[0]-c3[0]
for a,b in zip(c2[1:],c3[1:]):
    if a-b != same:
        same_flg=False





c1=list(temp[0])
c2=list(temp[1])
c3=list(temp[2])

same = c1[0]-c2[0]
for a,b in zip(c1[1:],c2[1:]):
    if a-b != same:
        same_flg=False

same = c1[0]-c3[0]
for a,b in zip(c1[1:],c3[1:]):
    if a-b != same:
        same_flg=False

same = c2[0]-c3[0]
for a,b in zip(c2[1:],c3[1:]):
    if a-b != same:
        same_flg=False

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

Submission status: Accepted

Solution code:
a,b,c = [list(map(int,input().split())) for i in range(3)]
for i in range(a[0]+1):
    b1=a[0]-i
    b2=a[1]-i
    b3=a[2]-i
    a2=[]
    a3=[]
    a2.append(b[0]-b1)
    a2.append(b[1]-b2)
    a2.append(b[2]-b3)
    a3.append(c[0]-b1)
    a3.append(c[1]-b2)
    a3.append(c[2]-b3)
    if len(set(a2))==1 and len(set(a3))==1:
        print("Yes")
        exit()
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()))

a1 = 0
b1 = L1[0]
b2 = L1[1]
b3 = L1[2]
a2 = L2[1]-b2
a3 = L3[2]-b3

if a1+b1==L1[0] and a1+b2==L1[1] and a1+b3==L1[2] and a2+b1==L2[0] and a2+b2==L2[1] and a2+b3==L2[2] and a3+b1==L3[0] and a3+b2==L3[1] and a3+b3==L3[2]:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
def main():
    import numpy as np
    A = np.array([[1, 0, 0, 1, 0, 0],
                  [1, 0, 0, 0, 1, 0],
                  [1, 0, 0, 0, 0, 1],
                  [0, 1, 0, 1, 0, 0],
                  [0, 1, 0, 0, 1, 0],
                  [0, 1, 0, 0, 0, 1],
                  [0, 0, 1, 1, 0, 0],
                  [0, 0, 1, 0, 1, 0],
                  [0, 0, 1, 0, 0, 1]])
    C = [[int(i) for i in input().split()] for j in range(3)]
    C = np.array(C)
    C = C.reshape([9, 1])
    ext_A = np.concatenate([A, C], axis=1)
    A_rank = np.linalg.matrix_rank(A)
    ext_A_rank = np.linalg.matrix_rank(ext_A)
    # 拡大係数行列と係数行列のrankが等しければ解が存在する
    if A_rank == ext_A_rank:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
C = [list(map(int,input().split())) for _ in range(3)]
print('Yes' if C[0][0]-C[0][1] == C[1][0]-C[1][1] == C[2][0]-C[2][1] and C[0][1]-C[0][2] == C[1][1]-C[1][2] ==C[2][1]-C[2][2] else 'No')

Submission status: Accepted

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

Submission status: Accepted

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

dx1 = C[0][1] - C[0][0]
dx2 = C[0][2] - C[0][1]
dy1 = C[1][0] - C[0][0]
dy2 = C[2][0] - C[1][0]

Ans = "Yes"
for i in range(3):
    if (C[i][1] - C[i][0] != dx1 or C[i][2] - C[i][1] != dx2 or
        C[1][i] - C[0][i] != dy1 or C[2][i] - C[1][i] != dy2):
        Ans = "No"
        break

print(Ans)

Submission status: Accepted

Solution code:
c = ['' for _ in range(3)]
c[0] = list(map(int, input().split()))
c[1] = list(map(int, input().split()))
c[2] = list(map(int, input().split()))
ans = 'Yes'
for i in range(2):
    line = [0 for _ in range(3)]
    column = [0 for _ in range(3)]
    for j in range(3):
        line[j] = c[i + 1][j] - c[i][j]
        column[j] = c[i + 1][j] - c[i][j]
    if len(set(line)) != 1 or len(set(column)) != 1:
        ans = 'No'
        break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
if a[1]-a[0]==b[1]-b[0]==c[1]-c[0]:
    if a[1]-a[2]==b[1]-b[2]==c[1]-c[2]:
        print("Yes")
        sys.exit()
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()))
k2=C2[0]-C1[0]
k3=C3[0]-C1[0]
C2=[i-k2 for i in C2]
C3=[i-k3 for i in C3]
print(['No','Yes'][C1==C2==C3])

Submission status: Accepted

Solution code:
c = []
c_diff = []
 
for i in range(3) :
    c.append([int(x) for x in input().split()])
 
for i in range(3) :
    c_diff.append([c[i][j] - c[i][0] for j in range(3)])
 
if c_diff[0] == c_diff[1] == c_diff[2] :
    print('Yes')
else :
    print('No')

Submission status: Accepted

Solution code:
c = []
c_diff = []

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

for i in range(3) :
    c_min = min(c[i])
    c_diff.append([c[i][j] - c_min for j in range(3)])

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

Submission status: Accepted

Solution code:
line1 = list(map(int, input().split()))
line2 = list(map(int, input().split()))
line3 = list(map(int, input().split()))

b1 = [line1[1]-line1[0], line1[2]-line1[0]]
b2 = [line2[1]-line2[0], line2[2]-line2[0]]
b3 = [line3[1]-line3[0], line3[2]-line3[0]]

a1 = [line2[0] - line1[0], line3[0] - line1[0]]
a2 = [line2[1] - line1[1], line3[1] - line1[1]]
a3 = [line2[2] - line1[2], line3[2] - line1[2]]

check = False
if b1[0] == b2[0] and b1[0] == b3[0]:
    if b1[1] == b2[1] and b1[1] == b3[1]:
        if a1[0] == a2[0] and a1[0] == a3[0]:
            if a1[1] == a2[1] and a1[1] == a3[1]:
                check = True

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

Submission status: Accepted

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

count = 0
for i in range(3):
    for j in range(3):
        if c[i][j] + c[j][i] == c[i][i] + c[j][j]:
            count += 1
if count == 9:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:

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

a = [None, None, None]
b = [None, None, None]
for a1 in range(101):
    a[0] = a1
    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]


ans = 'Yes'
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=[list(map(int,input().split())) for _ in range(3)]

for i in range(1,3):
  if C[i][0]-C[0][0]==C[i][1]-C[0][1] and C[i][0]-C[0][0]==C[i][2]-C[0][2]:
    pass
  else:
    print("No")
    exit()
    
print("Yes")

Submission status: Accepted

Solution code:
c=[]
for _ in range(3):
  c.append(list(map(int,input().split())))
for i in range(2):
  if c[i][0]-c[i+1][0]!=c[i][1]-c[i+1][1] or c[i][1]-c[i+1][1]!=c[i][2]-c[i+1][2]:
    print('No')
    exit()
  if c[0][i]-c[0][i+1]!=c[1][i]-c[1][i+1] or c[1][i]-c[1][i+1]!=c[2][i]-c[2][i+1]:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

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

for i in range(1,3):
  if C[i][0]-C[0][0]==C[i][1]-C[0][1] and C[i][0]-C[0][0]==C[i][2]-C[0][2]:
    pass
  else:
    print("No")
    exit()
    
print("Yes")

Submission status: Accepted

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

a1=c[1][0]-c[0][0]
a2=c[1][1]-c[0][1]
a3=c[1][2]-c[0][2]
b1=c[2][0]-c[1][0]
b2=c[2][1]-c[1][1]
b3=c[2][2]-c[1][2]

if a1==a2==a3 and b1==b2==b3 and a1%1==0 and a2%1==0 and a3%1==0 and b1%1==0 and b2%1==0 and b3%1==0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
c=[list(map(int,input().split())),list(map(int,input().split())),list(map(int,input().split()))]
f=True
if not c[1][0]-c[0][0]==c[1][1]-c[0][1]==c[1][2]-c[0][2]: # 0行-1行の成分が全て同じ
    f=False
if not c[2][0]-c[1][0]==c[2][1]-c[1][1]==c[2][2]-c[1][2]: # 1行-2行の成分が全て同じ
    f=False
if not c[0][1]-c[0][0]==c[1][1]-c[1][0]==c[2][1]-c[2][0]: # 0列-1列の成分が全て同じ
    f=False
if not c[0][2]-c[0][1]==c[1][2]-c[1][1]==c[2][2]-c[2][1]: # 1列-2列の成分が全て同じ
    f=False
print('Yes' if f else 'No')

Submission status: Accepted

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

ans = "Yes"
tmp=C[0][0]

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

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

Submission status: Accepted

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

closs1 = 0
closs2 = 0

for i in range(2):
	if list1[i][1] - list1[i][0] == list1[i+1][1] - list1[i+1][0] and \
	list1[i][2] - list1[i][1] == list1[i+1][2] - list1[i+1][1]:
		continue
	else:
		print("No")
		exit()
print("Yes")

Submission status: Accepted

Solution code:
X=list(map(int,input().split()))
Y=list(map(int,input().split()))
Z=list(map(int,input().split()))

res = "Yes"
for i in range(2):
	if X[i]-X[i+1] == Y[i]-Y[i+1] and X[i]-X[i+1] == Z[i]-Z[i+1]:
		res = "No"
		break
	i
if(X[0]-X[1]==Y[0]-Y[1] and X[0]-X[1]==Z[0]-Z[1] and X[2]-X[1]==Y[2]-Y[1] and X[2]-X[1]==Z[2]-Z[1]):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
import sys


def slove():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    a = [list(map(int, input().rstrip('\n').split())) for _ in range(3)]
    for i in range(3):
        t = min(a[i])
        if t != 0:
            for j in range(3):
                a[i][j] -= t
        t = min([a[j][i] for j in range(3)])
        if t != 0:
            for j in range(3):
                a[j][i] -= t
    print("Yes" if max([a[i][j] for i in range(3) for j in range(3)]) == 0 else "No")


if __name__ == '__main__':
    slove()

Submission status: Accepted

Solution code:
import numpy as np
c=[]
for i in range(3):
    c.append(list(map(lambda x: int(x), input().split())))
c=np.array(c)
ans='Yes'
tmp=c[:,0]-c[:,1]
if np.min(tmp) != np.max(tmp):
    ans='No'
tmp=c[:,0]-c[:,2]
if np.min(tmp) != np.max(tmp):
    ans='No'
tmp=c[0,:]-c[1,:]
if np.min(tmp) != np.max(tmp):
    ans='No'
tmp=c[0,:]-c[2,:]
if np.min(tmp) != np.max(tmp):
    ans='No'
print(ans)

Submission status: Accepted

Solution code:
import sys

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

#print(c)

coldif = [c[0][1] - c[0][0], c[0][2] - c[0][1]]

#print(coldif)

for i in range(1, 3):
    dif = [c[i][1] - c[i][0], c[i][2] - c[i][1]]
    if dif != coldif:
        print('No')
        sys.exit()

rowdif = [c[1][0] - c[0][0], c[2][0] - c[1][0]]

#print(rowdif)

for i in range(1, 3):
    dif = [c[1][i] - c[0][i], c[2][i] - c[1][i]]
    if dif != rowdif:
        print('No')
        sys.exit()

print('Yes')

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


#print(max(max(C[0],C[0],C[0])))

res=False

for a1 in range(0,min(C[0])+1):
        b1=C[0][0] - a1
        b2=C[0][1] - a1
        b3=C[0][2] - a1

        if C[1][0] - b1 == C[1][1] - b2 == C[1][2] - b3:
                if C[2][0] - b1 == C[2][1] - b2 == C[2][2] - b3:
                        res=True
                        break

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

Submission status: Accepted

Solution code:
S = []
for _ in range(3):
	s = list(map(int, input().split()))
	S.append(s)
	
a = [None, None, None]
b = [None, None, None]

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

yes = 1

for i in range(3):
	for j in range(3):
		if not S[i][j] == a[i] + b[j]:
			yes = 0
			break

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

Submission status: Accepted

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

Submission status: Accepted

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

a = [0] * 3
b = [0] * 3

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

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

for i in range(3):
    for j in range(3):
        if c[i][j] == a[i] + b[j]:
            pass
        else:
            print("No")
            sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
c = [list(map(int,input().split())) for _ in range(3)]
import sys
a = [0,0,0]
b= [0,0,0]

min_1 = min(c[0])
for j in range(0,min_1+1):
  a[0] = j
  b[0] = c[0][0]-j
  b[1] = c[0][1]-j
  b[2] = c[0][2]-j
  a[1] = c[1][0]-b[0]
  a[2] = c[2][0]-b[0]
  if a[1]<0 or a[2]<0: continue
  for i in [1,2]:
    for k in [1,2]:
      if c[i][k] != a[i]+b[k]:
        break
      else:
        if i==2 and k==2:
          print("Yes")
          sys.exit()
    else:
      continue
    break

print("No")

Submission status: Accepted

Solution code:
# 1行目と2行目を引いて全ての列で同じか確かめる
# それをあと３回繰り返す

def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    cs = [list(map(int, input().split())) for _ in range(3)]
    for i in range(2):
        tmp_diff = [0] * 3
        for j in range(3):
            tmp_diff[j] = cs[i][j] - cs[i + 1][j]
        if len(set(tmp_diff)) == 1:
            pass
        else:
            print("No")
            exit()
    
    for i in range(2):
        tmp_diff = [0] * 3
        for j in range(3):
            tmp_diff[j] = cs[j][i] - cs[j][i + 1]
        if len(set(tmp_diff)) == 1:
            pass
        else:
            print("No")
            exit()
    print("Yes")



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
X=list(map(int,input().split()))
Y=list(map(int,input().split()))
Z=list(map(int,input().split()))
if(X[0]-X[1]==Y[0]-Y[1] and X[0]-X[1]==Z[0]-Z[1] and X[2]-X[1]==Y[2]-Y[1] and X[2]-X[1]==Z[2]-Z[1]):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
import numpy as np

def test():
    c = np.array([list(map(int,input().split())) for i in range(3)])
    a = c - np.min(c,axis=0)
    if a[0][0]==a[0][1]==a[0][2] and a[1][0]==a[1][1]==a[1][2] and a[2][0]==a[2][1]==a[2][2]:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    test()

Submission status: Accepted

Solution code:
def solve():
    c = [[int(i) for i in input().split()] for _ in range(3)]
    for i in range(2):
        for j in range(2):
            if not c[i][j]-c[i+1][j] == c[i][j+1]-c[i+1][j+1]:
                return 'No'
    for i in range(2):
        for j in range(2):
            if not c[i][j]-c[i][j+1] == c[i+1][j]-c[i+1][j+1]:
                return 'No'
    return 'Yes'

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

Submission status: Accepted

Solution code:
def solve():
    c = [[int(i) for i in input().split()] for _ in range(3)]
    for i in range(2):
        for j in range(2):
            if not c[i][j]-c[i+1][j] == c[i][j+1]-c[i+1][j+1]:
                return 'No'
    for i in range(2):
        for j in range(2):
            if not c[j][i]-c[j][i+1] == c[j+1][i]-c[j+1][i+1]:
                return 'No'
    return 'Yes'
        

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

Submission status: Accepted

Solution code:
def solve():
    c = [[int(i) for i in input().split()] for _ in range(3)]
    if not (c[0][0]-c[1][0] == c[0][1]-c[1][1] == c[0][2]-c[1][2]):
        return 'No'
    elif not (c[1][0]-c[2][0] == c[1][1]-c[2][1] == c[1][2]-c[2][2]):
        return 'No'
    elif not (c[0][0]-c[0][1] == c[1][0]-c[1][1] == c[2][0]-c[2][1]):
        return 'No'
    elif not (c[0][1]-c[0][2] == c[1][1]-c[1][2] == c[2][1]-c[2][2]):
        return 'No'
    else:
        return 'Yes'

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

Submission status: Accepted

Solution code:
l=[list(map(int, input().split())) for i in range(3)]
l.sort()
if l[1][0]-l[0][0]==l[1][1]-l[0][1]==l[1][2]-l[0][2]:
    if l[2][0]-l[0][0]==l[2][1]-l[0][1]==l[2][2]-l[0][2]:
        print('Yes')
    else:print('No')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

q1 = c[0][0] - c[0][1] == c[1][0] - c[1][1] == c[2][0] - c[2][1]
q2 = c[0][0] - c[0][2] == c[1][0] - c[1][2] == c[2][0] - c[2][2]
q3 = c[0][0] - c[1][0] == c[0][1] - c[1][1] == c[0][2] - c[1][2]
q4 = c[0][0] - c[2][0] == c[0][1] - c[2][1] == c[0][2] - c[2][2]

if q1 and q2 and q3 and q4 == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a,b,c = list(map(int,input().split()))
d,e,f = list(map(int,input().split()))
g,h,i = list(map(int,input().split()))
x = [0]
y = []
ans = "No"
y+=[a-x[0],d-x[0],g-x[0]]
x+=[b-y[0],c-y[0]]
if x[1]+y[1]==e and x[2]+y[1]==f and x[1]+y[2]==h and x[2]+y[2]==i:
  ans = "Yes"
print(ans)

Submission status: Accepted

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

yokosa=[grid[0][i]-grid[0][i-1] for i in range(1,3)]
for y in range(1,3):
  tmp=[grid[y][i]-grid[y][i-1] for i in range(1,3)]
  if yokosa!=tmp:
    print('No')
    exit()
tatesa=[grid[i][0]-grid[i-1][0] for i in range(1,3)]
for x in range(1,3):
  tmp=[grid[i][x]-grid[i-1][x] for i in range(1,3)]
  if tatesa!=tmp:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

Solution code:
import sys
C =[0 for _ in range(3)]
for i in range(3):
    C[i] = list(map(int,input().split()))

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] and\
           C[j][i] - C[j+1][i] == C[j][i+1] - C[j+1][i+1]:
            continue
        else:
            print("No")
            sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
import numpy as np

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

a0 = 0
B = np.array([c[0][0], c[0][1], c[0][2]])

if len(set(np.array(c[1]) - B)) == 1 and len(set(np.array(c[2]) - B)) == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
l=[]
for i in range(3):
    l.append(list(map(int,input().split())))
    std=l[i][0]
    for j in range(3):
        l[i][j]-=std

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

Submission status: Accepted

Solution code:
li1 = list(map(int,input().split()))
li2 = list(map(int,input().split()))
li3 = list(map(int,input().split()))

dyoko1 = li1[1]-li1[0]
dyoko2 = li1[2]-li1[1]
dtate1 = li2[0]-li1[0]
dtate2 = li3[0]-li2[0]

if li2[1]-li2[0] != dyoko1 or li3[1]-li3[0] != dyoko1:
  print("No")
  exit()
elif li2[2]-li2[1] != dyoko2 or li3[2]-li3[1] != dyoko2:
  print("No")
  exit()
elif li2[1]-li1[1] != dtate1 or li2[2]-li1[2] != dtate1:
  print("No")
  exit()
elif li3[1]-li2[1] != dtate2 or li3[2]-li2[2] != dtate2:
  print("No")
  exit()
  
print("Yes")

Submission status: Accepted

Solution code:
c = {}

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


for ai in range(101):
    a = {0:ai}
    b ={}
    
    for i in range(3):
        for j in range(3):
            if (i in a) and (j in b):
                if a[i]+b[j] != c[(i,j)]:
                    break
                else:
                    pass
            elif (i in a) and (not j in b):
                b[j] = c[(i,j)] - a[i]
            elif (not i in a) and (j in b):
                a[i] = c[(i,j)] - b[j]
            if i==2 and j==2:
                print('Yes')
                exit()
        else:
            continue
        break

print('No')

Submission status: Accepted

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

if N[0][0]-N[0][1]==N[1][0]-N[1][1]==N[2][0]-N[2][1] and N[0][1]-N[0][2]==N[1][1]-N[1][2]==N[2][1]-N[2][2] and N[0][0]-N[1][0]==N[0][1]-N[1][1]==N[0][2]-N[1][2] and N[1][0]-N[2][0]==N[1][1]-N[2][1]==N[1][2]-N[2][2]:
        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()))
if (A[0]-A[1]==B[0]-B[1]==C[0]-C[1])and(A[1]-A[2]==B[1]-B[2]==C[1]-C[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())


for a1 in range(0, 101):
    b1 = c11 - a1
    b2 = c12 - a1
    b3 = c13 - a1
    a2 = c21 - b1
    a3 = c31 - b1

    if all([c22 == a2 + b2,
           c23 == a2 + b3,
           c32 == a3 + b2,
           c33 == a3 + b3]):
        print("Yes")
        exit(0)
else:
    print("No")

Submission status: Accepted

Solution code:
from functools import reduce
from itertools import *

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

l= [read(), read(), read()]

a = len(list(set([l[1][i]-l[0][i] for i in range(3)])))
b = len(list(set([l[2][i]-l[1][i] for i in range(3)])))
c = len(list(set([l[i][1]-l[i][0] for i in range(3)])))
d = len(list(set([l[i][2]-l[i][1] for i in range(3)])))

if a==1 and b==1 and c==1 and d ==1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

a = [0]*3
b = [0]*3

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

good = True
for i in range(3):
    for j in range(3):
        if c[i][j] != a[i] + b[j]:
            good = False
            break
    else:
        continue
    break
print('Yes' if good else 'No')

Submission status: Accepted

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

a = [0]*3
b = [0]*3

for i in range(0, 101):
    a[0] = i
    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 j in range(3):
        for k in range(3):
            if c[j][k] != a[j] + b[k]:
                break
        else:
            continue
        break
    else:
        print('Yes')
        break
else:
    print('No')

Submission status: Accepted

Solution code:
C = [list(map(int,input().split())) for _ in range(3)]
ind = 0
for j in range(1,3):
    if not(C[0][j]-C[0][j-1]==C[1][j]-C[1][j-1]==C[2][j]-C[2][j-1]):
        ind = 1
        break
if ind==1:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
import sys
from functools import reduce
import copy
import math
from pprint import pprint


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    grid = list(map(string_to_int, inputs))

    for x in range(101):
        a = [-1, -1, -1]
        b = [-1, -1, -1]
        a[0] = x
        for j in range(3):
            b[j] = grid[0][j] - a[0]
        a[1] = grid[1][0] - b[0]
        a[2] = grid[2][0] - b[0]

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


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(3))
    print(ret)

Submission status: Accepted

Solution code:
ls1=[int(s) for s in input().split()]
ls2=[int(s) for s in input().split()]
ls3=[int(s) for s in input().split()]

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

Submission status: Accepted

Solution code:
l = [[] for _ in range(3)]
for i in range(0, 3):
    l[i] = [int(_) for _ in input().split()]
t = [0, 0, 0]
for i in range(0, 3):
    for j in range(0, 3):
        t[i] += l[j][i]
p = (t[0] - t[1]) / 3
q = (t[0] - t[2]) / 3
if l[0][0]-p == l[0][1] and l[0][0]-q == l[0][2] and l[1][0]-p == l[1][1] and l[1][0]-q == l[1][2] and l[2][0]-p == l[2][1] and l[2][0]-q == l[2][2]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

flag = True
for i in range(2):
    x = c[i][0] - c[i+1][0]
    y = c[i][1] - c[i+1][1]
    z = c[i][2] - c[i+1][2]

    p = c[0][i] - c[0][i+1]
    q = c[1][i] - c[1][i+1]
    r = c[2][i] - c[2][i+1]
    if x != y or y != z or x != z:
        flag = False
        break
    elif p != q or q != r or p != r:
        flag = False
        break

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

Submission status: Accepted

Solution code:
ary = [list(map(int, input().split())) for i in range(3)]
a = [0]
b = []
ans = 0

for i in range(3):
    b_i = ary[0][i] - a[0]
    b.append(b_i)

for i in range(1, 3):
    a_i = ary[i][0] - b[0]
    a.append(a_i)

for i in range(3):
    for j in range(3):
        if ary[i][j] == a[i] + b[j]:
            ans += 1

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

Submission status: Accepted

Solution code:
ary = [list(map(int,input().split())) for _ in range(3)]
for i in range(ary[0][0]+1):
    a = [ary[0][0]-i,ary[0][1]-i,ary[0][2]-i]
    a2 = ary[1][0] - a[0]
    a3 = ary[2][0] - a[0]
    b = [a2+a[0],a2+a[1],a2+a[2]]
    c = [a3+a[0],a3+a[1],a3+a[2]]
    if ary == [a,b,c]:print("Yes");exit()
else:print("No")

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
l= [[int(i) for i in input().split()] for j in range(3)]

a = [0]
b = []

for i in range(3):
    b.append(l[0][i]-a[0])

for i in range(1,3):
    a.append(l[i][0]-b[0])


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

print("Yes")

Submission status: Accepted

Solution code:
import numpy as np
L= np.array([list(map(int, input().split())) for i in range(3)])

a1 = 0
b1 = L[0][0]
b2 = L[0][1]
b3 = L[0][2]
a2 = L[1][0] - b1
a3 = L[2][0] - b1
if (a2 + b2 != L[1][1] or a2 + b3 != L[1][2] or 
    a3 + b2 != L[2][1] or a3 + b3 != L[2][2]):
  print ("No")
else:
  print ("Yes")

Submission status: Accepted

Solution code:
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
a,b = A[1]-A[0],A[2]-A[0]
c,d = B[1]-B[0],B[2]-B[0]
e,f = C[1]-C[0],C[2]-C[0]
if a==c==e and b==d==f:
    print("Yes")
else:
    print("No")