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

D = [[] for _ in range(4)]
for i in range(2):
    for j in range(3):
        D[i].append(C[i+1][j] - C[i][j])
        D[i+2].append(C[j][i+1] - C[j][i])

for d in D:
    if len(set(d)) != 1:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
C_grid = [list(map(int, input().split())) for i in range(3)]
a1, a2, a3 = C_grid[0][1] - C_grid[0][0], C_grid[0][2] - C_grid[0][1], C_grid[0][0] - C_grid[0][2]
for i in range(1, 3):
    gyo = C_grid[i]
    k1, k2, k3 = gyo[1] - gyo[0], gyo[2] - gyo[1], gyo[0] - gyo[2]
    if a1 == k1 and a2 == k2 and a3 == k3:
        continue
    else:
        print('No')
        exit(0)

a1, a2, a3 = C_grid[1][0] - C_grid[0][0], C_grid[2][0] - C_grid[1][0], C_grid[0][0] - C_grid[2][0]
for i in range(1, 3):
    k1, k2, k3 = C_grid[1][i] - C_grid[0][i], C_grid[2][i] - C_grid[1][i], C_grid[0][i] - C_grid[2][i]
    if a1 == k1 and a2 == k2 and a3 == k3:
        continue
    else:
        print('No')
        exit(0)
print('Yes')

Submission status: Accepted

Solution code:
[(a,b,c),(d,e,f),(g,h,i)] = [map(int,input().split()) for i in range(3)]

if a-b==d-e==g-h and b-c==e-f==h-i:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
[a,b,c]=[int(i) for i in input().split()]
[d,e,f]=[int(j) for j in input().split()]
[g,h,i]=[int(k) for k in input().split()]
t=0
if d-a == e-b and e-b == f-c:
  t+=1
if g-d == h-e and h-e == i-f:
  t+=1
if b-a == e-d and e-d == h-g:
  t+=1
if c-b == f-e and f-e == i-h:
  t+=1
if t== 4:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
import numpy as np
c1 = list(map(int,input().split()))
A = np.array(c1)
c1 = list(map(int,input().split()))
B = np.array(c1)
c1 = list(map(int,input().split()))
C = np.array(c1)

D = A-B 
D1 = list(D)
D1 = set(D1)
if len(D1) == 1:
    pass 
else:
    print('No')
    exit()

E = B-C
E1 = list(E)
E1 = set(E1) 
if len(E1)== 1:
    print('Yes') 
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

j1 = c[0][0] - c[0][1]
j2 = c[0][1] - c[0][2]
for i in range(1, 3):
    _j1 = c[i][0] - c[i][1]
    _j2 = c[i][1] - c[i][2]
    if j1 == _j1 and j2 == _j2:
        continue
    print("No")
    break
else:
    print("Yes")

Submission status: Accepted

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

if a[0] - b[0] == a[1] - b[1] == a[2] - b[2]:
    if  b[0] - c[0] == b[1] - c[1] == b[2] - c[2]:
        print("Yes")
        exit()
    else:
        pass

print("No")

Submission status: Accepted

Solution code:
c = [list(map(int, input().split())) for i in range(3)]
x = c[0][2] - c[0][1]
y = c[0][1] - c[0][0]
ans = 'Yes'
for i in range(1, 3):
  if c[i][2] - c[i][1] != x or c[i][1] - c[i][0] != y:
    ans = "No"
    break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
c = [[int(cn) for cn in input().split()] for _ in range(3)]
max_val = max(c[0])
ans = 'No'
for a1 in range(max_val + 1):
  b = [c[0][i] - a1 for i in range(3)]
  correct = True
  for i in range(2):
    ai_cand = []
    for j in range(3):
      cand = c[i + 1][j] - b[j]
      correct = cand >= 0
      if correct:
        ai_cand.append(cand)
      else:
        break
    correct = correct and (ai_cand[0] == ai_cand[1] and ai_cand[1] == ai_cand[2])
    if not correct:
      break
  if correct:
    ans = 'Yes'
    break
print(ans)

Submission status: Accepted

Solution code:
c = [[int(cn) for cn in input().split()] for _ in range(3)]
max_val = max(c[0])
ans = 'No'
for a1 in range(max_val + 1):
  b = [c[0][i] - a1 for i in range(3)]
  correct = True
  for i in range(2):
    ai_cand = []
    for j in range(3):
      cand = c[i + 1][j] - b[j]
      correct = cand >= 0
      if correct:
        ai_cand.append(cand)
      else:
        break
    if correct:
      correct = ai_cand[0] == ai_cand[1] and ai_cand[1] == ai_cand[2]
      if not correct:
        break
    else:
      break
  if correct:
    ans = 'Yes'
    break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
m=lambda:map(int,input().split())
a,b,c=m()
d,e,f=m()
g,h,i=m()
print(['No','Yes'][d-a==e-b==f-c and g-a==h-b==i-c])

Submission status: Accepted

Solution code:
g=[[*map(int,input().split())]for _ in range(3)]
for h in [0,1]:
  for w in [0,1]: 
    if g[h][w]+g[h+1][w+1]!=g[h+1][w]+g[h][w+1]:
      exit(print('No'))
print('Yes')

Submission status: Accepted

Solution code:
c = [list(map(int, input().split())) for i in range(3)]
for i in range(3):
    for j in range(3):
        for k in range(3):
            for l in range(3):
                if c[i][j] + c[k][l] != c[i][l] + c[k][j]:
                    print('No')
                    exit()
print('Yes')

Submission status: Accepted

Solution code:
#
# abc088 c
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1 0 1
2 1 2
1 0 1"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2 2 2
2 1 2
2 2 2"""
        output = """No"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """0 8 8
0 8 8
0 8 8"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """1 8 6
2 9 7
0 7 7"""
        output = """No"""
        self.assertIO(input, output)


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

    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 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")
    else:
        print("No")


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

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

res = 0
ans = 0

for i in range(3):
  res += sum(c[i])
  ans += c[i][i]*3
  
if res == ans:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
import numpy as np
a = np.array(input().split(), dtype='int')
b = np.array(input().split(), dtype='int') - a
c = np.array(input().split(), dtype='int') - a

if np.all(b == b[0]) and np.all(c == c[0]):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            b1 = c[0] - a1
            b2 = c[1] - a1
            b3 = c[2] - a1
            if c[3] == a2 + b1 and c[4] == a2 + b2 and c[5] == a2 + b3 and c[6] == a3 + b1 and c[7] == a3 + b2 and c[8] == a3 + b3:
                print('Yes')
                exit()
print('No')

Submission status: Accepted

Solution code:
def main():
	c = []
	
	for _ 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]

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

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

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

  
if __name__ == "__main__":
  	main()

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

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

a =[0]*3
b =[0]*3

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

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

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

Submission status: Accepted

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

# a1=0と仮定すると、b1=C[0][0], b2=C[0][1], b3=C[0][2]
# a2=C[1][0]-b1=C[1][1]-b2=C[1][2]-b3
# a3=C[2][0]-b1=C[2][1]-b2=C[2][2]-b3

b1, b2, b3 = C[0][0], C[0][1], C[0][2]
if (C[1][0]-b1 == C[1][1]-b2 == C[1][2]-b3) and (C[2][0]-b1 == C[2][1]-b2 == C[2][2]-b3):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import numpy as np
IN = [list(map(int, input().split())) for _ in range(3)]
c = np.array(IN)
column = np.sum(c, axis=0)
row = np.sum(c, axis=1)
S = np.sum(c)
if S%3==0:
    S_ = S//3
    for i in range(S_+1):
        x = i
        y = S_ - x
        row_ = row - y
        column_ = column - x
        if all(col % 3 == 0 for col in column_) and all(ro % 3 == 0 for ro in row_):
            print("Yes")
            break
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
lc = [[int(w) for w in input().split()] for i in range(3)]
cond = True

lb = lc[0]
a2 = lc[1][0]-lb[0]
a3 = lc[2][0]-lb[0]
la = [0, a2, a3]
for i in range(3):
    for j in range(3):
        if lc[i][j] != la[i]+lb[j]:
            cond = False
            break

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

Submission status: Accepted

Solution code:
c = [list(map(int, input().split())) for _ in range(3)]
# print(c)
ians = [c[0][0]-c[0][0], c[0][1]-c[0][0], c[0][2]-c[0][0]]
jans = [c[0][0]-c[0][0], c[1][0]-c[0][0], c[2][0]-c[0][0]]
# print(ians, jans)
ok = True
for i in range(1, 3):
    for j in range(3):
        # print(c[i][j]-c[i][0])
        if ians[j] != c[i][j]-c[i][0]:
            ok = False

for i in range(1, 3):
    for j in range(3):
        # print(c[j][i]-c[i][0])
        if jans[j] != c[j][i]-c[0][i]:
            ok = False

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

Submission status: Accepted

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

for i in range(3):
    minint = min(C[i])
    for j in range(3):
        C[i][j] -= minint

ans = True

for j in range(3):
    t = C[0][j]
    for i in range(3):
        if t != C[i][j]:
            ans = False
            break

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

Submission status: Accepted

Solution code:
import sys
c=[list(map(int,l.split())) for l in sys.stdin.read().splitlines()]
for i in range(2):
  c[2-i]=[x-y for x, y in zip(c[2-i],c[1-i])]
for i in range(2):
  for j in range(3):
    c[j][2-i]-=c[j][1-i]

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

Submission status: Accepted

Solution code:
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	#b , c = tin()
	#s = input()
	vl = [lin() for _ in range(3)]
	for f, t in [(0,1), (1,2), (2,0)]:
		is_same = set()
		for i in range(3):
			is_same.add(vl[f][i] - vl[t][i])
		if len(is_same) != 1:
			return 'No'
		
	for f, t in [(0,1), (1,2), (2,0)]:
		is_same = set()
		for i in range(3):
			is_same.add(vl[i][f] - vl[i][t])
		if len(is_same) != 1:
			return 'No'
	return 'Yes'
	
			
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

# a1 = 0と仮定して他を調整する
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:
vals = []
for line in range(3):
  s = input().split()
  val = []
  for v in s:
    val.append(int(v))
  vals.append(val)

info = True

a = [0,]
b = vals[0]
a.append(vals[1][0]-b[0])
a.append(vals[2][0]-b[0])

for i in range(3):
  for j in range(3):
    if vals[i][j] != a[i] + b[j]:
      info = False
print('Yes' if info else 'No')

Submission status: Accepted

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

a1 = 0
b1 = c[0][0]

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

b2 = c[0][1]
b3 = c[0][2]

A = [[a1,a1,a1],[a2,a2,a2],[a3,a3,a3]]
B = [[b1,b2,b3],[b1,b2,b3],[b1,b2,b3]]

C = c

ans = "Yes"

for x in range(3):
  for y in range(3):
    if A[x][y] + B[x][y] != C[x][y]:
      ans = "No"
      break
print(ans)

Submission status: Accepted

Solution code:
c=[list(map(int, input().split())) for i in range(3)]
if (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:
def solve():
    import sys
    s = list(map(int, sys.stdin.read().split()))
    x, y, z = s[0] + s[4] + s[8], s[1] + s[5] + s[6], s[2] + s[3] + s[7]
    if x == y == z:
        print("Yes")
    else:
        print("No")


solve()

Submission status: Accepted

Solution code:
# Problem: https://atcoder.jp/contests/abc088/tasks/abc088_c
# Python 2nd Try

import sys
# from collections import defaultdict
# import heapq,copy
import pprint as pp
# from collections import deque
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


YES = "Yes"
NO  = "No"


def solver(grid):
    result = NO
    # algorithm
    a0 = 0
    b0 = grid[0][0]
    b1 = grid[0][1]
    b2 = grid[0][2]
    a1 = grid[1][0] - b0
    a2 = grid[2][0] - b0
    if a1+b1 == grid[1][1] and a1+b2 == grid[1][2] \
        and a2 + b1 == grid[2][1] and a2+b2 == grid[2][2]:
        result = YES
    return result


if __name__ == "__main__":
    grid_c = [ [0] * 3 for j in range(0, 3)]
    # pp.pprint(grid_c)
    for j in range(0, 3):
        grid_c[j][0], grid_c[j][1], grid_c[j][2] = MI()
    # pp.pprint(grid_c)
    print("{}".format(solver(grid_c)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
c = [list(map(int, input().split())) for _ in range(3)]
flg = True
s = sum(c[0]) % 3
t = sum(c[i][0] for i in range(3)) % 3
for i in range(1, 3):
  if sum(c[i]) % 3 != s:
    flg = False
  if sum(c[j][i] for j in range(3)) % 3 != t:
    flg = False
if flg:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))
A += list(map(int, input().split()))
A += list(map(int, input().split()))
flag=0
for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            b1=A[6]-a1
            b2=A[7]-a1
            b3=A[8]-a1
            if b1<0 or b2<0 or b3<0:
                break
            if a3+b1==A[0] and a3+b2==A[1] and a3+b3==A[2] and a2+b1==A[3] and a2+b2==A[4] and a2+b3==A[5]:
                flag=1
print("Yes" if flag==1 else "No")

Submission status: Accepted

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

flag=1
for i in range(2):
    if not(x[i+1][0]-x[i][0]==x[i+1][1]-x[i][1]==x[i+1][2]-x[i][2]):
        flag = 0
        break
if flag==1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    C = [list(map(int, readline().split())) for _ in range(3)]

    A = [0] * 3
    B = [0] * 3

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

    for i in range(1, 3):
        A[i] = C[i][0] - B[0]

    for i in range(3):
        for j in range(3):
            if C[i][j] != A[i] + B[j]:
                print('No')
                return

    print('Yes')
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    C = [list(map(int, readline().split())) for _ in range(3)]

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

    print('Yes')
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
g = []

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

for i in range(1,3):
    offset = g[i][0] - g[0][0]
    if not ((g[i][1] - g[0][1] == offset) and (g[i][2] - g[0][2] == offset)):
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
def m(a,b):
    n=3
    L=[0]*3
    for i in range(n):
        L[i]=a[i]-b[i]
    return L

def f(L):
    return len(set(L))==1

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

F=True
for i,j in [(0,1),(1,2),(2,0)]:
    F&=f(m(C[i],C[j]))

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

Submission status: Accepted

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

Submission status: Accepted

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

a0=0
b0=c[0][0]-a0
b1=c[0][1]-a0
b2=c[0][2]-a0

a1= c[1][0]-b0
a2= c[2][0]-b0
if a1 == c[1][1]-b1 == c[1][2]-b2\
and a2 == c[2][1]-b1 == c[2][2]-b2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

for a0 in range(101):
  b0=c[0][0]-a0
  b1=c[0][1]-a0
  b2=c[0][2]-a0
  
  a1= c[1][0]-b0
  if a1 != c[1][1]-b1 or a1 != c[1][2]-b2:
    continue
  a2= c[2][0]-b0
  if a2 != c[2][1]-b1 or a2 != c[2][2]-b2:
    continue
  print("Yes")
  exit()
print("No")

Submission status: Accepted

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

a = sum(c[0]) + sum(c[1]) + sum(c[2])
b = c[0][0] + c[1][1] + c[2][2]

print('Yes' if a == 3 * b else 'No')

Submission status: Accepted

Solution code:
mat = [map(int ,raw_input().split()) for _ in range(3)]
def f(m):
	return (m[1] - m[0], m[2] - m[1])
b = True
s =set([])
for l in mat:
	s.add(f(l))
if len(s) >1:
	b = False
s = set([])
for j in range(3):
	c = [mat[i][j] for i in range(3)]
	s.add(f(c))
if len(s) >1:
	b = False
print 'Yes' if b else 'No'

Submission status: Accepted

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

c0 = [c[0][0]-c[0][1], c[0][0]-c[0][2], c[0][1]-c[0][2]]
c1 = [c[1][0]-c[1][1], c[1][0]-c[1][2], c[1][1]-c[1][2]]
c2 = [c[2][0]-c[2][1], c[2][0]-c[2][2], c[2][1]-c[2][2]]

if c0 == c1 == c2:
    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()))
print ("Yes") if c1[0]-c1[1] == c2[0]-c2[1] == c3[0]-c3[1] and c1[1]-c1[2] == c2[1]-c2[2] == c3[1]-c3[2] else print ("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
C = [[int(i) for i in input().split()] for j in range(3)]
a = [sum(C[i]) - sum(C[i-1]) for i in range(3)]
b = [sum([C[j][i] for j in range(3)]) - sum([C[j][i-1] for j in range(3)]) for i in range(3)]
for i in range(3):
    if not (a[i]/3).is_integer() or not (b[i]/3).is_integer():
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

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

d = []
for i in range(3):
  d.append([])
  for j, k in zip([0, 1, 2], [1, 2, 0]):
    d[i].append(c[i][j]-c[i][k])

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

Submission status: Accepted

Solution code:
c=[list(map(int,input().split()))for i in range(3)]
a=[c[0][i]-0 for i in range(3)]
b=[c[i][0]-a[0]for i in range(3)]
d=[[a[i]+b[j] for i in range(3)]for j in range(3)]
print('Yes' if c==d else 'No')

Submission status: Accepted

Solution code:
# Problem: https://atcoder.jp/contests/abc088/tasks/abc088_c
# Python 1st Try

import sys
# from collections import defaultdict
# import heapq,copy
import pprint as pp
# from collections import deque
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
yes = "Yes"
no = "No"


def solver(c_grid):
    result = no
    a_list=[0, c_grid[1][0] - c_grid[0][0], c_grid[2][0] - c_grid[0][0]]
    b_list=[c_grid[0][0], c_grid[0][1], c_grid[0][2]]
    if (c_grid[1][1] == a_list[1] + b_list[1]) and \
        (c_grid[1][2] == a_list[1] + b_list[2]) and \
            ( c_grid[2][1] == a_list[2] + b_list[1]) and \
                ( c_grid[2][2] == a_list[2] + b_list[2]):
                    result = yes
    return result


if __name__ == "__main__":
    c_grid = list()
    for _ in range(3):
        c_grid.append(LI())
    # print("{}".format(c_grid))
    print("{}".format(solver(c_grid)))

Submission status: Accepted

Solution code:
c = [list(map(int,input().split())), 
     list(map(int,input().split())), 
     list(map(int,input().split()))]
if c[0][0]-c[1][0] != c[0][1]-c[1][1] or c[0][1]-c[1][1] != c[0][2]-c[1][2]:
  print('No')
elif c[1][0]-c[2][0] != c[1][1]-c[2][1] or c[1][1]-c[2][1] != c[1][2]-c[2][2]:
  print('No')
else:
  print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
Num = np.zeros((3,3),dtype=int)
Flag = False
for T in range(0,3):
    Num[T,:] = np.array([int(X) for X in input().split()])
for T in range(0,3):
    Num[:,T] -= Num[0,T]
for A2 in range(min(Num[1,:]),max(Num[1,:])+1):
    AB2 = np.array([A2+Num[0,0],A2+Num[0,1],A2+Num[0,2]])
    if np.all(AB2==Num[1,:]):
        for A3 in range(min(Num[2,:]),max(Num[2,:])+1):
            AB3 = np.array([A3+Num[0,0],A3+Num[0,1],A3+Num[0,2]])
            if np.all(AB3==Num[2,:]):
                Flag = True
                break
    if Flag:
        break     
if Flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

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

for i in range(3):
        for j in range(3):
            if c[j][i]-c[(j+1)%3][i] != c[j][(i+1)%3]-c[(j+1)%3][(i+1)%3]:
                ans = False
                break

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

Submission status: Accepted

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

print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

sum = sum(list(itertools.chain.from_iterable(grid)))
if sum % 3 != 0:
    print('No')
    exit()

for i in range(-100,101):
    a1 = i
    b1 = grid[0][0] - a1
    b2 = grid[0][1] - a1
    b3 = grid[0][2] - a1
    a2 = grid[1][0] - b1
    a3 = grid[2][0] - b1
    if a1 + a2 + a3 + b1 + b2 + b3 == sum // 3:
        print('Yes')
        exit()
print('No')

Submission status: Accepted

Solution code:
c = {}
for i in range(3):
  c[i] = list(map(int, input().split()))
tfc = 0
for i in range(101):
  if tfc == 3:
    break
  else:
    tfc = 0
  cx = []
  for j in c.values():
    for k in j:
      cx.append(k)
  if i > max(cx):
    break
  b = []
  for j in range(3):
    b.append(c.get(0)[j] - i)
  for j in range(3):
    p = []
    for k in range(3):
      p.append(c.get(j)[k] - b[k])
    if min(p) == max(p):
      tfc += 1
if tfc == 3:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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

for i in range(3):
    for j in range(3):
        lu = C[i][j]
        for ii in range(3):
            if i == ii:
                continue
            for jj in range(3):
                if j == jj:
                    continue
                rd = C[ii][jj]
                ld = C[ii][j]
                ru = C[i][jj]

                if lu + rd != ld + ru:
                    print('No')
                    exit()
print('Yes')

Submission status: Accepted

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