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

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

a  = [0]*n

a = [int(s) for s in input().split()]

nxt = a[0]

seen = [0]
#load = []
res = 0
flag = 0
for i in range(k-1):
    #print(nxt)
    if not(nxt in seen):
        seen.append(nxt)
        nxt = a[nxt-1]
    else:
        root = i - seen.index(nxt) + 1
        #print(root)
        #print(k-1-i)
        zansa = (k-1-i)%root
        res = seen[seen.index(nxt)+zansa]
        flag = 1
        break


if(flag == 1):
    print(res)
else:
    print(nxt)

### FIXED CODE ###

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

a  = [0]*n

a = [int(s) for s in input().split()]

nxt = a[0]

seen = [1]
load = set()
load.add(1)
res = 0
flag = 0
for i in range(k-1):
    #print(seen)
    #print(nxt)
    if not(nxt in load):
        seen.append(nxt)
        load.add(nxt)
        nxt = a[nxt-1]
    else:
        root = i - seen.index(nxt) + 1
        #print(root)
        #print(k-1-i)
        zansa = (k-1-i)%root
        res = seen[seen.index(nxt)+zansa]
        flag = 1
        break


if(flag == 1):
    print(res)
else:
    print(nxt)
### BUGGY CODE ###

import math

n = int(input())
aL = list(map(int, input().split(" ")))

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

print(ans)


### FIXED CODE ###

import math

n = int(input())
aL = list(map(int, input().split(" ")))

d1 = {}
d2 = {}
for i in range(n):
    d1i = i - aL[i]
    d2i = i + aL[i]

    if d1i in d1:
        d1[d1i] += 1
    else:
        d1[d1i] = 1

    if d2i in d2:
        d2[d2i] += 1
    else:
        d2[d2i] = 1

ans = 0
for k, v in d2.items():
    if k in d1:
        ans += v * d1[k]

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

import heapq

N,K=map(int,input().split())
A=sorted(map(int,input().split()))
for i in range(N):
    if A[i]>=0:
        break
minus=i
for i in range(i,N):
    if A[i]>0:
        break
zero=i-minus
plus=N-zero-minus
if minus*plus>=K:
    h=[]
    heapq.heapify(h)
    for a in A[:minus]:
        for b in A[minus+zero:]:
            heapq.heappush(h,a*b)
    for _ in range(K-1):
        heapq.heappop(h)
    print(heapq.heappop(h))
    exit()
K-=minus*plus
if zero!=0:
    for i in range(zero):
        K-=N-zero+i
    if K<=0:
        print(0)
        exit()
h=[]
heapq.heapify(h)
for i in range(minus+zero,N-1):
    for j in range(i+1,N):
        heapq.heappush(h,A[i]*A[j])
for i in range(minus-1):
    for j in range(i+1,minus):
        heapq.heappush(h,A[i]*A[j])
for _ in range(K-1):
    heapq.heappop(h)
print(heapq.heappop(h))


### FIXED CODE ###

N,K=map(int,input().split())
A=sorted(map(int,input().split()))
x=0
r=10**18+1
l=-(10**18)
while l+1<r:
    x=(l+r)//2
    k=0
    for a in A:
        if a<0:
            ll,rr=-1,N
            while ll+1<rr:
                c=(rr+ll)//2
                if x>a*A[c]:
                    rr=c
                else:
                    ll=c
            k+=N-rr
        else:
            ll,rr=-1,N
            while ll+1<rr:
                c=(rr+ll)//2
                if x>a*A[c]:
                    ll=c
                else:
                    rr=c
            k+=rr
        if x>a**2:
            k-=1
    k//=2
    if k<K:
        l=x
    else:
        r=x
print(l)
### BUGGY CODE ###

from sys import stdin
import queue

H, W = [int(x) for x in stdin.readline().rstrip().split()]
maze = [stdin.readline().rstrip().split()[0] for _ in range(H)]

ans = 0

for h in range(H):
    for w in range(W):
        if maze[h][w] == '#':
            continue
        else:
            q = queue.Queue()
            q.put((h, w, 0))
            temp_h = h
            temp_w = w
            visited = [[0] * W for _ in range(H)]
            visited[h][w] = 1
            while q.qsize() > 0:
                temp = q.get()
                temp_h = temp[0]
                temp_w = temp[1]
                temp_d = temp[2]
                ans = max(ans, temp_d)
                visited[temp_h][temp_w] = 1
                if temp_h + 1 < H and maze[temp_h + 1][temp_w] == '.' and visited[temp_h + 1][temp_w] == 0:
                    # visited[temp_h + 1][temp_w] = 1
                    q.put((temp_h + 1, temp_w, temp_d + 1))
                if temp_h - 1 >= 0 and maze[temp_h - 1][temp_w] == '.' and visited[temp_h - 1][temp_w] == 0:
                    # visited[temp_h - 1][temp_w] = 1
                    q.put((temp_h - 1, temp_w, temp_d + 1))
                if temp_w + 1 < W and maze[temp_h][temp_w + 1] == '.' and visited[temp_h][temp_w + 1] == 0:
                    # visited[temp_h][temp_w + 1] = 1
                    q.put((temp_h, temp_w + 1, temp_d + 1))
                if temp_w - 1 >= 0 and maze[temp_h][temp_w - 1] == '.' and visited[temp_h][temp_w - 1] == 0:
                    # visited[temp_h][temp_w - 1] = 1
                    q.put((temp_h, temp_w - 1, temp_d + 1))

print(ans)


### FIXED CODE ###

from sys import stdin
import queue

H, W = [int(x) for x in stdin.readline().rstrip().split()]
maze = [stdin.readline().rstrip().split()[0] for _ in range(H)]

ans = 0

for h in range(H):
    for w in range(W):
        if maze[h][w] == '#':
            continue
        else:
            q = queue.Queue()
            q.put((h, w))
            visited = [[-1] * W for _ in range(H)]
            visited[h][w] = 0
            while q.qsize() > 0:
                temp = q.get()
                temp_h = temp[0]
                temp_w = temp[1]
                ans = max(ans, visited[temp_h][temp_w])
                if temp_h + 1 < H and maze[temp_h + 1][temp_w] == '.' and visited[temp_h + 1][temp_w] < 0:
                    visited[temp_h + 1][temp_w] = visited[temp_h][temp_w] + 1
                    q.put((temp_h + 1, temp_w))
                if temp_h - 1 >= 0 and maze[temp_h - 1][temp_w] == '.' and visited[temp_h - 1][temp_w] < 0:
                    visited[temp_h - 1][temp_w] = visited[temp_h][temp_w] + 1
                    q.put((temp_h - 1, temp_w))
                if temp_w + 1 < W and maze[temp_h][temp_w + 1] == '.' and visited[temp_h][temp_w + 1] < 0:
                    visited[temp_h][temp_w + 1] = visited[temp_h][temp_w] + 1
                    q.put((temp_h, temp_w + 1))
                if temp_w - 1 >= 0 and maze[temp_h][temp_w - 1] == '.' and visited[temp_h][temp_w - 1] < 0:
                    visited[temp_h][temp_w - 1] = visited[temp_h][temp_w] + 1
                    q.put((temp_h, temp_w - 1))

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

s = input()
l = len(s)
i =0
while s != 'W' * (l ) and s != 'B' * (l):
    x = s[0]
    if x == 'B':
        k = s.find('W')
        s = s[k:]
        s = 'W' * (k+1) + s
    else:
        k = s.find('B')
        s = s[k:]
        s = 'B' * (k+1) + s
    i += 1
    l = len(s)
print(i)


### FIXED CODE ###

s = input()
l = len(s)
i =0
while s != 'W' * (l) and s != 'B' * (l):
    x = s[0]
    if x == 'B':
        k = s.find('W')
        s = s[k:]
    else:
        k = s.find('B')
        s = s[k:]
    i += 1
    l = len(s)
print(i)
### BUGGY CODE ###

import math
import numpy as np
def comb(n, r):
    if n == -1:
        n = 0
    return n*(n-1) // 2
n = int(input())
num_list =  list(map(int,input().split()))
num_list2 = [0]*n
num_list3 = [0]*n
for i in num_list:
    num_list2[i-1] += 1
for i in range(n):
    ans = comb(num_list2[i-1],2)
    num_list3[i-1] = ans

for i in num_list:
    ans = comb(num_list2[i-1]-1,2)
    print(ans-num_list3[i-1]+np.sum(num_list3))
  #  elif size == 1:
        #ans = 0
   # else :
    #    ans = 0 
    #num_list5[num_list2[i]-1] = ans


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
cnt = [0] * n
for i in a:
    cnt[i-1] += 1
total = [0] * n
for i in range(n):
    total[i] = cnt[i] * (cnt[i] - 1) // 2
total_sum = sum(total)
for i in a:
    ans = total_sum
    ans -= total[i-1]
    ans += (cnt[i-1] - 1) * (cnt[i-1] - 2) // 2
    print(ans)
### BUGGY CODE ###

import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

s=input()
n=len(s)
lst=[0]*n
for i in range(n):
    lst[i]=s[i]

i=0
ans=0
while i<n-2:
    # print(i)
    # print(lst[i:i+3])
    if lst[i]=="A" and lst[i+1]=="B" and lst[i+2]=="C":
        lst[i],lst[i+1],lst[i+2]="B","C","A"
        ans+=1
        i=max(0,i-1)
        continue
    i+=1
print(ans)
# print(lst)

### FIXED CODE ###

import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

s=input()
n=len(s)
lst=[0]*n
for i in range(n):
    lst[i]=s[i]


ans=0
cnt=0
i=0
while i<n-2:
    if lst[i]=="A":
        cnt+=1
    else:
        cnt=0
    if lst[i]=="A" and lst[i+1]=="B" and lst[i+2]=="C":
        ans+=cnt
        cnt-=1
        lst[i+2]="A"
        i+=1
    # print(lst)
    # print(i,ans,cnt)
    i+=1
print(ans)
# print(lst)
### BUGGY CODE ###

k = int(input())

a = [9,8,7,6,5,4,3,2,1]
current_str = ''

for i in range(k):
  current_str = str(a.pop())
  current = list(current_str)
  candidates = []

  if current[-1] == "0":
    cp = current.copy()
    cp1 = current.copy()
    
    cp.append("0")
    cp1.append("1")

    candidates.append(int(''.join(cp)))
    candidates.append(int(''.join(cp1)))
  elif current[-1] == "9":
    cp = current.copy()
    cp1 = current.copy()
    
    cp.append("8")
    cp1.append("9")

    candidates.append(int(''.join(cp)))
    candidates.append(int(''.join(cp1)))
  else:
    cp = current.copy()
    cp1 = current.copy()
    cp2 = current.copy()

    cp.append(str(int(current[-1]) - 1))
    cp1.append(str(int(current[-1])))
    cp2.append(str(int(current[-1]) + 1))

    candidates.append(''.join(cp))
    candidates.append(''.join(cp1))
    candidates.append(''.join(cp2))
    

  for c in candidates:
    a.insert(0, int(c))

print(current_str)

### FIXED CODE ###

from collections import deque

k = int(input())

a = deque([9,8,7,6,5,4,3,2,1])
current_num = 0

for i in range(k):
  current_num = a.pop()
  current_str = str(current_num)
  current_last = int(current_str[-1])

  up = ""  
  mid = current_str + str(current_last)
  down = ""

  if current_last >= 0 and current_last <= 8:
    up = current_str + str(current_last + 1)

  if current_last >= 1 and current_last <= 9:
    down = current_str + str(current_last - 1)
  
  if len(down) != 0:
    a.appendleft(down)

  a.appendleft(mid)

  if len(up) != 0:
    a.appendleft(up)

print(current_num)
### BUGGY CODE ###

K,N=map(int,input().split())
A=list(map(int,input().split()))
b=[]
for i in range(N):
  if A[i]==0:
    b.append(A[N-1])
  else:
    for j in range(i+1,N):
      b.append(K-(A[j]-A[i]))
    

print(min(b))
    

### FIXED CODE ###

K,N=map(int,input().split())
A=list(map(int,input().split()))
b=[]
for i in range(N-1):
  b.append(K-(A[i+1]-A[i]))
  b.append(A[N-1]-A[0])

print(min(b))
### BUGGY CODE ###

import sys
readline = sys.stdin.readline

def main():
  N, K = map(int, readline().split())
  A = list(map(int, readline().split()))
 
  rs = 0
  p = -1
  r = []
  d = 1
  if N > K:
    for i in range(K+1):
      r.append(d)
      d = A[d - 1]
  else:
    for i in range(N+1):
      r.append(d)
      d = A[d - 1]
      for j in range(len(r)):
        if r[j] == d:
          rs = j
          p = i - j + 1
          break
  if p == -1:
    print(r[-1])
  else:
    print(r[rs+(K-rs)%p])

if __name__ == '__main__':
  main()

### FIXED CODE ###

import sys
readline = sys.stdin.readline

def main():
  N, K = map(int, readline().split())
  A = list(map(int, readline().split()))
 
  n = []
  for i in range(N):
    n.append(-1)
  s = 0
  c = -1
  d = A[1-1]
  r = [1]
  n[0] = 0
  for i in range(1, K+1):
    if n[d - 1] == -1:
      n[d - 1] = i
    else:
      s = n[d - 1]
      c = i - n[d - 1]
      break
    r.append(d)
    d = A[d - 1]
  if c == -1:
    print(r[-1])
  else:
    cr = r[s:s+c]
    k = (K - s)%c
    print(cr[k])
  exit()

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

a,b,c,d = map(int,input().split())
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
if c <=0 or d <= 0:
    print("No")
ans = c * d // gcd(c,d)
i = a
j = a
while True:
    if i % c == 0:
        break
    i += 1
while True:
    if j % d == 0:
        break
    j += 1
k = min(i,j)
while True:
    if k % ans == 0:
        break
    k += 1
ii = (b-i)//c 
jj = (b-j)//d 
kk = (b-k)//ans 
print(b-a-ii-jj+kk)


### FIXED CODE ###

a,b,c,d = map(int,input().split())
cc = b//c -(a-1)//c
dd = b//d -(a-1)//d
#a,bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

#a,bの最小公倍数
def lcm(a, b):
	return a * b // gcd (a, b)
cd = lcm(c, d)
cdcd = b//cd -(a-1)//cd
print(b-a+1-cc-dd+cdcd)
### BUGGY CODE ###

N = int(input())
nums = [input() for i in range(N)]

for i in range(0, N):
    f_nums = nums[:i]
    l_nums = nums[i+1:]
    f_nums.extend(l_nums)
    print(max(f_nums))

### FIXED CODE ###

N = int(input())
nums = [int(input()) for i in range(N)]

_nums = sorted(nums, reverse=True)
max1 = _nums[0]
max2 = _nums[1]
for i in range(0, N):
    if nums[i] == max1:
        print(max2)
    else:
        print(max1)
### BUGGY CODE ###

import itertools
N = int(input())
S = list(input())
num = [i for i in range(0,N)]
C = list(itertools.combinations(num,3))
ans = 0
for c in C:
    if c[1]-c[0] == c[2]-c[1]:
        continue
    if S[c[0]] != S[c[1]] and S[c[1]] != S[c[2]] and S[c[0]] != S[c[2]]:
        ans += 1
print(ans)


### FIXED CODE ###

N = int(input())
S = list(input())
R = S.count('R')
G = S.count('G')
B = S.count('B')
ans = R*G*B
for i in range(N):
    for k in range(i+1,N):
        if (k+i)%2 == 1:
            continue
        else:
            j = (k+i)//2
            if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
                ans -= 1
print(ans)
### BUGGY CODE ###

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

def calc(n):
    return sum([i for i in range(1, n+1)]) / n

ex = []
for i in p:
    ex.append(calc(i))
max_ex = 0
for i in range(0, N-(K-1)):
    temp = sum(ex[i:i+K])
    if temp > max_ex:
        max_ex = temp

print(max_ex)

### FIXED CODE ###

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

Es = [(1+p_i)/2 for p_i in p]

t = sum(Es[0:k])
ans = t

for i in range(n-k):
    t -= Es[i]
    t += Es[i+k]
    ans = max(ans,t)

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

R, G, B, N = (int(i) for i in input().split())

RGB = [R, G, B]
RGB.sort(reverse=False)

c = 0
for r in range(N//RGB[0], -1, -1): 
    new1 = N - r*RGB[0]
    for g in range(new1//RGB[1], -1, -1):
        new2 = new1 - g*RGB[1]
        for b in range(new2//RGB[2], -1, -1):
            if b*RGB[2] == new2:
                c += 1

print(c)

### FIXED CODE ###

R, G, B, N = (int(i) for i in input().split())

c = 0
for r in range(N//R, -1, -1): 
    new1 = N - r*R
    for g in range(new1//G, -1, -1):
        new2 = new1 - g*G
        if new2%B == 0:
            c +=1
    
print(c)
### BUGGY CODE ###

while True:
  n = int(input())
  if n == 0:
    break
  wlst = list(map(int, input().split()))
  dp = [[0] * n for _ in range(n + 1)]
  
  def check(left1, right1, left2, right2, cnt):
    if left1 > right1 and left2 > right2: return cnt
    if left1 > right1:return dp[right2 - left2 + 1][left2] + cnt
    if left2 > right2:return dp[right1 - left1 + 1][left1] + cnt
    ret = cnt + dp[right1 - left1 + 1][left1] + dp[right2 - left2 + 1][left2]
    if abs(wlst[right1] - wlst[left2]) <= 1:
      ret = max(ret, check(left1, right1 - 1, left2 + 1, right2, cnt + 1))
    if right1 - left1 + 1 >= 2 and dp[2][right1 - 1]:
      ret = max(ret, check(left1, right1 - 2, left2, right2, cnt + 1))
    if right2 - left2 + 1 >= 2 and dp[2][left2]:
      ret = max(ret, check(left1, right1, left2 + 2, right2, cnt + 1))
    return ret
  
  for length in range(2, n + 1):
    for left in range(n - length + 1):
      for k in range(length - 1):
        dp[length][left] = max(dp[length][left], check(left, left + k, left + k + 1, left + length - 1, 0))
  
  print(dp[n][0] * 2)



### FIXED CODE ###

def main():
  while True:
    n = int(input())
    if n == 0:
      break
    wlst = list(map(int, input().split()))
    connect = [[None] * n for _ in range(n)]
    for i in range(n):
      for j in range(n):
        connect[i][j] = abs(wlst[i] - wlst[j]) <= 1
    
    max_lst = [[False] * (n + 1) for _ in range(n + 1)]
    for i in range(n + 1):
      max_lst[0][i] = True
    
    dp = [[0] * n for _ in range(n + 1)]
    
    def check(length, left):
      ret = dp[length - 1][left]
      for k in range(length - 1, 0, -2):
        if not max_lst[length - k - 1][left + k]:continue
        if connect[left + k - 1][left + length - 1]:
          temp = length - k + 1 + dp[k - 1][left]
          if ret < temp:
            ret = temp
      return ret
    
    for length in range(2, n + 1):
      for left in range(n - length + 1):
        dp[length][left] = check(length, left)
        if dp[length][left] == length:
          max_lst[length][left] = True
    
    print(dp[n][0])

main()
### BUGGY CODE ###

N, K = (int(i) for i in input().split())
l, r = [0]*K, [0]*K
for k in range(K):
    l[k], r[k] = (int(x) for x in input().split())

# dp : マスiまで移動する方法のパターン数
# TLE
'''
import numpy as np
dp = [0]*N
dp[0] = 1
for i in range(N):
    for k in range(K):
        for j in range(l[k], r[k]+1):
            if (i+j < N):
                dp[i+j] = dp[i+j] + dp[i]
            if j == r[k]:
                print(i, (l[k], r[k]), dp, np.diff(dp))
print(dp[-1]%998244353)
'''

# dp : マスiまで移動する方法のパターン数
# dps : dp[i] と dp[i+1] の 差
dp = [0]*N
dps = [0]*(N-1)
dp[0] = 1
dps[0] = -1
for i in range(N-1):
    for k in range(K):
        if i + l[k] - 1 < (N - 1):
            dps[i + l[k] - 1] += dp[i]
        if i + r[k] < (N - 1):
            dps[i + r[k]    ] -= dp[i]
        #print(i, (l[k], r[k]), dp, dps)
    dp[i+1] = dps[i] + dp[i]
print(dp[-1]%998244353)

### FIXED CODE ###

N, K = (int(i) for i in input().split())
l, r = [0]*K, [0]*K
for k in range(K):
    l[k], r[k] = (int(x) for x in input().split())

# dp : マスiまで移動する方法のパターン数
# TLE
'''
import numpy as np
dp = [0]*N
dp[0] = 1
for i in range(N):
    for k in range(K):
        for j in range(l[k], r[k]+1):
            if (i+j < N):
                dp[i+j] = dp[i+j] + dp[i]
            if j == r[k]:
                print(i, (l[k], r[k]), dp, np.diff(dp))
print(dp[-1]%998244353)
'''

# dp : マスiまで移動する方法のパターン数
# dps : dp[i] と dp[i+1] の 差
dp = [0]*N
dps = [0]*(N-1)
dp[0] = 1
dps[0] = -1
for i in range(N-1):
    for k in range(K):
        if i + l[k] - 1 < (N - 1):
            dps[i + l[k] - 1] += dp[i]
        if i + r[k] < (N - 1):
            dps[i + r[k]    ] -= dp[i]
        #print(i, (l[k], r[k]), dp, dps)
    dp[i+1] = (dps[i] + dp[i])%998244353
print(dp[-1]%998244353)
### BUGGY CODE ###

N = int(input())
l = []
for i in range(N):
    S = input()
    if S not in l:
        l.append(S)
print(len(l))


### FIXED CODE ###

N = int(input())
S = [input() for i in range(N)]
print(len(set(S)))
### BUGGY CODE ###

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

rcount = S.count("R")
gcount = S.count("G")
bcount = N-rcount-gcount



count = rcount * gcount * bcount

for i in range(N-1):
    for j in range(i+1,N):
        if S[i] == "R" and S[j] == "G":
            if j+j-i < N and S[j+j-i] == "B":
                count -= 1
            
        if S[i] == "R" and S[j] == "B":
            if j+j-i < N and S[j+j-i] == "G":
                count -= 1

        if S[i] == "G" and S[j] == "R":
            if j+j-i < N and S[j+j-i] == "B":
                count -= 1

        if S[i] == "G" and S[j] == "B":
            if j+j-i < N and S[j+j-i] == "R":
                count -= 1

        if S[i] == "B" and S[j] == "R":
            if j+j-i < N and S[j+j-i] == "G":
                count -= 1

        if S[i] == "B" and S[j] == "G":
            if j+j-i < N and S[j+j-i] == "R":
                count -= 1

print(count)


### FIXED CODE ###

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

rcount = S.count("R")
gcount = S.count("G")
bcount = N-rcount-gcount



count = rcount * gcount * bcount
k = 0
for i in range(N-1):
    for j in range(i+1,N):
        k = 2*j-i
        if k < N :
            if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                count -= 1
print(count)
### BUGGY CODE ###

n = int(input())
p = list(map(int,input().split()))
cnt = 0
for i in range(n):
    state = 1
    for j in range(i):
        if p[i]<=p[j]:
            state = 1
        else:
            state = 0
            break
    if state == 1:
        cnt+=1
print(cnt)

### FIXED CODE ###

n = int(input())
p = list(map(int,input().split()))
cnt = 1
max_p = p[0]
for i in range(1,n):
    if max_p > p[i]:
        max_p = p[i]
        cnt+=1
print(cnt)
### BUGGY CODE ###

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

K,A,B=MAP()

rate=B/A
cnt=A-1
bis=A
while cnt<=K-2:
    bis=(bis//A)*A*rate+bis%A
    cnt+=2
if cnt==K-1:
    bis+=1

print(max(int(bis), K+1))


### FIXED CODE ###

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

"""
参考：https://emtubasa.hateblo.jp/entry/2019/02/12/003250
・問題の意味読み違えてた。
　A*2枚のビスケットがあったら2円分換金していいと思ってた。
　どうりでビスケット増え過ぎると思った。
"""

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

K,A,B=MAP()

rate=B/A
rest=K-(A-1)
bis=A

bis+=(B-A)*(rest//2)+(rest%2)

print(max(bis, K+1))
### BUGGY CODE ###

n, k, q = map(int, input().split())
quiz = [int(input()) for i in range(q)]
point = [k]*n
for i in quiz:
  a = point[i-1]
  point = list(map(lambda x:x-1, point))
  point[i-1] = a
for j in point:
  if j > 0:
    print("Yes")
  else:
    print("No")


### FIXED CODE ###

n, k, q = map(int, input().split())
quiz = [int(input()) for i in range(q)]
point = [k-q]*n
for i in quiz:
  point[i-1] += 1
[print("Yes") if i > 0 else print("No") for i in point]
'''
1. あらかじめ全員のポイントを Q 減らしておく (つまり，開始時点のポイントは K − Q)．
2. Q 回の正解それぞれに対して，正解者のポイントを 1 増やす．

リストの中身すべてに計算すると「リスト要素」＊「ループ回数」の計算量になる
'''
### BUGGY CODE ###

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

# 暗証番号は 000-999 の最大1000種類

ans = 0
for i in range(1000):
    v = str(i).zfill(3)
    # print(v)
    n = 0
    f = [False] * N
    for j in range(len(S)):
        if v[n] == S[j]:
            n += 1
        if n >= 3:
            # print(v)
            ans += 1
            break

print(ans)


### FIXED CODE ###

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

# 暗証番号は 000-999 の最大1000種類

ans = 0
for i in range(1000):
    v = str(i).zfill(3)
    # print(v)
    n = 0
    f = [False] * N
    for j in range(len(S)):
        if v[n] == S[j]:
            n += 1
        if n >= 3:
            # print(v)
            ans += 1
            break

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

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

sum_ = 0
for i in range(N):
  for j in range(N):
    if (i == j) | (i<=j):
      continue
    if As[i] == As[j]:
      sum_ += 1
      
for i in range(N):
  print(sum_-As.count(As[i])+1)

### FIXED CODE ###

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

c = collections.Counter(As)

sum_ = 0
for key, val in c.items():
  sum_ += (val*(val-1)/2)

sum_ = int(sum_)

for i in range(N):
  print(sum_-(c[As[i]]-1))