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

n=int(input())
A=list(map(int,input().split()))
inf=float("inf")
def gcd(a,b):
    if a==inf:return b
    if b==inf:return a
    if b==0: return a
    else:
        return gcd(b,a%b)
def lcm(a,b):
    return a*b//gcd(a,b)

class segtree:
    def __init__(self,n,operator,identity):
        """
        n: データ配列のサイズ
        operator: 演算子。関数。minとか。
        identity: 単位元。minだったらinf。
        """
        nb=bin(n)[2:] #2進数に変換し、最初の"0b"を除く
        bc=sum([int(digit) for digit in nb]) #これが1だったら2の累乗形
        if bc==1:
            self.num_end_leaves= 2**(len(nb)-1)
        else:
            self.num_end_leaves= 2**(len(nb))

        self.array= [identity for i in range(self.num_end_leaves *2)]
        #単位元で初期化。1個多いのは別にええやろ

        self.identity= identity
        self.operator = operator

    def update(self,x,val):
        """
        x: 代入場所
        val: 代入する値
        """
        actual_x= x+self.num_end_leaves-1
        #末端の葉数が32ならば、末端のindexは31から。

        self.array[actual_x] = val  #更新
        while actual_x>0:
            actual_x = (actual_x-1)//2 #親を見る
            self.array[actual_x]= \
            self.operator( self.array[actual_x*2+1], self.array[actual_x*2+2])

    def get(self, q_left, q_right, arr_ind=0, leaf_left=0, depth=0):
        """
        q_left: クエリ区間の左
        q_right: クエリ区間の右(閉区間)
        arr_ind: 木配列のindex. 最初は親なので0
        leaf_left: 葉がカバーしてる範囲の左端
        depth: 木配列の深さ。
        """
        
        width_of_floor = self.num_end_leaves//(2**depth)
        #今の葉のカバー幅(最初は全体(32としよう))

        leaf_right= leaf_left + width_of_floor - 1
        #今の葉のカバー幅の右端

        if (q_right < leaf_left) or (leaf_right < q_left):
            return  self.identity #クエリ領域と葉が関係ないなら単位元を返す

        elif q_left <= leaf_left and leaf_right <= q_right:
            return self.array[arr_ind] #クエリ領域に葉がすっぽり入ってるなら、葉の値を返す

        else: #そうじゃないならば、子を見る
            val_left = self.get(q_left,q_right, 2*arr_ind+1, leaf_left, depth+1)
            val_right = \
            self.get(q_left,q_right, \
            2*arr_ind+2, leaf_left+width_of_floor//2, depth+1)
            return self.operator(val_left,val_right) #子をマージする演算をする。


seg=segtree(n, gcd, float("inf"))
# A=[i for i in range(10)]
for i,num in enumerate(A):  #用意した配列をぶち込む
  seg.update(i,num)
# print(seg.array)
ans=0
for i in range(n):
    seg.update(i,inf)
    ans=max(ans, seg.array[0])
    seg.update(i,A[i])
print(ans)

### FIXED CODE ###

n=int(input())
A=list(map(int,input().split()))
def gcd(a,b):
  if a*b==0:
    return a if b==0 else b
  else:
    while b:
      a,b=b,a%b
  return a

B=[0]*(n+5)
C=[0]*(n+5)

for i in range(n):
  B[i+1]=gcd(B[i],A[i])
  C[i+1]=gcd(C[i],A[n-i-1])
po=0
for i in range(n):
  po=max(po,gcd(B[i],C[n-1-i]))
print(po)
### BUGGY CODE ###

import fractions
 
n = int(input())
a = list(map(int, input().split()))
 
def lcm(x, y):
	return (x // fractions.gcd(x, y))*y
 
num = a[0]
for i in range(1, n):
	num = lcm(num, a[i])
 
ans = 0
for i in range(n):
	ans += (num//a[i]) % 1000000007
	if ans > 1000000007:
		ans = ans%1000000007
 
print(ans)

### FIXED CODE ###

import fractions
 
n = int(input())
a = list(map(int, input().split()))
 
l = 1
for i in range(n):
	l = l // fractions.gcd(l, a[i])*a[i]
 
ans = 0
for i in range(n):
	ans += l//a[i]
print(ans%(10**9+7))
### BUGGY CODE ###

# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
import numpy as np
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N=int(input())
    A=np.array(list(map(int,input().split())))
    
    B=np.array([i for i in range(1,N+1)])
    
    A=A-B


    val1 = 0
    val2=0
    for i in A:
        val1 += abs(i - 1)
        val2+=abs(i+1)
    if val1<val2:

        minval = 10 ** 50
        j=0
        temp = 10**50
        while True:
            val=0
            for i in A:
                val+=abs(i-j)
            if val>=temp:
                break
            else:
                temp=val
                minval=min(minval,val)
                j+=1

    else:

        minval = 10 ** 50
        j=0
        temp = 10**50
        while True:
            val=0
            for i in A:
                val+=abs(i+j)
            if val>=temp:
                break
            else:
                temp=val
                minval=min(minval,val)
                j+=1
    print(minval)
resolve()

### FIXED CODE ###

# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
import numpy as np
#import statistics
#import sys
#sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N=int(input())
    A=np.array(list(map(int,input().split())))

    for i in range(N):
        A[i]-=i+1

    B=abs(A-np.median(A))
    print(int(sum(B)))
resolve()
### BUGGY CODE ###


import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)

s = input()
t = input()
N, M = len(s), len(t)

dp = [['' for _ in range(M+1)] for _ in range(N+1)]

for i in range(1,N+1):
    for j in range(1,M+1):
        if s[i-1] == t[j-1]:
            dp[i][j] = dp[i-1][j-1]+ s[i-1]
        elif len(dp[i-1][j]) > len(dp[i][j-1]):
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = dp[i][j-1]

ans = ''
for j in range(M+1):
    if len(dp[-1][j]) > len(ans):
        ans = dp[-1][j]
print(ans)


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Mon Apr 13 22:34:56 2020

@author: ctiuser
"""

import numpy as np

s = np.array(list(input()), dtype='U1')
t = np.array(list(input()), dtype='U1')

ls, lt = len(s), len(t)

eq = s[:, None] == t[None,:]
dp = [np.zeros(lt+1, int)]

for i in range(ls):
    prev = dp[-1].copy()
    np.maximum(prev[1:], prev[:-1] + eq[i], out = prev[1:])
#    print(prev)
    np.maximum.accumulate(prev, out = prev)
#    print(prev)
    dp.append(prev)

i, j = ls, lt
ans = ''
while i > 0 and j > 0:
    if eq[i-1][j-1]:
        ans += s[i-1]
        i -= 1
        j -= 1
        
    if dp[i][j] == dp[i][j-1]:
        j -= 1
        continue
    elif dp[i][j] == dp[i-1][j]:
        i -= 1
        continue
        
ans = ans[::-1]
print(ans)
### BUGGY CODE ###

from collections import Counter
n = int(input())
S = []
for _ in range(n):
    S.append(input())
cnt = 0
for i in range(1,n):
    d1 = Counter(S[i])
    for j in range(i):
        d2 = Counter(S[j])
        if d1 ==d2: cnt += 1
print(cnt)



### FIXED CODE ###

import collections
n = int(input())
S = collections.defaultdict(int)
for _ in range(n):
    s = ''.join(sorted(input()))
    S[s] += 1
cnt = 0
for key,val in S.items():
    if val >1:
        cnt += val*(val-1)//2
print(cnt)
### BUGGY CODE ###

import collections

n = int(input())
s = input()
res = 0
# for i in range(0, n):
#     for j in range(i+1,n):
#         if s[i] != s[j]:
#             for k in range(j+1,n):
#                 if j-i!=k-j and s[i] != s[k] and s[j] != s[k]:
#                     res += 1
#
# print(res)
num = collections.Counter(s)
# print(num)
num_r = num["R"]
num_g = num["G"]
num_b = n - num_r - num_g
count_2 = 0
for x in range(1,int(n/2)+1):
    for i in range(n-2):
        # print(x)
        # print(i)
        # print()
        if (i + 2 * x < n and s[i] != s[i + x] and s[i + x] != s[i + 2 * x] and s[i] != s[i + 2 * x] ):
            count_2 += 1
            # print(x)
            # print(i)
            # print()

res = num_r * num_g * num_b - count_2
# print(num_r)
# print(num_g)
# print(num_b)
print(res)

### FIXED CODE ###

import collections

n = int(input())
s = input()
res = 0
# for i in range(0, n):
#     for j in range(i+1,n):
#         if s[i] != s[j]:
#             for k in range(j+1,n):
#                 if j-i!=k-j and s[i] != s[k] and s[j] != s[k]:
#                     res += 1
#
# print(res)
num = collections.Counter(s)
# print(num)
num_r = num["R"]
num_g = num["G"]
num_b = n - num_r - num_g
count_2 = 0
for x in range(1,int(n/2)+1):
    for i in range(n-2*x):
        # print(x)
        # print(i)
        # print()
        if (i + 2 * x < n and s[i] != s[i + x] and s[i + x] != s[i + 2 * x] and s[i] != s[i + 2 * x] ):
            count_2 += 1
            # print(x)
            # print(i)
            # print()

res = num_r * num_g * num_b - count_2
# print(num_r)
# print(num_g)
# print(num_b)
print(res)
### BUGGY CODE ###

# coding: utf-8
# Your code here!
N = int(input())
L = list(map(int, input().split()))
ans = 1

for n in range(N):
 ans = L[n]*ans
 if ans >= 1000000000000000001: ans = -1
 if ans >= 1000000000000000001: break

print(ans)

### FIXED CODE ###

# coding: utf-8
# Your code here!
N = int(input())
L = list(map(int, input().split()))
ans = 1

for n in range(N):
 ans = L[n]*ans
 if ans >= 1000000000000000001: ans = -1
 if ans == -1: break

for n in range(N):
 if L[n] == 0: ans = 0
print(ans)
### BUGGY CODE ###

S = input()
Q = int(input())
L = 1
for i in range(Q):
    A = list(input().split())
    if int(A[0]) == 1:
        L = -L
    if int(A[0]) == 2:
        A[1] = 2*int(A[1]) - 3
        if L*A[1] == -1:
            S = A[2] + S
        else:
            S = S + A[2]

if L == 1:
    print(S)
else:
    print(''.join(list(reversed(S))))

### FIXED CODE ###

from collections import deque

S = input()
Q = int(input())
L = 1
S = deque(S)

for i in range(Q):
    A = list(input().split())
    if int(A[0]) == 1:
        L = -L
    if int(A[0]) == 2:
        A[1] = 2*int(A[1]) - 3
        if L*A[1] == -1:
            S.appendleft(A[2])
        else:
            S.append(A[2])

if L == 1:
    print(''.join(S))
else:
    print(''.join(list(reversed(S))))
### BUGGY CODE ###

def main():

    H, W = map(int, input().split())
    A = []
    for _ in range(H): A.append(input())
    # print(A)
    ans = 0
    mv = [[1,0],[0,1],[-1,0],[0,-1]]
    for i in range(H):
        for j in range(W):
            if A[i][j] == "#":
                # print(i, j)
                visited = set()
                visited.add((i, j))
                cnt = 0
                cur = [[i, j]]
                while cur:
                    temp = []
                    cnt += 1
                    if cnt % 2 == 1: c = "."
                    else: c = "#"
                    for i1, j1 in cur:
                        for di, dj in mv:
                            k, l = i1+di, j1+dj
                            if 0<=k<H and 0<=l<W and (k, l) not in visited and A[k][l] == c:
                                visited.add((k, l))
                                temp.append([k, l])
                                if c == ".":
                                    ans += 1
                    cur = temp
                # print(i, j, ans)

    return ans

if __name__ == '__main__':
    print(main())

### FIXED CODE ###

def main():

    H, W = map(int, input().split())
    A = []
    for _ in range(H): A.append(input())

    ans = 0
    visited = set()
    for i in range(H):
        for j in range(W):
            if (i, j) not in visited:
                visited.add((i, j))
                b, w = 0, 0
                if A[i][j] == "#":
                    b += 1
                    c = "."
                else:
                    w += 1
                    c = "#"
                cur = [[i, j]]
                while cur:
                    temp = []
                    for k1, l1 in cur:
                        for dk, dl in [[1,0],[-1,0],[0,1],[0,-1]]:
                            k, l = k1+dk, l1+dl
                            if 0<=k<H and 0<=l<W and (k,l) not in visited and A[k][l] == c:
                                visited.add((k,l))
                                temp.append([k, l])

                    if c == "#":
                        b += len(temp)
                        c = "."
                    else:
                        w += len(temp)
                        c = "#"
                    cur = temp
                ans += b*w
    return ans

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

import time

def floor(y):
    return int(y)

def main():
    a, b, n = map(int, input().split())
    ans = [floor(a*x/b) - a*floor(x/b) for x in range(1, n+1)]
    print(max(ans))

if __name__ == "__main__":
    main()

### FIXED CODE ###

import math
a, b, n = map(int, input().split())
x = min(b-1, n)
print(math.floor(a*(x%b)/b))
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
sum = 0

for i in range(0,n-1):
	for j in range(i+1,n):
  		sum += a[i]*a[j]
    
print(sum%(10**9+7))
	

### FIXED CODE ###

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

result= 0
asum = sum(a)
for j in range(0,n):
  asum -= a[j]
  result += a[j]*(asum)

print(result%(10**9+7))
### BUGGY CODE ###

n,m = map(int,input().split())
l = []
r = []
for i in range(m):
    a,b = map(int,input().split())
    l.append(a)
    r.append(b)
count = 0
for i in range(1,n+1):
        if l[m-1] <= i <= r[0]: 
            count += 1
for i in range(n):
    for j in range(m):
        l.append(1)
print(count)

### FIXED CODE ###

n,m = map(int,input().split())
l = []
r = []
for i in range(m):
    a,b = map(int,input().split())
    l.append(a)
    r.append(b)
count = 0
ma = max(l)
mi = min(r)
for i in range(1,n+1):
        if ma <= i <= mi: 
            count += 1
print(count)
### BUGGY CODE ###

N , K = map(int, input().split())
flag = "F"
while 1:
    if N>10000000*K:
        N = N -10000000*K
    if N>10000000*K:
        N = N -10000000*K
    if N>1000000*K:
        N = N -1000000*K
    if N>100000*K:
        N = N -100000*K
    if N>10000*K:
        N = N -10000*K
    
    a = N
    N = abs(N - K)
    

    if a<=K and N <= K:
        if a < N:
            result = a
            flag="T"
        else:
            result = N
            flag="T"
    if flag == "T":
        break
print(result)

### FIXED CODE ###

import math

N , K = map(int, input().split())
flag = "F"
if N !=0:
    while 1:
        lenN = int (math.log10(N) + 1)
        lenK = int (math.log10(K) + 1)
        N = abs(N-K*(10**abs(lenN-lenK-1)))
        lenN = int (math.log10(N) + 1)
        if abs(lenN-lenK)<2:
            break



        
while 1:
    
    
    a = N
    N = abs(N - K)
    

    if a<=K and N <= K:
        if a < N:
            result = a
            flag="T"
        else:
            result = N
            flag="T"
    if flag == "T":
        break
print(result)
### BUGGY CODE ###

N = int(input())
arr = list(map(int, input().split()))
count_1 = arr.count(1)
ans_list = [0] * (N)
ans = []
summ = 0
if count_1 == 0:
    print(0)
    exit()
for i in range(N):
    for j in range(N-i+1,N):
        if (j % i) == 0:
            summ += ans_list[j]
    if (summ % 2) != arr[i]:
        ans_list[i] = 1
        ans.append(arr[i])

print(sum(ans))
for i in range(len(ans)):
    print(ans[i],' ', end="")






### FIXED CODE ###

N = int(input())
arr = list(map(int, input().split()))
ans_list = [0] * (N)
ans = []
for i in range(N):
    summ = 0
    j = N - i
    while j < N:
        j = j + N - i
        if j - 1 < N:
            summ += ans_list[j-1]
    if (summ % 2) != arr[N - i - 1]:
        ans_list[N - i - 1] = 1
        ans.append(N - i)

ans.sort()
print(len(ans))
for i in range(len(ans)):
    if i == len(ans)-1:
        print(ans[i])
    else:
        print(ans[i],'', end="")
### BUGGY CODE ###

def calc_exp(p):
    result = 0
    for n in p:
        result += expectation(n)
    return result


def expectation(n):
    return 0.5 * n + 0.5


def main():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    max_num = 0
    max_idx = -1
    for i in range(n-k+1):
        num = sum(p[i:i+k])
        if num >= max_num:
            max_num = num
            max_idx = i
    print(calc_exp(p[max_idx:max_idx+k]))


if __name__ == "__main__":
    main()


### FIXED CODE ###

def expectation(p):
    return 0.5 * sum(p) + 0.5 * len(p)


def main():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    max_num = sum(p[0:k])
    max_idx = 0
    lst = [max_num]
    for i in range(1, n-k+1):
        num = lst[i-1] + p[i+k-1] - p[i-1]
        lst.append(num)

        if num >= max_num:
            max_num = num
            max_idx = i
    print(expectation(p[max_idx:max_idx+k]))


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

n, a, b = list(map(int, input().split()))
s = input()

# a: 国内の学生
# b: 海外の学生
# c: その他
# i番idxはi位

# 海外の学生
foregin_list = []
for i, c in enumerate(s):
    if c == "b":
        foregin_list.append(i)


passes_num = 0
for i, c in enumerate(s):
    if c == "c":
        print("No")
    elif c == "a":
        if passes_num < a + b:
            passes_num += 1
            print("Yes")
        else:
            print("No")
    else:
        if passes_num < a + b and foregin_list.index(i) + 1 <= b:
            passes_num += 1
            print("Yes")
        else:
            print("No")


### FIXED CODE ###

n, a, b = list(map(int, input().split()))
s = input()

# a: 国内の学生
# b: 海外の学生
# c: その他
# i番idxはi位


passes_num = 0  # 通過した人の数
foregin_rank = 1  # 海外の学生の中での順位
thredshould = a + b
for c in s:
    if c == "c":
        print("No")
    elif c == "a":
        if passes_num < thredshould:
            passes_num += 1
            print("Yes")
        else:
            print("No")
    else:
        if passes_num < thredshould and foregin_rank <= b:
            passes_num += 1
            foregin_rank += 1
            print("Yes")
        else:
            print("No")
### BUGGY CODE ###

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


def comb(x,y):
    r = 1
    for i in range(x,x-y,-1):
        r *= i
    for i in range(y,0,-1):
        r //= i
    return r
def find(ID,a):
    return ID[a]
def union(ID,a,b):
    ida = find(ID,a)
    if not find(ID,a)==find(ID,b):
        n1 = 0
        n2 = 0
        for i in range(len(ID)):
            if ID[i]==ID[b]:
                n2 += 1
            if ID[i]==ida:
                ID[i] = ID[b]
                n1 += 1
        return n1*n2
    return 0
bridges = []
res = []
ID = []
cnt = comb(n,2)
for i in range(n+1):
    ID.append(i)
for i in range(m):
    a,b = map(int,input().split())
    bridges.append((a,b))

for i in range(m-1,-1,-1):
    res.append(cnt)
    cnt -= union(ID,bridges[i][0],bridges[i][1])
    

for i in res[::-1]:
    print(i)            


### FIXED CODE ###

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


def comb(x,y):
    r = 1
    for i in range(x,x-y,-1):
        r *= i
    for i in range(y,0,-1):
        r //= i
    return r
def find(ID,a):
    tmp = a
    while tmp !=ID[tmp]:
        tmp = ID[tmp]
    return tmp
def union(ID,a,b):
    ida = find(ID,a)
    idb = find(ID,b)
    if ida!=idb:
        ID[a] = idb
        ID[b] = idb
        ID[ida] = idb
        tmp = SIZE[idb]*SIZE[ida]
        SIZE[idb] += SIZE[ida]
        return tmp 
    return 0
bridges = []
res = []
ID = []
SIZE = []
cnt = comb(n,2)
for i in range(n+1):
    ID.append(i)
    SIZE.append(1)
for i in range(m):
    a,b = map(int,input().split())
    bridges.append((a,b))

for i in range(m-1,-1,-1):
    res.append(cnt)
    cnt -= union(ID,bridges[i][0],bridges[i][1])
    

for i in range(m-1,-1,-1):
    print(res[i])
### BUGGY CODE ###

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

rev = 0

for i in range(N):
  Q = input().split()
  if Q[0] == "1":
    rev += 1
    rev %= 2
  else:
    if (rev + int(Q[1])) % 2 == 1:
      S = Q[2] + S
    else:
      S += Q[2]
if rev == 1:
  S = S[::-1]
print(S)
           
  

### FIXED CODE ###

from collections import deque
S = input()
S = deque(S)
N = int(input())

rev = 0

for i in range(N):
  Q = input().split()
  if Q[0] == "1":
    rev += 1
    rev %= 2
  else:
    if (rev + int(Q[1])) % 2 == 1:
      S.appendleft(Q[2])
    else:
      S.append(Q[2])
S = "".join(S)
if rev == 1:
  S = S[::-1]
print(S)
### BUGGY CODE ###

n = int(input())

p = 1

li = [i for i in range(1, n+1)]

for i in li:
  if p > (10**9+7):
    p -= (10**9+7)
  p *= i
  
print(p % (10**9+7))

### FIXED CODE ###

n = int(input())

p = 1

li = [i for i in range(1, n+1)]

for i in li:
  p = p*i % (10**9+7)
  
print(p)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
from itertools import accumulate
INF = float("inf")

MOD = 1000000007  # type: int


def solve(N: int, s: str):

    # DP[i][j]はi文字目までをみたす順列のうち、最後がjで終わるものの個数
    DP = [[0]*(N+1) for _ in range(N)]
    DP[0][1] = 1

    for i in range(1, N):
        tot = 0
        acc = list(accumulate(DP[i-1]))
        for j in range(1, (i+1)+1):
            if s[i-1] == "<":
                DP[i][j] = acc[j-1]
            else:
                DP[i][j] = acc[i+1] - acc[j-1]
            DP[i][j] %= MOD

    print(sum(DP[N-1]) % MOD)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = next(tokens)  # type: str
    solve(N, s)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from itertools import accumulate
INF = float("inf")

MOD = 1000000007  # type: int


def solve(N: int, s: str):

    # DP[i][j]はi文字目までをみたす順列のうち、最後がjで終わるものの個数
    DP = [[0]*(N+1) for _ in range(N)]
    DP[0][1] = 1

    for i in range(1, N):
        acc = list(accumulate(DP[i-1]))
        for j in range(1, (i+1)+1):
            if s[i-1] == "<":
                DP[i][j] = acc[j-1]
            else:
                DP[i][j] = acc[i+1] - acc[j-1]
            DP[i][j] %= MOD

    print(sum(DP[N-1]) % MOD)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = next(tokens)  # type: str
    solve(N, s)


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

s = raw_input()
K = input()

alpha = [chr(i) for i in range(97,97+26)]

for moji in range(1, len(s)+1):
	if alpha.index(s[moji-1]) != 0:
		if K >= 26-alpha.index(s[moji-1]):
			K = K - (26-alpha.index(s[moji-1]))
			s = s[:moji-1] + 'a' + s[moji:] 

if K>0:
	last_char = alpha[ alpha.index(s[-1]) + (K % 26) ]
	s = s[:-1] + last_char

print s

### FIXED CODE ###

s = raw_input()
K = input()

alpha = [chr(i) for i in range(97,97+26)]

i = 0
while K>=26 and i<len(s)-1:
	if alpha.index(s[i]) != 0:
		K = K - (26 - alpha.index(s[i]))
		s = s[:i] + 'a' + s[i+1:]
	i=i+1

for moji in range(i, len(s)):
	if alpha.index(s[moji]) != 0:
		if K >= 26-alpha.index(s[moji]):
			K = K - (26-alpha.index(s[moji]))
			s = s[:moji] + 'a' + s[moji+1:] 

if K>0:
	last_char = alpha[ alpha.index(s[-1]) + (K % 26) ]
	s = s[:-1] + last_char

print s
### BUGGY CODE ###

def b_len(v):
    return len(bin(v)[2:])


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

cs = [0]
for aa in a:
    cs.append(cs[-1] + aa)

ps = []
for i in range(1, n + 1):
    for j in range(i):
        ps.append(cs[i] - cs[j])

ps = sorted(ps, reverse=True)

pw = b_len(ps[k - 1])
MOD = 2 ** pw

nps = [set() for _ in range(pw)]
len_nps = [0 for _ in range(len(nps))]
for i, p in enumerate(ps, 0):
    for j in range(pw):
        if 1 << j & p:
            nps[j].add(i)
            len_nps[j] += 1
ans = 0
buf = set(range(len(ps)))
for j in range(pw)[::-1]:
    if len_nps[j] >= k:
        x = buf & nps[j]
        if len(x) >= k:
            buf = x
            ans += 2 ** j

print(ans)

### FIXED CODE ###

from math import log, ceil

n, k = map(int, input().split())
a = tuple(map(int, input().split()))

A_MAX = 10 ** 9
MAX_BIT_LENGTH = ceil(log(A_MAX * n, 2))

cs = [0]
t = 0
for aa in a:
    t += aa
    cs.append(t)

ps = []
for r in range(1, n + 1):
    for l in range(r):
        ps.append(cs[r] - cs[l])

ans = 0
for b in range(MAX_BIT_LENGTH)[::-1]:
    cnt = 0
    t = ans + (1 << b)
    for p in ps:
        if p & t == t:
            cnt += 1
            if cnt == k:
                ans = t
                break

print(ans)