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 = [list(map(int,input().split())) for i in range(3)]
if c[0][1]-c[0][0] == c[1][1]-c[1][0] == c[2][1]-c[2][0] and c[0][2]-c[0][1] == c[1][2]-c[1][1] == c[2][2]-c[2][1] and c[0][0]-c[1][0] == c[0][1]-c[1][1] == c[0][2]-c[1][2] and c[1][0]-c[2][0] == c[1][1]-c[2][1] == c[1][2]-c[2][2]:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

for i in range(max(c[0][0], c[1][0], c[2][0]) + 1):
    a1, a2, a3 = c[0][0] - i, c[1][0] - i, c[2][0] - i
    
    if c[0][1] - a1 == c[1][1] - a2 and c[0][1] - a1 == c[2][1] - a3 and\
       c[0][2] - a1 == c[1][2] - a2 and c[0][2] - a1 == c[2][2] - a3:
       flg = True

print("Yes" if flg else "No")

Submission status: Accepted

Solution code:
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    c=[[] for _ in range(4)]
    for i in range(1,4):
        c[i] = [0]+list(map(int, input().strip().split()))
        
    def diff(i,j,k):
        return c[k][i] - c[k][j]
    if diff(3,2,1)==diff(3,2,2)==diff(3,2,3) and diff(2,1,1)==diff(2,1,2)==diff(2,1,3):
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def II(): return int(input())
def MI(): return map(int,input().split())
def LMI(): return list(map(int,input().split()))
def LIIN(n): return list(int(input()) for _ in range(n))
def LMIN(n): return [list(map(int, input().split())) for _ in range(n)]
def IS(): return input()
def MS(): return map(str,input().split())
def LMS(): return list(map(str,input().split()))
def LISN(n): return list(input() for _ in range(n))
def LMSN(n): return [input().split() for _ in range(n)]
MOD = 10**9+7
INF = 10**18

def main():
    x = [0] * 3
    y = [0] * 3
    a = LMIN(3)

    x[0] = 0
    for i in range(3):
        y[i] = a[0][i] - x[0]
    for i in range(3):
        x[i] = a[i][0] - y[0]

    for i in range(3):
        for j in range(3):
            if x[i]+y[j] != a[i][j]:
                print('No')
                return 0
    print('Yes')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def myAnswer(C:list) -> int:
   return "Yes" if(C[0][0] + C[1][1] + C[2][2] == C[0][1]+C[1][2]+C[2][0] == C[0][2]+C[1][0]+C[2][1]) else "No"




def modelAnswer():
   return
def main():
   C = [list(map(int,input().split())) for _ in range(3)]
   print(myAnswer(C[:]))
   
if __name__ == '__main__':
   main()

Submission status: Accepted

Solution code:
def main():
    C = [[int(_) for _ in input().split()] for i in range(3)]
    if C[0][0] - C[0][1] == C[1][0] - C[1][1] and C[2][0] - C[2][1] == C[1][0] - C[1][1]:
        if C[0][1] - C[0][2] == C[1][1] - C[1][2] and C[2][1] - C[2][2] == C[1][1] - C[1][2]:
            print("Yes")
            return
    print("No")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = [list(map(int,input().split()))for i in range(3)]
check = False
for i in range(101):
  for j in range(101):
    if (S[0][0]-i == S[1][0]-j and S[0][1]-i == S[1][1]-j) and S[0][2]-i == S[1][2]-j:
      if (S[2][0]-S[0][0] == S[2][1]-S[0][1])and(S[2][0]-S[0][0] == S[2][2]-S[0][2]):
        check = True
        print('Yes')
        exit()
if check == False: print('No')

Submission status: Accepted

Solution code:
import numpy as np
from numpy.linalg import matrix_rank
A = np.array([[1,0,0,1,0,0],
            [1,0,0,0,1,0],
            [1,0,0,0,0,1],
            [0,1,0,1,0,0],
            [0,1,0,0,1,0],
            [0,1,0,0,0,1],
            [0,0,1,1,0,0],
            [0,0,1,0,1,0],
            [0,0,1,0,0,1]])

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

Ac = np.array([[1,0,0,1,0,0, c11],
            [1,0,0,0,1,0, c12],
            [1,0,0,0,0,1, c13],
            [0,1,0,1,0,0, c21],
            [0,1,0,0,1,0, c22],
            [0,1,0,0,0,1, c23],
            [0,0,1,1,0,0, c31],
            [0,0,1,0,1,0, c32],
            [0,0,1,0,0,1, c33]])

if matrix_rank(A) == matrix_rank(Ac):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
l = [[int(i) for i in input().split()] for x in range(3)]
total1 = 0
total2 = 0
for i in range(3):
    total1 += sum(l[i])
    total2 += l[i][i]
    
if total1 == total2 * 3:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

total1 = 0
total2 = 0


for i in range(3):
    total1 += sum(l[i])
    total2 += l[i][i]
    
if total1 == total2 * 3:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
c = [list(map(int,input().split())) for _ in range(3)]
a1 = 0
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
flag = 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' if flag else 'No')

Submission status: Accepted

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

flag = False
#print(a)
for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            if (a[0][0]-a1 == a[1][0]-a2 == a[2][0]-a3) and (a[0][1]-a1 == a[1][1]-a2 == a[2][1]-a3) and (a[0][2]-a1 == a[1][2]-a2 == a[2][2]-a3):
                flag = True
                break
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def readlines():
    for _ in range(3):
        yield list(map(int, input().split()))

c = list(readlines())

a1 = 0
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
ok = (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" if ok else "No")

Submission status: Accepted

Solution code:
def readlines():
    for _ in range(3):
        yield list(map(int, input().split()))

c = list(readlines())

def it():
    for a1 in range(100):
        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
        yield (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" if any(it()) else "No")

Submission status: Accepted

Solution code:
x = [list(map(int,input().split())) for i in range(3)]
m=0
for i in range(3):
    m+=sum(x[i])
if m%3 == 0 and (x[0][0]+x[1][1]+x[2][2])*3==m:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    '''
    code here
    '''

    grid = [[int(i) for i in input().split()] for _ in range(3)]

    is_flag = True

    for i in range(3):
        A = grid[0][i-1] -grid[0][i]
        C = grid[2][i-1] -grid[2][i]
        B = grid[1][i-1] -grid[1][i]

        if  A == B and B == C:
            pass
        else:
            is_flag = False

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



if __name__ == "__main__":
    resolve()

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 not(c12-c11 == c22-c21 == c32-c31):
    print("No")
    quit()
if not(c13-c12 == c23-c22 == c33-c32):
    print("No")
    quit()
if not(c21-c11 == c22-c12 == c23-c13):
    print("No")
    quit()
if not(c31-c21 == c32-c22 == c33-c23):
    print("No")
    quit()

print("Yes")

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+c22+c33 == c12+c23+c31 == c13+c21+c32:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a,b,c = map(int,input().split())
aa,bb,cc = map(int,input().split())
aaa,bbb,ccc = map(int,input().split())

ans = "No"
if a-aa == b-bb and b-bb == c-cc:
  if aa-aaa == bb-bbb and bb-bbb == cc-ccc:
    if a-b == aa-bb and aa-bb == aaa-bbb:
      if b-c == bb-cc and bb-cc == bbb-ccc:
        ans = "Yes"
        
print(ans)

Submission status: Accepted

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

if C[1][0]-C[0][0]==C[1][1]-C[0][1] and C[1][2]-C[0][2]==C[1][1]-C[0][1]:
  if C[2][0]-C[0][0]==C[2][1]-C[0][1] and C[2][2]-C[0][2]==C[2][1]-C[0][1]:
    result = 'Yes'
    
print(result)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.buffer.readline

# a1 = 0としてよい

A = [0,None,None]
B = [None,None,None]

bl = True
for i in range(3):
  C = [int(x) for x in input().split()]
  for j,c in enumerate(C):
    if A[i] is None:
      A[i] = c - B[j]
    if B[j] is None:
      B[j] = c - A[i]
    if A[i]+B[j] != c:
      bl = False

answer = 'Yes' if bl else 'No'
print(answer)

Submission status: Accepted

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

    a1 = 0
    a2 = 0
    a3 = 0
    b1 = 0
    b2 = 0
    b3 = 0

    find_a1 = False
    find_a2 = False
    find_a3 = False
    find_b1 = False
    find_b2 = False
    find_b3 = False
    find_all = False

    for a in range(101):
        find_a1 = False
        find_a2 = False
        find_a3 = False
        find_b1 = False
        find_b2 = False
        find_b3 = False

        for b in range(101):
            if a + b == grid[0][0]:
                b1 = b
                find_b1 = True
            
            if a + b == grid[0][1]:
                b2 = b
                find_b2 = True
            
            if a + b == grid[0][2]:
                b3 = b
                find_b3 = True

            if find_b1 and find_b2 and find_b3 :
                a1 = a
                find_a1 = True
                break
   
        for a_ in range(101):
            if (a_ == grid[1][0] - b1) and (a_ == grid[1][1] - b2) and (a_ == grid[1][2] - b3):
                a2 = a_
                find_a2 = True
                break

        for a_ in range(101):
            if (a_ == grid[2][0] - b1) and (a_ == grid[2][1] - b2) and (a_ == grid[2][2] - b3):
                a3 = a_
                find_a3 = True
                break

        if find_a1 and find_a2 and find_a3 and find_b1 and find_b2 and find_b3:
            find_all = True
            break

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

a1=0
b1=c11
b2=c12
b3=c13
a2=c21-b1
a3=c31-b1

if c22!=a2+b2:
    print("No")
elif c23!=a2+b3:
    print("No")
elif c32!=a3+b2:
    print("No")
elif c33!=a3+b3:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
# 2020/04/26
# AtCoder Beginner Contest 088 - C

# Input
cr = list()
for i in range(3):
    cw = list(map(int,input().split()))
    cr.append(cw)

a = list()
b = list()

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

wkans = list()

for i in range(3):
    wkrow = list()
    for j in range(3):
        wkrow.append(cr[i][j] - (a[i] + b[j]))
    wkans.append(wkrow)

# print(a)
# print(b)
# print(wkans)

if min(wkans) == max(wkans):
    ans = 'Yes'
else:
    ans = 'No'

# Output
print(ans)

Submission status: Accepted

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

for row in range(3):
    for col in range(3):
        if C[row][col] - C[(row+1)%3][col] != C[row][(col+1)%3] - C[(row+1)%3][(col+1)%3]:
            print('No')
            exit()

for col in range(3):
    for row in range(3):
        if C[row][col] - C[row][(col+1)%3] != C[(row+1)%3][col] - C[(row+1)%3][(col+1)%3]:
            print('No')
            exit()

print('Yes')

Submission status: Accepted

Solution code:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N = 3
rows = [list(map(int,input().split())) for _ in range(N)]
arr = np.array(rows)

b1 = arr[0] -arr[0][0]
b2 = arr[1] -arr[1][0]
b3 = arr[2] -arr[2][0]
if not (list(b1)==list(b2)==list(b3)):
    print("No")
    exit()

arr = arr.T
a1 = arr[0]-arr[0][0]
a2 = arr[1]-arr[1][0]
a3 = arr[2]-arr[2][0]
if not(list(a1)==list(a2)==list(a3)):
    print("No")
    exit()

print("Yes")
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

Submission status: Accepted

Solution code:
c1 = list(map(int,input().split()))
c2 = list(map(int,input().split()))
c3 = list(map(int,input().split()))
a = c1[0]+c2[1]+c3[2]
b = c1[1]+c2[2]+c3[0]
c = c1[2]+c2[0]+c3[1]
d = c1[0]+c2[2]+c3[1]
e = c1[1]+c2[0]+c3[2]
f = c1[2]+c2[1]+c3[0]
if a==b==c==d==e==f:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

for i in range(2):
  for j in range(i+1,3):
    if C[i][0]-C[j][0]==C[i][1]-C[j][1] and C[i][1]-C[j][1]==C[i][2]-C[j][2] and C[i][2]-C[j][2]==C[i][0]-C[j][0]:
      continue
    else:
      print('No')
      exit()

for i in range(2):
  for j in range(i+1,3):
    if C[0][i]-C[0][j]==C[1][i]-C[1][j] and C[1][i]-C[1][j]==C[2][i]-C[2][j] and C[2][i]-C[2][j]==C[0][i]-C[0][j]:
      continue
    else:
      print('No')
      exit()

print('Yes')

Submission status: Accepted

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

flg = False
if (grid[1][0] - grid[0][0] == grid[1][1] - grid[0][1] == grid[1][2] - grid[0][2])\
        and (grid[2][0] - grid[0][0] == grid[2][1] - grid[0][1] == grid[2][2] - grid[0][2]):
    flg = True

print("Yes" if flg == True else "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]

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

a[0]=0


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

good = True

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

print('Yes')

Submission status: Accepted

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

a2_a1 = c2[0] - c1[0]
a3_a2 = c3[0] - c2[0]
a1_a3 = c1[0] - c3[0]

b2_b1 = c1[1] - c1[0]
b3_b2 = c1[2] - c1[1]
b1_b3 = c1[0] - c1[2]

if a2_a1 != c2[1] - c1[1] or a2_a1 != c2[2] - c1[2]:
    print("No")
elif a3_a2 != c3[1] - c2[1] or a3_a2 != c3[2] - c2[2]:
    print("No")
elif a1_a3 != c1[1] - c3[1] or a1_a3 != c1[2] - c3[2]:
    print("No")
elif b2_b1 != c2[1] - c2[0] or b2_b1 != c3[1] - c3[0]:
    print("No")
elif b3_b2 != c2[2] - c2[1] or b3_b2 != c3[2] - c3[1]:
    print("No")
elif b1_b3 != c2[0] - c2[2] or b1_b3 != c3[0] - c3[2]:
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

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: Accepted

Solution code:
c = [[int(i) for i in input().split()] for _ in range(3)]
flag = False
for i in range(-100,100):
    for j in range(-100,100):
        for k in range(-100,100):
            a11 = c[0][0] - i
            a12 = c[0][1] - j
            a13 = c[0][2] - k
            if  a11!=a12 or a12!=a13:
                continue
            a21 = c[1][0] - i
            a22 = c[1][1] - j
            a23 = c[1][2] - k 
            if a21!=a22 or a22!=a23:
                continue
            a31 = c[2][0] - i
            a32 = c[2][1] - j
            a33 = c[2][2] - k 
            if a31!=a32 or a32!=a33:
                continue
            flag = True
print('Yes' if flag else 'No')

Submission status: Accepted

Solution code:
c=[]
for i in range(3):
  c.append(list(map(int,input().split())))
a21=[c[1][i]-c[0][i] for i in range(3)]
a32=[c[2][i]-c[1][i] for i in range(3)]
b21=[c[i][1]-c[i][0] for i in range(3)]
b32=[c[i][2]-c[i][1] for i in range(3)]
if max(a21)!=min(a21) or max(a32)!=min(a32) or max(b21)!=min(b21) or max(b32)!=min(b32):
  print("No")
else :
  flag=False
  for a1 in range(101):
    for b1 in range(101):
      a=[a1,a1+a21[0],a1+a21[0]+a32[0]]
      b=[b1,b1+b21[0],b1+b21[0]+b32[0]]
      flagij=True
      for i in range(3):
        for j in range(3):
          if c[i][j]!=a[i]+b[j]:
            flagij=False
      flag|=flagij
  if flag:
    print("Yes")  
  else:
    print("No")

Submission status: Accepted

Solution code:
import sys
C = [list(map(int, sys.stdin.readline().split(" "))) for i in range(3)]
for a0 in range(101):
    b0 = C[0][0] - a0
    b1 = C[0][1] - a0
    b2 = C[0][2] - a0
    if (C[1][0] - b0 == C[1][1] - b1 == C[1][2] - b2) and (C[2][0] - b0 == C[2][1] - b1 == C[2][2] - b2):
        print("Yes")
        exit()
print("No")

Submission status: Accepted

Solution code:
from sys import stdin
import sys

[c11, c12, c13] = list(map(int, stdin.readline().rstrip().split()))
[c21, c22, c23] = list(map(int, stdin.readline().rstrip().split()))
[c31, c32, c33] = list(map(int, stdin.readline().rstrip().split()))

#print("%d %d %d" % (c11, c12, c13))
#print("%d %d %d" % (c21, c22, c23))
#print("%d %d %d" % (c31, c32, c33))

## Horizontal
# 3*a1 + b1 + b2 + b3
# 3*a2 + b1 + b2 + b3
# 3*a3 + b1 + b2 + b3
# => 3 の倍数

## Vertical
# 3*b1 + a1 + a2 + a3
# 3*b2 + a1 + a2 + a3
# 3*b3 + a1 + a2 + a3
# => 3 の倍数

if ((c11 + c12 + c13) - (c21 + c22 + c23)) % 3 != 0 or ((c21 + c22 + c23) - (c31 + c32 + c33)) % 3 != 0 or ((c31 + c32 + c33) - (c11 + c12 + c13)) % 3 != 0:
    print("No")

elif ((c11 + c21 + c31) - (c12 + c22 + c32)) % 3 != 0 or ((c12 + c22 + c32) - (c13 + c23 + c33)) % 3 != 0 or ((c13 + c23 + c33) - (c11 + c21 + c31)) % 3 != 0:
    print("No")

else:
    print("Yes")

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

l = []
for i in range(3):
    l.append(iil())


f = True
for i in range(1,3):
    dif0 = l[i][0] - l[i-1][0]
    dif1 = l[i][1] - l[i-1][1]
    dif2 = l[i][2] - l[i-1][2]
    if dif0 == dif1 == dif2:
        continue
    f = False

for i in range(1,3):
    dif0 = l[0][i] - l[0][i-1]
    dif1 = l[1][i] - l[1][i-1]
    dif2 = l[2][i] - l[2][i-1]
    if dif0 == dif1 == dif2:
        continue
    f = False

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc088/tasks/abc088_c

matrix = []

for _ in range(3):
    row = [int(i) for i in input().split()]
    matrix.append(row)

a1 = matrix[1][0] - matrix[0][0]
a2 = matrix[2][0] - matrix[0][0]
b1 = matrix[0][1] - matrix[0][0]
b2 = matrix[0][2] - matrix[0][0]

if a1 + b1 == matrix[1][1] - matrix[0][0] and a2 + b2 == matrix[2][2] - matrix[0][0] and a1 + b2 == matrix[1][2] - matrix[0][0] and a2 + b1 == matrix[2][1] - matrix[0][0]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
c=[]
sum1=0
sum2=0
for i in range(3):
  c.append(list(map(int, input().split())))
  sum1+=sum(c[i])
  sum2+=c[i][i]
if sum1==sum2*3:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    c=[list(map(int,input().split())) for _ in range(3)]
    a=[[0]*3 for _ in range(3)]
    b=[[0]*3 for _ in range(3)]
    for i in range(3):
        for j in range(3):
            a[i][j]=c[i][j]-min(c[i])
            b[j][i]=c[i][j]-min(c[0][j],c[1][j],c[2][j])
    YesNo(a[0]==a[1]==a[2] and b[0]==b[1]==b[2])

if __name__ == '__main__':
    main()

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]
for i in range(2):
    if c[i][0]-c[i+1][0]!=c[i][1]-c[i+1][1] or c[i][1]-c[i+1][1]!=c[i][2]-c[i+1][2]:
        print("No")
        exit()
for j in range(2):
    if c[0][i+1]-c[0][i]!=c[1][i+1]-c[1][i] or c[1][i+1]-c[1][i]!=c[2][i+1]-c[2][i]:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
G=[]
for i in range(3):
    g=list(map(int, input().split()))
    G.append(g)
"""
a1=x
b1=G[0][0]-a1
b2=G[0][1]-a1
b3=G[0][2]-a1
a2=G[1][0]-b1
a3=G[2][0]-b1

G[1][1]=a2+b2=G[1][0]-G[0][0]+G[0][1]
G[1][2]=a2+b3=G[1][0]-G[0][0]+G[0][2]
G[2][1]=a3+b2=G[2][0]-G[0][0]+G[0][1]
G[2][2]=a3+b3=G[2][0]-G[0][0]+G[0][2]
"""
ok=True
if G[1][1]!=G[1][0]-G[0][0]+G[0][1]:
    ok=False

if G[1][2]!=G[1][0]-G[0][0]+G[0][2]:
    ok=False
if G[2][1]!=G[2][0]-G[0][0]+G[0][1]:
    ok=False
if G[2][2]!=G[2][0]-G[0][0]+G[0][2]:
    ok=False

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

Submission status: Accepted

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


for a1 in range(-10000,10001):
    b1 = grid[0][0] - a1
    a2 = grid[1][0] - b1
    a3 = grid[2][0] - b1
    b2 = grid[0][1] - a1
    b3 = grid[0][2] - a1

    if a2+b2 == grid[1][1] and a2+b3 == grid[1][2] and a3+b2 == grid[2][1] and a3+b3 == grid[2][2]:
        print('Yes')
        break
else:print('No')

Submission status: Accepted

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

a=[0]*3
b=[0]*3
for j in range(3):
    b[j] = C[0][j] - a[0]
for i in range(3):
    a[i] = C[i][0] - b[0]
ans=True
for i in range(1,3):
    for j in range(1,3):
        if C[i][j] != a[i]+b[j]:
            ans=False
print('Yes' if ans else 'No')

Submission status: Accepted

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

#a1=0としてよい
a=[0]*3
b=[0]*3
for j in range(3):
    b[j] = C[0][j] - a[0]
for i in range(3):
    a[i] = C[i][0] - b[0]
ans=True
for i in range(1,3):
    for j in range(1,3):
        if C[i][j] != a[i]+b[j]:
            ans=False
print('Yes' if ans else 'No')

Submission status: Accepted

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

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

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

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

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

print("Yes")

Submission status: Accepted

Solution code:
def solve():
    C = [[int(c) for c in input().split()] for _ in range(3)]
    diffr1 = C[0][1] - C[0][0]
    diffr2 = C[0][2] - C[0][1]
    diffc1 = C[1][0] - C[0][0]
    diffc2 = C[2][0] - C[1][0]
    if C[1][1] - C[1][0] == C[2][1] - C[2][0] == diffr1:
        if C[1][2] - C[1][1] == C[2][2] - C[2][1] == diffr2:
            if C[1][1]  - C[0][1] == C[1][2] - C[0][2] == diffc1:
                if C[2][1] - C[1][1] == C[2][2] - C[1][2] == diffc2:
                    return "Yes"
    return "No"

if __name__ == "__main__":
    print(solve())

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc088/tasks/abc088_c

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

for i in range(2):
    res1=c[i+1][0]-c[i][0]
    res2=c[i+1][1]-c[i][1]
    res3=c[i+1][2]-c[i][2]
    if res1==res2==res3:continue
    else:
        print('No')
        exit()


for j in range(2):
    res1=c[0][j+1]-c[0][j]
    res2=c[1][j+1]-c[1][j]
    res3=c[2][j+1]-c[2][j]
    if res1==res2==res3:continue
    else:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
def resolve():
  c = []
  c.append(list(map(int, input().split())))
  c.append(list(map(int, input().split())))
  c.append(list(map(int, input().split())))
  a01 = c[0][0] - c[0][1]
  a02 = c[0][0] - c[0][2]
  a12 = c[0][1] - c[0][2]
  b01 = c[0][0] - c[1][0]
  b02 = c[0][0] - c[2][0]
  b12 = c[1][0] - c[2][0]
  for i in range(3):
    if ((c[i][0] - c[i][1]) != a01) or (c[i][0] - c[i][2] != a02) or (c[i][1] - c[i][2] != a12):
      return False
    if ((c[0][i] - c[1][i]) != b01 or (c[0][i] - c[2][i]) != b02 or (c[1][i] - c[2][i]) != b12):
      return False

  return True

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

Submission status: Accepted

Solution code:
A = [list(map(int,input().split())) for _ in range(3)]
C = [0,0,0]
for j in range(3):
    for i in range(3):
        C[j] += A[i][j]
R = [0,0,0]
for i in range(3):
    for j in range(3):
        R[i] += A[i][j]
if (C[0]-C[1])%3==0 and (C[1]-C[2])%3==0 and (R[0]-R[1])%3==0 and (R[1]-R[2])%3==0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7

def main():
    c=[[]for _ in range(3)]
    for i in range(3):
        c[i]=LI()
    a=[0,0,0]
    b=[0,0,0]
    for i in range(3):
        b[i]=c[0][i]
        
    for i in range(1,3):
        a[i]=c[i][0]-b[0]
        
    flag=1
    
    for i in range(3):
        for j in range(3):
            if c[i][j]!=a[i]+b[j]:
                flag=0
                
    if flag==1:
        print("Yes")
    else:
        print("No")
        
    
            
    


main()

Submission status: Accepted

Solution code:
def main():
    c = [[int(x) for x in input().split()] for _ in range(3)]
    all_sum = 0
    answer = True
    for i in range(3):
        all_sum += sum(c[i])
    if all_sum % 3 == 0:
        all_sum //= 3
    else:
        answer = False
    now_sum = 0
    for i in range(3):
        now_sum += c[i][i]
    if now_sum != all_sum:
        answer = False
    now_sum = 0
    for i in range(3):
        now_sum += c[i][2 - i]
    if now_sum != all_sum:
        answer = False
    print("Yes" if answer else "No")


if __name__ == '__main__':
    main()

Submission status: Accepted

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

D = [[0]*3 for _ in range(2)]
for i in range(2):
    for j in range(3):
        D[i][j] = C[i+1][j]-C[i][j]

flag = True
if D[0][0] == D[0][1] and D[0][1] == D[0][2] and D[0][2] == D[0][0]:
    pass
else:
    flag = False

if D[1][0] == D[1][1] and D[1][1] == D[1][2] and D[1][2] == D[1][0]:
    pass
else:
    flag = False

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

Submission status: Accepted

Solution code:
C = []

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

def f():
    for i in range(2):
        if not C[i + 1][0] - C[i][0] == C[i + 1][1] - C[i][1] == C[i + 1][2] - C[i][2]:
            return False
    for i in range(2):
        if not C[0][i + 1] - C[0][i] == C[1][i + 1] - C[1][i] == C[2][i + 1] - C[2][i]:
            return False
    return True

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