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



Sample input:
1 0 1
2 1 2
1 0 1


Sample output:
Yes

Submission status: Accepted

Solution code:
n = [[0 for i in range(3)] for j in range(3)]

for i in range(3):
  x,y,z = input().split()
  n[i][0] = int(x)
  n[i][1] = int(y)
  n[i][2] = int(z)
  
a = [0,0,0]
b = [0,0,0]



isCmp = False

for j in range(100 +1):
  b[0] = j
  
  a[0] = n[0][0] -b[0]
  a[1] = n[1][0] -b[0]
  a[2] = n[2][0] -b[0]
  b[1] = n[0][1] -a[0]
  b[2] = n[0][2] -a[0]
  
  isCmp = True
  
  for l in range(3):
    for m in range(3):
      if n[l][m] != a[l] + b[m]:
        isCmp = False
        
    if isCmp == False:
      break
      
  if isCmp == True:
    print('Yes')
    isCmp = True
    break
    
if isCmp == False:
  print('No')

Submission status: Accepted

Solution code:
mat=[]
for _ in range(3):
    c=list(map(int,input().split()))
    mat.append([
        c[1]-c[0],
        c[2]-c[1],
        c[0]-c[2]
    ])
for v in zip(*mat):
    if v[0]!=v[1] or v[1]!=v[2]:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

if c1[0]-c2[0] == c1[1]-c2[1] == c1[2]-c2[2] and \
   c2[0]-c3[0] == c2[1]-c3[1] == c2[2]-c3[2]:
  print("Yes")
else:
  print('No')

Submission status: Accepted

Solution code:
grid = [list(map(int, input().split())) for i in range(3)]
b0_1 = set()
b1_2 = set()
a0_1 = set()
a1_2 = set()

for a in range(3):
    b0_1.add(grid[a][0] - grid[a][1])
    b1_2.add(grid[a][1] - grid[a][2])

for b in range(3):
    a0_1.add(grid[0][b] - grid[1][b])
    a1_2.add(grid[1][b] - grid[2][b])

if len(b0_1) == 1 and len(b1_2) == 1 and len(a0_1) == 1 and len(a1_2) == 1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
box=[list(map(int,input().split())) for i in range(3)]
flag=1
for j in range(3):
    checker=[]
    for i in range(3):
        if j==2:
            a11=box[j][i]-box[0][i]
        else:
            a11=box[j][i]-box[j+1][i]
        checker.append(a11)
    if checker.count(checker[0])==3:
        continue
    else:
        flag=0
        break

for j in range(3):
    checker=[]
    for i in range(3):
        if j==2:
            a11=box[i][j]-box[i][0]
        else:
            a11=box[i][j]-box[i][j+1]
        checker.append(a11)
    if checker.count(checker[0])==3:
        continue
    else:
        flag=0
        break
if flag:print("Yes")
else:print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
stand = list(map(int,input().split()))
flag = 1
for i in range(2):
  now = list(map(int,input().split()))
  diff = now[0] - stand[0]
  for j in range(1,3):
    if now[j] != stand[j] + diff:
      flag = 0
if flag == 1:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

for i in range(3):
    if a != c[i][1] -c[i][0]:
        print("No")
        break
    if b != c[i][2]-c[i][1]:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

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

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

    print(NO)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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) ]  # type: "List[List[int]]"
    solve(c)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
*m,=map(int,open(0).read().split())
b=m[:3]
a=[0,m[3]-b[0],m[6]-b[0]]
for i in range(9):
  if m[i]!=a[i//3]+b[i%3]:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

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

if (lst[1][0] - lst[0][0] == lst[1][1] - lst[0][1] == lst[1][2] - lst[0][2] and\
    lst[2][0] - lst[0][0] == lst[2][1] - lst[0][1] == lst[2][2] - lst[0][2]):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
arr = [list(map(int,input().split())) for _ in range(3)]
a = []
b = []
for i in range(3):
  b.append(arr[0][i]-0)
  a.append(arr[i][0]-b[0])
for i in range(3):
  for j in range(3):
    if a[i] + b[j] != arr[i][j]:
      print("No")
      exit()
print("Yes")

Submission status: Accepted

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

    r1max = max([c11, c12, c13])
    r2max = max([c21, c22, c23])
    r3max = max([c31, c32, c33])
    c1max = max([c11, c21, c31])
    c2max = max([c12, c22, c32])
    c3max = max([c13, c23, c33])
    for a1 in range(0, r1max + 1):
        for a2 in range(0, r2max + 1):
            for a3 in range(0, r3max + 1):
                m = max([a1, a2, a3])
                for b1 in range(0, c1max - m + 1):
                    if a1 + b1 == c11 and a2 + b1 == c21 and a3 + b1 == c31:
                        for b2 in range(0, c2max - m + 1):
                            if a1 + b2 == c12 and a2 + b2 == c22 and a3 + b2 == c32:
                                for b3 in range(0, c3max - m + 1):
                                    if a1 + b3 == c13 and a2 + b3 == c23 and a3 + b3 == c33:
                                        print('Yes')
                                        return

    print('No')
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

    r1max = max([c11, c12, c13])
    r2max = max([c21, c22, c23])
    r3max = max([c31, c32, c33])
    c1max = max([c11, c21, c31])
    c2max = max([c12, c22, c32])
    c3max = max([c13, c23, c33])
    for a1 in range(0, r1max + 1):
        for a2 in range(0, r2max + 1):
            for a3 in range(0, r3max + 1):
                m = max([a1, a2, a3])
                for b1 in range(0, c1max - m + 1):
                    C11 = a1 + b1
                    C21 = a2 + b1
                    C31 = a3 + b1
                    if C11 == c11 and C21 == c21 and C31 == c31:
                        for b2 in range(0, c2max - m + 1):
                            C12 = a1 + b2
                            C22 = a2 + b2
                            C32 = a3 + b2
                            if C12 == c12 and C22 == c22 and C32 == c32:
                                for b3 in range(0, c3max - m + 1):
                                    C13 = a1 + b3
                                    C23 = a2 + b3
                                    C33 = a3 + b3
                                    if C13 == c13 and C23 == c23 and C33 == c33:
                                        print('Yes')
                                        return

    print('No')
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(c: "List[List[int]]"):
    flag = True
    for i in range(2):
        D = []
        for j in range(3):
            d = c[i+1][j] - c[i][j]
            D.append(d)
        if len(set(D)) != 1:
            flag = False
    for i in range(2):
        D = []
        for j in range(3):
            d = c[j][i+1] - c[j][i]
            D.append(d)
        if len(set(D)) != 1:
            flag = False
    if flag:
        print('Yes')
    else:
        print('No')
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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) ]  # type: "List[List[int]]"
    solve(c)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a = [list(map(int,input().split())) for i in range(3)]
x = [0]*3
y = [0]*3
flag = 0
for i in range(3):
    y[i] = a[0][i]
    x[i] = a[i][0] - y[0]
for j in range(3):
    for k in range(3):
        if not a[j][k] == (x[j] + y[k]):
            flag = 1
            break
if flag == 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

li = [list(map(int, input().split())) for _ in range(3)]
sum1 = li[0][0] + li[1][1] + li[2][2]
sum2 = li[1][0] + li[2][1] + li[0][2]
sum3 = li[2][0] + li[0][1] + li[1][2]
if sum1 ==sum2 and sum2 == sum3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
c = list(map(int, input().split()))
c += list(map(int, input().split()))
c += list(map(int, input().split()))
# 値の確定
a = [0]*3
b = [0]*3
a[0] = 0
b[0] = c[0]
a[1] = c[3] - b[0]
b[1] = c[4] - a[1]
a[2] = c[6] - b[0]
b[2] = c[8] - a[2]

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

Submission status: Accepted

Solution code:
c=[[0 for i in range(3)] for j in range(3)]


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

Submission status: Accepted

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

def validation(lol):
    ans = True
    for i in range(len(lis)):
        for j in range(len(lis)):
            if i == j:
                break
            x = list(map(lambda x, y: x-y, c[i], c[j]))
            if len(set(x)) != 1:
              ans = False
            
    return ans

lis = []

for i in range(3):
    temp = []
    for j in range(3):
        temp.append(c[j][i])
    lis.append(temp)

if validation(c) and validation(lis):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
s='Yes'
for _ in [0]*2:
    x,y,z=map(int,input().split())
    if not x-a==y-b==z-c:s='No'
print(s)

Submission status: Accepted

Solution code:
C = [[int(zz) for zz in input().split()] for _ in range(3)]

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

print('Yes')

Submission status: Accepted

Solution code:
# ABC 088 C

from collections import deque

def resolve():
    def all_same(a, b, c):
        if a ==b and b ==c:
            return True
        return False

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

    if not all_same(c[0][0]-c[1][0], c[0][1] - c[1][1], c[0][2]-c[1][2]):
        ans = False
    if not all_same(c[0][0]-c[2][0], c[0][1] - c[2][1], c[0][2]-c[2][2]):
        ans = False
    if not all_same(c[0][0] - c[0][1], c[1][0] - c[1][1], c[2][0] - c[2][1]):
        ans = False
    if not all_same(c[0][0] - c[0][2], c[1][0] - c[1][2], c[2][0] - c[2][2]):
        ans = False

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


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
c1, c2, c3 = map(int, input().split())
c4, c5, c6 = map(int, input().split())
c7, c8, c9 = map(int, input().split())

if c1+c5+c9 == c1+c8+c6 == c4+c2+c9 == c4+c8+c3 == c7+c2+c6 == c7+c5+c3:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
c1 = [int(i) for i in input().split()]
c2 = [int(i) for i in input().split()]
c3 = [int(i) for i in input().split()]
flag = 0
for i in range(2):
    if not (c1[i+1] - c1[i] == c2[i+1] - c2[i] == c3[i+1] - c3[i]):
        flag = 1
print('Yes' if flag == 0 else 'No')

Submission status: Accepted

Solution code:
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
if c1[0] + c2[1] + c3[2] == c1[1] + c2[2] + c3[0] == c1[2] + c2[0] + c3[1]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
C = [list(map(int,input().split())) for i in range(3)]
A = [0] * 3
B = [0] * 3

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

for k in range(3):
  for l in range(3):
    if C[k][l] != A[k] + B[l]:
      print('No')
      exit()
      
print('Yes')

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, a = IR(2)
    n %= 500
    if a >= n:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    _ = II()
    a = LI()
    a.sort(reverse=True)
    op = 0
    ans = 0
    for ai in a:
        ans += -ai * op or ai
        op ^= 1
    print(ans)
    return

#C
def C():
    c = LIR(3)
    for x in range(c[0][0] + 1):
        b = (c[0][0] - x, c[0][1] - x, c[0][2] - x)
        if (c[1][0] - b[0]) == (c[1][1] - b[1]) == (c[1][2] - b[2]):
            if (c[2][0] - b[0]) == (c[2][1] - b[1]) == (c[2][2] - b[2]):
                print("Yes")
                return
    print("No")
    return
#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()

Submission status: Accepted

Solution code:
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]
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')

Submission status: Accepted

Solution code:
c = [[0, 0, 0] for _ in range(3)]

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

success = False

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

    if (c[1][0] - b1) == (c[1][1] - b2) and (c[1][1] - b2) == (c[1][2] - b3):
        if (c[2][0] - b1) == (c[2][1] - b2) and (c[2][1] - b2) == (c[2][2] - b3):
            success = True
            break

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
#ABC088C
import sys

tmp = input().split()
a = list(map(lambda a: int(a), tmp))
tmp = input().split()
b = list(map(lambda a: int(a), tmp))
tmp = input().split()
c = list(map(lambda a: int(a), tmp))

if(a[0]-b[0]==a[1]-b[1])and(a[1]-b[1]==a[2]-b[2]):
	if(a[0]-c[0]==a[1]-c[1])and(a[1]-c[1]==a[2]-c[2]):
		if(c[0]-b[0]==c[1]-b[1])and(c[1]-b[1]==c[2]-b[2]):
			if(a[0]-a[1]==b[0]-b[1])and(b[0]-b[1]==c[0]-c[1]):
				if(a[2]-a[1]==b[2]-b[1])and(b[2]-b[1]==c[2]-c[1]):
					if(a[0]-a[2]==b[0]-b[2])and(b[0]-b[2]==c[0]-c[2]):
						print("Yes")
						sys.exit()
print("No")

Submission status: Accepted

Solution code:
a=[list(map(int,input().split())) for _ in range(3)]
if not a[0][0]-a[1][0]==a[0][1]-a[1][1]==a[0][2]-a[1][2]:print("No");exit()
if not a[0][0]-a[2][0]==a[0][1]-a[2][1]==a[0][2]-a[2][2]:print("No");exit()
if not a[0][0]-a[0][1]==a[1][0]-a[1][1]==a[2][0]-a[2][1]:print("No");exit()
if not a[0][0]-a[0][2]==a[1][0]-a[1][2]==a[2][0]-a[2][2]:print("No");exit()
print("Yes")

Submission status: Accepted

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

ans = 'Yes'
for i in range(1, 3):
    if C[0][i] - C[1][i] != C[0][0] - C[1][0]:
        ans = 'No'
        break
    if C[0][i] - C[2][i] != C[0][0] - C[2][0]:
        ans = 'No'
        break
    if C[i][0] - C[i][1] != C[0][0] - C[0][1]:
        ans = 'No'
        break
    if C[i][0] - C[i][2] != C[0][0] - C[0][2]:
        ans = 'No'
        break
print(ans)

Submission status: Accepted

Solution code:
def Infomation():
    if not (c11 - c21 == c12 - c22 == c13 - c23):
        return False
    if not (c11 - c31 == c12 - c32 == c13 - c33):
        return False
    if not (c11 - c12 == c21 - c22 == c31 - c32):
        return False
    if not (c11 - c13 == c21 - c23 == c31 - c33):
        return False
    return True

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

flag = Infomation()

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

Submission status: Accepted

Solution code:
import numpy as np

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

db1 = grid[0][1]-grid[0][0]
db2 = grid[0][2]-grid[0][1]

flag = True

for i in range(1,3):
    d1 = grid[i][1]-grid[i][0]
    d2 = grid[i][2]-grid[i][1]

    if d1 == db1 and d2 == db2:
        continue
    else:
        flag = False

db1 = grid[1][0] - grid[0][0]
db2 = grid[2][0] - grid[1][0]

for i in range(1, 3):
    d1 = grid[1][i] - grid[0][i]
    d2 = grid[2][i] - grid[1][i]

    if d1 == db1 and d2 == db2:
        continue
    else:
        flag = False

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

Submission status: Accepted

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

Submission status: Accepted

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

for a1 in range(max(C[0])+1):
    b1 = C[0][0] - a1
    for a2 in range(max(C[1])+1):
        b2 = C[1][1] - a2
        if a1 + b2 != C[0][1] or a2 + b1 != C[1][0]:
            continue
        for a3 in range(max(C[2])+1):
            b3 = C[2][2] - a3
            if a1 + b3 == C[0][2] and a2 + b3 == C[1][2] and a3 + b1 == C[2][0] and a3 + b2 == C[2][1]:
                print("Yes")
                exit()
print("No")

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np
# マスに書かれている数字を入力する
c = np.empty((3, 3), dtype = int)
for i in range(3):
    c[i] = list(map(int, input().split()))
# 判定を初期化
judge = "Yes"
# 0〜1行目および0〜1列目について探索する
for i in range(2):
    # i行目からi+1行目を引いたものが等しくない場合
    if len(set(c[i] - c[i + 1])) != 1:
        # 判定を更新する
        judge = "No"
        # 繰り返しを抜ける
        break
    # i列目からi+1列目を引いたものが等しくない場合
    if len(set(c[:, i] - c[:, i + 1])) != 1:
        # 判定を更新する
        judge = "No"
        # 繰り返しを抜ける
        break
# 判定を出力する
print(judge)

Submission status: Accepted

Solution code:
def solve():
    if not (c11 - c21 == c12 - c22 == c13 - c23):
        return False
    if not (c11 - c31 == c12 - c32 == c13 - c33):
        return False
    if not (c11 - c12 == c21 - c22 == c31 - c32):
        return False
    if not (c11 - c13 == c21 - c23 == c31 - c33):
        return False
    return True


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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#ABC88 C
c = [list(map(int,input().split())) for _ in range(3)]
a = [0]
b = [c[0][i] for i in range(3)]
a.append(c[1][0] - c[0][0])
a.append(c[2][0] - c[0][0])
for i in range(3):
    for j in range(3):
        if a[i] + b[j] == c[i][j]:
            continue
        else:
            print('No')
            quit()
print('Yes')

Submission status: Accepted

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

ok=0
for i in range(3):
    for j in range(3):
        if c[i][j] != a[i]+b[j]:
            ok=1
            break
print("Yes" if ok==0 else "No")

Submission status: Accepted

Solution code:
def i():return map(int,input().split())
a,b,c = i()
d,e,f = i()
g,h,i = i()
print('Yes' if (d-a==e-b==f-c) and (g-d==h-e==i-f) and (b-a==e-d==h-g) and (c-b==f-e==i-h) else 'No')

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ans = 'Yes'
C = []
for i in range(0, 3):
	C.append(list(map(int, input().split())))
a1ma2 = C[0][0] - C[1][0]
if a1ma2 != C[0][1] - C[1][1] or a1ma2 != C[0][2] - C[1][2]:
	ans = 'No'
a1ma3 = C[0][0] - C[2][0]
if a1ma3 != C[0][1] - C[2][1] or a1ma3 != C[0][2] - C[2][2]:
	ans = 'No'
a2ma3 = C[1][0] - C[2][0]
if a2ma3 != C[1][1] - C[2][1] or a2ma3 != C[1][2] - C[2][2]:
	ans = 'No'
b1mb2 = C[0][0] - C[0][1]
if b1mb2 != C[1][0] - C[1][1] or b1mb2 != C[2][0] - C[2][1]:
	ans = 'No'
b1mb3 = C[0][0] - C[0][2]
if b1mb3 != C[1][0] - C[1][2] or b1mb3 != C[2][0] - C[2][2]:
	ans = 'No'
b2mb3 = C[0][1] - C[0][2]
if b2mb3 != C[1][1] - C[1][2] or b2mb3 != C[2][1] - C[2][2]:
	ans = 'No'
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h() if m > 1 else typ(input()) for _ in range(n)]


def main():
    c = read_v(n=3, m=3)

    # Assume a_1 = 0 without loss of generality
    a = [0, 0, 0]
    b = c[0]
    for i in (1, 2):
        a[i] = c[i][0] - b[0]

    # Check if Takahashi is correct
    for i in range(3):
        for j in range(3):
            if c[i][j] != a[i] + b[j]:
                print('No')
                return

    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Accepted

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

if c1[0]-c2[0]==c1[1]-c2[1]==c1[2]-c2[2] and c1[0]-c3[0]==c1[1]-c3[1]==c1[2]-c3[2]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys
lis_a = [0] * 3

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

b = [0] * 3

for i in range(min(lis_a[0]) + 1):
    a_1 = i
    for k in range(3):
        b[k] = lis_a[0][k] - a_1
    a_2 = lis_a[1][0] - b[0]
    a_3 = lis_a[2][0] - b[0]
    a = [a_1, a_2, a_3]
    for l in range(3):
        for m in range(3):
            if a[l] + b[m] != lis_a[l][m]:
                print('No')
                sys.exit()
print('Yes')

Submission status: Accepted

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

sum_yoko = [0 for i in range(3)]
for i in range(3):
    sum_yoko[i] = sum(c[i])
    
sum_tate = [0 for i in range(3)]
for i in range(3):
    sum_tate[i] = c[0][i]+c[1][i]+c[2][i]
    
b1mb2 = (sum_yoko[0]-sum_yoko[1])/3
b2mb3 = (sum_yoko[1]-sum_yoko[2])/3
b3mb1 = (sum_yoko[2]-sum_yoko[0])/3
a1ma2 = (sum_tate[0]-sum_tate[1])/3
a2ma3 = (sum_tate[1]-sum_tate[2])/3
a3ma1 = (sum_tate[2]-sum_tate[0])/3

chk =[b1mb2,b2mb3,b3mb1,a1ma2,a2ma3,a3ma1]

flg = 0
for i in chk:
    if (i*10)%10 != 0:
        flg = 1

if flg == 1:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
def main():
	C = [[0 for _ in range(3)] for _ in range(3)]
	for i in range(3):
		C[i] = list(map(int, input().split()))
	possible = True
	for i in range(1, 3):
		tmp = C[i][0]-C[i-1][0]
		for j in range(1, 3):
			if C[i][j]-C[i-1][j] != tmp:
				possible = False
				break
	for j in range(1, 3):
		tmp = C[0][j]-C[0][j-1]
		for i in range(1, 3):
			if C[i][j]-C[i][j-1] != tmp:
				possible = False
				break
	if possible:
		print("Yes")
	else:
		print("No")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
o =0
t1 = list(map(int,input().split()))
t2 = list(map(int,input().split()))
t3 = list(map(int,input().split()))
o = sum(t1)+sum(t2)+sum(t3)
if o%3 >0:
  print('No')
elif (t1[0]-t1[1]==t2[0]-t2[1]==t3[0]-t3[1] and t1[2]-t1[1]==t2[2]-t2[1]==t3[2]-t3[1] and t1[0]-t2[0]==t1[1]-t2[1]==t1[2]-t2[2] and t1[0]-t3[0]==t1[1]-t3[1]==t1[2]-t3[2]):
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
import numpy as np
row = [input().split() for i in range(3)]
f = np.vectorize(int)
c = f(row)

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

Submission status: Accepted

Solution code:
c11,c12,c13 = map(int,input().split())
c21,c22,c23 = map(int,input().split())
c31,c32,c33 = map(int,input().split())
for a1 in range(101):
    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")
        break
else:
    print("No")

Submission status: Accepted

Solution code:
C1 = list(map(int, input().split()))
C2 = list(map(int, input().split()))
C3 = list(map(int, input().split()))

if ((C1[1]-C1[0]) == (C2[1]-C2[0]) == (C3[1]-C3[0]) and
    (C1[2]-C1[1]) == (C2[2]-C2[1]) == (C3[2]-C3[1])):
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    c =[list(map(int, input().split())) for _ in range(3)]

    answer = 'No'
    for a1 in range(101):
        for a2 in range(101):
            for a3 in range(101):
                b1 = (c[0][0] + c[1][0] + c[2][0]) - (a1 + a2 + a3)
                b2 = (c[0][1] + c[1][1] + c[2][1]) - (a1 + a2 + a3)
                b3 = (c[0][2] + c[1][2] + c[2][2]) - (a1 + a2 + a3)

                if b1 % 3 == 0 and b2 % 3 == 0 and b3 % 3 == 0:
                    answer = 'Yes'
                    break
    print(answer)

Submission status: Accepted

Solution code:
c0=list(map(int, input().split()))
c1=list(map(int, input().split()))
c2=list(map(int, input().split()))

c=[c0,c1,c2]

judge = 0

if c[0][0]-c[0][1]==c[1][0]-c[1][1] and c[1][0]-c[1][1]==c[2][0]-c[2][1]:
  judge +=1
if c[0][2]-c[0][1]==c[1][2]-c[1][1] and c[1][2]-c[1][1]==c[2][2]-c[2][1]:
  judge +=1
if c[0][0]-c[1][0]==c[0][1]-c[1][1] and c[0][1]-c[1][1]==c[0][2]-c[1][2]:
  judge +=1
if c[2][0]-c[1][0]==c[2][1]-c[1][1] and c[2][1]-c[1][1]==c[2][2]-c[1][2]:
  judge +=1

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
d=[0]*3
e=d
for i in range(3):
  d[i]=a[i]-b[i]
  e[i]=b[i]-c[i]
f=[a[0]-a[1],b[0]-b[1],c[0]-c[1]]
g=[a[1]-a[2],b[1]-b[2],c[1]-c[2]]
d=len(set(d));e=len(set(e));f=len(set(f));g=len(set(g))
if d==1 and e==1 and f==1 and g==1:
  print('Yes')
else:
  print('No')