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: Runtime Error

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

bi_list = []
for b1 in range(100):
    b2 = b1 - (cij[0][0] - cij[0][1])
    b3 = b1 - (cij[0][0] - cij[0][2])
    if b2 < 0 or b3 < 0 or b2 > cij[0][1] or b3 > cij[0][2] :
        continue
    bi_list.append([b1, b2, b3])

for bi in bi_list:
    a1 = cij[0][0]+cij[0][1]+cij[0][2] -bi[0]-bi[1]-bi[2] 
a2 = cij[1][0]+cij[1][1]+cij[1][2] -bi[0]-bi[1]-bi[2] 
a3 = cij[2][0]+cij[2][1]+cij[2][2] -bi[0]-bi[1]-bi[2] 
    if (a1) % 3 == 0 and (a2) % 3 == 0 and (a3) % 3 == 0 and a1 >=0 and a2 >= 0 and a3 >= 0:
        print("Yes")
        exit()

print("No")

Submission status: Runtime Error

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

a1=0
b1=gridNumber[0][0] - a1
b2=gridNumber[1][0] - a1
b3=gridNumber[2][0] - a1

a2=gridNumber[2][0] - b1
a3=gridNumber[3][0] - b1

numbers.append([a1+b1, a1+b2, a1+b3])
numbers.append([a2+b1, a2+b2, a2+b3])
numbers.append([a3+b1, a3+b2, a3+b3])

for i in range(3):
    for j in range(3):
        if not(numbers[i][j] == gridNumber[i][j]):
            print("No")
            quit()
        else:
            pass

print("Yes")

Submission status: Runtime Error

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

a = [0]
b = []
result = 'Yes'

b.append(C[0][0])
b.append(C[1][0])
b.append(C[2][0])
a.append(C[1][0] - b1)
a.append(C[2][0] - b1)

for i in range(3):
    for j in range(3):
        if C[i][j] != a[i] + b[j]:
            result = 'No'
            
print(result)

Submission status: Runtime Error

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

a = []
b = []
result = 'Yes'

a.append(0)
b.append(C[0][0])
b.append(C[1][0])
b.append(C[2][0])
a.append(C[1][0] - b1)
a.append(C[2][0] - b1)

for i in range(3):
    for j in range(3):
        if C[i][j] != a[i] + b[j]:
            result = 'No'
            
print(result)

Submission status: Runtime Error

Solution code:
c=[]
for i in range(3):
  c += [map(int,input())]
 
if c[0][0] + c[1][1]+ c[2][2] == c[1][0] + c[2][1] + c[0][2] == c[2][0] + c[0][1] + c[1][2]:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <cstdio>
#include <set>
using namespace std;

int c[5][5];

int main ()
{
    int n=3;
    for (int i=1;n>=i;i++)
    {
        for (int j=1;n>=j;j++)
        {
            cin >> c[i][j];
        }
    }
    for (int i=1;n>i;i++)
    {
        set<int> st;
        for (int j=1;n>=j;j++)
        {
            st.insert(c[i+1][j] - c[i][j]);
        }
        if (st.size() != 1)
        {
            puts("No");
            return 0;
        }
    }
    for (int j=1;n>j;j++)
    {
        set<int> st;
        for (int i=1;n>=i;i++)
        {
            st.insert(c[i][j+1]-c[i][j]);
        }
        if (st.size() != 1)
        {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

Submission status: Runtime Error

Solution code:
sum = 0
zero = 0
for i in range(3):
	tmp = input().split()
	for j in range(3):
    	if int(tmp[j]) == 0:
    		zero += 1
        else:
        	sum += int(tmp[j])    
if sum%3 ==0 and zero%3 ==0:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
sum = 0
for i in range(3)
	tmp = input().split()
	sum += int(tmp[0])+int(tmp[1])int(tmp[2])
if sum%3 ==0:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
import numpy as np

grid = np.array([])
for _ in range(3):
    list1 = list(map(int, input().split()))
    grid = np.append(grid, list1)

grid = grid.reshape(3, 3)
grid2 = np.vstack((grid[1:3, :], grid[0, :]))
judge = grid - grid2
judge = judge.transpose()
judge2 = np.copy(judge)
judge2 = np.vstack((judge2[1:3, :], judge2[0, :]))
new_judge = judge - judge2

if new_judge == np.zeros(3, 3):
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
import numpy as np
a=[]
for i in range (3):
 a.append(list(map(int,input().split(" "))))
nd=np.array(a)
if(np.linalg.matrix_rank(nd)==1):
 print("Yes")
else
 print("No")

Submission status: Runtime Error

Solution code:
import numpy as np
a=[]
for i in range (3):
 a.append(map(int,input().split(" ")))
nd=np.array(a)
if(np.linalg.matrix_rank(nd)==1):
 print("Yes")
else
 print("No")

Submission status: Runtime Error

Solution code:
import numpy as np

l = []

for _ in range(3):
    a = [int(x) for x in input().split()]
    l.append(a)

l = np.array(l)

def check(m):
    a = []
    for i in range(3):
        b,c = m[i,0] - m[i,1], m[i,1] - m[i,2]
        m.append((b,c))
    if a[0] != a[1] or a[1] != a[2]:
        return False
    else:
        return True

if check(l) and check(np.transpose(l)):
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
%import numpy as np
c1 = [int(i) for i in input().split()]
c2 = [int(i) for i in input().split()]
c3 = [int(i) for i in input().split()]
s = sum(c1) + sum(c2) + sum(c3)
print('Yes' if s % 3 == 0 else 'No')

Submission status: Runtime Error

Solution code:
%import numpy as np
c1 = [int(i) for i in input().split()]
c2 = [int(i) for i in input().split()]
c3 = [int(i) for i in input().split()]
s = sum(c1) + sum(c2) + sum(c3)
print(s % 3 == 0)

Submission status: Runtime Error

Solution code:
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
total = 0
div = c1[0]+c2[1]+c3[2]
for (x,y,z) in zip(c1,c2,c3):
    total = total + x + y + z

print ('Yes' if total / div == 3 else 'No')

Submission status: Runtime Error

Solution code:
c0 = map(int, raw_input().split())
c1 = map(int, raw_input().split())
c2 = map(int, raw_input().split())

d0 = c0 - c2
d1 = c1 - c2
d2 = c2 - c1

b0 = ((d0[0] == d0[1]) and (d0[1] == d0[2]))
b1 = ((d1[0] == d1[1]) and (d1[1] == d1[2]))
b2 = ((d2[0] == d2[1]) and (d2[1] == d2[2]))

if (b0 and b1 and b2):
  print 'Yes'
else:
  print 'No'

Submission status: Runtime Error

Solution code:
import numpy as np
c0= list(map(int, input().split(' ')))
c1= list(map(int, input().split(' ')))
c2= list(map(int, input().split(' ')))
 
C = np.array([c0, c1, c2])
if C[1][0] - C[0][0] == C[1][1]-C[0][1] == C[1][2] - C[0][2] and C[2][0] - C[0][0] == C[2][1]-C[0][1 ]== C[2][2] - C[0][2]  :
 print('Yes')
else:
 print('No')
import numpy as np
c0= list(map(int, input().split(' ')))
c1= list(map(int, input().split(' ')))
c2= list(map(int, input().split(' ')))

C = np.array([c0, c1, c2])
if C[1][0] - C[0][0] == C[1][1]-C[0][1] == C[1][2] - C[0][2] and C[2][0] - C[0][0] == C[2][1]-C[0][1 ]== C[2][2] - C[0][2]  :
 print('Yes')
else:
 print('No')

Submission status: Runtime Error

Solution code:
1 8 6
2 9 7
0 7 7

Submission status: Runtime Error

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: Runtime Error

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: Runtime Error

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 judeg3 and judge4 :
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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[3] == a2[i]+b3[i]:
        judge3 = True
    if c3[1] == a3[i]+b2[i]:
        judge4 = True 
if judge1 and judge2 and judeg3 and judge4 :
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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:
            flg =True
            break
        if min([b0,b1,b2]) < 0:
            break
        
    if flg:
        print('Yes')

Submission status: Runtime Error

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

    a1_list = range(c[0][0]+1)
    for a1 in a1_list:
        b1 = c[0][0] - a1
        b2 = c[0][1] - a1
        b3 = c[0][2] - a1

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

        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
        print("Yes")
        return

    print("No")
    return

solve()

Submission status: Runtime Error

Solution code:
#include <iostream>
using namespace std;

int main(){
  int c[3][3];
  for(int i=0; i<3; i++){
    cin >> c[i][0] >> c[i][1] >> c[i][2];
  }
  if(c[1][0] - c[0][0] == c[1][1] - c[0][1] && c[1][0] - c[0][0] == c[1][2] - c[0][2]){
    if(c[2][0] - c[0][0] == c[2][1] - c[0][1] && c[2][0] - c[0][0] == c[2][2] - c[0][2]){
      cout << "Yes" << flush;
    }
    else{
      cout << "No" << flush;
    }
  }
  else{
    cout << "No" << flush;
  }
}

Submission status: Runtime Error

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

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

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

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

Submission status: Runtime Error

Solution code:
def main():
    arr = []
    for i in range(3):
        arr.append(map(int, input().split()))
    b1 = arr[0][0] - arr[0][1]
    b2 = arr[0][1] - arr[0][2]
    a1 = arr[1][0] - arr[0][0]
    a2 = arr[2][0] - arr[1][0]
    for i in range(3):
        if arr[i][0] - arr[i][1] != b1 or arr[i][1] - arr[i][2] != b2 or arr[1][i] - arr[0][i] != a1 or arr[2][i] - \
                arr[1][i] != a2:
            print("No")
            return
    print("Yes")

if __name__ == '__main__':
    main()