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

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

Submission status: Accepted

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

dy1,dy2 = C[1][0]-C[0][0], C[2][0]-C[1][0]
dx1,dx2 = C[0][1]-C[0][0], C[0][2]-C[0][1]

Ans = "Yes"
for i in range(1,3):
    if C[1][i]-C[0][i] != dy1 or C[2][i]-C[1][i] != dy2:
        Ans = "No"
        break
    if C[i][1]-C[i][0] != dx1 or C[i][2]-C[i][1] != dx2:
        Ans = "No"
        break

print(Ans)

Submission status: Accepted

Solution code:
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
if a[1]-a[0] == b[1] - b[0] == c[1] - c[0] and a[1]-a[2] == b[1] - b[2] == c[1] - c[2]:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
c = [list(map(int, input().split())) for _ in range(3)]
a = [0,0,0]
b = [0,0,0]
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]
for x in range(3):
    for y in range(3):
        if c[x][y] != (a[x]+b[y]):
            print("No")
            break
    else:
        continue
    break
else:
    print("Yes")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

diff2 = []
for i in range(3):
    diff2.append([c[1][i] - c[0][i], c[1][i] - c[2][i]])
if diff1[0] == diff1[1] and diff1[1] == diff1[2] and \
   diff2[0] == diff2[1] and diff2[1] == diff2[2]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

c = grid[0][0]
for i in range(c+1):
    a, b = [], []
    a.append(i)
    for j in range(3):
        b.append(grid[0][j]-a[0])

    for j in range(1, 3):
        a.append(grid[j][0]-b[0])

    for j in range(3):
        for k in range(3):
            if a[j]+b[k] != grid[j][k]:
                break

        else:
            continue
        break

    else:
        print("Yes")
        break

else:
    print("No")

Submission status: Accepted

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

found = False

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

    c22 = a2 + b2
    c23 = a2 + b3
    c32 = a3 + b2
    c33 = a3 + b3

    if c22 == c[1][1] and c23 == c[1][2] and c32 == c[2][1] and c33 == c[2][2]:
        found = True
        break

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

Submission status: Accepted

Solution code:


def is_correct(grids):
    for a1 in range(min(101, grids[0][0]+1)):
        b_list = grids[0][0] - a1, grids[0][1] - a1, grids[0][2] - a1
        a2, a3 = grids[1][0] - b_list[0], grids[2][0] - b_list[0]
        a_list = [a1, a2, a3]
        temp_grids = []
        for an in a_list:
            row = []
            for bn in b_list:
                row.append(an+bn)
            temp_grids.append(row)
        if grids == temp_grids:
            return True

    return False


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

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

Submission status: Accepted

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

ok = True
 
for x in range(2):
  ok = ok and (c[x][0]-c[x+1][0] == c[x][1]-c[x+1][1] == c[x][2]-c[x+1][2])
 
for x in range(2):
  ok = ok and (c[0][x]-c[0][x+1] == c[1][x]-c[1][x+1] == c[2][x]-c[2][x+1])
 
print ("Yes" if ok else "No")

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"


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

    for a1 in range(0, 101):
        for a2 in range(0, 101):
            for a3 in range(0, 101):

                b1_ok = (C[0][0] - a1) == (C[1][0] - a2) == (C[2][0] - a3)
                b2_ok = (C[0][1] - a1) == (C[1][1] - a2) == (C[2][1] - a3)
                b3_ok = (C[0][2] - a1) == (C[1][2] - a2) == (C[2][2] - a3)

                if b1_ok and b2_ok and b3_ok:
                    return Yes

    return No


def main():
    print(solve())


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np
a=np.array([list(map(int,input().split())) for i in range(3)])
b=np.copy(a)
result=0
a[0]-=a[2]
a[1]-=a[2]
a[:,0]-=a[:,2]
a[:,1]-=a[:,2] 
b[0]-=b[2]
b[1]-=b[2]
b[:,0]-=b[:,2]
b[:,1]-=b[:,2]
for i in range(2):
    for j in range(2):
        result=result or a[i][j] or b[i][j]
if not result:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
c = [[int(a) for a in input().split()] for _ in range(3)]
ok = True

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 a[i] + b[j] != c[i][j]:
            ok = False
print("Yes") if ok else print("No")

Submission status: Accepted

Solution code:
import numpy as np
c = np.zeros((3,3))
for i in range(3):
    c[i] = list(map(int,input().split()))
a = np.sum(c, axis=0)
b = np.sum(c, axis=1)
a_sub = [int(i/3) for i in a - a[0] if i%3 == 0]
b_sub = [int(i/3) for i in b - b[0] if i%3 == 0]
if (len(a_sub) != 3 or len(b_sub) != 3):
    print('No')
else:
    d = np.zeros((3,3),dtype=int)
    #print(a_sub,b_sub)
    for a_0 in range(int(c[0][0])+1):
        b_0 = c[0][0] - a_0
        for i in range(3):
            for j in range(3):
                d[i][j] = a_0 + a_sub[j] + b_0 + b_sub[i]
        if np.allclose(c, d):
            print('Yes')
            break
    else:
        print('No')

Submission status: Accepted

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

for k in range(2):
    if C[k][0]-C[k+1][0] != C[k][1]-C[k+1][1] or C[k][1]-C[k+1][1] != C[k][2]-C[k+1][2]:
        print("No")
        exit(0)
    elif C[0][k]-C[0][k+1] != C[1][k]-C[1][k+1] or C[1][k]-C[1][k+1] != C[2][k]-C[2][k+1]:
        print("No")
        exit(0)
print("Yes")

Submission status: Accepted

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

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 a[i] + b[j] != c[i][j]:
            ok = False

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

Submission status: Accepted

Solution code:
c = [list(map(int, input().split())) for _ in range(3)]
ok = False
for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            b1 = c[0][0] - a1
            b2 = c[0][1] - a1
            b3 = c[0][2] - a1

            a = [a1, a2, a3]
            b = [b1, b2, b3]
            ok_sub = True
            for i in range(3):
                for j in range(3):
                    if a[i] + b[j] != c[i][j]:
                        ok_sub = False
            if ok_sub:
                ok = True

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

Submission status: Accepted

Solution code:
import numpy as np

if __name__ == '__main__':
    c = np.array([list(map(int, input().split())) for _ in range(3)])
    comb = [(0, 1), (1, 2), (2, 0)]
    # row
    for yc in comb:
        total = np.sum(c[:, yc[0]]) - np.sum(c[:, yc[1]])
        if total % 3 != 0:
            print("No")
            exit(0)

    # column
    for xc in comb:
        total = np.sum(c[xc[0], :]) - np.sum(c[xc[1], :])
        if total % 3 != 0:
            print("No")
            exit(0)

    print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1, 3):
    diff = c[0][0] - c[i][0]
    for j in range(3):
        c[i][j] += diff

for i in range(3):
    if not (c[0][i] == c[1][i] == c[2][i]):
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
c = [list(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 = c[1][0] - b1
    a3 = c[2][0] - b1

    if a2 + b2 == c[1][1] and a2 + b3 == c[1][2] and a3 + b2 == c[2][1] and a3 + b3 == c[2][2]:
        print('Yes')
        exit()

print('No')

Submission status: Accepted

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

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

Submission status: Accepted

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

b = [c[0][0],c[0][1],c[0][2]]
a = [0,c[1][0]-c[0][0],c[2][0]-c[0][0]]

flag = True

for i in range(3):
    for j in range(3):
        if c[i][j] == a[i]+ b[j]:
            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][1]-c[0][0]==c[1][1]-c[1][0]==c[2][1]-c[2][0]\
 and c[0][2]-c[0][0]==c[1][2]-c[1][0]==c[2][2]-c[2][0]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys
n = [0 for i in range(3)]
for i in range(3):
    n[i] = [int(i) for i in input().split()]

b = n[0]
a = [0, n[1][0]-b[0], n[2][0]-b[0]]
for i in range(1, 3):
    for j in range(1, 3):
        if a[i]+b[j] != n[i][j]:
            print('No')
            sys.exit()

print('Yes')

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

c11,c12,c13 = na()
c21,c22,c23 = na()
c31,c32,c33 = na()
flag = 1
for row_1 in range(c11+1):
    col_1 = c11 - row_1
    col_2 = c12 - row_1
    row_2 = c21 - col_1
    col_3 = c13 - row_1
    if row_2 + col_2 != c22 or row_2 + col_3 != c23:
        flag = 0
        break
    row_3 = c31 - col_1
    if row_3 + col_2 != c32 or row_3 + col_3 != c33:
        flag = 0
        break
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,C = map(int, input().split())
D,E,F = map(int, input().split())
G,H,I = map(int, input().split())

flag = False
for i in range(101):
    b1 = A-i
    b2 = B-i
    b3 = C-i
    if (D-b1 == E-b2)and(E-b2 == F-b3):
        if (G-b1 == H-b2)and(H-b2 == I-b3):
            flag = True

if flag == True:
    print("Yes")
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()))

num=0
if c1[1]-c1[0]==c2[1]-c2[0]==c3[1]-c3[0]:
    num+=0
else:
    num+=1
if c1[2]-c1[1]==c2[2]-c2[1]==c3[2]-c3[1]:
    num+=0
else:
    num+=1
if c2[0]-c1[0]==c2[1]-c1[1]==c2[2]-c1[2]:
    num+=0
else:
    num+=1
if c3[0]-c2[0]==c3[1]-c2[1]==c3[2]-c2[2]:
    num+=0
else:
    num+=1
    
if num==0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

diffs = [table[0][i] - table[1][i] for i in range(3)]
if diffs[0] != diffs[1] or diffs[1] != diffs[2]:
    print("No")
    exit()

diffs = [table[1][i] - table[2][i] for i in range(3)]
if diffs[0] != diffs[1] or diffs[1] != diffs[2]:
    print("No")
    exit()

diffs = [table[0][i] - table[2][i] for i in range(3)]
if diffs[0] != diffs[1] or diffs[1] != diffs[2]:
    print("No")
    exit()

print("Yes")

Submission status: Accepted

Solution code:
data = [0]*3
c = [[0,0,0],[0,0,0],[0,0,0]]
a = [[0,0,0],[0,0,0],[0,0,0]]
flag = 0

for i in range(3):
    data[i] = input("")
    for j in range(3):
        c[i][j] = int(data[i].split(" ")[j])
for i in range(1,3):
    for j in range(3):
        a[i][j] = c[i][j] - c[0][j]
    for j in range(1,3):
        if a[i][j] != a[i][j-1]:
            print("No")
            flag = 1
            break
    if flag != 0:
        break
if flag == 0:
    print("Yes")

Submission status: Accepted

Solution code:
x = [[int(i) for i in input().split()] for i in range(3)]
a,b = x[0][0]-x[0][1],x[0][0]-x[0][2]
c,d = x[0][0]-x[1][0],x[0][0]-x[2][0]
if all(x[j][0]-x[j][1]==a and x[j][0]-x[j][2]==b for j in range(3)):
 if all(x[0][k]-x[1][k]==c and x[0][k]-x[2][k]==d for k in range(3)): print("Yes")
 else: print("No")
else: print("No")

Submission status: Accepted

Solution code:
c = [[int(i) for i in input().split()] for i in range(3)]
diff_a, diff_b = [], []
possible = True

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

Submission status: Accepted

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

def main():
    # tate
    dif = [[0,0,0],[0,0,0]]
    for i in range(2):
        for j in range(3):
            dif[i][j] = c[i+1][j] - c[i][j]

    if (dif[0][0] != dif[0][1] or dif[0][0] != dif[0][2]) or\
       (dif[1][0] != dif[1][1] or dif[1][0] != dif[1][2]):
        return "No"

    # yoko
    dif = [[0,0],[0,0],[0,0]]
    for i in range(3):
        for j in range(2):
            dif[i][j] = c[i][j+1] - c[i][j]

    if (dif[0][0] != dif[1][0] or dif[0][0] != dif[2][0]) or\
       (dif[0][1] != dif[1][1] or dif[0][1] != dif[2][1]):
        return "No"

    return "Yes"

print(main())

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(" "))
dif1=c12-c11
dif2=c13-c12

if c22-c21 == dif1 and c32-c31 == dif1 and c23-c22 == dif2 and c33-c32 == dif2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

T1=[]
T2=[]

for i in range(3):
    T1.append(S[1][i]-S[0][i])
for i in range(3):
    T2.append(S[2][i]-S[1][i])


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

Submission status: Accepted

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

flag=True
order=[(0,1), (1,2), (2,0)]
for i in order:
    for j in order:
        if c[i[0]][j[0]]-c[i[1]][j[0]]!=c[i[0]][j[1]]-c[i[1]][j[1]]:
            flag=False
        if c[j[0]][i[0]]-c[j[0]][i[1]]!=c[j[1]][i[0]]-c[j[1]][i[1]]:
            flag=False
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import numpy as np

C1 = input().split(' ')
C2 = input().split(' ')
C3 = input().split(' ')

C = np.array([C1,C2,C3], np.int)

r1 = C[0,:]-C[1,:]
r2 = C[1,:]-C[2,:]
r3 = C[2,:]-C[0,:]

c1 = C[:,0]-C[:,1]
c2 = C[:,1]-C[:,2]
c3 = C[:,2]-C[:,0]

if np.all(r1 == r1[0]) and np.all(r2 == r2[0]) and np.all(r2 == r2[0]):
    if np.all(c1 == c1[0]) and np.all(c2 == c2[0]) and np.all(c3 == c3[0]):
        print('Yes')
else: print('No')

Submission status: Accepted

Solution code:
s = []
for i in range(3):
    s.append(list(map(int,input().split())))
s1 = s[0][0] - s[0][1] - s[1][0] + s[1][1]
s2 = s[1][1] - s[1][2] - s[2][1] + s[2][2]
s3 = s[0][0] - s[0][2] - s[2][0] + s[2][2]
print('Yes' if s1== 0 and s2==0 and s3==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()))
s = [c1,c2,c3]

s1 = s[0][0] - s[0][1] - s[1][0] + s[1][1]
s2 = s[1][1] - s[1][2] - s[2][1] + s[2][2]
if  s1== 0 and s2==0:
    if s[0][0] + s[2][2] == s[0][2] + s[2][0]:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

Solution code:
c = [map(int, raw_input().split()) for _ in range(3)]
b = [min(_) for _ in c]
c = [[c[i][j] - b[i] for i in range(3)] for j in range(3)]
print 'No' if [_ for _ in c if len(set(_)) != 1] else 'Yes'

Submission status: Accepted

Solution code:
c = []
for i in range(3):
    c.append(list(map(int,input().split())))
a1 = 0
b1 = c[0][0]
b2 = c[1][0]
b3 = c[2][0]
a2 = c[0][1]-b1
a3 = c[0][2]-b1
if a2 + b2 == c[1][1] and a3 + b2 == c[1][2] and a2 + b3 == c[2][1] and a3 + b3 == c[2][2]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
sum = 0
list = [[0 for x in range(3)] for y in range(3)]
for i in range(3):
    tmp = input().split()
    list[i] = tmp
    sum += int(tmp[0]) + int(tmp[1]) + int(tmp[2])

flg = True
if sum%3 ==0:
    for n in range(2):
        for m in range(2):
            if (int(list[n][m]) + int(list[n+1][m+1]))!=(int(list[n+1][m])+int(list[n][m+1])):
                flg = False
                break
    if flg:
        print('Yes')
    else:
        print('No')
else:
  print('No')

Submission status: Accepted

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

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

    for val in range(-200, 201):
        a[0] = val
        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]

        ok = True
        for i in range(3):
            for j in range(3):
                if a[i]+b[j] != c[i][j]:
                    ok = False
        if ok:
            return 'Yes'

    return 'No'

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

Submission status: Accepted

Solution code:
diff = []
for h in range(3):
    c1,c2,c3 = [int(x) for x in input().split()]
    diff.append([c1-c2, c2-c3])

judge = True
for h in range(2):
    judge &= (diff[h][0] == diff[h+1][0] and diff[h][1] == diff[h+1][1])
print("Yes" if judge else "No")

Submission status: Accepted

Solution code:
a=[]
for i in range(3):
    b=map(int, raw_input().split())
    a.append(b)

lis=[[0,0,0],[0,0,0]]
for i in range(3):
    lis[0][i] = a[i][0] + a[i][1] + a[i][2]
    lis[1][i] = a[0][i] + a[1][i] + a[2][i]

ch=0
for i in range(3):
    if (lis[0][i-1]-lis[0][i])%3!=0:
        ch=1
        break
    if (lis[1][i-1]-lis[1][i])%3!=0:
        ch=1
        break

if ch==0:
    print "Yes"
else:
    print "No"

Submission status: Accepted

Solution code:
c1=[int(x) for x in input().split()]
c2=[int(x) for x in input().split()]
c3=[int(x) for x in input().split()]
b=[x for x in c1]
a=list(range(3))
a[0]=0
a[1]=c2[0]-b[0]
a[2]=c3[0]-b[0]
C1=[x+a[0] for x in b]
C2=[x+a[1] for x in b]
C3=[x+a[2] for x in b]
if (c1==C1)&(c2==C2)&(c3==C3):
	print("Yes")
else:
	print("No")

Submission status: Accepted

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

for i in range(3):
    c[i] = [j - min(c[i]) for j in c[i]]
    
if c[0] == c[1] and c[1] == c[2]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

if 1 == len({r[0] - r[1] for r in c}) == len({r[1] - r[2] for r in c}):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys

def end_program():
  print "No"
  sys.exit()

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

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

a2=c21-b1
if a2!=c22-b2: end_program()
if a2!=c23-b3: end_program()

a3=c31-b1
if a3!=c32-b2: end_program()
if a3!=c33-b3: end_program()

print "Yes"

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C


# HACK: More smartly.
def identify_a_and_b_from(grid_values):
    a = list()
    b = list()

    # Transform to equivalent expression.
    # (a1, a2, a3, b1, b2, b3)
    # = (p1 + x, p2 + x, p3 + x, q1 - x, q2 - x, q3 - x)
    # Because pi + qi = (pi + x) + (qi - x) holds.

    # It assumes that a1 = 0
    a.append(0)

    for j in range(3):
        b.append(grid_values[0][j] - a[0])

    for i in range(1, 3):
        a.append(grid_values[i][0] - b[0])
    return a, b


def satisfy_takahashi_information(grid_values, a, b):
    result = 'Yes'

    for i in range(0, 3):
        for j in range(0, 3):
            if grid_values[i][j] != a[i] + b[j]:
                return 'No'
    return result


if __name__ == '__main__':
    grid_values = [list(map(int, input().split())) for i in range(3)]

    # See:
    # https://img.atcoder.jp/abc088/editorial.pdf
    a, b = identify_a_and_b_from(grid_values)

    result = satisfy_takahashi_information(grid_values, a, b)
    print(result)

Submission status: Accepted

Solution code:
import numpy as np

grid = np.array([])
for _ in range(3):
    list1 = list(map(int, input().split()))
    grid = np.append(grid, list1)

grid = grid.reshape(3, 3)
grid2 = np.vstack((grid[1:3, :], grid[0, :]))
judge = grid - grid2
judge = judge.transpose()
judge2 = np.copy(judge)
judge2 = np.vstack((judge2[1:3, :], judge2[0, :]))
new_judge = judge - judge2

if np.allclose(new_judge, np.zeros_like(new_judge)):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
x=[[int(c) for c in input().split()] for _ in range(3)]
if 1 == len({r[0]-r[1] for r in x}) == len({r[0]-r[2] for r in x}):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import numpy as np

l = []

for _ in range(3):
    a = [int(x) for x in input().split()]
    l.append(a)

l = np.array(l)

def check(m):
    a = []
    for i in range(3):
        b,c = m[i,0] - m[i,1], m[i,1] - m[i,2]
        a.append((b,c))
    if a[0] != a[1] or a[1] != a[2]:
        return False
    else:
        return True

if check(l) and check(np.transpose(l)):
    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()))
if (A[0]-B[0] == A[1]-B[1] and A[0]-B[0] == A[2]-B[2]):
    F=0
else:
    F=1
if F == 1:
    print ('No')
else:
    if (A[0]-C[0] == A[1]-C[1] and A[0]-C[0] == A[2]-C[2]):
        F=0
    else:
        F=1
    if F == 1:
        print ('No')
    else:
        if (A[0]-A[1] == B[0]-B[1] and A[0]-A[1] == C[0]-C[1]):
            F=0
        else:
            F=1
        if F == 1:
            print('No')
        else:
            if (A[0]-A[2] == B[0]-B[2] and A[0]-A[2] == C[0]-C[2]):
                F=0
            else:
                F=1
            if F == 1:
                print('No')
            else:
                print('Yes')

Submission status: Accepted

Solution code:
l = []

for _ in range(3):
    l.append([int(x) for x in input().split()])

flag = True

v,h = [],[]

for i in range(3):
    a = l[i]
    b,c = a[0] - a[1], a[1] - a[2]
    v.append([b,c])

if v[0] != v[1] or v[1] != v[2]:
    flag = False

for i in range(3):
    a = [l[0][i], l[1][i], l[2][i]]
    b,c = a[0] - a[1], a[1] - a[2]
    h.append([b,c])

if h[0] != h[1] or h[1] != h[2]:
    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())))
b = [C[0][0],C[0][1],C[0][2]]
a = [0,C[1][0]-b[0],C[2][0]-b[0]]
if C ==[[a[0]+b[0],a[0]+b[1],a[0]+b[2]],\
        [a[1]+b[0],a[1]+b[1],a[1]+b[2]],\
        [a[2]+b[0],a[2]+b[1],a[2]+b[2]]]:
    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][0])==(C[0][1]-C[1][1])==(C[0][2]-C[1][2]) and\
 (C[1][0]-C[2][0])==(C[1][1]-C[2][1])==(C[1][2]-C[2][2]) and\
 (C[2][0]-C[0][0])==(C[2][1]-C[0][1])==(C[2][2]-C[0][2]) and\
 (C[0][0]-C[0][1])==(C[1][0]-C[1][1])==(C[2][0]-C[2][1]) and\
 (C[0][1]-C[0][2])==(C[1][1]-C[1][2])==(C[2][1]-C[2][2]) and\
 (C[0][2]-C[0][0])==(C[1][2]-C[1][0])==(C[2][2]-C[2][0])):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
c00, c01, c02 = [int(x) for x in input().split()]
c10, c11, c12 = [int(x) for x in input().split()]
c20, c21, c22 = [int(x) for x in input().split()]

t1 = c00 + c11 - c01 - c10
t2 = c00 + c12 - c02 - c10
t3 = c00 + c21 - c01 - c20
t4 = c00 + c22 - c02 - c20

if t1 == 0 and t2 == 0 and t3 == 0 and t4 == 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import numpy as np
c = np.array([[int(i) for i in input().split()] for _ in range(3)])
b = np.sum(c) % 3 == 0
b &= np.sum(c[0] - c[1]) % 3 == 0
b &= np.sum(c[0] - c[2]) % 3 == 0
b &= np.sum(c[1] - c[2]) % 3 == 0
c = c.T
b &= np.sum(c[0] - c[1]) % 3 == 0
b &= np.sum(c[0] - c[2]) % 3 == 0
b &= np.sum(c[1] - c[2]) % 3 == 0
print('Yes' if b else 'No')

Submission status: Accepted

Solution code:
c = [list(map(int, input().split())) for i in range(3)]
print('Yes' 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] else 'No')

Submission status: Accepted

Solution code:
row1 = list(map(int, input().split()))
row2 = list(map(int, input().split()))
row3 = list(map(int, input().split()))
K = (sum(row1) + sum(row2) + sum(row3)) / 3

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

Submission status: Accepted

Solution code:
A = []
boo = 0
for i in range(3):
	A.append(list(map(int, input().split())))
for i in range(2):
	for j in range(2):
		if A[i + 1][j] - A[i][j] != A[i + 1][j + 1] - A[i][j + 1]:
			boo = 1

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def dfs(depth, array, sums, b):
    if depth == 3:
        sumb=0 
        for i in b:
            sumb+=i

        a=[int((sums[0]-sumb)/3), int((sums[1]-sumb)/3), int((sums[2]-sumb)/3)]
        for i in range(3):
            for j in range(3):
                if a[i]+b[j] != array[i][j]:
                    return False
        return True
    else:
        for i in range(101):
            b[depth]=i
            if dfs(depth+1, array, sums, b):
                return True
        return False

array=[]
b=[0 for i in range(3)]
sums=[0 for i in range(3)]
for i in range(3):
    array.append([int(i) for i in input().split()])

for i in range(3):
    sums[i]+=array[i][0]+array[i][1]+array[i][2]

if(dfs(0, array, sums, b)):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

row1_21 = row1[1] -row1[0]
row2_21 = row2[1] -row2[0]
row3_21 = row3[1] -row3[0]

row1_31 = row1[2] -row1[0]
row2_31 = row2[2] -row2[0]
row3_31 = row3[2] -row3[0]
if ((row1_21==row2_21) and (row1_21==row3_21)) and ((row1_31==row2_31) and (row1_31==row3_31)):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import numpy as np

mat = np.array([list(map(int, input().split())) for _ in range(3)], 'i')

for a0 in range(101):
    v0 = mat[0, :] - a0
    if len(np.where(v0 < 0)[0]) > 0: break
    for a1 in range(101):
        v1 = mat[1, :] - a1
        if len(np.where(v1 < 0)[0]) > 0: break

        if v0[0] != v1[0] or v0[1] != v1[1] or v0[2] != v1[2]:
            continue
        
        v2 = mat[2, :] - v0
        if v2[0] == v2[1] and v2[0] == v2[2]:
            print("Yes")
            exit()
print("No")