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

from collections import Counter

def main(H, W, M, obj_h, obj_w, obj):
    c_h = Counter(obj_h)
    c_w = Counter(obj_w)
    max_h = max(c_h.values())
    max_w = max(c_w.values())
    lst_h = [kv[0] for kv in c_h.items() if kv[1] == max_h]
    lst_w = [kv[0] for kv in c_w.items() if kv[1] == max_w]
    for h in lst_h:
        for w in lst_w:
            if [h, w] not in obj:
                print(max_h + max_w)
                exit()
    else:
        print(max_h + max_w - 1)



if __name__ == '__main__':
    H, W, M = list(map(int, input().split()))
    obj = []
    obj_h = []
    obj_w = []
    for _ in range(M):
        i = list(map(int, input().split()))
        obj.append(i)
        obj_h.append(i[0])
        obj_w.append(i[1])
    main(H, W, M, obj_h, obj_w, obj)

### FIXED CODE ###

from collections import Counter

def main(H, W, M, obj_h, obj_w, obj):
    c_h = Counter(obj_h)
    c_w = Counter(obj_w)
    max_h = max(c_h.values())
    max_w = max(c_w.values())
    lst_h = [kv[0] for kv in c_h.items() if kv[1] == max_h]
    lst_w = [kv[0] for kv in c_w.items() if kv[1] == max_w]
    for h in lst_h:
        for w in lst_w:
            if (h, w) not in obj:
                print(max_h + max_w)
                exit()
    else:
        print(max_h + max_w - 1)



if __name__ == '__main__':
    H, W, M = list(map(int, input().split()))
    obj = set()
    obj_h = []
    obj_w = []
    for _ in range(M):
        i = list(map(int, input().split()))
        obj.add(tuple(i))
        obj_h.append(i[0])
        obj_w.append(i[1])
    main(H, W, M, obj_h, obj_w, obj)
### BUGGY CODE ###

from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

n,m,k = map(int,stdin.readline().rstrip().split())
mod = 998244353
wariate = 1
point = 0

def combination(n,r,mod=mod):
    r=min(r,n-r)
    up,down=1,1
    for i in range(r):
        up=up*(n-i)%mod
        down=down*(i+1)%mod
    return up*pow(down,mod-2,mod)%mod

for i in range(n-1,-1,-1):
    now = m
    if i != n-1:
        wariate *= m-1
        wariate %= mod
    if i <= k:
        now *= combination(n-1,i)%mod
        now *= wariate%mod
        point += now

print(point%mod)

### FIXED CODE ###

from sys import stdin
from sys import setrecursionlimit

setrecursionlimit(10 ** 7)

n,m,k = map(int,stdin.readline().rstrip().split())
mod = 998244353
wariate = 1
point = 0

def prepare(n, MOD=mod):
    facts = [1]*(n+1)
    for i in range(1, n+1):
        facts[i] = facts[i-1]*i%MOD
    invs = [1]*(n+1)
    invs[n] = pow(facts[n], MOD-2, MOD)
    for i in range(0, n)[::-1]:
        invs[i] = invs[i+1] * (i+1) % MOD
    return facts, invs
facts, invs = prepare(n, mod)
for i in range(n-1,-1,-1):
    now = m
    if i != n-1:
        wariate *= m-1
        wariate %= mod
    now *= wariate%mod

    now *= facts[n-1]*invs[n-1-i]*invs[i]
    if i <= k:
        point += now%mod

print(point%mod)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.buffer.readline
class SkewHeap:
  def __init__(self, init_val = None, left = None, right = None):
    self.val = init_val
    self.left = left
    self.right = right
    self.root = None
  def heapmeld(self, h1, h2):
    if h1 == None: return h2
    if h2 == None: return h1
    if h1.val > h2.val:
      h1.val, h1.left, h1.right, h2.val, h2.left, h2.right = h2.val, h2.left, h2.right, h1.val, h1.left, h1.right
    h1.right = self.heapmeld(h2, h1.right)
    return h1
  def heappop(self):
    if self.root == None:
      res = self.val
      h = self.heapmeld(self.left, self.right)
      if h == None: h = SkewHeap(None)
      self.val, self.left, self.right = h.val, h.left, h.right
      return res
    res = self.root.val
    self.root = self.heapmeld(self.root.left, self.root.right)
    return res
  def heappush(self, x):
    h = SkewHeap(x)
    self.root = self.heapmeld(self.root, h)
N, M = map(int, input().split())
a = list(map(int, input().split()))
h = SkewHeap()
res = 0
for e in a:
  h.heappush(-e)
for _ in range(M):
  h.heappush(-(-h.heappop() // 2))
for _ in range(N):
  res -= h.heappop()
print(res)

### FIXED CODE ###

import heapq
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = [-a for a in A]
heapq.heapify(A)
for _ in range(M):
  p = heapq.heappop(A)
  p = -p
  p //= 2
  p = -p
  heapq.heappush(A, p)
print(-sum(A))
### BUGGY CODE ###

x=int(input())
for i in range(-1000,1000):
    a=i
    for j in range(-1000,1000):
        b=j
        if a**5-b**5==x:
            am=a
            bm=b
        else:
            c=0
print(am,bm)

### FIXED CODE ###

x=int(input())
for i in range(200):
    a=i
    for j in range(-200,i):
        b=j
        if a**5-b**5==x:
            am=a
            bm=b
        else:
            c=0
print(am,bm)
### BUGGY CODE ###

import sys
import math
import heapq
from collections import defaultdict, deque
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

'''C Tsundoku'''
def count(i,n,j,m,a,b,k):
    if k<0:
        return 0
    if i==n:
        if j==m:
            return 0
        if b[j]<=k:
            return 1+count(i,n,j+1,m,a,b,k-b[j])
        return 0
    elif j==m:
        if i==n:
            return 0
        if a[i]<=k:
            return 1+count(i+1,n,j,m,a,b,k-a[i])
        return 0
    else:
        if a[i]>k and b[j]>k:
            return 0
        if a[i]>k:
            return 1+count(i,n,j+1,m,a,b,k-b[j])
        if b[j]>k:
            return 1+count(i+1,n,j,m,a,b,k-a[i])
        return max(1+count(i,n,j+1,m,a,b,k-b[j]),1+count(i+1,n,j,m,a,b,k-a[i]))

n,m,k=rm()
a=rl()
b=rl()
i=0;j=0;
print(count(i,n,j,m,a,b,k))

### FIXED CODE ###

import sys
import math
import heapq
from collections import defaultdict, deque
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

'''C Tsundoku'''
n,m,k=rm()
a=rl()
b=rl()
c=[0]*(n+1)
d=[0]*(m+1)
for i in range(n):
    c[i+1]=c[i]+a[i]
for i in range(m):
    d[i+1]=d[i]+b[i]
ans=0;j=m
for i in range(n+1):
    if c[i]>k:
        break
    while c[i]+d[j]>k:
        j-=1
    ans=max(ans,i+j)
print(ans)
### BUGGY CODE ###

from collections import defaultdict

N, M = [int(x) for x in input().split()]
a = []

for _ in range(M):
    a.append(int(input()))

MOD = 1000000007

dict = defaultdict(int)

for i in range(M):
    if i >= 1 and a[i] - a[i - 1] == 1:
        print("0")
        exit()

dict[0] = 1
for i in range(N):
    if not i in a:
        dict[i + 1] += dict[i]
        dict[i + 2] += dict[i]


print(dict[N] % MOD)




### FIXED CODE ###

from collections import defaultdict

N, M = [int(x) for x in input().split()]
a = []

for _ in range(M):
    a.append(int(input()))

MOD = 1000000007

dict = defaultdict(int)

for i in range(M):
    if i >= 1 and a[i] - a[i - 1] == 1:
        print("0")
        exit()

dict[0] = 1
a_s = set(a)
for i in range(N):
    if not i in a_s:
        dict[i + 1] += dict[i]
        dict[i + 2] += dict[i]


print(dict[N] % MOD)
### BUGGY CODE ###

inp = int(input())

def check(n):
    i = 1
    print(" ",end="")
    while(i != n):
        if  (i % 3 == 0):
            print(i,end="")
        elif(i % 10 == 3):
            print(i,end="")
            i = i / 10

check(inp)


### FIXED CODE ###

n = int(input())

for  i in range(1,n+1):
    if i%3 == 0 or str(i).find("3") != -1:
        print(" %d" %i ,end="")
print()
### BUGGY CODE ###

import numpy as np
def resolve():
    N = int(input())
    A = list(map(int,input().split()))
    count = 0
    for i in range(1,N):
        A_roll = np.roll(A, i)
        count += sum((A + A_roll)[i:] == i)
    print(count)
resolve()

### FIXED CODE ###

from collections import defaultdict
iim = lambda: map(int, input().rstrip().split())
 
def resolve():
    N = int(input())
    A = list(iim())
    ans = 0
    dp = [0]*N
    for i, ai in enumerate(A):
        x = i + ai
        if x < N:
            dp[x] += 1
        x = i - ai
        if x >= 0:
            ans += dp[x]
    print(ans)
resolve()
### BUGGY CODE ###

# coding: utf-8
# Your code here!
from itertools import accumulate
#import numpy as np

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

sum_A = list(accumulate(A))
sum_B = list(accumulate(B))


#sum_A = np.cumsum(A)
#sum_B = np.cumsum(B)

list_N = [0 for i in range(len(A)+1)]

pre_n = len(B)

for i in range(len(A)+1):
    if i == 0:
        buf = sum_B[:pre_n]
        num_B = sum([1 if buf[j] <= K else 0 for j in range(len(buf))])
        #len(buf[buf<=K])
        pre_n = num_B
        list_N[i] = i + num_B
    else:
        if K>=sum_A[i-1]:
            buf = sum_B[:pre_n]
            num_B = sum([1 if buf[j] <= (K-sum_A[i-1]) else 0 for j in range(len(buf))])
            #len(buf[buf<=(K-sum_A[i-1])])
            pre_n = num_B
            list_N[i] = i + num_B
            #print(K-sum_A[i-1])
            #print(i, num_B)
        else:
            list_N[i] = 0
    
#print(A)
#print(B)
#print(sum_A)
#print(sum_B)
#print(list_N)
print(max(list_N))

### FIXED CODE ###

# coding: utf-8
# Your code here!
from itertools import accumulate
#import numpy as np

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

sum_A = list(accumulate(A))
sum_B = list(accumulate(B))


#sum_A = np.cumsum(A)
#sum_B = np.cumsum(B)

list_N = [0 for i in range(len(A)+1)]

pre_n = len(B)

for i in range(len(A)+1):
    if i == 0:
        num_B = 0
        for j in range(pre_n)[::-1]:
            if sum_B[j] <= K:
                num_B = j+1
                break
            else:
                continue
        #len(buf[buf<=K])
        pre_n = num_B
        list_N[i] = i + num_B
    else:
        if K>=sum_A[i-1]:
            num_B = 0
            for j in range(pre_n)[::-1]:
                if sum_B[j] <= (K-sum_A[i-1]):
                    num_B = j+1
                    break
                else:
                    continue
            #len(buf[buf<=(K-sum_A[i-1])])
            pre_n = num_B
            list_N[i] = i + num_B
            #print(K-sum_A[i-1])
            #print(i, num_B)
        else:
            list_N[i] = 0
    
#print(A)
#print(B)
#print(sum_A)
#print(sum_B)
#print(list_N)
print(max(list_N))
### BUGGY CODE ###

N,P = map(int, input().split())

count = 1
ans = 0

if N > 1000001:
    print(1)
    exit

while True:
    
    if count**N > P:
        break

    if P % count**N == 0:
        ans = count

    count += 1
 
print(ans)

### FIXED CODE ###

N,P = map(int, input().split())

count = 1
ans = 0

if N == 1:
    print(P)
    exit()

if N > 1000001:
    print(1)
    exit()

while True:

    if count**N > P:
        break

    if P % count**N == 0:
        ans = count

    count += 1
 
print(ans)
### BUGGY CODE ###

# Problem D - String Formation

# input process
S = list(input())
Q = int(input()) # query number

# initialization
sento = 1

# process
for i in range(Q):
    query_num = input()
    # クエリが１の時
    if query_num[0]=="1":
        # 反転処理
        if sento==1:
            sento = 10
        else:
            sento = 1
    else: # query num 2
        n, f, c = query_num.split()
        f = int(f)
        if f==1: # 先頭追加処理
            # 先頭の位置によって変わる
            if sento==1:
                S.insert(0, c)
            else:
                S.append(c)
        else: # 末尾追加処理
            if sento==1:
                S.append(c)
            else:
                S.insert(0, c)

# output process
if sento==1:
    for s in S:
        print(s, end="")
else:
    for s in S[::-1]:
        print(s, end="")


### FIXED CODE ###

# Problem D - String Formation

from collections import deque

# input process
S = input().replace("\n", "")
S = deque(list(S))
Q = int(input()) # query number

# initialization
sento = 1

# process
for i in range(Q):
    query_num = input()
    # クエリが１の時
    if query_num[0]=="1":
        # 反転処理
        if sento==1:
            sento = 10
        elif sento==10:
            sento = 1
    elif query_num[0]=="2":
        n, f, c = query_num.split()
        f = int(f)
        if f==1: # 先頭追加処理
            # 先頭の位置によって変わる
            if sento==1:
                S.appendleft(c)
            elif sento==10:
                S.append(c)
        elif f==2: # 末尾追加処理
            if sento==1:
                S.append(c)
            elif sento==10:
                S.appendleft(c)

# output process
if sento==1:
    print("".join(S))
else:
    print("".join(list(S)[::-1]))
### BUGGY CODE ###

s = input()
t = input()

len_s=len(s)
len_t=len(t)

# dp[len(s)][len(t)]
# dp表をつくる
dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]

for i in range(1,len_s+1):
  for j in range(1,len_t+1):
    if s[i-1]==t[j-1]:
      dp[i][j]=dp[i-1][j-1]+1
    else:
      dp[i][j]=max(dp[i][j-1],dp[i-1][j])
#print(dp)

rev = ""
#復元する
i = len_s
j = len_t
while (i>=1 and j>=1):
  if dp[i][j] == dp[i][j-1]:
    j -=1
  elif dp[i][j] == dp[i-1][j]:
    i -=1
  else:
    rev = t[j-1] + rev
    i -=1
    j -=1

print(rev)

### FIXED CODE ###

s = input()
t = input()

len_s=len(s)
len_t=len(t)

# dp[len(s)][len(t)]
# dp表をつくる
dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]

for i in range(1,len_s+1):
  for j in range(1,len_t+1):
    if s[i-1]==t[j-1]:
      dp[i][j]=dp[i-1][j-1]+1
    else:
      dp[i][j]=max(dp[i][j-1],dp[i-1][j])
#print(dp)

#復元する
rev = ""
i = len_s
j = len_t
while (i>=1 and j>=1):
  if dp[i][j] == dp[i][j-1]:
    j -=1
  elif dp[i][j] == dp[i-1][j]:
    i -=1
  else:
    rev = t[j-1] + rev
    i -=1
    j -=1

print(rev)
### BUGGY CODE ###

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

ans = 0
three = [0, 0, 0]

for i in range(k+1):
    for j in range(k+1):
        for k in range(k+1):
            g = i + j + k
            if g == s:
                ans += 1
                 
print(ans)

### FIXED CODE ###

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

ans = 0

for x in range(k+1):
    for y in range(k+1):
        z = s - x - y
        if 0 <= z <= k :
            ans += 1
                 
print(ans)
### BUGGY CODE ###

a, b = list(map(int, input().split()))
p = 1

while True:
    p *= a
    a += 1

    if b < a:
        break

if 0 < p:
    print('Positive')
elif p < 0:
    print('Negative')
else:
    print('Zero')

### FIXED CODE ###

a, b = list(map(int, input().split()))
p = 1

if 0 < a and 0 < b:
    print('Positive')
elif a <= 0 and 0 <= b or 0 <= a and b <= 0:
    print('Zero')
else:
    if (b - a + 1) % 2 == 0:
        print('Positive')
    else:
        print('Negative')
### BUGGY CODE ###

s =input().split()
a=0
b=0
while a<int(s[0]) :
    b+=1
    a+=int(s[1])
    if a>int(s[0]) :
        break
    b+=1
    a=a-int(s[2])
    if a<0 :
        break
if a<0 :
    print(-1)
if a>int(s[0]) :
    print(int(b))

### FIXED CODE ###

k, a, b = map(int, raw_input().split())
if k <= a or a <= b:
    print [-1, 1][k <= a]
else:
    print (k - b - 1) / (a - b) * 2 + 1
### BUGGY CODE ###

N = input()
A = list(map(int, input().split()))
ans = 1
for i in A:
    
    ans = ans * i
    if ans == 0:
        break

if ans > 1000000000000000000:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

N = input()
A = list(map(int, input().split()))
A.sort()
ans = 1
for i in A:

    ans = ans * i
    if ans == 0:
        break
    if ans > 1000000000000000000:
        ans = -1
        break

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

n = int(input())
a_list=list(map(int,input().split()))

MOD = 10**9+7

ans=0
for i in range(60):
    one_cnt = 0
    for a in a_list:
        one_cnt += (a & 2**i) // 2**i
    zero_cnt = n - one_cnt
    ans = (ans + (2**i * one_cnt * zero_cnt) % MOD) % MOD
print(ans)

### FIXED CODE ###

n = int(input())
a_list=list(map(int,input().split()))

MOD = 10**9+7

ans=0
for i in range(60):
    one_cnt = 0
    for a in a_list:
        one_cnt += (a & 2**i)
    one_cnt //= 2**i
    zero_cnt = n - one_cnt
    ans = (ans + (2**i * one_cnt * zero_cnt) % MOD) % MOD
print(ans)
### BUGGY CODE ###

mod = 10 ** 9 + 7
inf = float("inf")

s = list(input())
n = len(s)

dp = [[0 for _ in range(13)] for _ in range(n+1)]
dp[0][0] = 1

for i in range(n):
    c = inf
    if s[i] == "?":
        c = -1
    else:
        c = ord(s[i]) - ord('0')
    for j in range(10):
        if c != -1 and c != j:
            continue
        for k in range(13):
            dp[i + 1][(k * 10 + j) % 13] += dp[i][k]
    for j in range(13):
        dp[i + 1][j] %= mod
        
print(dp[n][5])

### FIXED CODE ###

mod = 10 ** 9 + 7
inf = float("inf")

s = list(input())
n = len(s)

dp = [[0 for _ in range(13)] for _ in range(n+1)]
dp[0][0] = 1

for i in range(n):
    c = inf
    if s[i] == "?":
        c = -1
    else:
        c = ord(s[i]) - ord('0')
    for j in range(10):
        if c != -1 and c != j:
            continue
        for k in range(13):
            dp[i + 1][(k * 10 + j) % 13] += dp[i][k]
    for j in range(13):
        dp[i + 1][j] %= mod
        
print(dp[n][5])
### BUGGY CODE ###

n=int(input())
s=input()
x=[]
y=list(s)
m=999999
for i in range(n):
    del y[0]
    xn=x.count('W')
    yn=y.count('E')
    z=xn+yn
    m=min(m,z)
    x.append(s[i])
print(m)

### FIXED CODE ###

n=int(input())
s=input()
y=s.count('E')
x=0
m=(x+y)
for i in range(n):
    if s[i]==('W'):
        x+=1
    else:
        y-=1
    m=min(m,x+y)
print(m)
### BUGGY CODE ###

import math
import sys
import functools
import operator

n = int(input())
a = list(map(int, input().split()))
sumans = functools.reduce(operator.mul, a)

INF = 1000000000000000000
if (sumans > INF):
    print(-1)
else:
    print(sumans)


### FIXED CODE ###

import math
import sys
import functools
import operator

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


ans = 1
INF = 1000000000000000000

if (0 in a):
    print(0)
    sys.exit()

for i in a:
    ans *= i
    if(ans > INF):
        print(-1)
        sys.exit()

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

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

for i in range(max(a),0,-1):
  flg=0
  for j in range(n):
    if a[j]%i !=0 and flg==0:
      flg=1
    elif a[j]%i !=0 and flg==1:
      flg=2
      break
  if flg<2:
    print(i)
    break

### FIXED CODE ###

n=int(input())
a=sorted(list(map(int,input().split())))
i=a[1]
while i > 0:
  flg=0
  for j in a:
    if j%i!=0:
      flg+=1
      if flg>1:
        break
  if flg<=1:
    print(i)
    break
  else:
    i-=1
### BUGGY CODE ###

import itertools

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N,M,Q = map(int, input().split())
L = []

for i in range(1,M+1,1):
    for j in range(N):
        L.append(i)

A = []
B = []
C = []
D = []
for _ in range(Q):
    a,b,c,d = map(int, input().split())
    A.append(a)
    B.append(b)
    C.append(c)
    D.append(d)

List = list(itertools.combinations(L, N))
ans = 0
for l in List:
    temp = 0
    for q in range(Q):
        if (l[B[q]-1]-l[A[q]-1])==C[q]:
            temp = temp + D[q]
    ans = max(ans, temp)
print(ans)
            

### FIXED CODE ###

import itertools

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N,M,Q = map(int, input().split())
L = []

for i in range(1,M+1,1):
    L.append(i)

A = []
B = []
C = []
D = []
for _ in range(Q):
    a,b,c,d = map(int, input().split())
    A.append(a)
    B.append(b)
    C.append(c)
    D.append(d)

List = list(itertools.combinations_with_replacement(L, N))
ans = 0
for l in List:
    temp = 0
    for q in range(Q):
        if (l[B[q]-1]-l[A[q]-1])==C[q]:
            temp = temp + D[q]
    ans = max(ans, temp)
print(ans)
### BUGGY CODE ###

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


### FIXED CODE ###

import numpy

n,k = map(int,input().split())
p = list(map(int,input().split()))
q = []
for i in range(n):
    q.append(((((p[i]+1)*p[i])/2)/p[i]))

res = numpy.cumsum(q)
ans = []
ans.append(res[k-1])
for i in range(k,n):
  ans.append(res[i]-res[i-k])
print(max(ans))
### BUGGY CODE ###

import math

x = int(input())
while x > 0:
  for i in range(2, math.floor(x**(1/2))):
    if x % i == 0:
      print(x)
      break
  else:
    x += 1

### FIXED CODE ###

import math

x = int(input())
while x > 0:
  for i in range(2, math.floor(x**(1/2))):
    if x % i == 0:
      x += 1
      break
  else:
    print(x)
    break
### BUGGY CODE ###

n=int(input())

def prime_factors(n):
  i = 2
  factors = []
  while i * i <= n:
    if n % i==0:
      n //= i
      factors.append(i)
    else:
      i += 1
  if n > 1:
    factors.append(n)
  return factors
A=list(map(lambda x:prime_factors(x).count(2) if x%2==0 else 0,list(map(int,input().split()))))
print(sum(A))

### FIXED CODE ###

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

count = 0
for i in nums:
  if i % 2 ==0:
    while i % 2 ==0:
      i /= 2
      count += 1

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

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

def getDistNexts(As):
    lenA = len(As)
    poss = dict()
    for i, A in enumerate(As):
        if A not in poss:
            poss[A] = i + lenA

    distNexts = [0]*(lenA)
    for i in reversed(range(lenA)):
        distNexts[i] = poss[As[i]] - i
        poss[As[i]] = i
    return distNexts

distNexts = getDistNexts(As)

maxD = (N*K).bit_length() - 1

dp = [[0]*(N) for _ in range(maxD+1)]
for i in range(N):
    dp[0][i] = distNexts[i] + 1
for d in range(1, maxD+1):
    for i in range(N):
        i2 = i + dp[d-1][i]
        dp[d][i] = i2 + dp[d-1][i2%N] - i

iNow = 0
dist = 0
for d in reversed(range(maxD+1)):
    if dist+dp[d][iNow] <= N*K-1:
        dist += dp[d][iNow]
        iNow = dist%N

Ss = []
setS = set()
for A in As[iNow:]:
    if A in setS:
        S = ''
        while S != A:
            S = Ss.pop()
            setS.remove(S)
    else:
        Ss.append(A)
        setS.add(A)

if Ss:
    print(' '.join(map(str, Ss)))


### FIXED CODE ###

def solve():
    N, K = map(int, input().split())
    As = list(map(int, input().split()))

    def getDistNexts(As):
        lenA = len(As)
        poss = dict()
        for i, A in enumerate(As):
            if A not in poss:
                poss[A] = i + lenA

        distNexts = [0]*(lenA)
        for i in reversed(range(lenA)):
            distNexts[i] = poss[As[i]] - i
            poss[As[i]] = i
        return distNexts

    distNexts = getDistNexts(As)

    NK = N*K
    maxD = (NK).bit_length() - 1

    dp = [[0]*(N) for _ in range(maxD+1)]
    for i in range(N):
        dp[0][i] = distNexts[i] + 1
    for d in range(1, maxD+1):
        for i in range(N):
            i2 = i + dp[d-1][i]
            dp[d][i] = i2 + dp[d-1][i2%N] - i

    iNow = 0
    dist = 0
    for d in reversed(range(maxD+1)):
        if dist+dp[d][iNow] < NK:
            dist += dp[d][iNow]
            iNow = dist%N

    Ss = []
    setS = set()
    for A in As[iNow:]:
        if A in setS:
            S = ''
            while S != A:
                S = Ss.pop()
                setS.remove(S)
        else:
            Ss.append(A)
            setS.add(A)

    if Ss:
        print(' '.join(map(str, Ss)))


solve()
### BUGGY CODE ###

N=int(input())
a=list(map(int,input().split()))
o=[]
e=[]
for i in range(N):
    if i%2:
        o.append(a[i])
        e.insert(0,a[i])
    else :
        o.insert(0,a[i])
        e.append(a[i])
for i in o if N%2 else e:
    print(i,sep="",end=" ")

### FIXED CODE ###

N=int(input())
a=input().split()
print(*(a[::-2]+a[N%2::2]))