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



N = int(input())
E = []
A = [[-1 for j in range(N+1)] for i in range(N+1)]
edges = [[] for i in range(N+1)]
colors = [set() for i in range(N+1)]

for i in range(N-1):
  a, b = map(int, input().split())
  E.append((a,b))
  edges[a].append(b)
  edges[b].append(a)

def dfs(u):
  visited = set()
  visited.add(u)
  stack = [u]
  mcolor = -1

  while stack:
    u = stack.pop()
  
    for v in edges[u]:
      if v not in visited:
        c = colors[u] | colors[v]
        next = 1
        while next in c:
          next += 1
        
        mcolor = max(mcolor, next)
        A[u][v] = next
        A[v][u] = next
        colors[u].add(next)
        colors[v].add(next)
        visited.add(v)
        stack.append(v)
  
  return mcolor

print(dfs(1))

for edge in E:
  a, b = edge
  print(A[a][b])

### FIXED CODE ###


N = int(input())
edges = [[] for _ in range(N+1)]


for i in range(N-1):
  a, b = map(int, input().split())
  if i == 0:
    root = a
  edges[a].append((b, i))
  edges[b].append((a, i))

ans = [-1 for i in range(N-1)]
def dfs(u):
  flag = ["white"] * (N + 1)
  stack = [(u, -1, -1)]

  while stack:
    u, parent, color = stack.pop()
    flag[u] = "black"

    nextColor = 1
    for (next, index) in edges[u]:
      if next != parent and flag[next] != "black":
        if nextColor == color:
          nextColor += 1
        stack.append((next, u, nextColor))
        ans[index] = nextColor
        nextColor += 1

dfs(root)

print(max(ans))

for a in ans:
  print(a)
### BUGGY CODE ###

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

PRIME = 10 ** 9 + 7


def digitmod13(k, n):
    return (k * (10 ** n)) % 13


def main():
    S = input()
    N = len(S)
    dp = [[0 for _ in range(13)] for _ in range(N)]
    S = S[::-1]
    # init
    first = S[0]
    if first == '?':
        for k in range(10):
            dp[0][k] = 1
    else:
        first = int(first)
        dp[0][first] = 1
    for i in range(1, N):
        c = S[i]
        if c == '?':
            for d in range(13):
                for k in range(10):
                    dp[i][(d + digitmod13(k, i)) % 13] += dp[i - 1][d]
        else:
            c = int(c)
            for d in range(13):
                dp[i][(d + digitmod13(c, i)) % 13] += dp[i - 1][d]
        for d in range(13):
            dp[i][d] %= PRIME
    
    print(dp[N - 1][5] % PRIME)


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from functools import lru_cache

PRIME = 10 ** 9 + 7


@lru_cache(maxsize=None)
def digitmod13(y):
    if y == 0:
        return 1
    elif y == 1:
        return 10 % 13
    elif y % 2 == 0:
        return digitmod13(y // 2) ** 2 % 13
    else:
        return digitmod13(y // 2) ** 2 * 10 % 13


def main():
    S = input()
    N = len(S)
    dp = [[0 for _ in range(13)] for _ in range(N)]
    S = S[::-1]
    
    # init
    first = S[0]
    if first == '?':
        for k in range(10):
            dp[0][k] = 1
    else:
        first = int(first)
        dp[0][first] = 1
    
    # prepare table
    table = [[[(i + (j * k)) % 13 for k in range(13)] for j in range(10)] for i in range(13)]
    
    # dp
    for i in range(1, N):
        c = S[i]
        if c == '?':
            for d in range(13):
                for k in range(10):
                    mod = table[d][k][digitmod13(i)]
                    dp[i][mod] += dp[i - 1][d]
                    dp[i][mod] %= PRIME
        else:
            c = int(c)
            for d in range(13):
                mod = table[d][c][digitmod13(i)]
                dp[i][mod] += dp[i - 1][d]
                dp[i][mod] %= PRIME
    
    print(dp[N - 1][5] % PRIME)


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

from numba import jit


@jit
def main():
    INF = 10 ** 6
    H, W = list(map(int, input().split(' ')))
    A = [input() for _ in range(H)]
    d = [[INF for _ in range(W)] for _ in range(H)]
    # 距離テーブルの初期化
    for h in range(H):
        for w in range(W):
            if A[h][w] == '#':
                d[h][w] = 0
    # 黒マスまでの横方向の最短距離を出す
    for h in range(H):
        # 左から右方向へ探索
        for w in range(1, W):
            d[h][w] = min(d[h][w], 1 + d[h][w - 1])
        # 逆方向
        for w in range(W - 2, -1, -1):
            d[h][w] = min(d[h][w], 1 + d[h][w + 1])
    # 縦方向も同様に探索
    for w in range(W):
        for h in range(1, H):
            d[h][w] = min(d[h][w], 1 + d[h - 1][w])
        for h in range(H - 2, -1, -1):
            d[h][w] = min(d[h][w], 1 + d[h + 1][w])
    # 黒マスまでの最長距離が答え
    ans = 0
    for h in range(H):
        for w in range(W):
            ans = max(ans, d[h][w])
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    INF = 10 ** 6
    H, W = list(map(int, input().split(' ')))
    A = [input() for _ in range(H)]
    d = [[INF for _ in range(W)] for _ in range(H)]
    # 距離テーブルの初期化
    for h in range(H):
        for w in range(W):
            if A[h][w] == '#':
                d[h][w] = 0
    # 黒マスまでの横方向の最短距離を出す
    for h in range(H):
        # 左から右方向へ探索
        for w in range(1, W):
            d[h][w] = min(d[h][w], 1 + d[h][w - 1])
        # 逆方向
        for w in range(W - 2, -1, -1):
            d[h][w] = min(d[h][w], 1 + d[h][w + 1])
    # 縦方向も同様に探索
    for w in range(W):
        for h in range(1, H):
            d[h][w] = min(d[h][w], 1 + d[h - 1][w])
        for h in range(H - 2, -1, -1):
            d[h][w] = min(d[h][w], 1 + d[h + 1][w])
    # 黒マスまでの最長距離が答え
    ans = 0
    for h in range(H):
        for w in range(W):
            ans = max(ans, d[h][w])
    print(ans)


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

from collections import Counter

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

cs = []

counter = Counter()
for ci in c:
    counter.update([ci])
    c2 = Counter(counter)
    cs.append(c2)

memo = [[-1] * (N+1) for _ in range(N+1)]

for i in range(Q):
    l, r = map(int, input().split())

    if memo[l][r] != -1:
        print(memo[l][r])
    else:
        c3 = Counter(cs[r-1])
        if l > 1:
            c3.subtract(cs[l-2])
            c3 = +c3
        memo[l][r] = len(c3)
        print(memo[l][r])


### FIXED CODE ###

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n+1)

    def sum(self, i):  # sum in [0, i)
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):  # i > 0
        assert i > 0
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


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

lr = []
for i in range(Q):
    l, r = map(int, input().split())
    lr.append([l-1, r-1, i])

lr.sort(key=lambda x: x[1])

rightest = [-1] * (N + 1)
current_q = 0
bit = Bit(N)
ans = [0] * Q

for i in range(N):
    if rightest[c[i]] != -1:
        bit.add(rightest[c[i]]+1, -1)
    rightest[c[i]] = i
    bit.add(i+1, 1)

    while current_q < Q and lr[current_q][1] == i:
        ans[lr[current_q][2]] = bit.sum(lr[current_q][1] + 1) - bit.sum(lr[current_q][0])
        current_q += 1

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

s = input()
t = input()

LS = len(s)
LT = len(t)

dp = [[(0, '') for _ in range(LT + 1)] for _ in range(LS + 1)]
for i in range(1, LS + 1):
    for j in range(1, LT + 1):
        if s[i - 1] == t[j - 1]:
            dp[i][j] = (dp[i - 1][j - 1][0] + 1, dp[i - 1][j - 1][1] + s[i - 1])
        else:
            if dp[i - 1][j][0] < dp[i][j - 1][0]:
                dp[i][j] = dp[i][j - 1]
            else:
                dp[i][j] = dp[i - 1][j]

print(dp[LS][LT][1])


### FIXED CODE ###

s = input()
t = input()

ls = len(s)
lt = len(t)

dp = [[0 for _ in range(lt + 1)] for _ in range(ls + 1)]  # dp[ls][lt] = LCS_length

for i in range(ls):
    for j in range(lt):
        if s[i] == t[j]:
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1)
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j])
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1])

res = ''
i = ls
j = lt
while i > 0 and j > 0:
    if dp[i][j] == dp[i - 1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j - 1]:
        j -= 1
    else:
        res = s[i - 1] + res
        i -= 1
        j -= 1
print(res)
### BUGGY CODE ###

from copy import deepcopy


def solve(road, num, ans, n):
    pattern = 0
    test = deepcopy(road)
    if ans.count(str(num)) > 1:
        return 0
    if len(ans) is n:
        return 1
    if len(road[num - 1]) == int(0):
        return 0
    else:
        for i in range(len(road[num - 1])):
            tmp = test[num - 1][0]
            if tmp is not 0:
                word = ans + str(tmp)
            test[num - 1].pop(0)
            pattern += solve(test, tmp, word, n)
    return pattern


N, M = [int(i) for i in input().split()]
town = []
for i in range(N):
    town.append(deepcopy([]))

for i in range(M):
    a, b = [int(i) for i in input().split()]
    town[a - 1].append(b)
    town[b - 1].append(a)
print(solve(town, 1, '1', N))


### FIXED CODE ###

from copy import deepcopy


def solve(road, num, ans, n):
    pattern = 0
    test = deepcopy(road)
    for s in test:
        if num in s:
            s.remove(num)
    if len(ans) is n:
        return 1
    if len(test[num - 1]) == int(0):
        return 0
    else:
        for i in range(len(test[num - 1])):
            tmp = test[num - 1][i]
            if tmp is not 0:
                word = ans + str(tmp)
            pattern += solve(test, tmp, word, n)
    return pattern


N, M = [int(i) for i in input().split()]
town = []
for i in range(N):
    town.append(deepcopy([]))

for i in range(M):
    a, b = [int(i) for i in input().split()]
    if a is not 1 or b is not 1:
        town[a - 1].append(b)
        town[b - 1].append(a)
print(solve(town, 1, '1', N))
### BUGGY CODE ###

input_line = input().split(' ')
taka = int(input_line[0])
aoki = int(input_line[1])
numK = int(input_line[2])
 
for i in range(numK):
  if taka >= 1:
    taka -= 1
    continue
  elif aoki >= 1:
    aoki -= 1
    continue
  else:
    break
 
print(str(taka) + ' ' + str(aoki))

### FIXED CODE ###

input_line = input().split(' ')
taka = int(input_line[0])
aoki = int(input_line[1])
numK = int(input_line[2])
result = ""
if taka + aoki <= numK:
  result = "0 0"
elif taka >= numK:
  result = str(taka - numK) + " " + str(aoki)
elif taka + aoki > numK:
  result = "0 " + str(taka + aoki - numK)
  
print(result)
### BUGGY CODE ###

import sys

input = sys.stdin.readline

inf = float('inf')

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

es = []
for _ in range(N):
    s, t, x = map(int, input().split())
    es.append((s - x, 1, x))
    es.append((t - x, 0, x))

for _ in range(Q):
    es.append((int(input()), 2, -1))

es.sort(key=lambda x: (x[0], x[1]))
st = set()
cur_min_stop = inf
check_needed = True
d_cnt = 0
for i, (time, typ, pos) in enumerate(es):
    # print(es)
    # print(st)
    # print(i, (time, typ, pos))
    if typ == 1:
        st.add(pos)
        if pos < cur_min_stop:
            cur_min_stop = pos
    elif typ == 0:
        st.remove(pos)
        if pos == cur_min_stop:
            check_needed = True
    else:
        if check_needed:
            if st:
                cur_min_stop = min(st)
            else:
                cur_min_stop = inf
            check_needed = False
        print(cur_min_stop if cur_min_stop < inf else -1)
        d_cnt += 1
        if d_cnt == Q:
            break


### FIXED CODE ###

# 理解する時間がなかったので、とりあえず写経
from bisect import bisect_left
from operator import itemgetter

N, Q = [int(i) for i in input().split()]
Construction = [tuple(int(i) for i in input().split()) for j in range(N)]
D = [int(input()) for _ in range(Q)]

ans = [-1] * Q
skip = [-1] * Q

Construction.sort(key=itemgetter(2))

for s, t, x in Construction:
    l = bisect_left(D, s - x)
    r = bisect_left(D, t - x)
    t = l
    while t < r:
        if skip[t] == -1:
            ans[t] = x  # lからr-1の時刻に出発した人は座標xの工事に引っかかる
            skip[t] = r  # lからr-1の時刻に出発した人はもう調べないようにする
            t += 1
        else:
            t = skip[t]  # tが指定する人はもう調べ終わっているので飛ばす
print(*ans, sep='\n')
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline
N, Q = map(int,input().split())
graph = [[] for _ in range(N+1)]
point = [0] * (N+1)
for _ in range(N-1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)
for _ in range(Q):
    p, x = map(int, input().split())
    point[p] += x

# dfsをします。
def dfs(x, parent):
    point[x] += point[parent]
    for i in range(len(graph[x])):
        if graph[x][i] == parent:
            continue
        dfs(graph[x][i], x)
dfs(1, 0)
point_str = [str(n) for n in point]
ans = ' '.join(point_str[1:])
print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline
N, Q = map(int,input().split())
graph = [[] for _ in range(N+1)]
point = [0] * (N+1)
for _ in range(N-1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)
for _ in range(Q):
    p, x = map(int, input().split())
    point[p] += x

# dfsをします。
def dfs(x, parent):
    point[x] += point[parent]
    for i in range(len(graph[x])):
        if graph[x][i] == parent:
            continue
        dfs(graph[x][i], x)
dfs(1, 0)
point_str = [str(n) for n in point]
ans = ' '.join(point_str[1:])
print(ans)
### BUGGY CODE ###

n,m,p = map(int, input().split())
edge = []
ren = [set([i]) for i in range(n+1)]
for _ in range(m):
  a,b,c = map(int, input().split())
  edge.append((a,b,p-c))
dis = [float("inf")]*(n+1)
dis[1] = 0
t = []
for i in range(n):
  for a,b,c in edge:
    ren[b] |= ren[a]
    if dis[b] > dis[a] + c:
      dis[b] = dis[a] + c
      if i == n-1:
        t.append(b)
for v in t:
  if v in ren[n]:
    print(-1)
    break
else:
  print(max(0,-dis[n]))

### FIXED CODE ###

n,m,p = map(int, input().split())
edge = []
e1 = [list() for _ in range(n+1)]
for _ in range(m):
  a,b,c = map(int, input().split())
  edge.append((a,b,p-c))
  e1[a].append(b)
dis = [float("inf")]*(n+1)
dis[1] = 0
t = []
for i in range(n):
  for a,b,c in edge:
    if dis[b] > dis[a] + c:
      dis[b] = dis[a] + c
      if i == n-1:
        t.append(b)
s = set(t)
while t:
  v = t.pop()
  for x in e1[v]:
    if x == n:
      print(-1)
      exit(0)
    if x in s:
      continue
    s.add(x)
    t.append(x)
print(max(0,-dis[n]))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,K=map(int,input().split())
    N+=2
    H=[0]+list(map(int,input().split()))+[0]
    edge=[[] for _ in range(N*(K+1))]
    for i in range(N):
        for j in range(K+1):
            for k in range(K+1-j):
                if i+k+1<N and N-1-i>=K-(k+j):
                    edge[i*(K+1)+j].append((max(H[i+k+1]-H[i],0),(i+k+1)*(K+1)+j+k))
    from heapq import heappop,heappush
    def dijkstra(start,n,edges):
        d=[INF]*n
        used=[False]*n
        d[start]=0
        used[start]=True
        edgelist=[]
        for edge in edges[start]:
            heappush(edgelist,edge)
        while edgelist:
            minedge=heappop(edgelist)
            if used[minedge[1]]:
                continue
            v=minedge[1]
            d[v]=minedge[0]
            used[v]=True
            for edge in edges[v]:
                if not used[edge[1]]:
                    heappush(edgelist,(edge[0]+d[v],edge[1]))
        return d
    d=dijkstra(0,N*(K+1),edge)
    print(min(d[(N-1)*(K+1):]))

if __name__ == '__main__':
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,K=map(int,input().split())
    N+=1
    H=[0]+list(map(int,input().split()))+[0]
    dp=[[INF]*(K+1) for _ in range(N+1)]
    dp[0][0]=0
    for i in range(N):
        for j in range(K+1):
            for k in range(j,K+1):
                if i-(k-j)>=0:
                    dp[i+1][k]=min(dp[i+1][k],dp[i-(k-j)][j]+max(H[i+1]-H[i-(k-j)],0))
                    pass
    print(dp[-1][-1])

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

N=int(input())
A= list(map(int,input().split()))
for i in range(1,N+1):
    print(A.count(i))


### FIXED CODE ###

N=int(input())
A= list(map(int,input().split()))
L = [0]*(N+1)
for i in A:
    L[i]+=1
for i in L[1:]:
    print(i)
### BUGGY CODE ###

from sys import stdin
import math
import itertools


def makeIntMatrix(lines):
    intMatrix = []
    for a in makeStringMatrix(lines):
        intMatrix.append([int(b) for b in a])
    return intMatrix
 
 
def makeStringMatrix(lines):
    stringMatrix = [line.split() for line in lines]
    return stringMatrix
 
 
def makeInt(line):
    return int(line.rstrip())
 
 
def makeMultiInteger(line):
    return [int(x) for x in line.rstrip().split()]

from bisect import bisect_left
def find_lt(a, x):
    'Find rightmost value less than x'
    i = bisect_left(a, x)
    if i:
        return i
    else:
        return 0

def solve(input_string):
    N, M = makeMultiInteger(input_string[0])
    A = makeMultiInteger(input_string[1])
    S = makeIntMatrix(input_string[2:])
    cards = sorted(A)
    """
    cards_d = {}
    for card in cards:
        if not in cards_d:
            cards_d[card] = 1
        else:
            cards_d[card] += 1
    """
    """
    S = sorted(_S, key=lambda x: x[1])
    i = 1
    while(i < len(S)):
        b = S[i][0]
        c = S[i][1]
        if S[i-1][1] == c:
            S[i-1][0] += b
            S.pop(i)
            i -= 1
        i += 1
    #print(S)
    """

    for s in S:
        b = s[0]
        c = s[1]
        if c > cards[0]:
            for i in range(b):
                if c > cards[i]:
                    cards[i] = c
                else:
                    break
            part_cards = cards[b:]
            s_l = find_lt(part_cards, cards[0])
            if s_l != 0:
                cards = part_cards[:s_l] + cards[0:b] + part_cards[s_l:]
        """
        else:
            break
        """
    #print(cards)
    return sum(cards)
    #else:
    #    return len(ra)



def main():
    input_lines = stdin.readlines()
    answer = solve(input_lines)
    print(answer)


if __name__ == '__main__':
    main()


### FIXED CODE ###

# from sys import exit
N, M = [int(n) for n in input().split()]
# N = int(input())
a = [(int(n), 1) for n in input().split()]
B = [0 for _ in range(M)]
C = [0 for _ in range(M)]
for i in range(M):
    B[i], C[i] = [int(n) for n in input().split()]
    a.append((C[i], B[i]))

a = sorted(a, key=lambda x: -x[0])
i = 0
ans = 0
# print(a)
while(N != 0):
    num = min(N, a[i][1])
    ans += num*a[i][0]
    # print(num*a[i][0])
    N -= num
    i += 1

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

print(sum([i for i in range(int(input()))]))

### FIXED CODE ###

N = int(input())
print(N*(N-1)//2)
### BUGGY CODE ###


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

Con = 10**18

ans = 1
for i in A:
    ans*=i


print(ans if ans<=Con else "-1")

### FIXED CODE ###

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

Con = 10**18

ans = 1
if A.__contains__(0):
    print(0)
else:
    for i in A:
        if ans <=Con:
            ans*=i
        else:
            break
    print(ans if ans<=Con else "-1")
### BUGGY CODE ###

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

def main():
    N = int(input())
    P = list(map(float, input().split()))

    dp = [0.0]*(N+1)
    dp[0] = 1.0
    for i in range(N):
        dp_ = [0.0]*(N+1)
        for j in range(i+1,-1,-1):
            dp_[j]+=dp[j-1]*P[i]
            dp_[j-1]+=dp[j-1]*(1-P[i])
        dp=dp_.copy()
    print(sum(dp[N//2+1:]))

if __name__ == '__main__':
    main()

### FIXED CODE ###

N = int(input())
P = list(map(float, input().split()))
import numpy as np
def prob_ret():
  prob = [0.0]*(N+1)
  prob[0] = 1
  prob=np.array(prob)
  for n in range(N):
    p = prob[:N]*P[n]
    prob = prob * (1-P[n])
    prob[1:] = prob[1:] + p
  return sum(prob[N//2+1:])
print(prob_ret())
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
INF=10**9+7
md=len(bin(max(a)))-2
ans=0
for i in range(md):
  cnt1=sum([1 for j in a if (j>>i)&1])
  ans+=cnt1*(n-cnt1)*(1<<i)
  ans%=INF
print(ans%INF)


### FIXED CODE ###

import numpy as np
n=int(input())
a=np.array([int(i) for i in input().split()])
mod=int(1e9+7)
ans=0
for k in range(60):
  b=(a>>k)&1
  m=np.count_nonzero(b)
  ans+=m*(n-m)*2**k
  ans%=mod
print(ans)
### BUGGY CODE ###

H = list(input())
N = [1]*len(H)
T = N[:]
J0 = [2]*len(H)
J1 = [3]*len(H)
k=0
while True:
    k+=1

    if(J0==J1):break

    for i,para in enumerate(H):
        if(N[i]!=0):
            if(para=="R"):
                T[i+1]+=N[i]
            else:
                T[i-1]+=N[i]
            T[i]-=N[i]
    N=T[:]
    if(k%2==0):
        J1=J0[:]
        J0=N[:]

for para in N:
    print(para, end=" ")



### FIXED CODE ###

H = list(input())
N = [0]*len(H)

Lflag=0
Rcnt=0
Lcnt=0
cnt=0
for i in range(1,len(H)+1):
    if((H[i-1]=="L") & (Lflag==0)):
        Lflag=1
        Rcnt=i-1
        Lcnt=i
    if((H[i-1]=="R") & (Lflag==1)):
        if((i-1-cnt)%2==0):
            N[Rcnt-1]=int(((i-1)-cnt)/2)
            N[Lcnt-1]=int(((i-1)-cnt)/2)

        else:
            if(Rcnt%2==(i-1)%2):
                N[Rcnt-1]=int(((i-1)-cnt)/2+1)
                N[Lcnt-1]=int(((i-1)-cnt)/2)
            else:
                N[Rcnt-1]=int(((i-1)-cnt)/2)
                N[Lcnt-1]=int(((i-1)-cnt)/2+1)
        cnt=i-1
        Lflag=0

if((len(H)-cnt)%2==0):
    N[Rcnt-1]=int((len(H)-cnt)/2)
    N[Lcnt-1]=int((len(H)-cnt)/2)

else:
    if(Rcnt%2==len(H)%2):
        N[Rcnt-1]=int((len(H)-cnt)/2+1)
        N[Lcnt-1]=int((len(H)-cnt)/2)
    else:
        N[Rcnt-1]=int((len(H)-cnt)/2)
        N[Lcnt-1]=int((len(H)-cnt)/2+1)
    
for para in N:
    print(para, end=" ")
### BUGGY CODE ###


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

beautifuls = []
for i in range(0, len(a)):
    for j in range(i+1, len(a)+1):
        beautiful = sum(a[i:j])
        beautifuls.append(beautiful)

x_ = 0
t = 40
count = 0
while 1:
    for i in range(len(beautifuls)):
        if eval(str(bin((x_ + 2**(t-1)) & beautifuls[i]))) == x_+ 2**(t-1):
            count += 1
            if count == K:
                x_ += 2**(t-1)
                t = 40
                break
    count = 0
    t -= 1
    if t == 0:
        break

print(x_)


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
a = LIST()

l = []

for i in range(1, N+1):
	tmp = sum(a[:i])
	for j in range(N-i+1):
		l.append(tmp)
		tmp -= a[j]
		if j+i <= N-1:
			tmp += a[j+i]

ans = 0
for i in range(max(l).bit_length()-1, -1, -1):
	nextl = []
	for x in l:
		if (x>>i)&1:
			nextl.append(x)
	if len(nextl) >= K:
		ans += 1<<i
		l = nextl
print(ans)