qyliang/CodeNanoFix huggingface dataset:
Buggy 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")

Fixed 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")
Buggy code:
import sys
# from collections import defaultdict, deque
# import math
# import copy
from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 1000000007

def solve():
    n = getN()
    anums = getList()
    bnums = getList()
    if sum(anums) > sum(bnums):
        print("NO")
        return

    pair = []
    for i, j in zip(anums, bnums):
        pair.append((i, j))

    pair.sort(key=lambda x:- x[0] + x[1])
    # print(pair)
    kosi = 0
    for a,b in pair:
        a += kosi
        if b >= a:
            print("YES")
            return
        else:
            kosi = (a - b) * 2

    if kosi:
        print("NO")
        return
    else:
        print("YES")
        return


def main():
    n = getN()
    for _ in range(n):
        solve()
if __name__ == "__main__":
    # main()
    solve()


Fixed code:
import sys
# from collections import defaultdict, deque
# import math
# import copy
from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 1000000007

def solve():
    n = getN()
    anums = getList()
    bnums = getList()
    # if sum(anums) > sum(bnums):
    #     print("No")
    #     return

    pair = []
    for i, j in zip(anums, bnums):
        pair.append((i, j))

    pair.sort(key=lambda x:- x[0] + x[1])
    # print(pair)
    kosi = 0
    for a,b in pair:
        # a += kosi
        if b >= a:
            kosi -= (b-a) // 2 * 2
        else:
            kosi += (a - b) * 2
        # print(a, b, kosi)

    if kosi > 0:
        print("No")
        return
    else:
        print("Yes")
        return


def main():
    n = getN()
    for _ in range(n):
        solve()
if __name__ == "__main__":
    # main()
    solve()
Buggy code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
if sum(A) > sum(B):
    print('No')
    exit()
else:
    cnt = sum(B)-sum(A)
a_tmp = 0
b_tmp = 0
for i in range(N):
    if A[i] == B[i]:
        continue
    if A[i] > B[i]:
        b_tmp += A[i]-B[i]
    else:
        if (B[i]-A[i]) % 2 == 0:
            a_tmp += (B[i]-A[i]) // 2
        else:
            a_tmp += ((B[i]-A[i]) // 2)+1
            b_tmp += 1
if (cnt-a_tmp)*2 == cnt-b_tmp:
    print('Yes')
else:
    print('No')

Fixed code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
if sum(A) > sum(B):
    print('No')
    exit()
else:
    cnt = sum(B)-sum(A)
a_tmp = 0
b_tmp = 0
for i in range(N):
    if A[i] == B[i]:
        continue
    if cnt == 0:
        print('No')
        exit()
    if A[i] > B[i]:
        b_tmp += A[i]-B[i]
    else:
        if (B[i]-A[i]) % 2 == 0:
            a_tmp += (B[i]-A[i]) // 2
        else:
            a_tmp += ((B[i]-A[i]) // 2)+1
            b_tmp += 1
if a_tmp > cnt or b_tmp > cnt:
    print('No')
    exit()
if (cnt-a_tmp)*2 == cnt-b_tmp:
    print('Yes')
else:
    print('No')
Buggy code:
def solve():
    N = int(input())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))

    plus2_cnt = 0
    neg_cnt = 0
    for i in range(N):
        diff = b[i] - a[i]
        if diff >= 0:
            plus2_cnt += diff // 2
        else:
            neg_cnt += 1
    
    if plus2_cnt >= neg_cnt:
        print('Yes')
    else:
        print('No')
        
if __name__ == '__main__':
    solve()


Fixed code:
def solve():
    N = int(input())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))

    plus2_cnt = 0
    neg_cnt = 0
    for i in range(N):
        diff = b[i] - a[i]
        if diff >= 0:
            plus2_cnt += diff // 2
        else:
            neg_cnt += abs(diff)
    
    if plus2_cnt >= neg_cnt:
        print('Yes')
    else:
        print('No')
        
if __name__ == '__main__':
    solve()
Buggy code:
import sys
import math
import itertools
import bisect
from copy import copy
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(a)-sum(b)
cnt = 0
for i in range(N):
    if a[i] > b[i]:
        cnt += a[i]-b[i]
    if a[i] < b[i]:
        cnt += math.ceil((b[i]-a[i])/2)
if cnt > num:
    print('No')
else:
    print('Yes')

Fixed code:
import sys
import math
import itertools
import bisect
from copy import copy
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()
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')
Buggy 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')

Fixed code:
import sys
import math
import itertools
import bisect
from copy import copy
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()
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 += (b[i]-a[i]-1)//2+1
if cnt1 > num or cnt2 > num:
    print('No')
else:
    print('Yes')
Buggy 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')

Fixed code:
n = int(input())
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])//2

if b_gap-a_gap<0:
    print('No')
else:
    print('Yes')
Buggy 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')


Fixed 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')
Buggy code:
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = na()
    b = na()

    a_cnt = 0
    b_cnt = 0

    for ai, bi in zip(a, b):
        tmp = bi - ai
        if tmp < 0:
            b_cnt += abs(tmp)
            a_cnt -= abs(tmp)
        elif tmp > 0:
            a_cnt += (tmp + 1) // 2
            b_cnt += tmp % 2 - (tmp + 1) // 2
        print(ai, bi, a_cnt, b_cnt)

    print("Yes" if a_cnt > b_cnt else "No")


if __name__ == '__main__':
    main()


Fixed code:
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = na()
    b = na()

    a_cnt = 0
    b_cnt = 0

    for ai, bi in zip(a, b):
        tmp = bi - ai
        if tmp < 0:
            b_cnt += abs(tmp)
        elif tmp > 0:
            a_cnt += (tmp + 1) // 2
            b_cnt += tmp % 2
        # print(ai, bi, a_cnt, b_cnt)

    print("Yes" if a_cnt >= b_cnt else "No")


if __name__ == '__main__':
    main()
Buggy code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

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

print('Yes' if cnt>=0 else 'No')

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

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

print('Yes' if margin>=cnt else 'No')
Buggy code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
S=sum(b)-sum(a)
if S<0:print("No")
else:
    cnt=0
    for i in range(n):
        cnt+=max((b[i]-a[i])//2,0)
    if cnt<=S:print('Yes')
    else:print("No")

Fixed code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
S=sum(b)-sum(a)
if S<0:print("No")
else:
    cnt=0
    for i in range(n):
        cnt+=max((b[i]-a[i]+1)//2,0)
    if cnt<=S:print('Yes')
    else:print("No")
Buggy code:
import sys
def main():
    input = sys.stdin.readline
    N=int(input())
    *A,=map(int, input().split())
    *B,=map(int, input().split())

    opa=opb=0
    for a,b in zip(A,B):
        if a>=b:
            opb=a-b
        else:
            if (b-a)&1==0:
                opa+=(b-a)//2
            else:
                opa+=(b-a)//2 + 1
                opb+=1

    print('Yes' if a>=b else 'No')

if __name__ == '__main__':
    main()

Fixed code:
import sys
def main():
    input = sys.stdin.readline
    N=int(input())
    *A,=map(int, input().split())
    *B,=map(int, input().split())

    opa=opb=0
    for a,b in zip(A,B):
        if a>=b:
            opb+=a-b
        else:
            if (b-a)&1==0:
                opa+=(b-a)//2
            else:
                opa+=(b-a)//2 + 1
                opb+=1

    print('Yes' if opa>=opb else 'No')

if __name__ == '__main__':
    main()
Buggy code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

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

    for i in range(n):
        if B[i] > A[i]:
            cnt -= B[i] - A[i] / 2

    if cnt <= 0:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    resolve()


Fixed code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

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

    for i in range(n):
        if B[i] > A[i]:
            cnt -= (B[i] - A[i]) // 2

    if cnt <= 0:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    resolve()
Buggy code:
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a=sorted(a)
b=sorted(b)
ope = 0
for i in range(n):
    if b[i] > a[i]:
        ope+=(b[i]-a[i]+1)//2

if sum(b) - sum(a) < 0:
    print('No')        
elif ope <= sum(b) - sum(a):
    print('Yes')
else:
    print('No')

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

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

if sum(b) - sum(a) < 0:
    print('No')        
elif ope <= sum(b) - sum(a):
    print('Yes')
else:
    print('No')
Buggy code:
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    num_a = 0
    num_b = 0
    for a, b in zip(A, B):
        if a > b:
            num_a += a - b
        elif a < b:
            num_b += b - a

    cnt_a = num_a
    cnt_b = (num_b + 1) // 2

    if cnt_a > cnt_b:
        return "No"
    else:
        return "Yes"


print(solve())


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

    cnt_a = 0
    cnt_b = 0
    for a, b in zip(A, B):
        if a > b:
            cnt_a += a - b
        elif a < b:
            cnt_b += (b - a) // 2

    if cnt_a > cnt_b:
        return "No"
    else:
        return "Yes"


print(solve())
Buggy code:
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
numa = 0
numb = 0
num = sum(b)-sum(a)
for i in range(n):
    x = b[i] - a[i]
    if x > 0:
        numa += -(-x//2)
        if x % 2 == 1:
            numb += 1
    else:
        numb -= x
print(num,numa,numb)
if (num-numa)*2 == num-numb and num > numa:
    print("Yes")
else:
    print("No")

Fixed code:
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
numa = 0
numb = 0
num = sum(b)-sum(a)
for i in range(n):
    x = b[i] - a[i]
    if x > 0:
        numa += -(-x//2)
        if x % 2 == 1:
            numb += 1
    else:
        numb -= x
if (num-numa)*2 == num-numb and num >= numa:
    print("Yes")
else:
    print("No")
Buggy code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

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

if(twosum<=onesum):
    print("Yes")
else:
    print("No")

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

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

if(onesum<=twosum):
    print("Yes")
else:
    print("No")
Buggy code:
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
if sum(A)>sum(B):
    ans='No'
else:
    c=0
    d=0
    for a,b in zip(A,B):
        if a<b:
            d+=(b-a)//2+(b-a)%2
            c+=(b-a)%2
        else:
            c+=a-b
    if d==c:
        ans='Yes'
    else:
        ans='No'
print(ans)

Fixed code:
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
if sum(A)>sum(B):
    ans='No'
else:
    c=0
    d=0
    for a,b in zip(A,B):
        if a<b:
            d+=(b-a)//2+(b-a)%2
            c+=(b-a)%2
        else:
            c+=a-b
    if d>=c:
        ans='Yes'
    else:
        ans='No'
print(ans)
Buggy code:
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
if sum(A)>sum(B):
    ans='No'
else:
    l=sum(B)-sum(A)
    cnt_a=l*2
    cnt_b=l
    for i in range(n):
        if A[i]>B[i]:
            if (A[i]-B[i])%2==0:
                cnt_b-=(A[i]-B[i])
            else:
                cnt_b -= (A[i] - B[i])-1
                cnt_a -= 1
        else:
            cnt_a-=(B[i]-A[i])
    if cnt_a==cnt_b and cnt_a>=0:
        ans='Yes'
    else:
        ans='No'
print(ans)

Fixed code:
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
if sum(A)>sum(B):
    ans='No'
else:
    l=sum(B)-sum(A)
    cnt_a=l*2
    cnt_b=l
    for i in range(n):
        if A[i]>B[i]:
                cnt_b-=(A[i]-B[i])
        else:
            if (B[i]-A[i])%2==0:
                cnt_a-=(B[i]-A[i])
            else:
                cnt_a-=(B[i]-A[i])+1
                cnt_b-=1
    if cnt_a==cnt_b and cnt_a>=0:
        ans='Yes'
    else:
        ans='No'
print(ans)
Buggy code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    a = LI()
    b = LI()
    suma = sum(a)
    sumb = sum(b)
    diff = suma - sumb
    tmp = 0
    for i in range(n):
        tmp += max((a[i] - b[i] + 1) // 2, 0)
    if diff >= tmp:
        print("Yes")
    else:
        print("No")
    return


#main
if __name__ == '__main__':
    solve()


Fixed code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    a = LI()
    b = LI()
    suma = sum(a)
    sumb = sum(b)
    diff = sumb - suma
    tmp = 0
    for i in range(n):
        tmp += max((b[i] - a[i] + 1) // 2, 0)
    if diff >= tmp:
        print("Yes")
    else:
        print("No")
    return


#main
if __name__ == '__main__':
    solve()
Buggy 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 a[i]>b[i]:
        aPlus+=(a[i]-b[i])
    elif a[i]<b[i]:
        if (b[i]-a[i])%2==0:
            bPlus+=(b[i]-a[i])//2
        else:
            aPlus+=1
            bPlus+=(b[i]+1-a[i])//2
print(aPlus,bPlus)
if aPlus*2==bPlus or aPlus==bPlus:
    print("Yes")
else:
    print("No")

Fixed 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 a[i]>b[i]:
        aPlus+=(a[i]-b[i])
    elif a[i]<b[i]:
        if (b[i]-a[i])%2==0:
            bPlus+=(b[i]-a[i])//2
        else:
            aPlus+=1
            bPlus+=(b[i]+1-a[i])//2

if aPlus<=bPlus:
    print("Yes")
else:
    print("No")
Buggy code:
import bisect
import heapq
import sys
import queue


input = sys.stdin.readline
sys.setrecursionlimit(100000)


class V:
    def __init__(self, f):
        self.f = f
        self.v = None

    def __str__(self):
        return str(self.v)

    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n)

    def get(self):
        return self.v


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def main():
    N = int(input())
    A = read_list()
    B = read_list()

    A.sort()
    B.sort()

    KA = 0
    KB = 0
    for a, b in zip(A, B):
        if a == b:
            continue
 
        if a > b:
            KB += a - b
            continue
 
        if a % 2 != b % 2:
            KB += 1
            b += 1
 
        KA += (b - a) // 2
 
    print("Yes" if KA >= KB else "No")


if __name__ == "__main__":
    main()


Fixed code:
import bisect
import heapq
import sys
import queue


input = sys.stdin.readline
sys.setrecursionlimit(100000)


class V:
    def __init__(self, f):
        self.f = f
        self.v = None

    def __str__(self):
        return str(self.v)

    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n)

    def get(self):
        return self.v


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def main():
    N = int(input())
    A = read_list()
    B = read_list()

    KA = 0
    KB = 0
    for a, b in zip(A, B):
        if a == b:
            continue

        if a > b:
            KB += a - b
            continue

        if a % 2 != b % 2:
            KB += 1
            b += 1

        KA += (b - a) // 2

    print("Yes" if KA >= KB else "No")


if __name__ == "__main__":
    main()
Buggy code:
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
allSousa = sum(B)-sum(A)
atob = 0
for a, b in zip(A, B):
  if a < b:
    atob += (b-a)//2+(b-a)%2
if atob < allSousa:
  print("No")
else:
  print("Yes")


Fixed code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
allSousa = sum(B)-sum(A)
atob = 0
for a, b in zip(A, B):
  if a < b:
    atob += (b-a)//2+(b-a)%2
if allSousa < atob:
  print("No")
else:
  print("Yes")
Buggy code:
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
k = sum(b)-sum(a)
if k<0:
  print("No")
  exit()
ansa=0
ansb=0
for i in range(n):
  if b[i]<a[i]:
    ansb+=a[i]-b[i]
  else:
    re = b[i]-a[i]
    if re%2==0:
      ansa+=(b[i]-a[i])//2
    else:
      ansa+=(b[i]+1-a[i])//2
      ansb+=1
if (k-ansa)*2==k-ansb:
  print("Yes")
else:
  print("No")

Fixed code:
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
k = sum(b)-sum(a)
if k<0:
  print("No")
  exit()
ansa=0
ansb=0
for i in range(n):
  if b[i]<a[i]:
    ansb+=a[i]-b[i]
  else:
    re = b[i]-a[i]
    if re%2==0:
      ansa+=(b[i]-a[i])//2
    else:
      ansa+=(b[i]+1-a[i])//2
      ansb+=1
if (k-ansa)*2==k-ansb and 0<=k-ansa and 0<=k-ansb:
  print("Yes")
else:
  print("No")