Harryxun/stf_run huggingface dataset:
N = int(input())
T = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    T[a].append(b)
    T[b].append(a)


colors = [-1] * N
stack = [(0, 0)]
while stack:
    n, color = stack.pop()
    colors[n] = color
    for to in T[n]:
        if colors[to] != -1:
            continue
        stack.append((to, color ^ 1))


# あまり１、あまり２、あまり０になるように並び替え
X = [[] for _ in range(3)]
for n in range(1, N + 1):
    X[n % 3].append(n)
X.append(X[0])
del X[0]


ans = []
x12, x3 = X[0] + X[1], X[2]
if colors.count(0) <= N // 3:
    for color in colors:
        if color == 0:
            ans.append(x3.pop())
        elif x12:
            ans.append(x12.pop())
        else:
            ans.append(x3.pop())

elif colors.count(1) <= N // 3:
    for color in colors:
        if color == 1:
            ans.append(x3.pop())
        elif x12:
            ans.append(x12.pop())
        else:
            ans.append(x3.pop())

else:
    for color in colors:
        if X[color]:
            ans.append(X[color ^ 1].pop())
        else:
            ans.append(X[2].pop())

print(' '.join(map(str, ans)))


### FIXED CODE ###

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


colors = [-1] * N
stack = [(0, 0)]
while stack:
    n, color = stack.pop()
    colors[n] = color
    for to in T[n]:
        if colors[to] != -1:
            continue
        stack.append((to, color ^ 1))


# あまり１、あまり２、あまり０になるように並び替え
X = [[] for _ in range(3)]
for n in range(1, N + 1):
    X[n % 3].append(n)
X.append(X[0])
del X[0]


ans = []
x12, x3 = X[0] + X[1], X[2]
if colors.count(0) <= N // 3:
    for color in colors:
        if color == 0:
            ans.append(x3.pop())
        elif x12:
            ans.append(x12.pop())
        else:
            ans.append(x3.pop())

elif colors.count(1) <= N // 3:
    for color in colors:
        if color == 1:
            ans.append(x3.pop())
        elif x12:
            ans.append(x12.pop())
        else:
            ans.append(x3.pop())

else:
    for color in colors:
        if X[color]:
            ans.append(X[color].pop())
        else:
            ans.append(X[2].pop())

print(' '.join(map(str, ans)))
import numpy as np
from operator import itemgetter

N, M = input().split()
N, M = int(N), int(M)
C = [input().split() for i in range(M)]

for i, c in enumerate(C):
  C[i] = [int(c[0]), int(c[1])]
  C[i].append(i)

C_sorted = sorted(C, key = lambda x: (x[0], x[1]))

counter = 1
current = 1

for c in C_sorted:
  if current < c[0]:
    counter = 1
  pref = str(c[0])
  num = str(counter)
  number = ''
  for i in range(6 - len(pref)):
    number += '0'
  number += pref
  for i in range(6 - len(num)):
    number += '0'
  number += num

  c.append(number)
  counter += 1
  current = c[0]

C_reversed = sorted(C_sorted, key = lambda x: x[2])

for c in C_reversed:
  print(c[3])

### FIXED CODE ###

X, Y = input().split()
X, Y = int(X), int(Y)

print(int(X + Y/2))
N = int(input())
ls = []
for i in range(N):
  x,y,h = map(int, input().split())
  ls += [(h,x,y)]
ls.sort(key=lambda x:x[2])
px, py, ph = ls[-1]

ans = []
for i in range(101):
  for j in range(101):
    pH = ph+abs(px-i)+abs(py-j)
    for l in ls:
      h, x, y = l
      u = max(pH - abs(x-i) - abs(y-j), 0)
      if not u==h:
        break
    else:
      ans = (i,j,pH)
      flag = True
      break
  if flag:
    break
print(*ans)

### FIXED CODE ###

N = int(input())
ls = []
for i in range(N):
  x,y,h = map(int, input().split())
  ls += [(x,y,h)]
ls.sort(key=lambda x:x[2])
px, py, ph = ls[-1]

ans = []
flag = False
for i in range(101):
  for j in range(101):
    H = ph+abs(px-i)+abs(py-j)
    for l in ls:
      x, y, h = l
      u = max(H - abs(x-i) - abs(y-j), 0)
      if not u==h:
        break
    else:
      ans = (i,j,H)
      flag = True
      break
  if flag:
    break
print(*ans)
import sys

N = int(input())

mylist = list(input().split())

for i in range(N-1):
     
    if int(mylist[i+1]) >= int(mylist[i])-1 :
        continue

    else:
        print('No')
        sye.exit()


print('Yes')

### FIXED CODE ###

import numpy as np

N = int(input())
H = np.array(list(map(int, input().split())))
H[0] -= 1
for i in range(0, N - 1):
    diff = H[i + 1] - H[i]
    if diff >= 1:
        H[i + 1] -= 1
    elif diff < 0:
        print("No")
        exit()
print("Yes")
A. op, B = input().split()
print(A + B if op == "+" else A - B)

### FIXED CODE ###

A, op, B = input().split()
print(int(A) + int(B) if op == "+" else int(A) - int(B))
s = input()

while len(s) > 0:
  if s == "":
    print('YES')
    break
  s.replace('dreamer','')
  s.replace('eraser','')
  s.replace('dream','')
  s.replace('erase'v)
  
print('NO')
      

### FIXED CODE ###

s = input()

while True:
  if s == "":
    print('YES')
    break
  elif s[-7:] == 'dreamer':
    s = s[:-7]
  elif s[-6:] == 'eraser':
    s = s[:-6]
  elif s[-5:] == 'dream' or s[-5:] == 'erase':
    s = s[:-5]
  else:
    print('NO')
    break
import sys
from operator import itemgetter

sys.setrecursionlimit(200000)


def dfs(u, prev):
    global post_order, pre_order

    pre_order.append((u, prev))
    for w, t in edges[u]:
        if t != prev:
            dfs(t, u)
    post_order.append(u)


n = int(input())
edges = [set() for _ in range(n)]

for _ in range(n - 1):
    s, t, w = map(int, input().split())
    edges[s].add((w, t))
    edges[t].add((w, s))

post_order, pre_order = [], []
farthest = [{} for _ in range(n)]
height = [0] * n

dfs(0, None)

for i in post_order:
    for w, t in edges[i]:
        farthest[i][t] = w + max((d for tt, d in farthest[t].items() if tt != i), default=0)
for i, parent in pre_order:
    sorted_farthest = sorted(farthest[i].items(), key=itemgetter(1))
    max_t, max_d = sorted_farthest.pop()
    height[i] = max_d
    for w, t in edges[i]:
        if t == parent:
            continue
        farthest[t][i] = w + ((max_d if t != max_t else sorted_farthest[-1][1]) if sorted_farthest else 0)
for h in height:
    print(h)

### FIXED CODE ###

import sys
from operator import itemgetter

sys.setrecursionlimit(200000)


def dfs(u, prev):
    global post_order, pre_order

    pre_order.append((u, prev))
    for w, t in edges[u]:
        if t != prev:
            dfs(t, u)
    post_order.append(u)


n = int(input())
edges = [set() for _ in range(n)]

for _ in range(n - 1):
    s, t, w = map(int, input().split())
    edges[s].add((w, t))
    edges[t].add((w, s))

post_order, pre_order = [], []
farthest = [{} for _ in range(n)]
height = [0] * n

if n > 1:
    dfs(0, None)

for i in post_order:
    for w, t in edges[i]:
        farthest[i][t] = w + max((d for tt, d in farthest[t].items() if tt != i), default=0)
for i, parent in pre_order:
    sorted_farthest = sorted(farthest[i].items(), key=itemgetter(1))
    max_t, max_d = sorted_farthest.pop()
    height[i] = max_d
    for w, t in edges[i]:
        if t == parent:
            continue
        farthest[t][i] = w + ((max_d if t != max_t else sorted_farthest[-1][1]) if sorted_farthest else 0)
for h in height:
    print(h)
a=input()
print(a+1)

### FIXED CODE ###

a=input()
if a=="a":
  print("b")
if a=="b":
  print("c")
if a=="c":
  print("d")
if a=="d":
  print("e")
if a=="e":
  print("f")
if a=="f":
  print("g")
if a=="g":
  print("h")
if a=="h":
  print("i")
if a=="i":
  print("j")
if a=="j":
  print("k")
if a=="k":
  print("l")
if a=="l":
  print("m")
if a=="m":
  print("n")
if a=="n":
  print("o")
if a=="o":
  print("p")
if a=="p":
  print("q")
if a=="q":
  print("r")
if a=="r":
  print("s")
if a=="s":
  print("t")
if a=="t":
  print("u")
if a=="u":
  print("v")
if a=="v":
  print("w")
if a=="w":
  print("x")
if a=="x":
  print("y")
if a=="y":
  print("z")
import fraction

li = [int(i) for i in input().split(" ")]
res = (li[0] // fraction.gcd(li[0], li[1]) -1) * 3 * fraction.gcd(li[0], li[1])
print(res)

### FIXED CODE ###

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

li = [int(i) for i in input().split(" ")]
res = (li[0] // gcd(li[0], li[1]) -1) * 3 * gcd(li[0], li[1])
print(res)
a,b,k = map(int, input().split())
list = []
for i in range(a, b+1):
    list.append(i)
revList = sorted(list, reverse=True)
ans = []
for i in range(k):
    print(list[i])
for i in range(k):
    print(list[-k+i])

### FIXED CODE ###

a,b,k=map(int,input().split())
r=range(a,b+1)
for i in sorted(set(r[:k])|set(r[-k:])):print(i)
n,k=map(int,input().split())
x=list(map(int,input().split()))
for i in range(n-k+1):
    if i==0:
        a=min(abs(x[i])+abs(x[i]-x[i+k-1]),abs(x[i+k-1])+abs(x[i]-x[i+k-1]))
    else:
        a=min(ans,min(abs(x[i])+abs(x[i]-x[i+k-1]),abs(x[i+k-1])+abs(x[i]-x[i+k-1])))
print(a)

### FIXED CODE ###

n,k=map(int,input().split())
x=list(map(int,input().split()))
for i in range(n-k+1):
    if i==0:
        a=min(abs(x[i])+abs(x[i]-x[i+k-1]),abs(x[i+k-1])+abs(x[i]-x[i+k-1]))
    else:
        a=min(a,min(abs(x[i])+abs(x[i]-x[i+k-1]),abs(x[i+k-1])+abs(x[i]-x[i+k-1])))
print(a)
def main():
    from itertools import combinations
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    cc = combinations(range(n), (n-1)//2+1)
    m = -1
    for c in cc:
        memo1 = []
        memo2 = []
        for i in c:
            if i % 2 == 0:
                memo1.append((a[i], i))
            else:
                memo1.append((b[i], i))
        for i in set(range(n))-set(c):
            if i % 2 == 1:
                memo2.append((a[i], i))
            else:
                memo2.append((b[i], i))
        memo1.sort()
        memo2.sort()
        memo = []
        for i in range(n//2):
            memo.append(memo1[i])
            memo.append(memo2[i])
        if n % 2 == 1:
            memo.append(memo1[i+1])
        flag = 0
        for i in range(n-1):
            if memo[i][0] > memo[i+1][0]:
                flag = 1
                break
        if flag == 1:
            continue
        memo = [i for j, i in memo]
        cnt = 0
        for i in range(n-1):
            for j in range(i+1, n):
                if a[i] > a[j]:
                    cnt += 1
        m = max(cnt, m)
    print(m)


main()


### FIXED CODE ###

def main():
    from itertools import combinations
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    cc = combinations(range(n), (n-1)//2+1)
    m = 10**9
    if n == 1:
        print(0)
        return
    for c in cc:
        memo1 = []
        memo2 = []
        for i in c:
            if i % 2 == 0:
                memo1.append((a[i], i))
            else:
                memo1.append((b[i], i))
        for i in set(range(n))-set(c):
            if i % 2 == 1:
                memo2.append((a[i], i))
            else:
                memo2.append((b[i], i))
        memo1.sort()
        memo2.sort()
        memo = []
        for i in range(n//2):
            memo.append(memo1[i])
            memo.append(memo2[i])
        if n % 2 == 1:
            memo.append(memo1[i+1])
        flag = 0
        for i in range(n-1):
            if memo[i][0] > memo[i+1][0]:
                flag = 1
                break
        if flag == 1:
            continue
        memo = [i for j, i in memo]
        cnt = 0
        for i in range(n-1):
            for j in range(i+1, n):
                if memo[i] > memo[j]:
                    cnt += 1
        m = min(cnt, m)
    if m == 10**9:
        print(-1)
    else:
        print(m)


main()
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd

MOD = 1000000007  # type: int

def solve(N: int, K: int):
    ns = []
    for i in range(1, N):
        if N < i * i:
            break
        ns.append(i)
        ns.append(N // i)
    ns = sorted(list(set(ns)))

    m = {n: i for i, n in enumerate(ns)}
    l = [1] * len(ns)
    for i, (s, b) in enumerate(zip(ns, ns[1:])):
        l[i] = (N // s) - (N // b)
    l[len(ns) - 1] = 1

    dp = [[0] * len(ns) for _ in range(K+1)]
    dp[0][m[N]] = 1

    for i in range(K):
        for j in range(len(ns) - 2, -1, -1):
            dp[i][j] += dp[i][j + 1]
        for j, nn in enumerate(ns):
            nj = m[N // nn]
            dp[i+1][j] = (dp[i+1][j] + dp[i][nj] * l[j]) % MOD

    return sum(dp[-1]) % MOD


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    result = solve(N, K)
    print(result)

if __name__ == '__main__':
    main()

### FIXED CODE ###

#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd

MOD = 1000000007  # type: int

def solve(N: int, K: int):
    ns = []
    for i in range(1, N + 1):
        if N < i * i:
            break
        ns.append(i)
        ns.append(N // i)
    ns = sorted(list(set(ns)))

    m = {n: i for i, n in enumerate(ns)}
    l = [1] * len(ns)
    for i, (s, b) in enumerate(zip(ns, ns[1:])):
        l[i] = (N // s) - (N // b)

    dp = [[0] * len(ns) for _ in range(K+1)]
    dp[0][m[N]] = 1

    for i in range(K):
        for j in range(len(ns) - 2, -1, -1):
            dp[i][j] += dp[i][j + 1]
        for j, nn in enumerate(ns):
            nj = m[N // nn]
            dp[i+1][j] = (dp[i+1][j] + dp[i][nj] * l[j]) % MOD

    return sum(dp[-1]) % MOD


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    result = solve(N, K)
    print(result)

if __name__ == '__main__':
    main()
while 1:
    n,x = map(int,input().split())
    count == 0
    if n == 0 and x == 0:
        break

    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i + j + k == x:
                    count += 1
    print(count)

### FIXED CODE ###

while 1:
    n,x = map(int,input().split())
    count = 0
    if n == 0 and x == 0:
        break

    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i + j + k == x:
                    count += 1
    print(count)
a,b = map(int,input().split())
print("GREATER" if a > b else "LESS" a < b else "EQUAL")

### FIXED CODE ###

a = int(input())
b = int(input())
print("GREATER" if a > b else "LESS" if a < b else "EQUAL")
a, b = map(int, input().split())
if a * b % 2 == 1:
    print(Odd)
else:
    print(Even)

### FIXED CODE ###

a, b = map(int, input().split())
if a * b % 2 == 1:
    print("Odd")
else:
    print("Even")
#abc058 b
o=input()
e=input()
ans=""
for i in range(len(o)):
        ans+=o[i]
        ans+=e[i]
print(ans)

### FIXED CODE ###

#abc058 b
o=input()
e=input()
ans=""
for i in range(len(e)):
        ans+=o[i]
        ans+=e[i]
if len(o)-len(e)==1:
    ans+=o[-1]
print(ans)
a,b=(x for x in input().split()) 
t=len(a)
aa=[]
bb=[]
for i in range(t):
  aa.append(a[i])
  bb.append(b[i])
 
if(aa==bb):
  print("Yes)
else:
	print("No")

### FIXED CODE ###


#a,b=(int(x) for x in input().split()) #数値の時




#a,b=(x for x in input().split()) 
a=input()
print("\n")
b=input()
t=len(a)
aa=[]
bb=[]
for i in range(t):
    aa.append(a[i])
    bb.append(b[i])
 
if(aa==bb):
  print("Yes")
else:
	print("No")
import numpy as np

s = [ord(a)-ord('a') for a in input()]
n = len(s)

if n == 2:
    if s[0] == s[1]:
        print('1 2')
    else
        print('-1 -1')
    exit()

cnt = np.array([0] * 26)
cum = [cnt.copy()]

for i, a in enumerate(s):
    cnt[a] += 1
    cum.append(cnt.copy())

def is_check(cum, n):
    i = 3
    d = 1
    for j in range(n-i+1):
        for k in cum[j+i] - cum[j]:
            if k > d:
                return j+1, j+i
    return -1, -1

print(' '.join(map(str, is_check(cum, len(s)))))

### FIXED CODE ###

import numpy as np

s = [ord(a)-ord('a') for a in input()]
n = len(s)

if n == 2:
    if s[0] == s[1]:
        print('1 2')
    else:
        print('-1 -1')
    exit()

cnt = np.array([0] * 26)
cum = [cnt.copy()]

for i, a in enumerate(s):
    cnt[a] += 1
    cum.append(cnt.copy())

def is_check(cum, n):
    i = 3
    d = 1
    for j in range(n-i+1):
        cum_ = cum[j+i] - cum[j]
        if cum_[cum_>1]:
            return j+1, j+i
    return -1, -1

print(' '.join(map(str, is_check(cum, len(s)))))
from collections import Counter

n = int(input())
blue = Counter(input() for _ in range(n))
m = int(input())
red = Counter(input() for _ in range(m))
c = (blue - red).most_common(1)

print(max(c[0][1], 0))

### FIXED CODE ###

from collections import Counter

n = int(input())
blue = Counter(input() for _ in range(n))
m = int(input())
red = Counter(input() for _ in range(m))
c = (blue - red).most_common(1)

if c:
  print(max(c[0][1], 0))
else:
  print(0)
import copy
import sys
sys.setrecursionlimit(10**7)

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def lcm(a, b):
    return (a // gcd(a, b)) * b

def main():
    n, m = map(int, input().split())
    # これだと72がREになる
    A = [int(x) for x in input().split()]
    # A_s = set(A)
    # これだと74も78もREになる
    # A = [int(x) for x in input().split()]
    # A_ = copy.deepcopy(A)
    # a_lcm = A.pop()
    a_lcm = 1
    # Aの要素が複数ならlcmを計算する
    #if len(A) >= 1:
    for a in A:
        a_lcm = lcm(a_lcm, a)
    #else:
    #    a_lcm = a_lcm
    # 元のAの値とlcmの半分の値を割り切れるものがあったら0
    #for i in A_:
    for i in A:
        if (a_lcm / 2) % i == 0:
        # if (a_lcm / i) % 2 == 0: 
            print(0)
            exit()
        # else:
        #     continue
    # mがlcmの半分よりも小さかったら0
    if (a_lcm / 2) > m:
    # if a_lcm > m * 2:
        print(0)
        exit()
    else:
        # # あとは定数倍の数調べて終わり
        ans = int((m - (a_lcm / 2)) // a_lcm) + 1
        print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import copy
# from math import gcd


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def lcm(a, b):
    return (a // gcd(a, b)) * b
def main():
    n, m = map(int, input().split())
    A = set([int(x) for x in input().split()])
    a_lcm = 1
    for a in A:
        a_lcm = lcm(a_lcm, a)
        # mがlcmの半分よりも小さかったら0
        if (a_lcm / 2) > m:
            print(0)
            exit()
    for a in A:
        if (a_lcm / 2) % a == 0:
            print(0)
            exit()
    # # あとは定数倍の数調べて終わり
    ans = int((m - (a_lcm / 2)) // a_lcm) + 1
    print(ans)

if __name__ == '__main__':
    main()
s, t = map(str, input().split())
a, b = map(int, input().split())
u = str(input())

if u = s:
  print(a-1, b)
else:
  print(a, b-1)


### FIXED CODE ###

s, t = input().split()
a, b = map(int, input().split())
u = str(input())
 
if u==s:
  print(a-1, b)
else:
  print(a, b-1)
N,X = map(int, input().split())
L = [x for x in map(int, input().split())]
accumL = [sum(L[:x]) for x in range(len(L)+1)]
TF = [i < X for i in accumL]
print(TF.index(False) + 1)

### FIXED CODE ###

N,X = map(int, input().split())
L = [x for x in map(int, input().split())]
accumL = [sum(L[:x]) <= X for x in range(len(L)+1)]
if accumL[-1] == True:
  print(N + 1)
else:
  print(accumL.index(False))
#コピペAC
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9
def dfs(cur, a, b, c):
  if cur == N:
  return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
ret0 = dfs(cur + 1, a, b, c)
ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))


### FIXED CODE ###

#コピペAC
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9
def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))
from math import ceil
time_list = [int(input()) for i in range(5)]
sum_list = []
time_list_0 = []
for i in range(5):
    time_list_0[i] = ceil(time_list[i] / 10) * 10
for j in range(5):
    if time_list[j] == 0:
        sum_list[j] = sum(time_list_0)
    else:
        sum_list[j] = sum(time_list_0) - 10 + (time_list[j] % 10)
print(min(sum_list))


### FIXED CODE ###

from math import ceil
time_list = [int(input()) for i in range(5)]
sum_list = []
time_list_0 = []
for i in range(5):
    time_list_0.append(ceil(time_list[i] / 10) * 10)
for j in range(5):
    if time_list[j] % 10 == 0:
        sum_list.append(sum(time_list_0))
    else:
        sum_list.append(sum(time_list_0) - 10 + (time_list[j] % 10))
print(min(sum_list))
import math
def main():
  N, K = list(map(int, input().split()))
  A = list(map(int, input().split()))
 
  if K == 0:
    C = 0
  else:
    C = int(math.log2(K + 1))
    L = [[0 for i in range(44)] for j in range(C + 1)]
 
    for i in A:
      for j in range(len(L[0])):
        if i % 2 == 1:
          i -= 1
          L[0][j] += 1
        if i == 0:
          break
        i /= 2
    for i in range(1, C + 1):
      for j in range(44):
        L[i][j] = L[0][j]
 
    x = pow(2, C)
    T = [K for i in range(C + 1)]
    for i in range(C, -1, -1):
      for j in range(C + 1):
        if T[j] >= x:
          if j != i and L[j][i] <= N / 2:
            L[j][i] = N - L[j][i]
            T[j] -= x
      x //= 2
 
    Ans = [0 for i in range(C + 1)]
    x = 1
    for i in range(44):
      for j in range(C + 1):
        Ans[j] += L[j][i] * x
      x *= 2
 
  print(max(Ans))

main()

### FIXED CODE ###

import math
def main():
  N, K = list(map(int, input().split()))
  A = list(map(int, input().split()))
 
  if K == 0:
    C = 0
  else:
    C = int(math.log2(K + 1))
  L = [[0 for i in range(44)] for j in range(C + 1)]
 
  for i in A:
    for j in range(len(L[0])):
      if i % 2 == 1:
        i -= 1
        L[0][j] += 1
      if i == 0:
        break
      i /= 2
  for i in range(1, C + 1):
    for j in range(44):
      L[i][j] = L[0][j]
 
  x = pow(2, C)
  T = [K for i in range(C + 1)]
  for i in range(C, -1, -1):
    for j in range(C + 1):
      if T[j] >= x:
        if j != i and L[j][i] <= N / 2:
          L[j][i] = N - L[j][i]
          T[j] -= x
    x //= 2
 
  Ans = [0 for i in range(C + 1)]
  x = 1
  for i in range(44):
    for j in range(C + 1):
      Ans[j] += L[j][i] * x
    x *= 2
 
  print(max(Ans))

main()