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

x,y,z,k=map(int,input().split())
list_a=list(map(int,input().split()))
list_b=list(map(int,input().split()))
list_c=list(map(int,input().split()))
list_a.sort(reverse=True)
list_b.sort(reverse=True)
list_c.sort(reverse=True)
dict_p={}
dict_p[(0,0,0)]=list_a[0]+list_b[0]+list_c[0]
pop_list=[]
for i in range(0,k):
    Max=max(dict_p.values())
    print(Max)
    for j in dict_p:
        if dict_p[j]==Max:
            now=j
            dict_p.pop(now)
            pop_list.append(now)
            break
    x_t=1
    y_t=1
    z_t=1
    for i in pop_list:
            if (now[0]+1,now[1],now[2])==i:
                x_t=0
            if (now[0],now[1]+1,now[2])==i:
                y_t=0
            if (now[0],now[1],now[2]+1)==i:
                z_t=0
    if now[0]+1<x:
        if x_t==1:
            dict_p[(now[0]+1,now[1],now[2])]=list_a[now[0]+1]+list_b[now[1]]+list_c[now[2]]
    if now[1]+1<y:
        if y_t==1:
            dict_p[(now[0],now[1]+1,now[2])]=list_a[now[0]]+list_b[now[1]+1]+list_c[now[2]]
    if now[2]+1<z:
        if z_t==1:
            dict_p[(now[0],now[1],now[2]+1)]=list_a[now[0]]+list_b[now[1]]+list_c[now[2]+1]
    


### FIXED CODE ###

x,y,z,k=map(int,input().split())
list_a=list(map(int,input().split()))
list_b=list(map(int,input().split()))
list_c=list(map(int,input().split()))
list_a.sort(reverse=True)
list_b.sort(reverse=True)
list_c.sort(reverse=True)
dict_p={}
dict_p[(0,0,0)]=list_a[0]+list_b[0]+list_c[0]
pop_list=[]
for i in range(0,k):
    Max=max(dict_p.values())
    print(Max)
    for j in dict_p:
        if dict_p[j]==Max:
            now=j
            dict_p.pop(now)
            pop_list.append(now)
            break
    if now[0]+1<x:
        if not (now[0]+1,now[1],now[2]) in pop_list:
            dict_p[(now[0]+1,now[1],now[2])]=list_a[now[0]+1]+list_b[now[1]]+list_c[now[2]]
    if now[1]+1<y:
        if not (now[0],now[1]+1,now[2]) in pop_list:
            dict_p[(now[0],now[1]+1,now[2])]=list_a[now[0]]+list_b[now[1]+1]+list_c[now[2]]
    if now[2]+1<z:
        if not (now[0],now[1],now[2]+1) in pop_list:
            dict_p[(now[0],now[1],now[2]+1)]=list_a[now[0]]+list_b[now[1]]+list_c[now[2]+1]
### BUGGY CODE ###

s=input()
n=len(s)
for i in range(10,-1,-1):
    t='1'*2**i+'0'*2**i
    while t in s:
        s=s.replace(t,'')
for i in range(10,-1,-1):
    t='0'*2**i+'1'*2**i
    while t in s:
        s=s.replace(t,'')
print(n-len(s))


### FIXED CODE ###

s=input()
print(len(s)-abs(s.count('1')-s.count('0')))
### BUGGY CODE ###

n, k, q = map(int,input().split())
a = [int(input()) for _ in range(q)]

for i in range(1, n + 1):
    c = a.count(i)
    print('Yes' if k - q + c > 0 else 'No')


### FIXED CODE ###

n, k, q = map(int,input().split())
a = dict((i,0) for i in range(1,n+1))

for _ in range(q):
    a[int(input())] += 1

for i in range(1, n + 1):
    print('Yes' if k - q + a[i] > 0 else 'No')
### BUGGY CODE ###

import copy

S=input()

N=len(S)
M=[]
for s in S:
    if s == 'R':
        M.append(1)
    else:
        M.append(-1)


def move(C):
    D=[0] * N
    for i,c in enumerate(C):
        D[i+M[i]] += c
    return D



c=[1] * N
d=[0] * N
even_c = [0] * N

i=0
while True:
    d = move(c)
    if i%2 == 0:
        if c == even_c:
            break
        even_c = c
    c = d
    i+=1

for c in even_c:
    print(str(c)+' ',end='')
print()

### FIXED CODE ###

S=input()

N=len(S)
RLs=[]
Rs=[]
Ls=[]

rlen=0
llen=0
for i in range(N):

    if S[i]=='R':
        rlen+=1
        if S[i:i+2] == 'RL':
            RLs.append(i)
            Rs.append(rlen)
            rlen=0
    elif S[i]=='L':
        llen+=1
        if i==N-1 or S[i:i+2] == 'LR':
            Ls.append(llen)
            llen=0

ans = [0]*N
for i,rlpos in enumerate(RLs):
    rr=-(-Rs[i]//2)
    rl=Rs[i]//2

    lr=Ls[i]//2
    ll=-(-Ls[i]//2)

    ans[rlpos]+=rr+lr
    ans[rlpos+1]+=rl+ll

for a in ans:
    print(str(a)+' ',end='')
print()
### BUGGY CODE ###

n,k=map(int,input().split())
ans=0
while n!=0:
  if n//k!=0:
    ans=ans+1
  elif n%k!=0:
    ans=ans+1
print(ans)


### FIXED CODE ###

n,k=map(int,input().split())
ans=0
while n!=0:
  if n//k!=0:
    ans=ans+1
  elif n%k!=0:
    ans=ans+1
  n=n//k
print(ans)
### BUGGY CODE ###

import bisect

N,D,A = map(int,input().split())

monsters = []
for i in range(N):
    X, H =map(int,input().split())
    monsters.append([X,H])

monsters = sorted(monsters)

id = 0
ans = 0

damage = [0 for i in range(N)]

while id < N:
    if id > 0: damage[id] += damage[id-1]
    nowX, nowH = monsters[id][0], monsters[id][1]
    nowH -= damage[id]

    if nowH > 0:
        damage[id] += A * ((nowH + A - 1) // A)

        right = bisect.bisect_left(monsters, [nowX+2*D+1,0])
        if right < N:
            damage[right] -= A * ((nowH + A - 1) // A)

        ans += (nowH + A -1) // A

    id += 1

print(ans)

### FIXED CODE ###

import bisect

N,D,A = map(int,input().split())

monsters = []
for i in range(N):
    X, H =map(int,input().split())
    monsters.append([X,H])

monsters = sorted(monsters)

id = 0
ans = 0

damage = [0 for i in range(N)]

while id < N:
    if id > 0: damage[id] += damage[id-1]
    nowX, nowH = monsters[id][0], monsters[id][1]
    nowH -= damage[id]

    if nowH > 0:
        damage[id] += A * ((nowH + A - 1) // A)

        right = bisect.bisect_left(monsters, [nowX+2*D+1,0])
        if right < N:
            damage[right] -= A * ((nowH + A - 1) // A)

        ans += (nowH + A -1) // A

    id += 1

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

import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    K, N = il()
    A = il()
    A.sort()
    ret = max(A) - min(A)

    for n in range(N - 1):
        mi = min(A)
        tmp = abs(A[n] - mi) + (K - A[n + 1])
        ret = min(ret, tmp)

    print(ret)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    K, N = il()
    A = il()
    A.sort()
    ret = max(A) - min(A)

    for n in range(N - 1):
        ret = min(ret, A[n] + (K - A[n + 1]))

    print(ret)


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

S  = str(input())
lst_even = []
lst_odd = []
for i in range(len(S)):
    if i % 2 == 0:
        lst_even = lst_even + [S[i]]
    else:
        lst_odd =  lst_odd + [S[i]]
even_white = lst_even.count('1')
even_black = lst_even.count('0')
odd_white = lst_odd.count('1')
odd_black = lst_odd.count('0')
bw = even_white + odd_black
wb = even_black + odd_white
print (min(wb, bw))

### FIXED CODE ###

S  = str(input())
even_black = 0
even_white = 0
odd_black = 0
odd_white = 0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == '0':
            even_black += 1
        else:
            even_white += 1
    else:
        if S[i] == '0':
            odd_black += 1
        else:
            odd_white += 1
bw = even_white + odd_black
wb = even_black + odd_white
print (min(wb, bw))
### BUGGY CODE ###

import sys
n=int(input()) #　a1
lap = [int(input()) for i in range(n)]


ppsum=[]

def delap(ap,psum):
  if len(ap)==0:
    print(len(psum))
    sys.exit(0)
  a=ap[0]

  if ap.count(a)%2 != 0:
    psum.append(a)

  ap=[i for i in ap if i!=a  ]
  delap(ap,psum)

delap(lap,ppsum)

### FIXED CODE ###

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

n=int(input())
a=[int(input()) for _ in range(n)]
for i in range(n):
  p=a[::]
  p.pop(i)
  print(max(p))

### FIXED CODE ###

n=int(input())
a=[int(input()) for _ in range(n)]
p=a[::]
m=max(a)
a.remove(m)
m2=max(a)
for i in p:
  if i==m:
    print(m2)
  else:
    print(m)
### BUGGY CODE ###

a,b,c,d = map(int,input().split())
lis = list()
for i in range(a,b+1):
    for j in range(c,d+1):
        lis.append(i*j)
print(max(lis))

### FIXED CODE ###

a,b,c,d = map(int,input().split())
print(max(a*c , a*d , b * c , b*d))
### BUGGY CODE ###

data = input().split()

n = int(data[0])
a=[]
valueList=[]
for i in range(n):
    line = input().split()
    tmp=[]
    tmp.append(int(line[0]))
    tmp.append(int(line[1]))
    a.append(tmp)
    valueList.append(int(line[1]) + int(line[0]))

res=0

for i in range(n):
    ind = valueList.index(max(valueList))
    if(i%2 == 0):
        res += a[ind][0]
    else:
        res -= a[ind][1]
    a.pop(ind)
    valueList.pop(ind)

print(res)


### FIXED CODE ###

data = input().split()

n = int(data[0])
a=[]
for i in range(n):
    line = input().split()
    tmp=[]
    tmp.append(int(line[1]) + int(line[0]))
    tmp.append(int(line[0]))
    tmp.append(int(line[1]))
    a.append(tmp)

res=0
a.sort(key=lambda x: x[0])
a.reverse()

flg=True

for e in a:
    if(flg):
        res +=e[1]
    else:
        res -=e[2]
    flg=not(flg)
    

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

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

while m > 0:
    i = A.index(max(A))
    A[i] = A[i]//2
    m -= 1

print(sum(A))


### FIXED CODE ###

import heapq

n, m = map(int, input().split())
A = sorted(list(map(lambda x: int(x)*(-1), input().split())))

heapq.heapify(A)

for i in range(m):
    a = heapq.heappop(A)
    a = a * (-1) // 2
    heapq.heappush(A, -a)

print(-sum(A))
### BUGGY CODE ###

a,b=map(int,input().split())
for i in range(a+1,b+1):
  a = a^i
print(a)

### FIXED CODE ###

a,b=map(int,input().split())
def f(n):
  if n%4 == 0:
    return n
  elif n%4 == 1:
    return n^(n-1)
  elif n%4 == 2:
    return n^(n-1)^(n-2)
  else:
    return 0
print(f(b)^f(a-1))
### BUGGY CODE ###

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

dis = 0

a = A[0]
for i in range(len(A)-1):
    min_d = 1e6
    for i in range(1,len(A)-1):
        if a>A[i]:
            d = min(abs(a-A[i]), abs(a-A[i]-20))
        else:
            d = min(abs(a-A[i]), abs(a-A[i]+20))
        min_d = min(d, min_d)
    dis += min_d
print(dis)


### FIXED CODE ###

import numpy as np

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

A.append(K+A[0])
l = 0
for i in range(N):
    l = max(l, A[i+1]-A[i])
print(K-l)
### BUGGY CODE ###

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

for m in range(M):
  B,C = map(int,input().split())
  if A[0]<C:
    A+=B*[C]

A = sorted(A)[::-1]
print(sum(A[:N]))

### FIXED CODE ###

N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for m in range(M)]
BC = sorted(BC,key=lambda x:x[1])[::-1]

for b,c in BC:
  A.extend(b*[c])
  if 2*N<len(A):
    break

A = sorted(A)[::-1]
print(sum(A[:N]))
### 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()))
XY=[]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
for a in A:
    for b in B:
        XY.append(a+b)
XY.sort(reverse=True)
XY=XY[:K]
XYZ=[]
for xy in XY:
    for c in C:
        XYZ.append(xy+c)
XYZ.sort(reverse=True)
for i in range(K):
    print(XYZ[i])


### FIXED CODE ###

X,Y,Z,K = map(int,input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)
xy=[]
for a in A:
    for b in B:
        xy.append(a+b)
xy=sorted(xy,reverse=True)
xy=xy[:K]
xyz=[]
for c in C:
    for x in xy:
        xyz.append(x+c)
xyz=sorted(xyz,reverse=True)
for i in range(K):
    print(xyz[i])
### BUGGY CODE ###

n, m = map(int, input().split())
def ip(l1, l2):
  ans = []
  if len(l1) != len(l2):
    print('length mismatch')
  else:
    for i in range(len(l1)):
      ans.append(l1[i]*l2[i])
    return ans
g = []
for i in range(m):
  g.append(list(map(int, input().split())))
l = [1 for i in range(n)]
for i in range(m):
  temp_l = [0 for i in range(n)]
  for j in range(g[i][0]-1, g[i][1]):
    temp_l[j-1] = 1
  l = ip(l, temp_l)
ans = sum(l)
print(ans)
  
  

### FIXED CODE ###

n, m = map(int, input().split())
max_l = 0
min_r = n
for i in range(m):
  l, r = map(int, input().split())
  if l > max_l:
    max_l = l
  if r < min_r:
    min_r = r
ans = min_r - max_l + 1
if ans < 0:
  ans = 0
print(ans)
### BUGGY CODE ###

S = input()
N = len(S)
ans = 0
x = 1
# 累積和を格納
tot = 0
# 累積和のmod 2019をカウントする
cnt = [0] * 2019

for i in range(N)[::-1]:
  cnt[tot] += 1

  tot += int(S[i]) * x
  tot %= 2019
  ans += cnt[tot]
  x *= 10

print(ans)

### FIXED CODE ###

from collections import Counter
S = input()[::-1]
MOD = 2019
X = [0]
for i, s in enumerate(S):
  X.append((X[-1] + int(s)*pow(10,i,MOD)) % MOD)

C = Counter(X)
res = 0
for v in C.values():
  res += v*(v-1) // 2

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

import sys
input = sys.stdin.readline


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0 for _ in range(n + 2)]
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


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

rli = []
for i in range(q):
    l, r = map(int, input().split())
    rli.append((r, l, i))
rli.sort()

last = [-1 for _ in range(n + 1)]

bit = Bit(n)
ans = [-1 for _ in range(q)]
cur = 1
for r, l, i in rli:
    for j in range(cur, r + 1):
        if last[c[j - 1]] != -1:
            bit.add(last[c[j - 1]], -1)
        last[c[j - 1]] = j
        bit.add(j, 1)
    cur = r + 1
    ans[i] = bit.sum(r) - bit.sum(l - 1)
print(*ans, sep="\n")


### FIXED CODE ###

import sys
input = sys.stdin.readline


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0 for _ in range(n + 2)]
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


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

rli = []
for i in range(q):
    l, r = map(int, input().split())
    rli.append((r, l, i))
rli.sort(key=lambda x: x[0])

last = [-1 for _ in range(n + 1)]

bit = Bit(n)
ans = [-1 for _ in range(q)]
cur = 1
for r, l, i in rli:
    for j in range(cur, r + 1):
        if last[c[j - 1]] != -1:
            bit.add(last[c[j - 1]], -1)
        last[c[j - 1]] = j
        bit.add(j, 1)
    cur = r + 1
    ans[i] = bit.sum(r) - bit.sum(l - 1)
print(*ans, sep="\n")
### BUGGY CODE ###

import math

k = int(input())
result = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        for c in range(1, k + 1):
            p = math.gcd(a, b)
            q = math.gcd(p, c)
            result += q
print(result)


### FIXED CODE ###

import math

k = int(input())
result = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        p = math.gcd(a, b)
        for c in range(1, k + 1):
            q = math.gcd(p, c)
            result += q
print(result)
### BUGGY CODE ###

import numpy as np

MOD=1000000007

n,k=map(int,input().split())
k=min(k,n-1)
fac=np.zeros((n+1)).astype(np.int64)
invfac=np.zeros((n+1)).astype(np.int64)
inv=np.zeros((n+1)).astype(np.int64)

invfac[0]=fac[0]=invfac[1]=fac[1]=inv[1]=1
for i in range(2,n+1):
    fac[i]=(fac[i-1]*i)%MOD
    inv[i]=(-inv[MOD%i]*(MOD//i))%MOD
    invfac[i]=(invfac[i-1]*inv[i])%MOD
def nCr(n,r):
    return ((fac[n]*invfac[r]%MOD)*invfac[n-r])%MOD
def nHr(n,r):
    return nCr(n+r-1,r)

ret = 0
for i in range(k+1):
    ret = (ret + nCr(n,i)*nHr(n-i,i))%MOD

print(ret)

### FIXED CODE ###

import numpy as np

MOD=1000000007

n,k=map(int,input().split())
k=min(k,n-1)
fac=np.zeros((n+1)).astype(np.int64)
invfac=np.zeros((n+1)).astype(np.int64)
inv=np.zeros((n+1)).astype(np.int64)

invfac[0]=fac[0]=invfac[1]=fac[1]=inv[1]=1
for i in range(2,n+1):
    fac[i]=(fac[i-1]*i)%MOD
    inv[i]=(-inv[MOD%i]*(MOD//i))%MOD
    invfac[i]=(invfac[i-1]*inv[i])%MOD
def nCr(n,r):
    return ((fac[n]*invfac[r]%MOD)*invfac[n-r])%MOD
def nHr(n,r):
    return nCr(n+r-1,r)

ret = 0
x = nCr(n, np.arange(k+1))
y = nHr(n-np.arange(k+1), np.arange(k+1))
ret = np.sum(x*y%MOD)%MOD

print(ret)
### BUGGY CODE ###

S = input()
Q = int(input())
rev = 1
for _ in range(Q):
    op = input().split(" ")
    if int(op[0]) == 1:
        rev *= -1
    else:
        f, ch = op[1:]
        if rev == 1:
            if f == "1":
                S = ch + S
            else:
                S = S + ch
        else:
            if f == "1":
                S = S + ch
            else:
                S = ch + S
if rev == -1:
    S = S[::-1]
print(S)

### FIXED CODE ###

from collections import  deque
S = input()
Q = int(input())
rev = 1
q = deque(list(S))
for _ in range(Q):
    op = input().split(" ")
    if int(op[0]) == 1:
        rev *= -1
    else:
        f, ch = op[1:]
        if rev == 1:
            if f == "1":
                q.appendleft(ch)
            else:
                q.append(ch)
        else:
            if f == "1":
                q.append(ch)
            else:
                q.appendleft(ch)
S = "".join(q)
if rev == -1:
    S = S[::-1]
print(S)
### BUGGY CODE ###

st = input()
q = int(input())
for i in range(q):
    ipt = input()
    if ipt == "1":
        st = st[::-1]
    else:
        _, f, c = ipt.split()
        if f == "1":
            st = c + st
        else:
            st = st + c
print(st)

### FIXED CODE ###

#!/usr/bin/env python3
s, _, *q = open(0)
g = ""
s = s.strip()
for q in q:
  q = q.strip().split()
  if q[0] == "1":
    g, s = s, g
  else:
    if q[1] == "1":
      g += q[2]
    else:
      s += q[2]
print(g[::-1] + s)
### BUGGY CODE ###

a,b = map(int,input().split())
ans = 0
if a > b:
  for x in range(b+1):
    for y in range(b-x+1):
      for z in range(b-x-y+1):
        if (x+y+z)==b:
          ans += 1
else:
  for x in range(a+1):
    for y in range(a+1):
      for z in range(a+1):
        if (x+y+z)==b:
          ans += 1
        if (x+y+z)>=b and (x>=b or y>=b or z>=b):
          break
print(ans)

### FIXED CODE ###

a,b = map(int,input().split())
ans = 0

for x in range(b+1):
  if x > a:
    break
  for y in range(b+1):
    if y > a:
      break
    z = b-x-y
    if z <= a and z >= 0:
      ans +=1
    else:
      continue  
print(ans)
### BUGGY CODE ###

import numpy as np
n = int(input())
s = input()
a = np.zeros(n)
rgb = [[] for _ in range(3)]
rgb2 = np.zeros((3,n), int)
idx = {'R':0, 'G':1, 'B':2}
for i in range(n):
  rgb[idx[s[i]]].append(i)
#

middles = [[] for _ in range(3)]
for i in rgb[0]:
  for j in rgb[1]:
    if(i+j >= 2*n-1):
      break
    if((i+j)%2 == 0):
      middles[idx['B']].append((i+j)//2)
for i in rgb[0]:
  for j in rgb[2]:
    if(i+j >= 2*n-1):
      break
    if((i+j)%2 == 0):
      middles[idx['G']].append((i+j)//2)
for i in rgb[1]:
  for j in rgb[2]:
    if(i+j >= 2*n-1):
      break
    if((i+j)%2 == 0):
      middles[idx['R']].append((i+j)//2)
#
counts = 0
for i in range(3):
  tmp,c = np.unique(middles[i], return_counts=True)
  for j,c in zip(tmp,c):
    if(j in rgb[i]):
      counts += c
print(len(rgb[0])*len(rgb[1])*len(rgb[2]) - counts)

### FIXED CODE ###

import numpy as np
n = int(input())
s = input()

r = s.count('R')
g = s.count('G')
b = s.count('B')

counts = 0
for i in range(n):
  for j in range(i+1, n):
    k = 2*j-i
    if(k >= n):
      break
    if(s[i] != s[j] and s[j]!=s[k] and s[k]!=s[i]):
      counts += 1
print(r*g*b - counts)
### BUGGY CODE ###

def GCD(a, b):
    if b == 0:
        return a
    else:
        return GCD(b, a % b)


def LCM(a, b):
    return (a // GCD(a, b)) * b


MOD = 1000000007

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

l = 1
for i in range(n):
    l = LCM(l, a[i])

ans = 0
for i in range(n):
    num = l // a[i]
    ans += num
    ans = ans % MOD
print(ans)


### FIXED CODE ###

MOD = 1000000007


def GCD(a, b):
    if b == 0:
        return a
    else:
        return GCD(b, a % b)


def modinv(a, mod=MOD):
    b = mod
    u = 1
    v = 0
    while b > 0:
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    u %= mod
    if u < 0:
        u += mod
    return u


def LCM(a, b):
    return (a // GCD(a, b)) * b


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

l = 1
for i in range(n):
    l = LCM(l, a[i])
ans = 0
l %= MOD
for i in range(n):
    ans += l * modinv(a[i]) % MOD
    ans %= MOD
print(ans)
### BUGGY CODE ###

N = int(input())
P =list(map(int,input().split()))
cnt = 1
for i in range(1,N):
  if min(P[0:i+1]) < P[i]:
    cnt = cnt
  else:
    cnt += 1
print(cnt)
  

### FIXED CODE ###

N = int(input())
P =list(map(int,input().split()))
cnt = 1
minPi = P[0]
for i in range(1,N):
  if minPi > P[i]:
    minPi = P[i]
  
  if minPi < P[i]:
    cnt = cnt
  else:
    cnt += 1
print(cnt)
### BUGGY CODE ###

def gcd(a, b):
     while b:
         a, b = b, a%b
     return a

n, m = map(int, input().split())
s, t = input(), input()

l = n*m//gcd(n, m)

a = [i*(l//n) for i in range(n)]
b = [i*(l//m) for i in range(m)]

x = set(a) & set(b)

for i in x:
    if s[a.index(i)] != t[b.index(i)]:
        print(-1)
        exit()

print(l)

### FIXED CODE ###

def gcd(a, b):
     while b:
         a, b = b, a%b
     return a

n, m = map(int, input().split())
s, t = input(), input()

l = n*m//gcd(n, m)

a = [i*(l//n) for i in range(n)]
b = [i*(l//m) for i in range(m)]

x = set(a) & set(b)

for i in x:
    if s[a.index(i)] != t[b.index(i)]:
        print(-1)
        exit()

print(l)
### BUGGY CODE ###

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

def main():
    n,k = map(int, input().split())
    l = list(map(mean, input().split()))
    out = 0

    for i in range(len(l)-(k-1)):
        s = sum(l[i:i+k])

        if out < s:
            out = s

    print(out)

def mean(x):
    x = int(x)
    return x * (x+1) / (2 * x)

if __name__ == "__main__":
    main()


### FIXED CODE ###

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

def main():
    n,k = map(int, input().split())
    l = list(map(mean, input().split()))
    out = sum(l[:k])
    result = out

    for i in range(1, len(l)-(k-1)):
        result = result - l[i-1] + l[i+k-1]

        if out < result:
            out = result

    print(out)

def mean(x):
    x = int(x)
    return x * (x+1) / (2 * x)

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

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

X_sort = sorted(X)

for i in X:
    if X_sort.index(i) < len(X)//2:
        print(X_sort[len(X)//2])
    else: print(X_sort[len(X)//2-1])




### FIXED CODE ###

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

X_sort = sorted(X)
t = X_sort[len(X)//2]

for i in X:
    if i < t:
        print(X_sort[len(X)//2])
    else: print(X_sort[len(X)//2-1])