Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, c = map(int, raw_input().split())
A = map(int, raw_input().split())
B = map(int, raw_input().split())

MOD = 10**9+7

memo = [[0]*401 for i in xrange(401)]
for i in xrange(401):
    temp = 0
    for j in xrange(401):
        temp = (temp + pow(j, i, MOD)) % MOD
        memo[i][j] = temp

dp = {}
def dfs(i, r):
    if i==-1:
        return r==0
    if (i, r) in dp:
        return dp[i, r]
    res = 0
    for j in xrange(0, r+1):
        res = (res + (memo[j][B[i]]-memo[j][A[i]-1])*dfs(i-1, r-j)) % MOD
    dp[i, r] = res
    return res
print dfs(n-1, c)

Fixed submission:
n, c = map(int, raw_input().split())
A = map(int, raw_input().split())
B = map(int, raw_input().split())

MOD = 10**9+7

memo = [[0]*401 for i in xrange(401)]
for i in xrange(401):
    temp = 0
    for j in xrange(401):
        temp = (temp + pow(j, i, MOD)) % MOD
        memo[j][i] = temp
S = [memo[A[i]-1] for i in xrange(n)]
T = [memo[B[i]] for i in xrange(n)]

dp = [[-1]*(c+1) for i in xrange(n)]
def dfs(i, r):
    if i==-1:
        return r==0
    if dp[i][r] != -1:
        return dp[i][r]
    res = 0
    s = S[i]; t = T[i]
    for j in xrange(0, r+1):
        res = (res + (t[j]-s[j])*dfs(i-1, r-j)) % MOD
    dp[i][r] = res
    return res
print dfs(n-1, c)
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
s = raw_input()

MOD = 10**9+7
dp = [1]
for i in xrange(n):
    dp2 = [0]*(i+2)
    for j in xrange(i+1):
        dp2[j+1] += dp[j]
        dp2[j+1] %= MOD
    for j in xrange(1, i+1):
        dp2[j-1] += 2*dp[j]
        dp2[j-1] %= MOD
    dp2[0] = (dp2[0] + dp[0]) % MOD
    dp = dp2
print dp2[len(s)]

Fixed submission:
n = input()
s = raw_input()

MOD = 10**9+7
dp = [1]
for i in xrange(n):
    dp2 = [0]*(i+2)
    for j in xrange(i+1):
        dp2[j+1] += dp[j]
        dp2[j+1] %= MOD
    for j in xrange(1, i+1):
        dp2[j-1] += 2*dp[j]
        dp2[j-1] %= MOD
    dp2[0] = (dp2[0] + dp[0]) % MOD
    dp = dp2
print dp2[len(s)]
Buggy python submission (verdict: Runtime Error):
N = int(input())
if N % 2 == 0:
  print(0.5)
else:
  print((N-(N-1))/2N)


Fixed submission:
N = int(input())
if N % 2 == 0:
  print(0.5000000000)
else:
  print((N+1)/(2*N))

Buggy python submission (verdict: Runtime Error):
N = int(input())
if N % 2 == 0:
  print(0.5000000000)
else:
  print((N+1)//2N)


Fixed submission:
N = int(input())
if N % 2 == 0:
  print(0.5000000000)
else:
  print((N+1)/(2*N))

Buggy python submission (verdict: Runtime Error):
N = int(input())
if N %2 ==0:
  prnit(0.5)
else:
  print(2/(N+1))

Fixed submission:
N = int(input())
if N % 2 == 0:
  print(0.5000000000)
else:
  print((N+1)/(2*N))

Buggy python submission (verdict: Runtime Error):
N = int(input(''))
if (N % 2) == 0:
  print(round(2/N),10)
else:
  print(round((N+1)/2N),10)

Fixed submission:
N = int(input())
if N % 2 == 0:
  print(0.5000000000)
else:
  print((N+1)/(2*N))

Buggy python submission (verdict: Runtime Error):
N = int(input(''))
if (N % 2) == 0:
  print(N/2N)
else:
  print((N+1)/2N)

Fixed submission:
N = int(input())
if N % 2 == 0:
  print(0.5000000000)
else:
  print((N+1)/(2*N))

Buggy python submission (verdict: Runtime Error):
N = int(input())
if N % 2 == 0:
  print(0.5000000000)
else:
  print((N+1)/2N)


Fixed submission:
N = int(input())
if N % 2 == 0:
  print(0.5000000000)
else:
  print((N+1)/(2*N))

Buggy python submission (verdict: Runtime Error):
N = int(input())
if N % 2 == 0:
  print(0.5000000000)
else:
  print(float((N+1)/2N))

Fixed submission:
N = int(input())
if N % 2 == 0:
  print(0.5000000000)
else:
  print((N+1)/(2*N))

Buggy python submission (verdict: Runtime Error):
N = int(input())
if N % 2 == 0:
  print(0.5000000000)
else:
  print((N+1)/2N)

Fixed submission:
N = int(input())
if N % 2 == 0:
  print(0.5000000000)
else:
  print((N+1)/(2*N))

Buggy python submission (verdict: Runtime Error):
N = int(input())
if N % 2 == 0:
  print(0.5000000000)
else:
  print((N-1)/2N)


Fixed submission:
N = int(input())
if N % 2 == 0:
  print(0.5000000000)
else:
  print((N+1)/(2*N))
Buggy python submission (verdict: Runtime Error):
K,X = map(int,input().split())
L1 = list(range(X-K+1,X+K-1))
L2 =' '.join(L1)
print(L2)

Fixed submission:
K,X = map(int,input().split())
L1 = list(range(X-K+1,X+K))
L1_str = [str(n) for n in L1]
L2 = ' '.join(L1_str)
print(L2)
Buggy python submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i in range(1,N+1):
  if len(str(i)) % 2 == 1:
    sum += 1
print(sum)

Fixed submission:
A,B,C =  map(int,input().split())
print(max(0,B+C-A))

Buggy python submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i in range[1,N+1]:
  if len(i) % 2 == 1:
    sum += 1
print(sum)

Fixed submission:
A,B,C =  map(int,input().split())
print(max(0,B+C-A))

Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
print(max(0,B+C-A))

Fixed submission:
A,B,C =  map(int,input().split())
print(max(0,B+C-A))
Buggy python submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i in range[1,N+1]:
  if len(str(i)) % 2 == 1:
    sum += 1
print(sum)

Fixed submission:
N = int(input())
sum = 0
for i in range(1,N+1):
  if len(str(i)) % 2 == 1:
    sum += 1
print(sum)

Buggy python submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i in range[1,N+1]:
  if len(i) % 2 == 1:
    sum += 1
print(sum)

Fixed submission:
N = int(input())
sum = 0
for i in range(1,N+1):
  if len(str(i)) % 2 == 1:
    sum += 1
print(sum)

Buggy python submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i in range[1,N+1]:
  if len(i) // 2:
    i += 1
  else:
    sum += 1
    i += 1
print(sum)

Fixed submission:
N = int(input())
sum = 0
for i in range(1,N+1):
  if len(str(i)) % 2 == 1:
    sum += 1
print(sum)
Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split()) 
if (A % 2) == (B % 2):
  print(abs((A+B)/2))
else:
  print(IMPOSSIBLE)

Fixed submission:
A,B = map(int,input().split()) 
if (A+B) % 2 == 0:
  print(int((A+B)/2))
else:
  print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
r = int(input())
print(3r**2)

Fixed submission:
r = int(input())
print(3*r**2)
Buggy python submission (verdict: Runtime Error):
n=int(input())
p = list(map(int, input().split()))
sum = 0
for i in range(1,n):
  if p[i+1]>p[i]>p[i-1] or p[i-1]>p[i]>p[i+1]:
    sum +=1
print(sum)


Fixed submission:
n=int(input())
p = list(map(int, input().split()))
sum = 0
for i in range(1,n-1):
  if p[i+1]>p[i]>p[i-1] or p[i-1]>p[i]>p[i+1]:
    sum +=1
print(sum)
Buggy python submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i in range(0,N+1):
  sum + i = sum
print(sum)

Fixed submission:
N = int(input())
sum = 0
for i in range(0,N+1):
  sum+=i
print(sum)

Buggy python submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i in range(0,N):
  sum + i = sum
print(sum)

Fixed submission:
N = int(input())
sum = 0
for i in range(0,N+1):
  sum+=i
print(sum)

Buggy python submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i  in N:
  sum + i = sum
print(sum)

Fixed submission:
N = int(input())
sum = 0
for i in range(0,N+1):
  sum+=i
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
  n = int(input())
  l = []
  for i in range(n):
    l.append(input())
  for i in range(n):
    l[i] = ''.join(sorted(l[i]))
  l.sort()
  
  fact = [1 for i in range(n+1)]
  for i in range(1, n+1):
    fact[i] = fact[i-1]*i
  
  res = 0
  count = 1
  for i in range(1,n):
    if l[i-1] == l[i]:
      count += 1
      if i == n-1:
        res += int(fact[count]/(fact[count - 2]*fact[2]))
    elif count > 1:
      res += int(fact[count]/(fact[count - 2]*fact[2]))
      count = 1
    elif count == 1:
      pass
    else:
      print('error!')
      quit()
  
  print(res)
  
if __name__ == "__main__":
  main()

Fixed submission:
def main():
  n = int(input())
  l = []
  d = {}
  res = 0
  for i in range(n):
    s = input()
    l.append(''.join(sorted(s)))
  for j in range(n):
    if d.get(l[j]) is None:
      d[l[j]] = 1
    elif d.get(l[j]) > 0:
      d[l[j]] += 1
      res += d[l[j]] - 1
    else:
      print('error!')
      quit()
  
  return res
  
if __name__ == "__main__":
  res = main()
  print(res)
Buggy python submission (verdict: Runtime Error):
def dfs(graph, node, dist):
    if graph[node-1][2] == 1:
        return
    else:
        graph[node-1][2] = 1
        graph[node-1][3] += dist
        if graph[node-1][3] % 2 == 0:
            graph[node-1][4] = 1
        else:
            pass
        ll = graph[node-1][0]
        for i in range(len(ll)):
            dfs(graph, ll[i], graph[node-1][3] + graph[node-1][1][i]);

def main():
    n = int(input())
    edge = []
    for i in range(n-1): edge.append(list(map(int,input().split())))

# graph[[node, node, ...], [dist, dist, ...], [reached or not], 
#       [dist from root], [color]]
    graph = [[[],[],0,0,0] for i in range(n)]
    for i in range(n-1):
        node1 = edge[i][0]
        node2 = edge[i][1]
        weight = edge[i][2]
        graph[node1-1][0].append(node2)
        graph[node2-1][0].append(node1)
        graph[node1-1][1].append(weight)
        graph[node2-1][1].append(weight)
    
    dfs(graph, 1, 0)
    for i in range(n):
        print(graph[i][4])

if __name__ == "__main__":
    main()


Fixed submission:
import sys
sys.setrecursionlimit(1000000)

def dfs(graph, node, dist):
    if graph[node-1][2] == 1:
        return
    else:
        graph[node-1][2] = 1
        graph[node-1][3] += dist
        if graph[node-1][3] % 2 == 0:
            graph[node-1][4] = 1
        else:
            pass
        ll = graph[node-1][0]
        for i in range(len(ll)):
            dfs(graph, ll[i], graph[node-1][3] + graph[node-1][1][i]);

def main():
    n = int(input())
    edge = []
    for i in range(n-1): edge.append(list(map(int,input().split())))

# graph[[node, node, ...], [dist, dist, ...], [reached or not], 
#       [dist from root], [color]]
    graph = [[[],[],0,0,0] for i in range(n)]
    for i in range(n-1):
        node1 = edge[i][0]
        node2 = edge[i][1]
        weight = edge[i][2]
        graph[node1-1][0].append(node2)
        graph[node2-1][0].append(node1)
        graph[node1-1][1].append(weight)
        graph[node2-1][1].append(weight)
    
    dfs(graph, 1, 0)
    for i in range(n):
        print(graph[i][4])

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
n = int(input())
res = n-1 if n%(n-1) == int(n/(n-1)) else 0
i = 2
while i*i <= n:
  if n%i == 0:
    if n%(i-1) == int(n/(i-1)):
      res += i-1
    if i*i != n:
      if n%(int(n/i)-1) == int(n/(int(n/i)-1)):
        res += int(n/i) - 1
  else:
    pass
  i += 1
print(res)

Fixed submission:
n = int(input())
if n == 1:
  print(0)
  quit()
else:
  res = n-1 if n%(n-1) == int(n/(n-1)) else 0
i = 2
while i*i <= n:
  if n%i == 0:
    if n%(i-1) == int(n/(i-1)):
      res += i-1
    if i*i != n:
      if n%(int(n/i)-1) == int(n/(int(n/i)-1)):
        res += int(n/i) - 1
  else:
    pass
  i += 1
print(res)
Buggy python submission (verdict: Runtime Error):
n,k = list(map(int, input().split()))
s = input()
if s[n-1] == '1':
	s += '0'
else:
	s += '1'
c = []

j = 0
for i in range(1, n+1):
	if s[i-1] == s[i]:
		j += 1
	else:
		c.append([s[i-1], j+1])
		j = 0

for i in range(1, len(c)):
	c[i][1] += c[i-1][1]

if 2*k >= 2*len(c):
	print(c[-1][1])
	quit()
else:
	p = 0
	res = 0
	if s[0][0] == '0':
		res = c[1][1] if k == 1 else c[2*k+1][1]
		p += 1
	else:
		res = c[2][1] if k == 1 else c[2*k][1]
		p += 2

	while p+2*k < len(c):
		res = max(res, c[p+2*k][1] - c[p-1][1])
		p += 2

	print(res)
	quit()

Fixed submission:
a,b = list(map(int,input().split()))
s = 0
if a >= b:
    s += a
    a -= 1
else:
    s += b
    b -= 1
s += max(a,b)
print(s)

Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int,input().split()))
ans = 1
for i in range(1,n):
    flag = 1
    for j in range(i):
        if h[j] > h[i]:
            flag = 0
            break
        else:
            pass
    if flag:
        ans += 1
print(ans)


Fixed submission:
a,b = list(map(int,input().split()))
s = 0
if a >= b:
    s += a
    a -= 1
else:
    s += b
    b -= 1
s += max(a,b)
print(s)
Buggy python submission (verdict: Runtime Error):
    l=list(map(int,input().split()))
    l.sort()
    print(int(0.5*l[0]*l[1]))

Fixed submission:
l=list(map(int,input().split()))
l.sort()
print(int(0.5*l[0]*l[1]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
h = list(map(int, input().split()))
h.append(0)
count=0
while 1:
  flag=0
  for i in range(N):
    if h[i]>0:
      h[i] -= 1
      flag = 1
      if h[i+1]==0:
        count+=1
      else:
        pass
  if flag==0:
    break
print(count)

Fixed submission:
D = int(input())
print('Christmas' + ' Eve'*(25-D))
Buggy python submission (verdict: Runtime Error):
N = int(input())
h = list(map(int,input().split()))
h.append(0)

count=0
while 1:
  flag = 0
  for i in range(N):
    if h[i]>0:
      h[i] -= 1
      flag = 1
      if h[i+1] == 0:
        count += 1
      else:
        pass
  if flag == 0:
    break
print(count)

Fixed submission:
N,K=list(map(int,input().split()))
h=[]
for i in range(N):
  h.append(int(input()))
h.sort()

minimum=1000000000
for j in range(N-K+1):
  minimum=min(minimum, h[j+K-1]-h[j])
print(minimum)

Buggy python submission (verdict: Runtime Error):
N = int(input())
h = list(map(int,input().split()))
h.append(0)

count=0
while 1:
	flag=0
    for i in range(N):
    	if h[i]>0:
        	h[i] -= 1
      	    flag = 1
        if h[i+1] == 0:
        	count += 1
        else:
        	pass
    if flag == 0:
    	break
print(count)

Fixed submission:
N,K=list(map(int,input().split()))
h=[]
for i in range(N):
  h.append(int(input()))
h.sort()

minimum=1000000000
for j in range(N-K+1):
  minimum=min(minimum, h[j+K-1]-h[j])
print(minimum)

Buggy python submission (verdict: Runtime Error):
N = int(input())
h = list(map(int,input().split()))
h.append(0)

count=0
while 1:
  flag=0
  for i in range(N):
    if h[i]>0:
      h[i] -= 1
      flag = 1
      if h[i+1] == 0:
        count += 1
      else:
        pass
  if flag == 0:
    break
print(count)

Fixed submission:
N,K=list(map(int,input().split()))
h=[]
for i in range(N):
  h.append(int(input()))
h.sort()

minimum=1000000000
for j in range(N-K+1):
  minimum=min(minimum, h[j+K-1]-h[j])
print(minimum)
Buggy python submission (verdict: Runtime Error):
if not N==100:
    print(N*pow(100, D))
else:
    print(101*pow(100, D))

Fixed submission:
D,N = list(map(int, input().split()))

if not N==100:
    print(N*pow(100, D))
else:
    print(101*pow(100, D))

Buggy python submission (verdict: Runtime Error):
if N==100:
    print((N+1)*pow(100, D))
else:
    print(N*pow(100, D))

Fixed submission:
D,N = list(map(int, input().split()))

if not N==100:
    print(N*pow(100, D))
else:
    print(101*pow(100, D))
Buggy python submission (verdict: Runtime Error):
import math
N=int(input())
i=2
digitSum=pow(10,5)
while A<math.sqrt(N):
    A=i
    B=N-A
    A_digitsum=0
    while A>10:
        A_digitsum += N%10
        A = A//10
    while B>10:
        B_digitsum += N%10
        B = B//10
    if digitSum > A_digitsum+B_digitsum:
        digitSum = A_digitsum+B_digitsum
print(digitSum)

Fixed submission:
import math
N=int(input())
i=2
digitSum=pow(10,5)
A=int(2)
while i<=int(N/2)+1:
    A=i
    B=N-A
    A_digitsum=0
    while A>=10:
        A_digitsum += A%10
        A = A//10
    if A<10:
        A_digitsum+=A
    B_digitsum=0
    while B>=10:
        B_digitsum += B%10
        B = B//10
    if B<10:
        B_digitsum+= B
    if digitSum > A_digitsum+B_digitsum:
        digitSum = A_digitsum+B_digitsum
    i+=1
print(digitSum)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
minimum=3*pow(10, 5)
east=[]
for i in range(N):
    east.append([S[:i].count('E'), S[i+1:].count('E')])
for i in range(N):
    X=S[:i]
    Y=S[i+1:]
    candidate = len(X)-east[i][0]+east[i][1]
    minimum = min(candidate, minimum)
print(minimum)


Fixed submission:
N=int(input())
S=input()
minimum=3*pow(10, 5)
east=[0]
for i in range(1,N+1):
    if S[i-1]=='E':
        east.append(east[i-1]+1)
    else:
        east.append(east[i-1])
for i in range(N):
    candidate = i-east[i]+(east[N]-east[i+1])
    minimum = min(candidate, minimum)
print(minimum)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
minimum=3*pow(10, 5)
for i in range(N):
    X=S[:i]
    Y=S[i+1:]
    if S[i]=='E':
        candidate = (len(X)-X.count(S[i]))+Y.count(S[i])
    else:
        candidate = X.count(S[i])+(len(Y)-Y.count(S[i]))
    minimum = min(candidate, minimum)
print(minimum)

Fixed submission:
N=int(input())
S=input()
minimum=3*pow(10, 5)
east=[0]
for i in range(1,N+1):
    if S[i-1]=='E':
        east.append(east[i-1]+1)
    else:
        east.append(east[i-1])
for i in range(N):
    candidate = i-east[i]+(east[N]-east[i+1])
    minimum = min(candidate, minimum)
print(minimum)
Buggy python submission (verdict: Runtime Error):
A,B,C,K=list(map(int.input().split()))
print(((-1)**K)*(A-B))

Fixed submission:
A,B,C,K=list(map(int,input().split()))
print(((-1)**(K%2))*(A-B))
Buggy python submission (verdict: Runtime Error):
a,b=list(map(int, input().aplit()))
if a<=b:
    print(a)
else:
    print(a-1)

Fixed submission:
a,b=list(map(int, input().split()))
if a<=b:
    print(a)
else:
    print(a-1)
Buggy python submission (verdict: Runtime Error):
grid=[]
for i in range(3):
    grid.append(list(map(int,input().split())))
S=''
for i in range(3):
    S=S+grid[i][i]
print(S)


Fixed submission:
grid=[]
for i in range(3):
    grid.append(input())
S=''
for i in range(3):
    S=S+grid[i][i]
print(S)
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=list(map(int,input().split()))
bucket=[]
for i in range(N):
    if S[i]=='P':
        bucket[0]+=1
    elif S[i]=='W':
        bucket[1]+=1
    elif S[i]=='G':
        bucket[2]+=1
    else:
        bucket[3]+=1
if 4 - bucket.count(0)==3:
    print('Three')
else:
    print('Four')

Fixed submission:
N=int(input())
S=list(map(str,input().split()))
bucket=[0*i for i in range(4)]
for i in range(N):
    if S[i]=='P':
        bucket[0]+=1
    elif S[i]=='W':
        bucket[1]+=1
    elif S[i]=='G':
        bucket[2]+=1
    else:
        bucket[3]+=1
if 4 - bucket.count(0)==3:
    print('Three')
else:
    print('Four')
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

#N枚のカードがあり、i枚目のカードにはaiという数が書かれています。
#AliceとBobはこれらのカードを使ってゲームを行います。ゲームでは2人が交互に1枚ずつカードを取っていきます。Aliceが先にカードを取ります。
#2人が全てのカードを取った時ゲームは終了し、取ったカードの数の合計がその人の得点になります。2人とも自分の得点を最大化するように最適戦略を取った時、AliceはBobより何点多く獲得できるかを求めてください。

#1<=N<=100, 1<=ai<=100, 入力は整数
#数値例 N=3, a=(2,7,4), Answer: 5

N = int(input())
numbers = list(map(int, input().split()))
Alice_point = 0
Bob_point = 0

numbers.sort()
print(numbers)

while True:
    Alice_point += numbers[0]
    try:
        Bob_point += numbers[1]
        numbers.remove(numbers[0])
        numbers.remove(numbers[0])
    except IndexError:
        break

print(Alice_point - Bob_point)

Fixed submission:
N = int(input())
numbers = list(map(int, input().split()))
Alice_point = 0
Bob_point = 0

numbers.sort(reverse=True)

while True:
    try:
        Alice_point += numbers[0]
        Bob_point += numbers[1]
        numbers.remove(numbers[0])
        numbers.remove(numbers[0])
    except IndexError:
        break

print(Alice_point - Bob_point)
Buggy python submission (verdict: Runtime Error):
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")


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

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

a2=gridNumber[1][0] - b1
a3=gridNumber[2][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")
Buggy python submission (verdict: Runtime Error):
N=int(input())
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
B1=[0*i for i in range(N)]
B2=[0*i for i in range(N)]

B1[0]=A1[0]
B2[0]=A2[0]
for i in range(0,N-1):
    B1[i+1]=B1[i]+A1[i+1]
    B2[i+1]=B2[i]+A2[i+1]
maximum=B1[0]+B2[N-1]
for i in range(1,N):
    point=B1[i]+(B2[N-1]-B2[i-1])
    maximum=max(maximum,point)
print(maximum)


Fixed submission:
X=int(input())
A=int(input())
B=int(input())
X=X-A
while X>=B:
    X=X-B
print(X)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
B1=[0*i for i in range(N)]
B2=[0*i for i in range(N)]

B1[0]=A1[0]
B2=[0]=A2[0]
for i in range(0,N-1):
    B1[i+1]=B1[i]+A1[i+1]
    B2[i+1]=B2[i]+A2[i+1]
maximum=B1[0]+B2[N-1]
for i in range(1,N):
    point=B1[i]+(B2[N-1]-B2[i-1])
    maximum=max(maximum,point)
print(maximum)


Fixed submission:
N=int(input())
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
B1=[0*i for i in range(N)]
B2=[0*i for i in range(N)]

B1[0]=A1[0]
B2[0]=A2[0]
for i in range(0,N-1):
    B1[i+1]=B1[i]+A1[i+1]
    B2[i+1]=B2[i]+A2[i+1]
maximum=B1[0]+B2[N-1]
for i in range(1,N):
    point=B1[i]+(B2[N-1]-B2[i-1])
    maximum=max(maximum,point)
print(maximum)

Buggy python submission (verdict: Runtime Error):
N=int(input())
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
B1=[0*i for i in range(N)]
B2=[0*i for i in range(N)]

B1[0]=A1[0]
B2=[0]=A2[0]
for i in range(0,N-1):
    B1[i+1]=B1[i]+A1[i+1]
    B2[i+1]=B2[i]+A2[i+1]
maximum=B1[0]+B2[N-1]
for i in range(1,N):
    point=B1[i]+(B2[N-1]-B2[i-1])
    maximum=max(maximum,point)
print(maximum)


Fixed submission:
N=int(input())
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
B1=[0*i for i in range(N)]
B2=[0*i for i in range(N)]

B1[0]=A1[0]
B2[0]=A2[0]
for i in range(0,N-1):
    B1[i+1]=B1[i]+A1[i+1]
    B2[i+1]=B2[i]+A2[i+1]
maximum=B1[0]+B2[N-1]
for i in range(1,N):
    point=B1[i]+(B2[N-1]-B2[i-1])
    maximum=max(maximum,point)
print(maximum)
Buggy python submission (verdict: Runtime Error):

N=int(input())
Destinations=[[0,0,0]]
for i in range(N):
    Destinations.append(list(map(int, input().split())))

for i in range(N-1):
    x_distance = Destinations[i+1][1] - Destinations[i][1]
    y_distance = Destinations[i+1][2] - Destination[i][2]
    if x_distance < 0:
        x_distance = -x_distance
    if y_distance < 0:
        y_distance = -y_distance
    move_distance = x_distance+y_distance

    move_time = Destinations[i+1][0] Destinations[i][0]

    if move_distance == 0:
        print("No")

    if move_distance > move_time*1:
        print("No")
    elif move_distance%2 == move_time%2:
        print("Yes")
    else:
        print("No")

Fixed submission:
N=int(input())
Destinations=[[0,0,0]]
for i in range(N):
    Destinations.append(list(map(int, input().split())))

for i in range(N):
    x_distance = Destinations[i+1][1] - Destinations[i][1]
    y_distance = Destinations[i+1][2] - Destinations[i][2]
    if x_distance < 0:
        x_distance = -x_distance
    if y_distance < 0:
        y_distance = -y_distance
    move_distance = x_distance+y_distance

    move_time = Destinations[i+1][0] - Destinations[i][0]

    if move_distance == 0:
        print("No")
        break

    if move_distance > move_time*1:
        print("No")
        break
    elif move_distance%2 == move_time%2:
        pass
    else:
        print("No")
        break

    if i == N-1:
        print("Yes")