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 solve(a,b,c):
  x=sum(a)
  y=sum(b)
  z=sum(c)
  if abs(x-y)%3!=0 or abs(y-z)%3!=0 or abs(z-x)%3!=0:
    return False
  for i in range(101):
    for j in range(101):
      for k in range(101):
        if (i-j)*3==(x-y) and (j-k)*3==(y-z) and (k-i)*3==(z-x):
          return True
  return False

A1=[int(x) for x in input().split()]
A2=[int(x) for x in input().split()]
A3=[int(x) for x in input().split()]

B1=[A1[0],A2[0],A3[0]]
B2=[A1[1],A2[1],A3[1]]
B3=[A1[1],A2[1],A3[1]]

if solve(A1,A2,A3) and solve(B1,B2,B3):
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

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

flag = True
for i in range(3):
    for j in range(3):
        if c[i][j] - c[i][(j+1)%3] != c[(i+1)%3][j] - c[(i+1)%3][(j+1)%3]:
            flag = False

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

Submission status: Accepted

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

def solve():
    c = [list(map(int, input().split())) for _ in range(3)]
    for a0 in range(-100, 101) :
        b = [c[0][i] - a0 for i in range(3)]
        if any(c[1][0] - b[0] != c[1][i] - b[i] for i in range(3)):
            continue
        if any(c[2][0] - b[0] != c[2][i] - b[i] for i in range(3)):
            continue
        return True
    return False


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

Submission status: Accepted

Solution code:
n=3
c=[]

for i in range(n):
    c.append([int(i) for i in input().split()])

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

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

for i in range(n):
    if c[i][0]-c[i][1]==a and c[i][1]-c[i][2]==b and c[i][2]-c[i][0]==d:
        if c[0][i]-c[1][i]==e and c[1][i]-c[2][i]==f and c[2][i]-c[0][i]==g: 
            pass

    else:
              print("No")
              break  

else:
    print("Yes")

Submission status: Accepted

Solution code:
C=[ [] for i in range(3) ]
for i in range(3):
	c1,c2,c3=map(int,raw_input().split())
	C[i].append(c1)
	C[i].append(c2)
	C[i].append(c3)

for i in range(2):
	s=set()
	for x1,x2 in zip(C[i],C[i+1]):
		s.add(x1-x2)

	if len(s)>1:
		print "No"
		quit()

C1=[[] for i in range(3)]
for i in range(3):
	C1[i].append(C[i][0]-C[i][1])
	C1[i].append(C[i][1]-C[i][2])

if C1[0]==C1[1]==C1[2]:
	print "Yes"
else:
	print "No"

Submission status: Accepted

Solution code:
def main():
    N = 3
    c = []
    for i in range(N):
        c.append([int(j) for j in input().split()])
    for i in range(N-1):
        for j in range(N-1):
            if c[i][j] + c[i+1][j+1] != c[i][j+1] + c[i+1][j]:
                print('No')
                return
    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def calc(a1,c):
    As=[a1]
    Bs=[]
    Bs.append(c[0][0]-As[0])
    As.append(c[1][0]-Bs[0])
    As.append(c[2][0]-Bs[0])
    Bs.append(c[0][1]-As[0])
    Bs.append(c[0][2]-As[0])
    for a in range(3):
        for b in range(3):
            if As[a]+Bs[b]!=c[a][b]: return False
    return True

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

flag=False
for i in range(-int(1e4),100):
    if (calc(i,c)): 
        print('Yes')
        flag=True
        break
if not flag: print('No')

Submission status: Accepted

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

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

for i in range(3):
    if min(c[0][i], c[1][i], c[2][i]) != \
        max(c[0][i], c[1][i], c[2][i]):

        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
list_c = []

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

is_success = True

c0 = sum(list_c[0])
c1 = sum(list_c[1])
c2 = sum(list_c[2])
if c0 % 3 != c1 % 3 \
        or c1 % 3 != c2 % 3 \
        or c2 % 3 != c0 % 3:
    is_success = False

c0 = sum([list_c[i][0] for i in range(3)])
c1 = sum([list_c[i][1] for i in range(3)])
c2 = sum([list_c[i][2] for i in range(3)])
if c0 % 3 != c1 % 3 \
        or c1 % 3 != c2 % 3 \
        or c2 % 3 != c0 % 3:
    is_success = False

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

Submission status: Accepted

Solution code:
import sys,collections;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

mat = []
for i in range(3):
    mat.append(Is())
if mat[0][0] - mat[0][1] == mat[1][0] - mat[1][1] == mat[2][0] - mat[2][1]:
    if mat[0][1] - mat[0][2] == mat[1][1] - mat[1][2] == mat[2][1] - mat[2][2]:
        if mat[0][0] - mat[1][0] == mat[0][1] - mat[1][1] == mat[0][2] - mat[1][2]:
            if mat[1][0] - mat[2][0] == mat[1][1] - mat[2][1] == mat[1][2] - mat[2][2]:
                print("Yes")
                exit()
print("No")

Submission status: Accepted

Solution code:
c = [0,0,0]
c[0] = [int(i) for i in input().split()]
c[1] = [int(i) for i in input().split()]
c[2] = [int(i) for i in input().split()]
for i in range(3):
    for j in range(3):
        d = [c[i][k] - c[j][k] for k in range(3)]
        if sum(d) != 3*d[0]: 
            print('No')
            exit()
print('Yes')

Submission status: Accepted

Solution code:
import numpy as np

v = []
for i in range(3):
    v.extend(input().split())

v = np.array([int(x) for x in v])



coeffs = np.array([
    [1, 0, 0, 1, 0, 0, v[0]],
    [1, 0, 0, 0, 1, 0, v[1]],
    [1, 0, 0, 0, 0, 1, v[2]],
    [0, 1, 0, 1, 0, 0, v[3]],
    [0, 1, 0, 0, 1, 0, v[4]],
    [0, 1, 0, 0, 0, 1, v[5]],
    [0, 0, 1, 1, 0, 0, v[6]],
    [0, 0, 1, 0, 1, 0, v[7]],
    [0, 0, 1, 0, 0, 1, v[8]],
])

rank = np.linalg.matrix_rank(coeffs)
if rank < 6:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import math
import numpy as np
from operator import mul

# 整数Nを桁ごとのリストにする
# l = [int(x) for x in list(str(N))]

# リストliから重複を削除したリストli_uniqを作成
#li_uniq = []
#for i in li:
#    if x not in li_uniq:
#        li_uniq.append(x)

# 複数行のinput - list版
#list = [list(map(int, input().split())) for i in range(N)]
# 複数行のinput - dictionary版
# key = a, value = b
#for i in range(N):
#    a, b = map(int, input().split())
#    dict[a] = b


tmp = [list(map(int, input().split())) for i in range(3)]
C = np.array(tmp)
a = 0

div = C[0] - C[1]
if div[0] == div[1] and div[0] == div[2]:
    a += 1
    
div = C[1] - C[2]
if div[0] == div[1] and div[0] == div[2]:
    a += 1

div = C[0] - C[2]
if div[0] == div[1] and div[0] == div[2]:
    a += 1

C.T

div = C[0] - C[1]
if div[0] == div[1] and div[0] == div[2]:
    a += 1
    
div = C[1] - C[2]
if div[0] == div[1] and div[0] == div[2]:
    a += 1

div = C[0] - C[2]
if div[0] == div[1] and div[0] == div[2]:
    a += 1

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
https://abc088.contest.atcoder.jp/tasks/abc088_c

"""
import sys
from sys import stdin
input = stdin.readline


def solve(M):
    for a1 in range(100+1):
        b1 = M[0][0] - a1
        a2 = M[1][0] - b1
        a3 = M[2][0] - b1
        b2 = M[0][1] - a1
        b3 = M[0][2] - a1
        if a2+b2 == M[1][1] and a2+b3==M[1][2] and a3+b2==M[2][1] and a3+b3==M[2][2]:
            return 'Yes'
    return 'No'


def main(args):
    M = []
    for _ in range(3):
        M.append([int(x) for x in input().split()])
    ans = solve(M)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
#coding:utf-8
import numpy as np
c = []
c.append (list(map(int, input().split())))
c.append (list(map(int, input().split())))
c.append (list(map(int, input().split())))
c = np.array(c)
if np.sum(c)/3 == c[0][0]+c[1][1]+c[2][2]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

D_h = [[C[idx][jdx+1]-C[idx][jdx] for idx in range(3)] for jdx in range(2)]
D_v = [[C[idx+1][jdx]-C[idx][jdx] for idx in range(2)] for jdx in range(3)]

for idx in range(2):
	if D_h[idx][0] != D_h[idx][1]:
		print("No")
		exit(0)
	elif D_h[idx][0] != D_h[idx][2]:
		print("No")
		exit(0)

for idx in range(2):
	if D_v[0][idx] != D_v[1][idx]:
		print("No")
		exit(0)
	elif D_v[0][idx] != D_v[2][idx]:
		print("No")
		exit(0)

print("Yes")

Submission status: Accepted

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

b2b0_0 = c[0][2] - c[0][0]
b2b0_1 = c[1][2] - c[1][0]
b2b0_2 = c[2][2] - c[2][0]

a1a0_0 = c[1][0] - c[0][0]
a1a0_1 = c[1][1] - c[0][1]
a1a0_2 = c[1][2] - c[0][2]

a2a0_0 = c[2][0] - c[0][0]
a2a0_1 = c[2][1] - c[0][1]
a2a0_2 = c[2][2] - c[0][2]

b = (b1b0_0 == b1b0_1) and (b1b0_0 == b1b0_2) and (b2b0_0 == b2b0_1) and (b2b0_0 == b2b0_2)
a = (a1a0_0 == a1a0_1) and (a1a0_0 == a1a0_2) and (a2a0_0 == a2a0_1) and (a2a0_0 == a2a0_2)

if a and b:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
# coding=utf-8

c = []

for _ in range(3):
    line = list(map(lambda x:int(x), input().split(" ")))
    c.append(line)

if not (c[0][0]-c[1][0] == c[0][1]-c[1][1] == c[0][2]-c[1][2]):
    print("No")
    exit()

if not (c[1][0]-c[2][0] == c[1][1]-c[2][1] == c[1][2]-c[2][2]):
    print("No")
    exit()

if not (c[2][0]-c[0][0] == c[2][1]-c[0][1] == c[2][2]-c[0][2]):
    print("No")
    exit()

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

if not (c[0][2]-c[0][0] == c[1][2]-c[1][0] == c[2][2]-c[2][0]):
    print("No")
    exit()

print("Yes")

Submission status: Accepted

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

a2 = None
a3 = None
for i in range(c1[0]+1):
    a1 = i
    b1 = c1[0]-a1
    b2 = c1[1]-a1
    b3 = c1[2]-a1
    if c2[0]-b1 == c2[1]-b2 == c2[2]-b3:
        a2 = c2[0]-b1
    else:
        pass
    if c3[0]-b1 == c3[1]-b2 == c3[2]-b3:
        a3 = c3[0]-b1
    else:
        pass

print("Yes" if a2 is not None and a3 is not None else "No")

Submission status: Accepted

Solution code:
import numpy as np

def slove(c):
    diff1_1 = c[0,0] - c[0,1]
    diff1_2 = c[0,1] - c[0,2]
    diff2_1 = c[1,0] - c[1,1]
    diff2_2 = c[1,1] - c[1,2]
    diff3_1 = c[2,0] - c[2,1]
    diff3_2 = c[2,1] - c[2,2]

    if not(diff1_1 == diff2_1 == diff3_1):
        return "No"

    if not(diff1_2 == diff2_2 == diff3_2):
        return "No"

    return "Yes"


if __name__ == "__main__":
    c_lst = []
    for i in range(3):
        c_lst.append(input().split(" "))
    c = np.array(c_lst, dtype=int)
    print(slove(c))

Submission status: Accepted

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

# y0-1
if C[0][0]-C[1][0]!=C[0][1]-C[1][1] or C[0][1]-C[1][1]!=C[0][2]-C[1][2]:
    print('No')
    exit()
# y1-2
if C[1][0]-C[2][0]!=C[1][1]-C[2][1] or C[1][1]-C[2][1]!=C[1][2]-C[2][2]:
    print('No')
    exit()
if C[0][0]-C[0][1]!=C[1][0]-C[1][1] or C[1][0]-C[1][1]!=C[2][0]-C[2][1]:
    print('No')
    exit()
if C[0][1]-C[0][2]!=C[1][1]-C[1][2] or C[1][1]-C[1][2]!=C[2][1]-C[2][2]:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

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

x=c[0][0]+c[1][1]+c[2][2]
y=c[0][1]+c[1][2]+c[2][0]
z=c[1][0]+c[2][1]+c[0][2]
if x==y and y==z:
    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[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:
# -*- coding: utf-8 -*-

import numpy as np #1.11.0
#import matplotlib as plt #1.5.1
import copy 
import math

a = []
for i in range(3):
  b = list(map(int, input().strip().split(' ')))
  a.append(b)

flag = 0

for i in range(2):
  for j in range(2):
    if (a[i + 1][j] - a[i][j]) != (a[i + 1][j + 1] - a[i][j + 1]):
      flag = 1
  
for i in range(2):
  for j in range(2):
    if (a[i][j + 1] - a[i][j]) != (a[i + 1][j + 1] - a[i + 1][j]):
      flag = 1

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

Submission status: Accepted

Solution code:
import sys

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

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

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

	if ok:
		print("Yes")
		sys.exit(0)

print("No")

Submission status: Accepted

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

flag = True
for i in range(3):
    if abs(sum(c[i - 1]) - sum(c[i])) % 3 != 0:
        flag = False
        break

if flag:
    SUM = [
        c[0][0] + c[1][0] + c[2][0],
        c[0][1] + c[1][1] + c[2][1],
        c[0][2] + c[1][2] + c[2][2],
    ]
    for i in range(3):
        if abs(SUM[i - 1] - SUM[i]) % 3 != 0:
            flag = False
            break

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

Submission status: Accepted

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

Submission status: Accepted

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

ok = False
d1 = c[0][0] - c[0][1]
d2 = c[0][0] - c[0][2]
d3 = c[0][1] - c[0][2]
if c[1][0] - c[1][1] == c[2][0] - c[2][1] == d1:
  if c[1][0] - c[1][2] == c[2][0] - c[2][2] == d2:
    if c[1][1] - c[1][2] == c[2][1] - c[2][2] == d3:
      ok = True
if ok:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
if((a[0]+b[1] == a[1]+b[0])
  and (a[0]+c[1] == a[1]+c[0])
  and (a[0]+b[2] == a[2]+b[0])
  and (a[0]+c[2] == a[2]+c[0])
  and (a[1]+b[2] == a[2]+b[1])
  and (a[1]+c[2] == a[2]+c[1])
  and (b[0]+c[1] == b[1]+c[0])
  and (b[0]+c[2] == b[2]+c[0])):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

ok = True

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

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

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

Submission status: Accepted

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

x = 0
for i in range(3):
    if i == 0:
        a00 = a[i][0]
        a01 = a[i][1]
        a02 = a[i][2]
    else:
        if a[i][0] - a00 != a[i][1] - a01 or a[i][0] - a00 != a[i][2] - a02:
            x = 1
        if a[i][1] - a01 != a[i][0] - a00 or a[i][1] - a01 != a[i][2] - a02:
            x = 1
        if a[i][2] - a02 != a[i][0] - a00 or a[i][2] - a02 != a[i][1] - a01:
            x = 1

for i in range(3):
    if i == 0:
        a00 = a[0][i]
        a01 = a[1][i]
        a02 = a[2][i]
    else:
        if a[0][i] - a00 != a[1][i] - a01 or a[0][i] - a00 != a[2][i] - a02:
            x = 1
        if a[1][i] - a01 != a[0][i] - a00 or a[1][i] - a01 != a[2][i] - a02:
            x = 1
        if a[2][i] - a02 != a[0][i] - a00 or a[2][i] - a02 != a[1][i] - a01:
            x = 1

if x == 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
first = list(map(int,input().split()))
second = list(map(int,input().split()))
third = list(map(int,input().split()))

kekka = "Yes"

for i in range(2):
    fsa = first[i+1] - first[i]
    ssa = second[i+1] - second[i]
    tsa = third[i+1] - third[i]
    if fsa == ssa and fsa == tsa:
        pass
    else:
        kekka = "No"

zentai = [first,second,third]

for i in range(2):
    fsa = zentai[i][0] - zentai[i+1][0]
    ssa = zentai[i][1] - zentai[i+1][1]
    tsa = zentai[i][2] - zentai[i+1][2]
    if fsa == ssa and fsa == tsa:
        pass
    else:
        kekka = "No"

print(kekka)

Submission status: Accepted

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

def solve():
    c = [list(map(int, input().split())) for _ in range(3)]
    for a0 in range(-100, 101) :
        b = [c[0][i] - a0 for i in range(3)]
        if any(c[1][0] - b[0] != c[1][i] - b[i] for i in range(3)):
            continue
        if any(c[2][0] - b[0] != c[2][i] - b[i] for i in range(3)):
            continue
        return True


if __name__ == '__main__':
    if solve() :
        print("Yes")
    else :
        print("No")

Submission status: Accepted

Solution code:
import numpy as np

if __name__=='__main__':
    a = []
    for i in range(3):
        m = list(map(int, input().split(' ')))
        a.append(m)

    a = np.array(a).T
    for i in range(3):
        a[i] -= a[i][0]

    if np.allclose(a[0], a[1]) and np.allclose(a[0], a[2]):
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
c1 = input().split()
c2 = input().split()
c3 = input().split()

c1 = list(map(int,c1))
c2 = list(map(int,c2))
c3 = list(map(int,c3))

for i in range(2):
	c1[i+1] = c1[i+1] - c1[0]
	c2[i+1] = c2[i+1] - c2[0]
	c3[i+1] = c3[i+1] - c3[0]

c1 = c1[1:]
c2 = c2[1:]
c3 = c3[1:]

if c1 == c2 == c3:
	print("Yes")

else:
	print ("No")

Submission status: Accepted

Solution code:
a,b,c=[int(i) for i in input().split()]
m,n=b-a,c-b
a,b,c=[int(i) for i in input().split()]
o,p=b-a,c-b
if m!=o or n!=p:
    print('No')
    exit()
m,n=o,p
a,b,c=[int(i) for i in input().split()]
o,p=b-a,c-b
if m!=o or n!=p:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

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

def f(i):
    return C[i+1][0] - C[i][0] ==  C[i+1][1] - C[i][1] ==  C[i+1][2] - C[i][2]

def g(i):
    return C[0][i+1] - C[0][i] ==  C[1][i+1] - C[1][i] ==  C[2][i+1] - C[2][i]

print('Yes' if f(1) and f(0) and g(1) and g(0) else 'No')

Submission status: Accepted

Solution code:
import numpy as np

cs = []
cs.append([int(a) for a in input().split()])
cs.append([int(a) for a in input().split()])
cs.append([int(a) for a in input().split()])

cs = np.array(cs)

a1a2 = cs[0] - cs[1]
a2a3 = cs[1] - cs[2]
b1b2 = cs[:,0] - cs[:,1]
b2b3 = cs[:,1] - cs[:,2]

if np.all((a1a2 - a1a2[0]) == 0) and np.all((a2a3 - a2a3[0]) == 0) and np.all((b1b2 - b1b2[0]) == 0) and np.all((b2b3 - b2b3[0]) == 0):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import numpy as np
c1j = np.array(list(map(int, input().split())))
c2j = np.array(list(map(int, input().split())))
c3j = np.array(list(map(int, input().split())))
grids = np.vstack([c1j, c2j, c3j])
ci1 = grids[:,0]
ci2 = grids[:,1]
ci3 = grids[:,2]
if len(set(c1j - c2j)) == 1 and len(set(c2j - c3j)) == 1 and len(set(c3j-c1j)) \
        and len(set(ci1 - ci2)) == 1 and len(set(ci2 - ci3)) == 1 and len(set(ci3 - ci1)) == 1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
matrix = []
crow = []
for i in range(3):
    row = input().split()
    for j in row:
        crow.append(int(j))
    matrix.append(crow)
    crow = []

ans = 'Yes'

test = []
for i in range(2):
    for j in range(3):
        test.append(matrix[i][j]-matrix[i+1][j])
        if len(set(test))!=1:
            ans = 'No'
    test = []
    
for j in range(2):
    for i in range(3):
        test.append(matrix[i][j]-matrix[i][j+1])
        if len(set(test))!=1:
            ans = 'No'
        test = []
        

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

def solve():
    def_x = C[0][0] - C[0][1]
    if def_x != (C[1][0] - C[1][1]) or def_x != (C[2][0] - C[2][1]):
        print("No")
        return
    def_x = C[0][1] - C[0][2]
    if def_x != (C[1][1] - C[1][2]) or def_x != (C[2][1] - C[2][2]):
        print("No")
        return
    def_y = C[0][0] - C[1][0]
    if def_y != (C[0][1] - C[1][1]) or def_y != (C[0][2] - C[1][2]):
        print("No")
        return
    def_y = C[0][0] - C[2][0]
    if def_y != (C[0][1] - C[2][1]) or def_y != (C[0][2] - C[2][2]):
        print("No")
        return
    print("Yes")
    
    
    
solve()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a=[]
for i in range(3):
	b=list(map(int,input().split()))
	a.append(b)
k=0	
for i in range(101):
	b1=a[0][0]-i
	for j in range(101):
		b2=a[1][1]-j
		for k in range(101):
			b3=a[2][2]-k
			if(3*i+b1+b2+b3==sum(a[0]) and 3*j+b1+b2+b3==sum(a[1]) and 3*k+b1+b2+b3==sum(a[2])):
				k=1
				break
		if(k==1):
			break
	if(k==1):
		break
if(k==1):
	print("Yes")
else:
	print("No")

Submission status: Accepted

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

isValid = False
if c[0][0] - c[0][1] == c[1][0] - c[1][1] == c[2][0] - c[2][1]:
    if c[0][0] - c[0][2] == c[1][0] - c[1][2] == c[2][0] - c[2][2]:
        if c[0][0] - c[1][0] == c[0][1] - c[1][1] == c[0][2] - c[1][2]:
            if c[0][0] - c[2][0] == c[0][1] - c[2][1] == c[0][2] - c[2][2]:
              isValid = True

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
c0=list(map(int,input().split(' ')))
c1=list(map(int,input().split(' ')))
c2=list(map(int,input().split(' ')))
f=0
if (c0[0]-c1[0]) != (c0[1] - c1[1]) or (c0[0]-c1[0]) != (c0[2]-c1[2]):
    f=1
if (c0[0]-c2[0]) != (c0[1] - c2[1]) or (c0[0]-c2[0]) != (c0[2]-c2[2]):
    f=1
if (c0[0]-c0[1]) != (c1[0] - c1[1]) or (c0[0]-c0[1]) != (c2[0]-c2[1]):
    f=1
if (c0[2]-c0[1]) != (c1[2] - c1[1]) or (c0[2]-c0[1]) != (c2[2]-c2[1]):
    f=1
if f == 1:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
def C_Takahashis_Information():
    a,b,c= map(int, input().split())
    d,e,f= map(int, input().split())
    g,h,i= map(int, input().split())
    if (a+e==b+d) and (b+f==c+e) and (d+h==e+g) and (e+i==f+h):
        print('Yes')
    else:
        print('No')
    
C_Takahashis_Information()

Submission status: Accepted

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# Set 2 dimension list
def dim2input(N):
    li = []
    for _ in range(N):
        li.append(list(map(int, input())))
    return li

""" input template
S = input()
N = int(input())
L = list(map(int, input().split()))
a, b = list(map(int, input().split()))
SL = list(input())
"""

# --------------------------------------------

dp = None

def main():
    C = []

    for _ in range(3):
        C.append(list(map(int, input().split())))

    a1_limit = min(C[0])+1
    a2_limit = min(C[1])+1
    a3_limit = min(C[2])+1
    b1_limit = min(C[0][0], C[1][0], C[2][0])+1
    b2_limit = min(C[0][1], C[1][1], C[2][1])+1
    b3_limit = min(C[0][2], C[1][2], C[2][2])+1

    A1, A2, A3, B1, B2, B3 = [], [], [], [], [], []
    for i in range(a1_limit):
        A1.append(i)
    for i in range(a2_limit):
        A2.append(i)
    for i in range(a3_limit):
        A3.append(i)
    for i in range(b1_limit):
        B1.append(i)
    for i in range(b2_limit):
        B2.append(i)
    for i in range(b3_limit):
        B3.append(i)

    for a1, a2, a3 in itertools.product(A1, A2, A3):
        b1 = C[0][0] - a1
        b2 = C[1][1] - a2
        b3 = C[2][2] - a3

        if a1 + b1 != C[0][0]:
            continue
        if a2 + b1 != C[1][0]:
            continue
        if a3 + b1 != C[2][0]:
            continue
        if a1 + b2 != C[0][1]:
            continue
        if a2 + b2 != C[1][1]:
            continue
        if a3 + b2 != C[2][1]:
            continue
        if a1 + b3 != C[0][2]:
            continue
        if a2 + b3 != C[1][2]:
            continue
        if a3 + b3 != C[2][2]:
            continue

        print("Yes")
        return

    print("No")

main()

Submission status: Accepted

Solution code:
rows = []
for _ in range(3):
  rows.append(list(map(int, input().split())))
for i in range(3):
  for j in range(2, -1, -1):
    rows[i][j] -= rows[i][0]
ok = True
for j in range(3):
  for i in range(3):
    if rows[i][j] != rows[0][j]:
      ok = False
if ok: print("Yes")
else: print("No")

Submission status: Accepted

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

temp1, temp2 = [], []
temp3, temp4 = [], []
for i in range(3):
    temp1.append(c[1][i] - c[0][i])
    temp2.append(c[2][i] - c[0][i])
    temp3.append(c[i][1] - c[i][0])
    temp4.append(c[i][2] - c[i][0])
if len(set(temp1)) == len(set(temp2)) == len(set(temp3)) == len(set(temp4)) == 1:
    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[0][0]-c[0][1] == c[1][0]-c[1][1] and \
   c[0][0]-c[0][1] == c[2][0]-c[2][1] and \
   c[0][0]-c[0][2] == c[1][0]-c[1][2] and \
   c[0][0]-c[0][2] == c[2][0]-c[2][2] and \
   c[0][0]-c[1][0] == c[0][1]-c[1][1] and \
   c[0][0]-c[1][0] == c[0][2]-c[1][2] and \
   c[0][0]-c[2][0] == c[0][1]-c[2][1] and \
   c[0][0]-c[2][0] == c[0][2]-c[2][2]:
    print ("Yes")
else:
    print ("No")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
c = [[int(i) for i in input().split()] for i in range(3)]
flag = 1
for i in range(3):
    for j in range(3):
        if c[(i+1)%3][j] + c[i][(j+1)%3] != c[i][j] + c[(i+1)%3][(j+1)%3]:
           flag = 0
if flag == 0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding: UTF-8
#@document_it
def document_it(func):
    def new_function(*args,**kwargs):
        print('Running function:', func.__name__)
        print('Positional arguments:', args)
        print('Kewword arguments:', kwargs)
        result = func(*args,**kwargs)
        print('Result:', result)
        return result
    return new_function


def exe():
    C11,C12,C13 = map(int,input().split())
    C21,C22,C23 = map(int,input().split())
    C31,C32,C33 = map(int,input().split())
    
    C = C11
    A2 = C21 - C
    A3 = C31 - C
    B2 = C12 - C
    B3 = C13 - C
    C22 -= C
    C23 -= C
    C32 -= C
    C33 -= C
    
    if C22 == A2+B2 and C23 == A2+B3 and C32 == A3+B2 and C33 == A3+B3:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    exe()

Submission status: Accepted

Solution code:
import numpy as np
u = np.array(list(map(int, input().split())))
c = np.array(list(map(int, input().split())))
b = np.array(list(map(int, input().split())))
for l1 in range(u[0] + 1):
    u1 = u[0] - l1
    l2 = c[0] - u1
    l3 = b[0] - u1
    u2 = u[1] - l1
    u3 = u[2] - l1
    if c[1] == u2 + l2 and c[2] == u3 + l2 and b[1] == u2 + l3 and b[2] == u3 + l3:
        print("Yes")
        exit()
else:
    print("No")