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:
# coding: utf-8
data=[list(map(int,input().split())) for i in range(3)]
for i in range(101):
    for j in range(101):
        for k in range(101):
            for w in range(3):
                if not (data[0][w]-i==data[1][w]-j==data[2][w]-k):
                    break
            else:
                print('Yes')
                exit()
print('No')

Submission status: Accepted

Solution code:
def info(c):
    b = range(max([max(i) for i in c])+1)
    for i in b:
        for p in b:
            for o in b:
                cnt = 0
                for x in c:
                    if (x[0]-i)==(x[1]-p)and(x[1]-p)==(x[2]-o):
                        cnt += 1
                if cnt == 3:
                    return 'Yes'
    return 'No'
C = [list(map(int, input().split())) for i in range(3)]
print(info(C))

Submission status: Accepted

Solution code:
def info(c):
    b = range(max([max(i) for i in c])+1)
    for i in b:
        for p in b:
            for o in b:
                cnt = 0
                for s in c:
                    if ((s[0]-i) == (s[1]-p)) and ((s[1]-p) == (s[2]-o)):
                        cnt += 1
                if cnt == 3:
                    return 'Yes'
    return 'No'
C = [list(map(int, input().split())) for i in range(3)]
print(info(C))

Submission status: Accepted

Solution code:
flag=0
c11, c12, c13 = map(int, input().split())
b2b1 = c12-c11
b3b1 = c13-c11
c21, c22, c23 = map(int, input().split())
if c22-c21 != b2b1 or c23-c21 != b3b1:
    flag=1
a2a1 = c21-c11
if c22-c12!=a2a1 or c23-c13!=a2a1:
    flag=1
c31, c32, c33 = map(int, input().split())
if c32-c31 != b2b1 or c33-c31 != b3b1:
    flag = 1
a3a1 = c31-c11
if c32-c12 != a3a1 or c33-c13 != a3a1:
    flag = 1

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

#c11 = a1+b1 c12 = a1+b2 c13 = a1+b3
#c21 = a2+b1 C22 = a2+b2 c23 = a2+b3
#c31 = a3+b1 C22 = a3+b2 c23 = a3+b3

Submission status: Accepted

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

else:
    print("No")

Submission status: Accepted

Solution code:
c = [int(i) for i in input().split()]
d = [int(i) for i in input().split()]
e = [int(i) for i in input().split()]
if c[0] - d[0] == c[1] - d[1] == c[2] - d[2] and \
   c[0] - e[0] == c[1] - e[1] == c[2] - e[2]:
    print('Yes')
else:
  print('No')

Submission status: Accepted

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

n = 0

for i in range(2):
    s = A[0][i+1] - A[0][i]
    for j in range(1,3):
        if A[j][i+1] - A[j][i] != s :
            n = 1
for i in range(2):
    s = A[i+1][0] - A[i][0]
    for j in range(1,3):
        if A[i+1][j] - A[i][j] != s :
            n = 1

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

Submission status: Accepted

Solution code:
#ABC088C
C=[]
for _ in range(3):
	C.append(list(map(int,input().split())))
for i in range(3):
	m=min(C[i])
	for j in range(3):
		C[i][j]-=m
for i in range(3):
	if C[0][i]!=C[1][i] or C[1][i]!=C[2][i]:
		print('No')
		exit()
print('Yes')

Submission status: Accepted

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

A = x[0][1]-x[0][0]
B = x[1][1]-x[1][0]
C = x[2][1]-x[2][0]
D = x[0][2]-x[0][1]
E = x[1][2]-x[1][1]
F = x[2][2]-x[2][1]
G = x[1][0]-x[0][0]
H = x[1][1]-x[0][1]
I = x[1][2]-x[0][2]
J = x[2][0]-x[1][0]
K = x[2][1]-x[1][1]
L = x[2][2]-x[1][2]
    
cond1 = bool(A == B and B == C)
cond2 = bool(D == E and E == F)
cond3 = bool(G == H and H == I)
cond4 = bool(J == K and K == L)

if cond1 and cond2 and cond3 and cond4:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

b1=c[0][0]
b2=c[0][1]
b3=c[0][2]
a1=0
a2=c[1][0]-c[0][0]
a3=c[2][0]-c[0][0]
print('Yes') if a1+b1==c[0][0] and a1+b2==c[0][1] and a1+b3==c[0][2] and a2+b1==c[1][0] and a2+b2==c[1][1] and a2+b3==c[1][2] and a3+b1==c[2][0] and a3+b2==c[2][1] and a3+b3==c[2][2] else print('No')

Submission status: Accepted

Solution code:
l=[]
for i in range(3):
  x,y,z=map(int,input().split())
  l.append([x,y,z])
c11=l[0][0]
c12=l[0][1]
c13=l[0][2]
c21=l[1][0]
c22=l[1][1]
c23=l[1][2]
c31=l[2][0]
c32=l[2][1]
c33=l[2][2]
if (c21-c11)==(c22-c12)==(c23-c13) and (c31-c11)==(c32-c12)==(c33-c13):
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
import numpy as np
a = np.array([input().split() for i in range(3)]).astype(int)
for i in range(3):
    if sum(a[i-1]-a[i])%3 or sum(a[:,i-1]-a[:,i])%3:

        print("No");exit()
print("Yes")

Submission status: Accepted

Solution code:
ls1 = list(map(int, input().split()))
ls2 = list(map(int, input().split()))
ls3 = list(map(int, input().split()))

ls = [ls1, ls2, ls3]
ans = 0
if ls[1][0]-ls[0][0] == ls[1][1]-ls[0][1] and ls[1][1]-ls[0][1] == ls[1][2]-ls[0][2]:
    ans += 1 
if ls[2][0]-ls[1][0] == ls[2][1]-ls[1][1] and ls[2][1]-ls[1][1] == ls[2][2]-ls[1][2]:
    ans += 1 
if ls[0][1]-ls[0][0] == ls[1][1]-ls[1][0] and ls[1][1] -ls [1][0] == ls[2][1]-ls[2][0]:
    ans += 1 
if ls[0][2]-ls[0][1] == ls[1][2]-ls[1][1] and ls[1][2] -ls [1][1] == ls[2][2]-ls[2][1]:
    ans += 1 

if ans == 4:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import numpy as np
a=np.array([input().split()for i in[0]*3]).astype(int)
for s in range(3):
  if sum(a[s-1]-a[s])%3 or sum(a[:,s-1]-a[:,s])%3:print("No");exit()
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
C = np.array([list(map(int, input().split())) for _ in range(3)])
c12 = C[1]-C[0]
c23 = C[2]-C[1]
if len(set(c12)) == 1 and len(set(c23)) == 1:
    CT = C.T
    ct12 = CT[1]-CT[0]
    ct23 = CT[2]-CT[1]
    if len(set(ct12)) == 1 and len(set(ct23)) == 1:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
C = [list(map(int,input().split())) for _ in range(3)]
#a1 = 0 と固定
b = []
for i in range(3):
  b.append(C[0][i] - 0)
a = []
for i in range(3):
  a.append(C[i][0] - b[0])
ans = "Yes"
for i in range(3):
  for j in range(3):
    if(C[i][j] != a[i] + b[j]):
      ans = "No"
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

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

num = l[0][0]
for i in range(1,3):
	tmp = l[i][0]-num
	for j in range(3):
		l[i][j] -= tmp
for i in range(1,3):
	tmp = l[0][i]-num
	for j in range(3):
		l[j][i] -= tmp

cnt = 0
for i in range(3):
	cnt += l[i].count(num)
if cnt == 9:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a1 = 0
b1 = a[0] - a1
b2 = a[1] - a1
b3 = a[2] - a1
a2 = b[0] - b1
a3 = c[0] - b1
if b[1] == a2 + b2 and b[2] == a2 + b3 and c[1] == a3 + b2 and c[2] == a3 + b3:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a1 = 0
b1 = a[0] - a1
b2 = a[1] - a1
b3 = a[2] - a1
a2 = b[0] - b1
a3 = c[0] - b1
if b[1] == a2 + b2 and b[2] == a2 + b3 and c[1] == a3 + b2 and c[2] == a3 + b3:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
C=[list(map(int,input().split())) for _ in range(3)]
C_t=[list(x) for x in zip(*C)]
C=np.array(C)
C_t=np.array(C_t)
flag=False
if len(set(C[0]-C[1]))==len(set(C[1]-C[2]))==len(set(C[2]-C[0]))==\
    len(set(C_t[0]-C_t[1]))==len(set(C_t[1]-C_t[2]))==len(set(C_t[2]-C_t[0]))==1:
    flag=True
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import numpy as np

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

# check bi
aib1 = np.array([e[0] for e in grid])
aib2 = np.array([e[1] for e in grid])
aib3 = np.array([e[2] for e in grid])

if len(set(aib1 - aib2)) == 1 and len(set(aib2 - aib3)) and len(set(aib3 - aib1)) == 1:
    if len(set(grid[0] - grid[1])) == 1 and len(set(grid[1] - grid[2])) == 1 and len(set(grid[2]-grid[0])) == 1:
        print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

assumption = []
l = [a1+b1,a1+b2,a1+b3]
assumption.append(l)
l = [a2+b1,a2+b2,a2+b3]
assumption.append(l)
l = [a3+b1,a3+b2,a3+b3]
assumption.append(l)
if assumption == L:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
L = []
f = True
for _ in range(3):
    l =list(map(int, input().split()))
    L.append(l)
for i in range(2):
    cnt = 0
    tmp1 = -1
    for j in range(3):
        if tmp1 !=  L[i+1][j] -L[i][j]:
            cnt += 1
        tmp1 = L[i+1][j] -L[i][j]
    if cnt > 1:
        f = False

for i in range(2):
    cnt = 0
    tmp1 = -1
    for j in range(3):
        if tmp1 !=  L[j][i+1] -L[j][i]:
            cnt += 1
        tmp1 = L[j][i+1] -L[j][i]
    if cnt > 1:
        f = False

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

Submission status: Accepted

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

b = [0]*3
for i in range(3):
  b[i] = C[0][i]-0
a = [0]*3
for i in range(3):
  a[i] = C[i][0] - b[0]
ans = "Yes"
for i in range(3):
  for j in range(3):
    if(C[i][j] != a[i] + b[j]):
      ans = "No"
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Feb  9 06:50:02 2019

@author: shinjisu
"""


def getIntList(): return [int(x) for x in input().split()]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def db(x):
    global debug
    if debug:
        print(x)


def solve():
    if c[1][0] - c[0][0] != c[1][1] - c[0][1] or \
        c[1][0] - c[0][0] != c[1][2] - c[0][2]:
        return False
    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]:
        return False
    return True


debug = False
c = getIntMat(3)
db(c)
if solve():
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
#!/mnt/c/Users/moiki/bash/env/bin/python

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


b = [False, False, False, False]

if len( list( filter(lambda x: x==(c[1][0] - c[0][0]), [ c[1][j]  - c[0][j] for j in range(3)]))) == 3:
    # print(list( filter(lambda x: x==(c[1][0] - c[0][0]), [ c[1][j]  - c[0][j] for j in range(3)])))
    b[0] = True
if len( list( filter(lambda x: x==(c[2][0] - c[1][0]), [ c[2][j]  - c[1][j] for j in range(3)]))) == 3:
    b[1] = True
if len( list( filter(lambda x: x==(c[0][0] - c[0][1]), [ c[i][0]  - c[i][1] for i in range(3)]))) == 3:
    b[2] = True
if len( list( filter(lambda x: x==(c[0][2] - c[0][1]), [ c[i][2]  - c[i][1] for i in range(3)]))) == 3:
    b[3] = True

if len( list(filter(lambda x: x, b))) == 4:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
c = [tuple(map(int, input().split())) for _ in range(3)]
Accepted = {(c[0][0]+k, c[0][1]+k, c[0][2]+k) for k in range(-100, 101)}
print('Yes' if c[1] in Accepted and c[2] in Accepted else 'No')

Submission status: Accepted

Solution code:
up = list(map(int, input().split()))
mid = list(map(int, input().split()))
down = list(map(int, input().split()))

flag1 = 0
flag2 = 0
check = [0, 0, 0]

for i in range(-100, 101, 1):
    for j in range(3):
        check[j] = up[j] + i
    if check == mid:
        flag1 = 1
    if check == down:
        flag2 = 1

if flag1 == 1 & flag2 == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

sum_status = 0
sum_dig = 0
for h in range(3):
    for w in range(3):
        sum_status += status[h][w]
        if h == w:
            sum_dig += status[h][w]

if sum_dig*3 == sum_status:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
C = []
SUM = 0
for i in range(3):
    temp = input().split(" ")
    temp = [int(i) for i in temp]
    C.append(temp)
count = 0
for i in range(101):
    a1 = i
    b1 = C[0][0] - a1
    b2 = C[0][1] - a1
    b3 = C[0][2] - a1
    a2 = C[1][0] - b1
    a3 = C[2][0] - b1
    a = [a1,a2,a3]
    b = [b1,b2,b3]
    #print(a,b)
    for j in range(3):
        for k in range(3):
            judge = a[j] + b[k]
            if judge == C[j][k]:
                count += 1
    if count == 9:
        print("Yes")
        break

if count != 9:
	print("No")

Submission status: Accepted

Solution code:
# input
c1 = [int(i) for i in input().split()]
c2 = [int(i) for i in input().split()]
c3 = [int(i) for i in input().split()]

#値の異なる行を探す
flag = 0

'''
if c1[0] == c1[1] and c1[0] == c1[2]:
    flag = 1
    
if flag == 0 and c2[0] == c2[1] and c2[0] == c2[2]:
    flag = 2
    
if c3[0] == c3[1] and c3[0] == c3[2]:
    flag = 3
'''
    
for i in range(0,c1[0]+1):
        a1 = c1[0] - i
        a2 = c2[0] - i
        a3 = c3[0] - i
        b2 = c1[1] - a1
        if b2 + a2 == c2[1] and b2 + a3 == c3[1]:
           b3 = c1[2] - a1
           if b3 + a2 == c2[2] and b3 + a3 == c3[2]:
               print('Yes')
               flag = 1
               break
               
if flag == 0:
    print('No')

Submission status: Accepted

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

def validate(a, b, c):
    for i in range(3):
        for j in range(3):
            if c[i][j] != a[i] + b[j]:
                return False
    return True

found = False
min_b1 = min(c[0][0], c[1][0], c[2][0])
for b1 in range(min_b1 + 1):
    a = [c[0][0] - b1, c[1][0] - b1, c[2][0] - b1]
    b2s = [c[0][1] - a[0], c[1][1] - a[1], c[2][1] - a[2]]
    if b2s[0] != b2s[1] or b2s[0] != b2s[2]:
        continue
    b3s = [c[0][2] - a[0], c[1][2] - a[1], c[2][2] - a[2]]
    if b3s[0] != b3s[1] or b3s[0] != b3s[2]:
        continue
    b = [b1, b2s[0], b3s[0]]
    if not validate(a, b, c):
        continue
    found = True
    break

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

def main():
    rows = []
    for i in range(3):
        row = list(map(int, input().split()))
        rows.append(row)

    for i in range(2):
        if not rows[i][0] - rows[i + 1][0] == rows[i][1] - rows[i + 1][1] == rows[i][2] - rows[i + 1][2]:
            return False
    for j in range(2):
        if not rows[0][j] - rows[0][j + 1] == rows[1][j] - rows[1][j + 1] == rows[2][j] - rows[2][j + 1]:
            return False
    return True

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

Submission status: Accepted

Solution code:
import numpy as np
arr = np.zeros((3, 3), dtype=int)
for i in range(3):
    arr[i, 0], arr[i, 1], arr[i, 2] = list(map(int, input().split()))

ans = True
if np.any(arr[0] - arr[0, 0] != arr[1] - arr[1, 0]):
    ans = ans & False
if np.any(arr[0] - arr[0, 0] != arr[2] - arr[2, 0]):
    ans = ans & False
if np.any(arr[:, 0] - arr[0, 0] != arr[:, 1] - arr[0, 1]):
    ans = ans & False
if np.any(arr[:, 0] - arr[0, 0] != arr[:, 2] - arr[0, 2]):
    ans = ans & False

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

Submission status: Accepted

Solution code:
c = []
for i in range(3):
    t = list(map(int, input().split()))
    c.append(t)
for i in range(1,3):
    if not (c[i][0] - c[0][0] == c[i][1] - c[0][1] == c[i][2] - c[0][2]):
        print('No')
        exit()
print('Yes')

Submission status: Accepted

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

ans = True
if not(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[2][0]-c[2][1] == c[0][0]-c[0][1]):
  ans = False

if not(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] and c[2][1]-c[2][2] == c[0][1]-c[0][2]):
  ans = False
  
if not(c[0][0]-c[0][2] == c[1][0]-c[1][2] and c[1][0]-c[1][2] == c[2][0]-c[2][2] and c[2][0]-c[2][2] == c[0][0]-c[0][2]):
  ans = False
  
if not(c[0][0]-c[1][0] == c[0][1]-c[1][1] and c[0][1]-c[1][1] == c[0][2]-c[1][2] and c[0][2]-c[1][2] == c[0][0]-c[1][0]):
  ans = False

if not(c[0][0]-c[2][0] == c[0][1]-c[2][1] and c[0][1]-c[2][1] == c[0][2]-c[2][2] and c[0][2]-c[2][2] == c[0][0]-c[2][0]):
  ans = False

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
raw_1 = list(map(int, input().split()))
raw_2 = list(map(int, input().split()))
raw_3 = list(map(int, input().split()))
a = [0, 0, 0]
b = [0, 0, 0]

flg = False

while(a[0] <= raw_1[0]):
  for raw in range(len(raw_1)):
    b[raw] = raw_1[raw] - a[0]
  
  a[1] = raw_2[0] - b[0]
  a[2] = raw_3[0] - b[0]  
  # a,b全て求めた

  
  row_list = [raw_1, raw_2, raw_3]
  
  tmp_flg = True
  for num_a in range(3):
    for num_b in range(3):
      if row_list[num_a][num_b] != a[num_a] + b[num_b]:
          tmp_flg = False
          break
  
  if(tmp_flg):
    flg = True
    break
 
  a[0] += 1

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

Submission status: Accepted

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

if all(A[i][j] - A[i][j + 1] == A[i + 1][j] - A[i +1][j + 1] for i in range(2) for j in range(2)):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

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

Submission status: Accepted

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

for a0 in range(0,100+1):
	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 c[1][1] == a1+b1 and c[1][2] == a1+b2 and c[2][1] == a2+b1 and c[2][2] == a2+b2:
	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 c1[0] - c2[0] == c1[1] - c2 [1] == c1[2] - c2[2]:
    if c1[0] - c3[0] == c1[1] - c3[1] == c1[2] - c3[2]:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

Solution code:
# _*_ coding:utf-8 _*_
#  Atcoder_Begineer_Contest088-C
#  TODO https://atcoder.jp/contests/abc088/tasks/abc088_c
#  Along a commentary
def solveProblem(c):
	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
	c11eq = c[1][1] - (a1+b1)
	c12eq = c[1][2] - (a1+b2)
	c21eq = c[2][1] - (a2+b1)
	c22eq = c[2][2] - (a2+b2)
	if (c11eq == 0) and (c12eq == 0) and (c21eq == 0) and (c22eq == 0):
		answer = "Yes"
	else:
		answer = "No"
	return answer

if __name__ == '__main__':
	c=[]
	for _ in range(0,3,+1):
		c.append(list(map(int,input().strip().split(' '))))
	solution = solveProblem(c)
	print("{}".format(solution))

Submission status: Accepted

Solution code:
c = [[int(i) for i in input().split()] for j in range(3)]
f1 = c[1][0]-c[0][0]+c[0][1]==c[1][1]
f2 = c[2][0]-c[0][0]+c[0][1]==c[2][1]
f3 = c[1][0]-c[0][0]+c[0][2]==c[1][2]
f4 = c[2][0]-c[0][0]+c[0][2]==c[2][2]
if all([f1,f2,f3,f4]):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

a = [0,0,0]
b = [0,0,0]
for i in range(2):
    d = [] 
    e = []
    for j in range(3):
        d.append(c[i+1][j] - c[i][j])
        e.append(c[j][i+1] - c[j][i])
    
    if len(set(d)) == 1:
        a[i+1] = d[0]
    else:
        print('No')
        exit()
    
    if len(set(e)) == 1:
        b[i+1] = e[0]
    else:
        print('No')
        exit()

else:
    if min(a) < 0:
        for i in range(3):
            a[i] += abs(min(a))
    if min(b) < 0:
        for i in range(3):
            b[i] += abs(min(b))
    
    cnt = 0
    for i in range(3):
        for j in range(3):
            if (a[i] + b[j]) <= 100:
                cnt += 1
    
    if cnt == 9:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

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

flag = 1

for i in range(1, 3):
    if (c[0][0] - c[0][1] != c[i][0] - c[i][1]):
        flag = 0
    if (c[0][1] - c[0][2] != c[i][1] - c[i][2]):
        flag = 0
    if (c[0][2] - c[0][1] != c[i][2] - c[i][1]):
        flag = 0
if flag == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

from itertools import combinations,product

flag=True
for (i,j),(k,l) in product(combinations(range(3),2),repeat=2):
    flag = flag and (C[k][i]-C[k][j] == C[l][i]-C[l][j])
    flag = flag and (C[i][k]-C[j][k] == C[i][l]-C[j][l])
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
A = []

for i in range(3):
    A.append(list(map(int, input().split())))
ans = 0
for i in range(2):
    if(A[0][i] - A[1][i] == A[0][i+1] - A[1][i+1]):
        if(A[1][i] - A[2][i] == A[1][i+1] - A[2][i+1]):
            continue
        else:
            ans=1
    else:
        ans=1

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

Submission status: Accepted

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

for j in range(1, 3):
    flag = True
    for i in range(1, 3):
        if c[0][j]-c[0][(j+1) % 3] != c[i][j]-c[i][(j+1) % 3]:
            flag = False
            break
    if not flag:
        print('No')
        exit()
for i in range(1, 3):
    flag = True
    for j in range(1, 3):
        if c[i % 3][0]-c[(i+1) % 3][0] != c[i][j]-c[(i+1) % 3][j]:
            flag = False
            break
    if not flag:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
import copy
def a():return input()#s
def ai():return int(input())#a,n or k
def ma():return map(int, input().split())#a,b,c,d or n,k
def ms():return map(str, input().split())#,a,b,c,d
def lma():return list(map(int, input().split()))#x or y
def lms():return list(map(str, input().split()))#x or y
k= []
l = []
for i in range(3):
    k.append(lma())
l = copy.deepcopy(k)
p = copy.deepcopy(k)

for i in range(1,3):
    for j in range(0,3):
        l[i][j] -= k[i-1][j]
        p[j][i] -= k[j][i-1]
if l[1][0]==l[1][1] and l[1][1]==l[1][2] and l[2][0]==l[2][1] and l[2][1]==l[2][2] and p[0][1] == p[1][1] and p[2][1] == p[1][1] and p[2][2] == p[1][2] and p[0][2]==p[1][2]:
    print("Yes")
else:print("No")

Submission status: Accepted

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

for i in range(3):
    a = []
    for j in range(3):
        a.append(s[(i+1)%3][j] - s[i%3][j])

    if a.count(a[0]) == len(a):
        continue
    else:
        print('No')
        exit()
else:
    print('Yes')

Submission status: Accepted

Solution code:
A = []
A.append([int(x) for x in input().split()])
A.append([int(x) for x in input().split()])
A.append([int(x) for x in input().split()])

A2 = []
# print(A)
for r in A:
    mi = min(r)
    A2.append([x - mi for x in r])

a2 = A2[0]
ans = "Yes"
for x in A2:
    if a2 != x:
        ans = "No"

# print(A2)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(3):
    j = (i+1) % 3
    diff1 = grid[i][0] - grid[j][0]
    diff2 = grid[i][1] - grid[j][1]
    diff3 = grid[i][2] - grid[j][2]

    if diff1 != diff2 or diff2 != diff3:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

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

for i in range(3):
    j = (i+1) % 3
    diff1 = grid[i][0] - grid[j][0]
    diff2 = grid[i][1] - grid[j][1]
    diff3 = grid[i][2] - grid[j][2]

    if diff1 != diff2 or diff2 != diff3 or diff1 != diff3:
        print("No")
        exit()

for i in range(3):
    j = (i+1) % 3
    diff1 = grid[0][i] - grid[0][j]
    diff2 = grid[1][i] - grid[1][j]
    diff3 = grid[2][i] - grid[2][j]

    if diff1 != diff2 or diff2 != diff3 or diff1 != diff3:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a1,a2,a3 = map(int, input().split())
b1,b2,b3 = map(int, input().split())
c1,c2,c3 = map(int, input().split())
if (b1 - a1) == (b2 - a2) == (b3 - a3) and (c1 - b1) == (c2 - b2) == (c3 - b3):
  if a2 - a1 == b2 - b1 == c2 - c1 and a3 - a2 == b3 - b2 == c3 - c2:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Accepted

Solution code:
A = [[int(i) for i in input().split()] for i in range(3)]
ans = 'Yes'

for i in range(2):
    if A[i][0] - A[i + 1][0] != A[i][1] - A[i + 1][1]:
        ans = 'No'
        break
    if A[i][1] - A[i + 1][1] != A[i][2] - A[i + 1][2]:
        ans = 'No'
        break
        
print(ans)