Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03044 (python)

Fixed submission:
from collections import deque

N = int(input())
edges = {i: [] for i in range(N)}
for _ in range(N-1):
    x, y, z = map(int, input().split())
    edges[x-1].append((y-1, z%2))
    edges[y-1].append((x-1, z%2))
color = [None]*N

q = deque([(0, 0)])
while q:
    v, c = q.popleft()
    color[v] = c
    for u, w in edges[v]:
        if color[u] is None:
            if w == 0:
                q.append((u, c))
            else:
                q.append((u, c^1))
print(*color, sep='\n')

Buggy submission (verdict: Runtime Error):
from collections import deque

N = int(input())
edges = {i: [] for i in range(N)}
for _ in range(M-1):
    x, y, z = map(int, input().split())
    edges[x-1].append((y-1, z%2))
    edges[y-1].append((x-1, z%2))
color = [None]*N

q = deque([(0, 0)])
while q:
    v, c = q.popleft()
    color[v] = c
    for u, w in edges[v]:
        if color[u] is None:
            if w == 0:
                q.append((u, c))
            else:
                q.append((u, c^1))
print(*color, sep='\n')

Buggy submission (verdict: Runtime Error):
from collections import deque

N = int(input())
edges = {i: [] for i in range(N)}
for _ in range(M-1):
    x, y, z = map(int, input().split())
    edges[x-1].append((y-1, z%2))
    edges[y-1].append((x-1, z%2))
color = [None]*N

q = deque([(0, 0)])
while q:
    v, c = q.popleft()
    color[v] = c
    for u, w in edges[v]:
        if color[u] is None:
            if w == 0:
                q.append((u, c))
            else:
                q.append((u, c^1))
print(*color, sep='\n')

Buggy submission (verdict: Runtime Error):
from collections import deque

N = int(input())
edges = {i: [] for i in range(N)}
for _ in range(M-1):
    x, y, z = map(int, input().split())
    edges[x-1].append((y-1, z%2))
    edges[y-1].append((x-1, z%2))
color = [None]*N

q = deque([(0, 0)])
while q:
    v, c = q.popleft()
    color[v] = c
    for u, w in edges[v]:
        if color[u] is None:
            if w == 0:
                q.append((u, c))
            else:
                q.append((u, c^1))
print(*color, sep='\n')

Buggy submission (verdict: Runtime Error):
N = int(input())
edge = sorted([tuple(map(int, input().split())) for _ in range(N)])
color = [0]*N

for u, v, w in edge:
    if w % 2 == 1 and color[u-1] == color[v-1]:
        color[v-1] ^= 1
    elif w % 2 == 0 and color[u-1] != color[v-1]:
        color[v-1] ^= 1

print(*color, sep='\n')
Problem p03102 (python)

Fixed submission:
import numpy as np

N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]

B = np.array(B)
A = np.array(A)
vec = A.dot(B) + C
ans = np.sum(vec > 0)
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np

N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]

B = np.array(B)
A = np.array(A)
vec = A@B + C
ans = np.sum(vec > 0)
print(ans)
Problem p03128 (python)

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

numbers = [None, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = {i: -1 for i in range(N+1)}
dp[0] = 0
for i in range(N+1):
    for a in A:
        j = i + numbers[a]
        if j <= N:
            dp[j] = max(dp[j], dp[i]*10 + a)
print(dp[N])

Buggy submission (verdict: Runtime Error):
numbers = {'1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6}

N, M = map(int, input().split())
A = list(input().split())
cands = [(a, numbers[a]) for a in A]

dp = {i: None for i in range(1, N+1)}
for c in cands:
    dp[c[1]] = int(c[0])
for i in range(2, N+1):
    for c in cands:
        j = i - c[1]
        if j >= 1 and dp[j] is not None:
            if dp[i] is None:
                dp[i] = int(''.join(str(dp[j]) + c[0]))
            else:
                if len(str(dp[i])) <  len(str(dp[j]) + c[0]):
                    dp[i] = int(str(dp[j]) + c[0])
                elif len(str(dp[i])) ==  len(str(dp[j]) + c[0]):
                    dp[i] = max(dp[i], int(''.join(sorted(str(dp[j]) + c[0], reverse=True))))
print(''.join(sorted(dp[N], reverse=True)))
Problem p03174 (python)

Fixed submission:
MOD = 10**9 + 7
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
dp = [0] * (1 << N)
dp[0] = 1
bits = [1 << i for i in range(N)]
cands = [[] for _ in range(N+1)]
for s in range(1 << N):
    temp = 0
    for n in range(N):
        if s & (1 << n): temp += 1
    cands[temp].append(s)
for i, a in enumerate(A):
    for j in [k for k, v in enumerate(a) if v == 1]:
        bit = bits[j]
        for s in cands[i]:
            if s & bit == 0:
                new_s = s | bit
                dp[new_s] += dp[s]
                dp[new_s] %= MOD
print(dp[-1])

Buggy submission (verdict: Runtime Error):
MOD = 10**9 + 7
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
dp = [0] * (1 << N)
dp[0] = 1
prev = [0]
for i, a in enumerate(A):
    temp = []
    for j in [k for k, v in a if v == 1]:
        bit = 1 << j
        for s in prev:
            if s & bit == 0:
                new_s = s | bit
                dp[new_s] += dp[s]
                dp[new_s] %= MOD
                temp.append(new_s)
    prev = list(set(temp))
print(dp[(1 << N) - 1])
Problem p03244 (python)

Fixed submission:
from collections import defaultdict

n = int(input())
V = list(map(int, input().split()))

odds_counter = defaultdict(int)
evens_counter = defaultdict(int)

for o in V[0::2]:
    odds_counter[o] += 1
for e in V[1::2]:
    evens_counter[e] += 1

odds = sorted(odds_counter.items(), key=lambda x: x[1], reverse=True)
evens = sorted(evens_counter.items(), key=lambda x: x[1], reverse=True)

if odds[0][0] != evens[0][0]:
    ans = n - odds[0][1] - evens[0][1]
else:
    if len(odds) == 1 and len(evens) == 1:
        ans = odds[0][1]
    elif len(odds) == 1 and len(evens) != 1:
        ans = n - odds[0][1] - evens[1][1]
    elif len(odds) != 1 and len(evens) == 1:
        ans = n - odds[1][1] - evens[0][1]
    else:
        ans = min(n - odds[0][1] - evens[1][1], n - odds[1][1] - evens[0][1])
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict

n = int(input())
V = list(map(int, input().split()))

odds_counter = defaultdict(int)
evens_counter = defaultdict(int)

for o in V[0::2]:
    odds_counter[o] += 1
for e in V[1::2]:
    evens_counter[e] += 1

odds = sorted(odds_counter.items(), key=lambda x: x[1], reverse=True)
evens = sorted(evens_counter.items(), key=lambda x: x[1], reverse=True)

if odds[0][0] != evens[0][0]:
    ans = n - odds[0][1] - evens[0][1]
else:
    if odds[0][1] >= evens[0][1]:
        if len(odds) == 1:
            ans = n//2 - evens[1][1]
        else:
            ans = n - evens[0][1] - odds[1][1]
    else:
        if len(evens) == 1:
            ans = n//2 - odds[1][1]
        else:
            ans = n - odds[0][1] - evens[1][1]
print(ans)
Problem p03262 (python)

Fixed submission:
from functools import reduce

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

def gcd_list(numbers):
    return reduce(gcd, numbers)

N, X = map(int, input().split())
cities = list(map(int, input().split()))

ans = gcd_list([abs(c - X) for c in cities])

print(ans)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(numbers):
    return reduce(math.gcd, numbers)

N, X = map(int, input().split())
cities = list(map(int, input().split()))

ans = gcd([abs(c - X) for c in cities])


print(ans)
Problem p03263 (python)

Fixed submission:
from collections import deque

H, W = map(int, input().split())
A = []
for _ in range(H):
    temp = list(map(int, input().split()))
    a = [t % 2 for t in temp]
    A.append(a)

operations = []

for i in range(H):
    y = i + 1
    if i % 2 == 0:
        for j in range(W):
            x = j + 1
            if A[i][j] == 1:
                if x != W:
                    operations.append((y, x, y, x+1))
                    A[i][j+1] = (A[i][j+1] + 1) % 2
                elif y != H:
                    operations.append((y, x, y+1, x))
                    A[i+1][j] = (A[i+1][j] + 1) % 2
    else:
        for j in reversed(range(W)):
            x = j + 1
            if A[i][j] == 1:
                if x != 1:
                    operations.append((y, x, y, x-1))
                    A[i][j-1] = (A[i][j-1] + 1) % 2
                elif y != H:
                    operations.append((y, x, y+1, x))
                    A[i+1][j] = (A[i+1][j] + 1) % 2

N = len(operations)
print(N)
if N != 0:
    for op in operations:
        print(*op, sep=' ')

Buggy submission (verdict: Runtime Error):
from collections import deque

H, W = map(int, input().split())
for _ in range(H):
    temp = list(map(int, input().split()))
    a = [t % 2 for t in temp]
    A.append(a)

operations = []

for i in range(H):
    y = i + 1
    if i % 2 == 0:
        for j in range(W):
            x = j + 1
            if A[i][j] == 1:
                if x != W:
                    operations.append((y, x, y, x+1))
                    A[i][j+1] = (A[i][j+1] + 1) % 2
                elif y != H:
                    operations.append((y, x, y+1, x))
                    A[i+1][j] = (A[i+1][j] + 1) % 2
    else:
        for j in reversed(range(W)):
            x = j + 1
            if A[i][j] == 1:
                if x != 1:
                    operations.append((y, x, y, x-1))
                    A[i][j-1] = (A[i][j-1] + 1) % 2
                elif y != H:
                    operations.append((y, x, y+1, x))
                    A[i+1][j] = (A[i+1][j] + 1) % 2

N = len(operations)
print(N)
if N != 0:
    for op in operations:
        print(*op, sep=' ')
Problem p03282 (python)

Fixed submission:
S = input()
K = int(input())

for i, s in enumerate(S):
    if s != '1' and K-1 < i:
        ans = '1'
        break
    elif s != '1' and K-1 >= i:
        ans = s
        break
else:
    ans = '1'
print(ans)

Buggy submission (verdict: Runtime Error):
import collections

S = input()
K = int(input())

tmp = []
cum_p = [0.0]

for s in S:
    tmp.append(int(s))
total = sum(tmp)

for p in tmp:
    cum_p.append(cum_p[-1] + (p / total))

prob = K / (5*10e16)

for i in range(1, len(S) + 1):
    if prob < cum_p[i]:
        if S[i-1] == '1':
            print(S[i])
        else:
            print(S[i-1])
        break
Problem p03283 (python)

Fixed submission:
from itertools import product

N, M, Q = map(int, input().split())
table = [[0 for _ in range(N+1)] for _ in range(N+1)]
for _ in range(M):
    l, r = map(int, input().split())
    table[l][r] += 1
cum_sum2 = [[0 for _ in range(N+1)] for _ in range(N+1)]
for i, j in product(range(1, N+1), repeat=2):
    cum_sum2[i][j] += table[i][j] + cum_sum2[i-1][j] + cum_sum2[i][j-1] - cum_sum2[i-1][j-1]
for _ in range(Q):
    p, q = map(int, input().split())
    ans = cum_sum2[q][q] - cum_sum2[p-1][q] - cum_sum2[q][p-1] + cum_sum2[p-1][p-1]
    print(ans)

Buggy submission (verdict: Runtime Error):
N, M, Q = map(int, input().split())
table = [[0 for _ in range(N+1)] for _ in range(N+1)]
for _ in range(M):
    l, r = map(int, input().split())
    table[l][r] += 1
cum_sum2 = [[0 for _ in range(N+1)] for _ in range(N+1)]
for i, j in product(range(1, N+1), repeat=2):
    cum_sum2[i][j] += table[i][j] + cum_sum2[i-1][j] + cum_sum2[i][j-1] - cum_sum2[i-1][j-1]
for _ in range(Q):
    p, q = map(int, input().split())
    ans = cum_sum2[q][q] - cum_sum2[p-1][q] - cum_sum2[q][p-1] + cum_sum2[p-1][p-1]
    print(ans)
Problem p03287 (python)

Fixed submission:
from collections import defaultdict

N, M = map(int, input().split())
A = list(map(int, input().split()))
cumS = [0]
for a in A:
    cumS.append(a + cumS[-1])
cumS_rem = defaultdict(int)
for c in cumS:
    r = c % M
    cumS_rem[r] += 1
ans = 0
for r, n_r in cumS_rem.items():
    if n_r > 1:
        ans += n_r*(n_r-1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict

N, M = map(int, input().split())
A = list(map(int, input().split()))
cumS = [0]
for a in A:
    cumS.append(a + cumS[-1])
cumS_rem = defaultdict(int)
for c in cumS:
    r = c % M
    cumS_rem[r] += 1
ans = 0
for r, n_r in cumS_rem.items()
    if n_r > 1:
        ans += n_r*(n_r-1)//2
print(ans)
Problem p03290 (python)

Fixed submission:
from itertools import product

D, G = map(int, input().split())
probs = []
for _ in range(D):
    p, c = map(int, input().split())
    probs.append((p, c))
ans = 10**9
for choise in product([True, False], repeat=D):
    score = 0
    solved_probs = 0
    max_score_rem_id = 0
    for i, solve in enumerate(choise):
        if solve:
            score += probs[i][0]*(100*(i+1)) + probs[i][1]
            solved_probs += probs[i][0]
        else:
            max_score_rem_id = i
    if score < G:
        remain = G - score
        to_be_solved = (remain - 100) // (100*(max_score_rem_id+1)) + 1
        if to_be_solved < probs[max_score_rem_id][0]:
            solved_probs += to_be_solved
        else:
            continue
    ans = min(ans, solved_probs)
print(ans)

Buggy submission (verdict: Runtime Error):
D, G = map(int, input().split())
P = []
C = []

for _ in range(D):
    p, c = map(int, input().split())
    P.append(p)
    C.append(c)

ans = 0

summary = [(100*(i+1), p) for i, p in enumerate(P)]
summary = list(reversed(sorted([((comp[0]*comp[1] + c)/comp[1], comp[0]*comp[1] + c, comp[0], comp[1], c) for comp, c in zip(summary, C)])))

for i in range(D):
    _, comp_sc, prob_sc, n_prob, cp_bonus = summary[i]
    if G > comp_sc:
        G -= comp_sc
        ans += n_prob
    else:
        score = [(s[2], s[3]) for s in summary[i:] if s[1] > G]
        remain = []
        for prob_sc, n_prob in score:
            if prob_sc * n_prob < G:
                remain.append(n_prob)
            else:
                counter = 0
                tmp = G
                while True:
                    tmp -= prob_sc
                    counter += 1
                    if tmp <= 0:
                        break
                remain.append(counter)
        ans += min(remain)
        break

print(ans)
Problem p03318 (python)

Fixed submission:
def digit_sum(number):
    ans = 0
    for n in str(number):
        ans += int(n)
    return ans

def obj_func(number):
    return number/digit_sum(number)

K = int(input())
num_list = []
d = 1
n = 1

for i in range(K):
    num_list.append(n)
    if obj_func(n + 10**(d-1)) > obj_func(n + 10**d):
        d += 1
    n += 10**(d-1)

print(*num_list, sep='\n')

Buggy submission (verdict: Runtime Error):
K = int(input())

if K < 10:
    num_list = [i for i in range(1, K+1)]
    print(*num_list, sep='\n')
else:
    num_list = [i for i in range(1, 10)]
    n = 19
    digits = 2
    while len(num_list) < K:
        num_list.append(n)
        if str(n+1)[0] > 3:
            digits += 1
        n += 10**(digits - 1)
    print(*num_list, sep='\n')
Problem p03323 (python)

Fixed submission:
A, B = map(int, input().split())

if max(A, B) <= 8:
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())

if max(A, B) <= 8:
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())

if max(A, B) <= 8:
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())

if max(A, B) <= 8:
    print("Yay!")
else:
    print(":(")
Problem p03347 (python)

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
if any(a - b > 1for a, b in zip(A, [-1]+A)): print(-1)
else:
    ans = 0
    for a, nxt in zip(A, A[1:]+[0]):
        if a >= nxt:
            ans += a
    print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for _ in range(N)]
if any(a - b > 1for a, b in zip(A, [-1]+A)): print(-1)
else:
    ans = 0
    for a, nxt in zip(A, A[1:]+[0]):
        if a >= nxt:
            ans += a
print(ans)
Problem p03353 (python)

Fixed submission:
# ABC 097 C

from collections import defaultdict

S = input()
K = int(input())

alphabet = defaultdict(list)
for i, s in enumerate(S):
    alphabet[s].append(i)

alpha_list = sorted(alphabet.keys())
cand = []
i = 0
while len(cand) < K:
    for j in alphabet[alpha_list[i]]:
        if len(S)-j+1 >= K:
            for l in range(1, K+1):
                cand.append(S[j:j+l])
        else:
            for l in range(1, len(S)-j+1):
                cand.append(S[j:j+l])
    cand = list(set(cand))
    if len(cand) >= K:
        break
    i += 1
cand = sorted(cand)
print(cand[K-1])

Buggy submission (verdict: Runtime Error):
# ABC 097 C
S = input()
K = int(input())

cand = []
for l in range(1, K+1):
    for i in range(len(S) - l):
        cand.append(S[i:i+l])

cand = sorted(list(set(cand)))
print(cand[K-1])

Buggy submission (verdict: Runtime Error):
from collections import defaultdict

S = input()
K = int(input())

alphabet = defaultdict(list)
for i, s in enumerate(S):
    alphabet[s].append(i)

alpha_list = sorted(alphabet.keys())
cand = []
i = 0
while len(cand) < K:
    for j in alphabet[alpha_list[i]]:
        for l in range(1, len(S)-j+1):
            cand.append(S[j:j+l])
    cand = list(set(cand))
    if len(cand) < K:
        break
    i += 1
cand = sorted(cand)
print(cand[K-1])

Buggy submission (verdict: Runtime Error):
from collections import defaultdict

S = input()
K = int(input())

alphabet = defaultdict(list)
for i, s in enumerate(S):
    alphabet[s].append(i)

alpha_list = sorted(alphabet.keys())
cand = []
i = 0
while len(cand) < K:
    for j in alphabet[alpha_list[i]]:
        for l in range(1, len(S)-j+1):
            cand.append(S[j:j+l])
    i += 1
cand = sorted(list(set(cand)))
print(cand[K-1])
Problem p03362 (python)

Fixed submission:
import itertools
import math


def get_primes(x):
    if x < 2:
        return []

    primes = [i for i in range(x)]
    primes[1] = 0

    for prime in primes:
        if prime > math.sqrt(x):
            break
        if prime == 0:
            continue
        for non_prime in range(2 * prime, x, prime):
            primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]


N = int(input())
primes = get_primes(55555)
ans = []
i = 4

while len(ans) < N:
    p = primes[i]
    
    if p % 5 == 1:
        ans.append(p)

    i += 1

print(*ans)

Buggy submission (verdict: Runtime Error):
import itertools
import math


def get_primes(x):
    if x < 2:
        return []

    primes = [i for i in range(x)]
    primes[1] = 0

    for prime in primes:
        if prime > math.sqrt(x):
            break
        if prime == 0:
            continue
        for non_prime in range(2 * prime, x, prime):
            primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]


N = int(input())
primes = get_primes(55555)
ans = []

while len(ans) < N:
    p = primes[i]
    
    if p % 5 == 1:
        ans.append(p)

    i += 1

print(*ans)
Problem p03402 (python)

Fixed submission:
A, B = map(int, input().split())
print(100, 100)
grid = [['#'] * 100 for _ in range(50)] + [['.'] * 100 for _ in range(50)]
A -= 1; B -= 1
i, j = 0, 0
while A:
    grid[i][j] = '.'; A -= 1
    if j == 98: i += 2; j = 0
    else: j += 2
i, j = 51, 0
while B:
    grid[i][j] = '#'; B -= 1
    if j == 98: i += 2; j = 0
    else: j += 2
for r in grid:
    print(''.join(r))

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
print(100, 100)
grid = [['#'] * 100 for _ in range(50)] + [['.'] * 100 for _ in range(50)]
A -= 1; B -= 1
i, j = 0, 0
while A:
    grid[i][j] = '.'; A -= 1
    if i % 2 == 0:
        if j == 98: i += 1; j = 1
        else: j += 2
    else:
        if j == 99: i += 1; j = 0
        else: j += 2
i, j = 51, 0
while B:
    grid[i][j] = '#'; B -= 1
    if i % 2 == 0:
        if j == 98: i += 1; j = 1
        else: j += 2
    else:
        if j == 99: i += 1; j = 0
        else: j += 2
for r in grid:
    print(''.join(r))
Problem p03407 (python)

Fixed submission:
A, B, C= map(int, input().split())

if (A+B) >= C:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
 A, B, C= map(int, input().split())

if (A+B) >= C:
    print("Yes")
else:
    print("No")
Problem p03438 (python)

Fixed submission:
import math

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

total_manipulation =  sum(B) - sum(A)

manipulation_A = 0
manipulation_B = 0

for i in range(N):
    if A[i] < B[i]:
        manipulation_A += math.ceil((B[i] - A[i]) / 2)
        manipulation_B += (B[i] - A[i]) % 2
    elif A[i] > B[i]:
        manipulation_B += A[i] - B[i]

if total_manipulation - max(manipulation_A, manipulation_B) >= 0:
    print("Yes")
else:
    print("No")

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

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

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

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