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 = [[int(i) for i in input().split()] for j in range(3)]


c0 = C[0][0]-C[1][0]
c1 = C[0][1]-C[1][1]
c2 = C[0][2]-C[1][2]

d0 = C[1][0]-C[2][0]
d1 = C[1][1]-C[2][1]
d2 = C[1][2]-C[2][2]

e0 = C[0][1]-C[0][2]
e1 = C[1][1]-C[1][2]
e2 = C[2][1]-C[2][2]

if (c0 == c1 and c1 == c2) and (d0 == d1 and d1 == d2) and (e0 == e1 and e1 == e2):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

for i in range(2):
    d = []
    for j in range(3):
        d += [cs[i + 1][j] - cs[i][j]]

    if len(set(d)) > 1:
        print('No')
        exit()

for j in range(2):
    d = []
    for i in range(3):
        d += [cs[i][j + 1] - cs[i][j]]

    if len(set(d)) > 1:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
c = []
for i in range(3):
    c.append(list(map(int, input().split())))
tmp = [[] for i in range(4)]
for i in range(3):
    for j in range(2):
        tmp[j].append(c[j+1][i] - c[0][i])
        tmp[j+2].append(c[i][j+1] - c[i][0])
if set([len(set(i)) for i in tmp]) == {1}:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

flg =False
for i in range(100):
    b0,b1,b2  = grid[0][0]-i,grid[0][1]-i,grid[0][2]-i
    a1,a2 = grid[1][0]-b0,grid[2][0]-b0
    if grid[1][1] == a1+b1 and grid[1][2] == a1+b2 and grid[2][1] == a2+b1 and grid[2][2] == a2+b2:
        if grid[0][0] == i+b0 and grid[0][1] == i+b1 and grid[0][2] == i+b2 and grid[1][0] == a1+b0 and grid[2][0] == a2+b0:
            flg =True
            break
    if min([b0,b1,b2]) < 0:
        break
    
if flg:
    print('Yes')
    
else:
    print('No')

Submission status: Accepted

Solution code:
C = [[int(i) for i in input().split()] for i in range(3)]
res = 'No'
for i in range(100) :
  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
  if C[1][1] != a2 + b2 :
    continue
  if C[1][2] != a2 + b3 :
    continue
  if C[2][1] != a3 + b2 :
    continue
  if C[2][2] != a3 + b3 :
    continue
  res = 'Yes'
  break
print(res)

Submission status: Accepted

Solution code:
# coding: utf-8
# hello worldと表示する
adan = input().split()
bdan = input().split()
cdan = input().split()
aken = int(int(adan[int(1)])-int(bdan[int(1)]))
bken = int(int(adan[int(2)])-int(bdan[int(2)]))
cken = int(int(adan[int(0)])-int(bdan[int(0)]))
dken = int(int(adan[int(1)])-int(cdan[int(1)]))
eken = int(int(adan[int(2)])-int(cdan[int(2)]))
fken = int(int(adan[int(0)])-int(cdan[int(0)]))
if aken == bken == cken:
    if dken == eken == fken:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
c11,c12,c13=map(int,input().split())
c21,c22,c23=map(int,input().split())
c31,c32,c33=map(int,input().split())
if (c11-c12==c21-c22==c31-c32 and c12-c13==c22-c23==c32-c33 \
and c13-c11==c23-c21==c33-c31 and c11-c21==c12-c22==c13-c23 \
and c21-c31==c22-c32==c23-c33 and c31-c11==c32-c12==c33-c13) :
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import numpy as np


def main(a):
    a = np.diff(a)
    a = np.diff(a, axis=-1)
    a = np.diff(a, axis=0)
    a = np.diff(a, axis=0)
    if int(a[0]) == 0:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    a = np.empty(0)

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

Submission status: Accepted

Solution code:
# coding: utf-8

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

#print(C)

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

ans_flag = 'No'
a1_flag = False
a2_flag = False
a3_flag = False

def check_b(_b):
    b_count = 0
    for i_b in _b:
        if i_b >= 0 and i_b <= 100:
            b_count += 1
    
    if b_count >= 3:
        return True
    else:
        return False

def check_succes(a_val,b, c):
    b_count2 = 0
    i = 0
    for i_b in b:
        if i_b == c[i] - a_val:
            b_count2 += 1
        i += 1
    if b_count2 >= 3:
        return True
    else:
        return False

main_count = 0

for a_1 in range(101):
    a[0] = a_1
    for x in range(len(b)):
        b[x] = C[0][x] - a[0]
    #main_count += 1
    #if main_count == 1:
        #print("b = {0}".format(b))

    if check_b(b):
        a1_flag = True
        for a_2 in range(101):
            a[1] = a_2
            if check_succes(a[1], b, C[1]):
                a2_flag = True
                for a_3 in range(101):
                    a[2]= a_3
                    if check_succes(a[2], b, C[2]):
                        a3_flag = True
                        ans_flag = 'Yes'



print(ans_flag)


#print('--debug--')
#print(a1_flag)
#print(a2_flag)
#print(a3_flag)


def check_succes(a_val,b, c):
    b_count2 = 0
    i = 0
    for i_b in _b:
        if i_b == c[i] - a_val:
            b_count2 += 1
        i += 1
    if b_count2 >= 3:
        return True
    else:
        return False

Submission status: Accepted

Solution code:
c = []
for i in range(3):
    b = list(map(int,input().split()))
    c.append(b)
#[j][i]でcijが出てくる

#差分が一致するはず
if abs(c[0][1]-c[0][0]) == abs(c[1][0]-c[1][1]) == abs(c[2][0]-c[2][1]) and abs(c[0][1]-c[0][2]) == abs(c[1][1]-c[1][2]) == abs(c[2][1]-c[2][2]) and abs(c[0][0]-c[1][0]) == abs(c[0][1]-c[1][1]) == abs(c[0][2]-c[1][2]) and abs(c[1][0]-c[2][0]) == abs(c[2][1]-c[1][1]) == abs(c[1][2]-c[2][2]):
    print("Yes")

else:
    print("No")

Submission status: Accepted

Solution code:
c1 = list(map(int,input().split(" ")))
c2 = list(map(int,input().split(" ")))
c3 = list(map(int,input().split(" ")))
a1 = []
a2 = []
a3 = []
b1 = []
b2 = []
b3 = []
judge1 = False
judge2 = False
judge3 = False
judge4 = False
for i in range(c1[0]+1):
    a1.append(i)
b1 = sorted(a1,reverse = True)
for i in b1:
    a2.append(c2[0]-i)
for i in b1:
    a3.append(c3[0]-i)

for i in a1:
    b2.append(c1[1]-i)
for i in a1:
    b3.append(c1[2]-i)

for i in range(len(a1)):
    if c2[1] == a2[i]+b2[i]:
        judge1 = True
    if c3[2] == a3[i]+b3[i]:
        judge2 = True
    if c2[2] == a2[i]+b3[i]:
        judge3 = True
    if c3[1] == a3[i]+b2[i]:
        judge4 = True 
if judge1 and judge2 and judge3 and judge4 :
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import numpy as np
list1 = np.array(map(int,raw_input().split()))
list2 = np.array(map(int,raw_input().split()))
list3 = np.array(map(int,raw_input().split()))
list4 = list1 - list2
list5 = list1 - list3
list6 = [list1[0] - list1[1],list2[0] - list2[1],list3[0] - list3[1]]
list7 = [list1[0] - list1[2],list2[0] - list2[2],list3[0] - list3[2]]
def checkline(list):
    return (list[0] - list[1])**2 + (list[0] - list[2])**2

if checkline(list4) == 0 and checkline(list5) == 0 and checkline(list6) == 0 and checkline(list7) == 0:
        print 'Yes'
else:
    print 'No'

Submission status: Accepted

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

import sys

def main():
    c = tuple(tuple(map(int, line.split())) for line in sys.stdin.readlines())
    csum = sum((sum(ci) for ci in c))
    trace = sum((cij for i, ci in enumerate(c) for j, cij in enumerate(ci) if i == j))
    if csum == 3 * trace:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
A=input().split(" ")
A = list(map(int, A))
B=input().split(" ")
B = list(map(int, B))
C=input().split(" ")
C = list(map(int, C))


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

Submission status: Accepted

Solution code:
import sys

nS = [0 for i in range(3)]
nA = [0 for i in range(3)]
nB = [0 for i in range(3)]
nC = [0 for i in range(3)]

N = 3

nS  = input().rstrip().split(' ')
for i in range(N):
    nA[i] = int(nS[i])

nS  = input().rstrip().split(' ')
for i in range(N):
    nB[i] = int(nS[i])

nS  = input().rstrip().split(' ')
for i in range(N):
    nC[i] = int(nS[i])

Tmp = nC[0]-nA[0]
nTmp = nC[1]-nA[1]
if Tmp != nTmp:
    print('No')
    sys.exit()

nTmp = nC[2]-nA[2]
if Tmp != nTmp:
    print('No')
    sys.exit()

Tmp = nB[0]-nA[0]
nTmp = nB[1]-nA[1]
if Tmp != nTmp:
    print('No')
    sys.exit()

nTmp = nB[2]-nA[2]
if Tmp != nTmp:
    print('No')
    sys.exit()


Tmp = nA[1]-nA[0]
nTmp = nB[1]-nB[0]
if Tmp != nTmp:
    print('No')
    sys.exit()

nTmp = nC[1]-nC[0]
if Tmp != nTmp:
    print('No')
    sys.exit()

Tmp = nA[2]-nA[0]
nTmp = nB[2]-nB[0]
if Tmp != nTmp:
    print('No')
    sys.exit()

nTmp = nC[2]-nC[0]
if Tmp != nTmp:
    print('No')
    sys.exit()

Tmp = nA[0]+ nC[2]
nTmp = nA[2]+ nC[0]
if Tmp != nTmp:
    print('No')
    sys.exit()
    
print('Yes')

Submission status: Accepted

Solution code:
def c_takahashi_information(C):
    a = [min(C[0]), min(C[1]), min(C[2])]
    tmp = [[C[i][j] - a[i] for j in range(3)] for i in range(3)]
    b = list(map(list, set(map(tuple, tmp))))
    for bb in b:
        f = True
        for i in range(3):
            for j in range(3):
                if a[i] + bb[j] != C[i][j]:
                    f = False
                    break
            if not f:
                break
        if f:

            return 'Yes'
    return 'No'
  
C = [[int(i) for i in input().split()] for j in range(3)]
print(c_takahashi_information(C))

Submission status: Accepted

Solution code:
import sys

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

C = []

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

a = [0,0,0]
b = [0,0,0]
for b1 in range(101):
    b[0] = b1
    a[0] = C[0][0] - b1
    a[1] = C[1][0] - b1
    a[2] = C[2][0] - b1
    a_s = sum(a)

    b[1] = (C[0][1] + C[1][1] + C[2][1] - a_s) / 3
    b[2] = (C[0][2] + C[1][2] + C[2][2] - a_s) / 3

    if (check(a,b,C)):
        print('Yes')
        sys.exit()
print('No')

Submission status: Accepted

Solution code:
mt = []
for _ in range(3):
    mt.append(list(map(int, input().split())))
b1b2, b2b3, a1a2, a2a3 = [],[],[],[]
for i in range(3):
    b1b2.append(mt[i][0]-mt[i][1])
    b2b3.append(mt[i][1]-mt[i][2])
    a1a2.append(mt[0][i]-mt[1][i])
    a2a3.append(mt[1][i]-mt[2][i])
array = [b1b2,b2b3,a1a2,a2a3]
def sl(es):
    return len(list(set(es))) == 1
if all([sl(es) for es in array]):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
C0 = map(int, input().split())
C0 = list(C0)

C1 = map(int, input().split())
C1 = list(C1)

C2 = map(int, input().split())
C2 = list(C2)


if (C0[0] - C0[1] == C1[0]-C1[1] == C2[0]-C2[1] and C0[0] - C0[2] == C1[0]-C1[2] == C2[0]-C2[2] and C0[0] - C1[0] == C0[1] - C1[1] == C0[2] - C1[2] and C0[0] - C2[0] == C0[1] - C2[1] == C0[2] - C2[2] ):

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

Submission status: Accepted

Solution code:
d0 = [int(i) for i in input().split()]
d1 = [int(i) for i in input().split()]
d2 = [int(i) for i in input().split()]


x0 = d1[0]-d0[0]
x1 = d2[0]-d0[0]

y0 = d1[1]-d0[1]
y1 = d2[1]-d0[1]

z0 = d1[2]-d0[2]
z1 = d2[2]-d0[2]


i0 = d0[1]-d0[0]
i1 = d0[2]-d0[0]

j0 = d1[1]-d1[0]
j1 = d1[2]-d1[0]

k0 = d2[1]-d2[0]
k1 = d2[2]-d2[0]

if (x0 == y0) and (x0 == z0) and (x1 == y1) and (x1 == z1):
    if (i0 == j0) and (i0 == k0) and (i1 == j1) and (i1 == k1):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
c = [c1, c2, c3]
Takahashi = True
for i in range(3):
    for j in range(3):
        for k in range(3):
            for l in range(3):
                if c[i][k] - c[j][k] != c[i][l] - c[j][l]:
                    Takahashi = False
                    break
for i in range(3):
    for j in range(3):
        for k in range(3):
            for l in range(3):
                if c[i][k] - c[i][l] != c[j][k] - c[j][l]:
                    Takahashi = False
                    break
if Takahashi == True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
g = [[int(i) for i in input().split()] for i in range(3)]
res = 'No'

for a1 in range(101):
    b1 = g[0][0] - a1
    b2 = g[0][1] - a1
    b3 = g[0][2] - a1
    for a2 in range(101):
        if (a2 + b1) == g[1][0] and (a2 + b2) == g[1][1] and (a2 + b3) == g[1][2]:
            for a3 in range(101):
                if (a3 + b1) == g[2][0] and (a3 + b2) == g[2][1] and (a3 + b3) == g[2][2]:
                    res = 'Yes'
print(res)

Submission status: Accepted

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

    c = [[0 for _ in [0] * 4] for _ in [0] * 4]
    for i, n in enumerate(C):
        for j, m in enumerate(n):
            c[i+1][j+1] = m

    a, b = [0] * 4, [0] * 4
    for n in range(c[1][1] + 1):
        a[1] = n
        b[1] = c[1][1] - n
        a[2] = c[2][1] - b[1]
        b[2] = c[1][2] - a[1]
        a[3] = c[3][1] - b[1]
        b[3] = c[1][3] - a[1]

        flag = 0
        for i in range(1, 4):
            for j in range(1, 4):
                if c[i][j] != a[i] + b[j]:
                    flag = 1
                    break
            if flag:
                break
        else:
            print('Yes')
            break
    else:
        print('No')

main()

Submission status: Accepted

Solution code:
import sys
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    C = 0
    C_diag = 0
    for i in range(3):
        input_raw = read_func().strip().split()
        C += int(input_raw[0]) + int(input_raw[1]) + int(input_raw[2])
        C_diag += int(input_raw[i])
    if C % 3 == 0 and C/3 == C_diag :
        print "Yes"
    else:
        print "No"



if __name__ == '__main__':
    main()

Submission status: Accepted

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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a = [LI() for _ in range(3)]
    for i in range(3):
        a[i][2] -= a[i][1]
        a[i][1] -= a[i][0]
    if a[0][1] != a[1][1] or a[0][1] != a[2][1] or a[0][2] != a[1][2] or a[0][2] != a[2][2]:
        return 'No'

    return 'Yes'


print(main())

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[1]-c1[0]==c2[1]-c2[0]==c3[1]-c3[0] and c1[2]-c1[1]==c2[2]-c2[1]==c3[2]-c3[1]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import numpy as np

C = []

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

C = np.array(C)

row = [np.unique(C[i,:] - C[i+1, :]).shape[0] for i in range(2)]
column = [np.unique(C[:,i] - C[:, i+1]).shape[0] for i in range(2)]

if sum(np.concatenate((row, column), axis = 0)) == 4:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
L1 = input().split(" ")
L2 = input().split(" ")
L3 = input().split(" ")
lis1 = list(map(int, L1))
lis2 = list(map(int, L2))
lis3 = list(map(int, L3))

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

Submission status: Accepted

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

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

# c = [c1, c2, c3]

if(c21 - c11 == c22 - c12 == c23 - c13 and c31 - c11 == c32 - c12 == c33 - c13 and c12 - c11 == c22 - c21 == c32 - c31 and c13 - c11 == c23 - c21 == c33 - c31 ):
    if(isinstance(c21 - c11, int) and isinstance(c31-c11, int) and isinstance(c22-c12, int) and isinstance(c32-c12, int) and isinstance(c23-c13, int) and isinstance(c33-c13, int) and isinstance(c12-c11, int) and isinstance(c13-c11, int) and isinstance(c22-c21, int) and isinstance(c23-c21, int) and isinstance(c32-c31, int) and isinstance(c33-c31, int) ):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
#金額
num = input().split()
firstList = list( map((lambda x:int(x)),num))
num = input().split()
secoundList = list( map((lambda x:int(x)),num))
num = input().split()
thirdList = list( map((lambda x:int(x)),num))

t = firstList + secoundList + thirdList

flag = 0

if (t[0]-t[3]) == (t[1]-t[4]) == (t[2]-t[5]):
    if (t[6]-t[3]) == (t[7]-t[4]) == (t[8]-t[5]):
        if (t[6]-t[0]) == (t[7]-t[1]) == (t[8]-t[2]):
            if (t[1]-t[0]) == (t[4]-t[3]) == (t[7]-t[6]):
                if (t[1]-t[2]) == (t[4]-t[5]) == (t[7]-t[8]):
                    if (t[0]-t[2]) == (t[3]-t[5]) == (t[6]-t[8]):
                        flag = 1

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

Submission status: Accepted

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

flag = 0
b = c[0]
for i in range(2):
   if (c[i+1][0]-b[0])==(c[i+1][1]-b[1])==(c[i+1][2]-b[2]):
      flag = flag+1

if flag == 2:
   print("Yes")

else:
   print("No")

Submission status: Accepted

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

ans = []
ans1 = [0, 0, 0]
for i in range(3):
    ans1 = [0, 0, 0]
    for j in range(3):
        ans1[j] = a[i]+b[j]
    ans.append(ans1)

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

Submission status: Accepted

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

ans = "Yes"
cnt = {i: [] for i in range(6)}
for i in range(3):
    for j in range(3):
        cnt[i].append(c[i][j] - c[(i + 1) % 3][j])
        cnt[i + 3].append(c[j][i] - c[j][(i + 1) % 3])
for ls in cnt.values():
    if min(ls) < max(ls):
        ans = "No"

print(ans)

Submission status: Accepted

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

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

A = c[1][1]-c[1][0]-s
B = c[1][2]-c[1][0]-t
C = c[2][1]-c[2][0]-s
D = c[2][2]-c[2][0]-t

if (A == 0) & (B == 0) & (C == 0) & (D == 0):
	print("Yes")
else:print("No")

Submission status: Accepted

Solution code:
grid = [[int(i) for i in input().split()] for i in range(3)] 
ans = "No"
for i in range(1,101):
    a1 = i
    b1 = grid[0][0] - a1
    b2 = grid[0][1] - a1
    b3 = grid[0][2] - a1
    a2 = grid[1][0] - b1
    a3 = grid[2][0] - b1
    res = 1
    if(a2 + b2 != grid[1][1]):
        res*=0
    if(a2 + b3 != grid[1][2]):
        res*=0
    if(a3 + b2 != grid[2][1]):
        res*=0
    if(a3 + b3 != grid[2][2]):
        res*=0
    if(res):
        ans = "Yes"
        break
print(ans)

Submission status: Accepted

Solution code:
def main():
    """
    0 <= c <= 100
    c(i,j) = a(i) + b(j)
    a: 整数 -> 負もあるのでc特定の数不明

    c1,1 = a1 + b1
    c1,2 = a1 + b2
    c1,3 = a1 + b3

    c2,1 = a2 + b1
    c2,2 = a2 + b2
    c2,3 = a2 + b3

    c3,1 = a3 + b1
    c3,2 = a3 + b2
    c3,3 = a3 + b3

    a or b だけの式にできる
    →等しいか試す
    """
    N = 3
    C = [
        tuple(map(int, input().split()))
        for _ in range(N)
    ]

    a = is_valid_a(C, N)
    if not a:
        print("No")
        return

    b = is_valid_b(C, N)
    if not b:
        print("No")
        return

    print("Yes")


def is_valid_a(C, N):
    """
    c1,1 - c2,1: a1 - a2
    c1,2 - c2,2: a1 - a2
    c1,3 - c2,3: a1 - a2
    --------------
    ci,1 - c(i+1),1: ai - a(i+1)
    ci,2 - c(i+1),2: ai - a(i+1)
    ci,3 - c(i+1),3: ai - a(i+1)
    """
    from itertools import combinations
    for x, y in combinations([0, 1, 2], 2):
        valid = C[x][0] - C[y][0] == C[x][1] - C[y][1] == C[x][2] - C[y][2]
        if not valid:
            return False

    return True


def is_valid_b(C, N):
    """
    c1,1 - c1,2: b1 - b2
    c1,2 - c1,3: b2 - b3
    c1,3 - c1,1: b3 - b1
    --------------
    ci,1 - ci,2: b1 - b2
    ci,2 - ci,3: b2 - b3
    ci,3 - ci,1: b3 - b1
    """
    b1_m_b2 = set()
    b2_m_b3 = set()
    b3_m_b1 = set()
    for i in range(N):
        b1_m_b2.add(C[i][0] - C[i][1])
        b2_m_b3.add(C[i][1] - C[i][2])
        b3_m_b1.add(C[i][2] - C[i][0])

    return len(b1_m_b2) == 1 and len(b2_m_b3) == 1 and len(b3_m_b1) == 1


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 'Yes'

for i in range(2):
    a0 = c[0][i] - c[0][i + 1]
    a1 = c[1][i] - c[1][i + 1]
    a2 = c[2][i] - c[2][i + 1]
    if not (a0 == a1 == a2):
        ans = 'No'
        break

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

C0=list(map(int,input().split()))
C1=list(map(int,input().split()))
C2=list(map(int,input().split()))
k=0
C=np.zeros(4)
for a1 in range(101):
    for b1 in range(101):
        if C0[0]==a1+b1:
            a1_solid=a1
            b1_solid=b1
            b2=C0[1]-a1_solid
            b3=C0[2]-a1_solid
            a2=C1[0]-b1_solid
            a3=C2[0]-b1_solid
            if C1[1]==a2+b2 and C1[2]==a2+b3 and C2[1]==a3+b2 and C2[2]==a3+b3 and k==0:
                print("Yes")
                k+=1
        if a1==99 and b1==99  and k==0:
                print("No")
                k+=1

Submission status: Accepted

Solution code:
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

ra=[p,q,r]

x=p[1]-p[0]
y=p[2]-p[0]



ans=[]

for n in range(1,3):
    if ra[n][1]-ra[n][0] == x and ra[n][2]-ra[n][0] == y:
        ans.append(True)
    else:
        ans.append(False)

if ans[0] and ans[1]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

flag = False
for i in range(101):
    a[0], b[0] = i, C[0][0] - i
    if a[0] < 0 or b[0] < 0:
        continue

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

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

    if min(a) < 0 or min(b) < 0:
        continue

    rec = True
    for j in range(3):
        for k in range(3):
            if a[j] + b[k] != C[j][k]:
                rec = False

    if rec:
        flag = True
        break


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

Submission status: Accepted

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

for i in range(100+1):
  a1 = c1[0] - i
  a2 = c2[0] - i
  a3 = c3[0] - i
  if c1[1] - a1 == c2[1] - a2 == c3[1] - a3 and c1[2] - a1 == c2[2] - a2 == c3[2] - a3:
    print('Yes')
    exit(0)
print('No')

Submission status: Accepted

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

#print(d)

for x in range(d[0]+1):
    for y in range(d[1]+1):
        for z in range(d[2]+1):
            for i in range(3):
                if(c[0][i]-x+1==c[1][i]-y+1):
                    if(c[1][i]-y+1==c[2][i]-z+1):
                        pass                        
                    else:
                        break
                else:
                    break
            else:
                print('Yes')
                exit()
else:
    print('No')

Submission status: Accepted

Solution code:
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
c=i2()
s="Yes"
b=[c[0]-c[1],c[1]-c[2]]
c=i2()
if not (b[0]==c[0]-c[1] and b[1]==c[1]-c[2]):s="No"
c=i2()
if not (b[0]==c[0]-c[1] and b[1]==c[1]-c[2]):s="No"
print(s)

Submission status: Accepted

Solution code:


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


a1=0

t21=[x-y for x,y in zip(c2,c1)]
t32=[x-y for x,y in zip(c3,c2)]
t31=[x-y for x,y in zip(c3,c1)]

tmp1=t21[0]
tmp2=t32[0]
tmp3=t31[0]


for i in range(1,3):
    if tmp1!=t21[i] or tmp2!=t32[i] or tmp3!=t31[i]:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

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

    a0_list = range(c[0][0]+1)

    for a0 in a0_list:
        b0 = c[0][0] - a0
        b1 = c[0][1] - a0
        b2 = c[0][2] - a0

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

        if c[1][1] != a1 + b1:
            continue
        if c[1][2] != a1 + b2:
            continue
        if c[2][1] != a2 + b1:
            continue
        if c[2][2] != a2 + b2:
            continue
        print("Yes")
        return

    print("No")
    return

solve()

Submission status: Accepted

Solution code:
import random
import numpy
import sys

grid=[[0 for i in range(3)] for j in range(3)]
a = [0 for i in range(3)]
b = [0 for i in range(3)]
testgrid = [[0 for i in range(3)] for j in range(3)]

grid[0]=list(map(int, input().split(" ")))
grid[1]=list(map(int, input().split(" ")))
grid[2]=list(map(int, input().split(" ")))

for a[0] in range(100):
  for b[0] in range(100):
    if (a[0]+b[0]) == grid[0][0]:
      testgrid[0][0] = a[0]+b[0]
      b[1] = grid[0][1]-a[0]
      b[2] = grid[0][2]-a[0]
      testgrid[0][1] = a[0]+b[1]
      testgrid[0][2] = a[0]+b[2]
      if testgrid[0] == grid[0]:
        a[1] = grid[1][0]-b[0]
        testgrid[1][0] = a[1]+b[0]
        testgrid[1][1] = a[1]+b[1]
        testgrid[1][2] = a[1]+b[2]
        if testgrid[1] == grid[1]:
          a[2] = grid[2][0]-b[0]
          testgrid[2][0] = a[2]+b[0]
          testgrid[2][1] = a[2]+b[1]
          testgrid[2][2] = a[2]+b[2]
          if testgrid == grid:
            print("Yes")
            exit()
print("No")

Submission status: Accepted

Solution code:
c = [[int(x) for x in input().split()] for _ in range(3)]
f = True
from itertools import product
for i,j in product(range(1,3), range(1,3)):
        if c[0][0]+c[i][j] != c[i][0]+c[0][j]:
            f = False
            break

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

Submission status: Accepted

Solution code:
c = [[int(_) for _ in input().split()] for i in range(3)]
ans = True
for x in range(2):
    c0 = c[x+1][0] - c[x][0]
    c1 = c[x+1][1] - c[x][1]
    c2 = c[x+1][2] - c[x][2]
    if c0 != c1 or c1 != c2 or c2 != c0:
        ans = False
for y in range(2):
    c0 = c[0][y+1] - c[0][y]
    c1 = c[1][y+1] - c[1][y]
    c2 = c[2][y+1] - c[2][y]
    if c0 != c1 or c1 != c2 or c2 != c0:
        ans = False
if(ans):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
c1, c2, c3 = map(int, input().split())
c4, c5, c6 = map(int, input().split())
c7, c8, c9 = map(int, input().split())

frag = 0
x = c4 - c1
y = c5 - c2
z = c6 - c3
if x != y or y != z:
    frag = 1
x = c4 - c7
y = c5 - c8
z = c6 - c9
if x != y or y != z:
    frag = 1
x = c2 - c1
y = c5 - c4
z = c8 - c7
if x != y or y != z:
    frag = 1
x = c2 - c3
y = c5 - c6
z = c8 - c9
if x != y or y != z:
    frag = 1
if frag == 1:
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

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

judge = 0
for i in range(0,101):
    a1 = i

    b1 = c11 - a1
    b2 = c12 - a1
    b3 = c13 - a1
    
    if c21 - b1 == c22 - b2 and c22 - b2 == c23 -b3:
        if c31 - b1 == c32 - b2 and c32 - b2 == c33 -b3:
            print("Yes")
            judge = 1
            break
        else:
            pass
    else:
        pass

if judge == 0:
    print("No")
else:
    pass

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
grid = [list(map(int,input().split())) for _ in range(3)]
a1 = min(grid[0])
a2 = min(grid[1])
a3 = min(grid[2])


flag = False

while True:
    if a1 < 0 or a2 < 0 or a3 < 0:
        break
    b1 = grid[0][0] - a1
    c1 = grid[1][0] - a2
    d1 = grid[2][0] - a3
    
    b2 = grid[0][1] - a1
    c2 = grid[1][1] - a2
    d2 = grid[2][1] - a3
    
    b3 = grid[0][2] - a1
    c3 = grid[1][2] - a2
    d3 = grid[2][2] - a3

    if b1 == c1 == d1 and b2 == c2 == d2 and b3 == c3 == d3:
        flag = True
        break
    a1 -= 1
    a2 -= 1
    a3 -= 1
    
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
row1 = input().split(' ')
row2 = input().split(' ')
row3 = input().split(' ')

index = []
index.append(row1)
index.append(row2)
index.append(row3)

a = [] 
b = []

Ans = 'Yes'
for j in range(2):
    for i in range(3):
        a.append(int(index[i][j]) - int(index[i][j+1]))
    if max(a) != min(a):   
        Ans = 'No'
    a = []

for i in range(2):
    for j in range(3):
        b.append(int(index[i][j]) - int(index[i+1][j]))
    if max(b) != min(b):   
        Ans = 'No'
    b = []
    
print(Ans)