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

#!/usr/bin/python

n = int(input())
t = input().split()
a = []
for c in t:
    a.append(int(c))

# hash
h = {}
for v in a:
    if v in h:
        h[v] += 1
    else:
        h[v] = 1

ans = []
for c in a:
    aa = 0
    for k, v in h.items():
        vv = v
        if k == c:
            vv -= 1
        if vv > 1:
            aa += (vv*(vv-1)//2)
    print(aa)


### FIXED CODE ###

#!/usr/bin/python

n = int(input())
t = input().split()
a = []
for c in t:
    a.append(int(c))

# hash
h = {}
for v in a:
    if v in h:
        h[v] += 1
    else:
        h[v] = 1
total = 0
for k in h.values():
    if k > 1:
        total += (k*(k-1)//2)

for c in a:
    aa = total
    if h[c] > 1:
        aa -= (h[c]*(h[c]-1)//2)
    if h[c] > 2:
        aa += ((h[c]-1)*(h[c]-2)//2)
    print(aa)
### BUGGY CODE ###

import sys

N, Z, W = map(int, input().split())
A = list(map(int, input().split()))
inf = 10 ** 9 + 7

sys.setrecursionlimit(inf)

def calc(a, b):
  return abs(a - b)

def alphaBeta(X, Y, turn, depth, alpha, beta):
    if depth == N:
        return calc(X, Y)
    if turn:
        for i in range(depth, N):
            alpha = max(alpha, alphaBeta(A[i], Y, False, i+1, alpha, beta))
            if alpha >= beta:
                break
        return alpha
    else:
        for i in range(depth, N):
            beta = min(beta, alphaBeta(X, A[i], True, i+1, alpha, beta))
            if alpha >= beta:
                break
        return beta

print(alphaBeta(Z, W, True, 0, -1, inf))

### FIXED CODE ###

import sys

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

ans = abs(A[-1] - W)
if N != 1:
    ans = max(ans, abs(A[-1] - A[-2]))
print(ans)
### BUGGY CODE ###

X,K,D = map(int,input().split())
List = []

if K == 1:
    print(min(abs(X-D),abs(X+D)))
elif K == 2:
    print(min(abs(X+D+D),abs(X-D-D),abs(X)))
elif K == 3:
    print(min(abs(X+D+D+D),abs(X+D),abs(X-D),abs(X-D-D-D)))
else:
    for i in range(3):
        if abs(X - D) >= abs(X+D):
            List.append(abs(X+D))
            X = X+D
        else:
            List.append(abs(X-D))
            X = X-D

    for i in range(K-3):
        if List[i] == List[i+2]:
            if K%2 == i%2:
                print(List[i+1])
            else:
                print(List[i])
            break
        else:
            if abs(X - D) >= abs(X+D):
                List.append(abs(X+D))
                X = X+D
            else:
                List.append(abs(X-D))
                X = X-D

    if len(List) == K:
        print(List[K-1])
    else:
        pass
     

### FIXED CODE ###

X,K,D = map(int,input().split())

t = abs(X) // D
s = abs(X) % D

if abs(X) > K*D:
    print(abs(X) - K*D)
elif t%2 == K%2:
    print(s)
else:
    print(D-s)
### BUGGY CODE ###

import itertools

n,x,y = map(int, input().split())

a = [i for i in range(1, n+1)]
b = list(itertools.combinations(a, 2))
c = [0]*(n-1)

for j in range(len(b)):
    d = min(abs(b[j][0]-b[j][1]), abs(x-b[j][0])+1+abs(b[j][1]-y), abs(y-b[j][0])+1+abs(b[j][1]-x))
    c[d-1] += 1

for k in range(n-1):
    print(c[k])

### FIXED CODE ###

import itertools

n,x,y = map(int, input().split())

a = [i for i in range(1, n+1)]
b = [0]*(n-1)

for j in range(n):
    for k in range(j+1, n):
        c = min(abs(k-j),abs(j-(x-1)) +abs(k-(y-1))+1)
        b[c-1] += 1
    

for l in range(n-1):
    print(b[l])
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    def digit_sum(n):
        res = 0
        while n > 0:
            res += n % 10
            n //= 10
        return res

    n = int(input())
    if digit_sum(n) % 9 == 0:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    resolve()


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = list(map(int, input()))

    s = 0
    for num in n:
        s += num
        s %= 9

    print("Yes" if s == 0 else "No")


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

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

A.sort()

while M>0:
    A[N-1] /= 2
    M -= 1
    A[A.index(max(A))],A[N-1] = A[N-1],max(A)


ans = 0

for i in A:
    ans += int(i)

print(ans)


### FIXED CODE ###

import heapq

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

B = []

for i in A:
    B.append(-i)

heapq.heapify(B)

for i in range(M):
    tmp = heapq.heappop(B)
    heapq.heappush(B,-1*(-tmp//2))

print(-sum(B))
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().strip().split()))
A = 1
for i in range(n):
    A *= a[i]
if A > 10**18:
    print(-1)
else:
    print(A)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
x = 1
if 0 in a:
    x = 0
else:
    for i in range(n):
        x = x * a[i]
        if x > 10 ** 18:
            x = -1
            break
print(x)
### BUGGY CODE ###

N,K,Q = map(int, input().split())
A = []
for a in range(Q):
	A.append(int(input()))

#参加者の持ちスコア
PlayersScore = []
for i in range(N):
    PlayersScore.append(K)

for i in (A):
    number = (i-1)
    for j  in range(N):
        if j != number:
            PlayersScore[j] = (PlayersScore[j] - 1)

for k in PlayersScore:
    if k > 0 :
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

N,K,Q = map(int, input().split())
A = []
for a in range(Q):
	A.append(int(input()))


P = [K-Q] * N
for i in range(Q):
    P[A[i]-1] += 1
for i in range(N):
    if P[i] <= 0:
        print("No")
    else:
        print("Yes")
### BUGGY CODE ###

n = int(input())
a = [int(i) for i in input().split()]
answer = 0
while len(a)>2:
	if a[0]<=a[1]<=a[2] or a[0]>=a[1]>=a[2]:
		a = a[1:]
	else:
		answer += 1
		a = a[2:]
if a != []: answer+=1
print(answer)		

### FIXED CODE ###

import numpy as np
n = int(input())
a = [int(i) for i in input().split()]
answer = 1
if n!=1: flag = np.sign(a[1]-a[0])
for i in range(1,n-1):
	num = np.sign(a[i+1]-a[i])
	if flag==0:
		flag = num
	elif num==-flag:
		answer += 1
		flag = 0
print(answer)
### BUGGY CODE ###

import collections
import sys

N = int(input())
S = [input() for _ in range(N)]
# print(S)
if len(set(S)) == 1:
    print(S[0])
    sys.exit(0)
c = collections.Counter(S)
# print(c.most_common())

outputs = []
for i, (key, value) in enumerate(c.most_common()):
    outputs.append(key)
    if i == len(c.most_common())-1 or c.most_common()[i+1][1] != value:
        break
outputs.sort()
for x in outputs:
    print(x)

### FIXED CODE ###

N = int(input())
S = [input() for _ in range(N)]
S.sort()

ans = []
counter = 1
memo = 0

for i in range(1, N):
    if S[i] == S[i-1]:
        counter += 1
    else:
        if counter == memo:
            ans.append(S[i-1])
        elif counter > memo:
            ans.clear()
            ans.append(S[i-1])
            memo = counter
        counter = 1
if counter == memo:
    ans.append(S[N-1])
elif counter > memo:
    ans.clear()
    ans.append(S[N-1])
    memo = counter
for a in ans:
    print(a)
### BUGGY CODE ###

import sys
H, W = map(int, sys.stdin.readline().split())
INF = float('inf')
S = [[INF] * W for i in range(H)]
d = []
num = 0
for i in range(H):
    a = list(sys.stdin.readline())
    for j in range(W):
        if a[j] == '#':
            d.append((i, j, 0))
            S[i][j] = 0
            num += 1

ma = 0
while len(d) > 0:
    x, y, k = d.pop(0)
    ma = max(ma, k)
    for dx, dy in [(0, 1), (1, 0), (-1, 0), (0, -1)]:
        nx, ny = x + dx, y + dy
        if 0 <= nx < H and 0 <= ny < W and S[nx][ny] > k:
            S[nx][ny] = k
            d.append((nx, ny, k + 1))
            if num == H * W:
                break

print(ma)

### FIXED CODE ###

import sys
H, W = map(int, sys.stdin.readline().split())
INF = float('inf')
S = [[INF] * W for i in range(H)]
for i in range(H):
    a = list(sys.stdin.readline())
    for j in range(W):
        if a[j] == '#':
            S[i][j] = 0

ma = 0
for i in range(1, H):
    for j in range(W):
        S[i][j] = min(S[i][j], S[i - 1][j] + 1)

for i in range(H - 2, -1, -1):
    for j in range(W):
        S[i][j] = min(S[i][j], S[i + 1][j] + 1)

for i in range(H):
    for j in range(1, W):
        S[i][j] = min(S[i][j], S[i][j - 1] + 1)

for i in range(H):
    for j in range(W - 2, -1, -1):
        S[i][j] = min(S[i][j], S[i][j + 1] + 1)

for i in range(H):
    for j in range(W):
        ma = max(ma, S[i][j])

print(ma)
### BUGGY CODE ###

N = int(input())
c = 0

for C in range(1,N):
  NC = N-C
  for A in range(1,N-C+1):
    if (NC / A) % 1 == 0:
      #print(A,B,C)
      c += 1

print(c)

### FIXED CODE ###

N = int(input())
c = 0
for i in range(1,N):
  if i**2 >= N:
    break
  c += 1
for i in range(1,N):
  for j in range(i+1,N):
    if i*j >= N:
      break
    c += 2
print(c)
### BUGGY CODE ###

N = int(input())
S = 0
A = [0 for i in range(N)]
B = [0 for i in range(N)]
for i in range(N):
    A[i], B[i] = map(int, input().split())
for i in range(N):
    s = (-A[N-1-i])%B[N-1-i]
    S += s
    for j in range(N-i):
        A[j] += s
print(S)


### FIXED CODE ###

N = int(input())
S = 0
A = [0 for i in range(N)]
B = [0 for i in range(N)]
for i in range(N):
    A[i], B[i] = map(int, input().split())
for i in range(N):
    S += (-A[N-1-i])%B[N-1-i]
    if i != N-1:
        A[N-2-i]+= S
print(S)
### BUGGY CODE ###

import sys

input = sys.stdin.readline
sys.setrecursionlimit(200010)
n = int(input())
info = [list(map(int, input().split())) for i in range(n)]

v = 100000
graph = [[] for i in range(v*2)]
for i in range(n):
    x = info[i][0] - 1
    y = (info[i][1] - 1) + v
    graph[x].append(y)
    graph[y].append(x)

def dfs(pos):
    if visited[pos]:
        return
    visited[pos] = True
    cnt[pos//v] += 1
    for i in graph[pos]:
        dfs(i)
    return

visited = [False] * (v*2)
cnt = [0]*2
ans = 0
for i in range(v*2):
    cnt[0] = 0
    cnt[1] = 0
    dfs(i)
    ans += cnt[0]*cnt[1]
print(ans - n)


### FIXED CODE ###

import sys

input = sys.stdin.readline
sys.setrecursionlimit(200010)
n = int(input())
info = [list(map(int, input().split())) for i in range(n)]

v = 100000
graph = [[] for i in range(v*2)]
for i in range(n):
    x = info[i][0] - 1
    y = (info[i][1] - 1) + v
    graph[x].append(y)
    graph[y].append(x)

def dfs(pos):
    if visited[pos]:
        return
    visited[pos] = True
    cnt[pos//v] += 1
    for i in graph[pos]:
        dfs(i)
    return

visited = [False] * (v*2)
cnt = [0]*2
ans = 0
for i in range(v*2):
    cnt[0] = 0
    cnt[1] = 0
    dfs(i)
    ans += cnt[0]*cnt[1]
print(ans - n)
### BUGGY CODE ###

# -*- coding:utf-8 -*-
import sys

num_list = []
diff = -sys.maxsize -1
for i in range(int(input())):
    num_list.append(int(input()))

for (idx, Rt) in enumerate(num_list):
    if(idx+1 == len(num_list)-1):
        tmp = num_list[idx+1] - Rt
        if (tmp > diff):
            diff = tmp
    else:
        for Rj in num_list[idx+1:]:
            tmp = Rj - Rt
            if(tmp > diff):
                diff = tmp

print(diff)


### FIXED CODE ###

import sys

max_diff = -sys.maxsize - 1
for idx in range(int(input())):
    Rt = int(input())
    if(idx):
        tmp = Rt - min_num
        if(tmp > max_diff):
            max_diff = tmp
        if(Rt < min_num):
            min_num = Rt
    else:
        min_num = Rt
print(max_diff)
### BUGGY CODE ###

def main():
    n, k = map(int, raw_input().split())
    a = []
    g = [[] for _ in xrange(n)]
    for _ in xrange(n - 1):
        u, v = map(int, raw_input().split())
        u -= 1
        v -= 1
        a.append((u, v))
        g[u].append(v)
        g[v].append(u)
    st = []
    pu = st.append
    po = st.pop
    ans = 0
    if k % 2:
        k = k / 2 + 1
        for u, v in a:
            c = 0
            pu((u, k, v))
            pu((v, k, u))
            while st:
                u, d, p = po()
                d -= 1
                c += 1
                if d:
                    for v in g[u]:
                        if v != p:
                            pu((v, d, u))
            if ans < c:
                ans = c
    else:
        k = k / 2 + 1
        for i in xrange(n):
            c = 0
            pu((i, k, -1))
            while st:
                u, d, p = po()
                d -= 1
                c += 1
                if d:
                    for v in g[u]:
                        if v != p:
                            pu((v, d, u))
            if ans < c:
                ans = c
    print n - ans
main()


### FIXED CODE ###

def main(le=len):
    n, k = map(int, raw_input().split())
    a = []
    g = [[] for _ in xrange(n)]
    for _ in xrange(n - 1):
        u, v = map(int, raw_input().split())
        u -= 1
        v -= 1
        a.append((u, v))
        g[u].append(v)
        g[v].append(u)
    st = []
    pu = st.append
    po = st.pop
    ans = 0
    if k % 2:
        k = k / 2 + 1
        for u, v in a:
            c = 0
            pu((u, k, v))
            pu((v, k, u))
            while c < le(st):
                u, d, p = st[c]
                d -= 1
                if d:
                    for v in g[u]:
                        if v != p:
                            pu((v, d, u))
                c += 1
            if ans < c:
                ans = c
            del st[:]
    else:
        k = k / 2 + 1
        for i in xrange(n):
            c = 0
            pu((i, k, -1))
            while c < le(st):
                u, d, p = st[c]
                d -= 1
                if d:
                    for v in g[u]:
                        if v != p:
                            pu((v, d, u))
                c += 1
            if ans < c:
                ans = c
            del st[:]
    print n - ans
main()
### BUGGY CODE ###

def main(n: int, a: list):
    ans = 0

    i = 1

    if 1 not in a:
        print(-1)
        return

    while len(a) > 0:
        if a[0] != i:
            a.pop(0)
            ans += 1
            continue
        i += 1
        a.pop(0)

    print(ans)


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    main(n, a)


### FIXED CODE ###

def main(n: int, a: list):
    ans = 0

    i = 1

    if 1 not in set(a):
        print(-1)
        return

    for _a in a:
        if _a != i:
            ans += 1
        else:
            i += 1

    print(ans)


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    main(n, a)
### BUGGY CODE ###

k,n = map(int,input().split())
a = list(map(int,input().split()))
l = k - a[n-1] + a[0]
t = 0

for i in range(n):
    p = 0
    j = i + 1

    while True:
        if j == n:
            j = 0

        if j == i:
            break

        if j == 0:
            p += l
        else:
            p += a[j] - a[j-1]

        j += 1

    if t == 0:
        t = p
    else:
        if t > p:
            t = p

print(t)

### FIXED CODE ###

k,n = map(int,input().split())
a = list(map(int,input().split()))
t = 10 ** 6

for i in range(n - 1):
    a.append(a[i] + k)

for i in range(len(a)-n+1):
    t = min(t,a[i+n-1] - a[i])

print(t)
### BUGGY CODE ###

n,x,y = map(int, input().split())
dst = [[0 for j in range(n)] for i in range(n)]
ans = [0]*n

for i in range(n):
    for j in range(n):
        dst[i][j] = min(abs(i-j), abs(x-1-i)+abs(y-1-j)+1, abs(x-1-j)+abs(y-1-i)+1)
        ans[dst[i][j]] += 1

for m in range(1,n):
    print(ans[m]//2)

### FIXED CODE ###

n,x,y = map(int, input().split())
ans = [0]*(n-1)

for i in range(n):
    for j in range(1,n-i):
        d = min(j, abs(x-1-i)+abs(y-1-(i+j))+1)
        ans[d-1] += 1

for m in range(n-1):
    print(ans[m])
### BUGGY CODE ###

n=int(input())
l=list(map(int,input().split()))
ans=0
import itertools
v = itertools.combinations(l,3)
for a,b,c in v:
  m=max(a,b,c)
  s=a+b+c
  if m*2<s:
    ans+=1
print(ans)

### FIXED CODE ###

n = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 0
for i in range(n-2):
    a = l[n-1-i]
    for j in range(i+1,n-1):
        b = l[n-1-j]
        #print(a,b)
        mn = a - b
        ng = -1
        ok = n-1-j
        if mn >= b:
            continue
        while abs(ok - ng) > 1:
            hf = (ng + ok) // 2
            #print(a,b,l[hf])
            if l[hf] > mn:
                ok = hf
            else:
                ng = hf
        ans += n-1-j - ok
        #print(a,b,l[ok],mn,ok)


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

import itertools
 
N = int(input())
L = list(map(int, input().split()))
L = sorted(L, reverse=True)
 
counter = 0
 
for i in range(0, N-2):
    temp = L[i]
    other = list(itertools.combinations(L[i+1:], 2))
    for j in range(len(other)):
        if temp < other[j][0] + other[j][1]:
            counter += 1
 
print(counter)

### FIXED CODE ###

n = int(input())
nums = list(map(int, input().split(' ')))
nums.sort()
total = 0

for i in range(n-1, -1, -1):
    l = 0
    r = i - 1
    while l < r:
        if nums[l] + nums[r] > nums[i]:
            total += r - l
            r -= 1
        else:
            l += 1
print(total)
### BUGGY CODE ###

mod = 10**9+7
n,m = map(int,input().split())
a = []
for i in range(m):
    a.append(int(input()))
dp = [0]*(n+1)
dp[0] = 1
for i in range(1,n+1) :
    dp[i] = (dp[i-1] + dp[i-2])%mod
    if i in a :
        dp[i] = 0
print(dp[-1])

### FIXED CODE ###

mod = 10**9+7
n,m = map(int,input().split())
a = set()
for i in range(m):
    a.add(int(input()))
dp = [0]*(n+1)
dp[0] = 1
for i in range(1,n+1) :
    dp[i] = (dp[i-1] + dp[i-2]) % mod
    if i in a :
        dp[i] = 0
print(dp[n])
### BUGGY CODE ###

x = input().split()
n = int(x[0])
a = int(x[1])
b = int(x[2])
l = ''
boll_a = ''
boll_b = ''
for j in range(0, a):
  boll_a += 'b'
for k in range(0, b):
  boll_b += 'r'
while n >= len(l):
  l += boll_a
  l += boll_b

print(l[:n].count('b'))

### FIXED CODE ###

import math
x = input().split()
n = int(x[0])
a = int(x[1])
b = int(x[2])
z = 0
z = math.floor(n / (a+b)) * a
amari = math.floor(n % (a+b))
if amari == 0:
  pass
elif amari <= a:
  z += amari
else:
  z += a
print(z)
### BUGGY CODE ###

S = [str(i) for i in input()]
T = [str(i) for i in input()]
ans = "Yes"

for j in range(len(S)):
    IDXs = [i for i, x in enumerate(S) if x == S[j]]
    IDXt = [i for i, x in enumerate(T) if x == T[j]]

    if IDXs != IDXt:
        ans = "No"
        break

print(ans)

### FIXED CODE ###

S = [str(i) for i in input()]
T = [str(i) for i in input()]
ans = "Yes"

for j in range(len(S)):
    if S[j] == 0:
        continue

    IDXs = [i for i, x in enumerate(S) if x == S[j]]
    IDXt = [i for i, x in enumerate(T) if x == T[j]]

    if IDXs != IDXt:
        ans = "No"
        break

    for k in range(len(IDXs)):
        S[IDXs[k]] = 0
        T[IDXs[k]] = 0

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

[n, k, q] = list(map(int, input().split()))
a = []
for i in range(q):
    a.append(list(map(int, input().split()))[0])
    
player = [k] * n
for _a in a:
    for _i in range(n):
        if (_i != (_a-1)):
            player[_i] -= 1
            
for _p in player:
    if _p > 0:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

[n, k, q] = list(map(int, input().split()))
a = []
for i in range(q):
    a.append(list(map(int, input().split()))[0])
    
import numpy as np

player = [k] * n
player = np.array(player)

for _a in a:
    player[_a-1] += 1
    
player -= q
           
for _p in player:
    if _p > 0:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

import math
N = int(input())


def combination(n, r):
    if n >= 2:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    else:
        return 0

A = input().split()
len(set(A))
B = {}
C = {}
for i in set(A):
    B[i] = combination(A.count(i) - 1, 2)
    C[i] = combination(A.count(i), 2)
sC = sum(C.values())
for i in A:
    print(B[i] - C[i] + sC)


### FIXED CODE ###

n = int(input())

a = list(map(int, input().split()))
s = [0]*n
for i in range(n):
    s[a[i]-1] += 1
k = 0
for i in range(n):
    if s[i] >= 2:
        k += ((s[i]*(s[i]-1))//2)
for i in range(n):
    if s[a[i]-1] >= 2:
        print(k-(s[a[i]-1]-1))
    else:
        print(k)
### BUGGY CODE ###

import sys

N = int(sys.stdin.buffer.readline())

neighbor = [[] for _ in range(N)]
edge = []
for i in range(N-1):
    a, b = map(int, sys.stdin.buffer.readline().split())
    neighbor[a-1].append(b-1)
    neighbor[b-1].append(a-1)
    edge.append([a-1, b-1, i])

K = len(max(neighbor, key=len))
print(K)
color = [set(range(1, K+1)) for _ in range(N)]

edge = sorted(edge, key = lambda x:x[0])
for idx in range(N-1):
    c = color[edge[idx][0]].pop()
    edge[idx].append(c)
    color[edge[idx][1]].remove(c)

edge = sorted(edge, key=lambda x: x[2])
for x in edge:
    print(x[-1])

### FIXED CODE ###

import sys
sys.setrecursionlimit(500000)

N = int(sys.stdin.buffer.readline())

neighbor = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, sys.stdin.buffer.readline().split())
    neighbor[a-1].append([b-1, i])
    neighbor[b-1].append([a-1, i])

K = max(len(l) for l in neighbor)
print(K)
ans = [-1]*(N-1)

def dfs(current_point, parent_point, parent_edge_color):
    color = 1
    for next_point, idx in neighbor[current_point]:
        if next_point != parent_point:
            if parent_edge_color == color:
                color += 1
            ans[idx] = color
            dfs(next_point, current_point, color)
            color += 1

dfs(0, -1, -1)
print("\n".join(map(str, ans)))
### BUGGY CODE ###

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

### FIXED CODE ###

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

from collections import Counter


def check(ans, s):
    ret = 0
    for k, v in Sumdic.items():
        if ans & k != ans:
            continue
        ret += v
        if ret >= s:
            return True
    return False


n, k = map(int, input().split())
A = list(map(int, input().split()))
sumA = [0]
for i in range(len(A)):
    sumA.append(sumA[i] + A[i])

sumdic = [0] * (n * (n + 1) // 2)
kk = 0
for i in range(len(A)):
    # print(kk, sumdic)
    for j in range(i + 1, len(A) + 1):
        tmp = sumA[j] - sumA[i]
        sumdic[kk + j - 1 - i] = tmp
        # print(i, j)
    kk += n - i

# print(A)
# print(Counter(sumdic))
Sumdic = Counter(sumdic)

for i in reversed(range(len(format(sumA[-1], "b")))):
    # print(i)
    if check(2 ** i, k) is True:
        ans = 2 ** i
        tmp = i
        break
else:
    print(0)
    exit()

tmp -= 1
while(tmp != -1):
    if check(ans + 2 ** tmp, k) is True:
        ans += 2 ** tmp
    tmp -= 1
print(ans)

### FIXED CODE ###

def check(ans, s):
    ret = 0
    for k in sumdic:
        if ans & k != ans:
            continue
        ret += 1
        if ret >= s:
            return True
    return False


n, k = map(int, input().split())
A = list(map(int, input().split()))
sumA = [0]
for i in range(len(A)):
    sumA.append(sumA[i] + A[i])

sumdic = [0] * (n * (n + 1) // 2)
kk = 0
for i in range(len(A)):
    # print(kk, sumdic)
    for j in range(i + 1, len(A) + 1):
        tmp = sumA[j] - sumA[i]
        sumdic[kk + j - 1 - i] = tmp
        # print(i, j)
    kk += n - i

# print(A)
# print(Counter(sumdic))
# Sumdic = Counter(sumdic)

for i in reversed(range(len(format(sumA[-1], "b")))):
    # print(i)
    if check(2 ** i, k) is True:
        ans = 2 ** i
        tmp = i
        break
else:
    print(0)
    exit()

tmp -= 1
while(tmp != -1):
    if check(ans + 2 ** tmp, k) is True:
        ans += 2 ** tmp
    tmp -= 1
print(ans)