Harryxun/stf_run huggingface dataset:
import numpy as np
n=int(input())
y=list(map(int,input().split()))
y=list(map(lambda x: x*2,y))
A=np.zeros((n,n),dtype='int')
for i in range(n-1):
  for j in range(i,i+2):
    A[i][j]=1
A[n-1][0],A[n-1][n-1]=1,1
b=np.linalg.solve(A,y)
print(*b)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[sum(a)-2*sum(a[1:n-1:2])]
for i in range(1,n):
  b.append(2*a[i-1]-b[-1])
print(*b)
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(int argc, char const* argv[])
{
	string s;
	cin >> s;
	
	deque<char> q;
	rep(i, s.length()){
		if(s[i] == 'B' && !q.empty()){
			q.pop_back();
		} else if(s[i] != 'B'){
			q.push_back(s[i]);
		}
	}
	
	rep(i, q.size()){
		cout << q[i];
	}
	
	cout << endl;
	return 0;
}


### FIXED CODE ###

a = input()
ans = ""
for i in a:
    if i == "0" or i == "1":
        ans += i
    
    elif len(ans) > 0 :
        ans = ans[:len(ans)-1]

print(ans)
import math
 
a,b = map(int,input().split())
 
x = math.gcd(a,b)
 
print(a*b//x)

### FIXED CODE ###

a = int(input())
b = int(input())
 
print(6-a-b)
N = int(input())
if N[0] == 7 or N[1] == 7 or N[2] == 7:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

N = input()
ans = "No"
if N[0] == "7" or N[1] == "7" or N[2] == "7":
  ans = "Yes"
print(ans)
N = int(input().strip())
A = list(map(int, input().strip().split()))

mindiv = -1
for a in range(A):
  if mindiv == -1:
    mindiv = bin(a) - bin(a).rstrip('0')
  else:
    tmp = bin(a) - bin(a).rstrip('0')
    if tmp < mindiv:
      mindiv = tmp

print(mindiv)

### FIXED CODE ###

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

mindiv = -1
for a in A:
  if mindiv == -1:
    mindiv = len(bin(a)) - len(bin(a).rstrip('0'))
  else:
    tmp = len(bin(a)) - len(bin(a).rstrip('0'))
    if tmp < mindiv:
      mindiv = tmp

print(mindiv)
a = map(int, input().split())
a.sort()
for i in 3:
  print (a[i])

### FIXED CODE ###

a = list(map(int, input().split()))
a.sort()
print(a[0],a[1],a[2])
import numpy as np
n,k=map(int, input().split())
a=np.int64(list(map(int, input().split()))+[10**8]*(k+1))
dp=np.ones(n+k+10)*1000
dp[0]=0
s=np.arange(k)+1
for i in range(n+1):
    dp[s+i]=np.minimum(dp[s+i],dp[i]+np.abs(a[s+i]-a[i]))
print(int(dp[n-1]))

### FIXED CODE ###

n,k=map(int, input().split())
a=list(map(int, input().split()))
dp=[0]*n
for i in range(1,n):
    m=10**9
    for j in range(max(0,i-k),i):
        m=min(m,dp[j]+abs(a[j]-a[i]))
    dp[i]=m
print(dp[-1])
n = int(input())
seq_str = input().split(" ")
seq = [int(s) for s in seq_str]
counter = 0

for i in range(1,n-1):
    if seq[i-1] < sqe[i] and seq[i] < seq[i+1]
    counter =+ 1
print(counter)

### FIXED CODE ###

n = int(input())
seq_str = input().split(" ")
seq = [int(s) for s in seq_str]
counter = 0

for i in range(1,n-1):
    if (seq[i-1]-seq[i])*(seq[i+1]-seq[i]) < 0:
        counter += 1
print(counter)
a,b,k = map(int,input().split())
if a or b % k ==0:
	print("OK")
else:
    print("NG"

### FIXED CODE ###

K=int(input())
A,B=map(int,input().split())
ans="NG"

for i in range(1001):
  if A<=i*K and i*K<=B:
    ans="OK"
    break

print(ans)
import math
a=list(map(int,input().split()))
def W(x, y):
    return (x * y) // math.gcd(x, y)
print(W(a[0], a[1]))

### FIXED CODE ###

import fractions
a=list(map(int,input().split()))
def W(x, y):
    return (x * y) // fractions.gcd(x, y)
print(W(a[0], a[1]))
import math

S = input()
K = int(input())

ps = []

for s in S:
    i = int(s)
    if(i == 1):
        p == -1
    else:
        p = 5*(10**15) * math.log2(i)
    ps.append(p)

sum = 0
index = 0
for p in ps:
    if not p == -1:
        sum += p
    else:
        K -= 1
        
    if math.log2(K) < sum:
        print(S[index])
        break
        
    index += 1

### FIXED CODE ###

S = input()
K = int(input())

for i, k in enumerate(range(K)):
    if S[k] != '1':
        print(S[k])
        break
    if i == K - 1:
        print('1')
X, Y, Z = [int(a) for b in input() .split()]
print(Z, X, Y)

### FIXED CODE ###

X, Y, Z = map(int, input().split())
print(Z, X, Y)
target=input()
n = len(target)-1
bit_list = [list(f"{i:0{n}b}") for i in range(2**n)]
answer = 0

for bits in bit_list:
    one_number_indexes=[i for i, x in enumerate(bits) if x == '1']
    # ここで1がある場所を取得
    start=0    
    # 街灯の箇所で文字を区切る関数を実装
    for index in one_number_indexes:
        answer=answer+int(target[start:index+1])
        start=index+1
    answer=answer+int(target[start:n+1])

print(answer)

### FIXED CODE ###

import itertools

target=input()
n = len(target)-1
#bit_list = [list(f"{i:0{n}b}") for i in range(2**n)]
status = [['0', '1'] for _ in range(n)]
bit_list = list(itertools.product(*status)) 


answer = 0

for bits in bit_list:
    one_number_indexes=[i for i, x in enumerate(bits) if x == '1']
    
    # ここで1がある場所を取得
    start=0    
    # 街灯の箇所で文字を区切る関数を実装
    for index in one_number_indexes:
        answer=answer+int(target[start:index+1])
        start=index+1
    answer=answer+int(target[start:n+1])

print(answer)
n,m = map(int, input().split())
sc= [map(int, input().split()) for _ in range(m)]
s, c = [list(i) for i in zip(*sc)]



for ans in range(10**n):
    ans = str(ans)
    if len(ans) == n and all(ans[s[j]-1] == str(c[j]) for j in range(m)):
        print(ans)
        exit()
print(-1)

### FIXED CODE ###

# n,m = map(int, input().split())
# sc = [map(int, input().split()) for _ in range(m)]
# s, c = [list(i) for i in zip(*sc)]
#
#
#
# for i in range(10**n):
#     ans = str(i)
#     if len(i) == n and all([i[s[j]-1] == str(c[j]) for j in range(m)]):
#         print(ans)
#         exit()
#
#
# print(-1)

n, m = map(int, input().split())

s, c = [], []
for _ in range(m):
    s_, c_ = map(int, input().split())
    s.append(s_)
    c.append(c_)

for i in range(10 ** n):
    ans = str(i)
    if len(ans) == n and all([ans[s[j] - 1] == str(c[j]) for j in range(m)]):
        print(ans)
        exit()

print(-1)
from collections import Counter

def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

n, m, r = read_line(int, int, int)

rs = [int(r) for r in input().split()]

cities = Counter()

routes = {}
costs = {}
for _ in range(m):
    a, b, c = read_line(int, int, int)

    cities[a] = 1
    cities[b] = 1

    if a in routes:
        routes[a][b] = c
    else:
        routes[a] = { b : c }

    if b in routes:
        routes[b][a] = c
    else:
        routes[b] = { a : c }

for a in cities.keys():
    for b in cities.keys():
        if a not in costs:
            costs[a] = {}
        if b not in costs[a]:
            if a in routes and b in routes[a]:
                costs[a][b] = routes[a][b]
            else:
                costs[a][b] = 100000 + 1

# print('*')

keys = list(cities.keys())

for k in keys:
    for i in keys:
        for j in keys:
            c = costs[a][k] + costs[k][b]
            if a != b and costs[a][b] > c:
                costs[a][b] = c

# print('*')

def cost(selected):
    c = 0
    for i in range(len(selected) - 1):
        a = selected[i]
        b = selected[i + 1]
        c += costs[a][b]
    return c

smallest = 100000 + 1

def f(selected, rest):
    global smallest
    if len(rest) == 0:
        c = cost(selected)
        if smallest > c:
            smallest = c
    else:
        for i in range(len(rest)):
            r = rest[i]
            rest_copy = rest[:]
            del rest_copy[i]
            if cost(selected + [r]) < smallest:
                f(selected + [r], rest_copy)

f([], keys)
print(smallest)


### FIXED CODE ###

n = input()

if n[0] == '9' or n[1] == '9':
    print('Yes')
else:
    print('No')
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
h = [INT() for _ in range(N)]

h.sort()

ans = INF
for i in range(K):
	ans = min(ans, h[i+K-1]-h[i])

print(ans)


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
h = [INT() for _ in range(N)]

h.sort()

ans = INF
for i in range(N-K+1):
	ans = min(ans, h[i+K-1]-h[i])

print(ans)
N, M = list(map(int, input().split()))
D = list(map(int, input().split()))
UB = [list(map(int, input().split())) for _ in range(M)]

R = {}
for i in range(M):
  a, b = UB[i]
  a -= 1
  b -= 1
  if a not in R: R[a] = [[b, i]]
  else: R[a].append([b, i])
  if b not in R: R[b] = [[a, i]]
  else: R[b].append([a, i])

DD = [[0] * 2 for _ in range(N)]
for i in range(N):
  DD[i][0] = D[i]
  DD[i][1] = i
DD.sort()
L = [0] * N
H = [0] * M
LL = [[-1] * 2 for _ in range(N)]
for i in range(N):
  h, x = DD[i]
  if L[x] == 0:
    if LL[x][0] == -1:
      for n, m in R[x]:
        LL[n] = [x, h]
        if D[n] == D[x] or L[n] != 0:
          H[m] = h
          if L[n] == 1:
            L[n] = 1
            L[x] = 2
          else:
            L[n] = 2
            L[x] = 1
          break
      else:
        print(-1)
        exit()
    else:
      n, m = [LL[x]]
      H[m] = h
      if L[n] == 1:
        L[n] = 1
        L[x] = 2
      else:
        L[n] = 2
        L[x] = 1

t = ""
for i in range(N):
  if L[i] == 1:
    t += "B"
  else:
    t += "W"
print(t)
for i in range(M):
  if H[i] == 0:
    print(10 ** 9)
  else:
    print(H[i])


### FIXED CODE ###

import sys
input = sys.stdin.readline
N, M = list(map(int, input().split()))
D = list(map(int, input().split()))
UB = [list(map(int, input().split())) for _ in range(M)]

LL = [[-1] * 2 for _ in range(N)]
for i in range(M):
  a, b = UB[i]
  a -= 1
  b -= 1
  if D[a] < D[b]:
    LL[b] = [a, i]
  elif D[a] > D[b]:
    LL[a] = [b, i]
  else:
    LL[a] = [b, i]
    LL[b] = [a, i]

DD = [[0] * 2 for _ in range(N)]
for i in range(N):
  DD[i][0] = D[i]
  DD[i][1] = i
DD.sort()
L = [0] * N
H = [0] * M

for i in range(N):
  h, x = DD[i]
  if L[x] == 0:
    if LL[x][0] == -1:
      print(-1)
      exit()
    else:
      n, m = LL[x]
      H[m] = h
      if L[n] == 1:
        L[n] = 1
        L[x] = 2
      else:
        L[n] = 2
        L[x] = 1

for i in range(N):
  if L[i] == 1:
    L[i] = "B"
  else:
    L[i] = "W"
print("".join(list(map(str, L))))
for i in range(M):
  if H[i] == 0:
    print(10 ** 9)
  else:
    print(H[i])
X=int(input())
for x in range(X,2*X):
    for i in range(2,int(x**.5)+1):
      if X%i==0:
        break:
      else:
        print(x)
        break


### FIXED CODE ###

X=int(input())
for x in range(X,2*X):
    for i in range(2,int(x**.5)+1):
        if x%i==0:
            break
    else:
        print(x)
        break
N,M = map(int,input().split())
path_list = []
for i in range(M):
    z = []
    path_list.append(z)
for i in range(M):
    A,B = map(int,input().split())
    path_list[A-1].append(B)
    path_list[B-1].append(A)
chk = [0] * N

def bfs(a,chk,path):
    queue = [a]
    while queue:
        b = queue.pop(0)
        for i in range(len(path[b-1])):
            if chk[path[b-1][i]-1] == 0:
                queue.append(path[b-1][i])
                chk[path[b-1][i]-1] =b
    return chk
bfs(1,chk,path_list)
print("Yes")
for i in range(N):
    if i == 0:
        continue
    else:
        print(chk[i])


### FIXED CODE ###

N,M = map(int,input().split())
path_list = []
for i in range(N):
    z = []
    path_list.append(z)
for i in range(M):
    A,B = map(int,input().split())
    path_list[A-1].append(B)
    path_list[B-1].append(A)
chk = [0] * N

def bfs(a,chk,path):
    queue = [a]
    while queue:
        b = queue.pop(0)
        for i in range(len(path[b-1])):
            if chk[path[b-1][i]-1] == 0:
                queue.append(path[b-1][i])
                chk[path[b-1][i]-1] =b
    return chk
bfs(1,chk,path_list)
print("Yes")
for i in range(N):
    if i == 0:
        continue
    else:
        print(chk[i])
x = sorted(map(int, input().split()), reverse=True)
for i in range(3):
    print(x[i])

### FIXED CODE ###

x = sorted([int(input()) for i in range(10)], reverse=True)
for i in range(3):
    print(x[i])
a=input().split(' ')
b=int(a[0])
c=int(a[1])
data=input().split(' ')
data_1=0
data_2=0
for i in range(b):
	data_1=int(data[i])
	if data_1 >= c:
		data_2=data_2+1
	else:
		pass
print(data_2)

### FIXED CODE ###

a=int(input())
b=a+1
c=0
d=0
for i in range(b):
	c=i%2
	if c == 1:
		d=d+1
	else:
		pass
e=d/a
print(e)
N = int(input())
max_cnt = 0

for n in range(1, N+1):
    cnt = 0
    for div in range(1, 7):
        if n % 2**div == 0:
            cnt += 1
    if cnt > max_cnt:
        max_cnt = cnt
        ans = n
print(ans)

### FIXED CODE ###

N = int(input())
max_cnt = 0
ans = 0
for n in range(1, N+1):
    cnt = 0
    for div in range(0, 7):
        if n % 2**div == 0:
            cnt += 1
    if cnt > max_cnt:
        max_cnt = cnt
        ans = n
print(ans)
n, d = map(int, input())
print(-(-n // (1 + d * 2)))


### FIXED CODE ###

n, d = map(int, input().split())
print(-(-n // (1 + d * 2)))
import sys

N,M = map(int,input().split())
SC=[]

ans=0

for i in range(M):
    S,C = map(int,input().split())
    SC.append((S,C))

if N==1:
    if SC[0][1]==0:
        print(0)
        sys.exit()

for i in range(M):
    for j in range(M):
        if SC[i][0]==SC[j][0]:
            if not SC[i][1]==SC[j][1]:
                print(-1)
                sys.exit()
    if not N==1:
            if SC[i][0]==1:
                if SC[i][1]==0:
                    print(-1)
                    sys.exit()


            
SC=tuple(set(SC))
l=len(SC)

for i in range(l):
    a=SC[i][0]
    b=SC[i][1]
    ans=ans+(10**(N-a))*b

print(ans)

### FIXED CODE ###

import sys

N,M = map(int,input().split())
SC=[]

ans=0

for i in range(M):
    S,C = map(int,input().split())
    SC.append((S,C))

for i in range(M):
    for j in range(M):
        if SC[i][0]==SC[j][0]:
            if not SC[i][1]==SC[j][1]:
                print(-1)
                sys.exit()
    if not N==1:
            if SC[i][0]==1:
                if SC[i][1]==0:
                    print(-1)
                    sys.exit()

if M==0:
    if N==1:
        print(0)
        sys.exit()
    else:
        print(10**(N-1))
        sys.exit()

            
SC=tuple(set(SC))
l=len(SC)

for i in range(l):
    a=SC[i][0]
    b=SC[i][1]
    ans=ans+(10**(N-a))*b
if not N==1:
    if ans<10**(N-1):
        ans=ans+10**(N-1)

print(ans)
#coding: UTF-8

def Rectangle(a,b):
    return a*b,2*a+2*b

if __name__=="__main__":
    a = input()
    b = input()
    area,length = Rectangle(int(a),int(b))
    print(area,length)

### FIXED CODE ###

#coding: UTF-8

def Rectangle(a,b):
    return a*b,2*(a+b)

if __name__=="__main__":
    a = input().split(" ")
    area,length = Rectangle(int(a[0]),int(a[1]))
    print(area,length)
n,k=map(int,input().split());mod=10**9+7;print((n*(n+1)*(n+2)//6-k*(k-1)*(3*n-2*k+4)//6+n-k+2)%mod

### FIXED CODE ###

n,k = [int(i) for i in input().split()]
mod = 10**9+7
chk = 0
ans = 0
for i in range(n+1):
  chk += (n + i*n +1 -(i+1)*i)%mod
  chk %= mod
for i in range(k-1):
  ans += (n + i*n +1 -(i+1)*i)%mod
  ans %= mod
print((chk-ans)%mod)
n, m , d = map(int, input().split())
A = [0]*n
for i in range(1,m):
    B = A
    A = [0]*n
    for j in range(n):
        for k in range(n):
            if k + 1 - d >= 0 and k + 1 + d <= n:
                A[j] = B[j] + 2
            elif k + 1 - d >= 0 and k + 1 + d > n:
                A[j] = B[j] + 1
            elif k + 1 - d < 0 and k + 1 + d <= n:
                A[j] = B[j] + 1
            if k + 1 - d >= 0 and k + 1 + d <= n:
                A[j] += 2
            elif k + 1 - d >= 0 and k + 1 + d > n:
                A[j] += 1
            elif k + 1 - d < 0 and k + 1 + d <= n:
                A[j] += 1
print(sum(A)/(n**m))

### FIXED CODE ###

n, m, d = map(int, input().split())
if d == 0:
    C = n
else:
    C = 2*(n-d)
print(C*(m-1)/n**2)
n = int(input())
s = [input() for _ in range(2)]
if n == 1:
    print(3)
    exit()
law = 10 ** 9 + 7
dp = [[0 for _ in range(2)] for _ in range(n)] # 直前の色と同じかどうか
dp[0][0] = 3
dp[0][1] = 0
dp[1][0] = 0
dp[1][1] = 6
sideway = s[0][1] == s[0][2]
for i in range(2, n):
    if sideway:
        sideway = False
        if s[0][i-2] == s[1][i-2]: # |=
            dp[i][0] = 0
            dp[i][1] = sum(dp[i-1])
        else: # ==
            dp[i][0] = 0
            dp[i][1] = dp[i-1][0] * 2 + dp[i-1][1]
    else:
        if s[0][i] == s[1][i]:
            sideway = False
            if s[0][i-1] == s[1][i-1]: # ||
                dp[i][0] = 0
                dp[i][1] = sum(dp[i-1]) * 2
            else: # =|
                dp[i][0] = 0
                dp[i][1] = sum(dp[i-1])
        else:
            sideway = True
            if s[0][i-1] == s[1][i-1]: # |-
                dp[i][0] = 0
                dp[i][1] = sum(dp[i-1]) * 2
            else: # =-
                dp[i][0] = sum(dp[i-1])
                dp[i][1] = 2 * sum(dp[i-2]) - dp[i][0]
    dp[i][0] %= law
    dp[i][1] %= law
print(sum(dp[i-1]))

### FIXED CODE ###

n = int(input())
s = [input() for _ in range(2)]

ans = 1
law = 10 ** 9 + 7

i = 0
while i < n:
    if s[0][i] == s[1][i]:
        if i == 0:
            ans *= 3
        else:
            ans *= 3 - len({s[0][i-1], s[1][i-1]})
        i += 1
    else:
        if i == 0:
            ans *= 6
        else:
            if s[0][i-1] == s[1][i-1]:
                ans *= 2
            else:
                ans *= 3
        i += 2
    ans %= law
print(ans)
import math
a,b,c,d = map(int,input().split())
gcd_cd = c*d/math.gcd(c,d)
num_divb = int(b)-int(b/c)-int(b/d)+int(b/gcd_cd)
num_diva = -(a-1)+int((a-1)/c)+int((a-1)/d)-int((a-1)/gcd_cd)

print(int(num_divb)+int(num_diva))


### FIXED CODE ###

from fractions import gcd
a,b,c,d = map(int,input().split())
lcm = int(c*d/gcd(c,d))
num_divb = int(b)-int(b//c)-int(b//d)+int(b//lcm)
num_diva = +(a-1)-int((a-1)//c)-int((a-1)//d)+int((a-1)//lcm)

print(int(num_divb)-int(num_diva))
import sys
import numpy as np

N = int(sys.stdin.readline())
A = [int(x) for x in sys.stdin.readline().split()]
A.sort(reverse=True)

ans = 0
for i in range(len(A)):
    for j in range(i+1,len(A)):
        if A[i] % A[j] == 0:
            break
    else:
        ans += 1

print(ans)

### FIXED CODE ###

import sys
from collections import Counter

MAX_A = 10**6 + 5

N = int(sys.stdin.readline())
A = [int(x) for x in sys.stdin.readline().split()]
# A.sort(reverse=True)

dp = [True] * MAX_A
Ac = Counter(A)

for k, v in Ac.items():
    if v > 1:
        dp[k] = False
    for n in range(2*k, MAX_A, k):
        dp[n] = False

ans = 0
for a in A:
    if dp[a]:
        ans += 1

print(ans)
x,y=map(int,input().split());a=[4,6,9,11];b=[1,3,5,7,8,10,12];print(['No','Yes'][x in a and y in a+x in b and y in b])

### FIXED CODE ###

x,y=map(int,input().split());a=[4,6,9,11];b=[1,3,5,7,8,10,12];print(['No','Yes'][int(x in a)*(y in a)+ int(x in b)*(y in b)])
def get_primes(n):
    x = [0,0]+[i for i in range(2,n+1)]
    for i in range(int(n**0.5+1)):
        e = x[]
        if e !=0:
            for j in range(e*2, n+1,e):
                x[j] = 0
    return filter(None, x)

PRIMES = get_primes(10000)
n = int(input())
c = 0
for i in range(n):
    p = int(input())
    f = 1
    for e in PRIMES:
        if e >= p:
            break
        if p % e == 0:
            f = 0
            break
    c += f
print c

### FIXED CODE ###

def get_primes(n):
    x = [0,0]+[i for i in range(2,n+1)]
    for i in range(int(n**0.5+1)):
        e = x[i]
        if e !=0:
            for j in range(e*2, n+1,e):
                x[j] = 0
    return filter(None, x)

PRIMES = get_primes(10000)
n = int(input())
c = 0
for i in range(n):
    p = int(input())
    f = 1
    for e in PRIMES:
        if e >= p:
            break
        if p % e == 0:
            f = 0
            break
    c += f
print c
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
m = max(K, max(A))
l = len('{0:b}'.format(m))
fs = '{0:0'+str(l)+'b}'
import numpy as np
a = np.array([[int(i) for i in fs.format(a)] for a in A])
ans = ''

for i in range(N):
    ik = a[:, [i]].sum()
    zk = N - ik
    if ik > zk:
        ans += '0'
    else:
        ans += '1'

def f(X):
    return sum([x ^ X for x in A])

print(f(int(ans,2)))


### FIXED CODE ###

from numpy import array
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
k = '{0:040b}'.format(K)
a = array([[int(i) for i in '{0:040b}'.format(a)] for a in A])
ans = list(k)

f = False
for i in range(40):
    if k[i] == '0' and not f:
        continue
    ik = a[:, [i]].sum()
    zk = N - ik
    if ik > zk:
        ans[i] = '0'
        f = True
    else:
        ans[i] = '1'

ans = ''.join(ans)
k = int(ans, 2)
print(sum([x ^ k for x in A]))
s = input()

cnt = 0
for i in range(len(s)//2):
    if s[i] != s[-i-1]:
        cnt += 1
        s[-i-1] = s[i]
print(cnt)


### FIXED CODE ###

s = input()

cnt = 0
s = list(s)
for i in range(len(s)//2):
    if s[i] != s[-i-1]:
        cnt += 1
        s[-i-1] = s[i]
print(cnt)
N,K=map(int,input().split())
S=input()

#K=2
#S="011101010110011"
#N=len(S)

LIST=[[[0] for j in range (2)]for i in range(N)]

t=S[0]
c=0
k=0
for i in range(N):
    if(t!=S[i]):
        LIST[k][0]=c
        LIST[k][1]=t
        t=S[i]
        k+=1
        c=0
    c+=1

LIST[k][0]=c
LIST[k][1]=t
LIST=LIST[0:k+1]
MAX=0

s=0
l=0
r=0
f=0
if(LIST[0][1]=="1"):
    s+=LIST[0][0]
    l=0
    r=1
    f=1
MAX=0

while(K>0):
    s+=LIST[r][0]
    K-=1
    if(len(LIST)-1==r):
        break
    r+=1
    s+=LIST[r][0]
    if(len(LIST)-1==r):
        break
    r+=1

if f==1:
    while(r<N):
        s-=LIST[l][0]
        l+=1
        s-=LIST[l][0]
        l+=1

        s+=LIST[r][0]
        MAX=max(s,MAX)
        if(len(LIST)-1==r):
            break
        r+=1
        s+=LIST[r][0]
        MAX=max(s,MAX)
        if(len(LIST)-1==r):
            break
        r+=1
else:
    s-=LIST[l][0]
    l+=1

    s+=LIST[r][0]
    MAX=max(s,MAX)
    if(len(LIST)-1==r):
        print(MAX)
        exit()
    r+=1
    s+=LIST[r][0]
    MAX=max(s,MAX)
    if(len(LIST)-1==r):
        print(MAX)
        exit()
    r+=1
    while(r<N):
        s-=LIST[l][0]
        l+=1
        s-=LIST[l][0]
        l+=1

        s+=LIST[r][0]
        MAX=max(s,MAX)
        if(len(LIST)-1==r):
            break
        r+=1
        s+=LIST[r][0]
        MAX=max(s,MAX)
        if(len(LIST)-1==r):
            break
        r+=1

print(MAX)


### FIXED CODE ###

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

#K=1
#S="01100"
#N=len(S)

LIST=[[[0] for j in range (2)]for i in range(N)]

t=S[0]
c=0
k=0
for i in range(N):
    if(t!=S[i]):
        LIST[k][0]=c
        LIST[k][1]=t
        t=S[i]
        k+=1
        c=0
    c+=1

LIST[k][0]=c
LIST[k][1]=t
LIST=LIST[0:k+1]
MAX=0

s=0
l=0
r=0

if(LIST[r][1]=="1"):
    s+=LIST[r][0]
    r+=1
x=0
while(K>0 and len(LIST)>r):
    s+=LIST[r][0]
    K-=1
    if(len(LIST)-1==r):
        x=1
        break
    r+=1
    s+=LIST[r][0]
    if(len(LIST)-1==r):
        x=1
        break
    r+=1

MAX=max(s,MAX)

f=0
if(x==0):
    while(r<len(LIST)):
        if(l< len(LIST)-1):
            s-=LIST[l][0]
            l+=1
            f=1
        if(l<len(LIST)-1 and LIST[l][1]=="0"):
            s-=LIST[l][0]
            l+=1

        if(f==0):
            break
        

        s+=LIST[r][0]
        MAX=max(s,MAX)
        r+=1
        if(len(LIST)==r):
            break
        
        s+=LIST[r][0]
        MAX=max(s,MAX)
        r+=1
        if(len(LIST)==r):
            break

print(MAX)