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

b1 = 0
a1 = grid[0][0]
a2 = grid[1][0]
a3 = grid[2][0]

b2 = grid[0][1] - a1
b3 = grid[0][2] - a1

if b2 + a2 != grid[1][1]:
    ans = 'No'

if b2 + a3 != grid[2][1]:
    ans = 'No'

if b3 + a2 != grid[1][2]:
    ans = 'No'

if b3 + a3 != grid[2][2]:
    ans = 'No'

print(ans)

Submission status: Accepted

Solution code:
import sys

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


def dfs(a, b, i):
    if i > 2:
        for j in range(3):
            for k in range(3):
                if j != k:
                    if a[j] + b[k] != l[j][k]:
                        return
        print("Yes")
        sys.exit()
    for a[i] in range(l[i][i] + 1):
        b[i] = l[i][i] - a[i]
        dfs(a, b, i + 1)

dfs(a, b, 0)
print("No")

Submission status: Accepted

Solution code:
import sys
[a,b,c]=list(map(int,input().split()))
[d,e,f]=list(map(int,input().split()))
[g,h,i]=list(map(int,input().split()))
#print(a,b,c,d,e,f,g,h,i)

if d-a == e-b and e-b == f-c and g-d == h-e and h-e == i-f:
    if b-a == e-d and e-d == h-g and c-b == f-e and f-e== i-h:
        print('Yes')
        sys.exit(0)
print('No')

Submission status: Accepted

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

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

flag = True
for i in range(2):
	for j in range(i+1,3):
		c = grid[i][0] - grid[j][0]
		for k in range(1,3):
			if(c!=(grid[i][1] - grid[j][1]) or c!=(grid[i][2] - grid[j][2]) ):
				flag = False

for i in range(2):
	for j in range(i+1,3):
		c = grid[0][i] - grid[0][j]
		for k in range(1,3):
			if(c!=(grid[1][i] - grid[1][j]) or c!=(grid[2][i] - grid[2][j]) ):
				flag = False

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,0,0]
b = [0,0,0]
for i in range(3):
    b[i] = c[i][0] - 0
for i in range(3):
    a[i] = c[0][i] - b[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, = map(int,open(0).read().split())
for i in range(2):
    if( (c[1+i]-c[0+i])!=(c[4+i]-c[3+i]) or (c[1+i]-c[0+i])!=(c[7+i]-c[6+i])
       or (c[3+i*3]-c[i*3])!=(c[4+i*3]-c[1+i*3]) or (c[3+i*3]-c[i*3])!=(c[5+i*3]-c[2+i*3]) ):
        print("No")
        break
else:
    print("Yes")

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()))
c = [c_0,c_1,c_2]

for a_0 in range(100+1):
    for a_1 in range(100+1):
        for a_2 in range(100+1):
            b_0 = c[0][0] - a_0
            b_1 = c[0][1] - a_0
            b_2 = c[0][2] - a_0

            a = [a_0,a_1,a_2]
            b = [b_0,b_1,b_2]
            flag = True
            for i in range(3):
                for j in range(3):
                    if c[i][j] == a[i] + b[j]:
                        continue
                    else:
                        flag = False
            if flag:
                print('Yes')
                exit()
print('No')

Submission status: Accepted

Solution code:
c = []
c.append(list(map(int,input().split())))
c.append(list(map(int,input().split())))
c.append(list(map(int,input().split())))

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

Submission status: Accepted

Solution code:

c = []
for i in range(3):
    a = list(map(int,input().split()))
    c.append(a)
flag = True
b = [[0]*3]*3
B = dict()
for i in range(3):
    for j in range(3):
        if i == j:
            continue
        l = []
        for k in range(3):
            x = c[k][i] - c[k][j]
            if len(l) < 1:
                l.append(x)
            else:
                for m in range(len(l)):
                    if x != l[m]:
                        flag = False
                l.append(x)
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
src = []
src.append(list(map(int, input().split())))
src.append(list(map(int, input().split())))
src.append(list(map(int, input().split())))
for n1, n2 in zip([0, 1, 2], [1, 2, 0]):
    if not len(set(s[n1] - s[n2] for s in src)) == 1 or\
       not len(set(s1 - s2 for s1, s2 in zip(src[n1], src[n2]))) == 1:
        dst = "No"
        break
else:
    dst = "Yes"
print(dst)

Submission status: Accepted

Solution code:
# a1が決まればb1,b2,b3が決まり、b1が決まればa,a3が決まる
table = [list(map(int, input().split())) for _ in range(3)]
for a1 in range(101):
    b1 = table[0][0] - a1
    b2 = table[1][0] - a1
    b3 = table[2][0] - a1
    a2 = table[0][1] - b1
    a3 = table[0][2] - b1
    if (
        a2 + b2 == table[1][1]
        and a3 + b2 == table[1][2]
        and a2 + b3 == table[2][1]
        and a3 + b3 == table[2][2]
    ):
        print("Yes")
        exit()
print("No")

Submission status: Accepted

Solution code:
ans = []
flag = True
for i in range(3):
    ans.append(list(map(int,input().split())))
for i in range(2):
    diff1 = ans[i][0]-ans[i+1][0]
    diff2 = ans[i][1]-ans[i+1][1]
    diff3 = ans[i][2]-ans[i+1][2]
    if diff1!=diff2 or diff2!=diff2 or diff3!=diff1:
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(CC):
    R = [sum(CC[i]) for i in range(3)]
    C = [sum(CC[j][i] for j in range(3)) for i in range(3)]
    checked = all((R[i] - R[i - 1]) % 3 == 0 for i in range(3))
    checked &= all((C[i] - C[i - 1]) % 3 == 0 for i in range(3))
    return 'Yes' if checked else 'No'

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

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]

d = [[-1, -1, -1] for _ in range(3)]

for a1 in range(c[0][0]+1):
    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

    d[0][0] = a1 + b1
    d[0][1] = a1 + b2
    d[0][2] = a1 + b3
    d[1][0] = a2 + b1
    d[1][1] = a2 + b2
    d[1][2] = a2 + b3
    d[2][0] = a3 + b1
    d[2][1] = a3 + b2
    d[2][2] = a3 + b3

    if c == d:
        print('Yes')
        exit(0)
    else:
        continue

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())
A1=-1
A2=-1
A3=-1
B1=-1
B2=-2
B3=-1
flag=0
for j in range(a+1):
    A1=j
    B1=a-A1
    B2=b-A1
    B3=c-A1
    if B1<0 or B2<0 or B3 <0:
        continue
    A2=d-B1
    A3=g-B1
    if A2<0 or A3<0:
        continue
    if d-B1==e-B2 and e-B2==f-B3 and g-B1==h-B2 and h-B2 == i-B3:
        flag=1
        break
print('Yes' if flag else 'No')

Submission status: Accepted

Solution code:
import math
import calendar
import fractions
import itertools

c = [[0, 0, 0] for _ in range(3)]

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

x = min(c[0])
y = min(c[1])
z = min(c[2])
ans = 0
for a1 in range(x + 1):
    for a2 in range(y + 1):
        for a3 in range(z + 1):
            if a1 - c[0][0] == a2 - c[1][0] == a3 - c[2][0] and a1 - c[0][1] == a2 - c[1][1] == a3 - c[2][1] and a1 - c[0][2] == a2 - c[1][2] == a3 - c[2][2]:
                ans = 1
                break
        if ans == 1:
            break
    if ans == 1:
        break

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

Submission status: Accepted

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

Submission status: Accepted

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

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

flag = True
for i in range(2):
	for j in range(i+1,3):
		c = grid[i][0] - grid[j][0]
		for k in range(1,3):
			if(c!=(grid[i][1] - grid[j][1]) or c!=(grid[i][2] - grid[j][2]) ):
				flag = False

for i in range(2):
	for j in range(i+1,3):
		c = grid[0][i] - grid[0][j]
		for k in range(1,3):
			if(c!=(grid[1][i] - grid[1][j]) or c!=(grid[2][i] - grid[2][j]) ):
				flag = False

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

Submission status: Accepted

Solution code:
c1 = [int(n) for n in input().split()]
c2 = [int(n) for n in input().split()]
c3 = [int(n) for n in input().split()]
if ((c1[0]-c1[1]) == (c2[0]-c2[1])) and ((c1[0]-c1[1]) == (c3[0]-c3[1])) and ((c2[0]-c2[1]) == (c3[0]-c3[1])):
    pass
else:
    print("No")
    exit()
if ((c1[1]-c1[2]) == (c2[1]-c2[2])) and ((c1[1]-c1[2]) == (c3[1]-c3[2])) and ((c2[1]-c2[2]) == (c3[1]-c3[2])):
    pass
else:
    print("No")
    exit()
if ((c1[0]-c1[2]) == (c2[0]-c2[2])) and ((c1[0]-c1[2]) == (c3[0]-c3[2])) and ((c2[0]-c2[2]) == (c3[0]-c3[2])):
    pass
else:
    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()))

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

print("Yes")

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

x = a + e == b + d and b + f == c + e and d + h == e + g and e + i == f + h
print('YNeos'[0 if x else 1::2])

Submission status: Accepted

Solution code:
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

mis = 0
if a[0] + b[1] != a[1] + b[0]:
    print("No")
    quit(0)
elif a[1] + b[2] != a[2] + b[1]:
    print("No")
    quit(0)
elif a[0] + b[2] != a[2] + b[0]:
    print("No")
    quit(0)
elif a[0] + c[1] != c[1] + a[0]:
    print("No")
    quit(0)
elif a[1] + c[2] != a[2] + c[1]:
    print("No")
    quit(0)
elif a[0] + c[2] != a[2] + c[0]:
    print("No")
    quit(0)
elif b[0] + c[1] != c[1] + b[0]:
    print("No")
    quit(0)
elif b[1] + c[2] != b[2] + c[1]:
    print("No")
    quit(0)
elif b[0] + c[2] != b[2] + c[0]:
    print("No")
    quit(0)

print("Yes")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# a1を適当に決めると、他の値は任意に決まり
# 条件はfor i in range(3): c[2][i] -c[1][i] = const であること
c = []
for i in range(3):
    c.append(list(map(int,input().split())))
#print(c)
if c[2][0]-c[0][0] == c[2][1]-c[0][1]:
    #print(1)
    if c[2][0]-c[0][0] == c[2][2]-c[0][2]:
        #print(2)
        if c[1][0]-c[0][0] == c[1][1]-c[0][1]:
           # print(3)
            if c[1][0]-c[0][0] == c[1][2]-c[0][2]:
                print("Yes")
                exit()
print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())

d = c12 - c11
e = c13 - c12
f = c21 - c11
g = c31 - c21

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

ok = 1
ok &= (c11 == 0)
ok &= (c12 == d)
ok &= (c13 == d + e)
ok &= (c21 == f)
ok &= (c22 == f + d)
ok &= (c23 == f + d + e)
ok &= (c31 == f + g)
ok &= (c32 == f + g + d)
ok &= (c33 == f + g + d + e)

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

Submission status: Accepted

Solution code:
P = [list(map(int,input().split())) for i in range(3)]
#[print(i) for i in P]
#C11を取得
c_11 = P[0][0]
#引き算する
for i in range(3):
    for j in range(3):
        P[i][j] -= c_11

#[print(i) for i in P]

A_1 = 0
A_2 = P[1][0]
A_3 = P[2][0]
B_1 = 0
B_2 = P[0][1]
B_3 = P[0][2]

Flag = "Yes"

if not A_2 + B_2 == P[1][1]:
    Flag = "No"
if not A_2 + B_3 == P[1][2]:
    Flag = "No"
if not A_3 + B_2 == P[2][1]:
    Flag = "No"
if not A_3 + B_3 == P[2][2]:
    Flag = "No"

print(Flag)

Submission status: Accepted

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

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

for j in range(2):
    if C[0][j+1]-C[0][j] == C[1][j+1]-C[1][j] == C[2][j+1]-C[2][j]:
        continue
    else:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

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

b[0] = s[0][0]
b[1] = s[0][1]
b[2] = s[0][2]

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]

class Util():
    def round_up(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Util.round_up(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x

C = [[int(x)for x in cin.string().split()]  for y in range(3)]
for a1 in range(0,100 + 1):
    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
    m = [[a1 + b1,a1 + b2,a1 + b3],[a2 + b1,a2 + b2,a2 + b3],[a3 + b1,a3 + b2,a3 + b3]]
    if m == C:
        print("Yes")
        sys.exit()
print("No")

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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


    is_yes = True
    for j in range(2):
        tmp = 0
        for i in range(3):
            if i == 0:
                tmp = C[j + 1][i] - C[j][i]
            else:
                if tmp != C[j + 1][i] - C[j][i]:
                    is_yes = False
                    break

    for i in range(2):
        tmp = 0
        for j in range(3):
            if j == 0:
                tmp = C[j][i + 1] - C[j][i]
            else:
                if tmp != C[j][i + 1] - C[j][i]:
                    is_yes = False
                    break

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




if __name__ == '__main__':
    main()

Submission status: Accepted

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

# set a1 = 0
# bi = c1,i - a1
b = [c[0][i] for i in range(3)]
# ai = ci,1 - b1
a = [c[i][0] - b[0] for i in range(3)]

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:
M = []
for _ in range(3):
  m = list(map(int, input().split()))
  M.append(m)

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

Submission status: Accepted

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

b2_1 = A[0][1] - A[0][0]
b3_1 = A[0][2] - A[0][0]

if any([b2_1 != A[x][1] - A[x][0] for x in [1, 2]]) or any([b3_1 != A[x][2] - A[x][0] for x in [1,2]]):
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
C = [0] * 3
A = [0] * 3
B = [0] * 3
# a_0=0と考える
for j in range(3):
    C[j] = [int(x) for x in input().split()]
#print(C)
B[0], B[1], B[2] = C[0][0], C[0][1], C[0][2]
A[1], A[2] = C[1][0]-B[0], C[2][0]-B[0]
flag = 0
for i in range(3):
    for k in range(3):
        if C[i][k] != A[i] + B[k]:
            flag = 1
            break
if flag == 1:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
c = list()
for i in range(3):
    c.append(list(map(int, input().split())))

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]

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

print("Yes")

Submission status: Accepted

Solution code:
C = [tuple(map(int, input().split())) for _ in range(3)]
print("YNeos"[not all(C[i][j]+C[(i+1)%3][(j+1)%3] == C[(i+1)%3][j]+ C[i][(j+1)%3]for i in range(3) for j in range(3))::2])

Submission status: Accepted

Solution code:
def is_right(a0, a1, a2):
    for j in range(H):
        if grids[j][0] - a0 == grids[j][1] - a1 == grids[j][2] - a2:
            continue
        else:
            return False
    return True


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

for a0 in range(100 + 1):
    for a1 in range(100 + 1):
        for a2 in range(100 + 1):
            if is_right(a0, a1, a2):
                print('Yes')
                exit()
print('No')

Submission status: Accepted

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

## Ax = C
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] ])
# 拡大係数行列
Ab = 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)
rankAb = np.linalg.matrix_rank(Ab)

if rankA == rankAb:
    print('Yes')
else:
    print('No')

# print(C)
# A = [0] * 3
# B = [0] * 3
# flgList = []
# for k in range(3):
#     flgHorizontal = [False] * 3
#     flgList.append(flgHorizontal)
# ## c(i, j) = a(i) + b(j)
# for i in range(3):
#     for a in range(101):
#         A[i] = a
#         for j in range(3):
#             B[j] = C[i][j] - A[i]
#                 if C[i][j] == A[i] + B[j]:
#                     print(C[i][j], A[i], B[j])
#                     flgList[i][j] = True
# print(flgList)
# determinantList = [False] * 3
# for m in range(3):
#     if all(flgList[m]):
#         determinantList[m] = True

# if all(determinantList):
#     print('Yes')
# else:
#     print('No')C

Submission status: Accepted

Solution code:
c = []
for h in range(3):
    c.append([int(x) for x in input().split()])
b = c[0]
a = [0, c[1][0]-b[0], c[2][0]-b[0]]
for n in range(1,3):
    for h in range(1,3):
        if c[h][n] != a[h]+b[n]:
            print("No")
            exit()
print("Yes")

Submission status: Accepted

Solution code:


import numpy as np

a=np.array([[int(x) for x in input().split()]for y in range(3)],dtype=np.int64)
#print(a)
for i in range(3):
    for j in range(0,3):
        a[i][j]-=a[i][2]

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
C = [list(map(int,input().split())) for _ in range(3)]
K = C[0][0]
b1,b2 = C[0][1]-K,C[0][2]-K
a1,a2 = C[1][0]-K,C[2][0]-K
if C[1][1]==K+a1+b1 and C[1][2]==K+a1+b2 and C[2][1]==K+a2+b1 and C[2][2]==K+a2+b2:
  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 and\
   c7-c4 == c8-c5 == c9-c6:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:

points = [ [None for j in range(3)] for i in range(3) ]
from itertools import product

for i in range(3):
  c1, c2, c3 = map(int, input().split())
  points[i][0] = c1
  points[i][1] = c2
  points[i][2] = c3

valid = False

for a1 in range(101):
  maxA1 = min(points[0])

  if a1 > maxA1:
    continue

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

  A = {0: a1, 1: a2, 2: a3}
  B = {0: b1, 1: b2, 2: b3}

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


print("Yes")

Submission status: Accepted

Solution code:
li = []

li.append(list(map(int,input().split())))
li.append(list(map(int,input().split())))
li.append(list(map(int,input().split())))

ans = 'Yes'

for a0 in range(li[0][0] + 1):
  b0 = li[0][0] - a0
  b1 = li[1][0] - a0
  b2 = li[2][0] - a0

  a1 = li[0][1] - b0
  a2 = li[0][2] - b0

  if li[0][0] != a0 + b0:
    ans = 'No'
  
  if li[0][1] != a1 + b0:
    ans = 'No'

  if li[0][2] != a2 + b0:
    ans = 'No'

  if li[1][0] != a0 + b1:
    ans = 'No'

  if li[1][1] != a1 + b1:
    ans = 'No'

  if li[1][2] != a2 + b1:
    ans = 'No'

  if li[2][0] != a0 + b2:
    ans = 'No'

  if li[2][1] != a1 + b2:
    ans = 'No'

  if li[2][2] != a2 + b2:
    ans = 'No'

print(ans)

Submission status: Accepted

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

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 (a2+b2)==c[1][1] and (a2+b3)==c[1][2] and (a3+b2)==c[2][1] and (a3+b3)==c[2][2]:
        print("Yes")
        break
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
c = [list(map(int, input().split())) for i in range(3)]
r1 = sum(c[0][j] for j in range(3))
r2 = sum(c[1][j] for j in range(3))
r3 = sum(c[2][j] for j in range(3))
c1 = sum(c[i][0] for i in range(3))
c2 = sum(c[i][1] for i in range(3))
c3 = sum(c[i][2] for i in range(3))
if r1 % 3 == r2 % 3 == r3 % 3 and c1 % 3 == c2 % 3 == c3 % 3:
  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 c1-c4 == c2-c5 == c3-c6 and \
   c1-c7 == c2-c8 == c3-c9 and \
   c4-c7 == c5-c8 == c6-c9:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def solve():
    if not (c11 - c21 == c12 - c22 == c13 - c23):
        return False
    if not (c11 - c31 == c12 - c32 == c13 - c33):
        return False
    if not (c11 - c12 == c21 - c22 == c31 - c32):
        return False
    if not (c11 - c13 == c21 - c23 == c31 - c33):
        return False
    return True
 
 
c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())
 
print('Yes' if solve() else 'No')

Submission status: Accepted

Solution code:
# a+b=c -> b=c-a
C = [list(map(int, input().split())) for _ in range(3)]

# a1を決めて探索
for a1 in range(101):
  b1 = C[0][0] - a1
  b2 = C[0][1] - a1
  b3 = C[0][2] - a1
  
  # a2 = c-b
  a2 = C[1][0] - b1
  a3 = C[2][0] - b1
  # a+b = c  になっているか
  if (C[1][1]-b2) == a2 and (C[1][2]-b3) == a2:
    if (C[2][1]-b2) == a3 and (C[2][2]-b3) == a3:
      print("Yes")
      exit()
print("No")

Submission status: Accepted

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

flag = [0, 0, 0, 0]

if ls[0][0] - ls[1][0] == ls[0][1] - ls[1][1] and ls[0][1] - ls[1][1] == ls[0][2] - ls[1][2]:
    flag[0] = 1

if ls[1][0] - ls[2][0] == ls[1][1] - ls[2][1] and ls[1][1] - ls[2][1] == ls[1][2] - ls[2][2]:
    flag[1] = 1

if ls[0][0] - ls[0][1] == ls[1][0] - ls[1][1] and ls[1][0] - ls[1][1] == ls[2][0] - ls[2][1]:
    flag[2] = 1

if ls[0][1] - ls[0][2] == ls[1][1] - ls[1][2] and ls[1][1] - ls[1][2] == ls[2][1] - ls[2][2]:
    flag[3] = 1

if sum(flag) == 4:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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


import sys
min_a1 = min(C[0])
min_a2 = min(C[1])
min_a3 = min(C[2])

for a1 in range(min_a1+1):
    b1_a1 = C[0][0] - a1
    b2_a1 = C[0][1] - a1
    b3_a1 = C[0][2] - a1
    for a2 in range(min_a2+1):
        b1_a2 = C[1][0] - a2
        b2_a2 = C[1][1] - a2
        b3_a2 = C[1][2] - a2
        for a3 in range(min_a3+1):
            b1_a3 = C[2][0] - a3
            b2_a3 = C[2][1] - a3
            b3_a3 = C[2][2] - a3

            if b1_a1 == b1_a2 == b1_a3 and b2_a1 == b2_a2 == b2_a3 and b3_a1 == b3_a2 == b3_a3:
                print('Yes')
                sys.exit()

print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


def solve(inp):
    A = [list(map(int, inp.readline().split(' '))) for i in range(3)]

    m = list(map(min, A))
    for a1 in range(m[0] + 1):
        c1 = [A[0][0] - a1, A[0][1] - a1, A[0][2] - a1]
        for a2 in range(m[1] + 1):
            c2 = [A[1][0] - a2, A[1][1] - a2, A[1][2] - a2]
            for a3 in range(m[2] + 1):
                c3 = [A[2][0] - a3, A[2][1] - a3, A[2][2] - a3]
                if c1 == c2 == c3:
                    return "Yes"

    return "No"


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
f = []
for i in range(3):
    f.append(list(map(int, input().split())))
"""
a1+a2+a3+b1+b2+b3が3通りで合うか
"""
s1 = f[0][0] + f[1][1] + f[2][2]
s2 = f[0][1] + f[1][2] + f[2][0]
s3 = f[0][2] + f[1][0] + f[2][1]

if s1==s2==s3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

c = []

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

for a1 in range(0,101,1):
    b1 = c[0][0]-a1
    b2 = c[0][1]-a1
    b3 = c[0][2]-a1

    a2 = c[1][0]-b1
    if (a2+b2)!=c[1][1]:
        print("No")
        sys.exit()
    if (a2+b3)!=c[1][2]:
        print("No")
        sys.exit()
    a3 = c[2][0]-b1
    if (a3+b2)!=c[2][1]:
        print("No")
        sys.exit()
    if (a3+b3)!=c[2][2]:
        print("No")
        sys.exit()   
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
c = []
for i in range(3):
  r = list(map(int, input().split()))
  c.append(r)
  
d1 = set([])
d2 = set([])
d3 = set([])
d4 = set([])
for i in range(3):
  d1.add(c[i][1] - c[i][0])
  d2.add(c[i][2] - c[i][1])
  d3.add(c[1][i] - c[0][i])
  d4.add(c[2][i] - c[1][i])
if len(d1) == 1 and len(d2) == 1 and len(d3) == 1 and len(d4) == 1:
  print('Yes')
else:
  print('No')