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

Solution (Python):


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

for i in range(2):
    res1=c[i+1][0]-c[i][0]
    res2=c[i+1][1]-c[i][1]
    res3=c[i+1][2]-c[i][2]
    if res1==res2==res3:continue
    else:
        print('No')
        exit()


for j in range(2):
    res1=c[0][j+1]-c[0][j]
    res2=c[1][j+1]-c[1][j]
    res3=c[2][j+1]-c[2][j]
    if res1==res2==res3:continue
    else:
        print('No')
        exit()

print('Yes')

Solution (Python):
def resolve():
  c = []
  c.append(list(map(int, input().split())))
  c.append(list(map(int, input().split())))
  c.append(list(map(int, input().split())))
  a01 = c[0][0] - c[0][1]
  a02 = c[0][0] - c[0][2]
  a12 = c[0][1] - c[0][2]
  b01 = c[0][0] - c[1][0]
  b02 = c[0][0] - c[2][0]
  b12 = c[1][0] - c[2][0]
  for i in range(3):
    if ((c[i][0] - c[i][1]) != a01) or (c[i][0] - c[i][2] != a02) or (c[i][1] - c[i][2] != a12):
      return False
    if ((c[0][i] - c[1][i]) != b01 or (c[0][i] - c[2][i]) != b02 or (c[1][i] - c[2][i]) != b12):
      return False

  return True

if __name__ == "__main__":
  if (resolve()):
    print("Yes")
  else:
    print("No")

Solution (Python):
A = [list(map(int,input().split())) for _ in range(3)]
C = [0,0,0]
for j in range(3):
    for i in range(3):
        C[j] += A[i][j]
R = [0,0,0]
for i in range(3):
    for j in range(3):
        R[i] += A[i][j]
if (C[0]-C[1])%3==0 and (C[1]-C[2])%3==0 and (R[0]-R[1])%3==0 and (R[1]-R[2])%3==0:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7

def main():
    c=[[]for _ in range(3)]
    for i in range(3):
        c[i]=LI()
    a=[0,0,0]
    b=[0,0,0]
    for i in range(3):
        b[i]=c[0][i]
        
    for i in range(1,3):
        a[i]=c[i][0]-b[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==1:
        print("Yes")
    else:
        print("No")
        
    
            
    


main()

Solution (Python):
def main():
    c = [[int(x) for x in input().split()] for _ in range(3)]
    all_sum = 0
    answer = True
    for i in range(3):
        all_sum += sum(c[i])
    if all_sum % 3 == 0:
        all_sum //= 3
    else:
        answer = False
    now_sum = 0
    for i in range(3):
        now_sum += c[i][i]
    if now_sum != all_sum:
        answer = False
    now_sum = 0
    for i in range(3):
        now_sum += c[i][2 - i]
    if now_sum != all_sum:
        answer = False
    print("Yes" if answer else "No")


if __name__ == '__main__':
    main()

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

D = [[0]*3 for _ in range(2)]
for i in range(2):
    for j in range(3):
        D[i][j] = C[i+1][j]-C[i][j]

flag = True
if D[0][0] == D[0][1] and D[0][1] == D[0][2] and D[0][2] == D[0][0]:
    pass
else:
    flag = False

if D[1][0] == D[1][1] and D[1][1] == D[1][2] and D[1][2] == D[1][0]:
    pass
else:
    flag = False

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

Solution (Python):
C = []

for _ in range(3):
    C.append(list(map(int, input().split())))

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

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

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

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

Solution (Python):
def solve():
    c = [list(map(int,input().split())) for _ in range(3)]
    for i in range(101):
        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:
            print('Yes')
            exit()
    print('No')
if __name__=='__main__':
    solve()

Solution (Python):
a1,a2,a3 = map(int,input().split())
b1,b2,b3 = map(int,input().split())
c1,c2,c3 = map(int,input().split())

if not (a1-a2 == b1-b2 == c1-c2) or not (a2-a3 == b2-b3 == c2-c3):
    print('No')
elif not (a1-b1 == a2-b2 == a3-b3) or not (b1-c1 == b2-c2 == b3-c3):
    print('No')
else:
    print('Yes')

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

Solution (Python):
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")

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

match = True

for i in range(2):
    d1 = grid[0][i+1] - grid[0][i]
    d2 = grid[1][i+1] - grid[1][i]
    d3 = grid[2][i+1] - grid[2][i]
    if (d1 != d2) or (d1 != d3):
        match = False
        break

for i in range(2):
    d1 = grid[i+1][0] - grid[i][0]
    d2 = grid[i+1][1] - grid[i][1]
    d3 = grid[i+1][2] - grid[i][2]
    if (d1 != d2) or (d1 != d3):
        match = False
        break

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

Solution (Python):


import io

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

if (array[0][0]+array[1][1]+array[2][2])*3==(sum(array[0])+sum(array[1])+sum(array[2])):
  print('Yes')
else:
  print('No')

Solution (Python):
a=list(map(int,open(0).read().split()))
print('Yes' if a[0]-a[1]==a[3]-a[4]==a[6]-a[7] and a[1]-a[2]==a[4]-a[5]==a[7]-a[8] and a[0]-a[3]==a[1]-a[4]==a[2]-a[5] and a[3]-a[6]==a[4]-a[7]==a[5]-a[8] else 'No')

Solution (Python):
c = []
c.append(list(map(int, input().split())))
c.append(list(map(int, input().split())))
c.append(list(map(int, input().split())))

c0 = c[0][0] + c[0][1] + c[0][2]
c1 = c[1][0] + c[1][1] + c[1][2]
c2 = c[2][0] + c[2][1] + c[2][2]






for a0 in range(101):
    b0 = c[0][0] - a0
    b1 = c[0][1] - a0
    b2 = c[0][2] - a0
    for a1 in range(101):
        a2 = (c2 - c0 + 3 * a0) / 3
        if (
            c[1][0] - a1 == b0
            and c[1][1] - a1 == b1
            and c[1][2] - a1 == b2
            and c[2][0] - a2 == b0
            and c[2][1] - a2 == b1
            and c[2][2] - a2 == b2
        ):
            print("Yes")
            exit(0)
print("No")

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

Solution (Python):
c = [list(map(int, input().split())) for _ in range(3)]
c1 = [c[i][i] for i in range(3)]
c2 = [sum(i) for i in c]
print('Yes' if sum(c1) * 3 == sum(c2) else 'No')

Solution (Python):
c = []
for _ in range(3):
  ci  = list(map(int,input().split()))
  c.append(ci)
if all([c[0][0]-c[0][1]== c[1][0]-c[1][1],c[1][0]-c[1][1]==c[2][0]-c[2][1],c[0][1]-c[0][2]==c[1][1]-c[1][2],c[1][1]-c[1][2]==c[2][1]-c[2][2]]):
  print("Yes")
else:
  print("No")

Solution (Python):
l1=list(map(int,input().split()))
l2=list(map(int,input().split()))
l3=list(map(int,input().split()))

s=0
for i in range(0,min(l1[0],l1[1],l1[2],l2[0],l3[0])+1):
  j=l1[0]-i
  m=l1[1]-i
  n=l1[2]-i
  if l2[0]-j==l2[1]-m==l2[2]-n and l3[0]-j==l3[1]-m==l3[2]-n:
    s=1
    break

print("Yes" if s==1 else "No")

Solution (Python):
*l, = map(int, open(0).read().split())
print("YNeos"[4 != sum(sum(l[j]-l[0]+l[i] == l[i+j] for i in [1,2]) for j in [3,6])::2])

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

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

Solution (Python):
l = []
for i in range(3):
    ll = [int(x) for x in input().split()]
    l.append(ll)
if l[0][0] - l[0][1] != l[1][0] - l[1][1] or l[2][0] - l[2][1] != l[1][0] - l[1][1]:
    print("No")
    exit()
if l[0][2] - l[0][1] != l[1][2] - l[1][1] or l[2][2] - l[2][1] != l[1][2] - l[1][1]:
    print("No")
    exit()
if l[0][0] - l[1][0] != l[0][1] - l[1][1] or l[0][2] - l[1][2] != l[0][1] - l[1][1]:
    print("No")
    exit()
if l[2][0] - l[1][0] != l[2][1] - l[1][1] or l[2][2] - l[1][2] != l[2][1] - l[1][1]:
    print("No")
    exit()
print("Yes")

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

Solution (Python):
C = []
for _ in range(3):
    C.append(list(map(int,input().split())))
flag = 1
for i in range(2):
    if C[i+1][0] - C[i][0] != C[i+1][1] - C[i][1] or C[i+1][1] - C[i][1] != C[i+1][2] - C[i][2]:
        flag = 0
    if C[0][i+1] - C[0][i] != C[1][i+1] - C[1][i] or C[1][i+1] - C[1][i] != C[2][i+1] - C[2][i]:
        flag = 0

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

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


diff_tate=[]
for i in range(2):
  diff_tate.append([mat[i][0]-mat[2][0],mat[i][1]-mat[2][1],mat[i][2]-mat[2][2]])


diff_yoko=[]
for i in range(2):
  diff_yoko.append([mat[0][i]-mat[0][2],mat[1][i]-mat[1][2],mat[2][i]-mat[2][2]])


for diff in diff_tate+diff_yoko:
  dset=set(diff)
  if len(dset)>1:
    print("No")
    break
else:
  print("Yes")

Solution (Python):
c = [list(map(int, input().split())) for _ in range(3)]
c1 = [c[i][i] for i in range(3)]
c2 = [sum(i) for i in c]
print('Yes' if sum(c1) * 3 == sum(c2) else 'No')

Solution (Python):
C = [[]for i in range(3)]
for i in range(3):
    C[i].extend(list(map(int, input().split())))
flag = True

for i in range(2):
    if (C[1][i+1] - C[1][i] == C[2][i+1] - C[2][i]) and (C[1][i+1] - C[1][i] == C[0][i+1] - C[0][i]):
        continue
    else:
        flag = False
        break
for i in range(2):
    if not flag:
        break
    if (C[i+1][1] - C[i][1] == C[i+1][2] - C[i][2]) and (C[i+1][1] - C[i][1] == C[i+1][0] - C[i][0]):
        continue
    else:
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):
c = [list(map(int,input().split())) for _  in range(3)]
l = []
for i in c:
  l += i
if l[0]+l[4]==l[1]+l[3] and l[1]+l[5]==l[2]+l[4] and l[3]+l[7]==l[4]+l[6] and l[4]+l[8]==l[5]+l[7]:
  print('Yes')
else:
  print("No")

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

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

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

flag = False

for i in range(C[0][0]+1):
    a_1 = i
    b_1 = C[0][0] - i
    b_2 = C[0][1] - i
    b_3 = C[0][2] - i
    a_2 = C[1][0] - b_1
    a_3 = C[2][0] - b_1
    if (a_2 + b_2) == C[1][1] and (a_2 + b_3) == C[1][2] and (a_3 + b_2) == C[2][1] and (a_3 + b_3) == C[2][2]:
        flag = True
        break

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

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

ans = 'Yes'
diff_w = [c[0][1]-c[0][0], c[0][2]-c[0][1]]
for i in range(3):
    for j in range(1 ,3):
        if c[i][j] -c[i][j-1] != diff_w[j-1]:
            ans = 'No'
            break
diff_h = [c[1][0]-c[0][0], c[2][0]-c[1][0]]
for i in range(1, 3):
    for j in range(3):
        if c[i][j]-c[i-1][j] != diff_h[i-1]:
            ans = 'No'
            break

print(ans)

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

s=0
if(c1[0]-c2[0]==c1[1]-c2[1] and c1[0]-c2[0]==c1[2]-c2[2]):
    s+=1

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

Solution (Python):
import sys  
import numpy as np
N1 = list(map(int, input().split()))
N2 = list(map(int, input().split()))
N3 = list(map(int, input().split()))

temp = []
for i in range(3):
    a  = N1[i] + N2[i] - 2*N3[i]
    temp.append(a)
temp2 = []

temp2.append(N1[0] + N1[1] - 2*N1[2])

temp2.append(N2[0] + N2[1] - 2*N2[2])

temp2.append(N3[0] + N3[1] - 2*N3[2])


if len(list(set(temp))) == 1 & len(list(set(temp2))) == 1:
    print("Yes")
else :
    print("No")

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

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

Solution (Python):
def main():
    c = []
    for i in range(3):
        c.append(list(map(int, input().split())))
    for a1 in range(101):
        b1 = c[0][0] - a1
        b2 = c[0][1] - a1
        b3 = c[0][2] - a1
        if b1 < 0 or b2 < 0 or b3 < 0:
            continue
        a2_1 = c[1][0] - b1
        a2_2 = c[1][1] - b2
        a2_3 = c[1][2] - b3
        if a2_1 < 0 or a2_2 < 0 or a2_3 < 0:
            continue
        if a2_1 != a2_2 or a2_2 != a2_3 or a2_1 != a2_3:
            continue

        a3_1 = c[2][0] - b1
        a3_2 = c[2][1] - b2
        a3_3 = c[2][2] - b3
        if a3_1 < 0 or a3_2 < 0 or a3_3 < 0:
            continue
        if a3_1 != a3_2 or a3_2 != a3_3 or a3_1 != a3_3:
            continue

        print("Yes")
        return

    print("No")

if __name__ == "__main__":
    main()

Solution (Python):
c = [[] for _ in range(3)]
for i in range(3):
    c[i] = list(map(int,(input().split())))
a1 = c[1][0] - c[0][0]
a2 = c[2][0] - c[0][0]
b1 = c[0][1] - c[0][0]
b2 = c[0][2] - c[0][0]

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

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

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]:
    if 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]:
        print("Yes")
        exit()

print("No")

Solution (Python):
listA = []
list_number = []
for i in range(3):
    list_number.append(list(map(int,input().split())))
listA.append([min(list_number[0]),min(list_number[1]),min(list_number[2])])
b1 = min(list_number[0][0],list_number[1][0],list_number[2][0])
b2 = min(list_number[0][1],list_number[1][1],list_number[2][1])
b3 = min(list_number[0][2],list_number[1][2],list_number[2][2])
listA.append([b1,b2,b3])
for i in range(3):
    list_number[i] = list(map(lambda x:x-listA[0][i],list_number[i]))
for j in range(3):
    B = set([list_number[0][j],list_number[1][j],list_number[2][j]])
    if len(B) == 1:
        pass
    else:
        print("No")
        exit()
print("Yes")

Solution (Python):
a = [0 for i in range(3)]
b = [0 for i in range(3)]
c = []
c.append(list(map(int,input().split())))
c.append(list(map(int,input().split())))
c.append(list(map(int,input().split())))
ans = 'Yes'
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]:
            ans = 'No'
print(ans)

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip() 

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

    absum = []

    def dfs(depth, perm, s):
        if depth==3:
            absum.append(s)
        else:
            for i in range(3):
                if not i in perm:
                    dfs(depth+1, perm+[i], s+c[depth][i])

    dfs(0, [], 0)

    if len(set(absum))==1:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    resolve()

Solution (Python):
import numpy as np

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([], int)
for l in range(3):
    buf= list(map(int, input().strip().split()))
    b= np.concatenate((b, buf), axis=None)

b = np.reshape(b, (9,1))
Ab = np.concatenate((A, b), axis=1)

rA  = np.linalg.matrix_rank(A)
rAb = np.linalg.matrix_rank(Ab)

if rA==rAb:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))

def main():
    cc = [MII() for _ in range(3)]
    flag = True
    for i in range(2):
        if cc[i][0]-cc[i+1][0] != cc[i][1]-cc[i+1][1]: flag = False
        if cc[i][1]-cc[i+1][1] != cc[i][2]-cc[i+1][2]: flag = False
        if cc[0][i]-cc[0][i+1] != cc[1][i]-cc[1][i+1]: flag = False
        if cc[1][i]-cc[1][i+1] != cc[2][i]-cc[2][i+1]: flag = False
    if flag: print('Yes')
    else: print('No')

if __name__ == '__main__':
    main()

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

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

ans = False
for a1 in range(0, 101):
    for a2 in range(0, 101):
        for a3 in range(0, 101):
            b1, b2, b3 = C[0][0] - a1, C[0][1] - a1, C[0][2] - a1
            flag1 = (b1 == C[1][0] - a2) and (b1 == C[2][0] - a3)
            flag2 = (b2 == C[1][1] - a2) and (b2 == C[2][1] - a3)
            flag3 = (b3 == C[1][2] - a2) and (b3 == C[2][2] - a3)
            if flag1 and flag2 and flag3:
                ans = True

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

Solution (Python):
c = []
for i in range(3):
    c.append(list(map(int, input().split())))
    
def is_check(a, b, c):
    for j in range(3):
        for k in range(3):
            if c[j][k] != (a[j] + b[k]):
                return False
    return True

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 not (b1 >= 0 and b1 <= 100
        and b2 >= 0 and b2 <= 100
        and b3 >= 0 and b3 <= 100
        and a2 >= 0 and a2 <= 100
        and a3 >= 0 and a3 <= 100) :
        continue
    
    a = [a1, a2, a3]
    b = [b1, b2, b3]
    
    is_ok = is_check(a, b, c)

    if is_ok:
        print('Yes')
        break

else:
    print('No')

Solution (Python):
import sys
import numpy as np

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

def main():
    grid[:, :] -= grid[0]
    grid[:, :] -= grid[:, 0][:, None]
    print('No' if np.any(grid) else 'Yes')

if __name__ ==  '__main__':
    main()

Solution (Python):
C = []
for _ in range(3):
    c1, c2, c3 = map(int, input().split())
    tmp = [c1, c2, c3]
    C.append(tmp)

if not(C[0][0]-C[0][1] == C[1][0]-C[1][1] == C[2][0]-C[2][1]):
    print('No')
    exit(0)

if not(C[0][1]-C[0][2] == C[1][1]-C[1][2] == C[2][1]-C[2][2]):
    print('No')
    exit(0)

if not(C[0][0]-C[1][0] == C[0][1]-C[1][1] == C[0][2]-C[1][2]):
    print('No')
    exit(0)

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

Solution (Python):
c = [list(map(int,input().split())) for  _ in range(3)]
OK = False
for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            a = [a1,a2,a3]
            ok = True
            for j in range(3):
                v = c[0][j]-a[0]
                for i in range(2):
                    if c[i+1][j] - a[i+1] != v:ok = False
            if ok :OK = True
                    
if OK:print('Yes')
else:print('No')

Solution (Python):
import sys
import itertools
sys.setrecursionlimit(10000)
def resolve():
    C = [list(map(int, input().split(" "))) for i in range(3)]
    

    for a1 in range(101):
        b1 = C[0][0] - a1
        for a2 in range(101):
            b2 = C[1][1] - a2
            for a3 in range(101):
                b3 = C[2][2] - a3
                if check(C, [a1, a2, a3], [b1, b2, b3]):
                    print("Yes")
                    return
    print("No")

def check(C, A, B):
    for i in range(len(C)):
        for j in range(len(C[i])):
            if C[i][j] != A[i] + B[j]:
                return False
    return True

if '__main__' == __name__:
    resolve()

Solution (Python):

import sys
try:
    from typing import List
except ImportError:
    pass


YES = "Yes"  
NO = "No"  


def solve(c: "List[List[int]]"):
    print(YES if all(
        c[i][j] == c[0][j] + c[i][0] - c[0][0]
        for i in range(1, 3)
        for j in range(1, 3)
    ) else NO)


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)]  
    solve(c)


if __name__ == '__main__':
    main()

Solution (Python):



def readInts():
  return list(map(int,input().split()))
def main():
    C = [readInts() 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]
    for i in range(3):
        for j in range(3):
            if C[j][i] == a[j] + b[i]:
                pass
            else:
                print('No')
                exit()
    print('Yes')
if __name__ == '__main__':
  main()

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

for i in range(2):
    for j in range(1,3):
        if c[i][j] - c[i][j-1] != c[i+1][j] - c[i+1][j-1]:
            print('No')
            quit()
for i in range(1,3):
    for j in range(2):
        
        
        if c[i][j] - c[i-1][j] != c[i][j+1] - c[i-1][j+1]:
            print('No')
            quit()
print('Yes')

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

Solution (Python):


c_list = []

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

a_list[0] = 0
b_list[0] = c_list[0][0]

a_list[1] = c_list[0][1] - b_list[0]
a_list[2] = c_list[0][2] - b_list[0]

b_list[1] = c_list[1][0] - a_list[0]
b_list[2] = c_list[2][0] - a_list[0]

if (
    ((a_list[1] + b_list[1]) == c_list[1][1])
    and ((a_list[2] + b_list[1]) == c_list[1][2])
    and ((a_list[1] + b_list[2]) == c_list[2][1])
    and ((a_list[2] + b_list[2]) == c_list[2][2])
    ):
    print('Yes')

else:
    print('No')

Solution (Python):

import sys
input = sys.stdin.readline









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

dx1 = C[1][0] - C[0][0]
dx2 = C[2][0] - C[1][0]
dy1 = C[0][1] - C[0][0]
dy2 = C[0][2] - C[0][1]

ans = "Yes"
for i in range(3):
    if C[1][i]-C[0][i] != dx1 or C[2][i]-C[1][i] != dx2:
        ans = "No"
        break
    if C[i][1]-C[i][0] != dy1 or C[i][2]-C[i][1] != dy2:
        ans = "No"
        break

print(ans)

Solution (Python):
import sys
grid = []
for i in range(3):
	array = list(map(int,input().strip().split()))
	grid.append(array)
point = [[0,0],[0,1],[1,0],[1,1]]


for i,j in point:
	if grid[i][j] != grid[i][j+1] + grid[i+1][j] - grid[i+1][j+1] :
		print('No')
		sys.exit()	
print('Yes')

Solution (Python):







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

all_sum = 0
right_up = 0
right_down = 0
for c in C:
    all_sum += sum(c)
right_up += (C[0][2] + C[1][1] + C[2][0])
right_down += (C[0][0] + C[1][1] + C[2][2])

if all_sum %3 == 0 and right_up == all_sum//3 and right_down == all_sum//3:
    print("Yes")
else:
    print("No")

Solution (Python):
C=[]

for _ in range(3):
    C.append(list(map(int,input().split())))

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


for b1 in range(101):
    for b2 in range(101):
        for b3 in range(101):
            a1=(sum(C[0])-(b1+b2+b3))/3
            a2=(sum(C[1])-(b1+b2+b3))/3
            a3=(sum(C[2])-(b1+b2+b3))/3
            if a1+a2+a3+3*b1==sum(TC[0]) and a1+a2+a3+3*b2==sum(TC[1]) and a1+a2+a3+3*b3==sum(TC[2]):
                print("Yes")
                exit()

print("No")

Solution (Python):
C=[list(map(int,input().split())) for i in range(3)]
x1=C[0][1]-C[0][0];x2=C[0][2]-C[0][1];
y1=C[1][0]-C[0][0];y2=C[2][0]-C[1][0];
C2=[[C[0][0],C[0][0]+x1,C[0][0]+x1+x2],
    [C[0][0]+y1,C[0][0]+x1+y1,C[0][0]+x1+x2+y1],
    [C[0][0]+y1+y2,C[0][0]+x1+y1+y2,C[0][0]+x1+x2+y1+y2]]
print("Yes"if C==C2 else"No")

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

if c1[0]-c1[1] != c2[0]-c2[1] or c1[0]-c1[1] != c3[0]-c3[1]:
    print('No')
    exit()

if c1[0]-c1[2] != c2[0]-c2[2] or c1[0]-c1[2] != c3[0]-c3[2]:
    print('No')
    exit()

if c1[0]-c2[0] != c1[1]-c2[1] or c1[0]-c2[0] != c1[2]-c2[2]:
    print('No')
    exit()

if c1[0]-c3[0] != c1[1]-c3[1] or c1[0]-c3[0] != c1[2]-c3[2]:
    print('No')
    exit()

print('Yes')

Solution (Python):
c = [[0] * 3 for _ in range(3)]


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

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

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]

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


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

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

for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            if (k[0][0] - a1) == (k[0][1] - a2) == (k[0][2] - a3):
                if (k[1][0] - a1) == (k[1][1] - a2) == (k[1][2] - a3):
                    if (k[2][0] - a1) == (k[2][1] - a2) == (k[2][2] - a3):
                        if k[0][0] - a1 >= 0 and k[0][1] - a2 >= 0 and k[0][2] - a3 >= 0:
                            if (k[1][0] - a1) >= 0 and (k[1][1] - a2) >= 0 and (k[1][2] - a3) >= 0:
                                if (k[2][0] - a1) >= 0 and (k[2][1] - a2) >= 0 and (k[2][2] - a3) >= 0:
                                    print("Yes")
                                    exit()

print("No")

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

for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            if (k[0][0] - a1) == (k[0][1] - a2) == (k[0][2] - a3):
                if (k[1][0] - a1) == (k[1][1] - a2) == (k[1][2] - a3):
                    if (k[2][0] - a1) == (k[2][1] - a2) == (k[2][2] - a3):
                        if k[0][0] - a1 >= 0 and k[0][1] - a2 >= 0 and k[0][2] - a3 >= 0:
                            if (k[1][0] - a1) >= 0 and (k[1][1] - a2) >= 0 and (k[1][2] - a3) >= 0:
                                if (k[2][0] - a1) >= 0 and (k[2][1] - a2) >= 0 and (k[2][2] - a3) >= 0:
                                    print("Yes")
                                    exit()

print("No")

Solution (Python):
C1 = list(map(int,input().split()))
C2 = list(map(int,input().split()))
C3 = list(map(int,input().split()))
a = 0
if C2[0] - C1[0] == C2[1] - C1[1] == C2[2] - C1[2]:
  a2 = C2[0] - C1[0]
  a+= 1
if C3[0] - C2[0] == C3[1] - C2[1] == C3[2] - C2[2]:
  a3 = C3[0] - C2[0]
  a+= 1
if a == 2:
  print("Yes")
else:
  print("No")

Solution (Python):
c = list(map(int,open(0).read().split()))
a = all([c[i]-c[i+1] == c[i+3]-c[i+4] for i in [0,1,3,4]])
b = all([c[i]-c[i+3] == c[i+1]-c[i+4] for i in [0,1,3,4]])
if a and b:
  print("Yes")
else:
  print("No")

Solution (Python):
c1 = [int(elem) for elem in input().split()]
c2 = [int(elem) for elem in input().split()]
c3 = [int(elem) for elem in input().split()]

x1 = c1[0] - c2[0] == c1[1] - c2[1] == c1[2] - c2[2]
x2 = c1[0] - c3[0] == c1[1] - c3[1] == c1[2] - c3[2]
x3 = c3[0] - c2[0] == c3[1] - c2[1] == c3[2] - c2[2]
x4 = c1[0] - c1[1] == c2[0] - c2[1] == c3[0] - c3[1]
x5 = c1[0] - c1[2] == c2[0] - c2[2] == c3[0] - c3[2]
x6 = c1[2] - c1[1] == c2[2] - c2[1] == c3[2] - c3[1]

if x1 and x2 and x3 and x4 and x5 and x6:
  print("Yes")
else:
  print("No")

Solution (Python):
import numpy as np
a=[list(map(int, input().split())) for _ in range(3)]
a = np.array(a)
for i in range(3):
    a[i]-=min(a[i])
print('Yes' if all(a[0]==a[1]) and all(a[1]==a[2]) else 'No')