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:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(c: "List[List[int]]"):
    for b1 in range(0,101):
        for b2 in range(0,101):
            for b3 in range(0,101):
                for i in range(3):
                    if c[i][0]-b1 == c[i][1]-b2 == c[i][2]-b3:
                        continue
                    else:
                        break
                else:
                    print(YES)
                    return

    print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    c = [[int(next(tokens)) for _ in range(3)] for _ in range(3)]  # type: "List[List[int]]"
    solve(c)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

for j in range(2):
    for i in range(2):
        if C[i+1][j+1]-C[i+1][j]!=C[i][1+j]-C[i][j]:
            print('No')
            sys.exit()

print('Yes')

Submission status: Accepted

Solution code:
a = [list(map(int, input().split())) for i in range(3)]
for i in range(101):
    b1 = a[0][0] - i
    b2 = a[0][1] - i
    b3 = a[0][2] - i
    a1 = i
    a2 = a[1][0] - b1
    a3 = a[2][0] - b1
    A = [a1, a2, a3]
    B = [b1, b2, b3]
    flag = True

    for l in range(3):
        for r in range(3):
            if A[l]<0 or B[r] < 0 or a[l][r]!=A[l]+B[r]:
                flag = False
    if flag:
        print('Yes')
        exit()

print('No')

Submission status: Accepted

Solution code:
def check(a,b):
    for i in range(3):
        diffc[i] = c[i][a]-c[i][b]
        diffr[i] = c[a][i]-c[b][i]
    if diffc[0] != diffc[1] or diffc[1] != diffc[2] or diffr[0] != diffr[1] or diffr[1] != diffr[2]:
        print("No")
        exit()
        

c = [[int(i) for i in input().split()] for i in range(3)]
diffr = [0]*3
diffc = [0]*3
check(0,1)
check(1,2)
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()))
x = min(c1)
y = min(c2)
z = min(c3)
for i in range(3):
  c1[i] -= x
  c2[i] -= y
  c3[i] -= z
print('NYoe s' [c1==c2==c3::2])

Submission status: Accepted

Solution code:
c = []
for i in range(3):
    x = list(map(int,input().split()))
    c.append(x)
check = 0
for i in range(100):
    b1 = c[0][0] - i
    b2 = c[0][1] - i
    b3 = c[0][2] - i
    if (c[0][0] - b1 == c[0][1] - b2 == c[0][2] - b3 and
        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):
        check = 1
        break
if check == 1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

ans = 0
for i in range(101):
    b1 = A[0][0] - i
    b2 = A[0][1] - i
    b3 = A[0][2] - i
    a2_1 = A[1][0] - b1
    a2_2 = A[1][1] - b2
    a2_3 = A[1][2] - b3
    a3_1 = A[2][0] - b1
    a3_2 = A[2][1] - b2
    a3_3 = A[2][2] - b3
    if (a2_1 == a2_2) and (a2_2 == a2_3) and (a2_3 == a2_1) and (a3_1 == a3_2) and (a3_2 == a3_3) and (a3_3 == a3_1):
        ans += 0        
    else:
        ans += 1
if ans != 0:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
import numpy as np

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

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

B = np.array([
    [1,0,0,1,0,0,c[0][0]],
    [1,0,0,0,1,0,c[0][1]],
    [1,0,0,0,0,1,c[0][2]],
    [0,1,0,1,0,0,c[1][0]],
    [0,1,0,0,1,0,c[1][1]],
    [0,1,0,0,0,1,c[1][2]],
    [0,0,1,1,0,0,c[2][0]],
    [0,0,1,0,1,0,c[2][1]],
    [0,0,1,0,0,1,c[2][2]]])

rankA = np.linalg.matrix_rank(A)
rankB = np.linalg.matrix_rank(B)

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

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
g,h,i=map(int,input().split())

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

Submission status: Accepted

Solution code:
import math
import numpy as np
from fractions import gcd
import collections

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

C = np.array(C)

cross1 = C[0][0] + C[1][1] + C[2][2]
cross2 = C[0][2] + C[1][1] + C[2][0]
if(cross1 == cross2 and np.sum(C)/6 == cross1/2):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

a1=0
b1=grid[0][0] - a1
b2=grid[0][1] - a1
b3=grid[0][2] - a1
a21=grid[1][0] - b1
a22=grid[1][1] - b2
a23=grid[1][2] - b3
a31=grid[2][0] - b1
a32=grid[2][1] - b2
a33=grid[2][2] - b3
if a21==a22==a23:
    if a31==a32==a33:
        print('Yes')
        exit()
print('No')

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    c = []
    csum = 0
    for _ in range(3):
        _c = LI()
        csum += sum(_c)
        c.append(_c)

    if c[0][0] + c[1][1] + c[2][2] == csum/3:
        print('Yes')
    else:
        print('No')
main()

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]

# a1を任意に決めるとなし崩し的にa,bが全て出るのであとは全マスでうまくいくか確かめるだけ
f = False
for i in range(C[0][0] + 1):
    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
    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]:
        f = True
        break

if f == True:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys
import numpy as np 

c = np.array(sys.stdin.read().split(), dtype=np.int8).reshape(3, 3)

def main(c):
    c -= c[0]
    c -= c[:, 0][:, None]
    return 'No' if np.count_nonzero(c) else 'Yes'

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

Submission status: Accepted

Solution code:
c = [list(map(int,input().split()))for l in range(3)]
flag=False
for i in range(c[0][0]+1):
    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
    if c[1][1]==a2+b2 and c[1][2]==a2+b3 and c[2][1]==a3+b2 and c[2][2]==a3+b3:
        flag=True
        break
    else:
        continue

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

Submission status: Accepted

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

ans = "Yes"

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

print(ans)

Submission status: Accepted

Solution code:
c = [[int(i) for i in input().split()] for _ in range(3)]
cond = True
cond &= c[0][0] - c[0][1] == c[1][0] - c[1][1] == c[2][0] - c[2][1]
cond &= c[0][1] - c[0][2] == c[1][1] - c[1][2] == c[2][1] - c[2][2]
cond &= c[0][0] - c[1][0] == c[0][1] - c[1][1] == c[0][2] - c[1][2]
cond &= c[1][0] - c[2][0] == c[1][1] - c[2][1] == c[1][2] - c[2][2]
print("Yes" if cond else "No")

Submission status: Accepted

Solution code:
import sys
c_ls = []
for i in range(3):
    c = [int(i) for i in sys.stdin.readline().split()]
    c_ls.append(c)

yoko = [c_ls[0][i+1] - c_ls[0][i] for i in range(2)]
flg = True
for i in range(3):
    flg &= yoko == [c_ls[i][j+1] - c_ls[i][j] for j in range(2)]
print("Yes" if flg else "No")

Submission status: Accepted

Solution code:
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
x = min(c1)
y = min(c2)
z = min(c3)
for i in range(3):
    c1[i] -= x
    c2[i] -= y
    c3[i] -= z
print('NYoe s' [c1 == c2 == c3::2])

Submission status: Accepted

Solution code:
c = [[int(i) for i in input().split()] for _ in range(3)]
b = [0 for _ in range(3)]
ans = 'Yes'
for i in range(3):
    if i == 0:
        for j in range(3):
            b[j] = c[i][j] - c[i][(j+1)%3]
    else:
        for j in range(3):
            if b[j] != c[i][j] - c[i][(j+1)%3]:
                ans = 'No'
                break
        if ans == 'No':
            break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Here your code


n = 3
e = [[int(i) for i in input().split()] for i in range(n)] 
a = []
b = []
#for i in range(101):
a.append(0)
b.append(e[0][0] - a[0])
b.append(e[0][1] - a[0])
b.append(e[0][2] - a[0])
a.append(e[1][0] - b[0])
a.append(e[2][0] - b[0])

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

        
print("Yes")

Submission status: Accepted

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


def sol():
	if (sum(C[0]) - sum(C[1])) % 3 != 0:
		return('No')
	elif (sum(C[1]) - sum(C[2])) % 3 != 0:
		return('No')
	elif (sum(C[2]) - sum(C[0])) % 3 != 0:
		return('No')
	
	elif (C[0][0] + C[1][0] + C[2][0] - (C[0][1] + C[1][1] + C[2][1])) % 3 != 0:
		return('No')
	elif (C[0][1] + C[1][1] + C[2][1] - (C[0][2] + C[1][2] + C[2][2])) % 3 != 0:
		return('No')
	elif (C[0][2] + C[1][2] + C[2][2] - (C[0][0] + C[1][0] + C[2][0])) % 3 != 0:
		return('No')
	else:
		return('Yes')

print(sol())

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
import numpy as np
c = []
for _ in range(3):
    c.append([int(x) for x in input().split()])
c = np.array(c)
c_t = c.T
a = c[1] - c[0]
b = c[2] - c[1]
d = c[2] - c[0]
e = c_t[1] - c_t[0]
f = c_t[2] - c_t[1]
g = c_t[2] - c_t[0]
x = []
x.append(a)
x.append(b)
x.append(d)
x.append(e)
x.append(f)
x.append(g)
x = np.array(x)
for i in x:
    if i[0] != i[1] or i[1] != i[2] or i[2] != i[0]:
        print("No")
        sys.exit()
print("Yes")

Submission status: Accepted

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

ans = "Yes"
for i in range(len(c)):
    mi = min(c[i])
    *c[i], = map(lambda x: x-mi, c[i])


print("Yes" if c[0] == c[1] and c[1] == c[2] else "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())

a1=0
a2=(c12-c11,c22-c21,c32-c31)
a3=(c13-c11,c23-c21,c33-c31)

if len(set(a2))==1 and len(set(a3))==1:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

out='Yes'
a_1=nums[1, :]-nums[0, :]
if a_1[0]!=a_1[1] or a_1[0]!=a_1[2]:
  out='No'
  
a_2=nums[2, :]-nums[1, :]
if a_2[0]!=a_2[1] or a_2[0]!=a_2[2]:
  out='No'
  
b_1=nums[:, 1]-nums[:, 0]
if b_1[0]!=b_1[1] or b_1[0]!=b_1[2]:
  out='No'
  
b_2=nums[:, 2]-nums[:, 1]
if b_2[0]!=b_2[1] or b_2[0]!=b_2[2]:
  out='No'
  
print(out)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

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

Submission status: Accepted

Solution code:
grid = list()
for i in range(3):
    grid.append([int(k) for k in input().split(" ")])


def check_vert():
    for i in range(2):
        diffs = [grid[k][i] - grid[k][i+1]for k in range(3)]
        if not len(set(diffs)) == 1:
            return False
    else:
        return True


def check_hor():
    for i in range(2):
        diffs = [grid[i][k] - grid[i+1][k] for k in range(3)]
        if not len(set(diffs)) == 1:
            return False
    else:
        return True


if check_hor() and check_vert():
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

o = c[0][2] * 2 - c[0][1] - c[0][0]
p = c[1][2] * 2 - c[1][1] - c[1][0]
q = c[2][2] * 2 - c[2][1] - c[2][0]

if x == y == z and o == p == q:
    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[0][1]-c[0][2]] == [c[1][0]-c[1][1],c[1][1]-c[1][2]] == [c[2][0]-c[2][1],c[2][1]-c[2][2]]:
  if [c[0][0]-c[1][0],c[1][0]-c[2][0]] == [c[0][1]-c[1][1],c[1][1]-c[2][1]] == [c[0][2]-c[1][2],c[1][2]-c[2][2]]:
    print('Yes')
    exit()
print('No')

Submission status: Accepted

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

for i in range(101):
        if i > c[0][0]:
                break
        a[0] = i 
        b[0] = c[0][0] - a[0]
        a[1] = c[1][0] - b[0]
        a[2] = c[2][0] - b[0]
        b[1] = c[0][1] - a[0] 
        b[2] = c[0][2] - a[0] 

        flag = 1 
        for i in range(3):
                for j in range(3):
                        if c[i][j] != a[i] + b[j]:
                                flag = 0 
        if flag:
                ans = "Yes"
                break

print(ans)

Submission status: Accepted

Solution code:
d,e,f=[int(i) for i in input().split()]
x,y,z=[int(i) for i in input().split()]
s,t,u=[int(i) for i in input().split()]
b=x-d
c=s-d
if b+e==y and b+f==z and c+e==t and c+f==u:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def che(da):
  for i in range(2):
    for j in range(2):
      if da[i][j] - da[i][j+1] != da[2][j] - da[2][j+1]:
        return False
      if da[i][j] - da[i+1][j] != da[i][2] - da[i+1][2]:
        return False
  return True

da = [list(map(int,input().split())) for i in range(3)]
if che(da):
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
# ABC088 C - Takahashi's Information
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
l = [nl() for i in range(3)]
a1=0
b1=l[0][0]-a1
b2=l[0][1]-a1
b3=l[0][2]-a1
a2=l[1][0]-b1
a3=l[2][0]-b1
a = [a1,a2,a3]
b = [b1,b2,b3]

for i,aa in enumerate(a):
    for j,bb in enumerate(b):
        if l[i][j]!=aa+bb:
            print('No')
            exit()
print('Yes')

Submission status: Accepted

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

Submission status: Accepted

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

count = 0
for j in range(100):
    b1 = []
    a1 = []
    a = j

    for i in range(3):
        b1.append(c[0][i] - a)
        a1.append(c[i][0] - b1[0])

    for i in range(3):
        for j in range(3):
            if a1[i] + b1[j] != c[i][j]:
                count = 1


if count == 1:
    print('No')
else:
    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())
count = 0
if c21 - c11 == c22 - c12 == c23 - c13:
  count += 1
if c31 - c21 == c32 - c22 == c33 - c23:
  count += 1
if c12 - c11 == c22 - c21 == c32 - c31:
  count += 1
if c13 - c12 == c23 - c22 == c33 - c32:
  count += 1
if count == 4:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
c = [[int(i) for i in input().split()] for _ in range(3)]
ans = 'Yes'
if not sum(c[0]) % 3 == sum(c[1]) % 3 == sum(c[2]) % 3:
    ans = 'No'
cc = [0, 0, 0]
for ary in c:
    cc[0] += ary[0]
    cc[1] += ary[1]
    cc[2] += ary[2]
if not cc[0] % 3 == cc[1] % 3 == cc[2] % 3:
    ans = 'No'
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
c = [list(map(int, input().split())) for _ in range(3)]
cross_left = c[0][0] + c[1][1] + c[2][2]
cross_right = c[0][2] + c[1][1] + c[2][0]
total = 0
for i in range(3):
    total += sum(c[i])
if total % 3 == 0 and total // 3 == cross_left and total // 3 == cross_right:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import numpy as np

def main()->None:
    c_1 = list(map(int, input().split()))
    c_2 = list(map(int, input().split()))
    c_3 = list(map(int, input().split()))
    c = np.array([c_1, c_2, c_3],dtype=int)

    a = np.empty(3, dtype=int)
    b = np.empty(3, dtype=int)
    
    a[0] = 0
    range_3 = range(3)
    for j in range_3:
        b[j] = c_1[j] - a[0]
    for i in range(1, 3):
        a[i] = c[i][0] - b[0]

    # 条件通りかどうか判定するのに探索
    good = True
    for i, a_i in enumerate(a):
        for j, b_j in enumerate(b):
            if a_i + b_j != c[i][j]:
                good = False

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
lst = [[int(i) for i in input().split()] for _ in range(3)]
lst1 = [lst[1][i] - lst[0][i] for i in range(3)]
lst2 = [lst[2][i] - lst[0][i] for i in range(3)]
if len(set(lst1)) == 1 and len(set(lst2)) == 1:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
import numpy as np

lst = [[int(i) for i in input().split()] for _ in range(3)]
arr = np.array(lst)
if len(set(arr[1,:] - arr[0,:])) == 1 and len(set(arr[2,:] - arr[0,:])) == 1:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

a = c[1][0] - c[0][0]
b = c[2][0] - c[0][0]
string = "Yes"

for i in range(3):
    x = c[1][i] - c[0][i]
    if x != a:
        string = "No"

    y = c[2][i] - c[0][i]
    if y != b:
        string = "No"

print(string)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
b1,b2,b3=0,0,0
check=0
for i in range(3):
    c1,c2,c3=map(int,input().split())
    if i==0:
        b1,b2,b3=c1,c2,c3
    if i==1:
        if not((c1-b1)==(c2-b2)==(c3-b3)):
            check=1
    if i==2:
        if not((c1-b1)==(c2-b2)==(c3-b3)):
            check=1
print("Yes" if check==0 else "No")

Submission status: Accepted

Solution code:
import sys
if sys.platform == 'ios':
	sys.stdin = open('input_file.txt')

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

ans = 0

for i in range(max(max(c))+1):
	#print(i)
	a0 = i
	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:
		ans = ans +1
		break

print('Yes' if ans !=0 else 'No')

Submission status: Accepted

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

ax=x[0][1]-x[0][0]
bx=x[0][2]-x[0][1]
for i in range(3):
    if ax!=x[i][1]-x[i][0] or bx!=x[i][2]-x[i][1]:
        print("No")
        break
else:
    ay=x[1][0]-x[0][0]
    by=x[2][0]-x[1][0]

    for i in range(3):
        if ay!=x[1][i]-x[0][i] or by!=x[2][i]-x[1][i]:
            print("No")
            break
    else:
        print("Yes")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

[C11, C12, C13] = [int(i) for i in input().split()]
[C21, C22, C23] = [int(i) for i in input().split()]
[C31, C32, C33] = [int(i) for i in input().split()]

b1 = C11
b2 = C12
b3 = C13

# a2が存在する？
flag_a2 = False
if (C21 - b1) == (C22 - b2) and (C21 - b1) == (C23 - b3):
    flag_a2 = True

# a3が存在する？
flag_a3 = False
if (C31 - b1) == (C32 - b2) and (C31 - b1) == (C33 - b3):
    flag_a3 = True

if flag_a2 is True and flag_a3 is True:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
c_one = list(map(int, input().split()))
c_two = list(map(int, input().split()))
c_thr = list(map(int, input().split()))

a_b_ones = [(x, c_one[0]-x) for x in range(c_one[0]+1)]
a_b_twos = [(x, c_two[1]-x) for x in range(c_two[1]+1)]
a_b_thrs = [(x, c_thr[2]-x) for x in range(c_thr[2]+1)]

ans = 'No'

for p in a_b_ones:
    for q in a_b_twos:
        for r in a_b_thrs:
            a1, b1 = p[0], p[1]
            a2, b2 = q[0], q[1]
            a3, b3 = r[0], r[1]
            if (c_one[1] == a1 + b2) and (c_one[2] == a1 + b3) and (c_two[0] == a2 + b1) and (c_two[2] == a2 + b3) and (c_thr[0] == a3 + b1) and (c_thr[1] == a3 + b2):
                ans = 'Yes'
print(ans)

Submission status: Accepted

Solution code:
c = []
for i in range(3):
    C = list(map(int, input().split()))
    c.append(C)
for i in range(3):
    Min = min(c[i])
    for j in range(3):
        c[i][j] -= Min
for i in range(2):
    if c[i] == c[i + 1]:
        pass
    else:
        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()))

ans = True
a1=0
b=[]
for i in range(3):
    b.append(c1[i]-a1)

a2=c2[0]-b[0]
a3=c3[0]-b[0]

for i in range(1,3):
    if a2+b[i] != c2[i] or a3+b[i] != c3[i]:
        ans = False
        break

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

Submission status: Accepted

Solution code:
C=[[int(x) for x in input().split()] for _ in range(3)]
a=[C[0][0],C[0][1],C[0][2]]
b=[0,C[1][0]-C[0][0],C[2][0]-C[0][0]]
hantei= True
for i in range(3):
  for j in range(3):
    if C[i][j]!=a[j]+b[i]:
      hantei = False
print('Yes' if hantei else'No')

Submission status: Accepted

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

for b1 in range(101):
    a = []
    b = []
    a1 = c[0][0] - b1
    if a1 < 0:
        break
    a.append(a1)
    b.append(b1)
    for b2 in range(101):
        a2 = c[1][1] - b2
        if a2 < 0:
            break
        a.append(a2)
        b.append(b2)
        for b3 in range(101):
            a3 = c[2][2] - b3
            if a3 < 0:
                break
            a.append(a3)
            b.append(b3)
            for i in range(3):
                for j in range(3):
                    if a[j] + b[i] != c[i][j]:
                        break
                    if i == 2 and j == 2:
                        print("Yes")
                        exit()
                if a[j] + b[i] != c[i][j]:
                    break
            b.pop()
            a.pop()
        a.pop()
        b.pop()
print("No")

Submission status: Accepted

Solution code:
C = [list(map(int,input().split())) for i in range(3)]
c1,c2,c3 = C[0]
c1,c2,c3 = c1-c2,c2-c3,c3-c2
ans = 'Yes'
for c in C[1:]:
    cc1,cc2,cc3 = c
    cc1,cc2,cc3 = cc1-cc2,cc2-cc3,cc3-cc2
    # print(c1,cc1,c2,cc2,c3,cc3)
    if c1 == cc1 and c2 == cc2 and c3 == cc3:
        pass
    else:
        ans = 'No'
        break

c1,c2,c3 = C[0][0],C[1][0],C[2][0]
c1,c2,c3 = c1-c2,c2-c3,c3-c2
for i in range(1,3):
    cc1,cc2,cc3 = C[0][i],C[1][i],C[2][i]
    cc1,cc2,cc3 = cc1-cc2,cc2-cc3,cc3-cc2
    if c1 == cc1 and c2 == cc2 and c3 == cc3:
        pass
    else:
        ans = 'No'
        break
print(ans)

Submission status: Accepted

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

  
for i in range(101):
  a1 = i
  b1 = c[0][0]-a1
  b2 = c[0][1]-a1
  b3 = c[0][2]-a1
  if c[1][0]-b1 == c[1][1]-b2 == c[1][2]-b3:
    if c[2][0]-b1 == c[2][1]-b2 == c[2][2]-b3:
      print('Yes')
      exit()
print('No')

Submission status: Accepted

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

for _ in range(100):
    a1 = i
    b1 = grid[0][0] - a1
    b2 = grid[0][1] - a1
    b3 = grid[0][2] - a1
    if  grid[1][0] - b1 == grid[1][1] - b2 == grid[1][2] - b3 and grid[2][0] - b1 == grid[2][1] - b2 == grid[2][2] - b3:
        print('Yes')
        exit()
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())

def correct(a1, a2, a3, b1, b2, b3):
  if a1 + b1 != c11:
    return False
  if a2 + b2 != c22:
    return False
  if a3 + b3 != c33:
    return False
  if a1 + b2 != c12:
    return False
  if a1 + b3 != c13:
    return False
  if a2 + b1 != c21:
    return False
  if a2 + b3 != c23:
    return False
  if a3 + b1 != c31:
    return False
  if a3 + b2 != c32:
    return False
  return True

for i in range(c11 + 1):
  a1 = i
  b1 = c11 - i
  a2 = a1 - c11 + c21
  a3 = a1 - c11 + c31
  b2 = b1 - c11 + c12
  b3 = b1 - c11 + c13
  # print(a1, a2, a3, b1, b2, b3)
  if correct(a1, a2, a3, b1, b2, b3):
    print('Yes')
    exit(0)

# for i in range(c11 + 1):
#   for j in range(c22 + 1):
#     for k in range(c33 + 1):
#       a1 = i
#       b1 = c11 - i
#       a2 = j
#       b2 = c22 - j
#       a3 = k
#       b3 = c33 - k
#       if correct(a1, a2, a3, b1, b2, b3):
#         print('Yes')
#         exit(0)

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

def correct():
  if a1 + b2 != c12:
    return False
  if a1 + b3 != c13:
    return False
  if a2 + b1 != c21:
    return False
  if a2 + b3 != c23:
    return False
  if a3 + b1 != c31:
    return False
  if a3 + b2 != c32:
    return False
  return True

for i in range(c11 + 1):
  for j in range(c22 + 1):
    for k in range(c33 + 1):
      a1 = i
      b1 = c11 - i
      a2 = j
      b2 = c22 - j
      a3 = k
      b3 = c33 - k
      if correct():
        print('Yes')
        exit(0)

print('No')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

c = [LIST() for _ in range(3)]

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

Submission status: Accepted

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

max_1st_row = max(c[0])

for a1 in range(max_1st_row + 1):
    b = []

    for col in range(3):
        b.append(c[0][col] - a1)

    a2 = c[1][0] - b[0]

    if c[1][1] != (a2 + b[1]) or c[1][2] != (a2 + b[2]):
        continue

    a3 = c[2][0] - b[0]

    if c[2][1] != (a3 + b[1]) or c[2][2] != (a3 + b[2]):
        continue

    print('Yes')
    exit()

print('No')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import numpy as np
import scipy

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

for i in range(3):
    for j in range(3):
        if C[0][0] - C[0][j] != C[i][0] - C[i][j]:
            print("No")
            exit()
        if C[0][0] - C[i][0] != C[0][j] - C[i][j]:
            print("No")
            exit()
print("Yes")

Submission status: Accepted

Solution code:
C = [list(map(int,input().split())) for i in range(3)]
p=C[0][1]-C[0][0]
q=C[0][2]-C[0][1]
b1,b2,b3 = 0,0,0

for i in range(-200,201):
  b2=i
  b3=q-b2
  b1=b2-p
  if C[0][0]-b1==C[0][1]-b2 and  C[0][0]-b1==C[0][2]-b3:
    if C[1][0]-b1==C[1][1]-b2 and  C[1][0]-b1==C[1][2]-b3:
      if C[2][0]-b1==C[2][1]-b2 and  C[2][0]-b1==C[2][2]-b3:
        print("Yes");exit()
  
print("No")