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:
from itertools import product
c = [list(map(int, input().split())) for i in range(3)]

"""
a0 = 0 とする
すると
b0 = c00 - a0
b1 = c01 - a0
b2 = c02 - a0
"""

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

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

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

Submission status: Accepted

Solution code:
#c = [[0 for i in range(3)] for i in range[3]];
c = [[0,0,0],[0,0,0],[0,0,0]];
c[0] = [int(x) for x in input().split()];
c[1] = [int(x) for x in input().split()];
c[2] = [int(x) for x in input().split()];

ans = 'true';

for i in range(1,3) :
    hdiff =  c[0][i] - c[0][i-1];
    for j in range(1,3) :
        if  c[j][i] - c[j][i-1] != hdiff :
            ans = 'false';
            break;

for i in range(1,3) :
    vdiff =  c[i][0] - c[i-1][0];
    for j in range(1,3) :
        if  c[i][j] - c[i-1][j] != vdiff :
            ans = 'false';
            break;            

if(ans == 'true') :
    print('Yes');
else :
    print('No');

Submission status: Accepted

Solution code:
import sys

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    c = [list(mi()) for i in range(3)]
    if c[0][0]+c[1][1] == c[0][1]+c[1][0] \
        and c[1][1]+c[2][2] == c[1][2]+c[2][1] \
        and c[2][2]+c[0][0] == c[2][0]+c[0][2]:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Submission status: Accepted

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

diff1 = mtx[0][0] - mtx[1][0]
diff2 = mtx[0][0] - mtx[2][0]

diff3 = mtx[0][0] - mtx[0][1]
diff4 = mtx[0][0] - mtx[0][2]

if mtx[0][1] - mtx[1][1] != diff1:
    print('No')
elif mtx[0][2] - mtx[1][2] != diff1:
    print('No')
elif mtx[0][1] - mtx[2][1] != diff2:
    print('No')
elif mtx[0][2] - mtx[2][2] != diff2:
    print('No')
elif mtx[1][0] - mtx[1][1] != diff3:
    print('No')
elif mtx[2][0] - mtx[2][1] != diff3:
    print('No')
elif mtx[1][0] - mtx[1][2] != diff4:
    print('No')
elif mtx[2][0] - mtx[2][2] != diff4:
    print('No')
else:
    print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 今回はもし組み合わせがあるとしたらa1=0である組み合わせが確実にある。
# なぜなら、a1, a2, a3をxだけ引いた分b1, b2, b3をxだけ足せばつじつまがあうから
if __name__ == "__main__":
    c1 = list(map(int, input().split()))
    c2 = list(map(int, input().split()))
    c3 = list(map(int, input().split()))
    c = [c1, c2, c3]
    a = [0, 0, 0]
    b = [c1[0], c1[1], c1[2]]
    a[1] = c2[1] - b[1]
    a[2] = c3[1] - b[1]
    flg = True
    for i in range(3):
        for j in range(3):
            flg = flg&(a[i]+b[j] == c[i][j])
    if flg:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
lst=[]
for i in range(3):
    a=map(int,input().split())
    for j in a:
        lst.append(j)
for i in range(lst[0]+1):
    a,d=i,lst[0]-i
    b=lst[3]-lst[0]+a
    c=lst[6]-lst[0]+a
    e=lst[1]-lst[0]+d
    f=lst[2]-lst[0]+d
    if lst[4]==b+e and lst[5]==b+f and lst[7]==c+e and lst[8]==c+f:
        print("Yes")
        exit()
print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(min(c[0])+1):
    check[0] = C[0] - i
    for j in range(min(c[1])+1):
        check[1] = C[1] - j
        for k in range(min(c[2])+1):
            check[2] = C[2] - k
            if list(check[0]) == list(check[1]) and list(check[0]) == list(check[2]):
                print("Yes")
                exit()

print("No")

Submission status: Accepted

Solution code:
import sys
c = []

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

a = [0, -1, -1]
b = c[0]

for l, m in enumerate(c[1:]):
    for j, k in enumerate(m):
        if j == 0:
            a[l+1] = k - b[j] 
        else:
            if k != a[l+1] + b[j]:
                print('No')
                sys.exit()
print('Yes')

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-06-26 20:10:47 +0900
# LastModified: 2020-06-26 20:35:09 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    c = []
    for _ in range(3):
        c.append(list(map(int, input().split())))
    a_12 = c[0][0]-c[1][0]
    a_13 = c[0][0]-c[2][0]
    a_23 = c[1][0]-c[2][0]
    b_12 = c[0][0]-c[0][1]
    b_13 = c[0][0]-c[0][2]
    b_23 = c[0][1]-c[0][2]

    for i in range(1, 3):
        if b_12 != c[i][0]-c[i][1] or b_13 != c[i][0]-c[i][2] or b_23 != c[i][1]-c[i][2]:
            print("No")
            return
        if a_12 != c[0][i]-c[1][i] or a_13 != c[0][i]-c[2][i] or a_23 != c[1][i]-c[2][i]:
            print("No")
            return
    print("Yes")



        


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
c = [[int(i) for i in input().split()] for j in range(3)]
b2 = c[0][1]-c[0][0]
b3 = c[0][2]-c[0][0]
a2 = c[1][0]-c[0][0]
a3 = c[2][0]-c[0][0]

d = 0
for i in range(2):
    if c[i+1][1] - c[i+1][0] == b2:
        d += 1
    if c[i+1][2] - c[i+1][0] == b3:
        d += 1
for j in range(2):
    if c[1][i+1] - c[0][i+1] == a2:
        d += 1
    if c[2][i+1] - c[0][i+1] == a3:
        d += 1
if d == 8:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:

A = [None, None, None]
B = [0, None, None]
C = [None, None, None]

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

flag = True

for i in range(3):
	for j in range(3):
		
		if B[i] == None:
			B[i] = A[i][j] - C[j]
		elif C[j] == None:
			C[j] = A[i][j] - B[i]
		elif A[i][j] != B[i] + C[j]:
			flag = False
		
if flag == True :
	print ("Yes")
else :
	print ("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

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

for i in range(2):
    if not c[0,i]-c[0,i+1] == c[1,i]-c[1,i+1] == c[2,i]-c[2,i+1]:
        flg = False
        break
    if not c[i,0]-c[i+1,0] == c[i,1]-c[i+1,1] == c[i,2]-c[i+1,2]:
        flg = False
        break
print('Yes') if flg else print('No')

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools

## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for _ in range(M)]

C = [list(map(int, input().split())) for _ in range(3)]
 
Dif_H = [[] for _ in range(3)]
Dif_V = [[] for _ in range(3)]
 
for i in range(3):
    Dif_H[i] = [C[i][0] - C[i][1], C[i][1] - C[i][2], C[i][2] - C[i][0]]
for i in range(3):
    Dif_V[i] = [C[0][i] - C[1][i], C[1][i] - C[2][i], C[2][i] - C[0][i]]
 
if Dif_H[0] == Dif_H[1] == Dif_H[2] and Dif_V[0] == Dif_V[1] == Dif_V[2]:
    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+e==b+d:
  if b+f==c+e:
    if d+h==e+g:
      if e+i==f+h:
        print('Yes')
        exit()
print('No')

Submission status: Accepted

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

x1 = c[0][0]-c[1][0]
x2 = c[0][1]-c[1][1] 
x3 = c[0][2]-c[1][2]

x4 = c[1][0]-c[2][0]
x5 = c[1][1]-c[2][1]
x6 = c[1][2]-c[2][2]

if x1==x2 and x2==x3:
    pass
else:
    print('No')
    exit()
if x4==x5 and x5==x6:
    pass 
else:
    print('No')
    exit()

x1 = c[0][0]-c[0][1]
x2 = c[1][0]-c[1][1] 
x3 = c[2][0]-c[2][1]

x4 = c[0][1]-c[0][2]
x5 = c[1][1]-c[1][2]
x6 = c[2][1]-c[2][2]

if x1==x2 and x2==x3:
    pass
else:
    print('No')
    exit()
if x4==x5 and x5==x6:
    pass 
else:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

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

Submission status: Accepted

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

Dif_H = [[] for _ in range(3)]
Dif_V = [[] for _ in range(3)]

for i in range(3):
    Dif_H[i] = [C[i][0] - C[i][1], C[i][1] - C[i][2], C[i][2] - C[i][0]]
for i in range(3):
    Dif_V[i] = [C[0][i] - C[1][i], C[1][i] - C[2][i], C[2][i] - C[0][i]]

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

ans = 'Yes'
if not c[0][1] - c[0][0] == c[1][1] - c[1][0] == c[2][1] - c[2][0]:
    ans = 'No'
if not c[0][2] - c[0][1] == c[1][2] - c[1][1] == c[2][2] - c[2][1]:
    ans = 'No'
if not c[1][0] - c[0][0] == c[1][1] - c[0][1] == c[1][2] - c[0][2]:
    ans = 'No'
if not c[2][0] - c[1][0] == c[2][1] - c[1][1] == c[2][2] - c[1][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()))
ans='No'
if a[1]-a[0]==b[1]-b[0]==c[1]-c[0] and a[2]-a[1]==b[2]-b[1]==c[2]-c[1]:
  if b[0]-a[0]==b[1]-a[1]==b[2]-a[2] and c[0]-b[0]==c[1]-b[1]==c[2]-b[2]:
    ans='Yes'
print(ans)

Submission status: Accepted

Solution code:
c11, c12, c13 = map(int, input().split())

for i in range(2):
    c1, c2, c3 = map(int, input().split())
    if (c1-c11) == (c2-c12) and (c2-c12) == (c3-c13):
        c11, c12, c13 = c1, c2, c3
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

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

Submission status: Accepted

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

if L[1][1]!=L[1][0]-L[0][0]+L[0][1]:
    s=False
if L[1][2]!=L[1][0]-L[0][0]+L[0][2]:
    s=False
if L[2][1]!=L[2][0]-L[0][0]+L[0][1]:
    s=False
if L[2][2]!=L[2][0]-L[0][0]+L[0][2]:
    s=False
if s:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
G1 = list(map(int, input().split()))
G2 = list(map(int, input().split()))
G3 = list(map(int, input().split()))
sub_G1 = []
sub_G2 = []
sub_G3 = []
sub_R12 = []
sub_R23 = []
for i in range(2):
  sub_G1.append(G1[i+1] - G1[i])
  sub_G2.append(G2[i+1] - G2[i])
  sub_G3.append(G3[i+1] - G3[i])
for k in range(3):
  sub_R12.append(G2[i]-G1[i])
  sub_R23.append(G3[i]-G2[i])
condition1 = bool(sub_G1[0] == sub_G2[0] == sub_G3[0])
condition2 = bool(sub_G1[1] == sub_G2[1] == sub_G3[1])
condition3 = bool(len(set(sub_R12)) == 1)
condition4 = bool(len(set(sub_R23)) == 1)
if condition1 and condition2 and condition3 and condition4:
  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:
    if d-e == g-h:
        if b-c == e-f:
            if e-f == h-i:
                if a-d == b-e:
                    if b-e ==c-f:
                        if d-g == e-h:
                            if e-h ==f-i:
                                print("Yes")
                                exit()

print("No")

Submission status: Accepted

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

for i in range(3):
    y[i] = a[0][i]-x[0]

for i in range(3):
    x[i] = a[i][0]-y[0]

flag = True

for i in range(3):
    for j in range(3):
        if a[i][j] != x[i]+y[j]:
            flag=False

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

Submission status: Accepted

Solution code:
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))

c = []
for _ in range(3):
    c.append(LI())
a1_range = min(c[0])
for a1 in range(a1_range+1):
    a = [0]*3
    b = [0]*3
    a[0] = a1
    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 = True
    for i in range(3):
        for j in range(3):
            if c[i][j] != a[i] + b[j]:
                flag = False
                break
        if not flag:
            break
    if flag:
        print("Yes")
        sys.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())

if c7-c4==c8-c5==c9-c6 and c4-c1==c5-c2==c6-c3 and c3-c2==c6-c5==c9-c8 and c2-c1==c5-c4==c8-c7:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
"""
・全探索してもよい
・ある値（例えばa1）を決めたら他の値は全部決まってしまう
→ a1に適当な値を入れて後は全部できているかチェックすればよい
"""
import sys

c = [[int(i) for i in input().split()] for j in range(3)]
a = [0] * 3
b = [0] * 3

max_val = 100

# a1を適当に決める
a[0] = 0

# 他の値は勝手に決まる
b[0] = c[0][0] - a[0]
b[1] = c[0][1] - a[0]
b[2] = c[0][2] - a[0]
a[1] = c[1][0] - b[0]
a[2] = c[2][0] - b[0]

#print(f"a;{a}\t b:{b}")

for i in range(3):
    for j in range(3):
        left = a[i] + b[j]
        right = c[i][j]
        #print(f"{a[i]}+{b[j]} -> {c[i][j]}")
        if(left != right):
            ans = False
            print("No")
            sys.exit()


print("Yes")

Submission status: Accepted

Solution code:
import copy

line = [[int(i) for i in input().split()] for _ in range(3)]
ansB = copy.copy(line[0])
ansA = [0, line[1][0]-ansB[0], line[2][0]-ansB[0]]
# print(line, ansA, ansB)
for i in range(1, 3):
    for j in range(1, 3):
        if ansA[i] + ansB[j] != line[i][j]:
            print("No")
            exit()

print("Yes")

Submission status: Accepted

Solution code:
import numpy as np
from itertools import product
import sys
read = sys.stdin.buffer.read


C = np.array(read().split(), np.int32).reshape(3, 3)

a, b, c = np.max(C + 1, axis=1)
N = []
for i, j in product(range(a), range(b)):
    x = C[0, :] - i
    y = C[1, :] - j

    if np.all(x == y):
        N.append(x)

flag = 0
z = C[2, :]
for n in N:
    for k in range(c):
        if np.all(z - k == n):
            flag = 1
            break
    
    if flag:
        break

print(['No', 'Yes'][flag])

Submission status: Accepted

Solution code:
c = [list(map(int,input().split())) for _ in range(3)]
a = []
b = []
for i in range(3):
    a.append(abs(c[i][0]-c[i][1]))
    a.append(abs(c[i][1]-c[i][2]))
for i in range(3):
    b.append(abs(c[0][i]-c[1][i]))
    b.append(abs(c[1][i]-c[2][i]))
if a[0] == a[2] and a[2] == a[4] and b[0] == b[2] and b[2] == b[4] \
    and a[1] == a[3] and a[3] == a[5] and b[1] == b[3] and b[3] == b[5]:
    print('Yes')
    exit()
print('No')

Submission status: Accepted

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

b = c[0]
a = [0, c[1][0] - b[0], c[2][0] - b[0]]

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

Submission status: Accepted

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

for a1 in range(min(c[0])+1):
    for a2 in range(min(c[1])+1):
        for a3 in range(min(c[2])+1):
            b1 = c[0][0] - a1
            b2 = c[0][1] - a1
            b3 = c[0][2] - a1

            if c[1][0] == a2+b1 and c[1][1] == a2 + b2  and c[1][2] == a2 + b3 and c[2][0] == a3+b1 and c[2][1] == a3 + b2  and c[2][2] == a3 + b3:
                print('Yes')
                exit()
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[1] - C1[0] == C2[1] - C2[0] == C3[1] - C3[0] and C1[2] - C1[1] == C2[2] - C2[1] == C3[2] - C3[1] :
  if C2[0] - C1[0] == C2[1] - C1[1] == C2[2] - C1[2] and C3[0] - C2[0] == C3[1] - C2[1] == C3[2] - C2[2]:
    print("Yes")
  else:
    print("No")
  
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

c = [input().split() for i in range(3)]
num = [int(c[i][j]) for i in range(3) for j in range(3)]

if num[0] + num[4] != num[1] + num[3]:
    print('No')
    sys.exit()
elif num[4] + num[8] != num[5] + num[7]:
    print('No')
    sys.exit()
elif num[0] + num[8] != num[2] + num[6]:
    print('No')
    sys.exit()

print('Yes')

Submission status: Accepted

Solution code:
import sys
C11,C12,C13 = map(int, input().split())
C21,C22,C23 = map(int, input().split())
C31,C32,C33 = map(int, input().split())





if (C11+C22==C12+C21) and (C12+C23==C13+C22) and (C21+C32==C22+C31) and (C22+C33==C23+C32):
    print('Yes')
    sys.exit()


print("No")

Submission status: Accepted

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

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

print('Yes')

Submission status: Accepted

Solution code:
import numpy as np
C= [[0] * 3 for i in range(3)]
for i in range(3):
  C[i]=list(map(int, input().split()))
C=np.array(C)
answer='Yes'
 
S=C.sum()
trace=np.diag(C).sum()
S_row0=C[0,:].sum()
S_row1=C[1,:].sum()
S_row2=C[2,:].sum()

S_col0=C[:,0].sum()
S_col1=C[:,1].sum()
S_col2=C[:,2].sum()

if S != 3*trace:
  answer = 'No'
elif S_row0-3*C[0,0] != trace-S_col0:
  answer = 'No'
elif S_row1-3*C[1,0] != trace-S_col0:
  answer = 'No'



print(answer)

Submission status: Accepted

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

for i in range(min(c[0])+1):
  b=[c[0][k]-i for k in range(3)]
  a=[c[i][0]-b[0] for i in range(3)]
  for i in range(1,3):
    if c[i][1]!=a[i]+b[1] or c[i][2]!=a[i]+b[2]:
        break
  else:
    print('Yes')
    sys.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())

ans = 'No'

# a1b1, a1b2, a1b3
# a2b1, a2b2, a2b3
# a3b1, a3b2, a3b3

for i in range(c11+1):
  a1 = i
  b1 = c11 - a1
  a2 = c21 - b1
  b2 = c12 - a1
  a3 = c31 - b1
  b3 = c13 - a1
  
  #print(a1, a2, a3, b1, b2, b3)
  
  if (a2+b2 == c22) and (a2+b3 == c23) and (a3+b2 == c32) and (a3+b3 == c33):
    ans = 'Yes'
    break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import numpy as np
input = sys.stdin.readline

 
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TL(mylist):
    return np.array(mylist).T.tolist()

mylist1 = [list(map(int, input().rstrip().split())) for i in range(3)]
mylist2 = TL(mylist1)

def chech(mylist):
    result = True
    b1 = mylist[0][0] - mylist[0][1]
    c1 = mylist[0][0] - mylist[0][2]
    for i in range(1, 3):
        if (mylist[i][0] -  mylist[i][1]) != b1 or (mylist[i][0] -  mylist[i][2]) != c1:
            result = False
            break
    return result
    
if chech(mylist1) and chech(mylist2):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

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

print('Yes')

Submission status: Accepted

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

B = C[0]
A = (0, C[1][1] - B[1], C[2][2] - B[2])

for i in range(3):
    for j in range(3):
        v = A[i] + B[j]
        if not v == C[i][j]:
            print("No")
            exit(0)
print("Yes")

Submission status: Accepted

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

ans = 'Yes'
for i in range(2):
    d = C[2][i+1] - C[2][i]
    for j in range(2):
        if C[j][i+1] - C[j][i] != d:
            ans = 'No'
print(ans)

Submission status: Accepted

Solution code:
c = [[int(i) for i in input().split()] for j in range(3)]
f = True
a, b = c[0][0] - c[0][1], c[0][1] - c[0][2]
for i in range(1, 3):
    if not(c[i][0] - c[i][1] == a and c[i][1] - c[i][2] == b):
        f = False
a, b = c[0][0] - c[1][0], c[1][0] - c[2][0]
for i in range(1, 3):
    if not(c[0][i] - c[1][i] == a and c[1][i] - c[2][i] == b):
        f = False
print("Yes" if f else "No")

Submission status: Accepted

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

cnt = 0
for i in range(3):
    for j in range(3):
        if c[i][j] == a[i]+b[j]:
            cnt += 1

print('Yes' if cnt == 9 else 'No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():

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

    if (c[1][0]-c[2][0]) != (c[1][1]-c[2][1]) or (c[1][0]-c[2][0]) != (c[1][2]-c[2][2]) or (c[1][1]-c[2][1]) != (c[1][2]-c[2][2]):
        print('No')
        return

    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]) or (c[0][1]-c[2][1]) != (c[0][2]-c[2][2]):
        print('No')
        return

    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]) or (c[1][0]-c[1][1]) != (c[2][0]-c[2][1]):
        print('No')
        return

    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]) or (c[1][0]-c[1][2]) != (c[2][0]-c[2][2]):
        print('No')
        return

    if (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]) or (c[1][1]-c[1][2]) != (c[2][1]-c[2][2]):
        print('No')
        return

    print('Yes')

main()

Submission status: Accepted

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

    def is_ok(rs, cs):
        for r, ri in enumerate(rs, start=1):
            for c, ci in enumerate(cs):
                if G[r][c] != ri + ci:
                    return False
        return True

    for r0 in range(G[0][0] + 1):
        c0 = G[0][0] - r0
        c1 = G[0][1] - r0
        c2 = G[0][2] - r0

        r1 = G[1][0] - c0
        r2 = G[2][0] - c0

        rs = (r1, r2)
        cs = (c0, c1, c2)
        if is_ok(rs, cs):
            print('Yes')
            return

    print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def l(): return list(map(int, input().split()))
def m(): return map(int, input().split())

def main():
  c = [0]*3
  for i in range(3):
    c[i] = l()
  # for i in range(2):
  #   x = c[2][i+1] - c[2][i]
  #   for j in range(2):
  #     if c[j][i+1] - c[j][i] != x:
  #       print('No')
  #       exit()
  # print('Yes')

  a = [0]*3
  b = [0]*3
  b[0] = min(c[0])
  for i in range(3):
    a[i] = c[0][i] - b[0]
  for i in range(1,3):
    b[i] = c[i][0] - a[0]
  # print(a,b)
  for i in range(3):
    for j in range(3):
      if c[i][j] != a[j] + b[i]:
        print('No')
        exit()
  print('Yes')

  
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
def l(): return list(map(int, input().split()))
def m(): return map(int, input().split())

def main():
  c = [0]*3
  for i in range(3):
    c[i] = l()
  for i in range(2):
    x = c[2][i+1] - c[2][i]
    for j in range(2):
      if c[j][i+1] - c[j][i] != x:
        print('No')
        exit()
  print('Yes')

  
if __name__ == '__main__':
  main()

Submission status: Accepted

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

for i in li:
    for j in range(-100,102):
        if j == 101:
            print("No")
            exit()
        if [i+j for i in ans] == i:
            break

print("Yes")

Submission status: Accepted

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

if C[1][0]-C[0][0]!=C[1][1]-C[0][1]:
    ans='No'
elif C[1][2]-C[0][2]!=C[1][1]-C[0][1]:
    ans='No'
elif C[2][0]-C[1][0]!=C[2][1]-C[1][1]:
    ans='No'
elif C[2][2]-C[1][2]!=C[2][1]-C[1][1]:
    ans='No'

print(ans)

Submission status: Accepted

Solution code:
C=[list(map(int,input().split())) for i in range(3)]
a1=0
b=C[0]
a=[C[i][0]-b[0] for i in range(3)]
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)]

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

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[0][i] - C[1][i], C[1][i] - C[2][i], C[2][i] - C[0][i]])
for i in range(3):
  B.append([C[i][0] - C[i][1], C[i][1] - C[i][2], C[i][2] - C[i][0]])
ans = 'Yes'
if A[0] != A[1]:
  ans = 'No'
elif A[1] != A[2]:
  ans = 'No'
elif B[0] != B[1]:
  ans = 'No'
elif B[1] != B[2]:
  ans = 'No'
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    c0=list(map(int,input().split()))
    c1=list(map(int,input().split()))
    c2=list(map(int,input().split()))
    a=[0]*3
    b=[0]*3
    b[0]=c0[0]
    b[1]=c1[0]
    b[2]=c2[0]
    a[1]=c0[1]-b[0]
    a[2]=c0[2]-b[0]
    if a[1]+b[1]==c1[1] and a[1]+b[2]==c2[1] and\
            a[2]+b[1]==c1[2] and a[2]+b[2]==c2[2]:
        print('Yes')
    else:
        print('No')

resolve()