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

n, k = map(int, input().split())
p = list(map(int, input().split()))
exp_list = []
for i in p:
    prob = 1/i
    expect = 0
    for j in range(1, i+1):
        expect += j * prob 
    exp_list.append(expect)
answer = 0
for j in range(n-k+1):
    ans = 0
    for l in range(j, j+k):
        ans += exp_list[l]
    answer = max(answer, ans)
print(answer)

### FIXED CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
exp_list = []
for i in p:
    expect = (i+1)/2
    exp_list.append(expect)
s = sum(exp_list[0:k])
ans = s
for j in range(n-k):
    s -= exp_list[j]
    s += exp_list[j+k]
    if s > ans :
        ans = s
print(ans)
### BUGGY CODE ###

import sys
input = lambda: sys.stdin.readline().strip()
s=str(input())
q=int(input())
flag=0
for i in range(q):
    j=input()
    if j[0]=="1":
        flag+=1
    else:
        if flag%2==1:
            if j[2]=="1":
                s+=j[4]
            else:
                s=j[4]+s
        else:
            if j[2]=="1":
                s=j[4]+s
            else:
                s+=j[4]
if flag%2==1:
    s=s[::-1]
print(s)

### FIXED CODE ###

import sys
input = lambda: sys.stdin.readline().strip()
from collections import deque
s=deque(str(input()))
q=int(input())
flag=0
for i in range(q):
    j=input()
    if j[0]=="1":
        flag+=1
    else:
        if flag%2==1:
            if j[2]=="1":
                s.append(j[4])
            else:
                s.appendleft(j[4])
        else:
            if j[2]=="1":
                s.appendleft(j[4])
            else:
                s.append(j[4])
s=''.join(s)
if flag%2==1:
    s=s[::-1]
print(s)
### BUGGY CODE ###

N,K = map(int, input().split())
d = 10**9+7

A = [i for i in range(N+1)]
A_rev = sorted(A, reverse=True)
ans = 0
for i in range(K, N+2):
    maximum = sum(A_rev[0:i])
    minimum = sum(A[0:i])
    ans += maximum - minimum + 1
print(ans%d)

### FIXED CODE ###

N,K = map(int, input().split())
d = 10**9+7

A = [i for i in range(N+1)]
A_rev = sorted(A, reverse=True)
ans = 0
dp = {'max':sum(A_rev[0:K]), 'min':sum(A[0:K])}
ans += dp['max'] - dp['min'] + 1
for i in range(K, N+1):
    dp['max'] += A_rev[i]
    dp['min'] += A[i]
    ans += dp['max'] - dp['min'] + 1
print(ans%d)
### BUGGY CODE ###

def main():
    """
    ワーシャルフロイドで経由したときに変更がないことを確認する
    変更がある場合、
        最短経路ではないため条件を満たさない
    変更がない場合、
        経由の経路でも最短距離になるケースを除いて距離を計算する
    """
    N = int(input())
    a = [None] * N
    total = 0
    for i in range(N):
        a[i] = list(map(int, input().split()))
        total += sum(a[i])

    for k in range(N):
        for i in range(N):
            for j in range(N):
                # compare from-to / from-経由地点-to
                d = a[i][k] + a[k][j]
                if a[i][j] > d:
                    return -1
                a[i][j] = min(a[i][j],
                              a[i][k] + a[k][j])

    no_need = 0
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if i == k or j == k:
                    continue
                if a[i][j] == a[i][k] + a[k][j]:
                    no_need += a[i][j]

    # 対称なので半分にする
    return (total - no_need) // 2

if __name__ == '__main__':
    answer = main()
    print(answer)


### FIXED CODE ###

def main():
    """
    ワーシャルフロイドで経由したときに変更がないことを確認する
    変更がある場合、
        最短経路ではないため条件を満たさない
    変更がない場合、
        経由の経路でも最短距離になるケースを除いて距離を計算する
    """
    N = int(input())
    a = [None] * N
    total = 0
    for i in range(N):
        a[i] = list(map(int, input().split()))
        total += sum(a[i])

    for k in range(N):
        for i in range(N):
            for j in range(N):
                # compare from-to / from-経由地点-to
                d = a[i][k] + a[k][j]
                if a[i][j] > d:
                    return -1

    # 不要判定
    v = [[False] * N for _ in range(N)]
    no_need = 0
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if i == k or j == k:
                    continue
                if not v[i][j] and (a[i][j] == a[i][k] + a[k][j]):
                    no_need += a[i][j]
                    v[i][j] = True

    # 対称なので半分にする
    return (total - no_need) // 2

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

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

ans = 0
for bit in range(1 << n):

    s = 0
    count = 0
    for i in range(n):
        if bit & (1 << i):
            s += x[i]
            count += 1

    if count and s / count == a:
        ans += 1

print(ans)

### FIXED CODE ###

import collections

n, a = map(int, input().split())
X = [int(i) - a for i in input().split()]
ans = 0
sums = collections.Counter([0, X[0]])
for i in X[1:]:
    sums2 = collections.Counter()
    for s, c in sums.items():
        sums2[s + i] += c
    sums += sums2
print(sums[0] - 1)
### BUGGY CODE ###

n = int(input())
x = input()
a = x.count('1')
b = int(x,2)
# print (b)

ary = [None for i in range(200010)]
ary[0] = 0

def f(n):
  if ary[n] is not None:
    return ary[n]
  b = bin(n).count('1')
  r = 1 + f(n%b)
  ary[n] = r
  return ary[n]


a1 = a + 1
a0 = a - 1
for i in range(200010):
  f(i)


one = [1] * 200010
zero = [1] * 200010
for i in range(1, 200010):
    if a0 != 0:
        one[i] = one[i-1] * 2 % a0
    zero[i] = zero[i-1] * 2 % a1


ans = [0 for i in range(n)]
for i, j in enumerate(reversed(list(x))):
  if j == '0':
    x = b + zero[i]
    # y = x %a1
    x %= a1
    ans[i] = ary[x]+1
  else:
    if a0 != 0:
      x = b - one[i]
      # y = x %a0
      x %= a0
      ans[i] = ary[x]+1
    else:
      ans[i] = 0
ans.reverse()
for i in ans:
  print (i)

### FIXED CODE ###

n = int(input())
x = input()
a = x.count('1')
b = int(x,2)
# print (b)

ary = [None for i in range(200010)]
ary[0] = 0

def f(n):
  if ary[n] is not None:
    return ary[n]
  b = bin(n).count('1')
  r = 1 + f(n%b)
  ary[n] = r
  return ary[n]


a1 = a + 1
a0 = a - 1
for i in range(200010):
  f(i)


one = [1] * 200010
zero = [1] * 200010
for i in range(1, 200010):
    if a0 != 0:
        one[i] = one[i-1] * 2 % a0
    zero[i] = zero[i-1] * 2 % a1


ans = [0 for i in range(n)]
c1 = b%a1
if a0 != 0:
  c0 = b%a0
for i in range(n-1, -1, -1):
  if x[n-1-i] == '0':
    y = c1 + zero[i]
    # y = x %a1
    y %= a1
    print (ary[y]+1)
  else:
    if a0 != 0:
      y = c0 - one[i]
      y %= a0
      print (ary[y]+1)
    else:
      print (0)
# ans.reverse()
# for i in ans:
#   print (i)
### BUGGY CODE ###

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

a = [input().split() for i in range(m)]
c = []
d = []
for i in range(m):
    if int(a[i][0]) == 1 and int(a[i][1]) == n:
        continue
    elif int(a[i][0]) == 1:
        c.append(a[i][1])
    elif int(a[i][1]) == n:
        d.append(a[i][0])
ans = False
for i in range(len(c)):
    for j in range(len(d)):
        if c[i] == d[j]:
            ans = True
            break
if ans:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

### FIXED CODE ###

n,m = map(int,input().split())
a = [0 for _ in range(m)]
b = [0 for _ in range(m)]

for i in range(m):
    a[i],b[i] = map(int,input().split())

go = []
goal = []

for i in range(len(a)):
    if a[i] == 1:
        go.append(b[i])
    if b[i] == n:
        goal.append(a[i])

count = [0 for i in range(n)]
for i in range(len(go)):
    count[go[i]-1] = 1
for i in range(len(goal)):
    count[goal[i]-1] += 1
for i in range(len(count)):
    if count[i] > 1:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")
### BUGGY CODE ###

S=str(input())
K=int(input())
S_list=list(S)
J=[]
for i in range(len(S)):
  for j in range(i+1,len(S)+1):
    J += [''.join(S[i:j])]
J=sorted(list(set(J)))
print(J[K-1])

### FIXED CODE ###

S=str(input())
K=int(input())
S_list=list(S)
J=[]
for i in range(len(S)):
  for j in range(i+1,min(i+6,len(S)+1)):
    J += [''.join(S[i:j])]
J=sorted(list(set(J)))
print(J[K-1])
### BUGGY CODE ###

import re
s=input()
m=0
for i in range(len(s)//2):
  dst = re.sub(r'01|10', "", s)
  dst = re.sub(r'0000000000011111111111|1111111111100000000000', "", dst)
  if dst == s:
    break
  m += len(s) - len(dst)
  s=dst
print(m)

### FIXED CODE ###

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

def binary_search(l, item):

    if len(l) == 0 or l[0] <= item:
        return -1

    if item < l[-1]:
        return len(l) - 1

    list2 = [1001] + l + [0]

    low = 0
    high = len(list2) - 1

    while low <= high:
        mid = (low + high) // 2

        bigger = list2[mid]
        smaller = list2[mid+1]

        if smaller <= item and item < bigger:

            return mid - 1

        if smaller > item:
            low = mid + 1

        else:
            high = mid - 1

    return -1


import heapq


N = int(input())
L = []
for l in map(int, input().split(' ')):
    heapq.heappush(L, l*(-1))

L = [heapq.heappop(L)*(-1) for _ in range(N)]
# L = sorted(L, reverse=True)


result = 0
for i, a in enumerate(L[:-2:]):
    for j, b in enumerate(L[i+1:-1:]):
        k = binary_search(L[i+j+2::], a-b)
        if k == -1:
            break
        result += k + 1


print(result)


### FIXED CODE ###

from bisect import bisect_left

N = int(input())
L = list(map(lambda l: int(l)*(-1), input().split()))
L.sort()

result = 0
for i, a in enumerate(L[:-2:]):
    for ii, b in enumerate(L[i+1:-1:]):
        c_list = L[i+ii+2::]
        c_index = bisect_left(c_list, a-b)
        result += c_index

print(result)
### BUGGY CODE ###

n = int(input())
nlist = [int(input()) for i in range(n)]
xlist = []
c = 0
x = 1
while x != 2 and x not in xlist and c < n:
    xlist.append(x)
    x = nlist[x - 1]
    c += 1
if x == 2:
    print(c)
else:
    print(-1)


### FIXED CODE ###

n = int(input())
nlist = [int(input()) for i in range(n)]
c = 0
x = 1
while x != 2 and c < n:
    x = nlist[x - 1]
    c += 1
if x == 2:
    print(c)
else:
    print(-1)
### BUGGY CODE ###

N = int(input())
S = input()
print(min(S[:i].count('W') + S[i+1:].count('E') for i in range(N)))


### FIXED CODE ###

N = int(input())
S = input()
ans = [0]
ans[0] = S[1:].count('E')
for i in range(N-1):
    if S[i] == 'E' and S[i+1] == 'E':
        ans.append(ans[i] -1)
    if S[i] == 'E' and S[i+1] == 'W':
        ans.append(ans[i])
    if S[i] == 'W' and S[i+1] == 'E':
        ans.append(ans[i] )
    if S[i] == 'W' and S[i+1] == 'W':
        ans.append(ans[i] +1)
print(min(ans))
### BUGGY CODE ###

from heapq import heappop, heappush, heapify
from collections import deque
N, M = map(int, input().split())
A = [int(i) for i in input().split()]
S = []
for i in range(M):
  B,C = map(int, input().split())
  for j in range(B):
    heappush(S,-C)
A.sort()
i = 0
l = len(S)
while i < min(N,l):
  q = -1*heappop(S)
  if A[i] < q:
    A[i] = q
    i += 1
  else:
    break
print(sum(A))

### FIXED CODE ###

N, M = map(int, input().split())
A = [int(i) for i in input().split()]
table = []
for i in range(N):
  table.append((A[i],1))
for i in range(M):
  b,c = map(int, input().split())
  table.append((c,b))
table.sort()
count = 0
ans = 0
while True:
  c, b = table.pop()
  if b <= N - count:
    ans += c*b
    count += b
  else:
    ans += (N-count)*c
    break
print(ans)
### BUGGY CODE ###

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

### FIXED CODE ###

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

p=a-1
if (a-1)%4==0:
  p=a-1
elif (a-1)%4==1:
  p=1
elif (a-1)%4==2:
  p=(a-1)^1
else:
  p=0
  
if b%4==0:
  b=b
elif b%4==1:
  b=1
elif b%4==2:
  b=b^1
else:
  b=0
print(p^b)
### BUGGY CODE ###

import collections
import math

def comb(n, r):
    if n < 2:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N = int(input())
L = input().split(" ")

c = collections.Counter(L)

d = {}
tmp_total = 0 

memo1 = {}
for i in c:
    if c[i] not in memo1.keys():
        tmp = comb(c[i], 2)
        memo1[i] = tmp
        tmp_total += tmp
    else:
        tmp_total += memo1[c[i]]
        
total = tmp_total
memo = {}
for i in L:
    if i not in memo.keys():
        ans = total - memo1[i] + comb(c[i]-1, 2)
        memo[i] = ans
        print(ans)
    else:
        print(memo[i])

### FIXED CODE ###

import collections
import math

def comb(n, r):
    if n < 2:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N = int(input())
L = input().split(" ")

c = collections.Counter(L)

d = {}
tmp_total = 0 

memo1 = {}
L2 = {}

for i in c:
    if c[i] not in memo1.keys():
        tmp = comb(c[i], 2)
        memo1[c[i]] = tmp
        tmp_total += tmp
    else:
        tmp_total += memo1[c[i]]
        
total = tmp_total

for i in L:
    ans = total - memo1[c[i]] + memo1[c[i]]*(c[i]-2)//c[i]
    print(ans)
### BUGGY CODE ###

n = int(input())
a = list( map(int, input().split()))
p = 10**9+7

len_max = len(list(format(max(a), 'b')))

bin_list = [0]*len_max

for a_ in a:
    for i in range(1,len_max+1):
        if a_ & (1<<(i-1)):
            bin_list[-i] += 1

ans = 0
for i in range(1,len_max+1):
    num_1 = bin_list[-i]%p
    ans += 2**(i-1)%p * num_1 * (n-num_1)%p

print(ans%p)

### FIXED CODE ###

n = int(input())
a = list( map(int, input().split()))
p = 10**9+7

len_max = len(list(format(max(a), 'b')))

bin_list = [0]*len_max

for a_ in a:
    for i in range(1,len_max+1):
        if a_ & (1<<(i-1)):
            bin_list[-i] += 1

ans = 0
for i in range(1,len_max+1):
    num_1 = bin_list[-i]%p
    ans += 2**(i-1)%p * num_1 * (n-num_1)%p

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

n,m = map(int,input().split())
a =  [int(input()) for i in range(m)]

dp =[0]*(n+1)
if 0 in a:
    dp[0] =0
else:
    dp[0]=1

if 1 in a:
    dp[1] =0
else:
    dp[1]=1

for i in range(2,n+1):

    if dp[i-1]==dp[i-2]==0:break

    dp[i] = (dp[i-2]+dp[i-1])

    if i in a:
        dp[i] = 0

print(dp[-1]%1000000007)

### FIXED CODE ###

n,m = map(int,input().split())
a =  [int(input()) for i in range(m)]

dp =[0]*(n+1)

for i in a:
    dp[i] = -1

for i in [0,1]:
    if dp[i] == -1:
        dp[i] =0
    else:
        dp[i] =1

for i in range(2,n+1):
    if dp[i] == -1:
        dp[i] = 0
    else:
        if dp[i-1]==dp[i-2]==0:break
        dp[i] = (dp[i-2]+dp[i-1])

print(dp[-1]%1000000007)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
b = [0]*(max(a)+1)
ans = 0
for i in a:
    for j in range(i,max(a)+1,i):
        b[j]+=1
for i in a:
    if b[i]==1: ans+=1
print(ans)

### FIXED CODE ###

n = int(input())
a = sorted(list(map(int,input().split())))
am = a[-1]+1
b = [0]*am
for i in a:
    b[i]+=1
    if b[i]==1:
        for j in range(i*2,am,i):
            b[j]=2
print(b.count(1))
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
 
import fractions
from functools import reduce
 
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
 
score = 0
for i in range(N):
    B = A
    keep = B.pop(0)
    n = gcd_list(B)
    if n > score:
        score = n
    A.append(keep)
 
 
print(score)

### FIXED CODE ###

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

import fractions
from functools import reduce

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

L = [0 for i in range(N+1)]
R = [0 for j in range(N+1)]

for i in range(N):
    L[i+1] = fractions.gcd(L[i],A[i])
    R[N-1-i] = fractions.gcd(R[N-i],A[N-i-1])

M = 0
for i in range(N):
    M = max(M,fractions.gcd(L[i],R[i+1]))

print(M)
### BUGGY CODE ###

N = int(input())
li = list(map(int,input().split()))
C = 1
for i in range(N):
  C *= li[i]
if C <= 10 ** 18:
  print(C)
else: print(-1)

### FIXED CODE ###

N = int(input())
L = list(map(int,input().split()))
L.sort()
c = 1
for i in range(N):
    c *= L[i]
    if c > 10**18:
        c = -1
        break
print(c)
### BUGGY CODE ###

n = int(input())
S = {}
cnt = 0
for _ in range(n):
    s = input()
    s = sorted(s)
    u = "".join(s)
    if u in S.keys():
        S[u] += 1
    else:
        S[u] = 1
for x in S.values():
    x = x-1
    cnt += x*(x+1)//2
print(cnt)

### FIXED CODE ###

n = int(input())
S = {}
cnt = 0
for _ in range(n):
    s = input()
    s = sorted(s)
    u = ""
    for i in range(len(s)):
      u += s[i]
    if u in S.keys():
        S[u] += 1
    else:
        S[u] = 1
for x in S.values():
    x = x-1
    cnt += x*(x+1)//2
print(cnt)
### BUGGY CODE ###

S = input()
k = int(input())
n = len(S)
A = [[0] * n for _ in range(n)]

A[0][0] = S[0]
for i in range(1, n):
    A[0][i] = A[0][i - 1] + S[i]
    
for i in range(1, n):
    for j in range(0, n):
        A[i][j] = A[i - 1][j][1:]
        

flatA = []
for a in A:
    flatA.extend(a)

flatA.sort()
setA = set(flatA)

if '' in setA:
    setA.remove('')

finalA = list(setA)
finalA.sort()

print(finalA[k - 1])

### FIXED CODE ###

S = input()
k = int(input())
A = []

for i in range(len(S)):
    for j in range(1, k + 1):
        A.append(S[i : i + j])
        
ans = sorted(list(set(A)))
print(ans[k - 1])
### BUGGY CODE ###



import bisect

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

answer = 0
for a in A:
    bi = bisect.bisect_right(B, a)
    for i in range(bi, N):
        ci = bisect.bisect_right(C, B[i])
        answer += N - ci

print(answer)

### FIXED CODE ###

import bisect

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

answer = 0
for b in B:
    ai = bisect.bisect_left(A, b)
    ci = bisect.bisect_right(C, b)
    answer += ai * (N - ci)

print(answer)
### BUGGY CODE ###

import sys, math
from pprint import pprint
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()
A = rl()

b = [0] * 60

def count(a, b):
	i = len(b)-1
	while a:
		b[i] += a % 2
		a //= 2
		i -= 1
	return i+1

def sum_xor(a, b, l):
	i = len(b)-1
	e = 1
	s = 0
	for i in reversed(range(len(b))):
		if a % 2 == 0:
			s += b[i] * e % mod
		else:
			s += (l-(b[i])) * e % mod
		a //= 2
		e = e * 2 % mod
		s = s % mod
	return s

ans = 0
for i in range(N):
	if i > 0:
		ans = (ans + sum_xor(A[i], b, i)) % mod
	count(A[i], b)
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()
A = rl()

b = [0] * 60

def count(a, b):
	i = len(b)-1
	while a:
		b[i] += a % 2
		a //= 2
		i -= 1
	return i+1

def sum_xor(a, b, l, left):
	i = len(b)-1
	e = 1
	s = 0
	while a or left <= i:
		if a % 2 == 0:
			s = (s + b[i] * e) % mod
		else:
			s = (s + (l-(b[i])) * e) % mod
		a //= 2
		e = e * 2 % mod
		i -= 1
	return s

ans = 0
min_left = 60
for i in range(N):
	if i > 0:
		ans = (ans + sum_xor(A[i], b, i, min_left)) % mod
	left = count(A[i], b)
	min_left = min(min_left, left)
print(ans)
### BUGGY CODE ###

n = int(input())
l = list(map(int, input().split()))
sol = 1
nula = 0
over = 0
for i in l:
    if (i == 0):
        nula = 1
    sol = sol * i
    if sol>1000000000000000000:
        over = 1
if (nula == 1):
    print(0)
elif (over == 1):
    print(-1)
else:
    print(sol)


### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
sol = 1
nula = 0
over = 0
for i in l:
    if (i == 0):
        nula = 1
    sol = sol * i
    if sol>1000000000000000000:
        over = 1
        sol = 0
if (nula == 1):
    print(0)
elif (over == 1):
    print(-1)
else:
    print(sol)
### BUGGY CODE ###

n=int(input())
l=[]
for i in range(n):
  m=int(input())
  if m in l:
    del l[l.index(m)]
  else:
    l.append(m)
print(len(l))

### FIXED CODE ###

n=int(input())
l=[]
for i in range(n):
  m=int(input())
  l.append(m)
l=sorted(l)
c=0
d=1
e=l[0]
for i in range(1,n):
  if l[i]!=e:
    if d%2==1:
      c+=1
    e=l[i]
    d=1
  else:
    d+=1
if d%2==1:
  c+=1
print(c)
### BUGGY CODE ###

n = int(input())
a_list = list(map(int,input().split()))
a_list.sort()
a_max = a_list.pop()
result = []
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for a in a_list:
  result.append(comb(a_max,a))

print(a_max,a_list[result.index(max(result))])


### FIXED CODE ###

n = int(input())
a_list = list(map(int,input().split()))
a_list.sort()
a_max = a_list.pop()
result = []
import math
for a in a_list:
  result.append(abs(math.ceil(a_max /2) - a))

print(a_max,a_list[result.index(min(result))])
### BUGGY CODE ###

'''
Created on 2020/09/08

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  X,Y,Z,K=map(int,pin().split())
  A=list(map(int,pin().split()))
  B=list(map(int,pin().split()))
  C=list(map(int,pin().split()))
#   A.sort(reverse=True)
#   B.sort(reverse=True)
#   C.sort(reverse=True)

  d=[]
  for i in A:
    for j in B:
      d.append(i+j)
#   d.sort(reverse=True)
  ans=[]
  for k in d:
    for l in C:
      ans.append(k+l)
  ans.sort(reverse=True)
  for m in range(K):
    print(ans[m])
  return 
main()



### FIXED CODE ###

'''
Created on 2020/09/08

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  X,Y,Z,K=map(int,pin().split())
  A=list(map(int,pin().split()))
  B=list(map(int,pin().split()))
  C=list(map(int,pin().split()))
#   A.sort(reverse=True)
#   B.sort(reverse=True)
#   C.sort(reverse=True)

  d=[]
  for i in A:
    for j in B:
      d.append(i+j)
  d.sort(reverse=True)
  d=d[:K]
  ans=[]
  for k in d:
    for l in C:
      ans.append(k+l)
  ans.sort(reverse=True)
  for m in range(K):
    print(ans[m])
  return
main()
### BUGGY CODE ###

n=int(input())
a=[int(input()) for i in range(n)]
sorted(a)
for i in range(n):
  if a[i]==max(a):print(sorted(a)[-2])
  else:print(max(a))

### FIXED CODE ###

import heapq
n=int(input())
a=[int(input()) for i in range(n)]
b=list(map(lambda x:x*(-1), a))
heapq.heapify(b)
max1=heapq.heappop(b)*(-1)
max2=heapq.heappop(b)*(-1)

for i in range(n):
  if a[i]==max1:print(max2)
  else:print(max1)
### BUGGY CODE ###

N = int(input())
a = list(map(int,input().split()))
t = [];s = 0
for i in range(N):
    for j in range(N):
        if i != j:
            t.append(a[i]*a[j])
for i in t:
    s += i
s = s//2
print(s%(10**9+7))

### FIXED CODE ###

import itertools
N = int(input())
a = list(map(int,input().split()))
a2 = itertools.accumulate(a)
b = [0]
b += list(a2)
s = 0
for i in range(N):
    s += (a[i] * (b[-1] - b[i+1]))
print(s % (10**9+7))
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
b = [None] * n
print(a.index(1) + 1, end=" ")
for i in range(1, n):
    print(a.index(i + 1) + 1, end=" ")
print("")


### FIXED CODE ###

import sys
import collections
import bisect


def main():
    n = int(input())
    A = list(map(int, input().split()))
    B = [0] * n
    for i in range(n):
        B[A[i] - 1] = str(i + 1)
    print(" ".join(B))


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

#D
n = int(input())
s = input()
s_l = tuple(s)


cnt = 0
for i in range(n-2):
    for j in range(i,n-1):
        if s_l[i] != s_l[j]:
            for k in range(j,n):
                if s_l[i] != s_l[k] and s_l[j] != s_l[k] and j-i != k-j:
                    cnt += 1

print(cnt)

### FIXED CODE ###

#D
n = int(input())
s = input()
s_l = list(s)

a = s_l.count('R') * s_l.count('G') * s_l.count('B')
cnt = 0
#i,j,kがそれぞれ異なり、j-i = k-jであるものを求める
for i in range(n-2):
    for j in range(i,n-1):
        if 2*j - i < n:
            if s_l[i] != s_l[j] and s_l[i] != s_l[2*j-i] and s_l[j] != s_l[2*j-i]:
                cnt += 1
                
print(a - cnt)