Harryxun/stf_run huggingface dataset:
N,M = list(map(int, input().split()))
cakes = []
for i in range(N):
    cakes.append(list(map(int, input().split())))

ans = 0

for cake in cakes:
    value = 0
    for j in range(3):
        values.append(x+y+z)
values.sort()
values = values[::-1]
ans = max(ans, sum(values[:M]))

values = []
for cake in cakes:
    value = 0
    for j in range(3):
        values.append(x+y-z)
values.sort()
values = values[::-1]
ans = max(ans, sum(values[:M]))


values = []
for cake in cakes:
    value = 0
    for j in range(3):
        values.append(x-y+z)
values.sort()
values = values[::-1]
ans = max(ans, sum(values[:M]))


values = []
for cake in cakes:
    value = 0
    for j in range(3):
        values.append(x-y-z)
values.sort()
values = values[::-1]
ans = max(ans, sum(values[:M]))


values = []
for cake in cakes:
    value = 0
    for j in range(3):
        values.append(-x+y+z)
values.sort()
values = values[::-1]
ans = max(ans, sum(values[:M]))


values = []
for cake in cakes:
    value = 0
    for j in range(3):
        values.append(-x+y-z)
values.sort()
values = values[::-1]
ans = max(ans, sum(values[:M]))



values = []
for cake in cakes:
    value = 0
    for j in range(3):
        values.append(-x-y+z)
values.sort()
values = values[::-1]
ans = max(ans, sum(values[:M]))


values = []
for cake in cakes:
    value = 0
    for j in range(3):
        values.append(-x-y-z)
values.sort()
values = values[::-1]
ans = max(ans, sum(values[:M]))


print(ans)
    

### FIXED CODE ###

N,M = list(map(int, input().split()))
cakes = []
for i in range(N):
    cakes.append(list(map(int, input().split())))

ans = 0

for i in range(8):
    values = []
    for cake in cakes:
        value = 0
        for j in range(3):
            if (i >> j) % 2 == 1:
                value -= cake[j]
            else:
                value += cake[j]
        values.append(value)
    values.sort()
    values = values[::-1]
    ans = max(ans, sum(values[:M]))

print(ans)
from math import sqrt

Q = int(input())

for i in range(Q):
    A,B = map(int, input().split())
    m=A*B
    if A==B or B=A+1:
        ans = 2*A-2
    elif A=B+1
        ans = 2*B-2

    C = int(sqrt(m))
    if C*C==m:
        C=C-1

    if C*(C+1)<m:
        ans = 2*C-1
    else:
            ans = 2*C-2
    print(ans)

### FIXED CODE ###

from math import sqrt

Q = int(input())

for i in range(Q):
    A,B = map(int, input().split())
    m=A*B

    C = int(sqrt(m))
    if C*C==m:
        C=C-1

    if A==B or B==A+1:
        ans = 2*A-2
    elif A==B+1:
        ans = 2*B-2
    elif C*(C+1)<m:
        ans = 2*C-1
    else:
        ans = 2*C-2
    print(ans)
a,b,c,d = map(int,input().split())
l = list(range(a,b+1))
ans = 0
for i in l:
  l[i] % c != 0 and l[i] % d != 0:
    ans += 1
print(ans)

### FIXED CODE ###

A,B,C,D = map(int,input().split())

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

def F(N,C,D):
  x = N
  x -= N//C
  x -= N//D
  lcm = C*D//gcd(C,D)
  x += N//lcm
  return x

answer = F(B,C,D) - F(A-1,C,D)
print(answer)
while True:
    try:
        a, b = map(int, input().split())
        printe(a+b)
    except EOFError as e:
        break

### FIXED CODE ###

while True:
    try:
        a, b = map(int, input().split())
        print(a+b)
    except EOFError as e:
        break
n = int(input())
a = list(map(int, input().split()))

a_set = sorted(set(a))

count = [0] * n


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


sum = 0
for i in a_set:
    count[i] = a.count(i)
    sum += f(count[i])

for i in a:
    print(sum - (count[i] - 1))
    

### FIXED CODE ###

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

# a_set = sorted(set(a))

count = [0] * (n + 1)


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


sum = 0
for i in a:
    count[i] += 1
for i in count:
    sum += f(i)

for i in a:
    print(sum - (count[i] - 1))
N = int(input())
src = map(int,input().split())
S = sum(src)
M = N*(N+1)//2

if S%M:
    print('NO')
    exit()

K = S//M
mem = [src[i] - K*i for i in range(N)]
mem.append(mem[0])
for a,b in zip(mem,mem[1:]):
    if (a-b)%N:
        print('NO')
        exit()
print('YES')

### FIXED CODE ###

N = int(input())
src = list(map(int,input().split()))
S = sum(src)
M = N*(N+1)//2

if S%M:
    print('NO')
    exit()

K = S//M
mem = [src[i+1] - src[i] - K for i in range(N-1)]
mem.append(src[0] - src[N-1] - K)

print('YES' if all(map(lambda x:x<=0 and x%N==0, mem)) else 'NO')
A,B,C,D,E,F = map(int,input().split())
W = []
S = []

# 100A,100B の水
for a in range(1 + F // 100):
    for b in range(1 + F // 100):
        water = 100 * (a * A + b * B)
        if 0 < water <= F:
            W.append(water)

# c,d の砂糖
for c in range(1 + F // C):
    for d in range(1 + F // D):
        sugar = c * C + d * D
        if 0 < sugar <= F:
            S.append(sugar)

W = list(set(W))
S = list(set(S))

x = -1
for w in W:
    for s in S:
        if w + s <= F:
            sol = 100 * s / w
            if x < sol <= E:
                x = sol
                X, Y = w + s, s

print(X,Y)


### FIXED CODE ###

A,B,C,D,E,F = map(int,input().split())
W = []
S = []

# 100A,100B の水
for a in range(1 + F // 100):
    for b in range(1 + F // 100):
        water = 100 * (a * A + b * B)
        if 0 < water <= F:
            W.append(water)

# c,d の砂糖
for c in range(1 + F // C):
    for d in range(1 + F // D):
        sugar = c * C + d * D
        if sugar <= F:
            S.append(sugar)

W = list(set(W))
S = list(set(S))

x = -1
for w in W:
    for s in S:
        if w + s <= F:
            sol = 100 * s / w
            if x < sol <= E:
                x = sol
                X, Y = w + s, s

print(X,Y)
#include<iostream>
using namespace std;

int main() {
    int x;
    int HP = 0;
    bool FUCK = false;
    
    cin >> x;

    if(x < 5){
        cout << 0 << endl;
        FUCK = true;
    }
    
    while(x >= 500){
        HP += 1000;
        x -= 500;
    }
    
    while(x >= 5){
        HP += 5;
        x -= 5;
    }
        
    if(FUCK == false){
        cout << HP << endl;
    }
    
}

### FIXED CODE ###

x = int(input())
HP = 0
FUCK = False

if x < 5:
  print(0)
  FUCK = True

while x >= 500:
  x -= 500
  HP += 1000

while x >= 5:
  x -= 5
  HP += 5

if not FUCK:
    print(HP)
K, N = map(int, input().split())
A = list(map(int, input().split()))
A.append(A[0]+K)
max_d = A[1] - A[0]
for i in range(n-1):
  d = A[i+1] - A[i]
  if max_d < d:
    max_d = d
print(K - max_d)

### FIXED CODE ###

K, N = map(int, input().split())
A = list(map(int, input().split()))
A.append(A[0]+K)
max_d = A[1] - A[0]
for i in range(N):
  d = A[i+1] - A[i]
  if max_d < d:
    max_d = d
print(K - max_d)
S = int(input())
W = int(input())

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

### FIXED CODE ###

S,W=(int(x) for x in input().split())

if S <= W:
  print('unsafe')
else:
  print('safe')
print(input()[0:len(s):2])

### FIXED CODE ###

# https://atcoder.jp/contests/abc072/tasks/abc072_a

import itertools
import collections
import bisect

def main():
    X, t = map(int, input().split())
    print(max(0, X - t))

if __name__ == '__main__':
    main()
import re

N, S = map(int, input().split(' '))
pattern = "AC+"
T = input()
for _ in range(S):
    first,final = map(int, input().split(' '))
    print(first, final)
    result = re.findall(pattern, T[first -1:final])
    print(result)
    print(len(result))

### FIXED CODE ###

dic = {'A': 'T', 'T': 'A', 'C': 'G', 'G': 'C'}
b = input()
print(dic[b])
def swap(a,b,c):
    x = a[b]
    a[b] = a[c]
    a[c] = x
 
     
n = input()
a = list(map(int,input().split()))
alen = len(a)
a.append(0.5)
a.append(0.5)
ans = 0
 
med = [0 for x in range(alen +3)]
 
for i in range(alen):
    if a[i] == i+1:
        med[i+1] = 1
 
for i in range(len(med)):
    if med[i] == 1:
      if med[i+1] == 1:
            swap(a,a[i-1],a[i])
			med[i+1] == 0
            ans += 1
      else:
        swap(a,i,i+1)
        ans += 1
        
print(ans)

### FIXED CODE ###

n = input()
a = list(map(int,input().split()))
a.insert(0,0.5)
alen = len(a)
a.append(0.5)
a.append(0.5)

ans = 0
 
med = [0 for x in range(alen +2)]
 
for i in range(alen):
    if a[i] == i:
        med[i+1] = 1

for i in range(len(med)):
    if med[i] == 1:
        if med[i+1] == 1:
            med[i+1] = 0
            ans += 1
        else:
            ans += 1
        
print(ans)
import itertools;n,m,q,*l=map(int,open(0).read().split());print(max(sum(d for a in[l[j*4:j*4+4]for j in range(q)]if i[b-1]-i[a-1]==c)for i in itertools.combinations_with_replacement(range(m),n)))

### FIXED CODE ###

import itertools
n,m,q=map(int,input().split())
abcd=[list(map(int,input().split()))for _ in range(q)]
ans=0
for i in itertools.combinations_with_replacement(range(m),n):
  anss=0
  for a,b,c,d in abcd:
    if i[b-1]-i[a-1]==c:anss+=d
  ans=max(ans,anss)
print(ans)
a = int(input())

if a%n == 2 :
    print(a)
else :
    print(a*2)

### FIXED CODE ###

a = int(input())

if a%2 == 0 :
    print(a)
else :
    print(a*2)
import math

n = input()
x = input()
t = input()

if n % x == 0:
  return (n / x) * t
else n % x != 0:
  return math.ceil(n / x) * t



### FIXED CODE ###

import math

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

print(math.ceil(a[0] / a[1]) * a[2])
N = int(input())
i = int(input())

print N-i+1

### FIXED CODE ###

n, i = map(int, input().split())
print(n - i + 1)
s = int(input())

def calc(n):
  if n % 2:
    return 3 * n + 1
  else:
    return n // 2

if s == 1 or s == 2 or s == 4:
  print(4)
else:
  count = 1
  while s != 4:
    s = calc(s)
    count += 1

print(count + 3)

### FIXED CODE ###

s = int(input())

def calc(n):
  if n % 2:
    return 3 * n + 1
  else:
    return n // 2

if s == 1 or s == 2 or s == 4:
  print(4)
else:
  count = 1
  while s != 4:
    s = calc(s)
    count += 1
  print(count + 3)
N,Q = list(map(int, input().split()))
S = str(input())
lr=[]
for i in range(Q):
    lr.append(list(map(int, input().split())))


count=[0 for i in range(N)]
ind=0
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
      	ind+=1
        count[i+1]+=ind

for i,j in lr:
    print(count[j-1]-count[i-1])


### FIXED CODE ###

N,Q = list(map(int, input().split()))
S = str(input())
lr=[]
for i in range(Q):
    lr.append(list(map(int, input().split())))


count=[0 for i in range(N)]
ind=0
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        ind+=1
    count[i+1]+=count[i+1]+ind

for i,j in lr:
    print(count[j-1]-count[i-1])
import sys
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

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

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N, X = mi()
    t = [1<<i for i in range(55)]
    def f(L, x, t):
        if L == 0:
            return 1

        if x == 1:
            return 0
        elif 2 <= x <= t[L+1]-2:
            return f(L-1, x-1, t)
        elif x == t[L+1]-1:
            return t[L]
        elif t[L+1] <= x <= t[L+2]-4:
            return t[L]+f(L-1, x-t[L+1]+1, t)
        else:
            t[L+1]-1

    print(f(N, X, t))

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

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

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N, X = mi()
    a, p = [1], [1]
    for i in range(N):
        a.append(a[i]*2+3)
        p.append(p[i]*2+1)

    def f(N, X):
        if N == 0:
            return 0 if X <= 0 else 1

        if X <= 1 + a[N-1]:
            return f(N-1, X-1)
        else:
            return p[N-1]+1+f(N-1, X-2-a[N-1])

    print(f(N, X))

if __name__ == '__main__':
    main()
import math

def binary(n):
    l = [0] * 40#n<10^12<2^40
    for i in range(39,-1,-1):
        if n >= 2 ** i:
            l[i] = 1
            n = n - 2 ** i
        else:
            l[i] = 0
    
    return l#返り値はリストであることに注意

def xor_plus(l1,l2):#引数はリストであることに注意
    l = [0] * 40
    for i in range(0,40):
        if l1[i] == l2[i]:
            l[i] = 0
        else:
            l[i] = 1
    return l#返り値はリストであることに注意

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

b = [0] * n

for i in range(0,n):
    b[i] = binary(a[i])
    
l = int(math.log2(k))
ansx = 2 ** l

sum = 0

for i in range(0,n):
    sum = sum + xor_plus(binary(ansx),b[i])

return(sum)

### FIXED CODE ###

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

def f(x):
    ret = 0
    for i in range(N):
        ret += A[i] ^ x
    return ret

###2**(num-1)<=K<2**numなるnumを求める
P = bin(K)
num = len(list(map(int,P[2:])))

best = 0

for i in range(num):
    count = 0###2**iの位が1になるAの個数
    for j in range(N):
        if A[j] > A[j]^(2**i):
            count += 1
    
    if count <= N - count:
        best += 2**i

#print(best)
can = [0]*40

for i in range(40):
    if K & 2**i == 0:
        continue
    for j in range(0,i):
        can[i] += best & 2**j
    for j in range(i+1,40):
        can[i] += K & 2**j

can.append(K)

print(max(list(map(f,can))))
#高さは後から決まりそう、中心を決める
#x,y,nで動かす三重ループ

n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
XYH=[i for i in xyh if i[2]!=0]
n=len(XYH)
if n==1:
    #この時どうなるか
    if xyh[0][2]==0:
        k
        d=[xyh[0][0],xyh[0][1],xyh[0][2]]
        print(" ".join(map(str,d)))
else:
    d=[0,0]
    f=0
    for i in range(101):
        for j in range(101):
            l=abs(XYH[-1][0]-i)+abs(XYH[-1][1]-j)+XYH[-1][2]
            for k in range(n):
                if l!=abs(XYH[k][0]-i)+abs(XYH[k][1]-j)+XYH[k][2]:
                    break
            else:
                f=1
                d=[i,j]

            if f==1:
                break

        if f==1:
            break

    d.append(abs(XYH[0][0]-i)+abs(XYH[0][1]-j)+XYH[0][2])
    print(" ".join(map(str,d)))


### FIXED CODE ###

#高さは後から決まりそう、中心を決める
#x,y,nで動かす三重ループ

n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
XYH=[i for i in xyh if i[2]!=0]
n=len(XYH)
d=[0,0]
f=0
if n==1:
    d=[XYH[0][0],XYH[0][1],XYH[0][2]]
    print(" ".join(map(str,d)))
else:
    n=len(XYH)
    d=[0,0]
    f=0
    for i in range(101):
        for j in range(101):
            l=abs(XYH[0][0]-i)+abs(XYH[0][1]-j)+XYH[0][2]
            for k in range(n):
                if l!=abs(XYH[k][0]-i)+abs(XYH[k][1]-j)+XYH[k][2]:
                    break
            else:
                f=1
                d=[i,j]

            if f==1:
                break

        if f==1:
            break

    d.append(abs(XYH[0][0]-i)+abs(XYH[0][1]-j)+XYH[0][2])
    print(" ".join(map(str,d)))
# import bisect
# import heapq
# from copy import deepcopy
# from collections import deque
# from collections import Counter
# from itertools import accumulate
# from itertools import permutations
# import numpy as np
import math
# mod = 10**9 + 7

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


if n > 81:
    print('No')
    exit()

else:
    for i in range(2,10):
        if n % i == 0 and 1<= n // i <=9:
            print('Yes')
            exit()

print('No')
    

### FIXED CODE ###

# import bisect
# import heapq
# from copy import deepcopy
# from collections import deque
# from collections import Counter
# from itertools import accumulate
# from itertools import permutations
# import numpy as np
# import math
# mod = 10**9 + 7

# n = int(input())
# a = list(map(int, input().split()))
# n = int(input())
a,b = map(int,input().split())
ans = -1
if 1<=a<=9 and 1<=b<=9:
    ans = a*b

print(ans)
l, r = [int(i) for i in input.split()]

if l//2019 == r//2019:
  print(l*(l+1)%2019)
  
else:
  print(0)
  

### FIXED CODE ###

l, r = [int(i) for i in input().split()]

if l//2019 == r//2019:
  min_mod = 2017*2018
  for i in range(l, r):
    for j in range(l+1, r+1):
      temp = (i*j)%2019
      if temp < min_mod:
        min_mod = temp
  print(min_mod)
  
else:
  print(0)
n,m=map(int,input().split())
sc=[list(map(int,input().split())) for _ in range(m)]
n1=[0]*n
nc=[0]*n
for i in range(n):
    if n1[x[i][0]-1]==0:
        n1[x[i][0]-1]+=x[i][1]
        nc[x[i][0]-1]+=1
    elif nc[x[i][0]-1]!=0 and n1[x[i][0]-1]!=x[i][1]:
        print(-1)
        exit()
while True:
    if n1[0]==0:n1.pop(0)
    if sum(n1)==0:
        print(0)
        exit()
    else:break
print(''.join(map(str,n1)))

### FIXED CODE ###

n,m=map(int,input().split())
 
a=["0"]*n
 
for i in range(m):
    s,c=map(int,input().split())
    if a[s-1]=="0":
        a[s-1]=c
    elif a[s-1]!=c:
        print(-1)
        exit()

if n>1 and a[0]==0:
    print(-1)
    exit()

if n>1 and a[0]=="0":
    a[0]=1

print(*a,sep="")
while True:
    a = int(input())
    b = int(input())
    print(len(str(a + b)))


### FIXED CODE ###

while True:
    try:
        a, b = map(int, input().split(" "))
        print(len(str(a + b)))
    except:
        break
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a,b):
    return a*b // gcd(a,b)

n = int(input())
t_list = []
for x in range(n):
    t_list.append(int(input()))
result = 1
for t in t_list:
    result = lcm(result,t)
print(result)

### FIXED CODE ###

str = input()
print("Yes" if str == str[-1::-1] else "No")
ABInput = str(input())
 
AB = ABInput.split(" ")
 
A = AB[0]
B = AB[1]
 
if B * 2 >= A:
  print (0)
else:
  print (A-B*2)

### FIXED CODE ###

ABInput = str(input())
 
AB = ABInput.split(" ")
 
A = int(AB[0])
B = int(AB[1])
 
TotalCartain = B * 2
 
if TotalCartain > A or TotalCartain == A:
  print (0)
else:
  print (A-TotalCartain)
from collections import deque
n = int(input())
i = 2
a = []
x = n
while(i * i <= n):
    if (n % i == 0):
        a.append(i)
        n //= i
        while(n % i == 0):
            n //= i
            a.append(a[-1] * i)
    i += 1
if (n != 1):
    a.append(n)
a.sort(reverse = True)
ans = 0
while(x != 1 and len(a)):
    while(x % a[-1]):
        a.pop()
    x //= a[-1]
    a.pop()
    ans += 1
print(ans)
    


### FIXED CODE ###

from collections import deque
n = int(input())
i = 2
a = []
x = n
while(i * i <= n):
    if (n % i == 0):
        a.append(i)
        n //= i
        while(n % i == 0):
            n //= i
            a.append(a[-1] * i)
    i += 1
if (n != 1):
    a.append(n)
a.sort(reverse = True)
ans = 0
while(x != 1 and len(a)):
    while(x % a[-1]):
        a.pop()
        if (len(a) == 0):
            break
    if (len(a) == 0):
        break
    x //= a[-1]
    a.pop()
    ans += 1
print(ans)
a=list(input())

IN=[int(x) for x in a if x != " "]
N=IN[0]
A=IN[1]
B=IN[2]

ALL=A+B

cnt=0
num=N
while True:
        num = num - ALL
        if num > 0:
                cnt += 1
        else:
                break

if ALL - num > A:
        ans = A * cnt + A
else:
        ans = A * cnt + ALL - num

print(ans)

### FIXED CODE ###

S=list(input())

if S[0] == S[1]:
        if S[1] == S[2]:
                print("No")
        else:
                print("Yes")
else:
        print("Yes")
# coding: utf-8
# Your code here!
n=int(input())
sum=0
min=1000001
max=-1000001
for i in range(n)
    num=int(input())
    sum+=i
    if max<i:
        max=i
    if min>i:
        min=i

print(str(min)+" "+str(max)+" "+str(sum))


### FIXED CODE ###

# coding: utf-8
# Your code here!
n=int(input())
sum=0
min=1000001
max=-1000001
table=list(map(int,input().split(" ")))
for i in table:
    sum+=i
    if max<i:
        max=i
    if min>i:
        min=i

print(str(min)+" "+str(max)+" "+str(sum))
n = int(input())
s = input()
flag = 0
for i in range(n):
    if s[i] == 'A':
        if s[i+1] == 'B':
            if s[i+2] == 'C':
                flag =+ 1
print(flag)

### FIXED CODE ###

n = int(input())
s = input()
flag = 0
for i in range(n-1):
    if i == n-2:
        break
    if s[i] == 'A':
        if s[i+1] == 'B':
            if s[i+2] == 'C':
                flag += 1
print(flag)
N=int(input())
A=list(map(int, input().split()))

if N%2:
  A = A+ [0]

Adict={}
for a in A:
  Adict[a] = Adict.get(a, 0) +1
  
#print(Adict)

# 0,0,2,2,4,4  5   (i//2)*2 + 1- N%2 0,2,4
# 1,1,3,3,5,5  6

#print(range(1-N%2, N, 2))
#print(all([Adict[i]==2 for i in range(1-N%2, N, 2)]))

if all([Adict[i]==2 for i in range(1-N%2, N, 2)]):
  answer = 1
  for _ in range(N//2):
    answer = (answer * 2)%1000000007
  print(answer)
else:
  print(0)

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
mod=int(1e9+7)

memo={i:0 for i in range(n)}
for a in A:
  memo[a]=memo.get(a,0)+1

answer=1
if n%2:
  if memo[0]!=1:
    print(0)
    exit()
  for i in range(1, (n+1)//2):
    if memo[2*i]!=2:
      print(0)
      exit()
    else:
      answer = 2*answer %mod
elif not n%2:
  for i in range(n//2):
    if memo[2*i+1]!=2:
      print(0)
      exit()
    else:
      answer = 2*answer %mod
      
print(answer)
s=input()
k=int(input())
print(int(s[1]) if s[0]=="1" else s[0])

### FIXED CODE ###

s=list(input())
k=int(input())

if s[:k].count("1") ==k:print(1)
else:
    for i in range(k):
        if s[i]!="1":
            print(s[i])
            break
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)]
#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))
import math

N, K = mi()
A = li()

if K == 0:
    print(max(A))
    exit()

left = 0
right = max(A)

def count(num):
    cnt = 0
    for i in range(N):
        cnt += math.ceil(A[i] / num)
    
    return cnt


while True:
    mid = (left + right) // 2
    tmp = count(mid)
    if tmp == K:
        break
    elif tmp > K:
        if left == mid:
            mid += 1
            break
        left = mid
    else:
        right = mid


if tmp == K and tmp != count(mid-1):
    print(mid)
    exit()

if mid == 0:
    print(mid)
    exit()

right = mid
while True:
    tmp = count(mid)
    if tmp == K and tmp != count(mid-1):
        print(mid)
        break
    if tmp == K:
        right = mid
    else:
        left = mid
    mid = (left + right) // 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)]
#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))
import math

N, K = mi()
A = li()

if K == 0:
    print(max(A))
    exit()

left = 0
right = max(A)

def count(num):
    cnt = 0
    for i in range(N):
        cnt += math.ceil(A[i] / num) - 1
    return cnt

while True:
    mid = (left + right) // 2
    if mid == 0:
        print(1)
        exit()
    tmp = count(mid)
    if right - left <= 1:
        mid = right
        break
    elif tmp > K:
        left = mid
    else:
        right = mid

right = mid

while True:
    tmp = count(mid)
    if right - left <= 1:
        print(right)
        break
    elif tmp == K:
        right = mid
    else:
        left = mid
    mid = (left + right) // 2
    if mid == 0:
        print(1)
        break
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))

R = list(itertools.permutations(list(range(1,N+1))))
a = 0
b = 0

for i in range(len(R)):
    if list(R[i]) == P:
        a = i+1
    elif list(R[i]) == Q:
        b = i+1
    if a!=0 and b!=0:
        break
        
print(abs(a-b))

### FIXED CODE ###

import sys
input = sys.stdin.readline
import itertools

N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))

R = list(itertools.permutations(range(1,N+1)))

print(abs(R.index(Q) - R.index(P)))
x = int(input)
print(x ** 3)

### FIXED CODE ###

x = int(input())
print (x ** 3)