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

from collections import deque
import numpy as np

H, W = map(int, input().split())
d = [[-1]*W for i in range(H)]
#temp = [[float("inf")]*W for i in range(H)]
maze = [list(input()) for i in range(H)]

black_cells = deque()
for i in range(H):
    for j in range(W):
        if maze[i][j]=="#":
            black_cells.append((i,j))
            d[i][j] = 0

def bfs():
    #max = 0
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    #que = deque([])
    s = 0
    while black_cells:
        p = black_cells.popleft()
        s = d[p[0]][p[1]]
        for i in range(4):
            nx = p[1] + dx[i]
            ny = p[0] + dy[i]
            #a = temp[ny][nx]
            if 0<=nx<W and 0<=ny<H and d[ny][nx]==-1:
                #que.append((nx))
                #temp[ny][nx] = d[p[0]][p[1]] + 1
                #a = temp[ny][nx]
                #d[ny][nx] = d[p[0]][p[1]] + 1
                #if a < d[ny][nx]:
                black_cells.append((ny, nx))
                d[ny][nx] = s + 1
                    #if max < d[ny][nx]:
                        #max = d[ny][nx]

    return s






#for i in slist:
#    s = bfs(i[0], i[1])

print(bfs())
#print(s)


### FIXED CODE ###

from collections import deque

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

# 初期の黒('#')の位置からの距離
dist = [[-1]*W for _ in range(H)]

# '#'の位置をキューに追加（＝今回はこれが複数あるので、複数スタートとなる）
black_cells = deque()
for h in range(H):
    for w in range(W):
        if grid[h][w] == '#':
            black_cells.append((h, w))
            dist[h][w] = 0

def bfs(black_cells, dist):
    """
    BFSを用いて、全マス目を黒くする回数を求める

    Args:
        black_cells: 「開始時の黒マス」の座標が入ったキュー（複数座標あり）
        dist: 「開始時の黒マス」からの距離の入ったリスト  [[-1, -1, 0], ...]
        　　　（白マスの初期値は0）

    Returns:
        g: 操作を繰り返した数
    """
    d = 0
    while black_cells:
        # キューとして使うのでpop()ではなくpopleft()
        h, w = black_cells.popleft()
        d = dist[h][w]
        for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            new_h = h + dy
            new_w = w + dx
            if new_h < 0 or H <= new_h or new_w < 0 or W <= new_w:
                continue
            if dist[new_h][new_w] == -1:  # セルが白('.')であるのと同義
                dist[new_h][new_w] = d+1
                black_cells.append((new_h, new_w))
    return d

d = bfs(black_cells, dist)
print(d)
### BUGGY CODE ###

import sys

# class Node:
#     def __init__(self, n, N):
#         self.id = n
#         self.edges = []
#         self.dist = 2*10**5
#         self.nroom = -1

#     def set_edge(self, e):
#         self.edges.append(e)    
    
#     def set_dist(self, e, i):
#         if e < self.dist:
#             self.dist = e
#             self.nroom = i


from heapq import *

def dijkstra(start,node,edge):
    d = [float("inf")] * node
    m = [0]*node
    d[start] = 0
    #スタートをキューに入れる
    q = [0]
    heapify(q)
    
    while(len(q) != 0):
      i = heappop(q)
    #   print(i)  
      for j in edge[i]:
        if(d[j] > d[i] + 1):
          d[j] = d[i] + 1
          heappush(q, j)
          m[j] = i
    return d, m

def main():
    N,M = map(int, input().split())
    
    E = [[] for _ in [0]*N]
    
    for i in range(M):
      a,b = (int(x) for x in input().split())
      E[a-1].append(b-1)
      E[b-1].append(a-1)

    d, m = dijkstra(0, N, E)
    # print(d, m)
    print("Yes")
    for i in range(1,N):
      print(m[i]+1)

if __name__ == '__main__':
    main()


### FIXED CODE ###

from heapq import heapify, heappop, heappush

def dijkstra(start,node,edge):
    d = [2*10**5] * node
    m = [0]*node
    d[start] = 0
    q = [(0,0)]
    heapify(q)
    
    while(len(q) != 0):
      ci, i = heappop(q)
      di = d[i]
      for j in edge[i]:
        if(d[j] > di+1):
          d[j] = di + 1
          heappush(q, (di+1,j))
          m[j] = i+1
    return m

def main():
    N,M = map(int, input().split())
    
    E = [[] for _ in [0]*N]
    for i in range(M):
      a,b = (int(x) for x in input().split())
      E[a-1].append(b-1)
      E[b-1].append(a-1)

    m = dijkstra(0, N, E)
    print("Yes")
    print("\n".join(map(str, m[1:])))

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

import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

from itertools import combinations

n,x,y=map(int,readline().split())
dis=[0]*n
lst=list(range(1,n+1))
for a,b in combinations(lst,2):
  dist=min(b-a, abs(x-a)+abs(y-b)+1,abs(y-a)+abs(x-b)+1)
  dis[dist]+=1
print(*dis[1:],sep='\n')


### FIXED CODE ###

import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

from itertools import combinations

n,x,y=map(int,readline().split())
dis=[0]*n
lst=list(range(1,n+1))
for a,b in combinations(lst,2):
  if b<=x or a>=y:
    dist=b-a
  else:
    dist=min(b-a, abs(x-a)+abs(y-b)+1)
  dis[dist]+=1
print(*dis[1:],sep='\n')
### BUGGY CODE ###

N,W = input().split()
aArr = list()
ans = 0
tmp = int(N)
for i in range(int(W)):
    inputInt = int(input())
    aArr.append(inputInt)
    if inputInt - tmp == 1:
        print(ans)
        exit()
    tmp = inputInt
tmp = 0
intArr = list()
for i in range(int(N)+1):
    if(i in aArr):
        intArr.append(0)
    elif i < 2:
        intArr.append(1)
    else:
        intArr.append(intArr[i-2] + intArr[i-1])
print(intArr[int(N)] % 1000000007)


### FIXED CODE ###

import sys
N, W = input().split()
aArr = list()
ans = 0
tmp = int(N)
MOD = 10 ** 9 + 7
aArr = set(map(int, sys.stdin))

tmp = 0
tmpB = 0
ans = 1
for i in range(int(N)):
    if (i in aArr):
        tmp = 0
    elif i < 2:
        tmp = 1
    else:
        tmp = ans
    ans = (tmp + tmpB) % MOD
    tmpB = tmp
print(ans)
### BUGGY CODE ###

s = str(input())
k = int(input())
substring = []

for i in range(len(s)+1):
	for j in range(i,len(s)+1):
		if len(s[i:j]) <= 5:
			substring.append(s[i:j])

		
sub = list(set(substring))
sub.remove('')
sub.sort()

print(sub[k-1])


### FIXED CODE ###

#5番目までに大きな数値を探すということは、5文字以内の文字列だけを検索すれば良い
s = str(input())
k = int(input())
substring = []

for i in range(len(s)+1):
	for j in range(i,i+6):
		substring.append(s[i:j])

		
sub = list(set(substring))
sub.remove('')
sub.sort()

print(sub[k-1])
### BUGGY CODE ###

import sys
from collections import deque
input = lambda: sys.stdin.readline().rstrip()
Yes = lambda boolean: print('Yes') if boolean else print('No')
YES = lambda boolean: print('YES') if boolean else print('NO')
aint = lambda: int(input())
ints = lambda: list(map(int, input().split()))
is_even = lambda x: True if x%2==0 else False
zeros2d = lambda r,c: [[0 for col in range(c)] for row in range(r)]

n = aint()
a = ints()

for i in range(n):
    print(a.count(i+1))

### FIXED CODE ###

import sys
from collections import deque
input = lambda: sys.stdin.readline().rstrip()
aint = lambda: int(input())
ints = lambda: list(map(int, input().split()))

n = aint()
a = ints()
c = [0]*n
for i in range(n-1):
    c[a[i]-1]+=1
d = deque(c)
for i in range(n):
    print(d.popleft())
### BUGGY CODE ###

#!/usr/bin/python3
# -*- coding: utf-8 -*-
from bisect import bisect_left
from sys import stdin
from heapq import heappush, heappop


def main():
  ## input
  N,Q = map(int, stdin.readline().rstrip().split())
  STX = [[0,0,0] for _ in range(N)]
  for i in range(N):
    s,t,x = map(int, stdin.readline().rstrip().split())
    STX[i] = [x,s-x,t-x]
  Dn = [int(stdin.readline().rstrip()) for _ in range(Q)] + [10**10]
  ans = []

  for x,s,t in sorted(STX):
    l = bisect_left(Dn,s)
    r = l
    while Dn[r] < t:
      heappush(ans, (Dn[r],x))
      r += 1
    del Dn[l:r]

  for d in Dn[:-1]:
    heappush(ans, (d,-1))

  return ans


if __name__ == "__main__":
  ans = main()
  n=len(ans)
  for _ in range(n):
    print(heappop(ans)[1])    


### FIXED CODE ###

import sys
from bisect import bisect_left



N,Q = map(int, input().split())
lines = sys.stdin.readlines()
kkk = []
for line in lines[:N]:
  s, t, x = map(int, line.split())
  kkk.append((x, s, t))
kkk.sort()
ddd = list(map(int, lines[N:]))

ans = [-1] * Q
skip = [-1] * Q
for x, s, t in kkk:
  ss = bisect_left(ddd, s - x)
  tt = bisect_left(ddd, t - x)
  while ss < tt:
    sk = skip[ss]
    if sk == -1:
      ans[ss] = x
      skip[ss] = tt
      ss += 1
    else:
      ss = sk

print('\n'.join(map(str, ans)))
### BUGGY CODE ###

N=int(input())
S=input()
count=0
for i in range(N):
  for j in range(1,N-i//2):
    if (0<=i<=N-1 and 0<=i+j<=N-1 and 0<=i+2*j<=N-1):
      if S[i]!=S[i+j] and S[i+j]!=S[i+2*j] and S[i]!=S[i+2*j]:
        count+=1

r=0
g=0
for i in range(N):
  if S[i]=='R':
    r+=1
  if S[i]=='G':
    g+=1
print(r*g*(N-r-g)-count)

### FIXED CODE ###

N=int(input())
S=input()
r=S.count('R')
g=S.count('G')
b=S.count('B')
c=0
for i in range(N):
  for j in range(i+1,N):
    h=2*j-i
    if h>=N:
      break
    if S[i]!=S[j] and S[i]!=S[h] and S[j]!=S[h]:
      c+=1
ans=r*g*b-c
print(ans)
### BUGGY CODE ###

n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [tuple(map(int, input().split())) for _ in range(m)]
dic = {}
for i in range(m):
    a = ab[i][0]
    b = ab[i][1]
    if dic.get(a):
        dic[a].append(b)
    else:
        dic[a] = [b]

    if dic.get(b):
        dic[b].append(a)
    else:
        dic[b] = [a]
    dic[a] = list(set(dic[a]))
    dic[b] = list(set(dic[b]))
ans = 0
for i in range(n):
    if dic.get(i + 1):
        flg = True
        for j in range(len(dic[i + 1])):
            if h[i] <= h[dic[i + 1][j] - 1]:
                flg = False
                break
        if flg:
            ans += 1
    else:
        ans += 1
print(ans)


### FIXED CODE ###

n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [tuple(map(int, input().split())) for _ in range(m)]
dic = {}
ban = {}
for i in range(m):
    a = ab[i][0]
    b = ab[i][1]

    if dic.get(a):
        dic[a] = max(dic[a], h[b - 1])
    else:
        dic[a] = h[b - 1]

    if dic.get(b):
        dic[b] = max(dic[b], h[a - 1])
    else:
        dic[b] = h[a - 1]
ans = 0
for i in range(n):
    if dic.get(i + 1):
        if dic[i + 1] < h[i]:
            ans += 1
    else:
        ans += 1
print(ans)
### BUGGY CODE ###

n = int(input())

ans = 0

for a in range(1, n+1):
  for b in range(1, n+1):
    if a % b == 0:
      ans += a

print(ans)

### FIXED CODE ###

n = int(input())

ans = 0

for b in range(1, n+1):
  y = n // b
  ans += y*(y+1)*b/2

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

s = list(input())
k = int(input())
a = set()
for i in range(len(s)):
  for j in range(i, len(s)):
    a.add("".join(s[i:j + 1]))
a = sorted(a)
print(a[k - 1])

### FIXED CODE ###

s = input()
k = int(input())
sub = []
for i in range(len(s)):
    for j in range(i, i + k + 1):
        sub.append(s[i:j])
print(sorted(set(sub))[k])
### BUGGY CODE ###

def find_root(components, n):
    if components[n][0] == n:
        return n
    else:
        return find_root(components, components[n][0])

N, M = [int(s) for s in input().split(' ')]
bridges = []
for i in range(M):
    bridges.append([int(s)-1 for s in input().split(' ')])
components = [[i] for i in range(N)]
inconvenience = []
totalNpair = N * (N-1) / 2
for i in range(M-1, -1, -1):
    convenience = 0
    for c in components:
        convenience += len(c) * (len(c)-1) / 2
    inconvenience.append(int(totalNpair - convenience))
    a, b = bridges[i]
    a_root = find_root(components, a)
    b_root = find_root(components, b)
    if a_root != b_root:
        components[a_root].extend(components[b_root])
        components[b_root] = [a_root]
for i in range(M-1, -1, -1):
    print(inconvenience[i])
    

### FIXED CODE ###

def find_root(components, n):
    if components[n] == n:
        return n
    elif components[components[n]] == components[n]:
        return components[n]
    else:
        components[n] = find_root(components, components[n])
        return components[n]

N, M = [int(s) for s in input().split(' ')]
bridges = []
for i in range(M):
    bridges.append([int(s)-1 for s in input().split(' ')])
components = [i for i in range(N)]
componentsLen = [1 for i in range(N)]
inconvenience = [int(N * (N-1) / 2)]
for i in range(M-1, -1, -1):
    a, b = bridges[i]
    a_root = find_root(components, a)
    b_root = find_root(components, b)
    if a_root != b_root:
        inconvenience.append(inconvenience[-1] - componentsLen[a_root] * componentsLen[b_root])
        if componentsLen[a_root] < componentsLen[b_root]:
            a_root, b_root = b_root, a_root
        componentsLen[a_root] += componentsLen[b_root]
        components[b_root] = a_root
    else:
        inconvenience.append(inconvenience[-1])
for i in range(M-1, -1, -1):
    print(inconvenience[i])
### BUGGY CODE ###

import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
A2 = [0]*N
for i in range(K):
    for j in range(N):
        g = math.ceil(j+1-A[j]-0.5)
        if g<1:
            g=1
        h = math.floor(j+1+A[j]+0.5)
        if h>N:
            h=N
        for x in range(g,h+1):
            A2[x-1]+=1
    A=A2[:]
    A2 = [0]*N
    c = 0
    for p in range(N):
        c+=A[p]
    if c >= N*N:
        break

print(*A)


### FIXED CODE ###

import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
A2 = [0]*(N+1)
for i in range(K):
    for j in range(N):
        g = math.ceil(j+1-A[j]-0.5)
        if g<1:
            g=1
        h = math.floor(j+1+A[j]+0.5)
        if h>N:
            h=N
        A2[g-1]+=1
        A2[h]-=1
    A[0]=A2[0]
    for j in range(1, N):
        A[j]=A[j-1]+A2[j]
    A2 = [0]*(N+1)
    c = 0
    for p in range(N):
        c+=A[p]
    if c >= N*N:
        break

print(*A)
### BUGGY CODE ###

import queue
N = int(input())

q = queue.Queue()

[q.put(int(_)) for _ in input().split()]

ans = 1
for i in range(N):
    ans = ans * q.get()

if(ans > 10 **18):
    print(-1)
else:
    print(ans)

### FIXED CODE ###

import sys

N = int(input())

An = [int(_) for _ in input().split()]
An.sort()

ans = 1

for val in An:
    # 0がきたらすぐに抜ける
    if(int(val) == 0):
        print(0)
        sys.exit()
    ans *= val
    # ansが10^18を超えた時点で-1にする
    if(ans > 10 **18):
        print(-1)
        sys.exit()

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

from collections import *
from heapq import *
from itertools import *
from fractions import gcd

from decimal import *
import copy
from bisect import *
import time
import sys
import math
input=lambda :sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**7)
K=int(input())
#A,B=map(int,input().split())
#A=list(map(int,input().split()))
z=0
for a in range(1,K+1):
    for b in range(1,K+1):
        d=gcd(a,b)
        for c in range(1,K+1):
            z+=gcd(c,d)
print(z)


### FIXED CODE ###

from collections import *
from heapq import *
from itertools import *
from fractions import gcd

from decimal import *
import copy
from bisect import *
import time
import sys
import math
input=lambda :sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**7)
K=int(input())
#A,B=map(int,input().split())
#A=list(map(int,input().split()))
z=0
dic=defaultdict(int)
for a in range(1,K+1):
    for b in range(1,K+1):
        d=gcd(a,b)
        dic[d]+=1
for d in dic:

    for c in range(1,K+1):
        z+=dic[d]*gcd(c,d)
print(z)
### BUGGY CODE ###

N = int(input())
A = [int(input()) for i in range(N)]

for i in range(N): 
    if A.index(max(A))==i:
        print(sorted(A)[-2])
    else:    
        print(max(A)) 
   

### FIXED CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
n = A.index(max(A))
m = max(A)
A.remove(max(A))

for i in range(n):    
    print(m)
print(max(A))
for i in range(N-n-1):
    print(m)
### BUGGY CODE ###

#input
S = str(input())

#output
from collections import Counter
#2019 = 3 * 673
N = len(S)
#上からi桁目までの数を決めた時2019の個数をdp[i]とする。
dp = [0] * (N+1)

for i in range(1, N+1):
    dp[i] = int(S[-i::]) % 2019

T = Counter(dp[1:])

answer = 0
answer += T[0]

for t in T.values():
    if t >= 2:
        answer += t*(t-1)//2

print(answer)

### FIXED CODE ###

#input
S = str(input())[::-1]

#output
from collections import Counter
#2019 = 3 * 673
N = len(S)
#上からi桁目までの数を決めた時2019の個数をdp[i]とする。
dp = [0] * (N)
dp[0] = int(S[0])
times =10
for i in range(N-1):
    dp[i+1] = dp[i] + times * int(S[i+1])
    dp[i+1] %= 2019
    times *= 10
    times %= 2019

T = Counter(dp)

answer = T[0]

for t in T.values():
    answer += t*(t-1)//2

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

import sys
import time
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N = int(input())

groups = []

def dfs(s, n):
    if n == N:
        bits = [-1] * N
        for i, ss in enumerate(s):
            if bits[i] != -1:
                continue
            for ii in range(i+1, N):
                if s[ii] == ss:
                    bits[ii] = i
        if bits not in groups:
            groups.append(bits)
            print(s)
        return
    # for ns in 'abcdefghijklmnopqrstuvwxyz'[:n+1]:
    for ns in 'abcdefghij'[:n+1]:
        dfs(s+ns, n+1)

dfs('', 0)


### FIXED CODE ###

import sys
import time
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N = int(input())

def dfs(s, n, m):
    if n > N:
        print(''.join([chr(ss) for ss in s]))
        return True
    for ns in range(97, m+2):
        s[n-1] = ns
        dfs(s, n+1, max(m, ns))

s = [0] * N
dfs(s, 1, 96)
### BUGGY CODE ###

from time import sleep
n, a, b = map(int, input().split())
sleep(1.99)
print(max(a * n, b))

### FIXED CODE ###

n,a,b=map(int,input().split());print(min(n*a,b))
### BUGGY CODE ###

from functools import reduce
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

n = int(input())
A = list(map(int, input().split()))
k = lcm_list(A)
r = 0
ln = list(range(n))
for i in ln:
    r += k//A[i]
    if r > 10**9+7:
        r %= 10**9+7
print(r)

### FIXED CODE ###

from functools import reduce
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

n = int(input())
A = list(map(int, input().split()))
k = lcm_list(A)
r = 0
ln = list(range(n))
for i in ln:
    r += k//A[i]
print(r%(10**9+7))
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
c = n
s = a[0]
d = 0
for i in range(n):
	s = a[i]
	j = i
	d = 0
	while j < n-1:
		xs = s ^ a[j+1]
		s += a[j+1]
		if s == xs:
			d += 1
		else:
			break
		j += 1
	c += d
print (c)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
c = 0
s = 0
d = 0
j = 0
for i in range(n):
	d = 0
	while j < n and s & a[j] == 0:
		s += a[j]
		j += 1
	s -= a[i]
	c += j-i
print (c)
### BUGGY CODE ###

n = int(input())
s = [input() for _ in range(n)]
ans = 0
for i in range(n-1):
  for j in range(n):
    if i < j:
      for k in range(10):
        if s[i].count(s[i][k]) != s[j].count(s[i][k]):
          break
        if k == 9:
          ans += 1
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
# 最初はごちゃごちゃ考えていたが、文字列を１文字ずつリストにしてからソートして
# それをさらに文字列に戻してソートしたらおわり
n = int(input())
sort = [""]*n
for i in range(n):
    s = list(input())
    s.sort()
    sort[i] = s
sort.sort()
#print(sort)
ans = 0
cnt = 0
for i in range(n-1):
    if sort[i+1] == sort[i]: cnt += 1
    else: 
        ans += cnt*(cnt+1)//2
        cnt = 0
print(ans+cnt*(cnt+1)//2)
### BUGGY CODE ###

import functools
import math

K = int(input())

def gcd_2(*vals):
    return functools.reduce(math.gcd, vals)

ans=0
for x in range(1,K+1):
    for y in range(1,K+1):
        for z in range(1,K+1):
            ans += gcd_2(x,y,z)

print(ans)


### FIXED CODE ###

import functools
import math

K = int(input())

def gcd_2(*vals):
    return functools.reduce(math.gcd, vals)

ans=0
for x in range(1,K+1):
    for y in range(1,K+1):
        for z in range(1,K+1):
            ans += gcd_2(x,y,z)

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

import bisect
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
cnt = 0
while cnt < m:
    x = a.pop()
    x = x // 2
    cnt += 1
    if len(a) == 0 or x > a[-1]:
        a.append(x)
    else:
        bisect.insort_left(a, x)
print(sum(a))

### FIXED CODE ###

import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [-1 * i for i in a]
heapq.heapify(a)
cnt = 0
while cnt < m:
    x = heapq.heappop(a) * -1
    x = x // 2
    cnt += 1
    heapq.heappush(a, x * -1)
print(sum(a) * -1)
### BUGGY CODE ###

from math import log2, ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))

M = max(A)
M = max(M, K)

L = int(ceil(log2(M)))
p2 = [0] * L
for a in A:
    for i in range(L):
        if a & (1 << i):
            p2[i] += 1


ans = 0
for bs in range(K + 1):
    tmp = 0
    for i, cnt in enumerate(p2):
        if bs ^ (1 << i):
            tmp += (1 << i) * cnt
        else:
            tmp += (1 << i) * (N - cnt)
    ans = max(ans, tmp)

print(ans)


### FIXED CODE ###

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


# 上からi桁(0-indexed)のbitが立っているものがいくつあるか
bit_stand_counts = [0] * 40
for a in A:
    a = bin(a)[2:].zfill(40)
    for i in range(40):
        if a[i] == '1':
            bit_stand_counts[i] += 1


# 上からi番目のbitまでみたときに、dp[i][0]: K以下であることが未確定 dp[i][1]: K以下であることが確定 のときの最大値
dp = [[-1, -1] for i in range(41)]
dp[0][0] = 0


# Kをbitで表したもの
K_bit = bin(K)[2:].zfill(40)


for i in range(40):
    value_0 = (2 ** (39 - i)) * bit_stand_counts[i]  # i桁目を0にした時の報酬
    value_1 = (2 ** (39 - i)) * (N - bit_stand_counts[i])  # i桁目を1にした時の報酬
    
    if K_bit[i] == '0':  # Kの上からiビット目が0なら、K以下か未確定のほうは合わせるしかない
        dp[i + 1][0] = dp[i][0] + value_0
    else:
        dp[i + 1][0] = dp[i][0] + value_1
        dp[i + 1][1] = max(dp[i + 1][1], dp[i][0] + value_0)  # Kの上からiビット目が1ならK以下確定に飛べる

    if dp[i][1] != -1:  # K以下であることが確定しているなら、あとは貪欲にとれる
        dp[i + 1][1] = max(dp[i + 1][1], dp[i][1] + max(value_0, value_1))


print(max(dp[-1]))
### BUGGY CODE ###

S=int(input())
count=1
while S!=8:
    if S%2==0:
        S//=2
        count+=1
    else:
        S=S*3+1
        count+=1
else:
    print(count+4)

### FIXED CODE ###

S=int(input())
count=1
for i in range(1000000):
    if S==8:
        print(count+4)
        break
    elif S==4:
        print(count+3)
        break
    elif S==2:
        print(count+3)
        break
    elif S==1:
        print(count+3)
        break
    elif S%2==0:
        S//=2
        count+=1
    else:
        S=S*3+1
        count+=1
### BUGGY CODE ###

# coding: utf-8
# Your code here!

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

ans = []
for i in range(1, N+1):
    ans.append(str(A.index(i)+1))
print(" ".join(ans))

### FIXED CODE ###

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

ans = [0 for i in range(N)]
for i in range(N):
    idx = A[i]-1
    ans[idx] = str(i+1)
print(" ".join(ans))