Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
print(max(A)-min(A))


Fixed submission:
N = int(input())
A = list(map(int,input().split()))
print(max(A)-min(A))
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
if abs(c -a) <= d :
    print('Yes')
elif abs(b -a) <= d and abs(c -b) <= d:
    print('Yes')
else:
    print('No')


Fixed submission:
a,b,c,d = map(int , input().split())
if abs(c -a) <= d :
    print('Yes')
elif abs(b -a) <= d and abs(c -b) <= d:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
if abs(a -c) <= d :
    print('Yes')
elif abs(a - b) <= d and abs(b -c) <= d:
    print('Yes')
else:
    print('No')


Fixed submission:
a,b,c,d = map(int , input().split())
if abs(c -a) <= d :
    print('Yes')
elif abs(b -a) <= d and abs(c -b) <= d:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
if a - c <= d or c - a <= d :
    print('Yes')
elif a -c <= d or c - a <= d and b - c >= d or c - b <= d:
    print('Yes')
else:
    print('No')


Fixed submission:
a,b,c,d = map(int , input().split())
if abs(c -a) <= d :
    print('Yes')
elif abs(b -a) <= d and abs(c -b) <= d:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
if a - c <= d or c - a <= d :
    print('Yes')
else:
    print('No')


Fixed submission:
a,b,c,d = map(int , input().split())
if abs(c -a) <= d :
    print('Yes')
elif abs(b -a) <= d and abs(c -b) <= d:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
A,B,C,D = map(int,input().split())
print(min(A,B)+ min(C,D))

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
print(min(A,B)+ min(C,D))

Buggy python submission (verdict: Runtime Error):
A,B,C,D = map(int,input().split())
list1 = [A,B]
list2 = [C,D]
print(min(list1)+ min(list2))

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
print(min(A,B)+ min(C,D))

Buggy python submission (verdict: Runtime Error):
A,B,C,D = map(int,input().split())
list1 = [A,B]
list2 = [C,D]
X = min(list1)
Y = min(list2)
print(Y + X)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
print(min(A,B)+ min(C,D))
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a*b%2 ==0:
    print('Even')
else:
    print('Odd')

Fixed submission:
a,b = map(int, input().split())
c = a*b
if c % 2 == 0 :
    print('Even')
else:
    print('Odd')

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a*b%2 ==0:
    print('Even')
else:
    print('0dd')

Fixed submission:
a,b = map(int, input().split())
c = a*b
if c % 2 == 0 :
    print('Even')
else:
    print('Odd')
Buggy python submission (verdict: Runtime Error):
n ,s = map(str,input().split())
if n[0]== s[2]and n[1]==s[1] and n[2]== s[0]:
    print('Yes')
else:
    print('No')

    

Fixed submission:
n = str(input())
s = str(input())
if n[0]== s[2]and n[1]==s[1] and n[2]== s[0]:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
A = input()
B = input()
C = input()
if A[-1] == B[0] and B[-1] == C[0]:
    print('Yes')
else:
    print('No')



Fixed submission:
A,B,C = map(str,input().split())
if A[-1] == B[0] and B[-1] == C[0]:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
N = int(input())
x = 800*N
if 15 <= N <30 :
    y = 200
elif  30<= N <45:
    y = 400
elif 45 <= N <60:
    y = 600
elif 60 <= N < 75:
    y = 800
elif 75 <= N < 90:
    y = 1000
elif 90 <= N < 100:
    y = 1200
elif N ==100:
    y = 1200
print(x - y)

Fixed submission:
n = int(input())
print(800 * n - 200 * (n // 15))

Buggy python submission (verdict: Runtime Error):
N = int(input())
x = 800*N
if 15 <= int(N) <30 :
    y = 200
elif  30<= int(N) <45:
    y = 400
elif 45 <= int(N) <60:
    y = 600
elif 60 <= int(N) < 75:
    y = 800
elif 75 <= int(N) < 90:
    y = 1000
elif 90 <= int(N) < 100:
    y = 1200
elif int(N) ==100:
    y = 1200
print(x - y)

Fixed submission:
n = int(input())
print(800 * n - 200 * (n // 15))
Buggy python submission (verdict: Runtime Error):
import sys
if __name__ == '__main__':
    N,x = list(map(int,input().split()))
    if 1 < x < 2*N - 1:
        print('Yes')
        L = [i+1 for i in range(2*N - 1)]
        ANS = [-1 for i in range(2*N - 1)]
        if N != 2:
            subset = []
            if x == 2:
                subset = [x+1,x,x-1,x+2]
            else:
                subset = [x-1,x,x+2,x-2]
            for i in subset:
                L.remove(i)
            ANS[N-2:N+2] = subset
            for i in range(2*N-1):
                if ANS[i] == -1:
                    ANS[i] = L.pop()
        else:
            ANS = [1,2,3]
        for i in ANS:
            print(i)
    else:
        print('No')

Fixed submission:
import sys
if __name__ == '__main__':
    N,x = list(map(int,input().split()))
    if 1 < x < 2*N - 1:
        print('Yes')
        for i in range(2*N - 1):
            print(1+ ((x-N+i)%(2*N - 1)))
    else:
        print('No')

Buggy python submission (verdict: Runtime Error):
import sys
if __name__ == '__main__':
    N,x = list(map(int,input().split()))
    if 1 < x < 2*N - 1:
        print('Yes')
        L = [i+1 for i in range(2*N - 1)]
        if N == 2:
            for i in L:
                print(i)
        else:
            L[L.index(x+1)],L[N-2] = L[N-2],x+1
            L[L.index(x)],L[N-1] = L[N-1],x
            L[L.index(x-1)],L[N] = L[N],x-1
            L[L.index(x+2)],L[N+1] = L[N+1],x+2
            for i in L:
                print(i)
    else:
        print('No')


Fixed submission:
import sys
if __name__ == '__main__':
    N,x = list(map(int,input().split()))
    if 1 < x < 2*N - 1:
        print('Yes')
        for i in range(2*N - 1):
            print(1+ ((x-N+i)%(2*N - 1)))
    else:
        print('No')

Buggy python submission (verdict: Runtime Error):
import sys
if __name__ == '__main__':
    N,x = list(map(int,input().split()))
    if 1 < x < 2*N - 1:
        print('Yes')
        L = [i+1 for i in range(2*N - 1)]
        L[L.index(x+1)],L[N-2] = L[N-2],x+1
        L[L.index(x)],L[N-1] = L[N-1],x
        L[L.index(x-1)],L[N] = L[N],x-1
        L[L.index(x+2)],L[N+1] = L[N+1],x+2
        for i in L:
            print(i)
    else:
        print('No')


Fixed submission:
import sys
if __name__ == '__main__':
    N,x = list(map(int,input().split()))
    if 1 < x < 2*N - 1:
        print('Yes')
        for i in range(2*N - 1):
            print(1+ ((x-N+i)%(2*N - 1)))
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
count = 0
for q in range(Q):
    Query = input().split()
    if Query == ['1']:
        count += 1
    else:
        if count % 2 == 0:
            if Query[1] == "1":
                S = Query[2] + S
            else:
                S = S + Query[2]
        else:
            if Query[1] == "1":
                S = S + Query[2]
            else:
                S = Query[2] + S
if count % 2 == 1:
    print(S[::-1])
else:
    print(S)


Fixed submission:
from collections import deque

S = deque(list(input()))
Q = int(input())
count = 0
for q in range(Q):
    Query = input().split()
    if Query == ['1']:
        count += 1
    else:
        if count % 2 == 0:
            if Query[1] == "1":
                S.appendleft(Query[2])
            else:
                S.append(Query[2])
        else:
            if Query[1] == "1":
                S.append(Query[2])
            else:
                S.appendleft(Query[2])
if count % 2 == 1:
    print(''.join(list(S)[::-1]))
else:
    print(''.join(S))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
S_lis = []
for n in range(N):
    S = input()
    S_lis.append(S)

ans_lis = []
for key, value in Counter(S_lis).items():
    if value == max(Counter(S_lis).values()):
        ans_lis.append(key)
for item in sorted(ans_lis):
    print(item)


Fixed submission:
N = int(input())

S_dic = {}
maximum = 0
for n in range(N):
    S = input()
    if S not in S_dic:
        S_dic[S] = 1
    else:
        S_dic[S] += 1
    if maximum < S_dic[S]:
        maximum = S_dic[S]


for key, value in sorted(S_dic.items(), key=lambda x: x[0]):
    if value == maximum:
        print(key)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
ans = 0
evidence = [[] for n in range(N)]

for n in range(N):
    A = int(input())
    for a in range(A):
        lis = list(map(int, input().split()))
        evidence[n].append(lis)

for n in range(1 << N):
    bits = [(n >> i) & 1 for i in range(N)]
    boolean = True
    for i in range(N):
        if (n >> i) & 1 == 0:
            continue
        for x, y in evidence[i]:
            if bits[x-1] == y:
                continue
            flag = False
    if flag:
        ans = max(ans, sum(bits))
print(ans)

Fixed submission:
from collections import Counter
N = int(input())
ans = 0
evidence = [[] for n in range(N)]

for n in range(N):
    A = int(input())
    for a in range(A):
        lis = list(map(int, input().split()))
        evidence[n].append(lis)

for n in range(1 << N):
    bits = [(n >> i) & 1 for i in range(N)]
    flag = True
    boolean = True
    for i in range(N):
        if (n >> i) & 1 == 0:
            continue
        for x, y in evidence[i]:
            if bits[x-1] == y:
                continue
            flag = False
    if flag:
        ans = max(ans, sum(bits))
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import factorial
import sys

X, Y = map(int, input().split())
MOD = 10 ** 9 + 7

n1 = (2 * X - Y)
n2 = (2 * Y - X)

if n1 == 0 and n2 == 0:
    print(0)
    sys.exit()

if n1 % 3 != 0 or n2 % 3 != 0:
    print(0)
    sys.exit()
else:
    n1 = n1 // 3
    n2 = n2 // 3



P = 10**9 + 7
N = 333335
inv_t = [0]+[1]
for i in range(2,N):
    inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

m = 10**9+7
res = 1
for i in range(1, n1 + n2 + 1):
    res = res * i % m
for i in range(1, n2 + 1):
    res = res * inv_t[i] % m
for i in range(1, n1 + 1):
    res = res * inv_t[i] % m
print(res)

Fixed submission:
import sys

X, Y = map(int, input().split())
MOD = 10 ** 9 + 7

if (X + Y) % 3 != 0:
    print(0)
    sys.exit()

n1 = (2 * X - Y) // 3
n2 = (2 * Y - X) // 3

if n1 < 0 or n2 < 0:
    print(0)
    sys.exit()

P = 10 ** 9 + 7
N = 10 ** 6 + 5
inv_t = [0]+[1]
for i in range(2, N):
    inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

m = 10 ** 9 + 7
res = 1
for i in range(2, n1 + n2 + 1):
    res = res * i % m
for i in range(1, n2 + 1):
    res = res * inv_t[i] % m
for i in range(1, n1 + 1):
    res = res * inv_t[i] % m
print(res)

Buggy python submission (verdict: Runtime Error):
from math import factorial
import sys

X, Y = map(int, input().split())
MOD = 10 ** 9 + 7

n1 = (2 * X - Y)
n2 = (2 * Y - X)

if n1 % 3 != 0 or n2 % 3 != 0:
    print(0)
    sys.exit()
else:
    n1 = n1 // 3
    n2 = n2 // 3

if n1 == 0 and n2 == 0:
    print(0)
    sys.exit()


P = 10**9 + 7
N = 333334
inv_t = [0]+[1]
for i in range(2,N):
    inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

m = 10**9+7
res = 1
for i in range(n1 + 1, n1 + n2 + 1):
    res = res * i % m
for i in range(1, n1 + 1):
    res = res * inv_t[i] % m
print(res)

Fixed submission:
import sys

X, Y = map(int, input().split())
MOD = 10 ** 9 + 7

if (X + Y) % 3 != 0:
    print(0)
    sys.exit()

n1 = (2 * X - Y) // 3
n2 = (2 * Y - X) // 3

if n1 < 0 or n2 < 0:
    print(0)
    sys.exit()

P = 10 ** 9 + 7
N = 10 ** 6 + 5
inv_t = [0]+[1]
for i in range(2, N):
    inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

m = 10 ** 9 + 7
res = 1
for i in range(2, n1 + n2 + 1):
    res = res * i % m
for i in range(1, n2 + 1):
    res = res * inv_t[i] % m
for i in range(1, n1 + 1):
    res = res * inv_t[i] % m
print(res)
Buggy python submission (verdict: Runtime Error):
import math
from fractions import Fraction

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

y = Fraction(x / (a ** 2))

if b > a:
    a = Fraction(2 * a * y / b)
    teihen = b
else:
    teihen = 2 * (b - y)
res = Fraction(a / teihen)
print(90 - math.degrees(math.atan(res)))

Fixed submission:
import sys
import math
from fractions import Fraction

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

y = Fraction(x / (a ** 2))

if y == b:
    print(0)
    sys.exit()

if b - 2 * y > 0:
    a = Fraction(2 * a * y / b)
    teihen = b
else:   
    teihen = 2 * (b - y)
res = Fraction(a / teihen)
print(90 - math.degrees(math.atan(res)))
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right, bisect_left
N = int(input())
L = [int(_) for _ in input().split()]
ans = 0
L.sort()

for n in range(N - 1, -1, -1):
    for m in range(n - 1, -1, -1):
        if abs(N - 1 - bisect_left(L, L[n] + L[m])) > 0:
            #print(n, m)
            ans += bisect_left(L, L[n] + L[m]) - n - 1
            #print("ans", ans)

print(ans)

Fixed submission:
from bisect import bisect_right, bisect_left
N = int(input())
L = [int(_) for _ in input().split()]
ans = 0
L.sort()

for n in range(N - 1, -1, -1):
    for m in range(n - 1, -1, -1):
        ans += bisect_left(L, L[n] + L[m]) - n - 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right, bisect_left
N = int(input())
L = sorted([int(_) for _ in input().split()])
ans = 0

for n in range(N - 1, -1, -1):
    for m in range(n - 1, -1, -1):
        if abs(N - 1 - bisect_left(L, L[n] + L[m])) > 0:
            #print(n, m)
            ans += bisect_left(L, L[n] + L[m]) - n - 1
            #print("ans", ans)

print(ans)

Fixed submission:
from bisect import bisect_right, bisect_left
N = int(input())
L = [int(_) for _ in input().split()]
ans = 0
L.sort()

for n in range(N - 1, -1, -1):
    for m in range(n - 1, -1, -1):
        ans += bisect_left(L, L[n] + L[m]) - n - 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, K, Q = map(int, input().split())
A = np.array([K] * N)
for q in range(Q):
    answered = int(input())
    A[answered - 1] += 1
    A = A - 1
    #print(A)

for item in A:
    if item <= 0:
        print('No')
    else:
        print('Yes')

Fixed submission:
N, K, Q = map(int, input().split())

answered = [K - Q] * N

for q in range(Q):
    correct = int(input())
    answered[correct - 1] += 1
for item in answered:
    if item <= 0:
        print('No')
    else:
        print('Yes')

Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().split())
A = [K] * N
for q in range(Q):
    answered = int(input())
    A[answered - 1] += 1
    A = [_ - 1 for _ in A]
    #print(A)

for item in A:
    if item <= 0:
        print('No')
    else:
        print('Yes')

Fixed submission:
N, K, Q = map(int, input().split())

answered = [K - Q] * N

for q in range(Q):
    correct = int(input())
    answered[correct - 1] += 1
for item in answered:
    if item <= 0:
        print('No')
    else:
        print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
import bisect
import math
N, M = map(int, input().split())

A = sorted([-int(_) for _ in input().split()])
deq = deque(A)

for m in range(M):
    div = deq.popleft()
    div = math.ceil(div / 2)
    tmp_lis = list(deq)
    #print(tmp_lis)
    bisect.insort(tmp_lis, div)
    deq = deque(tmp_lis)
print(-sum(deq))

Fixed submission:
import heapq

N, M = map(int, input().split())
A = [-int(_) for _ in input().split()]
heapq.heapify(A)

tmp = 0
for m in range(M):
    div = -heapq.heappop(A)
    div = div // 2
    heapq.heappush(A, -div)
print(-sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N, M = map(int, input().split())

A = sorted([int(_) for _ in input().split()])

tmp = 0
for m in range(1, M + 1):
    div = A[-m]
    tmp += div
    div = div // 2
    bisect.insort(A, div)
    #print(A)
print(sum(A) - tmp)

Fixed submission:
import heapq

N, M = map(int, input().split())
A = [-int(_) for _ in input().split()]
heapq.heapify(A)

tmp = 0
for m in range(M):
    div = -heapq.heappop(A)
    div = div // 2
    heapq.heappush(A, -div)
print(-sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

N = int(input())
S = []
for n in range(N):
    string = ''.join(sorted(input()))
    S.append(string)

S.sort()
ans = 0

for n in range(N - 1):
    tmp = n
    while S[tmp + 1] == S[tmp]:
        ans += 1
        if tmp == N - 2:
            break
        tmp += 1

print(ans)
#print(S)

Fixed submission:
import bisect
import heapq
from collections import Counter

N = int(input())
S = []
for n in range(N):
    string = ''.join(sorted(input()))
    S.append(string)
ans = 0
counter_s = Counter(S)
for key, value in counter_s.items():
    if value >= 2:
        ans += value * (value - 1) // 2
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
N = int(input())
H = [int(_) for _ in input().split()]

diff = [0] * (N - 1)
for n in range(N - 1):
    diff[n] = H[n] - H[n + 1]

for n in range(N - 1):
    if diff[n] >= 2:
        print('No')
        sys.exit()
    if diff[n] == 1 and diff[n + 1] == 1:
        print('No')
        sys.exit()

print('Yes')

Fixed submission:
import sys
N = int(input())
A = [int(_) - 1 for _ in input().split()]

for n in range(1, N):
    if A[n] + 1 == A[n - 1]:
        A[n] += 1
    elif A[n] + 1 < A[n - 1]:
        print('No')
        sys.exit()
print('Yes')
Buggy python submission (verdict: Runtime Error):
import sys
N = int(input())
a_lis = [int(_) for _ in input().split()]

if set(b) == {0}:
    print('Yes')
    sys.exit()
else:
    if len(a_lis) % 3 == 0:
        print('Yes')
    else:
        print('No')

Fixed submission:
from collections import Counter
import sys
from functools import reduce
N = int(input())
A = [int(_) for _ in input().split()]

if set(A) == {0}:
    print('Yes')
    sys.exit()

counter = Counter(A)

if len(counter) and len(set(counter.values())) == 1:
    if reduce(lambda x, y: x ^ y, counter.keys()) == 0:
        print('Yes')
        sys.exit()

if len(counter) == 2:  
    if 0 in counter.keys():
        if counter[0] == len(A) // 3:
            print('Yes')
            sys.exit()
print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
A_vec = [int(_) for _ in input().split()]

matrix = [0] * N

for n in range(N - 1):
    matrix[n] = [0] * (n) + [0.5, 0.5] + [0] * (N - n - 2)
matrix[N - 1] = [0.5] + [0] * (N - 2) + [0.5]

X_vec = map(int, np.dot(np.linalg.inv(np.array(matrix)), A_vec))
print(' '.join(map(str, X_vec)))

Fixed submission:
n = int(input())
r_list = list(map(int, input().split()))
ans_list = []

for i in range(len(r_list)):
    if i == 0:
        a = sum(r_list)
        for j in range(1, len(r_list)):
            if j % 2 == 1:
                a -= r_list[j] * 2
    else:
        a = (2 * r_list[i-1]) - ans_list[i-1]
    ans_list.append(a)

print(' '.join(map(str, ans_list)))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(_) for _ in input().split()]
ans = [0] * N
for i in range(N):
    A_copy = A.copy()
    del A_copy[i]
    if i % 2 == 0:
        ans[i] = str(sum([A_copy[t] * (-1) ** ((t + 1) % 2) for t in range(N - 1)]) + A[i])
    else:
        ans[i] = str(sum([A_copy[t] * (-1) ** (t % 2) for t in range(N - 1)]) + A[i])
print(' '.join(ans))

Fixed submission:
n = int(input())
r_list = list(map(int, input().split()))
ans_list = []

for i in range(len(r_list)):
    if i == 0:
        a = sum(r_list)
        for j in range(1, len(r_list)):
            if j % 2 == 1:
                a -= r_list[j] * 2
    else:
        a = (2 * r_list[i-1]) - ans_list[i-1]
    ans_list.append(a)

print(' '.join(map(str, ans_list)))
Buggy python submission (verdict: Runtime Error):
import sys
N, K = map(int, input().split())

lis = [[] for i in range(N + 1)]

for n in range(N - 1):
    a, b = map(int, input().split())
    lis[a].append(b)
    lis[b].append(a)

MOD = 10 ** 9 + 7

def dfs(pos, from_, K, lis):
    if from_ == -1:
        to_multi = K - 1
    else:
        to_multi = K - 2
    if len(lis[pos]) > K:
        return 0

    ans = 1
    for item in lis[pos]:
        if item != from_:
            ans *= to_multi
            to_multi -= 1
            ans %= MOD
    for item in lis[pos]:
        if item != from_:
            ans *= dfs(item, pos, K, lis)
            ans %= MOD
    
    return ans

K * dfs(1, from_=-1, K=K, lis=lis)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 6)
N, K = map(int, input().split())

lis = [[] for i in range(N + 1)]

for n in range(N - 1):
    a, b = map(int, input().split())
    lis[a].append(b)
    lis[b].append(a)

MOD = 10 ** 9 + 7

def dfs(pos, from_, K, lis):
    if from_ == -1:
        to_multi = K - 1
    else:
        to_multi = K - 2
    if len(lis[pos]) > K:
        return 0

    ans = 1
    for item in lis[pos]:
        if item != from_:
            ans *= to_multi
            to_multi -= 1
            ans %= MOD
    for item in lis[pos]:
        if item != from_:
            ans *= dfs(item, pos, K, lis)
            ans %= MOD
    
    return ans

print(K * dfs(1, from_=-1, K=K, lis=lis) % MOD)
Buggy python submission (verdict: Runtime Error):
N = int(input())

a_b_lis = [0] * N

for i in range(N):
    a_b_lis[i] = list(map(int, input().split()))

count = 0
a_b_lis = sorted(a_b_lis, key=lambda x: x[1], x[0])

on_time = True
for item in a_b_lis:
    if item[0] + count <= item[1]:
        count += item[0]
        on_time = True
    else:
        on_time = False

if on_time:
    print('Yes')
else:
    print('No')

Fixed submission:
N = int(input())

a_b_lis = [0] * N

for i in range(N):
    a_b_lis[i] = list(map(int, input().split()))

count = 0
#print(a_b_lis)
a_b_lis = sorted(a_b_lis, key=lambda x: x[1])

on_time = True
for item in a_b_lis:
    count += item[0]
    if count > item[1]:
        on_time = False
if on_time:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
N = int(input())

a_b_lis = [0] * N

for i in range(N):
    a_b_lis[i] = list(map(int, input().split()))

count = 0
a_b_lis = sorted(a_b_lis, key=lambda x: x[1], X[0])

on_time = True
for item in a_b_lis:
    if item[0] + count <= item[1]:
        count += item[0]
        on_time = True
    else:
        on_time = False

if on_time:
    print('Yes')
else:
    print('No')

Fixed submission:
N = int(input())

a_b_lis = [0] * N

for i in range(N):
    a_b_lis[i] = list(map(int, input().split()))

count = 0
#print(a_b_lis)
a_b_lis = sorted(a_b_lis, key=lambda x: x[1])

on_time = True
for item in a_b_lis:
    count += item[0]
    if count > item[1]:
        on_time = False
if on_time:
    print('Yes')
else:
    print('No')