Problem:


Score: 300 points

Problem Statement

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

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

Determine if he is correct.  

Constraints

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

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

1 0 1
2 1 2
1 0 1

Sample Output 1

Yes

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

Sample Input 2

2 2 2
2 1 2
2 2 2

Sample Output 2

No

Takahashi is incorrect in this case.

Sample Input 3

0 8 8
0 8 8
0 8 8

Sample Output 3

Yes

Sample Input 4

1 8 6
2 9 7
0 7 7

Sample Output 4

No



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


Sample output:
Yes

Submission status: Accepted

Solution code:
c = [list(map(int, input().split())) for _ in range(3)]
a = [0] * 3
b = [0] * 3
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]
#print(a)
#print(b)
flag = True
for i in range(3):
  for j in range(3):
    if a[i] + b[j] != c[i][j]:
      flag = False
if flag:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

l1 = C[0]
l2 = C[1]
if not(l2[0] - l1[0] == l2[1] - l1[1] == l2[2] - l1[2]):
	print("No")
	exit()

l1 = C[0]
l2 = C[2]
if not(l2[0] - l1[0] == l2[1] - l1[1] == l2[2] - l1[2]):
	print("No")
	exit()

print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
b=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))
for i in range(max(0,b[0]-100,b[1]-100,b[2]-100),min(100,b[0],b[1],b[2])+1):
  t1=set()
  t2=set()
  for j in range(3):
    t1.add(a2[j]-(b[j]-i))
    t2.add(a3[j]-(b[j]-i))
  if len(t1)==1 and len(t2)==1 and list(t1)[0]>=0 and list(t2)[0]>=0:
    print('Yes')
    break
else:
  print('No')

Submission status: Accepted

Solution code:
hog1=list(map(int,input().split()))
hog2=list(map(int,input().split()))
hog3=list(map(int,input().split()))

for i in range(100):
  if(hog1[0]!=0 and hog1[1]!=0 and hog1[2]!=0):
    hog1[0]-=1
    hog1[1]-=1
    hog1[2]-=1
  if(hog2[0]!=0 and hog2[1]!=0 and hog2[2]!=0):
    hog2[0]-=1
    hog2[1]-=1
    hog2[2]-=1
  if(hog3[0]!=0 and hog3[1]!=0 and hog3[2]!=0):
    hog3[0]-=1
    hog3[1]-=1
    hog3[2]-=1
  if(hog1[0]!=0 and hog2[0]!=0 and hog3[0]!=0):
    hog1[0]-=1
    hog2[0]-=1
    hog3[0]-=1
  if(hog1[1]!=0 and hog2[1]!=0 and hog3[1]!=0):
    hog1[1]-=1
    hog2[1]-=1
    hog3[1]-=1
  if(hog1[2]!=0 and hog2[2]!=0 and hog3[2]!=0):
    hog1[2]-=1
    hog2[2]-=1
    hog3[2]-=1

ans=sum(hog1)+sum(hog2)+sum(hog3)
if(ans==0):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    g = [f() for i in range(3)]

    for i in range(2):
        if g[i][0] - g[i+1][0] != g[i][1] - g[i+1][1] or g[i][1] - g[i+1][1] != g[i][2] - g[i+1][2]:
            print('No')
            return
    
    for i in range(2):
        if g[0][i] - g[0][i+1] != g[1][i] - g[1][i+1] or g[2][i] - g[2][i+1] != g[1][i] - g[1][i+1]:
            print('No')
            return

    print('Yes')

solve()

Submission status: Accepted

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

L = [None] * 3
for i in range(3):
    L[i] = [int(v) for v in input().split()]
    
rl = [L[0][0] - L[0][1], L[0][1] - L[0][2]]
hl = [L[0][0] - L[1][0], L[1][0] - L[2][0]]

for v in L:
    if [v[0] - v[1], v[1] - v[2]] != rl:
        print("No")
        sys.exit()
        
for i in range(3):
    if [L[0][i] - L[1][i], L[1][i] - L[2][i]] != hl:
        print("No")
        sys.exit()
        
print("Yes")

Submission status: Accepted

Solution code:
C = [[int(x) for x in input().split()] for _ in range(3)]
ans = C[0][0]+C[1][1]+C[2][2]
if(ans == C[0][2]+C[1][0]+C[2][1] and ans == C[0][1]+C[1][2]+C[2][0]):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from sys import exit, stdin
C = [list(map(int, stdin.readline().rstrip().split())) for _ in range(3)]
a1,a2,a3,b1,b2,b3 = 0,0,0,0,0,0
for i in range(0,101):
    a1=i
    b1, b2, b3 = C[0][0]-a1,C[0][1]-a1,C[0][2]-a1
    for j in range(0,101):
        a2=j
        j_flag = a2+b1 == C[1][0] and a2+b2 == C[1][1] and a2+b3 == C[1][2]
        for k in range(0,101):
            a3=k
            k_flag = a3+b1 == C[2][0] and a3+b2 == C[2][1] and a3+b3 == C[2][2]
            if j_flag == True and k_flag == True:
                print('Yes')
                exit()
print('No')

Submission status: Accepted

Solution code:


def read_input():
    c1 = list(map(int, input().split()))
    c2 = list(map(int, input().split()))
    c3 = list(map(int, input().split()))
    return [c1, c2, c3]

# i列目を取り出す
def get_v(c, i):
    result = [c[j][i] for j in range(3)]
    return result

# i行目を取り出す
def get_h(c, i):
    result = [c[i][j] for j in range(3)]
    return result

# aとbの要素差がすべて等しいかチェック
def check_diff(a, b):
    diff = [i - j for i,j in zip(a, b)]

    d = diff[0]
    for e in diff[1:]:
        if d != e:
            return False
    return True


def submit():
    c = read_input()

    checkee = [(0, 1), (1, 2), (0, 2)]
    result = []
    for check in checkee:
        result.append(check_diff(get_v(c, check[0]), get_v(c, check[1])))
        result.append(check_diff(get_h(c, check[0]), get_h(c, check[1])))

    if all(result):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    submit()

Submission status: Accepted

Solution code:
c = []

for i in range(3):
    c.append(list(map(int, input().split())))
setset = {len({c[i][0] - c[i][1] for i in range(3)}),
          len({c[i][0] - c[i][2] for i in range(3)}),
          len({c[0][i] - c[2][i] for i in range(3)}),
          len({c[0][i] - c[2][i] for i in range(3)})
          }
l = list(setset)
print('Yes'if l == [1]else 'No')

Submission status: Accepted

Solution code:
a = [input().split() for l in range(3)]

x0 = 0
x1 = 0
x2 = 0
y0 = 0
y1 = 0
y2 = 0
judg = 0
for i in range(3):
    for j in range(3):
        a[i][j] = int(a[i][j])

for i in range(100):
    x0 = i
    y0 = a[0][0] - i
    y1 = a[0][1] - i
    y2 = a[0][2] - i
    x1 = a[1][1] - y1
    x2 = a[2][2] - y2
    if a[1][0] == x1 + y0 and a[1][2] == x1 + y2 and a[2][0] == x2 + y0 and a[2][1] == x2 + y1:
        judg = 1
    break

if judg == 0:
    print("No")
else:
    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()))

temp = max(c1)
if temp == 0:
    temp = 1

for i in range(temp):
    x1= c1[0] - i
    x2 = c1[1] - i
    x3 = c1[2] - i
    y1 = i
    y2 = c2[0] - x1
    y3 = c3[0] - x1
    
    if x1+y1 == c1[0] and x2+y1 == c1[1] and x3+y1 == c1[2] and x1+y2 == c2[0] and x2+y2 == c2[1] and x3+y2 == c2[2] and x1+y3 == c3[0] and x2+y3 == c3[1] and x3+y3 == c3[2]:
        print("Yes")
        break
    else:
        print("No")
        break

Submission status: Accepted

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

X = [0,0,0]
Y = [0,0,0]

for i in range(3):
    Y[i] = C[0][i] - X[0]
for i in range(3):
    X[i] = C[i][0] - Y[0]

for i in range(3):
    for j in range(3):
        if (C[i][j] != X[i] + Y[j]):
            print("No")
            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()))

x1 = (c1[1]-c1[0] == c2[1]-c2[0] == c3[1]-c3[0])
x2 = (c1[2]-c1[1] == c2[2]-c2[1] == c3[2]-c3[1])
x3 = (c2[0]-c1[0] == c2[1]-c1[1] == c2[2]-c1[2])
x4 = (c3[0]-c2[0] == c3[1]-c2[1] == c3[2]-c2[2])

if x1 and x2 and x3 and x4:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
c1,c2,c3=map(int,input().split())
d1=c2-c1
d2=c3-c2
ans=0
for i in range(2):
  c1,c2,c3=map(int,input().split())
  if c2-c1!=d1 or c3-c2!=d2:
    ans+=1
print("Yes" if ans==0 else "No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
l1 = list(map(int,input().split(" ")))
l2 = list(map(int,input().split(" ")))
l3 = list(map(int,input().split(" ")))

flag = True
diffs = []
for i in range(3):
    diffs.append(l1[i]-l2[i])

if len(set(diffs)) != 1:
    flag = False


diffs = []
for i in range(3):
    diffs.append(l2[i]-l3[i])

if len(set(diffs)) != 1:
    flag = False

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

Submission status: Accepted

Solution code:
x =list(map(int, input().split()))
y =list(map(int, input().split()))
z =list(map(int, input().split()))

if (sum(x)-sum(y)) % 3 == 0 and (sum(x)-sum(z)) % 3 ==0 \
    and ((x[0] + y[0] + z[0]) - (x[1] + y[1] + z[1])) % 3 ==0\
    and ((x[0] + y[0] + z[0]) - (x[2] + y[2] + z[2])) % 3 ==0:
        print('Yes')
else:
    print('No')

Submission status: Accepted

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

for i in range(3):
    a = min(c[i])
    for j in range(3):
        c[i][j] -= a

for j in range(3):
    b = min(c[0][j], c[1][j], c[2][j])
    for i in range(3):
        c[i][j] -= b

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

print('Yes')

Submission status: Accepted

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

for i in range(101):
    b = [c[0][0]-i, c[0][1]-i, c[0][2]-i]
    a = [i, c[1][0]-b[0], c[2][0]-b[0]]
    flag = False
    for j in range(3):
        for k in range(3):
            if c[j][k] != a[j] + b[k]:
                flag = True
                break
            if j == 2 and k == 2:
                ans = True
        if flag:
            break

if ans:
    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())))
a = []

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

if a[0] == a[1] and a[0] == a[2]:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
import numpy as np

c1 = [int(i) for i in input().split(" ")]
c2 = [int(i) for i in input().split(" ")]
c3 = [int(i) for i in input().split(" ")]
c = np.array([c1, c2, c3])

a = [[i[2] - i[1], i[1] - i[0]] for i in c.T]
b = [[i[2] - i[1], i[1] - i[0]] for i in c]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
c = [list(map(int,input().split())) for _ in [0]*3]
def main():
    for i in range(3):
        tmp1 = set()
        tmp2 = set()
        for j in range(3):
            tmp1.add(c[i][j]-c[(i+1)%3][j])
            tmp2.add(c[j][i]-c[j][(i+1)%3])
        if len(tmp1) != 1 or len(tmp2) != 1:
            return "No"
    return "Yes"
print(main())

Submission status: Accepted

Solution code:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)

#n = ip()                                     #入力整数1つ
#n,m= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
## a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#k = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(h)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
a = [[int(i) for i in input().split()] for k in range(3)]
for i in range(3):
    m = min(a[i])
    for k in range(3):
        a[i][k]-=m
for i in range(3):
    if not(a[0][i] == a[1][i] and a[1][i] == a[2][i]) :j(0)
j(1)

Submission status: Accepted

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

Submission status: Accepted

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

# a1を0と仮定して b1,b2,b3 の値を求める
for i in range(3):
    b[i] = c_table[0][i]
# b1の値から逆算して a1,a2,a3 の値を求める
for i in range(3):
    a[i] = c_table[i][0]-b[0]

for i in range(3):
    for j in range(3):
        # 成立しないケースがある場合
        if a[i]+b[j] != c_table[i][j]:
            print('No')
            exit()
print('Yes')

Submission status: Accepted

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

is_true = [0, 0]
for i in range(-100, 101):
    row = [v + i for v in c1]
    if row == c2:
        is_true[0] = 1
    if row == c3:
        is_true[1] = 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from numpy import*
x=array([list(map(int,input().split()))for i in range(3)])
for i in range(3):
    if sum(x[i]-x[i-1])%3 or sum(x[:,i]-x[:,i-1])%3:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

for i in range(2):
    for j in range(i+1, 3):
        if c[i][j] + c[j][i] != c[i][i] + c[j][j]:
            print('No')
            exit()

print('Yes')

Submission status: Accepted

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

if c[0][0]-c[0][1] != c[1][0]-c[1][1] or c[1][0]-c[1][1] != c[2][0]-c[2][1] or c[0][1]-c[0][2] != c[1][1]-c[1][2] or c[1][1]-c[1][2] != c[2][1]-c[2][2]:
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

Sum = 0
for i in c:
    Sum += sum(i)

if Sum % 3:
    print('No')
else:
    if c[0][0]-c[0][1] != c[1][0]-c[1][1] or c[1][0]-c[1][1] != c[2][0]-c[2][1] or c[0][1]-c[0][2] != c[1][1]-c[1][2] or c[1][1]-c[1][2] != c[2][1]-c[2][2]:
        print("No")
    else:
        print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

if __name__ == '__main__':
    rows = []
    for i in range(3):
        rows.append([int(i) for i in input().split()])
    mat = np.matrix(rows)

    upper_a = [mat[i, :].max() for i in range(3)]
    upper_b = [mat[:, i].max() for i in range(3)]

    # print(upper_a)
    # print(upper_b)

    for a1 in range(upper_a[0]+1):
        bs = [v - a1 for v in mat[0, :].tolist()[0]]
        # print(bs)
        for a2 in range(upper_a[1]+1):
            vals = [a2 + b for b in bs]
            # print(vals)
            if vals == mat[1, :].tolist()[0]:
                for a3 in range(upper_a[2]+1):
                    vals = [a3 + b for b in bs]
                    if vals == mat[2, :].tolist()[0]:
                        print('Yes')
                        exit(0)

    print('No')

Submission status: Accepted

Solution code:
m=[list(map(int,input().split()))for i in range(3)]
ans=0
if m[0][0]-m[1][0]!=m[0][1]-m[1][1]:
  ans=1
if m[0][0]-m[1][0]!=m[0][2]-m[1][2]:
  ans=1
if m[0][0]-m[2][0]!=m[0][1]-m[2][1]:
  ans=1
if m[0][0]-m[2][0]!=m[0][2]-m[2][2]:
  ans=1
if m[0][0]-m[0][1]!=m[1][0]-m[1][1]:
  ans=1
if m[0][0]-m[0][1]!=m[2][0]-m[2][1]:
  ans=1
if m[0][0]-m[0][2]!=m[1][0]-m[1][2]:
  ans=1
if m[0][0]-m[0][2]!=m[2][0]-m[2][2]:
  ans=1
print("YNeos"[ans::2])

Submission status: Accepted

Solution code:
C1=list(map(int,input().split()))
C2=list(map(int,input().split()))
C3=list(map(int,input().split()))

a=[0,0,0]
b=[0,0,0]
for i in range(100):
    a[0] = i
    b[0] = C1[0] - a[0]
    b[1] = C1[1] - a[0]
    b[2] = C1[2] - a[0]
    a[1] = C2[0] - b[0]
    a[2] = C3[0] - b[0]

    if a[1]+b[1]==C2[1] and a[1]+b[2]==C2[2] and a[2]+b[1]==C3[1] and a[2]+b[2]==C3[2]:
        print("Yes")
        exit()
print("No")

Submission status: Accepted

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

ans = True
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]:
        pass
    else:
        ans = False
for j in range(2):
    if c[j][0] - c[j][0] == c[j][1] - c[j][1] == c[j][2] - c[j][2]:
        pass
    else:
        ans = False
if ans:
    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())

b1=c11
b2=c12
b3=c13
a2=c21-b1
a3=c31-b1
if c22==a2+b2 and c23==a2+b3 and c32==a3+b2 and c33==a3+b3:
    print("Yes")
else:   
    print("No")

Submission status: Accepted

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

ans = "Yes"

for i in range(1,3):
    a = c[0][0] - c[0][i]
    if c[1][0] - a != c[1][i] or c[2][0] - a != c[2][i]:
        ans = "No"
for i in range(1,3):
    a = c[0][0] - c[i][0]
    if c[0][1] - a != c[i][1] or c[0][2] - a != c[i][2]:
        ans = "No"
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

diff = c[0][2] - c[2][2]
c[0][1] -= diff
c[0][0] -= diff

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

Submission status: Accepted

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

matrix = sorted(matrix)
for i in range(1, 3):
    diff = matrix[i][0] - matrix[0][0]
    for j in range(3):
        if matrix[i][j] != matrix[0][j] + diff:
            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()))

C = [C1, C2, C3]
A = [0] * 3
B = [0] * 3

B = C1
A[1] = C2[0] - B[0]
A[2] = C3[0] - B[0]
flg = True
for i, a in enumerate(A):
    for j, b in enumerate(B):
        if C[i][j] != a + b:
            flg = False

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

Submission status: Accepted

Solution code:
def main():
    C1n = list(map(int, input().split()))
    C2n = list(map(int, input().split()))
    C3n = list(map(int, input().split()))

    C = [C1n, C2n, C3n]

    a_s = [0]
    b_s = [C[0][0], C[0][1],C[0][2]]

    a_s.append(C[1][0] - b_s[0])
    a_s.append(C[2][0] - b_s[0])

    for i, a_i in enumerate(a_s):
        for j, b_j in enumerate(b_s):
            if not ((a_i + b_j) == C[i][j]):
                print("No")
                return 

    print("Yes")
      
main()

Submission status: Accepted

Solution code:
def main():
    C1n = list(map(int, input().split()))
    C2n = list(map(int, input().split()))
    C3n = list(map(int, input().split()))

    C = [C1n, C2n, C3n]

    for i in range(3):
        for j in range(3):
            if (not (C[i][j] - C[(i+1)%2][j]) == (C[i][(j+1)%2] - C[(i+1)%2][(j+1)%2])) or (not (C[i][j] - C[i][(j+1)%2]) == (C[(i+1)%2][j] - C[(i+1)%2][(j+1)%2])):
                print("No")
                return

    print("Yes")

main()

Submission status: Accepted

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

diff_list_x=[]
diff_list_y=[]
for i in range(3):
	diff_list_x.append([c[i][0]-c[i][1],c[i][1]-c[i][2]])
for i in range(3):
	diff_list_y.append([c[0][i]-c[1][i],c[1][i]-c[2][i]])

if diff_list_x[0]==diff_list_x[1]==diff_list_x[2] and diff_list_y[0]==diff_list_y[1]==diff_list_y[2]:
	print "Yes"
else:
	print "No"

Submission status: Accepted

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

flag = 'No'
for i in range(c1[0] + 1):
    a1 = i
    b1 = c1[0] - a1
    b2 = c1[1] - a1
    b3 = c1[2] - a1
    a2 = c2[0] - b1
    a3 = c3[0] - b1

    c22 = a2 + b2
    c23 = a2 + b3
    c32 = a3 + b2
    c33 = a3 + b3

    if (c2[1] - c22) ** 2 + (c2[2] - c23) ** 2 + (c3[1] - c32) ** 2 + (c3[2] - c33) ** 2 == 0:
         flag = 'Yes'
print(flag)

Submission status: Accepted

Solution code:
c1 = list(map(int, input().rstrip().split()))
c2 = list(map(int, input().rstrip().split()))
c3 = list(map(int, input().rstrip().split()))
answer = 'No'
#a1を定めればa2,a3,b1,b2,b3は芋づる式に求まる
for i in range(101):
    a1 = i
    b1 = c1[0] - a1
    b2 = c1[1] - a1
    b3 = c1[2] - a1
    a2 = c2[0] - b1
    a3 = c3[0] - b1
    c2_2 = a2 + b2
    c2_3 = a2 + b3
    c3_2 = a3 + b2
    c3_3 = a3 + b3
    if c2_2 == c2[1] and c2_3 == c2[2] and c3_2 == c3[1] and c3_3 == c3[2]:
        answer = 'Yes'
        break
print(answer)

Submission status: Accepted

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

for i in range(2):
  for j in range(2):
    if c[i][j]+c[i+1][j+1] == c[i+1][j]+c[i][j+1]:
      check += 1
if c[0][0]+c[2][2] == c[0][2]+c[2][0]:
  check += 1
      
if check == 5:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
c=[map(int, raw_input().split()) for i in range(3)]
def C(i,j):return c[i-1][j-1]
if C(1,1)-C(1,2) == C(3,1)-C(3,2) == C(2,1)-C(2,2) and C(1,2)-C(1,3)==C(2,2)-C(2,3)==C(3,2)-C(3,3):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
C = [0]*3
flg = True
for i in range(3):
  C[i] = list(map(int, input().split()))
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]):
      flg = False
for i in range(2):
  for j in range(2):
    if(C[i][j] -C[i+1][j] != C[i][j+1] -C[i+1][j+1]):
      flg = False
print("Yes" if flg else "No")

Submission status: Accepted

Solution code:
C = [0]*3
C1 = [[0]*2]*3
C2 = [[0]*3]*2
flg = False
for i in range(3):
  C[i] = list(map(int, input().split()))
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]):
      flg = True
for i in range(2):
  for j in range(2):
    if(C[i][j] -C[i+1][j] != C[i][j+1] -C[i+1][j+1]):
      flg = True
print("No" if flg else "Yes")

Submission status: Accepted

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

judge = 0 #0:不可,1:可
for i in range(max_c+1):
  a1 = i #a1のみ決めて後は全探索
  b1,b2,b3 = C[0][0]-a1,C[0][1]-a1,C[0][2]-a1
  if( ((C[1][0]-b1)==(C[1][1]-b2))and((C[1][0]-b1)==(C[1][2]-b3)) ):#a2
    if( ((C[2][0]-b1)==(C[2][1]-b2))and((C[2][0]-b1)==(C[2][2]-b3)) ):#a3
       judge = 1
       break

if(judge == 0): print('No')
else: 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()))

t = True
if not(c1[0]-c2[0] == c1[1]-c2[1] == c1[2]-c2[2]):
  t = False
if not(c1[0]-c3[0] == c1[1]-c3[1] == c1[2]-c3[2]):
  t = False

if not(c1[0]-c1[1] == c2[0]-c2[1] == c3[0]-c3[1]):
  t = False
if not(c1[0]-c1[2] == c2[0]-c2[2] == c3[0]-c3[2]):
  t = False

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

Submission status: Accepted

Solution code:
a=[list(map(int,input().split()))for _ in range(3)]
for i in range(2):
  if not a[0][i]-a[0][i+1]==a[1][i]-a[1][i+1]==a[2][i]-a[2][i+1]:print("No");exit()
for i in range(2):
  if not a[i][0]-a[i+1][0]==a[i][1]-a[i+1][1]==a[i][2]-a[i+1][2]:print("No");exit()
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

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

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

ans = True

for i in range(3):
    for j in range(3):
        if c[i][j] != a[i] + b[j]:
            ans = False
            break

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

Submission status: Accepted

Solution code:
c = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

for i in range(0, 3):
    c[i] = [int(j) for j in input().split(" ")]

f = True
for i in range(0, 2):
    f = f and c[i][0] - c[i][1] == c[i + 1][0] - c[i + 1][1]
    f = f and c[i][1] - c[i][2] == c[i + 1][1] - c[i + 1][2]

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

# print(glid)
a = [0] * 3
b = [0] * 3
for i in range(100):
    a[0] = i
    for j in range(N):
        b[j] = glid[0][j] - a[0]

    for j in range(1, N):
        a[j] = glid[j][0] - b[0]

f = True
for i in range(N):
    for j in range(N):
        if glid[i][j] != a[i] + b[j]:
            f = False
print('Yes' if f else 'No')

Submission status: Accepted

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

judge = 0
if a[0][1] - a[1][1] == a[0][2] - a[1][2] == a[0][0] - a[1][0]:
	if a[1][1] - a[2][1] == a[1][2] - a[2][2] == a[1][0] - a[2][0]:
		if a[1][0] - a[1][1] == a[2][0] - a[2][1] == a[0][0] - a[0][1]:
			if a[1][1] - a[1][2] == a[2][1] - a[2][2] == a[0][1] - a[0][2]:
				judge = 1

if judge == 0:
	print("No")
else:
	print("Yes")

Submission status: Accepted

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

for i in range(3):
  while not 0 in c[:,i]:
    c[:,i] -= 1
    
for i in range(3):
  while not 0 in c[i,:]:
    c[i,:] -= 1

if np.all(c==0):
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

if c3[0]-c3[1] == c2[0]-c2[1] and c2[0]-c2[1] == c1[0]-c1[1]:
    if c3[1]-c3[2] == c2[1]-c2[2]  and c2[1]-c2[2] == c1[1]-c1[2]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
C = [a1, a2, a3]
a1 = 0
b1 = C[0][0]
b2 = C[0][1]
b3 = C[0][2]
a2 = C[1][1] - b2
a3 = C[2][2] - b3
A = [a1, a2, a3]
B = [b1, b2, b3]
for i in range(3):
    for j in range(3):
        if C[i][j] == A[i] + B[j]:
            continue
        else:
            print("No")
            exit()
print("Yes")

Submission status: Accepted

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

def isCorrect():
    if not (c11 - c21 == c12 - c22 == c13 - c23):
        return "No"
    if not (c11 - c31 == c12 - c32 == c13 - c33):
        return "No"
    if not (c11 - c12 == c21 - c22 == c31 - c32):
        return "No"
    if not (c11 - c13 == c21 - c23 == c31 - c33):
        return "No"
    return "Yes"
 
print(isCorrect())

Submission status: Accepted

Solution code:
import sys
c=[[int(i) for i in l.split()] for l in sys.stdin]
for i in range(2):
  stack=c[i][0]-c[i+1][0]
  for j in range(3):
    if stack!=c[i][j]-c[i+1][j]:
      print('No')
      exit()
for i in range(2):
  stack=c[0][i]-c[0][i+1]
  for j in range(3):
    if stack!=c[j][i]-c[j][i+1]:
      print('No')
      exit()
print('Yes')

Submission status: Accepted

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

for b1 in range(0, 101):
    for b2 in range(0, 101):
        for b3 in range(0, 101):
            if (c11 - b1 == c12 - b2 == c13 - b3) and (c21 - b1 == c22 - b2 == c23 - b3) and (c31 - b1 == c32 - b2 == c33 - b3):
                print('Yes')
                exit()

print('No')