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 i in range(3)]


A1 = [C[0][0] - C[1][0], C[0][1] - C[1][1],C[0][2] - C[1][2]]
A1.sort()
A2 = [C[1][0] - C[2][0], C[1][1] - C[2][1],C[1][2] - C[2][2]]
A2.sort()
B1 = [C[0][0] - C[0][1], C[1][0] - C[1][1],C[2][0] - C[2][1]]
B1.sort()
B2 = [C[0][1] - C[0][2], C[1][1] - C[1][2],C[2][1] - C[2][2]]
B2.sort()
if A1[0] == A1[2] and A2[0] == A2[2] and B1[0] == B1[2] and B2[0] == B2[2]:
  print('Yes')
else:
  print('No')

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    C = [[int(c) for c in input().split()] for _ in range(3)]
    possible = True
    for i in range(3):
        if abs(C[i][0] - C[(i+1) % 3][0]) == abs(C[i][1] - C[(i+1) % 3][1]) == abs(C[i][2] - C[(i+1) % 3][2]): continue
        else:
            print("No")
            break
    else:
        for j in range(3):
            if abs(C[0][j] - C[0][(j+1) % 3]) == abs(C[1][j] - C[1][(j+1) % 3]) == abs(C[2][j] - C[2][(j+1) % 3]): continue
            else:
                print("No")
                break
        else: print("Yes")

    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
c = list(list(map(int, input().split())) for _ in range(3))
c00 = c[0][0]
c11 = c[1][1]
c22 = c[2][2]
for a0 in range(c00 + 1):
    for a1 in range(c11 + 1):
        for a2 in range(c22 + 1):
            A = [a0, a1, a2]
            B = [c00 - a0, c11 - a1, c22 - a2]
            tmp = []
            for a in A:
                row = []
                for b in B:
                    row.append(a + b)
                tmp.append(row)
            if tmp == c:
                print('Yes')
                exit()
print('No')

Solution (Python):
*C, = map(int, open(0).read().split())

a1 = 0
a2 = C[3]-C[0]
a3 = C[6]-C[0]

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

A = [a1, a2, a3]
B = [b1, b2, b3]


for i in range(3):
    for j in range(3):
        if C[i*3+j] != A[i]+B[j]:
            print('No')
            exit()

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[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 = [list(map(int,input().split())) for _ in range(3)]


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

Solution (Python):
import sys
c=list(map(int,input().split()))
diffa=c[1]-c[0]
diffb=c[2]-c[1]

c=list(map(int,input().split()))
if(diffa!=(c[1]-c[0]) or diffb!=(c[2]-c[1])):
    print("No")
    sys.exit()

c=list(map(int,input().split()))
if(diffa!=(c[1]-c[0]) or diffb!=(c[2]-c[1])):
    print("No")
    sys.exit()

print("Yes")

Solution (Python):
C = [list(map(int, input().split())) for _ in range(3)]
flag = True
for i in range(2):
    if C[i+1][0]-C[i][0] == C[i+1][1]-C[i][1] and C[i+1][0]-C[i][0] ==  C[i+1][2]-C[i][2]:
        pass
    else:
        flag = False

for i in range(2):
    if C[0][i+1]-C[0][i] == C[1][i+1]-C[1][i] and C[0][i+1]-C[0][i] ==  C[2][i+1]-C[2][i]:
        pass
    else:
        flag = False

if flag:
    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):
import sys
input = sys.stdin.readline
from collections import *

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

for i in range(3):
    if c[i][1]-c[i][0]!=c[0][1]-c[0][0]:
        flag = False

for i in range(3):
    if c[i][2]-c[i][1]!=c[0][2]-c[0][1]:
        flag = False

for i in range(3):
    if c[1][i]-c[0][i]!=c[1][0]-c[0][0]:
        flag = False

for i in range(3):
    if c[2][i]-c[1][i]!=c[2][0]-c[1][0]:
        flag = False

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

Solution (Python):












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

a1, a2, a3, b1, b2, b3 = 0, c[1][0]-c[0][0], c[2][0]-c[0][0], c[0][0], c[0][1], c[0][2]



if c[0][0] == a1 + b1 and c[0][1] == a1 + b2 and c[0][2] == a1 + b3 \
    and 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")

else:

    print("No")

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

a = 0
if c13 - c12 == c23 - c22 == c33 - c32:
  if c12 - c11 == c22 - c21 == c32 - c31:
    if c33 - c23 == c32 - c22 == c31 - c21:
      if c23 - c13 == c22 - c12 == c21 - c11:
        print("Yes")
        a = 1
        
if a == 0:
  print("No")

Solution (Python):
c = [list(map(int, input().split())) for _ in range(3)]
s1=sum(c[0])
s2=sum(c[1])
s3=sum(c[2])
s4=c[0][0]+c[1][0]+c[2][0]
s5=c[0][1]+c[1][1]+c[2][1]
s6=c[0][2]+c[1][2]+c[2][2]
for x in [s2-s1, s3-s1, s5-s4, s6-s4]:
    if abs(x)%3 != 0:
        print('No')
        break
else:
    print('Yes')

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

for a1 in range(-100, 101):
  b = [c - a1 for c in C[0]]
  for a2 in range(-100, 101):
    if b != [c - a2 for c in C[1]]:
      continue
    for a3 in range(-100, 101):
      if b == [c - a3 for c in C[2]]:
        print('Yes')
        quit()

print('No')

Solution (Python):
a11,a12,a13=map(int,input().split())
a21,a22,a23=map(int,input().split())
a31,a32,a33=map(int,input().split())

if a22!=a21+a12-a11:
    print('No')
elif a23!=a21+a13-a11:
    print('No')
elif a32!=a31+a12-a11:
    print('No')
elif a33!=a31+a13-a11:
    print('No')
else:
    print('Yes')

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


def read():
    C = []
    for i in range(3):
        c1, c2, c3 = map(int, input().strip().split())
        C.append((c1, c2, c3))
    return C,

def solve(C):
    for b0 in range(101):
        for b1 in range(101):
            for b2 in range(101):
                x = C[0][0] - b0
                y = C[0][1] - b1
                z = C[0][2] - b2
                if x != y or y != z:
                    continue
                x = C[1][0] - b0
                y = C[1][1] - b1
                z = C[1][2] - b2
                if x != y or y != z:
                    continue
                x = C[2][0] - b0
                y = C[2][1] - b1
                z = C[2][2] - b2
                if x != y or y != z:
                    continue
                return "Yes"
    return "No"


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))

Solution (Python):
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
c = [LI() for _ in range(3)]
x,y,z = c[0]
for x2,y2,z2 in c[1:]:
    d = x2-x
    if not y+d==y2 or not z+d==z2:
        print('No')
        break
else:
    print('Yes')

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

if (a == c[0][1]-c[1][1]) and (a==c[0][2] - c[1][2]):
  if (b == c[1][1] - c[2][1]) and (b == c[1][2]-c[2][2]):
    if (d == c[0][1]-c[2][1]) and (d == c[0][2]-c[2][2]):
      print('Yes')
      exit()
      
      
print('No')

Solution (Python):
c11,c12,c13 = list(map(int,input().split()))
c21,c22,c23 = list(map(int,input().split()))
c31,c32,c33 = list(map(int,input().split()))
a1 = 0
b1 = c11-a1
b2 = c12-a1
b3 = c13-a1
a2 = c21-b1
a3 = c31-b1
if a2+b2==c22 and a3+b2==c32 and a2+b3==c23 and a3+b3==c33:
    print('Yes')
else:
    print('No')

Solution (Python):
def main():
    c = [list(map(int, input().split(' '))) for _ in range(3)]
    for i in range(3):
        next_i = (i + 1) % 3
        d = [c[i][j] - c[next_i][j] for j in range(3)]
        if len(set(d)) > 1:
            print('No')
            return
    for j in range(3):
        next_j = (j + 1) % 3
        d = [c[i][j] - c[i][next_j] for i in range(3)]
        if len(set(d)) > 1:
            print('No')
            return
    print('Yes')


if __name__ == '__main__':
    main()

Solution (Python):
C = [list(map(int,input().split())) for _ in range(3)]
N = 0
for i in range(3):
  N = max(N, max(C[i]))+1
for i in range(N):
  for j in range(N):
    for k in range(N):
      check = 0
      for l in range(3):
        if C[l][0]-i == C[l][1]-j == C[l][2]-k:
          check += 1
      if check == 3:
        print('Yes')
        exit()

print('No')

Solution (Python):
C = [list(map(int, input().split())) for _ in range(3)]
def check(C):
    D = [[c[1] - c[0], c[2] - c[1]] for c in C]
    if D[0] == D[1] == D[2]:
        return 0
    else:
        print('No')
        exit()
check(C)
C = [list(c) for c in zip(*C)]
check(C)
print('Yes')

Solution (Python):
grid = [list(map(int, input().split())) for _ in range(3)]
B = [x for x in grid[0]]
b = B[0]
A = [grid[i][0] - b for i in range(3)]
res = True
for i, a in enumerate(A):
    for j, b in enumerate(B):
        if grid[i][j] != a + b:
            res = False
            break
    else:
        continue
    break
print('Yes' if res else 'No')

Solution (Python):

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

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

Solution (Python):
a1 = 0
c11, c12, c13 = map(int, input().split())
b1 = c11 - a1
b2 = c12 - a1
b3 = c13 - a1

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

if c21 - b1 == c22 - b2 == c23 - b3 and c31 - b1 == c32 - b2 == c33 - b3:
    print('Yes')
else:
    print('No')

Solution (Python):
s = [list(map(int,input().split())) for i in range(3)]
num = s[0][0]
ans = "No"

for i in range(num+1):
  a_1 = num - i
  b_1 = i
  
  a_2 = s[1][0] - b_1
  a_3 = s[2][0] - b_1
  b_2 = s[0][1] - a_1
  b_3 = s[0][2] - a_1
  
  if s[1][1] != a_2+b_2:
    continue
  if s[1][2] != a_2+b_3:
    continue
  if s[2][1] != a_3+b_2:
    continue
  if s[2][2] != a_3+b_3:
    continue
    
  ans = "Yes"
  
print(ans)

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






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count





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

if b-a==e-d==h-g and c-b==f-e==i-h and a-d==b-e==c-f and d-g==e-h==f-i:
  Y()
else:
  N()

Solution (Python):
ls = [list(map(int,input().split())) for _ in range(3)]
def sub(p,q):
    return p-q
for i in range(len(ls)):
    new = [ls[i][0]]*3
    ls[i] = list(map(sub,ls[i],new))
if (list(map(sub,ls[0],ls[1])) == [0,0,0]) and (list(map(sub,ls[0],ls[2])) == [0,0,0]) and (list(map(sub,ls[2],ls[1])) == [0,0,0]):
    print("Yes")
else:
    print("No")

Solution (Python):
c=[list(map(int, input().split())) for _ in range(3)]
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] or 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] or 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] or 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 = [[int(j) for j in input().split()] for i in range(3)]
flag = True
diffb21 = c[0][1] - c[0][0]
diffb32 = c[0][2] - c[0][1]
for i in range(1, 3):
    if c[i][1] - c[i][0] != diffb21 or c[i][2] - c[i][1] != diffb32:
        flag = False
tc = list(zip(*c))
diffa21 = tc[0][1] - tc[0][0]
diffa32 = tc[0][2] - tc[0][1]
for i in range(1, 3):
    if tc[i][1] - tc[i][0] != diffa21 or tc[i][2] - tc[i][1] != diffa32:
        flag = False
print('Yes' if flag else 'No')

Solution (Python):
l = list()

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

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

Solution (Python):
n = []
m = [[0 for i in range(3)] for j in range(2)]
for x in range(3):
    n.append(list(map(int, input().split())))

k =max(n)
kaisuu = max(k) + 1

def tansa(m):
    iti = 2
    for j in range(kaisuu):
        for k in range(kaisuu):
            if j + k == n[iti][iti]:
                m[0][iti] = j
                m[1][iti] = k
                for a in range(kaisuu):
                    for b in range(kaisuu):
                        if a + b == n[iti - 1][iti - 1] and a + m[1][iti] == n[iti - 1][iti]:
                            m[0][iti - 1] = a
                            m[1][iti - 1] = b
                            for c in range(kaisuu):
                                for d in range(kaisuu):
                                    if c + d == n[iti - 2][iti - 2] and c + m[1][iti - 1] == n[iti - 2][iti - 1] and c + m[1][iti] == n[iti - 2][iti]:
                                        m[0][iti-2] = c
                                        m[1][iti-2] = d
                                        if m[0][1] + m[1][0] == n[1][0] and m[0][2] + m[1][0] == n[2][0] and m[0][2] + \
                                                m[1][1] == n[2][1]:
                                            print("Yes")
                                            exit()

tansa(m)
print("No")

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

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

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]:
	print("Yes")
else:
	print("No")

Solution (Python):
pre_x, pre_y, pre_z = None,None,None
for i in range(3):
  x,y,z = map(int, input().split())
  if pre_x is None:
    pre_x, pre_y, pre_z = x,y,z
  else:
    if pre_y-pre_x!=y-x or pre_z-pre_y!=z-y or x-pre_x!=y-pre_y or y-pre_y!= z-pre_z:
      print('No')
      break
else:
  print('Yes')

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

Solution (Python):
def check(a,C):
    vertical=False
    horizonal=False
    
    d1=C[a[0]][0]-C[a[1]][0]
    d2=C[a[0]][1]-C[a[1]][1]
    d3=C[a[0]][2]-C[a[1]][2]
    if d1==d2==d3:
        vertical=True
    
    d4=C[0][a[0]]-C[0][a[1]]
    d5=C[1][a[0]]-C[1][a[1]]
    d6=C[2][a[0]]-C[2][a[1]]
    if d4==d5==d6:
        horizonal=True
    return vertical and horizonal    

def main():
    ans=True
    C=[list(map(int,input().strip().split())) for _ in range(3)]
    x=(0,1),(0,2),(1,2)
    for e in x:
        if check(e,C)==False:
            ans=False
            break            
    return "Yes" if ans else "No"

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

Solution (Python):
def main():
    c = []
    for _ in range(3):
        c.append(list(map(int, input().split())))
    for i in range(101):
        flag1 = False
        flag2 = False
        b0 = c[0][0] - i
        b1 = c[0][1] - i
        b2 = c[0][2] - i
        a10 = c[1][0] - b0
        a11 = c[1][1] - b1
        a12 = c[1][2] - b2
        if a10 == a11 == a12:
            flag1 = True
        else:
            continue
        a20 = c[2][0] - b0
        a21 = c[2][1] - b1
        a22 = c[2][2] - b2
        if a20 == a21 == a22:
            flag2 = True
            break
    if flag1 and flag2:
        print('Yes')
    else:
        print('No')
    
if __name__ == "__main__":
    main()

Solution (Python):
c_1 = list(map(int, input().split()))
c_2 = list(map(int, input().split()))
c_3 = list(map(int, input().split()))
c = c_1 + c_2 + c_3
if sum(c) == 3 * (c_1[0] + c_2[1] + c_3[2]):
    print('Yes')
else:
    print('No')

Solution (Python):

box = []

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


for a1 in range(101):
        for a2 in range(101):
                a1_b1 = box[0][0]-a1
                a1_b2 = box[1][0]-a1
                a1_b3 = box[2][0]-a1
                a2_b1 = box[0][1]-a2
                a2_b2 = box[1][1]-a2
                a2_b3 = box[2][1]-a2
                
                f = True
                if a1_b1 != a2_b1 or a1_b2 != a2_b2 or a1_b3 != a2_b3:
                        f = False
                a1_b = [a1_b1,a1_b2,a1_b3] 
                a2_b = [a2_b1,a2_b2,a2_b3] 
                res = True
                a1_a3 = []
                a2_a3 = []
                for i in range(3):
                        if (box[i][2]-a1_b[i]) != (box[i][2]-a2_b[i]):
                                res = False
                        a1_a3.append(box[i][2] - a1_b[i])
                        a2_a3.append(box[i][2] - a2_b[i])
                
                a3 = a1_a3[0]
                for i in range(1,3):
                        if a3 != a1_a3[i]:
                                res = False
                a3_b = []
                for i in range(3):
                        a3_b.append(box[i][2]- a3)
                
                a3_b = []
                for i in range(3):
                        a3_b.append(box[i][2] - a3)
                
                a = [a1,a2,a3]
                b = a3_b

                for i in range(3):
                        for j in range(3):
                                if box[i][j] != (b[i]+a[j]):
                                        res = False

                res = True
                for i in range(3):
                        for j in range(3):
                                if box[i][j] != (b[i]+a[j]):
                                        res = False
                
                
                if res:
                        print("Yes")
                        exit()
                
print("No")

Solution (Python):
import sys

input = sys.stdin.readline


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

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

    ans = "Yes"
    if (a2 + b2 != c22) or (a2 + b3 != c23) or (a3 + b2 != c32) or (a3 + b3 != c33):
        ans = "No"

    print(ans)


if __name__ == "__main__":
    main()

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

    res = 'No'

    for i in range(101):
        b1 = C[0][0] - i
        b2 = C[0][1] - i
        b3 = C[0][2] - i
        a2 = C[1][0] - b1
        a3 = C[2][0] - b1

        if C[1][1] == a2 + b2 and C[1][2] == a2 + b3 and C[2][1] == a3 + b2 and C[2][2] == a3 + b3:
            res = 'Yes'
            break
    
    print(res)

if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np

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

ans = []

c = np.array(c)
ch = np.diff(c)

if np.all(ch[0]==ch[1]) & np.all(ch[1]==ch[2]):
    ans.append(True)
else:
    ans.append(False)

cw = np.diff(c.T)

if np.all(cw[0]==cw[1]) & np.all(cw[1]==cw[2]):
    ans.append(True)
else:
    ans.append(False)

ans = "Yes" if all(ans) else "No"
print(ans)

Solution (Python):
import numpy as np

c = [list(map(int, input().split())) for i in range(3)]
c = np.array(c)
flag = False
for a1 in range(min(c[0]) + 1):
    b1 = c[0, 0] - a1
    b2 = c[0, 1] - a1
    b3 = c[0, 2] - a1
    if c[1, 0] - b1 == c[1, 1] - b2 == c[1, 2] - b3 and c[2, 0] - b1 == c[2, 1] - b2 == c[2, 2] - b3:
        print('Yes')
        flag = True
        break
if not flag:
    print('No')

Solution (Python):






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





import numpy as np





c_np = np.array(c)





flag = True
for a1 in range(max(c_np[0])+1):
    b = [x - a1 for x in c_np[0]]

    a_tmp = c_np[:,0] - b[0]

    for i in range(2):
        a = c_np[:,i+1] - b[i+1]

        if np.allclose(a_tmp,a):
            a_tmp = a
        else:
            print("No")
            flag = False
            break
    else:
        continue
    break
if flag:
    print("Yes")

Solution (Python):


import numpy as np
import math
import sys
from collections import defaultdict
input = sys.stdin.readline
A = np.array((list(map(int,input().split()))))
B = np.array((list(map(int,input().split()))))
C = np.array((list(map(int,input().split()))))
def kc(i ,a,b,c):
    if a[i] - a[i-1] == b[i] - b[i-1] ==c[i] - c[i-1] :
        return True
    else:
        return False

def kcc(a,b,c):
    if (a-b)[0] ==(a-b)[1] == (a-b)[2] and(b-c)[0]== (b-c)[1]==(b-c)[2] and  (c-a)[0]==(c-a)[1]==(c-a)[2]:
        return True
    else:
        return False


if kcc(A,B,C) and kc(0 ,A,B,C) and kc(1 ,A,B,C) and kc(2 ,A,B,C):
    print('Yes')
else:
    print('No')

Solution (Python):
cl = []
for i in range(3):
  c = list(map(int, input().split( )))
  cl.append(c)
rcl, trcl, acl, bcl = [], [], [], []
tcl = [x for x in zip(*cl)]
for i in range(3):
  rcb = []
  trca = []
  for j in range(3):
    if j < 2:
      rc = cl[i][j] - cl[i][j + 1]
      trc = tcl[i][j] - tcl[i][j + 1]
    else:
      rc = cl[i][j] - cl[i][j - 2]
      trc = tcl[i][j] - tcl[i][j - 2]
    rcb.append(rc)
    trca.append(trc)
  rcl.append(rcb)
  trcl.append(trca)
for i in range(3):
  if i < 2:
    bc = [x - y for (x, y) in zip(rcl[i], rcl[i + 1])]
    ac = [x - y for (x, y) in zip(trcl[i], trcl[i + 1])]
  else:
    bc = [x - y for (x, y) in zip(rcl[i], rcl[i - 2])]
    ac = [x - y for (x, y) in zip(trcl[i], trcl[i - 2])]
  bcl.append(bc)
  acl.append(ac)
f = lambda x: True if x == 0 else False
aclb = [all([f(n) for n in acl[m]]) for m in range(3)]
bclb = [all([f(n) for n in bcl[m]]) for m in range(3)]
if all(aclb) & all(bclb):
  print('Yes')
else:
  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] 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):
grid = list()
for a in range(3):
    a, b, c = map(int, input().split())
    grid.append([a, b, c])

ans = 'No'

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

        a_list = [a1, a2, a3]
        b_list = [b1, b2, b3]

        count = 0
        for x in range(3):
            for y in range(3):
                if grid[x][y] == a_list[x] + b_list[y]:
                    count += 1
        if count == 9:
            ans = 'Yes'
            break

print(ans)

Solution (Python):
def main():
    import sys
    sys.setrecursionlimit(10 ** 7)

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

    def recursion(ai=0, b0=-1, b1=-1, b2=-1):
        if ai == 3:
            return True

        if ai > 0:
            d = G[ai][0] - b0
            if (G[ai][0] - b0) == (G[ai][1] - b1) == (G[ai][2] - b2) and 0 <= d <= 100:
                return recursion(ai + 1, b0, b1, b2)
            else:
                return False

        for a in range(100 + 1):
            d = G[0][0] - a
            if d < 0: break
            b0 = d

            d = G[0][1] - a
            if d < 0: break
            b1 = d

            d = G[0][2] - a
            if d < 0: break
            b2 = d

            if recursion(ai + 1, b0, b1, b2):
                return True

        return False

    cond = recursion()
    print('Yes' if cond else 'No')


if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np

c = [[0]*3] * 3

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

c = np.array(c)

if len(set(c[0] - c[1])) == 1 and len(set(c[1] - c[2])) == 1 and len(set(c[:,0] - c[:,1])) == 1 and len(set(c[:,1] - c[:,2])) == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np

c = [[0]*3] * 3

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

c = np.array(c)

if len(set(c[0] - c[1])) == 1 and len(set(c[1] - c[2])) == 1 and len(set(c[:,0] - c[:,1])) == 1 and len(set(c[:,1] - c[:,2])) == 1:
    print("Yes")
else:
    print("No")

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

    B = []
    for i in range(3):
        C = []
        for j in range(3):
            C.append(A[i][j] - min(A[i]))
        B.append(C)

    flag = True
    for i in range(3):
        if B[0][i] != B[1][i] or B[0][i] != B[2][i]:
            flag = False

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

Solution (Python):
import numpy as np

c = [[0]*3] * 3

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

c = np.array(c)

if len(set(c[0] - c[1])) == 1 and len(set(c[1] - c[2])) == 1 and len(set(c[:,0] - c[:,1])) == 1 and len(set(c[:,1] - c[:,2])) == 1:
    print("Yes")
else:
    print("No")

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

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

for i in range(1,3):
    ALL = []
    for j in range(3):
        a = C[0][j] - C[i][j]
        ALL.append(a)

    if len(set(ALL)) != 1:
        print('No')
        exit()

print('Yes')

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

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