Harryxun/stf_run huggingface dataset:
N = int(input())

if N > 1000:
    hasu = N - (N // 1000)*1000
    
print(1000-hasu)

### FIXED CODE ###

N = int(input())

if N % 1000 == 0:
    print(0)
else:
    hasu = N - (N // 1000)*1000
    print(1000-hasu)
Tmp = []
Tmp = input().rstrip().split(' ')
 
nN = int(Tmp[0])
nT = int(Tmp[1])
 
nCost = 1001
nAns = 0
 
for i in range(nN):
  Tmp = input().rstrip().split(' ')
 
  nTmpCost = int(Tmp[0])
  nTmpT = int(Tmp[1])
  
  if nTmpT <= nT and nTmpCost < nCost:
    nCost = nTmpCost
    nAns = i+1
 
if nAns == 0:
  print('TLE')
else:
  print(nCost)
 
#6727236

ソースコード 

Copy
Copy
Tmp = []
Tmp = input().rstrip().split(' ')
 
nN = int(Tmp[0])
nT = int(Tmp[1])
 
nCost = 1001
nAns = 0
 
for i in range(nN):
  Tmp = input().rstrip().split(' ')
 
  nTmpCost = int(Tmp[0])
  nTmpT = int(Tmp[1])
  
  if nTmpT <= nT and nTmpCost < nCost:
    nCost = nTmpCost
    nAns = i+1

if nAns == 0:
  print('TLE')
else:
  print(nCost)
 


### FIXED CODE ###

Tmp = []
Tmp = input().rstrip().split(' ')
 
nN = int(Tmp[0])
nT = int(Tmp[1])
 
nCost = 1001
nAns = 0
 
for i in range(nN):
  Tmp = input().rstrip().split(' ')
 
  nTmpCost = int(Tmp[0])
  nTmpT = int(Tmp[1])
  
  if nTmpT <= nT and nTmpCost < nCost:
    nCost = nTmpCost
    nAns = i+1

if nAns == 0:
  print('TLE')
else:
  print(nCost)
import math

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

LCM = A[0]
for i in range(0,N-1,1):
    LCM = LCM*A[i+1]//gcd(A[i+1],LCM)

### FIXED CODE ###

def lcm(X,Y):
    x=X
    y=Y
    if y>x:
        x,y=y,x
    while x%y!=0:
        x,y=y,x%y
    return X*Y//y

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

LCM = A[0]
for i in range(0,N-1,1):
    LCM = lcm(LCM,A[i+1])
B = [0 for i in range(0,N,1)]
for i in range(0,N,1):
    B[i]= (LCM%MOD)*pow(A[i],MOD-2,MOD)%MOD

ans = 0
for i in range(0,N,1):
    ans = (B[i] + ans)%MOD

print(ans)
a, b, c = sorted(list(map(int, input().split())))

count  = (b - a) // 2
count += 2 if (a + count * 2) != b else 0
count += c - b
print(count)


### FIXED CODE ###

input()

print("NO" if sum(map(int, input().split())) % 2 else "YES")
N,Q = list(map(int,input().split()))
s = input()

t = ["a"]*Q
d = ["b"]*Q
for i in range(Q):
	t[i],d[i] = input().split()
c = [1]*N
flux = [0]*N

for i in range(Q):
	flux = [0]*N
	for j in range(N):
		if s[j] == t[i] and d[i] == "R":
			flux[j] += -c[j]
			if j != N-1:
				flux[j+1] += c[j]
		if s[j] == t[i] and d[i] == "L":
			flux[j] = -c[j]
			if j != 0:
				flux[j-1] += c[j]
	for j in range(N):
		c[j] += flux[j]
	#print(c)
ans = sum(c)
print(ans)


### FIXED CODE ###

a,b,c = list(map(int,input().split()))
if a==b and b == c:
	print("Yes")
	exit()
print("No")
b=input().split
print("A"+b[1]+"c")

### FIXED CODE ###

a,b,c=map(str,input().split())
print('{}{}{}'.format(a[0],b[0],c[0]))
a_list = []
for i in range(10):
    while True:
        a = input()
        a = int(a)
        if 0<a and a<10000:break
    a_list.append(a)

for i in range(3):
    print(max(a_list))
    a_list.remove(max(a_list))


### FIXED CODE ###

a_list = []
for i in range(10):
    while True:
        a = input()
        a = int(a)
        if 0<=a and a<=10000:break
    a_list.append(a)

for i in range(3):
    print(max(a_list))
    a_list.remove(max(a_list))
s = raw_input()
print s[0:4] + ' ' + s[4:]

### FIXED CODE ###

s=input()
print(s[:4]+ " "+s[4:])
import sys

def main():
    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())

    out = 'NO'
    t = (B - A) / (V - W)
    if t.is_integer()==True:
        t = int(t)
        if t > 0:
            if t<=T:
                out = 'YES'
    
    print(out)
main()

### FIXED CODE ###

import sys

def main():
    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())

    out = 'NO'

    if V==W:
        if B==A:
            out = 'YES'
            print(out)
            sys.exit()
        else:
            print(out)
            sys.exit()

    if B < A:
        t = (B - A) / (W - V)
    else:
        t = (B - A) / (V - W)
        
    if t >= 0:
        if t<=T:
            out = 'YES'
    
    print(out)
main()
#!/usr/bin/env python
# coding: utf-8

# In[86]:


N,M=map(int,input().split())
ab=[list(map(int,input().split())) for l in range(N)]
ct=0
money=0
l=[]
for i in range(N):
    l.append(ab[i][0])
l.sort()
for i in range(N):
   # min_id=l.index(min(l))
    if ct+ab[i][1]<M:
        money+=ab[i][0]*ab[i][1]
        ct+=ab[i][1]
        #l[i]=10000000000
    else:
        for i in range(ab[i][1]):
            money+=l[i]
            ct+=1
            if ct==M:
                break
print(money)


# ## 


### FIXED CODE ###

N,M=map(int,input().split())
ab=[list(map(int,input().split())) for l in range(N)]
ct=0
ct1=0
ct2=0
money=0
l=[]
id=[]
for i in range(N):
    l.append(ab[i][0])
id=sorted(range(len(l)),key=lambda k: l[k])
l.sort()
while ct<M:
    while ct2<ab[id[ct1]][1]:##
        money+=l[ct1] #l[ct1]
        #print(money,l[ct1])
        ct+=1
        ct2+=1
        if ct==M:
            break
    ct1+=1
    ct2=0
print(money)
from collections import defaultdict
from collections import OrderedDict
n = int(input())
ans = dict()
for _ in range(n):
    z = str(input())
    if z in answer:
        ans[z]+=1
    else:
        answer.update({z:1})
groupedByValue = defaultdict(list)
for key, value in sorted(answer.items()):
    groupedByValue[value].append(key)
M = groupedByValue[max(groupedByValue)]
for i in M:
    print(i)

### FIXED CODE ###

from collections import defaultdict
from collections import OrderedDict
n = int(input())
answer = dict()
for _ in range(n):
    z = str(input())
    if z in answer:
        answer[z]+=1
    else:
        answer.update({z:1})
groupedByValue = defaultdict(list)
for key, value in sorted(answer.items()):
    groupedByValue[value].append(key)
M = groupedByValue[max(groupedByValue)]
for i in M:
    print(i)
k, n = map(int, input().split())
a = list(map(int, input().split()))
d = 0

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

print(K - d)

### FIXED CODE ###

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

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

print(k - d)
S = int(input())
K = int(input())

if S <= 9:
 print(S)
else:
 s = str(S)
 index = 0
 while True:
  if s[index] != '1':
   print(s[index])
   break
  elif index == K:
   print(s[index])
   break
  else:
   index += 1

### FIXED CODE ###


S = int(input())
K = int(input())

s = str(S)
l = len(s)

for i in range(K):
 if i>=len(s):
  print(s[-1])
  exit()
 if s[i] != '1':
  print(s[i])
  exit()

print(1)
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    def solve_iter(hi, wi):
        vec = [(0,1),(0,-1),(1,0),(-1,0)]
        for v in vec:
            hn = hi + v[0]
            wn = wi + v[1]
            if hn >= 0 and hn < H and wn >= 0 and wn < W:
                if NLIST[hn][wn] == '#':
                    NLIST[hi][wi] = '.'
                    NLIST[hn][wn] = '.'
                    solve_iter(hn, wn)
        return

    H,W = map(int, lines.pop(0).split(' '))
    NLIST = []
    for i in range(H):
        NLIST.append(list(lines.pop(0)) )

    res = 'Yes'
    for i in range(H):
        for j in range(W):
            if NLIST[i][j] == '#':
                solve_iter(i, j)
            if NLIST[i][j] == '#':
                res = 'No'

    print(res)

#
# main
#
lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    def solve_iter(hi, wi):
        vec = [(0,1),(0,-1),(1,0),(-1,0)]
        for v in vec:
            hn = hi + v[0]
            wn = wi + v[1]
            if hn >= 0 and hn < H and wn >= 0 and wn < W:
                if NLIST[hn][wn] == '#' or NLIST[hn][wn] == '*':
                    NLIST[hi][wi] = '*'
                    NLIST[hn][wn] = '*'
                    #solve_iter(hn, wn)
        return

    H,W = map(int, lines.pop(0).split(' '))
    NLIST = []
    for i in range(H):
        NLIST.append(list(lines.pop(0)) )

    res = 'Yes'
    for i in range(H):
        for j in range(W):
            if NLIST[i][j] == '#':
                solve_iter(i, j)
            if NLIST[i][j] == '#':
                res = 'No'

    print(res)

#
# main
#
lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)
c = input()
if c == a or c == i or c == u or c ==e or c == o:
    print('vowel')
else:
    print('consonant')

### FIXED CODE ###

c = input()
if c == 'a' or c == 'i' or c == 'u' or c == 'e' or c == 'o':
    print('vowel')
else:
    print('consonant')
L, R = map(int, input().split())

listX = []
sw = 0
for i in range(99050):
  listX.append(i*2019)

for n in range(len(listX)):
  if L < listX[n] and R > listX[n]:
    sw += 1

if sw > 0:
  print(0)

else:      
  L_1 = L % 2019
  R_1 = R % 2019
  
  idx1 = 0
  listA = []
  for idx1 in range(L_1, R_1):
    idx2 = idx1 + 1
    for idx2 in range(idx1 + 1, R_1 + 1):
      listA.append(idx1 * idx2)
 
  print(min(listA))

### FIXED CODE ###

L, R = map(int, input().split())

listX = []
for i in range(1, 990590):
  listX.append(i*2019)

sw = 0
for n in range(len(listX)):
  if L < listX[n] and R > listX[n]:
    sw += 1

if sw > 0:
  print(0)

elif sw == 0:
  idx1 = 0
  listA = []
  for idx1 in range(L, R):
    for idx2 in range(idx1 + 1, R + 1):
      listA.append(idx1 * idx2)
 
  idx3 = 0
  listB = []
  for idx3 in range(len(listA)):
    listB.append(listA[idx3] % 2019)
 
  print(min(listB))
import math

def main2():
    input()
    t = sorted(list(map(int, input().split())))
    combs = {}
    comb(t[-1], t[len(t)//2], exact=True)
    c = math.factorial(t[-1]) // (math.factorial(t[-1] - t[len(t)//2]) * math.factorial(t[len(t)//2]))
    c2 = math.factorial(t[-1]) // (math.factorial(t[-1] - t[len(t)//2 + 1]) * math.factorial(t[len(t)//2 + 1]))
    if c < c2:
        print(t[-1], t[len(t) // 2 + 1])
    else:
        print(t[-1], t[len(t) // 2])



if __name__ == '__main__':
    main2()

### FIXED CODE ###

def main3():
    input()
    t = sorted(list(map(int, input().split())))
    ma = t.pop(-1)
    r = min(t, key=lambda x: abs(x - ma / 2))
    print(ma, r)

if __name__ == '__main__':
    main3()
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    H=[]
    Z=[]
    for i in range(n):
      x,y,h=s[i]
      if h!=0:
        H.append(abs(x-cx)+abs(y-cy)+h)
      else:
        Z.append(abs(x-cx)+abs(y-cy))
    if H.count(H[0])==len(H) and min(Z)>=H[0]:
      print(cx,cy,H[0])
      exit()


### FIXED CODE ###

import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    H=[]
    Z=[]
    for i in range(n):
      x,y,h=s[i]
      if h!=0:
        H.append(abs(x-cx)+abs(y-cy)+h)
      else:
        Z.append(abs(x-cx)+abs(y-cy))
    if len(Z)==0:
      Z.append(10**18)
    if H.count(H[0])==len(H) and min(Z)>=H[0]:
      print(cx,cy,H[0])
      exit()
import math

N, X = list(map(int, input().split()))
x = list(map(int, input().split()))

ans = 0
for i in range(len(x)):
    ans = math.gcd(ans, abs(X - x[i]))

print(ans)

### FIXED CODE ###

import fractions

N, X = list(map(int, input().split()))
x = list(map(int, input().split()))

ans = 0
for i in range(len(x)):
    ans = fractions.gcd(ans, abs(X - x[i]))

print(ans)
n,k = map(int,input().split())

mod = 10**9+7

m = 10**5 * 4 +10 
fac = [1]*m
ninv = [1]*m
finv = [1]*m
for i in range(2,m):
    fac[i] = fac[i-1]*i%mod
    ninv[i] = (-(mod//i)*ninv[mod%i])%mod
    finv[i] = finv[i-1]*ninv[i]%mod

def comb(n,k):
    return (fac[n]*finv[k]%mod)*finv[n-k]%mod

if k*2 >= n:
    print(comb(2*n-1,n))
    1/0
else:
    ans = 0
    for i in range(k+1):
        ans += comb(n,i)*comb(n-1,i)
        ans %= mod
    print(ans)

### FIXED CODE ###

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

mod = 10**9+7

m = 10**5 * 4 +10 
fac = [1]*m
ninv = [1]*m
finv = [1]*m
for i in range(2,m):
    fac[i] = fac[i-1]*i%mod
    ninv[i] = (-(mod//i)*ninv[mod%i])%mod
    finv[i] = finv[i-1]*ninv[i]%mod

def comb(n,k):
    return (fac[n]*finv[k]%mod)*finv[n-k]%mod

ans = 0
for i in range(min(n,k+1)):
    ans += comb(n,i)*comb(n-1,i)
    ans %= mod
print(ans)
import sys

args = []
args[0] = int(input())
args[1] = int(input())
args[2] = int(input())

result = int(args[1]) / args[0])
if result > args[2]:
    result = args[2]
print(result)


### FIXED CODE ###

import sys


args = str(input()).split(" ")

result = int(int(args[1]) / int(args[0]))
if result > int(args[2]):
    result = int(args[2])
print(result)
import sys

input = sys.stdin.readline

n = int(input())
graph = [[] for i in range(n + 1)]
cost = [[] * (n + 1) for j in range(n + 1)]
for i in range(n - 1):
    u, v, w = map(int, input().split())
    graph[u].append(v)
    graph[v].append(u)
    cost[u][v] = w
    cost[v][u] = w
ans = [] * (n + 1)


def dfs(a):
    dist = [-1] * (n + 1)
    stack = [a]
    dist[a] = 0
    while stack:
        v = stack.pop()
        for w in graph[v]:
            if dist[w] == -1:
                dist[w] = dist[v] + cost[w][v]
                dist[w] %= 2
                stack.append(w)
            else:
                continue
    return dist


dist = dfs(1)
print(*dist[1:], sep="\n")


### FIXED CODE ###

import sys

input = sys.stdin.readline

n = int(input())
graph = [[] for i in range(n + 1)]
for i in range(n - 1):
    u, v, w = map(int, input().split())
    graph[u].append((v, w))
    graph[v].append((u, w))


def dfs(a):
    dist = [-1] * (n + 1)
    stack = [a]
    dist[a] = 0
    while stack:
        v = stack.pop()
        for b, w in graph[v]:
            if dist[b] == -1:
                dist[b] = (dist[v] + w) % 2
                stack.append(b)
            else:
                continue
    return dist


dist = dfs(1)
print(*dist[1:], sep="\n")
from itertools import accumulate
N = int(input())
A = tuple([0,] + list(map(int, input().split())) + [0,])
D = []
sum = 0
for i, a in enumarate(A[1:-1]):
  i += 1
  pre = A[i - 1]
  tem = A[i]
  nex = A[i + 1]
  x = abs(pre - tem) + abs(tem - nex)
  sum += x
  D.append(abs(pre - nex) - x)
for d in D:
  print(sum + d)

### FIXED CODE ###

from itertools import accumulate
N = int(input())
A = tuple([0,] + list(map(int, input().split())) + [0,])
D = []
sum = 0
for i, a in enumerate(A[1:-1]):
  i += 1
  pre = A[i - 1]
  tem = A[i]
  nex = A[i + 1]
  x = abs(pre - tem)
  y = abs(tem - nex)
  sum += x
  D.append(abs(pre - nex) - x - y)
sum += y
for d in D:
  print(sum + d)
n = int(input())
A = sorted(tuple(map(int, input().split())))
B = tuple(map(int, input().split()))
C = sorted(tuple(map(int, input().split())))

count = 0
for b in B:
    # Aの候補
    la = -1
    ra = n
    while (ra - la) > 1:
        mid = (la+ra)//2
        if A[mid] > b:
            ra = mid
        else:
            la = mid
    if A[la] != b:
        la += 1

    # Cの候補
    lc = -1
    rc = n
    while (rc - lc) > 1:
        mid = (lc+rc)//2
        if C[mid] < b:
            lc = mid
        else:
            rc = mid
    if C[rc] == b:
        rc += 1
    
    count += la*(n-rc)

print(count)

### FIXED CODE ###

n = int(input())
A = sorted(tuple(map(int, input().split())))
B = tuple(map(int, input().split()))
C = sorted(tuple(map(int, input().split())))

import bisect

count = 0
for b in B:
    # Aの候補
    la = bisect.bisect_left(A, b)
    # Cの候補
    rc = bisect.bisect_right(C, b)
    
    count += la*(n-rc)

print(count)
N = int(input())
A = input()
B = input()
C = input()

ans = 0

for i in range(N):
  S = set(A[i], B[i], C[i])
  ans += S.__len__() - 1

print(ans)

### FIXED CODE ###

N = int(input())
A = input()
B = input()
C = input()

ans = 0

for i in range(N):
  S = {A[i], B[i], C[i]}
  ans += S.__len__() - 1

print(ans)
a,b,c = map(input().split())
d=0
x=0
for x in range(a,b+1):
    if c%x==0:d+=1
print(d)

### FIXED CODE ###

a,b,c = map(int,input().split())
d=0
for x in range(a,b+1):
    if c%x==0:d+=1
print(d)
X, Y = map(int, input().split())

for i in range(60):
    if X * 2**i > Y:
        ans = i
        break
print(ans)

### FIXED CODE ###

X, Y = map(int, input().split())

for i in range(300):
    if X * 2**i > Y:
        ans = i
        break
print(ans)
N, K = map(int, input().split())
S = input().split()

def result(S):
    count = 0
    for i in range(len(S)-1):
        if S[i]==S[i+1]:
            count += 1
    return count
  
def reverse(S, l, r):
    for i in range(l-1, r):
        if S[i] == "R":
            S[i] = "L"
        else:
            S[i] = "R"
        return S
M = 0
for k in range(K):
  for r in range(1, N+1):
      for l in range(1, r+1):
          new = result(reverse(S))
          if new > M:
              M = new
print(new)

### FIXED CODE ###

N, K = map(int, input().split())
S = input()
count = 0
for i in range(1, N):
  if S[i] == S[i - 1]:
    count += 1
print(min(N - 1, count + K * 2))
import math
n, k = map(int, input().split())
a = list(map(int, input().split()))
def binary_search(left, right):
    if right - left <= 0.01:
        return right
    middle = round((right + left) / 2, 2)
    if is_can(middle):
        return binary_search(middle, right)
    else:
        return binary_search(left, middle)
def is_can(target):
    count = 0
    for i in range(n):
        count += a[i] //target
    return count > k
print(math.ceil(round(binary_search(0,10**18),1)))


### FIXED CODE ###

import math
import sys
sys.setrecursionlimit(10**8)
n, k = map(int, input().split())
a = list(map(int, input().split()))
def binary_search(left, right):
    if right - left <= 0.01:
        return right
    middle = (right + left) / 2
    if is_can(middle):
        return binary_search(left, middle)
    else:
        return binary_search(middle, right)
def is_can(target):
    count = 0
    for i in range(n):
        if a[i] > target:
            count += a[i] // target
    return count <= k
p = binary_search(0, 10**10)
if int(p) != 0 and is_can(int(p)) :
    print(int(p))
else:
    print(int(p) + 1)
print(round((N/2)+0.01))

### FIXED CODE ###

N = int(input())
print(round((N/2)+0.01))
n=input()
x,y=n.split()
c=(4*int(x)-int(y))/2
t=int(x)-c
print(z)
if c.is_integer and 100>=c>=0 and 100>=t>=0:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

n=input()
x,y=n.split()
for c in range(int(x)+1):
  cnt=0
  t=int(x)-c
  asi=2*c+4*t
  if asi==int(y):
    print("Yes")
    cnt=1
    break
if cnt==0:
  print("No")
import sys

args = sys.argv

num = int(args[1])
print(str(num**3))


### FIXED CODE ###

s = input()
num = int(s)
print(str(num**3))
n,k=map(int,input().split())
print(min([n%abs(n-k), abs(n%abs(n-k)-k)]))

### FIXED CODE ###

n,k=map(int,input().split())
if (n-k)!=0:
	print(min([abs(n%k), abs(abs(n%k)-k)]))
else:
	print("0")
#coding:utf-8
n=[int(i) for i in input().split()]
if(n[1]-n[0]<=2*n[2]):
  for i in range(n[0],n[1]):
    print(i)
else:
  for j in range(n[0],n[0]+n[2]):
    print(j)
  for k jn range(n[1]-n[2]+1,n[1]):
    print(k)

### FIXED CODE ###

#coding:utf-8
n=[int(i) for i in input().split()]
if(n[1]-n[0]+1<=2*n[2]):
  for i in range(n[0],n[1]+1):
    print(i)
else:
  for j in range(n[0],n[0]+n[2]):
    print(j)
  for k in range(n[1]-n[2]+1,n[1]+1):
    print(k)
list1=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
a = int(input())
print(list1[a])

### FIXED CODE ###

import sys

list1=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
for line in sys.stdin:
	print(list1[int(line)-1])
N = int(input())

c = N % 9
if(c==0):
  print("Yes")
else:
  print("No")
        
     

### FIXED CODE ###

N,X,T = map(int,input().split())

count = 0
while(N>0):
  N = N - X
  count += 1
  
print(T*count)
import heapq
X,Y,Z,K=[int(s) for s in input().split()]
x=sorted([-int(s) for s in input().split()])
y=sorted([-int(s) for s in input().split()])
z=sorted([-int(s) for s in input().split()])
count=[[[0 for _ in range(X)]for _ in range(Y)]for _ in range(Z)]
count[0][0][0]=1
Q=[[x[0]+y[0]+z[0],0,0,0]]
heapq.heapify(Q)
for i in range(K):
  cake,a,b,c=heapq.heappop(Q)
  print(-cake)
  if count[a+1][b][c]==0:
    heapq.heappush(Q,[x[a+1]+y[b]+z[c],a+1,b,c])
    count[a+1][b][c]=1
  if count[a][b+1][c]==0:
    heapq.heappush(Q,[x[a]+y[b+1]+z[c],a,b+1,c])
    count[a][b+1][c]=1
  if count[a][b][c+1]==0:
    heapq.heappush(Q,[x[a]+y[b]+z[c+1],a,b,c+1])
    count[a][b][c+1]=1

### FIXED CODE ###

X,Y,Z,K=[int(s) for s in input().split()]
xls=sorted([int(s) for s in input().split()],reverse=True)
yls=sorted([int(s) for s in input().split()],reverse=True)
zls=sorted([int(s) for s in input().split()],reverse=True)
xyls=[]
for x in xls[:K]:
  for y in yls[:K]:
    xyls.append(x+y)
xyls=sorted(xyls,reverse=True)
cake=[]
for xy in xyls[:K]:
  for z in zls[:K]:
    cake.append(xy+z)
cake=sorted(cake,reverse=True)
for i in range(K):
  print(cake[i])
a=raw_input()
x=sum([a[i]=="01"[i%2] for i in range(len(a))])
ans=min([x,n-x])
print ans



### FIXED CODE ###

a=raw_input()
x=sum([a[i]=="01"[i%2] for i in range(len(a))])
ans=min([x,len(a)-x])
print ans
antennas = [int(input()) for i in range(5)]

max_dist = int(input())

coords = {}

for i in range(len(antennas)):
  coords[i] = antennas[i]
flag = 1
for i in range():
  for j in range(i + 1, 5):
    if abs(coords[i] - coords[j]) > max_dist:
      print(':(')
      flag = 0
      break
  if flag == 0:
    break
if flag == 1:
  print('Yay!')
      

### FIXED CODE ###

antennas = [int(input()) for i in range(5)]

max_dist = int(input())

coords = {}

for i in range(len(antennas)):
  coords[i] = antennas[i]
flag = 1
for i in range(5):
  for j in range(i + 1, 5):
    if abs(coords[i] - coords[j]) > max_dist:
      print(':(')
      flag = 0
      break
  if flag == 0:
    break
if flag == 1:
  print('Yay!')
from bisect import*
INF=10**18
n,d,a=map(int,input().split())
mon=[]
for _ in range(n):
  mon+=[list(map(int,input().split()))]
mon.sort()
i=0
ans=0
while i<n:
  j=bisect_left(mon,[mon[i][0]+2*d+1,INF])
  h=max(mon[i:j],key=lambda x:x[1])[1]
  if h!=mon[j-1][1] or i==j-1:
    ans+=(b+a-1)//a
    i=j
  else:
    h=max(mon[i:j-1],key=lambda x:x[1])[1]
    ans+=(h+a-1)//a
    mon[j-1][1]-=(h+a-1)//a*a
    if mon[j-1][1]>0:i=j-1
    else:i=j
print(ans)

### FIXED CODE ###

from collections import*
INF=10**18
n,d,a=map(int,input().split())
mon=[]
for _ in range(n):
  mon+=[list(map(int,input().split()))]
mon.sort()
ans=0
tot=0
q=deque()
for i in range(n):
  x,h=mon[i]
  while q and q[0][0]<x:
    tot-=q.popleft()[1]
  h-=tot
  if h>0:
    b=(h+a-1)//a
    tot+=b*a
    ans+=b
    q.append((x+2*d,b*a))
print(ans)
N,M = map(int,input().split())

a = [int(input()) for i in range(M)]

wa = (10**9) + 7

def Fib(n):
    if n==0:
        return 0 #F0
    elif n==1:
        return 1 #F1
    else:
        fibo_minus1 = 1 #Fn-1
        fibo_minus2 = 0 #Fn-2
        for i in range(2,n):
            fibo = fibo_minus1 + fibo_minus2 #Fn = Fn-1 + Fn-2
            fibo_minus2 = fibo_minus1 # Fn-2の値を更新
            fibo_minus1 = fibo # Fn-1の値を更新
        return fibo





ans = 1



if M!= 1:
    length = a[0]
    ans *= Fib(length+1)

    for i in range(0,M-1):
        length = a[i+1]-a[i]-1
        # print(length)
        if length == 0:
            ans *= 0
        else:
            ans *= Fib(length+1)
        # print(ans)


    
if M==1:
    length = a[0]
    ans *= Fib(length+1)




length = N-a[-1]


ans *= Fib(length+1)

print(ans%wa)




### FIXED CODE ###

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

a = [int(input()) for i in range(M)]

wa = (10**9) + 7

#dpを使う

dp = [0]*(N+1)
dp[0]=1
now_a = 0
if len(a)==0:
    now_a = -1
if len(a)!=0:
    a.reverse()
    now_a = a.pop()

for i in range(1,N+1):
    # print(now_a)
    if i==1:
        dp[i]=dp[i-1]
    else:
        dp[i]=dp[i-1] + dp[i-2]
    if i == now_a:
        dp[i]=0
        if len(a)!=0:
            now_a = a.pop()
        else:
            now_a = -1

# print(dp)

print(dp[N]%wa)