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 = []
for i in range(3):
    c.append(list(map(int,input().split())))
"""
変数6個で解9個
b1-b2 : c*1-c*2
b2-b3 : c*2-c*3 
b3-b1 : c*3-c*1
a1-a2 : c1*-c2* 
a2-a3 : c2*-c3*
a3-a1 : c3*-c1*
"""

i = 0
flaga12 = True
flaga23 = True 
flaga31 = True
flagb12 = True
flagb23 = True 
flagb31 = True

b12 = c[i][0]-c[i][1]
b23 = c[i][1]-c[i][2]
b31 = c[i][2]-c[i][0]

for i in range(3):
    flagb12 = flagb12 and (b12 == c[i][0]-c[i][1])
    flagb23 = flagb23 and (b23 == c[i][1]-c[i][2])
    flagb31 = flagb31 and (b31 == c[i][2]-c[i][0])
    
j = 0
a12 = c[0][j]-c[1][j]
a23 = c[1][j]-c[2][j]
a31 = c[2][j]-c[0][j]
for i in range(3):
    a12 = c[0][j]-c[1][j]
    a23 = c[1][j]-c[2][j]
    a31 = c[2][j]-c[0][j]
    flaga12 = flaga12 and (a12 == c[0][j]-c[1][j])
    flaga23 = flaga23 and (a23 == c[1][j]-c[2][j])
    flaga31 = flaga31 and (a31 == c[2][j]-c[0][j])

judge = (flaga12 and flaga23 and flaga31 and flagb12 and flagb23 and flagb31)
if judge:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

sa_a=[c[0][0]-c[1][0], c[1][0]-c[2][0]]
sa_b=[c[0][0]-c[0][1], c[0][1]-c[0][2]]
for i in range(2):
    if sa_a[i]!=c[i][i+1]-c[i+1][i+1]:
        print("No")
        quit()
for i in range(2):
    if sa_b[i]!=c[i+1][i]-c[i+1][i+1]:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
c=[list(map(int,input().split())) for _ in range(3)]
b1=c[0][0]
b2=c[0][1]
b3=c[0][2]
a2=c[1][0]-b1
a3=c[2][0]-b1
f=True
if a2+b2!=c[1][1]:f=False
if a2+b3!=c[1][2]:f=False
if a3+b2!=c[2][1]:f=False
if a3+b3!=c[2][2]:f=False
if f:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
c=[]
for i in range(3):
    sub_list=list(map(int,input().split()))
    c.append(sub_list)
a=[0]*3
b=[0]*3
for i in range(101):
    a[0]=i
    b[0]=c[0][0]-i
    b[1]=c[0][1]-i
    b[2]=c[0][2]-i
    a[1]=c[1][0]-b[0]
    a[2]=c[2][0]-b[0]
    count=0
    for j in a:
        if not 0<=j<=100:
            count=1
    for j in b:
        if not 0<=j<=100:
            count=1
    if count==1:
        continue
    count=0
    for m in range(3):
        for n in range(3):
            if not c[m][n]==a[m]+b[n]:
                count=1
    if count==1:
        continue
    else:
        print('Yes')
        import sys
        sys.exit()
print('No')

Submission status: Accepted

Solution code:
c = []
ans = "No"

for i in range(3):

    nc = list(map(int,input().split()))
    c.append(nc)


if c[0][1]-c[0][0] == c[1][1]-c[1][0] and c[1][1]-c[1][0] == c[2][1]-c[2][0] and c[0][2]-c[0][1] == c[1][2]-c[1][1] and c[1][2]-c[1][1] == c[2][2]-c[2][1]:

    if c[1][0]-c[0][0] == c[1][1] - c[0][1] and c[1][1]-c[0][1] == c[1][2] - c[0][2] and c[2][0]-c[1][0] == c[2][1]-c[1][1] and c[2][1]-c[1][1] == c[2][2]-c[1][2]:

        ans = "Yes"

print (ans)

Submission status: Accepted

Solution code:
c_11, c_12, c_13 = [int(c) for c in input().split()]
c_21, c_22, c_23 = [int(cc) for cc in input().split()]
c_31, c_32, c_33 = [int(ccc) for ccc in input().split()]
if c_11 + c_22 == c_12 + c_21 and c_11 + c_33 == c_13 + c_31 and c_22 + c_33 == c_23 + c_32:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

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

    for ai in range(len(a)):
      for bi in range(len(b)):  
        if c[ai][bi] != a[ai]+b[bi]:
          print('No')
          return
  print('Yes')

check(c)

Submission status: Accepted

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

a=[-1,-1,-1]
b=[-1,-1,-1]
N=min(c[0])
ans='No'
for i in range(N+1):
    a[0]=i
    b[0]=c[0][0]-a[0]
    b[1]=c[0][1]-a[0]
    b[2]=c[0][2]-a[0]
    a[1]=c[1][0]-b[0]
    a[2]=c[2][0]-b[0]

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

Submission status: Accepted

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

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

flag = True
for i in range(3):
    for j in range(3):
        if a[i] + b[j] == c[i][j]:
            pass
        else:
            flag = False
            break

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

Submission status: Accepted

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

if c21-c11+c12-c22==0 and c31-c11+c12-c32==0 and c21-2*c11+c12+c13-c23==c31-2*c11+c12+c13-c33:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from sys import stdin

data = []
for _ in range(3):
    data.append([int(x) for x in stdin.readline().rstrip().split()])

flag = False

for j in range(0,101):
    b1 = data[0][0] - j
    b2 = data[0][1] - j
    b3 = data[0][2] - j
    cnt = 0
    for k in data[1:]:
        if (k[0] - b1) == (k[1] - b2) == (k[2] - b3):
            cnt += 1
    if cnt == 2:
        flag = True
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
c11,c12,c13 = map(int,input().split())
c21,c22,c23 = map(int,input().split())
c31,c32,c33 = map(int,input().split())
def wrong():
	print('No')
	exit()
if c12 - c11 == c22 - c21 == c32 - c31:
	pass
else:wrong()
if c13 - c11 == c23 - c21 == c33 - c31:
	pass
else:wrong()
if c13 - c12 == c23 - c22 == c33 - c32:
	pass
else:wrong()
if c21 - c11 == c22 - c12 == c23 - c13:
	pass
else:wrong()
if c31 - c11 == c32 - c12 == c33 - c13:
	pass
else:wrong()
if c31 - c21 == c32 - c22 == c33 - c23:
	pass
else:wrong()
print('Yes')

Submission status: Accepted

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

ans = 'No'
if C[0][0] - C[1][0] == C[0][1] - C[1][1] == C[0][2] - C[1][2]:
    if C[1][0] - C[2][0] == C[1][1] - C[2][1] == C[1][2] - C[2][2]:
        if C[0][0] - C[0][1] == C[1][0] - C[1][1] == C[2][0] - C[2][1]:
            if C[0][1] - C[0][2] == C[1][1] - C[1][2] == C[2][1] - C[2][2]:
                ans = 'Yes'
print(ans)

Submission status: Accepted

Solution code:
c = [[int(i) for i in input().split()] for i in range(3)]
a = []
b = [c[0][i] for i in range(3)]
a = [c[i][0]-b[0] for i in range(3)]
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=[]
for _ in range(3):
    c.append(list(map(int,input().split())))
a=[0]
b=[]
for i in range(3):
    b.append(c[0][i]-a[0])
for i in range(1,3):
    a.append(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")
            exit()
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

import sys
C = [nl(), nl(), nl()]

d1 = C[0][0] - C[0][1]
d2 = C[1][0] - C[1][1]
d3 = C[2][0] - C[2][1]
if d1 != d2 or d2 != d3:
    print('No')
    sys.exit()

d4 = C[0][0] - C[0][2]
d5 = C[1][0] - C[1][2]
d6 = C[2][0] - C[2][2]
if d4 != d5 or d5 != d6:
    print('No')
    sys.exit()

e1 = C[0][0] - C[1][0]
e2 = C[0][1] - C[1][1]
e3 = C[0][2] - C[1][2]
if e1 != e2 or e2 != e3:
    print('No')
    sys.exit()

e4 = C[0][0] - C[2][0]
e5 = C[0][1] - C[2][1]
e6 = C[0][2] - C[2][2]
if e4 != e5 or e5 != e6:
    print('No')
    sys.exit()


print('Yes')

Submission status: Accepted

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

Submission status: Accepted

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

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

ans = 0

if c[1][0] - c[1][1] == b[0] - b[1] and c[1][1] - c[1][2] == b[1] - b[2]:
    ans += 1

if c[2][0] - c[2][1] == b[0] - b[1] and c[2][1] - c[2][2] == b[1] - b[2]:
    ans += 1

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

Submission status: Accepted

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

a1 = 0
a2 = 0
a3 = 0
b1 = 0
b2 = 0
b3 = 0

flag = 0
for i in range(0, 101):#a1の数
    for j in range(0, 101):#b1の数
        for k in range(0, 101):#b2の数
            if i+j == int(c[0][0]) and i+k == int(c[0][1]):
                a1 = i
                b1 = j
                b2 = k
                b3 = int(c[0][2])-i

if int(c[1][0])-b1 == int(c[1][1])-b2 and int(c[1][1])-b2 == int(c[1][2])-b3 and int(c[1][0])-b1 == int(c[1][2])-b3:
    if int(c[2][0])-b1 == int(c[2][1])-b2 and int(c[2][1])-b2 == int(c[2][2])-b3 and int(c[2][0])-b1 == int(c[2][2])-b3:
        flag = 1 

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

Submission status: Accepted

Solution code:
c = [[0]*3 for i in range(3)];
for i in range(3) :
	s = input().split(" ");
	for j in range(3) :
		c[i][j] = int(s[j]);
if c[1][0] - c[0][0] == c[1][1] - c[0][1] and c[1][0] - c[0][0] == c[1][2] - c[0][2] and c[2][0] - c[0][0] == c[2][1] - c[0][1] and c[2][2] - c[0][2] == c[2][0] - c[0][0] and c[0][1] - c[0][0] == c[1][1] - c[1][0] and c[0][1] - c[0][0] == c[2][1] - c[2][0] and c[0][2] - c[0][0] == c[1][2] - c[1][0] and c[0][2] - c[0][0] == c[2][2] - c[2][0] :
	print('Yes');
else :
	print('No')

Submission status: Accepted

Solution code:
# ABC088C - Takahashi's Information
def main():
    arr = [list(map(int, input().rstrip().split())) for _ in range(3)]
    memo = []
    for i, j, k in arr:
        memo += [(i - j, j - k)]
    print("Yes" if len(set(memo)) == 1 else "No")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# ABC088C - Takahashi's Information
def main():
    arr = [list(map(int, input().rstrip().split())) for _ in range(3)]
    memo = []
    for i, j, k in arr:
        memo += [(i - j, j - k)]
    flg = True if memo[0] == memo[1] and memo[1] == memo[2] else False

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# ABC088C - Takahashi's Information
def main():
    arr = [list(map(int, input().rstrip().split())) for _ in range(3)]
    memo = []
    for i, j, k in arr:
        memo += [(i - j, j - k)]
    flg = True if memo[0] == memo[1] and memo[1] == memo[2] else False

    memo = []
    for i in range(3):
        i, j, k = arr[0][i], arr[1][i], arr[2][i]
        memo += [(i - j, j - k)]
    flg = True if memo[0] == memo[1] and memo[1] == memo[2] else False
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# ABC088C - Takahashi's Information
def main():
    arr = [list(map(int, input().rstrip().split())) for _ in range(3)]
    memo = []
    for i, j, k in arr:
        memo += [(i - j, j - k)]
    flg_1 = True if memo[0] == memo[1] == memo[2] else False

    memo = []
    for i in range(3):
        i, j, k = arr[0][i], arr[1][i], arr[2][i]
        memo += [(i - j, j - k)]
    flg_2 = True if memo[0] == memo[1] == memo[2] else False
    
    print("Yes" if flg_1 and flg_2 else "No")


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

a_flag = [0,0,0]
b_flag = [0,0,0]
for i in range(3):
    if i !=0:
        if c[0][i] - c[0][i-1] == c[1][i] - c[1][i-1] and c[1][i] - c[1][i-1] == c[2][i] - c[2][i-1]:
            a_flag[i]=1
    else:
        if c[0][2] - c[0][0] == c[1][2] - c[1][0] and c[1][2] - c[1][0] == c[2][2] - c[2][0]:
            a_flag[i]=1
            
for j in range(3):
    if j !=0:
        if c[j][0] - c[j-1][0] == c[j][1] - c[j-1][1] and c[j][1] - c[j-1][1] == c[j][2] - c[j-1][2]:
            b_flag[j]=1
    else:
        if c[2][0] - c[0][0] == c[2][1] - c[0][1] and c[2][1] - c[0][1] == c[2][2] - c[0][2]:
            b_flag[j]=1

if sum(a_flag) ==3 and sum(b_flag)==3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
C=[]
A=[0]*3
B=[0]*3
for i in range(3):
    C.append(list(map(int,input().split())))
for i in range(3):
    A[i]=min(C[i])
#print(C)
for i in range(3):
    B[i]=C[0][i]-A[0]
#print(A)
#print(B)
for i in range(3):
    for j in range(1,3):
        if B[i]+A[j]!=C[j][i]:
            print('No')
            sys.exit()
print('Yes')

Submission status: Accepted

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

for a1 in range(101):
    b1 = c_list[0][0] - a1
    a2 = c_list[1][0] - b1
    a3 = c_list[2][0] - b1
    b2 = c_list[0][1] - a1
    b3 = c_list[0][2] - a1
    if a2 + b2 == c_list[1][1] and a2 + b3 == c_list[1][2] and a3 + b2 == c_list[2][1] and a3 + b3 == c_list[2][2]:
        print('Yes')
        exit()
print('No')

Submission status: Accepted

Solution code:
c1,c2,c3=map(int,input().split())
c4,c5,c6=map(int,input().split())
c7,c8,c9=map(int,input().split())
d1,d2,d3,d4,d5,d6=c2-c1,c3-c2,c5-c4,c6-c5,c8-c7,c9-c8
if d1==d3 and d3==d5 and d2==d4 and d4==d6:print("Yes")
else:print("No")

Submission status: Accepted

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

flg = "Yes"

for i in range(2):
    if ls[0][i]-ls[0][i+1] == ls[1][i]-ls[1][i+1] and ls[0][i]-ls[0][i+1] == ls[2][i]-ls[2][i+1]:
        pass
    else:
        flg = "No"
print(flg)

Submission status: Accepted

Solution code:
c =[]

for _ in range(3):
    c1,c2,c3 = map(int,input().split())
    c.append((c1,c2,c3))

a_test = [[0,0,0] for _ in range(2)]
b = [0,0,0]

for a1 in range(c[0][0]+1):
    dec = [True,True]
    for j in range(3):
        b[j] = c[0][j] - a1
    
    for i in range(2):
        for j in range(3):
            a_test[i][j] = c[i+1][j] - b[j]
            
        a_set = set(a_test[i])
        if len(a_set) != 1:
            dec[i] = False
    if all(dec):
        break
        
if all(dec):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

b0 = C[0][0]
b1 = C[0][1]
b2 = C[0][2]

a2_1 = C[1][0] - b0
a2_2 = C[1][1] - b1
a2_3 = C[1][2] - b2

a3_1 = C[2][0] - b0
a3_2 = C[2][1] - b1
a3_3 = C[2][2] - b2

if a2_1 == a2_2 and a2_2 == a2_3:
    if a3_1 == a3_2 and a3_2 == a3_3:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

Solution code:
from itertools import product as p
c = [list(map(int, input().split())) for _ in range(3)]
 
a = [-1]*3
a[0] = 0
b = c[0]
a[1] = c[1][0] - b[0]
a[2] = c[2][0] - b[0]
 
for i, j in p(range(3), range(3)):
    if c[i][j] != a[i] + b[j]:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
C = [[int(i) for i in input().split()] for k in range(3)]
tC = [list(k) for k in zip(*C)]
for i in range(2):
    p = [C[i][k]-C[i+1][k] for k in range(3)]
    tp = [tC[i][k]-tC[i+1][k] for k in range(3)]
    if p[0] == p[1] == p[2] and tp[0] == tp[1] == tp[2]:
        continue
    else:
        print("No")
        exit()
else:
    print("Yes")

Submission status: Accepted

Solution code:
C = [[int(i) for i in input().split()] for k in range(3)]
tC = [list(k) for k in zip(*C)]
for i in range(2):
    p = [C[i][k]-C[i+1][k] for k in range(3)]
    tp = [tC[i][k]-tC[i+1][k] for k in range(3)]
    if p[0] == p[1] == p[2] and tp[0] == tp[1] == tp[2]:
        continue
    else:
        print("No")
        exit()
else:
    print("Yes")

Submission status: Accepted

Solution code:
C1 = list(map(int,input().split()))
C2 = list(map(int,input().split()))
C3 = list(map(int,input().split()))
a = 0
b1,b2,b3 = C1[0],C1[1],C1[2]
a1,a2,a3  = 0,C2[1]-b2,C3[1]-b2
if C1[0]!=a1+b1 or C1[1]!=a1+b2 or C1[2]!=a1+b3 or C2[0]!=a2+b1 or C2[1]!=a2+b2 or C2[2]!=a2+b3 or C3[0]!=a3+b1 or C3[1]!=a3+b2 or C3[2]!=a3+b3:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
l1=list(map(int,input().split()))
l2=list(map(int,input().split()))
l3=list(map(int,input().split()))
a1=l1[0]
b2=l1[1]-a1
b3=l1[2]-a1
a2=l2[0]
a3=l3[0]
if a2+b2==l2[1] and a2+b3==l2[2] and a3+b2==l3[1] and a3+b3==l3[2]:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
# from pprint import pprint

mat = [[x for x in map(int, sys.stdin.readline().rstrip().split()) ] for y in range(3)]

# print(mat)

t = mat[0][0]

da1 = mat[1][0] - t
da2 = mat[2][0] - t

db1 = mat[0][1] - t
db2 = mat[0][2] - t

flag = True

# Row 2
if not (mat[1][1] == t + da1 + db1 and mat[1][2] == t + da1 + db2):
  flag = False

# Row 3
if not (mat[2][1] == t + da2 + db1 and mat[2][2] == t + da2 + db2):
  flag = False

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

Submission status: Accepted

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

# print(C)

A = [0*3]*3
B = [0]*3
B[0] = C[0][0]
B[1] = C[0][1]
B[2] = C[0][2]
A[1] = C[1][0] - B[0]
A[2] = C[2][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:
a = [list(map(int, input().split())), list(map(int, input().split())), list(map(int, input().split()))]

def main():
    for i in range(1,3):
        x = a[0][0] - a[0][i] == a[1][0] - a[1][i]== a[2][0] -a[2][i]
        y = a[0][0] - a[i][0] == a[0][1] - a[i][1]== a[0][2] -a[i][2]
        if x is False or y is False:
            return "No"
    return "Yes"

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

Submission status: Accepted

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

ans = 'Yes'
if c[0][0] - c[0][1] != c[1][0] - c[1][1] or c[0][0] - c[0][1] != c[2][0] - c[2][1]:
    ans = 'No'
if c[0][0] - c[0][2] != c[1][0] - c[1][2] or c[0][0] - c[0][2] != c[2][0] - c[2][2]:
    ans = 'No'
if c[0][0] - c[1][0] != c[0][1] - c[1][1] or c[0][0] - c[1][0] != c[0][2] - c[1][2]:
    ans = 'No'
if c[0][0] - c[2][0] != c[0][1] - c[2][1] or c[0][0] - c[2][0] != c[0][2] - c[2][2]:
    ans = 'No'

print(ans)

Submission status: Accepted

Solution code:
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
for i in range(101):
    for j in range(101):
        for h in range(101):
            X = [a-i for a in A]
            Y = [b-j for b in B]
            Z = [c-h for c in C]
            if  X == Y == Z:
                print('Yes')
                exit()
print("No")

Submission status: Accepted

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

Submission status: Accepted

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


lst_diff_i = []
for i in range(3):
    diff1 = lst_c[i][0] - lst_c[i][1]
    diff2 = lst_c[i][1] - lst_c[i][2]
    diff3 = lst_c[i][2] - lst_c[i][0]
    lst_diff_i.append([diff1, diff2, diff3])
if lst_diff_i[0] == lst_diff_i[1] == lst_diff_i[2]:
    ans = "Yes"
else:
    print("No")
    exit()


print(ans)

Submission status: Accepted

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


lst_diff_i = []
for i in range(3):
    diff1 = lst_c[i][0] - lst_c[i][1]
    diff2 = lst_c[i][1] - lst_c[i][2]
    diff3 = lst_c[i][2] - lst_c[i][0]
    lst_diff_i.append([diff1, diff2, diff3])
if lst_diff_i[0] == lst_diff_i[1] == lst_diff_i[2]:
    ans = "Yes"
else:
    print("No")
    exit()


for i in range(3):
    diff1 = lst_c[0][i] - lst_c[1][i]
    diff2 = lst_c[1][i] - lst_c[2][i]
    diff3 = lst_c[2][i] - lst_c[0][i]
    lst_diff_i.append([diff1, diff2, diff3])
if lst_diff_i[0] == lst_diff_i[1] == lst_diff_i[2]:
    ans = "Yes"
else:
    print("No")
    exit()


print(ans)

Submission status: Accepted

Solution code:
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

C = np.array(list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(3)])))

ok = len(set(C[0] - C[1])) == len(set(C[1] - C[2])) == len(set(C[:, 0] - C[:, 1])) == len(set(C[:, 1] - C[:, 2])) == 1
if ok:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

a, b, c = mi()
d, e, f = mi()
g, h, i = mi()

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

Submission status: Accepted

Solution code:
from itertools import product as p
c = [list(map(int, input().split())) for _ in range(3)]

a = [-1]*3
a[0] = 0
b = c[0]
a[1] = c[1][0] - b[0]
a[2] = c[2][0] - b[0]

for i, j in p(range(3), range(3)):
    if c[i][j] != a[i] + b[j]:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
from itertools import product as p

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

a = [0]*3
b = [0]*3
for a1 in range(c[0][0]+1):
    a[0] = a1
    b[0] = c[0][0] - a1
    for a2 in range(c[1][1]+1):
        a[1] = a2
        b[1] = c[1][1] - a2
        for a3 in range(c[2][2]+1):
            a[2] = a3
            b[2] = c[2][2] - a3

            for i, j in p(range(3), range(3)):
                if c[i][j] != a[i] + b[j]:
                    break
            else:
                print('Yes')
                exit()

print('No')

Submission status: Accepted

Solution code:
f1,f2,f3 = map(int,input().split())
d1 = f2 - f1
d2 = f3 - f2
flag = True
for _ in range(2):
    c1,c2,c3 = map(int, input().split())
    if c2-c1 != d1 or c3-c2 != d2:
        flag = False
        break
if flag:
    print("Yes")
else:
    print("No")

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]]"):

    L = []
    for i in range(3):
        L.append(c[i][0] - c[i][1])
    if len(set(L)) > 1:
        print(NO)
        return

    R = []
    for i in range(3):
        R.append(c[i][1] - c[i][2])
    if len(set(R)) > 1:
        print(NO)
        return

    print(YES)


    return


# Generated by 1.1.4 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 i in range(3):
    c.append([int(i) for i in input().split()])

flag = True
if c[0][0]-c[0][1] != c[1][0]-c[1][1] or c[0][0]-c[0][1] != c[2][0]-c[2][1]:
    flag = False
elif c[0][1]-c[0][2] != c[1][1]-c[1][2] or c[0][1]-c[0][2] != c[2][1]-c[2][2]:
    flag = False
elif c[0][0]-c[1][0] != c[0][1]-c[1][1] or c[0][0]-c[1][0] != c[0][2]-c[1][2]:
    flag = False
elif c[0][0]-c[2][0] != c[0][1]-c[2][1] or c[0][0]-c[2][0] != c[0][2]-c[2][2]:
    flag = False

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

Submission status: Accepted

Solution code:
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    c = []
    for _ in range(3):
        c.append(list(int(_) for _ in input().split()))
    c_row_sum = []
    c_column_sum = []
    for i in range(3):
        c_row_sum.append(sum(c[i]))
    for i in range(3):
        tmp_sum = 0
        for j in range(3):
            tmp_sum += c[j][i]
        c_column_sum.append(tmp_sum)
    
    for b in range(301):
        a1 = (c_column_sum[0] - b)/3
        a2 = (c_column_sum[1] - b)/3
        a3 = (c_column_sum[2] - b)/3
        if a1.is_integer() and a2.is_integer() and a3.is_integer():
            b1 = (c_row_sum[0]-(a1+a2+a3))/3
            b2 = (c_row_sum[1]-(a1+a2+a3))/3
            b3 = (c_row_sum[2]-(a1+a2+a3))/3
            if b1.is_integer() and b2.is_integer() and b3.is_integer():
                print('Yes')
                return
    print('No')
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = "Yes"
for i in range(2):
  for j in range(2):
    if c[i + 1][j + 1] - c[i][j + 1] != c[i + 1][j] - c[i][j]:
      ans = "No"
      break
    if c[i + 1][j + 1] - c[i + 1][j] != c[i][j + 1] - c[i][j]:
      ans = "No"
      break

print(ans)

Submission status: Accepted

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


a_list = [0] * 3
b_list = [0] * 3
for a0 in range(c[0][0] + 1):
    a_list[0] = a0
    b_list[0] = c[0][0] - a_list[0]
    a_list[1] = c[1][0] - b_list[0]
    a_list[2] = c[2][0] - b_list[0]
    b_list[1] = c[0][1] - a_list[0]
    b_list[2] = c[0][2] - a_list[0]
    if not all([tmp >= 0 for tmp in a_list]):
        continue
    if not all([tmp >= 0 for tmp in b_list]):
        continue
    
    tmp = [[0] * 3 for i in range(3)]
    for i in range(3):
        for j in range(3):
            tmp[i][j] = a_list[i] + b_list[j]

    for n, m in zip(c, tmp):
        if not n == m:
            break
    else:
        print('Yes')
        exit()
else:
    print('No')

Submission status: Accepted

Solution code:


a, b, c = [ int(v) for v in input().split() ]
d, e, f = [ int(v) for v in input().split() ]
g, h, i = [ int(v) for v in input().split() ]

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

Submission status: Accepted

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

Submission status: Accepted

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