Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
Q = int(input())
query = [list(input().split()) for _ in range(Q)]
revflag = 0

for i in query:
    if i[0] == '1':
        revflag = 1 - revflag
    else:
        if (revflag == 0 and i[1] == '1') or (revflag == 1 and i[1] == '2'):
            S.insert(0, i[2])
        else:
            S.append(i[2])

if revflag == 0:
    print(''.join(S))
else:
    print(''.join(S[::-1]))

Fixed submission:
S = input()
Q = int(input())
query = [list(input().split()) for _ in range(Q)]
revflag = 0
before = ""
after = ""

for i in query:
    if i[0] == '1':
        revflag = 1 - revflag
    else:
        if (revflag == 0 and i[1] == '1') or (revflag == 1 and i[1] == '2'):
            before += i[2]
        else:
            after += i[2]

if revflag == 0:
    print(before[::-1]+S+after)
else:
    print(after[::-1]+S[::-1]+before)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
query = [list(input().split()) for _ in range(Q)]
revflag = 0

for i in query:
    if i[0] == '1':
        revflag = 1 - revflag
    else:
        if (revflag == 0 and i[1] == '1') or (revflag == 1 and i[1] == '2'):
            S = i[2] + S
        else:
            S = S + i[2]

if revflag == 0:
    print(S)
else:
    print(S[::-1])

Fixed submission:
S = input()
Q = int(input())
query = [list(input().split()) for _ in range(Q)]
revflag = 0
before = ""
after = ""

for i in query:
    if i[0] == '1':
        revflag = 1 - revflag
    else:
        if (revflag == 0 and i[1] == '1') or (revflag == 1 and i[1] == '2'):
            before += i[2]
        else:
            after += i[2]

if revflag == 0:
    print(before[::-1]+S+after)
else:
    print(after[::-1]+S[::-1]+before)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
cond = [list(map(int, input().split())) for _ in range(M)]
flag = True
ans = [-1]*N

if M == 0:
    if N == 1:
        print(0)
    else:
        print('1'+'0'*(N-1))
else:
    for i in cond:
    digit = i[0]-1
    if digit > N-1:
        flag = False
        break
    elif ans[digit] != -1 and ans[digit] != i[1]:
        flag = False
        break
    elif i == [1, 0] and N > 1:
        flag = False
        break
    else:
        ans[digit] = i[1]

    if flag:
        if ans[0] == -1:
            ans[0] = 1
        
        for i in range(1, N):
            if ans[i] == -1:
                ans[i] = 0
        
        print(''.join(map(str, ans)))
    else:
        print(-1)

Fixed submission:
N, M = map(int, input().split())
cond = [list(map(int, input().split())) for _ in range(M)]
flag = True
ans = [-1]*N

if M == 0:
    if N == 1:
        print(0)
    else:
        print('1'+'0'*(N-1))
else:
    for i in cond:
        digit = i[0]-1
        if digit > N-1:
            flag = False
            break
        elif ans[digit] != -1 and ans[digit] != i[1]:
            flag = False
            break
        elif i == [1, 0] and N > 1:
            flag = False
            break
        else:
            ans[digit] = i[1]

    if flag:
        if ans[0] == -1:
            ans[0] = 1
        
        for i in range(1, N):
            if ans[i] == -1:
                ans[i] = 0
        
        print(''.join(map(str, ans)))
    else:
        print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
p = list(map(int, input().split()))

for i in range(N):
    p[i] = (p[i]+1)/2

ans = 0
for i in range(N-K+1):
    tmp = sum(p[i:i+K])
    if tmp > ans:
        ans = tmp

print(ans)

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

for i in range(N):
    p[i] = (p[i]+1)/2

ans = sum(p[:K])
tmp = ans

for i in range(N-K):
    tmp += -p[i] + p[i+K]
    if tmp > ans:
        ans = tmp

print(ans)
Buggy python submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
print(A*B//math.gcd(A, B))

Fixed submission:
import fractions
A, B = map(int, input().split())
print(A*B//fractions.gcd(A, B))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
digit = [0]*60

for i in A:
    b = i
    tmp = 0
    while(b):
        digit[tmp] += b & 1
        tmp += 1
        b >>= 1

ans = 0
for i in range(60):
    ans = (ans + (digit[i]*(N-digit[i]) % mod) * pow(2, i, mod) % mod) % mod

print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
digit = [0]*60

for i in A:
    b = i
    tmp = 0
    while(b):
        digit[tmp] += b & 1
        tmp += 1
        b >>= 1

ans = 0
for i in range(60):
    ans = (ans + (digit[i]*(N-digit[i]) % mod) * pow(2, i, mod) % mod) % mod

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0

for i in range(N-2):
    for j in range(i+1, N-1):
        a = L[i]
        b = L[j]
        ok = j
        ng = N-1
        if b-a < L[ng] and L[ng] < a+b:
            ans += N-1-j
        else:
            while ng - ok > 1:
                mid = (ok+ng) // 2
                if b-a < L[mid] and L[mid] < a+b:
                    ok = mid
                else:
                    ng = mid
       
            ans += ok - j

print(ans)

Fixed submission:
N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0

for i in range(N-2):
    for j in range(i+1, N-1):
        a = L[i]
        b = L[j]
        ok = j
        ng = N-1
        if b-a < L[ng] and L[ng] < a+b:
            ans += N-1-j
        else:
            while ng - ok > 1:
                mid = (ok+ng) // 2
                if b-a < L[mid] and L[mid] < a+b:
                    ok = mid
                else:
                    ng = mid
       
            ans += ok - j

print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
if S == "Sunny":
    print("Cloudy")
elif S == "Cloudy"
    print("Rainy")
else:
    print("Sunny")

Fixed submission:
S = input()
if S == "Sunny":
    print("Cloudy")
elif S == "Cloudy":
    print("Rainy")
else:
    print("Sunny")
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    A = sorted(list(map(int, input().split())))

    for _ in range(M):
        ins = A.pop() // 2
        A.insert(bisect.bisect_left(A, ins), ins)

    print(sum(A))


if __name__ == '__main__':
    main()


Fixed submission:
import heapq

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

for _ in range(M):
    high = -heapq.heappop(A)
    heapq.heappush(A, -(high//2))

print(-sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect


def main():
    N, M = map(int, input().split())
    A = sorted(list(map(int, input().split())))

    for _ in range(M):
        ins = A.pop() // 2
        A.insert(bisect.bisect_left(A, ins), ins)

    print(sum(A))


if __name__ == '__main__':
    main()

Fixed submission:
import heapq

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

for _ in range(M):
    high = -heapq.heappop(A)
    heapq.heappush(A, -(high//2))

print(-sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

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

A_pop = A.pop
A_insert = A.insert
for _ in range(M):
    ins = A_pop() // 2
    A_insert(bisect.bisect_left(A, ins), ins) 

print(sum(A))

Fixed submission:
import heapq

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

for _ in range(M):
    high = -heapq.heappop(A)
    heapq.heappush(A, -(high//2))

print(-sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

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

for _ in range(M):
    ins = A.pop() // 2
    A.insert(bisect.bisect_left(A, ins), ins) 

print(sum(A))

Fixed submission:
import heapq

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

for _ in range(M):
    high = -heapq.heappop(A)
    heapq.heappush(A, -(high//2))

print(-sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

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

for _ in range(M):
    ins = A.pop() // 2
    A.insert(bisect.bisect_left(A, ins), ins) 

print(sum(A))

Fixed submission:
import heapq

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

for _ in range(M):
    high = -heapq.heappop(A)
    heapq.heappush(A, -(high//2))

print(-sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
from numpy.linalg import solve

N = int(input())
A = list(map(int, input().split()))
mat = [[0]*N for _ in range(N)]
A = [2*n for n in A]

for i in range(N):
    mat[i][i] = 1
    mat[i][(i+1)%N] = 1

ans = list(map(int, solve(mat, A)))
print(' '.join(map(str, ans)))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = [-1]*N
ans[0] = sum(A[::2])-sum(A[1::2])

for i in range(1, N):
    ans[i] = 2*A[i-1] - ans[i-1]

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

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

N = int(input())
A = np.array([int(_) for _ in input().split()], dtype=int)


A = 2*A
M = np.zeros((N, N), dtype=int)
for i in range(N):
    M[i, i] = 1
    if i < N-1:
        M[i, i+1] = 1
    else:
        M[i, 0] = 1

x = np.dot(np.linalg.inv(M), A)

ans = [0]*N
for i in range(N):
    ans[i] = str(int(x[i]))
    
print(' '.join(ans))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = [-1]*N
ans[0] = sum(A[::2])-sum(A[1::2])

for i in range(1, N):
    ans[i] = 2*A[i-1] - ans[i-1]

print(' '.join(map(str, ans)))
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
dp = [0] * (N+1)
mod = 10**9 + 7

for i in range(M):
    dp[a[i]] = -1

dp[0] = 1
if dp[1] != -1 and dp[2] != -1:
    dp[1] = 1
    dp[2] = dp[0] + dp[1]
elif dp[1] == -1 and dp[2] != -1:
    dp[2] = 1
elif dp[1] != -1 and dp[2] == -1:
    dp[1] = 1
else:
    print(0)
    exit()

for i in range(3, N+1):
    if dp[i] == -1:
        continue
    elif dp[i-1] == -1 and dp[i-2] != -1:
        dp[i] = dp[i-2]
    elif dp[i-1] != -1 and dp[i-2] == -1:
        dp[i] = dp[i-1]
    elif dp[i-1] != -1 and dp[i-2] != -1:
        dp[i] = dp[i-1] + dp[i-2]
    else:
        print(0)
        exit()

print(dp[N] % mod)

Fixed submission:
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
dp = [0] * (N+1)
mod = 10**9 + 7

for i in range(M):
    dp[a[i]] = -1

if N == 1:
    print(1)
elif N == 2:
    if dp[1] == -1:
        print(1)
    else:
        print(2)
else:
    dp[0] = 1
    if dp[1] != -1 and dp[2] != -1:
        dp[1] = 1
        dp[2] = dp[0] + dp[1]
    elif dp[1] == -1 and dp[2] != -1:
        dp[2] = 1
    elif dp[1] != -1 and dp[2] == -1:
        dp[1] = 1
    else:
        print(0)
        exit()
    
    
    for i in range(3, N+1):
        if dp[i] == -1:
            continue
        elif dp[i-1] == -1 and dp[i-2] != -1:
            dp[i] = dp[i-2]
        elif dp[i-1] != -1 and dp[i-2] == -1:
            dp[i] = dp[i-1]
        elif dp[i-1] != -1 and dp[i-2] != -1:
            dp[i] = dp[i-1] + dp[i-2]
        else:
            print(0)
            exit()
    
    print(dp[N] % mod)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


N, M, K = map(int, input().split())
mod = 10**9 + 7

x = N*N*(M*M*(M+1)//2 - M*(M+1)*(2*M+1)//6)
y = M*M*(N*N*(N+1)//2 - N*(N+1)*(2*N+1)//6)
ans = cmb(N*M-2, K-2) * (x + y) % mod
print(ans)

Fixed submission:
from math import factorial


def comb(n, k, mod):
  if n < 0 or k < 0 or n < k:
      return 0
  if n == 0 or k == 0:
      return 1
  
  a=factorial(n) % mod
  b=factorial(k) % mod
  c=factorial(n-k) % mod
  return (a*power_func(b, mod-2, mod)*power_func(c, mod-2, mod)) % mod


def power_func(a,b,mod):
  if b == 0:
      return 1
  if b % 2 == 0:
    d = power_func(a, b//2, mod)
    return d*d % mod
  if b % 2 == 1:
    return (a*power_func(a, b-1, mod)) % mod


N, M, K = map(int, input().split())
mod = 10**9 + 7


x = N*N*(M*M*(M+1)//2 - M*(M+1)*(2*M+1)//6)
y = M*M*(N*N*(N+1)//2 - N*(N+1)*(2*N+1)//6)
ans = comb(N*M-2, K-2, mod) * (x + y) % mod
print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input()

ans = S[:K-1] + S[K-1].lower() + S[K:]
print(ans3 1) 

Fixed submission:
N, K = map(int, input().split())
S = input()
 
ans = S[:K-1] + S[K-1].lower() + S[K:]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())
number = [R, G, B]
number = sorted(number)
M = N // number[2]
ans = 0

for i in range(0, M+1):
    value1 = i * number[2]
    L = (N-value1) // number[1]
    for j in range(0, L+1):
        value2 = j * number[1]
        if N-value1-value2 >= 0 and (N-value1-value2) % number[0] == 0:
            ans += 1
            continue

print(ans)

Fixed submission:
R, G, B, N = map(int, input().split())
number = [R, G, B]
number = sorted(number)
M = N // number[2]
ans = 0

if number[2] == 1:
    print((N+2)*(N+1)//2)
else:
    for i in range(0, M+1):
        value1 = i * number[2]
        L = (N-value1) // number[1]
        for j in range(0, L+1):
            value2 = j * number[1]
            if N-value1-value2 >= 0 and (N-value1-value2) % number[0] == 0:
                ans += 1
                continue
    
    print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline 
N, K = map(int, input().split())
S = list(map(int, input()))

cnt = 0
now = 1
Nums = []

for i in range(N):
    if S[i] == now:
        cnt += 1
    else:
        Nums.append(cnt)
        now = 1 - now
        cnt = 1

if cnt != 0:
    Nums.append(cnt)
if len(Nums) % 2 == 0:
    Nums.append(0)

add = 2*K+1
ans = 0
left = right = 0
tmp = 0    # [left, right)

for i in range(0, len(Nums), 2):
    Nextleft = i
    Nextright = min(i+add, len(Nums))
    
    while Nextleft > left:
        tmp -= Nums[left]
        left += 1
    
    while Nextright > right:
        tmp += Nums[right]
        right += 1
    
    ans = max(tmp, ans)

print(ans)

Fixed submission:
N, K = map(int, input().split())
S = list(input())
left = 0
right = 0
onecnt = 0
zerocnt = 0
zeroflag = False
leftflag = False
ans = 0

while right < N:
    if S[right] == '0' and not zeroflag:
        zerocnt += 1
        zeroflag = True
    elif S[right] == '1' and zeroflag:
        zeroflag = False
        
    if zerocnt > K and zeroflag:
        tmp = right - left
        if tmp > ans:
            ans = tmp
        while True:
            if S[left] == '0' and not leftflag:
                leftflag = True
            elif S[left] == '1' and leftflag:
                leftflag = False
                break
            left += 1
        zerocnt -= 1
    right += 1

if right - left > ans:
    ans = right - left

print(ans)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
tmp = 9
for i in [A, B, C, D, E]:
    if i % 10 == 0:
        continue
    else:
        if i % 10 < tmp:
            tmp = i % 10
            last = i

ans = 0
for i in [A, B, C, D, E]:
    if i % 10 == 0:
        ans += i
    else:
        ans += i + (10-i%10)

print(ans-(10-last%10))

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
tmp = 9
last = 0
for i in [A, B, C, D, E]:
    if i % 10 == 0:
        continue
    else:
        if i % 10 <= tmp:
            tmp = i % 10
            last = i

ans = 0
for i in [A, B, C, D, E]:
    if i % 10 == 0:
        ans += i
    else:
        ans += i + (10-i%10)

print(ans-(10-last%10) if last != 0 else ans)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product
import sys
input = sys.stdin.readline

X, Y, Z, K = map(int, input().split())
A = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]
C = [int(_) for _ in input().split()]
A = sorted(A)[::-1]
B = sorted(B)[::-1]
C = sorted(C)[::-1]

cnt = 0
Ax = 0
Bx = 0
Cx = 0
while cnt <= K:
    if Ax < X-1:
        a = A[Ax]-A[Ax+1]
    else:
        a = float('inf')
    if Bx < Y-1:
        b = B[Bx]-B[Bx+1]
    else:
        b = float('inf')
    if Cx < Z-1:
        c = C[Cx]-C[Cx+1]
    else:
        c = float('inf')
    if a <= b and a <= c:
        Ax += 1
    elif b <= a and b <= c:
        Bx += 1
    else:
        Cx += 1
    cnt += 1

List = []
for i, j, k in product(A[:Ax+1], B[:Bx+1], C[:Cx+1]):
    List.append(i+j+k)

List = sorted(List)[::-1]

for i in range(K):
    print(List[i])

Fixed submission:
X, Y, Z, K = map(int, input().split())
A = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]
C = [int(_) for _ in input().split()]
A = sorted(A)[::-1]
B = sorted(B)[::-1]
C = sorted(C)[::-1]

List = []

for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1) > K:
                break
            else:
                List.append(A[i]+B[j]+C[k])

List = sorted(List)[-1:-K-1:-1]
for i in range(K):
    print(List[i])
Buggy python submission (verdict: Runtime Error):
b = int(input())
if b == "A":
    print("T")
elif b == "T":
    print("A")
elif b == "G":
    print("C")
else:
    print("G")

Fixed submission:
b = input()
if b == "A":
    print("T")
elif b == "T":
    print("A")
elif b == "G":
    print("C")
else:
    print("G")
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
Prob = [[int(_) for _ in input().split()] for _ in range(Q)]

for i, j in Prob:
    print(S[i-1:j].count("AC"))

Fixed submission:
N, Q = map(int, input().split())
S = input()
Prob = [[int(_) for _ in input().split()] for _ in range(Q)]
numlist = [0, ]
cnt = 0

for i in range(1, N):
    if S[i-1: i+1] == "AC":
        cnt += 1
    numlist.append(cnt)

for j, k in Prob:
    print(numlist[k-1]-numlist[j-1])
Buggy python submission (verdict: Runtime Error):
import math

N = int(input())
A = [int(_) for _ in input().split()]
GCD = math.gcd(A[0], A[1])

for i in range(1, N-1):
    GCD = math.gcd(GCD, A[i+1])

print(GCD)

Fixed submission:
import sys
input = sys.stdin.readline


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


N = int(input())
A = [int(_) for _ in input().split()]
GCD = gcd(A[0], A[1])

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

print(GCD)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = [int(_) for _ in input().split()]
ans = 0
tmp = 0

for i in range(40, -1, -1):
    onenum = 0
    for j in A:
        if 2**i & j == 2**i:
            onenum += 1
    
    zeronum = N - onenum
    
    if tmp + 2**i > K:
        ans += onenum * 2**i
    else:
        if onenum > zeronum:
            ans += onenum * 2**i
        else:
            ans += zeronum * 2**i
            tmp += 2**i

print(ans)

Fixed submission:
import numpy as np

N, K = map(int, input().split())
MAX_DIGIT = 50
A = [int(_) for _ in input().split()]
dp = np.full((MAX_DIGIT+1, 2), -1, dtype=np.int64)
dp[0][0] = 0

for d in range(MAX_DIGIT):
    mask = 1 << (MAX_DIGIT - 1 - d)
    onenum = 0
    for i in A:
        if (i & mask) == mask:
            onenum += 1
    
    cost0 = mask * onenum
    cost1 = mask * (N - onenum)
    
    if dp[d][1] != -1:
        dp[d+1][1] = max(dp[d+1][1], dp[d][1] + max(cost0, cost1))
    
    if dp[d][0] != -1:
        if K & mask:
            dp[d+1][1] = max(dp[d+1][1], dp[d][0] + cost0)
    
    if dp[d][0] != -1:
        if K & mask:
            dp[d+1][0] = max(dp[d+1][0], dp[d][0] + cost1)
        else:
            dp[d+1][0] = max(dp[d+1][0], dp[d][0] + cost0)

print(max(dp[MAX_DIGIT][0], dp[MAX_DIGIT][1]))
Buggy python submission (verdict: Runtime Error):
N = [int(_) for _ in input().split()]
S = "".join(sorted(N))
print("YES" if S == 1479 else "NO")

Fixed submission:
N = [str(_) for _ in input().split()]
S = "".join(sorted(N))
print("YES" if S == '1479' else "NO")
Buggy python submission (verdict: Runtime Error):
N = int(input())
h = [int(_) for _ in input().split()] + [0]*N
dp = [float('inf')]*(N*N)
dp[0] = 0
dp[1] = abs(h[0]-h[1])

for i in range(N):
    dp[i+1] = min(dp[i+1], dp[i]+abs(h[i]-h[i+1]))
    dp[i+2] = min(dp[i+2], dp[i]+abs(h[i]-h[i+2]))

print(dp[N-1])

Fixed submission:
N = int(input())
h = list(map(int, input().split()))
dp = [(10 ** 4) * N] * N
dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2, N):
    dp[i] = min(dp[i-2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i] - h[i-1]))

print(dp[N-1])
Buggy python submission (verdict: Runtime Error):
N, H, W = map(int, input().split())
AB = [[int(_) for _ in input().split()] for _ in range(N)]
ans = 0

for i in AB:
    if i[0] >= H and AB[1] >= W:
        ans += 1

print(ans)

Fixed submission:
N, H, W = map(int, input().split())
AB = [[int(_) for _ in input().split()] for _ in range(N)]
ans = 0

for i in AB:
    if i[0] >= H and i[1] >= W:
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
import bisect
from math import factorial as fact
import sys
input = sys.stdin.readline

N = int(input())
prime = []
p_flag = [False] * (101)
p_flag[0] = p_flag[1] = True

for i in range(2, 101):
    if not p_flag[i]:
        prime.append(i)
        for j in range(2*i, 101, i):
            p_flag[j] = True

M = len(prime)
factor = [0]*M

for i in range(2, N+1):
    for j in range(M):
        tmp = prime[j]
        while i % tmp == 0:
            factor[j] += 1
            tmp *= tmp

factor = factor[::-1]
point74 = M - bisect.bisect_left(factor, 74)
point24 = M - bisect.bisect_left(factor, 24)
point14 = M - bisect.bisect_left(factor, 14)
point4 = M - bisect.bisect_left(factor, 4)
point2 = M - bisect.bisect_left(factor, 2)

ans = max(fact(point4)//(fact(point4-2)*fact(2)) * (point2-2), 0)
if point14 > 0:
    ans += point14 * (point4-1)
if point24 > 0:
    ans += point24 * (point2-1)
if point74 > 0:
    ans += point74

print(ans)

Fixed submission:
import bisect
from math import factorial as fact
import sys
input = sys.stdin.readline
 
N = int(input())
prime = []
p_flag = [False] * (101)
p_flag[0] = p_flag[1] = True
 
for i in range(2, 101):
    if not p_flag[i]:
        prime.append(i)
        for j in range(2*i, 101, i):
            p_flag[j] = True
 
M = len(prime)
factor = [0]*M
 
for i in range(2, N+1):
    for j in range(M):
        tmp = prime[j]
        if tmp > i:
            break
        while i % tmp == 0:
            factor[j] += 1
            tmp *= prime[j]
 
factor = factor[::-1]
point74 = M - bisect.bisect_left(factor, 74)
point24 = M - bisect.bisect_left(factor, 24)
point14 = M - bisect.bisect_left(factor, 14)
point4 = M - bisect.bisect_left(factor, 4)
point2 = M - bisect.bisect_left(factor, 2)
 
if N < 10:
    ans = 0
else:
    ans = fact(point4)//(fact(point4-2)*fact(2)) * (point2-2)
    if point14 > 0:
        ans += point14 * (point4-1)
    if point24 > 0:
        ans += point24 * (point2-1)
    if point74 > 0:
        ans += point74
 
print(ans)