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

import copy

data = input().split()
N = int(data[0])
K = int(data[1])

TL = input()
TL = list(TL)
TLlist = []
now = TL[0]
nowlist = now
inx = []

for lop in range(1,len(TL)):
    if not (now == TL[lop]):
        if nowlist[:1] == "0":
            inx.append(len(TLlist))
        TLlist.append(nowlist)
        nowlist = TL[lop]
        now = TL[lop]
        
    else:
        nowlist += now
if nowlist[:1] == "0":
    inx.append(len(TLlist))
TLlist.append(nowlist)

maxS = 0
cnt = 0
fg = 0
tfg = 0
fg2 = False
loplist = copy.deepcopy(TLlist)

for lop3 in range(len(loplist)):
    for lop2 in inx:
        if fg <= tfg:
            loplist[lop2] = loplist[lop2].replace('0', '1')
            cnt += 1
            if cnt == K:
                fg2 = True
                break
        else:
            tfg += 1
    loplist = "".join(loplist).split("0")
    for lop2 in loplist:
        if maxS < len(lop2):
            maxS = len(lop2)

    loplist = copy.deepcopy(TLlist)
    fg += 1
    cnt = 0
    tfg = 0
    if fg2 == False:
        break
    else:
        fg2 = False
print(maxS)


### FIXED CODE ###

data = input().split()
N = int(data[0])
K = int(data[1])
 
TL = list(input())
TLlist = []
TLLlist = []
now = TL[0]
nowlist = now
anslist = []
 
for lop in range(1,len(TL)):
    if not (now == TL[lop]):
        TLlist.append(nowlist)
        TLLlist.append(len(nowlist))
        nowlist = TL[lop]
        now = TL[lop]
    else:
        nowlist += now
TLlist.append(nowlist)
TLLlist.append(len(nowlist))
 
 
if TLlist[0][:1] == "0" :
    anslist.append( sum(TLLlist[:2*K]) )
    anslist.append( sum(TLLlist[1:2*K + 2]) )
    for lop in range(3,len(TLlist),2):
        if 2*K +  lop > len(TLlist):
            break
        anslist.append( anslist[len(anslist)-1] - sum(TLLlist[lop-2:lop]) + sum(TLLlist[lop + 2*K - 1 : lop + 2*K + 1])  )
elif TLlist[0][:1] == "1" :
    anslist.append( sum(TLLlist[:2*K + 1 ]) )
    for lop in range(2,len(TLlist),2):
        if 2*K +  lop > len(TLlist):
            break
        anslist.append( anslist[len(anslist)-1] - sum(TLLlist[lop-2:lop]) + sum(TLLlist[lop + 2*K - 1 : lop + 2*K + 1])  )
 
print(max(anslist))
### BUGGY CODE ###

N = int(input())
S = input()

count = 0
for i in range(0, N-2):
    S_i = S[i]
    for j in range(i+1, N-1):
        S_j = S[j]
        if S_i != S_j:
            for k in range(j+1, N):
                S_k = S[k]
                if S_j != S_k and S_k != S_i and j-i != k-j:
                    count += 1
print(count)

### FIXED CODE ###

import itertools

N = int(input())
S = input()

RGB = {"R":[0]*N, "G":[0]*N, "B":[0]*N}
for i in range(N):
    if S[i] == "R":
        RGB["R"][i] = 1
    elif S[i] == "G":
        RGB["G"][i] = 1
    else:
        RGB["B"][i] = 1

for k in RGB.keys():
    RGB[k] = list(itertools.accumulate(RGB[k]))

ans = 0
for i in range(N-2):
    l_i = S[i]
    for j in range(i+1, N-1):
        l_j = S[j]
        d = {"R", "G", "B"}
        if l_i != l_j:
            d.remove(l_i)
            d.remove(l_j)
            l_k = d.pop()
            ans += RGB[l_k][N-1] - RGB[l_k][j]
            if j*2 - i <= N-1:
                if S[j*2 - i] == l_k:
                    ans -= 1

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

n,k=map(int,input().split())
X=list(map(int,input().split()))
ans=float('inf')
for i in range(n-k+1):
    t = X[i:i+k]
    a,b=t[0],t[-1]
    if b<0:
        ans=min(ans,-a)
    elif a>0:
        ans=min(ans,b)
    else:
        tmp=min(-a,b)*2+max(-a,b)
        ans=min(ans,tmp)
print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
X=list(map(int,input().split()))
ans=float('inf')
for i in range(n-k+1):
    a,b=X[i],X[i+k-1]
    if b<0:
        ans=min(ans,-a)
    elif a>0:
        ans=min(ans,b)
    else:
        tmp=min(-a,b)*2+max(-a,b)
        ans=min(ans,tmp)
print(ans)
### BUGGY CODE ###

N=int(input())
T=[]
for i in range(N):
    X,L=map(int,list(input().split(" ")))
    T.append([X+L,X-L])
T.sort()
sum=1
def check(T,v,w):
    if T[v][0]<=T[w][1] or T[v][1]>=T[w][0]:
        return True
    else:
        return False

checks=[0]
for i in range(1,N):
    count=0
    for  j in checks:
        if not check(T,i,j):
            break
        count+=1
    if count==len(checks):
        sum+=1
        checks.append(i)
print(sum)

### FIXED CODE ###

N=int(input())
X=[]
for i in range(N):
    a,b=map(int,list(input().split(" ")))
    X.append([a+b,a-b])
X.sort()
D={}
D[0]=1
exe=[0]
for i in range(1,N):
    k=X[i][0]
    if X[i][1]<X[exe[-1]][0]:
        D[i]=D[exe[-1]]
    else:
        D[i]=D[exe[-1]]+1
        exe.append(i)
print(len(exe))
### BUGGY CODE ###

n = int(input())
A = list(map(int,input().split()))
L = [0]*(10**6+1)

for a in A:
    temp = a
    while temp < 10**6+1:
        L[temp] += 1
        temp += a

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

print(ans)


### FIXED CODE ###

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

A_max = max(A)
L = [0]*(A_max+1)
A.sort()

for a in A:
    temp = a
    while temp < A_max+1:
        L[temp] += 1
        temp += a

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

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

n =int(input())
for q in range(1,n+1):
    ans=0
    for x in range(1,int(n**0.5)+1):
        for y in range(1,int((n-x**2)**0.5)+1):
            for z in range(1,int((n-x**2-y**2)**0.5)+1):
                if x**2+y**2+z**2+x*y+y*z+z*x==q:
                    ans+=1
    print(ans)

### FIXED CODE ###

n =int(input())
ans=[0]*n
for x in range(1,int(n**0.5)+1):
    for y in range(1,int((n-x**2)**0.5)+1):
        for z in range(1,int((n-x**2-y**2)**0.5)+1):
            p = x**2+y**2+z**2+x*y+y*z+z*x
            if 1<=p and p<=n:
                ans[p-1]+=1
for i in range(n):
    print(ans[i])
### BUGGY CODE ###

n=int(input())
ps=list(map(int,input().split()))
cnt=0
for i,p in enumerate(ps):
    for q in ps[:i+1]:
        if p>q:
            break
    else:
        cnt+=1
print(cnt)


### FIXED CODE ###

n=int(input())
ps=list(map(int,input().split()))
cnt=0
max_=ps[0]
min_=ps[0]
for p in ps:
    if min_>=p:
        cnt+=1
        min_=p
print(cnt)
### BUGGY CODE ###

# python3だとTLE,pypy3だとAC
import sys
sys.setrecursionlimit(10**6)


def get(i, j):
    global dp
    global p
    if i < 0 or j < 0:
        return 0.0
    if dp[i][j] == 0.0:
        dp[i][j] = get(i - 1, j) * (1 - p[i - 1]) + \
            get(i - 1, j - 1) * p[i - 1]
    return dp[i][j]


def main():
    N = int(input())
    global dp
    global p
    p = list(map(float, input().split()))
    dp = [[0.0] * (N + 1) for _ in range(N + 1)]
    dp[0][0] = 1.0
    for i in range(N, 0, -1):
        get(N, i)
    print(sum(dp[N][N//2+1:]))


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    N = int(input())
    p = list(map(float, input().split()))
    dp = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
    p_mul = 1
    dp[0][0] = 1
    for i in range(1, N + 1):
        p_mul *= (1-p[i-1])
        dp[i][0] = p_mul
    for i in range(1, N+1):
        for j in range(1, N+1):
            dp[i][j] = dp[i - 1][j] * \
                (1 - p[i - 1]) + dp[i - 1][j - 1] * p[i - 1]
    print(sum(dp[N][N//2+1:]))


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

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

exp = []
for p in P:
  cnt = p-1+1
  r = 0
  for i in range(1, p+1):
    r += i*(cnt**-1)
  exp.append(r)

res = 0
i = 0
k = K
while k <= N:
  res = max(res, sum(exp[i:k]))
  i += 1
  k += 1

print(res)

### FIXED CODE ###

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

T = [0] * (N+1)

for i in range(N):
  T[i+1] = T[i] + (1+p[i])/2

ans = 0
for j in range(K, N+1):
  ans = max(ans, T[j]-T[j-K])

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

from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

MOD = 10**9 + 7

N = read()

NN = N + 1
fact = [1] * NN
for i in range(1, NN):
  fact[i] = (fact[i-1] * i) % MOD

def inv(n):
  return pow(n, MOD-2, MOD)

def comb(n, k):
  return fact[n] * inv(fact[n-k]) % MOD * inv(fact[k]) % MOD

S = [0] * N
for k in range((N+1) // 2, N):
  S[k] = comb(k-1, N-1-k) * fact[k] % MOD * fact[N-1-k] % MOD

ans = 0
for k in range((N+1) // 2, N):
  ans = (ans + k * (S[k] - S[k-1]) % MOD) % MOD
print(ans)


### FIXED CODE ###

from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect
 
def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]
 
MOD = 10**9 + 7
 
N = read()
 
NN = N + 1
fact = [1] * NN
for i in range(1, NN):
  fact[i] = (fact[i-1] * i) % MOD
 
def inv(n):
  return pow(n, MOD-2, MOD)
 
invfact = [0] * NN
invfact[-1] = inv(fact[-1])
for i in range(NN-2, -1, -1):
  invfact[i] = invfact[i+1] * (i+1) % MOD
 
def comb(n, k):
  return fact[n] * invfact[n-k] % MOD * invfact[k] % MOD
 
S = [0] * N
for k in range((N+1) // 2, N):
  S[k] = comb(k-1, N-1-k) * fact[k] % MOD * fact[N-1-k] % MOD
 
ans = 0
for k in range((N+1) // 2, N):
  ans = (ans + k * (S[k] - S[k-1]) % MOD) % MOD
print(ans)
### BUGGY CODE ###

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

_sum = 0

for i in range(N-1):
    for j in range(i+1,N):
        _sum += A[i]*A[j]
        _sum %= (10**9 + 7)

print(_sum)

### FIXED CODE ###

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

S = [A[0]]

for i in range(1,N):
    S.append(A[i]+S[i-1])

_sum = 0
for i in range(N):
    _sum += A[i]*(S[N-1]-S[i])
    _sum %= 10**9+7

print(_sum)
### BUGGY CODE ###

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
X = int(input())
soin = factorization(X)
small = soin[0][0]

for i in range(10**9):
    if i**5-(i-small)**5==X:
        print(i,i-small)
        break

### FIXED CODE ###

X = int(input())

flag = False
for a in range(-118,120):
    for b in range(-119,119):
        if a**5-b**5==X:
            print(a,b)
            flag = True
            break
    if flag:
        break
### BUGGY CODE ###

n, k = map(int, input().split())
A = list(map(int, input().split()))
 
seki_list = [0]*n
seki = 1
temp = 0

for i in range(n):
    seki *= A[i]
    seki_list[i] = seki

point = seki_list[k-1]

for i in range(k, n):
    temp = seki_list[i]/seki_list[i-k]
    if temp > point:
        print("Yes")
        point = temp
    else:
        print("No")
        point = temp

### FIXED CODE ###

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

for i in range(k,n):
    if A[i] > A[i-k]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

from itertools import permutations
from math import ceil, floor

D, G = [int(elem) for elem in input().split(' ')]
point_info_list = [[int(elem) for elem in input().split()] for _ in range(D)]
assert len(point_info_list) == D
assert len(point_info_list[0]) == 2

min_num = float('inf')
for perm in permutations(range(D)):
    current_point = 0
    current_num = 0
    for point in perm:
        if (G - current_point) - (point + 1) * 100 * point_info_list[point][0] <= 0:
            current_num += ceil((G - current_point) / ((point + 1) * 100))
            break
        elif (G - current_point) - (point + 1) * 100 * point_info_list[point][0] - point_info_list[point][1] <= 0:
            current_num += point_info_list[point][0]
            break
        else:
            current_point += (point + 1) * 100 * point_info_list[point][0] + point_info_list[point][1]
            current_num += point_info_list[point][0]
    min_num = min(current_num, min_num)

print(min_num)


### FIXED CODE ###

from itertools import permutations
from math import ceil, floor

D, G = [int(elem) for elem in input().split(' ')]
point_info_list = [[int(elem) for elem in input().split()] for _ in range(D)]
assert len(point_info_list) == D
assert len(point_info_list[0]) == 2

min_num = float('inf')
for perm in permutations(range(D)):
    current_point = 0
    current_num = 0
    for point in perm:
        if (G - current_point) - (point + 1) * 100 * point_info_list[point][0] <= 0:
            current_num += ceil((G - current_point) / ((point + 1) * 100))
            break
        elif (G - current_point) - (point + 1) * 100 * point_info_list[point][0] - point_info_list[point][1] <= 0:
            current_num += point_info_list[point][0]
            break
        else:
            current_point += (point + 1) * 100 * point_info_list[point][0] + point_info_list[point][1]
            current_num += point_info_list[point][0]
    min_num = min(current_num, min_num)

print(min_num)
### BUGGY CODE ###

from itertools import combinations
N = int(input())
S = list(input())

com = combinations(S,3)
print(len(set(com)))

### FIXED CODE ###

N = int(input())
S = list(input())
sS = set(S)
from itertools import product
sS = product(sS,repeat=3)
c = 0

for i in sS:
	if i[0] in S:
		a = S.index(i[0])
		if i[1] in S[a+1:]:
			b = S[a+1:].index(i[1]) + a + 1
			if i[2] in S[b+1:]:
				c += 1
print(c)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
import numpy as np

input = sys.stdin.readline
mod = 998244353


def I():
    return int(input())


def MI():
    return map(int, input().split())


def main(N, steps):
    dp = np.zeros(N, np.int64)
    dp[0] = 1
    for i in range(N):
        if steps.size == 0:
            break
        steps = steps[steps < N]
        dp[steps] += dp[i]
        dp[steps] %= mod
        steps += 1

    return dp[N - 1]


N, K = MI()

steps = []
for _ in range(K):
    l, r = MI()
    steps += list(range(l, r + 1))

steps.sort()
steps = np.array(steps, np.int64)

print(main(N, steps))


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import numpy as np

# import numba
# from numba import njit, b1, i4, i8, f8

input = sys.stdin.readline
mod = 998244353


def I():
    return int(input())


def MI():
    return map(int, input().split())


# @njit((i8, i8[:]), cache=True)
def main(N, steps):
    dp = np.zeros(N + 1, np.int64)
    dpsum = np.zeros(N + 1, np.int64)
    dp[1] = 1
    dpsum[1] = 1
    for i in range(2, N + 1):
        for l, r in steps:
            li = i - r
            ri = i - l
            if ri < 0:
                continue
            li = max(li, 1)
            dp[i] += dpsum[ri] - dpsum[li - 1]
            dp[i] %= mod
        dpsum[i] = dpsum[i - 1] + dp[i]
        dpsum[i] %= mod

    return dp[N]


N, K = MI()

steps = []
for _ in range(K):
    l, r = MI()
    steps.append((l, r))


print(main(N, steps))
### BUGGY CODE ###

n=int(input())
l=list(map(int,input().split()))
sm=0
for i in range(n):
    var=l[i]
    for j in range(n):
        if i==j:continue
        if var%l[j]==0:
            break
    else: sm+=1
print(sm)

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
l.sort()
m=l[-1]
work=[0]*(m+1)
for i in l:
    if work[i]<=1:
        for j in range(i,m+1,i):
            work[j]+=1
sm=0
for s in l:
    if work[s]==1: sm+=1
print(sm)
### BUGGY CODE ###

import copy

def score(i,j):
  Ali = copy.deepcopy(data)
  Ali[i][j] = 0
  score = 0
  turn = 0
  
  for i in range(1,H+1):
    for j in range(W):
      if Ali[-i][j] == 0:
        for k in range(i+1,H+1):
          if Ali[-k][j] != 0:
            Ali[-i][j] = Ali[-k][j]
            Ali[-k][j] = 0
            break
            
  while True:
    sc = score
    #同じものを消す処理
    for i in range(H):
      a = 0 #今の数字
      b = 0 #今の数字が始まった場所
      
      for j in range(W):
        if Ali[i][j] != a:
          if j-b >= K:
            for k in range(b,j):
              score += Ali[i][k]*2**turn
              Ali[i][k] = 0
          a = Ali[i][j]
          b = j
      if W-b >= K:
        for k in range(b,W):
          score += Ali[i][k]*2**turn
          Ali[i][k] = 0
      
      
    if sc == score:
        break
    turn += 1
      
    #落としていく処理
    #下から上に見ていく
    for i in range(1,H+1):
      for j in range(W):
        if Ali[-i][j] == 0:
          for k in range(i+1,H+1):
            if Ali[-k][j] != 0:
              Ali[-i][j] = Ali[-k][j]
              Ali[-k][j] = 0
              break
              
  return score
  
H,W,K = map(int,input().split())
data = [[int(d) for d in input()] for _ in range(H)]
res = 0

for i in range(H):
  for j in range(W):
    res = max(res,score(i,j))
    
print(res)

### FIXED CODE ###

import copy

def score(i,j):
  Ali = copy.deepcopy(data)
  Ali[i][j] = 0
  score = 0
  turn = 0
  
  for i in range(1,H+1):
    for j in range(W):
      if Ali[-i][j] == 0:
        for k in range(i+1,H+1):
          if Ali[-k][j] != 0:
            Ali[-i][j] = Ali[-k][j]
            Ali[-k][j] = 0
            break
            
  while True:
    sc = score
    #同じものを消す処理
    for i in range(H):
      a = 0 #今の数字
      b = 0 #今の数字が始まった場所
      
      for j in range(W):
        if Ali[i][j] != a:
          if j-b >= K:
            for k in range(b,j):
              score += Ali[i][k]*2**turn
              Ali[i][k] = 0
          a = Ali[i][j]
          b = j
      if W-b >= K:
        for k in range(b,W):
          score += Ali[i][k]*2**turn
          Ali[i][k] = 0
      
      
    if sc == score:
        break
    turn += 1
      
    #落としていく処理
    #下から上に見ていく
    for i in range(1,H+1):
      for j in range(W):
        if Ali[-i][j] == 0:
          for k in range(i+1,H+1):
            if Ali[-k][j] != 0:
              Ali[-i][j] = Ali[-k][j]
              Ali[-k][j] = 0
              break
              
  return score
  
H,W,K = map(int,input().split())
data = [[int(d) for d in input()] for _ in range(H)]
res = 0

for i in range(H):
  for j in range(W):
    res = max(res,score(i,j))
    
print(res)
### BUGGY CODE ###

from collections import Counter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    uq = list(set(A))
    ans_hash = {}
    num_hash = {}
    for u in uq:
        ans = 0
        a = A[:]
        i = a.index(u)
        del a[i]
        val = Counter(a).values()
        for num in val:
            if num in num_hash:
                ans += num_hash[num]
            else:
                num_hash[num] = num * (num - 1) // 2
                ans += num_hash[num]
        ans_hash[u] = ans
    for n in A:
        print(ans_hash[n])


if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import Counter

def choose(n):
    return n * (n - 1) // 2


def main():
    N = int(input())
    A = list(map(int, input().split()))
    C = Counter(A)
    cnt = 0
    for c in C.values():
        cnt += choose(c)

    for a in A:
        ans = cnt
        ans -= choose(C[a])
        ans += choose(C[a] - 1)
        print(ans)


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

n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in a:
    ans = ans*i
if ans > 1000000000000000000:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
else:
    ans = 1
    for i in a:
        ans = ans*i
        if ans > 1000000000000000000:
            print(-1)
            ans = -1
            break
    if ans != -1:
        print(ans)
### BUGGY CODE ###

import fractions
from functools import reduce

def gcd(numbers):
    return reduce(fractions.gcd, numbers)

K = int(input())
ans = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans += gcd([i,j,k])

print(ans)

### FIXED CODE ###

import math
from functools import reduce

def gcd(numbers):
    return reduce(math.gcd, numbers)

k = int(input())
ans = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for k in range(1,k+1):
            ans += gcd([i,j,k])

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

import sys
n=int(input())
a=list(map(int,input().split()))
a.sort()
if(n%2==0):
  if(0 in a):
    print(0)
    sys.exit()
  else:
    num=0
    for i in range(1,n,2):
      if(a.count(i)==2):
        num+=1
        a.remove(i)
        a.remove(i)
      else:
        print(0)
        sys.exit()
    if(len(a)>0):
      print(0)
      sys.exit()
else:
  if(a.count(0)!=1):
    print(0)
    sys.exit()
  else:
    a.remove(0)
    num=0
    for i in range(2,n,2):
      if(a.count(i)==2):
        num+=1
        a.remove(i)
        a.remove(i)
      else:
        print(0)
        sys.exit()
print(int(2**num)%(10**9+7))

### FIXED CODE ###

import sys
n=int(input())
a=list(map(int,input().split()))
lis=[0 for i in range(n)]
for i in a:lis[i]+=1
if(1):
  if(lis[0]!=n%2):
    print(0)
    sys.exit()
  num=0
  for i in range(1,n):
    if(i%2==n%2):
      if(lis[i]!=0):
        print(0)
        sys.exit()
    else:
      if(lis[i]!=2):
        print(0)
        sys.exit()
      else:num+=1
  print((2**num)%(10**9+7))
### BUGGY CODE ###

n,k=map(int,input().split())
*a,=map(int,input().split())
l=[]
for i in range(n):
    for j in range(i+1,n+1):
        l.append(sum(a[i:j]))
l=sorted(l)[::-1]
m=0
import itertools
for t in itertools.combinations(l,k):
    c=t[0]
    for u in t[1:]:
        c&=u
    m=max(m,c)
print(m)

### FIXED CODE ###

n,k,*a=map(int,open(0).read().split())
l=[]
for i in range(n):
    t=0
    for j in range(i,n):
        t+=a[j]
        l.append(t)
for i in range(40,-1,-1):
    j=2**i
    t=[]
    for x in l:
        if x&j:
            t.append(x)
    if len(t)>=k:
        l=t
a,*b=l
for t in b:
    a&=t
print(a)
### BUGGY CODE ###

import sys
input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    H = [int(x) for x in input().split()]

    dp = [0] * (N + 1)
    dp[2] = abs(H[0] - H[1])



    for i in range(3, N + 1):
        mi = float("inf")
        for j in range(i - 1, i - K - 1, -1):
            if j == 0:
                break
            mi = min(mi, dp[j] + abs(H[j - 1] - H[i - 1]))
        dp[i] = mi

    print(dp[N])




if __name__ == '__main__':
    main()



### FIXED CODE ###

import sys
input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    H = [int(x) for x in input().split()]

    dp = [0] * (N + 1)
    dp[2] = abs(H[0] - H[1])

    for i in range(3, N + 1):
        mi = float("inf")
        for j in range(i - 1, i - K - 1, -1):
            if j == 0:
                break
            mi = min(mi, dp[j] + abs(H[j - 1] - H[i - 1]))
        dp[i] = mi

    print(dp[N])




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

N,a,b=map(int,input().split())
m = 10**9+7

M = pow(2, N)%m

m = 10**9+7
#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m
 
def nCr(n,r):
    if r*2>n:
        return nCr(n,n-r)
    else:
        a = b = 1
        for i in range(r):
            a = a * (n - i) % m
            b = b * (r - i) % m
        return (a * pow(b,m-2,m)) % m
 
ans = M - 1 - nCr(N,a) - nCr(N,b)
print(ans%m)

### FIXED CODE ###

N,a,b=map(int,input().split())
m = 10**9+7

M = pow(2, N, m)

def nCr(n,r):
    if r*2>n:
        return nCr(n,n-r)
    else:
        a = b = 1
        for i in range(r):
            a = a * (n - i) % m
            b = b * (r - i) % m
        return (a * pow(b,m-2,m)) % m
 
ans = M - 1 - nCr(N,a) - nCr(N,b)
print(ans%m)