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:
a1 = 0
c11, c12, c13 = map(int, input().split())
b1 = c11 - a1
b2 = c12 - a1
b3 = c13 - a1

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

if c21 - b1 == c22 - b2 == c23 - b3 and c31 - b1 == c32 - b2 == c33 - b3:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = [list(map(int,input().split())) for i in range(3)]
num = s[0][0]
ans = "No"

for i in range(num+1):
  a_1 = num - i
  b_1 = i
  
  a_2 = s[1][0] - b_1
  a_3 = s[2][0] - b_1
  b_2 = s[0][1] - a_1
  b_3 = s[0][2] - a_1
  
  if s[1][1] != a_2+b_2:
    continue
  if s[1][2] != a_2+b_3:
    continue
  if s[2][1] != a_3+b_2:
    continue
  if s[2][2] != a_3+b_3:
    continue
    
  ans = "Yes"
  
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

a,b,c = IL()
d,e,f = IL()
g,h,i = IL()

if b-a==e-d==h-g and c-b==f-e==i-h and a-d==b-e==c-f and d-g==e-h==f-i:
  Y()
else:
  N()

Submission status: Accepted

Solution code:
ls = [list(map(int,input().split())) for _ in range(3)]
def sub(p,q):
    return p-q
for i in range(len(ls)):
    new = [ls[i][0]]*3
    ls[i] = list(map(sub,ls[i],new))
if (list(map(sub,ls[0],ls[1])) == [0,0,0]) and (list(map(sub,ls[0],ls[2])) == [0,0,0]) and (list(map(sub,ls[2],ls[1])) == [0,0,0]):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
c = [[int(j) for j in input().split()] for i in range(3)]
flag = True
diffb21 = c[0][1] - c[0][0]
diffb32 = c[0][2] - c[0][1]
for i in range(1, 3):
    if c[i][1] - c[i][0] != diffb21 or c[i][2] - c[i][1] != diffb32:
        flag = False
tc = list(zip(*c))
diffa21 = tc[0][1] - tc[0][0]
diffa32 = tc[0][2] - tc[0][1]
for i in range(1, 3):
    if tc[i][1] - tc[i][0] != diffa21 or tc[i][2] - tc[i][1] != diffa32:
        flag = False
print('Yes' if flag else 'No')

Submission status: Accepted

Solution code:
l = list()

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

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

Submission status: Accepted

Solution code:
n = []
m = [[0 for i in range(3)] for j in range(2)]
for x in range(3):
    n.append(list(map(int, input().split())))

k =max(n)
kaisuu = max(k) + 1

def tansa(m):
    iti = 2
    for j in range(kaisuu):
        for k in range(kaisuu):
            if j + k == n[iti][iti]:
                m[0][iti] = j
                m[1][iti] = k
                for a in range(kaisuu):
                    for b in range(kaisuu):
                        if a + b == n[iti - 1][iti - 1] and a + m[1][iti] == n[iti - 1][iti]:
                            m[0][iti - 1] = a
                            m[1][iti - 1] = b
                            for c in range(kaisuu):
                                for d in range(kaisuu):
                                    if c + d == n[iti - 2][iti - 2] and c + m[1][iti - 1] == n[iti - 2][iti - 1] and c + m[1][iti] == n[iti - 2][iti]:
                                        m[0][iti-2] = c
                                        m[1][iti-2] = d
                                        if m[0][1] + m[1][0] == n[1][0] and m[0][2] + m[1][0] == n[2][0] and m[0][2] + \
                                                m[1][1] == n[2][1]:
                                            print("Yes")
                                            exit()

tansa(m)
print("No")

Submission status: Accepted

Solution code:
C = [[int(hoge) for hoge in input().split()] for i in range(3)]
B = C[0]
A = [0,C[1][0] - C[0][0],C[2][0] - C[0][0]]
if C[1] == [A[1] +B[0],A[1]+B[1],A[1] + B[2]] and C[2] ==[A[2] +B[0],A[2]+B[1],A[2] + B[2]]:
    print("Yes")
else:print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
c = [list(map(int,input().split())) for _ in range(3)]
b = c[0]
a = [0]
for i in range(1,3):
    a.append(c[i][i]-b[i])
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:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

c = [LIST() for _ in range(3)]

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

Submission status: Accepted

Solution code:
pre_x, pre_y, pre_z = None,None,None
for i in range(3):
  x,y,z = map(int, input().split())
  if pre_x is None:
    pre_x, pre_y, pre_z = x,y,z
  else:
    if pre_y-pre_x!=y-x or pre_z-pre_y!=z-y or x-pre_x!=y-pre_y or y-pre_y!= z-pre_z:
      print('No')
      break
else:
  print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def check(a,C):
    vertical=False
    horizonal=False
    #vertical
    d1=C[a[0]][0]-C[a[1]][0]
    d2=C[a[0]][1]-C[a[1]][1]
    d3=C[a[0]][2]-C[a[1]][2]
    if d1==d2==d3:
        vertical=True
    #horizonal
    d4=C[0][a[0]]-C[0][a[1]]
    d5=C[1][a[0]]-C[1][a[1]]
    d6=C[2][a[0]]-C[2][a[1]]
    if d4==d5==d6:
        horizonal=True
    return vertical and horizonal    

def main():
    ans=True
    C=[list(map(int,input().strip().split())) for _ in range(3)]
    x=(0,1),(0,2),(1,2)
    for e in x:
        if check(e,C)==False:
            ans=False
            break            
    return "Yes" if ans else "No"

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

Submission status: Accepted

Solution code:
def main():
    c = []
    for _ in range(3):
        c.append(list(map(int, input().split())))
    for i in range(101):
        flag1 = False
        flag2 = False
        b0 = c[0][0] - i
        b1 = c[0][1] - i
        b2 = c[0][2] - i
        a10 = c[1][0] - b0
        a11 = c[1][1] - b1
        a12 = c[1][2] - b2
        if a10 == a11 == a12:
            flag1 = True
        else:
            continue
        a20 = c[2][0] - b0
        a21 = c[2][1] - b1
        a22 = c[2][2] - b2
        if a20 == a21 == a22:
            flag2 = True
            break
    if flag1 and flag2:
        print('Yes')
    else:
        print('No')
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
c_1 = list(map(int, input().split()))
c_2 = list(map(int, input().split()))
c_3 = list(map(int, input().split()))
c = c_1 + c_2 + c_3
if sum(c) == 3 * (c_1[0] + c_2[1] + c_3[2]):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:

box = []

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


for a1 in range(101):
        for a2 in range(101):
                a1_b1 = box[0][0]-a1
                a1_b2 = box[1][0]-a1
                a1_b3 = box[2][0]-a1
                a2_b1 = box[0][1]-a2
                a2_b2 = box[1][1]-a2
                a2_b3 = box[2][1]-a2
                
                f = True
                if a1_b1 != a2_b1 or a1_b2 != a2_b2 or a1_b3 != a2_b3:
                        f = False
                a1_b = [a1_b1,a1_b2,a1_b3] 
                a2_b = [a2_b1,a2_b2,a2_b3] 
                res = True
                a1_a3 = []
                a2_a3 = []
                for i in range(3):
                        if (box[i][2]-a1_b[i]) != (box[i][2]-a2_b[i]):
                                res = False
                        a1_a3.append(box[i][2] - a1_b[i])
                        a2_a3.append(box[i][2] - a2_b[i])
                
                a3 = a1_a3[0]
                for i in range(1,3):
                        if a3 != a1_a3[i]:
                                res = False
                a3_b = []
                for i in range(3):
                        a3_b.append(box[i][2]- a3)
                
                a3_b = []
                for i in range(3):
                        a3_b.append(box[i][2] - a3)
                
                a = [a1,a2,a3]
                b = a3_b

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

                res = True
                for i in range(3):
                        for j in range(3):
                                if box[i][j] != (b[i]+a[j]):
                                        res = False
                #for i in range(3):
                #        print(a1_b[i]+a1,a1_b[i]+a2,)
                if res:
                        print("Yes")
                        exit()
                
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())

    # a1 = 0
    b1, b2, b3 = c11, c12, c13
    a2 = c21 - b1
    a3 = c31 - b1

    ans = "Yes"
    if (a2 + b2 != c22) or (a2 + b3 != c23) or (a3 + b2 != c32) or (a3 + b3 != c33):
        ans = "No"

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

    res = 'No'

    for i in range(101):
        b1 = C[0][0] - i
        b2 = C[0][1] - i
        b3 = C[0][2] - i
        a2 = C[1][0] - b1
        a3 = C[2][0] - b1

        if C[1][1] == a2 + b2 and C[1][2] == a2 + b3 and C[2][1] == a3 + b2 and C[2][2] == a3 + b3:
            res = 'Yes'
            break
    
    print(res)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np

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

ans = []

c = np.array(c)
ch = np.diff(c)

if np.all(ch[0]==ch[1]) & np.all(ch[1]==ch[2]):
    ans.append(True)
else:
    ans.append(False)

cw = np.diff(c.T)

if np.all(cw[0]==cw[1]) & np.all(cw[1]==cw[2]):
    ans.append(True)
else:
    ans.append(False)

ans = "Yes" if all(ans) else "No"
print(ans)

Submission status: Accepted

Solution code:
import numpy as np

c = [list(map(int, input().split())) for i in range(3)]
c = np.array(c)
flag = False
for a1 in range(min(c[0]) + 1):
    b1 = c[0, 0] - a1
    b2 = c[0, 1] - a1
    b3 = c[0, 2] - a1
    if c[1, 0] - b1 == c[1, 1] - b2 == c[1, 2] - b3 and c[2, 0] - b1 == c[2, 1] - b2 == c[2, 2] - b3:
        print('Yes')
        flag = True
        break
if not flag:
    print('No')

Submission status: Accepted

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

# In[59]:


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


# In[52]:


import numpy as np


# In[60]:


c_np = np.array(c)


# In[62]:


flag = True
for a1 in range(max(c_np[0])+1):
    b = [x - a1 for x in c_np[0]]
#     print("a1=%s"%a1, "b=%s"%b)
    a_tmp = c_np[:,0] - b[0]
#     print("i=0", "a=%s"%a_tmp)
    for i in range(2):
        a = c_np[:,i+1] - b[i+1]
#         print("i=%s"%(i+1), "a_tmp=%s"%a_tmp, "a=%s"%a)
        if np.allclose(a_tmp,a):
            a_tmp = a
        else:
            print("No")
            flag = False
            break
    else:
        continue
    break
if flag:
    print("Yes")


# In[ ]:

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# sys.stdin.readline()
import numpy as np
import math
import sys
from collections import defaultdict
input = sys.stdin.readline
A = np.array((list(map(int,input().split()))))
B = np.array((list(map(int,input().split()))))
C = np.array((list(map(int,input().split()))))
def kc(i ,a,b,c):
    if a[i] - a[i-1] == b[i] - b[i-1] ==c[i] - c[i-1] :
        return True
    else:
        return False

def kcc(a,b,c):
    if (a-b)[0] ==(a-b)[1] == (a-b)[2] and(b-c)[0]== (b-c)[1]==(b-c)[2] and  (c-a)[0]==(c-a)[1]==(c-a)[2]:
        return True
    else:
        return False


if kcc(A,B,C) and kc(0 ,A,B,C) and kc(1 ,A,B,C) and kc(2 ,A,B,C):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
cl = []
for i in range(3):
  c = list(map(int, input().split( )))
  cl.append(c)
rcl, trcl, acl, bcl = [], [], [], []
tcl = [x for x in zip(*cl)]
for i in range(3):
  rcb = []
  trca = []
  for j in range(3):
    if j < 2:
      rc = cl[i][j] - cl[i][j + 1]
      trc = tcl[i][j] - tcl[i][j + 1]
    else:
      rc = cl[i][j] - cl[i][j - 2]
      trc = tcl[i][j] - tcl[i][j - 2]
    rcb.append(rc)
    trca.append(trc)
  rcl.append(rcb)
  trcl.append(trca)
for i in range(3):
  if i < 2:
    bc = [x - y for (x, y) in zip(rcl[i], rcl[i + 1])]
    ac = [x - y for (x, y) in zip(trcl[i], trcl[i + 1])]
  else:
    bc = [x - y for (x, y) in zip(rcl[i], rcl[i - 2])]
    ac = [x - y for (x, y) in zip(trcl[i], trcl[i - 2])]
  bcl.append(bc)
  acl.append(ac)
f = lambda x: True if x == 0 else False
aclb = [all([f(n) for n in acl[m]]) for m in range(3)]
bclb = [all([f(n) for n in bcl[m]]) for m in range(3)]
if all(aclb) & all(bclb):
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

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

ans = 'No'

for a1 in range(0, 101):
    for a2 in range(0, 101):
        b1 = grid[0][0] - a1
        b2 = grid[1][1] - a2
        a3 = grid[2][1] - b2
        b3 = grid[2][2] - a3

        a_list = [a1, a2, a3]
        b_list = [b1, b2, b3]

        count = 0
        for x in range(3):
            for y in range(3):
                if grid[x][y] == a_list[x] + b_list[y]:
                    count += 1
        if count == 9:
            ans = 'Yes'
            break

print(ans)

Submission status: Accepted

Solution code:
def main():
    import sys
    sys.setrecursionlimit(10 ** 7)

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

    def recursion(ai=0, b0=-1, b1=-1, b2=-1):
        if ai == 3:
            return True

        if ai > 0:
            d = G[ai][0] - b0
            if (G[ai][0] - b0) == (G[ai][1] - b1) == (G[ai][2] - b2) and 0 <= d <= 100:
                return recursion(ai + 1, b0, b1, b2)
            else:
                return False

        for a in range(100 + 1):
            d = G[0][0] - a
            if d < 0: break
            b0 = d

            d = G[0][1] - a
            if d < 0: break
            b1 = d

            d = G[0][2] - a
            if d < 0: break
            b2 = d

            if recursion(ai + 1, b0, b1, b2):
                return True

        return False

    cond = recursion()
    print('Yes' if cond else 'No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np

c = [[0]*3] * 3

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

c = np.array(c)

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

Submission status: Accepted

Solution code:
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    # a, b = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    A = [list(map(int, input().split())) for i in range(3)]

    B = []
    for i in range(3):
        C = []
        for j in range(3):
            C.append(A[i][j] - min(A[i]))
        B.append(C)

    flag = True
    for i in range(3):
        if B[0][i] != B[1][i] or B[0][i] != B[2][i]:
            flag = False

    if flag == True:
        print("Yes")
    else:
        print("No")
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1,3):
    ALL = []
    for j in range(3):
        a = C[0][j] - C[i][j]
        ALL.append(a)

    if len(set(ALL)) != 1:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
c = [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 (c[0][0] - a1 == c[1][0] - a2 == c[2][0] - a3) and (c[0][1] - a1 == c[1][1] - a2 == c[2][1] - a3) and (c[0][2] - a1 == c[1][2] - a2 == c[2][2] - a3):
                print("Yes")
                exit()
else:
    print("No")

Submission status: Accepted

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

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

    for a2 in range(c[1][0] + 1):
        if b1 != c[1][0] - a2:
            continue
        if b2 != c[1][1] - a2:
            continue
        if b3 != c[1][2] - a2:
            continue

        for a3 in range(c[2][0] + 1):
            if b1 != c[2][0] - a3:
                continue
            if b2 != c[2][1] - a3:
                continue
            if b3 != c[2][2] - a3:
                continue

            print("Yes")
            exit()

print("No")

Submission status: Accepted

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

flg = True
a1 = 0
b1 = C[0][0]
b2 = C[0][1]
b3 = C[0][2]

if not (C[1][0]-b1==C[1][1]-b2 and C[1][1]-b2==C[1][2]-b3):
    flg = False
if not (C[2][0]-b1==C[2][1]-b2 and C[2][1]-b2==C[2][2]-b3):
    flg = False

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

Submission status: Accepted

Solution code:
import sys
n = 3

c = [[-1,-1,-1] for _ in range(n)]
for i in range(n):
  c[i] = list(map(int,input().split()))
  
#print(c)

Flag = True
if c[1][0]-c[0][0] != c[1][1]-c[0][1] or c[1][0]-c[0][0] != c[1][2]-c[0][2]:
  print("No")
  sys.exit()
if c[2][0]-c[0][0] != c[2][1]-c[0][1] or c[2][0]-c[0][0] != c[2][2]-c[0][2]:
  print("No")
  sys.exit()
if c[0][1]-c[0][0] != c[1][1]-c[1][0] or c[2][1]-c[2][0] != c[1][1]-c[1][0]:
  print("No")
  sys.exit()
if c[0][2]-c[0][0] != c[1][2]-c[1][0] or c[2][2]-c[2][0] != c[1][2]-c[1][0]:
  print("No")
  sys.exit()
print("Yes")

Submission status: Accepted

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

for i in range(3):
    a_a.add(c[i][0]-c[i][1])
    a_b.add(c[i][1]-c[i][2])
    a_c.add(c[i][2]-c[i][0])
if len(a_a)==1 and len(a_b)==1 and len(a_c)==1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

for b1 in range(101):
    a1 = C[0][0] - b1
    a2 = C[0][1] - b1
    a3 = C[0][2] - b1
    for b2 in range(101):
        aa1 = C[1][0] - b2
        aa2 = C[1][1] - b2
        aa3 = C[1][2] - b2
        for b3 in range(101):
            aaa1 = C[2][0] - b3
            aaa2 = C[2][1] - b3
            aaa3 = C[2][2] - b3
            if (a1, a2, a3) == (aa1, aa2, aa3) == (aaa1, aaa2, aaa3):
                print("Yes")
                exit()

print("No")

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    a = [f_inf] * 3
    b = [f_inf] * 3
    a[0] = 0
    for j in range(3):
        b[j] = C[0][j] - a[0]

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

    print("Yes")


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
import sys
from collections import Counter
from collections import deque
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

l=[lmp() for i in range(3)]
n1=l[0][0]-l[0][1]
n2=l[0][0]-l[0][2]

for i in range(1,3):

    if n1!=l[i][0]-l[i][1] or n2!=l[i][0]-l[i][2]:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

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

Submission status: Accepted

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

j = True
for i in range(2):
    if abs(c[i+1][0]-c[i][0]) == abs(c[i+1][1]-c[i][1]) == abs(c[i+1][2]-c[i][2]):
        pass
    else:
        j = False

for i in range(2):
    if abs(c[0][i+1]-c[0][i]) == abs(c[1][i+1]-c[1][i]) == abs(c[2][i+1]-c[2][i]):
        pass
    else:
        j = False

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

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

l1=LI()
l2=LI()
l3=LI()
c1=l1[0]
c2=l1[1]
c3=l1[2]
c4=l2[0]
c5=l2[1]
c6=l2[2]
c7=l3[0]
c8=l3[1]
c9=l3[2]
a1=0
b1=c1
a2=c4-c1
a3=c7-c1
b2=c2
b3=c3
count=0
if c5==a2+b2:
    count+=1
if c6==a2+b3:
    count+=1
if c8==a3+b2:
    count+=1
if c9==a3+b3:
    count+=1
if count==4:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

print('No')

Submission status: Accepted

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

    for i in range(101):
        for j in range(101):
            for k in range(101):
                A = [i, j, k]
                B = [C[0][0]-A[0], C[1][1]-A[1], C[2][2]-A[2]]
                count = 0
                for l in range(3):
                    for m in range(3):
                        if C[l][m] == A[l]+B[m]:
                            count += 1
                if count == 9:
                    print('Yes')
                    return
    print('No')


if __name__ == '__main__':
    main()

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]
ans = False
for i in range(101):
    flag = False
    a[0] = i
    for j in range(3):
        b[j] = c[0][j] - a[0]
    for j in range(3):
        a[j] = c[j][0] - b[0] 
    
    for j in range(3):
        for k in range(3):
            if a[j] + b[k] != c[j][k]:
                flag = True
                break
        
    if flag:
        break
    else:
        ans = True
        break

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

Submission status: Accepted

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

R1 = [A[i][1] - A[i][0] for i in range(3)]
R2 = [A[i][2] - A[i][1] for i in range(3)]
C1 = [A[1][i] - A[0][i] for i in range(3)]
C2 = [A[2][i] - A[1][i] for i in range(3)]

ok = True
for x in [R1,R2,C1,C2]:
  if len(set(x)) != 1:
    ok = False
    break
    
if not ok:
  print('No')
else:
  print('Yes')