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

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# N: ノードの数
# Q: 数値をノードに付与する回数
N, Q = list(map(int, input().split()))

# {0: [], 1: [], ...} のような辞書を作る
links = { x:[] for x in range(N) }

values = [ 0 for _ in range(N) ]

for i in range(N - 1):
    edge1, edge2 = [x - 1 for x in list(map(int, input().split()))]
    links[edge1].append(edge2)
    links[edge2].append(edge1)

for i in range(Q):
    node, val = list(map(int, input().split()))
    values[node - 1] += val

# 値の計算
queue = [(0, -1)]  # [(ノードID, 親ノードID)] のリスト (-1 は番兵)
while queue:
    node = queue[0]
    queue = queue[1:]

    for linked_node in links[node[0]]:
        if linked_node == node[1]:  # link が親ノード向けでなければ
            continue

        values[linked_node] += values[node[0]]
        queue.append((linked_node, node[0]))

print(*values)

### FIXED CODE ###

# -*- coding: utf-8 -*-
# https://atcoder.jp/contests/abc138/tasks/abc138_d


def main():
    n, q = map(int, input().split())
    values = [0] * n
    links = [[] for _ in range(n)]

    for _ in range(n - 1):
        a, b = map(int, input().split())
        links[a - 1].append(b - 1)
        links[b - 1].append(a - 1)

    for _ in range(q):
        p, x = map(int, input().split())
        values[p - 1] += x

    s = [(0, -1)]
    while s:
        i, p = s.pop()
        for j in links[i]:
            if j == p:
                continue
            values[j] += values[i]
            s.append((j, i))

    print(*values)


main()
### BUGGY CODE ###

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

c = [0] * n

for i in range(n):
    for j in range(i):
        if p[i] > p[j]:
            c[i] = 1
            break

print(c.count(0))

### FIXED CODE ###

n = int(input())
p = [int(i) for i in input().split()]
x = p[0]
ans = 0
for i in p:
    if x >= i:
        ans += 1
        x = i
print(ans)
### BUGGY CODE ###

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

from itertools import permutations, combinations,combinations_with_replacement,product
nCr = list(combinations(range(N), 3))

ret = 0
for i in nCr:
  if L[i[0]]<L[i[1]]+L[i[2]] and L[i[1]]<L[i[2]]+L[i[0]] and L[i[2]]<L[i[0]]+L[i[1]]:
    ret +=1
print(ret)

### FIXED CODE ###

from bisect import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()
ret = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        ret += bisect(L,L[i]+L[j]-1)-j-1
print(ret)
### BUGGY CODE ###

def main():
    import collections
    import sys
    sys.setrecursionlimit(10**5)
    N = int(input())
    a = list(map(int, input().split()))
    A = collections.Counter(a)
    dp = [[[-1]*(N+1) for i in range(N+1)] for j in range(N+1)]
    # for i in range(1, L+1):

    dp[0][0][0] = 0

    def solve(c1, c2, c3):
        if dp[c1][c2][c3] >= 0:
            return(dp[c1][c2][c3])
        else:
            P = 1
            if c1 > 0:
                P += solve(c1-1, c2, c3) * (c1/N)
            if c2 > 0:
                P += solve(c1+1, c2-1, c3)*(c2/N)
            if c3 > 0:
                P += solve(c1, c2+1, c3-1)*(c3/N)
            P /= (1 - (N-c1-c2-c3)/N)
            dp[c1][c2][c3] = P

            return(P)

    print(solve(A[1], A[2], A[3]))
main()


### FIXED CODE ###

def main():
    N = int(input())
    A = list(map(int, input().split()))
    a = A.count(1)
    b = A.count(2)
    c = A.count(3)
    floatN = N*1.0
    dp = [[[.0]*(N+1) for i in range(N+1)] for j in range(N+1)]

    for k in range(c+1):
        for j in range(b+c + 1 - k):
            for i in range(N + 1 - k - j):
                if i + j+k == 0:
                    continue
                dp[i][j][k] = floatN
                if i > 0:
                    dp[i][j][k] += dp[i-1][j][k] * i
                if j > 0:
                    dp[i][j][k] += dp[i+1][j-1][k] * j
                if k > 0:
                    dp[i][j][k] += dp[i][j+1][k-1] * k
                dp[i][j][k] /= (i+j+k)
    print(dp[a][b][c])


main()
### BUGGY CODE ###

N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
j=0
for i in range(M):
    A[A.index(max(A[:j+1]))]=A[A.index(max(A[:j+1]))]//2
    j=j+1
    if j==100:
        A.sort(reverse=True)    
        j=0
print(sum(A))

### FIXED CODE ###

import heapq
N,M=map(int,input().split())
A=list(map(lambda x: x*(-1),list(map(int,input().split()))))
A.sort()
B=[]
for i in range(N):
    heapq.heappush(B,A[i])
for i in range(M):
    heapq.heappush(B,(((heapq.heappop(B))*(-1))//2)*(-1))
print((sum(B))*(-1))
### BUGGY CODE ###

def main():
  n=int(input())
  s=tuple(input())
  r=[i for i, x in enumerate(s) if x == 'R']
  g=[i for i, x in enumerate(s) if x == 'G']
  rg=r+g
  b=[i for i in range(n) if not i in rg]
  R,G,B=len(r),len(g),len(b)
  ans=R*G*B
  for i in r:
    for j in g:
      ans+=-1 if (i+j)/2 in b else 0 
      ans+=-1 if ((i+j)+abs(i-j)*3)/2 in b else 0
      ans+=-1 if ((i+j)-abs(i-j)*3)/2 in b else 0
  print(ans)
if __name__=='__main__':
  main()

### FIXED CODE ###

def main():
  n=int(input())
  s=input()
  R,G,B=s.count('R'),s.count('G'),s.count('B')
  ans=R*G*B
  for i in range(n):
    for j in range(i+1,n):
      if 2*j-i>n-1:
        break
      if s[i]!=s[j] and s[j]!=s[2*j-i] and s[2*j-i]!=s[i]:
        ans-=1
  print(ans)
if __name__=='__main__':
  main()
### BUGGY CODE ###

import numpy as np
n, k, q = map(int, input().split())
points = []
minus = []
for i in range(n):
    points.append(k)
    minus.append(-1)
for i in range(q):
    a = int(input())
    points = np.array(points) + np.array(minus)
    points[a - 1] += 1
for point in points:
    if point > 0:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

import numpy as np
n, k, q = map(int, input().split())
points = np.full(n, k)
z = np.full(n, 0)
points = points - q
for i in range(q):
    a = int(input())
    z[a - 1] += 1
points = points + z
for point in points:
    if point > 0:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

# ABC117c
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
sa = [0]
for i in range(1, m):
    sa.append(x[i]-x[i-1])
# print(x)
# print(sa)
# print('aa')
sa.sort()
for _ in range(min(n-1, len(sa)-1)):
    sa = sa[:-1]
# print(sa)
print(sum(sa))

### FIXED CODE ###

def main():
    # ABC117c
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)

    n, m = map(int, input().split())
    x = list(map(int, input().split()))
    if(m == 1):
        print(0)
        exit(0)
    if(n >= m):
        print(0)
        exit(0)
    x.sort()
    sa = [0]
    for i in range(1, m):
        sa.append(x[i]-x[i-1])
    # print(x)
    # print(sa)
    # print('aa')
    sa.sort()
    # or _ in range(min(n-1, len(sa)-1)):
    #    sa = sa[:-1]
    # print(sa)
    print(sum(sa[:len(sa)-min(n-1, len(sa)-1)]))


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

# -*- coding: utf-8 -*-
import math
# 整数の入力
n = int(input())
s = 0
for i in range(1, n + 1):
    for j in range(1, n + 1):
        for k in range(1, n + 1):
            gcd = math.gcd(math.gcd(i, j),k)
            s += gcd
print(s)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import math
# 整数の入力
n = int(input())
s = 0
for i in range(1, n + 1):
    for j in range(i, n + 1):
        for k in range(j, n + 1):
            gcd = math.gcd(math.gcd(i, j),k)
            if i == j and j == k:
                s += gcd
            elif i == j or j == k or k ==i:
                s += gcd * 3
            else:
                s += gcd * 6
# for i in range(1, n + 1):
#     for j in range(1, n + 1):
#         for k in range(1, n + 1):
#             gcd = math.gcd(math.gcd(i, j),k)
#             s += gcd
print(s)
### BUGGY CODE ###

n = int(input())
A = sorted(map(int, input().split()))

U = 10**6
line = [1]*(U+1)
ans = set()
depricated = set()
for a in A:
    if a in ans:
        depricated.add(a)
    if line[a]:
        ans.add(a)
        for p in range(2*a, U+1, a):
            line[p] = 0
print(len(ans-depricated))


### FIXED CODE ###

n = int(input())
A = sorted(map(int, input().split()))
used = set()

U = A[-1]+1
is_prime = [1]*U
cnt = [0]*U
depri = 0
for a in A:
    cnt[a] += 1
    if cnt[a] == 2 and is_prime[a]:
        depri += 1
    if is_prime[a]:
        used.add(a)
        for q in range(2*a, U, a):
            is_prime[q] = 0
print(len(used)-depri)
### BUGGY CODE ###

n=int(input())
l=list(map(int,input().split()))
l.sort()
count=0
for i in range(n-2):
  for j in range(i+1,n-1):
    left=j+1
    right=n-1
    while left<=right:
      center=(right+left)//2
      if center==n-1:
        if l[i]+l[j]>l[center]:
          count+=center-j
        break
      elif l[center+1]>l[i]+l[j]>l[center] :
        count+=center-j
        break
      elif l[i]+l[j]>l[center]:
        left=center+1
      else:
        right=center-1
print(count)

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
l.sort()
l.reverse()
count=0
for i in range(n-2):
  j=i+1
  k=n-1
  while j<k:
    if l[i]<l[j]+l[k]:
      count+=k-j
      j+=1
    else:
      k-=1
print(count)
### BUGGY CODE ###

#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    gates={}
    s={}
    n,m = map(int,input().split())
    gates=[list(map(int,input().split())) for _ in range(m)]

    for gate in gates:
        if len(s)==0:
            s = set([i for i in range(gate[0],gate[1]+1)])
        else:
            s = s & set([i for i in range(gate[0],gate[1]+1)])
    print(len(s))

if __name__=="__main__":
    main()

### FIXED CODE ###

#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    gates=[]
    n,m = map(int,input().split())
    gates=[list(map(int,input().split())) for _ in range(m)]
    min_data=0
    max_data=10**5+1

    for gate in gates:
        if min_data < gate[0]:
            min_data=min(gate)
        if max_data > gate[1]:
            max_data=max(gate)
    print(len(list(range(min_data,max_data+1))))

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

N = int(input())
A = [int(x) for x in input().split()]
total_medians = N*(N+1)//2
# n件のデータ
# (上側中央値 >= x) iff (a > x となる a が(n-1)//2以下)

def BIT_update(BIT,x,value):
  # 番号xにvalueを加える
  L = len(BIT)
  while x < L:
    BIT[x] += value
    x += (x & (-x))
  return

def BIT_sum(BIT,x):
  # 番号1～xの和を求める
  result = 0
  while x:
    result += BIT[x]
    x -= (x & (-x))
  return result

def test(x):
  # 「答はx以下である」
  # 「xより真に大きな区間中央値が(total_medians-1)//2個以下」
  B = [0]
  for a in A:
    B.append(B[-1] + (1 if a > x else -1))
  m = min(B)-1
  BIT = [0]*(N+1)
  cnt = 0
  prev = 1
  for b in B[1:N+1]:
    b -= m
    BIT_update(BIT,prev,1)
    cnt += BIT_sum(BIT,b) # 右端がRとなる(L,R)対
    prev = b
    
  return cnt <= (total_medians-1)//2

AA = sorted(A)
left = -1 # 答はAA[left]より大きい
right = len(AA)-1 # 答はAA[right]以下である
while right - left > 1:
  mid = (left+right)//2
  if test(AA[mid]):
    right = mid
  else:
    left = mid
    
answer = AA[right]
print(answer)


### FIXED CODE ###

N = int(input())
A = [int(x) for x in input().split()]
total_medians = N*(N+1)//2
# n件のデータ
# (上側中央値 >= x) iff (a > x となる a が(n-1)//2以下)

def BIT_update(BIT,x,value):
  # 番号xにvalueを加える
  L = len(BIT)
  while x < L:
    BIT[x] += value
    bottom_bit = x & (-x)
    x += bottom_bit
  return

def BIT_sum(BIT,x):
  # 番号1～xの和を求める
  result = 0
  while x:
    result += BIT[x]
    bottom_bit = x & (-x)
    x -= bottom_bit
  return result

def test(x):
  # 「答はx以下である」
  # 「xより真に大きな区間中央値が(total_medians-1)//2個以下」
  B = [0]
  for a in A:
    B.append(B[-1] + (1 if a>x else -1))
  m = min(B)-1
  B = [x-m for x in B]

  BIT = [0]*(N+1)
  
  cnt = 0
  for R in range(1,N+1):
    BIT_update(BIT,B[R-1],1)
    cnt += BIT_sum(BIT,B[R]) # 右端がRとなる(L,R)対
  return cnt <= (total_medians-1)//2

AA = sorted(A)
left = -1 # 答はAA[left]より大きい
right = len(AA)-1 # 答はAA[right]以下である
while right - left > 1:
  mid = (left+right)//2
  if test(AA[mid]):
    right = mid
  else:
    left = mid
answer = AA[right]

print(answer)
### BUGGY CODE ###

N=int(input())

ans=0
for i in range(1,N+1):
    for j in range(1,N):
        if i <=j**2:
            break
        for k in range(1,N):
            if i <=j**2+k**2+j*k:
                break
            for l in range(1,N):
                if i <j**2+k**2+l**2+j*k+k*l+l*j:
                    break
                if l**2+j**2+k**2+l*j+j*k+k*l==i:
                    ans+=1
    print(ans)
    ans=0

### FIXED CODE ###

N=int(input())

ans=[0]*N

for i in range(1,int(N**0.5)):
    if i**2 >=N:
        break
    for j in range(1,int(N**0.5)):
            if i**2+j**2+i*j>=N:
                break
            for k in range(1,int(N**0.5)):
                    if i**2+j**2+k**2+i*j+j*k+k*i <=N:
                        ans[i**2+j**2+k**2+i*j+j*k+k*i-1] +=1

for i in range(N):
    print(ans[i])
### BUGGY CODE ###

N = int(input())
a = list(map(int, input().split()))
ans = 0

for k in set(a):
	ans = max(ans, a.count(k) + a.count(k + 1) + a.count(k - 1))
	ans = max(ans, a.count(k - 1) + a.count(k) + a.count(k - 2))
	ans = max(ans, a.count(k + 1) + a.count(k + 2) + a.count(k))

print(ans)


### FIXED CODE ###

from bisect import bisect_left, bisect_right

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

ans = 1
for i in range(N):
    X = a[i]
    res = bisect_right(a, X+1) - bisect_left(a, X-1)
    ans = max(res, ans)

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

N = int(input())

ai_char = map(str, input().split(" "))
Ai = []
for i in ai_char:
    Ai.append(int(i))

mod_val = 1000000007
N1 = N-1
sum = 0
for i in range(N1):
    sum_tmp = 0
    for j in range(i+1, N):
        sum_tmp += Ai[j]
    sum += Ai[i] * sum_tmp

    if sum > mod_val:
        sum = sum % mod_val


print(int(sum))

### FIXED CODE ###

N = int(input())

ai_char = map(str, input().split(" "))
Ai = []
for i in ai_char:
    Ai.append(int(i))

mod_val = 1000000007
N1 = N-1
sum = 0

sum_tmp = 0
for j in range(0, N):
    sum_tmp += Ai[j]

for i in range(N1):
    sum_tmp -= Ai[i]
    sum += Ai[i] * sum_tmp

    if sum > mod_val:
        sum = sum % mod_val


print(int(sum))
### BUGGY CODE ###

n = int(input())
a = list(map(int, [input() for _ in range(n)]))
ans = 0
for i in set(a):
  if a.count(i) % 2 == 1:
    ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
s = set()
for i in range(n):
  a = input()
  if a in s:
    s.remove(a)
  else:
    s.add(a)
print(len(s))
### BUGGY CODE ###

a=input().split(" ")

number1=int(a[0])
number2=int(a[1])
n1=0
n2=0

for i in range(number1+1):
    for j in range(number1+1):
        n1=number2-int(i)-int(j)
        if n1<=number1 and 0<=n1:
            n2=n2+1

print(n2)


### FIXED CODE ###

a=input().split(" ")

number1=int(a[0])
number2=int(a[1])
n1=0
n2=0

for i in range(number1+1):
    for j in range(number1+1):
        n1=number2-int(i)-int(j)
        if n1<=number1 and 0<=n1:
            n2=n2+1

print(n2)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
P = 10**9+7
ans = 0

for i in range(N):
    for j in range(i+1,N):
        ans += ((A[i]%P)*(A[j]%P))%P
print(ans%P)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
P = 10**9+7
ans = 0
S = sum(A)

for i in range(N):
    S -= A[i]
    ans += A[i]*S%P
print(ans%P)
### BUGGY CODE ###

from collections import deque


def main():
    S = input()
    LS = len(S)
    T = input()
    LT = len(T)
    # LCS
    dp = [[0 for _ in range(LT + 1)] for _ in range(LS + 1)]
    for s in range(LS):
        for t in range(LT):
            if S[s] == T[t]:
                dp[s + 1][t + 1] = 1 + dp[s][t]
            else:
                dp[s + 1][t + 1] = max([dp[s][t + 1], dp[s + 1][t]])
    # recover
    s, t = LS, LT
    que = deque()
    que.appendleft('')
    while s > 0 and t > 0:
        if dp[s][t] == dp[s - 1][t]:
            s -= 1
        elif dp[s][t] == dp[s][t - 1]:
            t -= 1
        else:
            que.appendleft(S[s - 1])
            s -= 1
            t -= 1
    print(''.join(list(que)))


if __name__ == '__main__':
    main()

### FIXED CODE ###

import numpy as np


def main():
    S = np.array(list(input()))
    LS = len(S)
    T = np.array(list(input()))
    LT = len(T)
    # LCS
    dp = np.zeros((LS + 1, LT + 1))
    match = S.reshape(-1, 1) == T.reshape(1, -1)
    for s in range(LS):
        dp[s + 1, 1:] = np.fmax(dp[s, :(-1)] + match[s], dp[s, 1:])
        dp[s + 1] = np.maximum.accumulate(dp[s + 1])
    # recover
    s, t = LS, LT
    ans = ''
    while s > 0 and t > 0:
        if dp[s, t] == dp[s - 1, t]:
            s -= 1
        elif dp[s, t] == dp[s, t - 1]:
            t -= 1
        else:
            ans = S[s - 1] + ans
            s -= 1
            t -= 1
    print(ans)


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

import sys
sys.setrecursionlimit(1000000)

def dfs(gr,li,n,fr):
    if(len(gr[n])==1 and gr[n][0]==fr):
        li[n].add(n)
        return set([n])
    else:
        ans = set([n])
        for i in gr[n]:
            if(i==fr):continue
            ans |= dfs(gr,li,i,n)
        li[n] |= ans
        return ans
#%%
N,Q = [int(x) for x in input().split()]
nlist = [set() for _ in range(N)]
gp = [[] for _ in range(N)]
for _ in range(N-1):
    a,b = [int(x) for x in input().split()]
    gp[a-1].append(b-1)
    gp[b-1].append(a-1)

qu = [[int(x) for x in input().split()]for _ in range(Q)]
#%%
li = [0]*N
dfs(gp,nlist,0,-1)
for p,x in qu:
    for j in nlist[p-1]:
        li[j] += x
print(*li)


### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    N,Q = [int(x) for x in input().split()]
    li = [0]*N
    gp = [[] for _ in range(N)]
    for _ in range(N-1):
        a,b = input().split()
        a = int(a)
        b = int(b)
        gp[a-1].append(b-1)
        gp[b-1].append(a-1)

    for _ in range(Q):
        p,x = input().split()
        li[int(p)-1] += int(x)

    st = []
    seen = set()
    st.append(0)
    while(st):
        x = st.pop()
        if(x in seen):continue
        seen.add(x)
        for i in gp[x]:
            if(i in seen):continue
            li[i]+=li[x]
            st.append(i)
    print(*li)

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

n = int(input())
pn = list(map(int, input().split()))
count = 0

for i in range(0, len(pn)):
    icount = 0
    for j in range(0, i):
        if pn[i] <= pn[j]:
            icount += 1
    if icount == i:
        count += 1

print(count)

### FIXED CODE ###

n = int(input())
pn = list(map(int, input().split()))
count = 1
min = pn[0]

for i in range(1,len(pn)):
    if min > pn[i - 1]: min = pn[i - 1]
    if min > pn[i]: count += 1
print(count)
### BUGGY CODE ###

H,N = map(int, input().split())
A = [0]*N
B = [0]*N
for i in range(N):
    A[i], B[i] = map(int, input().split())

dp = [0]*(H+max(A)+1)
dp[0] = 0
for i in range(1, H+max(A)+1):
    for j in range(N):
        t = max(0,i-A[j])
        if dp[i]==0:
            dp[i] = dp[t] + B[j]
        else:
            dp[i] = min(dp[i], dp[t]+B[j])

ans = dp[H]
for i in range(H, H+max(A)+1):
    ans = min(ans, dp[i])
print(ans)


### FIXED CODE ###

H,N = map(int, input().split())
A = [0]*N
B = [0]*N
for i in range(N):
    A[i], B[i] = map(int, input().split())

dp = [0]*(H+max(A)+1)
dp[0] = 0
for i in range(1, H+max(A)+1):
    for j in range(N):
        t = max(0,i-A[j])
        if dp[i]==0:
            dp[i] = dp[t] + B[j]
        else:
            dp[i] = min(dp[i], dp[t]+B[j])

ans = dp[H]
for i in range(H, H+max(A)+1):
    ans = min(ans, dp[i])
print(ans)
### BUGGY CODE ###

"""import bisect
lst=[i for i in range(100)]
lst.reverse()
print(bisect.bisect_left(lst,1))
exit()
"""
N=int(input())
A=[int(input()) for i in range(N)]
B=[0 for i in range(N)]
C=sorted(A)
count=0
lst=[]
lstm=0
for i in range(N):
    if A[i]==C[-1]:

        if not lst:
            C.pop()
            count+=1
            continue
    flag=1
    for l in range(len(lst)):
        if lst[l]<A[i]:
            lst[l]=A[i]
            flag=0
            break
    if flag:
        lst.append(A[i])
        count+=1
    #print(count,i,lst)
print(count)


### FIXED CODE ###

import bisect
import collections

N=int(input())
A=[int(input()) for i in range(N)]
B=[0 for i in range(N)]
C=sorted(A)
count=0
lst=collections.deque([])
for i in range(N):
    if A[i]==C[-1]:
        C.pop()
        if lst:
            lst.pop()
        else:
            count+=1
        continue
    idx=bisect.bisect_left(lst,A[i])-1
    #print(idx,lst,A[i])
    if idx<0:
        lst.appendleft(A[i])
        count+=1
    else:
        lst[idx]=A[i]

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

X,Y,Z,K = map(int,input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

C = sorted(C, reverse = True)

AB=[]

for i in range(X):
  for j in range(Y):
    AB.append(A[i]+B[j])
    
ans = []

ABl = len(AB)
for i in range(ABl):
  for j in range(min(K,Z)):
    ans.append(AB[i]+C[j])

ans = sorted(ans, reverse=True)

for i in range(K):
  print(ans[i])
      


### FIXED CODE ###

X,Y,Z,K = map(int,input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A = sorted(A, reverse = True)
B = sorted(B, reverse = True)
C = sorted(C, reverse = True)

ans = []

for i in range(min(K,X)):
  for j in range(min(K//(i+1),Y)):
    for k in range(min(K//(i+1)//(j+1),Z)):
      ans.append(A[i]+B[j]+C[k])
    
ans = sorted(ans, reverse=True)

for i in range(K):
  print(ans[i])
### BUGGY CODE ###

def main():
  import numpy as np
  import sys
  readline = sys.stdin.readline
  readlines = sys.stdin.readlines
  N,K = map(int,readline().split())
  A = np.array(readline().split(),np.int64)
  AA = np.cumsum(A)
  L = AA
  for i in range(N-1):
    AA = AA - A[i]
    L = np.concatenate([L,AA[i+1:]])
  ans = 0
  remains = []
  for i in range(40):
    bit = 1 << (39 - i)
    l = []
    cnt = 0
    for j in range(len(L)):
      if bit & L[j] == bit:
        cnt += 1
        l.append(L[j])
    if cnt >= K:
      ans += bit
      L = l
  print(ans)
main()

### FIXED CODE ###

N, K = map(int,input().split())
A = list(map(int,input().split()))
L = []
for i in range(N):
  for j in range(i+1,N+1):
    L.append(sum(A[i:j]))
L.sort(reverse=True)
ans = 0
remains = []
for i in range(40):
  bit = 1 << (39 - i)
  l = []
  cnt = 0
  #print(bit)
  for j in range(len(L)):
    if bit & L[j] == bit:
      cnt += 1
      l.append(L[j])
  if cnt >= K:
    ans += bit
    L = l
print(ans)