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:
from sys import exit
C = [list(map(int, input().split())) for _ 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")
    exit()
if not (C[0][0] - C[0][2] == C[1][0] - C[1][2] == C[2][0] - C[2][2]):
    print("No")
    exit()
if not (C[0][2] - C[0][1] == C[1][2] - C[1][1] == C[2][2] - C[2][1]):
    print("No")
    exit()

print("Yes")

Submission status: Accepted

Solution code:
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode
import sys
sys.setrecursionlimit(10 ** 6)

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

c = LI(3)

for a1 in range(c[0][0]+1):
    # print(a1)
    a = []
    b = []
    a.append( a1 )
    b.append( c[0][0] - a1 )
    b.append( c[0][1] - a1 )
    b.append( c[0][2] - a1 )
    a.append( c[1][0] - b[0] )
    a.append( c[2][0] - b[0] )
    if a[1]+b[1]==c[1][1] and a[1]+b[2]==c[1][2] and a[2]+b[1]==c[2][1] and a[2]+b[2]==c[2][2]:
        print("Yes")
        exit()
print("No")
exit()

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

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

flag = 1

for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            if c[0][0] - a1 == c[1][0] - a2 and c[1][0] - a2 == c[2][0] - a3:
                if c[0][1] - a1 == c[1][1] - a2 and c[1][1] - a2 == c[2][1] - a3:
                    if c[0][2] - a1 == c[1][2] - a2 and c[1][2] - a2 == c[2][2] - a3:
                        flag = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

            a = [a1, a2, a3]
            b = [b1, b2, b3]

            cnt = 0
            for i in range(3):
                for j in range(3):
                    if l[i][j] == a[i] + b[j]:
                        cnt += 1
            if cnt == 9:
                print("Yes")
                exit()
print("No")

Submission status: Accepted

Solution code:
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

c = [lint() for _ in range(3)]
judge(
    c[0][0]-c[0][1]==c[1][0]-c[1][1]==c[2][0]-c[2][1] and
    c[0][0]-c[0][2]==c[1][0]-c[1][2]==c[2][0]-c[2][2] and
    c[0][1]-c[0][2]==c[1][1]-c[1][2]==c[2][1]-c[2][2] and
    c[0][0]-c[1][0]==c[0][1]-c[1][1]==c[0][2]-c[1][2] and
    c[0][0]-c[2][0]==c[0][1]-c[2][1]==c[0][2]-c[2][2] and
    c[2][0]-c[1][0]==c[2][1]-c[1][1]==c[2][2]-c[1][2]
)

Submission status: Accepted

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

Submission status: Accepted

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

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(c: "List[List[int]]"):
    from itertools import product
    for a1, b1 in product(range(101), repeat=2):
        a2 = c[1][0] - b1
        a3 = c[2][0] - b1
        b2 = c[0][1] - a1
        b3 = c[0][2] - a1
        if a2 < 0 or a3 < 0 or b2 < 0 or b3 < 0:
            continue
        a = [a1, a2, a3]
        b = [b1, b2, b3]
        if all((a[i]+b[j])==c[i][j] for i, j in product(range(3), repeat=2)):
            return YES
    return NO

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    c = [[int(next(tokens)) for _ in range(3)] for _ in range(3)]  # type: "List[List[int]]"
    print(solve(c))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()

Submission status: Accepted

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

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

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

for 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:
A=[list(map(int,input().split())) for i  in range(3)]
if A[0][0]+A[1][1]==A[0][1]+A[1][0] and A[1][1]+A[2][2]==A[1][2]+A[2][1] and A[0][0]+A[2][2]==A[0][2]+A[2][0] :
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(2):
    tate = abs(cs[0+i][0] - cs[1+i][0])
    for j in range(1,3):
        if tate - abs(cs[i][j] - cs[i+1][j]) != 0:
            print('No')
            exit()
print('Yes')

Submission status: Accepted

Solution code:
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    c = []
    for _ in range(3):
        c.append(input_int_list())

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

    return


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# vim: fileencoding=utf-8


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

    for a1 in range(0, l[0][0] + 1):
        b1 = l[0][0] - a1
        b2 = l[0][1] - a1
        b3 = l[0][2] - a1
        a2 = l[1][0] - b1
        a3 = l[2][0] - b1
        if b1 < 0:
            continue
        if b2 < 0:
            continue
        if b3 < 0:
            continue
        if a2 < 0:
            continue
        if a3 < 0:
            continue
        if (
            l[1][1] == b2 + a2
            and l[1][2] == b3 + a2
            and l[2][1] == b2 + a3
            and l[2][2] == b3 + a3
        ):
            print("Yes")
            return
    print("No")


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

dx1=c[1]-c[0]
dx2=c[2]-c[1]
dy1=d[1]-d[0]
dy2=d[2]-d[1]

for i in range(3):
  c=a[i]
  d=b[i]
  if dx1==c[1]-c[0] and dx2==c[2]-c[1] and dy1==d[1]-d[0] and dy2==d[2]-d[1]:
    f=True
  else:
    f=False
    break
if f:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
List=[list(map(int,input().split())) for i in range(3)]
newlist=[]
new = [x-y for (x,y) in zip(List[0],List[1])]
new2 = [x-y for (x,y) in zip(List[2],List[1])]
if new[0]==new[1] and new[1]==new[2]:
    pass
else:
    print('No')
    exit()
if new2[0]==new2[1] and new2[1]==new2[2]:
    pass
else:
    print('No')
    exit()
    
if List[0][0]-List[0][1]==List[1][0]-List[1][1] and List[2][0]-List[2][1]==List[1][0]-List[1][1]:
    pass
else:
    print('No')
    exit()
if List[0][0]-List[0][2]==List[1][0]-List[1][2] and List[2][0]-List[2][2]==List[1][0]-List[1][2]:
    pass
else:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

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

for a1 in range(min(c[0])+1):
    b = [c[0][0] - a1, c[0][1] - a1, c[0][2] - a1]
    if c[1][0] - b[0] == c[1][1] - b[1] == c[1][2] - b[2]:
        if c[2][0] - b[0] == c[2][1] - b[1] == c[2][2] - b[2]:
            print("Yes")
            exit()
print("No")

Submission status: Accepted

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

a = [0, 0, 0]
b = [0, 0, 0]

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

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

    if check(c, a, b):
        print("Yes")
        exit()

print("No")

Submission status: Accepted

Solution code:
import numpy as np
C = np.array([[int(x) for x in input().split()] for _ in range(3)])
ans = 'Yes'
for i in range(2):
    if not(C[0,i+1]-C[0,i] == C[1,i+1]-C[1,i] == C[2,i+1]-C[2,i]):
        ans = 'No'
    if not(C[i+1,0]-C[i,0] == C[i+1,1]-C[i,1] == C[i+1,2]-C[i,2]):
        ans = 'No'
print(ans)

Submission status: Accepted

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

ans = True
for i in range(2):
    tmp = c[0][i + 1] - c[0][i]
    for j in range(2):
        if c[j + 1][i + 1] - c[j + 1][i] != tmp:
            ans = False
            break

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
c_1_1, c_1_2, c_1_3 = map(int, input().split())
c_2_1, c_2_2, c_2_3 = map(int, input().split())
c_3_1, c_3_2, c_3_3 = map(int, input().split())

ans = "No"
for a_1 in range(101):
  b_1 = c_1_1 - a_1
  b_2 = c_1_2 - a_1
  b_3 = c_1_3 - a_1
  for a_2 in range(101):
    if c_2_1 != a_2 + b_1:
      continue
    if c_2_2 != a_2 + b_2:
      continue
    if c_2_3 != a_2 + b_3:
      continue
    for a_3 in range(101):
      if c_3_1 != a_3 + b_1:
        continue
      if c_3_2 != a_3 + b_2:
        continue
      if c_3_3 != a_3 + b_3:
        continue
      ans = "Yes"
      break
    if ans == "Yes":
      break
  if ans == "Yes":
    break

print(ans)

Submission status: Accepted

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

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

ans=[[a1+b1,a1+b2,a1+b3],[a2+b1,a2+b2,a2+b3],[a3+b1,a3+b2,a3+b3]]

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

Submission status: Accepted

Solution code:
#18 C - Takahashi's Information
c = [list(map(int,input().split())) for _ in range(3)]

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 cnt == 3:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
def main():
    grid = [list(map(int, input().split())) for i in range(3)]
    all = sum(sum(grid, []))
    a = [0] * 3
    b = [0] * 3
    for i, j, k in itertools.product(range(grid[0][0] + 1), range(grid[1][1] + 1), range(grid[2][2] + 1)):
        a = [i, j, k]
        b = [grid[idx][idx] - v for idx, v in enumerate(a)]
        if (sum(a) * 3) + (sum(b) * 3) == all:
            print("Yes")
            exit()
    print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    grid = [list(map(int, input().split())) for i in range(3)]
    all = sum(sum(grid, []))
    a = [0] * 3
    b = [0] * 3
    for i1 in range(0, grid[0][0] + 1):
        a[0] = i1
        b[0] = grid[0][0] - i1
        for j2 in range(0, grid[1][1] + 1):
            a[1] = j2
            b[1] = grid[1][1] - j2
            for k3 in range(0, grid[2][2] + 1):
                a[2] = k3
                b[2] = grid[2][2] - k3
                if (sum(a) * 3) + (sum(b) * 3) == all:
                    print("Yes")
                    exit()
    print('No')





if __name__ == '__main__':
    main()

Submission status: Accepted

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

flag = True

for i in range(1, 3):
    if not(c[i][0] - c[0][0] == c[i][1] - c[0][1] == c[i][2] - c[0][2]):
        flag = False
    if not(c[0][i] - c[0][0] == c[1][i] - c[1][0] == c[2][i] - c[2][0]):
        flag = False

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

Submission status: Accepted

Solution code:
def is_valid(m, a, b):
    for i in range(3):
        for j in range(3):
            if (m[i][j] != a[i] + b[j]):
                return 0
    return 1


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

for a0 in range(101):
    b0 = m[0][0] - a0
    b1 = m[0][1] - a0
    b2 = m[0][2] - a0
    a1 = m[1][0] - b0
    a2 = m[2][0] - b0
    if (is_valid(m, [a0, a1, a2], [b0, b1, b2])):
        print("Yes")
        exit()
print("No")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
arr = []

for _ in range(3):
    arr += list(map(int, input().split()))

a = [0] * 3
b = [0] * 3
a[0] = 0
b[0] = arr[0]
b[1] = arr[1]
b[2] = arr[2]
a[1] = arr[4] - b[1]
a[2] = arr[8] - b[2]

tmp = [a[i] + b[j] for i in range(3) for j in range(3)]

print('Yes' if arr == tmp else 'No')

Submission status: Accepted

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

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]:
            ok = False
        
if ok:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

ok = True

lis = [[0,1],[1,2],[2,0]]

d = [[c[l[0]][i]-c[l[1]][i] for i in range(3)]for l in lis]
e = [[c[i][l[0]]-c[i][l[1]] for i in range(3)]for l in lis]

for i in range(3):
    if d[i].count(d[i][0])!=3:
        ok = False
    if e[i].count(e[i][0])!=3:
        ok = False
        
if ok:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def main():
    c_lst = [list(map(int, input().split())) for _ in range(3)]
    c1 = c_lst[0][0] + c_lst[1][1] + c_lst[2][2]
    c2 = c_lst[1][0] + c_lst[2][1] + c_lst[0][2]
    c3 = c_lst[2][0] + c_lst[0][1] + c_lst[1][2]
    
    if c1 == c2 and c2 == c3:
        print('Yes')
    else:
        print('No')
        

if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans="No"
for a1 in range(c11+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)

Submission status: Accepted

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

if c[2][1] - c[2][0] == c[0][1] - c[0][0] and c[0][2] - c[1][2] == c[0][0] - c[1][0] and c[1][2] - c[2][2] == c[1][0] - c[2][0] and c[0][2] - c[2][2] == c[0][0] - c[2][0] and c[1][1] - c[0][1] == c[1][0] - c[0][0]:
    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()))
c = [c1,c2,c3]
for a1 in range(100):
    b1 = c1[0] - a1
    b2 = c1[1] - a1
    b3 = c1[2] - a1
    a21 = c2[0] - b1
    a22 = c2[1] - b2
    a23 = c2[2] - b3
    a31 = c3[0] - b1
    a32 = c3[1] - b2
    a33 = c3[2] - b3
#     print('a1',a1)
#     print('a2',a21,a22,a23)
#     print('a3',a31,a32,a33)
#     print('b',b1,b2,b3)
    if (a21 == a22 == a23) and (a31 == a32 == a33):
        print('Yes')
        break
    elif a1 == 99:
        print('No')
        break
    else:
        continue

Submission status: Accepted

Solution code:
c = [list(map(int, input().split())) for _ in range(3)]
for i in [1, 2]:
  d1 = c[0][0] - c[i][0]
  d2 = c[0][1] - c[i][1]
  d3 = c[0][2] - c[i][2]
  d4 = c[0][0] - c[0][i]
  d5 = c[1][0] - c[1][i]
  d6 = c[2][0] - c[2][i]
  if d1 != d2 or d1 != d3 or d4 != d5 or d4 != d6:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

Solution code:

def main():
    c11, c12, c13 = map(int, input().split())
    c21, c22, c23 = map(int, input().split())
    c31, c32, c33 = map(int, input().split())
    
    for a1 in range(-200, 200):
        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:
            print('Yes')
            exit()
    print('No')
    
    




if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
grid = [[-1] * 4 for i in range(4)]
for i in range(1,4):
    grid[i][1],grid[i][2],grid[i][3] = map(int,input().split())
    grid[i][0] = min(grid[i][1],grid[i][2],grid[i][3])
#print('----------')
#for i in range(4):
#    print(grid[i])

isOK = False
for i in range(grid[1][0]+1):
    grid[0][0] = i
    grid[0][1] = grid[1][1]-i
    grid[0][2] = grid[1][2]-i
    grid[0][3] = grid[1][3]-i
#    print('----------')
#    for j in range(4):
#        print(grid[j])
    if grid[2][1]-grid[0][1] == grid[2][2]-grid[0][2] and grid[2][2]-grid[0][2] == grid[2][3]-grid[0][3]:
        if grid[3][1]-grid[0][1] == grid[3][2]-grid[0][2] and grid[3][2]-grid[0][2] == grid[3][3]-grid[0][3]:
            isOK = True
            break
if isOK:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    grid = []
    for _ in range(3):
        grid.append(LI())
    
    ans = True
    l1 = grid[0][1] - grid[0][0]
    l2 = grid[0][2] - grid[0][1]
    ans &= grid[1][1] - grid[1][0] == l1 and grid[1][2] - grid[1][1] == l2
    ans &= grid[2][1] - grid[2][0] == l1 and grid[2][2] - grid[2][1] == l2

    r1 = grid[1][0] - grid[0][0]
    r2 = grid[1][0] - grid[0][0]
    ans &= grid[1][1] - grid[0][1] == r1 and grid[1][1] - grid[0][1] == r2
    ans &= grid[1][2] - grid[0][2] == r1 and grid[1][2] - grid[0][2] == r2
    print("Yes" if ans else "No")
main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
c = [[0]*3]*3

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

ans = False

if c[0][0] - c[0][1] == c[1][0] - c[1][1] == c[2][0] - c[2][1] and\
    c[0][0] - c[0][2] == c[1][0] - c[1][2] == c[2][0] - c[2][2]:
    ans = True

if ans == True:
    print('Yes')
else: # ans == False:
    print('No')

Submission status: Accepted

Solution code:
a = [list(map(int, input().split())) for _ in range(3)]
if a[0][1] - a[0][0] == a[1][1] - a[1][0] == a[2][1] - a[2][0] and a[0][2] - a[0][0] == a[1][2] - a[1][0] == a[2][2] - a[2][0]:
    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()))

sw = 1
b1 = min(c1)
a = [c1[0]-b1, c1[1]-b1, c1[2]-b1]

if not(c2[0]-a[0] == c2[1]-a[1] == c2[2]-a[2]):
    sw = 0
if not(c3[0]-a[0] == c3[1]-a[1] == c3[2]-a[2]):
    sw = 0
    
print(["No","Yes"][sw])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A1 = 0
B1, B2, B3 = map(int, input().split())
C1, C2, C3 = map(int, input().split())
D1, D2, D3 = map(int, input().split())
flag = 0
if not( C2-B2 == C1-B1 and C3-B3 == C1-B1 and C2-B2 == C3-B3):
    flag = 1
if not( D2-B2 == D1-B1 and D3-B3 == D1-B1 and D2-B2 == D3-B3):
    flag = 1
print("Yes" if flag == 0 else "No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
c = list(map(int, input().split()))
x, y, z = c[0]-c[1], c[1]-c[2], c[2]-c[0]
flag = True
for i in range(2):
  c = list(map(int, input().split()))
  s, t, u = c[0]-c[1], c[1]-c[2], c[2]-c[0]
  if (x!=s) or (y!=t) or (z!=u):
    flag = False
    break
    
if flag:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

#Flag=0

#if C[0][0]-C[1][0]==C[0][1]-C[1][1] and 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] and C[1][1]-C[2][1]==C[1][2]-C[2][2]:
#    Flag=1
Flag=1
for ii in range(1,3):
    for jj in range(1,3):
        if C[ii-1][jj-1]-C[ii][jj-1]!=C[ii-1][jj]-C[ii][jj]:
            Flag=0
            break
    if Flag==0:
        break

if Flag==1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
c=[0]*3
c_max=0
for i in range(3):
    c[i]=list(map(int,input().split()))
    c_max=max(c_max,max(c[i]))
c_max+=1
for a1 in range(c_max):
    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 a1+b1==c[0][0] and a1+b2==c[0][1] and a1+b3==c[0][2] and a2+b1==c[1][0] and a2+b2==c[1][1] and a2+b3==c[1][2] and a3+b1==c[2][0] and a3+b2==c[2][1] and a3+b3==c[2][2]:
        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 c2[0]-c1[0]==c2[1]-c1[1] and c2[1]-c1[1]==c2[2]-c1[2] and c3[0]-c1[0]==c3[1]-c1[1] and c3[1]-c1[1]==c3[2]-c1[2] :
    print("Yes")
    exit()
print("No")

Submission status: Accepted

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

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