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:
#escape_ck_ans
c=[]
for i in range(3):
    c.append(list(map(int,input().split())))
a=[0]*3
b=[0]*3
a[0]=0#一つ固定する
a[1]=c[1][1]-c[0][1]
a[2]=c[2][2]-c[0][2]
b[0]=c[0][0]
b[1]=c[0][1]
b[2]=c[0][2]
flag=True
for i in range(3):
    for j in range(3):
        if c[i][j]!=a[i]+b[j]:
            flag=False
if flag==True:
    print("Yes")
else:
    print("No")
""" 
print("Yes") if flag(is true) 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())

bs = []
for a1 in range(0, 101):
    for b1 in range(0, 101):
        if a1 + b1 == c11:
            f1 = True
            break
    for b2 in range(0, 101):
        if a1 + b2 == c12:
            f2 = True
            break
    for b3 in range(0, 101):
        if a1 + b3 == c13:
            f3 = True
            break
    if f1 and f2 and f3:
        bs.append((b1, b2, b3))

bss = []
for a2 in range(0, 101):
    for b1, b2, b3 in bs:
        if a2 + b1 == c21 and a2 + b2 == c22 and a2 + b3 == c23:
            bss.append((b1, b2, b3))

for a3 in range(0, 101):
    for b1, b2, b3 in bss:
        if a3 + b1 == c31 and a3 + b2 == c32 and a3 + b3 == c33:
            print("Yes")
            break
    else:
        continue
    break
else:
    print("No")

Submission status: Accepted

Solution code:
# /usr/bin/python
# -*- coding: utf-8 -*-
#
# import sys
# import math


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


def check(cn):
  for i in range(2):
    dif0 = cn[i][0]-cn[i+1][0]
    dif1 = cn[i][1]-cn[i+1][1]
    dif2 = cn[i][2]-cn[i+1][2]
    if dif0 != dif1 or dif1 != dif2:
      return False
  return True

if check(An) and check(Bn):
  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()]
if (len(set([c1[i] - c2[i] for i in range(3)])) == 1) & ((len(set([c2[i] - c3[i] for i in range(3)])) == 1)):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
g = [list(map(int, input().split())) for _ in range(3)]
for i in range(101):
    b1, b2, b3 = g[0][0] - i, g[0][1] - i, g[0][2] - i
    if g[1][0] - b1 == g[1][1] - b2 and g[1][1] - b2 == g[1][2] - b3:
        if g[2][0] - b1 == g[2][1] - b2 and g[2][1] - b2 == g[2][2] - b3:
            print('Yes')
            exit()
print('No')

Submission status: Accepted

Solution code:
import sys
c = [[0]*3 for i in range(3)]
for i in range(3):
    c[i] = list(map(int, input().split()))
for i in range(101):
    b1, b2, b3 = c[0][0]-i, c[0][1]-i, c[0][2]-i
    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:
            print('Yes')
            sys.exit()
print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

C = [[0,0,0,0]]
for i in range(3):
    C.append([0] + LI())

"""
yxの順
a1 + b1 = c11
a2 + b1 = c21
a3 + b1 = c31
a1 + b2 = c12
a2 + b2 = c22

b1 = b2 + c11 - c12
b2 = -a2 + c22
b1 = -a2 + c22 + c11 - c12
a2 - a2 + c22 + c11 - c12 = c21
c22+c11 = c21 + c12

"""
#  print(C)
if (C[2][2] + C[1][1] - C[1][2] == C[2][1]) and (C[1][1] + C[3][3] == C[1][3] + C[3][1]) and (C[2][2] + C[3][3] == C[2][3] + C[3][2]):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
matrix = [list(map(int, input().split())) for _ in range(3)]
for j in range(2) :
  for i in range(3) :
    if(matrix[i][0] > 0 and matrix[i][1] > 0 and matrix[i][2] > 0) :
      matrix[i] = list(map(lambda x: x - min(matrix[i][0], matrix[i][1], matrix[i][2]), matrix[i]))
  matrix = [list(x) for x in zip(*matrix)]
if(matrix == [[0]*3]*3) : print("Yes")
else : 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()))

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

Submission status: Accepted

Solution code:
c = []
c.append(list(map(int, input().split())))
c.append(list(map(int, input().split())))
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]:
    if c[1][0] - c[2][0] == c[1][1] - c[2][1] == c[1][2] - c[2][2]:
        if c[0][0] - c[0][1] == c[1][0] - c[1][1] == c[2][0] - c[2][1]:
            if c[0][1] - c[0][2] == c[1][1] - c[1][2] == c[2][1] - c[2][2]:
                print('Yes')
                exit()
print('No')

Submission status: Accepted

Solution code:
data = []

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

#check row

if data[0][1]-data[0][0] == data[1][1]-data[1][0] and data[1][1]-data[1][0]==data[2][1]-data[2][0] and data[0][2]-data[0][1]==data[1][2]-data[1][1] and data[1][2]-data[1][1]==data[2][2]-data[2][1]:
    x= 1
else:
    print("No")
    exit(0)

#check col

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    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[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]:
        return 'Yes'
    else:
        return 'No'

print(solve())

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

Submission status: Accepted

Solution code:
def solve(string):
    c11, c12, c13, c21, c22, c23, c31, c32, c33 = map(int, string.split())
    check = c11 - c12 == c21 - c22 == c31 - c32 and c12 - c13 == c22 - c23 == c32 - c33 and c13 - c11 == c23 - c21 == c33 - c31 and c11 - c21 == c12 - c22 == c13 - c23 and c21 - c31 == c22 - c32 == c23 - c33 and c31 - c11 == c32 - c12 == c33 - c13
    return "Yes" if check else "No"


if __name__ == '__main__':
    n = 3
    print(solve('\n'.join([input() for _ in range(n)])))

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

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

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

Submission status: Accepted

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

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


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

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())
if d-a==e-b==f-c and g-a==h-b==i-c:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

ans = True

X = 0
b = [c[i][0] - X for i in range(3)]
a = [c[0][i] - b[0] for i in range(3)]

for i in range(3) :
    for j in range(3) :
        if a[j] + b[i] != c[i][j] :
            ans = False

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

Submission status: Accepted

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

ans = False

for i in range(101) :
    a1 = 0
    b1 = c[0][0]
    b2 = c[0][1]
    b3 = c[0][2]
    a2 = c[1][0] - b1
    a3 = c[2][0] - b1
    a = []
    a.append(a1)
    a.append(a2)
    a.append(a3)
    if a2 + b2 != c[1][1] :
        continue
    elif a3 + b2 != c[2][1] :
        continue
    elif a2 + b3 != c[1][2] :
        continue
    elif a3 + b3 != c[2][2] :
        continue
    ans = True
    break

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

Submission status: Accepted

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

ans = False

for i in range(101) :
    for j in range(101) :
        for k in range(101) :
            b1 = c[0][0] - i
            b2 = c[1][0] - i
            b3 = c[2][0] - i
            if j + b1 != c[0][1] :
                continue
            elif j + b2 != c[1][1] :
                continue
            elif j + b3 != c[2][1] :
                continue
            elif k + b1 != c[0][2] :
                continue
            elif k + b2 != c[1][2] :
                continue
            elif k + b3 != c[2][2] :
                continue
            ans = True

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

Submission status: Accepted

Solution code:
c = [[int(x) for x in input().split()] for _ in range(3)]
for i in range(3):
    for j in range(3):
        ni = (i+1) % 3
        nj = (j+1) % 3
        if c[i][j] + c[ni][nj] != c[i][nj] + c[ni][j]:
            print("No")
            exit()
print("Yes")

Submission status: Accepted

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

def check():
  flag=True
  for i in range(2):
    for j in range(2):
      flag &= (mat[i+1][j]-mat[i][j])==(mat[i+1][j+1]-mat[i][j+1])
      flag &= (mat[i][j+1]-mat[i][j])==(mat[i+1][j+1]-mat[i+1][j])
  return flag


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

Submission status: Accepted

Solution code:
def main():
    c1 = list(map(int, input().split()))
    c2 = list(map(int, input().split()))
    c3 = list(map(int, input().split()))
    if abs(c1[0] - c1[1]) == abs(c2[0] - c2[1]) == abs(c3[0] - c3[1]) and \
            abs(c1[0] - c1[2]) == abs(c2[0] - c2[2]) == abs(c3[0] - c3[2]):
        print('Yes')
    else:
        print('No')


main()

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())
if c+e+g==b+d+i and a+f+h==b+d+i:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

a1 = 0
b1 = c_i_j[0][0] - a1
b2 = c_i_j[0][1] - a1
b3 = c_i_j[0][2] - a1
b = [b1, b2, b3]

flag = False
for i in range(1, 3):
    if len(set([c_i_j[i][j]-b[j] for j in range(3)])) != 1:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
def main():
    c = [[int(s) for s in input().split()] for _ in range(3)]
    if solve(c):
        print('Yes')
    else:
        print('No')

def solve(c):
    for i in range(1, 3):
        for j in range(1, 3):
            if c[i][j] - c[i][0] != c[0][j] - c[0][0]:
                return False
    
    return True

main()

Submission status: Accepted

Solution code:
import numpy as np
mat = [list(map(int, input().split())) for i in range(3)]
array = np.array(mat, dtype=np.int64)
a20 = array[2]-array[0]
a10 = array[1]-array[0]
b20 = array[:,2]-array[:,0]
b10 = array[:,1]-array[:,0]
flag  = False
if (a20==a20[0]).all() and (a10==a10[0]).all() and (b20==b20[0]).all() and (b10==b10[0]).all():
    for a1 in range(0, 101):
        a2 = a1+ a10[0]
        a3 = a1 + a20[0]
        b1 = array[0,0] - a1
        b2 = b1 + b10[0]
        b3 = b1 +b20[0]
        A = np.array([[a1, a2, a3]]).T
        B = np.array([[b1, b2, b3]])
        C = A+B
        if (C == array).all():
            flag =True
            break
if flag==True:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
e=[[int(i) for i in input().split()]for i in range(3)]
#print(e)
val=0
for j in range(3):
  for i in range(3):
    val+=e[j][i]
val0=val//3
#print(val0)
val1=e[0][0]+e[1][1]+e[2][2]
val2=e[1][0]+e[2][1]+e[0][2]
val3=e[2][0]+e[1][2]+e[0][1]
val4=e[2][0]+e[1][1]+e[0][2]
val5=e[2][2]+e[1][0]+e[0][1]
val6=e[0][0]+e[2][1]+e[1][2]
#print(val1,val2,val3,val4,val5,val6)
if val0==val1==val2==val3==val4==val5==val6:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

if len(set(vert1)) == len(set(vert2)) == len(set(horiz1)) == len(set(horiz2)) == 1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import numpy as np
import itertools
a1row = np.array(list(map(int,input().split())))
a2row = np.array(list(map(int,input().split())))
a3row = np.array(list(map(int,input().split())))
amatrix = np.array([a1row,a2row,a3row])
a1a2row = amatrix[0,:]-amatrix[1,:]
a2a3row = amatrix[1,:]-amatrix[2,:]
a1a2col = amatrix[:,0]-amatrix[:,1]
a2a3col = amatrix[:,1]-amatrix[:,2]
flag1 = all(a1a2row == a1a2row[0])
flag2 = all(a2a3row == a2a3row[0])
flag3 = all(a1a2col == a1a2col[0])
flag4 = all(a2a3col == a2a3col[0])
if flag1*flag2*flag3*flag4:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc088/tasks/abc088_c

import itertools
import collections
import bisect

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

    for a1 in range(101):
        b1 = A[0][0] - a1
        b2 = A[0][1] - a1
        b3 = A[0][2] - a1
        for a2 in range(101):
            if all([a2 + b1 == A[1][0], a2 + b2 == A[1][1], a2 + b3 == A[1][2]]):
                for a3 in range(101):
                    if all([a3 + b1 == A[2][0], a3 + b2 == A[2][1], a3 + b3 == A[2][2]]):
                        print("Yes")
                        exit()

    print("No")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from sys import exit
# A,B,C =
G = [[int(n) for n in input().split()]for _ in range(3)]#H,W
ptr = [ [0,1],[1,2], [0,2]]
e1 = G[0][0] - G[1][0]#a1 - a2
for p in ptr:
    e = G[0][p[0]] - G[0][p[1]]
    for h in range(1,3):
        if(e !=G[h][p[0]] - G[h][p[1]]):
            print("No")
            exit()
for p in ptr:
    e = G[p[0]][0] - G[p[1]][0]
    for w in range(1,3):
        if(e !=G[p[0]][w] - G[p[1]][w]):
            print("No")
            exit()
print("Yes")
# a = [int(input()) for _ in range(N)]
# S = str(input())
# L = len(S)
# T = str(input())
exit()

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[1]:


C=[list(map(int,input().split())) for l in range(3)]
a=0
b=0
c=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]:
    a=1
if C[0][1]-C[0][2]==C[1][1]-C[1][2] and C[1][1]-C[1][2]==C[2][1]-C[2][2]:
    b=1
if C[0][2]-C[0][0]==C[1][2]-C[1][0] and C[1][2]-C[1][0]==C[2][2]-C[2][0]:
    c=1
if a==1 and b==1 and c==1:
    print('Yes')
else:
    print('No')


# In[ ]:

Submission status: Accepted

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

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

Submission status: Accepted

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


def main():
    flg = True

    for i in range(2):
        for j in range(2):
            if c[i][j] + c[i + 1][j + 1] != c[i][j + 1] + c[i + 1][j]:
                flg = False
                break

        if not flg:
            break

    print("Yes" if flg else "No")
    return


main()

Submission status: Accepted

Solution code:

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

b  = Cij[0][0] + Cij[1][1] == Cij[0][1] + Cij[1][0]
b &= Cij[1][1] + Cij[2][2] == Cij[2][1] + Cij[1][2]
b &= Cij[2][2] + Cij[0][0] == Cij[2][0] + Cij[0][2]

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

Submission status: Accepted

Solution code:
c = sum([[int(x) for x in input().split()] for _ in range(3)], [])
flag = True
if c[1]-c[0] != c[4]-c[3] or c[4]-c[3] != c[7]-c[6]:
    flag = False
elif c[2]-c[1] != c[5]-c[4] or c[5]-c[4] != c[8]-c[7]:
    flag = False
elif c[3]-c[0] != c[4]-c[1] or c[4]-c[1] != c[5]-c[2]:
    flag = False
elif c[6]-c[3] != c[7]-c[4] or c[7]-c[4] != c[8]-c[5]:
    flag = False

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

Submission status: Accepted

Solution code:
c=[list(map(int, input().split())) for i in range(3)]
def C(a,b):
    for i in range(3):
        for j in range(3):
            if c[i][j]!=a[i]+b[j]:
                return False
    return True 
def D():
    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
                if C([a1,a2,a3],[b1,b2,b3]):
                    return True
    return False
print('Yes' if D() else 'No')

Submission status: Accepted

Solution code:
def takahashis_information(C: list) -> bool:
    for a1 in range(C[0][0] + 1):
        b1 = C[0][0] - a1
        b2 = C[0][1] - a1
        b3 = C[0][2] - a1

        if b1 < 0 or b2 < 0 or b3 < 0:
            continue

        # check a2
        if C[1][0] - b1 != C[1][1] - b2:
            continue
        if C[1][1] - b2 != C[1][2] - b3:
            continue

        # check a3
        if C[2][0] - b1 != C[2][1] - b2:
            continue
        if C[2][1] - b2 != C[2][2] - b3:
            continue

        return True

    return False


if __name__ == "__main__":
    C = [[int(s) for s in input().split()] for _ in range(3)]
    yes = takahashis_information(C)
    print('Yes' if yes else 'No')

Submission status: Accepted

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

r = [sum([c[j][i] for i in range(3)]) for j in range(3)]
q = [sum([c[i][j] for i in range(3)]) for j in range(3)]
if (r[2]-r[1]) % 3 == 0 and (r[1]-r[0]) % 3 == 0 and (q[2]-q[1]) % 3 == 0 and (q[1]-q[0]) % 3 == 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
f = [list(map(int, input().split())) for _ in range(3)]
a, b = [0], f[0]
a.append(f[1][0] - b[0])
a.append(f[2][0] - b[0])
flag = True
for i in range(3):
  for j in range(3):
    if a[i] + b[j] != f[i][j]:
      flag = False
if flag:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

for i in range(2):
    a0 = c[i][0] - c[i+1][0]
    a1 = c[i][1] - c[i+1][1]
    a2 = c[i][2] - c[i+1][2]
    if a0 != a1 or a1 != a2:
        print("No")
        exit()

for i in range(2):
    a0 = c[0][i] - c[0][i+1]
    a1 = c[1][i] - c[1][i+1]
    a2 = c[2][i] - c[2][i+1]
    if a0 != a1 or a1 != a2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

b = [C[0][i]-0 for i in range(3)]
a = [C[i][0]-b[0] for i in range(3)]

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

Submission status: Accepted

Solution code:
c = []
for _ in range(3):
    ci = list(map(int, input().split()))
    c.append(ci)
row_list = [[0, 1], [1, 2], [0, 2], [0, 1]]
for i in range(len(row_list)-1):
    if c[row_list[i][0]][0] - c[row_list[i][1]][0] == c[row_list[i][0]][1] - c[row_list[i][1]][1] == c[row_list[i][0]][2] - c[row_list[i][1]][2] \
    and c[row_list[i+1][0]][0] - c[row_list[i+1][1]][0] == c[row_list[i+1][0]][1] - c[row_list[i+1][1]][1] == c[row_list[i+1][0]][2] - c[row_list[i+1][1]][2]:
        print("Yes")
        exit()
print("No")

Submission status: Accepted

Solution code:
[(a,b,c),(d,e,f),(g,h,i)]=[map(int,input().split())for _ in [0]*3]
print('Yes'if a-b==d-e==g-h and b-c==e-f==h-i else'No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def main():
    input = sys.stdin.readline
    C = []
    s = 0
    for _ in range(3):
        c = list(map(int, input().split()))
        C.append(c)
        s += sum(c)
    if s % 3 != 0:
        print('No')
    else:
        p1 = C[0][0] - C[1][0] == C[0][1] - C[1][1] == C[0][2] - C[1][2]
        p2 = C[0][0] - C[2][0] == C[0][1] - C[2][1] == C[0][2] - C[2][2]
        p3 = C[1][0] - C[2][0] == C[1][1] - C[2][1] == C[1][2] - C[2][2]
        p4 = C[0][0] - C[0][1] == C[1][0] - C[1][1] == C[2][0] - C[2][1]
        p5 = C[0][0] - C[0][2] == C[1][0] - C[1][2] == C[2][0] - C[2][2]
        p6 = C[0][1] - C[0][2] == C[1][1] - C[1][2] == C[2][1] - C[2][2]

        if all([p1, p2, p3, p4, p5, p6]):
            print('Yes')
        else:
            print('No')



if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import numpy as np
import random

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

a = [0 for i in range(3)]
b = [0 for i in range(3)]
for i in range(3):
    min_line =  min(c[i])
    for j in range(3):
        c[i][j] -= min_line
    # a[i] += min_line

# print(c)

c = np.array(c)

for i in range(3):
    min_row = min(c[:,i])
    for j in range(3):
        c[j,i] -= min_row

if np.all(c==0):
    ans = True
else:
    ans = False
    
if ans:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
c = [list(map(int,input().split())) for _ in range(3)]
a = c[0][1]-c[0][0]
b = c[0][2]-c[0][1]
cc = c[1][0]-c[0][0]
d = c[2][0]-c[1][0]
for i in range(1,3):
    if not (c[i][1]-c[i][0])==a or not (c[i][2]-c[i][1])==b:
        print('No')
        exit()
    if not c[1][i]-c[0][i]==cc or not c[2][i]-c[1][i]==d:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

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

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

for i in range(2):
    if  not a[0][i+1] - b[0] == a[1][i+1] - b[1] == a[2][i+1] - b[2]:
        print("No")
        sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
import numpy as np
c = [list(map(int, input().split()))for i in range(3)]
c = np.array(c)
c1 = c[0][0] - c[1][0]
c2 = c[0][0] - c[2][0]

if all(c[1]+c1 == c[0]) and all(c[2]+c2 == c[0]):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
C = [list(map(int, input().split())) for _ in range(3)]
targets = [(0, 1), (1, 0), (1, 2), (2, 1), (2, 0), (0, 2)]
for i, j in targets:
    if (C[i][i] + C[i][j] + C[j][i] + C[j][j]) % 2 != 0:
        print("No")
        break
else:
    if sum([sum(c) for c in C]) % 3 != 0:
        print("No")
    else:
        print("Yes")

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())
if b-a==e-d and b-a==h-g and c-b==f-e and c-b==i-h:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
# C
c = [[int(i) for i in input().split()] for i in range(3)]
a = [0] * 3
b = [0] * 3
ans = True
for i in range(3):
    b[i] = c[0][i]
for i in range(1,3):
    a[i] = c[i][0] - b[0]
for i in range(3):
    for j in range(3):
        if c[i][j] != a[i] + b[j]:
            ans = False
if ans:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
L=[[int(i) for i in input().split()] for i in range(3)]
if L[0][1]-L[0][0]==L[1][1]-L[1][0]==L[2][1]-L[2][0] and L[0][2]-L[0][1]==L[1][2]-L[1][1]==L[2][2]-L[2][1] and L[1][0]-L[0][0]==L[1][1]-L[0][1]==L[1][2]-L[0][2] and L[2][0]-L[1][0]==L[2][1]-L[1][1]==L[2][2]-L[1][2]:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
c = [list(map(int, input().split())) for _ in range(3)]
adif1 = c[0][1] - c[0][0]
adif2 = c[0][2] - c[0][1]
bdif1 = c[1][0] - c[0][0]
bdif2 = c[2][0] - c[1][0]
for row in range(1,3):
    if c[row][1] - c[row][0] != adif1 or c[row][2] - c[row][1] != adif2:
        print('No')
        exit()
    if c[1][row] - c[0][row] != bdif1 or c[2][row] - c[1][row] != bdif2:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Mar  3 00:25:12 2019

@author: yuta
"""

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

def mat(m):
    count = 0
    for i in range(len(m)):
        for j in range(len(m)):
            if m[i][j] != 0:
                count += 1
    if count == 0:
        return 0
    else:
        return 1
    
def main(c1,c2,c3):
#行列の要素を挿入
    matrix_i = [c1,c2,c3]
    min_i = [min(c1),min(c2),min(c3)]
    min_j = [0,0,0]
#i行の最小値をi行から引く
    for i in range(3):
        for j in range(3):
            matrix_i[i][j] = matrix_i[i][j] - min_i[i]
    matrix_j = matrix_i
#j列の最小値をmin_jに入れる
    for j in range(3):
        min_j[j] = min(matrix_i[0][j],matrix_i[1][j],matrix_i[2][j])
#j列の最小値をj列から引く
    for i in range(3):
        for j in range(3):
            matrix_j[i][j] = matrix_j[i][j] - min_j[j]
#行列の全成分が0ならYes,違うならNo
    if mat(matrix_j) == 0:
        print("Yes")
    else:
        print("No")    

main(C1,C2,C3)