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

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

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

N = int(input())
P = list(map(int, input().split()))
Pmin = [0] * N
for i in range(N):
    minP = 2 * 10**5
    for j in range(i+1):
        minP = min(minP, P[j])
    Pmin[i] = minP

ans = 0
for i in range(N):
    if Pmin[i] >= P[i]:
        ans += 1

print(ans)


### FIXED CODE ###

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

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

N = int(input())
P = list(map(int, input().split()))
Pmin = [2*10**5 for i in range(N)]
Pmin[0] = P[0]
for i in range(1, N):
    Pmin[i] = min(Pmin[i-1], P[i])

ans = 0
for i in range(N):
    if Pmin[i] >= P[i]:
        ans += 1

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

import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

n,m=map(int,input().split())
l=[]
for i in range(n):
    for j in input().split()[1:]:
        l.append((i,int(j)+n-1,1))
edge=np.array(l,dtype=np.int64).T
graph=csr_matrix(((edge[2],edge[:2])),(n+m,n+m))
ans=dijkstra(graph,directed=False,indices=0)
for i in ans[:n]:
    if i==float("inf"):
        print("NO")
        exit()
print("YES")

### FIXED CODE ###

import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import connected_components
import sys
input=sys.stdin.readline

n,m=map(int,input().split())
l=[]
for i in range(n):
    for j in input().split()[1:]:
        l.append((i,int(j)+n-1,1))
edge=np.array(l,dtype=np.int64).T
graph=csr_matrix(((edge[2],edge[:2])),(n+m,n+m))

_,ll=connected_components(graph)

if 1 in ll[:n]:
    print("NO")
else:
    print("YES")
### BUGGY CODE ###

p = 1000000007
N = int(input())
T = [[] for _ in range(N)]
for _ in range(N - 1):
  (a, b) = (int(x) - 1 for x in input().split())
  T[a].append(b)
  T[b].append(a)
P = [-1] * N
P[0] = 0
Q = [0]
for i in range(N):
  q = Q[i]
  for adj in T[q]:
    if 0 <= P[adj]:
      continue
    P[adj] = q
    Q.append(adj)
ST = [[] for _ in range(N)]
for q in Q[N - 1:0:-1]:
  s = sum(ST[q]) + 1
  ST[P[q]].append(s)
  ST[q].append(N - s)
B = [pow(1 << i, p - 2, p) for i in range(N)]
H = [0] * N
ans = 0
for S in ST:
  ans += B[1] * ((1 - B[-1] - sum([(B[N - 1 - s] * (1 - B[s])) % p for s in S])) % p)
  ans %= p
print(ans)

### FIXED CODE ###

p = 1000000007
N = int(input())
T = [[] for _ in range(N)]
for _ in range(N - 1):
  (a, b) = (int(x) - 1 for x in input().split())
  T[a].append(b)
  T[b].append(a)
P = [-1] * N
P[0] = 0
Q = [0]
for i in range(N):
  q = Q[i]
  for adj in T[q]:
    if 0 <= P[adj]:
      continue
    P[adj] = q
    Q.append(adj)
ST = [[] for _ in range(N)]
for q in Q[N - 1:0:-1]:
  s = sum(ST[q]) + 1
  ST[P[q]].append(s)
  ST[q].append(N - s)
B = [1] * N
B[-1] = pow(1 << (N - 1), p - 2, p)
for i in range(N - 1, 0, -1):
  B[i - 1] = B[i] * 2 % p
H = [0] * N
ans = 0
for S in ST:
  ans += B[1] * ((1 - B[-1] - sum([(B[N - 1 - s] * (1 - B[s])) % p for s in S])) % p)
  ans %= p
print(ans)
### BUGGY CODE ###

def main():
    import sys
    from collections import defaultdict
    dic = defaultdict(int)

    input = sys.stdin.readline

    s = str(input().rstrip())
    m = 0

    for i in range(1,len(s)+1):
        m_ad = (int(s[-i]) * (10 ** (i - 1))) % 2019
        m = (m_ad + m) % 2019
        dic[m] += 1

    ans1 = 0

    for x in dic.values():
        if x > 1:
            ans1 += x * (x - 1) // 2
    ans2 = dic[0]

    print(ans1 + ans2)

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    import sys
    from collections import defaultdict
    dic = defaultdict(int)

    input = sys.stdin.readline

    s = str(input().rstrip())
    m = 0
    before_m = 0.1

    for i in range(1, len(s) + 1):
        before_m = int(before_m*10)%2019
        m_ad = (int(s[-i]) * before_m) % 2019
        m = (m_ad + m) % 2019
        dic[m] += 1

    ans1 = 0

    for x in dic.values():
        if x > 1:
            ans1 += x * (x - 1) // 2
    ans2 = dic[0]

    print(ans1 + ans2)

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

from collections import deque

def make_wall(maze,h,w):
    maze=deque(maze)
    for i in range(h):
        maze[i]="##"+maze[i]+"##"
    maze.appendleft("#"*(w+4))
    maze.appendleft("#"*(w+4))
    maze.append("#"*(w+4))
    maze.append("#"*(w+4))
    return list(maze)

def bfs(maze, visited, sy, sx, gy, gx):
    queue = deque([[sy, sx]])
    cost[sy][sx]=0
    walk = [(1, 0), (-1, 0), (0, 1), (0, -1)]
    warp = [(i,j) for i in range(-2,3) for j in range(-2,3) if (i,j) not in [(0,0)]+walk]
    
    while queue:
        y, x = queue.popleft()
        if [y, x] == [gy, gx]:
            return cost[y][x]
        
        # 移動A
        for i,j in walk:
            ny, nx = y+i, x+j
            if maze[ny][nx] == "." and cost[ny][nx]>cost[y][x]:
                cost[ny][nx]=cost[y][x]
                queue.appendleft([ny,nx])
            
        # 移動B
        for i, j in warp:
            ny, nx = y+i, x+j
            if cost[ny][nx] > cost[y][x]+1 and maze[ny][nx]==".":
                cost[ny][nx]=cost[y][x]+1
                queue.append([ny,nx])
            
    return -1 #ゴールできない

h,w=map(int,input().split())
sy,sx=map(int,input().split())
gy,gx=map(int,input().split())

maze=[input() for _ in range(h)]

maze=make_wall(maze,h,w)
h+=4
w+=4
sy+=2
sx+=2
gy+=2
gx+=2

INF = 10**12
cost = [[INF]*w for _ in range(h)]

ans=bfs(maze, cost, sy-1, sx-1, gy-1, gx-1)
if ans==INF:
    ans=-1
print(ans)


### FIXED CODE ###

from collections import deque

def make_wall(maze,h,w):
    maze=deque(maze)
    for i in range(h):
        maze[i]="##"+maze[i]+"##"
    maze.appendleft("#"*(w+4))
    maze.appendleft("#"*(w+4))
    maze.append("#"*(w+4))
    maze.append("#"*(w+4))
    return list(maze)

def bfs(maze, visited, sy, sx, gy, gx):
    queue = deque([[sy, sx]])
    cost[sy][sx]=0
    walk = [(1, 0), (-1, 0), (0, 1), (0, -1)]
    warp = [(i,j) for i in range(-2,3) for j in range(-2,3) if (i,j) not in [(0,0)]+walk]
    
    while queue:
        y, x = queue.popleft()
        if [y, x] == [gy, gx]:
            return cost[y][x]
        
        # 移動A
        for i,j in walk:
            ny, nx = y+i, x+j
            if maze[ny][nx] == "." and cost[ny][nx]>cost[y][x]:
                cost[ny][nx]=cost[y][x]
                queue.appendleft([ny,nx])
            
        # 移動B
        for i, j in warp:
            ny, nx = y+i, x+j
            if cost[ny][nx] > cost[y][x]+1 and maze[ny][nx]==".":
                cost[ny][nx]=cost[y][x]+1
                queue.append([ny,nx])
            
    return -1 #ゴールできない

h,w=map(int,input().split())
sy,sx=map(int,input().split())
gy,gx=map(int,input().split())

maze=[input() for _ in range(h)]

maze=make_wall(maze,h,w)
h+=4
w+=4
sy+=2
sx+=2
gy+=2
gx+=2

INF = 10**12
cost = [[INF]*w for _ in range(h)]

ans=bfs(maze, cost, sy-1, sx-1, gy-1, gx-1)
if ans==INF:
    ans=-1
print(ans)
### BUGGY CODE ###

N = int(input())
P_list = list(map(int,input().split()))

cnt = 0
for i in range(1,N+1):
  ans_list = P_list[:i]
  ans_list.sort()
  if ans_list[0] == P_list[i-1]:
    cnt += 1

print(cnt)

### FIXED CODE ###

N = int(input())
P_list = list(map(int,input().split()))
M = P_list[0]
cnt = 1

for i in range(N):
  if M > P_list[i]:
    cnt += 1
    M = P_list[i]

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

N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = input()
res = 0
k = ''
log = ''
for i in range(N):
  t = T[i]
  if t == 'r':
    if K <= i and log[i-K] == 'p':
      log += 'x'
    else:
      res += P
      log += 'p'
  elif t == 's':
    if K <= i and log[i-K] == 'r':
      log += 'x'
    else:
      res += R
      log += 'r'
  else:
    if K <= i and log[i-K] == 's':
      log += 'x'
    else:
      res += S
      log += 's'

print(res)


### FIXED CODE ###

N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = input()
res = 0
k = ''
log = []
for i in range(N):
  t = T[i]
  if t == 'r':
    if K <= i and log[i-K] == 'p':
      log.append('x')
    else:
      res += P
      log.append('p')
  elif t == 's':
    if K <= i and log[i-K] == 'r':
      log.append('x')
    else:
      res += R
      log.append('r')
  else:
    if K <= i and log[i-K] == 's':
      log.append('x')
    else:
      res += S
      log.append('s')

print(res)
### BUGGY CODE ###

H,W,D=map(int,input().split());A=[list(map(int,input().split())) for _ in range(H)];Q=int(input());d=[0]*(H*W+1);g=[[0]*(H*W+1) for _ in range(D+1)]
for i in range(H):
  for j in range(W):d[A[i][j]]=[i,j]
for i in range(1,D+1):
  for j in range(1,H*W//D+1):
    if i+D*j<=H*W:g[i][i+j*D]=abs(d[i+j*D-D][0]-d[i+j*D][0])+abs(d[i+j*D-D][1]-d[i+j*D][1])+g[i][i+D*j-D]
g[0]=g[D]
for q in range(Q):
  l,r=map(int,input().split());t=l%D;print(g[t][r]-g[t][l])

### FIXED CODE ###

H,W,D=map(int,input().split());A=[list(map(int,input().split())) for _ in range(H)];Q=int(input());d=[0]*(H*W+1);g=[0]*(H*W+1)
for i in range(H):
  for j in range(W):d[A[i][j]]=[i,j]
for i in range(1,H*W-D+1):
  g[i+D]=abs(d[i+D][0]-d[i][0])+abs(d[i+D][1]-d[i][1])+g[i]
for q in range(Q):
  l,r=map(int,input().split());print(g[r]-g[l])
### BUGGY CODE ###

def main():
    import math
    n = int(input())
    a = sorted(list(map(int,input().split())))
    g=a[0]
    for i in range(1,n):
        g = math.gcd(g,a[i])
    if g > 1:
        print('not coprime')
        return
    d = [1 for i in range(a[-1])]
    for i in range(2,a[-1]+1):
        if d[i-1] == 1:
            for j in range(1,a[-1]//i+1):
                if d[i*j-1] == 1:
                    d[i*j-1] = i
    prm = [0 for i in range(a[-1])]
    for i in range(n):
        p = []
        while a[i] != 1:
            p.append(d[a[i]-1])
            a[i] = a[i] // d[a[i]-1]
        p = set(p)
        for p_ in p:
            prm[p_-1] += 1
    for i in range(1,len(prm)):
        if prm[i]>1:
            print('setwise coprime')
            return
    print('pairwise coprime')

if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    import math
    n = int(input())
    a = sorted(list(map(int,input().split())))
    g=a[0]
    for i in range(1,n):
        g = math.gcd(g,a[i])
    if g > 1:
        print('not coprime')
        return
    d = [1 for i in range(a[-1])]
    for i in range(2,a[-1]+1):
        if d[i-1] == 1:
            for j in range(1,a[-1]//i+1):
                if d[i*j-1] == 1:
                    d[i*j-1] = i
    prm = {}
    for i in range(n):
        p = []
        while a[i] != 1:
            p.append(d[a[i]-1])
            a[i] = a[i] // d[a[i]-1]
        p = set(p)
        for p_ in p:
            if prm.get(p_)==None:
                prm[p_] = 1
            else:
                print('setwise coprime')
                return
    print('pairwise coprime')

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

import math
import sys
from functools import reduce


def eratosthenes(n):
    prime = [2]
    limit = int(n**0.5)
    prime_list = [i + 1 for i in range(2, n, 2)]
    while True:
        p = prime_list[0]
        if limit <= p:
            return prime + prime_list
        prime.append(p)
        prime_list = [e for e in prime_list if e % p != 0]

def prime_factorize(n):
    prime_list = eratosthenes(n)
    arr = []

    for p in prime_list:
        if n % p == 0:
            cnt = 0
            while n % p == 0:
                n //= p
                cnt += 1
            arr.append([p, cnt])
    
    return arr

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


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

prime_list = eratosthenes(n)
check = [0]*(10**6)
pairwise = True

for x in a:
    for p in prime_list:
        if x % p == 0:
            if check[p]:
                pairwise = False
            check[p] += 1
            if check[p] == n:
                print('not coprime')
                sys.exit()

if pairwise:
    print('pairwise coprime')
else:
    print('setwise coprime')
    

### FIXED CODE ###

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

num = [0]*(10**6+1)

for x in a:
    num[x] += 1

pairwise = True
for i in range(2, 10**6+1):
    cnt = sum(num[i::i])
    if cnt == n:
        print('not coprime')
        exit()
    if cnt > 1:
        pairwise = False

if pairwise:
    print('pairwise coprime')
else:
    print('setwise coprime')
### BUGGY CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

### 素数の逆元とCombination

M = p
N = 10**4 # 必要なテーブルサイズ

g1 = [None] * (N+1) # 元テーブル
g2 = [None] * (N+1) #逆元テーブル
inverse = [None] * (N+1) #逆元テーブル計算用テーブル
g1[0] = g1[1] = g2[0] = g2[1] = 1
inverse[0], inverse[1] = [0, 1] 

for i in range( 2, N + 1 ):
    g1[i] = ( g1[i-1] * i ) % M 
    inverse[i] = ( -inverse[M % i] * (M//i) ) % M # ai+b==0 mod M <=> i==-b*a^(-1) <=> i^(-1)==-b^(-1)*aより
    g2[i] = (g2[i-1] * inverse[i]) % M 

def cmb(n, r, M):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return (g1[n] * g2[r] * g2[n-r]) % M
ans = [0]*p
for i,num in enumerate(a):
    if num==0:
        continue
    for j in range(p):
        ans[j] += -cmb(p-1,j,M) * pow(-i,p-1-j)
    ans[0] += 1
for i in range(p):
    ans[i] %= M
write(" ".join(map(str, ans)))

### FIXED CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

### 素数の逆元とCombination

M = p
N = 10**4 # 必要なテーブルサイズ

g1 = [None] * (N+1) # 元テーブル
g2 = [None] * (N+1) #逆元テーブル
inverse = [None] * (N+1) #逆元テーブル計算用テーブル
g1[0] = g1[1] = g2[0] = g2[1] = 1
inverse[0], inverse[1] = [0, 1] 

for i in range( 2, N + 1 ):
    g1[i] = ( g1[i-1] * i ) % M 
    inverse[i] = ( -inverse[M % i] * (M//i) ) % M # ai+b==0 mod M <=> i==-b*a^(-1) <=> i^(-1)==-b^(-1)*aより
    g2[i] = (g2[i-1] * inverse[i]) % M 

def cmb(n, r, M):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return (g1[n] * g2[r] * g2[n-r]) % M
ans = [0]*p
for i,num in enumerate(a):
    if num==0:
        continue
    for j in range(p):
        ans[j] += -cmb(p-1,j,M) * pow(-i,p-1-j,M)
        ans[j] %= M
    ans[0] += 1
for i in range(p):
    ans[i] %= M
write(" ".join(map(str, ans)))
### BUGGY CODE ###

n,p=map(int,input().split())
s=list(map(int,list(input())))
dp=[[-1,-1] for i in range(n)]
for i in range(n):
    d=0
    for j in range(i,n):
        d=10*d+s[j]
        if d%p==0:
            dp[i]=[1,j+1]
            break

ans=0
for i in range(n):
    if dp[i]!=[-1,-1]:
        ans+=dp[i][0]
        if dp[i][1]!=n:
            if dp[dp[i][1]]!=[-1,-1]:
                dp[dp[i][1]][0]+=dp[i][0]

print(ans)

### FIXED CODE ###

from itertools import groupby
n,p=map(int,input().split())
s=[int(i) for i in input()]
if p==2 or p==5:
    ans=0
    for i in range(n-1,-1,-1):
        #Rとなるもの
        if s[i]%p==0:
            ans+=(i+1)
    exit(print(ans))
S=[0]*(n+1)
po=[1]*(n+1)
for i in range(n):
    po[i+1]=po[i]*10
    po[i+1]%=p
for i in range(n-1,-1,-1):
    S[i]=S[i+1]+s[i]*po[n-1-i]
    S[i]%=p
t=[[S[i],i] for i in range(n+1)]
t.sort()
#[L,R)となるのの候補
u=[[i[1] for i in sorted(list(group))] for key,group in groupby(t,key=lambda x: x[0])]
ans=0
for v in u:
    ans+=(len(v))*(len(v)-1)//2
print(ans)
### BUGGY CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def rec(i,j,k):
    if dp[i][j][k]>=0:
        return dp[i][j][k]
    if i==0 and j==0 and k==0:
        return 0.0
    res=0.0
    if i>0:res+=rec(i-1,j,k)*i
    if j>0:res+=rec(i+1,j-1,k)*j
    if k>0:res+=rec(i,j+1,k-1)*k
    res+=n
    res/=i+j+k
    dp[i][j][k]=res
    return res

def main():
    global dp,n
    n=int(input())
    A=list(map(int,input().split()))
    ac=Counter(A)
    #1個がi個，2個がj個，3個がk個
    dp=[[[-1.0]*(n+1) for j in range(n+1)]for i in range(n+1)]
    print(rec(ac[1],ac[2],ac[3]))


if __name__=='__main__':
    main()

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    n=int(input())
    A=list(map(int,input().split()))
    ac=Counter(A)
    #1個がi個，2個がj個，3個がk個
    dp=[[[0.0]*(n+1) for j in range(n+1)]for i in range(n+1)]
    max_i,max_j,max_k=ac[1],ac[2],ac[3]
    for k in range(max_k+1):
        for j in range(max_j+max_k+1):
            for i in range(min(max_i+max_j+max_k+1,n-(j+k)+1)):
                if i+j+k==0:continue
                res=n
                if i>0:res+=dp[i-1][j][k]*i
                if j>0:res+=dp[i+1][j-1][k]*j
                if k>0:res+=dp[i][j+1][k-1]*k
                res/=i+j+k
                dp[i][j][k]=res
    print(dp[max_i][max_j][max_k])

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

import heapq
import bisect

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

F = sorted(F, reverse = True)
A = sorted(A)
flg = 0
lst = []

for i in range(N):
	if A[i] == 0 or F[i] == 0:
		break
	else:
		lst.insert(bisect.bisect_left(lst, [A[i] * F[i], F[i]]),[A[i] * F[i], F[i]]) 
		# heapq.heappush(heap, [- A[i] * F[i], F[i]])
		
for i in range(K):
	popped = lst.pop(-1)
	popped[0] -= popped[1]
	lst.insert(bisect.bisect_left(lst, popped), popped)

print(lst[-1][0])	

### FIXED CODE ###

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

A.sort()
F.sort(reverse = True)

ng = -1
ok = 10 ** 12

while ok - ng > 1:
	mid = (ok + ng) // 2
	ctr = 0
	for i in range(N):
		ctr += max(0, A[i] - mid // F[i])
	if ctr <= K:
		ok = mid
	else:
		ng = mid

print(ok)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
count = 0
for i in range (0,N-1):
    while(A[i]>A[i+1]):
        count += 1
        A[i+1] += 1
    if(A[i]<=A[i+1]):
        continue

print(count)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
count = 0
max = A[0]
for i in range (0,N):
    while(max>A[i]):
        count = count + (max - A[i])
        A[i] = max
       # print(A)
    if(max<=A[i]):
        max = A[i]
      #  print(A)
print(count)
### BUGGY CODE ###

N = int(input())
A = sorted(list(map(int, input().split())))
memo = {}
ans = 0

for a in A:
    if not a in memo:
        flag = True
        for div in memo:
            if a % div == 0:
                flag = False
                break
        if flag:
            ans += 1
            memo[a] = 1
    else:
        if memo[a] == 1:
            ans -= 1
            memo[a] += 1
        else:
            continue

print(ans)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
memo = [0]*(10**6+1)

for a in A:
    memo[a] += 1
    if memo[a] < 2:
        for i in range(2*a, 10**6+1, a):
            memo[i] += 1

ans = 0
for a in A:
    if memo[a] == 1:
        ans += 1

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

import sys
n,m = map(int,input().split())
d = []
a = 0
w = 0

if m == 0:
    print(0,0)
    sys.exit()
for i in range(m):
    p,s = input().split()
    if (p,"AC") not in d:
        d.append((p,s))
for j in d:
    if j[1] == "AC":
        a += 1
    elif j[1] == "WA":
        w += 1
print(a,w)

### FIXED CODE ###

n,m = map(int,input().split())
ps = [list(input().split()) for _ in range(m)]
aw = ["WA"] * n
wacnt = [0] * n
ac = 0
wa = 0
for i in ps:
    if aw[int(i[0])-1] == "WA":
        if i[1] == "AC":
            ac += 1
            wa += wacnt[int(i[0])-1]
            aw[int(i[0])-1] = "AC"
        else:
            wacnt[int(i[0])-1] += 1
    else:
        pass
print(ac,wa)
### BUGGY CODE ###

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)
ans = []

for i in range(min(X, K)):
  for j in range(min(Y, K)):
    for k in range(min(Z, K)):
      ans.append(A[i] + B[j] + C[k])

ans.sort(reverse = True)

for i in range(K):
  print(ans[i])

### FIXED CODE ###

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)
ans = []

for i in range(min(X, K)):
  for j in range(min(Y, K)):
    if (i + 1) * (j + 1) > K:
      break
    for k in range(min(Z, K)):
      if (i + 1) * (j + 1) * (k + 1) > K:
        break
      ans.append(A[i] + B[j] + C[k])

ans.sort(reverse = True)

for i in range(K):
  print(ans[i])
### BUGGY CODE ###

n = int(input())

ans = 0

table = [[0]*10 for _ in range(10)]

for i in range(1,10):
    for j in range(1, 10):
        number = 1
        while number <= n:
            n_str = str(number)
            if int(n_str[0]) == i and int(n_str[-1]) == j:
                table[i][j] += 1
            number += 1

for i in range(1,10):
    for j in range(1, 10):
        ans += table[j][i] * table[i][j]
print(ans)






### FIXED CODE ###

n = int(input())

ans = 0

table = [[0]*10 for _ in range(10)]

for number in range(1, n+1):
    i = int(str(number)[0])
    j = int(str(number)[-1])
    table[i][j] += 1

for i in range(1,10):
    for j in range(1, 10):
        ans += table[j][i] * table[i][j]
print(ans)
### BUGGY CODE ###

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

ans = {i for i in range(1, N + 1)}
for line in sys.stdin:  # much faster than input
    L, R = map(int, line.split())
    allowed = {i for i in range(L, R + 1)}
    ans = ans & allowed

print(len(ans))


### FIXED CODE ###

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

Lmax = 1
Rmin = N
for line in sys.stdin:  # much faster than input
    L, R = map(int, line.split())
    Lmax = max(L, Lmax)
    Rmin = min(R, Rmin)

print(max(0, Rmin - Lmax + 1))
### BUGGY CODE ###

H,W=map(int,input().split())
sum=0
for i in range(H):
    for j in range(W):
        if (i-j)%2==0:
            sum+=1
print(sum)

### FIXED CODE ###

import math
H,W=map(int,input().split())
sum=0
# for i in range(H):
#     for j in range(W):
#         if (i-j)%2==0:
#             sum+=1
if H==1 or W==1:
    print(1)
else:
    sum=(H*W)/2
    print(math.ceil(sum))
### BUGGY CODE ###

a,b=input().split()
a=int(a)
b=int(b)
x=10
y=int(x*8/100)
z=int(x*10/100)
i=0
while i==0:
  if int(x*8/100)==a and int(x*10/100)==b:
    print(x)
    break
  else:
    x=x+1

### FIXED CODE ###

a,b=input().split()
a=int(a)
b=int(b)
x=10
y=int(x*8/100)
z=int(x*10/100)
i=0
while x<10000:
  if int(x*8/100)==a and int(x*10/100)==b:
    print(x)
    break
  else:
    x=x+1
if x==10000:
  print("-1")