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: Wrong Answer

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: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
c = [[int(x) for x in input().split()] for _ in range(3)]
f = True
for i, j in zip(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: Wrong Answer

Solution code:
rows = []
for _ in range(3):
  rows.append(list(map(int, input().split())))
for i in range(3):
  for j in range(3):
    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: Time Limit Exceeded

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

# worst order: 101^6 => 10^8

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

    return flag

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

arr_c = np.array(c)
a_max = np.amax(arr_c, axis=1)
b_max = np.amax(arr_c, axis=0)

a = []
b = []
for i in range(3):
    if len(list(range(0, a_max[i]+1, 1)))==0:
        a.append([0])
    else:
        a.append(list(range(0, a_max[i]+1, 1)))
    
    if len(list(range(0, b_max[i]+1, 1)))==0:
        b.append([0])
    else:
        b.append(list(range(0, b_max[i]+1, 1)))

ans = 'No'
cnt = 0
for a0 in a[0]:
    for a1 in a[1]:
        for a2 in a[2]:
            for b0 in b[0]:
                for b1 in b[1]:
                    for b2 in b[2]:
                        a_list = [a0, a1, a2]
                        b_list = [b0, b1, b2]
                        flag = check(a_list, b_list, c)
                        if flag == True:
                            print("Yes")
                            exit(0)

print(ans)

Submission status: Time Limit Exceeded

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

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

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

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

Submission status: Time Limit Exceeded

Solution code:
c=[0]*3
c_max=0
for i in range(3):
    c[i]=list(map(int,input().split()))
    c_max=max(c_max,max(c[i]))
c_max+=1
for a1 in range(c_max):
    for a2 in range(c_max):
        for a3 in range(c_max):
            for b1 in range(c_max):
                for b2 in range(c_max):
                    for b3 in range(c_max):
                        if a1+b1==c[0][0] and a1+b2==c[0][1] and a1+b3==c[0][2] and a2+b1==c[1][0] and a2+b2==c[1][1] and a2+b3==c[1][2] and a3+b1==c[2][0] and a3+b2==c[2][1] and a3+b3==c[2][2]:
                            print('Yes')
                            exit()
print('No')

Submission status: Time Limit Exceeded

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

I = max(c[0:3]) + 1
J = max(c[3:6]) + 1
K = max(c[6:9]) + 1
L = max(c[0], c[3], c[6]) + 1
M = max(c[1], c[4], c[7]) + 1
N = max(c[2], c[5], c[8]) + 1

for i in range(I):
    for j in range(J):
        for k in range(K):
            for l in range(L):
                for m in range(M):
                    for n in range(N):
                        if c[0] == i + l and c[1] == i + m and c[2] == i + n and c[3] == j + l and c[4] == j + m and c[5] == j + n and c[6] == k + l and c[7] == k + m and c[8] == k + n:
                            print('Yes')
                            exit()
print('No')

Submission status: Time Limit Exceeded

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

max_c = max(c) + 1

for i in range(max_c):
    for j in range(max_c):
        for k in range(max_c):
            for l in range(max_c):
                for m in range(max_c):
                    for n in range(max_c):
                        if c[0] == i + l and c[1] == i + m and c[2] == i + n and c[3] == j + l and c[4] == j + m and c[5] == j + n and c[6] == k + l and c[7] == k + m and c[8] == k + n:
                            print('Yes')
                            exit()
print('No')

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
Num = np.zeros((3,3),dtype=int)
for T in range(0,3):
    Num[T,:] = np.array([int(X) for X in input().split()])
               
Flag = False
MIN  = [min(Num[X,:]) for X in range(0,3)]+[min(Num[:,X]) for X in range(0,3)]
for R1 in range(MIN[0]+1):
    for R2 in range(MIN[1]+1):
        for R3 in range(MIN[2]+1):
            for C1 in range(MIN[3]+1):
                for C2 in range(MIN[4]+1):
                    for C3 in range(MIN[5]+1):
                        Sum = np.array([[R1+C1,R1+C2,R1+C3],[R2+C1,R2+C2,R2+C3],[R3+C1,R3+C2,R3+C3]])
                        if np.all(Sum==Num):
                            Flag = True
if Flag:
    print('Yes')
else:
    print('No')

Submission status: Time Limit Exceeded

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

maxNum = max(max(c))
for i in product(range(maxNum+1),repeat=3):
  if max(i) > maxNum: continue
  for x in range(maxNum+1):
    row1 = (i[0]+x,i[1]+x,i[2]+x)
    if row1 == c[0]:
      for y in range(maxNum+1):
        row2 = (i[0]+y,i[1]+y,i[2]+y)
        if row2 == c[1]:
          for z in range(maxNum+1):
            row3 = (i[0]+z,i[1]+z,i[2]+z)
            if row3 == c[2]:
              print("Yes")
              exit()
print("No")

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
from itertools import product
import sys
read = sys.stdin.buffer.read


C = np.array(read().split(), np.int32).reshape(3, 3)
i, j, k = np.max(C + 1, axis=1)
flag = 0
for i, j, k in product(range(i), range(j), range(k)):
    x = C[0, :] - i
    y = C[1, :] - j
    z = C[2, :] - k

    if np.all((x == y) & (y == z)):
        flag = 1
        break

print(['No', 'Yes'][flag])

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
import numpy as np
c = [[int(x) for x in input().split()] for _ in range(3)]

c = np.array(c)

for i in range(101):
    for j in range(101):
        for k in range(101):
            if (c[0] - i == c[1] - j).all() and (c[1] - j == c[2] - k).all():
                print("Yes")
                sys.exit()
print("No")

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

c = [[0]*3] * 3

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

c = np.array(c)

flg = False
for j in range(101):
    if (c[0] - j < 0).sum() >= 1:
        continue
    for k in range(101):
        if (c[1] - k < 0).sum() >= 1:
            continue
        for l in range(101):
            if (c[2] - l < 0).sum() >= 1:
                continue
            if (c[0] - j == c[1] - k).sum() == 3 and (c[1] - k == c[2] - l).sum() == 3:
                flg = True
                break

if flg:
    for j in range(101):
        if (c[:,0] - j < 0).sum() >= 1:
            continue
        for k in range(101):
            if (c[:, 1] - k < 0).sum() >= 1:
                continue
            for l in range(101):
                if (c[:, 2] - l < 0).sum() >= 1:
                    continue
                if (c[:, 0] - j == c[:,1] - k).sum() == 3 and (c[:,1] - k == c[:,2] - l).sum() == 3:
                    print("Yes")
                    exit()

print("No")

Submission status: Time Limit Exceeded

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

for i in range(101):
    for j in range(101):
        if i + j > c1[0]:
            break
        for k in range(101):
            if k + j > c2[0]:
                break
            for l in range(101):
                if i + l > c1[1] or k + l > c2[1]:
                    break
                for m in range(101):
                    if m + j > c3[0] or m + l > c3[1]:
                        break
                    for n in range(101):
                        if i + n > c1[2] or k + n > c2[2] or m + n > c3[2]:
                            break
                        if i + j == c1[0] and i + l == c1[1] and i + n == c1[2] and k + j == c2[0] and k + l == c2[1] and k + n == c2[2] and m + j == c3[0] and m + l == c3[1] and m + n == c3[2]:
                            print('Yes')
                            exit()
print('No')

Submission status: Time Limit Exceeded

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

for i in range(101):
    for j in range(101):
        for k in range(101):
            for l in range(101):
                if i + l > c1[0] or j + l > c2[0] or k + l > c3[0]:
                    break
                for m in range(101):
                    if i + m > c1[1] or j + m > c2[1] or k + m > c3[1]:
                        break
                    for n in range(101):
                        if i + n > c1[2] or j + n > c2[2] or k + n > c3[2]:
                            break
                        if i + l == c1[0] and i + m == c1[1] and i + n == c1[2] and j + l == c2[0] and j + m == c2[1] and j + n == c2[2] and k + l == c3[0] and k + m == c3[1] and k + n == c3[2]:
                            print('Yes')
                            exit()
print('No')

Submission status: Time Limit Exceeded

Solution code:
def resolve():
	g = [list(map(int, input().split())) for _ in range(3)]
	t = [[None]*3 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):
				for d in range(m+1):
					for e in range(m+1):
						for f in range(m+1):
							y = [a, b, c]
							x = [d, e, f]
							ans = True
							for i in range(3):
								for j in range(3):
									if g[i][j] != y[i] + x[j]:
										ans = False
							if ans:
								print('Yes')
								return
	print('No')
resolve()

Submission status: Time Limit Exceeded

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):
            for d in range(0,101):
                for e in range(0,101):
                    for f in range(0,101):
                        a1 = f
                        a2 = e
                        a3 = d
                        b1 = c
                        b2 = b
                        b3 = a
                        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: Time Limit Exceeded

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

tmp = []
for m in range(3):
    c_total = 0
    for n in range(3):
        c_total += c_list[m][n]

    for an in range(101):
        for b1 in range(c_total - 3 * an + 1):
            for b2 in range(c_total - 3 * an - b1 + 1):
                b3 = c_total - 3 * an - b1 - b2
                # print("c_total:", c_total, "an:", an, "b1:", b1, "b2:", b2, "b3:", b3)
                tmp.append([b1, b2, b3])
# 同じ配列が３つあれば条件を満たす。
flag = False
for t in tmp:
    if tmp.count(t) == 3:
        flag = True

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

Submission status: Time Limit Exceeded

Solution code:
# c_00 c_01 c_02
# c_10 c_11 c_12
# c_20 c_21 c_22
# a_0+b_0 a_0+b_1 a_0+b_2
# a_1+b_0 a_2+b_2 a_1+b_2
# a_2+b_0 a_2+b_1 a_2+b_2

c_0 = list(map(int, input().split()))
c_1 = list(map(int, input().split()))
c_2 = list(map(int, input().split()))
c = [c_0,c_1,c_2]

for a_0 in range(100+1):
    for a_1 in range(100+1):
        for a_2 in range(100+1):
            b_0 = c[0][0] - a_0
            b_1 = c[0][1] - a_0
            b_2 = c[0][2] - a_0

            a = [a_0,a_1,a_2]
            b = [b_0,b_1,b_2]
            flag = True
            for i in range(3):
                for j in range(3):
                    if c[i][j] == a[i] + b[j]:
                        continue
                    else:
                        flag = False
            if flag:
                print('Yes')
                exit()
print('No')

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
L = []
for _ in range(3) :
  L.append(list(map(int, input().split())))

a = []
b = []

a.append(max(L[0]))
a.append(max(L[1]))
a.append(max(L[2]))

b.append(max(L[0][0], L[1][0], L[2][0]))
b.append(max(L[0][1], L[1][1], L[2][1]))
b.append(max(L[0][2], L[1][2], L[2][2]))

for a1 in range(a[0]+1) :
  for a2 in range(a[1]+1) :
    for a3 in range(a[2]+1) :
      for b1 in range(b[0]+1) :
        for b2 in range(b[1]+1) :
          for b3 in range(b[2]+1) :
            if a1+b1 == L[0][0] :
              if a2+b1 == L[1][0] :
                if a3+b1 == L[2][0] :
                  if a1+b2 == L[0][1] :
                    if a2+b2 == L[1][1] :
                      if a3+b2 == L[2][1] :
                        if a1+b3 == L[0][2] :
                          if a2+b3 == L[1][2] :
                            if a3+b3 == L[2][2] :
                              print ("Yes")
                              exit()
print ("No")

Submission status: Time Limit Exceeded

Solution code:
c=[[int(i) for i in input().split()] for j in range(3)]
ans='No'
for x in range(101):
  for y in range(101):
    for z in range(101):
      d=[]
      d.append([c[0][j]-x for j in range(3)])
      d.append([c[1][j]-y for j in range(3)])
      d.append([c[2][j]-z for j in range(3)])
      if sum(len(set(d[i][j] for i in range(3))) for j in range(3))==3:
             ans='Yes'
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def checker(ded, da):
  for i in range(3):
    for j in range(2):
      if da[i][j] - ded[j] != da[i][2] - ded[2]:
        return False
  return True

def ma(da):
  for i in range(-100, 101):
    for j in range(-100, 101):
      for k in range(-100, 101):
        if checker([i, j, k], da):
          return False
  return True

da = [list(map(int,input().split())) for i in range(3)]
if not ma(da):
  print('Yes')
else:
  print('No')

Submission status: Time Limit Exceeded

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

for a1 in range(max(c[0][0], c[0][1], c[0][2]) + 1):
    for a2 in range(max(c[1][0], c[1][1], c[1][2]) + 1):
        for a3 in range(max(c[2][0], c[2][1], c[2][2]) + 1):
            for b1 in range(max(c[0][0], c[1][0], c[2][0]) + 1):
                for b2 in range(max(c[0][1], c[1][1], c[2][1]) + 1):
                    for b3 in range(max(c[0][2], c[1][2], c[2][2]) + 1):
                        if a1 + b1 == c[0][0] and \
                           a1 + b2 == c[0][1] and \
                           a1 + b3 == c[0][2] and \
                           a2 + b1 == c[1][0] and \
                           a2 + b2 == c[1][1] and \
                           a2 + b3 == c[1][2] and \
                           a3 + b1 == c[2][0] and \
                           a3 + b2 == c[2][1] and \
                           a3 + b3 == c[2][2]:
                            print('Yes')
                            exit()
print('No')

Submission status: Time Limit Exceeded

Solution code:
c = []
for i in range(3):
    c.append([int(c) for c in input().split(' ')])
result = 'No'
for a1 in range(0, 201):
    for a2 in range(0, 201):
        for a3 in range(0, 201):
            if ((a1 - a2 == c[0][0]+c[0][1]+c[0][2]
            - c[1][0]- c[1][1] - c[1][2])
             and (a1-a3 == c[0][0]+c[0][1]+c[0][2]
             -c[2][0]- c[2][1] - c[2][2])
             and (a2 - a3 == c[1][0]+ c[1][1] + c[1][2]
             - c[2][0] - c[2][1] - c[2][2]
             )):
                result = 'Yes'
                break
print(result)

Submission status: Time Limit Exceeded

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

    r1max = max([c11, c12, c13])
    r2max = max([c21, c22, c23])
    r3max = max([c31, c32, c33])
    c1max = max([c11, c21, c31])
    c2max = max([c12, c22, c32])
    c3max = max([c13, c23, c33])
    for a1 in range(0, r1max + 1):
        for a2 in range(0, r2max + 1):
            for a3 in range(0, r3max + 1):
                for b1 in range(0, c1max + 1):
                    C11 = a1 + b1
                    C21 = a2 + b1
                    C31 = a3 + b1
                    if C11 == c11 and C21 == c21 and C31 == c31:
                        for b2 in range(0, c2max + 1):
                            C12 = a1 + b2
                            C22 = a2 + b2
                            C32 = a3 + b2
                            if C12 == c12 and C22 == c22 and C32 == c32:
                                for b3 in range(0, c3max + 1):
                                    C13 = a1 + b3
                                    C23 = a2 + b3
                                    C33 = a3 + b3
                                    if C13 == c13 and C23 == c23 and C33 == c33:
                                        print('Yes')
                                        return

    print('No')
    return


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

    r1max = max([c11, c12, c13])
    for a1 in range(0, r1max + 1):
        r2max = max([c21, c22, c23])
        for a2 in range(0, r2max + 1):
            r3max = max([c31, c32, c33])
            for a3 in range(0, r3max + 1):
                m = max([a1, a2, a3])
                for b1 in range(0, 101 - m):
                    C11 = a1 + b1
                    C21 = a2 + b1
                    C31 = a3 + b1
                    if C11 == c11 and C21 == c21 and C31 == c31:
                        for b2 in range(0, 101 - m):
                            C12 = a1 + b2
                            C22 = a2 + b2
                            C32 = a3 + b2
                            if C12 == c12 and C22 == c22 and C32 == c32:
                                for b3 in range(0, 101 - m):
                                    C13 = a1 + b3
                                    C23 = a2 + b3
                                    C33 = a3 + b3
                                    if C13 == c13 and C23 == c23 and C33 == c33:
                                        print('Yes')
                                        return

    print('No')
    return


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

    for a1 in range(0, 101):
        for a2 in range(0, 101):
            for a3 in range(0, 101):
                m = max([a1, a2, a3])
                for b1 in range(0, 101 - m):
                    C11 = a1 + b1
                    C21 = a2 + b1
                    C31 = a3 + b1
                    if C11 > 100 or C21 > 100 or C31 > 100:
                        break
                    if C11 == c11 and C21 == c21 and C31 == c31:
                        for b2 in range(0, 101 - m):
                            C12 = a1 + b2
                            C22 = a2 + b2
                            C32 = a3 + b2
                            if C12 > 100 or C22 > 100 or C32 > 100:
                                break
                            if C12 == c12 and C22 == c22 and C32 == c32:
                                for b3 in range(0, 101 - m):
                                    C13 = a1 + b3
                                    C23 = a2 + b3
                                    C33 = a3 + b3
                                    if C13 > 100 or C23 > 100 or C33 > 100:
                                        break
                                    if C13 == c13 and C23 == c23 and C33 == c33:
                                        print('Yes')
                                        return

    print('No')
    return


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

    for a1 in range(0, 101):
        for a2 in range(0, 101):
            for a3 in range(0, 101):
                for b1 in range(0, 101):
                    C11 = a1 + b1
                    C21 = a2 + b1
                    C31 = a3 + b1
                    if C11 > 100 or C21 > 100 or C31 > 100:
                        break
                    if C11 == c11 and C21 == c21 and C31 == c31:
                        for b2 in range(0, 101):
                            C12 = a1 + b2
                            C22 = a2 + b2
                            C32 = a3 + b2
                            if C12 > 100 or C22 > 100 or C32 > 100:
                                break
                            if C12 == c12 and C22 == c22 and C32 == c32:
                                for b3 in range(0, 101):
                                    C13 = a1 + b3
                                    C23 = a2 + b3
                                    C33 = a3 + b3
                                    if C13 > 100 or C23 > 100 or C33 > 100:
                                        break
                                    if C13 == c13 and C23 == c23 and C33 == c33:
                                        print('Yes')
                                        return

    print('No')
    return


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

flag = False
m = max(c1) + 1

for a1 in range(m):
    for a2 in range(m):
        for a3 in range(m):
            for b1 in range(m):
                for b2 in range(m):
                    for b3 in range(m):
                        p = a1 + b1 == c1[0] and a1 + b2 == c1[1] and a1 + b3 == c1[2] and a2 + b1 == c1[3] and a2 + b2 == c1[4] and a2 + b3 == c1[5] and a3 + b1 == c1[6] and a3 + b2 == c1[7] and a3 + b3 == c1[8]
                        if p:
                            flag = True

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

Submission status: Time Limit Exceeded

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

    for a1 in range(101):
        for a2 in range(101):
            for a3 in range(101):
                b1 = c[0][0] - a1
                b2 = c[0][1] - a1
                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
                if flag:
                    print("Yes")
                    return
    print("No")

main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import itertools
a1row = np.array(list(map(int,input().split())))
a2row = np.array(list(map(int,input().split())))
a3row = np.array(list(map(int,input().split())))
flag = 'No'
L = list(range(0,101))
for a1,a2,a3 in itertools.product(L,L,L):
    if all(a1row - a1 == a2row - a2) and all(a2row - a2 == a3row - a3):
        flag = 'Yes'
        break
print(flag)

Submission status: Time Limit Exceeded

Solution code:
c = [list(map(int,input().split())) for i in range(3)]
for i in range(-101,101):
  for j in range(-101,101):
    for k in range(-101,101):
      a = [i,j,k]
      b = [c[0][0] - a[0] ,c[1][1] - a[1], c[2][2] - a[2]]
      flag = 0
      for x in range(3):
        for y in range(3):
          if a[x]+b[y] != c[x][y]:
            flag = 1
      if flag == 0:
        print("Yes")
        exit()
print("No")

Submission status: Time Limit Exceeded

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

bi_list = []
for b1 in range(-500000, 500000):
    b2 = b1 - (cij[0][0] - cij[0][1])
    b3 = b1 - (cij[0][0] - cij[0][2])

    a1 = cij[0][0]+cij[0][1]+cij[0][2] -b1-b2-b3
    a2 = cij[1][0]+cij[1][1]+cij[1][2] -b1-b2-b3
    a3 = cij[2][0]+cij[2][1]+cij[2][2] -b1-b2-b3
    if a1/3+b1 ==cij[0][0] and a1/3+b2 ==cij[0][1] and a1/3+b3 ==cij[0][2] and a2/3+b1 ==cij[1][0] and a2/3+b2 ==cij[1][1] and a2/3+b3 ==cij[1][2] and a3/3+b1 ==cij[2][0] and a3/3+b2 ==cij[2][1] and a3/3+b3 ==cij[2][2]:
            print("Yes")
            exit()

print("No")

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!


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


for i in range(min(S[0][0]+1,S[0][1]+1,S[0][2]+1)):
    for j in range(min(S[1][0]+1,S[1][1]+1,S[1][2]+1)): 
        for k in range(min(S[2][0]+1,S[2][1]+1,S[2][2]+1)): 
            for l in range(min(S[0][0]+1,S[1][0]+1,S[2][0]+1)): 
                for m in range(min(S[0][1]+1,S[1][1]+1,S[2][1]+1)): 
                    for n in range(min(S[0][2]+1,S[1][2]+1,S[2][2]+1)): 
                        if S[0][0]==i+l and S[1][0]==j+l and S[2][0]==k+l and S[0][1]==i+m and S[1][1]==j+m and S[2][1]==k+m and S[0][2]==i+n and S[1][2]==j+n and S[2][2]==k+n :
                            print("Yes")
                            
                            exit()
print("No")

Submission status: Time Limit Exceeded

Solution code:
c = [list(map(int, input().split())) for _ in range(3)]
ok = False
for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            b1 = c[0][0] - a1
            b2 = c[0][1] - a1
            b3 = c[0][2] - a1
            a = [a1, a2, a3]
            b = [b1, b2, b3]
            ok_sub = True
            for i in range(3):
                for j in range(3):
                    if a[i] + b[j] != c[i][j]:
                        ok_sub = False
            if ok_sub:
                ok = True

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

Submission status: Time Limit Exceeded

Solution code:
table=[]
a=[9999,9999,9999]
b=[9999,9999,9999]
for i in range(3):
    table.append(list(map(int,input().split())))
    a[i]=min(table[-1])
    for j in range(3):
        b[j]=min(b[j],table[-1][j])
for q in range(a[0]+1):
    for w in range(a[1]+1):
        for e in range(a[2]+1):
            for r in range(b[0]+1):
                for t in range(b[1]+1):
                    for y in range(b[2]+1):
                        #print(q,w,e,r,t,y)
                        if q+r==table[0][0] and \
                        q+t==table[0][1] and \
                        q+y==table[0][2] and \
                        w+r==table[1][0] and \
                        w+t==table[1][1] and \
                        w+y==table[1][2] and \
                        e+r==table[2][0] and \
                        e+t==table[2][1] and \
                        e+y==table[2][2]:
                            print('Yes')
                            exit()
print('No')

Submission status: Time Limit Exceeded

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())
    for i in range(-100, 101):
        b = [c[0][0] - i]
        for j in range(-100, 101):
            b.append(c[1][1] - j)
            for k in range(-100, 101):
                b.append(c[2][2] - k)
                a = (i, j, k)
                flg = False
                for l in range(3):
                    for m in range(3):
                        if l != m and a[l] + b[m] != c[l][m]:
                            flg = True
                            break
                    if flg == True:
                        break
                else:
                    print('Yes')
                    sys.exit()
    else:
        print('No')

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def c_takahashi_information(C):
    a = []
    b = []
    for a_0 in range(min(C[0]) + 1):
        for a_1 in range(min(C[1]) + 1):
            for a_2 in range(min(C[2]) + 1):
                tmp1 = [a_0, a_1, a_2]
                tmp2 = [[C[i][j] - tmp1[i]
                         for j in range(3)] for i in range(3)]
                tmp2 = list(map(list,set(map(tuple, tmp2))))
                a.append(tmp1)
                b.append(tmp2)
    for aa, bb in zip(a, b):
        for bbb in bb:
            f = True
            for i in range(3):
                for j in range(3):
                    if aa[i] + bbb[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))