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:
import numpy as np
array = np.zeros((3, 3), dtype="int8")
for i in range(3):
    array[i, :] = np.array([int(x) for x in input().split()])
    
b_1 = array[0, 0]
b_2 = array[0, 1]
b_3 = array[0, 2]
a_2 = array[1, 0] - b_1
a_3 = array[2, 0] - b_1
if array[1, 1] != (a_2 + b_2):
    flag = 0
elif array[2, 2] != (a_3 + b_3):
    flag = 0
else:
    flag = 1

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

Submission status: Wrong Answer

Solution code:
import numpy as np
array = np.zeros((3, 3), dtype="int8")
for i in range(3):
    array[i, :] = np.array([int(x) for x in input().split()])
    
flag = 0
for a_1 in range(-10000, 10000):
    b_1 = array[0, 0] - a_1
    b_2 = array[0, 1] - a_1
    b_3 = array[0, 2] - a_1
    a_2 = array[1, 0] - b_1
    a_3 = array[2, 0] - b_1
    if array[1, 1] != (a_2 + b_2):
        continue
    if array[2, 2] != (a_3 + b_3):
        continue
    flag = 1
    break
    
if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
array = np.zeros((3, 3), dtype="int8")
for i in range(3):
    array[i, :] = np.array([int(x) for x in input().split()])
    
flag = 0
for a_1 in range(-1000, 1000):
    b_1 = array[0, 0] - a_1
    b_2 = array[0, 1] - a_1
    b_3 = array[0, 2] - a_1
    a_2 = array[1, 0] - b_1
    a_3 = array[2, 0] - b_1
    if array[1, 1] != (a_2 + b_2):
        continue
    if array[2, 2] != (a_3 + b_3):
        continue
    flag = 1
    break
    
if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
array = np.zeros((3, 3), dtype="int8")
for i in range(3):
    array[i, :] = np.array([int(x) for x in input().split()])
    
flag = 0
for a_1 in range(-100, 100):
    b_1 = array[0, 0] - a_1
    b_2 = array[0, 1] - a_1
    b_3 = array[0, 2] - a_1
    a_2 = array[1, 0] - b_1
    a_3 = array[2, 0] - b_1
    if array[1, 1] != (a_2 + b_2):
        continue
    if array[2, 2] != (a_3 + b_3):
        continue
    flag = 1
    break
    
if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
array = np.zeros((3, 3), dtype="int8")
for i in range(3):
    array[i, :] = np.array([int(x) for x in input().split()])
    
flag = 0
for a_1 in range(0, array[0, 0]):
    b_1 = array[0, 0] - a_1
    b_2 = array[0, 1] - a_1
    b_3 = array[0, 2] - a_1
    a_2 = array[1, 0] - b_1
    a_3 = array[2, 0] - b_1
    if array[1, 1] != (a_2 + b_2):
        continue
    if array[2, 2] != (a_3 + b_3):
        continue
    flag = 1
    break
    
if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin
from itertools import combinations
from math import factorial
import numpy as np

li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(3)]

point = 0
zero = 0

for i in li:
    point += sum(i)
    zero += i.count(0)

lin = np.asarray(li).T.tolist()

for i in range(3):
    if li[i].count(0)%3 != 0 and lin[i].count(0)%3 != 0:
        print("No")
        exit()

if point % 3 == 0:
    print("Yes")
    exit()

print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin
from itertools import combinations
from math import factorial

li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(3)]

point = 0
zero = 0
for i in li:
    point += sum(i)
    zero += i.count(0)

if point%3==0 and zero%3==0:
    print("Yes")
    exit()

print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin
from itertools import combinations
from math import factorial

li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(3)]

point = 0
for i in li:
    point += sum(i)
"""
if point%3==0:
    print("Yes")
    exit()
"""
print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin
from itertools import combinations
from math import factorial

li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(3)]

point = 0
for i in li:
    point += sum(i)

if point%3==0:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
def main():
    c=[list(map(int,input().split())) for i in range(3)]
    a=[0,0,0]
    b=[0,0,0]
    for i in range(1,101):
        a[0]=i
        a[1]=-1
        a[2]=-1
        b[0]=c[0][0]-a[0]
        b[1]=c[0][1]-a[0]
        b[2]=c[0][2]-a[0]
        for j in range(1,3):
            if c[j][0]-b[0]!=c[j][1]-b[1] or c[j][1]-b[1]!=c[j][2]-b[2]:
                break
            a[j]=c[j][0]-b[0]
            if j == 2 and check(a,b):

                print('Yes')
                return
    print('No')

def check(a,b):
    for i in range(0,3):
        if a[i] > 0 and b[i] > 0 :
            continue
        else:
            return False
    return True

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    c=[list(map(int,input().split())) for i in range(3)]
    a=[0,0,0]
    b=[0,0,0]
    for i in range(1,101):
        a[0]=i
        a[1]=-1
        a[2]=-1
        b[0]=c[0][0]-a[0]
        b[1]=c[0][1]-a[0]
        b[2]=c[0][2]-a[0]
        for j in range(1,3):
            if c[j][0]-b[0]!=c[j][1]-b[1] or c[j][1]-b[1]!=c[j][2]-b[2]:
                break
            a[j]=c[j][0]-b[0]
            if j == 2:
                print('YES')
                return
    print('NO')

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
lst=[]
for i in range(3):
  a,b,c=map(int,input().split())
  lst.append([a,b,c])
for i in range(2):
  if (lst[i][1]-lst[i][0])!=(lst[i+1][1]-lst[i+1][0]) or (lst[1][i]-lst[0][i])!=(lst[1][i+1]-lst[0][i+1]):
    print('No')
    sys.exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
lst=[]
for i in range(3):
  a,b,c=map(int,input().split())
  lst.append([a,b,c])
for i in range(3):
  if (lst[i][1]-lst[i][0])!=(lst[i][2]-lst[i][1]) or (lst[1][i]-lst[0][i])!=(lst[2][i]-lst[1][i]):
    print('No')
    sys.exit()
print('Yes')

Submission status: Wrong Answer

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

def func(x):
    import sys
    a = [0]*3
    b = [0]*3
    a = [x[0][i] for i in range(3)]
    b = [x[i][0]-a[0] for i in range(3)]

    for i in range(3):
        for j in range(3):
            if a[j] + b[i] != c[i][j]:
                print("No")
                sys.exit()
    print("yes")

func(c)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


  
for i in range(101):
  info=True
  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 min(a1,a2,a3,b1,b2,b3)<0:
    info=False
  if c[1][1]!=a2+b2:
    info=False
  if c[2][1]!=a3+b2:
    info=False
  if c[2][1]!=a2+b3:
    info=False
  if c[2][2]!=a3+b3:
    info=False
  
  if info:
    print("Yes")
    break
else:
  print("No")

Submission status: Wrong Answer

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


  
for i in range(101):
  info=True
  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 min(a1,a2,a3,b1,b2,b3)<0:
    info=False
  if c[1][1]!=a2+b2:
    info=False
  if c[2][1]!=a3+b2:
    info=False
  if info:
    print("Yes")
    break
else:
  print("No")

Submission status: Wrong Answer

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

info=True

for i in range(101):
  a1=i
  b1=c[0][0]-a1
  b2=c[0][1]-a1
  b3=c[0][2]-a1
  a2=c[1][0]-b1
  a3=c[2][0]-b1
  if min(a1,a2,a3,b1,b2,b3)<0:
    info=False
  if c[1][1]!=a2+b2:
    info=False
  if c[2][1]!=a3+b2:
    info=False
  if info:
    print("Yes")
    break
else:
  print("No")

Submission status: Wrong Answer

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

info=True

for i in range(101):
  a1=i
  b1=c[0][0]-a1
  b2=c[0][1]-a1
  b3=c[0][2]-a1
  s=c[1][0]-b1
  t=c[1][1]-b2
  a2=s
  if s!=t:
    info=False
    break
  u=c[2][0]-b1
  v=c[2][1]-b2
  a3=u
  if u!=v:
    info=False
    break
  if min(a1,a2,a3,b1,b2,b3)<0:
    info=False
    break
  info=True

if info:
  print("Yes")
  #print(a1,a2,a3,b1,b2,b3)
else:
  print("No")

Submission status: Wrong Answer

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

info=True

for i in range(101):
  a1=i
  b1=c[0][0]-a1
  b2=c[0][1]-a1
  b3=c[0][2]-a1
  s=c[1][0]-b1
  t=c[1][1]-b2
  a2=s
  if s!=t:
    info=False
    break
  u=c[2][0]-b1
  v=c[2][1]-b2
  a3=u
  if u!=v:
    info=False
    break
  if min(a1,a2,a3,b1,b2,b3)<0:
    info=False
    break
  info=True

if info:
  print("Yes")
  print(a1,a2,a3,b1,b2,b3)
else:
  print("No")

Submission status: Wrong Answer

Solution code:
if sum([ sum(list(map(int, input().split()))) for _ in range(3) ]) % 3:
  print("No")
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
c=[[0]*3]*3
f=0
for i in range(3):
    c[i]= list(map(int, input().split()))
for b1 in range(100):
    for b2 in range(100):
        for b3 in range(100):
            a1= [c[0][0]-b1, c[0][1]-b2,c[0][2]-b3]
            a2=  [c[1][0]-b1, c[1][1]-b2,c[1][2]-b3]
            a3=[c[2][0]-b1, c[2][1]-b2,c[2][2]-b3]
            if not a1[0]==a1[1]==a1[2]:
                continue
            elif not a2[0]==a2[1]==a2[2]:
                continue
            elif not a3[0]==a3[1]==a3[2]:
                continue
            else:
                print('Yes')
                f+=1
                break
        if f==1:
            break
    if f==1:
        break
if f==0:
    print('No')

Submission status: Wrong Answer

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

c = c1 + c2 + c3

if sum(c) % 3 == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
c=[]
for _ in range(3):
  c.append(list(map(int,input().split())))
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]:
    print('No')
    exit()
  if c[0][i]-c[0][i+1]!=c[1][i]-c[1][i+1]!=c[2][i]-c[2][i+1]:
    print('No')
    exit()
print('Yes')

Submission status: Wrong Answer

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

a=[0]*3
b=[0]*3

a[0]=min(c1[0],c1[1],c1[2])
a[1]=min(c2[0],c2[1],c2[2])
a[2]=min(c3[0],c3[1],c3[2])

b[0]=min(c1[0],c2[0],c3[0])
b[1]=min(c1[1],c2[1],c3[1])
b[2]=min(c1[2],c2[2],c3[2])


d1=[0]*3
d2=[0]*3
d3=[0]*3

for i in range(3):
    d1[i]=a[0]+b[i]
    d2[i]=a[1]+b[i]
    d3[i]=a[2]+b[i]

A=[0]*3
B=[0]*3
A[0]=min(d1[0]-c1[0],d1[1]-c1[1],d1[2]-c1[2])
A[1]=min(d2[0]-c2[0],d2[1]-c2[1],d2[2]-c2[2])
A[2]=min(d3[0]-c3[0],d3[1]-c3[1],d3[2]-c3[2])

B[0]=min(d1[0]-c1[0],d2[0]-c2[0],d3[0]-c3[0])
B[1]=min(d1[1]-c1[1],d2[1]-c2[1],d3[1]-c3[1])
B[2]=min(d1[2]-c1[2],d2[2]-c2[2],d3[2]-c3[2])


##print(c1,c2,c3)
if(max(A,B)==min(A,B)):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

a=[0]*3
b=[0]*3

a[0]=min(c1[0],c1[1],c1[2])
a[1]=min(c2[0],c2[1],c2[2])
a[2]=min(c3[0],c3[1],c3[2])

b[0]=min(c1[0],c2[0],c3[0])
b[1]=min(c1[1],c2[1],c3[1])
b[2]=min(c1[2],c2[2],c3[2])


d1=[0]*3
d2=[0]*3
d3=[0]*3

for i in range(3):
    d1[i]=a[0]+b[i]
    d2[i]=a[1]+b[i]
    d3[i]=a[2]+b[i]

A=[0]*3
B=[0]*3
A[0]=min(d1[0]-c1[0],d1[1]-c1[1],d1[2]-c1[2])
A[1]=min(d2[0]-c2[0],d2[1]-c2[1],d2[2]-c2[2])
A[2]=min(d3[0]-c3[0],d3[1]-c3[1],d3[2]-c3[2])

B[0]=min(d1[0]-c1[0],d2[0]-c2[0],d3[0]-c3[0])
B[1]=min(d1[1]-c1[1],d2[1]-c2[1],d3[1]-c3[1])
B[2]=min(d1[2]-c1[2],d2[2]-c2[2],d3[2]-c3[2])


##print(c1,c2,c3)
if(max(A,B)==min(A,B)):
    print("YES")
else:
    print("No")

Submission status: Wrong Answer

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

a=[0]*3
b=[0]*3

a[0]=min(c1[0],c1[1],c1[2])
a[1]=min(c2[0],c2[1],c2[2])
a[2]=min(c3[0],c3[1],c3[2])

b[0]=min(c1[0],c2[0],c3[0])
b[1]=min(c1[1],c2[1],c3[1])
b[2]=min(c1[2],c2[2],c3[2])


d1=[0]*3
d2=[0]*3
d3=[0]*3

for i in range(3):
    d1[i]=a[0]+b[i]
    d2[i]=a[1]+b[i]
    d3[i]=a[2]+b[i]

A=[0]*3
B=[0]*3
A[0]=min(c1[0]-d1[0],c1[1]-d1[1],c1[2]-d1[2])
A[1]=min(c2[0]-d2[0],c2[1]-d2[1],c2[2]-d2[2])
A[2]=min(c3[0]-d3[0],c3[1]-d3[1],c3[2]-d3[2])

B[0]=min(c1[0]-d1[0],c2[0]-d2[0],c3[0]-d3[0])
B[1]=min(c1[1]-d1[1],c2[1]-d2[1],c3[1]-d3[1])
B[2]=min(c1[2]-d1[2],c2[2]-d2[2],c3[2]-d3[2])


##print(c1,c2,c3)
if((min(A)==0)&(min(B)==0)):
    print("YES")
else:
    ("No")

Submission status: Wrong Answer

Solution code:
c=[0 for _ in range(3)]
for i in range(3):
    c[i] = list(map(int,input().split()))
for i in range(2):
    if c[i][0]-c[i+1][0] != c[i][1]-c[i+1][1] and c[i][1]-c[i+1][1] != c[i][2]-c[i+1][2] :
        print("No")
        exit()
for i in range(2):
    if c[0][i]-c[0][i+1] != c[1][i]-c[1][i+1] and c[1][i]-c[1][i+1] != c[2][i]-c[2][i+1] :
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

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

if (c1+c2+c3)%3 ==0:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
def test():
    #a = [list(map(int,input().split())) for i in range(3)]
    ans = 0
    for i in range(3):
        a = list(map(int,input().split()))
        ans += sum(a)
    if ans % 3 == 0:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    test()

Submission status: Wrong Answer

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

tate,yoko=[],[]
for i in range(3):
  tate.append(min(grid[i]))
for i in range(3):
  yoko.append(min(grid[0][i],grid[1][i],grid[2][i]))
for i in range(3):
  for j in range(3):
    if grid[j][i]!=tate[i]+yoko[j]:
      print('No')
      exit()
print('Yes')

Submission status: Wrong Answer

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

tate,yoko=[],[]
for i in range(3):
  tate.append(min(grid[i]))
for i in range(3):
  yoko.append(min(grid[0][i],grid[1][i],grid[2][i]))
for i in range(3):
  for j in range(3):
    if grid[i][j]!=tate[i]+yoko[j]:
      print('No')
      exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools

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

# 係数行列。まずa0, a1, b0, b1を求める
A = []
mini_c = []
for i in range(2):
    for j in range(2):
        A.append([1 if idx == i else 0 for idx in range(2)] + [1 if idx == j else 0 for idx in range(2)])
        mini_c.append([c[i][j]])

A = np.matrix(A)
mat_mini_c = np.matrix(mini_c)

v = np.linalg.pinv(A)*mat_mini_c
v = v.tolist()
v = list(itertools.chain.from_iterable(v))
v = list(map(round, v))

a0, a1, b0, b1 = v

# 求めた数が条件を満たすかチェック
if [a0+b0, a0+b1, a1+b0, a1+b1] != list(itertools.chain.from_iterable(mini_c)):
    print("No")
    exit()

# 求めた数からa2, b2が一意に決まるかチェック
b2 = c[0][2] - a0
a2 = c[2][0] - b0
if b2 == c[1][2] - a1 and a2 == c[2][1] - b1 and a2 + b2 == c[2][2]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
c=0
for i in range(3):
  a,b,d=map(int,input().split())
  c+=(a+b+d)
if c%3==0:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

c1=sum(C[0])+C[0][0]+C[1][0]+C[2][0]
c2=sum(C[1])+C[0][1]+C[1][1]+C[2][1]
c3=sum(C[2])+C[0][2]+C[1][2]+C[2][2]

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

Submission status: Wrong Answer

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

a1 = min(c[0])
a2 = min(c[1])
a3 = min(c[2])
b1 = min(c[0][0], c[1][0], c[2][0])
b2 = min(c[0][1], c[1][1], c[2][1])
b3 = min(c[0][2], c[1][2], c[2][2])
a = [a1, a2, a3]
b = [b1, b2, b3]
for i in range(3):
    for j in range(3):
        if c[i][j] != a[i] + b[j]:
            print("No")
            exit()
print("Yes")

Submission status: Wrong Answer

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

ans = 'Yes'
for i in range(c[0][0] + 1):
    b = [c[0][0] - i, c[0][1] - i, c[0][2] - i]
    a = [i, abs(b[0] - c[1][0]), abs(b[0] - c[2][0])]
    for j in range(1, 3):
        for k in range(3):
            if c[j][k] != a[j] + b[k]:
                ans = 'No'
                break
        if ans != 'Yes':
            break
    if ans == 'Yes':
        break
    if i != c[0][0] - 1:
        ans = 'Yes'

print(ans)

Submission status: Wrong Answer

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

ans = 'Yes'
for i in range(c[0][0]):
    b = [c[0][0] - i, c[0][1] - i, c[0][2] - i]
    a = [i, abs(b[0] - c[1][0]), abs(b[0] - c[2][0])]
    for j in range(1, 3):
        for k in range(3):
            if c[j][k] != a[j] + b[k]:
                ans = 'No'
                break
        if ans != 'Yes':
            break
    if ans == 'Yes':
        break
    if i != c[0][0] - 1:
        ans = 'Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
c = [list(map(int, input().split())) for _ in range(3)]
b = [c[0][0], c[0][1], c[0][2]]
a = [0, abs(b[0] - c[1][0]), abs(b[0] - c[2][0])]
for i in range(1, 3):
    for j in range(3):
        if c[i][j] != a[i] + b[j]:
            print('No')
            sys.exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
s=list(map(int,input().split()))
t=list(map(int,input().split()))
u=list(map(int,input().split()))
a=s[0]+s[1]+s[2]+t[0]+t[1]+t[2]+u[0]+u[1]+u[2]
b=s[1]+s[2]+t[0]+t[2]+u[0]+u[1]-2*s[0]-2*t[1]-2*u[2]
if a%3==0 and b%3==0:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
s=list(map(int,input().split()))
t=list(map(int,input().split()))
u=list(map(int,input().split()))
a=s[0]+s[1]+s[2]+t[0]+t[1]+t[2]+u[0]+u[1]+u[2]
if a%3==0:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
# ABC088C - Takahashi's Information
def main():
    C = tuple(tuple(map(int, input().split())) for _ in range(3))
    memo = {(i, j, j - k) for i, j, k in C}
    flg = len(memo) == 1
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

q1 = c[0][0] - c[0][1] == c[1][0] - c[1][1] == c[2][0] - c[2][1]
q2 = c[0][0] - c[0][2] == c[1][0] - c[1][2] == c[2][0] - c[2][2]
q3 = c[0][0] - c[1][0] == c[0][1] - c[1][1] == c[0][2] - c[1][2]
q4 = c[0][0] - c[2][0] == c[0][1] - c[2][1] == c[0][2] - c[2][2]

print("Yes" if q1 and q2 and q3 and q4 else "no")

Submission status: Wrong Answer

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

ans = "Yes"

for i in range(1, -1, -1):
    C0i = C[0][2] - C[0][i]
    C1i = C[1][2] - C[1][i]
    C2i = C[2][2] - C[2][i]
    
    if C0i != C1i and C0i != C2i:
        ans = "No"
        
print(ans)

Submission status: Wrong Answer

Solution code:
C=[list(map(int,input().split())) for i in range(3)]
for n in range(0,2):
  x=C[0][2]-C[0][n]
  y=C[1][2]-C[1][n]
  z=C[2][2]-C[2][n]
  if x==y and y==z :
    print('Yes')
    exit()
else:
  print('No')

Submission status: Wrong Answer

Solution code:
C=[list(map(int,input().split())) for i in range(3)]
count = 0
for n in range(0,2):
  x=C[0][2]-C[0][n]
  y=C[1][2]-C[1][n]
  z=C[2][2]-C[2][n]
  if x==y and y==z :
    count+=1
    print('Yes')
    break
if count == 0:
  print('No')

Submission status: Wrong Answer

Solution code:
C=[list(map(int,input().split())) for i in range(3)]
count = 0
for n in range(1,3):
  for m in range(1,3):
    if C[m-1][n]-C[m-1][n-1]==C[m][n]-C[m][n-1] and C[m-1][n]-C[m][n-1]==C[m][n]-C[m][n-1]:
      count += 1
if count == 4:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
C=[list(map(int,input().split())) for i in range(3)]
print(C)
print(C[1][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]:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
grid = [list(map(int, input().split())) for _ in range(3)]
total = sum([sum(row) for row in grid])
print('Yes' if total % 3 == 0 else 'No')

Submission status: Wrong Answer

Solution code:
# sys.stdin.readline
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        c = [list(map(int, input().split())) for _ in range(3)]
        for a1 in range(100):
            for b1 in range(100 - a1):
                if c[0][0] != a1 + b1:
                    continue
            
                a2 = c[1][0] - b1
                a3 = c[2][0] - b1
                b2 = c[0][1] - a1
                b3 = c[0][2] - a1
                if c[1][1] == a2 + b2 and c[1][2] == a2 + b3 and c[2][1] == a3 + b2 and c[2][2] == a3 + b3:
                    print('Yes')
                    exit()
        print('No')


# Run main
if __name__ == '__main__':
    AtCoder().main()

Submission status: Wrong Answer

Solution code:
# sys.stdin.readline
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        c = [list(map(int, input().split())) for _ in range(3)]
        for a1 in range(100):
            for b1 in range(100 - a1):
                a2 = c[1][0] - b1
                a3 = c[2][0] - b1
                b2 = c[0][1] - a1
                b3 = c[0][2] - a1
                if c[1][1] == a2 + b2 and c[1][2] == a2 + b3 and c[2][1] == a3 + b2 and c[2][2] == a3 + b3:
                    print('Yes')
                    exit()
        print('No')


# Run main
if __name__ == '__main__':
    AtCoder().main()

Submission status: Wrong Answer

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

a2 = c[1][0] - c[0][0]
a3 = c[2][0] - c[0][0]

if any(c[1][x] != a2 + c[1][x] for x in [1, 2]) or any(c[2][x] != a3 + c[1][x] for x in [1, 2]):
	print('No')
else:
	print('Yes')

Submission status: Wrong Answer

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

a2 = c[1][0] - c[0][0]
a3 = c[2][0] - c[0][0]
if any(c[1][x] != a2 + c[1][x] for x in [1, 2]) or any(c[2][x] != a3 + c[1][x] for x in [0, 2]):
	print('No')
else:
	print('Yes')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from statistics import *
from collections import *
from operator import itemgetter

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

ct = 0
for i in range(3):
    ct += sum(na())
print("Yes" if ct % 3 == 0 else 'No')

Submission status: Wrong Answer

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


if (sum(c1)+sum(c2)+sum(c3))%3!=0:
    print("No")
    exit()
elif c2[0]-c1[0]!=c2[1]-c1[1] or c2[0]-c1[0]!=c2[2]-c1[2] or c2[2]-c1[2]!=c2[1]-c1[1]:
    print("No")
    exit()
elif c3[0]-c1[0]!=c3[1]-c3[1] or c3[0]-c1[0]!=c3[2]-c1[2] or c3[0]-c1[0]!=c3[1]-c1[1]:
    print("No")
    exit()
elif c1[1]-c1[0]!=c2[1]-c2[0] or c3[1]-c3[0]!=c2[1]-c2[0] or c1[1]-c1[0]!=c3[1]-c3[0]:
    print("No")
    exit()
elif c1[2]-c1[0]!=c2[2]-c2[0] or c3[2]-c3[0]!=c2[2]-c2[0] or c1[2]-c1[0]!=c3[2]-c3[0]:
    print("No")
    exit()    
    
    
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import numpy as np
c=np.array([[int(i) for i in input().split()] for _ in range(3)])

if c.sum()%3==0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:

def find_numbers(grid):
    for a1 in range(0, 101):
        for a2 in range(0, 101):
            if (grid[0] + grid[1] + grid[2]) - 3 * a1 == (grid[3] + grid[4] + grid[5]) - 3 * a2:
                for a3 in range(0, 101):
                    if (grid[0] + grid[1] + grid[2]) - 3 * a1 == (grid[6] + grid[7] + grid[8]) - 3 * a3:
                        return True
    return False


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

print("Yes" if find_numbers(grid) else "No")

Submission status: Wrong Answer

Solution code:
c = [[]]*3

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

if ans % 3 == 0:
    arr = [[0]* 6]*3
    for i in range(3):
        arr[i][0] = c[i][0] - c[i][1]
        arr[i][1] = c[i][0] - c[i][2]
        arr[i][2] = c[i][1] - c[i][0]
        arr[i][3] = c[i][1] - c[i][2]
        arr[i][4] = c[i][2] - c[i][0]
        arr[i][5] = c[i][2] - c[i][1]
    for i in range(6):
        if arr[0][i] == arr[1][i] and arr[0][i] == arr[2][i]:
            continue
        else:
            print("No")
            exit(0)

    for i in range(3):
        arr[i][0] = c[0][i] - c[1][i]
        arr[i][1] = c[0][i] - c[2][i]
        arr[i][2] = c[1][i] - c[0][i]
        arr[i][3] = c[1][i] - c[2][i]
        arr[i][4] = c[2][i] - c[1][i]
        arr[i][5] = c[2][i] - c[0][i]
            
    for i in range(6):
        if arr[0][i] == arr[1][i] and arr[0][i] == arr[2][i]:
            continue
        else:
            print("No")
            exit(0)


    print("Yes")
    exit(0)

print("No")

Submission status: Wrong Answer

Solution code:
c = [[]]*3

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

if ans % 3 == 0:
    arr = [[0]* 3]*3
    for i in range(3):
        arr[i][0] = c[i][0] - c[i][1]
        arr[i][1] = c[i][0] - c[i][2]
        arr[i][2] = c[i][1] - c[i][2]
    
    for i in range(3):
        if arr[0][i] == arr[1][i] and arr[0][i] == arr[2][i]:
            continue
        else:
            print("No")
            exit(0)
    arr = [[0]* 3]*3
    for i in range(3):
        arr[i][0] = c[0][i] - c[1][i]
        arr[i][1] = c[0][i] - c[2][i]
        arr[i][2] = c[1][i] - c[2][i]
            
    for i in range(3):
        if arr[0][i] == arr[1][i] and arr[0][i] == arr[2][i]:
            continue
        else:
            print("No")
            exit(0)


    print("Yes")
    exit(0)

print("No")

Submission status: Wrong Answer

Solution code:
c = [[]]*3

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

if ans % 3 == 0:
    arr = [[0]* 3]*3
    for i in range(3):
        arr[i][0] = c[i][0] - c[i][1]
        arr[i][1] = c[i][0] - c[i][2]
        arr[i][2] = c[i][1] - c[i][2]
    
    for i in range(3):
        if arr[0][i] == arr[1][i] and arr[0][i] == arr[2][i]:
            continue
        else:
            print("No")
            exit(0)
    print("No")
    exit(0)

print("No")

Submission status: Wrong Answer

Solution code:
c = [[]]*3

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

if ans % 3 == 0:
    arr = [[0]* 3]*3
    for i in range(3):
        arr[i][0] = c[i][0] - c[i][1]
        arr[i][1] = c[i][0] - c[i][2]
        arr[i][2] = c[i][1] - c[i][2]
    
    for i in range(3):
        if arr[0][i] == arr[1][i] and arr[0][i] == arr[2][i]:
            continue
        else:
            print("No")
            exit(0)
    print("Yes")
    exit(0)

print("No")

Submission status: Wrong Answer

Solution code:
c = [[]]*3

for i in range(3):
    c[i] = map(int, input().split())
ans = 0
for i in range(3):
    ans += sum(c[i])

if ans % 3 == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
nums_ary = [[0 for i in range(3)] for i in range(3)]
check_ary = [[0 for i in range(3)] for i in range(2)]
check_minus = False
count = 0

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

for i in range(nums_ary[0][0]+1):

    for x in range(3):
        check_ary[1][x] = nums_ary[0][x] - i
        if check_ary[1][x] < 0:
            check_minus = True
    for y in range(3):
        check_ary[0][y] = nums_ary[y][0] - check_ary[1][0]
        if check_ary[0][y] < 0:
            check_minus = True
    if check_minus :
        continue

    for x in range(3):
        for y in range(3):
            if check_ary[0][x] + check_ary[1][y] == nums_ary[x][y]:
                count += 1

    if count == 9:
        print("Yes")
        sys.exit()
print("No")