Harryxun/stf_run huggingface dataset:
import random
import itertools
import sys
def input():
    return sys.stdin.readline()[:-1]
  
H, W, M = map(int, input().split())
Hsum = [0] * H
Wsum = [0] * W
hw = []
for m in range(M):
  h, w = map(int, input().split())
  #h = random.randint(0, H)
  #w = random.randint(0, W)
  Hsum[h-1] += 1
  Wsum[w-1] += 1
  hw.append(str(h-1)+"_"+str(w-1))

hmax_ind = list(map(lambda x: True if x == max(Hsum) else False, Hsum))
hmax_ind = list(itertools.compress(range(len(Hsum)), hmax_ind))
wmax_ind = list(map(lambda x: True if x == max(Wsum) else False, Wsum))
wmax_ind = list(itertools.compress(range(len(Wsum)), wmax_ind))
 
res = []
for n in itertools.product(hmax_ind, wmax_ind):
  res.append(str(n[0])+"_"+str(n[1]))

if len(set(res).intersection(set(hw))) == len(res):
  print(max(Hsum) + max(Wsum)-1)
else:
  print(max(Hsum) + max(Wsum)

### FIXED CODE ###

import sys
input = sys.stdin.readline
 
H, W, M = map(int, input().split())
Hsum = [0] * H
Wsum = [0] * W
hw = set()
for m in range(M):
  h, w = map(lambda x: int(x) - 1, input().split())
  Hsum[h] += 1
  Wsum[w] += 1
  hw.add((h, w))

mh = max(Hsum)
mw = max(Wsum)
hidx = [i for i, _ in enumerate(Hsum) if _ == mh]
widx = [i for i, _ in enumerate(Wsum) if _ == mw]
 
if len(hidx) * len(widx) > M:
  print(mh + mw)
else:
  fi_flg = False
  for h in hidx:
    for w in widx:
      if (h, w) not in hw:
        print(mh + mw)
        fi_flg = True
        break
    if fi_flg:
      break
  if fi_flg is False:
    print(mh + mw - 1)
import sys
from functools import lru_cache

sys.setrecursionlimit(10000)


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

@lru_cache(maxsize=None)
def dfs(K, graph, now, source):
  if source == -1:
    can_use_color_num = K - 1
  else:
    can_use_color_num = K - 2
  if len(graph[now]) > K:
    return 0
  else:
    case_num = 1
    for dst in graph[now]:
      if dst == source:
        continue
      case_num *= can_use_color_num
      can_use_color_num -= 1
      case_num %= mod
    for dst in graph[now]:
      if dst == source:
        continue
      case_num *= dfs(K, graph, dst, now)
      case_num %= mod
    return case_num
  

graph = [[] for i in range(N)]
for i in range(N - 1):
  a, b = map(lambda x:int(x)-1, input().split())
  graph[a].append(b)
  graph[b].append(a)

answer = K * dfs(K, graph, 0, -1)
answer %= mod
print(answer)

### FIXED CODE ###

import sys

sys.setrecursionlimit(10**9)


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

def dfs(K, graph, now, source):
  if source == -1:
    can_use_color_num = K - 1
  else:
    can_use_color_num = K - 2
  if len(graph[now]) > K:
    return 0
  else:
    case_num = 1
    for dst in graph[now]:
      if dst == source:
        continue
      case_num *= can_use_color_num
      can_use_color_num -= 1
      case_num %= mod
    for dst in graph[now]:
      if dst == source:
        continue
      case_num *= dfs(K, graph, dst, now)
      case_num %= mod
    return case_num
  

graph = [[] for i in range(N)]
for i in range(N - 1):
  a, b = map(lambda x:int(x)-1, input().split())
  graph[a].append(b)
  graph[b].append(a)

answer = K * dfs(K, graph, 0, -1)
answer %= mod
print(answer)
print(a, b)
        pair += 1
        a += 1
        b -= 1

### FIXED CODE ###

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

a = 1
b = n

if n%2==1:
    for i in range(m):
        print(a, b)
        a += 1
        b -= 1
else:
    pair = 0
    while b-a > n//2 and pair < m:
        print(a, b)
        pair += 1
        a += 1
        b -= 1
    a += 1
    while pair < m:
        print(a, b)
        pair += 1
        a += 1
        b -= 1
b = input()

c = {A:T,T:A,C:G,G:C}

print(c[b])

### FIXED CODE ###

b = input()
 
c = {"A":"T","T":"A","C":"G","G":"C"}
 
print(c[b])
a = int(input())
b = int(input())

if b*a % 2 ==0:
    print("Even")
else:
    print("Odd")

### FIXED CODE ###

a,b = map(int,input().split())
if (a% 2 ==0)or(b% 2 ==0):
    print("Even")
else:
    print("Odd")
import math
A,B,C,D = (int(i) for i in input().split())

X = (C * D) // math.gcd(C, D)
Y = (C + D) // math.gcd(C, D) - 1

#print(X,Y)

#count = (B - A) // X * Y 
#print(count)


N = A % X 
N_S = N-1
UA = Y - (N_S // C + N_S // D)

#print(UA)
M = B % X
UB = M // C + M // D
if M == 0:
    UB = 0
#print(UB)


SA =  A + ( X - N )
SB =  B - M 
#print(SA,SB)
count = (SA - SB) // X * Y 

add = count + UA + UB
    
Z = B - A - add + 1
print(Z)

### FIXED CODE ###

import fractions
a,b,c,d = map(int,input().split())
e = c * d // fractions.gcd(c,d)

c_count = b // c - (a - 1) // c
d_count = b // d - (a - 1) // d
e_count = b // e - (a - 1) // e

ans = b - a + 1 - c_count - d_count + e_count
print(ans)
n = int(input())
m = 0
a = 0
r = 0
c = 0
h = 0
for i in range(n):
  s = input()
  if s[0] == "M":
    m += 1
  if s[0] == "A":
    a += 1
  if s[0] == "R":
    r += 1
  if s[0] == "C":
    c += 1
  if s[0] == "H":
    H += 1
ans = m * a * r +m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+r*c*h+a*c*h
print(ans)

### FIXED CODE ###

n = int(input())
m = 0
a = 0
r = 0
c = 0
h = 0
for i in range(n):
  s = input()
  if s[0] == "M":
    m += 1
  if s[0] == "A":
    a += 1
  if s[0] == "R":
    r += 1
  if s[0] == "C":
    c += 1
  if s[0] == "H":
    h += 1
ans = m * a * r +m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+r*c*h+a*c*h
print(ans)
for i in range(1, N + 1):
    if (i % 3 == 0) and (i % 5 == 0):
        print('FizzBuzz')
    elif i % 3 == 0:
        print('Fizz')
    elif i % 5 == 0:
        print('Buzz')
    else:
        print(str(number))



### FIXED CODE ###

N = int(input())
total = 0
 
for i in range(1, N+1):
    if i % 3 != 0 and i % 5 != 0:
        total += i
 
print(total)
N, M, K= map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))

Asum=[0]
Bsum=[0]

for i in range(N):
    Asum.append(Asum[-1]+A[i])
    if Asum[i]>K:
        break
        
for i in range(M):
    Bsum.append(Bsum[-1]+B[i])
    if Bsum[i]>K:
        break
    
m=0
for i in range(len(Asum)):
    for j in range(len(Bsum)):

        elif Asum[i]+Bsum[j]<=K and m<i+j:
            m=i+j
print(m)
        

### FIXED CODE ###

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

Asum=[0]
Bsum=[0]

for i in range(N):
    Asum.append(Asum[-1]+A[i])
        
for i in range(M):
    Bsum.append(Bsum[-1]+B[i])
    
m=0
j=M

for i in range(len(Asum)):
    if Asum[i]>K:
        break
    while Asum[i]+Bsum[j]>K:
        j-=1
    if m<i+j:
        m=i+j
        
print(m)
menu = [0]*5
md = 300
time = 0
for i in range(5):
    menu[i] = int(input())
for i in range(5):
    if(((menu[i]%10)<md)and(menu[i]%10)!=0):
        x = menu[i]
        md = menu[i]%10
        index = i
#        print(md,index)
menu.pop(index)
for i in range(4):
    hoge = menu[i] % 10
    if hoge != 0:
        time = time + menu[i] + (10 - hoge)
    else:
        time = time + menu[i]

time  = time + x
print(time)

### FIXED CODE ###

A=[int(input())for _ in[0]*5]
B=[-(-a//10)*10-a for a in A]
print(sum(B)+sum(A)-max(B))
A = list(map(int, input().split()))
k = A.find(0)
print(k+1)

### FIXED CODE ###

A = list(map(int, input().split()))
k = A.index(0)
print(k+1)
import math
N = int(input())
a = [int(_) for _ in input().split()]

floor = math.floor(sum(a) / len(a))
ceil = math.ceil(sum(a) / len(a))

ceil_sum = sum([(item - ceil) ** 2 for item in a])
floor_sum = sum([(item - floor) ** 2 for item in a])

print(min(ceil_sum, floor_sum, median_sum))

### FIXED CODE ###

import math
N = int(input())
a = [int(_) for _ in input().split()]

floor = math.floor(sum(a) / len(a))
ceil = math.ceil(sum(a) / len(a))

ceil_sum = sum([(item - ceil) ** 2 for item in a])
floor_sum = sum([(item - floor) ** 2 for item in a])

print(min(ceil_sum, floor_sum))
# n, k: 数値　s: 文字列　が与えられる
# k文字目を入れ替えよ

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

dic = {"A":"a", "B":"b", "C":"c"}

# キーとなる文字　文字列のインデックスは0から
# s[k-1]

# 小文字にする表現がある
# print(s[:k] + )

# [開始インデックス:終了インデックス] 数値は　より大　と　未満
print(s[:k-1] + dic.get("s[k-1]") + s[k-1:])

### FIXED CODE ###

n, k = map(int, input().split())
s = input()
print(s[:k-1] + s[k-1].lower() + s[k:])
n = int(raw_input())

G = [0 for i in range(n)] 
a = [[0 for i in range(n)] for j in range(n)]
dis = [-1 for i in range(n)]
dis[0] = 0

for i in range(n):
    G = map(int, raw_input().split())
    for j in range(G[1]):
        a[G[0]-1][G[2+j]-1] = 1

def bfs_visit(s):
    for k in range(n):
      if a[s][k] == 1 and dis[k] == -1:
         dis[k] = dis[s] + 1
         bfs_visit(k)

for s in range(s):
    bfs_visit()
for s in range(s):
    print (s+1,dis[s])


 
 

    
    
   

          

### FIXED CODE ###

n = int(raw_input())
   
dis = [99999 for i in range(n)]
G = [0 for i in range(n)]
v = [[0 for i in range(n)] for j in range(n)]
   
def BFS(s):
  for e in range(n):
    if v[s][e] == 1:
      if dis[e] > dis[s] + 1:
        dis[e] = dis[s]+1
        BFS(e)
   
for i in range(n):
  G = map(int, raw_input().split())
  for j in range(G[1]):
    v[G[0]-1][G[2+j]-1] = 1
   
dis[0] = 0
for s in range(n):
  BFS(s)
for s in range(n):
  if dis[s] == 99999:
    dis[s] = -1
for s in range(n):
  print'{0} {1}'.format(s+1, dis[s])
# -*- coding: utf-8 -*-

A,B=input().split()
x=int(B[0])
y=int(B[2])
z=int(B[3])

ans1=str(int(A)*x)
ans2=str(int(A)*y)
ans3=str(int(A)*z)

ans=int(ans1)+int(ans2[:-1])+int(ans1[-2])
if int(ans2[-1])*10+int(ans2[-2:]) > 100:
    ans+=1
print(int(ans))


### FIXED CODE ###

# -*- coding: utf-8 -*-

A,B=input().split()

x=int(B[0])
y=int(B[2])
z=int(B[3])

ans=[0]*18
L=len(A)

for i in range(L):
    a=int(A[L-i-1])
    c=a*z
    ans[17-i]=c

for i in range(L):
    a=int(A[L-i-1])
    c=a*y
    ans[16-i]+=c

for i in range(L):
    a=int(A[L-i-1])
    c=a*x
    ans[15-i]+=c

S=0

for i in range(16):
    S+=ans[i]*10**(15-i)

if ans[16]*10+ans[17] > 100:
    S+=(ans[16]*10+ans[17])//100
print(int(S))
from bisect import bisect_left
n = int(input())
a = list(map(int, input().split()))

result = [-1 for _ in range(n)]
tree = [[] for _ in range(n)]
for _i in range(n-1):
    u, v = map(int, input().split())
    u, v = u-1, v-1
    tree[u].append(v)
    tree[v].append(u)
INF = float('inf')
dp = [INF for _i in range(n+1)]


def dfs(p, x):
    i = bisect_left(dp, a[p])
    old = dp[i]
    dp[i] = a[p]
    result[p] = bisect_left(dp, INF)
    for j in tree[p]:
        if j != x:
            dfs(j, p)
    dp[i] = old
    

dfs(0, -1)

for i in result:
    print(i)

### FIXED CODE ###

from bisect import bisect_left
import sys
sys.setrecursionlimit(10 ** 9)
n = int(input())
a = list(map(int, input().split()))

result = [-1 for _ in range(n)]
tree = [[] for _ in range(n)]
for _i in range(n-1):
    u, v = map(int, input().split())
    u, v = u-1, v-1
    tree[u].append(v)
    tree[v].append(u)
INF = float('inf')
dp = [INF for _i in range(n+1)]


def dfs(p, x):
    i = bisect_left(dp, a[p])
    old = dp[i]
    dp[i] = a[p]
    result[p] = bisect_left(dp, INF)
    for j in tree[p]:
        if j != x:
            dfs(j, p)
    dp[i] = old
    

dfs(0, -1)

for i in result:
    print(i)
N = int(input())
H = list(map(int, input().split()))
result = 0

for i in range(N):
    dec = True
    for j in range(i-1):
        if H[i] <= H[j]:
            dec = False
            break
    if dec == True:
        result += 1
print(result)

### FIXED CODE ###

A, B = list(map(int, input().split()))
result = 0
A, B = max(A, B), min(A, B)
result += A + max(A-1, B)
print(result)
a, b = map(int, input().split())
# intは入力に対しての関数、出力ではない

if (a+b)%3 => 0:
    print("Possible")
elif a%3 => 0:
    print("Possible")
elif b%3 => 0:
    print("Possible")
else:
    print("Impossible")

### FIXED CODE ###

a, b = map(int, input().split())
# intは入力に対しての関数、出力ではない

if (a+b)%3 == 0:
    print("Possible")
elif a%3 == 0:
    print("Possible")
elif b%3 == 0:
    print("Possible")
else:
    print("Impossible")
n=int(input())
s=[input() for _ in range(n)]
ans=0
dic={}
for i in range(n):
    a=s[i].sort()
    if not a in dic.keys():
      dic[a]=1
    else: dic[a]+=1
for i in dic.values():
  ans+=i*(i-1)//2


print(ans)


### FIXED CODE ###

n=int(input())
ans=0
dic={}
for _ in range(n):
    s=input()
    s=sorted(s)
    s=''.join(s)
    if not s in dic.keys():
      dic[s]=1
    else: dic[s]+=1
for i in dic.values():
  ans+=i*(i-1)//2


print(ans)
print(len(set(list(lambda x: not x%2, set([input() for i in range(int(input()))])))))

### FIXED CODE ###

time = int(input())
ans = []
n = 0
for i in range(time):
    ans.append(input())
ans.sort(key=int)
while n+1 < len(ans):
    if ans[n] == ans[int(n + 1)]:
        ans.pop(n)
        ans.pop(n)
    else:
        n += 1
print(len(ans))
a = input()
b = input()

if  a/b == 0:
  print(a + b)
else:
  print(b - a)

### FIXED CODE ###

A, B = map(int, input().split())
print(A+B if B % A == 0 else B-A)
import numpy as np
MOD = 998244353

N,S = map(int,input().split())
A = list(map(int,input().split()))
coefs = np.array([0]*(S+1))
coefs[0] = 1

for i in range(N):
    tmp = coefs[:]
    coefs = coefs*2
    coefs[A[i]:] += tmp[:-A[i]]
    coefs%=MOD
    
print(coefs[-1])
    



### FIXED CODE ###

N,S = map(int,input().split())
A = list(map(int,input().split()))
mod = 998244353

dp = [[0]*3005 for _ in range(3005)]
dp[0][0] = 1
for i in range(0,N):
    for s in range(0,S+1):
        if s-A[i] >= 0:
            dp[i+1][s] = dp[i][s]*2 + dp[i][s-A[i]]
        else:
            dp[i+1][s] = dp[i][s]*2
        dp[i+1][s] %= mod

print(dp[N][S])
N,K = map(int,input().split())
X = list(map(int,input().split()))
ls = []
rs = []
for x in X:
    if x < 0:
        ls.append(-x)
    else:
        rs.append(x)
ls.reverse()

ans = float('inf')
if len(ls) >= K:
    ans = min(ans, ls[K-1])
if len(rs) >= K:
    ans = min(ans, rs[K-1])

for l in range(1,K):
    if l >= len(ls): break
    r = K-l
    ans = min(ans, ls[l-1]*2 + rs[r-1])
    ans = min(ans, rs[r-1]*2 + ls[l-1])
print(ans)

### FIXED CODE ###

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

ans = float('inf')
for l in range(N-K+1):
    r = l + K - 1
    if src[l] > 0:
        ans = min(ans, src[r])
    elif src[r] < 0:
        ans = min(ans, -src[l])
    else:
        ans = min(ans, src[r]*2 - src[l], -src[l]*2 + src[r])
print(ans)
from sys import stdin
n = int(stdin.readline().rstrip())

a = []
while n // 26 >= 1:
    if n%26 == 0:
        a.insert(0, 26)
        n = (n - 26) // 26
    else:
        a.insert(0, n%26)
        n = (n - n%26) // 26
if n >= 0:
    a.insert(0, n)

i = 1
while i <= len(a):
    t = a[i-1]
    if t == 1:
        a[i-1] = "a"
    elif t == 2:
        a[i-1] = "b"
    elif t == 3:
        a[i-1] = "c"
    elif t == 4:
        a[i-1] = "d"
    elif t == 5:
        a[i-1] = "e"
    elif t == 6:
        a[i-1] = "f"
    elif t == 7:
        a[i-1] = "g"
    elif t == 8:
        a[i-1] = "h"
    elif t == 9:
        a[i-1] = "i"
    elif t == 10:
        a[i-1] = "j"
    elif t == 11:
        a[i-1] = "k"
    elif t == 12:
        a[i-1] = "l"
    elif t == 13:
        a[i-1] = "m"
    elif t == 14:
        a[i-1] = "n"
    elif t == 15:
        a[i-1] = "o"
    elif t == 16:
        a[i-1] = "p"
    elif t == 17:
        a[i-1] = "q"
    elif t == 18:
        a[i-1] = "r"
    elif t == 19:
        a[i-1] = "s"
    elif t == 20:
        a[i-1] = "t"
    elif t == 21:
        a[i-1] = "u"
    elif t == 22:
        a[i-1] = "v"
    elif t == 23:
        a[i-1] = "w"
    elif t == 24:
        a[i-1] = "x"
    elif t == 25:
        a[i-1] = "y"
    elif t == 26:
        a[i-1] = "z"
    i += 1


print(''.join(a))

### FIXED CODE ###

from sys import stdin
n = int(stdin.readline().rstrip())

a = []
while n // 26 >= 1:
    if n%26 == 0:
        a.insert(0, 26)
        n = (n - 26) // 26
    else:
        a.insert(0, n%26)
        n = (n - n%26) // 26
if n > 0:
    a.insert(0, n)

i = 1
while i <= len(a):
    t = a[i-1]
    if t == 1:
        a[i-1] = "a"
    elif t == 2:
        a[i-1] = "b"
    elif t == 3:
        a[i-1] = "c"
    elif t == 4:
        a[i-1] = "d"
    elif t == 5:
        a[i-1] = "e"
    elif t == 6:
        a[i-1] = "f"
    elif t == 7:
        a[i-1] = "g"
    elif t == 8:
        a[i-1] = "h"
    elif t == 9:
        a[i-1] = "i"
    elif t == 10:
        a[i-1] = "j"
    elif t == 11:
        a[i-1] = "k"
    elif t == 12:
        a[i-1] = "l"
    elif t == 13:
        a[i-1] = "m"
    elif t == 14:
        a[i-1] = "n"
    elif t == 15:
        a[i-1] = "o"
    elif t == 16:
        a[i-1] = "p"
    elif t == 17:
        a[i-1] = "q"
    elif t == 18:
        a[i-1] = "r"
    elif t == 19:
        a[i-1] = "s"
    elif t == 20:
        a[i-1] = "t"
    elif t == 21:
        a[i-1] = "u"
    elif t == 22:
        a[i-1] = "v"
    elif t == 23:
        a[i-1] = "w"
    elif t == 24:
        a[i-1] = "x"
    elif t == 25:
        a[i-1] = "y"
    elif t == 26:
        a[i-1] = "z"
    i += 1

print(''.join(a))
Sp = [1,2,3,4,5,6,7,8,9,10,11,12,13]
Hu = [1,2,3,4,5,6,7,8,9,10,11,12,13]
Cr = [1,2,3,4,5,6,7,8,9,10,11,12,13]
Dy = [1,2,3,4,5,6,7,8,9,10,11,12,13]

num = input()
i = 0
while i < num:
     suit, n = raw_input().split
     n = int(n)
     if suit == "S":
        Sp[n-1] = 0
     elif suit == "H":
        Hu[n-1] = 0
     elif suit == "C":
        Cr[n-1] = 0
     else:
        Dy[n-1] = 0
     i += 1

for i in Sp:
    if Sp[i] != 0:
        print "S", Sp[i]

for i in Hu:
    if Hu[i] != 0:
        print "H", Hu[i]

for i in Cr:
    if Cr[i] != 0:
        print "C", Cr[i]

for i in Dy:
    if Dy[i] != 0:
        print "D", Dy[i]

### FIXED CODE ###

Sp = [1,2,3,4,5,6,7,8,9,10,11,12,13]
Hu = [1,2,3,4,5,6,7,8,9,10,11,12,13]
Cr = [1,2,3,4,5,6,7,8,9,10,11,12,13]
Dy = [1,2,3,4,5,6,7,8,9,10,11,12,13]

num = int(input())
i = 0

while i < num:
     suit, n = raw_input().split()
     n = int(n)
     if suit == "S":
        Sp[n-1] = 0
     elif suit == "H":
        Hu[n-1] = 0
     elif suit == "C":
        Cr[n-1] = 0
     else:
        Dy[n-1] = 0
     i += 1

for i in Sp:
    if i != 0:
        print "S", i

for i in Hu:
    if i != 0:
        print "H", i

for i in Cr:
    if i != 0:
        print "C", i

for i in Dy:
    if i != 0:
        print "D", i
import sys
import math
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
x,y,z,p = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
if x*y*z <= 3*10**6:
    abc = []
    for i in range(x):
        for j in range(y):
            for k in range(z):
                abc.append(a[i]+b[j]+c[k])
    abc.sort()
    abc = abc[::-1]
    for i in range(p):
        print(abc[i])  
    exit()
ab = []
for i in range(x):
    for j in range(y):
        ab.append(a[i]+b[j])
ab.sort()
c = c[::-1]
ab = ab[::-1]
ab.append(-2**62)
ans = []
miru = [0]*z
for i in range(z):
    if i + 1 == z:
        d = -2**60
    else:
        d = c[i+1]+ab[0]
    for j in range(i+1):
        ans.sort()
        while ab[miru[j]] + c[j] >= d and (len(ans)<= k or ab[miru[j]] + c[j] >= ans[-1]):
             ans.append(ab[miru[j]] + c[j])
             miru[j]+=1
    if len(ans) >= k:
        break
ans.sort()
ans = ans[::-1]
for i in range(p):
    print(ans[i])

### FIXED CODE ###

import sys
import math
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
x,y,z,p = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
"""
if x*y*z <= 3*10**6:
    abc = []
    for i in range(x):
        for j in range(y):
            for k in range(z):
                abc.append(a[i]+b[j]+c[k])
    abc.sort()
    abc = abc[::-1]
    for i in range(p):
        print(abc[i])  
    exit()
"""
ab = []
for i in range(x):
    for j in range(y):
        ab.append(a[i]+b[j])
ab.sort()
c = c[::-1]
ab = ab[::-1]
ab.append(-2**62)
ans = []
miru = [0]*z
for i in range(z):
    if i + 1 == z:
        d = -2**60
    else:
        d = c[i+1]+ab[0]
    for j in range(i+1):
        flag = 0
        while ab[miru[j]] + c[j] >= d and (len(ans)<= p or ab[miru[j]] + c[j] >= ans[0]):
             ans.append(ab[miru[j]] + c[j])
             miru[j]+=1
             flag = 1
        if flag and len(ans) <=p+1:
            ans.sort()
ans.sort()
ans = ans[::-1]
for i in range(p):
    print(ans[i])
import math
from fractions import gcd

A, B = map(int, input().split())

print((A * B)//math.gcd(A, B))

### FIXED CODE ###

import math
from fractions import gcd

A, B = map(int, input().split())

print((A * B)//gcd(A, B))
s = str(input())
 
length = len(s)
 
n = length//2
 
m = 0
 
for i in range(n):
  x = (i+1)*(-1)
  if s[i]!=s[k]:
    m += 1
print(m)

### FIXED CODE ###

s = str(input())
 
length = len(s)
 
n = length//2
 
m = 0
 
for i in range(n):
  x = (i+1)*(-1)
  if s[i]!=s[x]:
    m += 1
print(m)
T = input()
PD = list(T)

for i in range(len(PD)):
  if PD[i] == '?':
    if i == 0 and P[1] == 'D':
      PD[i] = 'P'
    elif i == len(PD):
      PD[i] = 'D'
    elif (PD[i-2] == 'P' and PD[i-1] == 'D') and (PD[i-1] == 'D' and PD[i+1] in ('D','?')):
      PD[i] = 'P'
    else:
      PD[i] = 'D'
      
print(''.join(PD))

### FIXED CODE ###

T = input()
print(T.replace('?','D'))
text = input()

a = int(text.split(' ')[0])
b = int(text.split(' ')[1])
c = int(text.split(' ')[2])

x, y, z = sorted([a, b, c])

cnt = z - y
y = z
x += cnt

cnt += int((y - x) / 2)
x += int((y - x) / 2) * 2

if y - x == 1:
    print(cnt+2)
else:
    print(cnt)


### FIXED CODE ###

text = raw_input()

if 'a' in text and 'b' in text and 'c' in text:
    print 'Yes'
else:
    print 'No'
s = input()
l = len(s)
mod = [1] + [0 for _ in range(2017)]
ml = [0 for _ in range(l + 1)]
ans = 0

tmp = 0
for idx, degit in enumerate(reversed(s)):
    m = (int(degit) * (10 ** idx) + tmp) % 2019
    tmp = m
    ans += mod[m]
    mod[m] += 1

print(ans)


### FIXED CODE ###

s = input()
l = len(s)
mod = [1] + [0 for _ in range(2019)]
ml = [0 for _ in range(l + 1)]
ans = 0

tmp = 0
for idx, degit in enumerate(s[::-1]):
    m = int(degit) * pow(10, idx, 2019)
    m = (m + tmp) % 2019
    tmp = m
    ans += mod[m]
    mod[m] += 1

print(ans)
s = input()
if "F" in s[s.index("C"):]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

s = input()
if "C" in s:
    if "F" in s[s.index("C"):]:
        print("Yes")
        exit()
print("No")
data = map(int, input().split())

main = (data[2] - date[0]) * 60 + data[3] - date[1] - data[3]

### FIXED CODE ###

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

main = (data[2] - data[0]) * 60 + data[3] - data[1] - data[4]

print(main)
import numpy as np
t=int(input())
for _ in range(t):
    n=int(input())
    a=list(map(int,input().split()))
    s=input()
    matrix=np.zeros((60,1))
    for i in range(n-1,-1,-1):
        ne=np.array([(a[i]>>j)&1 for j in range(60)])
        matrix=np.c_[matrix,ne]
        col=matrix.shape[1]
        ra=np.linalg.matrix_rank(matrix)
        if s[i]=="0":
            if col!=ra+1:
                matrix=np.delete(matrix,col-1,1)
        else:
            if col==ra+1:
                print(1)
                break
    else:
        print(0)

### FIXED CODE ###

#一次独立：rankが成分数
import numpy as np
#0-indexed,MSBがma以下の時
def msb(x,ma=59):
    for i in range(ma,-1,-1):
        if (x>>i)&1:
            return i
    return len()
t=int(input())
for _ in range(t):
    n=int(input())
    a=list(map(int,input().split()))
    s=input()
    #独立、msb同じものはない
    #逆に異なれば独立
    msbs=[0 for i in range(60)]
    for i in range(n-1,-1,-1):
        now=a[i]
        m=59
        #独立のときfはTrue、独立でない時fはFalse
        while True:
            m=msb(now,m)
            if msbs[m]==0:
                f=True
                break
            now=msbs[m]^now
            if now==0:
                f=False
                break
        if s[i]=="0":
            if f:
                msbs[m]=now
        else:
            if f:
                print(1)
                break
    else:
        print(0)
import math
A, B = map(int, input().split())
def lcm(x, y):
    return (x * y) // math.gcd(x,y)

print(lcm(A, B))

### FIXED CODE ###

A, B = map(int, input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

print(lcm(A, B))
w,h,x,y,r = map(int,input().split())
print(['No','Yes'][(r<=x<=w-r)*(r<=y<=h-r)])in


### FIXED CODE ###

w,h,x,y,r = map(int,input().split())
print(['No','Yes'][r<=x<=w-r and r<=y<=h-r])