Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
flag = [True] * n
cnt = [0] * n
for i in range(m):
    a = int(input())
    flag[a - 1] = False

for i in range(n - 1, -1, -1):
    if flag[i]:
        if i == n - 1 or i == n - 2:
            cnt[i] = 1
        else:
            cnt[i] = (cnt[i + 1] + cnt[i + 2]) % (10 ** 9 + 7)
    else:
        cnt[i] = 0
print (cnt[0]+ cnt[1])

Fixed submission:
n, m = map(int, input().split())
flag = [True] * (n + 1)
cnt = [0] * (n + 1)
for i in range(m):
    a = int(input())
    flag[a] = False

for i in range(n, -1, -1):
    if flag[i]:
        if i == n or i == n - 1:
            cnt[i] = 1
        else:
            cnt[i] = (cnt[i + 1] + cnt[i + 2]) % (10 ** 9 + 7)
    else:
        cnt[i] = 0
print (cnt[0])
Buggy python submission (verdict: Runtime Error):
n, a, b, c, d = map(int, input().split())
s = input()
flag1, flag2 = False, False
if d > c
    flag = "##" not in s[b: d] and "##" not in s[a: c]
else:
    flag = "..." in s[b: d]

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

Fixed submission:
n, a, b, c, d = map(int, input().split())
s = input()
flag1, flag2 = False, False
if d > c:
    flag = "##" not in s[b: d] and "##" not in s[a: c]
else:
    flag = "..." in s[b - 2: d + 1]

print("Yes" if flag else "No")
Buggy python submission (verdict: Time Limit Exceeded):

s = input()
ans = 0
while "ABC" in s:
    ans += s.count("ABC")
    s = s.replace("ABC", "BCA")
print(ans)

Fixed submission:

s = input()
i, ans, total = 0, 0, 0

while i < len(s) - 1:
    if s[i: i + 2] == "BC":
        ans += total 
        i += 2
    elif s[i] == "A":
        total += 1
        i += 1
    else:
        total = 0
        i += 1

print(ans)
Buggy python submission (verdict: Runtime Error):

n, m = map(int, input().split())
L = [0] * m
R = [0] * m
for i in range(m):
    L[i], R[i] = map(int, input().split())
print(min(R) - max(L) + 1 if min(R) >= max(L else 0))

Fixed submission:

n, m = map(int, input().split())
L = [0] * m
R = [0] * m
for i in range(m):
    L[i], R[i] = map(int, input().split())
print(min(R) - max(L) + 1 if min(R) >= max(L) else 0)

Buggy python submission (verdict: Runtime Error):

n, m = map(int, input().split())
L = [0] * m
R = [0] * def funcname(self, parameter_list):
    pass
for i in range(m):
    L[i], R[i] = map(int, input().split())
print(min(R) - max(L) + 1)

Fixed submission:

n, m = map(int, input().split())
L = [0] * m
R = [0] * m
for i in range(m):
    L[i], R[i] = map(int, input().split())
print(min(R) - max(L) + 1 if min(R) >= max(L) else 0)

Buggy python submission (verdict: Time Limit Exceeded):

n, m = map(int, input().split())
L = [0] * m
R = [0] * m
judge = [0] * n
for i in range(m):
    L[i], R[i] = map(int, input().split())
    for j in range(L[i], R[i] + 1):
        judge[j - 1] += 1

cnt = 0
for i in range(n):
    if judge[i] == m:
        cnt += 1

print(cnt)

Fixed submission:

n, m = map(int, input().split())
L = [0] * m
R = [0] * m
for i in range(m):
    L[i], R[i] = map(int, input().split())
print(min(R) - max(L) + 1 if min(R) >= max(L) else 0)
Buggy python submission (verdict: Time Limit Exceeded):
r, g, b, n = map(int, input().split())

ans = 0
for i in range(n // r + 1):
    for j in range((n - i * r) // g + 1):
        if i * r + j * g > n:
            break
        k = n - (i * r + j * g)

        if k % b == 0:
            ans += 1

print(ans)

Fixed submission:
r, g, b, n = map(int, input().split())

ans = 0
for i in range(n // r + 1):
    for j in range((n - i * r) // g + 1):
        k = n - (i * r + j * g)
        if k % b == 0:
            ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
r, g, b, n = map(int, input().split())

ans = 0
for i in range(n // r + 1):
    for j in range(n // g + 1):
        if i * r + j * g > n:
            break
        k = n - (i * r + j * g)

        if k % b == 0:
            ans += 1

print(ans)

Fixed submission:
r, g, b, n = map(int, input().split())

ans = 0
for i in range(n // r + 1):
    for j in range((n - i * r) // g + 1):
        k = n - (i * r + j * g)
        if k % b == 0:
            ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
r, g, b, n = map(int, input().split())

ans = 0
for i in range(n // r + 1):
    for j in range(n // g + 1):
        if i * r + j * g > n:
            break
        k = n - (i * r + j * g)

        if k % b == 0:
            ans += 1

print(ans)

Fixed submission:
r, g, b, n = map(int, input().split())

ans = 0
for i in range(n // r + 1):
    for j in range((n - i * r) // g + 1):
        k = n - (i * r + j * g)
        if k % b == 0:
            ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = 0
i = 1

def calc(x):
    x -= 1
    if n // x == n % x:
        return x
    return 0

for i in range(1, int(n ** 0.5) + 1):
    if n % i == 0:
        if i != 1:
            ans += calc(i)
        ans += calc(n // i)
print(ans)

Fixed submission:
n = int(input())
ans = 0
def calc(x):
    x -= 1
    if x <= 0:
        return 0
    elif n // x == n % x:
        return x
    return 0

for i in range(1, int(n ** 0.5) + 1):
    if n % i == 0:
        ans += calc(n // i) + calc(i)
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import gcd

n = int(input())
A = list(map(int, input().split()))
L, R = [0] * (n + 1), [0] * (n + 1)

for i in range(1, n + 1):
    L[i] = gcd(L[i - 1], A[i - 1])

for i in range(n - 1, -1, -1):
    R[i] = gcd(R[i + 1], A[i])

ans = 0
#print(L, R)
for i in range(n):
    ans = max(ans, gcd(L[i], R[i + 1]))
print(ans)

Fixed submission:
from fractions import gcd

n = int(input())
A = list(map(int, input().split()))
L, R = [0] * (n + 1), [0] * (n + 1)

for i in range(1, n + 1):
    L[i] = gcd(L[i - 1], A[i - 1])

for i in range(n - 1, -1, -1):
    R[i] = gcd(R[i + 1], A[i])

ans = 0
#print(L, R)
for i in range(n):
    ans = max(ans, gcd(L[i], R[i + 1]))
print(ans)

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

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

def calc_gcd(a, b):
    if a < b:
        temp = b
        b = a
        a = temp
    
    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b
    
    return b

gcd = math.gcd(A[0], A[1])

for i in range(2, n - 1):
    gcd = math.gcd(gcd, A[i])

ans = gcd
for i in range(1, n - 1):
    gcd1 = A[i - 1]
    gcd2 = A[i + 1]
    for j in range(i - 1):
        gcd1 = math.gcd(gcd1, A[j])
    
    for j in range(i + 2, n - 1):
        gcd2 = math.gcd(gcd2, A[i])
    gcd = math.gcd(gcd1, gcd2)
    ans = max(ans, gcd)
    
print(ans)

Fixed submission:
from fractions import gcd

n = int(input())
A = list(map(int, input().split()))
L, R = [0] * (n + 1), [0] * (n + 1)

for i in range(1, n + 1):
    L[i] = gcd(L[i - 1], A[i - 1])

for i in range(n - 1, -1, -1):
    R[i] = gcd(R[i + 1], A[i])

ans = 0
#print(L, R)
for i in range(n):
    ans = max(ans, gcd(L[i], R[i + 1]))
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
i = 0
ans = 0
while i < len(s):
    if s[i] == "A" or s[i] == "T" or s[i] == "C" or s[i] == "G":
        for j in range(len(s) - i):
            if s[i + j] != "A" and s[i + j] != "T" and s[i + j] != "C" and s[i + j] != "G":
                break
        ans = max(ans, j)
    i += j
print(ans)


Fixed submission:

s = input()

cnt = 0
ans = 0
for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'T' or s[i] == 'C' or s[i] == 'G':
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0

ans = max(ans, cnt)
print(ans)
Buggy python submission (verdict: Runtime Error):

n, q = map(int, input().split())
s = input()
cnt = 0
for i in range(n):
    if s[i] == 'A' and s[i + 1] == 'C':
        cnt += 1

data = [0] * cnt
j = 0
ans = [0] * q
for i in range(n - 1):
    if s[i] == 'A' and s[i + 1] == 'C':
        data[j] = i + 1
        j += 1
        
for i in range(q):
    l, r = map(int, input().split())
    cnt = 0
    for j in range(len(data)):
        if data[j] <= r - 1 and data[j] >= l:
            cnt += 1
        elif data[j] >= r:
            break
    ans[i] = cnt

for i in range(q):
    print(ans[i])

Fixed submission:

n, q = map(int, input().split())
s = input()
cnt = 0
data = [0] * (n + 1)
ans = [0] * q
for i in range(n - 1):
    if s[i] == 'A' and s[i + 1] == 'C':
        cnt += 1
    data[i + 1] = cnt

data[n - 1] = cnt

for i in range(q):
    l, r = map(int, input().split())

    ans[i] = data[r - 1] - data[l - 1]

for i in range(q):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
a, b = map(int, input().split())
ans = 0
for i in range(a, b + 1):
    ans ^= i
print(ans)

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

def f(x):
    res = 0
    while x % 4 != 3:
        res ^= x
        x -= 1
    
    return res

print(f(a - 1) ^ f(b))
Buggy python submission (verdict: Runtime Error):
s = list(input())
n = len(s)
i = 0
cnt = 0
while i != n - 1:
    if (s[i] == '0' and s[i + 1] == '1') or (s[i] == '1' and s[i + 1] == '0'):
        s[i:i + 2] = []
        i -= 1
        cnt += 2
        n = len(s)
    else:
        i += 1

print(cnt)

Fixed submission:
s = list(input())
n = len(s)
i = 0
cnt = 0
while i < n - 1:
    if n == 1:
        break
    if (s[i] == '0' and s[i + 1] == '1') or (s[i] == '1' and s[i + 1] == '0'):
        s[i:i + 2] = []
        i = max(i - 1, 0)
        cnt += 2
        n = len(s)
    else:
        i += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):

n, m = map(int, input().split())

x = list(map(int, input().split()))
x.sort()
dis = [0] * (m - 1)
for i in range(m - 1):
    dis[i] = x[i + 1] - x[i]

dis.sort()
ans = x[m - 1] - x[0]
for i in range(len(dis) - 1, len(dis)- n, -1):
    ans -= dis[i]

print(ans)

Fixed submission:

n, m = map(int, input().split())

x = list(map(int, input().split()))
if n >= m:
    print(0)
    exit()
x.sort()
dis = [0] * (m - 1)
for i in range(m - 1):
    dis[i] = x[i + 1] - x[i]

dis.sort()
ans = x[m - 1] - x[0]
for i in range(len(dis) - 1, len(dis)- n, -1):
    ans -= dis[i]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A, B = [], []

for i in range(n):
    a, b = map(int, input().split())
    A.append([a, i])
    B.append([b, i])

A = sorted(A, key = lambda x: x[0])
B = sorted(B, key = lambda x: x[0])
flag = [0] * n
sum_t, sum_a = 0, 0

def search_num(l):
    ret = 0
    while flag[l[-1 - ret][1] - 1] == 1:
        ret += 1
    
    return ret

for i in range(n):
    if i % 2 == 0:
        index = search_num(A)
        sum_t += A[-1 - index][0]
        flag[A[-1 - index][1] - 1] = 1
    else:
        index = search_num(B)
        sum_a += B[-1 - index][0]
        flag[B[-1 - index][1] - 1] = 1

print(sum_t - sum_a)

Fixed submission:
n = int(input())
point = [0] * n
total_b = 0
for i in range(n):
    a, b = map(int, input().split())
    point[i] = a + b
    total_b += b

point.sort(reverse = True)

sum_t = 0
for i in range(n):
    if i % 2 == 0:
        sum_t += point[i]

print(sum_t - total_b)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
n, p = map(int, input().split())
cnt = defaultdict(int)
while p != 1:
    for i in range(2, p + 1):
        flag = False
        while p % i == 0:
            p //= i
            cnt[i] += 1
            flag = True
        if flag:
            break
ans = 1
for k, v in cnt.items():
    ans *= k ** (v // n)

print(ans)

Fixed submission:
from collections import defaultdict
n, p = map(int, input().split())
cnt = defaultdict(int)
if n == 1:
    print(p)
    exit()
for i in range(2, int(p ** 0.5) + 1):
    flag = False
    while p % i == 0:
        p //= i
        cnt[i] += 1
ans = 1
for k, v in cnt.items():
    ans *= k ** (v // n)

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = 0
for i in range(n):
    x = max(int(input()), x)
print("first" if sum % 2 == 1 else "second")

Fixed submission:
n = int(input())
a = [0] * n
flag = True
for i in range(n):
    a[i] = int(input())
    if a[i] % 2 == 1:
        flag = False
print("second" if flag else "first")
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())

ans = 0
for i in range(len(s)):
    for j in range(len(s) - 1):
        if s[j] == "B" and s[j + 1] == "W":
            ans += 1
            s[j] = "W"
            s[j + 1] = "B"


print(ans)

Fixed submission:
s = list(input())

ans = 0
x = len(s) - 1
for i in range(len(s) - 1, -1, -1):
    if s[i] == "B":
        ans += x - i
        x -= 1

print(ans)
Buggy python submission (verdict: Runtime Error):

n, x = map(int, input().split())

def make_burger(n):
    if n == 0:
        return "P"
    else:
        L = make_burger(n - 1)
        return "B" + L + "P" + L + "B"
    

b = make_burger(n)
ans = 0
for i in range(len(b) - 1, len(b) - x - 1, -1):
    if b[i] == "P":
        ans += 1
print(ans)

Fixed submission:

n, x = map(int, input().split())

a, p = [1], [1]

for i in range(n):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)

def cnt_p(n, x):
    if n == 0:
        if x <= 0:
            return 0
        return 1
    elif x <= 1 + a[n - 1]:
        return cnt_p(n - 1, x - 1)
    else:
        return p[n - 1] + 1 + cnt_p(n - 1, x - 2 - a[n - 1])


print(cnt_p(n, x))
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
n, m = map(int, input().split())
s = list(input())
t = list(input())
i = 1
ans = n * m // gcd(n, m)

a = [""] * (ans + 1)
flag = False
for j in range(n):
    a[ans // n * j] = s[j]
for k in range(m):
    if a[ans // m * k] != "" and a[ans // m * k] != t[k]:
        i += 1
        flag = True
        break
    a[ans // m * k] = t[k]
if flag:
    ans = -1

print(ans)


Fixed submission:
from fractions import gcd
n, m = map(int, input().split())
s = list(input())
t = list(input())
i = 1
ans = n * m // gcd(n, m)
g = gcd(n, m)
for i in range(g):
    if s[i * n // g] != t[i * m // g]:
        ans = -1
        break
print(ans)

Buggy python submission (verdict: Runtime Error):
from fractions import gcd
n, m = map(int, input().split())
s = list(input())
t = list(input())
i = 1
ans = n * m // gcd(n, m)

a = [""] * (ans * i)
flag = False
for j in range(n):
    a[ans // n * j] = s[j]
for k in range(m):
    if a[ans // m * k] != "" and a[ans // m * k] != t[k]:
        i += 1
        flag = True
        break
    a[ans // m * k] = t[k]
if flag:
    ans = -1

print(ans)


Fixed submission:
from fractions import gcd
n, m = map(int, input().split())
s = list(input())
t = list(input())
i = 1
ans = n * m // gcd(n, m)
g = gcd(n, m)
for i in range(g):
    if s[i * n // g] != t[i * m // g]:
        ans = -1
        break
print(ans)

Buggy python submission (verdict: Runtime Error):
from fractions import gcd
n, m = map(int, input().split())
s = list(input())
t = list(input())
if max(n, m) % min(n, m) == 0:
    print(-1)
else:
    i = 1
    lcm = n * m // gcd(n, m)
    while 1:
        a = [""] * (lcm * i)
        flag = True
        for j in range(n):
            a[lcm // n * j] = s[j]
        for k in range(m):
            if a[lcm // m * k] != "" and a[lcm // m * k] != t[k]:
                i += 1
                flag = False
                break
            a[lcm // m * k] = t[k]
        if flag:
            print(lcm * i)
            exit()


Fixed submission:
from fractions import gcd
n, m = map(int, input().split())
s = list(input())
t = list(input())
i = 1
ans = n * m // gcd(n, m)
g = gcd(n, m)
for i in range(g):
    if s[i * n // g] != t[i * m // g]:
        ans = -1
        break
print(ans)

Buggy python submission (verdict: Runtime Error):
from math import gcd
n, m = map(int, input().split())
s = input()
t = input()
if max(n, m) % min(n, m) == 0:
    print(-1)
else:
    print(n * m // gcd(n, m))


Fixed submission:
from fractions import gcd
n, m = map(int, input().split())
s = list(input())
t = list(input())
i = 1
ans = n * m // gcd(n, m)
g = gcd(n, m)
for i in range(g):
    if s[i * n // g] != t[i * m // g]:
        ans = -1
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import gcd 

N, X = map(int, input().split())
x = list(map(int, input().split()))
ans = abs(X - x[0])
for i in range(1, N):
    ans = gcd(ans, abs(x[i - 1] - x[i]))

print(ans)

Fixed submission:
from fractions import gcd 

N, X = map(int, input().split())
x = list(map(int, input().split()))
ans = abs(X - x[0])
for i in range(1, N):
    ans = gcd(ans, abs(x[i - 1] - x[i]))

print(ans)
Buggy python submission (verdict: Runtime Error):

s = input()
n = int(input())

i = 0
while s[i] == '1':
    i += 1

if n <= i:
    print(1)
else:
    print(s[i])

Fixed submission:

s = input()
n = int(input())

i = 0
while i != len(s) and s[i] == '1':
    i += 1

if n <= i:
    print(1)
else:
    print(s[i])
Buggy python submission (verdict: Runtime Error):
a = list(map(int, input().split()))

a.sort()
ans = 0:
for i in range(1, 3):
    ans += abs(a[i] - a[i - 1])

print(ans)

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

a.sort()
ans = 0
for i in range(1, 3):
    ans += abs(a[i] - a[i - 1])

print(ans)
Buggy python submission (verdict: Runtime Error):

d, n = map(int, input().split())

print(100 ** d * n　if n <= 99 else 100 ** d * (n + 1))

Fixed submission:

d, n = map(int, input().split())

print(100 ** d * n if n <= 99 else 100 ** d * (n + 1))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())

data = set()
for i in range(len(s)):
    for j in range(i, len(s)):
        data.add(s[i: j + 1])

data = sorted(data)
print(data[k - 1])

Fixed submission:
s = input()
k = int(input())

data = set()
for i in range(len(s)):
    for j in range(i, i + k):
        data.add(s[i: j + 1])
data = sorted(data)
print(data[k - 1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())

data = []
for i in range(len(s)):
    for j in range(i, len(s)):
        data.append(s[i: j + 1])

data = sorted(set(data))
print(data[k - 1])

Fixed submission:
s = input()
k = int(input())

data = set()
for i in range(len(s)):
    for j in range(i, i + k):
        data.add(s[i: j + 1])
data = sorted(data)
print(data[k - 1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cnt_a, cnt_b = sum(a), sum(b)
ans = "No"
i = 0
cnt = 0
while cnt < cnt_b - cnt_a:
    if a[i] < b[i]:
        cnt += int((b[i] - a[i]) / 2 + 0.5)
    else:
        cnt += a[i] - b[i]
    i += 1
    if i == n:
        ans = "Yes"

print(ans)


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

x, y = 0, 0
for i in range(n):
    dif = b[i] - a[i]
    if dif > 0:
        x += dif // 2
    else:
        y += -dif

print("Yes" if x >= y else "No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l, r = 0, n - 1
print(0)
data1 = input()
print(n - 1)
data2 = input()

def check(l, r, data1, data2):
    if ( (r - l) % 2 == 0 and data1 != data2) or ( (r - l) % 2 == 1 and data1 == data2):
        return True
    return False

while data1 != "Vacant" and data2 != "Vacant":
    m = (l + r) // 2
    print(m)
    s = input()
    if s == "Vacant":
        exit()
    if check(m, r, data1, s):
        l = m
        data1 = s
    elif check(l, m s, data1):
        r = m
        data2 = s
    
    


Fixed submission:
n = int(input())
l, r = 0, n - 1
print(0)
data = input()
while data != "Vacant":
    m = (l + r) // 2
    print(m)
    s = input()
    if s == "Vacant":
        exit()
    if ( m % 2 == 0 and data == s) or ( m % 2 == 1 and data != s):
        l = m + 1
    else:
        r = m - 1

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l, r = 0, n - 1

data = input()
while data != "Vacant":
    m = (l + r) // 2
    print(m)
    s = input()
    if s == "Vacant":
        exit()
    
    if ( (r - l) % 2 == 0 and data == s) or ( (r - l) % 2 == 1 and data != s):
        l = m + 1
    else:
        r = m - 1
    


Fixed submission:
n = int(input())
l, r = 0, n - 1
print(0)
data = input()
while data != "Vacant":
    m = (l + r) // 2
    print(m)
    s = input()
    if s == "Vacant":
        exit()
    if ( m % 2 == 0 and data == s) or ( m % 2 == 1 and data != s):
        l = m + 1
    else:
        r = m - 1

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l, r = 0, n - 1

data = input()
while data != "Vacant":
    m = (l + r) // 2
    print(m)
    s = input()
    if s == "Vacant":
        exit()
    
    if ( (r - l) % 2 == 0 and data == s) or ( (r - l) % 2 == 1 and data != s):
        l = m + 1
    else:
        r = m - 1
    


Fixed submission:
n = int(input())
l, r = 0, n - 1
print(0)
data = input()
while data != "Vacant":
    m = (l + r) // 2
    print(m)
    s = input()
    if s == "Vacant":
        exit()
    if ( m % 2 == 0 and data == s) or ( m % 2 == 1 and data != s):
        l = m + 1
    else:
        r = m - 1
Buggy python submission (verdict: Runtime Error):
from math import ceil
n, h = map(int, input().split())
data1, data2 = [], []
for i in range(n):
    a, b = map(int, input().split())
    data1.append([a, b])
    data2.append([a, b])

data1 = sorted(data1, key = lambda x: x[0], reverse = True)
data2 = sorted(data2, key = lambda x: x[1], reverse = True)
ans = 0
while data1[0][0] < data2[0][1]:
    h -= data2[0][1]
    ans += 1
    del data2[0]
ans += ceil(h / data1[0][0])
print(ans)

Fixed submission:
from math import ceil
n, h = map(int, input().split())
data1, data2 = [], []
for i in range(n):
    a, b = map(int, input().split())
    data1.append([a, b])
    data2.append([a, b])

data1 = sorted(data1, key = lambda x: x[0], reverse = True)
data2 = sorted(data2, key = lambda x: x[1], reverse = True)
ans = 0
while h > 0 and data1[0][0] < data2[0][1]:
    h -= data2[0][1]
    ans += 1
    del data2[0]
    if len(data2) == 0:
        break
ans += ceil(max(0, h) / data1[0][0])
print(ans)
Buggy python submission (verdict: Runtime Error):
q = int(input())
l, r = [0] * q, [0] * q
for i in range(q):
    l[i], r[i] = map(int, input().split())

mini = min(min(l), min(r))
maxi = max(max(l), max(r))
ans = [0] * (maxi + 1)
prime = [0] * (maxi + 1)
def judge_prime(n):
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    
    return True if n != 1 else False

for i in range((mini + 1) // 2, maxi + 1):
    prime[i] = judge_prime(i)

for i in range(mini, maxi + 1, 2):
    ans[i] = ans[i - 2] + 1 if prime[i] and prime[(i + 1) // 2] else ans[i - 2
for i in range(q):
    print(ans[r[i]] - ans[max(0, l[i] - 2)])


Fixed submission:
q = int(input())
l, r = [0] * q, [0] * q
for i in range(q):
    l[i], r[i] = map(int, input().split())

mini = min(min(l), min(r))
maxi = max(max(l), max(r))
ans = [0] * (maxi + 1)
prime = [0] * (maxi + 1)
def judge_prime(n):
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    
    return True if n != 1 else False

for i in range((mini + 1) // 2, maxi + 1):
    prime[i] = judge_prime(i)

for i in range(mini, maxi + 1, 2):
    ans[i] = ans[i - 2] + 1 if prime[i] and prime[(i + 1) // 2] else ans[i - 2]
for i in range(q):
    print(ans[r[i]] - ans[max(0, l[i] - 2)])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

def calc_luca(n):
    if n == 0:
        return 2
    elif n == 1:
        return 1
    else:
        return calc_luca(n - 1) + calc_luca(n - 2)

print(calc_luca(n))

Fixed submission:
n = int(input())

ans = [0] * (n + 1)
ans[0] = 2
ans[1] = 1
for i in range(2, n + 1):
    ans[i] = ans[i - 1] + ans[i - 2]

print(ans[n])