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



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

    if a1 < 0 or a2 < 0 or a3 < 0 or b1 < 0 or b2 < 0 or b3 < 0:
        flag = False

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

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  a=LI()
  b=LI()
  c=LI()

  for i in range(2):
    if not (a[i+1]-a[i]==b[i+1]-b[i] and b[i+1]-b[i]==c[i+1]-c[i]):
      return 'No'

  return 'Yes'

print(main())

Submission status: Accepted

Solution code:
from itertools import product

C1 = [int(x) for x in input().split()]
C2 = [int(x) for x in input().split()]
C3 = [int(x) for x in input().split()]
R1 = [c[0] for c in [C1,C2,C3]]
R2 = [c[1] for c in [C1,C2,C3]]
R3 = [c[2] for c in [C1,C2,C3]]

def check(C1, C2):
    r = 1 == len(set([C1[0] - C2[0], C1[1] - C2[1], C1[2] - C2[2]]))
    return r

if all(check(c1, c2) for c1, c2, in product([C1,C2,C3], [C1,C2,C3])) and \
        all(check(c1, c2) for c1, c2 in product([R1,R2,R3], [R1,R2,R3])):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
c = [list(map(int, input().split())) for i in range(3)]
a = [0]*3
b = [0]*3
b[0] = c[0][0]
b[1] = c[0][1]
b[2] = c[0][2]
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]:
            print("No")
            exit()
print("Yes")

Submission status: Accepted

Solution code:
numbertable = []
for i in range(0, 3):
	numbertable.append(list(map(int, input().split())))
flag = True
for i in range(0, 3):
	for j in range(0, 3):
		if numbertable[i][j] + numbertable[(i+1)%3][(j+1)%3] != numbertable[i][(j+1)%3] + numbertable[(i+1)%3][j]:
			flag = False
			break
	if not flag: break
if flag: print('Yes')
else: print('No')

Submission status: Accepted

Solution code:
import sys
a=[list(map(int,input().split())) for i in range(3)]
x1,x2=a[0][0]-a[0][1],a[0][0]-a[0][2]
for i in range(3):
    if a[i][0]-a[i][1]!=x1 or a[i][0]-a[i][2]!=x2: print("No"),sys.exit()

y1,y2=a[0][0]-a[1][0],a[0][0]-a[2][0]
for j in range(3):
    if a[0][j]-a[1][j]!=y1 or a[0][j]-a[2][j]!=y2: print("No"),sys.exit()

print("Yes")

Submission status: Accepted

Solution code:
a0,a1,a2=0,0,0
b0,b1,b2=0,0,0
matrix=[list(map(int,input().split())) for i in range(3)]
b0=matrix[0][0]-a0
b1=matrix[0][1]-a0
b2=matrix[0][2]-a0
a1=matrix[1][0]-b0
a2=matrix[2][0]-b0
flag=True
if matrix[1][1]==a1+b1 and matrix[1][2]==a1+b2 and matrix[2][1]==a2+b1 and matrix[2][2]==a2+b2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

cnd = True

cnd &= C[0][0] - C[0][1] == C[1][0] - C[1][1]
cnd &= C[0][0] - C[0][1] == C[2][0] - C[2][1]

cnd &= C[0][0] - C[0][2] == C[1][0] - C[1][2]
cnd &= C[0][0] - C[0][2] == C[2][0] - C[2][2]

cnd &= C[0][1] - C[0][2] == C[1][1] - C[1][2]
cnd &= C[0][1] - C[0][2] == C[2][1] - C[2][2]

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

Submission status: Accepted

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

f = c[0][0]
s = c[0][1] - f
t = c[0][2] - f

for i in c:
    i_f = i[0]

    if i[1] != i_f + s or i[2] != i_f + t:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
import numpy as np
c=np.array([list(map(int,input().split())) for i in range(3)])
f=True
for i in range(2):
     d=c[i,0]-c[i+1,0]
     for j in range(2):
          if c[i,j+1]-c[i+1,j+1]!=d:
               f=False
for i in range(2):
     d=c[0,i]-c[0,i+1]
     for j in range(2):
          if c[j+1,i]-c[j+1,i+1]!=d:
               f=False
print('Yes' if f else 'No')

Submission status: Accepted

Solution code:
c = [list(map(int, input().split())) for _ in range(3)]
m = 0
for col in c:
  for v in col:
    m = max(m, v)
for a1 in range(m + 1):
  b1 = c[0][0] - a1
  b2 = c[0][1] - a1
  b3 = c[0][2] - a1
  a2 = c[1][0] - b1
  a3 = c[2][0] - b1
  if a2 + b2 != c[1][1]:
    continue
  elif a2 + b3 != c[1][2]:
    continue
  elif a3 + b2 != c[2][1]:
    continue
  elif a3 + b3 != c[2][2]:
    continue
  else:
    print('Yes')
    break
else:
  print('No')

Submission status: Accepted

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

b2_1 = c[0][1] - c[0][0]
b3_1 = c[0][2] - c[0][0]

if any([b2_1 != c[x][1] - c[x][0] for x in [1, 2]]) or any([b3_1 != c[x][2] - c[x][0] for x in [1, 2]]):
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

for j in range(1, 3):
    a[j] = C[j][0] - b[0]
for j in range(3):
    for k in range(3):
        if C[j][k] != a[j] + b[k]:
            flg = False
            break
if flg:
    print('Yes')
    quit()
print('No')

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(101):
    a[0] = i
    flg = True
    for j in range(3):
        b[j] = C[0][j] - i
        if b[j] < 0:
            flg = False
            break
    if flg:
        for j in range(1, 3):
            a[j] = C[j][0] - b[0]
            if a[j] < 0:
                flg = False
                break
    if flg:
        for j in range(3):
            for k in range(3):
                if C[j][k] != a[j] + b[k]:
                    flg = False
                    break
        if flg:
            print('Yes')
            quit()
print('No')

Submission status: Accepted

Solution code:
# a1 = 0としてよい

A = [0,None,None]
B = [None,None,None]

bl = True
for i in range(3):
  C = [int(x) for x in input().split()]
  for j,c in enumerate(C):
    if A[i] is None:
      A[i] = c - B[j]
    if B[j] is None:
      B[j] = c - A[i]
    if A[i]+B[j] != c:
      bl = False

answer = 'Yes' if bl else 'No'
print(answer)

Submission status: Accepted

Solution code:
c=[list(map(int,input().split())) for i in range(3)]
a=[0]*3
b=[0]*3
a[0]=min(c[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][1]-b[1]
a[2]=c[2][2]-b[2]
for i in range(3):
    for j in range(3):
        if a[i]+b[j]!=c[i][j]:
            print("No")
            break
    else:continue
    break
else:print("Yes")

Submission status: Accepted

Solution code:
a1 , b1 , c1 = (int(i) for i in input().split())
a2 , b2 , c2 = (int(i) for i in input().split())
a3 , b3 , c3 = (int(i) for i in input().split())
am = min(a1,a2,a3)
bm = min(b1,b2,b3)
cm = min(c1,c2,c3)
a = [a1-am,a2-am,a3-am]
b = [b1-bm,b2-bm,b3-bm]
c = [c1-cm,c2-cm,c3-cm]
if a == b == c:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

total = 0
for i in range(3):
    for j in range(3):
        total += lst[i][j]

total = total//3

flag = True
for i in range(3):
    a = lst[0][i%3]+lst[1][(i+1)%3]+lst[2][(i+2)%3]
    if a != total:
        flag = False

a = lst[0][0] + lst[1][2] + lst[2][1]
if a != total:
    flag = False

a = lst[1][1] + lst[0][2] + lst[2][0]
if a != total:
    flag = False

a = lst[2][2] + lst[1][0] + lst[0][1]
if a != total:
    flag = False

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

Submission status: Accepted

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

for a1 in range(101):
    b1 = c[0][0] - a1
    b2 = c[0][1] - a1
    b3 = c[0][2] - a1
    a2_1 = c[1][0] - b1
    a2_2 = c[1][1] - b2
    a2_3 = c[1][2] - b3
    a3_1 = c[2][0] - b1
    a3_2 = c[2][1] - b2
    a3_3 = c[2][2] - b3
    if (a2_1 == a2_2 == a2_3) and (a3_1 == a3_2 == a3_3):
        print('Yes')
        exit()

print('No')

Submission status: Accepted

Solution code:
C = [list(map(int,input().split())) for i in range(3)]
cii_sum = sum([C[i][i] for i in range(3)])
C_sum = sum(list(map(sum,C)))
print("Yes" if cii_sum==(C_sum/3) else "No")

Submission status: Accepted

Solution code:
import numpy as np

c = np.array([list(map(int, input().split())) for _ in range(3)])
diff = np.diff(c, n=1)
for n in range(1, diff.shape[0]):
    if not all(diff[n] == diff[0]):
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

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

if all(c[i][0]-c[0][0]==c[i][1]-c[0][1] and c[i][1]-c[0][1]==c[i][2]-c[0][2] for i in [1,2]):
    print('Yes')
else:
    print('No')

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]]"):
    if (c[0][1] - c[0][0] == c[1][1] - c[1][0] and
        c[0][1] - c[0][0] == c[2][1] - c[2][0] and
        c[0][2] - c[0][1] == c[1][2] - c[1][1] and
        c[0][2] - c[0][1] == c[2][2] - c[2][1] and
        c[1][0] - c[0][0] == c[1][1] - c[0][1] and
        c[2][0] - c[1][0] == c[2][1] - c[1][1]):
        ret = YES
    else:
        ret = NO
    print(ret)
    return


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]]"
    solve(c)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
c = [list(map(int,input().split())) for _ in range(3) ]
for a1 in range(101):
    b1 = c[0][0] - a1
    b2 = c[0][1] - a1
    b3 = c[0][2] - a1
    a2 = c[1][0] - b1
    a3 = c[2][0] - b1
    if 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")
        break
else:
    print("No")

Submission status: Accepted

Solution code:
c=[]
for i in range(3):
    ci=list(map(int,input().split()))
    c.append(ci)
for i in range(101):
    a1=i
    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
    a=[a1,a2,a3]
    b=[b1,b2,b3]
    T=True
    for j in range(3):
        for k in range(3):
            if c[j][k]!=a[j]+b[k]:
                T=False
                break
    if T:
        print("Yes")
        quit()
print("No")

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

import sys

input = sys.stdin.readline

def main():
    G = [[0 for _ in range(3)] for _ in range(3)]
    for i in range(3):
        G[i] = [int(e) for e in input().split()]

    for a0 in range(0, 100+1):
        b0 = G[0][0] - a0
        b1 = G[0][1] - a0
        b2 = G[0][2] - a0

        a1 = G[1][0] - b0
        a2 = G[2][0] - b0

        if a0 + b0 == G[0][0] and \
           a0 + b1 == G[0][1] and \
           a0 + b2 == G[0][2] and \
           a1 + b0 == G[1][0] and \
           a1 + b1 == G[1][1] and \
           a1 + b2 == G[1][2] and \
           a2 + b0 == G[2][0] and \
           a2 + b1 == G[2][1] and \
           a2 + b2 == G[2][2]:
               print("Yes")
               return
    print("No")


main()

Submission status: Accepted

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

a = [0 for _ in range(3)]
b = [0 for _ in range(3)]

A = [sum(c) for c in C]
B = [C[0][i] + C[1][i] + C[2][i] for i in range(3)]

is_correct = True
for i in range(3):
    for j in range(i, 3):
        if abs(A[i] - A[j]) % 3 != 0:
            is_correct = False
        if abs(B[i] - B[j]) % 3 != 0:
            is_correct = False

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

Submission status: Accepted

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

Submission status: Accepted

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

x = [list() for _ in range(2)]
y = [list() for _ in range(2)]
for i in range(3):
  for j in range(2):
    x[j].append(C[i][j] - C[i][j+1])
    y[j].append(C[j][i] - C[j+1][i])

out = False
for j in range(2):
  if min(x[j]) != max(x[j]):
    break
  if min(y[j]) != max(y[j]):
    break
else:
  print("Yes")
  out = True
if not out:
  print("No")

Submission status: Accepted

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


if (grid[0][0] - grid[1][0]) == (grid[0][1] - grid[1][1]) == (grid[0][2] - grid[1][2]) and (grid[0][0]-grid[0][1]) == (grid[1][0]-grid[1][1]) == (grid[2][0] - grid[2][1]) and(grid[0][0] - grid[2][0]) == (grid[0][1] - grid[2][1]) == (grid[0][2] - grid[2][2]) and  (grid[0][0]-grid[0][2]) == (grid[1][0]-grid[1][2]) == (grid[2][0] - grid[2][2]):

    print('Yes')

else:
    print('No')

Submission status: Accepted

Solution code:
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


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


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


class UnionFind:

    def __init__(self, n):
        self.parent = [i for i in range(n)]

    def root(self, i):
        if self.parent[i] == i:
            return i
        self.parent[i] = self.root(self.parent[i])
        return self.parent[i]

    def unite(self, i, j):
        rooti = self.root(i)
        rootj = self.root(j)
        if rooti == rootj:
            return
        if rooti < rootj:
            self.parent[rootj] = rooti
        else:
            self.parent[rooti] = rootj

    def same(self, i, j):
        return self.root(i) == self.root(j)


###############################################################################


def main():
    c = [intina() for _ in range(3)]

    if c[0][0] - c[0][1] != c[1][0] - c[1][1]:
        print('No')
        return

    if c[0][0] - c[0][1] != c[2][0] - c[2][1]:
        print('No')
        return

    if c[0][0] - c[0][2] != c[1][0] - c[1][2]:
        print('No')
        return

    if c[0][0] - c[0][2] != c[2][0] - c[2][2]:
        print('No')
        return

    if c[0][0] - c[1][0] != c[0][1] - c[1][1]:
        print('No')
        return

    if c[0][0] - c[1][0] != c[0][2] - c[1][2]:
        print('No')
        return

    if c[0][0] - c[2][0] != c[0][1] - c[2][1]:
        print('No')
        return

    if c[0][0] - c[2][0] != c[0][2] - c[2][2]:
        print('No')
        return

    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i in range(3):
    a2.append(C[0][i]-C[1][i])
    a3.append(C[0][i]-C[2][i])
if len(set(a2))==1 and len(set(a3))==1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
l=[list(map(int,input().split())) for _ in range(3)]
for i in range(2):
	if len(set([l[i+1][j]-l[i][j] for j in range(3)]))!=1 or len(set([l[j][i+1]-l[j][i] for j in range(3)]))!=1:
		print('No')
		break
else:print('Yes')

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

Submission status: Accepted

Solution code:
c=[list(map(int,input().split()))for _ in range(3)]
for i in range(c[0][0]+1):
    b=[c[0][0]-i,c[0][1]-i,c[0][2]-i]
    a=[i,c[1][0]-b[0],c[2][0]-b[0]]
    t=1
    for j in range(3):
        for k in range(3):
            if c[j][k]!=a[j]+b[k]:
                t=0
                break
    if t:
        print('Yes')
        exit()
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[0][0]-c[2][0])==(c[0][1]-c[2][1])==(c[0][2]-c[2][2]) and\
    (c[0][0]-c[0][1])==(c[1][0]-c[1][1])==(c[2][0]-c[2][1]) and\
    (c[0][0]-c[0][2])==(c[1][0]-c[1][2])==(c[2][0]-c[2][2]):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
lst = []
for i in range(3):
	a = list(map(int,input().split()))
	lst.append(a)
#print(lst)
F = False

for i in range(100):
	b1 = lst[0][0] - i
	b2 = lst[0][1] - i
	b3 = lst[0][2] - i
	if lst[1][0] - b1 == lst[1][1] - b2 and +\
	lst[1][1] - b2 == lst[1][2] - b3 and +\
	lst[2][0] - b1 == lst[2][1] - b2 and +\
	lst[2][1] - b2 == lst[2][2] - b3:
		F = True

if F == False:
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:


def main():
    a = list(map(int, input().split()))
    a1, a2 = a[1] - a[0], a[2] - a[1]

    b = list(map(int, input().split()))
    b1, b2 = b[1] - b[0], b[2] - b[1]

    c = list(map(int, input().split()))
    c1, c2 = c[1] - c[0], c[2] - c[1]

    if a1 == b1 == c1 and a2 == b2 == c2:
        print('Yes')
    else:
        print('No')



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np

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

col_0 = [A[0][1]-A[0][0], A[0][2]-A[0][0]]
col_1 = [A[1][1]-A[1][0], A[1][2]-A[1][0]]
col_2 = [A[2][1]-A[2][0], A[2][2]-A[2][0]]

bool = (col_0 == col_1) and (col_0 == col_2)

if bool == True:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
import numpy as np

C = np.zeros((3, 3))
for i in range(3):
    C[i, 0], C[i, 1], C[i, 2] = [int(_) for _ in input().split()]

for i in range(3):
    for j in range(2):
        if not(C[i, 0] - C[j, 0] == C[i, 1] - C[j, 1] == C[i, 2] - C[j, 2])\
                or not\
                (C[0, i] - C[0, j] == C[1, i] - C[1, j] == C[2, i] - C[2, j]):
            print('No')
            quit()
print('Yes')

Submission status: Accepted

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


Hs = [[] for _ in range(H)]
for i in range(H):
    Hs[i].append(C[i][0] - C[i][1])
    Hs[i].append(C[i][1] - C[i][2])
    Hs[i].append(C[i][2] - C[i][0])

Ws = [[] for _ in range(H)]
for i in range(H):
    Ws[i].append(C[0][i] - C[1][i])
    Ws[i].append(C[1][i] - C[2][i])
    Ws[i].append(C[2][i] - C[0][i])

if all([Hs[0] == h for h in Hs]) and all([Ws[0] == w for w in Ws]):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
c = [list(map(int, input().split())) for i in range(3)]
x = [0 for i in range(len(c))]
for i, line in enumerate(c):
    for j in range(len(c)):
            x[j] += line[(i+j) % len(c)]
print('Yes' if all(x[i] == x[0] for i in range(len(c))) else 'No')

Submission status: Accepted

Solution code:
lis1 = []
lis2 = []
lis3 = []
count = 0
flag = 0
for num in input().split():
    lis1.append(int(num))
for num in input().split():
    lis2.append(int(num))
for num in input().split():
    lis3.append(int(num))
for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            if lis1[0] - a1 == lis2[0] - a2 == lis3[0] - a3:
        	    if lis1[1] - a1 == lis2[1] - a2 == lis3[1] - a3:
		            if lis1[2] - a1 == lis2[2] - a2 == lis3[2] - a3:
             	 		print("Yes")
             	 		flag = 1
             	 		break
        if flag == 1:
            break
    if flag == 1:
        break
    if a1 == 100 and flag == 0:
      	print("No")

Submission status: Accepted

Solution code:
lis1 = []
lis2 = []
lis3 = []
count = 0
for num in input().split():
    lis1.append(int(num))
for num in input().split():
    lis2.append(int(num))
for num in input().split():
    lis3.append(int(num))
for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            count = 0
            if lis1[0] - a1 == lis2[0] - a2 == lis3[0] - a3:
                count += 1
            if lis1[1] - a1 == lis2[1] - a2 == lis3[1] - a3:
                count += 1
            if lis1[2] - a1 == lis2[2] - a2 == lis3[2] - a3:
                count += 1
            if count == 3:
                print("Yes")
                break
        if count == 3:
          	break
    if count == 3:
      break
    if a1 == 100 and count != 3:
      	print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python
import string
import sys
from itertools import chain, dropwhile, takewhile


def read(
    *shape, f=int, it=chain.from_iterable(sys.stdin), whitespaces=set(string.whitespace)
):
    def read_word():
        w = lambda c: c in whitespaces
        nw = lambda c: c not in whitespaces
        return f("".join(takewhile(nw, dropwhile(w, it))))

    if not shape:
        return read_word()
    elif len(shape) == 1:
        return [read_word() for _ in range(shape[0])]
    elif len(shape) == 2:
        return [[read_word() for _ in range(shape[1])] for _ in range(shape[0])]


def readi(*shape):
    return read(*shape)


def readi1(*shape):
    return [i - 1 for i in read(*shape)]


def readf(*shape):
    return read(*shape, f=float)


def reads(*shape):
    return read(*shape, f=str)


def arr(*shape, fill_value=0):
    if len(shape) == 1:
        return [fill_value] * shape[fill_value]
    elif len(shape) == 2:
        return [[fill_value] * shape[1] for _ in range(shape[0])]


def dbg(**kwargs):
    print(
        ", ".join("{} = {}".format(k, repr(v)) for k, v in kwargs.items()),
        file=sys.stderr,
    )


def main():
    c = readi(3, 3)
    d = list(zip(*c))
    print(
        "Yes"
        if all(
            len(set(i - j for i, j in zip(e[n], e[m]))) == 1
            for e in [c, d]
            for n in range(3)
            for m in range(n)
        )
        else "No"
    )


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
list1 = [int(s) for s in input().split()]
list2 = [int(s) for s in input().split()]
list3 = [int(s) for s in input().split()]
flag = 0
for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            if (list1[0] - a1) == (list2[0] - a2) == (list3[0] - a3):
                if (list1[1] - a1) == (list2[1] - a2) == (list3[1] - a3):
                    if (list1[2] - a1) == (list2[2] - a2) == (list3[2] - a3):
                        print('Yes')
                        flag = 1
        if flag == 1:
            break
if flag == 0:
    print('No')

Submission status: Accepted

Solution code:
#!/usr/bin/env python
import string
import sys
from itertools import chain, dropwhile, takewhile


def read(
    *shape, f=int, it=chain.from_iterable(sys.stdin), whitespaces=set(string.whitespace)
):
    def read_word():
        w = lambda c: c in whitespaces
        nw = lambda c: c not in whitespaces
        return f("".join(takewhile(nw, dropwhile(w, it))))

    if not shape:
        return read_word()
    elif len(shape) == 1:
        return [read_word() for _ in range(shape[0])]
    elif len(shape) == 2:
        return [[read_word() for _ in range(shape[1])] for _ in range(shape[0])]


def readi(*shape):
    return read(*shape)


def readi1(*shape):
    return [i - 1 for i in read(*shape)]


def readf(*shape):
    return read(*shape, f=float)


def reads(*shape):
    return read(*shape, f=str)


def arr(*shape, fill_value=0):
    if len(shape) == 1:
        return [fill_value] * shape[fill_value]
    elif len(shape) == 2:
        return [[fill_value] * shape[1] for _ in range(shape[0])]


def dbg(**kwargs):
    print(
        ", ".join("{} = {}".format(k, repr(v)) for k, v in kwargs.items()),
        file=sys.stderr,
    )


def main():
    c = readi(3, 3)
    d = list(zip(*c))
    print(
        "Yes"
        if all(
            len(set(i - j for i, j in zip(c[n], c[m]))) == 1
            for n in range(3)
            for m in range(n)
        )
        and all(
            len(set(i - j for i, j in zip(d[n], d[m]))) == 1
            for n in range(3)
            for m in range(n)
        )
        else "No"
    )


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
lis1 = []
lis2 = []
lis3 = []
count = 0
for num in input().split():
    lis1.append(int(num))
for num in input().split():
    lis2.append(int(num))
for num in input().split():
    lis3.append(int(num))
if lis1[0]-lis2[0]==lis1[1]-lis2[1]==lis1[2]-lis2[2]:
    count += 1
if lis1[0]-lis3[0]==lis1[1]-lis3[1]==lis1[2]-lis3[2]:
    count += 1
if lis1[0]-lis1[1]==lis2[0]-lis2[1]==lis3[0]-lis3[1]:
    count += 1
if lis1[0]-lis1[2]==lis2[0]-lis2[2]==lis3[0]-lis3[2]:
    count += 1
if count == 4:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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]):
        print("No")
        exit()
    if not(c[i+1][0] - c[i][0] == c[i+1][1] - c[i][1] == c[i+1][2] - c[i][2]):
        print("No")
        exit()

print("Yes")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#ABC088-C
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
C=[IL() for i 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]
flag=True
for i in range(3):
    for j in range(3):
        if A[i]+B[j]!=C[i][j]:
            flag=False
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

AB = [0 for i in range(6)]
AB[3] = C[0][0] - 0
AB[1] = C[1][0] - AB[3]
AB[2] = C[2][0] - AB[3]
AB[4] = C[0][1] - 0
AB[5] = C[0][2] - 0
if C[1][1] != AB[1] + AB[4]:
    print('No')
    quit()
if C[1][2] != AB[1] + AB[5]:
    print('No')
    quit()
if C[2][1] != AB[2] + AB[4]:
    print('No')
    quit()
if C[2][2] != AB[2] + AB[5]:
    print('No')
    quit()

print('Yes')

Submission status: Accepted

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


def solve():
    for i in range(max(grid[0]) + 1):
        b1 = grid[0][0] - i
        b2 = grid[0][1] - i
        b3 = grid[0][2] - i
        if not b1 < 0 and not b2 < 0 and not b3 < 0:
            if grid[1][0] - b1 == grid[1][1] - b2 == grid[1][2] - b3:
                if grid[2][0] - b1 == grid[2][1] - b2 == grid[2][2] - b3:
                    print("Yes")
                    return 0
    print("No")
    return 0


if __name__ == "__main__":
    solve()