Problem:


Score: 300 points

Problem Statement

We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.

According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j.

Determine if he is correct.  

Constraints

c_{i, j} \ (1 \leq i \leq 3, 1 \leq j \leq 3) is an integer between 0 and 100 (inclusive).

Input

Input is given from Standard Input in the following format:

c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3}

Output

If Takahashi's statement is correct, print Yes; otherwise, print No.

Sample Input 1

1 0 1
2 1 2
1 0 1

Sample Output 1

Yes

Takahashi is correct, since there are possible sets of integers such as: a_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.

Sample Input 2

2 2 2
2 1 2
2 2 2

Sample Output 2

No

Takahashi is incorrect in this case.

Sample Input 3

0 8 8
0 8 8
0 8 8

Sample Output 3

Yes

Sample Input 4

1 8 6
2 9 7
0 7 7

Sample Output 4

No



Sample input:
1 0 1
2 1 2
1 0 1


Sample output:
Yes

Submission status: Accepted

Solution code:
c = [list(map(int,input().split())) for i in range(3)]
x = c[0][0]
for i in range(x+1):
    a1 = i
    b1 = x-i
    a2 = c[1][0] - b1
    a3 = c[2][0] - b1
    b2 = c[0][1] - a1
    b3 = c[0][2] - a1
    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")
        exit()
print("No")

Submission status: Accepted

Solution code:
J=lambda:map(int,input().split());A,B,C=J();D,E,F=J();G,H,I=J();print("YNeos"[any([A-B-D+E,A-C-G+I,E-F-H+I])::2])

Submission status: Accepted

Solution code:
import sys

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

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

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

Submission status: Accepted

Solution code:
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

c = []
for _ in range(3):
    c.append(III())

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]:
        pass
    else:
        print('No')
        exit()

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()
    
print('Yes')

Submission status: Accepted

Solution code:
num = list(input().split() for l in range(3))
flg = 0
for i in range(0,101):
    d = int(num[0][0]) - i
    e = int(num[1][0]) - i
    f = int(num[2][0]) - i
    b = int(num[0][1]) - d
    c = int(num[0][2]) - d
    if int(num[1][1]) == b + e and int(num[1][2]) == c + e and int(num[2][1]) == b + f and int(num[2][2]) == c + f:
        flg = 1

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

Submission status: Accepted

Solution code:
import sys
from statistics import *
from collections import *
from operator import itemgetter

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

ct = 0
li = []
for i in range(3):
    li.append(na())

bbb = li[0]
aaa = [0, li[1][0] - li[0][0], li[2][0] - li[0][0]]
ans = "Yes"
for i in range(3):
    for j in range(3):
        if li[i][j] != aaa[i] + bbb[j]:
            ans = 'No'
            break
print(ans)

Submission status: Accepted

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

n1 = max(c[0])
n2 = max(c[1])
n3 = max(c[2])
ans = 'No'

for a1 in range(n1+1):
	for a2 in range(n2+1):
		for a3 in range(n3+1):
			if c[0][0] - a1 == c[1][0] - a2 == c[2][0] - a3 :
				if c[0][1] - a1 == c[1][1] - a2 == c[2][1] - a3 :
					if c[0][2] - a1 == c[1][2] - a2 == c[2][2] - a3 :
						ans = 'Yes'
						break


print(ans)

Submission status: Accepted

Solution code:
import sys

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

for a in range(-1000, 1001):
    b_1 = m[0][0] - a
    b_2 = m[0][1] - a
    b_3 = m[0][2] - a
    if (m[1][0] - b_1 ==
        m[1][1] - b_2 ==
        m[1][2] - b_3) and \
        (m[2][0] - b_1 ==
         m[2][1] - b_2 ==
         m[2][2] - b_3):
        print('Yes')
        sys.exit()
print('No')

Submission status: Accepted

Solution code:
sa = []
cnt = 0
for i in range(3):
    x,y,z = map(int,input().split())
    sa.append([x-y,y-z,z-x])
for i in range(3):
    if sa[0][i] == sa[1][i] == sa[2][i]:
        cnt += 1
if cnt==3:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
"""#################################################################
【ABC088】
C_Takahashi's Information
#################################################################"""

#インポート
import sys
from collections import Counter

#入力用
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))  #リスト(int型)
def MI(): return map(int, sys.stdin.readline().rstrip().split())        #多変数(int型)
def II(): return int(sys.stdin.readline().rstrip())                     # 1変数(int型)
def S(): return sys.stdin.readline().rstrip()                           #文字列(str型)

c = []
x = []
y = []
for _ in range(3):
    c.append(LI())
x.append(0) # x[0]=0と仮定
#y[0:2]の算出
for j in range(3):
    y.append(c[0][j] - x[0])
#x[1:2]の算出
for i in range(1, 3):
    x.append(c[i][0]-y[0])
#チェック
OK = True
for i in range(3):
    for j in range(3):
        if c[i][j] != x[i]+y[j]:
            OK = False
if OK == True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
C = []
for i in range(3):
  Cs = list(map(int, input().split()))
  C.append(Cs)
As = [0]*3
Bs = [0]*3
As[0] = 0
Bs[0] = C[0][0]-As[0]
for i in range(3):
  As[i] = C[i][0]-Bs[0]
for j in range(3):
  Bs[j] = C[0][j]-As[0]
ok = True
for i in range(3):
  for j in range(3):
    if C[i][j] != As[i]+Bs[j]:
      ok = False
if ok:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
c = []
for _ in range(3):
    c.append(list(map(int, input().split())))
ans = False
for a1 in range(min(c[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
    if c[1][1] - b2 == a2 and c[1][2] - b3 == a2:
        if c[2][1] - b2 == a3 and c[2][2] - b3 == a3:
            ans = True
            break
if ans == True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

# http://mkan-0141.hatenablog.com/entry/2018/02/18/224008


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

if(C[0][0] - C[0][1] == C[1][0] - C[1][1] and # a1のb1<>b2 と a2のb1<>b2の比較
   C[1][0] - C[1][1] == C[2][0] - C[2][1] and # a2のとa3の b1<>b2の比較
   C[0][1] - C[0][2] == C[1][1] - C[1][2] and # a0のとa1のb2<>b3の比較
   C[1][1] - C[1][2] == C[2][1] - C[2][2]):   # a2のとa3のb2<>b3の比較
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
C = []

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

flg = True

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
tbl = [[int(_) for _ in input().split()] for _ in range(3)]
for a1 in range(100):
    B = [tbl[0][i] - a1 for i in range(3)]
    A = [a1, tbl[1][0] - B[0], tbl[2][0] - B[0]]

    flg = True
    for i in range(3):
        for j in range(3):
            if tbl[i][j] != A[i] + B[j]:
                flg = False
                break
        if not flg: break
    if flg:
        print('Yes')
        exit()
print('No')

Submission status: Accepted

Solution code:
import numpy as np

n1 = list(map(int , input().split()))
n2 = list(map(int , input().split()))
n3 = list(map(int , input().split()))
A = np.array([n1,n2,n3])

def check(b1, b2, b3):
    if b1==b2 and b2 ==b3:
        return True
    else:
        return False
      
flg = False
for i in range(max(A[0])+1):
    diff_n1 =  A[0] - i
    b1 = A[1][0] - diff_n1[0]
    b2 = A[1][1] - diff_n1[1]
    b3 = A[1][2] - diff_n1[2]
    c1 = A[2][0] - diff_n1[0]
    c2 = A[2][1] - diff_n1[1]
    c3 = A[2][2] - diff_n1[2]
    if check(b1, b2, b3) and check(c1, c2, c3):
        flg = True
if flg:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

ans = "Yes"
if not(c[0][0] - c[1][0] == c[0][1] - c[1][1] == c[0][2] - c[1][2]):
  ans = "No"
elif not(c[1][0] - c[2][0] == c[1][1] - c[2][1] == c[1][2] - c[2][2]):
  ans = "No"
elif not(c[0][0] - c[0][1] == c[1][0] - c[1][1] == c[2][0] - c[2][1]):
  ans = "No"
elif not(c[0][1] - c[0][2] == c[1][1] - c[1][2] == c[2][1] - c[2][2]):
  ans = "No"
  
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np

def main():
    c = np.array([list(map(int, input().split())) for i in range(3)])

    for i in range(3):
        c[i] -= min(c[i])
    
    for i in range(3):
        c[:,i] -= min(c[:,i])
    
    if np.sum(c) == 0:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Accepted

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

r_sum = [sum(l) for l in cs]
total = sum(r_sum)

ok = True
for i in range(3):
    diffs = [cs[i][j] - cs[(i + 1) % 3][j] for j in range(3)]
    d0 = diffs[0]
    for j in range(1, 3):
        if diffs[j] != d0:
            ok = False
            break
    if not ok:
        break
if ok:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc088/tasks/abc088_c
# C - Takahashi's Information

c_matrix = []
for _ in range(3):
    c_list = list(map(int, input().split()))
    c_matrix.append(c_list)

a_matrix = []
a_list = []
b_list = []
a_list.append(0) # a1
b_list.append(c_matrix[0][0])
b_list.append(c_matrix[0][1])
b_list.append(c_matrix[0][2])
a_list.append(c_matrix[1][0] - b_list[0])
a_list.append(c_matrix[2][0] - b_list[0])

is_ok = True

for i in range(3):
    for j in range(3):
        if a_list[i] + b_list[j] != c_matrix[i][j]:
            is_ok = False
            break

    if not is_ok:
        break

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

Submission status: Accepted

Solution code:
c1=list(map(int,input().split()))
c2=list(map(int,input().split()))
c3=list(map(int,input().split()))
 
 
if (sum(c1)+sum(c2)+sum(c3))%3!=0:
    print("No")
    exit()
elif c2[0]-c1[0]!=c2[1]-c1[1] or c2[0]-c1[0]!=c2[2]-c1[2] or c2[2]-c1[2]!=c2[1]-c1[1]:
    print("No")
    exit()
elif c3[0]-c1[0]!=c3[1]-c1[1] or c3[0]-c1[0]!=c3[2]-c1[2] or c3[2]-c1[2]!=c3[1]-c1[1]:
    print("No")
    exit()
elif c3[0]-c2[0]!=c3[1]-c2[1] or c3[0]-c2[0]!=c3[2]-c2[2] or c3[0]-c2[0]!=c3[1]-c2[1]:
    print("No")
    exit()   
    
elif c1[1]-c1[0]!=c2[1]-c2[0] or c3[1]-c3[0]!=c2[1]-c2[0] or c1[1]-c1[0]!=c3[1]-c3[0]:
    print("No")
    exit()
elif c1[2]-c1[0]!=c2[2]-c2[0] or c3[2]-c3[0]!=c2[2]-c2[0] or c1[2]-c1[0]!=c3[2]-c3[0]:
    print("No")
    exit()    
elif c1[2]-c1[1]!=c2[2]-c2[1] or c3[2]-c3[1]!=c2[2]-c2[1] or c1[2]-c1[1]!=c3[2]-c3[1]:
    print("No")
    exit()      
    
else:
    print("Yes")

Submission status: Accepted

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

b123=c[0]
a123=np.array([
    0,
    c[1][1]-b123[1],
    c[2][2]-b123[2],
])

isOk=True
for i in range(3):
    for j in range(3):
        if c[i][j]!=a123[i]+b123[j]:
            isOk=False

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

Submission status: Accepted

Solution code:
s = []

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

sum_num = 0
for i in range(3):
    for j in range(3):
        sum_num += s[i][j]


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

if sum_num % 3 == 0 and magic_num * 3 == sum_num:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def main():
    mat = []
    for _ in range(3):
        mat.append([int(c) for c in input().split()])
    for j in range(2):
        ref = mat[0][j+1] - mat[0][j]
        if ref != mat[1][j+1] - mat[1][j] or ref != mat[2][j+1] - mat[2][j]:
            return "No"
    for i in range(2):
        ref = mat[i+1][0] - mat[i][0]
        if ref != mat[i+1][1] - mat[i][1] or ref != mat[i+1][2] - mat[i][2]:
            return "No"
    return "Yes"


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

Submission status: Accepted

Solution code:
def find_numbers(grid):
    for a1 in range(0, 101):
        for a2 in range(0, 101):
            if (grid[0] + grid[3] + grid[6]) - 3 * a1 == (grid[1] + grid[4] + grid[7]) - 3 * a2:
                for a3 in range(0, 101):
                    if (grid[0] + grid[3] + grid[6]) - 3 * a1 == (grid[2] + grid[5] + grid[8]) - 3 * a3:
                        return True
    return False


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

print("Yes" if find_numbers(grid) else "No")

Submission status: Accepted

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

lia = li[0]
lib = li[1]
lic = li[2]

if lia[0]-lia[1]==lib[0]-lib[1]==lic[0]-lic[1] and lia[1]-lia[2]==lib[1]-lib[2]==lic[1]-lic[2]\
and lia[0]-lib[0]==lia[1]-lib[1]==lia[2]-lib[2] and lib[0]-lic[0]==lib[1]-lic[1]==lib[2]-lic[2]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc088/tasks/abc088_c

import sys

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

for a in range(-1000, 1001):
    b_1 = m[0][0] - a
    b_2 = m[0][1] - a
    b_3 = m[0][2] - a
    if (m[1][0] - b_1 ==
        m[1][1] - b_2 ==
        m[1][2] - b_3) and \
        (m[2][0] - b_1 ==
         m[2][1] - b_2 ==
         m[2][2] - b_3):
        print('Yes')
        sys.exit()
print('No')

Submission status: Accepted

Solution code:
c = [[]]*3

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


arr = [0]*3
sum = 0
for i in range(3):
    arr[0] += c[i][i]
for i in range(3):
    if i + 1 < 3:
        arr[1] += c[i][i+1]
    else:
        arr[1] += c[i][0]
for i in range(3):
    if i + 2 < 3:
        arr[2] += c[i][i+2]
    else:
        arr[2] += c[i][i-1]

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

print("Yes")
exit(0)

Submission status: Accepted

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

for i in range(3):
    D = []
    for j in range(3):
        D.append(X[i][j]-X[i-1][j])
    if len(set(D)) > 1:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
c = [[]]*3

for i in range(3):
    c[i] = list(map(int, input().split()))
ans = 0
for i in range(3):
    ans += sum(c[i])

if ans % 3 == 0:
    

    arr = [0]*3
    sum = 0
    for i in range(3):
        arr[0] += c[i][i]
    for i in range(3):
        if i + 1 < 3:
            arr[1] += c[i][i+1]
        else:
            arr[1] += c[i][0]
    for i in range(3):
        if i + 2 < 3:
            arr[2] += c[i][i+2]
        else:
            arr[2] += c[i][i-1]
    
    if arr[0] != arr[1] or arr[0] != arr[2]:
        print("No")
        exit(0)

    print("Yes")
    exit(0)

print("No")

Submission status: Accepted

Solution code:
c = [[]]*3

for i in range(3):
    c[i] = list(map(int, input().split()))
ans = 0
for i in range(3):
    ans += sum(c[i])

if ans % 3 == 0:
    arr = [[0]* 6]*3
    for i in range(3):
        arr[i][0] = c[i][0] - c[i][1]
        arr[i][1] = c[i][0] - c[i][2]
        arr[i][2] = c[i][1] - c[i][0]
        arr[i][3] = c[i][1] - c[i][2]
        arr[i][4] = c[i][2] - c[i][0]
        arr[i][5] = c[i][2] - c[i][1]
    for i in range(6):
        if arr[0][i] == arr[1][i] and arr[0][i] == arr[2][i]:
            continue
        else:
            print("No")
            exit(0)

    for i in range(3):
        arr[i][0] = c[0][i] - c[1][i]
        arr[i][1] = c[0][i] - c[2][i]
        arr[i][2] = c[1][i] - c[0][i]
        arr[i][3] = c[1][i] - c[2][i]
        arr[i][4] = c[2][i] - c[1][i]
        arr[i][5] = c[2][i] - c[0][i]
          

    for i in range(6):
        if arr[0][i] == arr[1][i] and arr[0][i] == arr[2][i]:
            continue
        else:
            print("No")
            exit(0)

    arr = [0]*3
    sum = 0
    for i in range(3):
        arr[0] += c[i][i]
    for i in range(3):
        if i + 1 < 3:
            arr[1] += c[i][i+1]
        else:
            arr[1] += c[i][0]
    for i in range(3):
        if i + 2 < 3:
            arr[2] += c[i][i+2]
        else:
            arr[2] += c[i][i-1]
    
    if arr[0] != arr[1] or arr[0] != arr[2]:
        print("No")
        exit(0)

    print("Yes")
    exit(0)

print("No")

Submission status: Accepted

Solution code:
import sys
check_ary = [[0 for i in range(3)]for i in range(2)]
num_ary = [[0 for i in range(3)]for i in range(3)]
check_minus = False

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

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

    for x in range(3):
        check_ary[1][x] = num_ary[0][x] - i

    for a in range(3):
        check_ary[0][a] = num_ary[a][0] - check_ary[1][0]

    for x in range(3):
        for y in range(3):
            if not check_ary[0][x] + check_ary[1][y] == num_ary[x][y]:
                break
        else:
            continue
        break
    else :
        print("Yes")
        sys.exit()

print("No")

Submission status: Accepted

Solution code:
nums_ary = [[0 for i in range(3)] for i in range(3)]
check_ary = [[0 for i in range(3)] for i in range(2)]
good = True

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

check_ary[0][0] = 0

for x in range(3):
    check_ary[1][x] = nums_ary[0][x] - check_ary[0][0]

for y in range(3):
    check_ary[0][y] = nums_ary[y][0] - check_ary[1][0]

for x in range(3):
    for y in range(3):
        if not check_ary[0][x] + check_ary[1][y] == nums_ary[x][y]:
            good = False

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

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
g,h,i=map(int,input().split())
if b-a==e-d==h-g and c-b==f-e==i-h and\
d-a==e-b==f-c and g-d==h-e==i-f:
	print("Yes")
else:
	print("No")

Submission status: Accepted

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

judge = True
for i in range(2):
    for j in range(2):
        if (c[j][i]-c[j+1][i]) != (c[j][i+1]-c[j+1][i+1]):
            judge = False
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]):
            judge = False
if judge:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

if c[0][1] - c[0][0] != c[1][1] - c[1][0] or c[0][1] - c[0][0] != c[2][1] - c[2][0]:
    print('No')
    exit()

if c[0][2] - c[0][0] != c[1][2] - c[1][0] or c[0][2] - c[0][0] != c[2][2] - c[2][0]:
    print('No')
    exit()
    
if c[0][2] - c[0][1] != c[1][2] - c[1][1] or c[0][2] - c[0][1] != c[2][2] - c[2][1]:
    print('No')
    exit()
    

if c[2][0] - c[1][0] != c[2][1] - c[1][1] or c[2][0] - c[1][0] != c[2][2] - c[1][2]:
    print('No')
    exit()
    
if c[2][0] - c[0][0] != c[2][1] - c[0][1] or c[2][0] - c[0][0] != c[2][2] - c[0][2]:
    print('No')
    exit()
    
if c[0][0] - c[1][0] != c[0][1] - c[1][1] or c[0][0] - c[1][0] != c[0][2] - c[1][2]:
    print('No')
    exit()

print('Yes')

Submission status: Accepted

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

Q=[]
a1=0
b1=Z[0][0]-a1
b2=Z[0][1]-a1
b3=Z[0][2]-a1
a2=Z[1][0]-b1
a3=Z[2][0]-b1
c1=[a1+b1,a1+b2,a1+b3]
c2=[a2+b1,a2+b2,a2+b3]
c3=[a3+b1,a3+b2,a3+b3]
Q.append(c1)
Q.append(c2)
Q.append(c3)

if Z==Q:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

def exit_if_not_eq(i, j):
    if i != j:
        print("No")
        exit()

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

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

Submission status: Accepted

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

for I in range (3):
    j,k,l = A[1]-A[0]
    if not (j==k and k==l):
        print ( "No")
        quit()
    j,k,l = A[2]-A[0]
    if not (j==k and k==l):
        print ( "No")
        quit()
print("Yes")

Submission status: Accepted

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

for I in range (2):
    j,k,l = A[1]-A[0]
    if not (j==k and k==l):
        print ( "No")
        quit()
    j,k,l = A[2]-A[0]
    if not (j==k and k==l):
        print ( "No")
        quit()
print("Yes")

Submission status: Accepted

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

ans = "No"

for a_1 in range(101):
  b_1 = c[0][0] - a_1
  b_2 = c[0][1] - a_1
  b_3 = c[0][2] - a_1
  a_2 = c[1][0] - b_1
  a_3 = c[2][0] - b_1
  if a_2+b_2==c[1][1] and a_2+b_3==c[1][2] and a_3+b_2==c[2][1] and a_3+b_3==c[2][2]:
    ans = "Yes"
    break

print(ans)

Submission status: Accepted

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

ans = False

for a_1 in range(101):
	b_1 = c[0][0] - a_1
	b_2 = c[0][1] - a_1
	b_3 = c[0][2] - a_1
	a_2 = c[1][0] - b_1
	a_3 = c[2][0] - b_1
	if 	a_2+b_2==c[1][1] and a_2+b_3==c[1][2] and a_3+b_2==c[2][1] and a_3+b_3==c[2][2]:
		ans = True
		break

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

Submission status: Accepted

Solution code:
def divisors(n, sort=False):
    """
    nの約数をO(√n)で列挙する
    """
    d = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            d.append(i)
            if i != n // i:
                d.append(n//i)
    if sort:
        d.sort()
    return d


C = [list(map(int, input().split())) for _ in range(3)]
if sum([sum(r) for r in C]) == 0:
    print('Yes')
    exit(0)
    
for a0 in divisors(sum(C[0])):
    a = [a0, None, None]
    b = [None, None, None]
    b[0] = C[0][0] - a[0]
    a[1] = C[1][0] - b[0]
    a[2] = C[2][0] - b[0]
    b[1] = C[0][1] - a[0]
    b[2] = C[0][2] - a[0]
    ok = True
    for i in range(3):
        for j in range(3):
            if C[i][j] != a[i] + b[j]:
                ok = False
    if ok:
        print('Yes')
        exit(0)
print('No')

Submission status: Accepted

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

ans = False

for a_1 in range(101):
	b_1 = c[0][0] - a_1
	b_2 = c[0][1] - a_1
	b_3 = c[0][2] - a_1
	a_2 = c[1][0] - b_1
	a_3 = c[2][0] - b_1
	if 	a_2+b_2==c[1][1] and a_2+b_3==c[1][2] and a_3+b_2==c[2][1] and a_3+b_3==c[2][2]:
		ans = True
		break

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

Submission status: Accepted

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

#print(li[0])

def chk(al,bl,li) :
  for i in range(3) :
    for j in range(3) :
      if li[i][j]!=al[i]+bl[j] :
        return False
  return True
        #print("No")
        #exit()
  #print("Yes")

flag=True
for a1 in range(max(li[0])+1):
  al=[]
  bl=[]
  #print(a1)
  bl=[li[0][0]-a1,li[0][1]-a1,li[0][2]-a1]
  #print(bl)
  al.append(a1)
  al.append(li[1][0]-bl[0])#a2
  al.append(li[2][0]-bl[0])#a3
  #print(al)
  if chk(al,bl,li) :
    print("Yes")
    exit()
print("No")

Submission status: Accepted

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

Submission status: Accepted

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

a_list = [0]
b_list = []

for c in c_list[0]:
    b = c - a_list[0]
    b_list.append(b)

for i in range(1,3):
    c = c_list[i][0]
    b = b_list[0]
    a = c - b
    a_list.append(a)

def check():
    for i in range(3):
        for j in range(3):
            a = a_list[i]
            b = b_list[j]
            c = c_list[i][j]
            if not c == a + b:
                return False
    return True

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

Submission status: Accepted

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

if A[0][0]-A[1][0]!=A[0][1]-A[1][1]:
    print('No')
    exit(0)

if A[0][0]-A[1][0]!=A[0][2]-A[1][2]:
    print('No')
    exit(0)

if A[1][0]-A[2][0]!=A[1][1]-A[2][1]:
    print('No')
    exit(0)

if A[1][0]-A[2][0]!=A[1][2]-A[2][2]:
    print('No')
    exit(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())
o = p = q = r = 0
if (a - b) == (d - e) == (g - h):
  o = 1
if (b - c) == (e - f) == (h - i):
  p = 1
if (a - d) == (b - e) == (c - f):
  q = 1
if (d - g) == (e - h) == (f - i):
  r = 1
if o == p == q == r == 1:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

d = []
for i in range(3):
  sum = 0
  d.append([])
  for j in range(3):
    sum += c[i][j]
  for j in range(3):
    d[i].append(3*c[i][j] - sum)
    
for i in range(3):
  if d[0][i]==d[1][i] and d[0][i]==d[2][i]:
    pass
  else:
    print('No')
    break
else:
  print('Yes')

Submission status: Accepted

Solution code:
c = list
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
c=[p,q,r]
br = 0
for i in range(2):
  for j in range(2):
    if(c[i][j]+c[i+1][j+1]==c[i][j+1]+c[i+1][j]):
      None
    else:
      br+=1
      break
if(br==0):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3

# c0 c1 c2
# c3 c4 c5
# c6 c7 c8

# 入力値受取り
c = [0] * 9
for i in range(3):
    tmp = list(map(int, input().split()))
    for j in range(3):
        c[i * 3 + j] = tmp[j]

# 縦差分CHECK
if not(c[0] - c[3] == c[1] - c[4] and c[0] - c[3] == c[2] - c[5] and c[3] - c[6] == c[4] - c[7] and c[3] - c[6] == c[5] - c[8]):
    print('No')
    exit()

# 横差分CHECK
if not (c[0] - c[1] == c[3] - c[4] and c[0] - c[1] == c[6] - c[7] and c[1] - c[2] == c[4] - c[5] and c[1] - c[2] == c[7] - c[8]):
    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(2):
    dist = c[i+1][0] - c[i][0]
    if c[i+1][1] - c[i][1] == dist and c[i+1][2] - c[i][2] == dist:
        continue
    else:
        print('No')
        exit()

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

print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

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

A = np.array([
    [1, 0, 0, 1, 0, 0],
    [0, 1, 0, 1, 0, 0],
    [0, 0, 1, 1, 0, 0],
    [1, 0, 0, 0, 1, 0],
    [0, 1, 0, 0, 1, 0],
    [0, 0, 1, 0, 1, 0],
    [1, 0, 0, 0, 0, 1],
    [0, 1, 0, 0, 0, 1],
    [0, 0, 1, 0, 0, 1],
])

Aplus = np.array([
    [1, 0, 0, 1, 0, 0, C[0][0]],
    [0, 1, 0, 1, 0, 0, C[1][0]],
    [0, 0, 1, 1, 0, 0, C[2][0]],
    [1, 0, 0, 0, 1, 0, C[0][1]],
    [0, 1, 0, 0, 1, 0, C[1][1]],
    [0, 0, 1, 0, 1, 0, C[2][1]],
    [1, 0, 0, 0, 0, 1, C[0][2]],
    [0, 1, 0, 0, 0, 1, C[1][2]],
    [0, 0, 1, 0, 0, 1, C[2][2]],
])

rankA = np.linalg.matrix_rank(A)
rankAp = np.linalg.matrix_rank(Aplus)

if rankA == rankAp:
    print('Yes')
else:
    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())))
ans = "Yes"
for i in range(3):
    a1 = c[1][i]-c[0][i]
    a2 = c[2][i]-c[1][i]
    a3 = c[i][2]-c[i][1]
    a4 = c[i][1]-c[i][0]
    l = [a1,a2,a3,a4]
    if i == 0:
        p = l
    else:
        if p!=l:
            ans = "No"
print(ans)

Submission status: Accepted

Solution code:
def main():
    c = [[0] * 3] * 3

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

    if (c[0][0] - c[1][0]) == (c[0][1] - c[1][1]) == (c[0][2] - c[1][2]):
        if (c[1][0] - c[2][0]) == (c[1][1] - c[2][1]) == (c[1][2] - c[2][2]):
            if (c[0][0] - c[2][0]) == (c[0][1] - c[2][1]) == (c[0][2] - c[2][2]):
                print('Yes')
                exit()
    print('No')

main()

Submission status: Accepted

Solution code:

import collections
import itertools

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

grid = [getints() for i in range(3)]


def normalize(grid):
    if not grid:
        return
    line = grid[0]
    mx = min(line)
    for j in range(3):
        line[j] -= mx
    normalize(grid[1:])

normalize(grid)

ok = grid[0] == grid[1] and grid[1] == grid[2]

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