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):
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
C = [c1, c2, c3]


f = False
for i in range(C[0][0] + 1):
    a1 = i
    b1 = C[0][0] - a1
    b2 = C[0][1] - a1
    b3 = C[0][2] - a1
    a2 = C[1][0] - b1
    a3 = C[2][0] - b1
    if a1 + b1 == C[0][0] and a1 + b2 == C[0][1] and a1 + b3 == C[0][2] and 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]:
        f = True
        break

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

Solution (Python):
import sys
import numpy as np 

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

def main(c):
    c -= c[0]
    c -= c[:, 0][:, None]
    return 'No' if np.count_nonzero(c) else 'Yes'

if __name__ == '__main__':
    ans = main(c)
    print(ans)

Solution (Python):
c = [list(map(int,input().split()))for l in range(3)]
flag=False
for i in range(c[0][0]+1):
    a1=i
    b1=c[0][0]-a1
    b2=c[0][1]-a1
    b3=c[0][2]-a1
    a2=c[1][0]-b1
    a3=c[2][0]-b1
    if c[1][1]==a2+b2 and c[1][2]==a2+b3 and c[2][1]==a3+b2 and c[2][2]==a3+b3:
        flag=True
        break
    else:
        continue

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

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(1, 3):
    a[i] = c[i][0] - b[0]

ans = "Yes"

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

print(ans)

Solution (Python):
c = [[int(i) for i in input().split()] for _ in range(3)]
cond = True
cond &= c[0][0] - c[0][1] == c[1][0] - c[1][1] == c[2][0] - c[2][1]
cond &= c[0][1] - c[0][2] == c[1][1] - c[1][2] == c[2][1] - c[2][2]
cond &= c[0][0] - c[1][0] == c[0][1] - c[1][1] == c[0][2] - c[1][2]
cond &= c[1][0] - c[2][0] == c[1][1] - c[2][1] == c[1][2] - c[2][2]
print("Yes" if cond else "No")

Solution (Python):
import sys
c_ls = []
for i in range(3):
    c = [int(i) for i in sys.stdin.readline().split()]
    c_ls.append(c)

yoko = [c_ls[0][i+1] - c_ls[0][i] for i in range(2)]
flg = True
for i in range(3):
    flg &= yoko == [c_ls[i][j+1] - c_ls[i][j] for j in range(2)]
print("Yes" if flg else "No")

Solution (Python):
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
x = min(c1)
y = min(c2)
z = min(c3)
for i in range(3):
    c1[i] -= x
    c2[i] -= y
    c3[i] -= z
print('NYoe s' [c1 == c2 == c3::2])

Solution (Python):
c = [[int(i) for i in input().split()] for _ in range(3)]
b = [0 for _ in range(3)]
ans = 'Yes'
for i in range(3):
    if i == 0:
        for j in range(3):
            b[j] = c[i][j] - c[i][(j+1)%3]
    else:
        for j in range(3):
            if b[j] != c[i][j] - c[i][(j+1)%3]:
                ans = 'No'
                break
        if ans == 'No':
            break
print(ans)

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

Solution (Python):




n = 3
e = [[int(i) for i in input().split()] for i in range(n)] 
a = []
b = []

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

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

        
print("Yes")

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


def sol():
	if (sum(C[0]) - sum(C[1])) % 3 != 0:
		return('No')
	elif (sum(C[1]) - sum(C[2])) % 3 != 0:
		return('No')
	elif (sum(C[2]) - sum(C[0])) % 3 != 0:
		return('No')
	
	elif (C[0][0] + C[1][0] + C[2][0] - (C[0][1] + C[1][1] + C[2][1])) % 3 != 0:
		return('No')
	elif (C[0][1] + C[1][1] + C[2][1] - (C[0][2] + C[1][2] + C[2][2])) % 3 != 0:
		return('No')
	elif (C[0][2] + C[1][2] + C[2][2] - (C[0][0] + C[1][0] + C[2][0])) % 3 != 0:
		return('No')
	else:
		return('Yes')

print(sol())

Solution (Python):
import sys
input = sys.stdin.readline
import numpy as np
c = []
for _ in range(3):
    c.append([int(x) for x in input().split()])
c = np.array(c)
c_t = c.T
a = c[1] - c[0]
b = c[2] - c[1]
d = c[2] - c[0]
e = c_t[1] - c_t[0]
f = c_t[2] - c_t[1]
g = c_t[2] - c_t[0]
x = []
x.append(a)
x.append(b)
x.append(d)
x.append(e)
x.append(f)
x.append(g)
x = np.array(x)
for i in x:
    if i[0] != i[1] or i[1] != i[2] or i[2] != i[0]:
        print("No")
        sys.exit()
print("Yes")

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

ans = "Yes"
for i in range(len(c)):
    mi = min(c[i])
    *c[i], = map(lambda x: x-mi, c[i])


print("Yes" if c[0] == c[1] and c[1] == c[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())

a1=0
a2=(c12-c11,c22-c21,c32-c31)
a3=(c13-c11,c23-c21,c33-c31)

if len(set(a2))==1 and len(set(a3))==1:
  print("Yes")
else:
  print("No")

Solution (Python):
import numpy as np
nums=np.array([list(map(int, input().split())) for i in range(3)])

out='Yes'
a_1=nums[1, :]-nums[0, :]
if a_1[0]!=a_1[1] or a_1[0]!=a_1[2]:
  out='No'
  
a_2=nums[2, :]-nums[1, :]
if a_2[0]!=a_2[1] or a_2[0]!=a_2[2]:
  out='No'
  
b_1=nums[:, 1]-nums[:, 0]
if b_1[0]!=b_1[1] or b_1[0]!=b_1[2]:
  out='No'
  
b_2=nums[:, 2]-nums[:, 1]
if b_2[0]!=b_2[1] or b_2[0]!=b_2[2]:
  out='No'
  
print(out)

Solution (Python):

import sys
input = sys.stdin.readline

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

Solution (Python):
grid = list()
for i in range(3):
    grid.append([int(k) for k in input().split(" ")])


def check_vert():
    for i in range(2):
        diffs = [grid[k][i] - grid[k][i+1]for k in range(3)]
        if not len(set(diffs)) == 1:
            return False
    else:
        return True


def check_hor():
    for i in range(2):
        diffs = [grid[i][k] - grid[i+1][k] for k in range(3)]
        if not len(set(diffs)) == 1:
            return False
    else:
        return True


if check_hor() and check_vert():
    print("Yes")
else:
    print("No")

Solution (Python):
c = []
for i in range(3):
    tmp = list(map(int, input().split()))
    c.append(tmp)
    
x = c[0][0] * 2 - c[1][0] - c[2][0]
y = c[0][1] * 2 - c[1][1] - c[2][1]
z = c[0][2] * 2 - c[1][2] - c[2][2]

o = c[0][2] * 2 - c[0][1] - c[0][0]
p = c[1][2] * 2 - c[1][1] - c[1][0]
q = c[2][2] * 2 - c[2][1] - c[2][0]

if x == y == z and o == p == q:
    print("Yes")
else:
    print("No")

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

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

for i in range(101):
        if i > c[0][0]:
                break
        a[0] = i 
        b[0] = c[0][0] - a[0]
        a[1] = c[1][0] - b[0]
        a[2] = c[2][0] - b[0]
        b[1] = c[0][1] - a[0] 
        b[2] = c[0][2] - a[0] 

        flag = 1 
        for i in range(3):
                for j in range(3):
                        if c[i][j] != a[i] + b[j]:
                                flag = 0 
        if flag:
                ans = "Yes"
                break

print(ans)

Solution (Python):
d,e,f=[int(i) for i in input().split()]
x,y,z=[int(i) for i in input().split()]
s,t,u=[int(i) for i in input().split()]
b=x-d
c=s-d
if b+e==y and b+f==z and c+e==t and c+f==u:
    print('Yes')
else:
    print('No')

Solution (Python):
def che(da):
  for i in range(2):
    for j in range(2):
      if da[i][j] - da[i][j+1] != da[2][j] - da[2][j+1]:
        return False
      if da[i][j] - da[i+1][j] != da[i][2] - da[i+1][2]:
        return False
  return True

da = [list(map(int,input().split())) for i in range(3)]
if che(da):
  print('Yes')
else:
  print('No')

Solution (Python):
def checker(ded, da):
  for i in range(3):
    for j in range(2):
      if da[i][j] - ded[j] != da[i][2] - ded[2]:
        return False
  return True

def ma(da):
  for i in range(-100, 101):
    for j in range(-100, 101):
      for k in range(-100, 101):
        if checker([i, j, k], da):
          return False
  return True

da = [list(map(int,input().split())) for i in range(3)]
if not ma(da):
  print('Yes')
else:
  print('No')

Solution (Python):

si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
l = [nl() for i in range(3)]
a1=0
b1=l[0][0]-a1
b2=l[0][1]-a1
b3=l[0][2]-a1
a2=l[1][0]-b1
a3=l[2][0]-b1
a = [a1,a2,a3]
b = [b1,b2,b3]

for i,aa in enumerate(a):
    for j,bb in enumerate(b):
        if l[i][j]!=aa+bb:
            print('No')
            exit()
print('Yes')

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

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

count = 0
for j in range(100):
    b1 = []
    a1 = []
    a = j

    for i in range(3):
        b1.append(c[0][i] - a)
        a1.append(c[i][0] - b1[0])

    for i in range(3):
        for j in range(3):
            if a1[i] + b1[j] != c[i][j]:
                count = 1


if count == 1:
    print('No')
else:
    print('Yes')

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

Solution (Python):
c = [[int(i) for i in input().split()] for _ in range(3)]
ans = 'Yes'
if not sum(c[0]) % 3 == sum(c[1]) % 3 == sum(c[2]) % 3:
    ans = 'No'
cc = [0, 0, 0]
for ary in c:
    cc[0] += ary[0]
    cc[1] += ary[1]
    cc[2] += ary[2]
if not cc[0] % 3 == cc[1] % 3 == cc[2] % 3:
    ans = 'No'
print(ans)

Solution (Python):
c = [list(map(int, input().split())) for _ in range(3)]
b = [c[0][0], c[0][1], c[0][2]]
a = [0, c[1][0] - b[0], 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):
c = [list(map(int, input().split())) for _ in range(3)]
cross_left = c[0][0] + c[1][1] + c[2][2]
cross_right = c[0][2] + c[1][1] + c[2][0]
total = 0
for i in range(3):
    total += sum(c[i])
if total % 3 == 0 and total // 3 == cross_left and total // 3 == cross_right:
    print('Yes')
else:
    print('No')

Solution (Python):
import numpy as np

def main()->None:
    c_1 = list(map(int, input().split()))
    c_2 = list(map(int, input().split()))
    c_3 = list(map(int, input().split()))
    c = np.array([c_1, c_2, c_3],dtype=int)

    a = np.empty(3, dtype=int)
    b = np.empty(3, dtype=int)
    
    a[0] = 0
    range_3 = range(3)
    for j in range_3:
        b[j] = c_1[j] - a[0]
    for i in range(1, 3):
        a[i] = c[i][0] - b[0]

    
    good = True
    for i, a_i in enumerate(a):
        for j, b_j in enumerate(b):
            if a_i + b_j != c[i][j]:
                good = False

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


if __name__ == "__main__":
    main()

Solution (Python):
lst = [[int(i) for i in input().split()] for _ in range(3)]
lst1 = [lst[1][i] - lst[0][i] for i in range(3)]
lst2 = [lst[2][i] - lst[0][i] for i in range(3)]
if len(set(lst1)) == 1 and len(set(lst2)) == 1:
  print('Yes')
else:
  print('No')

Solution (Python):
import numpy as np

lst = [[int(i) for i in input().split()] for _ in range(3)]
arr = np.array(lst)
if len(set(arr[1,:] - arr[0,:])) == 1 and len(set(arr[2,:] - arr[0,:])) == 1:
  print('Yes')
else:
  print('No')

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

a = c[1][0] - c[0][0]
b = c[2][0] - c[0][0]
string = "Yes"

for i in range(3):
    x = c[1][i] - c[0][i]
    if x != a:
        string = "No"

    y = c[2][i] - c[0][i]
    if y != b:
        string = "No"

print(string)

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

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

Solution (Python):
b1,b2,b3=0,0,0
check=0
for i in range(3):
    c1,c2,c3=map(int,input().split())
    if i==0:
        b1,b2,b3=c1,c2,c3
    if i==1:
        if not((c1-b1)==(c2-b2)==(c3-b3)):
            check=1
    if i==2:
        if not((c1-b1)==(c2-b2)==(c3-b3)):
            check=1
print("Yes" if check==0 else "No")

Solution (Python):
import sys
if sys.platform == 'ios':
	sys.stdin = open('input_file.txt')

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

ans = 0

for i in range(max(max(c))+1):
	
	a0 = i
	b0 = c[0][0]-a0
	b1 = c[0][1]-a0
	b2 = c[0][2]-a0	
	a1 = c[1][0]-b0	
	a2 = c[2][0]-b0
	
	if c[1][1]==a1+b1 and c[1][2]==a1+b2 and c[2][1]==a2+b1 and c[2][2]==a2+b2:
		ans = ans +1
		break

print('Yes' if ans !=0 else 'No')

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

ax=x[0][1]-x[0][0]
bx=x[0][2]-x[0][1]
for i in range(3):
    if ax!=x[i][1]-x[i][0] or bx!=x[i][2]-x[i][1]:
        print("No")
        break
else:
    ay=x[1][0]-x[0][0]
    by=x[2][0]-x[1][0]

    for i in range(3):
        if ay!=x[1][i]-x[0][i] or by!=x[2][i]-x[1][i]:
            print("No")
            break
    else:
        print("Yes")

Solution (Python):


[C11, C12, C13] = [int(i) for i in input().split()]
[C21, C22, C23] = [int(i) for i in input().split()]
[C31, C32, C33] = [int(i) for i in input().split()]

b1 = C11
b2 = C12
b3 = C13


flag_a2 = False
if (C21 - b1) == (C22 - b2) and (C21 - b1) == (C23 - b3):
    flag_a2 = True


flag_a3 = False
if (C31 - b1) == (C32 - b2) and (C31 - b1) == (C33 - b3):
    flag_a3 = True

if flag_a2 is True and flag_a3 is True:
    print('Yes')
else:
    print('No')

Solution (Python):
c_one = list(map(int, input().split()))
c_two = list(map(int, input().split()))
c_thr = list(map(int, input().split()))

a_b_ones = [(x, c_one[0]-x) for x in range(c_one[0]+1)]
a_b_twos = [(x, c_two[1]-x) for x in range(c_two[1]+1)]
a_b_thrs = [(x, c_thr[2]-x) for x in range(c_thr[2]+1)]

ans = 'No'

for p in a_b_ones:
    for q in a_b_twos:
        for r in a_b_thrs:
            a1, b1 = p[0], p[1]
            a2, b2 = q[0], q[1]
            a3, b3 = r[0], r[1]
            if (c_one[1] == a1 + b2) and (c_one[2] == a1 + b3) and (c_two[0] == a2 + b1) and (c_two[2] == a2 + b3) and (c_thr[0] == a3 + b1) and (c_thr[1] == a3 + b2):
                ans = 'Yes'
print(ans)

Solution (Python):
c = []
for i in range(3):
    C = list(map(int, input().split()))
    c.append(C)
for i in range(3):
    Min = min(c[i])
    for j in range(3):
        c[i][j] -= Min
for i in range(2):
    if c[i] == c[i + 1]:
        pass
    else:
        print("No")
        exit()
print("Yes")

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

ans = True
a1=0
b=[]
for i in range(3):
    b.append(c1[i]-a1)

a2=c2[0]-b[0]
a3=c3[0]-b[0]

for i in range(1,3):
    if a2+b[i] != c2[i] or a3+b[i] != c3[i]:
        ans = False
        break

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

Solution (Python):
C=[[int(x) for x in input().split()] for _ in range(3)]
a=[C[0][0],C[0][1],C[0][2]]
b=[0,C[1][0]-C[0][0],C[2][0]-C[0][0]]
hantei= True
for i in range(3):
  for j in range(3):
    if C[i][j]!=a[j]+b[i]:
      hantei = False
print('Yes' if hantei else'No')

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

for b1 in range(101):
    a = []
    b = []
    a1 = c[0][0] - b1
    if a1 < 0:
        break
    a.append(a1)
    b.append(b1)
    for b2 in range(101):
        a2 = c[1][1] - b2
        if a2 < 0:
            break
        a.append(a2)
        b.append(b2)
        for b3 in range(101):
            a3 = c[2][2] - b3
            if a3 < 0:
                break
            a.append(a3)
            b.append(b3)
            for i in range(3):
                for j in range(3):
                    if a[j] + b[i] != c[i][j]:
                        break
                    if i == 2 and j == 2:
                        print("Yes")
                        exit()
                if a[j] + b[i] != c[i][j]:
                    break
            b.pop()
            a.pop()
        a.pop()
        b.pop()
print("No")

Solution (Python):
C = [list(map(int,input().split())) for i in range(3)]
c1,c2,c3 = C[0]
c1,c2,c3 = c1-c2,c2-c3,c3-c2
ans = 'Yes'
for c in C[1:]:
    cc1,cc2,cc3 = c
    cc1,cc2,cc3 = cc1-cc2,cc2-cc3,cc3-cc2
    
    if c1 == cc1 and c2 == cc2 and c3 == cc3:
        pass
    else:
        ans = 'No'
        break

c1,c2,c3 = C[0][0],C[1][0],C[2][0]
c1,c2,c3 = c1-c2,c2-c3,c3-c2
for i in range(1,3):
    cc1,cc2,cc3 = C[0][i],C[1][i],C[2][i]
    cc1,cc2,cc3 = cc1-cc2,cc2-cc3,cc3-cc2
    if c1 == cc1 and c2 == cc2 and c3 == cc3:
        pass
    else:
        ans = 'No'
        break
print(ans)

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

  
for i in range(101):
  a1 = i
  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:
    if c[2][0]-b1 == c[2][1]-b2 == c[2][2]-b3:
      print('Yes')
      exit()
print('No')

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

for _ in range(100):
    a1 = i
    b1 = grid[0][0] - a1
    b2 = grid[0][1] - a1
    b3 = grid[0][2] - a1
    if  grid[1][0] - b1 == grid[1][1] - b2 == grid[1][2] - b3 and grid[2][0] - b1 == grid[2][1] - b2 == grid[2][2] - b3:
        print('Yes')
        exit()
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())

def correct(a1, a2, a3, b1, b2, b3):
  if a1 + b1 != c11:
    return False
  if a2 + b2 != c22:
    return False
  if a3 + b3 != c33:
    return False
  if a1 + b2 != c12:
    return False
  if a1 + b3 != c13:
    return False
  if a2 + b1 != c21:
    return False
  if a2 + b3 != c23:
    return False
  if a3 + b1 != c31:
    return False
  if a3 + b2 != c32:
    return False
  return True

for i in range(c11 + 1):
  a1 = i
  b1 = c11 - i
  a2 = a1 - c11 + c21
  a3 = a1 - c11 + c31
  b2 = b1 - c11 + c12
  b3 = b1 - c11 + c13
  
  if correct(a1, a2, a3, b1, b2, b3):
    print('Yes')
    exit(0)














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

def correct():
  if a1 + b2 != c12:
    return False
  if a1 + b3 != c13:
    return False
  if a2 + b1 != c21:
    return False
  if a2 + b3 != c23:
    return False
  if a3 + b1 != c31:
    return False
  if a3 + b2 != c32:
    return False
  return True

for i in range(c11 + 1):
  for j in range(c22 + 1):
    for k in range(c33 + 1):
      a1 = i
      b1 = c11 - i
      a2 = j
      b2 = c22 - j
      a3 = k
      b3 = c33 - k
      if correct():
        print('Yes')
        exit(0)

print('No')

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

ans = False
if mat[1][0] - mat[0][0] == mat[1][1] - mat[0][1] == mat[1][2] - mat[0][2]:
  if mat[2][0] - mat[0][0] == mat[2][1] - mat[0][1] and mat[2][1] - mat[0][1] == mat[2][2] - mat[0][2]:
    ans = True
 
if ans:
  print("Yes")
else:
  print("No")

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

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

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

max_1st_row = max(c[0])

for a1 in range(max_1st_row + 1):
    b = []

    for col in range(3):
        b.append(c[0][col] - a1)

    a2 = c[1][0] - b[0]

    if c[1][1] != (a2 + b[1]) or c[1][2] != (a2 + b[2]):
        continue

    a3 = c[2][0] - b[0]

    if c[2][1] != (a3 + b[1]) or c[2][2] != (a3 + b[2]):
        continue

    print('Yes')
    exit()

print('No')

Solution (Python):


import numpy as np
import scipy

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


for i in range(3):
    for j in range(3):
        if C[0][0] - C[0][j] != C[i][0] - C[i][j]:
            print("No")
            exit()
        if C[0][0] - C[i][0] != C[0][j] - C[i][j]:
            print("No")
            exit()
print("Yes")

Solution (Python):
C = [list(map(int,input().split())) for i in range(3)]
p=C[0][1]-C[0][0]
q=C[0][2]-C[0][1]
b1,b2,b3 = 0,0,0

for i in range(-200,201):
  b2=i
  b3=q-b2
  b1=b2-p
  if C[0][0]-b1==C[0][1]-b2 and  C[0][0]-b1==C[0][2]-b3:
    if C[1][0]-b1==C[1][1]-b2 and  C[1][0]-b1==C[1][2]-b3:
      if C[2][0]-b1==C[2][1]-b2 and  C[2][0]-b1==C[2][2]-b3:
        print("Yes");exit()
  
print("No")

Solution (Python):
import sys 
import numpy as np

def main():
    grid = np.array(sys.stdin.read().split(), dtype=np.int64).reshape(3, 3)
    
    grid = grid - grid[0]
    grid = grid.T 
    grid = grid - grid[0]
    if np.all(grid == 0):
        ans = 'Yes'
    else:
        ans = 'No'
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
C = [[],[],[]]
C[0] = list(map(int,input().split()))
C[1] = list(map(int,input().split()))
C[2] = list(map(int,input().split()))

cond0_0 = C[0][0] - C[0][1] == C[1][0] - C[1][1] == C[2][0] - C[2][1]
cond0_1 = C[0][0] - C[0][2] == C[1][0] - C[1][2] == C[2][0] - C[2][2]
cond0_2 = C[0][1] - C[0][2] == C[1][1] - C[1][2] == C[2][1] - C[2][2]
cond0 = cond0_0 and cond0_1 and cond0_2

cond1_0 = C[0][0] - C[1][0] == C[0][1] - C[1][1] == C[0][2] - C[1][2]
cond1_1 = C[0][0] - C[2][0] == C[0][1] - C[2][1] == C[0][2] - C[2][2]
cond1_2 = C[1][0] - C[2][0] == C[1][1] - C[2][1] == C[1][2] - C[2][2]
cond1 = cond1_0 and cond1_1 and cond1_2

if cond0 and cond1:
  print('Yes')
else:
  print('No')

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

flag = True
abs_a = []
for i in range(3):
    abs_a.append(abs(c[0][i] - c[1][i]))
    abs_a.append(abs(c[1][i] - c[2][i]))
    abs_a.append(abs(c[0][i] - c[2][i]))
    
if abs_a[0] == abs_a[3] and abs_a[0] == abs_a[6]:
    pass
else:
    flag = False

if abs_a[1] == abs_a[4] and abs_a[1] == abs_a[7]:
    pass
else:
    flag = False

if abs_a[2] == abs_a[5] and abs_a[2] == abs_a[8]:
    pass
else:
    flag = False

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

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

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

c = [c1, c2, c3]
row = []
p1 = p2 = p3 = 0

for i in c:
    row.append(sum(i))
    p1 += i[0]
    p2 += i[1]
    p3 += i[2]

col = [p1, p2, p3]

con1, con2, con3 = row[0] - row[1], row[0] - row[2], row[1] - row[2]
con4, con5, con6 = col[0] - col[1], col[0] - col[2], col[1] - col[2]

con = [con1, con2, con3, con4, con5, con6]

for j in con:
    if j % 3 != 0:
        print('No')
        exit()

print('Yes')

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

Solution (Python):
C = [list(map(int, input().split())) for i in range(3)]
def thr_check(a, b, c):
  if a==b and b==c and c==a:
    return True
  else:
    return False
s1 = thr_check(C[0][0] - C[0][1], C[1][0] - C[1][1], C[2][0] - C[2][1])
s2 = thr_check(C[0][1] - C[0][2], C[1][1] - C[1][2], C[2][1] - C[2][2])
s3 = thr_check(C[0][2] - C[0][0], C[1][2] - C[1][0], C[2][2] - C[2][0])
s4 = thr_check(C[0][0] - C[1][0], C[0][1] - C[1][1], C[0][2] - C[1][2])
s5 = thr_check(C[1][0] - C[2][0], C[1][1] - C[2][1], C[1][2] - C[2][2])
s6 = thr_check(C[2][0] - C[0][0], C[2][1] - C[0][1], C[2][2] - C[0][2])
if s1 and s2 and s3 and s4 and s5 and s6:
  print("Yes")
else:
  print("No")

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

Solution (Python):


c=[]
for i in range(3):
    c.append(list(map(int,input().split())))
D1=[]
stp = 0
for i in range(3):
    for j in range(3):
        for k in range(j+1,3):
            D1.append(c[i][j]-c[i][k])

for i in range(6):
    if D1[i] != D1[i+3]:
        stp += 1

D2=[]
for i in range(3):
    for j in range(3):
        for k in range(j+1,3):
            D2.append(c[j][i]-c[k][i])

for i in range(6):
    if D2[i] != D2[i+3]:
        stp += 1
if stp == 0:
    print('Yes')
else:
    print('No')

Solution (Python):

c_array = []
for i in range(3):
    c_list = [int(e) for e in input().split()]
    c_array.append(c_list)
    










































c11 = c_array[0][0]
c12 = c_array[0][1]
c13 = c_array[0][2]
c21 = c_array[1][0]
c22 = c_array[1][1]
c23 = c_array[1][2]
c31 = c_array[2][0]
c32 = c_array[2][1]
c33 = c_array[2][2]

if (c11 - c12 == c21 - c22 and
    c21 - c22 == c31 - c32 and
    c11 - c12 == c31 - c32 and 
    c12 - c13 == c22 - c23 and
    c22 - c23 == c32 - c33 and
    c12 - c13 == c32 - c33 and
    c11 - c13 == c21 - c23 and
    c21 - c23 == c31 - c33 and
    c11 - c13 == c31 - c33):
    print("Yes")
else:
    print("No")

Solution (Python):
c1,c2,c3=map(int,input().split())
c4,c5,c6=map(int,input().split())
c7,c8,c9=map(int,input().split())
if c4-c1==c5-c2==c6-c3 and c7-c1==c8-c2==c9-c3:
  print("Yes")
else:
  print("No")

Solution (Python):

import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

B=list(map(int,input().split()))
A2=list(map(int,input().split()))
tmp=A2[0]-B[0]
for i in range(3):
    if not tmp==A2[i]-B[i]:
        print("No")
        exit()
        
A2=list(map(int,input().split()))
tmp=A2[0]-B[0]
for i in range(3):
    if not tmp==A2[i]-B[i]:
        print("No")
        exit()

print("Yes")

Solution (Python):
import sys
cl = []

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

if cl[0][0] + cl[1][1] != cl[1][0] + cl[0][1]:
    print("No")
    sys.exit()

if cl[1][1] + cl[2][2] != cl[1][2] + cl[2][1]:
    print("No")
    sys.exit()

if cl[0][0] + cl[2][2] != cl[0][2] + cl[2][0]:
    print("No")
    sys.exit()

print("Yes")

Solution (Python):
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

if a[0] + b[1] == a[1] + b[0] and a[2] + c[0] == a[0] + c[2] and b[2] + c[1] == b[1] + c[2]:
    print("Yes")
else:
    print("No")

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

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

ok=True

for p in range(2):
  diff=[0]*3
  for i in range(3):
    diff[i]=C[i][p+1]-C[i][p]
  if len(set(diff))>1:
    ok=False
  
for p in range(2):
  diff=[0]*3
  for i in range(3):
    diff[i]=C[p+1][i]-C[p][i]
  if len(set(diff))>1:
    ok=False

print(("No","Yes")[ok])

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

diff=[0]*3
for i in range(3):
  diff[i]=C[i][1]-C[i][0]
if len(set(diff))>1:
  ok=False
  
diff=[0]*3
for i in range(3):
  diff[i]=C[i][2]-C[i][1]
if len(set(diff))>1:
  ok=False

diff=[0]*3
for i in range(3):
  diff[i]=C[1][i]-C[0][i]
if len(set(diff))>1:
  ok=False

diff=[0]*3
for i in range(3):
  diff[i]=C[2][i]-C[1][i]
if len(set(diff))>1:
  ok=False

print(("No","Yes")[ok])

Solution (Python):
c = [list(map(int,input().split())) for _ in range(3)]
x = [0] * 3
y = [0] * 3
state=True
for i in range(3):
    y[i] = c[0][i] - x[0]
for i in range(3):
    x[i] = c[i][0] - y[0]
for i in range(3):
    for j in range(3):
        if c[i][j] != x[i] + y[j]:
            print('No')
            state = False
            break
    if state == False:
        break
if state == True:
    print('Yes')