Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def prime_factorize(P):
    prime = list()
    for i in range(2, P + 1):
        if i**2 <= P:
            if P % i == 0:
                c = 0
                while P % i == 0:
                    P //= i
                    c += 1
                prime.append([i, c])
            else:
                continue
        else:
            break
 
    if P != 1:
        prime.append([P, 1])
 
    return prime
 
def main2():
    N, P = map(int, input().split())
 
    prime = prime_factorize(P)
 
    print(prime)
    ans = 1
    for p in prime:
        n, c = p
        ans *= (n ** (c // N)) 
 
    print(ans)
 
if __name__ == "__main__":
    main2()
def prime_factorize(P):
    prime = list()
    for i in range(2, P + 1):
        if i**2 <= P:
            if P % i == 0:
                c = 0
                while P % i == 0:
                    P //= i
                    c += 1
                prime.append([i, c])
            else:
                continue
        else:
            break

    if P != 1:
        prime.append([P, 1])

    return prime

def main2():
    N, P = map(int, input().split())

    prime = prime_factorize(P)
    ans = 1
    for p in prime:
        n, c = p
        ans *= (n ** (c // N)) 

    print(ans)

if __name__ == "__main__":
    main2()

Fixed submission:
import math
def prime_factorize(P):
    prime = list()
    for i in range(2, int(math.sqrt(P)) + 1):
        if P % i == 0:
            c = 0
            while P % i == 0:
                P //= i
                c += 1
            
            prime.append([i, c])
        else:
            continue

    if P != 1:
        prime.append([P, 1])

    return prime

def main():
    N, P = map(int, input().split())

    prime = prime_factorize(P)
    ans = 1
    for p in prime:
        n, c = p
        if c >= N:
            ans *= (n ** (c // N))

    print(ans)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, K = map(int, input().split())
    H = [int(input()) for i in range(N)]
    H.sort()
    mi = 10**9
    for i in range(N - K + 1):
        h_ = H[i:i+K]
        diff = h_[-1] - h_[0]
        if diff < mi:
            mi = diff
    print(mi)
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N, K = map(int, input().split())
    H = [int(input()) for i in range(N)]
    H.sort()
    mi = 10**9
    for i in range(N - K + 1):
        diff = H[i+K-1] - H[i]
        if diff < mi:
            mi = diff
    print(mi)
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, K = map(int, input().split())
    H = [int(input()) for i in range(N)]
    H.sort()
    mi = 10**9
    for i in range(N - K + 1):
        h_ = H[i:i+K]
        diff = max(h_) - min(h_)
        if diff < mi:
            mi = diff
    print(mi)
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N, K = map(int, input().split())
    H = [int(input()) for i in range(N)]
    H.sort()
    mi = 10**9
    for i in range(N - K + 1):
        diff = H[i+K-1] - H[i]
        if diff < mi:
            mi = diff
    print(mi)
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, K = map(int, input().split())
    H = [int(input()) for i in range(N)]
    H.sort()
    mi = 10**9
    for i in range(N - K + 1):
        h_ = H[i:i+K]
        if max(h_) - min(h_) < mi:
            mi = max(h_) - min(h_)
    print(mi)
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N, K = map(int, input().split())
    H = [int(input()) for i in range(N)]
    H.sort()
    mi = 10**9
    for i in range(N - K + 1):
        diff = H[i+K-1] - H[i]
        if diff < mi:
            mi = diff
    print(mi)
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import math
def main():
    X = int(input())
    ma = 1
    for b in range(2, X):
        for p in range(2, X):
            if b**p <= X:
                if ma < b**p:
                    ma = b**p
    print(ma)  
main()

Fixed submission:
import math
def main():
    X = int(input())
    ma = 1
    for b in range(2, X):
        for p in range(2, X):
            if b**p <= X:
                if ma < b**p:
                    ma = b**p
            else:
                break
    print(ma)  
main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
def main():
    N = int(input())
    X = [int(a) for a in input().split()]
    X_s = sorted(X)

    medi = defaultdict(int)

    for i in range(len(X)):
        if X[i] in medi.keys():
            print(medi[X[i]])
        else:
            dummy = X_s[:]
            dummy.remove(X[i])
            m = dummy[len(dummy) // 2]
            print(m)
            medi[X[i]] = m

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N = int(input())
    X = [int(a) for a in input().split()]
    Xs = sorted(X)

    for i in range(len(X)):
        if  Xs[len(Xs)//2] > X[i]:
            print(Xs[len(Xs)//2])
        else:
            print(Xs[len(Xs)//2 - 1])

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    A, B, K = map(int, input().split())
    count = 0
    for i in range(A, B+1):
        if count < K or  (B-A)-K < count:        
            print(i)
        count += 1
main()

Fixed submission:
def main():
    A, B, K = map(int, input().split())
    if 2*K > B - A:
        for j in range(A, B + 1):
            print(j)
    else:
        for i in range(A, A + K):
            print(i)
        for j in range(B-(K-1), B + 1):
            print(j)
main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
def main():
    A, B, K = map(int, input().split())
    number = deque()
    for i in range(A, B+1):
        number.append(i)
    for i in range(K):
        if len(number) > 0:
            print(number.popleft())
    l = deque()
    for i in range(K):
        if len(number) > 0:
            l.append(number.pop())
    for i in range(len(l)):
        if len(l) > 0:
            print(l.pop())
main()

Fixed submission:
def main():
    A, B, K = map(int, input().split())
    if 2*K > B - A:
        for j in range(A, B + 1):
            print(j)
    else:
        for i in range(A, A + K):
            print(i)
        for j in range(B-(K-1), B + 1):
            print(j)
main()
Buggy python submission (verdict: Runtime Error):
def main():
    s = list(input())
    t = list(input())
    s = sorted(s)
    t = sorted(t)
    ind = 0
    for i in range(len(s)):
        if s[i] == t[i]:
            ind = i
    shrt = False
    for i in range(ind, len(t)):
        if s[0] < t[i]:
            shrt = True
            break
    if shrt :
        print("Yes")
    else:
        print("No")
main()

Fixed submission:
def main():
    s = list(input())
    t = list(input())
    s = sorted(s)
    t = sorted(t)
    t = t[::-1]
    
    if "".join(s) < "".join(t):
        print("Yes")
    else:
        print("No")
main()
Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())
    A = [int(input()) for a in range(N)]
    L = [0 for i in range(10**4)]

    for i in range(N):
        if L[A[i]-1] == 0:
            L[A[i]-1] = 1
        elif L[A[i]-1] == 1:
            L[A[i]-1] = 0

    print(sum(L))
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N = int(input())
    A = [int(input()) for a in range(N)]
    S = set()

    for i in range(N):
        if A[i] in S:
            S.remove(A[i])
        else:
            S.add(A[i])
    print(len(S))
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    number = sorted(set(A))
    c = defaultdict(int)
    for k in number:
        c[k] = A.count(k-1) + A.count(k) + A.count(k+1)
    ma = 0
    for k, v in c.items():
        if v > ma:
            ma = v
    print(ma)

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    C = [0]*10**5
    for i in range(N):
        C[A[i]] += 1
    ma = 0
    for i in range(1, len(C)-1):
        count = C[i-1] + C[i] + C[i+1]
        if count > ma:
            ma = count    
    print(ma)
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    N = input()
    S = str(N)
    S = S[::-1]

    odd = 0
    even = 0

    for i in range(len(S)):
        if (i + 1) % 2 == 0:
            even += int(S[i])
        else:
            odd += int(S[i])
    print(even, odd)

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N, A, B = map(int, input().split())
    ans = 0

    if A > B:
        ans = 0
    else:
        if N == 1:
            if A != B:
                ans = 0
            else:
                ans = 1
        elif N == 2:
            ans = 1
        else:
            ans = (B - A)*(N - 2) + 1

    print(ans)
    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    power = 1
    for i in range(N):
        power *= (i + 1)
    print(power%(1000000000 + 7))
main()

Fixed submission:
import math
def main():
    N = int(input())
    power = math.factorial(N)
    print(power%(1000000000 + 7))
main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    power = 1
    for i in range(N):
        power *= (i + 1)
    print(power%(1000000000 + 7))
main()

Fixed submission:
import math
def main():
    N = int(input())
    power = math.factorial(N)
    print(power%(1000000000 + 7))
main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    K, S = map(int, input().split())
    count = 0
    for i in range(K+1):
        if i > S:
            break
        for j in range(K+1):
            if i + j > S:
                break
            for k in range(K+1):
                if i + j + k > S:
                    break
                elif i + j + k == S:
                    count += 1
    print(count)
main()

Fixed submission:
def solve(K, S):
    count = 0
    for i in range(K+1):
        for j in range(K+1):
            if 0 <= S - i - j <= K:
                count += 1
    return count
def main():
    K, S = map(int, input().split())
    count = solve(K, S)
    print(count)
main()
Buggy python submission (verdict: Runtime Error):
def main2():
    x, y = map(int, input().split())

    delta = abs(abs(x) - abs(y))

    c1 = delta + 0 + 0
    c2 = delta + 0 + 1
    c3 = delta + 1 + 0
    c4 = delta + 1 + 1

    print(min(c1, c2, c3, c4))

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    x, y = map(int, input().split())

    if x == y:
        print(0)

    elif abs(x) == abs(y):
        print(1)

    elif x < y:
        if x >= 0 and y >= 0:
            print(y - x)

        elif x >= 0 and y <= 0:
            pass

        elif x <= 0 and y >= 0:
            if y == 0:
                print(abs(x))
            else:
                if abs(y) > abs(x):
                    print(abs(y) - abs(x) + 1)
                else:
                    print(abs(x) - abs(y) + 1)

        elif x <= 0 and y <= 0:
            print(abs(x) - abs(y))

    elif x > y:
        if x <= 0 and y <= 0:
            c1 = abs(y) - x + 1
            c2 = abs(y) - abs(x) + 2
            print(min(c1, c2))

        elif x <= 0 and y >= 0:
            pass

        elif x >= 0 and y <= 0:
            print(max(abs(x), abs(y)) - min(abs(x), abs(y)) + 1)
            
        elif x >= 0 and y >= 0:
            print(x - y + 2)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
a = 1
repeat_count = 0
while a*a <= n:
    b = 1
    while a*b < n:
        ans += 1
        if b * b > n:
            repeat_count += 1
        b += 1
    a += 1
print(ans + repeat_count)

Fixed submission:
import math as mt
from collections import defaultdict
  
MAXN = 10**6
  
spf = [0 for i in range(MAXN)] 
  
def sieve(): 
    spf[1] = 1
    for i in range(2, MAXN): 
        spf[i] = i 
    for i in range(4, MAXN, 2): 
        spf[i] = 2
  
    for i in range(3, mt.ceil(mt.sqrt(MAXN))): 
        if (spf[i] == i): 
            for j in range(i * i, MAXN, i):  
                if (spf[j] == j): 
                    spf[j] = i 
  
# A O(log n) function returning prime  
# factorization by dividing by smallest  
# prime factor at every step 
def getFactorization(x): 
    d = defaultdict(int)
    while (x != 1): 
        #ret.append(spf[x])
        d[spf[x]] += 1 
        x = x // spf[x] 
    #return Counter(ret)
    ans = 1
    for i in d:
        ans *= (d[i]+1)
    return ans
sieve()

n = int(input())
ans = 0
for i in range(1, n):
    ans += getFactorization(i)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
a = 1
repeat_count = 0
while a <= n:
    b = 1
    while b <= a and a*b < n:
        ans += 1
        if b < a:
            repeat_count += 1
        b += 1
    a += 1
print(ans + repeat_count)

Fixed submission:
import math as mt
from collections import defaultdict
  
MAXN = 10**6
  
spf = [0 for i in range(MAXN)] 
  
def sieve(): 
    spf[1] = 1
    for i in range(2, MAXN): 
        spf[i] = i 
    for i in range(4, MAXN, 2): 
        spf[i] = 2
  
    for i in range(3, mt.ceil(mt.sqrt(MAXN))): 
        if (spf[i] == i): 
            for j in range(i * i, MAXN, i):  
                if (spf[j] == j): 
                    spf[j] = i 
  
# A O(log n) function returning prime  
# factorization by dividing by smallest  
# prime factor at every step 
def getFactorization(x): 
    d = defaultdict(int)
    while (x != 1): 
        #ret.append(spf[x])
        d[spf[x]] += 1 
        x = x // spf[x] 
    #return Counter(ret)
    ans = 1
    for i in d:
        ans *= (d[i]+1)
    return ans
sieve()

n = int(input())
ans = 0
for i in range(1, n):
    ans += getFactorization(i)
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
tol = 1e-6
ans = 1
cur = [0,0]
cur[0] += math.cos(ans*math.pi/x)
cur[1] += math.sin(ans*math.pi/x)
while cur[0]**2 + cur[1]**2 > tol:
    ans += 1
    cur[0] += math.cos(ans*math.pi/x)
    cur[1] += math.sin(ans*math.pi/x)
print(ans)


Fixed submission:
import math
x = int(input())
tol = 1e-6
ans = 1
cur = [0,1]
unit = x/180*math.pi
while cur[0]**2 + cur[1]**2 > tol:
    cur[0] += math.sin(ans*unit)
    cur[1] += math.cos(ans*unit)
    ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
tol = 1e-6
ans = 1
cur = [0,0]
cur[0] += math.cos(ans*math.pi/x)
cur[1] += math.sin(ans*math.pi/x)
while cur[0]**2 + cur[1]**2 > tol:
    ans += 1
    cur[0] += math.cos(ans*math.pi/x)
    cur[1] += math.sin(ans*math.pi/x)
print(ans)

Fixed submission:
import math
x = int(input())
tol = 1e-6
ans = 1
cur = [0,1]
unit = x/180*math.pi
while cur[0]**2 + cur[1]**2 > tol:
    cur[0] += math.sin(ans*unit)
    cur[1] += math.cos(ans*unit)
    ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = [int(i) for i in input().split()]
A = [0] + [int(i) for i in input().split()]
# first study the cycle of A
cycle = [A[1]]
i = A[1]
while A[i] not in cycle:
    cycle.append(A[i])
    i = A[i]
cycle.append(A[i])
interest_ind = cycle.index(cycle[-1])
first_part = cycle[:interest_ind]
second_part = cycle[interest_ind:-1]
p = len(second_part)
k -= 1
if k < interest_ind:
    print(first_part[k])
else:
    k -= interest_ind
    k %= p
    print(second_part[k])

Fixed submission:
n, k = [int(i) for i in input().split()]
A = [0] + [int(i) for i in input().split()]
# first study the cycle of A
cycle = [A[1]]
i = A[1]
visited = set(cycle)
while A[i] not in visited:
    cycle.append(A[i])
    visited.add(A[i])
    i = A[i]
interest_ind = cycle.index(A[i])
second_part = cycle[interest_ind:]
p = len(cycle) - interest_ind
k -= 1
if k < interest_ind:
    print(cycle[k])
else:
    k -= interest_ind
    k %= p
    print(cycle[interest_ind + k])
Buggy python submission (verdict: Runtime Error):
j = int(input())
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(A[k-1])

Fixed submission:
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(A[k-1])
Buggy python submission (verdict: Runtime Error):
print((N+1)//2)

Fixed submission:
print((int(input()) + 1)//2)
Buggy python submission (verdict: Runtime Error):
N, M , X, Y = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
if X < Y and max(x) < min(y) and  min(y) > X and max(x) < Y:
    print('No War')
else:
    print('War')

Fixed submission:
A, B, C = input().split()
#ABC
#ABC
#BAC
#BCA 
#CAB
#CBA 
print(max(int(A+B)+int(C), int(A+C)+int(B), int(B+A)+int(C), int(B+C)+int(A), int(C+A)+int(B),int(C+B)+int(A)))
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())
for i in S:
    if i != '1':
        print(i)
        break
    K -= 1
    if K == 0:
        print(1)
        break

Fixed submission:
A, B = [ int(i) for i in input().split()]
print(A*B - A - B + 1)
Buggy python submission (verdict: Runtime Error):
from itertools import permutations
N, M, R = [int(i) for i in input().split()]
r = [int(i) - 1 for i in input().split()]
V = N
# Define infinity as the large enough value. This value will be
# used for vertices not connected to each other
INF  = 10000000
 
graph = [[INF for i in range(N)] for j in range(N)]
 
for m in range(M):
    A, B, C  = [int(i) for i in input().split()]
    A = A - 1
    B = B - 1
    graph[A][B] = C
    graph[B][A] = C
 
# Solves all pair shortest path via Floyd Warshall Algrorithm
def floydWarshall(graph):
    dist = graph
    for k in range(V):
 
        # pick all vertices as source one by one
        for i in range(V):
 
            # Pick all vertices as destination for the
            # above picked source
            for j in range(V):
 
                # If vertex k is on the shortest path from 
                # i to j, then update the value of dist[i][j]
                dist[i][j] = min(dist[i][j] ,
                                  dist[i][k]+ dist[k][j]
                                )
    return(dist)
 
new_graph = floydWarshall(graph)
smallest_dist = INF
for sub_permute in permutations(r):
    tmp = 0
    for i in range(R-1):
        tmp += new_graph[sub_permute[i]][sub_permute[i+1]]
    smallest_dist = min(smallest_dist, tmp)
print(smallest_dist)

Fixed submission:
N = input()
if '9' in N:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
writing = [0 for i in range(1 << 9)]
for n in range(N):
    A = int(input()) - 1
    writing[A] += 1
    writing[A] %= 2
print(sum(writing))

Fixed submission:
N = int(input())
writing = set()
for n in range(N):
    A = int(input())
    if A in writing:
        writing.remove(A)
    else:
        writing.add(A)
print(len(writing))
Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    """Return greatest common divisor using Euclid's Algorithm."""
    while b:      
        a, b = b, a % b
    return a

def lcm(a, b):
    """Return lowest common multiple."""
    return a * b // gcd(a, b)

N = int(input())
if N > 1:
    T = int(input())
for i in range(1, N):
    T = lcm(int(input()), T)
print(T)

Fixed submission:
def gcd(a, b):
    """Return greatest common divisor using Euclid's Algorithm."""
    while b:      
        a, b = b, a % b
    return a

def lcm(a, b):
    """Return lowest common multiple."""
    return a * b // gcd(a, b)

N = int(input())
T = int(input())
for i in range(1, N):
    T = lcm(int(input()), T)
print(T)
Buggy python submission (verdict: Runtime Error):
N, K = [int(i) for i in input().split()]
print(K*((K-1)**(N-1)))

Fixed submission:
s=set(input().split())
print(len(s))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

l = [0] * 1000001

ans = 0

for i in range(n):
    l[a[i]] += 1

for i in range(1, 1000001):
    if l[i] > 0:
        if l[i] == 1:
            ans += 1
        for j in range(2, 1000001//i + 1):
            l[i * j] = 0

print(ans)

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

l = [0] * 1000001

ans = 0

for i in range(n):
    l[a[i]] += 1

for i in range(1, 1000001):
    if l[i] > 0:
        if l[i] == 1:
            ans += 1
        for j in range(2, 1000000//i + 1):
            l[i * j] = 0

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int, input().split())
a = list(map(int, input().split()))

end = False

def one(list):
    b = [0] * n
    for i in range(n):
        l = max(0, i-list[i])
        r = min(i+list[i], n-1)
        b[l] += 1
        if r + 1 < n:
            b[r+1] -= 1
    ee = True
    if b[0] < n:
        ee = False
    for i in range(1, n):
        b[i] += b[i-1]
        if b[i] < n:
            ee = False
    if ee == True:
        end = True
    return b

for i in range(k):
    a = one(a)
    if end:
        break

print(*a)

Fixed submission:
n,k = map(int, input().split())
a = list(map(int, input().split()))


for _ in range(k):
    b = [0] * n
    for i in range(n):
        l = max(0, i - a[i])
        r = min(n-1, i + a[i])
        b[l] += 1
        if r + 1 < n:
            b[r + 1] -= 1
    ee = True
    a[0] = b[0]
    if a[0] < n:
        ee = False
    for i in range(1, n):
        a[i] = a[i-1] + b[i]
        if a[i] < n:
            ee = False
    if ee == True:
        break

print(*a)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
left = []
right = []
for i in range(n):
    s = input()
    n0 = 0
    n1 = 0
    l = len(s)
    for j in range(l):
        if s[j] == "(":
            n0 += 1
        else:
            if n0 == 0:
                n1 += 1
            else:
                n0 -= 1
    if n0 > 0 or n1 > 0:
        if n0 >= n1:
            left.append([n1, n0])
        else:
            right.append([n0, n1])
 
left.sort()
right.sort()
 
def solve():
    nl0 = 0
    nl1 = 0
    for p in left:
        if p[0] > nl0:
            return False
        nl0 -= p[0]
        nl0 += p[1]
    nr0 = 0
    nr1 = 0
    for p in right:
        if p[0] > nr1:
            return False
        nr1 -= p[0]
        nr1 += p[1]
    if nl0 == nr1:
        return True
    else:
        return False
 
if solve():
    print("Yes")
else:
    print("No")

Fixed submission:
n = int(input())
left = []
right = []
for i in range(n):
    s = input()
    n0 = 0
    n1 = 0
    l = len(s)
    for j in range(l):
        if s[j] == "(":
            n0 += 1
        else:
            if n0 == 0:
                n1 += 1
            else:
                n0 -= 1
    if n0 > 0 or n1 > 0:
        if n0 >= n1:
            left.append([n1, n0])
        else:
            right.append([n0, n1])
 
left.sort()
right.sort()
 
def solve():
    nl0 = 0
    nl1 = 0
    for p in left:
        if p[0] > nl0:
            return False
        nl0 -= p[0]
        nl0 += p[1]
    nr0 = 0
    nr1 = 0
    for p in right:
        if p[0] > nr1:
            return False
        nr1 -= p[0]
        nr1 += p[1]
    if nl0 == nr1:
        return True
    else:
        return False
 
if solve():
    print("Yes")
else:
    print("No")