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

list_a = [0, C[1][0] - C[0][0], C[2][0] - C[0][0]]
list_b = [C[0][0], C[0][1], C[0][2]]

for i in range(3) :
    for j in range(3) :
        if C[i][j] != list_a[i] + list_b[j] :
            print("No")
            exit()

print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

if (c[0][0] + c[0][1] - (c[0][2])*2 == c[1][0] + c[1][1] - (c[1][2])*2) and (c[0][0] + c[0][1] - (c[0][2])*2 == c[2][0] + c[2][1] - (c[2][2])*2):
    if (c[0][0] + c[1][0] - (c[2][0])*2 == c[0][1] + c[1][1] - (c[2][1])*2) and (c[0][0] + c[1][0] - (c[2][0])*2 == c[0][2] + c[1][2] - (c[2][2])*2):
        print("Yes")
        exit(0)

print("No")

Submission status: Accepted

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

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

    isGood = True

    if a1 + b1 != num_list[0][0]:
        isGood = False
    if a1 + b2 != num_list[0][1]:
        isGood = False
    if a1 + b3 != num_list[0][2]:
        isGood = False
    if a2 + b1 != num_list[1][0]:
        isGood = False
    if a2 + b2 != num_list[1][1]:
        isGood = False
    if a2 + b3 != num_list[1][2]:
        isGood = False
    if a3 + b1 != num_list[2][0]:
        isGood = False
    if a3 + b2 != num_list[2][1]:
        isGood = False
    if a3 + b3 != num_list[2][2]:
        isGood = False

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

diff1 = abs(c[0][0] - c[0][1])
diff2 = abs(c[0][1] - c[0][2])

for i in range(1,3):
    d1 = abs(c[i][0] - c[i][1])
    d2 = abs(c[i][1] - c[i][2])
    if d1 != diff1 or d2 != diff2:
        flag = False
        break

if flag:
    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()))
    
a=[0,0,0]
b=[0,0,0]
    

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

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

Submission status: Accepted

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

x = C[0][0]
a = [c[0] - x for c in C]
b = [C[0][i]-a[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_0 = [int(_) for _ in input().split()]
c_1 = [int(_) for _ in input().split()]
c_2 = [int(_) for _ in input().split()]

d = [0] * 3
e = [0] * 3

for i in range(3):
    d[i] = c_0[i%3] + c_1[(i+1)%3] + c_2[(i+2)%3]
    e[i] = c_0[(i+2)%3] + c_1[(i+1)%3] + c_2[i%3]

flag = True

for i in range(2):
    if d[0] != d[i] or d[0] != e[i]:
        flag = False

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

Submission status: Accepted

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

ans = "Yes"

A = [0] * 3
B = C[0]

A[1] = C[1][0] - B[0]
A[2] = C[2][0] - B[0]

for i in range(3):
  for j in range(3):
    if C[i][j] != A[i] + B[j]:
      ans = "No"
      break

print(ans)

Submission status: Accepted

Solution code:
inp=[]

inp.append(list(map(int,input().split())))
inp.append(list(map(int,input().split())))
inp.append(list(map(int,input().split())))

for i in range(101):
  flag=0
  
  a1=i
  b1=inp[0][0]-a1
  if b1<0:
    flag=1
  a2=inp[0][1]-b1
  if a2<0:
    flag=1
  a3=inp[0][2]-b1
  if a3<0:
    flag=1
  if inp[1][0]-a1!=inp[1][1]-a2 or inp[1][0]-a1 != inp[1][2]-a3:
    flag=1
  if inp[2][0]-a1!=inp[2][1]-a2 or inp[2][0]-a1 != inp[2][2]-a3:
    flag=1
  if flag==0:
    print("Yes")
    exit()
  
  
print("No")

Submission status: Accepted

Solution code:
dat = []
for _ in range(3):
    dat.append(list(map(int, input().split())))
f = True
a1,a2,a3,b1,b2,b3 = -1,-1,-1,-1,-1,-1
a1 = 0
b1 = dat[0][0]
b2 = dat[0][1]
b3 = dat[0][2]

a2 = dat[1][0] - b1
a3 = dat[2][0] - b1

if dat[1][1] != a2 + b2:
    f = False

if dat[1][2] != a2 + b3:
    f = False

if dat[2][1] != a3 + b2:
    f = False

if dat[2][2] != a3 + b3:
    f = False

#if 0 > a1 or 0>a2 or 0>a3 or 0>b1 or 0>b2 or 0>b3:
#    f = False

#print(a1,a2,a3,b1,b2,b3)
print("Yes" if f else "No")

Submission status: Accepted

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

for i in range(3):
  x = a[i][0] - a[(i+1)%3][0]
  y = a[0][i] - a[0][(i+1)%3]
  if x != a[i][1] - a[(i+1)%3][1] or x != a[i][2] - a[(i+1)%3][2]:
    print('No')
    exit()
  
  if y != a[1][i] - a[1][(i+1)%3] or y != a[2][i] - a[2][(i+1)%3]:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

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

a=max(c[0])
for i in range(a+1):
    a1=i
    b=[0,0,0]
    a=[0,0,0]
    cnt=0
    for j in range(3):
        for k in range(3):
            if j==0:
                #b1,b2,b3を決める
                b[k]=c[j][k]-a1

            elif j==2 or j==1:
                a[k]=c[j][k]-b[k]

            if (j==1 or j==2) and k==2:
                #print(a1,a,b)
                if len(set(a))==1 and a[0]>=0:
                    cnt+=1

print('Yes' if cnt==2 else'No')

Submission status: Accepted

Solution code:
import sys
# input = sys.stdin.buffer.readline
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))
import math
import bisect
import heapq
from collections import defaultdict, Counter, deque
MOD = 10**9 + 7
INF = 10**15

def main():
    a,b,c = getlist()
    s12 = b - a
    s13 = c - a
    s23 = c - b
    for i in range(2):
        d,e,f = getlist()
        # print(d,e,f)
        # print(s12,s23,s13)
        if e-d != s12:
            # print(e-d)
            print("No")
            return
        if f-d != s13:
            print("No")
            return
        if f-e != s23:
            print("No")
            return

    print("Yes")
    return

if __name__ == '__main__':
    main()

"""
9999
3

2916
"""

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    c = list()
    for i in range(3):
        c.append(list(map(int, input().split())))

    tmp = list()
    for i in range(3):
        tmp.append([c[i][0]-c[0][0], c[i][1]-c[0][1], c[i][2]-c[0][2]])
    for i in range(3):
        if tmp[i][0] == tmp[i][1] == tmp[i][2]:
            continue
        else:
            print('No')
            exit()

    tmp = list()
    for i in range(3):
        tmp.append([c[0][i]-c[0][0], c[1][i]-c[1][0], c[2][i]-c[2][0]])
    for i in range(3):
        if tmp[i][0] == tmp[i][1] == tmp[i][2]:
            continue
        else:
            print('No')
            exit()

    print('Yes')

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    C=LLIN(3)
    A=[C[0][i]-C[0][0] for i in range(3)]
    B=[C[1][i]-C[1][0] for i in range(3)]
    C=[C[2][i]-C[2][0] for i in range(3)]
    if A==B==C:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = 3
C = [list(map(int, input().split())) for i in range(N)]
f = True
for i in range(N - 1):
    a = C[i][0] - C[i + 1][0]
    b = C[i][1] - C[i + 1][1]
    c = C[i][2] - C[i + 1][2]
    if a == b == c:
        continue
    else:
        f = False
for j in range(N - 1):
    a = C[0][j] - C[0][j + 1]
    b = C[1][j] - C[1][j + 1]
    c = C[2][j] - C[2][j + 1]
    if a == b == c:
        continue
    else:
        f = False
if f:
    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()))

if sum(c1)+sum(c2)+sum(c3) == 3*(c1[0]+c2[1]+c3[2]):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    C = [[int(c) for c in input().split()] for _ in range(3)]
    possible = False
    for i in range(101):
        for j in range(101):
            for k in range(101):
                a11 = C[0][0] - i
                a12 = C[0][1] - j
                a13 = C[0][2] - k
                a21 = C[1][0] - i
                a22 = C[1][1] - j
                a23 = C[1][2] - k
                a31 = C[2][0] - i
                a32 = C[2][1] - j
                a33 = C[2][2] - k
                if a11 == a12 == a13 and a21 == a22 == a23 and a31 == a32 == a33:
                    possible = True
                    break
            if possible: break
        if possible: break
    print("Yes" if possible else "No")

    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
def main():
    A = [[int(i) for i in input().split()] for j in range(3)]
    from itertools import product
    for a1, a2, a3 in product(range(101), repeat=3):
        c1 = A[0][0] - a1 == A[1][0] - a2 == A[2][0] - a3
        c2 = A[0][1] - a1 == A[1][1] - a2 == A[2][1] - a3
        c3 = A[0][2] - a1 == A[1][2] - a2 == A[2][2] - a3
        if c1 and c2 and c3:
            return print("Yes")
    print("No")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
C=[]
for i in range (3):
	C.append(list(map(int,input().split())))
count=0
if C[0][0]+C[2][2]!=C[2][0]+C[0][2]:
	count+=1
D=[]
E=[]
F=[]
for i in range (3):
	D.append(C[i][0]-C[i][1])
	E.append(C[i][1]-C[i][2])
	F.append(C[i][2]-C[i][0])
if len(set(D))!=1 or len(set(E))!=1 or len(set(F))!=1:
	count+=1
G=[]
H=[]
I=[]
for i in range (3):
	G.append(C[0][i]-C[1][i])
	H.append(C[1][i]-C[2][i])
	I.append(C[2][i]-C[0][i])
if len(set(G))!=1 or len(set(H))!=1 or len(set(I))!=1:
	count+=1	
if count==0:
	print("Yes")
else:
	print("No")

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

# a: 行共通の値
# b: 列共通の値
flag = False
for a0 in range(0,min(C[0])+1):
    b = [0] * 3
    for j in range(3):
        b[j] = C[0][j] - a0
    for i in range(1,3):
        tmp1 = C[i][0] - b[0]
        for j in range(1,3):
            tmp2 = C[i][j] - b[j]
            if tmp1 != tmp2:
                flag = True
            else:
                tmp1 = tmp2

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

a=1
b=0
if A[0]-B[0]==A[1]-B[1]==A[2]-B[2]:
    b=1
else:
    a=0

if B[0]-C[0]==B[1]-C[1]==B[2]-C[2]:
    b=1
else:
    a=0

if A[0]-A[1]==B[0]-B[1]==C[0]-C[1]:
    b=1
else:
    a=0
if A[1]-A[2]==B[1]-B[2]==C[1]-C[2]:
    b=1
else:
    a=0

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

Submission status: Accepted

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

mx = 0
for i in range(3): mx = max(mx, max(c[i]))

flag = True
for i in range(mx+1):
    d1 = [c[0][0]-i, c[0][1]-i, c[0][2]-i]
    for j in range(mx+1):
        d2 = [c[1][0]-j, c[1][1]-j, c[1][2]-j]
        for k in range(mx+1):
            d3 = [c[2][0]-k, c[2][1]-k, c[2][2]-k]
            if d1==d2==d3: flag = False
print("YNeos"[flag::2])

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(3):
    for j in range(3):
        m[i][j] = l[i][j] - l[0][j]

for i in range(3):
    f = True
    for j in range(3):
        if m[i][j] != m[i][0]:
            f = False
            break
    if not f:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
c=[]
for i in range(3):
    c_i=list(map(int,input().split()))
    c.append(c_i)
h01=c[0][1]-c[0][0]
h12=c[0][2]-c[0][1]
v01=c[1][0]-c[0][0]
v12=c[2][0]-c[1][0]
buf=1
for i in range(1,3):
    if c[i][1]-c[i][0]!=h01 or c[i][2]-c[i][1]!=h12 or c[1][i]-c[0][i]!=v01 or c[2][i]-c[1][i]!=v12:
        buf=0
        break
if buf==1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

t = True
for i in range(3):
  if not l[i][0] - l[i-1][0] == l[i][1] - l[i-1][1] == l[i][2] - l[i-1][2] or not l[0][i] - l[0][i-1] == l[1][i] - l[1][i-1] == l[2][i] - l[2][i-1]:
    t = False

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
  pc1, pc2, pc3 = map(int, input().split())
  for i in range(2):
    c1, c2, c3 = map(int, input().split())
    if (c1-pc1)==(c2-pc2) and (c2-pc2)==(c3-pc3):
      pc1, pc2, pc3 = c1, c2, c3
      
    else:
      return 'No'
    
  return 'Yes'

print(main())

Submission status: Accepted

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


def check(data):
    diff={}
    
    for i in range(3):
        for j in range(2):
            
            # diff b
            key_b = "b_" + str(j) + "-" + str(j+1)
            delta_b = data[i][j+1] - data[i][j]
            if key_b in diff:
                if diff[key_b] != delta_b:
                    return False
            else:
                diff[key_b] = delta_b

    for j in range(3):
        for i in range(2):
            # diff a
            key_a="a_" + str(i) + "-" + str(i+1)
            delta_a = data[i+1][j] - data[i][j]
            if key_a in diff:
                if diff[key_a] != delta_a:
                    return False
            else:
                diff[key_a] = delta_a

    return True

#----------
data = [list(map(int, input().rstrip().split())) for _ in range(3)]
#----------
if check(data):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
c = [[int(x) for x in input().split()] for _ in range(3)]
s = True
for i in range(2):
    for j in range(i+1, 3):
        if c[0][j] - c[0][i] == c[1][j] - c[1][i] == c[2][j] - c[2][i]:
            continue
        else:
            s = False
            break
for i in range(2):
    for j in range(i+1, 3):
        if c[j][0] - c[i][0] == c[j][1] - c[i][1] == c[j][2] - c[i][2]:
            continue
        else:
            s = False
            break
print("Yes") if s else print("No")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def main():
    c11, c12, c13 = map(int, input().split())
    c21, c22, c23 = map(int, input().split())
    c31, c32, c33 = map(int, input().split())
    ans = "No"
    for a1 in range(0, min([c11, c12, c13]) + 1):
        b1 = c11 - a1
        b2 = c12 - a1
        b3 = c13 - a1
        a2 = c21 - b1
        a3 = c31 - b1
        if c22 == a2 + b2 and c23 == a2 + b3 and c32 == a3 + b2 and c33 == a3 + b3:
            ans = "Yes"
            break
    print(ans)

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

Submission status: Accepted

Solution code:
l=[]
l.append(list(map(int,input().split())))
l.append(list(map(int,input().split())))
l.append(list(map(int,input().split())))
for i in range(2):
  if l[i][1]-l[i][0]!=l[i+1][1]-l[i+1][0] or l[i][2]-l[i][1]!=l[i+1][2]-l[i+1][1]:
    print('No')
    break
  if i==1:
    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())

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

Submission status: Accepted

Solution code:
c = [list(map(int, input().split())) for _ in range(3)]
def a(c):
    for j in range(2):
        if not ((c[0][j]-c[0][j+1]) == (c[1][j]-c[1][j+1]) and (c[1][j]-c[1][j+1]) == (c[2][j]-c[2][j+1])):
            return print('No')
        if not ((c[j][0]-c[j+1][0]) == (c[j][1]-c[j+1][1]) and (c[j][1]-c[j+1][1]) == (c[j][2]-c[j+1][2])):
            return print('No')
    return print('Yes')
a(c)

Submission status: Accepted

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

e = c[0][1] - c[0][0]
f = c[0][2] - c[0][1]

if any(e != c[x][1]-c[x][0] for x in [1,2]) or any(f != c[x][2]-c[x][1] for x in [1,2]) :
    print('No')
else:
    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())

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

Submission status: Accepted

Solution code:
from itertools import permutations


def main():
    grid = []
    num_sum = 0
    for _ in range(3):
        tmp = list(map(int, input().split(" ")))
        num_sum += sum(tmp)
        grid.append(tmp)
    num_sum //= 3
    index_list = permutations([0, 1, 2])
    answer = "Yes"
    for index in index_list:
        if not grid[0][index[0]] + grid[1][index[1]] + grid[2][index[2]] == num_sum:
            answer = "No"
            break
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
c = []
for i in range(3):
    c.append(list(map(int, input().split())))
x = [0] * 3
y = [0] * 3
# print(c)
for i in range(3):
    y[i] = c[0][i]
for i in range(3):
    x[i] = c[i][0] - y[0]

answer = 'Yes'
for i in range(3):
    for j in range(3):
        if c[i][j] != x[i] + y[j]:
            answer = 'No'

print(answer)

Submission status: Accepted

Solution code:
[(a,b,c),(d,e,f),(g,h,i)]=[map(int,input().split()) for _ in range(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 = []
for i in range(3):
    c.append(list(map(int, input().split())))
a = [0]*3
b = [0]*3
for i in range(3):
    b[i] = c[0][i]
for i in range(3):
    a[i] = c[i][0] - b[0]

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

Submission status: Accepted

Solution code:
from itertools import permutations
l = list(range(3))
l = list(permutations(l, 2))
C = [[0]*3 for i in range(3)]
r = 'Yes'
for i in range(3):
    C[i] = list(map(int, input().split()))
for i in l:
    if not C[0][i[0]]-C[0][i[1]]==C[1][i[0]]-C[1][i[1]]==C[2][i[0]]-C[2][i[1]]:
        r = 'No'
        break
print(r)

Submission status: Accepted

Solution code:
import numpy as np
import sys
c = np.array([list(map(int, input().split())) for _ in range(3)])
for i in range(-1, 2):
    if len(set(c[i] - c[i+1])) == 1:
        pass
    else:
        print("No")
        sys.exit()

for i in range(-1, 2):
    if len(set(c[:, i] - c[:, i+1])) == 1:
        pass
    else:
        print("No")
        sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
c = [list(map(int,input().split())) for _ in range(3)]
#%%
b = [0]*3
N = max(max(c))+1

for a1 in range(N):
    for a2 in range(N):
        for a3 in range(N):
            b[0] = c[0][0]-a1
            b[1] = c[0][1]-a1
            b[2] = c[0][2]-a1
            flag = True
            nb = [0]*3
            for i in range(3):
                nb[i] = c[1][i]-a2
                if nb[i]!=b[i]:
                    flag = False
                    break
            for i in range(3):
                nb[i] = c[2][i]-a3
                if nb[i]!=b[i]:
                    flag = False
                    break
            
            if flag:
                import sys
                print('Yes')
                sys.exit()

            
print('No')

Submission status: Accepted

Solution code:
def mod3(num):
    if num % 3 == 0:
        return True
    else:
        return False

cList = [list(map(int, input().split())) for _ in range(3)]
row = [sum(cList[0]), sum(cList[1]), sum(cList[2])]
col = [cList[0][i] + cList[1][i] + cList[2][i] for i in range(3)]
differenceRow = [row[i - 1] - row[i] for i in range(3)]
differenceCol = [col[i - 1] - col[i] for i in range(3)]
difference = [sum(row)] + differenceRow + differenceCol
if list(filter(mod3, difference)) != difference:
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

ans = 'Yes'

if not c[0][1] - c[0][0] == c[1][1] - c[1][0] == c[2][1] - c[2][0]:
    ans = 'No'
if not c[0][2] - c[0][1] == c[1][2] - c[1][1] == c[2][2] - c[2][1]:
    ans = 'No'

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
C=[]
for i in range(3):
    c=list(map(int,input().split()))
    #print(c)
    C.append(c)


cnt=0
#横
if C[0][0]-C[1][0]==C[0][1]-C[1][1]==C[0][2]-C[1][2]:
    cnt+=1
if C[1][0]-C[2][0]==C[1][1]-C[2][1]==C[1][2]-C[2][2]:
    cnt+=1
if C[2][0]-C[0][0]==C[2][1]-C[0][1]==C[2][2]-C[0][2]:
    cnt+=1
    
#縦
if C[0][0]-C[0][1]==C[1][0]-C[1][1]==C[2][0]-C[2][1]:
    cnt+=1
if C[0][1]-C[0][2]==C[1][1]-C[1][2]==C[2][1]-C[2][2]:
    cnt+=1
if C[0][2]-C[0][0]==C[1][2]-C[1][0]==C[2][2]-C[2][0]:
    cnt+=1
#print(cnt)
if cnt==6:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
# coding: utf-8
m = []
for i in range(3):
    m.append(list(map(int, input().split())))

# 横の走査
flag = True
l = []
for i in range(2):
    for j in range(1, 3):
        l = []
        for k in range(3):
            l.append(m[i][k] - m[j][k])
        if len(set(l)) != 1:
            flag = False
# 縦の走査
for i in range(2):
    for j in range(1, 3):
        l = []
        for k in range(3):
            l.append(m[k][i] - m[k][j])
        if len(set(l)) != 1:
            flag = False
print("Yes" if flag else "No")

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
M=[]

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

flg=True

for i in range(3):
    if M[0][i]-M[0][i-1] == M[1][i]-M[1][i-1] == M[2][i]-M[2][i-1]:
        continue
    else:
        flg=False
    
    if M[i][0]-M[i-1][0] == M[i][1]-M[i-1][1] == M[i][2]-M[i-1][2]:
        continue
    else:
        flg=False

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

Submission status: Accepted

Solution code:
grid = []
al = 0
cnt = 0
for i in range(3):
    a = list(map(int,input().split()))
    al += sum(a)
    cnt += a[i]
    grid.append(a)

if al == cnt * 3:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            if (N[0][0]-a1==N[1][0]-a2==N[2][0]-a3
                    and  N[0][1] -a1==N[1][1]-a2==N[2][1]-a3
                    and N[0][2] -a1 == N[1][2]-a2 ==N[2][2] -a3):
                print('Yes')
                exit()
print('No')

Submission status: Accepted

Solution code:
# 入力を格納
C = [list(map(int, input().split())) for _ in range(3)]

# a, bをリストとして準備
a = [0] * 3
b = [0] * 3

# a1=0ならば、b1, b2, b3はC[0]に該当
b[0], b[1], b[2] = C[0][0], C[0][1], C[0][2]

# Cとbの値からa1, a2, a3の値を求める
a[0], a[1], a[2] = 0, C[1][0] - b[0], C[2][0] - b[0]

# Cとai+biを比較し、いずれかのケースで一致いない場合は出力を”No"とする
ans = "Yes"
for i in range(3):
    for j in range(3):
        if C[i][j] == (a[i] + b[j]):
            pass
        else:
            ans = "No"
            break

print(ans)

Submission status: Accepted

Solution code:
# ABC 088 C - Takahashi's Information
"""
高橋君の提示している条件内では、ai,biが不定でも問題ないことがポイントです。
つまり、cii = ai+biを満たせばよいので、aiをx増やしたらbiをx減らせばciiは同様に成り立ちます。
一般化すると
(𝑎1, 𝑎2, 𝑎3, 𝑏1, 𝑏2, 𝑏3) = (𝑝1, 𝑝2, 𝑝3, 𝑞1, 𝑞2, 𝑞3)から
(𝑎1, 𝑎2, 𝑎3, 𝑏1, 𝑏2, 𝑏3) = (𝑝1 + 𝑥, 𝑝2 +𝑥, 𝑝3 + 𝑥, 𝑞1 − 𝑥, 𝑞2 − 𝑥, 𝑞3 − 𝑥)にしても問題ないです。
この性質を利用して𝑎1 = 0とすると、c11=a1+b1=b1,　c12=a1+b2=b2,　c13=a1+b3=b3
が成立します。b1がわかれば上記と同様にa2,a3はわかります(c21=a2+b1,c31=a3+b1から)。
(1)a = 0として、b1,b2,b3を求める
(2)a2 = c21-b1, a3 = c31-b1からa2,a3を求める
(3)求めたa1~3とb1~3を使ってcijの我が正しいか判定する
"""
C = [list(map(int,input().split())) for __ in range(3)]

a=[0]*3
b=[0]*3
b[0],b[1],b[2]=C[0]
a[0],a[1],a[2]=0,C[1][0]-b[0],C[2][0]-b[0]
flag = True
for i in range(3):
    if flag == False:
        break
    for j in range(3):
        if C[i][j] != a[i]+b[j]:
            print("No")
            flag = False
            break
if flag == True:
    print("Yes")

Submission status: Accepted

Solution code:
import sys
lis = [list(map(int,input().split())) for _ in range(3)]
d1 = lis[0][0] - lis[0][1]
d2 = lis[0][1] - lis[0][2]
flag = 'No'
for l in lis:
    if l[0] - l[1] != d1 or l[1] - l[2] != d2:
        print('No')
        sys.exit()
else:
    flag = 'Yes'
print(flag)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

X = [[int(x) for x in input().split()] for _ in range(3)]

for i in range(min(X[0])+1):
    t1 = [x-i for x in X[0]]
    for j in range(min(X[1])+1):
        t2 = [x-j for x in X[1]]
        for k in range(min(X[2])+1):
            t3 = [x-k for x in X[2]]
            if t1==t2==t3:
                print('Yes')
                sys.exit()

print('No')

Submission status: Accepted

Solution code:
def pin(type=int):
    return map(type,input().split())
#どっかで最悪計算量の入力データを用意する関数を作ろう？
def worstdata():
    a=0
    return a
#solution:
def comp(x,y):
    dp=[0,max(act[0])]*(N+1) #[i]日目のActivity で得られる最大幸福量
    
    return 0

#input
C=[list(pin()) for _ in range(3)]#combinationの実装が適当すぎる
yoko=[[0]*3 for _ in range(3)]
yoko[0]=[C[1][i]-C[0][i] for i in range(3) ]
yoko[1]=[C[2][i]-C[1][i] for i in range(3) ]
yoko[2]=[C[0][i]-C[2][i] for i in range(3) ]
#print(yoko)
cond=1
for kakaka in range(3):
    if not(yoko[kakaka][0]== yoko[kakaka][1] and yoko[kakaka][1]== yoko[kakaka][2]):
        cond=0
        break
#print(solution(H,N))
print(["No","Yes"][cond])

Submission status: Accepted

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

for i in range(2):
    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]:
        print("No")
        exit()
print("Yes")