Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from math import ceil
N, K = map(int,input().split())
A = list(map(int,input().split()))
def chk(L):
    cnt = 0
    for i in range(N):
        cnt += ceil(A[i]/L)-1
    return cnt <= K
l, r = 1, max(A)
while l <= r:
    m = (l+r)//2
    if chk(m):
        r = m-1
    else:
        l = m+1
print(max([x for x in [m-1,m,m+1] if chk(x)]))

Fixed submission:
from math import ceil
N, K = map(int,input().split())
A = list(map(int,input().split()))
def chk(L):
    cnt = 0
    for i in range(N):
        cnt += ceil(A[i]/L)-1
    return cnt <= K
l, r = 1, max(A)
while l <= r:
    m = (l+r)//2
    if chk(m):
        r = m-1
    else:
        l = m+1
print(min([x for x in [m-1,m,m+1] if x > 0 and chk(x)]))

Buggy python submission (verdict: Runtime Error):
from math import ceil
N, K = map(int,input().split())
A = list(map(int,input().split()))
def chk(L):
    cnt = 0
    for i in range(N):
        cnt += ceil(A[i]/L)-1
    return cnt <= K
l, r = 1, max(A)
while l <= r:
    m = (l+r)//2
    if chk(m):
        r = m-1
    else:
        l = m+1
print(max([x for x in [l-1, l, l+1, r-1,r,r+1, m-1,m,m+1] if chk(x)]))

Fixed submission:
from math import ceil
N, K = map(int,input().split())
A = list(map(int,input().split()))
def chk(L):
    cnt = 0
    for i in range(N):
        cnt += ceil(A[i]/L)-1
    return cnt <= K
l, r = 1, max(A)
while l <= r:
    m = (l+r)//2
    if chk(m):
        r = m-1
    else:
        l = m+1
print(min([x for x in [m-1,m,m+1] if x > 0 and chk(x)]))

Buggy python submission (verdict: Runtime Error):
from math import ceil
N, K = map(int,input().split())
A = list(map(int,input().split()))
def chk(L):
    cnt = 0
    for i in range(N):
        cnt += ceil(A[i]/L)-1
    return cnt <= K
l, r = 1, max(A)
while l <= r:
    m = (l+r)//2
    if chk(m):
        r = m-1
    else:
        l = m+1
print(max([x for x in [l, r, m-1,m,m] if chk(x)]))

Fixed submission:
from math import ceil
N, K = map(int,input().split())
A = list(map(int,input().split()))
def chk(L):
    cnt = 0
    for i in range(N):
        cnt += ceil(A[i]/L)-1
    return cnt <= K
l, r = 1, max(A)
while l <= r:
    m = (l+r)//2
    if chk(m):
        r = m-1
    else:
        l = m+1
print(min([x for x in [m-1,m,m+1] if x > 0 and chk(x)]))

Buggy python submission (verdict: Runtime Error):
from math import ceil
N, K = map(int,input().split())
A = list(map(int,input().split()))
def chk(L):
    cnt = 0
    for i in range(N):
        cnt += ceil(A[i]/L)-1
    return cnt <= K
l, r = 1, max(A)
while l <= r:
    m = (l+r)//2
    if chk(m):
        r = m-1
    else:
        l = m+1
print(max([x for x in [m-1,m,m] if chk(x)]))

Fixed submission:
from math import ceil
N, K = map(int,input().split())
A = list(map(int,input().split()))
def chk(L):
    cnt = 0
    for i in range(N):
        cnt += ceil(A[i]/L)-1
    return cnt <= K
l, r = 1, max(A)
while l <= r:
    m = (l+r)//2
    if chk(m):
        r = m-1
    else:
        l = m+1
print(min([x for x in [m-1,m,m+1] if x > 0 and chk(x)]))
Buggy python submission (verdict: Runtime Error):
C = []
A = []
for _ in range(N):
    l = list(map(int,input().split()))
    C.append(l[0])
    A.append(np.array(l[1:]))
ans = 10**100
for i in range(2**N):
    rikaido = np.zeros(M)
    c = 0
    for j in range(N):
        if (i >> j) & 1:
            c += C[j]
            rikaido += A[j]
    if all([x >= X for x in rikaido]):
        ans = min(ans, c)
print(ans if ans != 10**100 else -1)

Fixed submission:
import numpy as np
N,M,X = map(int,input().split())
C = []
A = []
for _ in range(N):
    l = list(map(int,input().split()))
    C.append(l[0])
    A.append(np.array(l[1:]))
ans = 10**100
for i in range(2**N):
    rikaido = np.zeros(M)
    c = 0
    for j in range(N):
        if (i >> j) & 1:
            c += C[j]
            rikaido += A[j]
    if all([x >= X for x in rikaido]):
        ans = min(ans, c)
print(ans if ans != 10**100 else -1)
Buggy python submission (verdict: Runtime Error):
use proconio::input;
use proconio::marker::Usize1;
use itertools::Itertools;
use std::cmp::max;
fn main() {
    input! {
        n:usize,m:usize,q:usize,
        qs: [(Usize1, Usize1, usize, usize); q]
    };
    let mut ans = 0;
    for A in (1..m+1).combinations_with_replacement(n) {
        let mut sm = 0;
        for &(a,b,c,d) in &qs {
            if A[b]-A[a] == c {
                sm += d;
            }
        }
        ans = max(ans, sm);
    }
    println!("{}", ans);
}

Fixed submission:
from itertools import combinations_with_replacement
N, M, Q = map(int,input().split())
ls = []
for _ in range(Q):
    a,b,c,d = map(int,input().split())
    ls.append((a-1,b-1,c,d))
ans = -1
for A in combinations_with_replacement(range(1,M+1),r=N):
    sm = 0
    for a,b,c,d in ls:
        if A[b]-A[a] == c:
            sm += d
    ans = max(ans, sm)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
R = [0]*(N+1)
G = [0]*(N+1)
B = [0]*(N+1)
for i in range(N-1, -1, -1):
    R[i] = R[i+1]+1 if S[i] == "R" else R[i+1]
    G[i] = G[i+1]+1 if S[i] == "G" else G[i+1]
    B[i] = B[i+1]+1 if S[i] == "B" else B[i+1]
ans = 0
for i in range(N):
    for j in range(i+1, N):
        if S[i] != S[j]:
            c = ["R","G","B"]
            c.remove(S[i])
            c.remove(S[j])
            c = c[0]
            if c == "R":
                ans += R[j+1]
                if 2*j-i < N and S[2*j-i] == "R":
                    ans -= 1
            if c == "G":
                ans += G[j+1]
                if 2*j-i < N and S[2*j-i] == "G":
                    ans -= 1
            if c == "B":
                ans += B[j+1]
                if 2*j-i < N and S[2*j-i] == "B":
                    ans -= 1
print(ans)

Fixed submission:
N = int(input())
S = input()
R = [0]*(N+1)
G = [0]*(N+1)
B = [0]*(N+1)
for i in range(N-1, -1, -1):
    R[i] = R[i+1]+1 if S[i] == "R" else R[i+1]
    G[i] = G[i+1]+1 if S[i] == "G" else G[i+1]
    B[i] = B[i+1]+1 if S[i] == "B" else B[i+1]
ans = 0
for i in range(N):
    for j in range(i+1, N):
        if S[i] != S[j]:
            c = ["R","G","B"]
            c.remove(S[i])
            c.remove(S[j])
            c = c[0]
            if c == "R":
                ans += R[j+1]
                if 2*j-i < N and S[2*j-i] == "R":
                    ans -= 1
            if c == "G":
                ans += G[j+1]
                if 2*j-i < N and S[2*j-i] == "G":
                    ans -= 1
            if c == "B":
                ans += B[j+1]
                if 2*j-i < N and S[2*j-i] == "B":
                    ans -= 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
H,N = map(int,input().split())
AB = [tuple(map(int,input().split())) for _ in range(N)]
INF = float("inf")
dp0 = [INF]*(H+1)
dp1 = [INF]*(H+1)
dp0[0] = 0
for i in range(N):
    a,b = AB[i]
    dp1[H] = dp0[H]
    for h in range(H-1, -1, -1):
        dp1[h] = min(dp0[h], dp1[h+1])
    assert dp1[0] == 0
    for h in range(H+1):
        dp1[h] = min(dp1[h], dp1[max(h-a,0)]+b)
    t = dp1
    dp1 = dp0
    dp0 = t
print(dp0[H])

Fixed submission:
H,N = map(int,input().split())
AB = [tuple(map(int,input().split())) for _ in range(N)]
INF = float("inf")
dp0 = [INF]*(H+1)
dp1 = [0]*(H+1)
dp0[0] = 0
for i in range(N):
    a,b = AB[i]
    dp1[H] = dp0[H]
    for h in range(H-1, -1, -1):
        dp1[h] = min(dp0[h], dp1[h+1])
    for h in range(H+1):
        dp1[h] = min(dp1[h], dp1[max(h-a,0)]+b)
    t = dp1
    dp1 = dp0
    dp0 = t
print(dp0[H])
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
print("Yes" N==M else "No")

Fixed submission:
a,b = map(int,input().split())
print("Yes" if a==b else "No")
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
N = len(S)
mod = 10**9+7
dp = [[0]*13 for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
    if S[i] == "?":
        for d in range(10):
            for k in range(13):
                dp[i+1][(k*10+d)%13] = (dp[i+1][(k*10+d)%13]+dp[i][k])%mod
    else:
        d = int(S[i])
        for k in range(13):
            dp[i+1][(k*10+d)%13] = (dp[i+1][(k*10+d)%13]+dp[i][k])%mod
print(dp[N][5]%mod)

Fixed submission:
S = input()
N = len(S)
mod = 10**9+7
dp = [[0]*13 for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
    if S[i] == "?":
        for d in range(10):
            for k in range(13):
                dp[i+1][(k*10+d)%13] = (dp[i+1][(k*10+d)%13]+dp[i][k])%mod
    else:
        d = int(S[i])
        for k in range(13):
            dp[i+1][(k*10+d)%13] = (dp[i+1][(k*10+d)%13]+dp[i][k])%mod
print(dp[N][5]%mod)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
N = len(S)
dp = [[0]*13 for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
    if S[i] == "?":
        for d in range(10):
            for k in range(13):
                dp[i+1][(k*10+d)%13] += dp[i][k]
    else:
        d = int(S[i])
        for k in range(13):
            dp[i+1][(k*10+d)%13] += dp[i][k]
print(dp[N][5]%(10**9+7))


Fixed submission:
S = input()
N = len(S)
mod = 10**9+7
dp = [[0]*13 for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
    if S[i] == "?":
        for d in range(10):
            for k in range(13):
                dp[i+1][(k*10+d)%13] = (dp[i+1][(k*10+d)%13]+dp[i][k])%mod
    else:
        d = int(S[i])
        for k in range(13):
            dp[i+1][(k*10+d)%13] = (dp[i+1][(k*10+d)%13]+dp[i][k])%mod
print(dp[N][5]%mod)
Buggy python submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input().split()))
box=[0]*N
for i in range(N, 0,-1):
    sm = 0
    for j in range(i, N+1, i):
        sm += box[j-1]
    print(i, sm)
    box[i-1] = (sm % 2) ^ a[i-1]
print(sum(box))
print(*sum)

Fixed submission:
N = int(input())
a = [0]+list(map(int,input().split()))
ls = [0]*(N+1)
for i in range(N, 0, -1):
    sm = 0
    for j in range(i, N+1, i):
        sm += ls[j]
    ls[i] = (sm % 2) ^ a[i]
b = [i for i in range(N+1) if ls[i] == 1]
print(len(b))
print(*b)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
edges = [[] for _ in range(N)]
used = [False]*N
mod = 10**9+7
for _ in range(N-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)
def f(n,c):
    sm = 1
    t = K-c
    for m in edges[n]:
        if not used[m]:
            used[m] = True
            if t <= 0:
                print(0)
                exit(0)
            sm = (sm*f(m,2)*t) % mod
            t -= 1
    return sm
used[0] = True
print(K*f(0,1) % mod)

Fixed submission:
import sys
sys.setrecursionlimit(10**9)
N,K = map(int,input().split())
edges = [[] for _ in range(N)]
used = [False]*N
mod = 10**9+7
for _ in range(N-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)
def f(n,c):
    sm = 1
    t = K-c
    for m in edges[n]:
        if not used[m]:
            used[m] = True
            if t <= 0:
                print(0)
                exit(0)
            sm = (sm*f(m,2)*t) % mod
            t -= 1
    return sm
used[0] = True
print(K*f(0,1) % mod)
Buggy python submission (verdict: Runtime Error):
N, K = map(int,input().split())
def comb(n,k):
    if n == 0:
        return 1
    if n < 0:
        return 0
    if k < 0:
        return 0
    if k == 0:
        return 1
    return comb(n-1,k-1) * n // k
R = N-K
MOD = 10**9+7
A = K-1
B = R-1
if N == K:
    print(1)
    for i in range(2, K+1):
        print(0)
else:
    for i in range(1, K+1):
        x = comb(A, i-1)
        y = comb(B, i-2)
        z = comb(B, i-1)
        w = comb(B, i)
        ans = x*(y+2*z+w)
        print(ans % MOD)

Fixed submission:
import sys
sys.setrecursionlimit(3000)
N, K = map(int,input().split())
def comb(n,k):
    if n == 0:
        return 1
    if n < 0:
        return 0
    if k < 0:
        return 0
    if k == 0:
        return 1
    return comb(n-1,k-1) * n // k
R = N-K
MOD = 10**9+7
A = K-1
B = R-1
if N == K:
    print(1)
    for i in range(2, K+1):
        print(0)
else:
    for i in range(1, K+1):
        x = comb(A, i-1)
        y = comb(B, i-2)
        z = comb(B, i-1)
        w = comb(B, i)
        ans = x*(y+2*z+w)
        print(ans % MOD)

Buggy python submission (verdict: Runtime Error):
N, K = map(int,input().split())
def comb(n,k):
    if k < 0:
        return 0
    if k == 0:
        return 1
    return comb(n-1,k-1) * n // k
R = N-K
MOD = 10**9+7
A = K-1
B = R-1
for i in range(1, K+1):
    x = comb(A, i-1)
    y = comb(B, i-2)
    z = comb(B, i-1)
    w = comb(B, i)
    ans = x*(y+2*z+w)
    print(ans % MOD)

Fixed submission:
import sys
sys.setrecursionlimit(3000)
N, K = map(int,input().split())
def comb(n,k):
    if n == 0:
        return 1
    if n < 0:
        return 0
    if k < 0:
        return 0
    if k == 0:
        return 1
    return comb(n-1,k-1) * n // k
R = N-K
MOD = 10**9+7
A = K-1
B = R-1
if N == K:
    print(1)
    for i in range(2, K+1):
        print(0)
else:
    for i in range(1, K+1):
        x = comb(A, i-1)
        y = comb(B, i-2)
        z = comb(B, i-1)
        w = comb(B, i)
        ans = x*(y+2*z+w)
        print(ans % MOD)
Buggy python submission (verdict: Runtime Error):
import heapq as pq
from collections import deque
from itertools import accumulate
N,K = map(int,input().split())
v = list(map(int,input().split()))
acc = [0]+list(accumulate(v,lambda x,y: x+y))
anss = -1
for k in range(K+1):
    for i in range(k+1):
        ans = 0
        ls = deque(v)
        heap = []
        j = k-i
        ans += acc[i]+acc[-1]-acc[-1-j]
        for q in range(i):
            if ls:
                pq.heappush(heap,ls.popleft())
            else:
                break
        for q in range(j):
            if ls:
                pq.heappush(heap,ls.pop())
            else:
                break
        for i in range(K-k):
            if heap:
                x = pq.heappop(heap)
                if x < 0:
                    ans -= x
                else:
                    break
        anss = max(ans,anss)
print(anss)

Fixed submission:
import heapq as pq
from collections import deque
from itertools import accumulate
N,K = map(int,input().split())
v = list(map(int,input().split()))
acc = [0]+list(accumulate(v,lambda x,y: x+y))
anss = -1
M = min(K,N)
for k in range(M+1):
    for i in range(k+1):
        ans = 0
        ls = deque(v)
        heap = []
        j = k-i
        ans += acc[i]+acc[-1]-acc[-1-j]
        for q in range(i):
            if ls:
                pq.heappush(heap,ls.popleft())
            else:
                break
        for q in range(j):
            if ls:
                pq.heappush(heap,ls.pop())
            else:
                break
        for i in range(K-k):
            if heap:
                x = pq.heappop(heap)
                if x < 0:
                    ans -= x
                else:
                    break
        anss = max(ans,anss)
print(anss)
Buggy python submission (verdict: Time Limit Exceeded):
class SegmentTree(object):
    def __init__(self, size, op, id):
        s = 1
        while s < size:
            s *= 2
        self.num_leaves = s
        self.nodes = [id]*(2*s-1)
        self.op = op
        self.id = id
    def update(self, i, x):
        i += self.num_leaves - 1
        self.nodes[i] = x
        while i > 0:
            i = (i-1)//2
            self.nodes[i] = self.op(self.nodes[2*i+1], self.nodes[2*i+2])
    def query(self, l, r):
        l += self.num_leaves-1
        r += self.num_leaves-1
        res = self.id
        while l < r:
            if l&1==0:
                res = self.op(res, self.nodes[l])
            if r&1==0:
                r -= 1
                res = self.op(res, self.nodes[r])
            l >>= 1
            r >>= 1
        return res
INF = -float("inf")
def gcd(x,y):
    if x == INF:
        return y
    if y == INF:
        return x
    if x<y:
        x,y = y,x
    r = (x%y)
    while r:
        x,y = y, r
        r = (x%y)
    return y
    
N = int(input())
A = list(map(int,input().split()))
seg = SegmentTree(N, gcd, INF)
for i in range(N):
    seg.update(i, A[i])
ans = INF
for i in range(N):
    ans = max(gcd(seg.query(0,i), seg.query(i+1, N)), ans)
print(ans)


Fixed submission:
INF = -float("inf")
def gcd(x,y):
    if x == INF:
        return y
    if y == INF:
        return x
    if x<y:
        x,y = y,x
    r = (x%y)
    while r:
        x,y = y, r
        r = (x%y)
    return y
    
N = int(input())
A = list(map(int,input().split()))
lgcd = [INF]*N
rgcd = [INF]*N
lgcd[0] = A[0]
rgcd[0] = A[-1]
for i in range(1,N):
    lgcd[i] = gcd(lgcd[i-1], A[i])
    rgcd[i] = gcd(rgcd[i-1], A[N-i-1])
lgcd = [INF]+lgcd
rgcd = [INF]+rgcd
ans = INF
for i in range(N):
    ans = max(ans, gcd(lgcd[i],rgcd[N-i-1]))
print(ans)
Buggy python submission (verdict: Runtime Error):
def f(s):
    if s == "":
        return []
    if s[0] == "1": 
        if "0" in s:
            i = s.index("0")
            return [len(s[:i])]+f(s[i:])
        else:
            return [len(s)]
    else:
        if "1" in s:
            i = s.index("1")
            return [-len(s[:i])]+f(s[i:])
        else:
            return [-len(s)]
from itertools import accumulate
N,K = map(int,input().split())
S = input()
ls = f(S)
inds = []
for i in range(len(ls)):
    if ls[i] < 0:
        inds.append(i)
acc1 = [0]+list(accumulate(ls, lambda x,y:max(x,0)+max(0,y)))
if acc1[1] < 0:
    acc1[1] *= -1
acc2 = [0]+list(accumulate([-ls[i] for i in inds], lambda x,y:x+y))
ans = max(ls)

for i in range(len(inds)-K+1):
    #print(acc2[i+K]-acc2[i], acc1[min(inds[i+K-1]+2, len(acc1)-1)],acc1[max(inds[i]-1,0)])
    ans = max(acc2[i+K]-acc2[i]+acc1[min(inds[i+K-1]+2, len(acc1)-1)]-acc1[max(inds[i]-1,0)], ans)
print(ans)

Fixed submission:
N,K = map(int,input().split())
s = input()
ls = []
i = 0
c = 0
while i < N and s[i] == "1":
    c += 1
    i += 1
if i==N:
    print(N)
    exit()
while i < N:
    l = c
    c = 0
    while i < N and s[i] == "0":
        c += 1
        i += 1
    m = c
    c = 0
    while i < N and s[i] == "1":
        c += 1
        i += 1
    r = c
    ls.append((l,m,r))
K = min(K, len(ls))
from itertools import accumulate
acc = list(accumulate([0]+ls, lambda x,y:x+y[1]+y[2]))
ans = 0
for i in range(len(ls)-K+1):
    ans = max(ans, acc[i+K]-acc[i]+ls[i][0])
print(ans)
Buggy python submission (verdict: Runtime Error):
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
abc = [(-(A[0]+B[0]+C[0]), 0,0,0)]
used = set((0,0,0))
while K > 0:
    K -= 1
    p,i,j,k = hq.heappop(abc)
    print(-p)
    for a,b,c in [(i+1,j,k), (i,j+1,k), (i,j,k+1)]:
        if a < x and b < y and c < z and (a,b,c) not in used:
            used.add((a,b,c))
            hq.heappush(abc, (-(A[a]+B[b]+C[c]), a,b,c))


Fixed submission:
import heapq as hq
x,y,z,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ab = []
for a in A:
    for b in B:
        hq.heappush(ab, -a-b)
abc = []
cnt = 0
while cnt < k and ab:
    cnt += 1
    a = hq.heappop(ab)
    for b in C:
        hq.heappush(abc, a-b)
cnt = 0
while cnt < k:
    print(-hq.heappop(abc))
    cnt += 1

Buggy python submission (verdict: Time Limit Exceeded):
x,y,z,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ab = list()
for a in A:
    for b in B:
        ab.append(a+b)
ab.sort(reverse=True)
C.sort(reverse=True)
abc = []
for a in ab[:k]:
    for b in C:
        abc.append(a+b)
abc.sort(reverse=True)
print(*abc[:k], sep="\n")

Fixed submission:
import heapq as hq
x,y,z,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ab = []
for a in A:
    for b in B:
        hq.heappush(ab, -a-b)
abc = []
cnt = 0
while cnt < k and ab:
    cnt += 1
    a = hq.heappop(ab)
    for b in C:
        hq.heappush(abc, a-b)
cnt = 0
while cnt < k:
    print(-hq.heappop(abc))
    cnt += 1

Buggy python submission (verdict: Runtime Error):
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ab = list()
for a in A:
    for b in B:
        ab.append(a+b)
ab.sort(reverse=True)
C.sort(reverse=True)
i = 0
cnt = 0
abc = []
for a in ab[:k]:
    for b in C:
        abc.append(a+b)
abc.sort(reverse=True)
print(*abc[:k], sep="\n")

Fixed submission:
import heapq as hq
x,y,z,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ab = []
for a in A:
    for b in B:
        hq.heappush(ab, -a-b)
abc = []
cnt = 0
while cnt < k and ab:
    cnt += 1
    a = hq.heappop(ab)
    for b in C:
        hq.heappush(abc, a-b)
cnt = 0
while cnt < k:
    print(-hq.heappop(abc))
    cnt += 1
Buggy python submission (verdict: Runtime Error):
import numpy as np
N,K = map(int,input().split())
A = list(map(int,input().split()))
MAXBITS = 40
bits = np.ndarray((N, MAXBITS), dtype=int)
for i in range(N):
    a = A[i]
    bits[i] = np.array([(a >> j) & 1 for j in range(MAXBITS-1, -1, -1)])
sm = bits[0]
for b in bits[1:]:
    sm += b
lower = False
Kbits = np.array([(K >> j) & 1 for j in range(MAXBITS-1, -1, -1)])
ans = 0
for i in range(MAXBITS):
    ones = sm[i]
    zeros = N-sm[i]
    base = 2**(MAXBITS-i-1)
    if ones >= zeros:
        b = 0
    elif lower or Kbits[i] == 1:
        b = 1
    if Kbits[i] > b:
        lower = True
    ans += ones*base if b == 0 else zeros*base
print(ans)


Fixed submission:
import numpy as np
N,K = map(int,input().split())
A = list(map(int,input().split()))
MAXBITS = 40
bits = np.ndarray((N, MAXBITS), dtype=int)
for i in range(N):
    a = A[i]
    bits[i] = np.array([(a >> j) & 1 for j in range(MAXBITS-1, -1, -1)])
sm = bits[0]
for b in bits[1:]:
    sm += b
lower = False
Kbits = np.array([(K >> j) & 1 for j in range(MAXBITS-1, -1, -1)])
ans = 0
for i in range(MAXBITS):
    ones = sm[i]
    zeros = N-sm[i]
    base = 2**(MAXBITS-i-1)
    bit = 0
    if ones >= zeros:
        bit = 0
    elif lower or Kbits[i] == 1:
        bit = 1
    if Kbits[i] > bit:
        lower = True
    ans += ones*base if bit == 0 else zeros*base
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
n = int(input())
v = list(map(int,input().split()))
a = v[::2]
b = v[1::2]
def calc(l):
    d = defaultdict(int)
    for x in l:
        d[x] += 1
    return sorted([(d[x], x) for x in d],reverse=True)
A = calc(a)
B = calc(b)
al,ax = A[0]
bl,bx = B[0]
if ax != bx:
    print(n-al-bl)
else:
    ar,ay = A[1] if len(A) > 1 else 0,None
    br,by = B[1] if len(B) > 1 else 0,None
    print(min(n-al-br,n-ar-bl))

Fixed submission:
from collections import defaultdict
n = int(input())
v = list(map(int,input().split()))
a = v[::2]
b = v[1::2]
def calc(l):
    d = defaultdict(int)
    for x in l:
        d[x] += 1
    return sorted([(d[x], x) for x in d],reverse=True)
A = calc(a)
B = calc(b)
al,ax = A[0]
bl,bx = B[0]
if ax != bx:
    print(n-al-bl)
else:
    ar,ay = A[1] if len(A) > 1 else (0,None)
    br,by = B[1] if len(B) > 1 else (0,None)
    print(min(n-al-br,n-ar-bl))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
s = input()
t = input()
d = defaultdict(set)
e = defaultdict(set)
for i in range(len(s)):
    d[s[i]].add(i)
    e[t[i]].add(i)
ans = True
for i in range(len(s)):
    if e[t[i]] != d[s[i]]:
        ans = False
print("Yes" if ans else "No")

Fixed submission:
from collections import defaultdict
s = input()
t = input()
d = defaultdict(str)
e = defaultdict(str)
for i in range(len(s)):
    c1,c2 = s[i],t[i]
    if d[c1] == "":
        d[c1] = c2
    elif d[c1] != c2:
        print("No")
        exit(0)
    if e[c2] == "":
        e[c2] = c1
    elif e[c2] != c1:
        print("No")
        exit(0)
print("Yes")
Buggy python submission (verdict: Runtime Error):
ｔd,n = map(int,input().split())
print(n*100**d)

Fixed submission:
d,n = map(int,input().split())
print(n*100**d if n < 100 else 101*100**d)