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

Submission status: Accepted

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

# a1,a2,a3を++、b1,b2,b3を--してもcは変わらない
# うまいことやればa1を0にできる、これを仮定する
# 第一行からbを求める
# 第一列からaを求める

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

# 仮のa,bが求まった、これが9マス全体で成り立つか調べる
for i in range(3):
    for j in range(3):
        if a[i] + b[j] != c[i][j]:
            print('No')
            exit()

print('Yes')

Submission status: Accepted

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

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

Submission status: Accepted

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

diff = []

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

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

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

print("Yes")

Submission status: Accepted

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

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

print('Yes')

Submission status: Accepted

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

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

Submission status: Accepted

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

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


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

print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

            flg=0

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

print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def taka(A):
  t = 0
  for a1 in range(101):
    b1 = A[0][0] - a1#A11
    b2 = A[0][1] - a1#A12
    b3 = A[0][2] - a1#A13
    a2 = A[1][0] - b1#A21
    a3 = A[2][0] - b1#A31
    if a2 + b2 != A[1][1]:
      t = 1
    if a2 + b3 != A[1][2]:
      t = 1    
    if a3 + b2 != A[2][1]:
      t = 1      
    if a3 + b3 != A[2][2]:
      t = 1
    #print(a1, a2, a3, b1, b2, b3, t)
    if t == 0:
      return "Yes"
    
  return "No"  

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(f)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


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

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


"""

1 + k



"""

Submission status: Accepted

Solution code:
c = [list(map(int,input().split())) for i in range(3)]
#change
c1_2 = []
for i in range(3):
    c1_1 = []
    for j in range(2):
        c1_1.append(c[i][j] - c[i][j+1])
    c1_2.append(c1_1)
c1_1 = []
for i in range(3):
    for j in range(1):
        c1_1.append(c1_2[i][j] - c1_2[i][j+1])
if(len(set(c1_1))==1):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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


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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

from itertools import combinations

ans='Yes'
for r in combinations(range(3),2):
    for c in combinations(range(3),2):
        if C_list[r[0]][c[0]]-C_list[r[1]][c[0]] != C_list[r[0]][c[1]]-C_list[r[1]][c[1]]:
            ans='No'
            break
        if C_list[r[0]][c[0]]-C_list[r[0]][c[1]] != C_list[r[1]][c[0]]-C_list[r[1]][c[1]]:
            ans='No'
            break
print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

C = [inl() for _ in range(3)]


def solve():
    a10 = C[1][0] - C[0][0]
    if C[1][1] - C[0][1] != a10 or C[1][2] - C[0][2] != a10:
        return False
    a21 = C[2][0] - C[1][0]
    if C[2][1] - C[1][1] != a21 or C[2][2] - C[1][2] != a21:
        return False
    b10 = C[0][1] - C[0][0]
    if C[1][1] - C[1][0] != b10 or C[2][1] - C[2][0] != b10:
        return False
    b21 = C[0][2] - C[0][1]
    if C[1][2] - C[1][1] != b21 or C[2][2] - C[2][1] != b21:
        return False
    return True


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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

c11,c12,c13 = list(map(int,input().split()))
c21,c22,c23 = list(map(int,input().split()))
c31,c32,c33 = list(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 a2+b2 == c22 and a3+b2 == c32 and a2+b3 == c23 and a3+b3 == c33:
        print('Yes')
        exit()

print('No')

Submission status: Accepted

Solution code:
import numpy as np
c1 = list(map(int,input().split()))
c2 = list(map(int,input().split()))
c3 = list(map(int,input().split()))
C = np.array([c1,c2,c3])
Ct = np.transpose(C)
ans = C + Ct
fact = "Yes"
for i in range(3):
    for j in range(3):
        if not(ans[i,j] == C[i,i] + C[j,j]):
            fact = "No"
            break
print(fact)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

rankA = np.linalg.matrix_rank(A)
rankB = np.linalg.matrix_rank(B)

if rankA == rankB:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from itertools import permutations

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

ans = []

for x in permutations(A, 3):
  temp = 0
  for j in range(3):
    temp += C[j][x[j]]
  ans.append(temp)
    
if len(set(ans)) == 1:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
C = [list(map(int,input().split())) for _ in range(3)]
for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            b1 = C[0][0]-a1 == C[1][0]-a2 == C[2][0]-a3
            b2 = C[0][1]-a1 == C[1][1]-a2 == C[2][1]-a3
            b3 = C[0][2]-a1 == C[1][2]-a2 == C[2][2]-a3
            if b1 and b2 and b3:
                print('Yes')
                exit()
print('No')

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
g,h,i=map(int,input().split())
if a+e==b+d:
    if b+f==c+e:
        if d+h==e+g:
            if e+i==f+h:
                print('Yes')
                exit()
print('No')

Submission status: Accepted

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

# 斜め同士を足し合わせ比較をする
if c[0][0] + c[1][1] == c[0][1] + c[1][0]:
  if c[0][1] + c[1][2] == c[0][2] + c[1][1]:
    if c[1][0] + c[2][1] == c[1][1] + c[2][0]:
      if c[1][1] + c[2][2] == c[1][2] + c[2][1]:
        print("Yes")
        exit()
print("No")

Submission status: Accepted

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

C = [0] * 3

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

for i in range(1, 3):
    x = C[i][0] - C[i - 1][0]
    for j in range(1, 3):
        if C[i][j] - C[i - 1][j] != x:
            print("No")
            exit()

for j in range(1, 3):
    x = C[0][j] - C[0][j - 1]
    for i in range(1, 3):
        if C[i][j] - C[i][j - 1] != x:
            print("No")
            exit()
print("Yes")

Submission status: Accepted

Solution code:
c11, c12,c13=[int(i) for i in input().split()]
c21, c22,c23=[int(i) for i in input().split()]
c31, c32,c33=[int(i) for i in input().split()]

ans=0
for a1 in range(c11+1):
    b1=c11-a1
    b2=c12-a1
    b3=c13-a1
    a2=c21-b1
    a3=c31-b1
    
    if c22==a2+b2 and c23==a2+b3 and c32==a3+b2 and c33==a3+b3:
        print("Yes")
        ans=1
        break

if ans==0:
    print("No")

Submission status: Accepted

Solution code:
y1_list = list(map(int,input().split()))
y2_list = list(map(int,input().split()))
y3_list = list(map(int,input().split()))
L = [y1_list,y2_list,y3_list]
 
a1 = list()
a2 = list()
b1 = list()
b2 = list()
 
for i in range(3):
    a1.append(y1_list[i] - y2_list[i])
    a2.append(y2_list[i] - y3_list[i])

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

Submission status: Accepted

Solution code:
y1_list = list(map(int,input().split()))
y2_list = list(map(int,input().split()))
y3_list = list(map(int,input().split()))
L = [y1_list,y2_list,y3_list]
 
a1 = list()
a2 = list()
b1 = list()
b2 = list()
 
for i in range(3):
    a1.append(y1_list[i] - y2_list[i])
    a2.append(y2_list[i] - y3_list[i])
    b1.append(L[i][0] - L[i][1])
    b2.append(L[i][1] - L[i][2])
 
 
if (a1[0] == a1[1] and a1[2] == a1[0])and(b1[0] == b1[1] and b1[2] == b1[0]):
    if (a2[0] == a2[1] and a2[2] == a2[0])and(b2[0] == b2[1] and b2[2] == b2[0]):
        print("Yes")
        
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

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

bl=c[0]
a2=c[1][0]-bl[0]
a3=c[2][0]-bl[0]
al=[0,a2,a3]
flag='Yes'
for i in range(3):
    for j in range(3):
        if c[i][j]!=al[i]+bl[j]:
            flag='No'
            break
print(flag)

Submission status: Accepted

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

d = [0, 1, 2, 0, 1]
x = c[0][0] + c[1][1] + c[2][2]
ok = True
for i in range(3):
    a = c[d[i]][0] + c[d[i+1]][1] + c[d[i+2]][2]
    b = c[d[i]][2] + c[d[i+1]][1] + c[d[i+2]][0]

    if x != a or x != b:
        ok = False

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

Submission status: Accepted

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

Submission status: Accepted

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

    if grid[0][0] == (grid[0][2] + grid[2][0]) - grid[2][2] and grid[1][1] == (grid[0][1] + grid[1][0]) - grid[0][0] and grid[2][2] == (grid[1][2]+grid[2][1]) - grid[1][1]:
        ans = 'Yes'
    else:
        ans = 'No'
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

for a1 in range(101):
    b1 = int(c[0][0]) - a1
    if b1 < 0:
        continue

    b2 = int(c[0][1]) - a1
    if b2 < 0:
        continue

    b3 = int(c[0][2]) - a1
    if b3 < 0:
        continue

    a2 = int(c[1][0]) - b1
    if a2 < 0:
        continue

    a3 = int(c[2][0]) - b1
    if a3 < 0:
        continue

    if int(c[1][1]) != (a2 + b2):
        continue

    if int(c[1][2]) != (a2 + b3):
        continue

    if int(c[2][1]) != (a3 + b2):
        continue

    if int(c[2][2]) != (a3 + b3):
        continue

    print("Yes")
    break

else:
    print("No")

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):
        if c[j][i+1] - c[j][i] != c[j+1][i+1] - c[j+1][i]:
            print('No')
            exit()
print('Yes')

Submission status: Accepted

Solution code:
c_list=[]
for i in range(3):
    c_list.append([int(i) for i in input().split()])
#print(c_list)

#c11
c_11=c_list[0][0]
ans=0
for a_1 in range(c_11+1):
    b_1=c_11-a_1
    b_2=c_list[0][1]-a_1
    b_3=c_list[0][2]-a_1
    if c_list[1][0]-b_1==c_list[1][1]-b_2==c_list[1][2]-b_3 and c_list[2][0]-b_1==c_list[2][1]-b_2==c_list[2][2]-b_3:
        print("Yes")
        ans=1
        exit()

if ans==0:
    print("No")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import exit

c = [list(map(int, input().split())) for _ in range(3)]
l_1 = [0, 1, 2]
l_2 = [1, 2, 0]

for i in range(3):
    if not c[l_1[i]][0] - c[l_2[i]][0] == c[l_1[i]][1] - c[l_2[i]][1] == c[l_1[i]][2] - c[l_2[i]][2]:
        print('No')
        exit()
    
    if not c[0][l_1[i]] - c[0][l_2[i]] == c[1][l_1[i]] - c[1][l_2[i]] == c[2][l_1[i]] - c[2][l_2[i]]:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
from pprint import pprint

# import math
# import collections

# n = int(input())
# n, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))

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

diff_v = [[0] * 3 for i in range(3)]
diff_h = [[0] * 3 for i in range(3)]

for i in range(0, 3):
    for j in range(0, 3):
        if i > 0:
            diff_v[i][j] = c[i][j] - c[i - 1][j]

for j in range(0, 3):
    for i in range(0, 3):
        if j > 0:
            diff_h[j][i] = c[i][j] - c[i][j - 1]


def map_all(es):
    return all([e == es[0] for e in es[1:]]) if es else False


eq_v = all([map_all(d) for d in diff_v])
eq_h = all([map_all(d) for d in diff_h])

if eq_v and eq_h:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
l = [list(map(int,input().split())) for _ in range(3)]
# print(l)
l1 = []
for i in range(3):
    l1.append(tuple(j - min(l[i]) for j in l[i]))
if len(set(l1)) != 1:
    print('No')
    exit()

k = [[0]*3 for _ in range(3)]
for i in range(3):
    for j in range(3):
        k[j][i] = l[i][j]
k1 = []
for i in range(3):
    k1.append(tuple(j - min(k[i]) for j in k[i]))
if len(set(k1)) != 1:
    print('No')
    exit()

print('Yes')

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(3):
    b[i]=c[0][i]-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"
            break
print(ans)

Submission status: Accepted

Solution code:
import sys

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

Submission status: Accepted

Solution code:
#create date: 2020-07-03 16:23

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    c = na()
    dif1, dif2 = c[1] - c[0], c[2] - c[1]
    for i in range(2):
        cn = na()
        if cn[1] - cn[0] != dif1 or cn[2] - cn[1] != dif2:
            print("No")
            quit()
    print("Yes")

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
c = [list(map(int, input().split())) for i in range(3)]
x = c[0][2]-c[0][1]
y = c[0][1]-c[0][0]
for i in range(1, 3):
    if c[i][1]-c[i][0] != y:
        print('No')
        break
    if c[i][2]-c[i][1] != x:
        print('No')
        break

else:
    print('Yes')

Submission status: Accepted

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

def f():
    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]:
                return False
            if C[j][i]-C[j+1][i] != C[j][i+1]-C[j+1][i+1]:
                return False
    return True

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

Submission status: Accepted

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

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

ans = [
    [a1+b1, a1+b2, a1+b3],
    [a2+b1, a2+b2, a2+b3],
    [a3+b1, a3+b2, a3+b3]
]

for i in range(3):
    for j in range(3):
        if c[i][j] == ans[i][j]:
            pass
        else:
            print('No')
            exit()
print('Yes')

Submission status: Accepted

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

# check
base = [C[0][0], C[1][1], C[2][2]]
case_AB = [
    1
    for a in range(base[0] + 1)
    for b in range(base[1] + 1)
    for c in range(base[2] + 1)
    if [
        [base[0], b + (base[0] - a), c + (base[0] - a)],
        [a + (base[1] - b), base[1], c + (base[1] - b)],
        [a + (base[2] - c), b + (base[2] - c), base[2]]
    ] == C
]

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

Submission status: Accepted

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

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 j in range(3):
        if c[i][j] != a[i]+b[j]:
            print("No")
            exit()
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())
ans = 'No'
if c11 - c21 == c12 - c22 & c12 - c22 == c13 - c23:
    if c21 - c31 == c22 - c32 & c22 - c32 == c23 - c33:
        if c11 - c12 == c21 - c22 & c21 -c22 == c31 - c32:
            if c12 - c13 == c22 - c23 & c22 - c23 == c32 - c33:
                ans = 'Yes'
print(ans)

Submission status: Accepted

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

flag1 = 0
flag2 = 0
for a1 in range(101):
    b1 = lis[0][0] - a1
    b2 = lis[0][1] - a1
    b3 = lis[0][2] - a1
    
    for a2 in range(101):
        if a2 + b1 == lis[1][0] and a2 + b2 == lis[1][1] and a2 + b3 == lis[1][2]:
            flag1 = 1
            break
        else:
            flag1 = 0
            
    for a3 in range(101):
        if a3 + b1 == lis[2][0] and a3 + b2 == lis[2][1] and a3 + b3 == lis[2][2]:
            flag2 = 1
            break
        else:
            flag2 = 0
            
    if flag1 == 1 and flag2 ==1:
        print("Yes")
        exit()

print("No")

Submission status: Accepted

Solution code:
import sys
import timeit


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


def main():
    c = LIR(3)
    a = [0] * 3
    b = [0] * 3
    ans = 'No'
    for i in range(101):
        a[0] = i
        b[0] = c[0][0] - a[0]
        for j in range(101):
            a[1] = j
            b[1] = c[1][1] - a[1]
            for k in range(101):
                a[2] = k
                b[2] = c[2][2] - a[2]
                current = [[a[i] + b[j] for j in range(3)] for i in range(3)]
                if c == current:
                    ans = 'Yes'
                    break
    print(ans)


# res = timeit.timeit('main()', globals=globals(), number=1)
# print(res / 1)
main()

Submission status: Accepted

Solution code:
C = [list(map(int,input().split())) for _ in range(3)]
D1 = [[] for _ in range(3)]
D2 = [[] for _ in range(3)]
for i in range(3):
    for j in range(2):
        D1[i].append(C[i][j] - C[i][j + 1])
for j in range(3):
    for i in range(2):
        D2[j].append(C[i][j] - C[i + 1][j])
print('Yes' if D1[0] == D1[1] == D1[2] and D2[0] == D2[1] == D2[2] 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[2]-c1[1]== c2[2]-c2[1] and c2[2]-c2[1]== c3[2]-c3[1] and c2[1]-c2[0]== c3[1]-c3[0] and c2[1]-c2[0]== c1[1]-c1[0]):
    print('Yes')
else:
    print('No')