Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
st_con = [[i for i in map(int,input().split())] for j in range(N)]
rieki = [[i for i in map(int,input().split())] for j in range(N)]

ans = -10**9
for i in range(1,2**10):
    a = 0
    count = [0]*10
    for j in range(N):
        for h in range(10):
            if (i>>h) & st_con[j][h] and (i>>h) == 1:
                count[j] += 1
        a += rieki[j][count[j]]
    
    if ans < a : ans = a 
print("{}".format(ans))
                

Fixed submission:
N = int(input())
st_con = [[i for i in map(int,input().split())] for j in range(N)]
rieki = [[i for i in map(int,input().split())] for j in range(N)]

ans = -10**9
for i in range(1,2**10):
    a = 0
    for j in range(N):
        count = 0 
        for h in range(10):
            if (i>>h) & st_con[j][h] and (i>>h) & 1:
                count += 1
        a += rieki[j][count]
    
    if ans < a : ans = a 
print("{}".format(ans))

Buggy python submission (verdict: Runtime Error):
N = int(input())
st_con = [[i for i in map(int,input().split())] for j in range(N)]
rieki = [[i for i in map(int,input().split())] for j in range(N)]

ans = []
for i in range(1,2**10):
    a = 0
    count = [0]*10
    for j in range(N):
        for h in range(10):
            if (i>>h) & st_con[j][h] and (i>>h)&1:
                count[j] += 1
        a += rieki[j][count[j]]
    ans.append(a)
    
print("{}".format(max(ans)))

Fixed submission:
N = int(input())
st_con = [[i for i in map(int,input().split())] for j in range(N)]
rieki = [[i for i in map(int,input().split())] for j in range(N)]

ans = -10**9
for i in range(1,2**10):
    a = 0
    for j in range(N):
        count = 0 
        for h in range(10):
            if (i>>h) & st_con[j][h] and (i>>h) & 1:
                count += 1
        a += rieki[j][count]
    
    if ans < a : ans = a 
print("{}".format(ans))

Buggy python submission (verdict: Runtime Error):
N = int(input())
st_con = [[i for i in map(int,input().split())] for j in range(N)]
rieki = [[i for i in map(int,input().split())] for j in range(N)]

ans = []
for i in range(1,2**10):
    a = 0
    count = [0]*10
    for j in range(N):
        for h in range(10):
            if (i>>h) & st_con[j][h] and (i>>h)&1:
                count[j] += 1
        a += rieki[j][count[j]]
    ans.append(a)
    
print("{}".format(max(ans)))

Fixed submission:
N = int(input())
st_con = [[i for i in map(int,input().split())] for j in range(N)]
rieki = [[i for i in map(int,input().split())] for j in range(N)]

ans = -10**9
for i in range(1,2**10):
    a = 0
    for j in range(N):
        count = 0 
        for h in range(10):
            if (i>>h) & st_con[j][h] and (i>>h) & 1:
                count += 1
        a += rieki[j][count]
    
    if ans < a : ans = a 
print("{}".format(ans))
Buggy python submission (verdict: Runtime Error):
N=int(input())
para = [int(input()) for i in range(N)]
para.sort(reverse=True)

"""
全ての最小公倍数を求めたら良い
lcm(a,b,c...) = lcm(a,lcm(b,c.......))
gcd(a,b,c...) = gcd(a,gcd(b,c,d....))
"""

"""
最大公倍数の実装
ユークリッドの互除法
a = b*c + d
c = d*e + f
"""
def gcd(a,b):
    if b == 0 : 
        return a  
    return gcd(b,a%b)

def lcm(a,b) :
    return a*b//gcd(a,b)

for i in range(N-1,0,-1):
    if i == N-1:
        p = lcm(para[i-1],para[i])
    else :
        a = max(para[i],p)
        b = min(para[i],p)
        p = lcm(a,b)
print(p)

Fixed submission:
N=int(input())
para = [int(input()) for i in range(N)]
para.sort(reverse=True)


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

def lcm(a,b) :
    return a*b//gcd(a,b)

for i in range(N-1,-1,-1):
    if i == N-1:
        p = lcm(para[i-1],para[i])
    else :
        a = max(para[i],p)
        b = min(para[i],p)
        p = lcm(a,b)
print(p)

Buggy python submission (verdict: Runtime Error):
N=int(input())
para = [int(input()) for i in range(N)]
para.sort(reverse=True)
import sys
sys.setrecursionlimit(100000)

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

def lcm(a,b) :
    return a*b//gcd(a,b)

for i in range(N-1,0,-1):
    if i == N-1:
        p = lcm(para[i-1],para[i])
    else :
        p = lcm(para[i],p)
print(p)

Fixed submission:
N=int(input())
para = [int(input()) for i in range(N)]
para.sort(reverse=True)


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

def lcm(a,b) :
    return a*b//gcd(a,b)

for i in range(N-1,-1,-1):
    if i == N-1:
        p = lcm(para[i-1],para[i])
    else :
        a = max(para[i],p)
        b = min(para[i],p)
        p = lcm(a,b)
print(p)

Buggy python submission (verdict: Runtime Error):
N=int(input())
para = [int(input()) for i in range(N)]
para.sort(reverse=True)

"""
全ての最小公倍数を求めたら良い
lcm(a,b,c...) = lcm(a,lcm(b,c.......))
gcd(a,b,c...) = gcd(a,gcd(b,c,d....))
"""

"""
最大公倍数の実装
ユークリッドの互除法
a = b*c + d
c = d*e + f
"""
def gcd(a,b):
    if b == 0 : 
        return a  
    return gcd(b,a%b)

def lcm(a,b) :
    return a*b//gcd(a,b)

for i in range(N-1,0,-1):
    if i == N-1:
        p = lcm(para[i-1],para[i])
    else :
        p = lcm(para[i],p)
print(p)

Fixed submission:
N=int(input())
para = [int(input()) for i in range(N)]
para.sort(reverse=True)


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

def lcm(a,b) :
    return a*b//gcd(a,b)

for i in range(N-1,-1,-1):
    if i == N-1:
        p = lcm(para[i-1],para[i])
    else :
        a = max(para[i],p)
        b = min(para[i],p)
        p = lcm(a,b)
print(p)
Buggy python submission (verdict: Runtime Error):
N = int(input())

class Edge:
    def __init__(self,to,cost):
        self.to = to
        self.cost = cost

graph = [[] for i in range(N)]
for i in range(N-1):
    a,b,c = map(int,input().split())
    graph[a-1].append(Edge(b-1,c))
    graph[b-1].append(Edge(a-1,c))
dp = [0 for i in range(N)]

def dfs(s,pare):
    for i in graph[s]:
        if i.to != pare :
            dp[i.to] = dp[s] + i.cost
            dfs(i.to,s)


Q,K = map(int,input().split())
dfs(K-1,-1)
print(dp)
for i in range(Q):
    x,y = map(int,input().split())
    print("{}".format(dp[x-1]+dp[y-1]))

Fixed submission:
import sys
sys.setrecursionlimit(10**9)
N = int(input())

class Edge:
    def __init__(self,to,cost):
        self.to = to
        self.cost = cost
#隣接グラフ
graph = [[] for i in range(N)]
for i in range(N-1):
    a,b,c = map(int,input().split())
    graph[a-1].append(Edge(b-1,c))
    graph[b-1].append(Edge(a-1,c))
dp = [0 for i in range(N)]

def dfs(s,pare):
    for i in graph[s]:
        if i.to != pare :
            dp[i.to] = dp[s] + i.cost
            dfs(i.to,s)
        else:
            continue 


Q,K = map(int,input().split())
dfs(K-1,-1)
for i in range(Q):
    x,y = map(int,input().split())
    print("{}".format(dp[x-1]+dp[y-1]))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 1
for i in range(n):
    ans = ans * (i+1)
print("{}".format(ans % (10**9+7)))

Fixed submission:
n = int(input())

ans = 1
for i in range(n):
    ans = ans * (i+1) % (10**9+7)
print("{}".format(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)
    B.append(b)
k = 0 
for i in range(N-1,-1,-1):
    if A[i] % B[i] == 0 :
        continue
    else :
        c = (B[i] - A[i] % B[i])
        k += c
        for j in range(i):
            A[j] += c

print(k)

Fixed submission:
N = int(input())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
k = 0 
for i in range(N-1,-1,-1):
    A[i] += k
    if A[i] % B[i] == 0 :
        pass
    else :
        c = (B[i] - A[i] % B[i])
        k += c

print(k)

Buggy python submission (verdict: Runtime Error):
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
k = 0 
for i in range(N-1,-1,-1):
    if A[i] % B[i] == 0 :
        continue
    else :
        c = (B[i] - A[i] % B[i])
        k += c
        for j in range(i):
            A[j] += c

print(k)

Fixed submission:
N = int(input())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
k = 0 
for i in range(N-1,-1,-1):
    A[i] += k
    if A[i] % B[i] == 0 :
        pass
    else :
        c = (B[i] - A[i] % B[i])
        k += c

print(k)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())

def ans(cnt,a,b,c=0):
    if cnt == a :
        return c
    else :
        if cnt == 0: 
            c += b
            cnt += 1
            return ans(cnt,a,b,c) 
        else: 
            cnt += 1
            c = c*(b-1)
            return ans(cnt,a,b,c)

a = ans(cnt = 0,a = n,b = k,c=0)
print(a)



Fixed submission:
n,k = map(int,input().split())
ans = k*(k-1)**(n-1)
print(ans)

Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())

def ans(cnt,a,b,c=0):
    if cnt == a :
        return c
    else :
        if cnt == 0: 
            c += b
            cnt += 1
            return ans(cnt,a,b,c) 
        else: 
            cnt += 1
            c = c*(b-1)
            return ans(cnt,a,b,c)

a = ans(cnt = 0,a = n,b = k,c=0)
print(a)

Fixed submission:
n,k = map(int,input().split())
ans = k*(k-1)**(n-1)
print(ans)
Buggy python submission (verdict: Runtime Error):
s = list(input())
size = len(s)
ans = []
for i in range(size) :
    if s[i] ==  "B":
        ans.pop(-1)
    else: ans.append(s[i])

b = "".join(ans)
print(b)

Fixed submission:
s = list(input())
size = len(s)
ans = []
for i in range(size) :
    if len(ans) >= 1 :
        if s[i] ==  "B" :
            ans.pop(-1)
        else : ans.append(s[i])

    elif s[i] != "B" : ans.append(s[i])

b = "".join(ans)
print(b)

Buggy python submission (verdict: Runtime Error):
s = list(input())
size = len(s)
print(s)
ans = []
for i in range(size) :
    if s[i] ==  "B":
        ans.pop(-1)
    else: ans.append(s[i])

b = "".join(ans)
print(b)

Fixed submission:
s = list(input())
size = len(s)
ans = []
for i in range(size) :
    if len(ans) >= 1 :
        if s[i] ==  "B" :
            ans.pop(-1)
        else : ans.append(s[i])

    elif s[i] != "B" : ans.append(s[i])

b = "".join(ans)
print(b)
Buggy python submission (verdict: Runtime Error):
#D
n = int(input())
A = list(map(int, input().split()))

sum_eve = sum(A[0::2])
sum_odd = sum(A[1::2])

x = [0] * n

x[0] = sum_eve - sum_odd

for num in range(1, n):
    x[num] = 2 * A[num-1] - x[num-1]
    
ans = " ".join(map(str,x))

pritn(ans)

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

sum_eve = sum(A[0::2])
sum_odd = sum(A[1::2])

x = [0] * n

x[0] = sum_eve - sum_odd

for num in range(1, n):
    x[num] = 2 * A[num-1] - x[num-1]
    
ans = " ".join(map(str,x))
print(ans)
Buggy python submission (verdict: Runtime Error):
w, h, x, y = list(map(int, input().split()))
area_ans = w * h / 2
cog_x = w/2 
cog_y = h/2
if cog_x == x and cog_y == y: 
    cog_ans = 1
    print(str(area_ans) +" "+ str(cog_ans))
elif:
    cog_ans = 0
    print(str(area_ans) +" "+ str(cog_ans))

Fixed submission:
w, h, x, y = list(map(int, input().split()))
area_ans = w * h / 2
cog_x = w/2 
cog_y = h/2
if cog_x == x and cog_y == y: 
    cog_ans = 1
    print(str(area_ans) +" "+ str(cog_ans))
else:
    cog_ans = 0
    print(str(area_ans) +" "+ str(cog_ans))
Buggy python submission (verdict: Runtime Error):
dice_num = int(input_num[0])
border_socre = int(input_num[1])
ans_p = 0

for score in range(1,dice_num + 1):
    coin_counter = 0
    
    while score <= border_socre:
        score = score * 2
        coin_counter += 1
    ans_p += (1 / dice_num ) * (1/2 ) ** coin_counter
print(ans_p)

Fixed submission:
input_num = input().split()
dice_num = int(input_num[0])
border_socre = int(input_num[1])
ans_p = 0

for score in range(1,dice_num + 1):
    coin_counter = 0
    while score < border_socre:
        score = score * 2
        coin_counter += 1
    ans_p += (1 / dice_num ) * ((1/2 ) ** coin_counter)
    
print(round(ans_p, 12))
Buggy python submission (verdict: Time Limit Exceeded):
r, g, b, n = map(int, input().split())
ans = 0
nr = n // r
ng = n // g
for i in range(nr + 1):
    for j in range(ng + 1):
        tmp = n - i * r - j * g
        if tmp % b == 0 and tmp >= 0:
            ans += 1
print(ans)


Fixed submission:
r, g, b, n = map(int, input().split())
ans = 0
for i in range(n + 1):
    for j in range(n + 1):
        if i * r + j * g == n:
            ans += 1
        elif (n - (i * r + j * g)) >= 0 and (n - (i * r + j * g)) % b == 0:
            ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
r, g, b, n = map(int, input().split())
cnt = 0
nr = n // r
ng = n // g
for i in range(nr + 1):
    for j in range(ng + 1):
        tmp = n - i * r - j * g
        if tmp >= 0 and tmp % b == 0:
            cnt += 1
print(cnt)

Fixed submission:
r, g, b, n = map(int, input().split())
ans = 0
for i in range(n + 1):
    for j in range(n + 1):
        if i * r + j * g == n:
            ans += 1
        elif (n - (i * r + j * g)) >= 0 and (n - (i * r + j * g)) % b == 0:
            ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
r, g, b, n = map(int, input().split())
ans = 0
nr = n // r
ng = n // g
for i in range(nr + 1):
    for j in range(ng + 1):
      	tmp = n - i * r - j * g 
        if tmp >= 0 and tmp % b == 0:
            ans += 1
print(ans)


Fixed submission:
r, g, b, n = map(int, input().split())
ans = 0
for i in range(n + 1):
    for j in range(n + 1):
        if i * r + j * g == n:
            ans += 1
        elif (n - (i * r + j * g)) >= 0 and (n - (i * r + j * g)) % 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 + 1):
    for j in range(n + 1):
        if i * r + j * g == n:
            ans += 1
        elif (n - (i * r + j * g)) >= 0 and (n - (i * r + j * g)) % b == 0:
            ans += 1
print(ans)


Fixed submission:
r, g, b, n = map(int, input().split())
ans = 0
for i in range(n + 1):
    for j in range(n + 1):
        if i * r + j * g == n:
            ans += 1
        elif (n - (i * r + j * g)) >= 0 and (n - (i * r + j * g)) % 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 + 1):
    for j in range(n + 1):
        if i * r + j * g == n:
            ans += 1
        elif (n - (i * r + j * g)) >= 0 and (n - (i * r + j * g)) % b == 0:
            ans += 1
print(ans)

Fixed submission:
r, g, b, n = map(int, input().split())
ans = 0
for i in range(n + 1):
    for j in range(n + 1):
        if i * r + j * g == n:
            ans += 1
        elif (n - (i * r + j * g)) >= 0 and (n - (i * r + j * g)) % b == 0:
            ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
cnt = 0
res = []
for a in s:
    if a in ["A", "G", "C", "T"]:
        cnt += 1
    else:
        res.append(cnt)
        cnt = 0
print(max(res))

Fixed submission:
s = input()
cnt = 0
r = []
r.append(0)
for ss in s:
    if ss in ["A", "C", "T", "G"]:
        cnt += 1
    else:
        r.append(cnt)
        cnt = 0
    r.append(cnt)
print(max(r))
Buggy python submission (verdict: Runtime Error):
import sys

N = int(input())
C = [int(sys.stdin.readline()) for _ in range(N)]
MOD = 10**9 + 7
A = []
for c in C:
    if A and A[-1] == c:
        continue
    A.append(c)
NA = len(A)
last = [-1] * NA
B = [-1] * NA
for i, a in enumerate(A):
    B[i] = last[a]
    last[a] = i

dp = [0] * NA
dp[0] = 1
for i in range(1, NA):
    prev = 0 if B[i] < 0 else dp[B[i]]
    dp[i] = (dp[i - 1] + prev) % MOD
print(dp[-1])

Fixed submission:
import sys

N = int(input())
C = [int(sys.stdin.readline()) for _ in range(N)]
MOD = 10**9 + 7
A = []
for c in C:
    if A and A[-1] == c:
        continue
    A.append(c)
NA = len(A)
last = [-1] * 200001
B = [-1] * 200001
for i, a in enumerate(A):
    B[i] = last[a]
    last[a] = i

dp = [0] * NA
dp[0] = 1
for i in range(1, NA):
    prev = 0 if B[i] < 0 else dp[B[i]]
    dp[i] = (dp[i - 1] + prev) % MOD
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
import bisect
import sys
A, B, Q = map(int, input().split())
INF = 10 ** 13
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
xs = [int(sys.stdin.readline()) for i in range(Q)]
for x in range(xs):
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)

Fixed submission:
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)

Fixed submission:
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = set(input().split()[1:])
for i in range(n - 1):
    a &= set(reads()[1:])
print(len(a))

Fixed submission:
def read():
    return int(input())

def reads():
    return list(map(int, input().split()))

n,m = reads()
a = []
r = []
for i in range(n):
    a.append(reads())
for i in range(n):
    for j in range(1,a[i][0]+1):
        r.append(a[i][j])
ans = 0
for i in set(r):
    if r.count(i) == n:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
def read():
    return int(input())

def reads():
    return list(map(int, input().split()))

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

n = read()
a = reads()
print(gcd(a))

Fixed submission:
def read():
    return int(input())

def reads():
    return list(map(int, input().split()))

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

n = read()
a = reads()
ans = a[0]
for i in range(n):
    ans = gcd(ans,a[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
n,m = map(int,input().split())
x = np.array(list(map(int, input().split())))
if n>= m:
    print(0)
    exit()
x.sort()
xd = sorted(np.diff(x))
print(sum(xd[:m-n]))

Fixed submission:
import numpy as np
n,m = map(int,input().split())
x = np.array(list(map(int, input().split())))
if n>= m:
    print(0)
    exit()
x.sort()
xd = sorted(np.diff(x))
print(sum(xd[:m-n]))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n,m = map(int,input().split())
x = np.array(list(map(int, input().split())))
if n>= m:
    print(0)
    exit()
x.sort()
xd = np.diff(x)
xd2=xd.tolist()
for i in range(n-1):
    xd2.remove(max(xd2))
print(sum(xd2))

Fixed submission:
import numpy as np
n,m = map(int,input().split())
x = np.array(list(map(int, input().split())))
if n>= m:
    print(0)
    exit()
x.sort()
xd = sorted(np.diff(x))
print(sum(xd[:m-n]))

Buggy python submission (verdict: Runtime Error):
import numpy as np
n,m = map(int,input().split())
x = np.array(list(map(int, input().split())))
if n>= m:
    print(0)
    exit()
x.sort()
xd = np.diff(x)
xd2=xd.tolist()
for i in range(n-1):
    xd2.remove(max(xd2))
print(sum(xd2))


Fixed submission:
import numpy as np
n,m = map(int,input().split())
x = np.array(list(map(int, input().split())))
if n>= m:
    print(0)
    exit()
x.sort()
xd = sorted(np.diff(x))
print(sum(xd[:m-n]))
Buggy python submission (verdict: Runtime Error):
n = int(input())
AB = [list(map(int, input().split())) for _ in range(n)]
AB.sort(reverse = True, key = lambda x:x[0]+x[1])
ans = sum(AB[0::2][0]) - sum(AB[1::2][1])
print(ans)

Fixed submission:
n = int(input())
AB = [list(map(int, input().split())) for _ in range(n)]
AB.sort(reverse = True,key = lambda x:x[0]+x[1])
ans = 0
for i in range(n):
    if i % 2 == 0:
        ans += AB[i][0]
    else:
        ans -= AB[i][1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = (int(i) for i in input().split())
h = list(int(i) for i in input().split())
dp = [0]
for i in range(1,n):
    s = float("inf")
    for j in range(1,min(k,i)+1):
        s = min(s,dp[i-j]+abs(h[i]-h[i-j]))
    dp.append(s)
print(dp[-1])

Fixed submission:
n,k = (int(i) for i in input().split())
h = list(int(i) for i in input().split())
dp = [0]
for i in range(1,n):
    s = float("inf")
    for j in range(1,min(k,i)+1):
        s = min(s,dp[i-j]+abs(h[i]-h[i-j]))
    dp.append(s)
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
dp = [0]*(W+1)
for i in range(N):
    w, v = map(int, input().split())
    for j in range(W, w-1, -1):
        dp[j] = max(dp[j], dp[j-w] + v)
print(max(dp))

Fixed submission:
N, W = map(int, input().split())
dp = [0]*(W+1)
for i in range(N):
    w, v = map(int, input().split())
    for j in range(W, w-1, -1):
        dp[j] = max(dp[j], dp[j-w] + v)
print(max(dp))

Buggy python submission (verdict: Runtime Error):
N, W = map(int, input().split())
dp = [0]*(W+1)
for i in range(n):
    w, v = map(int, input().split())
    for j in range(W, w-1, -1):
        dp[j] = max(dp[j], dp[j-w] + v)
print(max(dp))

Fixed submission:
N, W = map(int, input().split())
dp = [0]*(W+1)
for i in range(N):
    w, v = map(int, input().split())
    for j in range(W, w-1, -1):
        dp[j] = max(dp[j], dp[j-w] + v)
print(max(dp))