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

n=int(input())
L_lst=sorted(list(map(int,input().split())))
i=n-2
j=n-1
cnt=0
while j>1:
    for x in range(i-1,-1,-1):
        if x==0:#0だとout of range
            if abs(L_lst[i]-L_lst[j])<L_lst[x]<L_lst[i]+L_lst[j]:
                cnt+=1
        else:
            if L_lst[x]!=L_lst[x-1]:
                if abs(L_lst[i]-L_lst[j])<L_lst[x]<=L_lst[i]+L_lst[j]:
                    cnt+=1
    i-=1
    if i==0:
        j-=1
        i=j-1
print(cnt)

### FIXED CODE ###

n=int(input())
L_lst=sorted(list(map(int,input().split())))
cnt=0
for j in range(n-1,1,-1):
    i=j-1
    x=0
    while x<i:
        if L_lst[i]+L_lst[x]>L_lst[j]:
            cnt+=i-x
            i-=1
        else:
            x+=1
print(cnt)
### BUGGY CODE ###

def main():
    S = input()
    cnt = 0
   
    if len(set(S)) == 1 :
        print(0)
    else:
        l_past  = None
        l_new = None
        block = list(S)

        for i in range(10**5):
            block = [ a for a in block if a != "-"]
            l_new = len(block)

            if l_past == l_new :
                break

            for i in range(len(block) - 1):
                if (block[i] == "0" and block[i+1] == "1") or (block[i] == "1" and block[i+1] == "0"):
                    cnt += 2
                    block[i] = "-"
                    block[i+1] = "-"

            l_past = l_new

        print(cnt)

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    S = input()
    print(2*min(S.count("0"), S.count("1")))
if __name__ == "__main__":
    main()
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)
 
 
def solve(c, idx, N, S, ans):
    if len(c)==3:
        ans.append(c)
        return
    if idx >= len(S):
        return
    solve(c+S[idx], idx+1, N, S, ans)
    solve(c, idx+1, N, S, ans)
 
if __name__ == "__main__":
    N = int(input())
    S = input()
    ans = []
    solve("", 0, N, S, ans)
    print(len(set(ans)))

### FIXED CODE ###

N = int(input())
S = input()
ans = 0
for i in range(1000):
    cnt = 0
    n = str(i).zfill(3)
    for c in S:
        if c == n[cnt]:
            cnt += 1

        if cnt == 3:
            ans += 1
            break

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

###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

# 拡張ユークリッド互除法
# ax + by = gcd(a,b)の最小整数解を返す
def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)

# mを法とするaの乗法的逆元
def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

N, A, B, C = mi()

MOD = 10**9+7
a = A * modinv(A+B, MOD)
b = B * modinv(A+B, MOD)
gyakugenofAB = 100 * modinv(A+B, MOD)

# 累乗を返す sは'a'or'b'(文字列)
#[0]行にはaの階乗を、[1]行にはbの階乗を入れる
powlist = [[-1 for _ in range(N+1)] for _ in range(2)]
def calcpow(i, num, r):
  tmp = powlist[i][r]
  if tmp == -1:
    tmp = (num**r)
    powlist[i][r] = tmp
    return tmp
  else:
    return tmp


#cmb(m)でmCn-1を計算
import math
Nmin1fct = math.factorial(N-1)
def cmb(k):
  ans = 1
  for i in range(max(1,k-1),k-N,-1):
    ans = (ans * i) % MOD
  ans = round(ans / Nmin1fct)
  return ans
#cmbの計算終わり

#期待値（確率×回数）を足し上げていく。
#N回目～2N-1回目についてループを回す
#m-1Cn-1なことに注意
e = 0
cnt = 0
for m in range(N, 2*N):
#  cnt += 1
#  if cnt % 1000 == 0: print(cnt)
  e += (m * gyakugenofAB * (cmb(m) % MOD) * (((calcpow(0,a,N) % MOD) * (calcpow(1,b,m-N) % MOD)) + ((calcpow(0,a,m-N) % MOD) * (calcpow(1,b,N) % MOD)))) % MOD
  e %= MOD

print(e)


### FIXED CODE ###

###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###
import time

# 拡張ユークリッド互除法
# ax + by = gcd(a,b)の最小整数解を返す
def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)

# mを法とするaの乗法的逆元
def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

N, A, B, C = mi()

MOD = 10**9+7
a = (A * modinv(A+B, MOD)) % MOD
b = (B * modinv(A+B, MOD)) % MOD
gyakugenofAB = (100 * modinv(A+B, MOD)) % MOD

# 累乗を返すリスト
#[0]行にはaの階乗を、[1]行にはbの階乗を入れる
powlist = [[-1] * (N+1) for _ in range(2)]
preA = 1
preB = 1
powlist[0][0] = 1
powlist[1][0] = 1
for i in range(1,N+1):
  preA = (preA * a) % MOD
  preB = (preB * b) % MOD
  powlist[0][i] = preA
  powlist[1][i] = preB


#cmb(m)でmCn-1を計算
import math
Nmin1fct = modinv(math.factorial(N-1),MOD) % MOD

#一度でも計算したらflagがオン
flag = 0
preans = 1
def cmb(k):
  global flag
  global preans
  ans = 1
  if flag == 0:
    flag = 1
    for i in range(max(1,k-1),k-N,-1):
      ans = (ans * i) % MOD
    preans = (ans * Nmin1fct) % MOD
    return preans
  else:
    preans = (preans * (k-1) * modinv(max(1, k-N),MOD)) % MOD
  return preans
#cmbの計算終わり


#期待値（確率×回数）を足し上げていく。
#N回目～2N-1回目についてループを回す
#m-1Cn-1なことに注意
e = 0
cnt = 0
for m in range(N, 2*N):
#  cnt += 1
#  if cnt % 1000 == 0: print(cnt)
#  start_time = time.perf_counter()
  e += (m * gyakugenofAB * (cmb(m) % MOD) * ((powlist[0][N] * powlist[1][m-N]) + (powlist[0][m-N] * powlist[1][N])))
  e %= MOD
#  print(time.perf_counter() - start_time)


print(e)
### BUGGY CODE ###

K = int(input())
import fractions
import itertools
A = list(itertools.product(range(1,K+1),repeat=3))
ans = 0
for i in A:
    num = i[0]
    for j in range(1,3):
        num = fractions.gcd(num,i[j])
    ans += num
print(ans)

### FIXED CODE ###

K = int(input())
import math
from functools import reduce


def gcd (*numbers):
  return reduce(math.gcd,numbers)

ans = 0
for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      ans += gcd(a,b,c)

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

# AGC033A - Darker and Darker
def bfs() -> None:
    dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
    cur, q = 0, []
    for x, b in enumerate(B):
        for y, i in enumerate(b):
            if i != cur:
                continue
            for dx, dy in dxy:
                nx, ny = x + dx, y + dy
                if 0 <= nx < H and 0 <= ny < W and B[nx][ny] == -1:
                    B[nx][ny] = cur + 1
                    q.append((nx, ny))
    while q:
        cur += 1
        next_q = []
        for x, y in q:
            for dx, dy in dxy:
                nx, ny = x + dx, y + dy
                if 0 <= nx < H and 0 <= ny < W and B[nx][ny] == -1:
                    B[nx][ny] = cur + 1
                    next_q.append((nx, ny))
        q = next_q
    return cur


def main():
    global H, W, B
    H, W, *A = open(0).read().split()
    H, W = int(H), int(W)
    B = [[0 if i == "#" else -1 for i in a] for a in A]
    dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
    ans = bfs()
    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

# AGC033A - Darker and Darker
from scipy.ndimage import distance_transform_cdt as dist


def main():
    """
    distance_transform_cdt(matric="taxicab"):
        0 0 0    1 1 1
        0 1 0 -> 1 0 1
        0 0 0    1 1 1
    """
    h, w = tuple(map(int, input().rstrip().split()))
    A = list(list(input()) for _ in range(h))
    B = [[1 if i == "." else 0 for i in a] for a in A]
    D = dist(B, metric="taxicab")
    print(D.max())


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

import heapq
def SME():
    A = [[x,i] for i,x in enumerate(Whole)]
    heapq.heapify(A)
    C = set([i for i in range(N)])
    D = set([])
    if N == 10 ** 5 :
        parameter = 0.997
    else :
        parameter = 0.99
    count = 0
    ANS = [None] * N
    for j in range(N) :
        a = heapq.heappop(A)
        for i,x in enumerate(ANS[a[1]:a[1]+L]):
            if x : continue
            else :
                ANS[a[1]+i] = a[0]
                D.add(a[1]+i)
                count += 1
        if count > N * parameter : break
    for i in C.difference(D):
        if i < L : ANS[i] = min(Whole[:i+1])
        else : ANS[i] = min(Whole[i+1-L:i+1])
    return ANS

[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
ANS = SME()
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

A, B, N = map(int, input().split())
ans = 0
for x in range(1, N+1):
    now = (A*(x%B) - (A*x)%B)/B
    ans = max(now, ans)
print(int(ans))

### FIXED CODE ###

A, B, N = map(int, input().split())
x = min(B-1, N)

ans = int(A*x/B) - A*int(x/B)
print(ans)
### BUGGY CODE ###

S = input()

# S = 'erasedream'

words = ['dream', 'dreamer', 'erase', 'eraser']

flag = False
while True:
    for word in words:
        # word=words[0]
        length = len(word)
        if S[-length:] == word:
            S = S[:len(S)-length]
            flag = True
            break
    if flag:
        if S == '':
            print('YES')
            break
        else:
            continue
    else:
        print('NO')
        break


### FIXED CODE ###

S = input()

# S = 'dreameraser'

words = ['dream', 'dreamer', 'erase', 'eraser']

while True:
    flag = False

    for word in words:
        # word=words[3]
        length = len(word)
        if S[-length:] == word:
            S = S[:len(S) - length]
            flag = True
            break

    if flag:
        if S == '':
            print('YES')
            break
        else:
            continue
    else:
        print('NO')
        break
### BUGGY CODE ###

A, B, M = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))

xyc_list = []
for i in range(M):
    xyc_list.append(list(map(int, input().split())))

total_list = []
for x,y,c in xyc_list:
    if a_list[x-1] in a_list and b_list[y-1] in b_list:
        total = a_list[x-1] + b_list[y-1] - c
        total_list.append(total)

nonChicket = min(a_list) + min(b_list)

if min(total_list) < nonChicket:
    print(min(total_list))
else:
    print(nonChicket)

### FIXED CODE ###

A, B, M = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))

xyc_list = []
for i in range(M):
    xyc_list.append(list(map(int, input().split())))

total_min = min(a_list) + min(b_list)
for x,y,c in xyc_list:
    total = a_list[x-1] + b_list[y-1] - c
    if total_min > total:
        total_min = total

print(total_min)
### BUGGY CODE ###

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

import bisect
L.sort()
ans=0
i=0
while i<N-2:
    j=i+1
    while j<N-1:
        x=bisect.bisect_left(L[j+1:],L[i]+L[j])
        ans+=x
        j+=1
    i+=1
print(ans)




### FIXED CODE ###

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

L.sort()
ans=0
i=0
while i<N-2:
    j=i+1
    k=j+1
    while j<N-1:
        while k<N:
            if L[i]+L[j]<=L[k]:
                ans+=k-j-1
                break
            k+=1
        if k==N:
            ans+=k-1-j
        j+=1
    i+=1
print(ans)
### BUGGY CODE ###

import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]


def main():
    n, m, q = na()
    lrs = [na() for _ in range(m)]
    pqs = [na() for _ in range(q)]

    map = {}
    for l, r in lrs:
        x = r - l
        if l in map:
            if x in map[l]:
                map[l][x] += 1
            else:
                map[l][x] = 1
        else:
            map[l] = {}
            map[l][x] = 1

    for p, q in pqs:
        cnt = 0
        for l in range(p, q+1):
            if l in map:
                for x in range(q-l+1):
                    if x in map[l]:
                        cnt += map[l][x]

        print(cnt)
                

main()


### FIXED CODE ###

import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]


def main():
    n, m, q = na()
    lrs = [na() for _ in range(m)]
    pqs = [na() for _ in range(q)]

    table = [[0] * (n+1) for _ in range(n+1)]

    # 
    for l, r in lrs:
        table[l][r] += 1

    # 行方向の累積和
    for i in range(1, n+1):
        for j in range(1, n+1):
            table[i][j] += table[i][j-1]

    # 列方向の累積和
    for j in range(1, n+1):
        for i in range(1, n+1):
            table[i][j] += table[i-1][j]
            
    for p, q in pqs:
        v = table[q][q] - table[q][p-1] - table[p-1][q] + table[p-1][p-1]
        print(v)
    

main()
### BUGGY CODE ###

r=range(128)
def f():v=min(i for i in r if D[i]);D[v]-=1;D[127-v]+=1;D[127]+=1
for i in[0]*input():n,d=map(int,raw_input().split());D=[0]*128;D[d]=1;exec("f();"*~-n);print sum(i*D[i]for i in r)

### FIXED CODE ###

for i in[0]*input():n,d=map(int,raw_input().split());print~-n*127+(127*(n+1&1)^d)
### BUGGY CODE ###

n = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

if len(prime_factorize(n)) == 1:
  print(n - 1)
  exit()

ret = None
min_r = n
for x in range(1, int( n / 2)):
  q, mod = divmod(n, x)
  _min_r = (2 * x - 2) + (q - x)
  if mod == 0 and min_r > _min_r:
    min_r = _min_r
    ret = (x, q)

print(min_r)

### FIXED CODE ###

n = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

if len(prime_factorize(n)) == 1:
  print(n - 1)
  exit()

ret = None
min_r = n
for x in range(2, int( n / 2)):
  q, mod = divmod(n, x)
  _min_r = (2 * x - 2) + (q - x)
  if mod == 0 and min_r > _min_r:
    min_r = _min_r
    ret = (x, q)
  
  if x > q:
    break

print(min_r)
### BUGGY CODE ###

n = int(input())
t = input()
s = [0]*n
for i in range(n):
  if t[i] == 'D':
    s[i] = 1
  elif t[i] == 'M':
    s[i] = 2
  elif t[i] == 'C':
    s[i] = 3
_ = input()
l = list(map(int, input().split()))
for k in l:
  d,m,dm,dmc = 0,0,0,0
  for i in range(n):
    if i > k-1:
      j = i-k
      if s[j] == 1:
        d -= 1
        dm -= m
      elif s[j] == 2:
        m -= 1
    if s[i] == 1:
      d += 1
    elif s[i] == 2:
      m += 1
      dm += d
    elif s[i] == 3:
      dmc += dm
  print(dmc)

### FIXED CODE ###

def num(s,n,k):
  d,m,dm,dmc = 0,0,0,0
  for i in range(n,n*2):
    x,y = s[i],s[i-k]
    if y == 68:
      d -= 1
      dm -= m
    elif y == 77:
      m -= 1
    if x == 68:
      d += 1
    elif x == 77:
      m += 1
      dm += d
    elif x == 67:
      dmc += dm
  return dmc

def main():
  n = int(input())
  s = [0]*n + list(map(ord, list(input())))
  _ = input()
  l = list(map(int, input().split()))
  for k in l:
    print(num(s,n,k))

main()
### BUGGY CODE ###

import math

def f_gcd(a, b):
    return math.gcd(a, b)

k = int(input())

ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans += f_gcd(math.gcd(a, b), c)

print(ans)

### FIXED CODE ###

import math

def f_gcd(a, b):
    return math.gcd(a, b)

k = int(input())

ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans += f_gcd(math.gcd(a, b), c)

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

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

for n in range(N):
    print(A.count(n+1))

### FIXED CODE ###

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

#for n in range(N):
#    print(A.count(n+1))

M = {}
for a in A:
    M[a] = M.get(a,0) + 1

for n in range(N):
    print(M.get(n+1,0))
### BUGGY CODE ###

S=input()
Q=int(input())
lst=[]
for _ in range(Q):
    lst.append(input().split())

#print(S, Q, lst)

str=list(S)

right=True
for operation in lst:
    if operation[0]=='1':
       right=not right

    else:
        if right==True and operation[1]=='1' or right==False and operation[1]=='2':
            str=[operation[2]]+str
        else:
            str=str+[operation[2]]

if right==True:
    print(''.join(str))
else:
    print(''.join(str[::-1]))

### FIXED CODE ###

S=input()
Q=int(input())
lst=[]
for _ in range(Q):
    lst.append(input().split())

import collections

str=list(S)
d=collections.deque(str)

right=True
for operation in lst:
    if operation[0]=='1':
       right=not right

    else:
        if right==True and operation[1]=='1' or right==False and operation[1]=='2':
            d.appendleft(operation[2])
        else:
            d.append(operation[2])
str=list(d)
if right==True:
    print(''.join(str))
else:
    print(''.join(str[::-1]))
### BUGGY CODE ###



a,b,m = [int(x) for x in input().split()]
an = [(int(x),i+1) for i,x in enumerate(input().split())]
bn = [(int(x),i+1) for i,x in enumerate(input().split())]

an = sorted(an)
bn = sorted(bn)

discounts = {}
discount_list = []
for i in range(m):
    x,y,c = [int(x) for x in input().split()]
    if (x,y) in discounts and discounts[(x,y)] > c:
        continue
    discounts[(x,y)] = c
    discount_list.append(c)

discount_list = sorted(discount_list,reverse=True)

i = 0
j = 0
min = an[0][0]+bn[0][0]
max_discount = max(discount_list)
len_an = len(an)
len_bn = len(bn)

# print(an)
# print(bn)
# print(min)
# print(discounts)

for ai in an:
    for bj in bn:
        a_index = ai[1]
        b_index = bj[1]
        discount = 0
        if (a_index, b_index) in discounts:
            discount = discounts[(a_index, b_index)]
        total = ai[0] + bj[0] - discount
        if min > total:
            min = total

        if ai[0] + bj[0] - max_discount > min:
            break



# while True:
#     a_index = an[i][1]
#     b_index = bn[j][1]
#     discount = 0
#     if (a_index, b_index) in discounts:
#         discount = discounts[(a_index, b_index)]
#     total = an[i][0] + bn[j][0] - discount
#     if min > total:
#         min = total
#
#     if an[i][0] + bn[j][0] - max_discount > min:
#         break
#     elif i == len_an-1 and j == len_bn-1:
#         break
#     elif i == len_an-1:
#         j += 1
#     elif j == len_bn-1:
#         i += 1
#     else:
#         a_diff = an[i+1][0] - an[i][0]
#         b_diff = bn[j+1][0] - an[j][0]
#         if a_diff < b_diff:
#             i += 1
#         else:
#             j += 1

print(min)





### FIXED CODE ###



a,b,m = [int(x) for x in input().split()]
an = [int(x) for x in input().split()]
bn = [int(x) for x in input().split()]

ans = min(an)+min(bn)
for i in range(m):
    p, q, discount = [int(x) for x in input().split()]
    a_cost = an[p-1]
    b_cost = bn[q-1]
    total = a_cost + b_cost - discount
    ans = min(total, ans)

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

S = list(input())
while len(S) > 0:
    if ''.join(S[-5:]) == 'dream' or ''.join(S[-5:]) == 'erase':
        S = S[:-5]
    elif ''.join(S[-6:]) == 'eraser':
        S = S[:-6]
    elif ''.join(S[-7:]) == 'dreamer':
        S = S[-7:]
    else:
        print('NO')
        quit()
print('YES')

### FIXED CODE ###

S = list(input())
while len(S) > 0:
    if ''.join(S[-5:]) == 'dream' or ''.join(S[-5:]) == 'erase':
        S = S[:-5]
    elif ''.join(S[-6:]) == 'eraser':
        S = S[:-6]
    elif ''.join(S[-7:]) == 'dreamer':
        S = S[:-7]
    else:
        print('NO')
        quit()
print('YES')
### BUGGY CODE ###

n, k = map(int, input().split())
a = [int(x)-1 for x in input().split()]

inds = [[] for _ in range(max(a)+1)]
y = [0]*n

for i in range(n):
    if inds[a[i]]:
        y[inds[a[i]][-1]] = i+1 - inds[a[i]][-1]
    inds[a[i]].append(i)

for j in range(max(a)+1):
    if inds[j]:
        y[inds[j][-1]] = n+inds[j][0]+1 - inds[j][-1]

length = (n*k).bit_length()

db = [y]
for m in range(length):
    next_y = [0]*n
    for i in range(n):
        next_y[i] = db[-1][i] + db[-1][(i+db[-1][i]) % n]
    db.append(next_y)

cur = 0
i = length

while cur < n*k:
    while i > -1 and cur + db[i][cur % n] > n*k:
        i -= 1
    if i == -1:
        break
    cur = cur + db[i][cur % n]

ans = []
while cur < n*k:
    if cur + db[0][cur % n] > n*k:
        ans.append(cur)
        cur += 1
    elif cur + db[0][cur % n] == n*k:
        break
    else:
        cur = cur + db[0][cur % n]

print(*map(lambda x: a[x % n]+1, ans))


### FIXED CODE ###

from bisect import bisect_right
n, k = map(int, input().split())
a = [int(x) for x in input().split()]

d = {}
for i in range(n):
    if a[i] in d:
        d[a[i]].append(i)
    else:
        d[a[i]] = [i]


def simulate(k):
    if k == 0:
        return 0, []
    lap = 1
    res = [0]
    while True:
        s = res.pop()
        nxt = d[a[s]][bisect_right(d[a[s]], s) % len(d[a[s]])] + 1
        if nxt == n:
            if lap == k and s == n-1:
                res.append(s)
            if s == n-1:
                lap += 1
            return lap, res
        elif nxt <= s+1:
            if lap == k:
                res.append(s)
                if s == n-1:
                    return lap, res
                res.append(s+1)
                if s+1 == n-1:
                    return lap, res
            else:
                res.append(nxt)
                lap += 1
        else:  # s+1 < nxt
            s = nxt
            res.append(s)
    return 0


period, ans = simulate(k)

if period != k:
    lap, ans = simulate(k % period)

print(*[a[x] for x in ans])