Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, k, q = map(int, input().split())
alist = [int(input()) for i in range(q)]

for i in range(1, n + 1):
    if k + (-1)*(q - alist.count(i)) <= 0:
        print('No')
    else:
        print('Yes')

Fixed submission:
n, k, q = map(int, input().split())
alist = [int(input()) for i in range(q)]
ans = [k - q] * n

for Ai in alist:
    ans[Ai - 1] += 1

for Ai in ans:
    print('Yes') if Ai > 0 else print('No')

Buggy python submission (verdict: Runtime Error):
n, k, q = map(int, input().split())
alist = [int(input()) for i in range(n)]

for i in range(1, n + 1):
    if n - alist.count(i) >= k:
        print('No')
    else:
        print('Yes')


Fixed submission:
n, k, q = map(int, input().split())
alist = [int(input()) for i in range(q)]
ans = [k - q] * n

for Ai in alist:
    ans[Ai - 1] += 1

for Ai in ans:
    print('Yes') if Ai > 0 else print('No')

Buggy python submission (verdict: Runtime Error):
n, k, q = list(input())
alist = [int(input()) for i in range(n)]

for i in range(1, n + 1):
    if n - alist.count(i) >= k:
        print('No')
    else:
        print('Yes')


Fixed submission:
n, k, q = map(int, input().split())
alist = [int(input()) for i in range(q)]
ans = [k - q] * n

for Ai in alist:
    ans[Ai - 1] += 1

for Ai in ans:
    print('Yes') if Ai > 0 else print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
alist = list(map(int, input().split()))

for i in range(m):
    num = max(alist)
    num = num >> 1

    alist.remove(max(alist))
    alist.append(num)

print(sum(alist))


Fixed submission:
import heapq


n, m = map(int, input().split())
alist = list(map(int, input().split()))
alist = list(map(lambda x: -x, alist))
heapq.heapify(alist)

for i in range(m):
    minus_max = alist[0]
    heapq.heapreplace(alist, ((-1)*minus_max >> 1)*(-1))

print(-1*sum(alist))
Buggy python submission (verdict: Runtime Error):
n = int(input())
hlist = list(map(int, input().split()))
delta = [hlist[i + 1] - hlist[i] for i in range(len(hlist) - 1)]

counter = 0
for i in range(len(delta)):
    if delta[i] <= 0:
        counter += 1
    else:
        ans = counter
        counter = 0
ans = max(ans, counter)
print(ans)


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

counter, ans = 0, 0
for i in range(len(h)-1):
    if h[i] >= h[i+1]:
        counter += 1
    else:
        if ans <= counter:
            ans = counter
        counter = 0
ans = max(ans, counter)


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())
if R - L + 1 >= 2019:
    print(0)
    quit

for num in range(L, R + 1):
    if num % 2019 == 0:
        print(0)
        quit

ans = 2018
for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
        if (i * j) % 2019 <ans:
            ans = (i * j) % 2019
print(ans)


Fixed submission:
L, R = map(int, input().split())
if R - L + 1 == 2:
    print((R * L) % 2019)
    quit()

if R - L + 1 >= 673:
    print(0)
    quit()

for num in range(L, R + 1):
    if num % 673 == 0:
        print(0)
        quit()


ans = 2018
for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
        amari = (i*j) % 2019
        if amari < ans:
            ans = amari
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
plist = list(map(int, input().split()))
counter = 0

for i in range(2, n):
    a = plist[i - 1]
    b = plist[i]
    c = plist[i+1]
    if a < b < c or c < b < a:
        counter += 1

print(counter)


Fixed submission:
n = int(input())
plist = list(map(int, input().split()))
counter = 0

for i in range(1, n-1):
    a, b, c = plist[i-1:i+2]
    if a < b < c or c < b < a:
        counter += 1

print(counter)

Buggy python submission (verdict: Runtime Error):
n = int(input())
plist = list(map(int, input().split()))
counter = 0

for i in range(2, n):
    a, b, c = plist[i - 1:i + 2]
    if a < b < c or c < b < a:
        counter += 1

print(counter)

Fixed submission:
n = int(input())
plist = list(map(int, input().split()))
counter = 0

for i in range(1, n-1):
    a, b, c = plist[i-1:i+2]
    if a < b < c or c < b < a:
        counter += 1

print(counter)
Buggy python submission (verdict: Runtime Error):
from math import floor, ceil
from math import gcd
# from fractions import gcd


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


A, B, C, D = map(int, input().split())
LCM = lcm(C, D)

x = floor(B / C)
y = floor(B / D)
z = floor(B / LCM)
ans = B-x-y+z

x = floor((A-1) / C)
y = floor((A-1) / D)
z = floor((A - 1) / LCM)

ans -= (A - 1) - x - y + z

print(ans)


Fixed submission:
from fractions import gcd


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


A, B, C, D = map(int, input().split())

LCM = lcm(C, D)

x = B//C
y = B // D
z = B // LCM
ans = B-x-y+z

x = (A-1) // C
y = (A-1) // D
z = (A-1) // LCM

ans -= (A-1) - x - y + z

print(ans)

Buggy python submission (verdict: Runtime Error):
from math import floor, ceil, gcd


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


A, B, C, D = map(int, input().split())
LCM = lcm(C, D)

multiple_of_C = floor(B / C) - ceil(A / C) + 1
multiple_of_D = floor(B / D) - ceil(A / D) + 1
multiple_of_CtimesD = floor(B / LCM) - ceil(A / LCM) + 1

print((B-A+1)-multiple_of_C-multiple_of_D+multiple_of_CtimesD)


Fixed submission:
from fractions import gcd


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


A, B, C, D = map(int, input().split())

LCM = lcm(C, D)

x = B//C
y = B // D
z = B // LCM
ans = B-x-y+z

x = (A-1) // C
y = (A-1) // D
z = (A-1) // LCM

ans -= (A-1) - x - y + z

print(ans)

Buggy python submission (verdict: Runtime Error):
from math import floor, ceil, gcd


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


A, B, C, D = map(int, input().split())
LCM = lcm(C, D)

multiple_of_C = floor(B / C) - ceil(A / C) + 1
multiple_of_D = floor(B / D) - ceil(A / D) + 1
multiple_of_CtimesD = floor(B / LCM) - ceil(A / LCM) + 1

print((B-A+1)-multiple_of_C-multiple_of_D+multiple_of_CtimesD)


Fixed submission:
from fractions import gcd


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


A, B, C, D = map(int, input().split())

LCM = lcm(C, D)

x = B//C
y = B // D
z = B // LCM
ans = B-x-y+z

x = (A-1) // C
y = (A-1) // D
z = (A-1) // LCM

ans -= (A-1) - x - y + z

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

ans = -100000000000
for num in range(2 ** N):
    value = cost = 0
    for i in range(N):
        if (num >> i) & 1 == 1:
            value += vlist[i]
            cost += clist[i]
    if value - cost > ans:
        ans = value - cost
print(ans)


Fixed submission:
N = int(input())
vlist = list(map(int, input().split()))
clist = list(map(int, input().split()))
ans=0
for i in range(N):
    if vlist[i] - clist[i] > 0:
        ans += vlist[i] - clist[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, c = list(map(int, input().split())).sort(reverse=True)
print('Yes' if b - c < a and a < b + c else 'No')

Fixed submission:
a, b, c = list(map(int, input().split()))
print('Yes' if a == b == c and a > 0 else 'No')
Buggy python submission (verdict: Runtime Error):
n, Y = list(map(int, input().split()))
for i in range(N + 1):
    for j in range(n + 1 - i):
        if 10000 * i + 5000 * j + 1000 * (n - i - j) == Y:
            print(i, j, n - i - j)
            exit()
else:
    print('-1 -1 -1')


Fixed submission:
n, Y = list(map(int, input().split()))
for i in range(n + 1):
    for j in range(n + 1 - i):
        if 10000 * i + 5000 * j + 1000 * (n - i - j) == Y:
            print(i, j, n - i - j)
            exit()
else:
    print('-1 -1 -1')

Buggy python submission (verdict: Runtime Error):
N, Y = list(map(int, input().split()))
for i in range(N + 1):
    for j in range(n + 1 - i):
        if 10000 * i + 5000 * j + 1000 * (n - i - j) == Y:
            print(i, j, n - i - j)
            exit()
else:
    print('-1 -1 -1')


Fixed submission:
n, Y = list(map(int, input().split()))
for i in range(n + 1):
    for j in range(n + 1 - i):
        if 10000 * i + 5000 * j + 1000 * (n - i - j) == Y:
            print(i, j, n - i - j)
            exit()
else:
    print('-1 -1 -1')
Buggy python submission (verdict: Runtime Error):
N = int(input())
Alist = [int(input()) for i in range(N)]
Alist.sort()
Alist.append('END')
counter = 1
ans = 0

for i in range(1, len(alist)):
    if Alist[i - 1] == Alist[i]:
        counter += 1
    else:
        if counter % 2 == 1:
            ans += 1
        counter = 1

print(ans)


Fixed submission:
N = int(input())
Alist = [int(input()) for i in range(N)]
Alist.sort()
Alist.append('END')
counter = 1
ans = 0

for i in range(1, len(Alist)):
    if Alist[i - 1] == Alist[i]:
        counter += 1
    else:
        if counter % 2 == 1:
            ans += 1
        counter = 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
cycles = [int(input()) for i in range(N)]


x = 1
M = max(cycles)
while 1:
    for num in cycles:
        if (M * x) % num != 0:
            x += 1
            break
    else:
        print(M * x)
        quit()


Fixed submission:
def GCD(x: int, y: int):
    if x < y:
        x, y = y, x

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


def LCM(x: int, y: int):
    return x * y // GCD(x, y)


N = int(input())
Tlist = [int(input()) for i in range(N)]
ans = 1
for num in Tlist:
    ans = LCM(ans, num)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
rates = list(map(int, input().split()))

colors = [0]*9

for rate in rates:
    colors[rate // 400] += 1

zeros = colors[0:8].count(0)
nonzeros = 8 - zeros

M = nonzeros + colors[8]

if nonzeros == 0:
    m = 1
else:
    m = nonzeros

print(m, M)


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

colors = [0]*9

for rate in rates:
    if rate < 3200:
        colors[rate // 400] += 1
    else:
        colors[8] += 1

zeros = colors[0:8].count(0)
nonzeros = 8 - zeros

M = nonzeros + colors[8]

if nonzeros == 0:
    m = 1
else:
    m = nonzeros

print(m, M)

Buggy python submission (verdict: Runtime Error):
N = int(input())
rates = list(map(int, input().split()))

colors = [0]*9

for rate in rates:
    colors[rate // 400] += 1

if colors[0:8] == [0] * 8:
    print(1, min(colors[8], 8))
else:
    zeros = colors[0:8].count(0)
    print(8-zeros, 8-zeros+min(zeros, colors[8]))

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

colors = [0]*9

for rate in rates:
    if rate < 3200:
        colors[rate // 400] += 1
    else:
        colors[8] += 1

zeros = colors[0:8].count(0)
nonzeros = 8 - zeros

M = nonzeros + colors[8]

if nonzeros == 0:
    m = 1
else:
    m = nonzeros

print(m, M)

Buggy python submission (verdict: Runtime Error):
N = int(input())
rates = list(map(int, input().split()))

colors = [0]*9

for rate in rates:
    colors[rate // 400] += 1

if colors[0:8] == [0] * 8:
    print(1, min(colors[8], 8))
else:
    zeros = colors[0:8].count(0)
    print(8-zeros, 8-zeros+min(zeros, colors[8]))

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

colors = [0]*9

for rate in rates:
    if rate < 3200:
        colors[rate // 400] += 1
    else:
        colors[8] += 1

zeros = colors[0:8].count(0)
nonzeros = 8 - zeros

M = nonzeros + colors[8]

if nonzeros == 0:
    m = 1
else:
    m = nonzeros

print(m, M)
Buggy python submission (verdict: Runtime Error):
N, T = list(map(int, input().split()))
push_list = list(map(int, input().split()))
print(push_list)

dabaaaaa = 0

for i in range(len(dabaaaaa)-1):
    if push_list[i + 1] - push_list[i] < 5:
        dabaaaaa += push_list[i + 1] - push_list[i]
    else:
        dabaaaaa += 5

print(dabaaaaa)


Fixed submission:
N, T = list(map(int, input().split()))
push_list = list(map(int, input().split()))


dabaaaaa = 0

for i in range(len(push_list)-1):
    if push_list[i + 1] - push_list[i] < T:
        dabaaaaa += push_list[i + 1] - push_list[i]
    else:
        dabaaaaa += T

    # 最後の人が押した後のT秒も加算

print(dabaaaaa+T)
Buggy python submission (verdict: Time Limit Exceeded):
k, s = list(map(int, input().split()))


def Weight(x, y, z):
    if len({x, y, z}) == 1:
        return 1
    elif len({x, y, z}) == 2:
        return 3
    elif len({x, y, z}) == 3:
        return 6


counter = 0
for x in range(k+1):
    for y in range(x+1):
        for z in range(y+1):
            if x + y + z == s:
                counter += Weight(x, y, z)

print(counter)

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


counter = 0
for x in range(k+1):
    for y in range(k+1):
        if 0 <= s - x - y <= k:
            counter += 1

print(counter)

Buggy python submission (verdict: Time Limit Exceeded):
k, s = list(map(int, input().split()))

counter = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x + y + z == s:
                counter += 1

print(counter)


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


counter = 0
for x in range(k+1):
    for y in range(k+1):
        if 0 <= s - x - y <= k:
            counter += 1

print(counter)
Buggy python submission (verdict: Runtime Error):
N = int(input())
Tlist = list(map(int, input().split()))
M = int(input())
PX = [list(map(int, input().split())) for i in range(M)]

for i in range(M):
    print(sum(Tlist)-Tlist[i]+PX[i][1])

Fixed submission:
N = int(input())
Tlist = list(map(int, input().split()))
M = int(input())
PX = [list(map(int, input().split())) for i in range(M)]

for i in range(M):
    print(sum(Tlist)-Tlist[PX[i][0]-1]+PX[i][1])
Buggy python submission (verdict: Runtime Error):
k,n=map(int, input().strip().split())
a=list(map(int, input().strip().split()))
a.append(a[0]+k)

ans=0
for i in range(n):
 ans=max(max, a[i+1]-a[i])
print(k-ans)

Fixed submission:
k,n=map(int, input().strip().split())
a=list(map(int, input().strip().split()))
a.append(a[0]+k)

v=0
for i in range(n): v=max(v,a[i+1]-a[i])
print(k-v)
Buggy python submission (verdict: Runtime Error):
N = int(input())
if N % 2 == 1:
    print("No")
	exit()
S = input()
if S[0:N//2] == S[N//2:]:
    print("Yes")
else:
    print("No")


Fixed submission:
N = int(input())
if N % 2 == 1:
    print("No")
    exit()
S = input()
if S[0:N//2] == S[N//2:]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import collections
import fractions

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return set(a)

A, B = list(map(int, input().split()))
print(len(fractions.gcd(A, B)) + 1)


Fixed submission:
import collections
import fractions

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return set(a)


A, B = list(map(int, input().split()))
print(len(prime_factorize(fractions.gcd(A, B))) + 1)
Buggy python submission (verdict: Runtime Error):
import numpy as np

N, D = list(map(int, input().split()))
X = []
for i in range(D):
    x_i = [int(i) for i in input().split()]
    X.append(i)
X = np.array(X)

ans = 0
for i in range(D):
    for j in range(i + 1, D):
        if np.sqrt(np.sum(X[i] - X[j]) ** 2).is_integer():
            ans += 1
print(ans)


Fixed submission:
import numpy as np

def main():
    N, D = list(map(int, input().split()))
    X = []
    for i in range(N):
	    line = [int(a) for a in input().split()]
	    X.append(line)
    X_np = np.array(X)

    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            if(is_dist_int(X_np, D, i, j)):
                ans += 1
    print(ans)

def is_dist_int(X_np, D, i, j):
    dif = np.sum(np.square(np.abs(X_np[i] - X_np[j])))
    dis = np.sqrt(dif)
    return dis.is_integer()

main()

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

N, D = list(map(int, input().split()))
X = []
for i in range(D):
    x_i = [int(i) for i in input().split()]
    X.append(i)
X = np.array(X)

ans = 0
for i in range(D):
    for j in range(i + 1, D):
        if np.is_integer(np.sqrt(np.sum(X[i] - X[j]) ** 2)):
            ans += 1
print(ans)


Fixed submission:
import numpy as np

def main():
    N, D = list(map(int, input().split()))
    X = []
    for i in range(N):
	    line = [int(a) for a in input().split()]
	    X.append(line)
    X_np = np.array(X)

    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            if(is_dist_int(X_np, D, i, j)):
                ans += 1
    print(ans)

def is_dist_int(X_np, D, i, j):
    dif = np.sum(np.square(np.abs(X_np[i] - X_np[j])))
    dis = np.sqrt(dif)
    return dis.is_integer()

main()
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())
ans = 2018
for i in range(L, R):
    for j in range(i + 1, R + 1):
        ans = min(ans, (i * j) % 2019)
        if ans == 0:
            break
print(ans)


Fixed submission:
def main():
    L, R = list(map(int, input().split()))
    ans = 2018
    end = min(R+1, L+2019)
    for i in range(L, end-1):
        for j in range(i+1, end):
            ans = min(ans, (i*j)%2019)
    print(ans)

main()

Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())
ans = 2018
for i in range(L, R):
    for j in range(i + 1, R + 1):
        ans = min(ans, (i * j) % 2019)
        if ans == 0:
            break
print(ans)


Fixed submission:
def main():
    L, R = list(map(int, input().split()))
    ans = 2018
    end = min(R+1, L+2019)
    for i in range(L, end-1):
        for j in range(i+1, end):
            ans = min(ans, (i*j)%2019)
    print(ans)

main()

Buggy python submission (verdict: Runtime Error):
def main():
    L, R = list(map(int, input().split()))
    ans = 2018
    end = min(R+1, L+2019))
    for i in range(L, end-1):
        for j in range(i+1, end):
            print(ans, (i*j)%2019)
            ans = min(ans, (i*j)%2019)
    print(ans)

main()


Fixed submission:
def main():
    L, R = list(map(int, input().split()))
    ans = 2018
    end = min(R+1, L+2019)
    for i in range(L, end-1):
        for j in range(i+1, end):
            ans = min(ans, (i*j)%2019)
    print(ans)

main()
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])
P = []
for i in range(N):
    if i == N - 1:
        P.append([0.5] + [0] * (N - 2) + [0.5])
    else:
        P.append([0] * i + [0.5, 0.5] + [0] * (N - 2 - i))
P = np.array(P)
for i in np.dot(np.linalg.inv(P), A):
    print(int(i)," ", end="")


Fixed submission:
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])
# dif = A1-A2+A3-A4 ...
dif = sum([A[i] * pow(-1, i) for i in range(N - 1)])
ans = [0] * N
ans[0] = A[-1] + dif
ans[-1] = A[-1] - dif
for i in range(1, N - 1):
    ans[i] = 2 * A[i - 1] - ans[i - 1]
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
a = [int(input()) for i in range(M)]
MOD = 10 ** 9 + 7
dp = [1]
if 1 in a:
    dp.append(0)
else:
    dp.append(1)
for ith_stair in range(2, N + 1):
    if ith_stair in a:
        dp.append(0)
    else:
        dp.append((dp[ith_stair - 1] + dp[ith_stair - 2]) % MOD)
print(dp[N] % MOD)


Fixed submission:
N, M = map(int, input().split())
a = set([int(input()) for i in range(M)])
MOD = 10 ** 9 + 7
dp = [1]
if 1 in a:
    dp.append(0)
else:
    dp.append(1)
for ith_stair in range(2, N + 1):
    if ith_stair in a:
        dp.append(0)
    else:
        dp.append((dp[ith_stair - 1] + dp[ith_stair - 2]) % MOD)
print(dp[N] % MOD)
Buggy python submission (verdict: Runtime Error):
r, D, X = list(map(int, input().split()))
for i in range(10):
    x = r * x - D
    print(x)


Fixed submission:
r, D, x = list(map(int, input().split()))
for i in range(10):
    x = r * x - D
    print(x)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = [int(i) for i in input().split()]
for i in range(M):
    b, c = map(int, input().split())
    A += [c] * b
A.sort()
A.reverse()
print(sum(A[0:N]))


Fixed submission:
import operator as op

N, M = map(int, input().split())
A = [int(i) for i in input().split()]
BC = []
for i in range(M):
    b, c = map(int, input().split())
    BC.append([b, c])
for a in A:
    BC.append([1, a])
BC_sort = sorted(BC, key=op.itemgetter(1), reverse=True)
rest = N
ans = 0
for i in range(len(BC_sort)):
    if rest >= BC_sort[i][0]:
        ans += BC_sort[i][0] * BC_sort[i][1]
        rest -= BC_sort[i][0]
    elif 0 <= rest < BC_sort[i][0]:
        ans += rest * BC_sort[i][1]
        break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = [int(i) for i in input().split()]
for i in range(M):
    b, c = map(int, input().split())
    A += [c] * b
A.sort()
A.reverse()
print(sum(A[0:N]))


Fixed submission:
import operator as op

N, M = map(int, input().split())
A = [int(i) for i in input().split()]
BC = []
for i in range(M):
    b, c = map(int, input().split())
    BC.append([b, c])
for a in A:
    BC.append([1, a])
BC_sort = sorted(BC, key=op.itemgetter(1), reverse=True)
rest = N
ans = 0
for i in range(len(BC_sort)):
    if rest >= BC_sort[i][0]:
        ans += BC_sort[i][0] * BC_sort[i][1]
        rest -= BC_sort[i][0]
    elif 0 <= rest < BC_sort[i][0]:
        ans += rest * BC_sort[i][1]
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools as it

N = int(input())
V = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

ans = 0
for ith_conf in it.product(range(2), repeat=N):
    dif = 0
    for j_jewel in range(N):
        if ith_conf[j_jewel] == 1:
            dif += V[j_jewel] - C[j_jewel]
    ans = max(ans, dif)
print(ans)


Fixed submission:
N = int(input())
V = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
ans = 0
for i in range(N):
    if V[i] > C[i]:
        ans += V[i] - C[i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import fractions

def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    ans = 1
    for i_out in range(len(A)):
        A_ith = [A[i] for i in range(len(A))]
        del A_ith[i_out]
        ans = max(ans, cal_all_gcb(A_ith))
    print(ans)

def cal_all_gcb(A):
    gcd = A[0]
    for j in range(1, len(A)):
        gcd = fractions.gcd(gcd, A[j])
    return gcd

main()

Fixed submission:
import fractions as f

N = int(input())
A = [int(i) for i in input().split()]
L = [A[0]]
for i in range(1, N):
    L.append(f.gcd(L[-1], A[i]))
A.reverse()
R = [A[0]]
for i in range(1, N):
    R.append(f.gcd(R[-1], A[i]))
R.reverse()
ans = 0
for i in range(N):
    if i == 0:
        ans = max(ans, R[1])
    elif i == N - 1:
        ans = max(ans, L[N - 2])
    else:
        ans = max(ans, f.gcd(L[i - 1], R[i + 1]))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
S_list = [int(S[i]) for i in range(len(S))]
ans = 0
rm_list = []
for aaa in range(len(S) // 2):
    for i in range(len(S_list) - 1):
        if S_list[i] != S_list[i + 1] and i not in rm_list:
            rm_list.append(i)
            rm_list.append(i + 1)
    S_list = [S_list[i] for i in range(len(S_list)) if i not in rm_list]
    if len(rm_list) == 0:
        break
    ans += len(rm_list)
    rm_list = []
print(ans)


Fixed submission:
S = input()
a = sum([int(S[i]) for i in range(len(S))])
b = len(S) - a
print(2*min(a, b))

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
S_list = [int(S[i]) for i in range(len(S))]
ans = 0
rm_list = []
for aaa in range(len(S)//2):
    for i in range(len(S_list) - 1):
        if S_list[i] != S_list[i + 1] and i not in rm_list:
            rm_list.append(i)
            rm_list.append(i + 1)
    S_list = [S_list[i] for i in range(len(S_list)) if i not in rm_list]
    ans += len(rm_list)
    rm_list = []
print(ans)

Fixed submission:
S = input()
a = sum([int(S[i]) for i in range(len(S))])
b = len(S) - a
print(2*min(a, b))