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:
def main(*args, **kwargs):
    """Write Codes for contest here."""
    grid = []
    for i in range(3):
        grid.append(list(map(int, input().split())))

    #for b_sum in range(1, 301):
    #    a1 = Fraction(Fraction(sum(grid[0]), b_sum), 3)
    #    a2 = Fraction(Fraction(sum(grid[1]), b_sum), 3)
    #    a3 = Fraction(Fraction(sum(grid[2]), b_sum), 3)
    #    if is_integer(a1) and is_integer(a2) and is_integer(a3) and 0 <= a1 <= 100 and 0 <= a2 <= 100 and 0 <= a3 <= 100:
    #        print('Yes')

    for a1 in range(0, 101):
        b1_1 = grid[0][0] - a1
        b2_1 = grid[0][1] - a1
        b3_1 = grid[0][2] - a1
        for a2 in range(0, 101):
            b1_2 = grid[1][0] - a2
            b2_2 = grid[1][1] - a2
            b3_2 = grid[1][2] - a2
            for a3 in range(0, 101):
                b1_3 = grid[2][0] - a3
                b2_3 = grid[2][1] - a3
                b3_3 = grid[2][2] - a3

                # Check the condition
                if b1_1 == b1_2 == b1_3 and b2_1 == b2_2 == b2_3 and b3_1 == b3_2 == b3_3:
                    print('Yes')
                    return
    print('No')
    return
main()

Submission status: Accepted

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


def diff(arr):
    return tuple([pre_x - x for pre_x, x in zip(arr[:-1], arr[1:])])


diffs = [diff(row) for row in c]

if diffs[0] == diffs[1] == diffs[2]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

for a1 in range(100 + 1):
    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')
        break
else:
    print('No')

Submission status: Accepted

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

ans = "No"

for a1 in range(0, 101):
    for a2 in range(0, 101):
        for a3 in range(0, 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")
                quit()

print(ans)

Submission status: Accepted

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

def solve():
    if not (s[0][1] - s[0][0] == s[1][1] - s[1][0] == s[2][1] - s[2][0]): return False
    if not (s[0][2] - s[0][1] == s[1][2] - s[1][1] == s[2][2] - s[2][1]): return False
    if not (s[1][0] - s[0][0] == s[1][1] - s[0][1] == s[1][2] - s[0][2]): return False
    if not (s[2][0] - s[1][0] == s[2][1] - s[1][1] == s[2][2] - s[1][2]): return False
    return True

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

Submission status: Accepted

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

cmax = 0
for i in c:
  for j in i:
    cmax = max(cmax,j)

ck = 0
for i in range(-cmax,cmax+1):
  a = [0,0,0]
  b = [0,0,0]

  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]
  if c[1][1] - b[1] != a[1] or c[1][2] - b[2] != a[1]:
    continue

  a[2] = c[2][0] - b[0]
  if a[2] != c[2][1] - b[1] or a[2] != c[2][2] - b[2]:
    continue

  ck = 1
  break

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

Submission status: Accepted

Solution code:
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1

c1 = readInts()
c2 = readInts()
c3 = readInts()

for a1 in range(-100,101):
	b1 = c1[0]-a1
	b2 = c1[1]-a1
	b3 = c1[2]-a1
	a2 = c2[0]-b1
	a3 = c3[0]-b1
	if c2[1]==a2+b2 and c2[2]==a2+b3 and c3[1]==a3+b2 and c3[2]==a3+b3:
		print("Yes")
		exit()

print("No")

Submission status: Accepted

Solution code:
c = [list(map(int, input().split())) for _ in range(3)]
    
b1b2 = c[0][0]-c[1][0] == c[0][1]-c[1][1] == c[0][2]-c[1][2]
b1b3 = c[0][0]-c[2][0] == c[0][1]-c[2][1] == c[0][2]-c[2][2]
b2b3 = c[1][0]-c[2][0] == c[1][1]-c[2][1] == c[1][2]-c[2][2]

if b1b2 and b1b3 and b2b3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# coding: utf-8
import re
import math
from collections import defaultdict
from collections import deque
import itertools
from copy import deepcopy
import random
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
#@lru_cache(maxsize=None)
readline=sys.stdin.readline
sys.setrecursionlimit(2000000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_pow(a,b):#aはbの累乗数か
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def get_primes(n,type="int"):
    if n==0:
        if type=="int":return []
        else:return [False]
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=""):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)
    return ret
def seifu(x):
    return x//abs(x)
######################################################################################################
def main():
    C=[list(map(int,input().split())) for a in range(3)]
    A=[0]*3
    B=[C[0][0],C[0][1],C[0][2]]*3
    for a in range(1,3):
        A[a]=C[a][0]-B[0]
    f=True
    for a in range(3):
        for b in range(3):
            if A[a]+B[b]!=C[a][b]:
                f=False
    Yn(f)

main()

Submission status: Accepted

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

c1 = L[0][2] + L[1][1] + L[2][0]
c2 = L[0][1] + L[1][0] + L[2][2]
c3 = L[0][0] + L[1][2] + L[2][1]

if (c1 == c2 and c2 == c3):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
c = [list(map(int, input().split())),
     list(map(int, input().split())),
     list(map(int, input().split()))]

if (sum(c[0]) + sum(c[1]) + sum(c[2])) % 3 != 0:
    print('No')
    exit()

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

Submission status: Accepted

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

answer = "No"
for a1 in range(101):
    b1 = numbers[0][0] - a1
    b2 = numbers[1][0] - a1
    b3 = numbers[2][0] - a1
    a2 = numbers[0][1] - b1
    a3 = numbers[0][2] - b1
    if a2 + b2 == numbers[1][1] and a3 + b2 == numbers[1][2] and a2 + b3 == numbers[2][1] and a3 + b3 == numbers[2][2] and a1 >= 0 and a2 >= 0 and a3 >= 0 and b1 >= 0 and b2 >= 0 and b3 >= 0:
        answer = "Yes"

print(answer)

Submission status: Accepted

Solution code:
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
from operator import itemgetter
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
c = [None]*3
for i in range(3):
    c[i] = [None]*3
for i in range(3):
    c[i] = readints()
# print(c)
# a1=0,a2=1,a3=0,b1=1,b2=0,b3=1
#a = [0, 1, 0]
#b = [1, 0, 1]


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


a = [None]*3
b = [None]*3

for i in range(101):
    for j in range(101):
        for k in range(101):
            for l in range(3):
                a[0] = i
                a[1] = j
                a[2] = k
                b[0] = c[l][0]-a[l]
                b[1] = c[l][1]-a[l]
                b[2] = c[l][2]-a[l]
                if func(a, b):
                    print('Yes')
                    exit()
print('No')

Submission status: Accepted

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

d1 = C[0][0] + C[1][1] + C[2][2]
d2 = C[1][0] + C[2][1] + C[0][2]
d3 = C[2][0] + C[0][1] + C[1][2]
if d1 == d2 == d3:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def resolve():
	g = [list(map(int, input().split())) for _ in range(3)]
	m = max(map(max, g))
	for a in range(m+1):
		for b in range(m+1):
			for c in range(m+1):
				y = [a, b, c]
				x = [g[i][i] - y[i] for i in range(3)]
				ans = True
				for i in range(3):
					for j in range(3):
						v = y[i] + x[j]
						if g[i][j] != v:
							ans = False
				if ans:
					print('Yes')
					return

	print('No')
resolve()

Submission status: Accepted

Solution code:
s = []
judge = True

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

for i in range(3):
    for j in range(3):
        for k in range(3):
            for l in range(3):
                if i != k and k != l:
                    a = s[i][j] + s[k][l]
                    b = s[i][l] + s[k][j]
                    if a != b:
                        judge = False
                        break

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

Submission status: Accepted

Solution code:
import itertools
import sys
import numpy as np
import collections

c1=list(map(int, input().split()))
c2=list(map(int, input().split()))
c3=list(map(int, input().split()))

ans=[]
cr1,cr2,cr3 = zip(c1,c2,c3)
for c in [c1,c2,c3]:
    for i,cr in enumerate([cr1,cr2,cr3]):
        a=sum(c)+sum(cr)-c[i]*3
        ans.append(a)
print('Yes' if len(set(ans))==1 else 'No')

Submission status: Accepted

Solution code:
import numpy as np

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

A = np.array([
    [1, 0, 0, 1, 0, 0],
    [1, 0, 0, 0, 1, 0],
    [1, 0, 0, 0, 0, 1],
    [0, 1, 0, 1, 0, 0],
    [0, 1, 0, 0, 1, 0],
    [0, 1, 0, 0, 0, 1],
    [0, 0, 1, 1, 0, 0],
    [0, 0, 1, 0, 1, 0],
    [0, 0, 1, 0, 0, 1]])

B = np.array([
    [1, 0, 0, 1, 0, 0, c[0][0]],
    [1, 0, 0, 0, 1, 0, c[0][1]],
    [1, 0, 0, 0, 0, 1, c[0][2]],
    [0, 1, 0, 1, 0, 0, c[1][0]],
    [0, 1, 0, 0, 1, 0, c[1][1]],
    [0, 1, 0, 0, 0, 1, c[1][2]],
    [0, 0, 1, 1, 0, 0, c[2][0]],
    [0, 0, 1, 0, 1, 0, c[2][1]],
    [0, 0, 1, 0, 0, 1, c[2][2]]])

rankA = np.linalg.matrix_rank(A)
rankB = np.linalg.matrix_rank(B)

if rankA == rankB:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
C = []
for i in range(3):
    C.append(list(map(int, input().split())))
for i in range(1,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 [[i+b1,i+b2,i+b3],[a2+b1,a2+b2,a2+b3],[a3+b1,a3+b2,a3+b3]] == C:
        print("Yes")
        exit()
print("No")

Submission status: Accepted

Solution code:
l = []

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

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

Submission status: Accepted

Solution code:
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = list(map(int, input().split()))

a = (sum(x) + sum(y) + sum(z)) / 3
b = x[0] + y[1] + z[2]
c = x[1] + y[2] + z[0]
d = x[2] + y[0] + z[1]

if a == b == c == d:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
d = [None]*3
for i in range(3):
  c = list(map(int, input().split()))
  d[i] = [c[i] - c[i+1] for i in range(2)]
print('Yes' if all(d[i] == d[i+1] for i in range(2)) 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())

N = 101

for i in range(N):
    a1 = i

    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')
else:
    print('No')

Submission status: Accepted

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


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

for i in range(1,3):
    if a1!=(input_map[i][0]-input_map[i][1]):print('No');exit()
    if a2!=(input_map[i][0]-input_map[i][2]):print('No');exit()
    if a3!=(input_map[i][1]-input_map[i][2]):print('No');exit()

for i in range(1,3):
    if b1!=(input_map[0][i]-input_map[1][i]):print('No');exit()
    if b2!=(input_map[0][i]-input_map[2][i]):print('No');exit()
    if b3!=(input_map[1][i]-input_map[2][i]):print('No');exit() 

print('Yes')

Submission status: Accepted

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

a=t[1][0]-t[0][0]
b=t[2][0]-t[1][0]
c=t[0][1]-t[0][0]
d=t[0][2]-t[0][1]

flag=0

if t[1][1]-t[0][1]!=a or t[1][2]-t[0][2]!=a:
    flag=1
elif t[2][1]-t[1][1]!=b or t[2][2]-t[1][2]!=b:
    flag=1
elif t[1][1]-t[1][0]!=c or t[2][1]-t[2][0]!=c:
    flag=1
elif t[1][2]-t[1][1]!=d or t[2][2]-t[2][1]!=d:
    flag=1

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

Submission status: Accepted

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

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

a_ = [a1,a2,a3]
b_ = [b1,b2,b3]

flag = True
for i in range(3):
    for j in range(3):
        if c_[i][j] != a_[i] + b_[j]:
            flag = False

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

Submission status: Accepted

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

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

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]

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

Submission status: Accepted

Solution code:

r = [None] * 3
for i in range(3):
    x = list(map(int, input().split()))
    r[i] = [x[i] - x[i+1] for i in range(2)]

print('Yes' if all(r[i] == r[i+1] for i in range(2)) else 'No')

Submission status: Accepted

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

for i in range(2):
    c = list(map(int, input().split()))
    d = [c[i] - c[i+1] for i in range(2)]
    if b != d:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
F = [None] * 3

a = list(map(int, input().split()))
b = [a[i] - a[i+1] for i in range(2)]

for i in range(2):
    c = list(map(int, input().split()))
    d = [c[i] - c[i+1] for i in range(2)]
    if b != d:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
F = [None] * 3

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

for a1 in range(F[0][0]+1):
    b1 = F[0][0] - a1

    b2 = F[0][1] - a1
    b3 = F[0][2] - a1

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

    for i, a in enumerate([a1, a2, a3]):
        for j, b in enumerate([b1, b2, b3]):
            if F[i][j] != a + b:
                break
        else:
            continue
        break
    else:
        print('Yes')
        break
else:
    print('No')

Submission status: Accepted

Solution code:
def main():
    c = [list(map(int, input().split())) for _ in range(3)]
    f = [[x[0] - x[1], x[1] - x[2], x[2] - x[0]] for x in c]
    g = f[0] == f[1] == f[2]
    print('Yes' if g else '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())

ok = False
for i in range(101):
    for j in range(101):
        a1 = i
        a2 = c21 - c11 + a1
        a3 = c31 - c11 + a1
        b1 = j
        b2 = c12 - c11 + b1
        b3 = c13 - c11 + b1
        if((c11==a1+b1)and(c12==a1+b2)and(c13==a1+b3)and(c21==a2+b1)and(c22==a2+b2)and(c23==a2+b3)and(c31==a3+b1)and(c32==a3+b2)and(c33==a3+b3)):
            ok = True
            break
    if(ok):
        break
if ok:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    c_arr = []
    for i in range(3):
        _ = list(map(int,_in[i].split(' ')))
        c_arr.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    sum_c_arr = sum([sum(c) for c in c_arr])
    if (c_arr[0][0]+c_arr[1][1]+c_arr[2][2]) == sum_c_arr/3 and \
       (c_arr[1][0]+c_arr[2][1]+c_arr[0][2]) == sum_c_arr/3 and \
       (c_arr[0][1]+c_arr[1][2]+c_arr[2][0]) == sum_c_arr/3 and \
       (c_arr[2][0]+c_arr[1][1]+c_arr[0][2]) == sum_c_arr/3 and \
       (c_arr[1][0]+c_arr[0][1]+c_arr[2][2]) == sum_c_arr/3 and \
       (c_arr[0][0]+c_arr[2][1]+c_arr[1][2]) == sum_c_arr/3:
        TF = 'Yes'
    else:
        TF = 'No'
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(TF)

Submission status: Accepted

Solution code:
row1 = list(map(int, input().split()))
row2 = list(map(int, input().split()))
row3 = list(map(int, input().split()))

if (row1[1] - row1[0] != row2[1] - row2[0] or row1[1] - row1[0] != row3[1] - row3[0] or
    row1[2] - row1[1] != row2[2] - row2[1] or row1[2] - row1[1] != row3[2] - row3[1]):
    print('No')
elif (row1[0] - row2[0] != row1[1] - row2[1] or row1[0] - row2[0] != row1[2] - row2[2] or
      row1[0] - row3[0] != row1[1] - row3[1] or row1[0] - row3[0] != row1[2] - row3[2]):
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    c=[]
    s=0
    for i in range(3):
        li=list(map(int,readline().split()))
        s+=sum(li)
        c.append(li)

    if s%3!=0:
        print("No")
    else:
        if c[0][0]+c[1][1]+c[2][2]==s//3:
            print("Yes")
        else:
            print("No")

if __name__=="__main__":
    main()

Submission status: Accepted

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

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

# print('A, B', A, B)

if (A[0] - A[1]) % 3 == 0 and (A[1] - A[2]) % 3 == 0 and (A[2] -
                                                          A[0]) % 3 == 0:
    if (B[0] - B[1]) % 3 == 0 and (B[1] - B[2]) % 3 == 0 and (B[2] -
                                                              B[0]) % 3 == 0:
        print('Yes')
        exit()
print('No')

Submission status: Accepted

Solution code:
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    c_arr = []
    for i in range(3):
        _ = list(map(int,_in[i].split(' ')))
        c_arr.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    sum_c_arr = sum([sum(c) for c in c_arr])
    if (c_arr[0][0]+c_arr[1][1]+c_arr[2][2]) == sum_c_arr/3 and \
       (c_arr[1][0]+c_arr[2][1]+c_arr[0][2]) == sum_c_arr/3 and \
       (c_arr[0][1]+c_arr[1][2]+c_arr[2][0]) == sum_c_arr/3:
        TF = 'Yes'
    else:
        TF = 'No'
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(TF)

Submission status: Accepted

Solution code:
c =[]
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:
C = [[int(c) for c in input().split()] for i in range(3)]

for i in range(3):
    p = min(C[i])
    for j in range(3):
        C[i][j] -= p

ans = True
for i in range(3):
    if(C[i][0]==C[i][1]==C[i][2]):
        continue
    else:
        ans = False
if(not ans):
    ans = True
    for i in range(3):
        if(C[0][i]==C[1][i]==C[2][i]):
            continue
        else:
            ans = False
print("Yes") if ans 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()))


for a in range(0,101):
    for b in range(0,101):
        for c in range(0,101):
                        a1 = a
                        a2 = b
                        a3 = c
                        b1 = c1[0] - a1
                        b2 = c1[1] - a1
                        b3 = c1[2] - a1
                        if a1 + b1 == c1[0] and a1 +b2 == c1[1] and a1 + b3 ==c1[2] \
                            and a2 + b1 == c2[0] and a2 +b2 == c2[1] and a2 + b3 ==c2[2] \
                                and a3 + b1 == c3[0] and a3 +b2 == c3[1] and a3 + b3 ==c3[2]:
                                print("Yes")
                                exit()
print("No")

Submission status: Accepted

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

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

for j in range(1, 3):
    a.append(c[j][j] - b[j])
ans = 'Yes'
for k in range(3):
    for m in range(3):
        if c[k][m] != a[k] + b[m]:
            ans = 'No'
            break
print(ans)

Submission status: Accepted

Solution code:
c = []
for _ in range(3):
    c.append([int(x) for x in input().split()])
ans = 'Yes'
for i in range(3):
    minv = min(c[i])
    for j in range(3):
        c[i][j] = c[i][j] - minv

for k in range(3):
    if c[0][k] == c[1][k] and c[0][k] == c[2][k]:
        pass
    else:
        ans = 'No'
print(ans)

Submission status: Accepted

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

b2mb1 = c_l[0][1]-c_l[0][0]
b3mb1 = c_l[0][2]-c_l[0][0]

for i in (1,2):
    if c_l[i][1] != c_l[i][0] + b2mb1:
        print('No')
        exit()
    if c_l[i][2] != c_l[i][0] + b3mb1:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
c1 = [int(i) for i in input().split()]
c2 = [int(i) for i in input().split()]
c3 = [int(i) for i in input().split()]
flag = False

if c1[1] - c1[0] == c2[1]- c2[0]:
    if c1[1] - c1[0] == c3[1]- c3[0]:
        if c1[2] - c1[0] == c2[2]- c2[0]:
            if c1[2] - c1[0] == c3[2]- c3[0]:
                if c1[0] - c2[0] == c1[1] - c2[1]:
                    if c1[0] - c2[0] == c1[2] - c2[2]:
                        if c1[0] - c3[0] == c1[1] - c3[1]:
                            if c1[0] - c3[0] == c1[2] - c3[2]:
                                flag = True
                                print('Yes')
if not flag:
    print('No')

Submission status: Accepted

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

ans = True

for a, b in itertools.combinations(range(3), 2):
    x = c[0][a] - c[0][b]
    for j in range(1, 3):
        if x != c[j][a] - c[j][b]:
            ans = False

for a, b in itertools.combinations(range(3), 2):
    x = c[a][0] - c[b][0]
    for j in range(1, 3):
        if x != c[a][j] - c[b][j]:
            ans = False

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

Submission status: Accepted

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


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

a1 = c[1][0] - b[0]
a2 = c[2][0] - b[0]
a = [a0, a1, a2]
is_ok =True
for i in range(3):
    for j in range(3):
        if c[i][j] != a[i] + b[j]:
            is_ok=False
if is_ok:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

a = [0]*3
b = []
for i in range(3):
    b.append(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 a[i]+b[j] != c[i][j]:
            print("No")
            exit()
print("Yes")

Submission status: Accepted

Solution code:
c = []
for _ in range(3):
    c.append(list(map(int, input().split())))
a = []
for i in range(3):
    tmp = []
    for j in range(3):
        tmp.append(c[i][j%3] - c[i][(j+1)%3])
    a.append(tmp)
for i in range(2):
    for j in range(3):
        if a[i][j]!=a[i+1][j]:
            print('No')
            break
    else:
        continue
    break
else:
    print('Yes')

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] \
and 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:
c=[]
for i in range(3):
    c.append([int(x) for x in list(input().split())])

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

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 a0 in range(101):
  b0 = c[0][0] - a0
  b1 = c[0][1] - a0
  b2 = c[0][2] - a0
  if (((c[1][0]-b0) == (c[1][1]-b1) == (c[1][2]-b2)) and
      ((c[2][0]-b0) == (c[2][1]-b1) == (c[2][2]-b2))):
    print("Yes")
    break
else:
  print("No")