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


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


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


print(ans)

Solution (Python):
c = [list(map(int,input().split())) for k in range(3)]
A = [sum(a) for a in c]
B = [0,0,0]
AB = 0
for y in range(3):
    for x in range(3):
        if x == y:
            AB += c[y][x]
        B[x] += c[y][x]

for k in range(3):
    t = (A[k]+B[k]-AB)
    if t >= 0 and t%3 == 0:
        pass
    else:
        print("No")
        exit(0)
print("Yes")

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

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

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

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

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

Solution (Python):

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


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

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

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

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

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

Solution (Python):
from itertools import product as p

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

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

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

print('No')

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

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  

def solve(c: "List[List[int]]"):

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

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

    print(YES)


    return



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

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

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

Solution (Python):
from functools import reduce
import math

def main():
    
    
    
    

    
    
    
    
    
    

    
    

    
    
    
    
    
    
    
    
    
    INF = float("inf")

    
    MOD = 10**9+7
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    c = []
    for _ in range(3):
        c.append(list(int(_) for _ in input().split()))
    c_row_sum = []
    c_column_sum = []
    for i in range(3):
        c_row_sum.append(sum(c[i]))
    for i in range(3):
        tmp_sum = 0
        for j in range(3):
            tmp_sum += c[j][i]
        c_column_sum.append(tmp_sum)
    
    for b in range(301):
        a1 = (c_column_sum[0] - b)/3
        a2 = (c_column_sum[1] - b)/3
        a3 = (c_column_sum[2] - b)/3
        if a1.is_integer() and a2.is_integer() and a3.is_integer():
            b1 = (c_row_sum[0]-(a1+a2+a3))/3
            b2 = (c_row_sum[1]-(a1+a2+a3))/3
            b3 = (c_row_sum[2]-(a1+a2+a3))/3
            if b1.is_integer() and b2.is_integer() and b3.is_integer():
                print('Yes')
                return
    print('No')
    
if __name__ == '__main__':
    main()

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

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

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

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

print(ans)

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


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

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

Solution (Python):


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

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

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

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

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



for a1 in range(101):
    flag = True
    b1 = c[0][0] - a1
    b2 = c[1][0] - a1
    b3 = c[2][0] - a1
    a2 = c[0][1] - b1
    if a2 != (c[1][1] - b2) or a2 != (c[2][1] - b3):
        flag = False
    a3 = c[0][2] - b1
    if a3 != (c[1][2] - b2) or a3 != (c[2][2] - b3):
        flag = False

    if a1 < 0 or a2 < 0 or a3 < 0 or b1 < 0 or b2 < 0 or b3 < 0:
        flag = False

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

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  a=LI()
  b=LI()
  c=LI()

  for i in range(2):
    if not (a[i+1]-a[i]==b[i+1]-b[i] and b[i+1]-b[i]==c[i+1]-c[i]):
      return 'No'

  return 'Yes'

print(main())

Solution (Python):
from itertools import product

C1 = [int(x) for x in input().split()]
C2 = [int(x) for x in input().split()]
C3 = [int(x) for x in input().split()]
R1 = [c[0] for c in [C1,C2,C3]]
R2 = [c[1] for c in [C1,C2,C3]]
R3 = [c[2] for c in [C1,C2,C3]]

def check(C1, C2):
    r = 1 == len(set([C1[0] - C2[0], C1[1] - C2[1], C1[2] - C2[2]]))
    return r

if all(check(c1, c2) for c1, c2, in product([C1,C2,C3], [C1,C2,C3])) and \
        all(check(c1, c2) for c1, c2 in product([R1,R2,R3], [R1,R2,R3])):
    print("Yes")
else:
    print("No")

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

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

Solution (Python):
numbertable = []
for i in range(0, 3):
	numbertable.append(list(map(int, input().split())))
flag = True
for i in range(0, 3):
	for j in range(0, 3):
		if numbertable[i][j] + numbertable[(i+1)%3][(j+1)%3] != numbertable[i][(j+1)%3] + numbertable[(i+1)%3][j]:
			flag = False
			break
	if not flag: break
if flag: print('Yes')
else: print('No')

Solution (Python):
import sys
a=[list(map(int,input().split())) for i in range(3)]
x1,x2=a[0][0]-a[0][1],a[0][0]-a[0][2]
for i in range(3):
    if a[i][0]-a[i][1]!=x1 or a[i][0]-a[i][2]!=x2: print("No"),sys.exit()

y1,y2=a[0][0]-a[1][0],a[0][0]-a[2][0]
for j in range(3):
    if a[0][j]-a[1][j]!=y1 or a[0][j]-a[2][j]!=y2: print("No"),sys.exit()

print("Yes")

Solution (Python):
a0,a1,a2=0,0,0
b0,b1,b2=0,0,0
matrix=[list(map(int,input().split())) for i in range(3)]
b0=matrix[0][0]-a0
b1=matrix[0][1]-a0
b2=matrix[0][2]-a0
a1=matrix[1][0]-b0
a2=matrix[2][0]-b0
flag=True
if matrix[1][1]==a1+b1 and matrix[1][2]==a1+b2 and matrix[2][1]==a2+b1 and matrix[2][2]==a2+b2:
    print('Yes')
else:
    print('No')

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

cnd = True

cnd &= C[0][0] - C[0][1] == C[1][0] - C[1][1]
cnd &= C[0][0] - C[0][1] == C[2][0] - C[2][1]

cnd &= C[0][0] - C[0][2] == C[1][0] - C[1][2]
cnd &= C[0][0] - C[0][2] == C[2][0] - C[2][2]

cnd &= C[0][1] - C[0][2] == C[1][1] - C[1][2]
cnd &= C[0][1] - C[0][2] == C[2][1] - C[2][2]

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

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

f = c[0][0]
s = c[0][1] - f
t = c[0][2] - f

for i in c:
    i_f = i[0]

    if i[1] != i_f + s or i[2] != i_f + t:
        print("No")
        exit()

print("Yes")

Solution (Python):
import numpy as np
c=np.array([list(map(int,input().split())) for i in range(3)])
f=True
for i in range(2):
     d=c[i,0]-c[i+1,0]
     for j in range(2):
          if c[i,j+1]-c[i+1,j+1]!=d:
               f=False
for i in range(2):
     d=c[0,i]-c[0,i+1]
     for j in range(2):
          if c[j+1,i]-c[j+1,i+1]!=d:
               f=False
print('Yes' if f else 'No')

Solution (Python):
c = [list(map(int, input().split())) for _ in range(3)]
m = 0
for col in c:
  for v in col:
    m = max(m, v)
for a1 in range(m + 1):
  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 a2 + b2 != c[1][1]:
    continue
  elif a2 + b3 != c[1][2]:
    continue
  elif a3 + b2 != c[2][1]:
    continue
  elif a3 + b3 != c[2][2]:
    continue
  else:
    print('Yes')
    break
else:
  print('No')

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

b2_1 = c[0][1] - c[0][0]
b3_1 = c[0][2] - c[0][0]

if any([b2_1 != c[x][1] - c[x][0] for x in [1, 2]]) or any([b3_1 != c[x][2] - c[x][0] for x in [1, 2]]):
    print("No")
else:
    print("Yes")

Solution (Python):
nums=[]
for i in range(3):
  nums.append(list(map(int,input().split())))
subd=[]
for i in range(3):
  subd.append([nums[i][0]-nums[i][1],nums[i][1]-nums[i][2]])
for i in range(3):
  subd.append([nums[0][i]-nums[1][i],nums[1][i]-nums[2][i]])
if subd[0]==subd[1] and subd[1]==subd[2] and subd[3]==subd[4] and subd[4]==subd[5]:
  print("Yes")
else:
  print("No")

Solution (Python):
C = [list(map(int, input().split())) for _ in range(3)]
a = [0] * 3
b = [0] * 3
flg = True
for j in range(3):
    b[j] = C[0][j] - a[0]

for j in range(1, 3):
    a[j] = C[j][0] - b[0]
for j in range(3):
    for k in range(3):
        if C[j][k] != a[j] + b[k]:
            flg = False
            break
if flg:
    print('Yes')
    quit()
print('No')

Solution (Python):
C = [list(map(int, input().split())) for _ in range(3)]
a = [0] * 3
b = [0] * 3
for i in range(101):
    a[0] = i
    flg = True
    for j in range(3):
        b[j] = C[0][j] - i
        if b[j] < 0:
            flg = False
            break
    if flg:
        for j in range(1, 3):
            a[j] = C[j][0] - b[0]
            if a[j] < 0:
                flg = False
                break
    if flg:
        for j in range(3):
            for k in range(3):
                if C[j][k] != a[j] + b[k]:
                    flg = False
                    break
        if flg:
            print('Yes')
            quit()
print('No')

Solution (Python):


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):
c=[list(map(int,input().split())) for i in range(3)]
a=[0]*3
b=[0]*3
a[0]=min(c[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][1]-b[1]
a[2]=c[2][2]-b[2]
for i in range(3):
    for j in range(3):
        if a[i]+b[j]!=c[i][j]:
            print("No")
            break
    else:continue
    break
else:print("Yes")

Solution (Python):
a1 , b1 , c1 = (int(i) for i in input().split())
a2 , b2 , c2 = (int(i) for i in input().split())
a3 , b3 , c3 = (int(i) for i in input().split())
am = min(a1,a2,a3)
bm = min(b1,b2,b3)
cm = min(c1,c2,c3)
a = [a1-am,a2-am,a3-am]
b = [b1-bm,b2-bm,b3-bm]
c = [c1-cm,c2-cm,c3-cm]
if a == b == c:
    print("Yes")
else:
    print("No")

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

total = 0
for i in range(3):
    for j in range(3):
        total += lst[i][j]

total = total//3

flag = True
for i in range(3):
    a = lst[0][i%3]+lst[1][(i+1)%3]+lst[2][(i+2)%3]
    if a != total:
        flag = False

a = lst[0][0] + lst[1][2] + lst[2][1]
if a != total:
    flag = False

a = lst[1][1] + lst[0][2] + lst[2][0]
if a != total:
    flag = False

a = lst[2][2] + lst[1][0] + lst[0][1]
if a != total:
    flag = False

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

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

for a1 in range(101):
    b1 = c[0][0] - a1
    b2 = c[0][1] - a1
    b3 = c[0][2] - a1
    a2_1 = c[1][0] - b1
    a2_2 = c[1][1] - b2
    a2_3 = c[1][2] - b3
    a3_1 = c[2][0] - b1
    a3_2 = c[2][1] - b2
    a3_3 = c[2][2] - b3
    if (a2_1 == a2_2 == a2_3) and (a3_1 == a3_2 == a3_3):
        print('Yes')
        exit()

print('No')

Solution (Python):
C = [list(map(int,input().split())) for i in range(3)]
cii_sum = sum([C[i][i] for i in range(3)])
C_sum = sum(list(map(sum,C)))
print("Yes" if cii_sum==(C_sum/3) else "No")

Solution (Python):
C = [list(map(int,input().split())) for i in range(3)]
cii_sum = sum([C[i][i] for i in range(3)])
C_sum = sum(list(map(sum,C)))
print("Yes" if cii_sum==(C_sum/3) else "No")

Solution (Python):
import numpy as np

c = np.array([list(map(int, input().split())) for _ in range(3)])
diff = np.diff(c, n=1)
for n in range(1, diff.shape[0]):
    if not all(diff[n] == diff[0]):
        print('No')
        break
else:
    print('Yes')

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

if all(c[i][0]-c[0][0]==c[i][1]-c[0][1] and c[i][1]-c[0][1]==c[i][2]-c[0][2] for i in [1,2]):
    print('Yes')
else:
    print('No')

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  

def solve(c: "List[List[int]]"):
    if (c[0][1] - c[0][0] == c[1][1] - c[1][0] and
        c[0][1] - c[0][0] == c[2][1] - c[2][0] and
        c[0][2] - c[0][1] == c[1][2] - c[1][1] and
        c[0][2] - c[0][1] == c[2][2] - c[2][1] and
        c[1][0] - c[0][0] == c[1][1] - c[0][1] and
        c[2][0] - c[1][0] == c[2][1] - c[1][1]):
        ret = YES
    else:
        ret = NO
    print(ret)
    return


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):
c = [list(map(int,input().split())) for _ in range(3) ]
for a1 in range(101):
    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 a2+b1==c[1][0] and a2+b2==c[1][1] and a2+b3==c[1][2] and a3+b1==c[2][0] and a3+b2==c[2][1] and a3+b3==c[2][2]:
        print("Yes")
        break
else:
    print("No")

Solution (Python):
c=[]
for i in range(3):
    ci=list(map(int,input().split()))
    c.append(ci)
for i in range(101):
    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
    a=[a1,a2,a3]
    b=[b1,b2,b3]
    T=True
    for j in range(3):
        for k in range(3):
            if c[j][k]!=a[j]+b[k]:
                T=False
                break
    if T:
        print("Yes")
        quit()
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]:
    print('Yes')
else:
    print('No')

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



import sys

input = sys.stdin.readline

def main():
    G = [[0 for _ in range(3)] for _ in range(3)]
    for i in range(3):
        G[i] = [int(e) for e in input().split()]

    for a0 in range(0, 100+1):
        b0 = G[0][0] - a0
        b1 = G[0][1] - a0
        b2 = G[0][2] - a0

        a1 = G[1][0] - b0
        a2 = G[2][0] - b0

        if a0 + b0 == G[0][0] and \
           a0 + b1 == G[0][1] and \
           a0 + b2 == G[0][2] and \
           a1 + b0 == G[1][0] and \
           a1 + b1 == G[1][1] and \
           a1 + b2 == G[1][2] and \
           a2 + b0 == G[2][0] and \
           a2 + b1 == G[2][1] and \
           a2 + b2 == G[2][2]:
               print("Yes")
               return
    print("No")


main()

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

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

A = [sum(c) for c in C]
B = [C[0][i] + C[1][i] + C[2][i] for i in range(3)]

is_correct = True
for i in range(3):
    for j in range(i, 3):
        if abs(A[i] - A[j]) % 3 != 0:
            is_correct = False
        if abs(B[i] - B[j]) % 3 != 0:
            is_correct = False

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

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

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

x = [list() for _ in range(2)]
y = [list() for _ in range(2)]
for i in range(3):
  for j in range(2):
    x[j].append(C[i][j] - C[i][j+1])
    y[j].append(C[j][i] - C[j+1][i])

out = False
for j in range(2):
  if min(x[j]) != max(x[j]):
    break
  if min(y[j]) != max(y[j]):
    break
else:
  print("Yes")
  out = True
if not out:
  print("No")

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


if (grid[0][0] - grid[1][0]) == (grid[0][1] - grid[1][1]) == (grid[0][2] - grid[1][2]) and (grid[0][0]-grid[0][1]) == (grid[1][0]-grid[1][1]) == (grid[2][0] - grid[2][1]) and(grid[0][0] - grid[2][0]) == (grid[0][1] - grid[2][1]) == (grid[0][2] - grid[2][2]) and  (grid[0][0]-grid[0][2]) == (grid[1][0]-grid[1][2]) == (grid[2][0] - grid[2][2]):

    print('Yes')

else:
    print('No')

Solution (Python):


from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


class UnionFind:

    def __init__(self, n):
        self.parent = [i for i in range(n)]

    def root(self, i):
        if self.parent[i] == i:
            return i
        self.parent[i] = self.root(self.parent[i])
        return self.parent[i]

    def unite(self, i, j):
        rooti = self.root(i)
        rootj = self.root(j)
        if rooti == rootj:
            return
        if rooti < rootj:
            self.parent[rootj] = rooti
        else:
            self.parent[rooti] = rootj

    def same(self, i, j):
        return self.root(i) == self.root(j)





def main():
    c = [intina() for _ in range(3)]

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

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

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

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

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

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

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

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

    print('Yes')


if __name__ == '__main__':
    main()

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

for i in range(3):
    a2.append(C[0][i]-C[1][i])
    a3.append(C[0][i]-C[2][i])
if len(set(a2))==1 and len(set(a3))==1:
    print('Yes')
else:
    print('No')

Solution (Python):
l=[list(map(int,input().split())) for _ in range(3)]
for i in range(2):
	if len(set([l[i+1][j]-l[i][j] for j in range(3)]))!=1 or len(set([l[j][i+1]-l[j][i] for j in range(3)]))!=1:
		print('No')
		break
else:print('Yes')

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

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

for i in range(101):
    flag = True
    a[0] = i
    b[0] = c[0][0]-a[0]
    b[1] = c[0][1]-a[0]
    b[2] = c[0][2]-a[0]
    a[1] = c[1][0]-b[0]
    a[2] = c[2][0]-b[0]
    for j in range(1,3):
        for k in range(1,3):
            if a[j] + b[k] != c[j][k]:
                flag = False
                break
        else:continue
        break
    
    if flag:
        break
    
if flag:
    print('Yes')
else:
    print('No')

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

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

F = False

for i in range(100):
	b1 = lst[0][0] - i
	b2 = lst[0][1] - i
	b3 = lst[0][2] - i
	if lst[1][0] - b1 == lst[1][1] - b2 and +\
	lst[1][1] - b2 == lst[1][2] - b3 and +\
	lst[2][0] - b1 == lst[2][1] - b2 and +\
	lst[2][1] - b2 == lst[2][2] - b3:
		F = True

if F == False:
  print("No")
else:
  print("Yes")

Solution (Python):


def main():
    a = list(map(int, input().split()))
    a1, a2 = a[1] - a[0], a[2] - a[1]

    b = list(map(int, input().split()))
    b1, b2 = b[1] - b[0], b[2] - b[1]

    c = list(map(int, input().split()))
    c1, c2 = c[1] - c[0], c[2] - c[1]

    if a1 == b1 == c1 and a2 == b2 == c2:
        print('Yes')
    else:
        print('No')



if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np

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

col_0 = [A[0][1]-A[0][0], A[0][2]-A[0][0]]
col_1 = [A[1][1]-A[1][0], A[1][2]-A[1][0]]
col_2 = [A[2][1]-A[2][0], A[2][2]-A[2][0]]

bool = (col_0 == col_1) and (col_0 == col_2)

if bool == True:
  print('Yes')
else:
  print('No')

Solution (Python):
import numpy as np

C = np.zeros((3, 3))
for i in range(3):
    C[i, 0], C[i, 1], C[i, 2] = [int(_) for _ in input().split()]

for i in range(3):
    for j in range(2):
        if not(C[i, 0] - C[j, 0] == C[i, 1] - C[j, 1] == C[i, 2] - C[j, 2])\
                or not\
                (C[0, i] - C[0, j] == C[1, i] - C[1, j] == C[2, i] - C[2, j]):
            print('No')
            quit()
print('Yes')

Solution (Python):
H = 3
W = 3
C = []
for _ in range(H):
    C.append([int(i) for i in input().split()])


Hs = [[] for _ in range(H)]
for i in range(H):
    Hs[i].append(C[i][0] - C[i][1])
    Hs[i].append(C[i][1] - C[i][2])
    Hs[i].append(C[i][2] - C[i][0])

Ws = [[] for _ in range(H)]
for i in range(H):
    Ws[i].append(C[0][i] - C[1][i])
    Ws[i].append(C[1][i] - C[2][i])
    Ws[i].append(C[2][i] - C[0][i])

if all([Hs[0] == h for h in Hs]) and all([Ws[0] == w for w in Ws]):
    print("Yes")
else:
    print("No")

Solution (Python):
c = [list(map(int, input().split())) for i in range(3)]
x = [0 for i in range(len(c))]
for i, line in enumerate(c):
    for j in range(len(c)):
            x[j] += line[(i+j) % len(c)]
print('Yes' if all(x[i] == x[0] for i in range(len(c))) else 'No')

Solution (Python):
lis1 = []
lis2 = []
lis3 = []
count = 0
flag = 0
for num in input().split():
    lis1.append(int(num))
for num in input().split():
    lis2.append(int(num))
for num in input().split():
    lis3.append(int(num))
for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            if lis1[0] - a1 == lis2[0] - a2 == lis3[0] - a3:
        	    if lis1[1] - a1 == lis2[1] - a2 == lis3[1] - a3:
		            if lis1[2] - a1 == lis2[2] - a2 == lis3[2] - a3:
             	 		print("Yes")
             	 		flag = 1
             	 		break
        if flag == 1:
            break
    if flag == 1:
        break
    if a1 == 100 and flag == 0:
      	print("No")