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)]

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

    for a2 in range(c[1][0] + 1):
        if b1 != c[1][0] - a2:
            continue
        if b2 != c[1][1] - a2:
            continue
        if b3 != c[1][2] - a2:
            continue

        for a3 in range(c[2][0] + 1):
            if b1 != c[2][0] - a3:
                continue
            if b2 != c[2][1] - a3:
                continue
            if b3 != c[2][2] - a3:
                continue

            print("Yes")
            exit()

print("No")

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

flg = True
a1 = 0
b1 = C[0][0]
b2 = C[0][1]
b3 = C[0][2]

if not (C[1][0]-b1==C[1][1]-b2 and C[1][1]-b2==C[1][2]-b3):
    flg = False
if not (C[2][0]-b1==C[2][1]-b2 and C[2][1]-b2==C[2][2]-b3):
    flg = False

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

Solution (Python):
import sys
n = 3

c = [[-1,-1,-1] for _ in range(n)]
for i in range(n):
  c[i] = list(map(int,input().split()))
  


Flag = True
if c[1][0]-c[0][0] != c[1][1]-c[0][1] or c[1][0]-c[0][0] != c[1][2]-c[0][2]:
  print("No")
  sys.exit()
if c[2][0]-c[0][0] != c[2][1]-c[0][1] or c[2][0]-c[0][0] != c[2][2]-c[0][2]:
  print("No")
  sys.exit()
if c[0][1]-c[0][0] != c[1][1]-c[1][0] or c[2][1]-c[2][0] != c[1][1]-c[1][0]:
  print("No")
  sys.exit()
if c[0][2]-c[0][0] != c[1][2]-c[1][0] or c[2][2]-c[2][0] != c[1][2]-c[1][0]:
  print("No")
  sys.exit()
print("Yes")

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

for i in range(3):
    a_a.add(c[i][0]-c[i][1])
    a_b.add(c[i][1]-c[i][2])
    a_c.add(c[i][2]-c[i][0])
if len(a_a)==1 and len(a_b)==1 and len(a_c)==1:
    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):
C = [list(map(int, input().split())) for _ in range(3)]

for b1 in range(101):
    a1 = C[0][0] - b1
    a2 = C[0][1] - b1
    a3 = C[0][2] - b1
    for b2 in range(101):
        aa1 = C[1][0] - b2
        aa2 = C[1][1] - b2
        aa3 = C[1][2] - b2
        for b3 in range(101):
            aaa1 = C[2][0] - b3
            aaa2 = C[2][1] - b3
            aaa3 = C[2][2] - b3
            if (a1, a2, a3) == (aa1, aa2, aa3) == (aaa1, aaa2, aaa3):
                print("Yes")
                exit()

print("No")

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

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

    print("Yes")


if __name__ == '__main__':
    resolve()

Solution (Python):
import sys
from collections import Counter
from collections import deque
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

l=[lmp() for i in range(3)]
n1=l[0][0]-l[0][1]
n2=l[0][0]-l[0][2]

for i in range(1,3):

    if n1!=l[i][0]-l[i][1] or n2!=l[i][0]-l[i][2]:
        print("No")
        exit()
print("Yes")

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

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

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

j = True
for i in range(2):
    if abs(c[i+1][0]-c[i][0]) == abs(c[i+1][1]-c[i][1]) == abs(c[i+1][2]-c[i][2]):
        pass
    else:
        j = False

for i in range(2):
    if abs(c[0][i+1]-c[0][i]) == abs(c[1][i+1]-c[1][i]) == abs(c[2][i+1]-c[2][i]):
        pass
    else:
        j = False

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

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


if __name__ == '__main__':
    main()

Solution (Python):



import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

l1=LI()
l2=LI()
l3=LI()
c1=l1[0]
c2=l1[1]
c3=l1[2]
c4=l2[0]
c5=l2[1]
c6=l2[2]
c7=l3[0]
c8=l3[1]
c9=l3[2]
a1=0
b1=c1
a2=c4-c1
a3=c7-c1
b2=c2
b3=c3
count=0
if c5==a2+b2:
    count+=1
if c6==a2+b3:
    count+=1
if c8==a3+b2:
    count+=1
if c9==a3+b3:
    count+=1
if count==4:
    print("Yes")
else:
    print("No")

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

for a1 in range(0, c[0][0] + 1):
    b1 = c[0][0] - a1
    a2 = c[1][0] - b1
    a3 = c[2][0] - b1
    b2 = c[0][1] - a1
    if a2 + b2 != c[1][1]:
        continue
    if a3 + b2 != c[2][1]:
        continue
    b3 = c[0][2] - a1
    if a2 + b3 != c[1][2]:
        continue
    if a3 + b3 != c[2][2]:
        continue
    print('Yes')
    sys.exit()

print('No')

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

    for i in range(101):
        for j in range(101):
            for k in range(101):
                A = [i, j, k]
                B = [C[0][0]-A[0], C[1][1]-A[1], C[2][2]-A[2]]
                count = 0
                for l in range(3):
                    for m in range(3):
                        if C[l][m] == A[l]+B[m]:
                            count += 1
                if count == 9:
                    print('Yes')
                    return
    print('No')


if __name__ == '__main__':
    main()

Solution (Python):
c = []
for i in range(3):
    c.append(list(map(int, input().split())))
a = [0, 0, 0]
b = [0, 0, 0]
ans = False
for i in range(101):
    flag = False
    a[0] = i
    for j in range(3):
        b[j] = c[0][j] - a[0]
    for j in range(3):
        a[j] = c[j][0] - b[0] 
    
    for j in range(3):
        for k in range(3):
            if a[j] + b[k] != c[j][k]:
                flag = True
                break
        
    if flag:
        break
    else:
        ans = True
        break

print('Yes') if ans 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())
n = 'No'
if c21-c11 == c22-c12 == c23-c13:
  if c31-c11 == c32-c12 == c33-c13:
    if c12-c11 == c22-c21 == c32-c31:
      if c13-c11 == c23-c21 == c33-c31:
        print('Yes')
      else:
        print(n)
    else:
      print(n)
  else:
    print(n)
else:
  print(n)

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

R1 = [A[i][1] - A[i][0] for i in range(3)]
R2 = [A[i][2] - A[i][1] for i in range(3)]
C1 = [A[1][i] - A[0][i] for i in range(3)]
C2 = [A[2][i] - A[1][i] for i in range(3)]

ok = True
for x in [R1,R2,C1,C2]:
  if len(set(x)) != 1:
    ok = False
    break
    
if not ok:
  print('No')
else:
  print('Yes')

Solution (Python):
def main(*args, **kwargs):
    """Write Codes for contest here."""
    grid = []
    for i in range(3):
        grid.append(list(map(int, input().split())))

    
    
    
    
    
    

    for a1 in range(0, 101):
        b1_1 = grid[0][0] - a1
        b2_1 = grid[0][1] - a1
        b3_1 = grid[0][2] - a1
        for a2 in range(0, 101):
            b1_2 = grid[1][0] - a2
            b2_2 = grid[1][1] - a2
            b3_2 = grid[1][2] - a2
            for a3 in range(0, 101):
                b1_3 = grid[2][0] - a3
                b2_3 = grid[2][1] - a3
                b3_3 = grid[2][2] - a3

                
                if b1_1 == b1_2 == b1_3 and b2_1 == b2_2 == b2_3 and b3_1 == b3_2 == b3_3:
                    print('Yes')
                    return
    print('No')
    return
main()

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


def diff(arr):
    return tuple([pre_x - x for pre_x, x in zip(arr[:-1], arr[1:])])


diffs = [diff(row) for row in c]

if diffs[0] == diffs[1] == diffs[2]:
    print('Yes')
else:
    print('No')

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

for a1 in range(100 + 1):
    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')
        break
else:
    print('No')

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

ans = "No"

for a1 in range(0, 101):
    for a2 in range(0, 101):
        for a3 in range(0, 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")
                quit()

print(ans)

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

def solve():
    if not (s[0][1] - s[0][0] == s[1][1] - s[1][0] == s[2][1] - s[2][0]): return False
    if not (s[0][2] - s[0][1] == s[1][2] - s[1][1] == s[2][2] - s[2][1]): return False
    if not (s[1][0] - s[0][0] == s[1][1] - s[0][1] == s[1][2] - s[0][2]): return False
    if not (s[2][0] - s[1][0] == s[2][1] - s[1][1] == s[2][2] - s[1][2]): return False
    return True

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

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


cmax = 0
for i in c:
  for j in i:
    cmax = max(cmax,j)

ck = 0
for i in range(-cmax,cmax+1):
  a = [0,0,0]
  b = [0,0,0]

  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]
  if c[1][1] - b[1] != a[1] or c[1][2] - b[2] != a[1]:
    continue

  a[2] = c[2][0] - b[0]
  if a[2] != c[2][1] - b[1] or a[2] != c[2][2] - b[2]:
    continue

  ck = 1
  break

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

Solution (Python):
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): 
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): 
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} 
def bitArr(n):
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1

c1 = readInts()
c2 = readInts()
c3 = readInts()

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

print("No")

Solution (Python):
c = [list(map(int, input().split())) for _ in range(3)]
    
b1b2 = c[0][0]-c[1][0] == c[0][1]-c[1][1] == c[0][2]-c[1][2]
b1b3 = c[0][0]-c[2][0] == c[0][1]-c[2][1] == c[0][2]-c[2][2]
b2b3 = c[1][0]-c[2][0] == c[1][1]-c[2][1] == c[1][2]-c[2][2]

if b1b2 and b1b3 and b2b3:
    print("Yes")
else:
    print("No")

Solution (Python):

import re
import math
from collections import defaultdict
from collections import deque
import itertools
from copy import deepcopy
import random
import time
import os
import queue
import sys
import datetime
from functools import lru_cache

readline=sys.stdin.readline
sys.setrecursionlimit(2000000)

alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_pow(a,b):
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def get_primes(n,type="int"):
    if n==0:
        if type=="int":return []
        else:return [False]
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=""):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)
    return ret
def seifu(x):
    return x//abs(x)

def main():
    C=[list(map(int,input().split())) for a in range(3)]
    A=[0]*3
    B=[C[0][0],C[0][1],C[0][2]]*3
    for a in range(1,3):
        A[a]=C[a][0]-B[0]
    f=True
    for a in range(3):
        for b in range(3):
            if A[a]+B[b]!=C[a][b]:
                f=False
    Yn(f)

main()

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

c1 = L[0][2] + L[1][1] + L[2][0]
c2 = L[0][1] + L[1][0] + L[2][2]
c3 = L[0][0] + L[1][2] + L[2][1]

if (c1 == c2 and c2 == c3):
    print('Yes')
else:
    print('No')

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

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

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

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

answer = "No"
for a1 in range(101):
    b1 = numbers[0][0] - a1
    b2 = numbers[1][0] - a1
    b3 = numbers[2][0] - a1
    a2 = numbers[0][1] - b1
    a3 = numbers[0][2] - b1
    if a2 + b2 == numbers[1][1] and a3 + b2 == numbers[1][2] and a2 + b3 == numbers[2][1] and a3 + b3 == numbers[2][2] and a1 >= 0 and a2 >= 0 and a3 >= 0 and b1 >= 0 and b2 >= 0 and b3 >= 0:
        answer = "Yes"

print(answer)

Solution (Python):
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
from operator import itemgetter
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor



dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
c = [None]*3
for i in range(3):
    c[i] = [None]*3
for i in range(3):
    c[i] = readints()






def func(a, b):
    for i in range(3):
        for j in range(3):
            if a[i]+b[j] == c[i][j]:
                continue
            return False
            break
    return True


a = [None]*3
b = [None]*3

for i in range(101):
    for j in range(101):
        for k in range(101):
            for l in range(3):
                a[0] = i
                a[1] = j
                a[2] = k
                b[0] = c[l][0]-a[l]
                b[1] = c[l][1]-a[l]
                b[2] = c[l][2]-a[l]
                if func(a, b):
                    print('Yes')
                    exit()
print('No')

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

d1 = C[0][0] + C[1][1] + C[2][2]
d2 = C[1][0] + C[2][1] + C[0][2]
d3 = C[2][0] + C[0][1] + C[1][2]
if d1 == d2 == d3:
    print('Yes')
else:
    print('No')

Solution (Python):
def resolve():
	g = [list(map(int, input().split())) for _ in range(3)]
	m = max(map(max, g))
	for a in range(m+1):
		for b in range(m+1):
			for c in range(m+1):
				y = [a, b, c]
				x = [g[i][i] - y[i] for i in range(3)]
				ans = True
				for i in range(3):
					for j in range(3):
						v = y[i] + x[j]
						if g[i][j] != v:
							ans = False
				if ans:
					print('Yes')
					return

	print('No')
resolve()

Solution (Python):
s = []
judge = True

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

for i in range(3):
    for j in range(3):
        for k in range(3):
            for l in range(3):
                if i != k and k != l:
                    a = s[i][j] + s[k][l]
                    b = s[i][l] + s[k][j]
                    if a != b:
                        judge = False
                        break

if judge == True:
    print("Yes")
else:
    print("No")

Solution (Python):
import itertools
import sys
import numpy as np
import collections

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

ans=[]
cr1,cr2,cr3 = zip(c1,c2,c3)
for c in [c1,c2,c3]:
    for i,cr in enumerate([cr1,cr2,cr3]):
        a=sum(c)+sum(cr)-c[i]*3
        ans.append(a)
print('Yes' if len(set(ans))==1 else 'No')

Solution (Python):
import numpy as np

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

A = np.array([
    [1, 0, 0, 1, 0, 0],
    [1, 0, 0, 0, 1, 0],
    [1, 0, 0, 0, 0, 1],
    [0, 1, 0, 1, 0, 0],
    [0, 1, 0, 0, 1, 0],
    [0, 1, 0, 0, 0, 1],
    [0, 0, 1, 1, 0, 0],
    [0, 0, 1, 0, 1, 0],
    [0, 0, 1, 0, 0, 1]])

B = np.array([
    [1, 0, 0, 1, 0, 0, c[0][0]],
    [1, 0, 0, 0, 1, 0, c[0][1]],
    [1, 0, 0, 0, 0, 1, c[0][2]],
    [0, 1, 0, 1, 0, 0, c[1][0]],
    [0, 1, 0, 0, 1, 0, c[1][1]],
    [0, 1, 0, 0, 0, 1, c[1][2]],
    [0, 0, 1, 1, 0, 0, c[2][0]],
    [0, 0, 1, 0, 1, 0, c[2][1]],
    [0, 0, 1, 0, 0, 1, c[2][2]]])

rankA = np.linalg.matrix_rank(A)
rankB = np.linalg.matrix_rank(B)

if rankA == rankB:
    print("Yes")
else:
    print("No")

Solution (Python):
C = []
for i in range(3):
    C.append(list(map(int, input().split())))
for i in range(1,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 [[i+b1,i+b2,i+b3],[a2+b1,a2+b2,a2+b3],[a3+b1,a3+b2,a3+b3]] == C:
        print("Yes")
        exit()
print("No")

Solution (Python):
l = []

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

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

Solution (Python):
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = list(map(int, input().split()))

a = (sum(x) + sum(y) + sum(z)) / 3
b = x[0] + y[1] + z[2]
c = x[1] + y[2] + z[0]
d = x[2] + y[0] + z[1]

if a == b == c == d:
    print('Yes')
else:
    print('No')

Solution (Python):
d = [None]*3
for i in range(3):
  c = list(map(int, input().split()))
  d[i] = [c[i] - c[i+1] for i in range(2)]
print('Yes' if all(d[i] == d[i+1] for i in range(2)) 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())

N = 101

for i in range(N):
    a1 = i

    b1 = c11 - a1
    b2 = c12 - a1
    b3 = c13 - a1

    a2 = c21 - b1
    a3 = c31 - b1

if c22==a2+b2 and c23==a2+b3 and c32==a3+b2 and c33==a3+b3:
    print('Yes')
else:
    print('No')

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


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

for i in range(1,3):
    if a1!=(input_map[i][0]-input_map[i][1]):print('No');exit()
    if a2!=(input_map[i][0]-input_map[i][2]):print('No');exit()
    if a3!=(input_map[i][1]-input_map[i][2]):print('No');exit()

for i in range(1,3):
    if b1!=(input_map[0][i]-input_map[1][i]):print('No');exit()
    if b2!=(input_map[0][i]-input_map[2][i]):print('No');exit()
    if b3!=(input_map[1][i]-input_map[2][i]):print('No');exit() 

print('Yes')

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

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

flag=0

if t[1][1]-t[0][1]!=a or t[1][2]-t[0][2]!=a:
    flag=1
elif t[2][1]-t[1][1]!=b or t[2][2]-t[1][2]!=b:
    flag=1
elif t[1][1]-t[1][0]!=c or t[2][1]-t[2][0]!=c:
    flag=1
elif t[1][2]-t[1][1]!=d or t[2][2]-t[2][1]!=d:
    flag=1

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

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

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

a_ = [a1,a2,a3]
b_ = [b1,b2,b3]

flag = True
for i in range(3):
    for j in range(3):
        if c_[i][j] != a_[i] + b_[j]:
            flag = False

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

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

a=[0,0,0]
b=[0,0,0]

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]

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

Solution (Python):

r = [None] * 3
for i in range(3):
    x = list(map(int, input().split()))
    r[i] = [x[i] - x[i+1] for i in range(2)]

print('Yes' if all(r[i] == r[i+1] for i in range(2)) else 'No')

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

for i in range(2):
    c = list(map(int, input().split()))
    d = [c[i] - c[i+1] for i in range(2)]
    if b != d:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
F = [None] * 3

a = list(map(int, input().split()))
b = [a[i] - a[i+1] for i in range(2)]

for i in range(2):
    c = list(map(int, input().split()))
    d = [c[i] - c[i+1] for i in range(2)]
    if b != d:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
F = [None] * 3

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

for a1 in range(F[0][0]+1):
    b1 = F[0][0] - a1

    b2 = F[0][1] - a1
    b3 = F[0][2] - a1

    a2 = F[1][0] - b1
    a3 = F[2][0] - b1

    for i, a in enumerate([a1, a2, a3]):
        for j, b in enumerate([b1, b2, b3]):
            if F[i][j] != a + b:
                break
        else:
            continue
        break
    else:
        print('Yes')
        break
else:
    print('No')

Solution (Python):
def main():
    c = [list(map(int, input().split())) for _ in range(3)]
    f = [[x[0] - x[1], x[1] - x[2], x[2] - x[0]] for x in c]
    g = f[0] == f[1] == f[2]
    print('Yes' if g else 'No')


if __name__ == '__main__':
    main()

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

ok = False
for i in range(101):
    for j in range(101):
        a1 = i
        a2 = c21 - c11 + a1
        a3 = c31 - c11 + a1
        b1 = j
        b2 = c12 - c11 + b1
        b3 = c13 - c11 + b1
        if((c11==a1+b1)and(c12==a1+b2)and(c13==a1+b3)and(c21==a2+b1)and(c22==a2+b2)and(c23==a2+b3)and(c31==a3+b1)and(c32==a3+b2)and(c33==a3+b3)):
            ok = True
            break
    if(ok):
        break
if ok:
    print("Yes")
else:
    print("No")

Solution (Python):
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    c_arr = []
    for i in range(3):
        _ = list(map(int,_in[i].split(' ')))
        c_arr.append(_)
    
    sum_c_arr = sum([sum(c) for c in c_arr])
    if (c_arr[0][0]+c_arr[1][1]+c_arr[2][2]) == sum_c_arr/3 and \
       (c_arr[1][0]+c_arr[2][1]+c_arr[0][2]) == sum_c_arr/3 and \
       (c_arr[0][1]+c_arr[1][2]+c_arr[2][0]) == sum_c_arr/3 and \
       (c_arr[2][0]+c_arr[1][1]+c_arr[0][2]) == sum_c_arr/3 and \
       (c_arr[1][0]+c_arr[0][1]+c_arr[2][2]) == sum_c_arr/3 and \
       (c_arr[0][0]+c_arr[2][1]+c_arr[1][2]) == sum_c_arr/3:
        TF = 'Yes'
    else:
        TF = 'No'
    
    print(TF)

Solution (Python):
row1 = list(map(int, input().split()))
row2 = list(map(int, input().split()))
row3 = list(map(int, input().split()))

if (row1[1] - row1[0] != row2[1] - row2[0] or row1[1] - row1[0] != row3[1] - row3[0] or
    row1[2] - row1[1] != row2[2] - row2[1] or row1[2] - row1[1] != row3[2] - row3[1]):
    print('No')
elif (row1[0] - row2[0] != row1[1] - row2[1] or row1[0] - row2[0] != row1[2] - row2[2] or
      row1[0] - row3[0] != row1[1] - row3[1] or row1[0] - row3[0] != row1[2] - row3[2]):
    print('No')
else:
    print('Yes')

Solution (Python):
from sys import stdin
def main():
    
    readline=stdin.readline
    c=[]
    s=0
    for i in range(3):
        li=list(map(int,readline().split()))
        s+=sum(li)
        c.append(li)

    if s%3!=0:
        print("No")
    else:
        if c[0][0]+c[1][1]+c[2][2]==s//3:
            print("Yes")
        else:
            print("No")

if __name__=="__main__":
    main()

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

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



if (A[0] - A[1]) % 3 == 0 and (A[1] - A[2]) % 3 == 0 and (A[2] -
                                                          A[0]) % 3 == 0:
    if (B[0] - B[1]) % 3 == 0 and (B[1] - B[2]) % 3 == 0 and (B[2] -
                                                              B[0]) % 3 == 0:
        print('Yes')
        exit()
print('No')

Solution (Python):
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    c_arr = []
    for i in range(3):
        _ = list(map(int,_in[i].split(' ')))
        c_arr.append(_)
    
    sum_c_arr = sum([sum(c) for c in c_arr])
    if (c_arr[0][0]+c_arr[1][1]+c_arr[2][2]) == sum_c_arr/3 and \
       (c_arr[1][0]+c_arr[2][1]+c_arr[0][2]) == sum_c_arr/3 and \
       (c_arr[0][1]+c_arr[1][2]+c_arr[2][0]) == sum_c_arr/3:
        TF = 'Yes'
    else:
        TF = 'No'
    
    print(TF)