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

# coding: utf-8
# Your code here!

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

l_max = len(A)
#print(l_max)
r = 0
count = l_max

for l in range(0, l_max):
    bitSums = A[l]
    Sums = A[l]
    for r in range(l+1, l_max):
        bitSums = bitSums ^ A[r]
        Sums = Sums + A[r]
        #print(Sums)
        if bitSums == Sums:
            count += 1

print(count)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ps=0
xs=0
c=0
j=0
for i in range(n):
  ps+=a[i]
  xs^=a[i]
  while ps!=xs:
    ps-=a[j]
    xs^=a[j]
    j+=1
  c+=i-j+1
print(c)
### BUGGY CODE ###


n = int(input())

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


total = 0
for i in range(n-1):
    for j in a[i+1:]:
        t = a[i]%(10**9+7)
        k = j%(10**9+7)
        total += (t*k)
        total = total%(10**9+7)

print(total)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
 
ans = 0
total = sum(A)
for i in range(N - 1):
    total -= A[i]
    ans += (A[i] * total) 
 
print(ans % mod)
### BUGGY CODE ###

n, k = map(int, input().split())
A = list( map(int, input().split()))
F = list( map(int, input().split())) 
A = sorted(A)
F = sorted(F, reverse = True)

def isok(ans):
    k_ = 0
    for a,f in zip(A,F):
        if a > ans//f:
            k_ += a - ans//f
            if k_ > k:
                return False
    return True

ok = max(A)*max(F)
ng = 0

while ok - ng >= 1:
    m = (ok+ng)//2
    if ok - ng == 1:
        if isok(ng):
            ok = ng
            break
        break
    if isok(m):
        ok = m
    else:
        ng = m
print(ok)



### FIXED CODE ###

n, k = map(int, input().split())
A = list( map(int, input().split()))
F = list( map(int, input().split())) 
A = sorted(A)
F = sorted(F, reverse = True)

def isok(ans):
    k_ = 0
    for a,f in zip(A,F):
        if a > ans//f:
            k_ += a - ans//f
            if k_ > k:
                return False
    return True

ok = max(A)*max(F)
ng = 0

while ok - ng >= 1:
    m = (ok+ng)//2
    if ok - ng == 1:
        if isok(ng):
            ok = ng
            break
        break
    if isok(m):
        ok = m
    else:
        ng = m
print(ok)
### BUGGY CODE ###

n = int(input())
p = list(map(int,input().split()))
c = 0
for i in range(n):
    q = p[0:i+1]
    if min(q) == p[i]:
        c += 1

print(c)

### FIXED CODE ###

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

tmp = (input().split(' '))
n = int(tmp[0])
k = int(tmp[1])
tmp = input().split(' ')
grades = []
for i in range(len(tmp)):
  grades.append(int(tmp[i]))
  
curr_res = grades[0]
prev_res = grades[0]

for i in range(1,k):
  curr_res = curr_res * grades[i]
  
j = k
while j < n:
  prev_res = curr_res
  curr_res = curr_res/grades[j-k]
  curr_res = curr_res*grades[j]
  if curr_res > prev_res:
    print('Yes')
  else:
    print('No')
  j+=1
  

### FIXED CODE ###

tmp = (input().split(' '))
n = int(tmp[0])
k = int(tmp[1])
tmp = input().split(' ')
map_tmp = map(int,tmp)
grades = list(map_tmp)
j = k
while j < n:
  curr_res = grades[j]
  prev_res = grades[j-k]
  if curr_res > prev_res:
    print('Yes')
  else:
    print('No')
  
  j+=1
### BUGGY CODE ###

S = str(input())
l = len(S)
mem = l
i = 0
while (i < l-1):
    j = 0
    if (S[i] != S[i + 1]):
        if (i == 0):
            S = S[i + 2:]
        else:
            S = S[:i] + S[i + 2:]
        i = 0
    else:
        i += 1
    l = len(S)

print(mem-len(S))

### FIXED CODE ###

S = []
ans = 0
for c in input():
    if len(S) > 0 and c != S[-1]:
        S.pop()
        ans += 2
    else:
        S.append(c)
print(ans)
### BUGGY CODE ###

n = int(input())
count = 0
for i in range(1,n+1):
        for j in range(1,n+1):
            if i % 10 == int(str(j)[0]) and j % 10 == int(str(i)[0]):
                count += 1

print(count)

### FIXED CODE ###

n = int(input())
count = 0
l = [[0]*10 for i in range(10)]
for i in range(1,n+1):
    l[int(str(i)[0])][int(str(i)[-1])] += 1
for i in range(1,10):
    for j in range(1,10):
        count += l[i][j]*l[j][i]
            

print(count)
### BUGGY CODE ###

import sys
from itertools import accumulate

def main():
  input = sys.stdin.readline
  N, C = map(int, input().split())
  X = []
  V = []
  for _ in range(N):
    x, v = map(int, input().split())
    X.append(x)
    V.append(v)
  Vr = V[::-1]
  Xr = X[::-1]
  
  
  R = list(accumulate(V))
  for i in range(N):
    R[i] = R[i] - X[i]

  L = list(accumulate(Vr))
  for i in range(N):
    L[i] = L[i] - (C - Xr[i])

  Rmax = max(R)
  Lmax = max(L)
  
  RLmax = 0
  for i in range(N-1):
    cur = R[i] + max(L[:-(i+1)]) - X[i]
    RLmax = max(RLmax, cur)
  
  LRmax = 0
  for i in range(N-1):
    cur = L[i] + max(R[:-(i+1)]) - (C - Xr[i])
    LRmax = max(LRmax, cur)
  
  ans = max(0, Rmax, Lmax, RLmax, LRmax)
  print(ans)


if __name__ == '__main__':
  main()

### FIXED CODE ###

import sys
from itertools import accumulate

def main():
  input = sys.stdin.readline
  N, C = map(int, input().split())
  X = []
  V = []
  for _ in range(N):
    x, v = map(int, input().split())
    X.append(x)
    V.append(v)
  Vr = V[::-1]
  Xr = X[::-1]

  F = list(accumulate(V))
  R = list(accumulate(Vr))
  F[0], R[0] = F[0] - X[0], R[0] - (C - Xr[0])
  for i in range(1, N):
    F[i] = max(F[i-1], F[i] - X[i])
    R[i] = max(R[i-1], R[i] - (C - Xr[i]))

  val = 0
  for i in range(N-1):
    v1 = F[i] + R[N-(i+2)] - X[i]
    v2 = R[i] + F[N-(i+2)] - (C - Xr[i])
    val = max(val, v1, v2)
  
  ans = max(0, val, max(F), max(R))
  print(ans)


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

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

import sys
from fractions import gcd

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 list4d(a, b, c, d, e): return [[[[e] * d for j in range(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(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)

N = INT()
A = LIST()

l = 1
for a in A:
    l = lcm(l, a)

B = [0] * N
for i, a in enumerate(A):
    B[i] = l // a

ans = 0
for b in B:
    ans += b
    ans %= MOD
print(ans)


### FIXED CODE ###

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

import sys
from fractions import gcd

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 list4d(a, b, c, d, e): return [[[[e] * d for j in range(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(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def lcm(x, y): return (x * y) // gcd(x, y)

N = INT()
A = LIST()

l = 1
for a in A:
    l = lcm(l, a)

ans = 0
for i, a in enumerate(A):
    ans += l // a
print(ans%MOD)
### BUGGY CODE ###

from collections import Counter

s = input()

rests = []
n = 0
a = 0
m = 1
for i in list(s)[::-1]:
    n = n + int(i)*m

    rests.append(n % 2019)
    m *= 10

c = Counter(rests)

for v in c.values():
    a += v * (v-1) // 2
 
a += c[0]
 
print(a)






### FIXED CODE ###

from collections import defaultdict

s = input()

rests = [0]
n = 0
a = 0
m = 1
c = defaultdict(int)
c[0] += 1
for i in list(s)[::-1]:
    n = n + int(i)*m

    c[n % 2019] += 1
    m = m * 10 % 2019

for v in c.values():
    a += v * (v-1) // 2
print(a)
### BUGGY CODE ###

from collections import Counter

N, P = map(int,input().split())
if N >= P:
    print(1)
    exit(0)
if N == 1:
    print(P)
    exit(0)
if N == 2:
    M = P
    Q = []
    k = 2
    while k*k <= M:
        if M%k == 0:
            M //= k
            Q.append(k)
        else:
            k += 1
    if M > 1:
        Q.append(M)
    R = Counter(Q)
    ans = 1
    for k in R:
        if R[k] >= 2:
            ans *= k**(R[k]//2)
    print(ans)
    exit(0)

ans = 1
k = 1
while k**N <= P:
    if P%(k**N)==0:
        ans = k
    k += 1

print(ans)

### FIXED CODE ###

from collections import Counter
import math

N, P = map(int,input().split())
if N >= 41:
    print(1)
    exit(0)
if N >= P:
    print(1)
    exit(0)
if N == 1:
    print(P)
    exit(0)
if N == 2:
    M = P
    Q = []
    k = 2
    while k*k <= M:
        if M%k == 0:
            M //= k
            Q.append(k)
        else:
            k += 1
    if M > 1:
        Q.append(M)
    R = Counter(Q)
    ans = 1
    for k in R:
        if R[k] >= 2:
            ans *= k**(R[k]//2)
    print(ans)
    exit(0)

ans = 1
k = 1
while pow(k,N) <= P:
    if P%pow(k,N)==0:
        ans = k
    k += 1

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

[N,L] = [int(x) for x in input().split()]
A = {}
B = [0]*N
ANS = {}
count = 0
for i,x in enumerate(input().split()):
    i = int(i)
    x = int(x)
    B[i] = x
    if x in A : A[x] += [i]
    else : A[x] = [i]
for i in sorted(A) :
    for j in A[i] :
        for k in range(L) :
            if j + k not in ANS :
                ANS[j+k] = i
                count += 1
    if count > N * 0.9997 : break
        
for i in range(L):
    if i not in ANS : ANS[i] = min(B[:i+1])
for i in range(L,N):
    if i not in ANS : ANS[i] = min(B[i+1-L:i+1])
for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N-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 ###

import math
def computeGCD(x, y): 
  
    if x > y: 
        small = y 
    else: 
        small = x 
    for i in range(1, small+1): 
        if((x % i == 0) and (y % i == 0)): 
            gcd = i 
              
    return gcd 
n=int(input())
a=list(map(int,input().split()))
ans=computeGCD(a[0],a[1])
for i in range(2,n):
  ans=computeGCD(ans,a[i])
print(ans)

### FIXED CODE ###

import math
def computeGCD(x, y): 
  
   while(y): 
       x, y = y, x % y 
  
   return x 
n=int(input())
a=list(map(int,input().split()))
ans=computeGCD(a[0],a[1])
for i in range(2,n):
  ans=computeGCD(ans,a[i])
print(ans)
### BUGGY CODE ###

s=input()
n=int(input())
t=True
a=str()
b=str()
for i in range(n):
    q=input().split()
    if(len(q)==1):
        t=not t
        a=a[::-1]
        b=b[::-1]
        continue
    if(int(q[1])==1):
        if(t):a=q[2]+a
        else:b=q[2]+b
    if(int(q[1])==2):
        if(t):b=b+q[2]
        else:a=a+q[2]
if(t):print(a+s+b)
else:print(b+s[::-1]+a)

### FIXED CODE ###

s=input()
n=int(input())
t=True
a=str()
b=str()
for i in range(n):
    q=input().split()
    if(len(q)==1):
        t=not t
        continue
    if(int(q[1])==1):
        if(t):a=q[2]+a
        else:b=b+q[2]
    if(int(q[1])==2):
        if(t):b=b+q[2]
        else:a=q[2]+a
if(t):print(a+s+b)
else:print(b[::-1]+s[::-1]+a[::-1])
### BUGGY CODE ###

N, M = map(int, input().split())
P = [input().split() for i in range(M)]

def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]
wa_sum = 0
ac_uq_list = []

ac_uq_list = get_unique_list([P[i] for i in range(M) if P[i][1] == "AC"])


for ac in ac_uq_list:
    c_list = [P[i] for i in range(len(P)) if P[i][0] == ac[0]]
    wa_sum += len(c_list[:c_list.index(ac)])

print(str(len(ac_uq_list)) + " " + str(wa_sum))   

### FIXED CODE ###

def resolve_c():
    n, m = map(int, input().split())
    ac_list = [0] * n
    wa_list = [0] * n
    wa_tmp_list = [0] * n
    for i in range(m):
        p, s = input().split()
        if ac_list[int(p)-1] == 0:
            if s == "AC":
                ac_list[int(p)-1] = 1
                wa_list[int(p)-1] = wa_tmp_list[int(p)-1]
            elif s == "WA":
                wa_tmp_list[int(p)-1] += 1
    print(str(sum(ac_list)) + " " + str(sum(wa_list)))
resolve_c()
### BUGGY CODE ###

#<134>
import sys
input = sys.stdin.readline
N = int(input())
A = []
for n in range(N):
    A.append(int(input()))
#print(A)
for n in range(N):
    x = A[n]
    A[n] = 0
    print(max(A))
    A[n] = x
    #print(A)

### FIXED CODE ###

N = int(input())
A = []
for n in range(N):
    A.append(int(input()))

B = sorted(A, reverse = True)
max1 = B[0]
max2 = B[1]
for a in A:
    print(max2 if a == max1 else max1)
### BUGGY CODE ###

import math
k=int(input())
ans= 0
for s in range(1,k+1):
    for t in range(1,k+1):
        for u in range(1,k+1):
            ans= ans + math.gcd(math.gcd(s,t),u)
print(ans)      

### FIXED CODE ###

import math
k=int(input())
ans= 0
for s in range(1,k+1):
    for t in range(1,k+1):
        if math.gcd(s,t) == 1:
            ans=ans+k
        else:
            for u in range(1,k+1):
                ans= ans + math.gcd(math.gcd(s,t),u)
print(ans)
### BUGGY CODE ###

n=int(input())
a=list(map(int, input().split()))
#print(a)
ans='YES'
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        elif a[i]==a[j]:
            ans = 'NO'
print(ans)


### FIXED CODE ###

n=int(input())
a=list(map(int, input().split()))
#print(a)
a.sort()
ans='YES'
prev=0
for i in range(n):
    if prev == a[i]:
        ans='NO'
        break
    else:
        prev = a[i]
print(ans)
### BUGGY CODE ###

N,K = map(int, input().split())
S = str(input())

## 連続するものをlistとして保持する
import re

def nchars(s,n):
    reg = re.compile("(.)\\1{%d,}" % (n-1))
    while True:
        m = reg.search(s)
        if not m:
            break
        yield m.group(0)
        s =s[m.end():]
        
candidates = list(nchars(S,1))
## いい具合にnumpyで操作
import numpy as np
count_0 = np.zeros((len(candidates)))
count_1 = np.zeros((len(candidates)))

for i,candidate in enumerate(candidates):
  if int(candidate[0]) == 0:
    count_0[i] += len(candidate)
  else:
    count_1[i] += len(candidate)
    
## 最小の試行回数
min_Try = len(np.where(count_0 != 0)[0])

change_ = np.where(count_0 != 0)[0]
## 最小の試行回数以下の時どうするかが厳しいな...
## 連続しないので、とりあえず大きい順に入れていけばオッケー
## 個数分だけ全部足して、indexで見たときに一番大きいやつが正解！！
if min_Try <= K :
  print(N)
else:
  count_ = count_0 + count_1
  #print(count_)
  change_list = []
  for k in range(min_Try-K+1):
    c__ = change_[k:k+K]
    s = max(0,c__[0]-1)
    e = min(len(candidates)-1,c__[-1]+1)
    #print(count_[s:e+1])
    change_list.append(np.sum(count_[s:e+1]))
  print(int(max(change_list)))

### FIXED CODE ###

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

S = S + 'E'   # 終端処理
ans = -1    # 答えの初期値（十分に小さい値）

# 立った人の連続の数
if (S[0] == '0'):
    stand = 1
else:
    stand = 0

L = 0
R = 0

# 尺取り法
while (R < N):
    # 右端を進めることが可能（立った人の連続の数がK以下）なら、右端を進める
    if (stand <= K):
        # 立った人の連続の数が増えるなら1足す
        if (S[R] == '1' and S[R + 1] == '0'):
            stand += 1
        # 答えの更新
        ans = max(ans, R - L + 1)
        R += 1
    # 進められない場合、左端と右端が同じなら両者を進める
    # 左端が右端を追い越さないための処理
    elif (L == R):
        L += 1
        R += 1
    # それ以外は左端のみを進める
    else:
        # 立った人の連続の数が減るなら1減らす
        if (S[L] == '0' and S[L + 1] == '1'):
            stand -= 1
        L += 1
        # 左端のみを進めた場合は答えを更新し得ない

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

from collections import deque
n,m=map(int,input().split())
a=[tuple(map(int,input().split())) for i in range(m)]

d=deque([(1,0)])
checked=[0]*n
checked[0]=1
ans=[0]*(n-1)
while len(d)>0:
    rm,dep=d.popleft()
    for i in a:
        if i[0]==rm or i[1]==rm:
            if checked[i[i.index(rm)-1]-1]==0:
                d.append((i[i.index(rm)-1],dep+1))
                checked[i[i.index(rm)-1]-1]=1
                ans[i[i.index(rm)-1]-2]=rm
print('Yes')
for i in ans:
    print(i)

### FIXED CODE ###

from collections import deque
n,m=map(int,input().split())
a=[tuple(map(int,input().split())) for i in range(m)]
pr=[[] for i in range(n)]
for i in a:
    pr[max(i)-1].append(min(i))
    pr[min(i)-1].append(max(i))
d=deque([1])
checked=[0]*n
checked[0]=1
ans=[0]*(n-1)
while len(d)>0:
    rm=d.popleft()
    for i in pr[rm-1]:
        if checked[i-1]==0:
            d.append(i)
            checked[i-1]=1
            ans[i-2]=rm
    #print(d)
print('Yes')
for i in ans:
    print(i)
### BUGGY CODE ###

s = input()
q = int(input())

inv = False
mae = ''
usiro = ''

for _ in range(q):
    tmp = list(input().split())
    if tmp == ['1']:
        inv = not inv

    elif tmp[1] == '1' and not inv:
        mae = mae + tmp[2]
    elif tmp[1] == '2' and not inv:
        usiro = usiro + tmp[2]
    elif tmp[1] == '1' and inv:
        usiro = usiro + tmp[2]
    elif tmp[1] == '2' and inv:
        mae = mae + tmp[2]

    # print(mae,s,usiro)

ans = mae[::-1] + s + usiro

if inv:
    ans = ans[::-1]

print(ans)

### FIXED CODE ###

s = input()
q = int(input())

inv = False
mae = ''
usiro = ''

for _ in range(q):
    tmp = input()
    if tmp[0] == '1':
        inv = not inv

    else:
        _,f,c = tmp.split()

        if f == '1' and not inv:
            mae += c
        elif f == '2' and not inv:
            usiro += c
        elif f == '1' and inv:
            usiro += c
        elif f == '2' and inv:
            mae += c

    # print(mae,s,usiro)

ans = mae[::-1] + s + usiro

if inv:
    ans = ans[::-1]

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

ks = input()
count = 0
k, s = [int(x) for x in ks.split(" ")]
for i in range(min(k + 1,s + 2)):
    for j in range(i + 1, s + 2):
        x = i
        y = j - i - 1
        z = s - y - x
        if x <= k and y <= k and z <= k:
            count += 1
print(count)

### FIXED CODE ###

ks = input()
k, s = [int(x) for x in ks.split(" ")]
comb = []
for x in range(min(k,s) + 1)[::-1]:
    for y in range(min(x + 1, s - x + 1))[::-1]:
        z = s - x - y
        if (x <= k and y <= k and z <= k and y <= x and z <= y):
            comb.append([x,y,z])
count = 0
for c in comb:
    l = len(set(c))
    if l == 1:
        count += 1
    elif l == 2:
        count += 3
    else:
        count += 6
print(count)
### BUGGY CODE ###

from bisect import bisect_right
from collections import defaultdict

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

for i, j in enumerate(A):
    dd[j].append(i)

conv = [0] * (N+1)
for i, j in enumerate(A):
    pos = i

    while pos < N:
        v = A[pos]
        p = bisect_right(dd[v], pos)
        size = len(dd[v])
        if p < size:
            pos = dd[v][p]+1
            if pos == N:
                conv[i] = 0
                break
        else:
            conv[i] = dd[A[pos]][0] + 1
            break
conv[N] = 0

dp = [[0]*(N+1) for _ in range(60)]
for i in range(N+1):
    dp[0][i] = conv[i]

for k in range(1, 60):
    for n in range(N+1):
        dp[k][n] = dp[k - 1][dp[k - 1][n]]

res = []
t = K-1
for i in range(60):
    if (t>>i)&1:
        res.append(i)
    
pos = 0
for i in res:
    pos = dp[i][pos]

ans = []
while pos < N:
    num = A[pos]
    pp = bisect_right(dd[num], pos)
    if pp < len(dd[num]):
        pos = dd[num][pp]+1
    else:
        ans.append(num)
        pos += 1
print(*ans)

### FIXED CODE ###

from collections import defaultdict, Counter
from bisect import bisect_right, bisect_left

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

c = Counter(A)
target = []
d = defaultdict(list)

dd = defaultdict(list)
for i, j in enumerate(A):
    dd[j].append(i)

pos = 0
loop = 1
l = []

while pos < N:
    num = A[pos]
    
    pp = bisect_right(dd[num], pos)
    if pp < len(dd[num]):
        pos = dd[num][pp]+1
    else:
        pos = dd[num][0]+1            
        loop += 1
    l.append((num, pos, loop))

for v, pos, p in l:
    if (K-p)%loop==0:
        break

pos = pos if pos<N else 0
ans = []
while pos < N:
    num = A[pos]
    pp = bisect_right(dd[num], pos)
    if pp < len(dd[num]):
        pos = dd[num][pp]+1
    else:
        ans.append(num)
        pos += 1
print(*ans)
### BUGGY CODE ###

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

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        a = L[i]
        b = L[j]
        if b >= L[-1] + a:
            break
        for k in range(j + 1, N):
            c = L[k]
            if c >= a + b:
                break
            ans += 1
print(ans)


### FIXED CODE ###

from bisect import bisect_left

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

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        a = L[i]
        b = L[j]
        idx = bisect_left(L, a + b)
        ans += idx - 1 - j
print(ans)
### BUGGY CODE ###

A,B,C,K = map(int,input().split())
for a in range(A):
    if a == K:
        print(a)
        
for b in range(B):
    if A+b == K:
        print(A)
        
for c in range(C):
    if A+B+c == K:
        print(A-c)

### FIXED CODE ###

A,B,C,K = map(int,input().split())
if A >= K:
    print(K)
elif A+B >= K:
    print(A)
else:
    print(2*A+B-K)
### BUGGY CODE ###

import copy
 
H, W = map(int, input().split())
A = [[0 for i in range(W)]for j in range(H)]
white_num = 0
for i in range(H):
    S = input()
    for j in range(W):
        A[i][j] = S[j]
        if A[i][j] == '.':
            white_num += 1
 
ans = 0
while white_num > 0:
    A_ = copy.deepcopy(A)
    ans += 1
    for y in range(H):
        for x in range(W):
            if A[y][x] == ".":
                continue
            if A[y][x] == "#":
                for k in range(4):
                    nx = x + [1, 0, -1, 0][k]
                    ny = y + [0, 1, 0, -1][k]
                    if nx < 0 or ny < 0 or nx >= W or ny >= W:
                        continue
                    if A[ny][nx] == "#":
                        continue
                    if A[ny][nx] == "." and A_[ny][nx] == ".":
                        A_[ny][nx] = "#"
                        white_num -= 1
    A = A_
print(ans)

### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
que = deque()
A = [[0 for i in range(W)] for j in range(H)]
white_num = 0
for i in range(H):
    S = input()
    for j in range(W):
        if S[j] == '.':
            A[i][j] = -1
            white_num += 1
        elif S[j] == '#':
            A[i][j] = 0
            que.append([j, i])

ans = 0
while len(que) > 0:
    x, y = que.popleft()
    for k in range(4):
        nx = x + [1, 0, -1, 0][k]
        ny = y + [0, 1, 0, -1][k]
        if nx < 0 or ny < 0 or nx >= W or ny >= H:
            continue
        if A[ny][nx] == -1:
            que.append([nx, ny])
            A[ny][nx] = A[y][x] + 1
            ans = max(ans, A[ny][nx])
print(ans)
### BUGGY CODE ###

def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n,k=n1()
p=n1()
e=[(1+x)/2 for x in p]
ans=0
for i in range(n-k+1):
    ans=max(ans,sum(e[i:i+k]))
print(ans)

### FIXED CODE ###

def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n,k=n1()
p=n1()

e=[(1+x)/2 for x in p]

ans=sum(e[0:k])
tmp=ans
for i in range(k,n):
    tmp=tmp+e[i]-e[i-k]
    ans=max(tmp,ans)
print(ans)