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

Ss = [list(map(int,input().split()))[1:] for _ in range(M)]
Ps = list(map(int,input().split()))

ans = 0
switch_pattern_num = 2**N

for i in range(switch_pattern_num):
    binary = format(i,'0%ib'%N)
    satisfied = True
    for j,S in enumerate(Ss):
        count = 0
        for e in S:
            if int(binary[e-1]):
                count += 1
        if count % 2 != Ps[j]:
            satisfied = False
    if satisfied:
        ans += 1
print(ans)


Fixed submission:

N, M = map(int,input().split())
LRs = [list(map(int,input().split())) for _ in range(M)]

current_L = 1
current_R = N
for L,R in LRs:
    if current_L < L:
        current_L = L
    if current_R > R:
        current_R = R


if current_R < current_L:
    print(0)
else:
	print(current_R-current_L+1)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq

N, M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]

heapq.heapify(A)


for i in range(M):
    c = 0
    while  c < BC[i][0]:
        value = heapq.heappop(A)
        if value > BC[i][1]:
            heapq.heappush(A,value)
            break
        else:
            heapq.heappush(A,BC[i][1])
        c += 1
print(sum(A))



Fixed submission:
from collections import defaultdict
N, M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]
X = []
D = defaultdict(int)

for a in A:
    D[a] += 1
for b,c in BC:
    D[c] += b
ans = 0
for e in sorted(D.keys(),reverse=True):
    if D[e] >= N:
        ans += e*N
        break
    else:
        ans += e*D[e]
        N -= D[e]
print(ans)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
import math
ans = 0.
for c in range(1,N+1):
    if c >= K:
        req = 0
    else:
        req = int(math.log2(K/c)) + 1
    ans += (1/N)*((1/2)**req)
print(ans)
    


Fixed submission:
N,K = map(int,input().split())
import math
ans = 0.
for c in range(1,N+1):
    if c >= K:
        req = 0
    else:
        req = math.log2(K/c)
        if req != int(req):
            req = int(req) + 1
        else:
            req = int(req)
    ans += (1/N)*((1/2)**req)
print(ans)
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()))

A.sort(reverse=True)
ans = []

BC_ans = []

for eb in B:
    for ec in C:
        BC_ans.append(eb+ec)
BC_ans.sort(reverse=True)
BC_ans = BC_ans[:K]
for ea in A[:K]:
    for ebc in BC_ans:
        ans.append(ea+ebc)
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])
    
    



Fixed submission:
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()))
A.sort(reverse=True)
ans = []
BC_ans = []
for eb in B:
    for ec in C:
        BC_ans.append(eb+ec)
BC_ans.sort(reverse=True)
BC_ans = BC_ans[:K]
for ea in A[:K]:
    for ebc in BC_ans:
        ans.append(ea+ebc)
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])

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()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
ans = []

BC_ans = []

for eb in B:
    for ec in C:
        BC_ans.append(eb+ec)
max_BC = max(BC_ans)
for ea in A:
    if len(ans):
        if max_BC+ea < min(ans):
            break
    for ebc in BC_ans:
        ans.append(ea+ebc)
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])
    
    



Fixed submission:
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()))
A.sort(reverse=True)
ans = []
BC_ans = []
for eb in B:
    for ec in C:
        BC_ans.append(eb+ec)
BC_ans.sort(reverse=True)
BC_ans = BC_ans[:K]
for ea in A[:K]:
    for ebc in BC_ans:
        ans.append(ea+ebc)
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
H = list(map(int,input().split()))
dp = [float('inf') for i in range(N)]
dp[0]=0
for i in range(N):
    for j in range(1,K+1):
        if i+j < N:
            dp[i+j]  = min(dp[i+j],dp[i]+abs(H[i]-H[i+j]))
print(dp[N-1])

Fixed submission:
N,K = map(int,input().split())
H = list(map(int,input().split()))
dp = [float('inf') for i in range(N)]
dp[0]=0
for i in range(N):
    for j in range(1,K+1):
        if i+j < N:
            dp[i+j]  = min(dp[i+j],dp[i]+abs(H[i]-H[i+j]))
print(dp[N-1])
Buggy python submission (verdict: Runtime Error):
N,W = map(int,input().split())
WV = []
for i in range(N):
    WV.append(list(map(int,input().split())))
dp = [[] for i in range(N)]
dp[0].append((0,0))
for i in range(N):
    if i == 0:
        dp[i].append((0,0))
        if W >= WV[i][0]:
            dp[i].append((WV[i][0],WV[i][1]))
    else:
        dp[i].append((e1,e2))
        for e1,e2 in dp[i-1]:
            if W >= e1+WV[i][0]:
                dp[i].append((e1+WV[i][0],e2+WV[i][1]))
ans = 0
for e1,e2 in dp[-1]:
    ans = max(e2,ans)
print(ans)

Fixed submission:
N,W = map(int,input().split())
WV = []
for i in range(N):
    WV.append(list(map(int,input().split())))
dp = [[float('inf') for j in range(100001)] for i in range(N)]
dp[0][0] = 0
for i in range(N):
    w,v = WV[i]
    if i == 0:
        dp[i][v] = w
    else:
        for j in range(100001):
            if j-v >= 0:
                dp[i][j] = min(dp[i-1][j-v]+w,dp[i-1][j])
            else:
                dp[i][j] = dp[i-1][j]

ans = 0
for i,e in enumerate(dp[-1]):
    if W >= e:
        ans = i
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,W = map(int,input().split())
WV = []
for i in range(N):
    WV.append(list(map(int,input().split())))
dp = [[] for i in range(N)]
dp[0].append((0,0))
for i in range(N):
    if i == 0:
        dp[i].append((0,0))
        if W >= WV[i][0]:
            dp[i].append((WV[i][0],WV[i][1]))
    else:
        for e1,e2 in dp[i-1]:
            dp[i].append((e1,e2))
            if W >= e1+WV[i][0]:
                dp[i].append((e1+WV[i][0],e2+WV[i][1]))
ans = 0
for e1,e2 in dp[-1]:
    ans = max(e2,ans)
print(ans)

Fixed submission:
N,W = map(int,input().split())
WV = []
for i in range(N):
    WV.append(list(map(int,input().split())))
dp = [[float('inf') for j in range(100001)] for i in range(N)]
dp[0][0] = 0
for i in range(N):
    w,v = WV[i]
    if i == 0:
        dp[i][v] = w
    else:
        for j in range(100001):
            if j-v >= 0:
                dp[i][j] = min(dp[i-1][j-v]+w,dp[i-1][j])
            else:
                dp[i][j] = dp[i-1][j]

ans = 0
for i,e in enumerate(dp[-1]):
    if W >= e:
        ans = i
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left
from collections import deque
N,M = map(int,input().split())
PY = []
S =[[] for _ in range(N)]

for i in range(M):
    PY.append(list(map(int,input().split())))
    S[PY[i][0]-1].insert(bisect_left(S[PY[i][0]-1],PY[i][1]),PY[i][1])

for i in range(M):
    x = bisect_left(S[PY[i][0]-1],PY[i][1])+1
    print(str(PY[i][0]).zfill(6)+str(x).zfill(6))







Fixed submission:
from bisect import bisect_left
from collections import deque
N,M = map(int,input().split())
PY = []
S =[[] for _ in range(N)]

for i in range(M):
    PY.append(list(map(int,input().split())))
    S[PY[i][0]-1].append(PY[i][1])

for i in range(N):
	S[i].sort()

for i in range(M):
    x = bisect_left(S[PY[i][0]-1],PY[i][1])+1
    print(str(PY[i][0]).zfill(6)+str(x).zfill(6))
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
if k % 2 == 1:
    print((n // k) ** 3)
else:
    print((n // k) ** 3 + ((n + k // 2) // k) ** 3)

Fixed submission:
N,K = map(int,input().split())
if K % 2 == 1:
    print((N // K) ** 3)
else:
    print((N // K) ** 3 + ((N + K // 2) // K) ** 3)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import sys
input = sys.stdin.readline
N,M,Q = map(int,input().split())
LR = []
matrix = np.zeros((N,N)).astype('int')
for i in range(M):
    l,r = map(int,input().split())
    matrix[l-1][r-1] += 1
cumsums = []
for i in range(N):
    c = [0]
    for e in matrix[i]:
        c.append(c[-1]+e)
    cumsums.append(c)
for i in range(Q):
    p,q = map(int,input().split())
    p,q = p-1,q-1
    ans = 0
    for j in range(p,q+1):
        ans += cumsums[j][q+1]-cumsums[j][p]
    print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
N,M,Q = map(int,input().split())
LR = []
matrix = [[0 for i in range(N+1)] for j in range(N+1)]
for i in range(M):
    l,r = map(int,input().split())
    matrix[l][r] += 1
for i in range(N+1):
    for j in range(N):
        matrix[i][j+1] += matrix[i][j]
for i in range(N+1):
    for j in range(N):
        matrix[j+1][i] += matrix[j][i]
for i in range(Q):
    p,q = map(int,input().split())
    ans = matrix[q][q]-matrix[q][p-1]-matrix[p-1][q]+matrix[p-1][p-1]
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,M,Q = map(int,input().split())
LR = []
matrix = np.zeros((N,N)).astype('int')
for i in range(M):
    l,r = map(int,input().split())
    matrix[l-1][r-1] += 1
cumsums = []
for i in range(N):
    c = [0]
    for e in matrix[i]:
        c.append(c[-1]+e)
    cumsums.append(c)
for i in range(Q):
    p,q = map(int,input().split())
    p,q = p-1,q-1
    ans = 0
    for j in range(p,q+1):
        ans += cumsums[j][q+1]-cumsums[j][p]
    print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
N,M,Q = map(int,input().split())
LR = []
matrix = [[0 for i in range(N+1)] for j in range(N+1)]
for i in range(M):
    l,r = map(int,input().split())
    matrix[l][r] += 1
for i in range(N+1):
    for j in range(N):
        matrix[i][j+1] += matrix[i][j]
for i in range(N+1):
    for j in range(N):
        matrix[j+1][i] += matrix[j][i]
for i in range(Q):
    p,q = map(int,input().split())
    ans = matrix[q][q]-matrix[q][p-1]-matrix[p-1][q]+matrix[p-1][p-1]
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,M,Q = map(int,input().split())
LR = []
matrix = np.zeros((N,N)).astype('int')
for i in range(M):
    l,r = map(int,input().split())
    matrix[l-1][r-1] += 1
for i in range(Q):
    p,q = map(int,input().split())
    print(np.sum(matrix[p-1:q,p-1:q]))

Fixed submission:
import sys
input = sys.stdin.readline
N,M,Q = map(int,input().split())
LR = []
matrix = [[0 for i in range(N+1)] for j in range(N+1)]
for i in range(M):
    l,r = map(int,input().split())
    matrix[l][r] += 1
for i in range(N+1):
    for j in range(N):
        matrix[i][j+1] += matrix[i][j]
for i in range(N+1):
    for j in range(N):
        matrix[j+1][i] += matrix[j][i]
for i in range(Q):
    p,q = map(int,input().split())
    ans = matrix[q][q]-matrix[q][p-1]-matrix[p-1][q]+matrix[p-1][p-1]
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,C = map(int,input().split())
D = []
for i in range(C):
    D.append(list(map(int,input().split())))
G = []
for i in range(N):
    G.append(list(map(int,input().split())))

X = [[] for i in range(3)]
for i in range(N):
    for j in range(N):
        X[(i+j+2)%3].append(G[i][j])
ans = float('inf')
for c1 in range(C):
    for c2 in range(C):
        if c1 == c2:
            continue
        for c3 in range(C):
            if c1 == c3 or c2 == c3:
                continue
            cost = 0
            for i,x in enumerate(X):
                for e in x:
                    if i == 0:
                        cost += D[e-1][c1]
                    elif i == 1:
                        cost += D[e-1][c2]
                    else:
                        cost += D[e-1][c3]
            ans = min(cost,ans)
print(ans)



Fixed submission:
N,C = map(int,input().split())
D = []
for i in range(C):
    D.append(list(map(int,input().split())))
G = []
for i in range(N):
    G.append(list(map(int,input().split())))

X = [[] for i in range(3)]
for i in range(N):
    for j in range(N):
        X[(i+j+2)%3].append(G[i][j])
ans = float('inf')

Costs = [[0 for i in range(C)] for j in range(3)]

for c in range(C):
    for i in range(3):
        for e in X[i]:
            Costs[i][c] += D[e-1][c]

for c1 in range(C):
    for c2 in range(C):
        if c1 == c2:
            continue
        for c3 in range(C):
            if c1 == c3 or c2 == c3:
                continue
            cost = 0
            for i,e in enumerate([c1,c2,c3]):
                cost += Costs[i][e]
            ans = min(cost,ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
from bisect import bisect_left
N = int(input())
X = list(map(int,input().split()))
Y = X.copy()
Y.sort()
for i in range(N):
    k = bisect_left(Y,X[i])
    if k < N//2:
        print(Y[N//2])
    else:
        print(Y[N//2-1])


Fixed submission:
from bisect import bisect_left
N = int(input())
X = list(map(int,input().split()))
Y = X.copy()
Y.sort()
for i in range(N):
    k = bisect_left(Y,X[i])
    if k < N//2:
        print(Y[N//2])
    else:
        print(Y[N//2-1])

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left
N = int(input())
X = list(map(int,input().split()))
subX = X[1:]
subX.sort()
for i in range(N-1):
    print(subX[N//2-1])
    k = bisect_left(subX,X[i])
    subX.insert(k,X[i])
    k = bisect_left(subX,X[i+1])
    subX.pop(k)
print(subX[N//2-1])


Fixed submission:
from bisect import bisect_left
N = int(input())
X = list(map(int,input().split()))
Y = X.copy()
Y.sort()
for i in range(N):
    k = bisect_left(Y,X[i])
    if k < N//2:
        print(Y[N//2])
    else:
        print(Y[N//2-1])
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
print((1900*M+100*(N-m))*2**M)


Fixed submission:
N,M = map(int,input().split())
print((1900*M+100*(N-M))*2**M)
Buggy python submission (verdict: Runtime Error):
N = int(input())
P = list(map(int,input().split()))
ans = 0
for i in range(N):
    if i+1 == P[i]:
        P[i],P[i+1] = P[i+1],P[i]
        ans += 1
print(ans)

Fixed submission:
N = int(input())
P = list(map(int,input().split()))
ans = 0
for i in range(N):
    if i+1 == P[i]:
        if i+1 == N:
            P[i],P[i-1] = P[i-1],P[i]
        else:
            P[i],P[i+1] = P[i+1],P[i]
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
from collections import defaultdict
D = defaultdict(int)
for e in A:
    D[e] += 1


l1 = []
l2 = []
for key,value in D.items():
    if value > 1:
        l1.append(key)
    if value > 3:
        l2.append(key)
if len(l1) < 2:
    print(0)
    exit()
l1.sort()
l2.sort()
print(max(l1[-1]*l1[-2],l2[-1]*l2[-1]))

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
from collections import defaultdict
D = defaultdict(int)
for e in A:
    D[e] += 1
l1 = []
l2 = []
for key,value in D.items():
    if value > 1:
        l1.append(key)
    if value > 3:
        l2.append(key)
if len(l1) < 2:
    print(0)
    exit()
l1.sort()
l2.sort()
if len(l2) > 0:
    print(max(l1[-1]*l1[-2],l2[-1]*l2[-1]))
else:
    print(l1[-1]*l1[-2])

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
from collections import defaultdict
D = defaultdict(int)
for e in A:
    D[e] += 1
possible_length = []
for key,value in D.items():
    if value > 1:
        possible_length.append(key)
if len(possible_length) < 2:
    print(0)
possible_length.sort()
print(possible_length[-1]*possible_length[-2])

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
from collections import defaultdict
D = defaultdict(int)
for e in A:
    D[e] += 1
l1 = []
l2 = []
for key,value in D.items():
    if value > 1:
        l1.append(key)
    if value > 3:
        l2.append(key)
if len(l1) < 2:
    print(0)
    exit()
l1.sort()
l2.sort()
if len(l2) > 0:
    print(max(l1[-1]*l1[-2],l2[-1]*l2[-1]))
else:
    print(l1[-1]*l1[-2])
Buggy python submission (verdict: Runtime Error):
N = int(input())
Edges = [[] for i in range(N)]
for i in range(N-1):
    a,b,c = map(int,input().split())
    a,b = a-1,b-1
    Edges[a].append((b,c))
    Edges[b].append((a,c))
D = [float('inf') for i in range(N)]
def dfs(v,p,d):
    D[v] = d
    for e1,e2 in Edges[v]:
        if e1 != p:
            dfs(e1,v,d+e2)
Q,K = map(int,input().split())
dfs(K-1,-1,0)
for i in range(Q):
    x,y = map(int,input().split())
    print(D[x-1]+D[y-1])

Fixed submission:
import sys
sys.setrecursionlimit(10**9)
N = int(input())
Edges = [[] for i in range(N)]
for i in range(N-1):
    a,b,c = map(int,input().split())
    a,b = a-1,b-1
    Edges[a].append((b,c))
    Edges[b].append((a,c))
D = [float('inf') for i in range(N)]
def dfs(v,p,d):
    D[v] = d
    for e1,e2 in Edges[v]:
        if e1 != p:
            dfs(e1,v,d+e2)
Q,K = map(int,input().split())
dfs(K-1,-1,0)
for i in range(Q):
    x,y = map(int,input().split())
    print(D[x-1]+D[y-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
B = [-10000 for i in range(N)]
for i in range(N):
    if (N-i)%2 != 0:#from front
        index = (N-i)//2
        B[index] = A[i]
    else:# from backward
        index = N - (N-i)//2
        B[index] = A[i]
ans = ''
for e in B:
    ans += str(e)+' '
print(ans[:-1])

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = [-10000 for i in range(N)]
for i in range(N):
    if (N-i)%2 != 0:#from front
        index = (N-i)//2
        B[index] = A[i]
    else:# from backward
        index = N - (N-i)//2
        B[index] = A[i]
ans = ''
for e in B:
    ans += str(e)+' '
print(ans[:-1])

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = [-10000 for i in range(N)]
for i in range(N):
    if (N-i)%2 != 0:#from front
        index = (N-i)//2
        B[index] = A[i]
    else:# from backward
        index = N - (N-i)//2
        B[index] = A[i]
print(" ".join(B))

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = [-10000 for i in range(N)]
for i in range(N):
    if (N-i)%2 != 0:#from front
        index = (N-i)//2
        B[index] = A[i]
    else:# from backward
        index = N - (N-i)//2
        B[index] = A[i]
ans = ''
for e in B:
    ans += str(e)+' '
print(ans[:-1])
Buggy python submission (verdict: Time Limit Exceeded):
k,s = input().split(' ')
k,s = int(k),int(s)


count = 0
for i in range(k+1):
	if i > s:
		break
	for j in range(k+1):
		if i+j > s:
			break
		z = s - (i+j)
		if z <= k and z >= 0:
			count += 1

print(count)

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


count = 0
for i in range(k+1):
	for j in range(k+1):
		z = s - (i+j)
		if z <= k and z >= 0:
			count += 1
print(count)

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


count = 0
for i in range(k+1):
	if i > s:
		break
	for j in range(k+1):
		if i+j > s:
			break
		for l in range(k+1):
			x = i+j+l
			if s == x:
				count += 1

print(count)

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


count = 0
for i in range(k+1):
	for j in range(k+1):
		z = s - (i+j)
		if z <= k and z >= 0:
			count += 1
print(count)

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


count = 0
for i in range(k+1):
	for j in range(k+1):
		for l in range(k+1):
			x = i+j+l
			if s == x:
				count += 1

print(count)

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


count = 0
for i in range(k+1):
	for j in range(k+1):
		z = s - (i+j)
		if z <= k and z >= 0:
			count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
N,A = map(int,input().split())
X = list(map(int,input().split()))
ans = 0

def make_array(dims,fill):
    if len(dims) == 1:
        return [fill]*dims[0]
    ret = []
    nxt = dims[1:]
    for i in range(dims[0]):
        ret.append(make_array(nxt,fill))
    return ret
S = sum(X)+1
dp = make_array([N+2,N+2,S],0)
dp[0][0][0] = 1
for i in range(N):
    for j in range(N):
        for s in range(S-X[i]):
            dp[i+1][j+1][s+X[i]] += dp[i][j][s]
            dp[i+1][j][s] += dp[i][j][s]
ans = 0
for j in range(1,N+1):
    for s in range(1,S+1):
        if j*A == s:
            ans += dp[-2][j][s]
print(ans)

Fixed submission:
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

if N < K:
    print(N*X)
else:
    print(K*X+(N-K)*Y)
Buggy python submission (verdict: Time Limit Exceeded):
N,A = map(int,input().split())
X = list(map(int,input().split()))
ans = 0

def make_array(dims,fill):
    if len(dims) == 1:
        return [fill]*dims[0]
    ret = []
    nxt = dims[1:]
    for i in range(dims[0]):
        ret.append(make_array(nxt,fill))
    return ret
S = sum(X)+1
dp = make_array([N+2,N+2,S],0)
dp[0][0][0] = 1
for i in range(N):
    for j in range(N):
        for s in range(S-X[i]):
            dp[i+1][j+1][s+X[i]] += dp[i][j][s]
            dp[i+1][j][s] += dp[i][j][s]
ans = 0
for j in range(1,N+1):
    for s in range(1,S+1):
        if j*A == s:
            ans += dp[-2][j][s]
print(ans)

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

def make_array(dims,fill):
    if len(dims) == 1:
        return [fill]*dims[0]
    ret = []
    nxt = dims[1:]
    for i in range(dims[0]):
        ret.append(make_array(nxt,fill))
    return ret
S = sum(X)+1
dp = make_array([N+2,N+2,S],0)
dp[0][0][0] = 1
for i in range(N):
    for j in range(N):
        for s in range(S-X[i]):
            dp[i+1][j+1][s+X[i]] += dp[i][j][s]
            dp[i+1][j][s] += dp[i][j][s]
ans = 0
for j in range(1,N+1):
    for s in range(1,S+1):
        if j*A == s:
            ans += dp[-2][j][s]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,A = map(int,input().split())
X = list(map(int,input().split()))
ans = 0
for i in range(1,2**N):
    state = format(i,'0%ib'%(N))
    value = 0
    count = 0
    for j,s in enumerate(state):
        if s == '1':
            value += X[j]
            count += 1
    if value == A*count:
        ans += 1
print(ans)

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

def make_array(dims,fill):
    if len(dims) == 1:
        return [fill]*dims[0]
    ret = []
    nxt = dims[1:]
    for i in range(dims[0]):
        ret.append(make_array(nxt,fill))
    return ret
S = sum(X)+1
dp = make_array([N+2,N+2,S],0)
dp[0][0][0] = 1
for i in range(N):
    for j in range(N):
        for s in range(S-X[i]):
            dp[i+1][j+1][s+X[i]] += dp[i][j][s]
            dp[i+1][j][s] += dp[i][j][s]
ans = 0
for j in range(1,N+1):
    for s in range(1,S+1):
        if j*A == s:
            ans += dp[-2][j][s]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
H=list(map(int,input().split()))
H.sort(reverse=True)
for i in range(K):
    if len(H)==0:
        break
    H.pop(0)
print(sum(H))

Fixed submission:
N,K=map(int,input().split())
H=list(map(int,input().split()))
H.sort(reverse=True)
print(sum(H[K:]))
Buggy python submission (verdict: Runtime Error):
N,X=list(map(int,input().split()))
L=list(map(int,input().split()))
cnt=1
d=0
for i in L:
    d+=L[i]
    if d<=X:
        cnt+=1

print(cnt)

Fixed submission:
N,X=list(map(int,input().split()))
L=list(map(int,input().split()))
cnt=1
d=0
for i in L:
    d+=i
    if d<=X:
        cnt+=1

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,k=list(map(int,input().split()))
l=[]
v=[]
for i in range(a,b+1):
    l.append(i)
for i in range(k):
    if i>=len(l):
        break
    v.append(l[i])
l.reverse()
for i in range(k-1,-1,-1):
    if i>=len(l):
        continue
    v.append(l[i])
s=set(v)
l=list(s)
l.sort()
for i in l:
    print(i)

Fixed submission:
A,B,K=list(map(int,input().split()))
L=[]
k=0
for i in range(A,B+1):
    L.append(i)
    k+=1
    if(k>=K):
        break

k=0
for i in range(B,A-1,-1):
    L.append(i)
    k+=1
    if(k>=K):
        break

S=set(L)
for s in sorted(list(S)):
    print(s)