Problem:


Score : 300 points

Problem Statement

You are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N.
Determine if we can repeat the following operation zero or more times so that the sequences a and b become equal.

Operation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two actions simultaneously:

Add 2 to a_i.

Add 1 to b_j.

Constraints

1 ≤ N ≤ 10 000

0 ≤ a_i,b_i ≤ 10^9 (1 ≤ i ≤ N)

All input values are integers.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 .. a_N
b_1 b_2 .. b_N

Output

If we can repeat the operation zero or more times so that the sequences a and b become equal, print Yes; otherwise, print No.

Sample Input 1

3
1 2 3
5 2 2

Sample Output 1

Yes

For example, we can perform three operations as follows to do our job:

First operation: i=1 and j=2. Now we have a = \{3,2,3\}, b = \{5,3,2\}.

Second operation: i=1 and j=2. Now we have a = \{5,2,3\}, b = \{5,4,2\}.

Third operation: i=2 and j=3. Now we have a = \{5,4,3\}, b = \{5,4,3\}.

Sample Input 2

5
3 1 4 1 5
2 7 1 8 2

Sample Output 2

No

Sample Input 3

5
2 7 1 8 2
3 1 4 1 5

Sample Output 3

No



Sample input:
3
1 2 3
5 2 2


Sample output:
Yes

Submission status: Runtime Error

Solution code:
N = int(input())
st = input().split()
a = [int(i) for i in input().split()]
A = sum(a)
b = [int(i) for i in input().split()]
B = sum(b)
def cost(n):
    if n == 0:
        return [0, 0]
    elif n < 0:
        return [0, -n]
    elif n > 0 and n % 2 == 0:
        return [n//2, 0]
    else:
        return [(n+1)//2, 1]

K = B - A
PC = 0
MC = 0
for i in range(N):
    c = cost(b[i] - a[i])
    PC += c[0]
    MC += c[1]
if PC <= K and MC <= K and ((K-PC)*2 == (K-MC)):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
n = int(input)
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(n):
  if a[i] > b[i]:
    print('No')
    sys.exit(0)
print('Yes')

Submission status: Runtime Error

Solution code:
import numpy as np
import math

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sum_dif =  sum(B) - sum(A)

difference = list(np.array(B) - np.array(A))
manipulation_A = sum([(d//2) for d in difference if d > 0])
manipulation_B = sum([-d for d in difference if d < 0])

if sum_dif < man_required_A + man_required_B:
    print("No")
else:
    print("Yes")

Submission status: Runtime Error

Solution code:
import numpy as np
import math

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sum_dif =  sum(B) - sum(A)

difference = list(np.array(B) - np.array(A))
manipulation_A = sum([d//2 for d in difference if d > 0])
manipulation_B = sum([-d for d in difference if d < 0])

if sum_dif < man_required_A + man_required_B:
    print("No")
else:
    print("Yes")

Submission status: Runtime Error

Solution code:
import numpy as np
import math

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sum_dif =  sum(B) - sum(A)

difference = list(np.array(B) - np.array(A))
manipulation_A = sum([d // 2 for d in difference if d > 0])
manipulation_B = sum([-d for d in difference if d < 0])

if sum_dif < man_required_A + man_required_B:
    print("No")
else:
    print("Yes")

Submission status: Runtime Error

Solution code:
class State:
  def __init__(self, n, c0, c1):
    self.n = len(c0)
    self.c0 = c0
    self.c1 = c1
    self.nok = 0

  def operate(self):
    for i in xrange(self.nok,self.n):
      if(self.c0[i]<self.c1[i] or i==self.n-1):
        self.c0[i] += 2
        break
    for i in xrange(self.nok,self.n):
      if(self.c0[i]>self.c1[i] or i==self.n-1):
        self.c1[i] += 1
        if(self.c0[i]==self.c1[i]):
          self.nok = i
        break


if __name__=='__main__':
  n = int(raw_input()) 
  c0 = map(int, raw_input().split())
  c1 = map(int, raw_input().split())

  nop = sum(c1) - sum(c0)  
  s = State(n, c0, c1)
  for i in xrange(nop):
    s.operate()
    print s.c0
    print s.c1

  
  if (c0==c1):
    print 'Yes'
  else:
    print 'No'

Submission status: Runtime Error

Solution code:
class State:
  def __init__(self, n, c0, c1):
    self.n = n
    self.c0 = c0
    self.c1 = c1
    self.nok = -1

  def operate(self):
    for i in xrange(self.nok,self.n):
      if(self.c0[i]<self.c1[i] or i==self.n-1):
        self.c0[i] += 2
        break
    for i in xrange(self.nok,self.n):
      if(self.c0[i]>self.c1[i] or i==self.n-1):
        self.c1[i] += 1
        if(self.c0[i]==self.c1[i]):
          self.nok = i
        break


if __name__=='__main__':
  n = int(raw_input()) 
  c0 = map(int, raw_input().split())
  c1 = map(int, raw_input().split())

  nop = sum(c1) - sum(c0)  
  s = State(n, c0, c1)
  for i in xrange(nop):
    s.operate()
    print s.c0
    print s.c1

  
  if (c0==c1):
    print 'Yes'
  else:
    print 'No'

Submission status: Runtime Error

Solution code:
def operation(c0,c1,n):
  for i in range(n):
    if(c0[i]<c1[i]):
      c0[i] += 2
      break
  for i in range(n):
    if(c0[i]>c1[i]):
      c1[i] += 1
      break
    if(i==n-1):
      c1[i] += 1


if __name__=='__main__':
  n = int(raw_input()) 
  c0 = map(int, raw_input().split())
  c1 = map(int, raw_input().split())

  nop = sum(c1) - sum(c0)  

  #print c0
  #print c1

  if(nop>0):
    for i in range(nop): 
      if(c0==c1):
        break
      operation(c0,c1,n)
      #print c0
      #print c1

  if (c0==c1):
    print 'Yes'
  else:
    print 'No'

Submission status: Runtime Error

Solution code:
from sys import stdin
ans = 'Yes'
n= int(stdin.readline())
a = map(int,stdin.readline().split())
b = map(int,stdin.r.eadline().split())
a.sort()
b.sort()
for i in xrange(n):
 if a[i] > b[i]:
  ans = 'No'
print ans

Submission status: Runtime Error

Solution code:

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sumA = 0
sumB = 0
sumAB = 0

for i in range(n):
    sumA += A[i]
    sumB += B[i]

for i in range(n):
    if A[i] < B[i]:
        sumAB += int((b[i] - a[i]) / 2 + 0.5)

if sumAB <= sumB - sumA:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

for i in range(n):
    sumA = A[i] + sumA
    sumB = B[i] + sumB

if sumA < sumB:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
n = int(input())
A = list(map(int, input().readline().split()))
B = list(map(int, input().readline().split()))

for i in range(n):
    sumA = A[i] + sumA
    sumB = B[i] + sumB

if sumA < sumB:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
    def main():
        _ = input()
        a_list = map(int, input().split())
        b_list = map(int, input().split())
        diffs = map(lambda a, b: b - a, a_list, b_list)
        total = 0
        count = 0
        for diff in diffs:
            if diff > 0:
                count += diff // 2
                total += diff % 2
            else:
                count += -diff
                total += diff
        if count <= total:
            print("Yes")
        else:
            print("No")
     
     
    if __name__ == '__main__':
        main()

Submission status: Runtime Error

Solution code:
def solve(a, b):
    a_copy = a[:]
    if a == b:
        return True

    elif len(a) == 1:
        if a[0] > b[0]:
            return False
        else:
            return solve([a[0]+2], [b[0]+1])

    check = 0
    for i in range(len(a)):
        for j in range(len(a)):
            if a[i] + 1 <= b[i] and b[j] < a[j]:
                a[i] += 2
                b[j] += 1
                check = 1
                break
        if check == 1:
            break
            
    if a_copy == a:
        return False

    k = 0
    while k < len(a):
        if a[k] == b[k]:
            a.pop(k)
            b.pop(k)
            continue
        k += 1

    return solve(a, b)


if __name__ == '__main__':
    N = int(input())

    a = input().rstrip().split(' ')
    b = input().rstrip().split(' ')

    a = [int(a[i]) for i in range(N)]
    b = [int(b[i]) for i in range(N)]

    if solve(a, b):
        print('Yes')
    else:
        print('No')

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = 0
b = 0
for i in range(N):
    if B[i] >= A[i]:
        a += (B[i] - A[i] + 1) // 2
        b += (B[i] - A[i]) % 2
    else:
        b += A[i] - bytes[i]
print('Yes' if a >= b else 'No')

Submission status: Runtime Error

Solution code:
if __name__ == "__main__":
    N = int(input())
    A = list(map(int, (input().split(' '))))
    B = list(map(int, (input().split(' '))))

    move = sum(B) - sum(A)
    # A行目が大きい場合は、B行目は+１ずつしかできないので追い越せない。
    if move < 0:
        print('No')
        return 0
    Amove = 0
    Bmove = 0
    # 3 4 2
    # 5 3 4
    for i in range(N):
        # A[i] = 4, B[i] = 3 -> Amove = 1
        if A[i] > B[i]:
            Amove += A[i] - B[i]
        # A[i] = 3, B[i] = 5 -> Bmove = 1
        # A[i] = 2, B[i] = 4 -> Bmove = 1
        elif A[i] < B[i]:
            Bmove += (B[i] - A[i]) // 2
    # Amove = 1, Bmove = 1
    if Amove > Bmove:
        print('No')
    else:
        print('Yes')

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

def check(X, Y):
	if(X == Y):
		print("Yes")
	elif((sum(X) >= sum(Y)) and (X != Y) ):
		print("No")
	else:
		if(X[0] == Y[0]):
			del X[0]
			del Y[0]
			check(X, Y)
		elif(X[0] == Y[0] - 1):
			X[0] += 2
			Y[0] += 1
			check(X, Y)
		elif(X[0] < Y[0] - 1):
			X[0] += 2
			Y[1] += 1
			check(X, Y)
		elif(X[0] > Y[0]):
			X[1] += 2
			Y[0] += 1
			check(X, Y)

check(a, b)

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

def check(X, Y):
	print(X)
	print(Y)
	print("")
	if(X == Y):
		print("Yes")
	elif((sum(X) >= sum(Y)) and (X != Y) ):
		print("No")
	else:
		if(X[0] == Y[0]):
			del X[0]
			del Y[0]
			check(X, Y)
		elif(X[0] == Y[0] - 1):
			X[0] += 2
			Y[0] += 1
			check(X, Y)
		elif(X[0] < Y[0] - 1):
			X[0] += 2
			Y[1] += 1
			check(X, Y)
		elif(X[0] > Y[0]):
			X[1] += 2
			Y[0] += 1
			check(X, Y)

check(a, b)

Submission status: Runtime Error

Solution code:
import numpy as np
import math

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sum_dif =  sum(B) - sum(A)

if sum_dif < 0:
    print("No")
elif sum_dif == 0:
    if A == B:
        print("Yes")
    else:
        print("No")
else:
    difference = list(np.array(A) - np.array(B))
    man_required_A = sum([math.ceil(- a/2) for a in difference if a < 0])
    man_required_B = sum([b for b in difference if b > 0])
    
    admissible_A = sum_dif - man_required_A - man_required_B
    
    if admissible > 0:
        print("Yes")
    else:
        print("No")

Submission status: Runtime Error

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

suma = sumb = num = 0
for i in range(N):
    suma += A[i]
    sumb += B[i]
    if A[i] < B[i]:
        num += ceil((B[i] - A[i]) / 2)

if A == B:
    print("Yes")
else:
    if suma >= sumb:
        print("No")
    else:
        if num > sumb - suma:
            print("No")
        else:
            print("Yes")

Submission status: Runtime Error

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

suma = sumb = num
for i in range(N):
    suma += A[i]
    sumb += B[i]
    if A[i] < B[i]:
        num += (B[i] - A[i]) // 2

if A == B:
    print("Yes")
else:
    if suma >= sumb:
        print("No")
    else:
        if num > sumb - suma:
            print("No")
        else:
            print("Yes")

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split(' ')))
b=list(map(int,input().split(' ')))
a1=0
b1=0
cnt=0
for i in range(0,n):
    if a[i]==b[i]:
        cnt+=1
    elif a[i]>b[i]:
        b1+=a[i]-b[i]
    else:
        if (b[i]-a[i])%2==0:
            a1+=(b[i]-a[i])//2
        else:
            a1+=(b[i]+1-a[i])//2
            b1+=1:
print("Yes")

Submission status: Runtime Error

Solution code:
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
p = sum(P)
q = sum(Q)
m = 0
l = 0
for i in range(N):
    if P[i] - Q[i] > 0:
        if (P[i] - Q[i]) % 2 == 1:
            #p += (P[i] - Q[i]) * 2
            m += (P[i] - Q[i] + 1) // 2
            l += 1
        else:
            #p += (P[i] - Q[i])
            m += (P[i] - Q[i]) // 2
    elif P[i] - Q[i] < 0:
        #q += (Q[i] - P[i])
        l += (Q[i] - P[i])

a = p + m * 2 + l
b = q + m + l


if a > b:
    print("No")
elif a == b:
    print("Yes")
else:
    if l % m == 0:
        print("Yes")
    else:
        print("No")

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

if sum(a) > sum(b):
    print('No')
if (sum(a)+sum(b))%3 = 1:
    print('No')
else:
    print('Yes')

Submission status: Runtime Error

Solution code:
N = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

li = [x-y for (x,y) in zip(a,b)]

s_p = 0
s_m = 0

for i in len(li):
     if li[i] > 0:
       s_p += li[i]   
     elif li[i] < 0
       s_m += li[i]
     elif li[i] == 0:
          pass

if (abs(s_p) + (abs(s_m) % 2) <= N:
     print('Yes')
else:
     print('No')

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

def check(X, Y):
	if(X == Y):
		print("Yes")
	elif((sum(X) >= sum(Y)) and (X != Y) ):
		print("No")
	else:
		if(X[0] == Y[0]):
			del X[0]
			del Y[0]
			check(X, Y)
		elif(X[0] == Y[0] + 1):
			X[0] += 2
			Y[0] += 1
			del X[0]
			del Y[0]
			check(X, Y)
		elif(X[0] < Y[0] + 1):
			X[0] += 2
			Y[1] += 1
			check(X, Y)
		elif(X[0] > Y[0]):
			X[1] += 2
			Y[0] += 1
			check(X, Y)

check(a, b)

Submission status: Runtime Error

Solution code:
N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
res=0
for i in range(len(a)):
  res+=a-b
if res<=0:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
p = sum(P)
q = sum(Q)
m = 0
l = 0
for i in range(N):
    if P[i] - Q[i] > 0:
        if (P[i] - Q[i]) % 2 == 1:
            #p += (P[i] - Q[i]) * 2
            m += (P[i] - Q[i] + 1) // 2
            l += 1
        else:
            #p += (P[i] - Q[i])
            m += (P[i] - Q[i]) // 2
    elif P[i] - Q[i] < 0:
        #q += (Q[i] - P[i])
        l += (Q[i] - P[i])

a = p + m * 2
b = q + m

if a > b:
    print("No")
elif a == b:
    print("Yes")
else:
    if l % m == 0:
        print("Yes")
    else:
        print("No")

Submission status: Runtime Error

Solution code:
N = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

li = [x-y for (x,y) in zip(a,b)]

if max(abs(li)) % 2 == 0:
     print('No')
elif (max(abs(li)) / 2) > N:
     print('No')
else:
     print('Yes')

Submission status: Runtime Error

Solution code:
N = int(input())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))

cl = [0 for n in range(N)]
res = False

for n in range(N):
    cl[n] = al[n] - bl[n]

# if sum(cl) > 0:
#     res = False
# else:
cl = sorted(cl)
cp = 0
cm = 0
for c in cl:
     if c > 0:
        cp += c
    if c < 0:
         cm += c
res = cp <= abs(cm/2)
    
if res:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
N = int(input())
A = input()
ai = A.split()
B = input()
bi = B.split()
i = 0
a = []
b = []
for i in range(N):
    a.append(int(ai[i]))
    b.append(int(bi[i]))

i = 0
asum = 0
bsum = 0
for i in range(N):
    asum += a[i]
    bsum += b[i]

c = True
j = 0
if asum > bsum:
    print("No")
    c = False
elif asum == bsum:
    for j in range(N):
        if a[j] != b[j]:
            print("No")
            c = False
            break
    if c:
        print("Yes")
        c = False
else:
    k = 0
    Da = 0
    Db = 0
    d = bsum - asum 
    while Da < d and Db < d:
        if a[k] < b[k]:
            Da += (b[k] - a[k]) // 2
            a[k] += ((b[k] - a[k]) // 2) * 2 
        elif a[k] == b[k]:
            k += 1
        else:
            Db += a[k] - b[k]
            b[k] += a[k] - b[k]
        if k == N:
            break
if c:
    for j in range(N):
        if a[j] != b[j]:
            print("No")
            c = False
            break
    if c:
        if (N - Da) * 2 == (N - Db) * 1:
            print("Yes")
        else:
            print("No")N = int(input())
A = input()
ai = A.split()
B = input()
bi = B.split()
i = 0
a = []
b = []
for i in range(N):
    a.append(int(ai[i]))
    b.append(int(bi[i]))

i = 0
asum = 0
bsum = 0
for i in range(N):
    asum += a[i]
    bsum += b[i]

c = True
j = 0
if asum > bsum:
    print("No")
    c = False
elif asum == bsum:
    for j in range(N):
        if a[j] != b[j]:
            print("No")
            c = False
            break
    if c:
        print("Yes")
        c = False
else:
    k = 0
    Da = 0
    Db = 0
    d = bsum - asum 
    while Da < d and Db < d:
        if a[k] < b[k]:
            Da += (b[k] - a[k]) // 2
            a[k] += ((b[k] - a[k]) // 2) * 2 
        elif a[k] == b[k]:
            k += 1
        else:
            Db += a[k] - b[k]
            b[k] += a[k] - b[k]
        if k == N:
            break
if c:
    for j in range(N):
        if a[j] != b[j]:
            print("No")
            c = False
            break
    if c:
        if (N - Da) * 2 == (N - Db) * 1:
            print("Yes")
        else:
            print("No")

Submission status: Runtime Error

Solution code:
import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque


# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))



##### main #####

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


def main():
	n = I()
	a = LI()
	b = LI()

	pos = 0
	neg = 0
	


	for i in range(n):
		diff = a[i]-b[i]

		if diff>0:
			pos += abs(diff)
		else:
			neg += abs(diff)

	g = gcd(pos,neg)
	if 2*(pos//g) == neg//g:
		print("Yes")
	else:
		print("No")


if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
N = int(input())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))

cl = [0 for n in range(N)]
res = False

for n in range(N):
    cl[n] = al[n] - bl[n]

if sum(cl) > 0:
    res = False
else:
    while True:
        cl = sorted(cl)
        print(cl)
        if sum(cl) > 0:
            res = False
            break
        elif cl[N-1] <= 0:
            res = True
            break
        cl[0] += cl[N-1] * 2
        cl[N-1] += cl[N-1] * -1

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

Submission status: Runtime Error

Solution code:
n = int(input())
numbersA = input().split()
numbersB = input().split()
sumA = 0
sumB = 0
diffNum = 0

for i in range(0,n):
	if numbersA[i] != numbersB[i]:
		diffNum += 1
	sumA += int(numbersA[i])
	sumB += int(numbersB[i])	

if (sumA <= sumB) and (diffNum <= sumB - sumA) and ((sumB - sumA) % diffNum) % 2 == 0:
	print("Yes")
else:
	print("No")

# 14 20

Submission status: Runtime Error

Solution code:
import random
n=int(input())
ans=[]
mem=[]
lowid=0
midid=0
highid=n
while(lowid<=highid):
    midid = lowid+1
    print(midid)
    ans.append(str(input()))
    if (ans[-1]=='Vacant'):
        print(midid)
        exit()
    elif ans[-1] == 'Male':
        lowid=random.randint(0,n-1)
    else:
        lowid=random.randint(0,n-1)

Submission status: Runtime Error

Solution code:
import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque


# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))



##### main #####

def main():
	n = I()
	a = LI()
	b = LI()

	for i in range(n-1):
		diff = a[i]-b[i]

		if diff == 0:
			pass

		elif diff>0:
			b[i] += diff
			a[i+1] += 2*diff

		elif diff<0:
			if diff%2:
				a[i] += abs(diff)+1
				b[i+1] += (abs(diff)+1)//2
				a[i+1] += 2
				b[i] += 1
			else:
				a[i] += abs(diff)
				b[i+1] += abs(diff)//2
		print(a)
		print(b)
		print("-"*10)

	print(a)
	print(b)
	print("-"*10)


	if a[-1]<=b[-1]:
		print("Yes")
	else:
		print("No")

if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
n = int(sys.stdin.readline())
a = list(map(int, (sys.stdin.readline()).split()))
b = list(map(int, (sys.stdin.readline()).split()))
a += [-n, 0]
b += [ n, 0]
a, b = np.array(a), np.array(b)
r = - a + b
c = np.zeros((n+2, 2*n))
for i in range(n):
  c[i,i] = 2
  c[i, n+i] = -1
  c[n,i] = c[n+1,i] = c[n, n+i] = 1
  c[n+1, n+i] = -1
b = np.linalg.pinv(c).dot(r)
print("Yes") if np.min(b) > 0 else print("No")

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

C = [A[i]-B[i] for i in range(N)]
if 0 in C:
    print("Yes")
    exit()

Cplus = list(filter(lambda x:x>0, C))
Cminas = list(filter(lambda  x:x<0, C))

Cplus.sort(reverse=True)
pl = len(Cplus)
Cminas.sort()
ml = len(Cminas)

i = 0
j = 0
while True:
    if Cplus[i] > 0:
        if Cminas[j] <= -2:
            Cplus[i] -= 1
            Cminas[j] += 2
        else:
            j += 1
            if j >= ml:
                print("No")
                break
    else:
        i += 1
        if i >= pl:
            print("No")
            break

    if (Cplus[-1] <= 0) & (Cminas[-1] <= 0):
        print("Yes")
        break

Submission status: Runtime Error

Solution code:
5
2 7 1 8 2
3 1 4 1 5