Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input.split())

inf = 10 ** 10

dp = [inf] * (1 << N)

for _ in range(M):
    a, b = map(int, input.split())
    c = sum([2 ** (i - 1) for i in map(int, input.split())])

    for j in range(1 << N):
        if dp[j] + a < dp[j | c]:
            dp[j | c] = dp[j] + a

res = dp[-1] if dp[-1] != inf else -1
print(res)

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

inf = 10 ** 10

dp = [inf] * (1 << N)
dp[0] = 0

for _ in range(M):
    a, b = map(int, input().split())
    c = sum([2 ** (i - 1) for i in map(int, input().split())])

    for j in range(1 << N):
      dp[j | c] = min(dp[j] + a, dp[j | c])

res = dp[-1] if dp[-1] != inf else -1
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, K, Q = map(int, input().split(" "))

score_list = np.ones(N) * K

for q in range(Q):
    i = int(input())

    subtract = np.ones(N) * -1
    subtract[i - 1] += 1

    score_list = score_list + subtract

for s in score_list:
    if s > 0:
        print("Yes")
    else:
        print("No")

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

score_list = [K - Q] * N

for q in range(Q):
    i = int(input())
    score_list[i - 1] += 1

for s in score_list:
    if s > 0:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, K, Q = map(int, input().split(" "))

score_list = np.array([K] * N)

for q in range(Q):
    i = int(input())

    subtract = np.array([-1] * N)
    subtract[i - 1] += 1

    score_list = score_list + subtract

for cond in (score_list > 0):
    print("Yes" if cond else "No")

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

score_list = [K - Q] * N

for q in range(Q):
    i = int(input())
    score_list[i - 1] += 1

for s in score_list:
    if s > 0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split(" "))
A = list(map(int, input().split(" ")))

for _ in range(M):
  i = A.index(max(A))
  A[i] = A[i] // 2

print(sum(A))

Fixed submission:
import heapq
N, M = map(int, input().split(" "))
A = list(map(lambda x: -int(x), input().split(" ")))

heapq.heapify(A)

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

print(-sum(A))
Buggy python submission (verdict: Runtime Error):
import math

A = float(input())
B = float(input())

print(int(math.ceil((B - 1.0) / (A - 1.0))))

Fixed submission:
import math

A, B = map(float, input().split())

print(int(math.ceil((B - 1.0) / (A - 1.0))))
Buggy python submission (verdict: Runtime Error):
K, X = map(int, input())

print(" ".join(list(range(X - K, X + K + 1))))

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

print(" ".join(list(map(str, range(X - K + 1, X + K)))))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

reward = [[] for _ in range(M)]

for i in range(N):
    a, b = map(int, input().split())

    if a > M:
        continue
    c[m - a].append(b)

import heapq

h = []
heapq.heapify(h)
ans = 0

for i in range(M - 1, -1, -1):
    for b in c[i]:
        heapq.heappush(h, -b)
    if len(h) > 0:
        ans += -1 * heapq.heappop(h)

print(ans)

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

c = [[] for _ in range(M)]

for i in range(N):
    a, b = map(int, input().split())

    if a > M:
        continue
    c[M - a].append(b)

import heapq

h = []
heapq.heapify(h)
ans = 0

for i in range(M - 1, -1, -1):
    for b in c[i]:
        heapq.heappush(h, -b)
    if len(h) > 0:
        ans += -1 * heapq.heappop(h)

print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()

def func(num, code):
    total = 0
    start = 0
    length = len(num)

    for i in range(1, length):
        if code & 1 == 1: #一番下にビットが立ってるなら
            total = total + int(num[start:i])
            start = i
        code = code >> 1

    total = total + int(num[start:i + 1])

    return total

total_of_all = 0

for i in range(2 ** (len(S) - 1)):
    total_of_all = total_of_all + func(S, i)

print(total_of_all)

Fixed submission:
S = input()

def func(num, code):
    total = 0
    start = 0
    length = len(num)

    for i in range(1, length):
        if code & 1 == 1: #一番下にビットが立ってるなら
            total = total + int(num[start:i])
            start = i
        code = code >> 1

    total = total + int(num[start:length])

    return total

total_of_all = 0

for i in range(2 ** (len(S) - 1)):
    total_of_all = total_of_all + func(S, i)

print(total_of_all)

Buggy python submission (verdict: Runtime Error):
S = input()

def func(num, code):
    total = 0
    start = 0
    length = len(num)

    for i in range(1, length):
        if code & 1 == 1: #一番下にビットが立ってるなら
            total = total + int(num[start:i])
            start = i
        code = code >> 1

    total = total + int(num[start:i + 1])

    return total

total_of_all = 0

for i in range(2 ** (len(S) - 1)):
    print(func(S, i))
    total_of_all = total_of_all + func(S, i)

print(total_of_all)

Fixed submission:
S = input()

def func(num, code):
    total = 0
    start = 0
    length = len(num)

    for i in range(1, length):
        if code & 1 == 1: #一番下にビットが立ってるなら
            total = total + int(num[start:i])
            start = i
        code = code >> 1

    total = total + int(num[start:length])

    return total

total_of_all = 0

for i in range(2 ** (len(S) - 1)):
    total_of_all = total_of_all + func(S, i)

print(total_of_all)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(raw_input())
a=[0]*n
for i in range(n):
    a[i]=str(raw_input())
s=set(a)
ans=[-1]
m=0
for i in s:
    if(a.count(i)==m):
        m=a.count(i)
        ans.append(i)
    elif(a.count(i)>m):
        m=a.count(i)
        ans.pop()
        ans.append(i)
ans.sort()
for i in ans:
    print i

Fixed submission:
n=int(raw_input())
d={}
for i in range(n):
    x=str(raw_input())
    try:
        d[x]+=1
    except:
        d[x]=0

key_max = max(d.keys(), key=(lambda k: d[k]))
x=d[key_max]
ans=[]
for i in d:
    if(d[i]==x):
        ans.append(i)
ans.sort()
for i in ans:
    print i
Buggy python submission (verdict: Time Limit Exceeded):
count = 0
flag = 0

def merge(a, left, mid, right):
    global count
    L = [0] * (mid - left + 1)
    R = [0] * (right - mid + 1)

    for i in range(len(L)):
        if i  == len(L) - 1:
            L[i] = float('inf')
        else:
            L[i] = a[left+i]
    
    for i in range(len(R)):
        if i == len(R) - 1:
            R[i] = float('inf')
        else:
            R[i] = a[mid+i]

    i = 0
    j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            a[k] = L[i]
            i += 1
        else:
            if i != len(L) - 1 and j != len(R) - 1:
                count += len(L) - i - 1
            a[k] = R[j]
            j += 1

def mergeSort(a, left, right):
    if left+1 < right:
        mid = int((left + right) / 2)
        mergeSort(a, left, mid)
        mergeSort(a, mid, right)
        merge(a, left, mid, right)

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

mergeSort(a, 0, n)

for i in range(len(a)-1):
    x = a[i]
    y = a[i+1]

    if x == y:
        flag = 1
        break

if flag == 0:
    print('YES')
else:
    print('NO')

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

a = set(a)

if n == len(a):
    print('YES')
else:
    print('NO')

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a_ = []
flag = 0

for aa in a:
    if aa not in a_:
        a_.append(aa)
    else:
        flag = 1
        break

if flag == 1:
    print('NO')
else:
    print('YES')

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

a = set(a)

if n == len(a):
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
nk = list(map(int, input().split()))
n = nk[0]
k = nk[1]
p = list(map(int, input().split()))
p_ = []

for i in range(n-k+1):
    r = 0
    for j in range(k):
        r += p[i+j]

    p_.append(r)

print((max(p_)+k)/2)

Fixed submission:
nk = list(map(int, input().split()))
n = nk[0]
k = nk[1]
p = list(map(int, input().split()))
p_ = []

r = 0
for i in range(k):
    r += p[i]
p_.append(r)

for i in range(k, n):
    r += p[i] - p[i-k]
    p_.append(r)

print((max(p_)+k)/2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d = [0] * (n+1)

#片方がその数字だと固定されたときに新しく追加される要素数を計算する関数
def count(u):
    top = int(str(u)[0])
    bottom = int(str(u)[-1])
    #先頭と最後が一緒な候補を入れていく。1けたと2けたは処理が例外的なので先に入れる
    c = []
    if bottom == 0:
        return 0
    if top == bottom:
        c.append(top)
    c.append(int(str(bottom)+str(top)))

    for i in range(len(str(u))-2):
        for k in range(10**(i+1)):
            r = str(bottom)
            r += str(k).zfill(i+1)
            r += str(top)
            c.append(int(r))
    cnt = 0
    for cc in c:
        if cc < u:
            cnt += 2
        elif cc == u:
            cnt += 1
    

    return cnt

d[1] = 1
for i in range(2, n+1):
    d[i] = d[i-1] + count(i)

print(d[-1])

Fixed submission:
n = int(input())

c = [[0] * 10 for i in range(10)]

for i in range(1, n+1):
    start = int(str(i)[0])
    stop = int(str(i)[-1])

    c[start][stop] += 1

r = 0
for i in range(10):
    for j in range(10):
        r += c[i][j] * c[j][i]

#iとjがどちらも0の場合は問題設定と合致しないので引く
print(r)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = [str(input()) for i in range(n)]

s = set(l)
c = [l.count(i) for i in s]

res = sorted([[c[i],list(s)[i]] for i in range(len(s))],key=lambda x: (-x[0],x[1]))
[print(i[1]) for i in res if i[0] == res[0][0]]


Fixed submission:
import collections

n = int(input())
l = [str(input()) for i in range(n)]

c = collections.Counter(l).most_common()[::1]
res = sorted([i[0] for i in c if i[1] == c[0][1]])
[print(i) for i in res]
Buggy python submission (verdict: Runtime Error):
import math

a, b = (int(_) for _ in input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a,b))



Fixed submission:
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

a, b = (int(_) for _ in input().split())

z = lcm(a,b)
print(z)
Buggy python submission (verdict: Runtime Error):
import math

a, b, x = (int(_) for _ in input().split())

aab  = b * (a**2)
y    = aab-x

if y <= x:
    tan0 = y / (a**3)
    tan0 = tan0 * 2
    print(math.degrees(math.atan(tan0)))
else:
    tan0 = x / a
    tan0 = (tan0 * 4)/(b**2)
    print(90-math.degrees(math.asin(tan0))/2)


Fixed submission:
import math

a, b, x = (int(_) for _ in input().split())

L3 = b * (a**2)
x2  = L3 - x

if x >= x2:
    h = 2 * (x2 / (a**2))
    print(math.degrees(math.atan(h/a)))
else:
    h = 2 * (x  / (a*b))
    print(90-math.degrees(math.atan(h/b)))

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

a, b, x = (int(_) for _ in input().split())

aab  = b * (a**2)
y    = aab-x

if aab/2 <= x:
    tan0 = y / (a**3)
    tan0 = tan0 * 2
    print(math.degrees(math.atan(tan0)))
else:
    tan0 = x / a
    tan0 = (tan0 * 4)/(b**2)
    print(90-math.degrees(math.asin(tan0))/2)


Fixed submission:
import math

a, b, x = (int(_) for _ in input().split())

L3 = b * (a**2)
x2  = L3 - x

if x >= x2:
    h = 2 * (x2 / (a**2))
    print(math.degrees(math.atan(h/a)))
else:
    h = 2 * (x  / (a*b))
    print(90-math.degrees(math.atan(h/b)))
Buggy python submission (verdict: Time Limit Exceeded):
n, q = (int(_) for _ in input().split())
l = [list(map(int, input().split())) for i in range(n-1)]
p = [list(map(int, input().split())) for i in range(q)]
l = sorted(l,key = lambda x:(x[0] ,x[1]))

res = [0] * n
for i in p:
    res[i[0]-1] += i[1]
for i in l:
    res[i[1]-1] += res[i[0]-1]

[print(i,end=" ") for i in res]
print()

Fixed submission:
n, q = (int(_) for _ in input().split())
res = [0] * n
l = [[] for i in range(n-1)]
for i in range(n-1):
    a, b = (int(_) for _ in input().split())
    l[a-1].append(b)
p = [list(map(int, input().split())) for i in range(q)]

for i in p:
    res[i[0]-1] += i[1]
for i in range(n-1):
    for ii in l[i]:
        res[ii-1] += res[i]

[print(i,end=" ") for i in res]
print()

Buggy python submission (verdict: Time Limit Exceeded):
n, q = (int(_) for _ in input().split())
l = [list(map(int, input().split())) for i in range(n-1)]
p = [list(map(int, input().split())) for i in range(q)]
l = sorted(l,key = lambda x:(x[0] ,x[1]))

res = [0] * n
for i in p:
    res[i[0]-1] += i[1]
for i in l:
    res[i[1]-1] += res[i[0]-1]

[print(i,end=" ") for i in res]
print()

Fixed submission:
n, q = (int(_) for _ in input().split())
res = [0] * n
l = [[] for i in range(n-1)]
for i in range(n-1):
    a, b = (int(_) for _ in input().split())
    l[a-1].append(b)
p = [list(map(int, input().split())) for i in range(q)]

for i in p:
    res[i[0]-1] += i[1]
for i in range(n-1):
    for ii in l[i]:
        res[ii-1] += res[i]

[print(i,end=" ") for i in res]
print()
Buggy python submission (verdict: Runtime Error):
n, m = (int(_) for _ in input().split())
x = [int(input()) for i in range(m)]
xi = 0

if m == 0:
    x = [999999]

a = [1,1]
if x[xi] == 1:
    xi += 1
    a[1] = 0

for i in range(n-1):
    if x[xi]-2 == i:
        a.append(0)
        xi = min(len(x)-1,xi+1)
    else:
        a.append(a[i+1]+a[i])

print(a[n]%1000000007)

Fixed submission:
n, m = (int(_) for _ in input().split())
x = [int(input()) for i in range(m)]
xi = 0

if m == 0:
    x = [999999]

a = [1,1]
if x[xi] == 1:
    xi = min(len(x)-1,xi+1)
    a[1] = 0

for i in range(n-1):
    if x[xi]-2 == i:
        a.append(0)
        xi = min(len(x)-1,xi+1)
    else:
        a.append(a[i+1]+a[i])

print(a[n]%1000000007)

Buggy python submission (verdict: Runtime Error):
n, m = (int(_) for _ in input().split())  
x = [int(input()) for i in range(m)]
xi = 0

a = [1,1]
if x[xi] == 1:
    xi += 1
    a[1] = 0

for i in range(n-1):
    if x[xi]-2 == i:
        a.append(0)
        xi = min(len(x)-1,xi+1)
    else:
        a.append(a[i+1]+a[i])

print(a[n]%1000000007)

Fixed submission:
n, m = (int(_) for _ in input().split())
x = [int(input()) for i in range(m)]
xi = 0

if m == 0:
    x = [999999]

a = [1,1]
if x[xi] == 1:
    xi = min(len(x)-1,xi+1)
    a[1] = 0

for i in range(n-1):
    if x[xi]-2 == i:
        a.append(0)
        xi = min(len(x)-1,xi+1)
    else:
        a.append(a[i+1]+a[i])

print(a[n]%1000000007)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = (int(_) for _ in input().split())  
a = list(map(int, input().split()))
x = [list(int(_) for _ in input().split()) for i in range(m)]
[a.extend(list(i[1] for ii in range(i[0]))) for i in x]

a = sorted(a,key = lambda x:-x)

print(sum(a[:n]))

Fixed submission:
n, m = (int(_) for _ in input().split())  
a = list(map(int, input().split()))
x = [list(int(_) for _ in input().split()) for i in range(m)]
x = sorted(x,key = lambda x:-x[1])

[a.extend(list(i[1] for ii in range(i[0]))) for i in x if len(a) <= n * 2]
a = sorted(a,key = lambda x:-x)

print(sum(a[:n]))
Buggy python submission (verdict: Runtime Error):
a, b = (int(_) for _ in input().split())  
res = float(sum([(1/2 ** (math.ceil(int(b/i)**(1/2)))) if i < b else 1 for i in range(1,a+1)]) / a)
print(res)

Fixed submission:
import math
a, b = (int(_) for _ in input().split())  
res = float(sum([(1/2 ** (math.ceil(math.log2(b/i)))) if i < b else 1 for i in range(1,a+1)]) / a)
print(res)
Buggy python submission (verdict: Runtime Error):
a = map(int,input().split())

if max(a) == min(a):
  print("Yes")
else:
  print("No")



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

if max(a) == min(a):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n = num(input())
l = list(input())
if l.count("R") > int(n/2):
  print("Yes")
else:
  print("No")



Fixed submission:
n = int(input())
l = list(input())
if l.count("R") > int(n/2):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
print(["ACGT"]["CATG".find(input())])

Fixed submission:
print("ACGT"["TGCA".find(input())])
Buggy python submission (verdict: Runtime Error):
a = list(map(int, input().split()))

if a in 1 and a in 9 and a in 7 and a in 4:
  print(YES)
else:
  print(NO)


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

if 1 in a and 9 in a and 7 in a and 4 in a:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
res = 0
d = 0

if sum(a) < sum(b):
    res = -1
else:
    c = [a[i] - b[i] for i in range(n)]
    c1 = [i if i > 0 else 0 for i in c]
    c2 = sum([i if i < 0 else 0 for i in c])
    c3 = sum([1 if i < 0 else 0 for i in c])
    if c2 < 0:
      	c4 = sorted(c1, reverse=True)
        for i in range(n):
            d = d + c4[i]
            if d + c2 > 0:
                res = c3 + i
                break

print(res)


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

if sum(a) < sum(b):
    res = -1
else:
    c = [a[i] - b[i] for i in range(n)]
    c1 = [i if i > 0 else 0 for i in c]
    c2 = sum([i if i < 0 else 0 for i in c])
    c3 = sum([1 if i < 0 else 0 for i in c])
    if c2 < 0:
        c4 = sorted(c1, reverse=True)
        for i in range(n):
            d = d + c4[i]
            if d + c2 > 0:
                res = c3 + i + 1
                break

print(res)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
res = 0

if sum(a) < sum(b):
    res = -1
else:
    c = [a[i] - b[i] for i in range(n)]
    c1 = [i if i > 0 else 0 for i in c]
    c2 = sum([i if i < 0 else 0 for i in c])
    c3 = sum([1 if i < 0 else 0 for i in c])
    if c2 < 0:
        c1.sort(reverse=True)
        for i in range(n):
            if sum(c1[0:i]) + c2 > 0:
                res = c3 + i
                break

print(res)


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

if sum(a) < sum(b):
    res = -1
else:
    c = [a[i] - b[i] for i in range(n)]
    c1 = [i if i > 0 else 0 for i in c]
    c2 = sum([i if i < 0 else 0 for i in c])
    c3 = sum([1 if i < 0 else 0 for i in c])
    if c2 < 0:
        c4 = sorted(c1, reverse=True)
        for i in range(n):
            d = d + c4[i]
            if d + c2 > 0:
                res = c3 + i + 1
                break

print(res)
Buggy python submission (verdict: Runtime Error):
N = input()
a = [input() for i in range(N)]
b = sorted(a ,reverse = True)
res = sum(b[0]/2,sum(b[1:]))
print(res)

Fixed submission:
N = int(input())
a = [int(input()) for i in range(N)]
b = sorted(a ,reverse = True)
res = int(b[0]/2 + sum(b[1:]))
print(res)
Buggy python submission (verdict: Runtime Error):
a = list(map(int, input().split()))

c = a[1]
res = 0

b = [[5,3,1]]
for i in range(1,a[0]+1):
    tmp = [b[i-1][0]*2+3,b[i-1][1]*2+1,i+1]
    b.append(tmp)

for i in range(50-1,0,-1):
    c = c - 1
    if b[i][0] < c:
        c = c - b[i][0] - 1
        res = res + b[i][1] + 1
if c == 1:
    res = res + 1

print(res)


Fixed submission:
a = list(map(int, input().split()))
c = a[1]
res = 0

b = [[5,3,1]]
for i in range(1,a[0]):
    tmp = [b[i-1][0]*2+3,b[i-1][1]*2+1,i+1]
    b.append(tmp)

for i in range(a[0]-1,-1,-1):
    if b[i][0] * 2 + 1 <= c:
        c = c - b[i][0]*2 - 1
        res = res + b[i][1] * 2 + 1
    elif b[i][0] <= c: 
        c = c - b[i][0]
        res = res + b[i][1]
        if c > 0:
            c = c - 1
            res = res + 1
    c = c - 1

if c > 0:
    res = res + c

print(res)
Buggy python submission (verdict: Runtime Error):
a = input()
b = 753
res = float("inf")
l = len(a)

for i in range(1,l-3):
    n = abs(b-int(a[i:i+3]))
    if res > n:
        res = n
        
print(n)    


Fixed submission:
a = input()
b = 753
res = float("inf")
l = len(a)

for i in range(0,l-2):
    n = abs(b-int(a[i:i+3]))
    if res > n:
        res = n
        
print(int(res))
Buggy python submission (verdict: Runtime Error):
n = int(input())

if n = 1:
  print("Hello World")
else:
  print(int(input())+int(input()))




Fixed submission:
n = int(input())
 
if n == 1:
  print("Hello World")
else:
  print(int(input())+int(input()))
Buggy python submission (verdict: Runtime Error):
x = int(input())

if x % 2 == 0:
  print(int((x//2)**2))
else:
  print(int((x//2)*((x//2)+1))


Fixed submission:
x = int(input())

if x % 2 == 0:
  print(int((x//2)**2))
else:
  print(int((x//2)*((x//2)+1)))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
b = list(map(int, input().split()))
a = list(map(int, input().split()))

p = [i for i in a if i > 0]
m = [i for i in a if i <= 0]
p = np.append(np.diff(np.append([0],p)),[10**10])
m = np.abs(np.append([10**10],np.diff(np.append(m,[0]))))

lp = [0]
lm = [0]

for i in range(b[1]):
    if p[0] > m[-1]:
        lm = lm + m[-1]
        m = np.delete(m, -1)
    else:
        lp = lp + p[0]
        p = np.delete(p, 0)

res = int(lp + lm + min(lm,lp))

print(res)

Fixed submission:
import numpy as np
b = list(map(int, input().split()))
a = list(map(int, input().split()))
x = b[0]-b[1]+1
res = 10**100
 
for i in range(x):
    tmp = i + b[1] - 1
    res = min( a[tmp]-a[i] + min(abs(a[i]),abs(a[tmp])),res)
        
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
b = list(map(int, input().split()))
a = list(map(int, input().split()))

p = np.append(np.diff(np.sort([i for i in a if i > 0] + [0])),[10**10])
m = np.append(np.diff(np.sort(np.abs([i for i in a if i <= 0] + [0]))),[10**10])

lp = []
lm = []
for i in range(b[1]):
    if p[0] > m[0]:
        lm.append(m[0])
        m = np.delete(m, 0)
    else:
        lp.append(p[0])
        p = np.delete(p, 0)

res = sum(lp) + sum(lm) + min(sum(lp),sum(lm))

print(res)

Fixed submission:
import numpy as np
b = list(map(int, input().split()))
a = list(map(int, input().split()))
x = b[0]-b[1]+1
res = 10**100
 
for i in range(x):
    tmp = i + b[1] - 1
    res = min( a[tmp]-a[i] + min(abs(a[i]),abs(a[tmp])),res)
        
print(res)
Buggy python submission (verdict: Runtime Error):
x = int(input())
print(max([i**ii for i in range(2,34) for ii in range(2,11) if i**ii <= x]))

Fixed submission:
x = int(input())
print(max([i**ii for i in range(1,34) for ii in range(2,11) if i**ii <= x]))

Buggy python submission (verdict: Runtime Error):
x = int(input())
print(max([int(x**(1/i))**i for i in range(10)]))

Fixed submission:
x = int(input())
print(max([i**ii for i in range(1,34) for ii in range(2,11) if i**ii <= x]))

Buggy python submission (verdict: Runtime Error):
x = int(input())
print(max([int(x**(1/i))**i for i in range(100)]))

Fixed submission:
x = int(input())
print(max([i**ii for i in range(1,34) for ii in range(2,11) if i**ii <= x]))
Buggy python submission (verdict: Runtime Error):
print(round(mean([int(i) for i in input().split()] )))

Fixed submission:
import math
print(math.ceil(sum([int(i) for i in input().split()] )/ 2))
Buggy python submission (verdict: Runtime Error):
x = int(input())
a, b = (abs(int(i)-x) for i in input().split())
if a > b:
  print("B")
else:
  print("A")


Fixed submission:
x, a, b = (int(i) for i in input().split())
if abs(a-x) > abs(b-x):
  print("B")
else:
  print("A")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input()) 
t = [int(input()) for i in range(n)] 

res = [1]
i = 1

while i <= n:
  res.append(t[res[-1]-1])
  if res[-1] == 2:
    print(len(res)-1)
    break
  elif len(res) != len(set(res)):
    print(-1)
    break
  i += 1


Fixed submission:
n = int(input()) 
t = [int(input()) for i in range(n)] 

x = 1
res = -1
for i in range(n):
  x = t[x-1]
  if x == 2:
    res = i + 1
    break
  
print(res)
Buggy python submission (verdict: Runtime Error):
a, b = (int(i) for i in input().split())

if sum(a,b) > 9:
  print("error")
else:
  print(sum(a,b))



Fixed submission:
a = [int(i) for i in input().split()] 

if sum(a) > 9:
  print("error")
else:
  print(sum(a))