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

import numpy as np

n, k, q = map(int, input().split())
i = np.array([k]*n)

# 計算
for l in range(q):
    a = int(input())
    i -= 1
    i[a-1] += 1

# 出力
for m in range(n):
    if i[m] <= 0:
        print('No')
    else:
        print('Yes')

### FIXED CODE ###

import numpy as np

n, k, q = map(int, input().split())
i = np.array([k-q]*n)

# 計算
for l in range(q):
    a = int(input())-1
    i[a] += 1

# 出力
[print('No') if i[m]<=0 else print('Yes') for m in range(n)]
### BUGGY CODE ###

N, M = map(int, input().split())
a_list = list(map(int, input().split()))
written_pairs = [None] * M

written_nums = []
for i in range(M):
    b, c = map(int, input().split())
    written_nums += [c] * b

written_nums = sorted(written_nums, reverse = True)
a_list = sorted(a_list)

total = 0
len_nums = len(written_nums)
for i in range(N):
    if i < len_nums and a_list[i] < written_nums[i]:
        total += written_nums[i]
    else:
        total += a_list[i]
print(total)


### FIXED CODE ###

#TLE
N, M = map(int, input().split())
a_list = list(map(int, input().split()))

written_nums = []
for i in range(M):
    b, c = map(int, input().split())
    written_nums.append((c, b))

written_nums.sort(reverse = True)
append_list = []
for c, b in written_nums:
    append_list += [c for _ in range(b)]

    if len(append_list) >= N:
        break

a_list += append_list
a_list.sort(reverse = True)

print(sum(a_list[:N]))
### BUGGY CODE ###

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

w = []
v = []

for i in range(N):
    a, b = map(int, input().split())
    w.append(a)
    v.append(b)

dp = [[0] * (W+1) for _ in range(N+1)]

for i in range(N):
    for j in range(0, W+1):
        if j - w[i] >= 0:  # i 番目の品物が容量 j に対して（他を0個以上捨てれば）入れられる場合
            if dp[i+1][j] < dp[i][j - w[i]] + v[i]:
                dp[i+1][j] = dp[i][j - w[i]] + v[i]

        if dp[i+1][j] < dp[i][j]:
            dp[i+1][j] = dp[i][j] # i 番目の品物を入れた場合と入れなかった場合の比較

print(dp[N][W])


### FIXED CODE ###

def dp():
    n, W = map(int, input().split())
    wv = (map(int, input().split()) for _ in range(n))
    dp = [0] * (W+1)

    for w, v in wv:
        for j in range(W, w-1, -1):
            DP = dp[j-w] + v
            if dp[j] < DP:
                dp[j] = DP
    return max(dp)
print(dp())
### BUGGY CODE ###

(A,B,C,D)=map(int,input().split())

##N=int(input())
##c=list(map(int, input().split()))

k=0
for i in range(A,B+1):
    if((i%C)and(i%D)):
        k=k+1
print(k)

### FIXED CODE ###

import math
import fractions
(a,b,c,d)=map(int,input().split())
g=c*d//fractions.gcd(c,d)
k=0
k+=b//c+b//d-b//g-int(a-1)//c-(a-1)//d+(a-1)//g

print(b-a+1-k)
### BUGGY CODE ###

N = int(input())
L = [int(i) for i in input().split()]


ans = 0
for a in range(N-2):
    for b in range(a+1, N-1):
        for c in range(b+1, N):
            # print(L[a], L[b], L[c])
            if L[a] < L[b]+L[c] and L[b] < L[a]+L[c] and L[c] < L[a]+L[b]:
                ans += 1

print(ans)

### FIXED CODE ###

N = int(input())
L = [int(i) for i in input().split()]

import bisect
L.sort()
ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        idx = bisect.bisect_left(L, L[i]+L[j])
        ans += (idx-(j+1))

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

# D - Wizard in Maze

import heapq

h,  w  = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
s = []
for i in range(h):
    s.append([c for c in input()])

queue = [(0, ch - 1, cw - 1)]  # (dist, y, x)

while len(queue) > 0:
    dist, y, x = heapq.heappop(queue)
    if s[y][x] != '.':
        continue
    s[y][x] = dist
    for vy in range(-2, 3):
        for vx in range(-2, 3):
            if 0 <= y + vy < h and 0 <= x + vx < w and \
               s[y + vy][x + vx] == '.':
                cost = 0 if abs(vx) + abs(vy) <= 1 else 1
                heapq.heappush(queue, (dist + cost, y + vy, x + vx))

dist = s[dh - 1][dw - 1]
print(dist if dist != '.' else -1)


### FIXED CODE ###

# D - Wizard in Maze

from collections import deque

h,  w  = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
s = []
for i in range(h):
    s.append([c for c in input()])

def dfs(y, x, area_id):
    stack = [(y, x)]
    while len(stack) > 0:
        y, x = stack.pop()
        if s[y][x] == '.':
            s[y][x] = area_id
            for vy, vx in [(-1, 0), (0, 1), (1, 0), (0, -1)]:
                if (0 <= x + vx < w and 0 <= y + vy < h and
                    s[y + vy][x + vx] == '.'):
                    stack.append((y + vy, x + vx))

n_area = 0
for y in range(h):
    for x in range(w):
        if s[y][x] == '.':
            dfs(y, x, n_area)
            n_area += 1

# links between areas
adj = [set() for i in range(n_area)]
for y in range(h):
    for x in range(w):
        if s[y][x] == '#':
            continue
        for vy in range(0, 3):
            for vx in range(-2, 3):
                if (0 <= x + vx < w and 0 <= y + vy < h and
                    s[y + vy][x + vx] != '#'):
                    adj[s[y][x]].add(s[y + vy][x + vx])
                    adj[s[y + vy][x + vx]].add(s[y][x])

c = s[ch - 1][cw - 1]
d = s[dh - 1][dw - 1]
dist = [float('inf') for i in range(n_area)]
dist[c] = 0

q = deque()
q.append((c, 0))
while len(q) > 0:
    c, cost = q.popleft()
    for x in adj[c]:
        if dist[x] > cost + 1:
            dist[x] = cost + 1
            q.append((x, cost + 1))

print(dist[d] if dist[d] < float('inf') else -1)
### BUGGY CODE ###

def poll(arr):
    ans_h = {}
    for ele in arr:
        if ele in ans_h.keys():
            ans_h[ele] += 1
        else:
            ans_h[ele] = 0
    for ele in sorted([kv for kv in ans_h.items() if kv[1] == max(ans_h.values())]):
        print(ele[0])

if __name__ == "__main__":
    n = int(input())
    arr = [input() for _ in range(0, n)]
    poll(arr)

### FIXED CODE ###

def poll(arr):
    ans_h = {}
    for ele in arr:
        if ele in ans_h.keys():
            ans_h[ele] += 1
        else:
            ans_h[ele] = 0
    max_v = max(ans_h.values())
    mkv = [kv for kv in ans_h.items() if kv[1] == max_v]
    for ele in sorted(mkv):
        print(ele[0])

if __name__ == "__main__":
    n = int(input())
    arr = [input() for _ in range(0, n)]
    poll(arr)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N=int(input())
A = [list(map(lambda x:int(x)-1,input().split())) for _ in [0]*N]

V = {(i,j):0 for i in range(N) for j in range(i+1,N)}
Ef = {(i,j):[] for i in range(N) for j in range(i+1,N)}
for i,B in enumerate(A):
    for a0,a1 in zip(B[:-1],B[1:]):
        k0 = tuple(sorted((i,a0)))
        k1 = tuple(sorted((i,a1)))
        Ef[k0].append(k1)
        V[k1] += 1

q = [k for k in V if V[k] == 0]
ans = 0
rmv = 0
while q:
    qq = []
    for k in q:
        for k2 in Ef[k]:
            V[k2] -= 1
            rmv += 1
            if V[k2] == 0 : qq.append(k2)
    ans += 1
    q = qq
if rmv != N*(N-2) : ans = -1
print(ans)

### FIXED CODE ###

#"""
import sys
input = sys.stdin.readline
#"""
def main():
    def get_key(i,j):
        if i<j: i,j = j,i
        return i*N+j
    N=int(input())
    A = [list(map(int,input().split())) for _ in [0]*N]
    V = [-1]*(N*N)
    for i in range(N):
        for j in range(i+1,N):
            V[get_key(i,j)] = 0
    Ef = [[] for _ in V]

    for i,B in enumerate(A):
        a0 = B[0]-1
        k1 = (i,a0)
        for a1 in B[1:]:
            a1 -= 1
            k0 = k1
            k1 = (i,a1)
            Ef[get_key(*k0)].append(get_key(*k1))
            V[get_key(*k1)] += 1

    q = [i for i,v in enumerate(V) if v == 0]
    ans = 0
    rmv = 0
    while q:
        qq = []
        for i in q:
            for j in Ef[i]:
                V[j] -= 1
                rmv += 1
                if V[j] == 0 : qq.append(j)
        ans += 1
        q = qq
    if rmv != N*(N-2) : ans = -1
    print(ans)
main()
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    inf=10**9
    h,n=MI()
    aa=[]
    bb=[]
    for _ in range(n):
        a,b=MI()
        aa.append(a)
        bb.append(b)
    dp=[inf]*(h+1)
    dp[0]=0
    for i in range(h):
        pre=dp[i]
        for a,b in zip(aa,bb):
            ni=h if i+a>h else i+a
            if pre+b<dp[ni]:dp[ni]=pre+b
    print(dp[h])

main()

### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    inf=10**9
    h,n=MI()
    aa=[]
    bb=[]
    for _ in range(n):
        a,b=MI()
        aa.append(a)
        bb.append(b)
    dp=[inf]*(h+1)
    dp[0]=0
    for i in range(h):
        pre=dp[i]
        for a,b in zip(aa,bb):
            ni=h if i+a>h else i+a
            if pre+b<dp[ni]:dp[ni]=pre+b
    print(dp[h])

main()
### BUGGY CODE ###

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

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

uf = UnionFind(N+1)

fb = [[False]*(N+1) for _ in range(N+1)]

for i in range(M):
    a, b = map(int, input().split())
    uf.union(a, b)
    fb[a][b] = True
    fb[b][a] = True

for i in range(K):
    c, d = map(int, input().split())
    fb[c][d] = True
    fb[d][c] = True

res = [0]*(N+1)

gp = list(uf.all_group_members().values())

for g in gp:
    for i in range(len(g)):
        for j in range(i+1, len(g)):
            n = g[i]
            m = g[j]
            if fb[n][m]:
                continue
            else:
                res[n] += 1
                res[m] += 1

print(" ".join(list(map(str, res[1:]))))

### FIXED CODE ###

N, M, K = map(int, input().split())
 
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):
        return -self.parents[self.find(x)]
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
 
uf = UnionFind(N)
 
deg = [0]*N
to = [[] for _ in range(N)]
 
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uf.union(a, b)
    deg[a] += 1
    deg[b] += 1
 
for i in range(K):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    to[c].append(d)
    to[d].append(c)
 
res = []

for i in range(N):
    r = uf.size(i)-1-deg[i]
    for u in to[i]:
        if uf.same(i, u):
            r -= 1
    res.append(str(r))

print(" ".join(res))
### BUGGY CODE ###

from collections import Counter
S = input()
S = S + '0'
mod = 2019
p = [0] * mod
r = 0
for i,s in enumerate(S[::-1]):
  t = int(s)%mod
  t *= (10**i)%mod
  r += t
  r %= mod
  p[r] += 1

#p.append(0)
#ans = 0
#c = Counter(p)
#for k,n in c.most_common():
#  if n > 1:
#    ans += 1
#  else:break
  
print(sum([i*(i-1)//2 for i in p]))


### FIXED CODE ###

S = input()
S = S + '0'
mod = 2019
p = [0] * mod
r = 0
d = 1
for s in reversed(S):
  t = int(s)%mod
  r += t*d
  r %= mod
  d = d*10%mod
  p[r] += 1

print(sum([i*(i-1)//2 for i in p]))
### BUGGY CODE ###

# coding: utf-8
# Your code here!

N,M = map(int,input().split(" "))
A = []
B = []

for i in range(N):
    a,b = map(int,input().split(" "))
    A.append(a)
    B.append(b)
    


#N 店の軒数


#M 買いたい本数
#A 一本の価格
#B 買える本数
yen = 0

while True:
    i = A.index(min(A))
    y = min(A)
    #print(A,B,i,y)
    if B[i] >= M:
        yen += M*A[i]
        break
    else:#B[i] < M
        yen += B[i] * A[i]
        M -= B[i]
        del B[i]
        del A[i]
        
print(yen)
        
    

### FIXED CODE ###

# coding: utf-8
# Your code here!

N,M = map(int,input().split(" "))
A = []
B = []

for i in range(N):
    a,b = map(int,input().split(" "))
    A.append(a)
    B.append(b)
    
L = list(zip(A,B))
L.sort()

#N 店の軒数


#M 買いたい本数
#A 一本の価格
#B 買える本数
yen = 0

while True:
    i = 0#i = A.index(min(A))
    #y = min(A)
    #print(A,B,M)
    if L[0][1] >= M:
        yen += M*L[0][0]
        break
    else:#B[i] < M
        yen += L[0][1] * L[0][0]
        M -= L[0][1]
        del L[0]
        
        
print(yen)
### BUGGY CODE ###

H, W = map(int, input().split())
M = [input() for _ in range(H)]

S = [[0] * W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if M[i][j] == ".":
            if j > 0:
                S[i][j] = S[i][j - 1] + 1
            else:
                S[i][j] = 1
    for j in range(W - 2, -1, -1):
        S[i][j] = max(S[i][j], S[i][j + 1]) * (1 if S[i][j] else 0)

T = [[0] * W for _ in range(H)]
for j in range(W):
    for i in range(H):
        if M[i][j] == ".":
            if i > 0:
                T[i][j] = T[i - 1][j] + 1
            else:
                T[i][j] = 1
    for i in range(H - 2, -1, -1):
        T[i][j] = max(T[i][j], T[i + 1][j]) * (1 if T[i][j] else 0)

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, S[i][j] + T[i][j] - 1)
print(ans)


### FIXED CODE ###

H, W = map(int, input().split())
M = [input() for _ in range(H)]

S = [[0] * W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if M[i][j] == ".":
            if j > 0:
                S[i][j] = S[i][j - 1] + 1
            else:
                S[i][j] = 1
    for j in range(W - 2, -1, -1):
        S[i][j] = max(S[i][j], S[i][j + 1]) * (1 if S[i][j] else 0)

T = [[0] * W for _ in range(H)]
for j in range(W):
    for i in range(H):
        if M[i][j] == ".":
            if i > 0:
                T[i][j] = T[i - 1][j] + 1
            else:
                T[i][j] = 1
    for i in range(H - 2, -1, -1):
        T[i][j] = max(T[i][j], T[i + 1][j]) * (1 if T[i][j] else 0)

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, S[i][j] + T[i][j] - 1)
print(ans)
### BUGGY CODE ###

N = int(input())
P = list(map(int, input().split()))
A = 1
for i in range(1, N):
  if P[i] <= min(P[:i]):
    A += 1
print(A)

### FIXED CODE ###

N = int(input())
P = list(map(int, input().split()))
A = 1
M = P[0]
for i in range(1, N):
  M = min(M, P[i])
  if P[i] <= M:
    A += 1
print(A)
### BUGGY CODE ###

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

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
K = [0] * 60
ans = 0
mod = 7 + 10**9
for i in A:
    for j in range(60):
        if (i >> j) & 1 == 1:
            K[j] += 1

for i, j in enumerate(K):
    ans += (2**i) * j * (N - j)
    ans %= mod

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

n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(len(a)):
	b.append(a[i])
	b = b[::-1]
for i in range(len(b)):
	print(b[i], end = ' ')

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b_1 = []
b_2 = []
b = []
for i in reversed(range(len(a))):
	if i % 2 != 0:
		b_1.append(a[i])
	else:
		b_2.append(a[i])
if len(a) % 2 == 0:
	b_2.reverse()
	b.extend(b_1)
	b.extend(b_2)
else:
	b_1.reverse()
	b.extend(b_2)
	b.extend(b_1)
for b_num in b:
	print(b_num, end = ' ')
### BUGGY CODE ###

#Doubling O(log k)
def main():
  ## IMPORT MODULE
  #import sys

  #sys.setrecursionlimit(100000)
  #input=lambda :sys.stdin.readline().rstrip()

  #f_inf=float("inf")
  #MOD=10**9+7
  
  if 'get_ipython' in globals(): 
    ## SAMPLE INPUT
    n, k = 4, 5
    A = [3, 2, 4, 1]

  else:
    ##INPUT 
    #n = input()
    n, k = map(int, input().split())
    A = list(map(int, input().split()))

  ## SUBMITION CODES HERE
  D = 60 # 10^18 is 60 digits, so we'll see to the 59th power of 2.
  MAX_N = 200005 #Namber of nodes
  to = [[0 for _ in range(MAX_N)] for _ in range(D)]

  # to[i][j]:nodes to 2^i away from j  
  for i in range(n):
    to[0][i] = A[i]
    to[0][i] -= 1

  # Doubling matrix
  for i in range(D-1):
    for j in range(n):
        to[i+1][j] = to[i][to[i][j]]

  v = 0
  for i in range(D-1, -1, -1):
    l = 1<<i # Look go to 2^i
    if l <= k:
        v = to[i][v]
        k -= l

  print(v+1)
    
main()

### FIXED CODE ###

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

Town = []
#まだ訪れていない町は-1
rec = [-1] * (n+1)
idx = 1
#周期までループをまわす
while (rec[idx] == -1):
    rec[idx] = len(Town)
    Town.append(idx)
    idx = A[idx-1]

#周期前
Exce = rec[idx]
#周期内
Cycl = len(Town) - Exce

if Exce > k:
    print(Town[k])
else:
    Warp = (k - Exce) % Cycl
    print(Town[Exce+Warp])
### BUGGY CODE ###

n,k=map(int,input().split())
li=list(map(int,input().split()))
kai=[0]
for i in range(1,1001):
  kai.append(kai[i-1]+i)

mx=0
for i in range(len(li)-k+1):
  ans=0
  x=li[i:i+k]

  for j in x:
    ans+=kai[j]/j
  mx=max(ans,mx)
print(mx)


### FIXED CODE ###

n,k=map(int,input().split())
li=list(map(int,input().split()))
kai=[0]
for i in range(1,1001):
  kai.append(kai[i-1]+i)
ka=[0]+[kai[i]/i for i in range(1,len(kai))]
lis=[ka[i] for i in li]

ans=sum(lis[:k])
mx=ans
for i in range(len(li)-k):
  ans-=lis[i]
  ans+=lis[i+k]
  mx=max(ans,mx)
print(mx)
### BUGGY CODE ###

import collections

n = int(input())

if n == 1:
    print(0)
else:
    lis = [i for i in range(n+1)]
    for i in range(2, int(n**0.5) + 1):
        if lis[i] == i:
            lis[i] = i
            for j in range(i**2, n+1, i):
                if lis[j] == j:
                    lis[j] = i
#print(lis)
def bunkai(m):
    ans = []
    for i in range(m):
        ans.append(lis[m])
        m = m//lis[m]
        if m == 1:
            break
    return ans

ans = 1

for i in range(2,n):
    tmp = 1
    yaku = collections.Counter(bunkai(i))
    for i in yaku:
        tmp = tmp * (yaku[i] +1)
    ans += tmp

print(ans)




### FIXED CODE ###

from collections import Counter

n = int(input())

if n == 1:
    print(0)
else:
    lis = [i for i in range(n+1)]
    for i in range(2, int(n**0.5) + 1):
        if lis[i] == i:
            lis[i] = i
            for j in range(i**2, n+1, i):
                if lis[j] == j:
                    lis[j] = i
#print(lis)
def bunkai(m):
    ans = []
    now = lis[m]
    cnt = 1
    for i in range(m):
        m = m//lis[m]
        if now == lis[m]:
            cnt += 1
        else:
            ans.append(cnt)
            cnt = 1
            now = lis[m]
        
        if m == 1:
            break
    return ans

ans = 1
for i in range(2,n):
    tmp = 1
    yaku = bunkai(i)
    for i in yaku:
        tmp *= (i +1)
    ans += tmp

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

import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    K = int(input())
    x = 0
    i = 0
    if K % 2 == 0 or K % 5 ==  0:
        print(-1)
        exit()
    
    while True:
        x = (x + 7 * 10 ** i) % K
        i += 1
        if x == 0:
            print(i)
            break


    

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    K = int(input())
    x = 0
    i = 0
    if K % 2 == 0 or K % 5 ==  0:
        print(-1)
        exit()
    
    while True:
        x = (x * 10 + 7) % K
        i += 1
        if x == 0:
            print(i)
            break


    

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

import itertools

N, K = map(int, input().split())
a = list(map(int, input().split()))
beautiful_num = []

for i in range(N):
    temp = 0
    for n in a[i:]:
        temp += n
        beautiful_num.append("{:040b}".format(temp))

ma_b_cnt = 0
target_set = None

for i in range(40):
    if target_set is None:
        for b in beautiful_num:
            if b[i] == "1":
                ma_b_cnt += 1
        if ma_b_cnt < K:
            ma_b_cnt = 0
        else:
            target_set = set([b for b in beautiful_num if b[i] == "1"])
    else:
        count = 0
        for b in target_set:
            if b[i] == 0:
                count += 1
        if len(target_set) - count >= K:
            for b in target_set:
                if b[i] == 0:
                    target_set.remove(b)
        else:
            break

result = 0
for comb in itertools.combinations(target_set, K):
    temp = bin(int(comb[0], 2))
    for b in comb:
        temp = bin(int(b, 2) & int(temp, 2))
    temp = int(temp, 2)
    if temp > result:
        result = temp

print(result)

### FIXED CODE ###

import itertools

N, K = map(int, input().split())
a = list(map(int, input().split()))
beautiful_num = []

for i in range(N):
    temp = 0
    for n in a[i:]:
        temp += n
        beautiful_num.append("{:040b}".format(temp))

ma_b_cnt = 0
target_set = None

result = 0
for i in range(40):
        for b in beautiful_num:
            if b[i] == "1":
                ma_b_cnt += 1
        if ma_b_cnt >= K:
            result += 2**(40-i-1)
            beautiful_num = [b for b in beautiful_num if b[i] == "1"]
        ma_b_cnt = 0

print(result)