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

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

ans = 10**9
for i in range(N):
    temp = []
    temp2 = []
    for j in range(N):
        if A[j] < A[i]:
            temp += sorted(temp2)[:min(len(temp2),max(0,len(temp2) - K + 1))]
            temp2 = []
        else:
            temp2.append(A[j])
    temp += sorted(temp2)[:min(len(temp2),max(0,len(temp2) - K + 1))]
    temp = sorted(temp)

    if len(temp) > Q - 1:
        ans = min(ans,temp[Q - 1] - A[i])
        
print(ans)
    


### FIXED CODE ###

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

R = sorted(set(A))
ans = 10**9
for i in range(len(R)):
    temp = []
    temp2 = []
    l = 0
    for j in range(N):
        if A[j] < R[i]:
            if l >= K:
                temp += sorted(temp2)[:min(l,max(0,l - K + 1))]
            temp2 = []
            l = 0
        else:
            temp2.append(A[j])
            l += 1
    if l >= K:
        temp += sorted(temp2)[:min(l,max(0,l - K + 1))]

    if len(temp) > Q - 1:
        temp = sorted(temp)
        ans = min(ans,temp[Q - 1] - R[i])
    else:
        break
        
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
input = sys.stdin.readline

a, b, c, d = map(int, input().split())
dp = [[0] * (d - b + 1) for _ in range(c - a + 1)]

dp[0][0] = 1
for i in range(c - a + 1):
    for j in range(d - b + 1):
        if i > 0:
            dp[i][j] += dp[i-1][j] * (b+j)
        if j > 0:
            dp[i][j] += dp[i][j-1] * (a+i)
        if i > 0 and j > 0:
            dp[i][j] -= dp[i-1][j-1] * (b+j-1) * (a+i-1)
        dp[i][j] %= 998244353

print(dp[-1][-1])

### FIXED CODE ###

#!/usr/bin/env python3
import sys
input = sys.stdin.readline

a, b, c, d = map(int, input().split())
dp = [[0] * (d - b + 1) for _ in range(c - a + 1)]

dp[0][0] = 1
for i in range(c - a + 1):
    for j in range(d - b + 1):
        if i > 0:
            dp[i][j] += dp[i-1][j] * (b+j)
        if j > 0:
            dp[i][j] += dp[i][j-1] * (a+i)
        if i > 0 and j > 0:
            dp[i][j] -= dp[i-1][j-1] * (b+j-1) * (a+i-1)
        dp[i][j] %= 998244353

print(dp[-1][-1])
### BUGGY CODE ###

from collections import  deque

N = int(input())
dic = {}
A = [[int(j) for j in input().split()] for i in range(N - 1)]
for i in range(N - 1):
    a, b = A[i]
    if a in dic.keys():
        dic[a].append(b)
    else:
        dic[a] = [b]
    if b in dic.keys():
        dic[b].append(a)
    else:
        dic[b] = [a]
ans1 = 0
for k, v in dic.items():
    ans1 = max(ans1, len(v))
no = 0
Used = [[] for i in range(N + 1)] #頂点において使った番号を記録
q = deque()

q.append((1, dic[1]))
dicans = {}
while len(q) > 0:
    i, l = q.popleft()
    num = 1
    #print(f'頂点{i}に関しての色使い情報{Used[i]}')
    for t in range(ans1 + 1):
        if num in Used[i]:
            num += 1
        else:
            break

    for k in l:
        if k < i:
            continue
        #print(f'頂点{i}から{k}に色{num}を割り当て')
        Used[i].append(num)
        Used[k].append(num)
        dicans[(i, k)] = num
        while True:
            if num in Used[i]:
                num += 1
            else:
                break
        q.append((k, dic[k]))
print(ans1)
for a, b in A:
    print(dicans[(a, b)])


### FIXED CODE ###

from collections import  deque
import time
N = int(input())
dic = {}
A = [[int(j) for j in input().split()] for i in range(N - 1)]
for i in range(N - 1):
    a, b = A[i]
    if a in dic.keys():
        dic[a].append(b)
    else:
        dic[a] = [b]
    if b in dic.keys():
        dic[b].append(a)
    else:
        dic[b] = [a]

ans1 = 0
for k, v in dic.items():
    ans1 = max(ans1, len(v))
no = 0
Used = [[] for i in range(N + 1)] #頂点において使った番号を記録
q = deque()

q.append((1, dic[1], 1))
dicans = {}

while len(q) > 0:
    i, l, c= q.popleft()
    num = c
    for k in l:
        if k < i:
            continue
        num += 1
        if num > ans1:
            num = 1
        dicans[(i, k)] = num
        q.append((k, dic[k], num))

print(ans1)

for a, b in A:
    print(dicans[(a, b)])
### BUGGY CODE ###

def quicksort2(numbers):
    length = len(numbers)
    if length <= 1:
        return numbers
    pivot = numbers[0]
    leftside = []
    rightside = []
    for x in numbers[1:]:
        if x <= pivot:
            leftside.append(x)
        else:
            rightside.append(x)
    leftside = quicksort2(leftside)
    rightside = quicksort2(rightside)
    return leftside + [pivot] + rightside
N, K = map(int, input().split())
H_list = list(map(int, input().split()))
H_list = quicksort2(H_list)
if N-K <= 0:
    print(0)
else:
    print(sum(H_list[0:N-K]))

### FIXED CODE ###

N, K = map(int, input().split())
H_list = list(map(int, input().split()))
if N-K <= 0:
    print(0)
else:
    H_list.sort()
    print(sum(H_list[0:N-K]))
### BUGGY CODE ###

#ABC176D

from collections import deque
h,w = map(int,input().split())
ch,cw = map(int,input().split())
dh,dw = map(int,input().split())
s = [list(input()) for _ in range(h)]

stack = deque()
stack.append([ch-1,cw-1])
INF=10**10
cost = [[INF]*w for _ in range(h)]
cost[ch-1][cw-1]=0

dxdy = [[1,0],[-1,0],[0,1],[0,-1]]
warp = []
for m in range(-2,3):
    for n in range(-2,3):
        if [m,n] not in [[0,0] + dxdy]:
            warp += [[m,n]]

while stack:
    x,y = stack.pop()
    for dx,dy in dxdy:
        nx,ny = x+dx,y+dy
        if -1<nx<h and -1<ny<w and s[nx][ny]!="#" and cost[x][y]<cost[nx][ny]:
            cost[nx][ny]=cost[x][y]
            stack.append([nx,ny])

    for dx,dy in warp:
        nx,ny = x+dx,y+dy
        if -1<nx<h and -1<ny<w and s[nx][ny]!="#" and cost[x][y]+1<cost[nx][ny]:            
            cost[nx][ny]=cost[x][y]+1
            stack.append([nx,ny])

if cost[dh-1][dw-1]<INF:
    print(cost[dh-1][dw-1])
else:
    print(-1)

### FIXED CODE ###

from collections import deque
h,w = map(int,input().split())
ch,cw = map(int,input().split())
dh,dw = map(int,input().split())
s = [list(input()) for _ in range(h)]
INF=10**7

queue = deque()

cost = [[INF]*w for _ in range(h)]
cost[ch-1][cw-1]=0

dxdy = [[1,0],[-1,0],[0,1],[0,-1]]
warp = []
for m in range(-2,3):
    for n in range(-2,3):
        if [m,n] not in [[0,0],[1,0],[-1,0],[0,1],[0,-1]]:
            warp += [[m,n]]

queue.append([ch-1,cw-1,0])

while queue:
    x,y,d = queue.popleft()
    for dx,dy in dxdy:
        nx,ny = x+dx,y+dy
        if -1<nx<h and -1<ny<w and s[nx][ny]!="#" and d<cost[nx][ny]:
            cost[nx][ny]=d
            queue.appendleft([nx,ny,d])
            #[print(*cost[l]) for l in range(h)]
            #print("---------------")

    for dx,dy in warp:
        nx,ny = x+dx,y+dy
        if -1<nx<h and -1<ny<w and s[nx][ny]!="#" and d+1<cost[nx][ny]:            
            cost[nx][ny]=d+1
            queue.append([nx,ny,d+1])
            #[print(*cost[l]) for l in range(h)]
            #print("---------------")


if cost[dh-1][dw-1]<INF:
    print(cost[dh-1][dw-1])
else:
    print(-1)
### BUGGY CODE ###

import itertools

N, C = map(int, input().split())
D = [list(map(int, input().split())) for i in range(C)]
c = [list(map(int, input().split())) for i in range(N)]

# 全探索だと間に合わない
# 一旦実装だけしてみる
corres = list(itertools.permutations(range(C), 3))
ans = float('inf')
indices = [2, 0, 1]
for corr in corres:
  cost = 0
  for i in range(N):
    idx = indices[i%3]
    for j in range(N):
      cost += D[c[i][j]-1][corr[idx]]
      idx = (idx + 1) % 3
  ans = min(ans, cost)

print(ans)

### FIXED CODE ###

N, C = map(int, input().split())
D = [list(map(int, input().split())) for i in range(C)]
c = [list(map(int, input().split())) for i in range(N)]

cost0 = []
cost1 = []
cost2 = []
indices = [2, 0, 1]
for color in range(C):
  cost = [0, 0, 0]
  for i in range(N):
    idx = indices[i%3]
    for j in range(N):
      cost[idx] += D[c[i][j]-1][color]
      idx = (idx + 1) % 3
  cost0.append([cost[0], color])
  cost1.append([cost[1], color])
  cost2.append([cost[2], color])

cost0.sort()
cost1.sort()
cost2.sort()
ans = float('inf')
for i in range(3):
  for j in range(3):
    for k in range(3):
      if len(set([cost0[i][1], cost1[j][1], cost2[k][1]])) == 3:
        ans = min(ans, cost0[i][0]+cost1[j][0]+cost2[k][0])

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

from math import factorial

N, K = map(int, input().split())

def comb(n,r):
  return factorial(n) / (factorial(r) * factorial(n-r)) if n >= r else 0

if K%2 == 1:
  cand = N // K
  print(int(cand + comb(cand,2) * 6 + comb(cand,3) * 6))
else:
  cand_mod0 = N // K
  ans_mod0 = cand_mod0\
           + cand_mod0 * (cand_mod0-1) * 3\
           + cand_mod0 * (cand_mod0-1) * (cand_mod0-2)
  cand_modhalf = N // K if N % K < K / 2 else (N // K) + 1
  ans_modhalf = cand_modhalf\
           + cand_modhalf * (cand_modhalf-1) * 3\
           + cand_modhalf * (cand_modhalf-1) * (cand_modhalf-2)
  print(int(ans_mod0 + ans_modhalf))

### FIXED CODE ###

N, K = map(int, input().split())

if K%2 == 1:
  cand = N // K
  ans = cand\
      + cand * (cand-1) * 3\
      + cand * (cand-1) * (cand-2)
  print(int(ans))
else:
  cand_mod0 = N // K
  ans_mod0 = cand_mod0\
           + cand_mod0 * (cand_mod0-1) * 3\
           + cand_mod0 * (cand_mod0-1) * (cand_mod0-2)
  cand_modhalf = N // K if N % K < K / 2 else (N // K) + 1
  ans_modhalf = cand_modhalf\
           + cand_modhalf * (cand_modhalf-1) * 3\
           + cand_modhalf * (cand_modhalf-1) * (cand_modhalf-2)
  print(int(ans_mod0 + ans_modhalf))
### BUGGY CODE ###

n,m=map(int,input().split())
#p=[list(input().split()) for _ in range(m)]

correct=[]
data={}

"""
for j in range(m):
    if p[j][0] in correct:
        continue
    if p[j][0] in data.keys():
        if p[j][1]=='WA': 
            data[p[j][0]]+=1
        else:
            correct.append(p[j][0])
    else:
        if p[j][1]=='WA':
            data[p[j][0]]=1
        else:
            correct.append(p[j][0])
"""

for i in [list(input().split()) for _ in range(m)]:
    if i[0] in correct:
        continue
    else:
        if i[0] in data.keys():
            if i[1]=='WA': 
                data[i[0]]+=1
            else:
                correct.append(i[0])
        else:
            if i[1]=='WA':
                data[i[0]]=1
            else:
                correct.append(i[0])


#print(correct,data)
#print(len(correct),sum(data.values()))

print(len(correct),sum([data[i] for i in correct if i in data.keys()]))

### FIXED CODE ###

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

if m==0:
    print(0,0)
    import sys
    sys.exit()

p=[list(input().split()) for _ in range(m)]
correct=set([p[i][0] for i in range(m) if p[i][1]=='AC'])

s=set()
sum_wa=0

for i in [p[j] for j in range(m) if p[j][0] in correct]:
    if i[0] in s:
        continue
    else:
        if i[1]=='WA':
            sum_wa+=1
        else:
            s.add(i[0])

print(len(correct),sum_wa)
### BUGGY CODE ###

n,m=map(int,input().split())
import heapq
a=list(map(int,input().split()))
heapq.heapify(a)

for _ in range(m):
    b,c=map(int,input().split())
    for i in range(b):
        x=heapq.heappop(a)
        if x<c:
            heapq.heappush(a,c)
        else:
            heapq.heappush(a,x)
            break
print(sum(a))


### FIXED CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
l=[]
for i in range(n):
    l.append([1,a[i]])
for i in range(m):
    l.append(list(map(int,input().split())))
l.sort(key=lambda x:x[1], reverse=True)
c=0
ans=0
for i in range(n+m):
    ans+=l[i][1]*l[i][0]
    c+=l[i][0]
    if c>n:
        ans-=l[i][1]*(c-n)
        break
print(ans)
### BUGGY CODE ###

# Union-Find
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    if par[x] > par[y]:
        x, y = y, x
    par[x] += par[y]
    par[y] = x
    return True


def same(x, y):
    return find(x) == find(y)


def size(x):
    return -par[find(x)]


def count(A):
    ans = N * (N-1) // 2
    for a in A:
        if a < 0:
            b = - a
            ans -= b * (b-1) // 2
    return ans



N, M = map(int, input().split())
# 負のとき size, 非負のとき parent
par = [-1] * N
Bridge = [tuple(map(int, input().split())) for _ in range(M)]
Bridge = Bridge[::-1]
Ans = []
for (a, b) in Bridge:
    Ans.append(count(par))
    unite(a-1, b-1)


Ans = Ans[::-1]

for an in Ans:
    print(an)



### FIXED CODE ###

# Union-Find
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    if par[x] > par[y]:
        x, y = y, x
    par[x] += par[y]
    par[y] = x
    return True


def same(x, y):
    return find(x) == find(y)


def size(x):
    return -par[find(x)]



N, M = map(int, input().split())
# 負のとき size, 非負のとき parent
par = [-1] * N
Bridge = [tuple(map(int, input().split())) for _ in range(M)]
Bridge = Bridge[::-1]
Ans = []
ans = N * (N-1) // 2
for (a, b) in Bridge:
    Ans.append(ans)
    if find(a-1) != find(b-1):
        x = size(a-1)
        y = size(b-1)
    else:
        x = 0
        y = 0
    unite(a-1, b-1)
    ans -= x * y


Ans = Ans[::-1]

for an in Ans:
    print(an)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n,m = map(int,input().split())
a = [0]*m
for i in range(m):
  a[i] = int(input())
dp = [0]*(n+1)
dp[0] = 1
if 1 in a:
  dp[1] = 0
else:
  dp[1] = 1

for j in range(2,n+1):
  if j in a:
    dp[j] = 0
  else:
    dp[j] = dp[j-1]+dp[j-2]
#print(dp)
print(dp[n]%1000000007)



### FIXED CODE ###

import sys
input = sys.stdin.readline
n,m = map(int,input().split())
a = [0]*m
#for i in range(m):
 # a[i] = int(input())
a = set([int(input()) for i in range(m)])
dp = [0]*(n+1)
dp[0] = 1
if 1 in a:
  dp[1] = 0
else:
  dp[1] = 1

for j in range(2,n+1):
  dp[j] = (dp[j-1]+dp[j-2])%1000000007
  if j in a:
    dp[j] = 0
print(dp[n])
### BUGGY CODE ###

#input
X = int(input())

#output

import math
initial_num = 1

left = 1
right = 10**2
while left + 1 < right:
    mid = (left + right)//2
    if mid **5  > X:
        right = mid
    else:
        left = mid

def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()
A = left
C = A**5 -X

if C >= 0:
    B = pow(C, 1/5)
else:
    B = -pow(-C, 1/5)

while not is_integer(B):
    A -= 1
    C = A**5 - X
    if C >= 0:
        B = pow(C, 1/5)
    else:
        B = -pow(-C, 1/5)

print(A, int(B))

### FIXED CODE ###

#input
X = int(input())

#output
for a in range(200):
    for b in range(-200, 200):
        if a**5 - b**5 == X:
            print(a, b)
            exit()
### BUGGY CODE ###


K = int(input())
n = 0
cnt = 0
tmp = 0
while cnt < K:
    n = n + 1

    nDigit = []
    nDiv   = []
    flg = True
    digits = len(str(n))
    tmpN = n
    for i in range(0,digits) :
        nDigit.append(tmpN // (10 ** (digits-i-1)))
        tmpN = tmpN % (10 ** (digits-i-1))
    if len(nDigit) == 1 :
        cnt = cnt + 1
        tmp = n
    else :
        tR = 0
        for i in range(0,len(nDigit)-1) :
            if abs(nDigit[i] - nDigit[i+1]) > 1 :
                flg = False
                tR = i
                i = len(nDigit)
        if flg == True :
            cnt = cnt + 1
            tmp = n
        elif nDigit[tR] - nDigit[tR+1] < 0 :
            n = n - (n % (10 ** (digits - tR))) + (nDigit[tR] + 1) * (10 ** (digits-tR-1)) - 1
        elif nDigit[tR] - nDigit[tR+1] > 0 :
            n = n - (n % (10 ** (digits - tR-1))) + (nDigit[tR] - 1) * (10 ** (digits-tR-2)) - 1

#for i in range(0,len(LunList)) :
#    print(i,LunList[i])
print(n)


### FIXED CODE ###

k = int(input())

i = 1
q = []
while i <= k :
    if(i < 10) :
        q.append(i)
    else :
        x = q.pop(0)
        tmp = 10 * x + (x % 10)
        if x % 10 != 0 :
            q.append(tmp-1)
            i+=1
        q.append(tmp)
        if x % 10 != 9 :
            q.append(tmp+1)
            i+=1
    i+=1
print(q.pop(k-i))
### BUGGY CODE ###

N = int(input())
S = input()

ans = 100000000

for i in range(N):
    A = S[0:i]
    B = S[i+1:]
    if S[i] == 'E':
        #向く方向を変える必要がある人数
        X = A.count('W')
        Y = B.count('E')
        ans = min(X + Y,ans)
    if S[i] == 'W':
        #向く方向を変える必要がある人数
        X = A.count('W')
        Y = B.count('E')
        ans = min(X + Y,ans)
print(ans)

### FIXED CODE ###

n = int(input())
s = input()
e = s.count("E")
w = s.count("W")
cnt1 = 0
cnt2 = 0
ans = 10e9
for i in s:
    if i=="E":
        cnt1 += 1
        ans = min(ans,cnt2+e-cnt1)
    else:
        ans = min(ans,cnt2+e-cnt1)
        cnt2 += 1
print(ans)
### BUGGY CODE ###

import copy
import collections
import sys


def input():
    return sys.stdin.readline()[:-1]


def bfs(sx, sy, gx, gy):
    # sx,sy := スタートの座標
    # gx,gy := ゴールの座標
    que = collections.deque()
    que.append([sx, sy])
    d = [[inf]*W for _ in range(H)]
    d[sx][sy] = 0
    s = copy.copy(field)
    while (len(que) > 0):
        p = que.popleft()
        if p[0] == gx and p[1] == gy:
            break
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            if (0 <= nx and nx < H and 0 <= ny and ny < W and s[nx][ny] != "#" and d[nx][ny] == inf):
                que.append([nx, ny])
                d[nx][ny] = d[p[0]][p[1]] + 1
    return d[gx][gy]


inf = float('inf')
H, W = map(int, input().split())
field = [list(input()) for _ in range(H)]
d = [[inf]*W for _ in range(H)]

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

cand = []
memo = []

for h1 in range(H):
    for w1 in range(W):
        for h2 in range(H):
            for w2 in range(W):
                if h1 == h2 and w1 == w2:
                    continue
                cand.append([h1, w1, h2, w2])
for c in cand:
    res = bfs(*c)
    if res != float('inf'):
        memo.append(res)
print(max(memo))


### FIXED CODE ###

import copy
import collections
import sys


def input():
    return sys.stdin.readline()[:-1]


def bfs(sx, sy):
    # sx,sy := スタートの座標
    # gx,gy := ゴールの座標
    que = collections.deque()
    que.append([sx, sy])
    d = [[inf]*W for _ in range(H)]
    d[sx][sy] = 0
    s = copy.copy(field)
    while (len(que) > 0):
        p = que.popleft()
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            if (0 <= nx and nx < H and 0 <= ny and ny < W and s[nx][ny] != "#" and d[nx][ny] == inf):
                que.append([nx, ny])
                d[nx][ny] = d[p[0]][p[1]] + 1
    return d  # d[gx][gy]


inf = -1
H, W = map(int, input().split())
field = [list(input()) for _ in range(H)]
d = [[inf]*W for _ in range(H)]

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

cand = []
memo = []

for h1 in range(H):
    for w1 in range(W):
        if field[h1][w1] == '#':
            continue
        cand.append([h1, w1])
for c in cand:
    res = bfs(*c)
    memo.append(max(sum(res, [])))
print(max(memo))
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = 0
mod = pow(10,9)+7
for i in range(N-1):
    for j in range(i+1,N):
        ans += (A[i]*A[j])%mod
        ans = ans%mod
print(ans)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = 0
mod = pow(10,9)+7

B = []
x = 0
for i in range(N-1):
    x += A[i]
    x %= mod
    B.append(x)

ans = 0
for i in range(1,N):
    ans += A[i]*B[i-1]
    ans %= mod

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

N=int(input())
S=['']*N
count=0

for i in range(N):
    tmp=input()
    if not(tmp in S):
        count+=1
        S[i]=tmp

print(count)

### FIXED CODE ###

N=int(input())
S=['']*N
count=0

for i in range(N):
    S[i]=input()

# s=collections.Counter(S)
# print(len(s))
print(len(set(S)))
### BUGGY CODE ###

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

#print(ai)
dai={}
dbi={}
for i in range(1, n+1):
    dai.setdefault(i, ai[i-1])
    dbi.setdefault(i, 0)

#print(dai)
#print(dbi)

anssum=0
ans=[]
for i in range(1, n+1)[::-1]:
    #print(i)
    tmp=0
    for j in range(2, n+1):
        check=i*j
        if check <= n:
            tmp = tmp + dbi[check]
    tmp = tmp%2
    #print(str(tmp) + ", " + str(dai[i]))
    if tmp != dai[i]:
        dbi[i]=1
        anssum=anssum+1
        ans.append(i)

#print(dbi)
print(anssum)
if anssum != 0:
    print(" ".join(map(str, reversed(ans))))

### FIXED CODE ###

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

#print(ai)
dai={}
dbi={}
for i in range(1, n+1):
    dai.setdefault(i, ai[i-1])
    dbi.setdefault(i, 0)

#print(dai)
#print(dbi)

anssum=0
ans=[]
for i in range(1, n+1)[::-1]:
    #print(i)
    tmp=0
    for j in range(2, n+1):
        check=i*j
        if check <= n:
            tmp = tmp + dbi[check]
        else:
            break
    tmp = tmp%2
    #print(str(tmp) + ", " + str(dai[i]))
    if tmp != dai[i]:
        dbi[i]=1
        anssum=anssum+1
        ans.append(i)

#print(dbi)
print(anssum)
if anssum != 0:
    print(" ".join(map(str, reversed(ans))))
### BUGGY CODE ###

count = 0
a,b = map(int,input().split())
for i in range(a+1):
    for j in range(a+1):
        for k in range(a+1):
            if i + j + k == b:
                count +=1
print(count)

### FIXED CODE ###

count = 0
a,b = map(int,input().split())
for i in range(a+1):
    for j in range(a+1):
            z = b - i - j
            if 0<=z<=a:
                count +=1
print(count)
### BUGGY CODE ###

import numpy as np
from math import ceil, floor

N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))
F = np.array(list(map(int, input().split())))

A.sort()
F.sort()

if np.sum(A) <= K:
    print(0)
else:
    st = 0
    ed = 10 ** 12
    md = ceil((st + ed) / 2)
    while True:
        if np.sum([max(a - floor(md / f), 0) for (a, f) in zip(A, F[::-1])]) <= K:
            ed = md
        else:
            st = md
        md = ceil((st + ed) / 2)

        if md == ed:
            break

    print(md)


### FIXED CODE ###

import numpy as np
from math import ceil

N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))
F = np.array(list(map(int, input().split())))

A.sort()
F.sort()

if np.sum(A) <= K:
    print(0)
else:
    st = 0
    ed = 10 ** 12
    md = ceil((st + ed) / 2)
    while True:
        if np.sum(A - np.minimum(A, md // F[::-1])) <= K:
            ed = md
        else:
            st = md
        md = ceil((st + ed) / 2)

        if md == ed:
            break

    print(md)