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

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

p = 0
for x, y in zip(a, b):
    if x > y:
        p += x - y
    else:
        p -= (y - x) // 2

if p <= 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

largeA = 0
largeB = 0
for i in range(N):
  d = A[i] - B[i]
  if d > 0:
    largeA += d
  elif d < 0:
    d = -d
    # 奇数の差をつぶす
    if d % 2 == 1:
      d = -1
      B[i] -= 1
    largeB += d

dsum = sum(B) - sum(A)
if dsum >= 0 and largeB//2 <= dsum and largeA <= dsum:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
n, a, b = input(), map(int, raw_input().split()), map(int, raw_input().split())
c = [a[i] - b[i] for i in xrange(n)]
print 'Yes' if sum([-x / 2 for x in c if x < 0]) >= sum([x for x in c if x > 0]) else 'No'

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
s = sum([a[i]-b[i] if a[i]>b[i] else -((b[i]-a[i])//2) for i in range(N)])
print("Yes" if s < 1 else "No")

Submission status: Accepted

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

C = [B[i]-A[i] for i in range(N)]

P = sum(filter(lambda x: x<0, C))
M = list(filter(lambda x: x>1, C))
M = list(map(lambda x: x//2, M))

M = sum(M)
if abs(M) >= abs(P):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

dif = sum(b) - sum(a)

if dif < 0:
	print("No")
	exit(0)

count = 0
for i in range(N):
	if (a[i] % 2) != (b[i] % 2):
		b[i] += 1
		count += 1
	
	if b[i] < a[i]:
		count += (a[i] - b[i])

if count > dif:
	print("No")
	exit(0)

if ((dif - count) % 2) == 0:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
N = int(input())
st = input().split()
a = [0 for i in range(N)]
A = 0
for i in range(N):
    a[i] = int(st[i])
    A += a[i]
st = input().split()
b = [0 for i in range(N)]
B = 0
for i in range(N):
    b[i] = int(st[i])
    B += b[i]
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: Accepted

Solution code:
n = int(raw_input())

a = map(int, raw_input().split())
b = map(int, raw_input().split())

ac=0
bc=0
for i in range(n):
   if (a[i]>b[i]):
      bc=bc+(a[i]-b[i])
   if (a[i]<b[i]):
      ac=ac+(b[i]-a[i]+1)/2
      bc=bc+(b[i]-a[i])%2

if ac>=bc:
   print "Yes"
else:
   print "No"

Submission status: Accepted

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

minus = 0
for v in map(lambda x: x[1] - x[0], zip(a, b)):
    if v < 0:
        minus += v
    else:
        minus += v // 2

print("Yes" if minus >= 0 else "No")

Submission status: Accepted

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

x = 0
y = 0
for a,b in zip(A,B):
  if a > b:
    x += a-b
  else:
    y += (b-a)//2

print('Yes' if y >= x else 'No')

Submission status: Accepted

Solution code:
n=int(input())
line=input().split()
line2=input().split()

a=[]
asum=0
b=[]
bsum=0
extraa=0
for i in range(n):
    a.append(int(line[i]))
    b.append(int(line2[i]))
    asum+=a[-1]
    bsum+=b[-1]

for i in range(n):
    if a[i]<b[i]:
        extraa+=(b[i]-a[i])//2
    if a[i]>b[i]:
        extraa-=a[i]-b[i]
if extraa>=0 and asum<=bsum:
    print ("Yes")
else:
    print("No")

Submission status: Accepted

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

ca = 0
cb = 0
for i in range(n):
    if a[i] > b[i]:
        ca += a[i] - b[i]
    elif a[i] < b[i]:
        cb += (b[i] - a[i]) // 2

if ca <= cb:
    ans = "Yes"
else:
    ans = "No"
print(ans)

Submission status: Accepted

Solution code:

import math

def main():
    N = int(input())

    a = list(map(int, input().split(' ')))
    b = list(map(int, input().split(' ')))

    man_count = 0

    for i in range(N):
        if a[i] < b[i]:
            da = math.ceil((b[i] - a[i])/2)
            a[i] += 2*da
            man_count += da

        if a[i] > b[i]:
            db = a[i] - b[i]
            b[i] += db
            man_count -= db

    if man_count >= 0:
        print('Yes')
    else:
        print('No')


main()

Submission status: Accepted

Solution code:
import random
import functools
import itertools
import math

R = lambda type_ = "int": list(map(eval(type_), input().split(' ')))

n = int(input())
a = R()
b = R()

pos, neg = 0, 0

for i in range(n):
    if a[i] > b[i]:
        neg += a[i] - b[i]
    else:
        pos += (b[i] - a[i]) // 2

#print('{} {}'.format(pos, neg))
print('Yes' if pos >= neg else 'No')

Submission status: Accepted

Solution code:
def LI(): return list(map(int, input().split()))
def LS(): return input().split()
def I(): return int(input())
def S(): return input()

n = I()
a = LI()
b = LI()
plus = 0
minus = 0
for i in range(n):
    c = a[i] - b[i]
    if c > 0:
        plus += c
    else:
        minus -= abs(c)//2
if minus + plus <= 0 :
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N=int(input())
a=list(map(int,input().split(' ')))
b=list(map(int,input().split(' ')))
i=0
A=0
B=0
n=0
while i < N:
    n+=(b[i]-a[i])
    if (a[i]-b[i])>=0:
        B+=(a[i]-b[i])
        i+=1
    elif (a[i]-b[i])<0 and int(abs(a[i]-b[i])%2)==0:
        A+=int(abs(a[i]-b[i])//2)
        i+=1
    else:
        A+=int(abs(a[i]-b[i])//2 + 1)
        B+=1
        i+=1
if max(n,A,B)==n:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

total_do=sum(b)-sum(a)
must_do_a=0
must_do_b=0

for i in range(N):
	dist=a[i]-b[i]
	if dist<0:
		dist=-dist
		must_do_a+=int((dist+1)/2)
		if dist%2!=0:
			must_do_b+=1
	elif dist>0:
		must_do_b+=dist
left_a=total_do-must_do_a
left_b=total_do-must_do_b

if total_do>=0 and must_do_a>=must_do_b and left_a*2==left_b:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:

def solve(A, B):
    t = 0
    s = 0
    for a, b in zip(A, B):
        if a > b:
            s += a - b
        if b > a:
            x = b - a
            t += x // 2
    if s <= t:
        return True
    else:
        return False

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

if solve(A, B):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())

astr = input().split()
bstr = input().split()

dp = []#b-a, plus
dm = []#minus
for (ai, bj)  in zip(astr, bstr):
    d = int(bj)-int(ai)
    if d < 0:
        dm.append(d)
    else:
        dp.append(d)
    
plus = 0
for d in dp:
    plus += d//2

if plus<abs(sum(dm)):
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
m=sum(b)-sum(a)
if m<0:
    print("No")
elif m==0:
    ok=True
    for i in range(n):
        if a[i]!=b[i]:
            ok=False
            break
    print("Yes" if ok else "No")
else:
    upb=0
    for i in range(n):
        if a[i]>b[i]:
            upb+=a[i]-b[i]
            b[i]=a[i]
    for i in range(n):
        if a[i]<b[i]:
            use=(b[i]-a[i])//2
            upb-=use
    print("Yes" if upb<=0 else "No")

Submission status: Accepted

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

K = sum(B) - sum(A)
C = 0; D = 0
for i in range(N):
    p = B[i] - A[i]
    if p > 0:
        C += (p+1)//2
        D += (p%2)
    else:
        D += -p
if C < K:
    D += 2*(K - C)
    C = K
if K >= 0 and C == D == K:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# B
N = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))

cnt_plus_a_2 = 0
cnt_plus_a_1 = 0
cnt_plus_b = 0

for i in range(N):
    if a_list[i] < b_list[i]:
        cnt_plus_a_2 += (b_list[i] - a_list[i]) // 2
        cnt_plus_a_1 += (b_list[i] - a_list[i]) % 2
    elif a_list[i] > b_list[i]:
        cnt_plus_b += -(b_list[i] - a_list[i])
        
if cnt_plus_a_2 >= cnt_plus_b:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(raw_input())
a = map(int, raw_input().split())
b = map(int, raw_input().split())
c = [a[i] - b[i] for i in xrange(n)]
f = -sum(c)
if f < 0:
    print 'No'
    quit()
t = f
for i in xrange(n):
    if c[i] < 0:
        k = (-c[i] + 1) / 2
        t -= k
        c[i] += k * 2
if t < 0:
    print 'No'
    quit()
s = f
for i in xrange(n):
    s -= c[i]
if s < 0:
    print 'No'
    quit()
if t * 2 == s:
    print 'Yes'
else:
    print 'No'

Submission status: Accepted

Solution code:
def solve(sa, sb):
    d = 0
    for a, b in zip(sa, sb):
        if a >= b:
            d += a - b
        else:
            d -= (b - a) // 2
    return d <= 0


n = input()
sa = map(int, input().split())
sb = map(int, input().split())

print('Yes' if solve(sa, sb) else 'No')

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    move = sum(b)-sum(a)
    if move<0:
        print("No")
        return 0
    amove = 0
    bmove = 0
    for i in range(n):
        if a[i] < b[i]:
            amove += (b[i]-a[i]+1)//2
            bmove += (b[i]-a[i])%2
        elif a[i] > b[i]:
            bmove += a[i]-b[i]
    if max(amove,bmove) <= move:
        print("Yes")
    else:
        print("No")

main()

Submission status: Runtime Error

Solution code:
n=int(input())

a=list(map(int,input().split()))
b=list(map(int,input().split()))

a.sort()
b.sort()

#sum(a)+2*k=sum(b)+k
#k=(sum(a)-sum(b))

k=suma-sumb
#
#1 1 1 6
#2 2 2 3

cnt=0
for i in range(n):
    if a[i]>b[i]:
        cnt+=b[i]-a[i]
    elif a[i]<b[i]:
        cnt+=(-1)*((a[i]-b[i])//2)

if cnt>=k:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    ba = 0
    bb = 0
    for i in range(N):
        if a[i] > b[i]:
            ba += a[i] - b[i]
        if b[i] > a[i]:
            bb += (b[i] - a[i]) // 2

    if bb = ba:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

ba = 0, bb = 0
for i in range(N):
    if a[i] > b[i]:
        ba += a[i] - b[i]
    if b[i] > a[i]:
        bb += (b[i] - a[i])//2

if bb >= ba:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    s = 0
    sm = 0
    for x, y in zip(a,b):
        tmp = x-y
        sm += tmp
        if tmp == -1
            tmp = 0
        if tmp > 0:
            tmp *= 2
        s += tmp
    if s > 0 or sm > 0:
        print('No')
    else:
        print('Yes')

    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    s = 0
    sm = 0
    for x, y in zip(a,b):
        tmp = x-y
        sm += tmp
        if tmp == -1
            tmp = 0
        if tmp > 0:
            tmp *= 2
        s += tmp
    if s > 0 or a > 0:
        print('No')
    else:
        print('Yes')

    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n,*a=map(int,open(0).read().split())
u=d=z=r=0
for i,j in zip(a[:n],a[n:]):
    if j-i>0:u+=(j-i)//2*2;r+=(j-i)%2
    elif j-i==0:z+=1
    else:d+=[j-i]
print("Yes" if u+2*d>=0 else "No")

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
cou = 0
for j,k in zip(a,b):
  if j<k:
    cou += (k-j)//2
  elif j>k:
    cou -= (j-k)
if cou=>0:
  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()))
sa = sum(a)
sb = sum(b)
counta = 0
countb = 0
for i,j in zip(a,b):
    if j > i:
        if j%i:
            countb += 1
        counta += (j-i+1)//2
    elif i > j:
        countb += i-j
if counta <= sb-sa and countb <= sb-sa:
    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()))

cnt_a, cnt_b = sum(a), sum(b)
ans = "No"
i = 0
cnt = 0
while cnt < cnt_b - cnt_a:
    if a[i] < b[i]:
        cnt += int((b[i] - a[i]) / 2 + 0.5)
    else:
        cnt += a[i] - b[i]
    i += 1
    if i == n:
        ans = "Yes"

print(ans)

Submission status: Runtime Error

Solution code:
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N = i()
a = l()
b = l()
if sum(a) >= sum(b):
    print('No')
    exit()
num = sum(b)-sum(a)
cnt1 = 0
cnt2 = 0
for i in range(N):
    if a[i] > b[i]:
        cnt1 += a[i]-b[i]
    if a[i] < b[i]:
        cnt2 += math.ceil((b[i]-a[i])/2)
if cnt1 > num or cnt2 > num:
    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()))

cnt = sum(B) - sum(A)
a, b = cnt, cnt
for i in range(N):
    if A[i] < B[i]:
        b -= (B[i]-A[i+1])//2
    elif A[i] > B[i]:
        a -= A[i]-B[i]
    if a < 0 or b < 0:
        print("No")
        break
else:
    print("Yes")

Submission status: Runtime Error

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

cnt = sum(B) - sum(A)
a, b = cnt, cnt
for i in range(N):
    if A[i] < B[i]:
        cnt -= (B[i]-A[i+1])//2
    elif A[i] > B[i]:
        a -= A[i]-B[i]
    if a < 0 or b < 0:
        print("No")
        break
else:
    print("Yes")

Submission status: Runtime Error

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

a_gap = 0
b_gap = 0
for i in range(n):
    if A[i]>B[i]:
        a_gap+=A[i]-B[i]
    if A[i]<B[i]:
        b_gap+=B[i]-A[i]

if a_gap*2-b_gap>0:
    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()))
cnt = 0
for a_, b_ in zip(a, b):
    if a_ > b_:
        cnt += a - b
    else:
        cnt -= (b - a) // 2
if cnt <= 0:
    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()))

c = max(0, sum(B) - sum(A))
ca = 0
cb = 0

for a, b in zip(A, B):
    if a < b:
        ca += (b - a + 1) // 2
        cb += (b - a) % 2
    if a > b:
        cb += a - b

if c < max(ca + cb):
    print('No')
else:
    print('Yes')

Submission status: Runtime Error

Solution code:
n, *p = map(int, open(0).read().split())
s = sum(j - i - max(0, i - j) - max(0, j - i)%2 for i, j in zip(p, p[n:]))
print("NO" if [s >= 0 == s%2 ::2] else "Yes")

Submission status: Runtime Error

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

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

diff1 = [] # a > b
diff2 = [] # b > a
for i, j in zip(a, b):
    if i > j:
        diff1.append(i - j)
    elif j > i:
        diff2.append(j - i)

if cnt < sum(diff1):
    print("No")
    sys.exit()
else:
    cnt -= sum(diff1)

a_add = cnt + sum(diff1) # 2を足す
b_add = cnt # 1を足す

c = []
for i in diff2:
    if i % 2 == 0:
        a_add -= i//2
    else:
        c.append(1)
        a_add -= (i - 1)//2
a_add -= sum(c)
b_add -= sum(c)
if a_add*2 == b_add:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list( map(int, input().split()))
b = list( map(int, input().split()))

sa = sum(a)
sb = sum(b)

al = sb-sa

if al<0:
    print('No')
    exit()

doub = 0
sing = 0

for i in range(n):
    diff = b[i]-a[i]
    if diff > 0:
        doub += diff//2
        sing += diff%2
    if diff < 0:
        sing += -diff

dnokori = al - doub
snokori = al - sing

if dnokori < 0 or snokori<0:
    print('No')
    exit()

if snokori/dnokori == 2:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list( map(int, input().split()))
b = list( map(int, input().split()))

sa = sum(a)
sb = sum(b)

al = sb-sa

if al<0:
    print('No')
    exit()

double = 0
single = 0

for i in range(n):
    diff = b[i]-a[i]
    diff_ = -diff
    if diff > 0:
        double += diff//2
        single += diff%2
    if diff < 0:
        single += diff_

dnokori = al - double
snokori = al - single


if dnokori < 0 or snokori<0:
    print('No')
    exit()

if snokori/dnokori == 2:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input()))
b = list(map(int, input()))
p = 0
q = 0
r = 0
s = 0
d = 0
for i in range(0, n):
  p += a[i]
  q += b[i]
  r += a[i] % 2
  s += b[i] % 2
  d += a[i] - b[i]
if d == p - q and d >= 0 and (r-s)%2 == d%2:
  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()))

aPlus = 0
bPlus = 0

for i in range(n):
    if b[i] > a[i]:
        if (b[i]-a[i]) % 2 == 0:
            aPlus += b[i]-a[i]
            bPlus += (b[i]-a[i])//2
        else:
            print("No")
            exit()
    else:
        aPlus += 2*(a[i]-b[i])
        bPlus += a[i]-b[i]

if aPlus//bPlus==2:
    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()))
k=0
for i in range(n):
    if a[i]<b[i]:
        p=b[i]-a[i]
        a[i]+=(p+1)//2*2
        while p>0 and k<n:
            if a[k]-b[k]>p:
                b[k]+=p
                p=0
            elif a[k]-b[k]>0:
                b[k]=a[k]
                p-=a[k]-b[k]
            k+=1
            # print(a,b,k,p,i)

# print(a,b)
if a==b and p==0:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l1=LI()
  l2=LI()

  sm1=sum(l1)
  sm2=sum(l2)

  nm=sm2-sm1
  if nm<0:
    return 'No'

  nm1=0
  for i in range(n):
    a=l1[i]
    b=l2[i]

    if a<b:
      _a=(b-a+1)//2
      l1[i]+=_a*2
      nm1+=_a

nm2=0
  for i in range(n):
    a=l1[i]
    b=l2[i]

    if a>b:
      _a=a-b
      nm2+=_a

  # print(nm,nm2)
  if nm<max(nm1,nm2):
    return 'No'

  return 'Yes'

# main()
print(main())

Submission status: Runtime Error

Solution code:
import heapq

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

sub1 = 0
li = []

for i in range(n):
    if a[i] > b[i]:
        sub1 += a[i] - b[i]
    else:
        heapq.heappush(li, a[i] - b[i])

for i in range(sub1):
    x = -heapq.heappop(li)
    if x >= 2:
        heapq.heappush(li, 2-x)
    else:
        print('No')
        exit()

print('Yes')

Submission status: Runtime Error

Solution code:
import heapq

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

sub1 = 0
li = []

for i in range(n):
    if a[i] > b[i]:
        sub1 += a[i] - b[i]
    else:
        heapq.heappush(li, a[i] - b[i])

for i in range(sub1):
    x = -heapq.heappop(li)
    if x >= 2:
        heapq.heappush(li, x-2)
    else:
        print('No')
        exit()

print('Yes')

Submission status: Runtime Error

Solution code:
from sys import stdin
n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))
b = list(map(int,stdin.readline().rstrip().split()))
A = sum(A);B = sum(B)
count = 0
total = B-A
for i,j in zip(a,b):
    if i < j:
        count += (j-i+1)//2
    else:
        count += i-j
if count <= total:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
import numpy as np


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

    C = np.zeros([2, N], dtype=np.int64)
    C[0, :] = A
    C[1, :] = B
    d = np.diff(C, axis=0)
    cnt1 = np.sum(d)
    cnt2 = np.sum(d)
    for i in range(len(d[0, :])):
        if d[0, i] > 0:
            cnt1 -= dimport numpy as np


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

    C = np.zeros([2, N], dtype=np.int64)
    C[0, :] = A
    C[1, :] = B
    d = np.diff(C, axis=0)
    cnt1 = np.sum(d)
    cnt2 = np.sum(d)
    for i in range(len(d[0, :])):
        if d[0, i] > 0:
            cnt1 -= d[0, i] / 2
        if d[0, i] < 0:
            cnt2 -= -d[0, i]

    print('Yes' if min(cnt1, cnt2) >= 0 else 'No')


main()
[0, i] / 2
        if d[0, i] < 0:
            cnt2 += d[0, i]

    print('Yes' if max(cnt1, cnt2) >= 0 else 'No')


main()

Submission status: Runtime Error

Solution code:
import numpy as np


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

    if A == B:
        print('Yes')
    else:
        C = np.zeros([2, N], dtype=np.int32)
        C[0, :] = A
        C[1, :] = B
        d = np.diff(C, axis=0)
        a = np.sum(d[d > 0])
        b = np.sum(d[d < 0])
        if a >= -2 * b:
            print('Yes')
        else:
            if (-2 * b - a) % len(d[d > 0]) == 0 and (
                (-2 * b - a) / len(a)) % 2 == 0:
                print('Yes')
            else:
                print('No')


main()

Submission status: Runtime Error

Solution code:
_=int(input())
print('Yes' if sum(list(map(int,input().split()))<=sum(list(map(int,input().split()))) else 'No')

Submission status: Runtime Error

Solution code:
N = int(input())
lia=[int(it) for it in input().split()]
lib=[int(it) for it in input().split()]
lip=[lia[i]-lib[i] for i in range(N)]
sb = 0
for i in range(N):
  if (lip[i]>0):
    sb+=lip[i]
sa2 = 0
for i in range(N):
  if (lip[i]<0):
    sa2=(-lip[i])//2
sas-=sb*2
x = sum(lib)-sum(lia)
if (x<0):
  print ("No")
else:
  if (sa2>=sb):
    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_b = 0
b_a = 0
for i in range(N):
    if A[i] > B[i]:
        a_b += A[i] - B[i]
        
    else
        b_a += (B[i] - A[i]) // 2

if a_b <= b_a
    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()))

num = 0
diff = 0
for i in range(N):
    if A[i] != B[i]:
        num += 1
        
    diff += A[i] - B[i]
    
if diff%num == 0 and diff >= 0:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func().strip().split()
    A = []
    for i in range(N):
        A.append(int(input_raw[i]))

    input_raw = read_func().strip().split()
    B = []
    for i in range(N):
        B.append(int(input_raw[i]))

    s_bigger_A = 0L
    s_bigger_B = 0L
    for i in range(N):
        if A[i]> B[i]:
            s_bigger_A += A[i] - B[i] + (A[i] - B[i]) % 2
        else:
            s_bigger_B += B[i] - A[i]

    if 2 * s_bigger_A  <= s_bigger_B:
        print h
    else:
        print "No"


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func().strip().split()
    A = []
    for i in range(N):
        A.append(int(input_raw[i]))

    input_raw = read_func().strip().split()
    B = []
    for i in range(N):
        B.append(int(input_raw[i]))

    s_bigger_A = 0L
    s_bigger_B = 0L
    for i in range(N):
        if A[i]> B[i]:
            s_bigger_A += A[i] - B[i]
        else:
            s_bigger_B += B[i] - A[i]

    if 2 * s_bigger_A  <= s_bigger_B:
        print h
    else:
        print "No"


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(int(input()))
B = list(int(input()))
diff = []
for i in range(N):
  diff.append(A[i] - B[i])
if abs(sum(diff)) == N:
  print("Yes"):
else:
  print("No")

Submission status: Runtime Error

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

if sum(a) <= sum(b):
    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()]
print('Yes' sum([max(A[i] - B[i], 0) for i in range(N)]) <= sum(B) - sum(A) if else 'No')

Submission status: Runtime Error

Solution code:
N = int(input())

print(0, flush=True)
s = input()
if s == "Vacant":
    exit()
n_next = 0
n = N

asked = set([0])
begin = 0
end = N

for i in range(20):
    q = abs((end - begin)) // 2
    if q in asked:
        q += 1
    print(q, flush=True)
    asked.add(q)
    s_n = input()
    if s_n == "Vacant":
        exit()
    elif s_n == s:
        # qより手前
        end = q
    else:
        # q より後ろ
        begin = q

Submission status: Runtime Error

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

A_sum = sum(A)
B_sum = sum(B)

#print(A_sum, '-', B_sum)
if A_sum > B_sum or (B_sum - A_sum) % 2 == 0:
    re = 'No'
else:
    diff = []
    for i in range(N):
        diff.append(A[i] - B[i])
        diff = sorted(diff)
    if abs(abs(diff(A[0])) - abs(diff(A[N-1]))) < abs(B_sum - A_sum):
        re = 'No'
    else:
        re = 'Yes'
print(re)

Submission status: Runtime Error

Solution code:
    def main():
        n = int(input())
        a = list(map(int,input().split()))
        b = list(map(int,input().split()))
     
     
        Flag = False
        biga = 0
        lessa = 0
        for i in range(3):
            if a[i] > b[i]:
                biga += a[i] - b[i]
            else:
     
                lessa += b[i] - a[i]
     
        tmp = lessa -(biga*2)
     
        if tmp >=0:
            print("Yes")
        else:
            print("No")
     
    if __name__ == "__main__":
        main()

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())
a_array = np.array(list(map(int, input().split(" "))))
b_array = np.array(list(map(int, input().split(" "))))


diff_array = b_array - a_array
diff = abs(np.sum(diff_array))

if diff == 0:
    print("Yes")


def update_diff(a_array, b_array):
    diff_array = a_array - b_array
    if np.sum(diff_array) == 0:
        print("Yes")
        exit()

    return np.where(diff_array < 0), np.where(diff_array > 0), diff_array


def judge(a_array, b_array):
    diff_array = a_array - b_array
    if np.sum(diff_array) == 0:
        print("Yes")
        exit()


b_index = None
for i in range(diff):
    candidate_a, candidate_b, diff_array = update_diff(a_array, b_array)

    if len(candidate_a[0]) == 0:
        a_array[candidate_b[0][0]] += 2
    else:
        a_array[candidate_a[0][0]] += 2
    if len(candidate_b[0]) == 0:
        if b_index is None:
            b_index = np.where(diff_array == 0)[0][0]
        b_array[b_index] += 1
    else:
        b_array[candidate_b[0][0]] += 1
    # print(a_array, b_array)
    judge(a_array, b_array)
    
print("No")

Submission status: Runtime Error

Solution code:
X, Y = list(map(int, input().split()))
if X % Y == 0:
    re = -1
elif X < Y:
    re = X
else:
    re = X * Y - X
print(re)