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

n = int(input())
list = list(range(9, 1, -1))
ans = 0

while n > 1:
    for i in list:
        if n % i == 0:
            n = n / i
            ans += 1
            break

if ans > 2:
    print("No")
else:
    print("Yes")


### FIXED CODE ###

n = int(input())
list = list(range(9, 1, -1))
ans = 0

if n > 1:
    while n > 1:
        flag = 1
        for i in list:
            if n % i == 0:
                n = n / i
                ans += 1
                flag = 0
                break

        if flag == 1:
            ans = 0
            break
elif n == 1:
    ans = 2

if 0 < ans <= 2:
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

from bisect import*
def main():
    root=[[],[]]
    def search_higher(key):
        ptr0,ptr1=root
        ret=None
        while ptr1:
            i=bisect(ptr0,key)
            if i!=len(ptr0):ret=ptr0[i]
            ptr0,ptr1=ptr1[i]
        i=bisect(ptr0,key)
        if i!=len(ptr0):ret=ptr0[i]
        return ret
    def search_lower(key):
        ptr0,ptr1=root
        ret=None
        while ptr1:
            i=bisect_left(ptr0,key)
            if i!=0:ret=ptr0[i-1]
            ptr0,ptr1=ptr1[i]
        i=bisect_left(ptr0,key)
        if i!=0:ret=ptr0[i-1]
        return ret
    def insert_rec(ptr,key):
        ptr0,ptr1=ptr
        b_size=512
        if not ptr[1]:
            insort(ptr0,key)
            if len(ptr0)==b_size*2-1:
                ret=[ptr0[:b_size],[]]
                ptr[0]=ptr0[b_size:]
                return ret
        else:
            i=bisect(ptr0,key)
            tmp=insert_rec(ptr1[i],key)
            if tmp:
                ptr0.insert(i,tmp[0].pop())
                ptr1.insert(i,tmp)
                if len(ptr1)==b_size*2:
                    ret=[ptr0[:b_size],ptr1[:b_size]]
                    ptr[0],ptr[1]=ptr0[b_size:],ptr1[b_size:]
                    return ret
    def insert(key):
        tmp=insert_rec(root,key)
        if tmp:root[0],root[1]=[tmp[0].pop()],[tmp,root]
    n,*a=map(int,open(0).read().split())
    l=[0]*n
    for i,v in enumerate(a,1):l[v-1]=i
    insert(0)
    insert(n+1)
    c=0
    for i,v in enumerate(l,1):
        c+=(search_higher(v)-v)*(v-search_lower(v))*i
        insert(v)
    print(c)
main()

### FIXED CODE ###

root=lambda x:x if par[x]==x else root(par[x])
same=lambda x,y:root(x)==root(y)
def unite(*z):
  x,y=map(root,z)
  if x!=y:
    if rank[x]<rank[y]:
      par[x]=y
      size[y]+=size[x]
    else:
      par[y]=x
      size[x]+=size[y]
      if rank[x]==rank[y]:rank[x]+=1
n,*a=map(int,open(0).read().split())
*par,=range(n)
rank=[1]*n
size=[1]*n
b=[0]*n
for i,t in enumerate(a):b[t-1]=i
c=0
for k in b[::-1]:
  l=r=1
  if k>0 and a[k-1]>a[k]:
    l+=size[root(k-1)]
    unite(k-1,k)
  if k+1<n and a[k+1]>a[k]:
    r+=size[root(k+1)]
    unite(k+1,k)
  c+=l*r*a[k]
print(c)
### BUGGY CODE ###

s = input()
count = 0
  
while len(set(s)) == 2:
  
  count += s.count("10")*2
  s = s.replace("10","")
  count += s.count("01")*2
  s = s.replace("01","")

print(count)



### FIXED CODE ###

s = input()
print(min(s.count("0"),s.count("1"))*2)
### BUGGY CODE ###

from heapq import heapify,heappop,heappush
N,M=map(int,input().split())
S,T=map(int,input().split())
Graph=[set() for i in range(N)]
Edge=[]
mod=10**9+7
inf=float("inf")
for i in range(N):
  Edge.append((i,i,0))
for i in range(M):
  a,b,c=map(int,input().split())
  Graph[a-1].add((c,b-1))
  Graph[b-1].add((c,a-1))
  Edge.append((a-1,b-1,c))
  Edge.append((b-1,a-1,c))
def dijkstra(s,n,links):
  Visited=[False]*n
  Visited[0]=True
  cost=[inf]*n
  P=[0]*n
  P[s]=1
  cost[s]=0
  heap=[(0,s)]
  heapify(heap)
  while heap:
    hc,hp=heappop(heap)
    for c,p in links[hp]:
      if Visited[p]:
        continue
      if c+hc<cost[p]:
        cost[p]=c+hc
        P[p]=P[hp]
        heappush(heap,(cost[p],p))
      elif c+hc==cost[p]:
        P[p]+=P[hp]
      if c+hc>cost[p]:
        Visited[p]=True
  return cost,P
  
cost_S,P_S=dijkstra(S-1,N,Graph)
cost_T,P_T=dijkstra(T-1,N,Graph)
D=cost_S[T-1]
List=[]
for a,b,c in Edge:
  if cost_S[a]+c+cost_T[b]==D and cost_S[a]<D/2 and cost_T[b]<D/2 and c>0:
    List.append(P_S[a]*P_T[b]%mod)
  if cost_S[a]+c+cost_T[b]==D and cost_S[a]==D/2 and cost_T[b]==D/2 and c==0:
    List.append(P_S[a]*P_T[b]%mod)
Sum=sum(List)%mod
ans=0
for i,c in enumerate(List):
  ans=(ans+(Sum-List[i])*List[i])%mod
print(ans)



      
  
  
  
  


### FIXED CODE ###

from heapq import heapify,heappop,heappush
import sys
input=sys.stdin.readline
N,M=map(int,input().split())
S,T=map(int,input().split())
Graph=[set() for i in range(N)]
Edge=[]
mod=10**9+7
inf=float("inf")
for i in range(M):
  a,b,c=map(int,input().split())
  Graph[a-1].add((c,b-1))
  Graph[b-1].add((c,a-1))
  Edge.append((a-1,b-1,c))
  Edge.append((b-1,a-1,c))
def dijkstra(s,n,links):
  Visited=[False]*n
  cost=[inf]*n
  P=[0]*n
  P[s]=1
  cost[s]=0
  heap=[(0,s)]
  heapify(heap)
  while heap:
    hc,hp=heappop(heap)
    if Visited[hp]:
      continue
    Visited[hp]=True
    for c,p in links[hp]:
      if Visited[p]:
        continue
      if c+hc<cost[p]:
        cost[p]=c+hc
        P[p]=P[hp]
        heappush(heap,(cost[p],p))
      elif c+hc==cost[p]:
        P[p]=(P[p]+P[hp])%mod
  return cost,P

def dp(s,n,links,d):
  Visited=[False]*n
  cost=[inf]*n
  P=[0]*n
  P[s]=1
  cost[s]=0
  heap=[(0,s)]
  heapify(heap)
  while heap:
    hc,hp=heappop(heap)
    if 2*hc>d:
      break
    if Visited[hp]:
      continue
    Visited[hp]=True
    for c,p in links[hp]:
      if Visited[p]:
        continue
      if c+hc<cost[p]:
        cost[p]=c+hc
        P[p]=P[hp]
        heappush(heap,(cost[p],p))
      elif c+hc==cost[p]:
        P[p]=(P[p]+P[hp])%mod
  return cost,P

cost_S,P_S=dijkstra(S-1,N,Graph)
D=cost_S[T-1]
cost_T,P_T=dp(T-1,N,Graph,D)
Pat=P_S[T-1]
ans=(Pat**2)%mod
for a,b,c in Edge:
  if cost_S[a]+cost_T[b]+c==D:
    if 2*cost_S[a]<D and 2*cost_T[b]<D:
      ans-=((P_S[a]*P_T[b])**2)%mod
for i in range(N):
  if 2*cost_S[i]==2*cost_T[i]==D:
    ans-=((P_S[i]*P_T[i])**2)%mod
print(ans%mod)
### BUGGY CODE ###

'''連徐法を利用した別バージョン'''
A,B = map(int, input().split())

M = max(A,B)//2
# print(M)
CoP = set([1])

for i in range(1,M):
    Co_flg = 1
#     print(i+1, A % (i+1), B % (i+1))
    while Co_flg:
        
        if A % (i+1) == 0 and B % (i+1) == 0:
            CoP.add(i+1)
            A = A /(i+1)
            B = B /(i+1)
#             print(A,B)
        else:
            Co_flg = 0

# print(CoP)
print(len(CoP))

### FIXED CODE ###

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

#解法の大まかな流れ
#　AとBの素因数をそれぞれ計算し、And集合の長さを出す

#　数Nの素因数の算出方法
#  基本的には、Nを小さい数から順に割れるだけ割っていく（除算法）
#    割る数は素数だけでいい
# 課題：1～Aまでそれぞれ割って判定では計算量が足りない　A <= 10^12なので
# アイディア①：素数一覧表を作成して、一覧表に入っている数字だけで、割れるか判定
#  ⇒ 素数一覧表の作成の方が高コストになる可能性高い
# アイディア②： eratosthenesの篩の応用


def Soinsu(N):
    soinsu = set([1]) 
    if N > 1:
        # 偶数チェック（ここで引っ掛けられると割る数のカウントアップを倍にできるので)
        div2_flg = 1
        while div2_flg:
            if N % 2 == 0:
                soinsu.add(2)
                N = N/2
            else:
                div2_flg = 0
#         print("after 2: ",N)
        for i in range(3,int(N)+1,2):
#             print("i: ",i, " N: ",N)
        
            div_flg = 1
            while div_flg:
#                 print("   N: ",N)
                if N % i == 0:
                    soinsu.add(i)
                    N = N/i
                else:
                    div_flg = 0
            # 割る数の上限はN**(1/2)であることを適用
            if i**2 > N:
                break
        # 自分自身も入れる：これを入れないと片方がもう一方の素因数である場合を逃す
        soinsu.add(N)
        
    return(soinsu)
            
soi_A = Soinsu(A)
soi_B = Soinsu(B)
# print(soi_A)
# print(soi_B)
print(len(soi_A & soi_B))
### BUGGY CODE ###

def submit():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))

    d = [float('inf') for _ in range(n)]
    d[0] = 0
    for i in range(1, n):
        for j in range(1, k + 1):
            if i - j >= 0:
                d[i] = min(d[i],
                           d[i - j] + abs(h[i] - h[i - j]))
            else:
                break
    print(d[n - 1])

submit()

### FIXED CODE ###

def submit():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))

    d = [float('inf') for _ in range(n)]
    d[0] = 0
    for i in range(1, n):
        for j in range(1, k + 1):
            if i - j >= 0:
                d[i] = min(d[i],
                           d[i - j] + abs(h[i] - h[i - j]))
            else:
                break
    print(d[n - 1])

submit()
### BUGGY CODE ###

R,G,B,N=map(int,input().split())

tmp=0
for i in range(0,N+1):
  for j in range(0,N+1):
    if (R*i+G*j)<=N and (N-(R*i+G*j))%B==0:
      tmp+=1
print(tmp)

### FIXED CODE ###

R,G,B,N=map(int,input().split())

tmp=0
for i in range(N//R+1):
  for j in range((N-R*i)//G+1):
    if (N-(R*i+G*j))%B==0:
      tmp+=1
print(tmp)
### BUGGY CODE ###

INF = 1000000000

def solve(s,g,E,n):
  D = [0 if i == s else INF for i in range(n)]
  U = [0 for i in range(n)]
  V = [s]
  while V:
    v = V.pop(0)
    if v == g:
      break
    for e in E[v]:
      if D[v] + e[1] < D[e[0]]:
        D[e[0]] = D[v] + e[1]
        V.append(e[0])
    V = sorted(V,key=lambda x:D[x])
  if D[g] >= INF:
    print(-1)
  else:
    print(D[g])
  
  
while True:
  try:
    n,k = list(map(int,input().split()))
    if n == 0 and k == 0:
      break
    E = [[] for i in range(n)]
    for i in range(k):
      lst = list(map(int,input().split()))
      a = min(lst[1],lst[2])
      b = max(lst[1],lst[2])
      if lst[0] == 0:
        solve(a - 1, b - 1, E, n)
      elif lst[0] == 1:
        E[a - 1].append([b - 1, lst[3]])
        E[b - 1].append([a - 1, lst[3]])
  except EOFError:
    break


### FIXED CODE ###

from heapq import heappush,heappop

def dij(s,g,E):
  h = []
  U = []
  heappush(h,(0,s))
  while h:
    v = heappop(h)
    if v[1] == g:
      if v[0] >= INF:print(-1)
      else:print(v[0])
      break
    U.append(v[1])
    for e in E[v[1]]:
      if not e[0] in U:
        heappush(h,(v[0] + e[1],e[0]))
  else:print(-1)
INF = 100000000
while True:
  try:
    n,k = map(int,input().split())
    if n == 0 and k == 0: break
    E = [[] for i in range(n)]
    for _ in range(k):
      lst = list(map(int,input().split()))
      if lst[0] == 0:
        dij(lst[1] - 1, lst[2] - 1, E)
      else:
        E[lst[1] - 1].append([lst[2] - 1, lst[3]])
        E[lst[2] - 1].append([lst[1] - 1, lst[3]])

  except EOFError:
    break
### BUGGY CODE ###

from functools import lru_cache
N = int(input())
A = list(map(int, input().split()))

@lru_cache(maxsize=2)
def f(i):
    if i >= 2:
        return f(i - 2) + 2 * A[i - 1] - 2 * A[i - 2]
    total = 0
    for j in range(N):
        if j % 2 == 0:
            total += A[(i + j) % N]
        else:
            total -= A[(i + j) % N]
    return total

B = (f(i) for i in range(N))

print(*B)

# A[0] = B[0] // 2 + B[1] // 2
# A[1] = B[1] // 2 + B[2] // 2
# A[2] = B[2] // 2 + B[3] // 2
# A[3] = B[3] // 2 + B[4] // 2
# A[4] = B[4] // 2 + B[0] // 2

# A[0] - A[1] = (B[0] - B[2]) // 2
# A[1] - A[2] = (B[1] - B[3]) // 2
# A[2] - A[3] = (B[2] - B[4]) // 2
# A[3] - A[4] = (B[3] - B[0]) // 2
# A[4] - A[0] = (B[4] - B[1]) // 2

# A[0] - A[1] + A[2] - A[3] + A[4] = B[0]
# A[1] - A[2] + A[3] - A[4] + A[0] = B[1]
# A[2] - A[3] + A[4] - A[0] + A[1] = B[2]
# A[3] - A[4] + A[0] - A[1] + A[2] = B[3]

#   A[0] - A[1] + A[2] - A[3] + A[4] = B[0]
# - A[0] + A[1] + A[2] - A[3] + A[4] = B[2]

#   A[1] - A[2] + A[3] - A[4] + A[0] = B[1]
# - A[1] + A[2] + A[3] - A[4] + A[0] = B[3]

# B[3] = B[1] + 2 * A[2] - 2 * A[1]


### FIXED CODE ###

from functools import lru_cache
N = int(input())
A = list(map(int, input().split()))

@lru_cache(maxsize=N)
def f(i):
    if i >= 2:
        return f(i - 2) + 2 * A[i - 1] - 2 * A[i - 2]
    total = 0
    for j in range(N):
        if j % 2 == 0:
            total += A[(i + j) % N]
        else:
            total -= A[(i + j) % N]
    return total

B = (f(i) for i in range(N))

print(*B)
### BUGGY CODE ###

def comb(n,k):
    nCk = 1
    MOD = 10**9+7

    for i in range(n-k+1, n+1):
        nCk *= i
        nCk %= MOD

    for i in range(1,k+1):
        nCk *= pow(i,MOD-2,MOD)
        nCk %= MOD
    return nCk

N, K = map(int, input().split())
MOD = 10 **9 + 7
ans = 0
for i in range(1, K + 1):
    ans = (comb(N - K + 1, i) * comb(K - 1, i - 1)) % MOD
    print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
MOD = 10 **9 + 7
C = [[0] * (N + 1) for i in range(N + 1)]
C[1][1] = 1
for i in range(2, N + 1):
    for j in range(1, i + 1):
        if j == 1:
            C[i][j] = C[i - 1][j] + 1
        elif j == i:
            C[i][j] = 1
        else:
            C[i][j] = C[i - 1][j - 1] + C[i - 1][j]
print(N - K + 1)
for i in range(2, K + 1):
    ans = (C[N - K + 1][i] * C[K - 1][i - 1]) % MOD
    print(ans)
### BUGGY CODE ###

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
  
import sys
sys.setrecursionlimit(100000)
from math import factorial


mod = 10**9+7 #出力の制限
N = 10**5+1
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
f=[0]*N
f[0]=1
for i in range(1,N):
  f[i]=(f[i-1]*i)%mod

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

n=int(input())
x=list(map(int,input().split()))
ans=0
for i in range(n-1):
  for j in range(i+1,n):
    if j!=n-1:
      ans=(ans+(((x[j]-x[i]))*cmb(n-1,j-i+1,mod)*f[n-1-j+i-1]*f[j-i-1])%mod)%mod
    else:
      ans=(ans+(((x[j]-x[i]))*cmb(n-1,j-i,mod)*f[n-1-j+i]*f[j-i-1])%mod)%mod
print(ans%mod)


### FIXED CODE ###

#----------------------------------------------------------
P = 10**9 + 7
N = 100001 #使う最大値+1以上にする、値に注意3*10^5とかにしとくと安心
inv = [0] + [1] # 1/x
finv = [1] + [1] # 1/x!
fac = [1] + [1] # x!
for i in range(2,N):
  inv += [inv[P % i] * (P - int(P / i)) % P]
  fac += [(fac[i-1] * i) % P]
  finv += [(finv[i-1] * inv[i]) % P]

def comb(a, b):
    if a<b or a<0 or b<0:
        return 0 # error
    return (fac[a] * ((finv[b] * finv[a-b]) % P)) %P
#----------------------------------------------------------

n=int(input())
x=list(map(int,input().split()))
s = [0] * n
for i in range(n):
    s[i] = x[i] + (s[i-1] if i>0 else 0)
ans=0

for i in range(n-1):
    t = (x[n-1]-x[n-2-i])%P
    t = (t * (fac[n-1]*inv[i+1])%P)%P
    ans=(ans+t)%P
for i in range(1, n-1):
    t = (s[n-2] - s[i-1] - s[n-2-i])%P
    p = (((fac[n-1] * inv[i])%P) * inv[i+1])%P
    ans = (ans + (t*p)%P)%P

print(ans%P)
### BUGGY CODE ###

from collections import defaultdict, deque
N, M = map(int, input().split())
dic = defaultdict(list)
for i in range(M):
  u, v = map(int, input().split())
  dic[u-1] += [v-1]
S, T = map(int, input().split())
S -= 1
T -= 1
dist = [[float('inf')]*3 for i in range(N)]
dist[S][0] = 0
q = deque([(S,0)])
flag = False
cnt = 0
while q:
  cnt += 1
  e, m = q.pop()
  n = (m+1)%3
  for p in dic[e]:
    if p==T:
      flag = True
    if dist[p][n]>dist[e][m]+1:
      dist[p][n] = dist[e][m]+1
      q += [(p,n)]
if flag:
  ans = dist[T][0] if dist[T][0]!=float('inf') else -1
  print(ans//3)
else:
  print(-1)


### FIXED CODE ###

from collections import defaultdict, deque
N, M = map(int, input().split())
dic = defaultdict(list)
for i in range(M):
  u, v = map(int, input().split())
  dic[u-1] += [v-1]
S, T = map(int, input().split())
S -= 1
T -= 1
dist = [[float('inf')]*3 for i in range(N)]
dist[S][0] = 0
q = deque([(S,0)])
flag = False
cnt = 0
while q:
  cnt += 1
  e, m = q.popleft()
  n = (m+1)%3
  for p in dic[e]:
    if p==T:
      flag = True
    if dist[p][n]>dist[e][m]+1:
      dist[p][n] = dist[e][m]+1
      q += [(p,n)]
if flag:
  ans = dist[T][0] if dist[T][0]!=float('inf') else -1
  print(ans//3)
else:
  print(-1)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
#from itertools import accumulate
#from itertools import combinations
N,K = map(int,input().split())
P = list(map(int,input().split()))
C = list(map(int,input().split()))

#N,K = 4,4
#P = [2,3,4,1]
#C = [-9,9,1,-1]

visited = [False]*(N+1)
loops = []
for v in range(1,N+1):
    if visited[v]:
        continue
    l = [v]
    while True:
        v = l[-1]
        visited[v] = True
        nv = P[v-1]
        if visited[nv]:
            break
        l.append(nv)
    loops.append(l)

cand = []
for loop in loops:
    temp = 0
    vals = [C[i-1] for i in loop]
    l = len(vals)
    vals2 = vals+vals[:-1]
    vals3 = vals+vals+vals[:-1]
    cumsum = [0]
    for v in vals3:
        cumsum.append(cumsum[-1] + v)
    #cumsum = [0] + list(accumulate(vals2))
    gh = []
    #print(vals)
    if K <= l:
        temp = 0
        for left in range(0,2*l-K):
            for right in range(left+1,left+K+1):
                gh.append(cumsum[right] - cumsum[left])
        if gh:
            temp = max(gh)
    else:
        temp = 0
        s = sum(vals)
        q, r = divmod(K,l)
        q -= 1
        r += l
        for left in range(0,3*l-r):
            for right in range(left+1,left+r+1):
                #print(left,right)
                gh.append(cumsum[right] - cumsum[left])
        if gh:
            temp = max(gh)
        if s > 0:
            temp += q * s
    cand.append(temp)
print(max(cand))






### FIXED CODE ###

import sys
input = sys.stdin.readline
#from itertools import accumulate
#from itertools import combinations
N,K = map(int,input().split())
P = list(map(int,input().split()))
C = list(map(int,input().split()))

#N,K = 4,4
#P = [2,3,4,1]
#C = [-9,9,1,-1]
#N = 5000
#K = 10**8
#P = [i+1 for i in range(1,5000)] + [1]
#C = [10**9] * N

visited = [False]*(N+1)
loops = []
for v in range(1,N+1):
    if visited[v]:
        continue
    l = [v]
    while True:
        v = l[-1]
        visited[v] = True
        nv = P[v-1]
        if visited[nv]:
            break
        l.append(nv)
    loops.append(l)

cand = []
for loop in loops:
    temp = 0
    vals = [C[i-1] for i in loop]
    l = len(vals)
    vals3 = vals+vals+vals[:-1]
    cumsum = [0]
    for v in vals3:
        cumsum.append(cumsum[-1] + v)
    gh = []
    #print(vals)
    if K <= l:
        temp = 0
        ma = min(vals)
        for left in range(0,2*l-K):
            for right in range(left+1,left+K+1):
                ma = max(ma,(cumsum[right] - cumsum[left]))
        temp += ma
    else:
        temp = 0
        s = sum(vals)
        q, r = divmod(K,l)
        q -= 1
        r += l
        ma = min(vals)
        for left in range(0,3*l-r):
            for right in range(left+1,left+r+1):
                ma = max(ma,(cumsum[right] - cumsum[left]))
        temp += ma
        if s > 0:
            temp += q * s
    cand.append(temp)
print(max(cand))
### BUGGY CODE ###

X, Y, Z, K = map(int, input().split())
*A, = sorted(map(int, input().split()), reverse=True)
*B, = sorted(map(int, input().split()), reverse=True)
*C, = sorted(map(int, input().split()), reverse=True)
AB = [A[x]+B[y] for x in range(X) for y in range(Y)]
AB.sort(reverse=True)
AB = AB[:K]
XY = len(AB)
ABC = [AB[xy]+C[z] for xy in range(XY) for z in range(Z)]
ABC.sort(reverse=True)
for k in range(K):
    print(ABC[k])


### FIXED CODE ###

X, Y, Z, K = map(int, input().split())
*A, = sorted(map(int, input().split()), reverse=True)
*B, = sorted(map(int, input().split()), reverse=True)
*C, = sorted(map(int, input().split()), reverse=True)
AB = [A[x] + B[y] for y in range(Y) for x in range(X)]
AB.sort(reverse=True)
AB = AB[:K]
ABC = [AB[x] + C[z] for z in range(Z) for x in range(len(AB))]
ABC.sort(reverse=True)
for k in range(K):
    print(ABC[k])
### BUGGY CODE ###

def main():
    N = int(input())
    ans = 1
    for i in range(N):
        ans = ans * (i+1)
    print(ans%(10**9+7))
    
main()

### FIXED CODE ###

def main():
    N = int(input())
    ans = 1
    for i in range(N):
        ans = (ans * (i+1)) % (10**9+7)
    print(ans)
    
main()
### BUGGY CODE ###

n=int(input()) #　a1
ap = [int(input()) for i in range(n)]

psum=[]

for a in ap:
  if a in psum:
    psum.remove(a)
  else:
    psum.append(a)

print(len(psum))

### FIXED CODE ###

n=int(input()) #　a1
s=set()
for i in range(n):
  s^={input()}
print(len(s))
### BUGGY CODE ###

def key_func(n):
	return n[0]

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

list_price_and_energydrink = []

for i in range(N):
	A_i, B_i = map(int, input().split())
	list_shop_number_i = [A_i, B_i]
	list_price_and_energydrink.append(list_shop_number_i)
	
list_price = []
list_possible_number_drink = []

count_number_drink = 0
count_price_drink = 0

while count_number_drink < M:
	list_minimum_i = min(list_price_and_energydrink, key=key_func)
	
	if count_number_drink + list_minimum_i[1] > M:
		count_price_drink += list_minimum_i[0] * (M - count_number_drink)
		count_number_drink = M
	else:
		count_number_drink += list_minimum_i[1]
		count_price_drink += list_minimum_i[0] * list_minimum_i[1]	
	
	list_price_and_energydrink.remove(list_minimum_i)

print(count_price_drink)

### FIXED CODE ###

from operator import itemgetter

def key_func(n):
	return n[0]

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

list_price_and_energydrink = []

for i in range(N):
	A_i, B_i = map(int, input().split())
	list_shop_number_i = [A_i, B_i]
	list_price_and_energydrink.append(list_shop_number_i)

count_number_drink = 0
count_price_drink = 0

list_price_and_energydrink.sort(key=itemgetter(0))

while count_number_drink < M:
	list_minimum_i = list_price_and_energydrink[0]
	
	if count_number_drink + list_minimum_i[1] > M:
		count_price_drink += list_minimum_i[0] * (M - count_number_drink)
		count_number_drink = M
	else:
		count_number_drink += list_minimum_i[1]
		count_price_drink += list_minimum_i[0] * list_minimum_i[1]	
	
	list_price_and_energydrink.remove(list_minimum_i)

print(count_price_drink)
### BUGGY CODE ###

line = input()
data = line.split(" ")
shoplist = [] #店のデータリスト
for i in range(int(data[0])):
    shop = input()
    shopdata = shop.split(" ")
    shop_int = []
    for j in range(len(shopdata)):
        shop_int.append(int(shopdata[j]))
    shoplist.append(shop_int)

payment = 0 #支払い金額
wantdrink = int(data[1]) #ほしい飲み物の数
pricelist = []  #金額のみのデータリスト
for i in range(len(shoplist)):
    pricelist.append(shoplist[i][0])
while wantdrink > 0 :
    pricemin = min(pricelist[i] for i in range(len(pricelist)))
    min_index = pricelist.index(pricemin)
    restwater = shoplist[min_index][1]
    while restwater > 0:
        payment += pricemin
        restwater -= 1
        wantdrink -= 1
        if wantdrink == 0:
            break
    del shoplist[min_index]
    del pricelist[min_index]
print(payment)

### FIXED CODE ###

# coding: utf-8

data = input().split()
shoplist = []
for i in range(int(data[0])):
    shopdata = list(map(int, input().split()))
    shoplist.append(shopdata)
shoplist.sort()

payment = 0
wantdrink = int(data[1])
while wantdrink > 0 :
    restdrink = shoplist[0][1]
    if restdrink >= wantdrink:
        payment += wantdrink * shoplist[0][0]
        break
    else:
        payment += restdrink * shoplist[0][0]
        wantdrink -= restdrink
        del shoplist[0]
print(payment)