Harryxun/stf_run huggingface dataset:
N = int(input())
As = list(map(int, input().split()))

def func(Bs):
    for x in range(N):
        if Bs[x] >= 0: continue
        if max(Bs[x::x + 1]) <= 0:
            Bs[x] = 0

func(As)

for x in range(34, 51):
    if As[x - 1] + As[x * 2 - 1] < 0:
        As[x - 1] = 0
        As[x * 2 - 1] = 0

for x in [27, 29, 31, 33]:
    if As[x - 1] + As[x * 2 - 1] + As[x * 3 - 1] < 0:
        As[x - 1] = 0
        As[x * 2 - 1] = 0
        As[x * 3 - 1] = 0
zs = [27, 29, 31, 33] + list(range(34, 51))

ns = [1, 2, 4, 8, 16, 32] + [3, 6, 9, 12, 18, 24, 27, 36, 48] \
    + [5, 10, 15, 20, 25, 30, 40, 45, 50] + [7, 14, 21, 28, 35, 42, 49] \
    + [11, 22, 33, 44] + [13, 26, 39] + [17, 34] + [19, 38] + [23, 46] \
    + [29, 31, 37, 41, 43, 47]

memo = {}
memo[tuple(As)] = sum(As)

cs = [n - 1 for n in ns if n <= N and n not in zs and As[n - 1] < 0]
for c in cs:
    for tupleA in list(memo.keys()):
        if tupleA[c] == 0:
            continue

        listA = list(tupleA)
        for x in range(c, N, c + 1):
            listA[x] = 0

        func(listA)
        memo[tuple(listA)] = sum(listA)

print(max(memo.values()))


### FIXED CODE ###

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

def func(Bs):
    for x in range(N):
        if Bs[x] >= 0: continue
        if max(Bs[x::x + 1]) <= 0:
            Bs[x] = 0

func(As)

zs = [27, 29, 31, 33] + list(range(34, 51))
for x in zs:
    if sum(As[x - 1::x]) < 0:
        for i in range(x - 1, N, x):
            As[i] = 0

ns = [1, 2, 4, 8, 16, 32] + [3, 6, 9, 12, 18, 24, 27, 36, 48] \
    + [5, 10, 15, 20, 25, 30, 40, 45, 50] + [7, 14, 21, 28, 35, 42, 49] \
    + [11, 22, 33, 44] + [13, 26, 39] + [17, 34] + [19, 38] + [23, 46] \
    + [29, 31, 37, 41, 43, 47]

memo = {}
memo[tuple(As)] = sum(As)

cs = [n - 1 for n in ns if n <= N and n not in zs and As[n - 1] < 0]
for c in cs:
    for tupleA in list(memo.keys()):
        if tupleA[c] == 0:
            continue

        listA = list(tupleA)
        for x in range(c, N, c + 1):
            listA[x] = 0

        func(listA)
        memo[tuple(listA)] = sum(listA)

print(max(memo.values()))
a,b,c=map(int,input(),split())
d=a*b
if d<c:
  print(d)
else:
  print(c)

### FIXED CODE ###

a,b,c=map(int,input().split())
d=a*b
if d<c:
  print(d)
else:
  print(c)
S, T = map(str, input().split)
A, B = map(int, input().split)
input()

a = A - 1
b = B - 1

if U == S:
  print({} {}.format(a,B))
else:
  print({} {}.format(A.b))


### FIXED CODE ###

S, T = map(str, input().split())
A, B = map(int, input().split())
U = input()

a = A - 1
b = B - 1

if U == S:
  print('{} {}'.format(a,B))
else:
  print('{} {}'.format(A,b))
N,K = map(int,input().split())
s = list(map(int,input()))
s.append(2)
start = s[0]
choku = [0]
saka = [0]
number = 1
for i in range(N):
    if s[i] == s[i+1]:
        number += 1
    else:
        if s[i] == 0:
            choku.append(number)
            number = 1
        else:
            saka.append(number)
            number = 1
choku.append(0)
saka.append(0)
while(1):
    max_align = 0
    m = len(choku)
    n = len(saka)
    if m <= K:
        print(N)
        break
    if start == 0: #最初が直立の場合
        for i in range(m-K+1):
            if max_align <= sum(choku[i:i+K]) + sum(saka[i-1:i+K]):
                max_align = sum(choku[i:i+K]) + sum(saka[i-1:i+K])
    else:
        for i in range(m-K+1):
            if max_align <= sum(choku[i:i+K]) + sum(saka[i:i+K+1]):
                max_align = sum(choku[i:i+K]) + sum(saka[i:i+K+1])
    print(max_align)
    break

### FIXED CODE ###

A,B = map(int,input().split())
if A == B:
  print(2 * A)
elif A > B:
  print(2 * A -1)
else:
  print(2 * B -1)
#n = int(input())
n,m = map(int,input().split())
#a_L = list(map(int,input().split()))

nCr = {}


def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

if n != 1:
    a = cmb(n,2)
else:
    a = 0

if m != 1:
    b = cmb(m,2)
else:
    b = 0
print(a + b)

### FIXED CODE ###

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

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

if n != 1 and n !=0:
    a = cmb(n,2)
else:
    a = 0

if m != 1 and m !=0:
    b = cmb(m,2)
else:
    b = 0
print(a + b)
s=input()
k=int(input())
if s.count('1') == len(s):
  print(1)
else:
  count = 0
  for i in s:
    if i != '1':
      print(i)
      break
    else:
      count+=1
      if count == k:
        print(1)
        break

### FIXED CODE ###

s=input()
k=int(input())
if s.count('1') == len(s):
  print(1)
else:
  count = 0
  for i in s:
    if i != '1':
      print(i)
      break
    else:
      count+=1
      if count == k:
        print(1)
        break
n= input().split()
n = int(n)
nums= input().split()
#map(int,input().split())
state = 1
for i in range(n):
    if nums[i] &1 == 0 :
        if nums[i]%3 ==0 or nums[i]%5 ==0:
            continue
        else:
            state= 0
            #print("DENIED")
            break
if state == 1:
    print("APPROVED")
else:
    print("DENIED")

### FIXED CODE ###

n= input()
n = int(n)
nums= input().split()
#map(int,input().split())
state = 1
for i in range(n):
    if int(nums[i]) &1 == 0 :
        if int(nums[i])%3 ==0 or int(nums[i])%5 ==0:
            continue
        else:
            state= 0
            #print("DENIED")
            break
if state == 1:
    print("APPROVED")
else:
    print("DENIED")
s=input()
t=input()
s.sort()
T=t.sort()[::-1]
L=sort([s,T])

if s==T:
  print('No')
else:
  if L[0]==s:
    print('Yes')
  else:
    print('No')

### FIXED CODE ###

s=list(input())
t=list(input())
S=''.join(sorted(s))
T=''.join(sorted(t)[::-1])
L=sorted([S,T])

if S==T:
  print('No')
else:
  if L[0]==S:
    print('Yes')
  else:
    print('No')
class int(int):  
  def times(self, callback):
    for times in range(0,self):
      callback()

class list(list):
  def maps(self, callback):
    return list(map(callback, self))

  def each(self, callback):
    list(map(callback, self))
    return self

  # index will sent to the function as a second parameter.
  def each_with_index(self,callback):
    list(map(callback, self, range(0,len(self))))
    return self

# Make sure you initialize object with class name.
# Ex: int(10).times, array = list([1,2,3,4,5])

target, length = input().split()
target = int(target)
length = int(length)

if length > 0:
  o_nums = list(input().split())

  def convert(arg):
    return int(arg)

  o_nums = o_nums.maps(convert)
  diffs = list()
  nums = list()
  for exclude_num in range(min(o_nums), max(o_nums)+1):
    if exclude_num in o_nums:
      continue
    else:
      nums.append(exclude_num)

  for num in nums:
    diffs.append(target - num)

  def absm(arg):
    return abs(arg)

  diffs_abs = diffs.maps(absm)
  smallest_diff_index = diffs_abs.index(min(diffs_abs))

  if -(nums[smallest_diff_index]) in nums:
    print(-(nums[smallest_diff_index]))
  else:
    print(nums[smallest_diff_index])

else:
  print(target)

### FIXED CODE ###

class int(int):  
  def times(self, callback):
    for times in range(0,self):
      callback()

class list(list):
  def maps(self, callback):
    return list(map(callback, self))

  def each(self, callback):
    list(map(callback, self))
    return self

  # index will sent to the function as a second parameter.
  def each_with_index(self,callback):
    list(map(callback, self, range(0,len(self))))
    return self

# Make sure you initialize object with class name.
# Ex: int(10).times, array = list([1,2,3,4,5])

target, length = input().split()
target = int(target)
length = int(length)
nums = list(input().split())

def convert(arg):
    return int(arg)
nums = nums.maps(convert)

for i in range(0,101):
  a = target - i
  if a not in nums:
    print(a)
    exit()

  b = target + i
  if b not in nums:
    print(b)
    exit()
a = input()

print(a + a*a + a*a*a)

### FIXED CODE ###

a = int(input())

print(a + a*a + a*a*a)
N = int(input())

def get_ans(x):
    if x == 0:
        return ['0']
    d = []
    i = 0
    div = 1
    while x != 0:
        if x % (div*2) == 0:
            d.append('0')
        else:
            d.append('1')
            x -= div
        i += 1
        div = div * (-2)
    return d

a = get_ans(N)
b = list(reversed(a))
ans = ''.join(b)
print(ans)

### FIXED CODE ###

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

if N % K == 0:
    ans = 0
else:
    ans = 1

print(ans)
s=input()
x,y=map(int,input().split())
X,Y=[],[]
ct,dir,ss=0,1,1
for i in range(len(s)):
  if s[i]=="F":
    ct+=1
    if i==len(s)-1:
      if dir==1:
        X.append(ct)
      else:
        Y.append(ct)
  else:
    if ss==1:
      x-=ct
      ct,dir,ss=0,0,0
    elif dir==1:
      X.append(ct)
      ct,dir=0,0
    else:
      Y.append(ct)
      ct,dir=0,1

def chk(Z,z):
  tot,nz=sum(Z),len(Z)
  if tot==0:
    if z==0:
      return True
    else:
      return False
  else:
    DP=[[False]*(2*tot+1) for _ in range(nz+1)]
    DP[0][tot]=True
    for i in range(nz):
      zz=Z[i]
      for j in range(2*tot+1):
        if j+zz<2*tot+1:
          DP[i+1][j]=DP[i][j+zz]
        elif j-zz>=0:
          DP[i+1][j]=DP[i][j-zz]
    return DP[nz][z+tot]

if chk(X,x) and chk(Y,y):
  print("Yes")
else:
  print("No")




### FIXED CODE ###

s=input()
x,y=map(int,input().split())
ct=0
XY=[]
for i in range(len(s)):
  if s[i]=="F":
    ct+=1
  else:
    XY.append(ct)
    ct=0
XY.append(ct)
x-=XY[0]
X=XY[2::2]
Y=XY[1::2]


def chk(Z,z):
  tot,nz=sum(Z),len(Z)
  if tot==0:
    if z==0:
      return True
    else:
      return False
  elif abs(z)>tot:
    return False
  else:
    DP=[[False]*(2*tot+1) for _ in range(nz+1)]
    DP[0][tot]=True
    for i in range(nz):
      zz=Z[i]
      for j in range(2*tot+1):
        if j+zz<2*tot+1 and DP[i][j+zz]==True:
          DP[i+1][j]=True
        if j-zz>=0 and DP[i][j-zz]==True:
          DP[i+1][j]=True
    return DP[nz][z+tot]

if chk(X,x) and chk(Y,y):
  print("Yes")
else:
  print("No")
W= [int(x) for x in input().split()]
print("Yes" if len(set(W) ==2 else "No") 

### FIXED CODE ###

W= [int(x) for x in input().split()]
print("Yes" if len(set(W)) ==2 else "No")
def main(n,a):
  k=40
  mp=[[0]*k for _ in range(k)]
  o=k//2
  ary=[]
  for i in range(n):
    b=list(a[i].split('.'))
    b.append('0')
    x=int(b[0])
    y=int((b[1]+'0'*9)[:9])
    x=x*pow(10,9)+y
    # x10^9
    cnt5=-9
    xx=x
    while xx>1:
      if xx%5==0:
        cnt5+=1
        xx//=5
      else:
        break
    cnt2=-9
    xx=x
    while xx>1:
      if xx%2==0:
        cnt2+=1
        xx//=2
      else:
        break
    #if 0<=cnt5+o<23 and 0<=cnt2+o<23:
    mp[cnt5+o][cnt2+o]+=1
    ary.append([cnt5+o,cnt2+o])

  ans=0
  for i in range(k-1,0,-1):
    for j in range(k):
      mp[j][i-1]+=mp[j][i]
  for i in range(k-1,0,-1):
    for j in range(k):
      mp[i-1][j]+=mp[i][j]
  for x,y in ary:
    if x>=o and y>=o:
      i=1
    else:
      i=0
    x-=o
    x*=-1
    x+=o
    y-=o
    y*=-1
    y+=o
    ans+=mp[x][y]-i
  print(ans//2)
  #mp[o,o]+=10
  #print(mp)

n=int(input())
a=[input() for _ in range(n)]
main(n,a)



### FIXED CODE ###

def main(n,a):
  k=60
  mp=[[0]*k for _ in range(k)]
  o=k//2
  ary=[]
  for i in range(n):
    b=list(a[i].split('.'))
    b.append('0')
    x=int(b[0])
    y=int((b[1]+'0'*9)[:9])
    x=x*pow(10,9)+y
    # x10^9
    cnt5=-9
    xx=x
    while xx>1:
      if xx%5==0:
        cnt5+=1
        xx//=5
      else:
        break
    cnt2=-9
    xx=x
    while xx>1:
      if xx%2==0:
        cnt2+=1
        xx//=2
      else:
        break
    #if 0<=cnt5+o<23 and 0<=cnt2+o<23:
    mp[cnt5+o][cnt2+o]+=1
    ary.append([cnt5+o,cnt2+o])

  ans=0
  for i in range(k-1,0,-1):
    for j in range(k):
      mp[j][i-1]+=mp[j][i]
  for i in range(k-1,0,-1):
    for j in range(k):
      mp[i-1][j]+=mp[i][j]
  for x,y in ary:
    if x>=o and y>=o:
      i=1
    else:
      i=0
    x-=o
    x*=-1
    x+=o
    y-=o
    y*=-1
    y+=o
    ans+=mp[x][y]-i
  print(ans//2)
  #mp[o,o]+=10
  #print(mp)

n=int(input())
a=[input() for _ in range(n)]
main(n,a)
def hello():
    N = int(input()) 
    R = int(input())
    if N >= 10: 
        print R 
    else: 
        print 100 * ( 10 - N ) + R
hello()

### FIXED CODE ###

N, R = map(int, input().split())
if N >= 10:
  print(R)
else:
  print( 100 * (10 - N) + R )
s = str(input())
L = len(s)
dict = {}
for i in range(L):
  amari = (int(s[i:])*(10**i)) % 2019
  if not(amari in dict.keys()):
    dict[amari] = 1
  else:
    dict[amari] += 1
dict[0] += 1
ans = 0
for key in dict.keys():
  ans += (dict[key]*(dict[key]-1))/2
print(int(ans))

### FIXED CODE ###

s = str(input())
L = len(s)
dict = [0] * 2019
dict[0] += 1
num = 0
for i in range(L-1, (-1), (-1)):
    num += (int(s[i]) * pow(10,(L-i-1), 2019))%2019
    amari = num % 2019
    dict[amari] += 1
ans = 0
for j in range(2019):
    ans += (dict[j]*(dict[j]-1))/2
print(int(ans))
import sys
sys.setrecursionlimit(10**8)

N = int(input())
X = str(input())
ones = X.count('1')
intX = int(X, 2)
def check(n, r):
    if n == 0:
        return print(r)
    d = str(bin(n)).count('1')
    check(n%d, r+1)

Xplus = intX % (ones + 1)
Xminus = intX % (ones - 1)
print(intX, ones, Xplus, Xminus)
for i in range(N):
    if X[i] == '0':
        num = (Xplus + pow(2, N-1-i)) % (ones + 1)
    else:
        num = (Xminus - pow(2, N-1-i)) % (ones - 1)
    check(num, 1)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)

N = int(input())
X = str(input())
ones = X.count('1')
intX = int(X, 2)
def check(n, r):
    if n == 0:
        return print(r)
    d = str(bin(n)).count('1')
    check(n%d, r+1)

if ones > 1:
    Xplus = intX % (ones + 1)
    Xminus = intX % (ones - 1)
else:
    Xplus = intX % (ones + 1)
    Xminus = intX

for i in range(N):
    e = 1
    if X[i] == '0':
        num = (Xplus + pow(2, N-1-i, ones + 1)) % (ones + 1)
    elif X[i] == '1' and ones > 1:
        num = (Xminus - pow(2, N-1-i, ones - 1)) % (ones - 1)
    else:
        num = (Xminus - pow(2, N-1-i))
        e = 0
    check(num, e)
def addc(p,ko,c,total):
  c[p] += total
  total = c[p]
  if(len(ko[p]) == 0):
    return 0

  else:
    for i in ko[p]:
      addc(i,ko,c,total)

  return 0

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

ko = [ [] for i in range(n + 1)]
c = [0 for i in range(n + 1)]

for i in range(n-1):
  a,b = map(int,input().split())
  ko[a].append(b)

for i in range(q):
  p,x = map(int,input().split())
  c[p] += x

_ = addc(1,ko,c,0)

c.pop(0)

print(*c)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

def addc(p,b):
  for i in e[p]:
    if(i == b):
      continue
    c[i] += c[p]
    addc(i,p)

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

e = [ [] for i in range(n + 1)]
c = [0]*(n+1)

for i in range(n-1):
  a,b = map(int,input().split())
  e[a].append(b)
  e[b].append(a)

for i in range(q):
  p,x = map(int,input().split())
  c[p] += x

addc(1,-1)

print(*c[1:])
from collections import deque
h,w = map(int,input().split())
list1 = [list(input()) for i in range(h) ]
visited = [[-1]*w for i in range(h)]
black_count = 0
for i in range(h):
	black_count += list1[i].count("#")
def bfs(maze, visited, sy, sx, gy, gx):
    queue = deque([[sy, sx]])
    visited[sy][sx] = 0
    while queue:
        y, x = queue.popleft()
        if [y, x] == [gy, gx]:
            return visited[y][x]
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y+j, x+k
            if 0 <= new_y < h and \
				0 <= new_x < w and\
				maze[new_y][new_x] == "." and \
                visited[new_y][new_x] == -1:
				
                visited[new_y][new_x] = visited[y][x] + 1
                queue.append([new_y, new_x])

shortest = bfs(list1,visited,0,0,h-1,w-1)

print(h*w - black_count - shortest-1) #-1はスタート地点

### FIXED CODE ###

from collections import deque
h,w = map(int,input().split())
list1 = [list(input()) for i in range(h) ]
visited = [[-1]*w for i in range(h)]
black_count = 0
for i in range(h):
	black_count += list1[i].count("#")
def bfs(maze, visited, sy, sx, gy, gx):
	queue = deque([[sy, sx]])
	visited[sy][sx] = 0
	while queue:
		y, x = queue.popleft()
		if [y, x] == [gy, gx]:
			return visited[y][x]
		for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
			new_y, new_x = y+j, x+k
			if 0 <= new_y < h and \
				0 <= new_x < w and\
				maze[new_y][new_x] == "." and \
				visited[new_y][new_x] == -1:
				
				visited[new_y][new_x] = visited[y][x] + 1
				queue.append([new_y, new_x])
	return -1

shortest = bfs(list1,visited,0,0,h-1,w-1)
if shortest == -1:
	print(-1)
	exit()
print(h*w - black_count - shortest-1) #-1はスタート地点
N, M = map(int,input().split()) 
P = [input().split() for i in range(M)]

ans = "Yes"
for n in range(N):
    for m in range(M):
        if p[n][m] == '#':
            if p[n-1][m] == "." and p[n][m-1] == "." and p[n+1][m] == "." and p[n][m+1] == ".":
                ans = "No"
                break
print(ans)

### FIXED CODE ###

N, M = map(int,input().split()) 
p = [input() for i in range(N)]

ans = "Yes"
for n in range(1,N-1):
    for m in range(1,M-1):
        if p[n][m] == '#':
            if p[n-1][m] != "#" and p[n][m-1] != "#" and p[n+1][m] != "#" and p[n][m+1]!= "#":
                ans = "No"
                break
print(ans)
n = int(input())
data = []
for i in range(n):
    data.append(list(map(int, input().split())))
dif = dict()
data.sort()
for i in range(n):
    for j in range(i+1, n):
        x = data[i][0] - data[j][0]
        y = data[i][1] - data[j][1]
        if (x,y) in dif:
            dif[(x,y)] += 1
        else:
            dif[(x,y)] = 1
print(dif)
print(n - max([dif[i] for i in dif.keys()]))
        
        



### FIXED CODE ###

n = int(input())
data = []
for i in range(n):
    data.append(list(map(int, input().split())))
dif = dict()
data.sort()
for i in range(n):
    for j in range(i+1, n):
        x = data[i][0] - data[j][0]
        y = data[i][1] - data[j][1]
        if (x,y) in dif:
            dif[(x,y)] += 1
        else:
            dif[(x,y)] = 1
if len(dif.keys()) == 0:
    print(n)
    exit()
print(n - max([dif[i] for i in dif.keys()]))
n = int(input())
s = input()

n /= 2;
if s[:n] == s[n:]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n = int(input())
s = input()

n //= 2
if s[:n] == s[n:]:
  print("Yes")
else:
  print("No")
from fractions import gcd #直して
n = int(input())
a = list(map(int, input().split()))
def primelist(N):
    prime = [2]
    for i in range(3, N+1):
        flag = 1
        for j in prime:
            if i % j == 0:
                flag = 0
                break
        if flag == 1:
            prime.append(i)
    return prime
prime = primelist(1001)

def factorization(n):
    arr = []
    temp = n
    for i in prime:
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


mod = 10**9+7
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

fact = [0] * (1000001)
pri = []
for i in range(n):
    f = factorization(a[i])
    for fac, c in f:
        fact[fac] = max(fact[fac], c)

fact_list = []
for i in range(1000001):
    if fact[i] > 0:
        fact_list.append((i, fact[i]))



"""
ans = 0
for i in range(n):
    m = modinv(a[i])
    for fac, c in fact_list:
        m *= pow(fac, c, mod)
        m %= mod

    ans += m
    ans %= mod
"""
print(ans)


### FIXED CODE ###

from fractions import gcd #直して
n = int(input())
a = list(map(int, input().split()))

mod = 10**9+7
l = 1
for i in range(n):
    l = a[i] // gcd(l, a[i]) * l
    

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

d = 0
for i in range(n):
    d += modinv(a[i])

print((l*d) % mod)
def calculate(n, s):
    arr = list(S)

    RNum = arr.count("R")

    leftW = 0
    rightR = RNum

    result = []
    for i in range(n):
        if arr[i] == "R":
            rightR -= 1
        if arr[i] == "W":
            leftW += 1

        result.append(max(leftW, rightR))

    print(min(result))


calculate(N, S)


### FIXED CODE ###

# N = 8
# S = "WRWWRWRR"
#
# N = 2
# S = "RR"
#
# N = 3
# S = "WWW"

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

def calculate(n, s):
    arr = list(s)

    wNum = arr.count("W")
    RNum = arr.count("R")

    if wNum == 0 or RNum == 0:
        print(0)
        return

    leftW = 0
    rightR = RNum



    result = []
    for i in range(n):
        if arr[i] == "R":
            rightR -= 1
        if arr[i] == "W":
            leftW += 1

        result.append(max(leftW, rightR))

    print(min(result))


calculate(N, S)
n=int(input())
a=list(map(int,input().split()))
q=int(input())
num=[[a.count(i+1)] for i in range(n)]
ans=sum(a)
for i in range(q):
    b,c=map(int,input().split())
    ans=ans+(c-b)*num[b-1][0]
    num[c-1][0]+=num[b-1][0]
    num[b-1][0]=0
    print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
q=int(input())
num=[0]*(10**5+1)
ans=sum(a)
for i in a:
    num[i]+=1
for i in range(q):
    b,c=map(int,input().split())
    ans=ans+(c-b)*num[b]
    num[c]+=num[b]
    num[b]=0
    print(ans)
N = int(input())
A = list(map(int, input().split()))
a.sort()
ans = 1
max_limit = 10 ** 18
for i in range(N):
  ans *= A[i]
  if ans > max_limit:
    ans = -1
    break

if ans > max_limit:
  print(str(-1))
else:
  print(str(ans))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = 1
max_limit = 10 ** 18
for i in range(N):
  ans *= A[i]
  if ans > max_limit:
    ans = -1
    break

if ans > max_limit:
  print(str(-1))
else:
  print(str(ans))
b,w=map(int,input().split())
from math import factorial as f
from math import gcd
p=f(b+w)//f(b)//f(w)
def g(x,y):print((1000000008*x)//y)
q=2
for i in range(min(b,w)):
    g(1,2)
    q*=2
x,y=1,2
for i in range(b+w-min(b,w)-1):
 bunbo=q
 bunsi=q//2+1
 x,y=bunbo,bunsi
 g(y,x)
 q*=2
g(y,x)

### FIXED CODE ###

a,b,c=map(int,input().split())
if a==b and b==c:print('Yes')
else:print('No')
S = input()
count = 0
count_max = 0

for k in range(len(s)):
    if S[k] == "A" or S[k] == "C" or S[k] == "G" or S[k] == "T":
        count += 1
        if count > count_max:
             count_max = count
    else:
        count=0
print(count_max)


### FIXED CODE ###

S = input()
count = 0
count_max = 0

for k in range(len(S)):
    if S[k] == "A" or S[k] == "C" or S[k] == "G" or S[k] == "T":
        count += 1
        if count > count_max:
             count_max = count
    else:
        count=0
print(count_max)
x,y,z,k = map(int,input().split())
num = []
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)
if x*y*z < 1e6:
    ans = []
    for a in A:
        for b in B:
            for c in C:
                ans.append(a+b+c)
    ans.sort(reverse = True)
    for i in range(k):
        print(ans[i])
else:
    A.append(-1e20)
    B.append(-1e20)
    C.append(-1e20)
    cnt=0
    a,b,c = (0,0,0)
    print(A[0]+B[0]+C[0])
    while(cnt<k-1):
        Adiv = A[0]-A[a+1]
        Bdiv = B[0]-B[b+1]
        Cdiv = C[0]-C[c+1]
        if(Adiv <= Bdiv and Adiv <= Cdiv):
            a+=1
            print(A[a]+B[0]+C[0])
        elif(Bdiv <= Adiv and Bdiv <= Cdiv):
            b+=1
            print(A[0]+B[b]+C[0])
        else:
            c+=1
            print(A[0]+B[0]+C[c])
        cnt+=1


### 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)
num = []
for a in A:
    for b in B:
        num.append(a+b)
num.sort(reverse = True)
num2 = []
for i in range(min(len(num),k)):
    for j in C:
        num2.append(num[i]+j)
num2.sort(reverse = True)
for i in range(k):
    print(num2[i])