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 =[]
c = [list(map(int,input().split())) for _ in range(3)]
count=0
for i in range(2):
    for j in range(2):
        if (c[i][j]+c[i+1][j+1]) == (c[i][j+1] + c[i+1][j]):
            count += 1
if count == 4:
    print('Yes')
else:
    print('No')

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

for i in range(3):
    p = min(C[i])
    for j in range(3):
        C[i][j] -= p

ans = True
for i in range(3):
    if(C[i][0]==C[i][1]==C[i][2]):
        continue
    else:
        ans = False
if(not ans):
    ans = True
    for i in range(3):
        if(C[0][i]==C[1][i]==C[2][i]):
            continue
        else:
            ans = False
print("Yes") if ans else print("No")

Solution (Python):
c =[]
c = [list(map(int,input().split())) for _ in range(3)]
count=0
for i in range(2):
    for j in range(2):
        if (c[i][j]+c[i+1][j+1]) == (c[i][j+1] + c[i+1][j]):
            count += 1
if count == 4:
    print('Yes')
else:
    print('No')

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


for a in range(0,101):
    for b in range(0,101):
        for c in range(0,101):
                        a1 = a
                        a2 = b
                        a3 = c
                        b1 = c1[0] - a1
                        b2 = c1[1] - a1
                        b3 = c1[2] - a1
                        if a1 + b1 == c1[0] and a1 +b2 == c1[1] and a1 + b3 ==c1[2] \
                            and a2 + b1 == c2[0] and a2 +b2 == c2[1] and a2 + b3 ==c2[2] \
                                and a3 + b1 == c3[0] and a3 +b2 == c3[1] and a3 + b3 ==c3[2]:
                                print("Yes")
                                exit()
print("No")

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

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

for j in range(1, 3):
    a.append(c[j][j] - b[j])
ans = 'Yes'
for k in range(3):
    for m in range(3):
        if c[k][m] != a[k] + b[m]:
            ans = 'No'
            break
print(ans)

Solution (Python):
c = []
for _ in range(3):
    c.append([int(x) for x in input().split()])
ans = 'Yes'
for i in range(3):
    minv = min(c[i])
    for j in range(3):
        c[i][j] = c[i][j] - minv

for k in range(3):
    if c[0][k] == c[1][k] and c[0][k] == c[2][k]:
        pass
    else:
        ans = 'No'
print(ans)

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

b2mb1 = c_l[0][1]-c_l[0][0]
b3mb1 = c_l[0][2]-c_l[0][0]

for i in (1,2):
    if c_l[i][1] != c_l[i][0] + b2mb1:
        print('No')
        exit()
    if c_l[i][2] != c_l[i][0] + b3mb1:
        print('No')
        exit()

print('Yes')

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

if c1[1] - c1[0] == c2[1]- c2[0]:
    if c1[1] - c1[0] == c3[1]- c3[0]:
        if c1[2] - c1[0] == c2[2]- c2[0]:
            if c1[2] - c1[0] == c3[2]- c3[0]:
                if c1[0] - c2[0] == c1[1] - c2[1]:
                    if c1[0] - c2[0] == c1[2] - c2[2]:
                        if c1[0] - c3[0] == c1[1] - c3[1]:
                            if c1[0] - c3[0] == c1[2] - c3[2]:
                                flag = True
                                print('Yes')
if not flag:
    print('No')

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

ans = True

for a, b in itertools.combinations(range(3), 2):
    x = c[0][a] - c[0][b]
    for j in range(1, 3):
        if x != c[j][a] - c[j][b]:
            ans = False

for a, b in itertools.combinations(range(3), 2):
    x = c[a][0] - c[b][0]
    for j in range(1, 3):
        if x != c[a][j] - c[b][j]:
            ans = False

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

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


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

a1 = c[1][0] - b[0]
a2 = c[2][0] - b[0]
a = [a0, a1, a2]
is_ok =True
for i in range(3):
    for j in range(3):
        if c[i][j] != a[i] + b[j]:
            is_ok=False
if is_ok:
    print("Yes")
else:
    print("No")

Solution (Python):
tab = [list(map(int,input().split())) for _ in range(3)]
a=[0]*3
b=[0]*3
a[0]=0
b[0]=tab[0][0]-a[0]
a[1]=tab[1][0]-b[0]
a[2]=tab[2][0]-b[0]
b[1]=tab[0][1]-a[0]
b[2]=tab[0][2]-a[0]
for i in range(3):
    for j in range(3):
        if tab[i][j]!=a[i]+b[j]:
            print('No')
            break
    else:
        continue
    break
else:
    print('Yes')

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

a = [0]*3
b = []
for i in range(3):
    b.append(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 a[i]+b[j] != c[i][j]:
            print("No")
            exit()
print("Yes")

Solution (Python):
c = []
for _ in range(3):
    c.append(list(map(int, input().split())))
a = []
for i in range(3):
    tmp = []
    for j in range(3):
        tmp.append(c[i][j%3] - c[i][(j+1)%3])
    a.append(tmp)
for i in range(2):
    for j in range(3):
        if a[i][j]!=a[i+1][j]:
            print('No')
            break
    else:
        continue
    break
else:
    print('Yes')

Solution (Python):
C=[list(map(int,input().split())) for _ in range(3)]
if C[0][0]-C[0][1]==C[1][0]-C[1][1]==C[2][0]-C[2][1]and C[0][1]-C[0][2]==C[1][1]-C[1][2]==C[2][1]-C[2][2] \
and C[0][0]-C[1][0]==C[0][1]-C[1][1]==C[0][2]-C[1][2] and C[1][0]-C[2][0]==C[1][1]-C[2][1]==C[1][2]-C[2][2]:
    print('Yes')

else: print('No')

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

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

Solution (Python):
c = [ [0,0,0] for _ in range(3)]
for i in range(3):
  c[i] = list(map(int, input().split()))
for a0 in range(101):
  b0 = c[0][0] - a0
  b1 = c[0][1] - a0
  b2 = c[0][2] - a0
  if (((c[1][0]-b0) == (c[1][1]-b1) == (c[1][2]-b2)) and
      ((c[2][0]-b0) == (c[2][1]-b1) == (c[2][2]-b2))):
    print("Yes")
    break
else:
  print("No")

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

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

for i in range(max(c[0][0], c[1][0], c[2][0]) + 1):
    a1, a2, a3 = c[0][0] - i, c[1][0] - i, c[2][0] - i
    
    if c[0][1] - a1 == c[1][1] - a2 and c[0][1] - a1 == c[2][1] - a3 and\
       c[0][2] - a1 == c[1][2] - a2 and c[0][2] - a1 == c[2][2] - a3:
       flg = True

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

Solution (Python):
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


















def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    c=[[] for _ in range(4)]
    for i in range(1,4):
        c[i] = [0]+list(map(int, input().strip().split()))
        
    def diff(i,j,k):
        return c[k][i] - c[k][j]
    if diff(3,2,1)==diff(3,2,2)==diff(3,2,3) and diff(2,1,1)==diff(2,1,2)==diff(2,1,3):
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

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

Solution (Python):
def II(): return int(input())
def MI(): return map(int,input().split())
def LMI(): return list(map(int,input().split()))
def LIIN(n): return list(int(input()) for _ in range(n))
def LMIN(n): return [list(map(int, input().split())) for _ in range(n)]
def IS(): return input()
def MS(): return map(str,input().split())
def LMS(): return list(map(str,input().split()))
def LISN(n): return list(input() for _ in range(n))
def LMSN(n): return [input().split() for _ in range(n)]
MOD = 10**9+7
INF = 10**18

def main():
    x = [0] * 3
    y = [0] * 3
    a = LMIN(3)

    x[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]

    for i in range(3):
        for j in range(3):
            if x[i]+y[j] != a[i][j]:
                print('No')
                return 0
    print('Yes')

if __name__ == '__main__':
    main()

Solution (Python):
def myAnswer(C:list) -> int:
   return "Yes" if(C[0][0] + C[1][1] + C[2][2] == C[0][1]+C[1][2]+C[2][0] == C[0][2]+C[1][0]+C[2][1]) else "No"




def modelAnswer():
   return
def main():
   C = [list(map(int,input().split())) for _ in range(3)]
   print(myAnswer(C[:]))
   
if __name__ == '__main__':
   main()

Solution (Python):
def main():
    C = [[int(_) for _ in input().split()] for i in range(3)]
    if C[0][0] - C[0][1] == C[1][0] - C[1][1] and C[2][0] - C[2][1] == C[1][0] - C[1][1]:
        if C[0][1] - C[0][2] == C[1][1] - C[1][2] and C[2][1] - C[2][2] == C[1][1] - C[1][2]:
            print("Yes")
            return
    print("No")


if __name__ == "__main__":
    main()

Solution (Python):
S = [list(map(int,input().split()))for i in range(3)]
check = False
for i in range(101):
  for j in range(101):
    if (S[0][0]-i == S[1][0]-j and S[0][1]-i == S[1][1]-j) and S[0][2]-i == S[1][2]-j:
      if (S[2][0]-S[0][0] == S[2][1]-S[0][1])and(S[2][0]-S[0][0] == S[2][2]-S[0][2]):
        check = True
        print('Yes')
        exit()
if check == False: print('No')

Solution (Python):
import numpy as np
from numpy.linalg import matrix_rank
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]])

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

Ac = np.array([[1,0,0,1,0,0, c11],
            [1,0,0,0,1,0, c12],
            [1,0,0,0,0,1, c13],
            [0,1,0,1,0,0, c21],
            [0,1,0,0,1,0, c22],
            [0,1,0,0,0,1, c23],
            [0,0,1,1,0,0, c31],
            [0,0,1,0,1,0, c32],
            [0,0,1,0,0,1, c33]])

if matrix_rank(A) == matrix_rank(Ac):
    print("Yes")
else:
    print("No")

Solution (Python):
l = [[int(i) for i in input().split()] for x in range(3)]
total1 = 0
total2 = 0
for i in range(3):
    total1 += sum(l[i])
    total2 += l[i][i]
    
if total1 == total2 * 3:
    print('Yes')
else:
    print('No')

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

total1 = 0
total2 = 0


for i in range(3):
    total1 += sum(l[i])
    total2 += l[i][i]
    
if total1 == total2 * 3:
    print('Yes')
else:
    print('No')

Solution (Python):
c = [list(map(int,input().split())) for _ in range(3)]
a1 = 0
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
flag = c[1][1] == a2 + b2 and c[1][2] == a2 + b3 and c[2][1] == a3 + b2 and c[2][2] == a3 + b3

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

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

flag = False

for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            if (a[0][0]-a1 == a[1][0]-a2 == a[2][0]-a3) and (a[0][1]-a1 == a[1][1]-a2 == a[2][1]-a3) and (a[0][2]-a1 == a[1][2]-a2 == a[2][2]-a3):
                flag = True
                break
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):
def readlines():
    for _ in range(3):
        yield list(map(int, input().split()))

c = list(readlines())

a1 = 0
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
ok = (c[1][1] == a2 + b2 and c[1][2] == a2 + b3 and
      c[2][1] == a3 + b2 and c[2][2] == a3 + b3)

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

Solution (Python):
def readlines():
    for _ in range(3):
        yield list(map(int, input().split()))

c = list(readlines())

def it():
    for a1 in range(100):
        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
        yield (c[1][1] == a2 + b2 and c[1][2] == a2 + b3 and
               c[2][1] == a3 + b2 and c[2][2] == a3 + b3)

print("Yes" if any(it()) else "No")

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

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

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

Solution (Python):
def resolve():
    '''
    code here
    '''

    grid = [[int(i) for i in input().split()] for _ in range(3)]

    is_flag = True

    for i in range(3):
        A = grid[0][i-1] -grid[0][i]
        C = grid[2][i-1] -grid[2][i]
        B = grid[1][i-1] -grid[1][i]

        if  A == B and B == C:
            pass
        else:
            is_flag = False

    print('Yes') if is_flag else print('No')



if __name__ == "__main__":
    resolve()

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

if not(c12-c11 == c22-c21 == c32-c31):
    print("No")
    quit()
if not(c13-c12 == c23-c22 == c33-c32):
    print("No")
    quit()
if not(c21-c11 == c22-c12 == c23-c13):
    print("No")
    quit()
if not(c31-c21 == c32-c22 == c33-c23):
    print("No")
    quit()

print("Yes")

Solution (Python):
c11,c12,c13=map(int,input().split())
c21,c22,c23=map(int,input().split())
c31,c32,c33=map(int,input().split())
if c11+c22+c33 == c12+c23+c31 == c13+c21+c32:
    print("Yes")
else:
    print("No")

Solution (Python):
a,b,c = map(int,input().split())
aa,bb,cc = map(int,input().split())
aaa,bbb,ccc = map(int,input().split())

ans = "No"
if a-aa == b-bb and b-bb == c-cc:
  if aa-aaa == bb-bbb and bb-bbb == cc-ccc:
    if a-b == aa-bb and aa-bb == aaa-bbb:
      if b-c == bb-cc and bb-cc == bbb-ccc:
        ans = "Yes"
        
print(ans)

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

if C[1][0]-C[0][0]==C[1][1]-C[0][1] and C[1][2]-C[0][2]==C[1][1]-C[0][1]:
  if C[2][0]-C[0][0]==C[2][1]-C[0][1] and C[2][2]-C[0][2]==C[2][1]-C[0][1]:
    result = 'Yes'
    
print(result)

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

if c1[0]+c2[1]+c3[2] == c1[1]+c2[2]+c3[0] == c1[2]+c2[0]+c3[1]:
    print("Yes")
else:
    print("No")

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



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

bl = True
for i in range(3):
  C = [int(x) for x in input().split()]
  for j,c in enumerate(C):
    if A[i] is None:
      A[i] = c - B[j]
    if B[j] is None:
      B[j] = c - A[i]
    if A[i]+B[j] != c:
      bl = False

answer = 'Yes' if bl else 'No'
print(answer)

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

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

    find_a1 = False
    find_a2 = False
    find_a3 = False
    find_b1 = False
    find_b2 = False
    find_b3 = False
    find_all = False

    for a in range(101):
        find_a1 = False
        find_a2 = False
        find_a3 = False
        find_b1 = False
        find_b2 = False
        find_b3 = False

        for b in range(101):
            if a + b == grid[0][0]:
                b1 = b
                find_b1 = True
            
            if a + b == grid[0][1]:
                b2 = b
                find_b2 = True
            
            if a + b == grid[0][2]:
                b3 = b
                find_b3 = True

            if find_b1 and find_b2 and find_b3 :
                a1 = a
                find_a1 = True
                break
   
        for a_ in range(101):
            if (a_ == grid[1][0] - b1) and (a_ == grid[1][1] - b2) and (a_ == grid[1][2] - b3):
                a2 = a_
                find_a2 = True
                break

        for a_ in range(101):
            if (a_ == grid[2][0] - b1) and (a_ == grid[2][1] - b2) and (a_ == grid[2][2] - b3):
                a3 = a_
                find_a3 = True
                break

        if find_a1 and find_a2 and find_a3 and find_b1 and find_b2 and find_b3:
            find_all = True
            break

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

if __name__ == "__main__":
    main()

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

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

a1=0
b1=c11
b2=c12
b3=c13
a2=c21-b1
a3=c31-b1

if c22!=a2+b2:
    print("No")
elif c23!=a2+b3:
    print("No")
elif c32!=a3+b2:
    print("No")
elif c33!=a3+b3:
    print("No")
else:
    print("Yes")

Solution (Python):




cr = list()
for i in range(3):
    cw = list(map(int,input().split()))
    cr.append(cw)

a = list()
b = list()

a.append(0)
b.append(cr[0][0] - a[0])
a.append(cr[1][0] - b[0])
b.append(cr[0][1] - a[0])
a.append(cr[2][0] - b[0])
b.append(cr[0][2] - a[0])

wkans = list()

for i in range(3):
    wkrow = list()
    for j in range(3):
        wkrow.append(cr[i][j] - (a[i] + b[j]))
    wkans.append(wkrow)





if min(wkans) == max(wkans):
    ans = 'Yes'
else:
    ans = 'No'


print(ans)

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

for row in range(3):
    for col in range(3):
        if C[row][col] - C[(row+1)%3][col] != C[row][(col+1)%3] - C[(row+1)%3][(col+1)%3]:
            print('No')
            exit()

for col in range(3):
    for row in range(3):
        if C[row][col] - C[row][(col+1)%3] != C[(row+1)%3][col] - C[(row+1)%3][(col+1)%3]:
            print('No')
            exit()

print('Yes')

Solution (Python):









import numpy as np






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

b1 = arr[0] -arr[0][0]
b2 = arr[1] -arr[1][0]
b3 = arr[2] -arr[2][0]
if not (list(b1)==list(b2)==list(b3)):
    print("No")
    exit()

arr = arr.T
a1 = arr[0]-arr[0][0]
a2 = arr[1]-arr[1][0]
a3 = arr[2]-arr[2][0]
if not(list(a1)==list(a2)==list(a3)):
    print("No")
    exit()

print("Yes")

Solution (Python):
c1 = list(map(int,input().split()))
c2 = list(map(int,input().split()))
c3 = list(map(int,input().split()))
a = c1[0]+c2[1]+c3[2]
b = c1[1]+c2[2]+c3[0]
c = c1[2]+c2[0]+c3[1]
d = c1[0]+c2[2]+c3[1]
e = c1[1]+c2[0]+c3[2]
f = c1[2]+c2[1]+c3[0]
if a==b==c==d==e==f:
  print('Yes')
else:
  print('No')

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

for i in range(2):
  for j in range(i+1,3):
    if C[i][0]-C[j][0]==C[i][1]-C[j][1] and C[i][1]-C[j][1]==C[i][2]-C[j][2] and C[i][2]-C[j][2]==C[i][0]-C[j][0]:
      continue
    else:
      print('No')
      exit()

for i in range(2):
  for j in range(i+1,3):
    if C[0][i]-C[0][j]==C[1][i]-C[1][j] and C[1][i]-C[1][j]==C[2][i]-C[2][j] and C[2][i]-C[2][j]==C[0][i]-C[0][j]:
      continue
    else:
      print('No')
      exit()

print('Yes')

Solution (Python):
grid = [list(int(s) for s in input().split()) for _ in range(3)]

flg = False
if (grid[1][0] - grid[0][0] == grid[1][1] - grid[0][1] == grid[1][2] - grid[0][2])\
        and (grid[2][0] - grid[0][0] == grid[2][1] - grid[0][1] == grid[2][2] - grid[0][2]):
    flg = True

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

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

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

a[0]=0


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

good = True

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

print('Yes')

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

a2_a1 = c2[0] - c1[0]
a3_a2 = c3[0] - c2[0]
a1_a3 = c1[0] - c3[0]

b2_b1 = c1[1] - c1[0]
b3_b2 = c1[2] - c1[1]
b1_b3 = c1[0] - c1[2]

if a2_a1 != c2[1] - c1[1] or a2_a1 != c2[2] - c1[2]:
    print("No")
elif a3_a2 != c3[1] - c2[1] or a3_a2 != c3[2] - c2[2]:
    print("No")
elif a1_a3 != c1[1] - c3[1] or a1_a3 != c1[2] - c3[2]:
    print("No")
elif b2_b1 != c2[1] - c2[0] or b2_b1 != c3[1] - c3[0]:
    print("No")
elif b3_b2 != c2[2] - c2[1] or b3_b2 != c3[2] - c3[1]:
    print("No")
elif b1_b3 != c2[0] - c2[2] or b1_b3 != c3[0] - c3[2]:
    print("No")
else:
    print("Yes")

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

if (c[1][0]-c[0][0] == c[1][1]-c[0][1] == c[1][2]-c[0][2]) and (c[2][0]-c[0][0] == c[2][1]-c[0][1] == c[2][2]-c[0][2]):
    print('Yes')

else:
    print('No')

Solution (Python):
c = [[int(i) for i in input().split()] for _ in range(3)]
flag = False
for i in range(-100,100):
    for j in range(-100,100):
        for k in range(-100,100):
            a11 = c[0][0] - i
            a12 = c[0][1] - j
            a13 = c[0][2] - k
            if  a11!=a12 or a12!=a13:
                continue
            a21 = c[1][0] - i
            a22 = c[1][1] - j
            a23 = c[1][2] - k 
            if a21!=a22 or a22!=a23:
                continue
            a31 = c[2][0] - i
            a32 = c[2][1] - j
            a33 = c[2][2] - k 
            if a31!=a32 or a32!=a33:
                continue
            flag = True
print('Yes' if flag else 'No')

Solution (Python):
c=[]
for i in range(3):
  c.append(list(map(int,input().split())))
a21=[c[1][i]-c[0][i] for i in range(3)]
a32=[c[2][i]-c[1][i] for i in range(3)]
b21=[c[i][1]-c[i][0] for i in range(3)]
b32=[c[i][2]-c[i][1] for i in range(3)]
if max(a21)!=min(a21) or max(a32)!=min(a32) or max(b21)!=min(b21) or max(b32)!=min(b32):
  print("No")
else :
  flag=False
  for a1 in range(101):
    for b1 in range(101):
      a=[a1,a1+a21[0],a1+a21[0]+a32[0]]
      b=[b1,b1+b21[0],b1+b21[0]+b32[0]]
      flagij=True
      for i in range(3):
        for j in range(3):
          if c[i][j]!=a[i]+b[j]:
            flagij=False
      flag|=flagij
  if flag:
    print("Yes")  
  else:
    print("No")

Solution (Python):
import sys
C = [list(map(int, sys.stdin.readline().split(" "))) for i in range(3)]
for a0 in range(101):
    b0 = C[0][0] - a0
    b1 = C[0][1] - a0
    b2 = C[0][2] - a0
    if (C[1][0] - b0 == C[1][1] - b1 == C[1][2] - b2) and (C[2][0] - b0 == C[2][1] - b1 == C[2][2] - b2):
        print("Yes")
        exit()
print("No")

Solution (Python):
from sys import stdin
import sys

[c11, c12, c13] = list(map(int, stdin.readline().rstrip().split()))
[c21, c22, c23] = list(map(int, stdin.readline().rstrip().split()))
[c31, c32, c33] = list(map(int, stdin.readline().rstrip().split()))

















if ((c11 + c12 + c13) - (c21 + c22 + c23)) % 3 != 0 or ((c21 + c22 + c23) - (c31 + c32 + c33)) % 3 != 0 or ((c31 + c32 + c33) - (c11 + c12 + c13)) % 3 != 0:
    print("No")

elif ((c11 + c21 + c31) - (c12 + c22 + c32)) % 3 != 0 or ((c12 + c22 + c32) - (c13 + c23 + c33)) % 3 != 0 or ((c13 + c23 + c33) - (c11 + c21 + c31)) % 3 != 0:
    print("No")

else:
    print("Yes")

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

l = []
for i in range(3):
    l.append(iil())


f = True
for i in range(1,3):
    dif0 = l[i][0] - l[i-1][0]
    dif1 = l[i][1] - l[i-1][1]
    dif2 = l[i][2] - l[i-1][2]
    if dif0 == dif1 == dif2:
        continue
    f = False

for i in range(1,3):
    dif0 = l[0][i] - l[0][i-1]
    dif1 = l[1][i] - l[1][i-1]
    dif2 = l[2][i] - l[2][i-1]
    if dif0 == dif1 == dif2:
        continue
    f = False

print('Yes' if f else 'No')

Solution (Python):


matrix = []

for _ in range(3):
    row = [int(i) for i in input().split()]
    matrix.append(row)

a1 = matrix[1][0] - matrix[0][0]
a2 = matrix[2][0] - matrix[0][0]
b1 = matrix[0][1] - matrix[0][0]
b2 = matrix[0][2] - matrix[0][0]

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

Solution (Python):
c=[]
sum1=0
sum2=0
for i in range(3):
  c.append(list(map(int, input().split())))
  sum1+=sum(c[i])
  sum2+=c[i][i]
if sum1==sum2*3:
  print('Yes')
else:
  print('No')

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    c=[list(map(int,input().split())) for _ in range(3)]
    a=[[0]*3 for _ in range(3)]
    b=[[0]*3 for _ in range(3)]
    for i in range(3):
        for j in range(3):
            a[i][j]=c[i][j]-min(c[i])
            b[j][i]=c[i][j]-min(c[0][j],c[1][j],c[2][j])
    YesNo(a[0]==a[1]==a[2] and b[0]==b[1]==b[2])

if __name__ == '__main__':
    main()

Solution (Python):
c1=list(map(int,input().split()))
c2=list(map(int,input().split()))
c3=list(map(int,input().split()))
c=[c1,c2,c3]
for i in range(2):
    if c[i][0]-c[i+1][0]!=c[i][1]-c[i+1][1] or c[i][1]-c[i+1][1]!=c[i][2]-c[i+1][2]:
        print("No")
        exit()
for j in range(2):
    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]:
        print("No")
        exit()
print("Yes")

Solution (Python):
G=[]
for i in range(3):
    g=list(map(int, input().split()))
    G.append(g)
"""
a1=x
b1=G[0][0]-a1
b2=G[0][1]-a1
b3=G[0][2]-a1
a2=G[1][0]-b1
a3=G[2][0]-b1

G[1][1]=a2+b2=G[1][0]-G[0][0]+G[0][1]
G[1][2]=a2+b3=G[1][0]-G[0][0]+G[0][2]
G[2][1]=a3+b2=G[2][0]-G[0][0]+G[0][1]
G[2][2]=a3+b3=G[2][0]-G[0][0]+G[0][2]
"""
ok=True
if G[1][1]!=G[1][0]-G[0][0]+G[0][1]:
    ok=False

if G[1][2]!=G[1][0]-G[0][0]+G[0][2]:
    ok=False
if G[2][1]!=G[2][0]-G[0][0]+G[0][1]:
    ok=False
if G[2][2]!=G[2][0]-G[0][0]+G[0][2]:
    ok=False

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

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


for a1 in range(-10000,10001):
    b1 = grid[0][0] - a1
    a2 = grid[1][0] - b1
    a3 = grid[2][0] - b1
    b2 = grid[0][1] - a1
    b3 = grid[0][2] - a1

    if a2+b2 == grid[1][1] and a2+b3 == grid[1][2] and a3+b2 == grid[2][1] and a3+b3 == grid[2][2]:
        print('Yes')
        break
else:print('No')

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

a=[0]*3
b=[0]*3
for j in range(3):
    b[j] = C[0][j] - a[0]
for i in range(3):
    a[i] = C[i][0] - b[0]
ans=True
for i in range(1,3):
    for j in range(1,3):
        if C[i][j] != a[i]+b[j]:
            ans=False
print('Yes' if ans else 'No')

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


a=[0]*3
b=[0]*3
for j in range(3):
    b[j] = C[0][j] - a[0]
for i in range(3):
    a[i] = C[i][0] - b[0]
ans=True
for i in range(1,3):
    for j in range(1,3):
        if C[i][j] != a[i]+b[j]:
            ans=False
print('Yes' if ans else 'No')

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

if not (c[2][0]-c[0][0]) == (c[2][1]-c[0][1]) == (c[2][2] - c[0][2]):
    print("No")
    exit()

if not (c[0][1]-c[0][0]) == (c[1][1]-c[1][0]) == (c[2][1] - c[2][0]):
    print("No")
    exit()

if not (c[0][2]-c[0][1]) == (c[1][2]-c[1][1]) == (c[2][2] - c[2][1]):
    print("No")
    exit()

if not (c[0][2]-c[0][0]) == (c[1][2]-c[1][0]) == (c[2][2] - c[2][0]):
    print("No")
    exit()

print("Yes")

Solution (Python):
def solve():
    C = [[int(c) for c in input().split()] for _ in range(3)]
    diffr1 = C[0][1] - C[0][0]
    diffr2 = C[0][2] - C[0][1]
    diffc1 = C[1][0] - C[0][0]
    diffc2 = C[2][0] - C[1][0]
    if C[1][1] - C[1][0] == C[2][1] - C[2][0] == diffr1:
        if C[1][2] - C[1][1] == C[2][2] - C[2][1] == diffr2:
            if C[1][1]  - C[0][1] == C[1][2] - C[0][2] == diffc1:
                if C[2][1] - C[1][1] == C[2][2] - C[1][2] == diffc2:
                    return "Yes"
    return "No"

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