Harryxun/stf_run huggingface dataset:
n,m = map(int, input().split())

lst = []
for i in range(m):
    s,c = map(int, input().split())
    lst.append((s,c))

for i in range(1,1000):
    flag = 0
    I = str(i)
    if len(I)==n:
        for j in range(len(lst)):
            if I[lst[j][0]-1]!=lst[k][1]:
                flag = 1
        if flag == 0:
            print(I)
print(-1)

### FIXED CODE ###

n,m = map(int, input().split())
lst = []
for i in range(m):
    s,c = map(int, input().split())
    lst.append((s-1,c))

if n!=1:
    for i in lst:
        if i==(0,0):
            print(-1)
            exit()

# print(lst)
if n==1:
    for i in range(10):
        I = str(i)
        flag = 0
        for j in lst:
            if I[j[0]]!=str(j[1]):
                flag = 1
        if flag == 0:
            print(I)
            exit()
else:
    for i in range(10**(n-1),10**n):
        I = str(i)
        # print(I)
        flag = 0
        for j in lst:
            if I[j[0]]!=str(j[1]):
                flag = 1
        if flag == 0:
            print(I)
            exit()

print(-1)
r = int(input())

return r * r

### FIXED CODE ###


r = int(input())
print(r*r)
A, B = map(int, input().split())

t = A + B
x = A * B
m = A - B

a_flg = False
b_flg = False

if A > 0:
  a_flg = True
if B > 0:
  b_flg = True
  
if A == 0:
  if B < 0:
    print(m)
if B == 0:
  if A < 0:
    print(x)
if A == 0 and B == 0:
  print(t)

if a_flg and b_flg:
  print(x)
elif a_flg == True and b_flg == False:
  print(m)
elif a_flg == False and b_flg == True:
  print(t)
elif a_flg == False and b-flg == False:
  print(x)

### FIXED CODE ###

A, B = map(int, input().split())
 
t = A + B
x = A * B
m = A - B
 
map = {'t': t, 'x': x, 'm': m}

sorted_map = sorted(map.items(), key=lambda x:x[1])

ans = sorted_map[-1]
print(ans[-1])
a = int(input())
b = int(input())
c = a * b
if c % 2 == 1:
    print("Odd")
else:
    print("Even")

### FIXED CODE ###

a, b = map(int, input().split())
c = (a * b) % 2
if c == 0:
    print('Even')
else:
    print('Odd')
a, b, c, k= int(input().split())

if a>=k:
    print(k)
elif a+b>=k:
    print(a)
else:
    print(2*a-k-b)

### FIXED CODE ###

a, b, c, k= map(int, input().split())

if a>=k:
    print(k)
elif a+b>=k:
    print(a)
else:
    print(2*a-k+b)
import bisect,copy,heapq,itertools,string
from collections import *
from math import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, a, b, c, d = MAP()
s = input()

flag = 0
for i in range(min(a,b)+1,max(c,d)):
        if (a < i < c or b < i < d) and s[i] == s[i-1] == '#':
                print("No")
                exit()       
        elif max(a,b) <= i <= min(c,d) and s[i-1] == s[i] == s[i+1] == '.':
                flag = 1

if c > d and flag == 0:
        print("No")
else:
        print("Yes")

### FIXED CODE ###

import bisect,copy,heapq,itertools,string
from collections import *
from math import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, a, b, c, d = MAP()
s = 'a' + input()

flag = 0
for i in range(min(a,b)+1,max(c,d)):
        if (a < i < c or b < i < d) and s[i] == s[i-1] == '#':
                print("No")
                exit()       
        elif max(a,b) <= i <= min(c,d) and s[i-1] == s[i] == s[i+1] == '.':
                flag = 1

if c > d and flag == 0:
        print("No")
else:
        print("Yes")
hoge, n = map(int, input().split())
s = list(input())
s[n] = s[n].lower()
print(*s, sep="")

### FIXED CODE ###

hoge, n = map(int, input().split())
s = list(input())
s[n-1] = s[n-1].lower()
print(*s, sep="")
c1x,c1y,c1r = [int(i) for i in input().split()]
c2x,c2y,c2r = [int(i) for i in input().split()]

d = math.sqrt(pow(c1x-c2x, 2) +  pow(c1y-c2y, 2))

s = c1r + c2r

if d > s:
    print(4)
elif d == c:
    print(3)
elif d > 2*s:
    print(2)
elif d == 2*s:
    print(1)
else:
    print(0)


### FIXED CODE ###

import math

c1x,c1y,c1r = [int(i) for i in input().split()]
c2x,c2y,c2r = [int(i) for i in input().split()]

d = math.sqrt(pow(c1x-c2x, 2) +  pow(c1y-c2y, 2))

bcr = 0
scr = 0

if c1r > c2r:
    bcr = c1r
    scr = c2r
else:
    bcr = c2r
    scr = c1r


if d > bcr + scr:
    print(4)
elif d == bcr + scr:
    print(3)
elif d + scr > bcr:
    print(2)
elif d + scr == bcr:
    print(1)
else:
    print(0)
from collections import Counter
s = input()
N = len(s)
sc = Counter(s)
del sc['x']

def trim_x():
    s_trim = ''.join([c for c in s if c != 'x'])
    for i in range(len(s_trim)):
        j = len(s_trim) - 1 - i
        if i >= j:
            break
        if s_trim[i] != s_trim[j]:
            return None
    return s_trim

def solve():
    s_trim = trim_x()  # anagram
    if s_trim is None:
        return -1
    pl = len(s_trim) // 2
    pr = pl
    if len(s_trim) % 2 == 0:
        pl -= 1
    xl = 0
    tl = 0
    while xl < N:
        if s[xl] != 'x':
            assert s[xl] == s_trim[tl]
            if tl == pl:
                break
            tl += 1
        xl += 1

    if len(s_trim) % 2 == 1:
        xr = xl
    else:
        xr = xl + 1
        while s[xr] == 'x':
            xr += 1

    cost = 0
    while True:
        assert s[xl] == s_trim[pl]
        assert s[xr] == s_trim[pr]
        assert s[xl] == s[xr]
        assert s_trim[pl] == s_trim[pr]
        pl -= 1; pr += 1
        while True:
            xl -= 1; xr += 1
            if not (xl >= 0 and xr < N and s[xl] == 'x' and s[xr] == 'x'):
                break
        while xl >= 0 and s[xl] == 'x':
            cost += 1
            xl -= 1
        while xr < N and s[xr] == 'x':
            cost += 1
            xr += 1
        if pl < 0 and pr >= len(s_trim) and xl < 0 and xr >= N:
            return cost

print(solve())


### FIXED CODE ###

s = input()
N = len(s)
s_trim = ''.join([c for c in s if c != 'x'])
N_trim = len(s_trim)

def check_anagram():
    for i in range(N_trim):
        j = N_trim - 1 - i
        if s_trim[i] != s_trim[j]:
            return False
    return True

def solve():
    if not check_anagram():
        return -1
    if N_trim == 0:
        return 0
    # Center of anagram
    pr = N_trim // 2
    pl = pr
    if N_trim % 2 == 0:
        pl -= 1

    xl = 0
    tl = 0
    while xl < N:
        if s[xl] != 'x':
            # assert s[xl] == s_trim[tl]
            if tl == pl:
                break
            tl += 1
        xl += 1

    if N_trim % 2 == 1:
        xr = xl
    else:
        xr = xl + 1
        while s[xr] == 'x':
            xr += 1

    cost = 0
    while True:
        # assert s[xl] == s_trim[pl]
        # assert s[xr] == s_trim[pr]
        # assert s[xl] == s[xr]
        # assert s_trim[pl] == s_trim[pr]
        pl -= 1; pr += 1
        while True:
            xl -= 1; xr += 1
            if not (xl >= 0 and xr < N and s[xl] == 'x' and s[xr] == 'x'):
                break
        while xl >= 0 and s[xl] == 'x':
            cost += 1
            xl -= 1
        while xr < N and s[xr] == 'x':
            cost += 1
            xr += 1
        if pl < 0 and pr >= N_trim and xl < 0 and xr >= N:
            return cost

print(solve())
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[1000]*n

dp[0]=0
for i in range(1,n):
    for j in range(i-k,i):
        dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]))
    
print(dp[n-1])

### FIXED CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**9]*n

dp[0]=0
for i in range(1,n):
    for j in range(1,min(k+1,i+1)):
        dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
    
print(dp[n-1])
class UnionFind:
    def __init__(self, n):
        '木の初期化をする'
        self.p = [-1] * n
        self.rank = [1]*n
        self.size = [1]*n
    def find(self, x):
        'x の親を返す'
        if self.p[x] == -1:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def unite(self, x, y):
        'rankの低い親を高い方のの親にする'
        if not self.same(x,y):
            x = self.find(x)
            y = self.find(y)
            if self.rank[x] > self.rank[y]:
                x,y = y,x
            elif self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.size[y] += self.size[x]
            self.p[x] = y
            return True
        else:
            return False

    def same(self, x, y):
        return self.find(x) == self.find(y)


n,m,k = map(int,input().split())
uf = UnionFind(n)
ans = [0] * n
for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    uf.unite(a,b)
    ans[a] -= 1
    ans[b] -= 1

for i in range(k):
    c,d = map(int,input().split())
    c -= 1
    d -= 1
    if uf.same(c,d):
        ans[c] -= 1
        ans[d] -= 1

for i in range(n):
    p = uf.find(i)
    ans[i] += uf.size[p] - 1

print(' '.join([str(i) for i in ans]))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 5 + 1)

class UnionFind:
    def __init__(self, n):
        '木の初期化をする'
        self.p = [-1] * n
        self.rank = [1]*n
        self.size = [1]*n
    def find(self, x):
        'x の親を返す'
        if self.p[x] == -1:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def unite(self, x, y):
        'rankの低い親を高い方のの親にする'
        if not self.same(x,y):
            x = self.find(x)
            y = self.find(y)
            if self.rank[x] > self.rank[y]:
                x,y = y,x
            elif self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.size[y] += self.size[x]
            self.p[x] = y
            return True
        else:
            return False

    def same(self, x, y):
        return self.find(x) == self.find(y)


n,m,k = map(int,input().split())
uf = UnionFind(n)
ans = [0] * n
for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    uf.unite(a,b)
    ans[a] -= 1
    ans[b] -= 1

for i in range(k):
    c,d = map(int,input().split())
    c -= 1
    d -= 1
    if uf.same(c,d):
        ans[c] -= 1
        ans[d] -= 1

for i in range(n):
    p = uf.find(i)
    ans[i] += uf.size[p] - 1

print(' '.join([str(i) for i in ans]))
a, b = map(int, input().split())
print(max(20-(a + b), 0)

### FIXED CODE ###

a, b = map(int, input().split())
print(max(a - 2 * b, 0))
def totalcost_recur(i,cost,N,lookup):
  if i>=N:
    return 0
  if i in lookup:
      return lookup[i]
  option1 = abs(cost[i]-cost[i+1]) + totalcost_recur(i+1,cost,N,lookup)
  ans = option1
  if i+2<=N:
    option2 = abs(cost[i]-cost[i+2]) + totalcost_recur(i+2,cost,N,lookup)
    ans = min(option2,ans)
  lookup[i] = ans
  return ans



def totalcost_dp(cost,N,k):
    dp = [float('inf')]*(N+1)
    dp[1] = 0
    
    
    for i in range(1,N+1):
        
        for j in range(i+1,k+i+1):
            if j < N+1:
                dp[j] = min(dp[j],dp[i]+abs(cost[i]-cost[j]))
                
            
        
        

    return dp[N]


n ,k= map(int,input().split())
cost = list(map(int,input().split()))
cost = [0]+cost
lookup = {}

print(totalcost_dp(cost,n,k))

### FIXED CODE ###

def totalcost_recur(i,cost,N,lookup):
  if i>=N:
    return 0
  if i in lookup:
      return lookup[i]
  option1 = abs(cost[i]-cost[i+1]) + totalcost_recur(i+1,cost,N,lookup)
  ans = option1
  if i+2<=N:
    option2 = abs(cost[i]-cost[i+2]) + totalcost_recur(i+2,cost,N,lookup)
    ans = min(option2,ans)
  lookup[i] = ans
  return ans



def totalcost_dp(cost,N):
    dp = [0]*(N+1)
    dp[1] = 0
    dp[2] = abs(cost[2]-cost[1])
    i = 3
    while i<=N:
        option1 = dp[i-1]+abs(cost[i]-cost[i-1])
        option2 = dp[i-2]+abs(cost[i]-cost[i-2])
        dp[i] = min(option1,option2)
        i+=1

    return dp[N]


n = int(input())
cost = list(map(int,input().split()))
cost = [0]+cost
lookup = {}

print(totalcost_dp(cost,n))
import heapq
import bisect

n = int(input())
n = n*3
a = list(map(int,input().split()))

big = a[0:n//3]
tempmin = a[n//3::]
tempmin.sort()
small = tempmin[0:n//3]
spare = tempmin[n//3::]

ans = sum(big)-sum(small)
mxm = ans

heapq.heapify(small)
heapq.heapify(spare)

for i in range(n//3,2*n//3):
    if len(spare) != 0 and a[i] >= spare[0]:
        index = bisect.bisect_left(spare,a[i])
        spare.pop(index)

    if a[i] > big[0]:
        ans += a[i]-big[0]
        index = bisect.bisect_left(big,a[i])
        big.insert(index,a[i])
        big.pop(0)
    
    if a[i] < small[-1]:
        ans -= spare[0]-a[i]
        heapq.heappush(small,spare[0])
        heapq.heappop(spare)
        index = bisect.bisect_left(small,a[i])
        small.pop(index)
    
    if ans > mxm:
        mxm = ans
print(mxm)

### FIXED CODE ###

import heapq
import bisect

n = int(input())
n = n*3
a = list(map(int,input().split()))

left = a[0:n//3]
right = list(-i for i in a[2*n//3:])

leftsum = [0 for i in range(n//3+1)]
rightsum = [0 for i in range(n//3+1)]

heapq.heapify(left)
leftsum[0] = sum(left)
for i in range(n//3):
    k = i + n//3
    heapq.heappush(left,a[k])
    temp = heapq.heappop(left)
    leftsum[i+1] = leftsum[i]+a[k]-temp

heapq.heapify(right)
rightsum[-1] = -sum(right)
for i in range(n//3)[::-1]:
    k = i + n//3
    heapq.heappush(right,-a[k])
    temp = -heapq.heappop(right)
    rightsum[i] = rightsum[i+1] - temp + a[k]




mxm = -sum(a)
for i in range(n//3+1):
    if leftsum[i]-rightsum[i] > mxm:
        mxm = leftsum[i]-rightsum[i]
print(mxm)
n = int(input())
*a, = map(int,input().split())
box = [0]*n
for i in range(n,0,-1):
    sum = 0
    for j in range(i,n+1,i):
        sum+=box[j-1]
    if sum%2!=a[i-1]:
        box[i-1]+=1

print(sum(box))
if sum(box):
    ans = []
    for i, x in enumerate(box):
        if x:
            ans.append(i)
    print(*ans)

### FIXED CODE ###

n = int(input())
*a, = map(int,input().split())
box = [0]*n
for i in range(n,0,-1):
    sum_box = 0
    for j in range(i,n+1,i):
        sum_box+=box[j-1]
    if sum_box%2!=a[i-1]:
        box[i-1]+=1

print(sum(box))
if sum(box):
    ans = []
    for i, x in enumerate(box):
        if x:
            ans.append(i+1)
    print(*ans)
N, M = map(int, input().split())
O = list(map(int, input().split()))
B = [[0 for i in range(N)] for j in range (N)]
 
for j in range(M):
  o_1, o_2 = map(int, input().split())
  B[o_1-1].append(o_2-1)
  B[o_2-1].append(o_1-1)
  
ans = 0
for k in range(N):
  flag =1
  for l in B[k]:
    if O[k] <= O[l]:
      flag = 0
      break
    else:
      continue
  if  flag ==1:
    ans += 1
print(ans)
      

### FIXED CODE ###

a = input()
if (a[1] == 'B'):
  print('ARC')
else:
  print('ABC')
### 解答
N, K = map(int, input().split())
A = list(map(int, input().split()))

#B = [0]*N                                 # 記録用のリスト

for k in range(K):                        # 以降の操作をK回繰り返す
  B = [0]*N 
  for i in range(N):                      # 各電球によって照らされる範囲を考える
    start = max(0, i-A[i])                # 始点のインデックスは0かi-A[i]
    end = min(N, i+A[i]+1)                # 終点のインデックスはNかi+A[i]+1
    B[start] += 1                         # 始点に+1を記録する
    if end <= N - 1:
      B[end] -= 1                         # 終点に電球が存在する場合は-1を記録する
  bmin = b[0] 
  for i in range(1, N):                   # 累積和の計算
    B[i] = B[i-1] + B[i]
    bmin = min(B[i], bmin)
  A = B                                   # AをBで更新してつぎのループへ 
  if bmin == N:                        # すべての電球がN個の電球に照らされるタイミングでbreakする
    break

print(*A)                                 # リストAの中身を順に表示

### FIXED CODE ###

import numpy as np
from numba import njit
 
n, k = map(int, input().split())
a = np.array(list(map(int, input().split())), dtype=np.int64)
 
@njit
def loop1(a):
  b = np.zeros(n+1, dtype=np.int64)
  for i in range(n):
    l = max(0, i-a[i])
    r = min(i+a[i]+1, n)
    b[l] += 1
    if r <= n-1: b[r] -= 1
  
  b = np.cumsum(b)[:-1]
  return b
 
for q in range(min(42, k)):
  a = loop1(a)
    
print(*a)
Aij= [int(input().split()) for l in range(3)]
N=int(input())
b= [int(input()) for i in range(N)]
for j in range(3):
    for k in range(3):
        for n in range(N):
            if int(Aij[j][k])==b[n]:
                Aij[j][k]="0"


if (Aij[0][0] == Aij[0][1] == Aij[0][2] == "0") or (Aij[1][0] == Aij[1][1] == Aij[1][2] == "0") or (Aij[2][0] == Aij[2][1] == Aij[2][2] == "0"):
    print('Yes')
elif Aij[0][0]=='0' and Aij[0][1]=='0' and Aij[0][2]=='0':
    print('Yes')
elif Aij[1][0]=='0' and Aij[1][1]=='0' and Aij[1][2]=='0':
    print('Yes')
elif Aij[2][0]=='0' and Aij[2][1]=='0' and Aij[2][2]=='0':
    print('Yes')
elif Aij[0][0]=='0'and Aij[1][1]=='0'and Aij[2][2]=='0':
    print('Yes')
elif Aij[0][2]=='0' and Aij[1][1]=='0'and Aij[2][0]=='0':
    print('Yes')
else:
    print('No')

### FIXED CODE ###

A = [list(map(int, input().split())) for i in range(3)]
N = int(input())

for k in range(N):
    B = int(input())
    for l in range(3):
        for m in range(3):
            if A[l][m] == B:
                A[l][m] = 0

if (A[0][0] == A[0][1] == A[0][2] == 0) or (A[1][0] == A[1][1] == A[1][2] == 0) or (A[2][0] == A[2][1] == A[2][2] == 0):
    print ("Yes")
elif (A[0][0] == A[1][0] == A[2][0] == 0) or (A[0][1] == A[1][1] == A[2][1] == 0) or (A[0][2] == A[1][2] == A[2][2] == 0):
    print ("Yes")
elif (A[0][0] == A[1][1] == A[2][2] == 0) or (A[0][2] == A[1][1] == A[2][0] == 0):
    print ("Yes")
else:
    print ("No")
N, M = [int(i) for i in input().split()]
g = [[int(i) for i in input().split()] for j in range(N)]
f = [item for sublist in g for item in sublist]
for i in range(1,N+1):
    print(i, f.count(i))

### FIXED CODE ###

N, M = [int(i) for i in input().split()]
g = [[int(i) for i in input().split()] for j in range(M)]
f = [item for sublist in g for item in sublist]
for i in range(1,N+1):
    print(f.count(i))
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

n = int(raw_input())
an = map(int, raw_input())
l = a[0]

for i in range(1,len(a)-1):
    b = a[i]
    g = gcd(l,b)
    l = a*b/g
print l
     

### FIXED CODE ###

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

n = int(raw_input())
a = map(int, raw_input().split())
l = a[0]

for i in range(1,len(a)):
    b = a[i]
    g = gcd(l,b)
    l = l*b/g
print l
S,W = map(int, input().split())

if W => S:
    print('unsafe')
else:
    print('safe')

### FIXED CODE ###


S,W = map(int, input().split())

if W >= S:
    print('unsafe')
else:
    print('safe')
'''input
7
1 1 1 1 2 3 4
'''
n = input()
arr = map(int,raw_input().split())
for i in range(n):
	arr[i] = (arr[i]-(i+1))
arr.sort()
mean = float(arr[n//2]+arr[n//2+1])/2
ans = 10**30
for i in range(int(mean)-30,int(mean)+30):
	q = 0
	for j in range(n):
		q += abs(arr[j]-i)
	ans = min(q,ans)
print ans

### FIXED CODE ###

'''input
7
1 1 1 1 2 3 4
'''
n = input()
arr = map(int,raw_input().split())
for i in range(n):
	arr[i] = (arr[i]-(i+1))
arr.sort()
mean = float(arr[n//2])
ans = 10**30
for i in range(int(mean)-30,int(mean)+30):
	q = 0
	for j in range(n):
		q += abs(arr[j]-i)
	ans = min(q,ans)
print ans
a,b,c=map(int,input().split())
print(['YES','NO'][a>c||c>a+b])

### FIXED CODE ###

a,b,c=map(int,input().split());print(['YES','NO'][a>c or c>a+b])
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
bc = [0] * M
for i in range(M):
    bc[i] = list(map(int, input().split()))

bc = sorted(bc, key= lambda x: x[1])[::-1]

n = 0
f = 0
for i in range(M):
    for j in range(bc[i][0]):
        if A[n] < bc[i][1] and n < N:
            A[n] = bc[i][1]
            n += 1
        else:
            f == 1
    if f == 1:
        break

print(sum(A))

### FIXED CODE ###

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
bc = [0] * M
for i in range(M):
    bc[i] = list(map(int, input().split()))

bc = sorted(bc, key= lambda x: x[1], reverse=True)

n = 0
f = 0
for i in range(M):
    for j in range(bc[i][0]):
        if A[n] < bc[i][1]:
            A[n] = bc[i][1]
            n += 1
            if n == N:
                f = 1
                break
        else:
            f = 1
    if f == 1:
        break

print(sum(A))
from functools import lru_cache
 
import numpy as np
 
 
def xor(bit, digit):
    """
    A の各要素について右から digit 桁目を bit で XOR した合計
    :param int bit:
    :param int digit:
    :return:
    """
    assert bit in [0, 1]
    bit <<= digit
    mask = 1 << digit
    return sum([(a ^ bit) & mask for a in A])
 
 
_, K = map(int, input().split())
A = list(map(int, input().split()))
 
DIGIT = 50
 
# [桁][k 未満の桁をえらんだことがあるか]
dp = np.empty([DIGIT + 1, 2], dtype=int)
dp.fill(-np.inf)
 
dp[-1][0] = 0
for d in reversed(range(DIGIT)):
    k = (K >> d) & 1
    # bit=k
    dp[d][0] = max(dp[d][0], dp[d + 1][0] + xor(bit=k, digit=d))
    # k==1 なら bit=0 も OK
    if k == 1:
        dp[d][1] = max(dp[d][1], dp[d + 1][0] + xor(bit=0, digit=d))
    # k 未満の桁をえらんだことがあるなら bit にどっちを選んでも OK
    dp[d][1] = max(dp[d][1], dp[d + 1][1] + xor(bit=0, digit=d))
    dp[d][1] = max(dp[d][1], dp[d + 1][1] + xor(bit=1, digit=d))
 
print(dp[0].max())

### FIXED CODE ###

from functools import lru_cache


def get_bit(n, d):
    return (n >> d) & 1


@lru_cache(maxsize=None)
def xor(bit, digit):
    """
    A の各要素について右から digit 桁目を bit で XOR した合計
    :param int bit:
    :param int digit:
    :return:
    """
    assert bit in [0, 1]
    # bit <<= digit
    # mask = 1 << digit
    # return sum([(a ^ bit) & mask for a in A])
    if bit == 0:
        return bit_counts[digit] << digit
    else:
        return (N - bit_counts[digit]) << digit


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

DIGIT = 50
bit_counts = [sum([get_bit(a, d=d) for a in A]) for d in range(DIGIT)]

# [桁][k 未満の桁をえらんだことがあるか]
dp = [[-float('inf') for _ in range(2)] for _ in range(DIGIT + 1)]
# dp = np.empty([DIGIT + 1, 2], dtype=int)
# dp.fill(-np.inf)

dp[-1][0] = 0
for d in reversed(range(DIGIT)):
    k = get_bit(K, d=d)
    # bit=k
    dp[d][0] = max(dp[d][0], dp[d + 1][0] + xor(bit=k, digit=d))
    # k==1 なら bit=0 も OK
    if k == 1:
        dp[d][1] = max(dp[d][1], dp[d + 1][0] + xor(bit=0, digit=d))
    # k 未満の桁をえらんだことがあるなら bit にどっちを選んでも OK
    dp[d][1] = max(dp[d][1], dp[d + 1][1] + xor(bit=0, digit=d))
    dp[d][1] = max(dp[d][1], dp[d + 1][1] + xor(bit=1, digit=d))

print(max(dp[0]))
n, k = map(int, input().split())
x = list(map(int, input().split()))

min_t = 10 ** 9

import bisect

snuke = bisect.bisect_left(x, 0)
if x[snuke] == 0:
    k -= 1
    n -= 1
    del x[snuke]

for i in range(k+1):
    if i == 0:
        left = 0
    elif snuke - i >= 0:
        left = abs(x[snuke - i])
    else:
        left = 10 ** 9

    if k - i == 0:
        right = 0
    elif snuke + k - i - 1 <= n - 1:
        right = abs(x[snuke + k - i - 1])
    else:
        right = 10 ** 9

    min_t = min(min_t, min(left, right) * 2 + max(left, right))

print(min_t)

### FIXED CODE ###

n, k = map(int, input().split())
x = list(map(int, input().split()))

min_t = 10 ** 9

import bisect

snuke = bisect.bisect_left(x, 0)
if snuke < n and x[snuke] == 0:
    k -= 1
    n -= 1
    del x[snuke]

for i in range(k+1):
    if i == 0:
        left = 0
    elif snuke - i >= 0:
        left = abs(x[snuke - i])
    else:
        left = 10 ** 9

    if k - i == 0:
        right = 0
    elif snuke + k - i - 1 <= n - 1:
        right = abs(x[snuke + k - i - 1])
    else:
        right = 10 ** 9

    min_t = min(min_t, min(left, right) * 2 + max(left, right))

print(min_t)