Harryxun/stf_run huggingface dataset:
h, w, k = map(int, input().split())
s = [list(map(int, list(input()))) for _ in range(h)]
result = []
if h*w<=k:
    result.append(0)
else:
    for i in range(2**(h-1)):
        checker, num = 0, i
        while num > 0:
            checker += num%2
            num >>= 1
        x = 0
        c = [0 for _ in range(checker+1)]
        
        num = i
        p = []
        for m in range(h):
            p.append(num%2)
            num >>= 1
        nex = [0 for _ in range(checker+1)]
        for m in range(h):
            nex[p[m]] += s[m][0]
        if max(nex) > k:
            x = float('inf')
            continue

        if all(nex[m]+c[m] <= k for m in range(checker+1)):
            c = [c[I]+nex[I] for I in range(checker+1)]
        else:
            x += 1

        for j in range(1, w):
            num = i
            nex = [0 for _ in range(checker+1)]
            for m in range(h):
                nex[p[m]] += s[m][j]
            if max(nex) > k:
                x = float('inf')
                break            
            
            if all(nex[m]+c[m] <= k for m in range(checker+1)):
                c = [c[I]+nex[I] for I in range(checker+1)]
            else:
                x += 1
                c = nex
        result.append(checker+x)
print(min(result))


### FIXED CODE ###

h, w, k = map(int, input().split())
s = [list(map(int, list(input()))) for _ in range(h)]
result = []
if h*w<=k:
    result.append(0)
else:
    for i in range(2**(h-1)):
        checker, num = 0, i
        while num > 0:
            checker += num%2
            num >>= 1
        x = 0
        c = [0 for _ in range(checker+1)]
        
        num = i
        p = 0
        nex = [0 for _ in range(checker+1)]
        for m in range(h):
            nex[p] += s[m][0]
            p += num%2
            num = num >> 1
        if max(nex) > k:
            x = float('inf')
            continue

        if all(nex[m]+c[m] <= k for m in range(checker+1)):
            c = [c[I]+nex[I] for I in range(checker+1)]
        else:
            x += 1

        for j in range(1, w):
            num = i
            p = 0
            nex = [0 for _ in range(checker+1)]
            for m in range(h):
                nex[p] += s[m][j]
                p += num%2
                num = num >> 1
            if max(nex) > k:
                x = float('inf')
                break            
            
            if all(nex[m]+c[m] <= k for m in range(checker+1)):
                c = [c[I]+nex[I] for I in range(checker+1)]
            else:
                x += 1
                c = nex
        result.append(checker+x)
print(min(result))
a = int(input())
items = input().split(" ")
nums = []
for i in range(a):
  nums.append(int(items[i]))
max_num = max(nums)
min_num = min(nums)
print(max_num - min_num)

### FIXED CODE ###

a = int(input())

if a % 2 == 0:
  print(a)
else:
  print(a * 2)
if __name__ == '__main__':
    N = int(input())
    ans = 0
    for i in range(N):
        l = list(map(int, input().split()))
        ans += abs(l[1]-l[0])
    print(ans

### FIXED CODE ###

if __name__ == '__main__':
    N = int(input())
    ans = 0
    for i in range(N):
        l = list(map(int, input().split()))
        ans += abs(l[1]-l[0]+1)
    print(ans)
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
x = min(A[0],B[0])
ans += x
for j in range(N-1):
    i = j+1
    x = min(A[i],B[i-1]-x)
    ans += x
    x = min(A[i]-x,B[i])
    ans += x
i = i+1
x = min(A[i],B[i-1]-x)
ans += x
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans, x = 0, 0
ans += x
for i in range(N):
    x = min(A[i]-x,B[i])
    ans += x
    x = min(A[i+1],B[i]-x)
    ans += x
print(ans)
import sys
sys.setrecursionlimit(10**7)

n = int(input())
info = []
for _ in range(n-1):
    c, s, f = map(int, input().split())
    info.append([c, s, f])
# print(info)

def func(i, low):
    # print(i, low)
    if i == low:
        # print(info[i][1] + info[i][0])
        return info[i][1] + info[i][0]
    # print(func2(func(i-1, low), info[i][1]))
    return func2(func(i-1, low), info[i][2]) + info[i][0]

def func2(n, f):
    if n <= f:
        return 
    if n % f == 0:
        return n
    else:
        return n//f * f + f

# print(func(n-2, 0))
for i in range(n):
    if i == n-1:
        print(0)
    print(func(n-2, i))

### FIXED CODE ###

n = int(input())
C = []
S = []
F = []
for _ in range(n-1):
    c, s, f = map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)

def f(n, s, f):
    if n <= s:
        return s
    if n % f == 0:
        return n
    else:
        return n // f * f + f

for i in range(n-1):
    now = S[i] + C[i]
    for j in range(i+1, n-1):
        now = f(now, S[j], F[j]) + C[j]
    print(now)
print(0)
from sys import stdin
from collections import deque


class BreadthFirstSearch:
    def __init__(self, num_nodes):
        self.n = num_nodes
        self.graph = [[] for _ in range(self.n)]

    # Edge数分回すことを想定
    def add_edge(self, start, end, undirected=True):
        self.graph[start].append(end)
        if undirected:
            self.graph[end].append(start)

    # depth = distance
    def search(self, start_node):
        order = [-1] * self.n # a bfs ordering of each vertex
        parent = [-1] * self.n # parent of each vertex in the bfs search tree
        depth = [-1] * self.n # the depth of each vertex
        q = deque([(start_node, -1, 0)]) # (vertex, parent, depth)
        num = 0 # current ordering
        while len(q) > 0:
            v, p, d = q.popleft()
            if order[v] < 0: # visited v for the first time
                order[v] = num; parent[v] = p; depth[v] = d
                num += 1
                for u in adj_list[v]:
                    if order[u] >= 0: continue
                    q.append((u, v, d+1))
        return order, parent, depth



# BFS
def breadth_first_search(adj_list, start_node):
    N = len(adj_list)
    order = [-1] * N # a bfs ordering of each vertex
    parent = [-1] * N # parent of each vertex in the bfs search tree
    depth = [-1] * N # the depth of each vertex
    q = deque([(start_node, -1, 0)]) # (vertex, parent, depth)
    num = 0 # current ordering
    while len(q) > 0:
        v, p, d = q.popleft()
        if order[v] < 0: # visited v for the first time
            order[v] = num; parent[v] = p; depth[v] = d
            num += 1
            for u in adj_list[v]:
                if order[u] >= 0: continue
                q.append((u, v, d+1))
    return order, parent, depth


# BFS pypyでAC
def get_result(data):
    N, X, Y = data
    _data = [[i, i+1] for i in range(1, N)]
    _data += [[X, Y]]
    bfs = BreadthFirstSearch(N)
    for val in _data:
        bfs.add_edge(val[0]-1, val[1]-1)
    dist_cnt = [0 for i in range(N)]
    for i in range(N):
        _, _, depth = bfs.search(i)
        for j in range(i, N):
            dist_cnt[depth[j]] += 1
    for i in range(1, N):
        print(dist_cnt[i])


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip('\n').split(' ')))
    get_result(data)


### FIXED CODE ###

from sys import stdin


def get_result(data):
    N, X, Y = data
    dist_cnt = [0 for i in range(N)]
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            min_dist = min([j-i, abs(X-i) + 1 + abs(Y-j), abs(Y-i) + 1 + abs(X-j)])
            dist_cnt[min_dist] += 1
    for i in range(1, N):
        print(dist_cnt[i])


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip('\n').split(' ')))
    get_result(data)
listSi = [0,0,0,0]
i = int(input())
while (i = input()):
    if i == "AC":
        listSi[0] += 1
    elif i == "WA":
        listSi[1] += 1
    elif i == "TLE":
        listSi[2] += 1
    elif i == "RE":
        listSi[3] += 1
print("AC x {listSi[0]}")
print("WA x {listSi[1]}")
print("TLE x {listSi[2]}")
print("RE x {listSi[3]}")


### FIXED CODE ###

listSi = [0,0,0,0]
ic = int(input())
icz = 0
while True:
  icz += 1
  i = input()
  if i == "AC":
    listSi[0] += 1
  elif i == "WA":
    listSi[1] += 1
  elif i == "TLE":
    listSi[2] += 1
  elif i == "RE":
    listSi[3] += 1
  if icz == ic:
    break
print(f"AC x {listSi[0]}")
print(f"WA x {listSi[1]}")
print(f"TLE x {listSi[2]}")
print(f"RE x {listSi[3]}")
# -*- coding: utf-8 -*-
#AGC014A
import sys
#import collections

#n= int(input())

tmp = input().split()
n,k = list(map(lambda a: int(a), tmp))

tmp = input().split()
a = list(map(lambda a: int(a), tmp))

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

maxa=a[0]
tmp=a[0]
for i in range(1,n):
	maxa=max(maxa,a[i])
	tmp=gcd(tmp, a[i])

if(k<=m)and(k%tmp ==0):
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

#print(maxa)
#print(tmp)




### FIXED CODE ###

# -*- coding: utf-8 -*-
#AGC014A
import sys
#import collections

#n= int(input())

tmp = input().split()
n,k = list(map(lambda a: int(a), tmp))

tmp = input().split()
a = list(map(lambda a: int(a), tmp))

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

maxa=a[0]
tmp=a[0]
for i in range(1,n):
	maxa=max(maxa,a[i])
	tmp=gcd(tmp, a[i])

if(k<=maxa)and(k%tmp ==0):
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

#print(maxa)
#print(tmp)
"""
the condition is straightforward.
each element of A and B must multiply to the same value.
to minimise the total of B, simply make that value as small
as possible (since A is fixed).

lcm(2, 3, 4) = 12
therefore B is
12/2, 12/3, 12/4
and the sum of B is
12/2 + 12/3 + 12/4

lcd of a list is loop: lcd(partial, new_value)
lcd(a, b) = ab / gcd(a, b)
"""

from math import gcd


def lcm(list_ints):
    lcm_ongoing = 1
    for val in list_ints:
        lcm_ongoing = int(round(val*lcm_ongoing/gcd(val, lcm_ongoing)))
    return lcm_ongoing


def flatten(N, A):
    # get lcm
    lcm_of_A = lcm(A)
    # get sum of lcm/values
    ans = sum(int(round(lcm_of_A/value)) for value in A)
    modulo_value = int(int(10e9)+7)
    return ans % modulo_value


if __name__ == "__main__":
    test1 = \
"""3
2 3 4"""
    test2 = \
"""5
12 12 12 12 12"""
    test3 = \
"""3
1000000 999999 999998"""
    test = test3
    # N = int(test.split("\n")[0])
    # A = list(map(int, test.split("\n")[1].split()))
    N = int(input())
    A = list(map(int, input().split()))
    print(flatten(N, A))


### FIXED CODE ###

"""
the condition is straightforward.
each element of A and B must multiply to the same value.
to minimise the total of B, simply make that value as small
as possible (since A is fixed).

lcm(2, 3, 4) = 12
therefore B is
12/2, 12/3, 12/4
and the sum of B is
12/2 + 12/3 + 12/4

lcd of a list is loop: lcd(partial, new_value)
lcd(a, b) = ab / gcd(a, b)
"""

from fractions import gcd


def lcm(list_ints):
    lcm_ongoing = 1
    for val in list_ints:
        lcm_ongoing = val*lcm_ongoing//gcd(val, lcm_ongoing)
    return lcm_ongoing


def flatten(N, A):
    # get lcm
    lcm_of_A = lcm(A)
    # get sum of lcm/values
    ans = sum(lcm_of_A//value for value in A)
    modulo_value = int(int(10e8)+7)
    return ans % modulo_value


if __name__ == "__main__":
    test1 = \
"""3
2 3 4"""
    test2 = \
"""5
12 12 12 12 12"""
    test3 = \
"""3
1000000 999999 999998"""
    test = test3
    # N = int(test.split("\n")[0])
    # A = list(map(int, test.split("\n")[1].split()))
    N = int(input())
    A = list(map(int, input().split()))
    print(flatten(N, A))
n,d = map(int,input().split())
w = [list(map(int,input().split())) for a in range(n)]
c = 0
 
for i in range(n-1):
  for j in range(i+1,n):
    b = 0
    for m in range(d):
      b += (w[i][m]-w[j][m])**2
    if (b**0.5)　== float(int(b**0.5)):
      c += 1
      
print(c)

### FIXED CODE ###

n,d = map(int,input().split())
w = [list(map(int,input().split())) for a in range(n)]
c = 0
 
for i in range(n-1):
  for j in range(i+1,n):
    b = 0
    for m in range(d):
      b += (w[i][m]-w[j][m])**2
    if (b**0.5)==float(int(b**0.5)):
      c += 1
      
print(c)
X=int(input())

A=[]
for i in range(X):
  for j in range(X):
    b=i+1
    p=j+1
    if b**p>X:
      break
    elif p>=2 and b**p not in A:
      A.append(b**p)
print(max(A))

### FIXED CODE ###

import math
X=int(input())

A=[1]
for b in range(2,32):
  for p in range(2,10):
    if b**p>X:
      break
    elif b**p not in A:
      A.append(b**p)
print(max(A))
import array

N = int(input())

EVEN = {}
ODD = {}
COLOR = array.array('i', [-1]*(N+1))

for i in range(1,N+1):
    EVEN[i] = []
    ODD[i] = []

for i in range(N-1):
    u,v,w = list(map(int, input().split()))
    if w % 2 == 0:
        EVEN[u].append(v)
    else:
        ODD[u].append(v)

print(EVEN)
print(ODD)

def determine_color(i):
    for j in EVEN[i]:
        if COLOR[j] == 0:
            return 0
        elif COLOR[j] == 1:
            return 1
    for j in ODD[i]:
        if COLOR[j] == 0:
            return 1
        elif COLOR[j] == 1:
            return 0

def reverse_color(color):
    if color == 0:
        return 1
    if color == 1:
        return 0
    
COLOR[1] = 0

for i in range(1,N+1):
    if COLOR[i] == -1:
        color = determine_color(i)
        COLOR[i] = color
    else:
        color = COLOR[i]

    for j in EVEN[i]:
        COLOR[j] = color
    for j in ODD[i]:
        COLOR[j] = reverse_color(color)


for i in range(1,N+1):
    print(COLOR[i])


### FIXED CODE ###

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

import sys
#import numpy
#from collections import deque
sys.setrecursionlimit(10**5)

def input():
    return sys.stdin.readline().rstrip('\n')

N = int(input())

childsof = [[] for _ in range(N+1)]

for _ in range(N-1):
    u,v,w = list(map(int, input().split()))
    childsof[u].append((v,w))
    childsof[v].append((u,w))

distances = [-1]*(N+1)
distances[1] = 0

def dfs(i):
    childs = childsof[i]

    for c in childs:
        j = c[0]
        if distances[j] == -1:
            distances[j] = distances[i] + c[1]
            dfs(j)

dfs(1)

for d in distances[1:]:
    if d % 2 == 0: #even
        print(0)
    else:
        print(1)
# coding: utf-8

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

## S中で、'AC'であるインデックスを求める
num = [0] * (N+1)
i = 0
for i in range(N):
    if S[i]=='A' and S[i+1]=='C':
        num[i + 1] = num[i] + 1
    else:
        num[i + 1] = num[i]

#print(num)

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


### FIXED CODE ###

# coding: utf-8

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

num = [0] * (N+1)

for i in range(N):
    #if S[i]=='A' and S[i+1]=='C':
    if S[i:i+2] =='AC':
        num[i + 1] = num[i] + 1
    else:
        num[i + 1] = num[i]

        

for i in range(Q):
    l, r = map(int, input().split())
    print( num[r-1] - num[l-1] )
import math

A, B, H, M = map(int, input().split())

theta = (H * 30 - M * 9.5) * math.pi / 180

ans = math.sqrt(A * A + B * B - 2 * A * B * math.cos(theta))

print(ans)
~                                                                                                                       ~                                                                                                                       ~                                                                                                                       ~                                                                                                                       ~                                         

### FIXED CODE ###

import math

A, B, H, M = map(int, input().split())

theta = (H * 30 - M * 5.5) * math.pi / 180

ans = math.sqrt(A * A + B * B - 2 * A * B * math.cos(theta))

print(ans)
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()
A = li()

max_a = [0] * (N+1)

max_a[0] = 1 - A[0]

for i in range(1, N+1):
    max_a[i] = max_a[i-1] * 2 - A[i]
    if max_a[i] < 0:
        print(-1)
        exit()

num = [0]*(N)
cnt = 0
tmp = A[-1]
for i in reversed(range(N)):

    if tmp <= max_a[i]:
        cnt += tmp
    else:
        cnt += max_a[i]
        tmp = max_a[i]

cnt += sum(A)

print(cnt+A[-2])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()
A = li()

if N == 0:
    if A==[1]:
        print(1)
    else:
        print(-1)
    exit()

max_a = [0] * (N+1)
max_a[0] = 1 - A[0]

for i in range(1, N+1):
    max_a[i] = max_a[i-1] * 2 - A[i]
    if max_a[i] < 0:
        print(-1)
        exit()

cnt_list = [0]*(N)
cnt_list[-1] = min(A[-1], max_a[N-1])

for i in reversed(range(N-1)):
    if cnt_list[i+1] + A[i+1] <= max_a[i]:
        cnt_list[i] = cnt_list[i+1] + A[i+1]
    else:
        cnt_list[i] = max_a[i]

cnt = sum(cnt_list[:N+1]) + sum(A)

print(cnt)
x,y=map(int,input().split())
 
for i in range(x+1):
  if i*4+(x-i)*2==y:
    print("Yes")
    
else:
  print("No")

### FIXED CODE ###

arr=list(map(int,input().split()))

print(arr.index(0)+1)
H,W,N = [int(input()) for i in range(3)]
n = 1
a = n * W
b = n * H
while a or b > N:
  if H < W and a > N:
    print(n)
	else:
      n += 1
  if W < H and b > N:
    print(n)
    else:
      n += 1
	

  
  
  



### FIXED CODE ###

H,W,N = [int(input()) for i in range(3)]
for o in range(1,10000):
  if H <= W and N / o <= W:
    break
  elif H >= W and N / o <= H:
    break
print(o)
#C
import sys
sys.setrecursionlimit(1000000)
mod=10**9+7
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
def f(x):
    b=1
    c=1
    if x==1 or x==0:
        return 1
    else:
        for i in range(x-1):
            b,c=(b+c)%mod,b
        return b
s=f(a[0]-1)
for i in range(1,m):
    if a[i]-a[i-1]==1:
        print(0)
        break
    s=(s*f(a[i]-a[i-1]-2))%mod
else:
    s=(s*f(n-a[m-1]-1))%mod
    print(s)

### FIXED CODE ###

#C
mod=10**9+7
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
def f(x):
    b=1
    c=1
    if x==1 or x==0:
        return 1
    else:
        for i in range(x-1):
            b,c=(b+c)%mod,b
        return b
if m>=1:
    s=f(a[0]-1)
    for i in range(1,m):
        if a[i]-a[i-1]==1:
            print(0)
            break
        s=(s*f(a[i]-a[i-1]-2))%mod
    else:
        s=(s*f(n-a[m-1]-1))%mod
        print(s)
else:
    print(f(n))
from collections import Counter





if __name__ == "__main__":
    #入力取得
    N = int(input())

    p = []


    results = [[] for i in range(N)]

    for row in results:
        for i in range(N):
            row.append('')

    tmp = []



    for i in range(N):
        l = list(map(int, input().split()))
        p.append(l)


    for i in range(len(p)):
        for j in range(i+1, len(p)):

            if p[i][0] == p[j][0]:
                r = N*N
            else:
                r = (p[i][1]-p[j][1])/(p[i][0]-p[j][0])

            results[i][j] = r

            tmp.append(r)



    counter = Counter(tmp)
    max_r = counter.most_common()[0][0]
    # print(max_r)

    results2 = [0]*N


    for i in range(len(results)):
        for j in range(i+1,len(results)):
            if results[i][j] == max_r:
                results2[i] += 1




    tmp_ans = N - (max(results2) + 1)
    if tmp_ans == 0:
        print(1)
    else:
        print(tmp_ans)


### FIXED CODE ###

n = int(input())
a = [tuple(map(int,input().split())) for i in range(n)]

m = dict()


ans = 0


for i in range(n):
    for j in range(n):
        if i !=j:
            x = a[i][0] - a[j][0]
            y = a[i][1] - a[j][1]

            p = (x,y)

            if p not in m:
                m[p] = 0

            m[p] += 1

            ans = max(m[p], ans)



print(n-ans)
N,M=map(int,input().split())
if M>=1:
    s=[0]*M
    c=[0]*M
    for i  in range(M):
      s[i],c[i]=map(int,input().split())

    a=0
    for i in range(M-1):
       for j in range(i+1,M):
        if s[i]==s[j] and c[i]!=c[j]:
          a+=1
    if a==0:
      u_=[0,0,0]
      for i in range(M):
        u_[s[i]-1]=c[i]
      if max(s)!=3 and N==2:
        if min(s)!=1 and u_[0]==0:
          print(10+u_[1])
        elif min(s)==1 and u_[0]==0:
          print(-1)
        else:
          print(u_[0]*10+u_[1])
      elif N==3:
        if min(s)!=1 and u_[0]==0:
          print(100+u_[1]*10+u_[2])
        elif min(s)==1 and u_[0]==0:
          print(-1)
        else:
          print(100*u_[0]+10*u_[1]+u_[2])
      elif N==1 and max(s)==1 and min(s)==1:
        print(c[0])
      else:
        print(-1)
    else:
      print(-1)
else:
  if N==1:
    print(0)
  else:
    N>=2:
      print(10**(N-1))
      


### FIXED CODE ###

N,M=map(int,input().split())
if M>=1:
    s=[0]*M
    c=[0]*M
    for i  in range(M):
      s[i],c[i]=map(int,input().split())

    a=0
    for i in range(M-1):
       for j in range(i+1,M):
        if s[i]==s[j] and c[i]!=c[j]:
          a+=1
    if a==0:
      u_=[0,0,0]
      for i in range(M):
        u_[s[i]-1]=c[i]
      if max(s)!=3 and N==2:
        if min(s)!=1 and u_[0]==0:
          print(10+u_[1])
        elif min(s)==1 and u_[0]==0:
          print(-1)
        else:
          print(u_[0]*10+u_[1])
      elif N==3:
        if min(s)!=1 and u_[0]==0:
          print(100+u_[1]*10+u_[2])
        elif min(s)==1 and u_[0]==0:
          print(-1)
        else:
          print(100*u_[0]+10*u_[1]+u_[2])
      elif N==1 and max(s)==1 and min(s)==1:
        print(c[0])
      else:
        print(-1)
    else:
      print(-1)
else:
  if N==1:
    print(0)
  else:
      print(10**(N-1))
N = input()
count = 0

for i in range(N):
    if N[i] == 7:
        print('yes')
        count += 1
        break
    
if count == 0:
    print('no')

### FIXED CODE ###

N = input()
length_N = len(N)
count = 0

for i in range(length_N):
    if N[i] == '7':
        print('Yes')
        count += 1
        break
    
if count == 0:
    print('No')
def f_max(X, digit):
    if X == 2**digit - 1:
        return sum([max(Ad[i], N - Ad[i]) * (2**i) for i in range(digit)])
    elif X >= 2**(digit-1):
        return max((N - Ad[digit-1]) * (2**(digit-1)) + f_max(X-2**(digit-1), digit-1), f_max(2**(digit-1)-1, digit-1))
    else:
        return Ad[digit-1] * (2**(digit-1)) + f_max(X, digit-1)

N, K = map(int, input().split())
A = list(map(int, input().split()))
K_max, digits = 2*10**12, 0
while K_max > 0
    K_max >>= 1
    digits += 1

Ad = {i:0 for i in range(digits)}
for a in A:
    for i in range(digits):
        Ad[i] += a % 2
        a >>= 1

print(f_max(K, digits))

### FIXED CODE ###

def f_max(X, digit):
    if X == 0:
        return sum([Ad[i] * (2**i) for i in range(digit)])
    elif X == 2**digit - 1:
        return sum([max(Ad[i], N - Ad[i]) * (2**i) for i in range(digit)])
    elif X >= 2**(digit-1):
        return max((N - Ad[digit-1]) * (2**(digit-1)) + f_max(X-2**(digit-1), digit-1), Ad[digit-1] * (2**(digit-1)) + f_max(2**(digit-1)-1, digit-1))
    else:
        return Ad[digit-1] * (2**(digit-1)) + f_max(X, digit-1)

N, K = map(int, input().split())
K_max, digits = 2*10**12, 0
while K_max > 0:
    K_max >>= 1
    digits += 1

Ad = [0]*digits
for a in list(map(int, input().split())):
    for i in range(digits):
        Ad[i] += a % 2
        a >>= 1

print(f_max(K, digits))