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 
import numpy as np

def main():
    grid = np.array(sys.stdin.read().split(), dtype=np.int64).reshape(3, 3)
    
    grid = grid - grid[0]
    grid = grid.T 
    grid = grid - grid[0]
    if np.all(grid == 0):
        ans = 'Yes'
    else:
        ans = 'No'
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
C = [[],[],[]]
C[0] = list(map(int,input().split()))
C[1] = list(map(int,input().split()))
C[2] = list(map(int,input().split()))

cond0_0 = C[0][0] - C[0][1] == C[1][0] - C[1][1] == C[2][0] - C[2][1]
cond0_1 = C[0][0] - C[0][2] == C[1][0] - C[1][2] == C[2][0] - C[2][2]
cond0_2 = C[0][1] - C[0][2] == C[1][1] - C[1][2] == C[2][1] - C[2][2]
cond0 = cond0_0 and cond0_1 and cond0_2

cond1_0 = C[0][0] - C[1][0] == C[0][1] - C[1][1] == C[0][2] - C[1][2]
cond1_1 = C[0][0] - C[2][0] == C[0][1] - C[2][1] == C[0][2] - C[2][2]
cond1_2 = C[1][0] - C[2][0] == C[1][1] - C[2][1] == C[1][2] - C[2][2]
cond1 = cond1_0 and cond1_1 and cond1_2

if cond0 and cond1:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

flag = True
abs_a = []
for i in range(3):
    abs_a.append(abs(c[0][i] - c[1][i]))
    abs_a.append(abs(c[1][i] - c[2][i]))
    abs_a.append(abs(c[0][i] - c[2][i]))
    
if abs_a[0] == abs_a[3] and abs_a[0] == abs_a[6]:
    pass
else:
    flag = False

if abs_a[1] == abs_a[4] and abs_a[1] == abs_a[7]:
    pass
else:
    flag = False

if abs_a[2] == abs_a[5] and abs_a[2] == abs_a[8]:
    pass
else:
    flag = False

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

Submission status: Accepted

Solution code:
mat = []
 
for i in range(3):
  a = list(map(int, input().split()))
  mat.append(a)
  
ans = False
if mat[1][0] - mat[0][0] == mat[1][1] - mat[0][1] == mat[1][2] - mat[0][2]:
  if mat[2][0] - mat[0][0] == mat[2][1] - mat[0][1] and mat[2][1] - mat[0][1] == mat[2][2] - mat[0][2]:
    ans = True
 
if ans:
  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()))

c = [c1, c2, c3]
row = []
p1 = p2 = p3 = 0

for i in c:
    row.append(sum(i))
    p1 += i[0]
    p2 += i[1]
    p3 += i[2]

col = [p1, p2, p3]

con1, con2, con3 = row[0] - row[1], row[0] - row[2], row[1] - row[2]
con4, con5, con6 = col[0] - col[1], col[0] - col[2], col[1] - col[2]

con = [con1, con2, con3, con4, con5, con6]

for j in con:
    if j % 3 != 0:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
C = [list(map(int, input().split())) for i in range(3)]
def thr_check(a, b, c):
  if a==b and b==c and c==a:
    return True
  else:
    return False
s1 = thr_check(C[0][0] - C[0][1], C[1][0] - C[1][1], C[2][0] - C[2][1])
s2 = thr_check(C[0][1] - C[0][2], C[1][1] - C[1][2], C[2][1] - C[2][2])
s3 = thr_check(C[0][2] - C[0][0], C[1][2] - C[1][0], C[2][2] - C[2][0])
s4 = thr_check(C[0][0] - C[1][0], C[0][1] - C[1][1], C[0][2] - C[1][2])
s5 = thr_check(C[1][0] - C[2][0], C[1][1] - C[2][1], C[1][2] - C[2][2])
s6 = thr_check(C[2][0] - C[0][0], C[2][1] - C[0][1], C[2][2] - C[0][2])
if s1 and s2 and s3 and s4 and s5 and s6:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
c=[]
for i in range(3):
    c.append(list(map(int,input().split())))
D1=[]
stp = 0
for i in range(3):
    for j in range(3):
        for k in range(j+1,3):
            D1.append(c[i][j]-c[i][k])

for i in range(6):
    if D1[i] != D1[i+3]:
        stp += 1

D2=[]
for i in range(3):
    for j in range(3):
        for k in range(j+1,3):
            D2.append(c[j][i]-c[k][i])

for i in range(6):
    if D2[i] != D2[i+3]:
        stp += 1
if stp == 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
#88c
c_array = []
for i in range(3):
    c_list = [int(e) for e in input().split()]
    c_array.append(c_list)
    
#整数 a1,a2,a3,b1,b2,b3 の値が決まっており, マス (i,j) には数 ai+bj が書かれているらしいです.
#ci,j (1≤i≤3,1≤j≤3) は 0 以上 100 以下の整数

#a1+b1 a1+b2 a1+b3
#a2+b1 a2+b2 a2+b3
#a3+b1 a3+b2 a3+b3

#a1+b1 = c11　…(1)
#a1+b2 = c12　…(2)
#a1+b3 = c13　…(3)
#a2+b1 = c21　…(4)
#a2+b2 = c22　…(5)
#a2+b3 = c23　…(6)
#a3+b1 = c31　…(7)
#a3+b2 = c32　…(8)
#a3+b3 = c33　…(9)

#(1)-(2)
#b1 - b2 = c11 - c12
#(4)-(5)
#b1 - b2 = c21 - c22  
#(7)-(8)
#b1 - b2 = c31 - c32　∴c11 - c12 = c21 - c22 = c31 - c32

#(2)-(3)
#b2 - b3 = c12 - c13
#(5)-(6)
#b2 - b3 = c22 - c23  
#(8)-(9)
#b2 - b3 = c32 - c33　∴c12 - c13 = c22 - c23 = c32 - c33

#(1)-(3)
#b1 - b3 = c11 - c13
#(4)-(6)
#b1 - b3 = c21 - c23  
#(7)-(9)
#b1 - b3 = c31 - c33　∴c11 - c13 = c21 - c23 = c31 - c33

#c11 - c12 = c21 - c22 = c31 - c32
#c12 - c13 = c22 - c23 = c32 - c33
#c11 - c13 = c21 - c23 = c31 - c33

c11 = c_array[0][0]
c12 = c_array[0][1]
c13 = c_array[0][2]
c21 = c_array[1][0]
c22 = c_array[1][1]
c23 = c_array[1][2]
c31 = c_array[2][0]
c32 = c_array[2][1]
c33 = c_array[2][2]

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

Submission status: Accepted

Solution code:
c1,c2,c3=map(int,input().split())
c4,c5,c6=map(int,input().split())
c7,c8,c9=map(int,input().split())
if c4-c1==c5-c2==c6-c3 and c7-c1==c8-c2==c9-c3:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

B=list(map(int,input().split()))
A2=list(map(int,input().split()))
tmp=A2[0]-B[0]
for i in range(3):
    if not tmp==A2[i]-B[i]:
        print("No")
        exit()
        
A2=list(map(int,input().split()))
tmp=A2[0]-B[0]
for i in range(3):
    if not tmp==A2[i]-B[i]:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
import sys
cl = []

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

if cl[0][0] + cl[1][1] != cl[1][0] + cl[0][1]:
    print("No")
    sys.exit()

if cl[1][1] + cl[2][2] != cl[1][2] + cl[2][1]:
    print("No")
    sys.exit()

if cl[0][0] + cl[2][2] != cl[0][2] + cl[2][0]:
    print("No")
    sys.exit()

print("Yes")

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] + b[1] == a[1] + b[0] and a[2] + c[0] == a[0] + c[2] and b[2] + c[1] == b[1] + c[2]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import numpy as np
M = np.array([list(map(int, input().split())) for _ in range(3)])
print('Yes' if (np.all(M[0,:]-M[0,0]==M[1,:]-M[1,0]) and
                np.all(M[0,:]-M[0,0]==M[2,:]-M[2,0]) and
                np.all(M[:,0]-M[0,0]==M[:,1]-M[0,1]) and
                np.all(M[:,0]-M[0,0]==M[:,2]-M[0,2])) else 'No')

Submission status: Accepted

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

ok=True

for p in range(2):
  diff=[0]*3
  for i in range(3):
    diff[i]=C[i][p+1]-C[i][p]
  if len(set(diff))>1:
    ok=False
  
for p in range(2):
  diff=[0]*3
  for i in range(3):
    diff[i]=C[p+1][i]-C[p][i]
  if len(set(diff))>1:
    ok=False

print(("No","Yes")[ok])

Submission status: Accepted

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

diff=[0]*3
for i in range(3):
  diff[i]=C[i][1]-C[i][0]
if len(set(diff))>1:
  ok=False
  
diff=[0]*3
for i in range(3):
  diff[i]=C[i][2]-C[i][1]
if len(set(diff))>1:
  ok=False

diff=[0]*3
for i in range(3):
  diff[i]=C[1][i]-C[0][i]
if len(set(diff))>1:
  ok=False

diff=[0]*3
for i in range(3):
  diff[i]=C[2][i]-C[1][i]
if len(set(diff))>1:
  ok=False

print(("No","Yes")[ok])

Submission status: Accepted

Solution code:
c = [list(map(int,input().split())) for _ in range(3)]
x = [0] * 3
y = [0] * 3
state=True
for i in range(3):
    y[i] = c[0][i] - x[0]
for i in range(3):
    x[i] = c[i][0] - y[0]
for i in range(3):
    for j in range(3):
        if c[i][j] != x[i] + y[j]:
            print('No')
            state = False
            break
    if state == False:
        break
if state == True:
    print('Yes')

Submission status: Accepted

Solution code:
S = [list(map(int, input().split())) for i in range(3)]
C1=S[0][0]
C2=S[0][1]
C3=S[0][2]
C4=S[1][0]
C5=S[1][1]
C6=S[1][2]
C7=S[2][0]
C8=S[2][1]
C9=S[2][2]

if C4-C1==C6-C3 and C6-C3==C5-C2 and C7-C1==C8-C2 and C8-C2==C9-C3:
    print('Yes')
else:print('No')

Submission status: Accepted

Solution code:
def examC():
    C = [LI() for _ in range(3)]
    ans = "Yes"
    cur = [0]*3
    for i in range(2):
        cur[0] = C[0][i+1]-C[0][i]
        cur[1] = C[1][i+1]-C[1][i]
        cur[2] = C[2][i+1]-C[2][i]
        if not cur[0]==cur[1]==cur[2]:
            ans = "No"
    for i in range(2):
        cur[0] = C[i+1][0]-C[i][0]
        cur[1] = C[i+1][1]-C[i][1]
        cur[2] = C[i+1][2]-C[i][2]
        if not cur[0]==cur[1]==cur[2]:
            ans = "No"
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()

Submission status: Accepted

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

c11,c12,c13=map(int, input().split())
c21,c22,c23=map(int, input().split())
c31,c32,c33=map(int, input().split())
# a1=0を仮定すると
# c11=b1,    c12=b2,    c13=b3
# c21=a2+b1, c22=a2+b2, c23=a2+b3
# c31=a3+b1, c32=a3+b2, c33=a3+b3

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

if c22==a2+b2 and c23==a2+b3 and c32==a3+b2 and c33==a3+b3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import numpy as np
array = np.zeros((3, 3), dtype="int8")
for i in range(3):
    inputs = [int(x) for x in input().split()]
    for j in range(3):
        array[i, j] = inputs[j]
    
b_1 = array[0, 0]
b_2 = array[0, 1]
b_3 = array[0, 2]
a_2 = array[1, 0] - b_1
a_3 = array[2, 0] - b_1
if (array[1, 1] == (a_2+b_2)) & (array[2, 2] == (a_3+b_3) ) & (array[1, 2] == (a_2+b_3)) & (array[2, 1] == (a_3+b_2)):
    flag = 1
else:
    flag = 0

if flag:
    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:
s = [[ int(i) for i in input().split(" ")] for _ in range(3)]

sum = s[0][0] + s[1][1] + s[2][2]

fail = 0

if s[0][0] + s[1][2] + s[2][1] != sum:
  fail = 1
if s[1][1] + s[0][2] + s[2][0] != sum:
  fail = 1
if s[2][2] + s[0][1] + s[1][0] != sum:
  fail = 1
  
if fail == 0:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
R = []

for i in range(3):
    c1, c2, c3 = map(int, input().split())
    R.append([c1-c2, c1-c3])

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    C=[list(map(int,input().split())) for _ in range(3)]

    if(not (C[1][0]-C[0][0]==C[1][1]-C[0][1]==C[1][2]-C[0][2])):
        print("No")
        return
    if(not (C[2][0]-C[1][0]==C[2][1]-C[1][1]==C[2][2]-C[1][2])):
        print("No")
        return
    if(not (C[0][0]-C[2][0]==C[0][1]-C[2][1]==C[0][2]-C[2][2])):
        print("No")
        return
    if(not (C[0][1]-C[0][0]==C[1][1]-C[1][0]==C[2][1]-C[2][0])):
        print("No")
        return
    if(not (C[0][2]-C[0][1]==C[1][2]-C[1][1]==C[2][2]-C[2][1])):
        print("No")
        return
    if(not (C[0][0]-C[0][2]==C[1][0]-C[1][2]==C[2][0]-C[2][2])):
        print("No")
        return
    print("Yes")
resolve()

Submission status: Accepted

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

for i in range(c_li[0][0]+1):
    a1 = i
    b1 = c_li[0][0] - a1
    b2 = c_li[0][1] - a1
    b3 = c_li[0][2] - a1
    
    a2 = c_li[1][0] - b1
    a3 = c_li[2][0] - b1
    
    if c_li[1][1] != a2+b2:
        continue
    if c_li[1][2] != a2+b3:
        continue
    if c_li[2][1] != a3+b2:
        continue
    if c_li[2][2] != a3+b3:
        continue
    
    res = 1
    
if res == 0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
from sys import stdin
from itertools import combinations
from math import factorial
import numpy as np

li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(3)]

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

lin = [[a1,a2,a3],[b1,b2,b3]]

for i in range(3):
    for j in range(3):
        if li[i][j] != lin[0][i]+lin[1][j]:
            print("No")
            exit()

print("Yes")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
import bisect
from logging import getLogger, StreamHandler, DEBUG, WARNING
logger = getLogger(__name__)
handler = StreamHandler()
handler.setLevel(DEBUG)
logger.setLevel(DEBUG)
# handler.setLevel(WARNING)
# logger.setLevel(WARNING)
logger.addHandler(handler)



# class SegTree():
#     def __init__(self, n):
#         self.value = [0 for i in range(n*2)]

# MOD = 10 ** 9 + 7

# def getinvmod(n):
#     return [pow(i, MOD-2, MOD) for i in range(n+1)]

def judge(a1, a2, a3, nums):
    b1 = nums[0][0] - a1
    b2 = nums[0][1] - a1
    b3 = nums[0][2] - a1
    if a2 + b1 == nums[1][0] and a2 + b2 == nums[1][1] and a2 + b3 == nums[1][2]:
        if a3 + b1 == nums[2][0] and a3 + b2 == nums[2][1] and a3 + b3 == nums[2][2]:
            return True

    return False

def main():
    nums = [getList() for _ in range(3)]
    for a1 in range(101):
        for a2 in range(101):
            for a3 in range(101):
                if judge(a1, a2, a3, nums):
                    print("Yes")
                    return

    print("No")

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
c=[]
for i in range(3):
    c.append(list(map(int,input().split())))
cnt=[]
ans=0
for k in range(2):
    cnt=c[k]
    for i in range(k+1,3):
        for j in range(-100,101,1):
            if k==i:
                break
            else:
                d=c[i]
                d=[a+j for a in c[i]]
                if d==c[k]:
                    ans+=1
                    break
                #print(c[i])
if ans==3:
    for k in range(2):
        c1=c[0][k]
        c2=c[1][k]
        c3=c[2][k]
        for i in range(k+1,3):
            d1=c[0][i]
            d2=c[1][i]
            d3=c[2][i]
            for j in range(-100,101,1):
                if k==i:
                    break
                else:
                    d1+=j
                    d2+=j
                    d3+=j
                    if d1==c1 and d2==c2 and d3==c3:
                        ans+=1
                        break
                    else:
                        d1=c[0][i]
                        d2=c[1][i]
                        d3=c[2][i]
                    #print(d1,d2,d3)
    #print(ans)
    if ans==6:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
C = [list(map(int, input().split())) for _ in range(3)]
flag = True
for i in range(1, 3):
    for j in range(1, 3):
        if C[i][j] - C[i-1][j] != C[i][0] - C[i-1][0]:
            flag = False
        if C[i][j] - C[i][j-1] != C[0][j] - C[0][j-1]:
            flag = False
print('Yes' if flag else 'No')

Submission status: Accepted

Solution code:
row0 = list(map(int,input().split()))
row1 = list(map(int,input().split()))
row2 = list(map(int,input().split()))

rows = [row0,row1,row2]
rowsdiff = []
for item in rows:
  rowsdiff.append([item[1]-item[0],item[2]-item[1]])
columns = [[rows[0][i],rows[1][i],rows[2][i]] for i in range(3)]
columnsdiff = []
for item in columns:
  columnsdiff.append([item[1]-item[0],item[2]-item[1]])

Answer = 'Yes'
rowscheck = (rowsdiff[0]==rowsdiff[1])*(rowsdiff[1]==rowsdiff[2])
columnscheck = (columnsdiff[0]==columnsdiff[1])*(columnsdiff[1]==columnsdiff[2])
if rowscheck*columnscheck != 1:
  Answer = 'No'

print(Answer)

Submission status: Accepted

Solution code:
def main():
    c=[list(map(int,input().split())) for i in range(3)]
    a=[0,0,0]
    b=[0,0,0]
    for i in range(0,101):
        a[0]=i
        a[1]=-1
        a[2]=-1
        b[0]=c[0][0]-a[0]
        b[1]=c[0][1]-a[0]
        b[2]=c[0][2]-a[0]
        for j in range(1,3):
            if c[j][0]-b[0]!=c[j][1]-b[1] or c[j][1]-b[1]!=c[j][2]-b[2]:
                break
            a[j]=c[j][0]-b[0]

            if j == 2 and check(a,b):
                print('Yes')
                return
    print('No')

def check(a,b):
    for i in range(0,3):
        if a[i] >= 0 and b[i] >= 0 :
            continue
        else:
            return False
    return True

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    c=[list(map(int,input().split())) for i in range(3)]
    a=[0,0,0]
    b=[0,0,0]
    for i in range(1,101):
        a[0]=i
        a[1]=-1
        a[2]=-1
        b[0]=c[0][0]-a[0]
        b[1]=c[0][1]-a[0]
        b[2]=c[0][2]-a[0]
        for j in range(1,3):
            if c[j][0]-b[0]!=c[j][1]-b[1] or c[j][1]-b[1]!=c[j][2]-b[2]:
                break
            a[j]=c[j][0]-b[0]
            if j == 2:
                print('Yes')
                return
    print('No')

if __name__=='__main__':
    main()

Submission status: Accepted

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

sum_mat = (sum(c[0]) + sum(c[1]) + sum(c[2])) / 3
print('Yes' if sum_mat == c[0][0] + c[1][1] + c[2][2] else 'No')

Submission status: Accepted

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

fin = False

for a1 in range(101):
	if fin:
		break
	for a2 in range(101):
		if fin:
			break
		for a3 in range(101):
			if (grid[0][0]-a1==grid[1][0]-a2 and grid[1][0]-a2==grid[2][0]-a3) and (grid[0][1]-a1==grid[1][1]-a2 and grid[1][1]-a2==grid[2][1]-a3) and (grid[0][2]-a1==grid[1][2]-a2 and grid[1][2]-a2==grid[2][2]-a3):
				print("Yes")
				fin = True
				break
if not fin:
	print("No")

Submission status: Accepted

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


for i in range(n):
    for j in range(n):
        if x[i][j] != (a[i] + b[j]):
            print('No')
            exit()
print('Yes')

Submission status: Accepted

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

def main():
  mC = [tuple(map(int, input().split()))
        for _ in range(3)]

  # col
  mD = [[mC[i][j]-mC[i][j+1] for j in range(2)]
        for i in range(3)]
  #print(mD)###

  # row
  mE = [[mC[i][j]-mC[i+1][j] for i in range(2)]
        for j in range(3)]
  #print(mE)###

  res = "Yes"
  if any(vd!=mD[0] for vd in mD[1:]) \
     or any(ve!=mE[0] for ve in mE[1:]):
    res = "No"

  print(res)

main()

Submission status: Accepted

Solution code:
L1 = list(map(int, input().split()))
for i in range(2):
	l = list(map(int, input().split()))
	sabun = None
	for j in range(3):
		if sabun == None:
			sabun = L1[j] - l[j]
		elif L1[j] - l[j] != sabun:
			print("No")
			exit()
print("Yes")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
a = [list(map(int, input().split())) for _ in range(3)]
dx = [0] * 2
dy = [0] * 2
for i in range(2):
  dx[i] = a[0][i + 1] - a[0][i]
for i in range(2):
  dy[i] = a[i + 1][0] - a[i][0]
for i in range(3):
  for j in range(2):
    if a[i][j + 1] - a[i][j] != dx[j]:
      print("No")
      exit(0)
for i in range(3):
  for j in range(2):
    if a[j + 1][i] - a[j][i] != dy[j]:
      print("No")
      exit(0)
print("Yes")

Submission status: Accepted

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

mat_dif = [0, 0, 0]
for i in range(3):
    mat_dif[i] = ([matrix[i][0]-matrix[i][1]], [matrix[i][1]-matrix[i][2]])

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

Submission status: Accepted

Solution code:
import sys
lst=[]
for i in range(3):
  a,b,c=map(int,input().split())
  lst.append([a,b,c])
for i in range(2):
  for j in range(2):
    if (lst[i][j+1]-lst[i][j])!=(lst[i+1][j+1]-lst[i+1][j]) or (lst[j+1][i]-lst[j][i])!=(lst[j+1][i+1]-lst[j][i+1]):
      print('No')
      sys.exit()
print('Yes')

Submission status: Accepted

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

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

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

print("Yes")

Submission status: Accepted

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

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

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

print("Yes")

Submission status: Accepted

Solution code:
a=[0]*3
b=[0]*3
C=[list(map(int,input().split())) for _ in range(3)]
for i in range(3):
  a[i]=C[0][i]
for i in range(3):
  b[i]=C[i][0]-a[0]
for i in range(3):
  for j in range(3):
    if a[j]+b[i] != C[i][j]:
      print("No")
      exit()
print("Yes")

Submission status: Accepted

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


  
for i in range(101):
  info=True
  a1=i
  b1=c[0][0]-a1
  b2=c[0][1]-a1
  b3=c[0][2]-a1
  a2=c[1][0]-b1
  a3=c[2][0]-b1
  if min(a1,a2,a3,b1,b2,b3)<0:
    info=False
  if c[1][1]!=a2+b2:
    info=False
  if c[2][1]!=a3+b2:
    info=False
  if c[1][2]!=a2+b3:
    info=False
  if c[2][2]!=a3+b3:
    info=False
  
  if info:
    print("Yes")
    break
else:
  print("No")

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 = [[int(x) for x in input().split()],[int(x) for x in input().split()],[int(x) for x in input().split()]]
a1max = min(C[0])
for a1 in range(a1max + 1):
  b1, b2, b3 = C[0][0] - a1, C[0][1] - a1, C[0][2] - a1
  a2 = C[1][0] - b1
  a3 = C[2][0] - b1
  if C[1][1] == a2 + b2 and C[1][2] == a2 + b3 and C[2][1] == a3 + b2 and \
    C[2][2] == a3 + b3:
      print('Yes')
      break
else:
  print('No')

Submission status: Accepted

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

list_a = [0 for _ in range(3)]
list_b = [0 for _ in range(3)]
for i in range(3):
  list_b[i] = list_c[i][0]
for i in range(3):
  if i != 0:
    list_a[i] = list_c[0][i] - list_b[0]

for j in range(3):
  for i in range(3):
    if list_c[i][j] != list_a[j] + list_b[i]:
      print("No")
      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(0,2):
    for j in range(0,2):
        if C[i][j] + C[i+1][j+1] != C[i+1][j] + C[i][j+1]:
            print('No')
            exit()
if C[0][0] + C[2][2] != C[0][2] + C[2][0]:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

Solution code:
C=[list(map(int,input().split())) for i in range(3)]
for a in range(101):
    for b in range(101):
        for c in range(101):
            d=C[0][0]-a
            e=C[1][1]-b
            f=C[2][2]-c
            if all([b+d==C[0][1],c+d==C[0][2],a+e==C[1][0],c+e==C[1][2],a+f==C[2][0],b+f==C[2][1]]):
                print('Yes')
                exit()
print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    t = [list(map(int, input().split())) for _ in range(3)]
    for i in range(2):
        if not t[i][0] - t[i + 1][0] == t[i][1] - t[i + 1][1] == t[i][2] - t[i + 1][2]:
            print("No")
            exit()
    for j in range(2):
        if not t[0][j] - t[0][j + 1] == t[1][j] - t[1][j + 1] == t[2][j] - t[2][j + 1]:
            print("No")
            exit()
    print("Yes")

main()

Submission status: Accepted

Solution code:
ar1 = list(map(int, input().split()))
ar2 = list(map(int, input().split()))
ar3 = list(map(int, input().split()))

for i in range(100):
	a1 = i
	b1 = ar1[0] - a1
	b2 = ar1[1] - a1
	b3 = ar1[2] - a1
	a2 = ar2[0] - b1
	a3 = ar3[0] - b1
	if a2 + b2 == ar2[1] and a2 + b3 == ar2[2] and a3 + b2 == ar3[1] == ar3[1] and a3 + b3 == ar3[2]:
		print ("Yes")
		exit()
print ("No")

Submission status: Accepted

Solution code:
X = [[int(a) for a in input().split()] for _ in range(3)]
f = 0
for i in range(1, 3):
    for j in range(1, 3):
        if X[i][j] + X[0][0] != X[i][0] + X[0][j]:
            print("No")
            f = 1
            break
    if f:
        break
else:
    print("Yes")

Submission status: Accepted

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

# print(C)

pairs = [(0, 1), (1, 2), (0, 2)]

for i, j in pairs:
    values = [C[i][col] - C[j][col] for col in range(3)]
    if len(set(values)) != 1:
        print('No')
        exit()

for i, j in pairs:
    values = [C[row][i] - C[row][j] for row in range(3)]
    if len(set(values)) != 1:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
#                         author:  kagemeka 
#                         created: 2019-11-06 16:18:30(JST)
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics

def main():
    c = [[int(x) for x in sys.stdin.readline().split()] for _ in range(3)]
    n = 3  # able to deal with n x n
    d = []
    for i in range(1, n):
        d0i = c[0][i] - c[0][0]
        d.append(d0i)
    for i in range(1,n):
        for j in range(1, n):
            if c[i][j] - c[i][0] == d[j-1]:
                continue
            else:
                print('No')
                exit()
    print('Yes')

if __name__ == "__main__":
    # execute only if run as a script
    main()

Submission status: Accepted

Solution code:
c = [list(map(int, input().split())) for _ in range(3)]
try:
    assert (sum(c[2]) - sum(c[1])) % 3 == 0
    assert (sum(c[1]) - sum(c[0])) % 3 == 0
    assert (sum([line[2] for line in c]) - sum([line[1] for line in c])) % 3 == 0
    assert (sum([line[1] for line in c]) - sum([line[0] for line in c])) % 3 == 0
    print("Yes")
except AssertionError:
    print("No")

Submission status: Accepted

Solution code:
import numpy as np
c1,c2,c3 = map(int,input().split())
c4,c5,c6 = map(int,input().split())
c7,c8,c9 = map(int,input().split())
A = np.array([[1,0,0,1,0,0,c1],[1,0,0,0,1,0,c2],[1,0,0,0,0,1,c3],[0,1,0,1,0,0,c4],[0,1,0,0,1,0,c5],[0,1,0,0,0,1,c6],[0,0,1,1,0,0,c7],[0,0,1,0,1,0,c8],[0,0,1,0,0,1,c9]])
if np.linalg.matrix_rank(A) ==5:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

right = c[0][1] + c[1][0] == c[0][0] + c[1][1] \
    and c[1][2] + c[2][1] == c[1][1] + c[2][2] \
    and c[2][0] + c[0][2] == c[2][2] + c[0][0]
print('Yes' if right else 'No')