Problem:


﻿Score: 300 points

Problem Statement

Mr. Infinity has a string S consisting of digits from 1 to 9. Each time the date changes, this string changes as follows:

Each occurrence of 2 in S is replaced with 22. Similarly, each 3 becomes 333, 4 becomes 4444, 5 becomes 55555, 6 becomes 666666, 7 becomes 7777777, 8 becomes 88888888 and 9 becomes 999999999. 1 remains as 1.

For example, if S is 1324, it becomes 1333224444 the next day, and it becomes 133333333322224444444444444444 the day after next.
You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days?

Constraints

S is a string of length between 1 and 100 (inclusive).

K is an integer between 1 and 10^{18} (inclusive).

The length of the string after 5 \times 10^{15} days is at least K.

Input

Input is given from Standard Input in the following format:

S
K

Output

Print the K-th character from the left in Mr. Infinity's string after 5 \times 10^{15} days.

Sample Input 1

1214
4

Sample Output 1

2

The string S changes as follows:  

Now: 1214

After one day: 12214444

After two days: 1222214444444444444444

After three days: 12222222214444444444444444444444444444444444444444444444444444444444444444

The first five characters in the string after 5 \times 10^{15} days is 12222. As K=4, we should print the fourth character, 2.

Sample Input 2

3
157

Sample Output 2

3

The initial string is 3. The string after 5 \times 10^{15} days consists only of 3.

Sample Input 3

299792458
9460730472580800

Sample Output 3

2



Sample input:
1214
4


Sample output:
2

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat May  9 16:54:06 2020

@author: shinba
"""

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

cnt = 0

while s[cnt] == "1":
    cnt += 1
    if cnt == len(s):
        break

if cnt >= k:
    print(1)
else:
    print(s[cnt])

Submission status: Accepted

Solution code:
def main():
    S  = input()
    K  = int(input())

    cnt = 0
    while cnt<len(S) and  S[cnt]=='1':
        cnt = cnt + 1
    
    if K<=cnt:
        print(S[0])
    elif cnt==len(S):
        print(S[cnt-1])
    else:
        print(S[cnt])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s=input()
k=int(input())

tmp=len(s)
for i in range(len(s)):
    if s[i]!='1':
        tmp=i
        num=s[i]
        break
if k>tmp:
    print(num)
else:
    print('1')

Submission status: Accepted

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))

def main():
    s = input()
    k = int(input())
    one = 0
    while s[one] == '1':
        one += 1
        if not one < len(s):
            break
    if one >= k:
        print(1)
    else:
        print(s[one])

if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
s = input()
k = int(input())

moji = ""
for i in range(k):
    if s[i] != '1':
        print(s[i])
        exit()
print(s[k-1])

Submission status: Accepted

Solution code:
def main():
    s = input()
    k = int(input())

    for i, c in enumerate(s, start=1):
        if c == '1': continue
        if i <= k:
            print(c)
            return
    print(1)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(S: int, K: int):
    for i, s in enumerate(str(S)[:K]):
        if s != '1':
            return s
    return 1

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    print(solve(S, K))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    k = int(input())

    for i in range(k):
        if s[i] != "1":
            res = s[i]
            break
    else:
        print(1)
        exit()

    print(res)


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
s = list(input())
k = int(input())
cnt = 0
for c in s:
    if c != '1':
        ans = c
        break
    cnt += 1
    if cnt == k:
        ans = 1
        break
print(ans)

Submission status: Accepted

Solution code:
S=input()
K=int(input())

if K==1:
    print(S[0])
else:
    for i,s in enumerate(S):
        if i==K-1:
            print(s)
            exit()
        if s!="1":
            print(s)
            exit()

Submission status: Accepted

Solution code:
S = str(input())
K = int(input())

ans = 1
index = 0
for j in range(len(S)):
    if S[j] != '1':
        ans = int(S[j])
        index = j
        break

if ans == 1:
    print(ans)
elif index > K-1:
    print(1)
else:
    print(ans)

Submission status: Accepted

Solution code:
S = input()
N = int(input())

for i in range(min(N,len(S))):
    if S[i] != "1":
        print(S[i])
        quit()

print(1)

Submission status: Accepted

Solution code:
S = input().strip()
K = int(input())
ind = len(S)+1
for i in range(len(S)):
    if S[i]!="1":
        ind = i+1
        break
if K<ind:
    print(1)
else:
    print(S[ind-1])

Submission status: Accepted

Solution code:
S = input()
K = int(input())

l = len(S)
one = 0
el = S[0]
for i in range(l):
    if S[i]=='1':
        one += 1
    else:
        el = S[i]
        break
if K<=one:
    print(1)
else:
    print(el)

Submission status: Accepted

Solution code:
s=input()
k=int(input())
a=1
for i in range(len(s)):
    if s[i]!='1':
        a=s[i]
        break
print(1 if k<=len(s) and s[0:k]=='1'*k else a)

Submission status: Accepted

Solution code:
S=input()
K=int(input())

first_not_1=-1
for i,s in enumerate(S):
    if s=="1":
        continue
    else:
        first_not_1=i
        break

if K-1<first_not_1:
    print(1)
else:
    print(S[first_not_1])

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    k = int(input())

    res = 1
    idx = 0
    for i in range(len(s)):
        if s[i] != "1":
            res = s[i]
            idx = i + 1
            break

    if k < idx:
        print(1)
    else:
        print(res)


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
S = input()
K = int(input())
for x in S:
    x = int(x)
    if x != 1:
        print(x)
        break
    else:
        if K == 1:
            print(x)
            break
        else:
            K -= 1

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = readline().rstrip().decode()
k = int(read())
for ss in s:
    ss = int(ss)
    if ss > 1:
        print(ss)
        break
    else:
        if k > 1:
            k -= 1
        else:
            print(ss)
            break

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
S = list(map(int, list(input())[: -1]))
K = int(input())
x = 0
for i in range(len(S)):
  if S[i] == 1: x += 1
  else: break
if K <= x: print(1)
else: print(S[x])

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc106/tasks/abc106_c
S = input()
K = read_a_int()
# 1だけはそのままでそれ以外だと無限の長さになる
# 答えは1か初めて1以外になる数字に成る
for i, s in enu(S, start=1):
    if s != '1':
        print(s)
        exit()
    if i == K:
        print(1)
        exit()

Submission status: Accepted

Solution code:
S = input()
K = int(input())

for s in S[:K]:
    if s != '1':
        print(s)
        break
else:
    print(1)

Submission status: Accepted

Solution code:
s = input()
k = int(input())

cnt = 0
for v in s:
  if v == "1": cnt += 1
  else: break
  if cnt == k: break
print(v)

Submission status: Accepted

Solution code:
def main():
    S = input()
    K = int(input())
    ans = "1"
    for i, s in enumerate(S):
        if s == "1":
            continue
        else:
            if i+1 <= K:
                ans = s
            break
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
k = int(input())

for i in range(k):
    if s[i]=='1':
        k-=1
        if k==0:
            print(s[i]);exit()
        continue
    else:
        print(s[i])
        break

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()
u=input().rstrip()
k=I()
for i in range(k):
    if u[i]=="1":
        continue
    else:
        print(u[i])
        sys.exit()
print("1")

Submission status: Accepted

Solution code:
def main():
    s = list(input())
    k = int(input())
    if max(s[:k]) == '1':
        print(1)
        return 0
    for i in s:
        if i > '1':
            print(i)
            return 0

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
k = int(input())

notone = 1
notonei = 101
for i, n in enumerate(s):
    if n != "1":
        notone = int(n)
        notonei = i
        break

if k <= notonei:
    print(1)
else:
    print(notone)

Submission status: Accepted

Solution code:
s = input()
k = int(input())

for i in range(k):
    if s[i] != '1':
        print(s[i])
        exit()
print('1')

Submission status: Accepted

Solution code:
import sys
import math

s=input()
k = int(input())
cnt = False
ans=0
for i in range(0,k):
    if s[i] != '1':
        ans = s[i]
        cnt = True
        break
if (not cnt):
    print(1)
else:
    print(ans)

Submission status: Accepted

Solution code:
import sys

s = input()
k = int(input())
cnt = 0
for i in range(len(s)):
    if s[i] != "1":
        break
    cnt += 1
if cnt >= k:
    print("1")
    sys.exit()

for i in range(len(s)):
    if s[i] != "1":
        ans = s[i]
        print(s[i])
        break

Submission status: Accepted

Solution code:
s=str(input())
k=int(input())

one=0
#最初に連続する1の数を数える
for i in s:
    if i=='1':
        one+=1
    else:
        break

if(k<=one):
    #kより1の数が多ければ1
    print(1)
else:
    #そうでない場合1の次に出てくる数字
    print(s[one])

Submission status: Accepted

Solution code:
def main():
    S = input()
    K = int(input())

    tmp = ''
    count = 0
    for s in S:
        if s == '1':
            count += 1
        else:
            tmp = s
            break

    if count >= K:
        print('1')
    else:
        print(tmp)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s = input()
k = int(input())
k = k-1
def not1(t):
    for i in range(len(t)):
        if t[i] != '1':
            return (i, t[i])
    return (-1, '1')
(j, t) = not1(s)
if j == -1:
    print('1')
    exit()
if k < j:
    print('1')
    exit()
if k >= j:
    print(t)
    exit()

Submission status: Accepted

Solution code:
s=input()
k=int(input())

cnt=0
for i in range(len(s)):
    if s[i]=="1":
        cnt+=1
    else:
        ans_index=i
        break

if k<=cnt:
    print(1)
else:
    print(s[ans_index])

Submission status: Accepted

Solution code:
S=input()
K=int(input())

one = True
for i in range(K):
  one = one and S[i]=='1'
  if not one:
    print(S[i])
    break
if one:
  print(1)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    s = input()
    k = ii()
    if k == 1:
        print(s[0])
    else:
        cnt = 0
        first = 0
        for i in range(len(s)):
            if s[i] == '1':
                cnt += 1
            else:
                first = i
                break
        if k <= cnt:
            print('1')
        else:
            print(s[first])


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    s = input()
    k = int(input())
    ans = solve(s, k)
    print(ans)


def solve(s, k):
    for i in range(k):
        if s[i] != '1':
            return s[i]
    return '1'


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()
K = int(input())
one = 0

for char in S:
    if char == "1":
        one += 1
    else:
        break

if K <= one:
    print(1)
elif one > 0:
    print(S[one])
else:
    print(S[0])

Submission status: Accepted

Solution code:
s=input()
k=int(input())

if k==1:
    print(int(s[0]))

elif int(s[0])==1:

    if len(s)<k:
        num=1
        for i in range(1, len(s)):
            if int(s[i])!=1:
                num=int(s[i])
                break
        print(num)

    else:
        if s[:k]=="1"*k:
            print(1)
        else:
            num=1
            for i in range(1, len(s)):
                if int(s[i])!=1:
                    num=int(s[i])
                    break
            print(num)

elif int(s[0])!=1:
    print(int(s[0]))

Submission status: Accepted

Solution code:
s = input()
k = int(input())
for i in range(len(s)):
    if s[i] == "1":
        k -= 1
    else:
        k-=10**19
    if k <= 0:
        print(s[i])
        break

Submission status: Accepted

Solution code:
s=input()
k=int(input())

for i in range(len(s)):
    if int(s[i])==1:
        k-=1
        if k==0:
            print(s[i]);exit()
    else:
        print(s[i]);exit()

Submission status: Accepted

Solution code:
def main(s: str, k: int):
    for i in range(k):
        if s[i] != "1":
            print(s[i])
            return

    print(1)


if __name__ == "__main__":
    s = input()
    k = int(input())

    main(s, k)

Submission status: Accepted

Solution code:
s = input()
k = int(input())
for i, c in enumerate(s):
    if int(c)>1:
        if k<i+1:
            print(1)
        else:
            print(int(c))
        break
else:
    print(1)

Submission status: Accepted

Solution code:
S = input()
K = int(input())
if len(S) >= K and S[:K].count("1") == K:
    print(1)
else:
    for c in S:
        if c != "1":
            print(c)
            break

Submission status: Accepted

Solution code:
s = input()
k = int(input())
for i in range(k):
    if s[i]!='1':
        print(s[i])
        exit()
print(s[k-1])

Submission status: Accepted

Solution code:
S=input()
k=int(input())
cnt=0
for i in range(len(S)):
    if S[i]=="1":
        cnt+=1 
    else:
        temp=S[i]
        break 
if k<=cnt:
    print(1)
else:
    print(temp)

Submission status: Accepted

Solution code:
s = input()
k = int(input())
if(k-1 < len(s)):
    for i in range(k):
        if(s[i] != '1'):break
    else:
        print(1)
        exit()
for i in s:
    if(i != '1'):
        print(i)
        exit()

Submission status: Accepted

Solution code:
S = [int(i) for i in input()]
K = int(input())

ans = 1
if K<=len(S):
    for i in S[:K]:
        if i!=1:
            ans=i
            break
else:
    for i in S:
        if i!=1:
            ans=i
            break
print(i)

Submission status: Accepted

Solution code:
n = input()
k = int(input())
if k == 1:
    print(n[0])
else:
    for i in range(len(n)):
        if int(n[i]) >= 2:
            print(n[i])
            exit()
        elif i+1 == k:
            print(n[i])
            exit()

Submission status: Accepted

Solution code:
s = input()
k = int(input())

counter = 0
for i in range(len(s)):
  if s[i] == "1":
    counter += 1
    ans = 1
  else:
    ans = i
    break
  
if k <= counter:
  ans = 1
else:
  ans = s[ans]
  
print(ans)

Submission status: Accepted

Solution code:
s = input()
k = int(input())
if set(s[:min(k, len(s))]) == {'1'}:
    print(1)
else:
    for si in s[:min(k, len(s))]:
        if si != '1':
            print(si)
            break

Submission status: Accepted

Solution code:
S = input()
K = int(input())

s0 = 0

for s in S:
    if s == '1':
        s0 += 1
        if s0 == K:break
    else: break
print(s)

Submission status: Accepted

Solution code:
S = input()
K = int(input())

ans = 0
s0 = 0

for s in S:
    if s == '1':
        s0 += 1
        if s0 == K:break
    else: break
print(s)

Submission status: Accepted

Solution code:
S = input()
K = int(input())

for i, si in enumerate(S):
    if si != '1' and i < K:
        print(si)
        break
    elif i == K-1:
        print(1)

Submission status: Accepted

Solution code:
S = input()
K = int(input())
ans = 0 
for i in range(K):
  if S[i] != "1":
    ans = int(S[i])
    break
  else:
    ans = 1

print(ans)

Submission status: Accepted

Solution code:
s = list(input())
k = int(input())
cnt = 0
x = min(len(s),k)
for i in range(x):
    if s[i] != '1':
        print(s[i])
        break
else:
    print(1)

Submission status: Accepted

Solution code:
s = list(input())
k = int(input())
cur = 1
for c in s:
    if c != "1":
        print(c)
        break
    else:
        if cur == k:
            print(c)
            break
        cur += 1

Submission status: Accepted

Solution code:
s = input()
k = int(input())

if sum(map(int, list(s[:k]))) == len(s[:k]):
    print('1')
else:
    ans = s.replace('1', '')[0]
    print(ans)

Submission status: Accepted

Solution code:
S = input()
K = int(input())

if all(s == "1" for s in S[:K]):
    print(1)
else:
    for i in range(len(S)):
        if S[i] != "1":
            print(S[i])
            break

Submission status: Accepted

Solution code:

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

for i in range(k):
    if s[i]!="1":
        break
if s[i]!="1":
    print(s[i])
else:
    print(1)

Submission status: Accepted

Solution code:
s = input()
k = int(input())
 
limit = min(100, k)
 
ans = 1
for i in range(limit):
    if s[i] != '1': # K番目までで1が登場すれば1、そうでなければその次のもの
        ans = s[i]
        break
 
print(ans)

Submission status: Accepted

Solution code:
n=str(input())
N = int(n)
m=int(input())
cnt = 0
for i in range(m):
    if i >= N:
        break
    if n[i] == "1":
        cnt +=1
    else:
        break
      
    
if cnt == m:
    print(1)
elif cnt == 0:
    print(n[0])
elif  cnt < m:
    print(n[cnt])

Submission status: Accepted

Solution code:
s=input()
k=int(input())
l=0
for i in s:
    if i=="1":
        l+=1
    else:
        break
print("1" if k<=l else s[l])

Submission status: Accepted

Solution code:
s=input()
k=int(input())
if len(s)>=k:
  for i in range(k):
    if s[i]!="1":
      print(s[i])
      break
  else:
    print(1)
    
else:
  for i in range(len(s)):
    if s[i]!="1":
      print(s[i])
      break

Submission status: Accepted

Solution code:
s = input()
k = int(input())
ans = 1

for i in range(min(len(s),k)):
    x = int(s[i])
    if x != 1:
        ans = x
        break
        
print(ans)

Submission status: Accepted

Solution code:
s = input()
k = int(input())

ans = 1

for s_i in s:
  if s_i == '1':
    k -= 1
    if k == 0: break
  else:
    ans = int(s_i)
    break
  
print(ans)

Submission status: Accepted

Solution code:
S = input()
K = input() 
ans = 1
if not all([i == '1' for i in S[:int(K)]]):
    for i in range(len(S)):
        if S[i] != '1':
            ans = int(S[i])
            break
print(ans)

Submission status: Accepted

Solution code:
s = input()
k = int(input())
for i in range(min(len(s), k)):
  if s[i] != '1':
    print(s[i])
    break
else:
  print(s[k - 1])

Submission status: Accepted

Solution code:
def main():
    S = input()
    K = int(input())
    idx = 0
    num = ""

    count_one = 0
    for i in range(len(S)):
        if S[i] == "1":
            count_one += 1
        else:
            idx = i
            num = S[i]
            break

    if count_one >= K:
        print("1")
    else:
        print(num)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(S: int, K: int):
    K -= 1
    for c in str(S):
        if c == "1":
            K -= 1
        else:
            K = -1
        if K < 0:
            print(c)
            return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(S, K)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()
K = int(input())

ren = 0
for i in range(len(S)):
  if S[i] =="1":
    ren+=1
  else:
    break

if K<=ren :
  print(1)
else:
  print(S[ren])

Submission status: Accepted

Solution code:
import sys

s = input()
k = int(input())
cur = 0

while cur < k:
    if s[cur] != "1":
        print(s[cur])
        sys.exit()
    cur += 1

print(1)

Submission status: Accepted

Solution code:
def main():
    s = input()
    k = int(input())

    if s[0] != '1':
        print(s[0])
        exit()

    for i in range(1,len(s)):
        if s[i] != '1':
            break
    else:
        print(1)
        exit()

    if i >= k:
        print(1)
        exit()

    print(s[i])

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()
K = int(input())

are_all_one = True
for i in range(len(S)):
    if S[i] != '1':
        are_all_one = False
        break

nth = i + 1
if are_all_one or K < nth:
    print(1)
    exit()

answer = S[i]
print(answer)

Submission status: Accepted

Solution code:
S=input()
k=int(input())
if S[0]!="1":
    print(S[0])
else:
    cnt=0
    for i in range(len(S)):
        if S[i]=="1":
            cnt+=1
        else:
            break
    if cnt>=k:
        print(1)
    else:
        print(S[i])

Submission status: Accepted

Solution code:
S = input()
K = int(input())
t = 0
for i in range(len(S)):
    if S[i] == "1":
        t += 1
    else:
        break
if K <= t:
    print(1)
else:
    print(S[t])

Submission status: Accepted

Solution code:
s=input()
k=int(input())

for i in list(s[:k]):
    if i!="1":print(i);exit()
else:print(1)

Submission status: Accepted

Solution code:
n = input()
k = int(input())
ans = 1

for i in range(k):
  
  if n[i] != "1":
    ans = n[i]
    break

print(ans)

Submission status: Accepted

Solution code:
s=input()
k=int(input())
i=0
while i<len(s) and s[i]=='1':
  i+=1
if k<=i or i==len(s):
  print(1)
else:
  print(s[i])

Submission status: Accepted

Solution code:
s = str(input())
k = int(input())
flag = False
for i in range(len(s)):
  if s[i] != '1':
    flag = True
    posi = i
    break
if flag:
  if k < posi+1:
    print(1)
  else:
    print(s[posi])
else:
  print(s[0])

Submission status: Accepted

Solution code:
s = input()
k = int(input())

limit = min(100, k)

ans = 1
for i in range(limit):
    if s[i] != '1':
        ans = s[i]
        break

print(ans)

Submission status: Accepted

Solution code:
s = input()
k = int(input())

for i in range(len(s)):
    if s[i] == "1":
        if i+1 == k:
            print(1)
            break
    else:
        print(s[i])
        break

Submission status: Accepted

Solution code:
S = str(input())
K = int(input())
for i in range(min(len(S), K)):
  if S[i] != "1":
    print(S[i])
    break
else:
  print(1)

Submission status: Accepted

Solution code:
s = input()
k = int(input())
m = 0
for i in s:
  if i=='1':
    m += 1
  else:
    break
if m>=k:
  print(1)
else:
  for i in s:
    if i!="1":
      print(i)
      break
    else:
      continue

Submission status: Accepted

Solution code:
S = input()
K = int(input())
ans = S[0]
for i in range(min(len(S),K)):
    if S[i] != '1':
        ans = S[i]
        break
print(ans)

Submission status: Accepted

Solution code:
def resolve():
    s = input()
    k = int(input())
    cnt = -1
    for i in range(len(s)):
        if s[i] != '1':
            break
        cnt = i + 1
    if cnt >= k:
        print(1)
    else:
        print(s[cnt] if len(s) > cnt > -1 else s[0])

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
s = input()
k = int(input())

for c in s:
  if c == '1':
    k -= 1
    if k == 0:
      print(1)
      break
  else:
    print(c)
    break

Submission status: Accepted

Solution code:
# solution

data=input()

k=int(input())

for i,c in enumerate(data):
  if c!='1' or i>=k-1:
    break

print(c)

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict(list)
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    s = input()
    k = int(input())
    ichi = 0
    for s_ in s:
        if s_ == '1':
            ichi += 1
        else:
            break
    if ichi >= k:
        print(1)
    else:
        print(s[ichi])
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
S=input()
K=int(input())
for i in range(K):
    if S[i]!='1':
        break
print(S[i])

Submission status: Accepted

Solution code:
S = list(input())
K = int(input())

for i in range(K):
    if S[i] != "1":
        print(S[i])
        exit()
    if i + 1 == K:
        print(S[i])
        exit()
print("1")

Submission status: Accepted

Solution code:
s = input()
k = int(input())

for i in range(len(s)):
    if s[i] != "1":
        print(s[i])
        break
        
    else:
        k -= 1
        if k == 0:
            print(1)
            break

Submission status: Accepted

Solution code:

s = input()
k = int(input())
for si in s:
    if si != '1':
        print(si)
        break
    else:
        k -= 1
        if k == 0:
            print(1)
            break

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline

def main():
    S = list(map(int, list(readline().rstrip())))
    K = int(readline())

    if S[0] != 1 or len(S) == 1:
        print(S[0])
        return

    idx = min(len(S), K)
    if sum(S[:idx]) == len(S[:idx]):
        print(1)
    else:
        for e in S:
            if e != 1:
                print(e)
                return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def myAnswer(S:list,K:int) -> int:
   if(K == 1): return S[0]
   ans = ""
   for n,s in enumerate(S):
      if(s != "1"):
         ans = s
         break
      elif(s == "1" and n == K -1 ):
         ans = "1"
         break
   return ans

def modelAnswer():
   tmp=1
def main():
   S = list(input())
   K = int(input())
   print(myAnswer(S[:],K))

if __name__ == '__main__':
   main()