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

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

for a_1 in range(min(c[0]), max(c[0])+1):
    for a_2 in range(min(c[1]), max(c[1])+1):
        for a_3 in range(min(c[2]), max(c[2])+1):
            b_1, b_2, b_3 = map(lambda x: x - a_1, c[0])
            if all([a_2 + b_1 == c[1][0],
                    a_2 + b_2 == c[1][1],
                    a_2 + b_3 == c[1][2],
                    a_3 + b_1 == c[2][0],
                    a_3 + b_2 == c[2][1],
                    a_3 + b_3 == c[2][2]]):
                print('Yes')
                sys.exit(0)
print('No')

Submission status: Accepted

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

d=c_0[0]+c_1[1]+c_2[2]
e=c_1[0]+c_0[2]+c_2[1]
f=c_0[1]+c_1[2]+c_2[0]
if d==e==f:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

t1=list(map(lambda x: x-min(C[0]),C[0]))
t2=list(map(lambda x: x-min(C[1]),C[1]))
t3=list(map(lambda x: x-min(C[2]),C[2]))
s1=list(map(lambda x: x-min([C[0][0],C[1][0],C[2][0]]),[C[0][0],C[1][0],C[2][0]]))
s2=list(map(lambda x: x-min([C[0][1],C[1][1],C[2][1]]),[C[0][1],C[1][1],C[2][1]]))
s3=list(map(lambda x: x-min([C[0][2],C[1][2],C[2][2]]),[C[0][2],C[1][2],C[2][2]]))

arr=[]
for i,j,k in zip(t1+s1,t2+s2,t3+s3):
    arr.append(i==j==k)

print('Yes' if all(arr) else 'No')

Submission status: Accepted

Solution code:
C=[list(map(int,input().split())) for _ in range(3)]
for i in range(2):
    if not(C[0][i+1]-C[0][i] == C[1][i+1]-C[1][i] == C[2][i+1]-C[2][i]):
        print('No')
        exit()
    if not(C[i+1][0]-C[i][0] == C[i+1][1]-C[i][1] == C[i+1][2]-C[i][2]):
        print('No')
        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 abs(a[0]-a[1])==abs(b[0]-b[1])==abs(c[0]-c[1]) and abs(a[1]-a[2])==abs(b[1]-b[2])==abs(c[1]-c[2])and abs(a[0]-b[0])==abs(a[1]-b[1])==abs(a[2]-b[2]) and abs(b[0]-c[0])==abs(b[1]-c[1])==abs(b[2]-c[2]):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
C = [list(map(int,input().split())) for _ in range(3)]
for i in range(max(C[0])+1):
  flg = 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 a2 + b2 != C[1][1] or a2 + b3 != C[1][2] or a3 + b2 != C[2][1] or a3 + b3 != C[2][2]:
    flg = False
  if flg == True:
    print("Yes")
    exit()
print("No")

Submission status: Accepted

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

for i in range(c[0][0]+1):

    a = [0]*3
    b = [0]*3
    a[0] = i
    b[0] = c[0][0] - i

    for j in range(1,3):
        a[j] = c[j][0] - b[0]
        b[j] = c[0][j] - a[0]
    flag = True
    for k in range(3):
        for l in range(3):
            if c[k][l] != a[k] + b[l]:
                flag = False
    if flag:
        print("Yes")
        exit()

print("No")

Submission status: Accepted

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

b = list(c[0])
a = [0, c[1][0] - b[0], 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:
Data = []
def yoko(a,b):
    x1 = Data[a][0]-Data[b][0]
    x2 = Data[a][1]-Data[b][1]
    x3 = Data[a][2]-Data[b][2]
    if x1 == x2 and x2 == x3:
        return 1
    else:
        return 0

def tate(a,b):
    x1 = Data[0][a]-Data[0][b]
    x2 = Data[1][a]-Data[1][b]
    x3 = Data[2][a]-Data[2][b]
    if x1 == x2 and x2 == x3:
        return 1 
    else:
        return 0 

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

ans = 1
ans &= yoko(0,1)
ans &= yoko(1,2)
ans &= yoko(2,1)

ans &= tate(0,1)
ans &= tate(1,2)
ans &= tate(2,1)
if ans == 1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

for b1 in range(101):
    a = [c[0][0] - b1, c[1][0] - b1, c[2][0] - b1]
    b = [b1, c[0][1] - a[0], c[0][2] - a[0]]
    if all(a[i] + b[j] == c[i][j] for j in range(3) for i in range(3)):
        print('Yes')
        exit()

print('No')

Submission status: Accepted

Solution code:
from numpy import array
a,b,c=array([list(map(int,input().split()))for i in range(3)])
e,f,g=[array(i)for i in zip(a,b,c)]
h=lambda x:list(x)==list(set(x))*3
print("YNeos"[1^all([h(a-b),h(b-c),h(c-a),h(e-f),h(f-g),h(g-e)])::2])

Submission status: Accepted

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

for b1 in range(101):
    a = [c[0][0] - b1, c[1][0] - b1, c[2][0] - b1]
    b = [b1, c[0][1] - a[0], c[0][2] - a[0]]
    if all(a[i] + b[j] == c[i][j] for j in range(3) for i in range(3)):
        print('Yes')
        exit()

print('No')

Submission status: Accepted

Solution code:
c = []

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

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

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

Submission status: Accepted

Solution code:
cube = [list(map(int, input().split())) for i in range(3)]
a = True
x = [0] * 3
y = [0] * 3
x[0] = 0
y[0] = cube[0][0] - x[0]
y[1] = cube[0][1] - x[0]
y[2] = cube[0][2] - x[0]
x[1] = cube[1][0] - y[0]
x[2] = cube[2][0] - y[0]
for i in range(3):
    for j in range(3):
        if not (x[i] + y[j] == cube[i][j]):
            a = False
if a:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

a = [C[0][0] - C[0][0]]
b = [C[0][0] - a[0]]

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

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

print('Yes')

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(3):
    b[i]=c[0][i]-a[0]
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]:
            print("No")
            exit()
print("Yes")

Submission status: Accepted

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

ans = 'Yes'
for i in range(c[0][0] + 1):
    b = [c[0][0] - i, c[0][1] - i, c[0][2] - i]
    a = [i, abs(b[0] - c[1][0]), abs(b[0] - c[2][0])]
    for j in range(1, 3):
        for k in range(3):
            if c[j][k] != a[j] + b[k]:
                ans = 'No'
                break
        if ans != 'Yes':
            break
    if ans == 'Yes':
        break
    if i != c[0][0]:
        ans = 'Yes'

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = True
row = C[0]
for i in range(1, 3):
    for j in range(3):
        C[i][j] -= C[0][j]

    if row != C[i] and len(set(C[i])) != 1:
        ans = False

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

Submission status: Accepted

Solution code:
import sys


def input(): return sys.stdin.readline().strip()


def main():
    C = [[int(x) for x in input().split()] for _ in range(3)]

    a = [0, 0, 0]

    b = [C[0][i] for i in range(3)]  # b_i = c_1,i - a_1

    a = [C[i][0] - b[0] for i in range(3)]  # a_i = c_i,1 - b_1

    ans = [[a[i] + b[j] for j in range(3)] for i in range(3)]

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=list(map(int,input().split()))
t=list(map(int,input().split()))
u=list(map(int,input().split()))
a=s[0]+s[1]+s[2]+t[0]+t[1]+t[2]+u[0]+u[1]+u[2]
b=s[1]+s[2]+t[0]+t[2]+u[0]+u[1]-2*s[0]-2*t[1]-2*u[2]
if a%3==0 and b==0:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
c = []
for i in range(3):
    c_i = [int(a) for a in input().split()]
    c.append(c_i)
if (
    c[0][0] + c[1][1] + c[2][2]
    == c[0][1] + c[1][2] + c[2][0]
    == c[0][2] + c[1][0] + c[2][1]
):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
array_1 = list(map(int, input().split()))
array_2 = list(map(int, input().split()))
array_3 = list(map(int, input().split()))
for a in range(101):
    for b in range(101):
        for c in range(101):
            if array_1[0]-a==array_2[0]-b and array_2[0]-b==array_3[0]-c and array_3[0]-c==array_1[0]-a and array_1[1]-a==array_2[1]-b and array_2[1]-b==array_3[1]-c and array_3[1]-c==array_1[1]-a and array_1[2]-a==array_2[2]-b and array_2[2]-b==array_3[2]-c and array_3[2]-c==array_1[2]-a:
                print('Yes')
                exit()
print('No')

Submission status: Accepted

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

Submission status: Accepted

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

flag = True
for i in range(2):
    if L[0][i]-L[0][i+1]!=L[1][i]-L[1][i+1] or L[1][i]-L[1][i+1]!=L[2][i]-L[2][i+1] or L[i][0]-L[i+1][0]!=L[i][1]-L[i+1][1] or L[i][1]-L[i+1][1]!=L[i][2]-L[i+1][2]:
        flag = False
        break
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
c = [list(map(int,input().split())) for k in range(3)]
A = [sum(a) for a in c]
B = [0,0,0]
AB = 0
for y in range(3):
    for x in range(3):
        if x == y:
            AB += c[y][x]
        B[x] += c[y][x]

for k in range(3):
    t = (A[k]+B[k]-AB)
    if t >= 0 and t%3 == 0:
        pass
    else:
        print("No")
        exit(0)
print("Yes")

Submission status: Accepted

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

ans = "Yes"
for i in range(3):
    temp = C[i][0]-C[(i+1)%3][0]
    for j in range(3):
        if C[i][j]-C[(i+1)%3][j] != temp:
            ans = "No"
for j in range(3):
    temp = C[0][j]-C[0][(j+1)%3]
    for i in range(3):
        if C[i][j]-C[i][(j+1)%3] != temp:
            ans = "No"
            
print(ans)

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

out = 'No'
if c13-c11 == c23-c21 == c33-c31:
  if c11-c12 == c21-c22 == c31-c32:
    if c12-c13 == c22-c23 == c32-c33:
      out = 'Yes'
      
print(out)

Submission status: Accepted

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

vert_sum = np.sum(c, axis=0)
horz_sum = np.sum(c, axis=1)

for a1 in range(101):
    a2 = (horz_sum[1] - horz_sum[0]) / 3 + a1
    a3 = (horz_sum[2] - horz_sum[0]) / 3 + a1
    for b1 in range(101):
        b2 = (vert_sum[1] - vert_sum[0]) / 3 + b1
        b3 = (vert_sum[2] - vert_sum[0]) / 3 + b1
        if (c[0, 0] == a1 + b1 and c[0, 1] == a1 + b2 and c[0, 2] == a1 + b3
            and c[1, 0] == a2 + b1 and c[1, 1] == a2 + b2
                and c[1, 2] == a2 + b3 and c[2, 0] == a3 + b1
                and c[2, 1] == a3 + b2 and c[2, 2] == a3 + b3):
            print('Yes')
            exit()
print('No')

Submission status: Accepted

Solution code:
# ABC088C - Takahashi's Information
def main():
    *C, = map(int, open(0).read().split())
    memo = {(i - j, j - k) for i, j, k in zip(*[iter(C)] * 3)}
    flg = len(memo) == 1
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()

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]

print("Yes" if q1 and q2 and q3 and q4 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()))

flag = 0
if c1[0]-c1[1] != c2[0]-c2[1] or c1[0]-c1[1] != c3[0]-c3[1]:
    flag = 1
if c1[0]-c1[2] != c2[0]-c2[2] or c1[0]-c1[2] != c3[0]-c3[2]:
    flag = 1
if c1[2]-c1[1] != c2[2]-c2[1] or c1[2]-c1[1] != c3[2]-c3[1]:
    flag = 1
if c1[0]-c2[0] != c1[1]-c2[1] or c1[0]-c2[0] != c1[2]-c2[2]:
    flag = 1
if c1[0]-c3[0] != c1[1]-c3[1] or c1[0]-c3[0] != c1[2]-c3[2]:
    flag = 1
if c3[0]-c2[0] != c3[1]-c2[1] or c3[0]-c2[0] != c3[2]-c2[2]:
    flag = 1

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

Submission status: Accepted

Solution code:
c = [list(map(int, input().split())) for i in range(3)]
if c[0][0]-c[0][1] == c[1][0]-c[1][1] == 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]:
    print("Yes")
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)]

q1 = a - b == d - e== g - h
q2 = a - c == d - f == g - i
q3 = a - d == b - e== c - f
q4 = a - g == b - h == c - i

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

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]

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

Submission status: Accepted

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

ans = "Yes"

for i in range(1, -1, -1):
    C0j = C[0][2] - C[0][i]
    C1j = C[1][2] - C[1][i]
    C2j = C[2][2] - C[2][i]
    
    if C0j != C1j or C0j != C2j:
        ans = "No"
        
print(ans)

Submission status: Accepted

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

ans = "Yes"

for i in range(1, -1, -1):
    C0i = C[0][2] - C[0][i]
    C1i = C[1][2] - C[1][i]
    C2i = C[2][2] - C[2][i]
    
    if C0i != C1i or C0i != C2i:
        ans = "No"
        
print(ans)

Submission status: Accepted

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

for i in range(2):
    for j in range(2):
        d = c[i][j] - c[i+1][j]
        e = c[i][j+1] - c[i+1][j+1]
        if d != e:
            print("No")
            exit(0)

for i in range(2):
    for j in range(2):
        d = c[i][j] - c[i][j+1]
        e = c[i+1][j] - c[i+1][j+1]
        if d != e:
            print("No")
            exit(0)

print("Yes")

Submission status: Accepted

Solution code:
# a1 = 0 とする
B = list(map(int, input().strip().split(' ')))
for _ in range(2):
  C = list(map(int, input().strip().split(' ')))
  if B[0]-C[0] == B[1]-C[1] == B[2]-C[2]:
    continue
  else:
    print('No')
    exit()
print('Yes')

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 c1 - c2 == c4 - c5 == c7 - c8 and c3 - c2 == c6 - c5 == c9 - c8:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
cnt = 0
c1, c2, c3 = map(int, input().split())
try :
  for j in range(c1+1):
    for k in range(c2+1):
      for l in range(c3+1):
        if c1-j == c2-k == c3-l:
          c4, c5, c6 = map(int, input().split())
          if c4 - j == c5 -k == c6 -l:
              c7, c8, c9 = map(int, input().split())
              if c7 - j == c8 -k == c9 -l:
                cnt += 1
                break
except EOFError:
  pass
if cnt != 0:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

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

for j in range(2):
  if c[0][j]-c[0][j+1]==c[1][j]-c[1][j+1] and c[2][j]-c[2][j+1]==c[1][j]-c[1][j+1]:
    res+=1
print("Yes" if res==4 else "No")

Submission status: Accepted

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

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

D = [[0,0,0] for i in range(3)]
for i in range(3):
    for j in range(3):
        D[i][j] = a[i]+b[j]

        
if C == D:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import numpy as np

cs = np.zeros((3,3))

cs[0,:] = input().split()
cs[1,:] = input().split()
cs[2,:] = input().split()

cs = cs.astype(int)

flag = True
x1 = cs[0,0]-cs[1,0]
x2 = cs[0,1]-cs[1,1]
x3 = cs[0,2]-cs[1,2]

y1 = cs[0,0]-cs[2,0]
y2 = cs[0,1]-cs[2,1]
y3 = cs[0,2]-cs[2,2]

if (x1!=x2)|(x2!=x3)|(y1!=y2)|(y2!=y3):
  flag = False

if flag:
  for a1 in range(0,100+1):
    a2 = a1 - (cs[0,0] - cs[1,0])
    a3 = a1 - (cs[0,0] - cs[2,0])
    x1 = cs[0,0] - a1
    x2 = cs[1,0] - a2
    x3 = cs[2,0] - a3

    y1 = cs[0,1] - a1
    y2 = cs[1,1] - a2
    y3 = cs[2,1] - a3

    z1 = cs[0,2] - a1
    z2 = cs[1,2] - a2
    z3 = cs[2,2] - a3

    if (x1!=x2)|(x2!=x3)|(y1!=y2)|(y2!=y3)|(z1!=z2)|(z2!=z3):
      flag = False
    else:
      flag = True
      break

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

Submission status: Accepted

Solution code:
C=[list(map(int,input().split())) for i in range(3)]
for n in range(0,2):
  x=C[0][2]-C[0][n]
  y=C[1][2]-C[1][n]
  z=C[2][2]-C[2][n]
  if x!=y or y!=z :
    print('No')
    exit()
else:
  print('Yes')

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    C = [list(map(int, input().split())) for _ in range(3)]
    flag = True
    for i in range(2):
            for ni in range(i+1,3):
                for j in range(2):
                    if C[i][j] - C[i][j+1] != C[ni][j] - C[ni][j+1]:
                        flag = False
                        break

    for i in range(2):
            for ni in range(i+1,3):
                for j in range(2):
                    if C[j][i] - C[j+1][i] != C[j][ni] - C[j+1][ni]:
                        flag = False
                        break
    
    if flag:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
import numpy as np

c = [list(map(int, input().split())) for i in range(3)]
c = np.array(c)
b = c[0]
a1 = [0] * 3
a2 = c[1] - b
a3 = c[2] - b

if len(set(a2)) == 1 and len(set(a3)) == 1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

a = [0, 0, 0]
b = [0, 0, 0]

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

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

# print(a)
# print(b)

ans_date = []
for i in a:
  date = []
  for j in b:
    num = i +j
    date.append(num)
  ans_date.append(date)
# print(grid)
# print(ans_date)  
if grid == ans_date:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
C = [list(map(int,input().split())) for i in range(3)]
check = [[0]*3]*3
flag = "True"
while(flag=="True"):
    flag = "false"
    for i in range(3):
        if min(C[i][0],C[i][1],C[i][2])!=0:
            C[i][0] -= 1
            C[i][1] -= 1
            C[i][2] -= 1
            flag = "True"
            break
        elif min(C[0][i],C[1][i],C[2][i])!=0:
            C[0][i] -= 1
            C[1][i] -= 1
            C[2][i] -= 1
            flag = "True"
            break
if C == check:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007



def main():
    flag = True
    L = LIR(3)
    diff_list = [[0] * 3 for _ in range(3)]
    for x in range(3):
        for y in range(3):
            diff_list[y][x] = L[y][x] - L[y - 1][x]


    for i, j, k in diff_list:
        if not i == j == k:
            flag = False


    diff_list = [[0] * 3 for _ in range(3)]
    for y in range(3):
        for x in range(3):
            diff_list[x][y] = L[y][x] - L[y][x - 1]


    for i, j, k in diff_list:
        if not i == j == k:
            flag = False


    if flag:
        return 'Yes'
    else:
        return 'No'


print(main())

Submission status: Accepted

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

h1 = c[1][0] - c[0][0] == c[1][1] - c[0][1] == c[1][2] - c[0][2]
h2 = c[2][0] - c[1][0] == c[2][1] - c[1][1] == c[2][2] - c[1][2]
w1 = c[0][1] - c[0][0] == c[1][1] - c[1][0] == c[2][1] - c[2][0]
w2 = c[0][2] - c[0][1] == c[1][2] - c[1][1] == c[2][2] - c[2][1]

if h1 and h2 and w1 and w2 :
    print('Yes')
else :
    print('No')

Submission status: Accepted

Solution code:
Cij = [list(map(int,input().split())) for _ in range(3)]
b1,b2,b3 = Cij[0][0],Cij[0][1],Cij[0][2]
a2,a3 = Cij[1][0]-b1,Cij[2][0]-b1

if Cij[1][1] != a2+b2:
  print("No")
  exit()
  
if Cij[1][2] != a2+b3:
  print("No")
  exit()
  
if Cij[2][1] != a3+b2:
  print("No")
  exit()
  
if Cij[2][2] != a3+b3:
  print("No")
  exit()
  
print("Yes")

Submission status: Accepted

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

a = [0] * 3
b = [0] * 3
ans = "Yes"
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 a[i] + b[j] != c[i][j]:
            ans = "No"

print(ans)

Submission status: Accepted

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

a = [0] * 3
b = [0] * 3
ans = "Yes"
for a1 in range(101):
    a[0] = a1
    b[0] = c[0][0] - a1
    b[1] = c[0][1] - a1
    b[2] = c[0][2] - a1
    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 a[i] + b[j] != c[i][j]:
                ans = "No"

print(ans)

Submission status: Accepted

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

ans = "Yes"

for i in range(2):
    x = grid[0][2] - grid[0][i]
    y = grid[1][2] - grid[1][i]
    z = grid[2][2] - grid[2][i]

    if x != y or x != z:
        ans = "No"
        
print(ans)

Submission status: Accepted

Solution code:
grid = [list(map(int, input().split())) for _ in range(3)]
ds = []
for c1, c2, c3 in grid:
    ds.append([c1-c2, c2-c3, c3-c1])
count = 0
for i in range(3):
    if ds[0][i] == ds[1][i] == ds[2][i]:
        count += 1
print('Yes' if count == 3 else 'No')

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    c = [[], [], []]
    for i in range(3):
        c[i] = list(map(int, input().split()))
    
    ans = "Yes"
    for i in range(2):
        d0 = c[0][2] - c[0][i]
        d1 = c[1][2] - c[1][i]
        d2 = c[2][2] - c[2][i]
        
        if d0 != d1 or d0 != d2:
            ans = "No"
    
    print(ans)

Submission status: Accepted

Solution code:
def resolve():
    c = list(list(map(int, input().split())) for _ in range(3))
    b = [c[0][0], c[0][1], c[0][2]]
    a = [0, c[1][0] - b[0], 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")
                return "No"
    print("Yes")
    return "Yes"


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
# sys.stdin.readline
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        c = [list(map(int, input().split())) for _ in range(3)]
        for a1 in range(101):
            for b1 in range(101 - a1):
                a2 = c[1][0] - b1
                a3 = c[2][0] - b1
                b2 = c[0][1] - a1
                b3 = c[0][2] - a1
                if c[0][0] == a1 + b1 and 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')
                    exit()
        print('No')


# Run main
if __name__ == '__main__':
    AtCoder().main()

Submission status: Accepted

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

ans=True
for i in range(2):
    check=c[i+1][0]-c[i][0]
    for j in range(1,3):
        if check !=c[i+1][j]-c[i][j]:
            ans=False
            break
for i in range(2):
    check=c[0][i+1]-c[0][i]
    for j in range(1,3):
        if check !=c[j][i+1]-c[j][i]:
            ans=False
            break

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

Submission status: Accepted

Solution code:
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

L =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(3)]


for a1 in range(101):
    b1 = L[0][0] - a1
    b2 = L[0][1] - a1
    b3 = L[0][2] - a1
    a2 = L[1][1] - b2
    a3 = L[2][2] - b3
    # print(a1, a2, a3, b1, b2, b3)
    # (2,1)(3,1),(3,2),(2,3)
    if (a2 + b1) == L[1][0] and (a3 + b1) == L[2][0] and (a3 + b2) == L[2][1] and (a2 + b3) == L[1][2]:
        print("Yes")
        exit()

print("No")

Submission status: Accepted

Solution code:
import numpy as np

list_ = [np.array(list(map(int, input().rstrip("\n").split()))) for _ in range(3)]
bool_ = (len(set(list_[1] - list_[0])) == len(set(list_[2] - list_[0])) == 1)

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

Submission status: Accepted

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

a2 = c[1][0] - c[0][0]
a3 = c[2][0] - c[0][0]

if any(c[1][x] != a2 + c[0][x] for x in [1, 2]) or any(c[2][x] != a3 + c[0][x] for x in [1, 2]):
	print('No')
else:
	print('Yes')

Submission status: Accepted

Solution code:
from sys import exit
c = [list(map(int, input().split())) for _ in range(3)]
a = [None] * 3
b = [None] * 3
a[0] = 0
for j in range(3):
  b[j] = c[0][j] - a[0]
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]:
      print('No')
      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()))
print('Yes' if c1[0]-c1[1]==c2[0]-c2[1]==c3[0]-c3[1] and c1[2]-c1[1]==c2[2]-c2[1]==c3[2]-c3[1] and c2[0]-c3[0]==c2[1]-c3[1]==c2[2]-c3[2] and c1[0]-c2[0]==c1[1]-c2[1]==c1[2]-c2[2] else 'No')

Submission status: Accepted

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

flag = True
for i in range(2):
	if C[0][i+1] - C[0][i] != C[1][i+1] - C[1][i]:
		flag = False
		break
	elif C[1][i+1] - C[1][i] != C[2][i+1] - C[2][i]:
		flag = False
		break

if flag:
	for i in range(2):
		if C[i+1][0] - C[i][0] != C[i+1][1] - C[i][1]:
			flag = False
			break
		elif C[i+1][1] - C[i][1] != C[i+1][2] - C[i][2]:
			flag = False
			break

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

Submission status: Accepted

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

Submission status: Accepted

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

x = [0] * 3
y = [0] * 3

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

print('Yes')