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

# coding: utf-8
# Your code here!
n = int(input())
s = list(map(int,input().split()))
ans = {}
a = []
answer = 0
for i in s:
    if not i in a:
        ans[i] = s.count(i)*(s.count(i)-1)//2
        a.append(i)
        answer += ans[i]
#print(ans)

#print(answer)
for i in range(n):
    print(answer-ans[s[i]]+((ans[s[i]]*2//s.count(s[i]))*(s.count(s[i])-2)//2)) 


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
List={}
x=0
for i in range(n):
    if not a[i] in List:
        List[a[i]] = 1
    else:
        List[a[i]]+=1
    
sigma=0
 
for key,item in List.items():
    sigma += item*(item-1)//2
for i in range(n):
    print(sigma-List[a[i]]+1)
### BUGGY CODE ###

x,y = map(int,input().split())
i = 1
if x == y:
  print(-1)
else:
  while True:
    if i%x == 0 and y != 0:
      print(i)
    else:
      i += 1

### FIXED CODE ###

x,y = map(int,input().split())
if x%y == 0:
  print(-1)
else:
  print(x)
### BUGGY CODE ###

X = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

def f(a, b):
  return a**5 - b**5

divs = make_divisors(X)
ans = 0
for div in divs:
  a = -div-100
  b = -100
  while f(a, b) < X and a < 2:
    a += 1
    b += 1
  if f(a, b) == X:
    ans = (a, b)
  a = -100
  b = -div-100
  while f(a, b) > X and a < 2:
    a += 1
    b += 1
  if f(a, b) == X:
    ans = (a, b)
    
print(ans[0], ans[1])

### FIXED CODE ###

X = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    save = -1
    for i in range(len(divisors)):
        if divisors[i] >= 200:
            save = i
            break
    if save > 0:
        divisors = divisors[:save]
    return divisors

def f(a, b):
  return a**5 - b**5

divs = make_divisors(X)
ans = 0
for div in divs:
  a = -div-120
  b = -120
  while f(a, b) < X and a < 2:
    a += 1
    b += 1
  if f(a, b) == X:
    ans = (a, b)
  a = -120
  b = -div-120
  while f(a, b) > X and b < 2:
    a += 1
    b += 1
  if f(a, b) == X:
    ans = (a, b)
    
print(ans[0], ans[1])
### BUGGY CODE ###

v, e, r = list(map(int, input().split()))
edgeList = [[0, 0, 0] for i in range(e)]
for i in range(e):
    a = list(map(int, input().split()))
    edgeList[i] = [a[2], a[0], a[1]]
 
 
rootList = [-1 for i in range(v)]
parent = [0 for i in range(v)]
lenList = [float("inf") for i in range(v)]
lenList[r] = 0
def getRoot(x):
    root = rootList[x]
    if root < 0:
        rootList[x] = x
    elif root != x:
        rootList[x] = getRoot(root)
    return rootList[x]
 
flag = True
while flag:
    flag = False
    edgeList.sort(key=lambda x: (x[0] + lenList[x[1]]))
    for e in edgeList:    # weight:e[0], e[1]->e[2]
        if e[2] == r:
            continue
        x = getRoot(e[1])
        y = getRoot(e[2])
        if x == r != y:
            parent[e[2]] = e[1]
            lenList[e[2]] = lenList[e[1]] + e[0]
            rootList[y] = r
            flag = True
            break
 
for i in lenList:
    if i == float("inf"):
        print("INF")
    else:
        print(i)

### FIXED CODE ###

from heapq import heappush, heappop
V, E, s = map(int, input().split())
Adj = [[] for i in range(V)]

for i in range(E):
    ui, vi, ci = map(int, input().split())
    Adj[ui].append([vi, ci])

d = [float("inf")] * V
d[s] = 0
pq = [[0, s]]
fixed = 0

while pq:
    di, v = heappop(pq)

    if di > d[v]:
        continue

    for u, c in Adj[v]:
        if d[v] + c < d[u]:
            d[u] = d[v] + c
            heappush(pq, [d[u], u])

    fixed += 1

    if fixed == V - 1:
        break

for di in d:
    print(di if di != float("inf") else 'INF')
### BUGGY CODE ###

n,s=map(int,input().split())
*A,=map(int,input().split())
mod=998244353
dp=[[0]*(s+1) for i in range(n+1)]
dp[0][0]=1
for i in range(n):
    for j in range(s+1):
        if A[i]+j<s+1:
            dp[i+1][j+A[i]]+=dp[i][j]
        dp[i+1][j]+=2*dp[i][j]
        dp[i+1][j]%=mod
print(dp[-1][-1])


### FIXED CODE ###

n,s=map(int,input().split())
*A,=map(int,input().split())
mod=998244353
dp=[[0]*(s+1) for i in range(n+1)]
dp[0][0]=1
for i in range(n):
    for j in range(s+1):
        if A[i]+j<s+1:
            dp[i+1][j+A[i]]=(dp[i+1][j+A[i]]+dp[i][j])%mod
        dp[i+1][j]=(dp[i+1][j]+2*dp[i][j])%mod
print(dp[-1][-1])
### BUGGY CODE ###

def readinput():
    n=int(input())
    x=input()
    return n,x

def popcount(n):
    binn=bin(n)
    return binn.count('1')

def f(n):
    #print(n)
    if n==0:
        return 0
    else:
        m=n%popcount(n)
        return f(m)+1

def main(n,x):
    for i in range(n):
        y=x
        if x[i]=='1':
            y=x[:i]+'0'+x[i+1:]
        else:
            y=x[:i]+'1'+x[i+1:]
        yint=int(y,2)
        print(f(yint))

if __name__=='__main__':
    n,x=readinput()
    main(n,x)


### FIXED CODE ###

def readinput():
    n=int(input())
    x=input()
    return n,x

poptbl=[0]*(2*10**5+1)
def popcount(x):
    global poptbl
    if poptbl[x]!=0:
        return poptbl[x]
    
    poptbl[x]=bin(x).count('1')
    return poptbl[x]

ftbl=[0]*(2*10**5+1)
def f(x):
    global ftbl

    if ftbl[x]!=0:
        return ftbl[x]
    
    #print('f(x), x: {}'.format(x))
    if x==0:
        return 0
    else:
        ans=f(x%popcount(x))+1
        #print(ans)
        ftbl[x]=ans
        return ans    

def main():
    n=int(input())
    x=input()
    m=x.count('1')
    #print('m: {}'.format(m))
    xint=int(x,2)
    #print('xint: {}'.format(xint))
    if m!=1:
        xmodm1=xint%(m-1)
    else:
        xmodm1=1
    xmodp1=xint%(m+1)
    pow2mod1=[0]*n
    pow2mod2=[0]*n
    pow2mod1[0]=1
    pow2mod2[0]=1
    for i in range(1,n):
        if m!=1:
            pow2mod1[i]=pow2mod1[i-1]*2 % (m-1)
        pow2mod2[i]=pow2mod2[i-1]*2 % (m+1)

    ans=[]
    #b=2**(n-1)
    for i in range(n):
        if x[i]=='1':
            if m==1:
                a=0
                ans.append(a)
            else:
                xx=( xmodm1 + (m-1) -pow2mod1[n-i-1] )%(m-1)
                #ans.append(f(xx)+1)
                a=f(xx)+1
                ans.append(a)
        else:
            xx=( xmodp1 + pow2mod2[n-i-1] )%(m+1)
            #ans.append(f(xx)+1)
            a=f(xx)+1
            ans.append(a)
        #b=b//2
        print(a)
    return ans

if __name__=='__main__':
    #n,x=readinput()
    ans=main()
    #for a in ans:
    #    print(a)
### BUGGY CODE ###

import collections

h,w = map(int,input().split())
maze = []
ans = 0
dy_dx = [[0,1],[1,0],[0,-1],[-1,0]]
for i in range(h):
    s = input()
    a = []
    for j in range(w):
        a.append(s[j])
    maze.append(a)
for i in range(h):
    for j in range(w):
        if maze[i][j] != '#':
            next = collections.deque()
            dist = []
            checked = []
            curmax = 0
            for k in range(h):
                a = [0]*w
                b = [0]*w
                dist.append(a)
                checked.append(b)
            next.append([i,j])
            while len(next) != 0:
                cur = next.popleft()
                checked[cur[0]][cur[1]] = 1
                for l in range(4):
                    if (0 <= cur[0]+dy_dx[l][0] <= h-1) and (0 <= cur[1]+dy_dx[l][1] <= w-1):
                        if checked[cur[0]+dy_dx[l][0]][cur[1]+dy_dx[l][1]] == 0:
                            if maze[cur[0]+dy_dx[l][0]][cur[1]+dy_dx[l][1]] == '.':
                                dist[cur[0]+dy_dx[l][0]][cur[1]+dy_dx[l][1]] = dist[cur[0]][cur[1]]+1
                                next.append([cur[0]+dy_dx[l][0],cur[1]+dy_dx[l][1]])
                                curmax = max(curmax,dist[cur[0]+dy_dx[l][0]][cur[1]+dy_dx[l][1]])
            ans = max(ans,curmax)
print(ans)        

### FIXED CODE ###

from collections import deque

h,w = map(int,input().split())
maze = []
ans = 0
dy_dx = [[0,1],[1,0],[0,-1],[-1,0]]
for i in range(h):
    maze.append(input())
flag = True
check = '.'*w
for i in range(h):
    if maze[i] != check:
        flag = False
        break
if flag:
    print(h+w-2)
else:
    for i in range(h):
        for j in range(w):
            if maze[i][j] == '.':
                ne = deque([[i,j]])
                dist = [[0]*w for k in range(h)]
                checked = [[0]*w for k in range(h)]
                while len(ne) != 0:
                    cur = ne.popleft()
                    checked[cur[0]][cur[1]] = 1
                    for l in range(4):
                        t = cur[0]+dy_dx[l][0]
                        u = cur[1]+dy_dx[l][1]
                        if (0 <= t <= h-1) and (0 <= u <= w-1):
                            if checked[t][u] == 0:
                                if maze[t][u] == '.':
                                    dist[t][u] = dist[cur[0]][cur[1]]+1
                                    ne.append([t,u])
                                    ans = max(ans,dist[t][u])
    print(ans)
### BUGGY CODE ###

N=int(input())  #数値入力 「N」だけの入力のとき
A=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき

def check():
    for i in range(N):
        if sum(A[:i]) == sum(A[i:]):
            return True
    return False

def check_distance():
    ret = []
    for i in range(1, N):
        tmp_a = abs(sum(A[:i]) - sum(A[i:]))
        ret.append(tmp_a)
        # print(f"at {i}, abs:{tmp_a}")
    return min(ret)

if check():
    print(0)
else:
    print(check_distance())

### FIXED CODE ###

N=int(input())  #数値入力 「N」だけの入力のとき
A=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき

# from functools import lru_cache
# @lru_cache(maxsize=100000)

# 一度差を出してから，どんどんi-1, i+1の和で縮めていく．

def check_distance():
    ret = []
    left = A[0]
    right = sum(A[1:])
    tmp_a = abs(left - right)
    ret.append(tmp_a)

    for i in range(1, N-1):
        left += A[i]
        right -= A[i]
        tmp_a = abs(left - right)
        ret.append(tmp_a)
    return min(ret)

print(check_distance())
### BUGGY CODE ###

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

for _ in range(q):
  l, r = map(int, input().split())
  l = l-1
  r = r-1
  temp = s[l:r+1]
  c = 0
  for i in range(len(temp)-1):
    if temp[i] == "A" and temp[i+1] == "C":
      c += 1

  print(c)

### FIXED CODE ###

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

t = [0] * (n+1)

for i in range(n):
  if s[i:i+2] == "AC":
    t[i+1] = t[i] + 1
  else:
    t[i+1] = t[i]

for i in range(q):
  l, r = map(int, input().split())
  l = l-1
  r = r-1
  print(t[r] - t[l])
### BUGGY CODE ###

n = int(input())
c = input()
ans = min(c.count('W'),c.count('R'))
for i in range(1, n - 1):
  l = c[:i].count('W')
  r = c[i:].count('R')
  ans = min(ans,max(l,r))
print(ans)

### FIXED CODE ###

n = int(input())
c = input()
_w = c.count('W')
_r = c.count('R')
ans = min(_w, _r)
d = [0] * n # i番目までのwの個数
d[0] = 1 if c[0] == 'W' else 0
for i in range(n-1):
  d[i] = d[i-1] + 1 if c[i] == 'W' else d[i-1]
for i in range(1, n - 1):
  l = d[i-1] #c[:i].count('W')
  r = _r - (i-d[i-1])
  ans = min(ans,max(l,r))
print(ans)
### BUGGY CODE ###

def DP():
  H,N,*T = map(int,open(0).read().split())
  
  #dpテーブルの設定と初期化
  dp = [0] + [10 ** 9] * H
  
  #各魔法について
  for d,c in zip(*[iter(T)] * 2):
    #d,cはそれぞれ魔法ダメージと魔法のコスト
    #dpテーブルの各HPについて
    for j in range(H + 1):
      k = max(j - d,0)
      #ダメージjを与える時のコストについて、
      #魔法iを新たに使った場合と、既存の最小コストを比較し更新する
      l = dp[k] + c
      dp[j] = min(l,dp[j])
  
  print(dp[-1])
  
DP()

### FIXED CODE ###

def main():
    h,n,*t=map(int,open(0).read().split())
    d=[0]+[10**18]*h
    for a,b in zip(*[iter(t)]*2):
        for j in range(h+1):
            k=j-a
            if k<0:k=0
            c=d[k]+b
            if c<d[j]:d[j]=c
    print(d[h])
main()
### BUGGY CODE ###

N = int(input())
A = [int(_) for _ in input().split()]
ans = [0] * N
for i in range(N):
    A_copy = A.copy()
    del A_copy[i]
    if i % 2 == 0:
        ans[i] = str(sum([A_copy[t] * (-1) ** ((t + 1) % 2) for t in range(N - 1)]) + A[i])
    else:
        ans[i] = str(sum([A_copy[t] * (-1) ** (t % 2) for t in range(N - 1)]) + A[i])
print(' '.join(ans))

### FIXED CODE ###

n = int(input())
r_list = list(map(int, input().split()))
ans_list = []

for i in range(len(r_list)):
    if i == 0:
        a = sum(r_list)
        for j in range(1, len(r_list)):
            if j % 2 == 1:
                a -= r_list[j] * 2
    else:
        a = (2 * r_list[i-1]) - ans_list[i-1]
    ans_list.append(a)

print(' '.join(map(str, ans_list)))
### BUGGY CODE ###

import bisect
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
Query = []
for _ in range(m):
    b,c = map(int,input().split())
    Query.append([c,b])
Query.sort(reverse=True)
for i in range(m):
    b,c = Query[i][1],Query[i][0]
    if min(A) >= c:
        pass
    else:
        A.sort()
        index = bisect.bisect_left(A,c)
        if b <= index:
            for i in range(b):
                A[i] = c
        else:
            for i in range(index):
                A[i] = c
print(sum(A))

### FIXED CODE ###

import sys
input = sys.stdin.readline
import bisect
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

minA = A[0]
Query = []
for _ in range(m):
    b,c = map(int,input().split())
    if c > minA:
        Query.append([b,c])
Query = sorted(Query, key=lambda x:(x[1], x[0]), reverse=True)

ans = 0
index = 0
for b,c in Query:
    if index >= n:
        break
    #print("----")
    cnt = 0
    Flag = True
    while Flag:
        #print(A,b,c,index)
        if A[index] < c:
            A[index] = c
            cnt += 1
            index += 1
            if (cnt >= b) or (index >= n):
                Flag = False
        else:
            Flag = False
    '''
    #A.sort()
    if A[0] >= c:
        break
    else:
        index = min(bisect.bisect_left(A,c),b)
        if index > len(A):
            ans += c * len(A)
            break
        else:
            ans += c * index
            A = A[index:]
    print(A)
    '''
print(sum(A))
### BUGGY CODE ###

from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n,m = inpl()
aa = [[] for i in range(m)]
ans = 0
for i in range(n):
    a,b = inpl()
    if a <= m:
        aa[a-1].append(b)
for i in range(m):
    if aa[i]:
        aa[i].sort()
        ans += aa[i].pop()
        if i < m-1:
            for j in aa[i]:
                aa[i+1].append(j)
print(ans)




### FIXED CODE ###

from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

ans = 0
hq = []
n,m = inpl()
ab = [[] for i in range(m)]
for i in range(n):
    a,b = inpl()
    if a <= m:
        ab[a-1].append(b)

heapq.heapify(hq)
for i in range(m):
    for j in ab[i]:
        heapq.heappush(hq,-j)
    if hq:
        ans -= heapq.heappop(hq)
print(ans)
### BUGGY CODE ###

#codinng:utf-8

N = int(input())
count = 0

while N > 0:
    count += (N % 100) % 9
    N = N // 100

if count % 9 == 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

#codinng:utf-8

N = int(input())
count = 0

while N > 0:
    count += (N % (10 ** 100)) % 9
    N = N // (10 ** 100)

if count % 9 == 0:
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

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

city = [[] for _ in range(n+1)]
arr = []

for i in range(m):
    s,t = map(int,input().split())
    city[s].append(t)
    arr.append((s,t))

for i in range(1,n+1):
    city[i].sort()
    
for i in range(m):
    x = str(arr[i][0])
    y = str(city[int(x)].index(arr[i][1]) + 1)
    print(x.rjust(6, "0") + y.rjust(6,"0"))

### FIXED CODE ###

import collections
import bisect

n,m = map(int,input().split())
 
city = [[] for _ in range(n+1)]
arr = []
 
for i in range(m):
    s,t = map(int,input().split())
    arr.append((s,t))
 
city =collections.defaultdict(list)

for x,y in sorted(arr):
    city[x] += [y]
for x,y in arr:
    z=str(bisect.bisect(city[x],y))
    print(str(x).rjust(6, "0") + z.rjust(6,"0"))
### BUGGY CODE ###

import numpy as np
import fractions
N = int(input())
numbers = np.array(list(map(int, input().split())))
# numbers = np.array([7, 6, 8])
# numbers = np.array([12, 15, 18])
# numbers = np.array([1000000000, 1000000000])
# N = len(numbers)


def calculate_maximum_sub_gcd(numbers):
    sub_gcds = np.array([sub_gcd(numbers[:i], numbers[i+1:]) for i in range(N)])
    return np.max(sub_gcds)


def sub_gcd(left, right):
    gcd = np.frompyfunc(fractions.gcd, 2, 1)
    if not left.size > 0:
        return np.ufunc.reduce(gcd, right)
    if not right.size > 0:
        return np.ufunc.reduce(gcd, left)
    else:
        subleft = np.ufunc.reduce(gcd, left)
        subright = np.ufunc.reduce(gcd, right)
        return gcd(subleft, subright)


print(calculate_maximum_sub_gcd(numbers))


### FIXED CODE ###

# import math
import fractions
import numpy as np
from itertools import accumulate, chain, islice, starmap
N = int(input())
numbers = list(map(int, input().split()))
# numbers = [2, 4, 8, 8]
# N = len(numbers)


def calculate_maximum_subgcd_with_np_ufunc(numbers):
    gcd = np.frompyfunc(fractions.gcd, 2, 1)
    cumgcds = gcd.accumulate(numbers, dtype=np.object).astype(np.int)
    sub_cumgcds = np.roll(cumgcds, 1)
    sub_cumgcds[0] = 0
    reverse_cumgcds = gcd.accumulate(
        numbers[::-1], dtype=np.object).astype(np.int)
    sub_reverse_cumgcds = np.roll(reverse_cumgcds, 1)
    sub_reverse_cumgcds[0] = 0
    return np.max(gcd(sub_cumgcds, sub_reverse_cumgcds[::-1]))


def calculate_maximum_subgcd_with_func(numbers):
    operation = fractions.gcd
    cumgcds = accumulate(numbers, operation)
    sub_cumgcds = islice(chain([0], cumgcds), len(numbers))
    reverse_cumgcds = accumulate(numbers[::-1], operation)
    sub_reverse_cumgcds = islice(chain([0], reverse_cumgcds), len(numbers))
    sub_gcds = starmap(operation, zip(sub_cumgcds, list(sub_reverse_cumgcds)[::-1]))
    return max(sub_gcds)


# calculate_maximum_subgcd = calculate_maximum_subgcd_with_np_ufunc
calculate_maximum_subgcd = calculate_maximum_subgcd_with_func

print(calculate_maximum_subgcd(numbers))
### BUGGY CODE ###

#!/usr/bin/env python3

def solve(n,k,a):
    l = [k]*n
    for i in range(len(a)):
        l[a[i]-1] += 1
        l = list(map(lambda x: x-1, l))
    lst = list(map(lambda x : x > 0 ,l))
    return lst


def main():
    N,K,Q = map(int,input().split())
    a = [int(input()) for _ in range(Q)]
    L = solve(N,K,a)
    for i in range(N):
        print("Yes" if L[i] else "No")

if __name__ == '__main__':
    main()

### FIXED CODE ###

#!/usr/bin/env python3
from collections import Counter


def main():
    N,K,Q = map(int,input().split())
    a = [int(input()) for _ in range(Q)]
    d = Counter(a)
    L = [(K+d[i+1]-Q)>0 for i in range(N)] 
    for i in range(N):
        print("Yes" if L[i] else "No")

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

N, K = [ int(v) for v in input().split(" ") ]
points = [ int(v) for v in input().split(" ") ]

results = []

for i in range(K, N+1):
  next_score = 1
  for p in points[i-K:i]:
    next_score *= p
  results.append(next_score)
  
for i in range(1, len(results)):
  if results[i] > results[i-1]:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

N, K = [ int(v) for v in input().split(" ") ]
points = [ int(v) for v in input().split(" ") ]

for i in range(K+1, N+1):
  if points[i-K-1] < points[i-1]:
    print("Yes")
  else:
    print("No")
### BUGGY CODE ###

import math

N=int(input())
A = list(map(int,input().split()))
cnt=[]
B=[]
for i in range(1,N+1):
	cnt.append(A.count(i))
ans=0
for i in range(1,N+1):
	if cnt[i-1]==0:
		ans+=0
	else:
		ans+=cnt[i-1]*(cnt[i-1]-1)//2

for i in range(0,N):
	point=A[i]
	deff=(cnt[point-1]*(cnt[point-1]-1))//2-((cnt[point-1]-1)*(cnt[point-1]-2))//2
	print(ans-deff)

### FIXED CODE ###

import math

N=int(input())
A = list(map(int,input().split()))
cnt=[0]*(N+1)
for i in range(0,N):
	cnt[A[i]-1]+=1
ans=0
for i in range(0,N+1):
	if cnt[i]==0:
		ans+=0
	else:
		ans+=cnt[i]*(cnt[i]-1)//2

for i in range(0,N):
	point=A[i]
	deff=(cnt[point-1]*(cnt[point-1]-1))//2-((cnt[point-1]-1)*(cnt[point-1]-2))//2
	print(ans-deff)
### BUGGY CODE ###



#１回のクエリで半分に空席がある場所を絞る
end = int(input()) - 1
print(0, flush=True)
S = input().rstrip()[0]
if S == 'V':
    exit()
start = 0
cur = S
for _ in range(19):
    target = start + max(2, (end - start) // 4 * 2)
    print(target, flush=True)
    s = input().rstrip()[0]
    if s == 'V':
        exit()
    if cur != s:
        end = target
    else:
        start = target
print(start + 1, flush=True)
s = input().rstrip()[0]
if s == 'V':
    exit()
else:
    print(start + 2, flush=True):
    exit()
#24


### FIXED CODE ###

N = int(input())

def ask(n):
    print(n, flush=True)
    resp = input().rstrip()[0]
    if resp == 'V':
        exit()
    return resp

def condition(L,R,resp_L,resp_R):
    if (R-L)&1:
        return resp_L == resp_R
    else:
        return resp_L != resp_R

resp = ask(0)

L = 0
R = N
resp_L = resp
resp_R = resp
for _ in range(19):
    M = (L + R) // 2
    resp_M = ask(M)
    if condition(L,M,resp_L,resp_M):
        R,resp_R = M,resp_M
    else:
        L,resp_L = M,resp_M
### BUGGY CODE ###

def dijkstra(s,n,w,cost):
    d = [float('inf')] * n
    used = [False] * n
    d[s] = 0

    while True:
        v = -1
        for i in range(n):
            if (not used[i]) and (v == -1):
                v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
            break
        used[v] = True

        for j in range(n):
            d[j] = min(d[j],d[v] + cost[v][j])
    return d

N = int(input())

cost = [[float('inf')] * N for _ in range(N)]

for i in range(N-1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    cost[a][b] = c
    cost[b][a] = c


Q, K = map(int, input().split())
b = dijkstra(K-1,N,N-1,cost)
for _ in range(Q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    print(b[x] + b[y])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
def dfs(v,p,d):
    for i, j in tree[v]:
        if i != p:
            depth[i] = d + j
            dfs(i,v,d+j)

N = int(input())

tree = [[] for _ in range(N)]

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

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

depth = [0 for i in range(N)]
depth[K-1] = 0

dfs(K-1,-1,0)

for _ in range(Q):
    x, y = map(int, input().split())
    print(depth[x-1] + depth[y-1])
### BUGGY CODE ###

N = int(input())
List = list(map(int, input().split()))
res = 0
A = [[0 for j in range(N)] for i in range(N)]
B = [[0 for j in range(N)] for i in range(N)]
for i in range(N):
  for j in range(i,N):
    if A[j][i] != 0:
      pass
    else:
      A[i][j] = List[i]+List[j]
      B[i][j] = A[i][j]-abs(j-i)
      if B[i][j] == 0:
        res = res + 1
print(res)

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
m = {}
ans = 0
for i in range(n):
    x = A[i] + i   #i番目と当該数字の和
    if x not in m:
        m[x] = 0   #和の属性値を0とする
    m[x] += 1      #和の属性値に１を足す
    if i - A[i] in m: #i番目と当該数字の差
        ans += m[i - A[i]] #差の位置に当たる属性値を答えに足す
print(ans)
### BUGGY CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
max_sum_k = 0

for i in range(n - k + 1):
    max_sum_k = max(max_sum_k, sum(p[i:i+k]))

max_ex = (k + max_sum_k) / 2
print(max_ex)


### FIXED CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
max_sum_k = 0
cum_sum = [0] * (n+1)
cum_sum[0] = 0
cum_sum[1] = p[0]
for i in range(2, n+1):
    cum_sum[i] = p[i-1] + cum_sum[i-1]

for i in range(k, n + 1):
    sum_p = cum_sum[i] - cum_sum[i-k]
    if sum_p > max_sum_k:
        max_sum_k = sum_p

max_ex = (k + max_sum_k) / 2
print(max_ex)