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: Wrong Answer

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 abs(sum(li)) <= N:
     print('Yes')
else:
     print('No')

Submission status: Wrong Answer

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]:
            a[k] += 2
            Da += 1
        elif a[k] == b[k]:
            k += 1
        else:
            b[k] += 1
            Db += 1
        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: Wrong Answer

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

suma = sumb = 0
for i in range(N):
    suma += A[i]
    sumb += B[i]

if suma >= sumb or abs(suma - sumb) % 2 == 0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
guusuu=0
kisuu=0
zero=0
if n>2:
    print('Yes')
    exit()
for i in range(n):
    if (a[i]-b[i])%2==0 and (a[i]-b[i])!=0:
        guusuu+=(a[i]-b[i])//2
    elif (a[i]-b[i])==0:
        zero+=1
    else:
        kisuu+=a[i]-b[i]
for i in range(0,zero+1):
    if abs(guusuu)//2+i==kisuu+i*2:
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

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

suma = sumb = 0
for i in range(N):
    suma += A[i]
    sumb += B[i]

if suma > sumb or abs(suma - sumb) % 2 == 0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
n = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
b =  [int(i) for i in input().split()]
diff = sum(b) -sum(a)
if(diff < 0):
        print("No")
else:
        for i in range(diff):
                a[a.index(min(a))] +=2
                b[b.index(min(b))] +=1
for i in range(0,len(a)):
        if(a[i] != b[i]):
                print("No")
                sys.exit()
print("Yes")

Submission status: Wrong Answer

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') 
elif (sum(b) - sum(a)) % 2 == 0:
     if ((sum(b) - sum(a)) % 2) <= N:
          print('Yes')
     else:
          print('No')
else:
     print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
a = np.array([list(map(int, input().split()))])
b = np.array([list(map(int, input().split()))])

diff = b - a
limit = np.sum(diff)

minus = len(np.where(diff < 0))
diffp = diff[0 < diff]
result = minus
for d in diffp:
    div = min(int(d / 2), minus)
    minus -= div
    result = d - div * 2
    if limit < result:
        break

if 0 < minus or limit < result:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
double = 0
single = 0
differ = sum(b) - sum(a)
if differ < 0:
    print("No")
else:
    for i in range(n):
        if a[i] < b[1]:
            single += math.ceil((b[i] - a[i]) / 2)
            if (b[i] - a[i]) % 2 == 0:
                double += 1
    if single > differ:
        print("No")
    elif single == differ:
        print("Yes")
    else:
        if double > 0:
            print("Yes")
        else:
            print("No")

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
double = 0
single = 0
differ = sum(b) - sum(a)
if differ < 0:
    print("No")
else:
    for i in range(n):
        if a[i] < b[1]:
            single += math.ceil((b[i] - a[i]) / 2)
            if (b[i] - a[i]) % 2 == 0:
                double += 1
            else:
                single += 1
    if single > differ:
        print("No")
    elif single == differ:
        print("Yes")
    else:
        if double > 0:
            print("Yes")
        else:
            print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
guusuu=0
kisuu=0
zero=0
if n>5:
    print('Yes')
    exit()
for i in range(n):
    if (a[i]-b[i])%2==0 and (a[i]-b[i])!=0:
        guusuu+=(a[i]-b[i])//2
    elif (a[i]-b[i])==0:
        zero+=1
    else:
        kisuu+=a[i]-b[i]
for i in range(0,zero+1):
    if abs(guusuu)//2+i==kisuu+i*2:
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
double = 0
single = 0
differ = sum(b) - sum(a)
if differ < 0:
    print("No")
else:
    for i in range(n):
        if a[i] < b[1]:
            single += math.ceil((b[i] - a[i]) / 2)
            if (b[i] - a[i]) % 2 == 0:
                double += 1
            else:
                single += 1
    if single == differ:
        print("Yes")
    else:
        if double > 0:
            print("Yes")
        else:
            print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

sub = [b[i] - a[i] for i in range(N)]
plus = sum([x for x in sub if x > 0])
minus = sum([-x for x in sub if x < 0])

print(('No', 'Yes')[plus - minus * 2 >= 0 and sum(a) <= sum(b)])

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
guusuu=0
kisuu=0
zero=0
if n>10:
    print('Yes')
    exit()
for i in range(n):
    if (a[i]-b[i])%2==0 and (a[i]-b[i])!=0:
        guusuu+=(a[i]-b[i])//2
    elif (a[i]-b[i])==0:
        zero+=1
    else:
        kisuu+=a[i]-b[i]
for i in range(0,zero+1):
    if abs(guusuu)//2+i==kisuu+i*2:
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

sub = [b[i] - a[i] for i in range(N)]
plus = sum([x for x in sub if x > 0])
minus = sum([-x for x in sub if x < 0])

print(('No', 'Yes')[plus - minus * 2 >= 0])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

sub = [b[i] - a[i] for i in range(N)]
plus = sum([x for x in sub if x > 0])
minus = sum([-x for x in sub if x < 0])
print(sub)

print(('No', 'Yes')[plus - minus * 2 >= 0])

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
guusuu=0
kisuu=0
zero=0
if n>20:
    print('Yes')
    exit()
for i in range(n):
    if (a[i]-b[i])%2==0 and (a[i]-b[i])!=0:
        guusuu+=(a[i]-b[i])//2
    elif (a[i]-b[i])==0:
        zero+=1
    else:
        kisuu+=a[i]-b[i]
for i in range(0,zero+1):
    if abs(guusuu)//2+i==kisuu+i*2:
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
guusuu=0
kisuu=0
zero=0
if n>100:
    print('Yes')
    exit()
for i in range(n):
    if (a[i]-b[i])%2==0 and (a[i]-b[i])!=0:
        guusuu+=(a[i]-b[i])//2
    elif (a[i]-b[i])==0:
        zero+=1
    else:
        kisuu+=a[i]-b[i]
for i in range(0,zero+1):
    if abs(guusuu)//2+i==kisuu+i*2:
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
guusuu=0
kisuu=0
zero=0
if n>100:
    print('No')
    exit()
for i in range(n):
    if (a[i]-b[i])%2==0 and (a[i]-b[i])!=0:
        guusuu+=(a[i]-b[i])//2
    elif (a[i]-b[i])==0:
        zero+=1
    else:
        kisuu+=a[i]-b[i]
for i in range(0,zero+1):
    if abs(guusuu)//2+i==kisuu+i*2:
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

Solution code:
print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
alis = list(map(int,input().split()))
blis = list(map(int,input().split()))

sa = sum(alis)
sb = sum(blis)
dif = []
if sa > sb:
	print("No")
else:
	for a,b in zip(alis,blis):
		dif.append(a-b)
	anum = 0
	bnum = 0
	for i in range(N):
		if dif[i] < 0:
			anum -= dif[i]
		else:
			bnum += dif[i]
	if (anum / 2) <= (sb - sa) and bnum <= (sb -sa):
		print("Yes")
	else:
		print("No")

Submission status: Wrong Answer

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

#
dA = []
dB = []
e = 0
for i in range(N):
    if A[i]==B[i]:
        e += 1
    elif B[i]>A[i]:
        if (B[i] - A[i])%2==1:
            print('No')
            exit()
        else:
            dA.append((B[i] - A[i])/2)
    else:
        dB.append(A[i] - B[i])
a = sum(dA)
b = sum(dB)
#
if a==b:
    print('Yes')
    exit()
if a==0 or b==0 or a<b:
    print('No')
    exit()

for i in range(min(a, b)):
    if (a - i)==(b - i)*2:
        if e>0 or max(min(dA), min(dB))<=i:
            print('Yes')
            exit()
print('No')

Submission status: Wrong Answer

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) % 2 == 1:
	print("Yes")
else:
	print("No")

# 14 20

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    print(sum(a), sum(b))
    if a == b:
        return print('Yes')
    if sum(a) > sum(b):
        return print('No')
    return print('Yes')


main()

Submission status: Wrong Answer

Solution code:
import sys

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

    a_sum = 0
    for x in A:
        a_sum += x
    b_sum = 0
    for x in B:
        b_sum += x
    if a_sum > b_sum:
        print('No')
        sys.exit()
    if (a_sum + N) < b_sum:
        print('No')
        sys.exit()
    print('Yes')

Submission status: Wrong Answer

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

for ai, bi in zip(a, b):
    if ai <= bi:
        pass
    else:
        print('No')
        sys.exit()
print('Yes')

Submission status: Wrong Answer

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

c = 0
for i in range(N):
   if b[i] - a[i] > 0:
      c += b[i] - a[i]
   elif b[i] - a[i] < 0:
      c += (b[i] - a[i])*2

if c >= 0:
   print("Yes")
else:
   print("No")

Submission status: Wrong Answer

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()
	ans = False
	
	for i in range(n-1):
		diff = a[i]-b[i]
		diff_next = a[i+1] - b[i+1]

		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

	if a[-1]<=b[-1]:
		ans = True
	else:
		ans = False

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

			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

		if a[0]<=b[0]:
			ans = True
		else:
			ans = False

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



if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import math
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

sub = [b[i] - a[i] for i in range(N)]
plus = sum([x for x in sub if x > 0])
minus = sum([x for x in sub if x < 0])

print(('No', 'Yes')[plus + minus * 2 >= 0])

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
import math
N = input()
a = input().split(" ")
b = input().split(" ")

# set_c = set(a)-set(b)
# print(set_c)
#a,b同じ配列か判定
# judge =True
for i in range(len(a)):

    if a[i] == b[i]:
        judge = True
    else:
        judge = False
if judge:
    print("Yes")
    sys.exit()
# a = map(int,a)
# b = map(int,b)
# c = []
c =0
# c =sum(a)-sum(b)
# print(c)
for i in range(len(a)):
    temp = (int(a[i])-int(b[i]))
    # print(temp)
    if temp<0:
        temp = temp/2
        c += math.floor(temp)
        # print(c)
    else:
        c += math.floor(temp)
        # print(c)
# print(c)
# print(c)
if c>=0:
    print("No")
elif abs(c)%2 == 0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())

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

S=B-A
T=[0]*N
H=[0]*N
P=[0]*N
p=0
t=0
for j in range(max(abs(S))+2):
    for i in range(N):
        if j==0 and S[i]==0:
            p=1
        if S[i]<0:
            S[i]+=1
            T[i]+=1
        elif S[i]>0:
            S[i]-=2
            H[i]+=1
        elif S[i]==0:
            t+=1
    if t==N:
        break
    else:
        t=0


if sum(T)-sum(S)==0:
    print("Yes")
elif sum(T)-sum(S)>0 and p==1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

b=input().split(" ")
b=list(map(int,b))
counta=0
countb=0
same=0
for i in range(n):
    if a[i]<b[i]: #a<b
        temp=b[i]-a[i] 
        if temp%2==0:
            counta+=int(temp/2)
        else:
            counta+=int((temp+1)/2)
            countb+=1
            
    if a[i]>b[i]:#a>b
        temp=a[i]-b[i]
        countb+=temp
        counta-=temp
    # print(counta)
    # print(countb)
if counta==countb:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
guusuu=0
kisuu=0
zero=0
for i in range(n):
    if (a[i]-b[i])%2==0 and (a[i]-b[i])!=0:
        guusuu+=(a[i]-b[i])//2
    elif (a[i]-b[i])==0:
        zero+=1
    else:
        kisuu+=a[i]-b[i]
for i in range(0,zero+1):
    if abs(guusuu)//2+i==kisuu+i*2:
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np


def a():
    x, y = map(int, input().split())


def b():
    n = int(input())
    a = np.asarray(list(map(int, input().split())))
    b = np.asarray(list(map(int, input().split())))
    x = b.sum() - a.sum()
    d = b - a
    a_req = 0
    b_req = 0
    for i in d:
        if i <= 0:
            b_req += i // -1
        else:
            a_req += i // 2 + i % 2
            b_req += i % 2
    print(x, a_req, b_req)
    # total require
    if (a_req >= b_req and (0 < a_req + (a_req - b_req) == x)) or (a_req == 0 and b_req == 0):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    b()

Submission status: Wrong Answer

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

flag = True

a = sorted(a)
b = sorted(b)
for i in range(len(a)):
    if a[i] > b[i]:
        flag = False
        break

q = 0
for k in a:
    if k % 2 == 0:
        q += 1
for k in b:
    if k % 2 == 1:
        q -= 1

if flag and q == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
lis1 = list(map(int,input().split()))
lis2 = list(map(int,input().split()))
k = 0
c = 0
s = 0
cou = sum(lis2)-sum(lis1)
if cou < 0:
    print("No")
else:
    for i in range(n):
        if lis1[i] < lis2[i]:
            c += math.ceil((lis2[i] - lis1[i]) / 2)
            if (lis2[i] - lis1[i])%2 == 0:
                k += 1
            else:
                s += 1
    if c > cou:
        print("No")
    elif c == cou:
        if s >= 1:
            print("Yes")
        else:
            print("No")
    else:
        if k >= 1:
            print("Yes")
        else:
            print("No")

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ai = [0]*n
bi = [0]*n

for i in range(n):
    if(a[i]<b[i]):
        bi[i] += (b[i]-a[i])
    elif(a[i]>b[i]):
        ai[i] += a[i]-b[i]


if(sum(ai)>sum(bi)):
    print("No")
else:
    for i in range(n):
        if(bi[i]%2!=0):
            print("No")
            sys.exit(0)
    print("Yes")

Submission status: Wrong Answer

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 sum(c)>0:
    print("No")
    exit()
while len(list(filter(lambda x:abs(x)>1, c))) != 0:
    i,j,m = 0,0,0
    f_i,f_j = False,False
    for k in range(n):
        if c[k] < -1 and not f_i:
            i = k
            f_i = True
        if c[k] > 0 and not f_j:
            j = k
            f_j = True
        if c[k] == 0:
            m = k
        if f_i and f_j:
            break
    if not f_i:
        print("No")
        exit()
    if not f_j:
        j = m
    c[i] += 2
    c[j] -= 1
if len(list(filter(lambda x:abs(x)==1, c))) > 1:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
a = np.array(list(map(int, input().split())))
b = np.array(list(map(int, input().split())))

limit = np.sum(b) - np.sum(a)

flag = False
for i in range(limit):
    diff = b - a
    # idxp = idxm = -1
    # for n in range(N):
    #     if idxm == -1 and diff[n] < 0:
    #         idxm = n
    #     elif idxp == -1 and 0 < diff[n]:
    #         idxp = n
    #     if idxp != -1 and idxm != -1:
    #          break
    idxp = np.where(0 < diff)[0]
    idxm = np.where(diff < 0)[0]
    if len(idxm) == 0:
        a[idxp[0]] += 2
        b[idxp[0]] += 1
    else:
        a[idxp[0]] += 2
        b[idxm[0]] += 1
    if np.allclose(a, b):
        flag = True
        break

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

Submission status: Wrong Answer

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

#
a = 0
b = 0
e = 0
for i in range(N):
    if A[i]==B[i]:
        e += 1
    elif B[i]>A[i]:
        if (B[i] - A[i])%2==1:
            print('No')
            exit()
        else:
            a += (B[i] - A[i])//2
    else:
        b += A[i] - B[i]

#
if a==b:
    print('Yes')
    exit()
if a==0 or b==0 or e==0:
    print('No')
    exit()

for i in range(min(a, b)+1):
    if (a - i)==(b - i)*2:
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
a = []
b = []

a = np.array([int(num) for num in input().split(" ")])
b = np.array([int(num) for num in input().split(" ")])

flag = False
M = sum(b) - sum(a)

a_count = 0
b_count = 0
c = b - a
for i in range(N):
    if c[i] < 0:
        b_count -= c[i]
    if c[i] > 0:
        count = c[i] % 2
        a_count += count
        b_count += count
        a_count += c[i] // 2
        
if M - b_count == (M - a_count) * 2:
        flag = True
if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

if a==b:
	print "Yes"
	quit()

try_cnt=sum(b)-sum(a)

if try_cnt<0:
	print "No"
	quit()

c=[]
for i,j in zip(a,b):
	c.append(i-j)

c_neg=filter(lambda n:n<0, c)
c_pos=filter(lambda n:n>0, c)

if sum(c_neg)+2*try_cnt>=0 and sum(c_pos)+(-1)*try_cnt<=0:
	print "Yes"
else:
	print "No"

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())

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

S=B-A
T=[0]*N
H=[0]*N
P=[0]*N
p=0
for j in range(max(abs(S))+2):
    for i in range(N):
        if j==0 and S[i]==0:
            p=1
        if S[i]<0:
            S[i]+=1
            T[i]+=1
        elif S[i]>0:
            S[i]-=2
            H[i]+=1

if sum(T)==sum(S):
    print("Yes")
elif sum(T)-sum(S)>0 and p==1:
    print("Yes")
else:
    print("No")






# if t==0: print("No")
# else: print("yes")

Submission status: Wrong Answer

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



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

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

if a==b:
	print "Yes"
	quit()

try_cnt=sum(b)-sum(a)

if try_cnt<0:
	print "No"
	quit()

c=[]
for i,j in zip(a,b):
	c.append(i-j)

c_neg=filter(lambda n:n<0, c)
c_pos=filter(lambda n:n>0, c)

if sum(c_neg)+2*try_cnt>0 and sum(c_pos)+(-1)*try_cnt<=0:
	print "Yes"
else:
	print "No"

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
N = input()
a = input().split(" ")
b = input().split(" ")

# set_c = set(a)-set(b)
# print(set_c)
#a,b同じ配列か判定
# judge =True
for i in range(len(a)):

    if a[i] == b[i]:
        judge = True
    else:
        judge = False
if judge:
    print("Yes")
    sys.exit()
a = map(int,a)
b = map(int,b)
# c = []
c =sum(a)-sum(b)
# print(c)
# for i in range(len(a)):
#     c += int(a[i])-int(b[i])
if c>=0:
    print("No")
elif abs(c)%2 == 0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

for i in range(n):
    if(a[i]<b[i]):
        bi += (b[i]-a[i])
    elif(a[i]>b[i]):
        ai += a[i]-b[i]


if(ai>bi or abs(ai-bi)%2==0):
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys, functools

N = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
d = [b[i] - a[i] for i in range(N)]

op_cnt = sum(b) - sum(a)

if op_cnt < 0:
    print('No')
    sys.exit()


def q1(a, b):
    if b < 0:
        a[1] += b * -1
    else:
        if b > 0:
            if b % 2 is 1:
                a[1] += 1
            a[0] += b // 2 + 1
    return a


q = functools.reduce(q1, d, [0, 0])

if q[0] > op_cnt or q[1] > op_cnt:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

if a_list == b_list:
    print('Yes')

else:
    cnt = sum(b_list) - sum(a_list)
    cnt_tmp = 0
    for i in range(N):
        if a_list[i] < b_list[i]:
            cnt_tmp += ((b_list[i] - a_list[i]) // 2) + 1

    if cnt_tmp > cnt:
        print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

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

limit = sum(b) - sum(a)

flag = False
for i in range(limit):
    diff = [bt - at for at, bt in zip(a, b)]
    idxp = idxm = -1
    for n in range(N):
        if idxm == -1 and diff[n] < 0:
            idxm = n
        elif idxp == -1 and 0 < diff[n]:
            idxp = n
        if idxp != -1 and idxm != -1:
            break
    if idxm == -1:
        a[idxp] += 2
        b[idxp] += 1
    else:
        a[idxp] += 2
        b[idxm] += 1
    if a == b:
        flag = True
        break

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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))
    admissible_A = - sum([a for a in difference if a < 0]) / 2
    admissible_B = sum([b for b in difference if b > 0])
    
    surplus_A = int((sum_dif - admissible_A)*2)
    surplus_B = (sum_dif - admissible_B)
    
    if surplus_A == surplus_B:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

    d = sum(B) - sum(A)

    if d < 0:
        print('No')
        return

    C = [a - b for a, b in zip(A, B)]
    m = sum((x for x in C if x < 0))

    print(d, m)

    if abs(m) > d * 2:
        print('No')
        return

    assert d * 2 + sum((x for x in C if x > 0)) + m == d
    print('Yes')


main()

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
a = []
b = []

a = np.array([int(num) for num in input().split(" ")])
b = np.array([int(num) for num in input().split(" ")])

flag = False
M = sum(b) - sum(a)

a_count = 0
b_count = 0
c = b - a
for i in range(N):
    if c[i] < 0:
        b_count -= c[i]
    if c[i] > 0:
        count = c[i] % 2
        a_count += count
        b_count += count
        a_count += c[i] // 2
b_count += M - a_count

if a_count == b_count:
        flag = True
if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

for i in range(n):
    if(a[i]<b[i]):
        ai += (b[i]-a[i])
    elif(a[i]>b[i]):
        bi += a[i]-b[i]


if((ai-bi)%2 and (ai-bi)>0):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

cnt = sum(b_list) - sum(a_list)

cnt_tmp = 0
for i in range(N):
    if a_list[i] < b_list[i]:
        cnt_tmp += ((b_list[i] - a_list[i]) // 2) + 1
        
if cnt_tmp >= cnt:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
plus=0;minus=0
for i in range(N):
    c=a[i]-b[i]
    if c < 0:
        minus-=c
    elif c > 0:
        plus+=c

print("Yes" if minus +1 >= plus*2 else "No")

Submission status: Wrong Answer

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

flag = "Yes"
A = sorted(a)[::-1]
B = sorted(b)[::-1]
for i in range(N):
   if A[i] > B[i]:
      flag = "No"
      break

print(flag)