Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

# D - Powerful Discount Tickets

def power(price, ticket_count):
    return int(price // (2 ** ticket_count))

# n: 商品数
# m: チケットの枚数
n, m = map(int, input().split())
data = list(map(int, input().split()))

ans = 0

for i in range(m):
    max_point = data.index( max(data) )
    data[max_point] = power(data[max_point], 1)

print(sum(data))


### FIXED CODE ###

# D - Powerful Discount Tickets
import heapq

n, m = map(int, input().split())
data = list(map(int, input().split()))

pq = []

for i in data:
    heapq.heappush(pq, -i)

for _ in range(m):
    # 先頭の "最小値"
    p = heapq.heappop(pq)
    heapq.heappush(pq, -(-p // 2))

print(-sum(pq))
### BUGGY CODE ###

n = int(input())
S = input()

countlist = []

for i in range(n):
  count1 = S[:i].count("W")
  count2 = S[i+1:].count("E")
  count_tem = count1+count2
  countlist.append(count_tem)
  
an = min(countlist)
print(an)


### FIXED CODE ###

n = int(input())
S = input()

l = [0]*n
wl = [0]*n
el = [0]*n

for i in range(n-1):
  if i == 0:
    wl[i+1] = S[i].count("W")
  else:
    wl[i+1] = S[i].count("W")+wl[i]

for i in reversed(range(1,n)):
  if i == n:
    el[i-1] = S[i].count("E")
  else:
    el[i-1] = S[i].count("E")+el[i]
    
for i in range(n):
  l[i] = wl[i] + el[i]
  
print(min(l))
### BUGGY CODE ###

from fractions import Fraction
n=int(input())
x=list(map(int,input().split()))
l=[1]
for i in range(1,n-1):
    l.append(l[-1]+Fraction(1,i+1))
#print(l)

for i in range(n-1):
    l[i]=l[i]*(x[i+1]-x[i])%(10**9+7)

ans=sum(l)
for i in range(1,n):
    ans=ans*i%(10**9+7)
print(ans)

### FIXED CODE ###

import math
n=int(input())
a=list(map(int,input().split()))
ans=math.factorial(n-1)%(10**9+7)

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

c=0
for i in range(1,n):
    c+=(a[-1]-a[i-1])*modinv(i, mod=10**9+7)
print(ans*c%(10**9+7))
### BUGGY CODE ###

n = int(input())
A = [int(input()) for _ in range(n)]

for i in range(n):
    tmp = A.copy()
    tmp.pop(i)
    print(max(tmp))

### FIXED CODE ###

n = int(input())
A = [int(input()) for _ in range(n)]
f_num = max(A)
A_c = A.copy()
A_c.remove(f_num)
s_num = max(A_c)

for a in A:
    if a == f_num:
        print(s_num)
    else:
        print(f_num)
### BUGGY CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()

from heapq import heappush, heappop 

running = []
events = []
delete = set()

n, q = map(int, input().split())
for _ in range(n):
    s, t, x = map(int, input().split())
    time = max(s - x, 0)
    if t - x < 0:
        continue
    events.append((s - x, x, 1)) # 追加イベント
    events.append((t - x, x, 0)) # 削除イベント
events.sort()
ans = []
idx = -1
for _ in range(q):
    d = int(input())
    if d >= events[-1][0]:
        ans.append(-1)
        continue
    while events[idx + 1][0] <= d:
        idx += 1
        if events[idx][2] == 1:
            heappush(running, events[idx][1])
            delete.discard(events[idx][1])
        else:
            delete.add(events[idx][1])
    flag = 1
    while running:
        x = heappop(running)
        if x not in delete:
            heappush(running, x)
            ans.append(x)
            flag = 0
            break
    if flag:
        ans.append(-1)
for i in ans:
    print(i)





### FIXED CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()

from heapq import heappush, heappop 

running = []
events = []
delete = set()

n, q = map(int, input().split())
for _ in range(n):
    s, t, x = map(int, input().split())
    time = max(s - x, 0)
    if t - x < 0:
        continue
    events.append((s - x, x, 1)) # 追加イベント
    events.append((t - x, x, 0)) # 削除イベント
events.sort()
ans = []
idx = -1
for _ in range(q):
    d = int(input())
    if d >= events[-1][0]:
        print(-1)
        #ans.append(-1)
        continue
    while events[idx + 1][0] <= d:
        idx += 1
        if events[idx][2] == 1:
            heappush(running, events[idx][1])
            delete.discard(events[idx][1])
        else:
            delete.add(events[idx][1])
    flag = 1
    while running:
        x = heappop(running)
        if x not in delete:
            heappush(running, x)
            print(x)
            #ans.append(x)
            flag = 0
            break
    if flag:
        print(-1)
### BUGGY CODE ###

from sys import stdin

if __name__ == '__main__':
    n = int(stdin.readline().rstrip())
    a = list(map(int, stdin.readline().rstrip().split()))

    l = len(bin(max(a))[2:])

    cumsums = [[0] for _ in range(l)]
    for aa in a:
        for j in range(l):
            if aa & (1 << j):
                cumsums[j].append(cumsums[j][-1] + 1)
            else:
                cumsums[j].append(cumsums[j][-1])

    ans = 0
    from bisect import bisect_left
    for i in range(1, n+1):
        left = 0
        for j in range(l):
            idx = bisect_left(cumsums[j], cumsums[j][i] - 1)
            left = max(left, idx)
        ans += i - left
    print(ans)


### FIXED CODE ###

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

l = len(bin(max(a))[2:])

cumsums = [[0] for _ in range(l)]
for i in range(n):
    for j in range(l):
        if a[i] & (1 << j):
            cumsums[j].append(cumsums[j][-1] + 1)
        else:
            cumsums[j].append(cumsums[j][-1])

ans = 0
left = 0
for i in range(1, n+1):
    while left < i:
        f = True
        for j in range(l):
            if cumsums[j][left] < cumsums[j][i] - 1:
                f = False

        if f:
            break
        else:
            left += 1

    ans += i - left
print(ans)
### BUGGY CODE ###

#coding: utf-8
import math
import heapq
import bisect
import numpy as np
#from scipy.misc import comb

N,M = map(int, input().split())
A = list(map(int, input().split()))

for i in range(M):
    B,C = map(int, input().split())
    A += [C]*B
    A.sort(reverse=True)
    A = A[:N]

print(sum(A))

### FIXED CODE ###

#coding: utf-8
import math
import heapq
import bisect
import numpy as np
#from scipy.misc import comb

N,M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

L = []
for i in range(M):
    l = list(map(int, input().split()))
    L.append(l)
L = sorted(L, key=lambda x:-x[1])

ans = 0
index = 0
for i in range(N):
    if index >= M:
        ans += A[i]
    else:
        if A[i] >= L[index][1]:
            ans += A[i]
        else:
            ans += L[index][1]
            L[index][0] -= 1
            if L[index][0] == 0:
                index += 1

print(ans)
### BUGGY CODE ###

n = int(input())
stmp = list(input())
Q = int(input())
target = ord("a")
s = [ord(stmp[i])-target for i in range(n)]
al = [chr(target+i) for i in range(26)]
k = [[0 for _ in range(n)] for _ in range(26)]

for i in range(n):
	k[s[i]][i] += 1


class BIT:
	"""
	<Attention> 0-indexed.
	query ... return the sum [0 to m]
	sum ... return the sum [a to b]
	sumall ... return the sum [all]
	add ... 'add' number to element (be careful that it doesn't set a value.)
	search ... the sum version of bisect.right
	output ... return the n-th element
	listout ... return the BIT list
	"""
	
	def query(self, m):
		res = 0
		while m > 0:
			res += self.bit[m]
			m -= m&(-m)
		return res
	
	def sum(self, a, b):
		return self.query(b)-self.query(a)
	
	def sumall(self):
		bitlen = self.bitlen-1
		return self.query(bitlen)
	
	def add(self, m, x):
		m += 1
		bitlen = len(self.bit)
		while m <= bitlen-1:
			self.bit[m] += x
			m += m&(-m)
		return
	
	def __init__(self, a):
		self.bitlen = len(a)+1
		self.bit = [0]*(len(a)+1)
		for i, j in enumerate(a):
			self.add(i, j)


b = [BIT(k[i]) for i in range(26)]

for _ in range(Q):
	q,qtmpa,qtmpb = input().split()
	if q[0] == "1":
		qa = int(qtmpa)
		t = ord(qtmpb)-target
		b[t].add(qa-1, 1)
		b[s[qa-1]].add(qa-1, -1)
		s[qa-1] = t
	else:
		ans = 0
		qta = int(qtmpa)
		qtb = int(qtmpb)
		for i in range(26):
			if b[i].sum(qta-1, qtb) != 0:
				ans += 1
		print(ans)


### FIXED CODE ###

n = int(input())
stmp = list(input())
Q = int(input())
target = ord("a")
s = [ord(stmp[i])-target for i in range(n)]

class BIT:
	"""
	<Attention> 0-indexed.
	query ... return the sum [0 to m]
	sum ... return the sum [a to b]
	sumall ... return the sum [all]
	add ... 'add' number to element (be careful that it doesn't set a value.)
	search ... the sum version of bisect.right
	output ... return the n-th element
	listout ... return the BIT list
	"""
	
	def query(self, m):
		res = 0
		while m > 0:
			res += self.bit[m]
			m -= m&(-m)
		return res
	
	def sum(self, a, b):
		return self.query(b)-self.query(a)
	
	def sumall(self):
		bitlen = self.bitlen-1
		return self.query(bitlen)
	
	def add(self, m, x):
		m += 1
		bitlen = len(self.bit)
		while m <= bitlen-1:
			self.bit[m] += x
			m += m&(-m)
		return
	
	def __init__(self, n):
		self.bitlen = n+1
		self.bit = [0]*(n+1)

b = [BIT(n) for i in range(26)]
for i in range(n):
	b[s[i]].add(i, 1)

for _ in range(Q):
	q,qtmpa,qtmpb = input().split()
	if q[0] == "1":
		qa = int(qtmpa)
		t = ord(qtmpb)-target
		b[t].add(qa-1, 1)
		b[s[qa-1]].add(qa-1, -1)
		s[qa-1] = t
	else:
		ans = 0
		qta = int(qtmpa)
		qtb = int(qtmpb)
		for i in range(26):
			if b[i].sum(qta-1, qtb) != 0:
				ans += 1
		print(ans)
### BUGGY CODE ###

import sys
from itertools import product
import numpy as np

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))
    A = np.array(A)

    total = sum(A)
    ans = float('inf')
    for pos in product(range(2), repeat=N):
        if len(set(pos)) == 1:
            continue

        x = np.array(pos)
        X = np.sum(A * x)
        Y = total - X
        ans = min(ans, abs(X - Y))

    return ans


if __name__ == '__main__':
    print(main())


### FIXED CODE ###

import sys
from itertools import accumulate

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))
    B = list(accumulate(A))

    total = sum(A)
    ans = float('inf')
    for b in B[:N-1]:
        ans = min(ans, abs((total - b) - b))

    return ans



if __name__ == '__main__':
    print(main())
### BUGGY CODE ###

def main():
    n = int(input())

    print(sum(range(1,n)))

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n = int(input())

    print(sum(range(1,n)))

if __name__ == '__main__':
    main()
### BUGGY CODE ###

count = int(input())
numbers = map(int, input().split(' '))

counter = 0
while True:
  for item in numbers:
    if item % 2 == 1:
      break
    else:
      counter += 1
  numbers = [item / 2 for item in numbers]

print(counter)
      

### FIXED CODE ###

count = int(input())
numbers = [int(num) for num in input().split()]

counter = 0
while True:
  tmp = 0
  for item in numbers:
    tmp += item % 2
  if tmp > 0:
    break
  counter += 1
  numbers = [item / 2 for item in numbers]
print(counter)
### BUGGY CODE ###

# 三井住友信託銀行プログラミングコンテスト 2019 D - Lucky PIN

import sys

N = int(input())  # 桁数
S = str(input())

ans = set()

for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            code = S[i] + S[j] + S[k]
            ans.add(code)

print(len(ans))

### FIXED CODE ###

# 三井住友信託銀行プログラミングコンテスト 2019 D - Lucky PIN

import sys


def main():
    N = int(input())  # 桁数
    S = str(input())

    ans = set()

    digit1 = set()

    for i in range(0, N - 2):
        if S[i] in digit1:
            continue
        digit1.add(S[i])
        digit2 = set()

        for j in range(i + 1, N - 1):
            if S[j] in digit2:
                continue
            digit2.add(S[j])
            digit3 = set()
            for k in range(j + 1, N):
                if len(digit3) == 10:
                    break
                code = S[i] + S[j] + S[k]
                ans.add(code)

    print(len(ans))


if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys
input=sys.stdin.readline
n=int(input())

#グラフの連結成分を調べる
def Graph():
    G=[[] for i in range(n)]
    #up_G=[0]*n#up_G[i]=頂点iの親
    for i in range(n-1):
        a,b,c=map(int,input().split())
        c=0 if c%2==0 else 1
        G[a-1].append((b,c))
        G[b-1].append((a,c))
    return G

#木上のDFSテンプレ
from collections import deque
def dfs(G,v,p):
    q=deque()
    q.append((v,p))
    dis=0
    dis_l=[-1]*n
    dis_l[0]=0
    while q:
        V,P=q[-1]
        for new_v in G[V-1]:
            v0,v1=new_v
            #new_vが頂点の時はアウト
            if v0==P:continue
            if dis_l[v0-1]>=0:continue
            dis=(dis_l[V-1]+v1)%2
            dis_l[v0-1]=dis
            q.append((v0,V))
            break
        else:
            q.pop()
    return dis_l


log=Graph()
ans=dfs(log,1,-1)
print(*ans,sep='\n')


### FIXED CODE ###

import sys
input=sys.stdin.readline
n=int(input())

#グラフの連結成分を調べる
def Graph():
    G=[[] for i in range(n)]
    #up_G=[0]*n#up_G[i]=頂点iの親
    for i in range(n-1):
        a,b,c=map(int,input().split())
        c=0 if c%2==0 else 1
        G[a-1].append((b,c))
        G[b-1].append((a,c))
    return G

#木上のDFSテンプレ
from collections import deque
def dfs(G,v,p):
    q=deque()
    q.append((v,p))
    dis=0
    dis_l=[-1]*n
    dis_l[0]=0
    while q:
        V,P=q.pop()
        for new_v in G[V-1]:
            v0,v1=new_v
            #new_vが頂点の時はアウト
            if v0==P:continue
            if dis_l[v0-1]>=0:continue
            dis=(dis_l[V-1]+v1)%2
            dis_l[v0-1]=dis
            q.append((v0,V))

    return dis_l


log=Graph()
ans=dfs(log,1,-1)
print(*ans,sep='\n')
### BUGGY CODE ###

i=input
i()
a=s=1
for x in i().split():
 a*=s
 if 2*~-s<int(x):s+=1
print(a%(10**9+7))

### FIXED CODE ###

mod = 10 ** 9 + 7

N, *X = map(int, open(0).read().split())

stack = []
ans = 1
for x in X:
    stack.append(x)
    if x < 2 * len(stack) - 1:
        ans = (ans * len(stack)) % mod
        stack.pop()
    else:
        ans = (ans * len(stack)) % mod

print(ans)
### BUGGY CODE ###

S = input()

cnt = 0
while True:
    updated = S.replace('ABC', 'BCA', 1)
    if updated == S:
        print(cnt)
        break
    cnt += 1
    S = updated


### FIXED CODE ###

S = input().replace('BC', '*')

a = 0
cnt = 0
for s in S:
    if s != 'A' and s != '*':
        a = 0
    elif s == 'A':
        a += 1
    elif s == '*':
        cnt += a

print(cnt)
### BUGGY CODE ###

import bisect
N = int(input())
Alist = [int(x) for x in input().split()]
Blist = [int(x) for x in input().split()]
Clist = [int(x) for x in input().split()]

Alist.sort()
Blist.sort()
Clist.sort()

cache = []
result = 0
doneb = 0
donea = 0
for c in Clist:
    idxc = bisect.bisect_left(Blist, c)
    for i in range(0, idxc):
        b = Blist[i]
        idxb = bisect.bisect_left(Alist, b)
        result += idxb

print(result)

### FIXED CODE ###

import bisect
N = int(input())
Alist = [int(x) for x in input().split()]
Blist = [int(x) for x in input().split()]
Clist = [int(x) for x in input().split()]

Alist.sort()
Blist.sort()
Clist.sort()

result = 0
for b in Blist:
    a = bisect.bisect_left(Alist, b)
    c = N - bisect.bisect_right(Clist, b)
    result += a*c

print(result)
### BUGGY CODE ###

n = int(input())
s = input()

def compare(x0, x1):
    old_x1 = x1
    while x1 < n and s[x0] == s[x1] and x0 < old_x1:
        x0 += 1
        x1 += 1
    return x1-old_x1


m = 0
for i0 in range(n):
    for i1 in range(i0+1, n):
        m = max(compare(i0, i1), m)

print(m)

### FIXED CODE ###

import hashlib

n = int(input())
s = input()


def output():
    left, right = 0, n//2+1
    while left < right-1:
        mid = (left+right)//2
        if check(mid):
            left = mid
        else:
            right = mid
    return left


def check(x):
    hashes = set()
    for i in range(n - 2*x + 1):
        hashes.add(s[i: i+x])
        if s[i+x: i+2*x] in hashes:
            return True
    return False


print(output())
### BUGGY CODE ###

import math
def equal(x,y,z):
    return x**2 + y**2 + z**2 +x*y+y*z+z*x

N = int(input())

for i in range(1,N+1):
    cnt = 0
    for x in range(1,math.ceil(math.sqrt(N))+1):
        for y in range(1,math.ceil(math.sqrt(N))+1):
            for z in range(1,math.ceil(math.sqrt(N))+1):
                if equal(x,y,z) == i:
                    #print(x,y,z)
                    cnt+=1
    print(cnt)


### FIXED CODE ###

import math
def equal(x,y,z):
    return x**2 + y**2 + z**2 +x*y+y*z+z*x

N = int(input())
ans = [0 for _ in range(10050)]
for x in range(1,105):
        for y in range(1,105):
            for z in range(1,105):
                v = equal(x,y,z)
                if v < 10050:
                    ans[v]+=1
for i in range(N):
    print(ans[i+1])
### BUGGY CODE ###

import collections
def bfs(G,l):
    l.append([1,1])
    visited = [[0] * len(G[0]) for i in range(len(G))]
    chk = 0
    G[1][1] = 0
    while(len(l)):
        now = l.popleft()
        visited[now[0]][now[1]] = 1
        if now == [len(G)-2,len(G[0])-2]:
            chk = 1
            break

        if G[now[0]][now[1]+1] != "#" and visited[now[0]][now[1]+1] == 0:
            l.append([now[0],now[1]+1])
            G[now[0]][now[1]+1] = min(G[now[0]][now[1]] + 1,G[now[0]][now[1]+1])

        if G[now[0]][now[1]-1] != "#" and visited[now[0]][now[1]-1] == 0:
            l.append([now[0],now[1]-1])
            G[now[0]][now[1]-1] = min(G[now[0]][now[1]] + 1,G[now[0]][now[1]-1])

        if G[now[0]+1][now[1]] != "#" and visited[now[0]+1][now[1]] == 0:
            l.append([now[0]+1,now[1]])
            G[now[0]+1][now[1]] = min(G[now[0]][now[1]] + 1,G[now[0]+1][now[1]])

        if G[now[0]-1][now[1]] != "#" and visited[now[0]-1][now[1]] == 0:
            l.append([now[0]-1,now[1]])
            G[now[0]-1][now[1]] = min(G[now[0]][now[1]]+1,G[now[0]-1][now[1]])
    return chk

[h,w] = [int(i) for i in input().split()]
s = [["#"] * (w+2)]
whites = 0
for i in range(h):
    ls = ["#"]
    tmp = input()
    for j in range(len(tmp)):
        if tmp[j] == ".":
            ls.append(200)
        else:
            ls.append(tmp[j])
    ls.append("#")
    whites += tmp.count(".")
    s.append(ls)
s.append(["#"] * (w+2))
l = collections.deque()

if bfs(s,l):
    print(whites - s[h][w]-1)
    
else:
    print(-1)
#print(s)


### FIXED CODE ###

import collections
import time
def bfs(G,l):
    l.append([1,1])
    visited = [[0] * len(G[0]) for i in range(len(G))]
    chk = 0
    G[1][1] = 0
    while(len(l)):
        [n0,n1] = l.popleft()
        if visited[n0][n1] == 1:
            continue
        else:
            visited[n0][n1] = 1
        if [n0,n1] == [len(G)-2,len(G[0])-2]:
            chk = 1
            break
        if G[n0][n1+1] != "#" and visited[n0][n1+1] == 0:
            l.append([n0,n1+1])
            G[n0][n1+1] = min(G[n0][n1] + 1,G[n0][n1+1])

        if G[n0][n1-1] != "#" and visited[n0][n1-1] == 0:
            l.append([n0,n1-1])
            G[n0][n1-1] = min(G[n0][n1] + 1,G[n0][n1-1])

        if G[n0+1][n1] != "#" and visited[n0+1][n1] == 0:
            l.append([n0+1,n1])
            G[n0+1][n1] = min(G[n0][n1]+1,G[n0+1][n1])

        if G[n0-1][n1] != "#" and visited[n0-1][n1] == 0:
            l.append([n0-1,n1])
            G[n0-1][n1] = min(G[n0][n1]+1,G[n0-1][n1])
        #print(n0,n1)
    return chk

[h,w] = [int(i) for i in input().split()]
st = time.time()
s = [["#"] * (w+2)]
whites = 0
for i in range(h):
    ls = ["#"]
    tmp = input()
    for j in range(len(tmp)):
        if tmp[j] == ".":
            ls.append(200)
        else:
            ls.append(tmp[j])
    ls.append("#")
    whites += tmp.count(".")
    s.append(ls)
s.append(["#"] * (w+2))
l = collections.deque()
#print(time.time() - st)
if bfs(s,l):
    print(whites - s[h][w]-1)

else:
    print(-1)
#print(time.time() - st)
### BUGGY CODE ###

import math
from functools import reduce

k = int(input()) + 1


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


def counter(num):
    count = 0
    for a in range(1, num):
        for b in range(1, num):
            for c in range(1, num):
                count += gcd(a, b, c)
    print(count)

counter(k)


### FIXED CODE ###

from math import gcd 

num = int(input()) + 1

count = 0
for a in range(1, num):
    for b in range(1, num):
        t = gcd(a,b)
        for c in range(1, num):
                count += gcd(t, c)
print(count)
### BUGGY CODE ###

import itertools
import sys

input = sys.stdin.readline

maxn = 10000000000

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.append(-maxn)
B.append(-maxn)
C.append(-maxn)

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

apos, bpos, cpos = 0, 0, 0

while (apos + 1) * (bpos + 1) * (cpos + 1) < min(10 ** 7, X * Y * Z):
    if (
        apos < len(A) - 2
        and abs(A[apos] - A[apos + 1]) < abs(B[bpos] - B[bpos + 1])
        and abs(A[apos] - A[apos + 1]) < abs(C[cpos] - C[cpos + 1])
    ):
        apos += 1
    elif bpos < len(B) - 2 and B[bpos] - B[bpos + 1] < C[cpos] - C[cpos + 1]:
        bpos += 1
    else:
        cpos += 1

res = []
for a in list(itertools.product(A[: apos + 1], B[: bpos + 1], C[: cpos + 1])):
    res.append(a[0] + a[1] + a[2])

res.sort(reverse=True)
for k in range(K):
    print(res[k])


### FIXED CODE ###

import itertools
import sys

input = sys.stdin.readline

maxn = 10000000000

X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

cand = []
for i, a in enumerate(A):
    for j, b in enumerate(B):
        for k, c in enumerate(C):
            if (i + 1) * (j + 1) * (k + 1) <= K:
                cand.append(a + b + c)
            else:
                break

cand.sort(reverse=True)
for k in range(K):
    print(cand[k])
### BUGGY CODE ###

import numpy as np
N = int(input())
A = input().split()
A = [int(s) for s in A]

for i in range(1,N+1):
    print(A.index(i)+1)


### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
L = [[] for i in range(N)]
for i in range(N):
    L[i] = [A[i], i+1]
L = sorted(L)
for i in range(N):
    print(L[i][1])
### BUGGY CODE ###

import sys
input=sys.stdin.readline

def calc():
  mod=998244353
  n,s=map(int,input().split())
  arr=list(map(int,input().split()))
  dp=[0]*(s+1)
  dp[0]=1
  ans=0
  for i in range(1,n+1):
    val=arr[i-1]
    for k in range(s,-1,-1):
      dp[k]*=2
      dp[k]%=mod
      if k>=val and dp[k-val]!=0:
        dp[k]+=dp[k-val]
  print(dp[s]%mod)
calc()

### FIXED CODE ###

import sys
input=sys.stdin.readline

def calc():
  mod=998244353
  n,s=map(int,input().split())
  arr=list(map(int,input().split()))
  dp=[0]*(s+1)
  dp[0]=1
  ans=0
  for i in range(1,n+1):
    val=arr[i-1]
    for k in range(s,-1,-1):
      dp[k]*=2
      dp[k]%=mod
      if k>=val and dp[k-val]!=0:
        dp[k]+=dp[k-val]
        dp[k]%=mod
  print(dp[s]%mod)
calc()
### BUGGY CODE ###

import sys
#import numpy as np
#import math
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
input=sys.stdin.readline

n,m=map(int,input().split())
node=[[] for _ in range(n)] 
for i in range(m):
    a,b=map(int,input().split())
    node[a-1].append(b)
    node[b-1].append(a)
d=deque()
d.append(1)
d.append(node[0][0])
f=True
while True:
    f=True
    for i in node[d[0]-1]:
        if i not in d:
          d.appendleft(i)
          f=False
          break
    for i in node[d[-1]-1]:
        if i not in d:
            d.append(i)
            f=False
            break
    if f:
        print(len(d))
        print(*d)
        exit()

### FIXED CODE ###

import sys
#import numpy as np
#import math
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
input=sys.stdin.readline

n,m=map(int,input().split())
node=[[] for _ in range(n)] 
for i in range(m):
    a,b=map(int,input().split())
    node[a-1].append(b)
    node[b-1].append(a)
d=deque()
d.append(1)
d.append(node[0][0])
s=set(d)
f=True
while True:
    f=True
    for i in node[d[0]-1]:
        if i not in s:
          d.appendleft(i)
          s.add(i)
          f=False
          break
    for i in node[d[-1]-1]:
        if i not in s:
            d.append(i)
            s.add(i)
            f=False
            break
    if f:
        print(len(d))
        print(*d)
        exit()