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: Time Limit Exceeded

Solution code:
def c_takahashi_information(C):
    a = []
    b = []
    for a_0 in range(min(C[0]) + 1):
        for a_1 in range(min(C[1]) + 1):
            for a_2 in range(min(C[2]) + 1):
                tmp1 = [a_0, a_1, a_2]
                tmp2 = [[C[i][j] - tmp1[i]
                         for j in range(3)] for i in range(3)]
                a.append(tmp1)
                b.append(tmp2)
    for aa, bb in zip(a, b):
        for bbb in bb:
            f = True
            for i in range(3):
                for j in range(3):
                    if aa[i] + bbb[j] != C[i][j]:
                        f = False
                        break
                if not f:
                    break
            if f:
                return 'Yes'
    return 'No'
  
C = [[int(i) for i in input().split()] for j in range(3)]
print(c_takahashi_information(C))

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# Set 2 dimension list
def dim2input(N):
    li = []
    for _ in range(N):
        li.append(list(map(int, input())))
    return li

""" input template
S = input()
N = int(input())
L = list(map(int, input().split()))
a, b = list(map(int, input().split()))
SL = list(input())
"""

# --------------------------------------------

dp = None

def main():
    C = []

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

    a1_limit = min(C[0])+1
    a2_limit = min(C[1])+1
    a3_limit = min(C[2])+1
    b1_limit = min(C[0][0], C[1][0], C[2][0])+1
    b2_limit = min(C[0][1], C[1][1], C[2][1])+1
    b3_limit = min(C[0][2], C[1][2], C[2][2])+1

    A1, A2, A3, B1, B2, B3 = [], [], [], [], [], []
    for i in range(a1_limit):
        A1.append(i)
    for i in range(a2_limit):
        A2.append(i)
    for i in range(a3_limit):
        A3.append(i)
    for i in range(b1_limit):
        B1.append(i)
    for i in range(b2_limit):
        B2.append(i)
    for i in range(b3_limit):
        B3.append(i)

    for a1, a2, a3, b1, b2, b3 in itertools.product(A1, A2, A3, B1, B2, B3):
        if a1 + b1 != C[0][0]:
            continue
        if a2 + b1 != C[1][0]:
            continue
        if a3 + b1 != C[2][0]:
            continue
        if a1 + b2 != C[0][1]:
            continue
        if a2 + b2 != C[1][1]:
            continue
        if a3 + b2 != C[2][1]:
            continue
        if a1 + b3 != C[0][2]:
            continue
        if a2 + b3 != C[1][2]:
            continue
        if a3 + b3 != C[2][2]:
            continue

        print("Yes")
        return

    print("No")

main()

Submission status: Accepted

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

for i in range(3):
    y[i] = C[0][i]
for i in range(3):
    x[i] = C[i][0] - y[0]
for i in range(3):
    for j in range(3):
        if C[i][j] != x[i] + y[j]:
            print('No')
            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()))

a1_a2 = c1[0] - c2[0]
a2_a3 = c2[0] - c3[0]
b1_b2 = c1[0] - c1[1]
b2_b3 = c1[1] - c1[2]

cnt = 0
if a1_a2 == c1[1]-c2[1] == c1[2]-c2[2]:
    cnt += 1
if a2_a3 == c2[1]-c3[1] == c2[2]-c3[2]:
    cnt += 1
if b1_b2 == c2[0]-c2[1] == c3[0]-c3[1]:
    cnt += 1
if b2_b3 == c2[1]-c2[2] == c3[1]-c3[2]:
    cnt += 1

if cnt == 4:
    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()))

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

    a2_1 = c2[0]-b1
    a2_2 = c2[1]-b2
    a2_3 = c2[2]-b3
    if not (a2_1==a2_2 and a2_2==a2_3):
        continue

    a3_1 = c3[0]-b1
    a3_2 = c3[1]-b2
    a3_3 = c3[2]-b3
    if not (a3_1==a3_2 and a3_2==a3_3):
        continue

    print("Yes")
    f=1
    break

if not f:
    print("No")

Submission status: Accepted

Solution code:
C=[list(map(int,input().split())) for i in range(3)]
B=[C[0][0],C[0][1],C[0][2]]
A=[0,C[1][0]-B[0],C[2][0]-B[0]]
for i in range(3):
  for j in range(3):
    if C[i][j] != A[i]+B[j]:
      print("No")
      quit()
print("Yes")

Submission status: Accepted

Solution code:
field=[]
result="Yes"
for i in range(3):
  field.append(list(map(int,input().split())))
for i in range(3):
  for j in range(3):
    if not (field[i][j]>=0 and field[i][j]<=100*2):
      result="No"
    if j ==0:
      pos_i0=field[i][j]
    field[i][j]-=pos_i0
for j in range(3):
  if not (field[0][j]==field[1][j] and field[0][j]==field[2][j]):
    result="No"
print(result)

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

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

Submission status: Accepted

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

s=0
for i in range (3):
    for j in range(3):
        if i==j:
            s+=c[i][j]*2
        else:s-=c[i][j]

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

Submission status: Accepted

Solution code:
import numpy as np

M = np.array(list(map(int,open(0).read().split()))).reshape(3,3)

hSum = M.sum(axis=0)
vSum = M.sum(axis=1)

f=True
for i in range(3):
  if (hSum[i]-hSum[(i+1)%3])%3!=0:
    f = False

for i in range(3):
  if (vSum[i]-vSum[(i+1)%3])%3!=0:
    f = False
    
print("Yes" if f else "No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

Submission status: Accepted

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    c = [i_list() for i in range(3)]

    for i in range(1,3):
        t = c[i][0] - c[0][0]
        if c[i][1] - c[0][1] == t and  c[i][2] - c[0][2] == t:
            pass
        else:
            print("No")
            exit()

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




if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 22 04:07:05 2020

@author: liang
"""

C = [[int (x) for x in input().split()] for _ in range(3)]
A = [0]*3
B = [0]*3

ans = False
for a1 in range(C[0][0]+1):
    tmp = True
    b1 = C[0][0] - a1
    b2 = C[0][1] - a1
    b3 = C[0][2] - a1
    a2 = C[1][0] - b1
    a3 = C[2][0] - b1
    if C[1][1] != a2+b2:
        tmp = False
    if C[1][2] != a2+b3:
        tmp = False
    if C[2][1] != a3+b2:
        tmp = False
    if C[2][2] != a3+b3:
        tmp = False
    if tmp == True:
        ans = True
if ans:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
r1 = list(map(int, input().split()))
r2 = list(map(int, input().split()))
r3 = list(map(int, input().split()))
a = [0]*3
b = [0]*3
for i in range(101):
  a[0] = i
  for j in range(3):
    b[j] = r1[j]-a[0]
    
  a[1] = r2[0] - b[0]
  a[2] = r3[0] - b[0]

  flag = False
  for j in range(3):
    if r1[j]==a[0]+b[j] and r2[j]==a[1]+b[j] and r3[j] == a[2]+b[j]:
      flag = True
    else:
      flag = False
      break
  if flag:
    break
    
print("Yes") if flag else print("No")

Submission status: Accepted

Solution code:
l = []
for i in range(3):
    c1,c2,c3 = map(int, input().split())
    l.append([c1,c2,c3])

# assign a1 as 0
b1 = l[0][0]
b2 = l[1][0]
b3 = l[2][0]

flag = 0
for i in range(3):
    if not (l[0][1]-b1 == l[1][1]-b2 == l[2][1]-b3):
        flag = 1
    if not (l[0][2]-b1 == l[1][2]-b2 == l[2][2]-b3):
        flag = 1
if flag == 1:
    print('No' , flush=True)
else:
    print('Yes' , flush=True)

# TLE
# l = []
# for i in range(3):
#     c1,c2,c3 = map(int, input().split())
#     l.append([c1,c2,c3])

# def check_sum(i,j):
#     for r in range(3):
#         if r == i:
#             continue;
#         for c in range(3):
#             if c == j:
#                 continue;
#             sum_a = l[i][j] + l[r][c]
#             sum_b = l[r][j] + l[i][c]
#             if sum_a == sum_b:
#                 return 1
#             else:
#                 return -1
#                 break;

# for i in range(3):
#     for j in range(3):
#         flag = check_sum(i, j)
#         if flag == -1:
#             break;

# if flag == 1:
#     print('Yes' , flush=True)
# else:
#     print('No' , flush=True)

Submission status: Accepted

Solution code:
# Problem: https://atcoder.jp/contests/abc088/tasks/abc088_c
# Python 3rd Try

import sys
# from collections import defaultdict
# import heapq,copy
import pprint as pp
# from collections import deque
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


# Const
MAXSIZE = ( 1 << 31 ) -1
MINSIZE = -( 1 << 31) + 1
yes = "Yes"
no = "No"

def solver(line00,line01,line02,
           line10,line11,line12,
           line20,line21,line22):

    result = no
    a0 = 0
    b0 = line00
    b1 = line01 - a0
    b2 = line02 - a0
    a1 = line10 -line00
    a2 = line20 - line00
    if (( a1 + b1 ) == line11) and (( a1 + b2 ) == line12
    ) and (( a2 + b1 ) == line21) and (( a2 + b2 ) == line22):
        result = yes
    return result


if __name__ == "__main__":
    line00 , line01, line02 = MI()
    line10 , line11, line12 = MI()
    line20 , line21, line22 = MI()
    print("{}".format(solver(line00, line01, line02,
                             line10, line11, line12,
                             line20, line21, line22)))

Submission status: Accepted

Solution code:
with open(0) as f:
    C = [list(map(int, line.split())) for line in f.readlines()]
b = [(C[i][1]-C[i][0], C[i][2]-C[i][1]) for i in range(3)]
a = [(C[1][j]-C[0][j], C[2][j]-C[1][j]) for j in range(3)]
print('Yes' if a[0]==a[1]==a[2] and b[0]==b[1]==b[2] else 'No')

Submission status: Accepted

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

if L[0][0] + L[1][1] != L[0][1] + L[1][0]: ans = 'No'
if L[0][1] + L[1][2] != L[0][2] + L[1][1]: ans = 'No'
if L[1][0] + L[2][1] != L[1][1] + L[2][0]: ans = 'No'
if L[1][1] + L[2][2] != L[1][2] + L[2][1]: ans = 'No'

print(ans)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

#N
#t1 x1 y1t1 x1 y1
#t2 x2 y2t2 x2 y2
#⋮⋮
#tN xN yNtN xN yN
N = 3
x = [0 for i in range(N)]
y = [0 for i in range(N)]
c =[[0 for i in range(N)] for i in range(N)]

for i in range(N):
    c1, c2, c3 = map(int, input().split())
    c[i][0] = c1
    c[i][1] = c2
    c[i][2] = c3


x[0] = 0
for i in range(N):
    y[i] = c[0][i] - x[0]
x[1] = c[1][0] - y[0]
x[2] = c[2][0] - y[0]

flag = True
for i in range(N):
   for j in range(N):
       numx = x[i]
       numy = y[j]
       if not numx + numy == c[i][j]:
           flag = False
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

Submission status: Accepted

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

for a1 in range(0, 101):
    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
    a2 = C[1][0] - b1
    if a2 < 0 or C[1][1] - b2 != C[1][2] - b3 or C[1][1] - b2 != a2:
        continue
    a3 = C[2][0] - b1
    if a3 < 0 or a3 != C[2][1]- b2 or a3 != C[2][2] - b3:
        continue
    print ("Yes")
    exit()
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[0]-C1[1]==C2[0]-C2[1]==C3[0]-C3[1] and C1[1]-C1[2]==C2[1]-C2[2]==C3[1]-C3[2] and 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:
c=[[] for _ in range(3)]
for i in range(3):
    c[i] = list(map(int, input().split()))

diff0 = [x - y for x, y in zip(c[0], c[1])]
diff1 = [x - y for x, y in zip(c[0], c[2])]
 
if diff0[0] == diff0[1] and diff0[0] == diff0[2] and diff1[0] == diff1[1] and diff1[0] == diff1[2]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

ans = "Yes"
for i in range(2):
    # print("i =",i)
    if c[0][i] - c[0][i+1] != c[1][i] - c[1][i+1]:
        # print("check1")
        # print(c[0][i], "-", c[0][i+1], "!=", c[1][i], "-", c[1][i+1])
        ans = "No"
    elif c[1][i] - c[1][i+1] != c[2][i] - c[2][i+1]:
        # print("check2")
        # print(c[1][i], "-", c[1][i+1], "!=", c[2][i], "-", c[2][i+1])
        ans = "No"
    elif c[i][0] - c[i+1][0] != c[i][1] - c[i+1][1]:
        # print("check3")
        # print(c[i][0], "-", c[i+1][0], "!=", c[i+1][1], "-", c[i+1][1])
        ans = "No"
    elif c[i][1] - c[i+1][1] != c[i][2] - c[i+1][2]:
        # print("check4")
        # print(c[i][1], "-", c[i+1][1], "!=", c[i+1][2], "-", c[i+1][2])
        ans = "No"
print(ans)

Submission status: Accepted

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

diff0 = [x - y for x, y in zip(c[0], c[1])]
diff1 = [x - y for x, y in zip(c[0], c[2])]

if diff0[0] == diff0[1] and diff0[0] == diff0[2] and diff1[0] == diff1[1] and diff1[0] == diff1[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())

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

Submission status: Accepted

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

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


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

check = []
check.append(c[1][1] == a2+b2)
check.append(c[2][1] == a3+b2)
check.append(c[1][2] == a2+b3)
check.append(c[2][2] == a3+b3)

if sum(check) == 4:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

ans = "Yes"

for i in range(2):
    if c[i+1][1]-c[i+1][0] != c[0][1]-c[0][0]:
        ans = "No"
    if c[i+1][2]-c[i+1][1] != c[0][2]-c[0][1]:
        ans = "No"
for j in range(2):
    if c[1][i+1]-c[0][i+1] != c[1][0]-c[0][0]:
        ans = "No"
    if c[2][i+1]-c[1][i+1] != c[2][0]-c[1][0]:
        ans = "No"

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=list(map(int, input().split()))
y=list(map(int, input().split()))
z=list(map(int, input().split()))
if x[1]-x[0] != y[1]-y[0] or y[1]-y[0] != z[1]-z[0] or x[2]-x[0] != y[2]-y[0] or y[0]-x[0] !=y[1]-x[1] or z[1]-x[1] !=z[2]-x[2] or z[0]-x[0] !=z[1]-x[1] or z[1]-x[1] !=z[2]-x[2] :
    print('No')
else:
    print('Yes')

Submission status: Accepted

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

if sum(tc) % 3 != 0:
  print('No')
else:
  cnt = 0
  for i in range(3):
    cnt  += cc[i][i]
  if cnt == sum(tc)//3:
    print('Yes')
  else:
    print('No')

Submission status: Accepted

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

ans = False
for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            ok = True
            b1 = c[0][0] - a1
            b2 = c[0][1] - a1
            b3 = c[0][2] - a1
            if c[1][0] != a2 + b1 or \
               c[1][1] != a2 + b2 or \
               c[1][2] != a2 + b3 or \
               c[2][0] != a3 + b1 or \
               c[2][1] != a3 + b2 or \
               c[2][2] != a3 + b3:
               ok = False
            if ok:
                ans = True

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

Submission status: Accepted

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

f = True
for j in range(2):
    x = c[j][0] - c[j + 1][0]
    y = c[0][j] - c[0][j + 1]
    for i in range(3):
        if c[j][i] - c[j + 1][i] != x:
            f = False
        if c[i][j] - c[i][j + 1] != y:
            f = False
print(['No', 'Yes'][int(f)])

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))
x = A[1] - A[0]
y = A[2] - A[1]
f = 0
for i in range(2):
  B = list(map(int, input().split()))
  if B[1] - B[0] != x or B[2] - B[1] != y:
    f = 1
    break
if f == 0:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
mycode = r'''
# distutils: language=c++
# cython: language_level=3, boundscheck=False, wraparound=False
# cython: cdivision=True
# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。

ctypedef long long LL
from libc.stdio cimport scanf, printf

cdef LL a,b,c,_,i
cdef LL[3][3] C
for i in range(3):
    scanf('%lld %lld %lld', &C[i][0],&C[i][1],&C[i][2])

    
cdef LL a0,a1,a2,b0,b1,b2
cdef bint flg=0
for a0 in range(101):
    b0=C[0][0]-a0
    b1=C[0][1]-a0
    b2=C[0][2]-a0
    for a1 in range(101):
        for a2 in range(101):
            if b0 == C[1][0]-a1 and b1==C[1][1]-a1 and b2==C[1][2]-a1 and b0 == C[2][0]-a2 and b1==C[2][1]-a2 and b2==C[2][2]-a2:
                if flg==0:
                   printf("Yes")
                flg=1
if flg==0:
    printf('No')

'''

import sys
import os
if sys.argv[-1] == 'ONLINE_JUDGE':  # コンパイル時
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode

Submission status: Accepted

Solution code:
mycode = r'''
# distutils: language=c++
# cython: language_level=3, boundscheck=False, wraparound=False
# cython: cdivision=True
# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。

ctypedef long long LL
from libc.stdio cimport scanf

cdef LL a,b,c,_,i
cdef LL[3][3] C
for i in range(3):
    scanf('%lld %lld %lld', &C[i][0],&C[i][1],&C[i][2])

    
cdef LL a0,a1,a2,b0,b1,b2
cdef bint flg=0
for a0 in range(101):
    b0=C[0][0]-a0
    b1=C[0][1]-a0
    b2=C[0][2]-a0
    for a1 in range(101):
        for a2 in range(101):
            if b0 == C[1][0]-a1 and b1==C[1][1]-a1 and b2==C[1][2]-a1 and b0 == C[2][0]-a2 and b1==C[2][1]-a2 and b2==C[2][2]-a2:
                print("Yes")
                exit()
print('No')


'''

import sys
import os
if sys.argv[-1] == 'ONLINE_JUDGE':  # コンパイル時
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode

Submission status: Accepted

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

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

a = [0] * 3
b = [0] * 3

for j in range(3):
    b[j] = c[0][j] - a[0]

for i in range(1,3,1):
    a[i] = c[i][0] - b[0]

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

print("Yes")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

# worst order: 101^6 => 10^8

c = []
c.append(list(map(int, input().split())))
c.append(list(map(int, input().split())))
c.append(list(map(int, input().split())))

arr_c = np.array(c)
a_max = np.amax(arr_c, axis=1)
b_max = np.amax(arr_c, axis=0)

a = []
b = []
for i in range(3):
    if len(list(range(0, a_max[i]+1, 1)))==0:
        a.append([0])
    else:
        a.append(list(range(0, a_max[i]+1, 1)))
    
    if len(list(range(0, b_max[i]+1, 1)))==0:
        b.append([0])
    else:
        b.append(list(range(0, b_max[i]+1, 1)))

ans = 'No'
cnt = 0
for a0 in a[0]:
    for b0 in b[0]:
        if c[0][0] != a0 + b0:
            continue
        for a1 in a[1]:
            if c[1][0] != a1 + b0:
                continue
            for b1 in b[1]:
                if c[0][1] != a0 + b1 or c[1][1] != a1 + b1:
                    continue   
                for a2 in a[2]:
                    if c[2][0] != a2 + b0 or c[2][1] != a2 + b1:
                        continue
                    for b2 in b[2]:
                        if c[0][2] != a0 + b2 or c[1][2] != a1 + b2 or c[2][2] != a2 + b2:
                            continue

                        print("Yes")
                        exit(0)

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

# worst order: 101^6 => 10^8

def check(a, b, c):
    flag = True
    for i in range(3):
        for j in range(3):
           if c[i][j]!=a[i]+b[j]:
               flag = False
               return flag

    return flag

c = []
c.append(list(map(int, input().split())))
c.append(list(map(int, input().split())))
c.append(list(map(int, input().split())))

arr_c = np.array(c)
a_max = np.amax(arr_c, axis=1)
b_max = np.amax(arr_c, axis=0)

a = []
b = []
for i in range(3):
    if len(list(range(0, a_max[i]+1, 1)))==0:
        a.append([0])
    else:
        a.append(list(range(0, a_max[i]+1, 1)))
    
    if len(list(range(0, b_max[i]+1, 1)))==0:
        b.append([0])
    else:
        b.append(list(range(0, b_max[i]+1, 1)))

ans = 'No'
cnt = 0
for a0 in a[0]:
    for b0 in b[0]:
        if c[0][0] != a0 + b0:
            continue
        for a1 in a[1]:
            if c[1][0] != a1 + b0:
                continue
            for b1 in b[1]:
                if c[0][1] != a0 + b1 or c[1][1] != a1 + b1:
                    continue   
                for a2 in a[2]:
                    if c[2][0] != a2 + b0 or c[2][1] != a2 + b1:
                        continue
                    for b2 in b[2]:
                        if c[0][2] != a0 + b2 or c[1][2] != a1 + b2 or c[2][2] != a2 + b2:
                            continue

                        print("Yes")
                        exit(0)

print(ans)

Submission status: Accepted

Solution code:
def LIHW(h):
    return [list(map(int, input().split())) for _ in range(h)]
 
 
masu = LIHW(3)
ans = "Yes"
for i in range(2):
    if masu[i+1][1]-masu[i+1][0] != masu[0][1]-masu[0][0]:
        ans = "No"
    if masu[i+1][2]-masu[i+1][1] != masu[0][2]-masu[0][1]:
        ans = "No"
for i in range(2):
    if masu[1][i+1]-masu[0][i+1] != masu[1][0]-masu[0][0]:
        ans = "No"
    if masu[2][i+1]-masu[1][i+1] != masu[2][0]-masu[1][0]:
        ans = "No"
print(ans)

Submission status: Accepted

Solution code:
def LIHW(h):
    return [list(map(int, input().split())) for _ in range(h)]


masu = LIHW(3)
ans = "Yes"
for i in range(2):
    if masu[i+1][1]-masu[i+1][0] != masu[0][1]-masu[0][0]:
        ans = "No"
    if masu[i+1][2]-masu[i+1][1] != masu[0][2]-masu[0][1]:
        ans = "No"
for i in range(2):
    if masu[1][i+1]-masu[0][i+1] != masu[1][0]-masu[0][0]:
        ans = "No"
    if masu[2][i+1]-masu[1][i+1] != masu[2][0]-masu[1][0]:
        ans = "No"
print(ans)

Submission status: Accepted

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

check = False
for i in range(101):
  for j in range(101):
    for k in range(101):
      o = c[0][0] - i
      p = c[1][1] - j
      q = c[2][2] - k
      
      if o < 0 or p < 0 or q < 0:
        continue
      
      ls = [[i+o,i+p,i+q],[j+o,j+p,j+q],[k+o,k+p,k+q]]
      if ls == c:
        check = True
        break
        
print("Yes" if check else "No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
xy = [list(map(int, input().split())) for i in range(3)]
result = sum(map(sum, xy))
if result % 3 != 0:
    print("No")
    exit()
if result != (xy[0][0]+xy[1][1]+xy[2][2]) * 3:
    print("No")
    exit()
if result != (xy[0][2]+xy[1][1]+xy[2][0]) * 3:
    print("No")
    exit()
else:
    print("Yes")

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
C = [readInts() for _ in range(3)]
A = [0] * 3
B = [0] * 3
A[0] = 0
for i in range(3):
    B[i] = C[0][i]
for j in range(3):
    A[j] = C[j][0] - B[0]
for i in range(3):
    for j in range(3):
        if A[i] + B[j] == C[i][j]:
            pass
        else:
            print('No')
            exit()
print('Yes')

Submission status: Accepted

Solution code:
c = [list(map(int, input().split())) for _ in range(3)]
# a2 + b1 = c21
# a2 + b2 = c22
# a2 + b3 = c23
b1, b2, b3 = c[0][0], c[0][1], c[0][2]

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

Submission status: Accepted

Solution code:
c = [list(map(int, input().split())) for _ in range(3)]
flag = True
for i in range(3):
  x = [0]*3
  y = [0]*3
  for j in range(3):
    x[j] = c[i-1][j] - c[i][j]
    y[j] = c[j][i-1] - c[j][i]
  if len(set(x)) != 1 or len(set(y)) != 1:
    flag = False
if flag:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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