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:
data = input()
num = int(input())

cnt = 0
for lop in range(len(data)):
    if int(data[lop]) == 1:
        cnt = cnt + 1
        if num == cnt:
            print(data[lop])
            break
    else :    
        cnt = cnt + (int(data[lop])*1000000000000000000)**5
        if cnt > num:
            print(data[lop])
            break

Submission status: Accepted

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

count = 0
for i in s:
    if(int(i) == 1):
        count += 1
    else:
        break

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

Submission status: Accepted

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

def main():
    s = sys.stdin.readline().rstrip()
    k = int(sys.stdin.readline().rstrip())

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


if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
def findFirstNot1(arg):
    ret = 1000
    ichi = 0
    for c in range(0, len(arg)):
        if arg[c] == '1':
            ichi += 1
        else:
            return ichi + 1
    return ret

instr = input()
nanmojime = int(input())
first1igai = findFirstNot1(instr)
if first1igai > nanmojime:
    ans = 1
else:
    ans = int(instr[first1igai - 1])
print(ans)

Submission status: Accepted

Solution code:
A = raw_input()
C = raw_input()

B = int(C)

num = map(int, str(A))

numnum = len(num)


i = 0

while num[i] == 1 and numnum-1 > i:
  i = i +1

  
if i < B:
  print num[i]
elif i > B-1:
  print 1

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8
#


def main(s, k):
    # 2**5000兆>10^18なので、左から数えて最初に出てきた2以外の数がほぼほぼ答え。
    # ただし、最初に1が詰まっていた場合、イレギュラー
    for i in range(k):
        if '1' != s[i:i+1]:
            print(s[i:i+1])
            return
    print(1)
    
    
if __name__ == '__main__':
    try:
        s = input().strip()
        k = int(input().strip())
        main(s, k)
    except EOFError:
        pass

Submission status: Accepted

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

## 5000兆日
#a = 5000 * 10000 * 10000 * 10000
#
## 10の18乗
#k = 10 ** 18 = 10 * 1000 * 1000 * 1000 * 1000 * 1000 * 1000


iLen = len(S)
iMin = min(iLen, K)

ans="1"
for i in range(iMin):
	c = S[i]
	if (c=="1"): continue
	ans = c
	break

print(ans)

Submission status: Accepted

Solution code:
#C
S=input()
K=int(input())
num='23456789'
if S[0]!='1':
    print(int(S[0]))
else:
    n=1
    while True:
        if n==len(S):
            n-=1
            break
        elif S[n]!='1':
            break
        n+=1
    if K-1<n:
        print(1)
    else:
        print(int(S[n]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
s = input()
k = int(input())

l = len(s)
ones = 0
i = 0
while s[i] == '1':
    ones += 1
    i += 1
    if i == l:
        break

if ones >= k:
    print('1')
else:
    print(s[i])

Submission status: Accepted

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

if set(Ss[:K]) == set('1'):
    print(1)
else:
    print(Ss.replace('1', '')[0])

Submission status: Accepted

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

big = False

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

if not big:
    ans = s[0]
elif k <= big:
    ans = 1
else:
    ans = s[big]

print(ans)

Submission status: Accepted

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

first_pos = -1
for i in range(len(s)):
    if s[i] != '1':
        first = s[i]
        first_pos = i + 1
        break

if first_pos == -1 or first_pos > k:
    print(1)
else:
    print(first)

Submission status: Accepted

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

if S[0] != "1":
    print(S[0])
    
else:
    for n in range(K):
        if S[n] == "1":
            continue
        
        print(S[n])
        break
    else:
        print(S[K-1])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

    for i, c in enumerate(s):
        if c == '1':
            if i == k - 1:
                print('1')
                break
            else:
                continue
        else:
            print(c)
            break


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

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

s = list(S)

count1 = 0
greater = 0

for c in s:
    if c=="1":
        count1+=1
    else:
        greater = c
        break

if K <= count1:
    print("1")
else:
    print(greater)

Submission status: Accepted

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

for i, si in enumerate(s):
    if i==k:
        print(1)
        exit()
    if si!='1':
        print(si)
        exit()
else:
    print(si)

Submission status: Accepted

Solution code:
def main():
    s = input()
    k = int(input())
    # あたまに '1' が並んでいるケース
    ss = ''
    for w in s:
        if w == '1':
            ss += w
        else:
            break
    if len(ss) >= k:
        print(1)
        return
    for w in s:
        if w != '1':
            print(w)
            break



if __name__ == '__main__':
    main()

Submission status: Accepted

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


n1 = 10**19
for i in range(2,10):
    if str(i) in a:
        temp = a.find(str(i))
        if temp < n1:
            n1 = temp
            num = i

if k <= n1:
    print(1)
else:
    print(num)

Submission status: Accepted

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

c = 0
cnt = 0
for i in S:
    if int(i) != 1:
        c = int(i)
        break
    cnt += 1


if K <= cnt:
    print(1)
else:
    print(c)

Submission status: Accepted

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

st=str(s)
l=len(st)
i=0
a=0
n=0
m=0

while n<1:
    if int(st[m])==1:
        m+=1
        a+=1
    else:
        n=1
    if a==l:
        n=1

if a>=k:
    print(1)

else:
    while i<=l:
        if int(st[i])!=1:
            print(int(st[i]))
            i=l+1
        else:
            i+=1

Submission status: Accepted

Solution code:
s =  int(input())
k =  int(input())
#print(pow(10, 12))
def main(string_s):
    for i, j in enumerate(str(string_s)):
#        print(i, j)
#        print(i, k)
        if j != '1':
            break
        if i+1 == k:
            print('1')
            return
    if str(s).lstrip('1') == '':
         print('1')
         return
    if str(s).lstrip('1')[0] == '2':
        print('2')
    elif str(s).lstrip('1')[0] == '3':
        print('3')
    elif str(s).lstrip('1')[0] == '4':
        print('4')
    elif str(s).lstrip('1')[0] == '5':
        print('5')
    elif str(s).lstrip('1')[0] == '6':
        print('6')
    elif str(s).lstrip('1')[0] == '7':
        print('7')
    elif str(s).lstrip('1')[0] == '8':
        print('8')
    elif str(s).lstrip('1')[0] == '9':
        print('9')
    else:
        print('1')

main(s)

Submission status: Accepted

Solution code:
l=list(input())
k=int(input())
m=[0]*len(l)
for i in range(len(l)):
    var=pow(int(l[i]),100)
    if(i==0):
        m[i]+=var
    if(i>=1):
        m[i]+=(m[i-1]+var)
    if(k<=m[i]):
        print(l[i])
        exit()

Submission status: Accepted

Solution code:
S=list(input())
K=int(input())
idx=[-1]*10
for i in '123456789':
    if i in S:
        idx[int(i)] = S.index(i)+1
if idx[2:]==[-1]*8 or K < max(idx[2:]):
    print(1)
else:
    print(S[min(i for i in idx[2:]if i>0)-1])

Submission status: Accepted

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

import numpy as np

ind = np.inf

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

Submission status: Accepted

Solution code:
def ans():
  s = input()
  k = int(input())
  for i in range(k):
    if s[i] != '1':
      print(s[i])
      return
  print("1")
  return

ans()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

for i,a in enumerate(s):
    if (a != '1' ) or k==i+1:
        ans = int(a)
        break

print (ans)

Submission status: Accepted

Solution code:
from sys import stdin

S = stdin.readline().rstrip()
K = int(stdin.readline().rstrip())

S = list(S)
ans = 1
for i in range(K):
    if int(S[i]) != 1:
        ans = int(S[i])
        break
print(ans)

Submission status: Accepted

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

x = 0
ans1 = []
for x in range(len(s)):
    if s[x] == '1':
        ans1.append(x+1)
        x += 1
    else:
        break

if k in ans1:
    print('1')
else:
    print(s[x])

Submission status: Accepted

Solution code:
S = input()
K = int(input())
one_length = 0
next_num = '1'
for (i, s) in enumerate(S):
    if s != '1':
        one_length = i
        next_num = s
        break

if one_length < K:
    print(str(next_num))
else:
    print('1')

# 1 or 一つ目の1以外

Submission status: Accepted

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

l=0

while s[l] == '1':
    l+=1
    if l >= len(s):
        l -= 1
        break

n = int(s[l])

if k<=l:
    print(1)
else:
    print(n)

Submission status: Accepted

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


for i, s in enumerate(S):
    if s == "1":
        if i + 1 == K:
            print(1)
            exit()
    else:
        print(s)
        exit()

Submission status: Accepted

Solution code:
import sys
s=input()
k=int(input())
if(len(s)==1):
    print(s[0])
    sys.exit()
if(k==1):
    print(s[0])
    sys.exit()
c=0
for i in range(k):
    if(s[i]=='1'):c+=1
    else:break
if(c==k):
    print(1)
else:
    print(s[c])

Submission status: Accepted

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

ans = '1'
one = 0
for i, s in enumerate(S):
    if s == '1':
        one += 1
        continue

    ans = s
    break

if K <= one:
    ans = '1'

print(ans)

Submission status: Accepted

Solution code:
#! usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    s, k = input(), int(input())

    if len(s) == 1 or k == 1:
        print(s[0])
        exit()

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

    if k < idx + 1:
        print("1")
    else:
        print(s[idx])


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
k = I()
ans = 0
for i in range(k):
    if int(s[i]) == 1:
        continue
    else:
        ans = i
        break
print(s[ans])

Submission status: Accepted

Solution code:
import numpy as np
def get():
    s = input()
    k = int(input())
    nums = []
    for item in s:
        nums.append(int(item))
    nums = np.array(nums)
    # if k >= nums.shape[0]:
    #     m = np.max(nums)
    # else:
    #     m = np.max(nums[:k])
    # count = np.bincount(nums)
    for i in nums[:k]:
        if i!=1:
            return i
    return 1
a = get()
print(a)

Submission status: Accepted

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

if k == '1':
    print(s[0])
else:
    n = min(int(k), len(s))
    f = True
    for i in range(n):
        if s[i] != '1':
            print(s[i])
            f = False
            break
    if f:
        print(1)

Submission status: Accepted

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

i = 0
ans = '0'
while True:
    try:
        if s[i] != '1':
            ans = s[i]
            break
        else:
            i += 1
    except IndexError:
        ans = s[i-1]
        break
    
if k <= len(s):
    ans = '1'
    for i in range(k):
        if s[i] != '1':
            ans = s[i]
            break

print(ans)

Submission status: Accepted

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

numlist = list(map(int, list(S)))
count = 0
for i in range(len(numlist)):
    if numlist[i] != 1:
        count = i + 1
        break

if count > K:
    print(1)
else:
    print(numlist[count - 1])

Submission status: Accepted

Solution code:
S = input().strip()
K = input().strip()

if len(K) <= 3:
    k = int(K)
else:
    k = 1000

if len(S) == 1:
    print(S)
elif len(S) == sum([int(i) for i in S]):
    print(1)
else:
    for i in S:
        k -= 1
        if (k == 0) or (i != "1"):
            print(i)
            break

Submission status: Accepted

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

if len(S) >= K :
    T = S[0:K]
else :
    T = S[0:len(S)]
point = T.count("1")
if point >= K :
    print(1)
else :
    for j in range(len(S)) :
        if S[j] != "1" :
            print(S[j])
            break

Submission status: Accepted

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

s = ''
for i in S:
    s += i
    if i != '1':
        break

if K < len(s):
    print(s[K-1])
else:
    print(s[-1])

Submission status: Accepted

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

ans = ''
i = 0
while True:
    if k == 1:
       ans = s[i]
       break
    else:
        if s[i] == '1':
            k -= 1
            i += 1
        else:
           ans = s[i]
           break
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
S = raw_input()
K = input()
DAYS = 60
sum_count_list = []
for i in range(len(S)):
	sc = 0
	if len(sum_count_list) > 0:
		sc = sum_count_list[-1]
	sc += int(S[i]) ** DAYS
	sum_count_list.append(sc)
	
for i in range(len(S)):
	if K <= sum_count_list[i]:
		print(S[i])
		break

Submission status: Accepted

Solution code:
a = list(map(int,input()))

b = int(input())

k = 0

if len(a) == 1:
    print(a[0])

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

Submission status: Accepted

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

count=0
for i in a:
    if i=="1":
        count+=1
    elif i != "1":
        break

for i in a:
    if count >= k:
        print("1")
        break
    if i!="1":
        print(i)
        break

Submission status: Accepted

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

if S[0]=="1":
	for i in range(K):
		if S[i]!="1":
			print S[i]
			quit()
	else:
		print 1
		quit()
	
else:
	print S[0]

Submission status: Accepted

Solution code:
s=input()
k=int(input())
atai = [0 for i in range(len(s))]
atai2 = [0 for i in range(len(s))]
kazu = [0 for i in range(len(s))]

gosen_chou = 5000 * 10 ** 12

for i in range(len(s)):
  atai[i] = int(s[i])

ans2 = -1
count = 0
for i in range(len(s)):
  if atai[i] ==1:
    count +=1
  elif atai[i] != 1:
    ans2 = atai[i]
    break    

if k <= count:
  print(1)
else:
  print(ans2)
    
    
"""
for i in range(len(s)):
  atai2[i] = atai[i] ** gosen_chou

a = 0  
for i in range(len(s)):
  a += atai2[i]
  kazu[i] = a

for i in range(len(s)):
  if k <= kazu[i]:
    ans = atai[i]
    break
    
  
print(atai)
print(kazu)
"""

Submission status: Accepted

Solution code:
A=input()
B=int(input())

for i in A:
    if int(i) == 1:
        B-=1
    else:
        print(int(i))
        exit(0)
    if B == 0:
        print(1)
        exit(0)

Submission status: Accepted

Solution 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()]

def test(x):
  return x % 2 == 1 and sum(x % y == 0 for y in range(1, x+1)) == 8

S = input()
K = read() - 1
N = len(S)
i0 = next((i for i in range(N) if S[i] != '1'), N)
if K < i0:
  print(1)
else:
  print(S[i0])

Submission status: Accepted

Solution code:
# coding=utf-8

if __name__ == '__main__':
    S = input()
    K = int(input())

    for elm in S:
        if elm != '1':
            ctr = S.index(elm)
            break
    else:
        ctr = -1

    if ctr == -1:
        print(1)
    else:
        if ctr+1 > K:
            print(1)
        else:
            print(S[ctr])

Submission status: Accepted

Solution code:
s = input()
k = int(input())
a = 0
b = 0
for i in range(len(s)):
  if(s[i] != "1"):
    a = s[i]
    b = i + 1
    break
if(a == 0 or k < b):
  print(1)
else:
  print(a)

Submission status: Accepted

Solution code:
s = list(input())
k = int(input())
if '1' not in s:
    print(s[0])
else:
    num = 0
    for i in range(len(s)):
        if s[0] == "1":
            s.pop(0)
            num += 1
        else:
            break
    if num >= k:
        print(1)
    else:
        print(s[0])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect

def s():
    return input()
def n():
    return int(input())

S = s()
K = n()

n=0
for s in S:
    n += 1
    if s != '1':
        s_first = s
        break

if n <= K:
    print(s)
else:
    print(1)

Submission status: Accepted

Solution code:
S = input()
K = int(input())
# A, B = map(int, input().split())
# A = list(map(int, input().split()))
# d = [list(map(int, input().split())) for _ in range(N)]
# s = input()
ar = []
#
for i in S:
    ar.append(int(i))
#
# sum = 0
# for i in ar:
#     sum += pow(i, K)
#     if sum >= K:
#         print(i)
#         break

for i in range(len(ar)):
    if ar[i] == 1:
        if i + 1 == K:
            print(1)
            break
    else:
        print(ar[i])
        break

Submission status: Accepted

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

count = 0
answer =''
for s in S:
    if s == '1':
        count += 1
    else:
        answer = s
        break
if count >= K:
    print('1')
else:
    print(answer)

Submission status: Accepted

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

i=0
while(s[i]=="1"):
    if i==(len(s)-1):
        break
    i +=1
    
if k<(i+1):
    print(1)
else:
    print(s[i])

Submission status: Accepted

Solution code:
S = input()
K = int(input())
for s in list(S):
  ans = s
  if s=='1':
    K = K-1
  else:
    break
  if K==0:
    break
print(ans)

Submission status: Accepted

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

for i,c in enumerate(S,1):
        if c == "1" and i != K:
                continue
        else:
                print(c)
                break
else:
        print("1")

Submission status: Accepted

Solution code:
s = list(input())
k = int(input())
i = 0
flag = 0
while s[i] == "1":
    i += 1
    if i == len(s):
        flag = 1
        break
onelength = i
if flag == 1:
    print(1)
else :
    onenext = s[i]
    if onelength < k:
        print(s[i])
    else:
        print(1)

Submission status: Accepted

Solution code:
n=input()
m=int(input())
s=list(n)
if s[0]!="1":
    print(s[0])
elif s[0]=="1":
    p=0
    for i in s:
        if i=="1":
            p+=1
        else:
            q=i
            break
    if m<=p:
        print(1)
    else:
        print(q)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()

S=ni()
K=ni()
S=str(S)

count_one=0
ans_tmp=1
for i in range(len(S)):
  if S[i]=='1':
    count_one+=1
  else:
    ans=S[i]
    break

if K<=count_one:
  print(1)
else:
  print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def run(s, k):
    cnt = 0
    for si in s:
        si = int(si)
        if si == 1:
            cnt += 1
        else:
            return si
        if k == cnt:
            return 1


def read_line():
    s = input()
    k = int(input())
    return (s, k)


def main():
    s, k = read_line()
    print(run(s, k))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from sys import stdin
# stdin = open('sample.txt')


def main():
    S = stdin.readline().rstrip()
    K = int(stdin.readline().rstrip())
    tmp = 0
    # spam = 5000 * 1000000000000
    for c in S:
        if c == '1':
            tmp += 1
            if K == tmp:
                print(1)
                break
        else:
            print(c)
            break


if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i in range(K):
    if S[i]== '1':
        pass
    else:
        print(S[i])
        break
else:
    print(1)

Submission status: Accepted

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

count = 0
for i in range(len(s)):
    if s[i] != "1":
        print(s[i])
        exit()
    if s[i] == "1":
        count += 1
        if count == k:
            print(s[i])
            exit()

Submission status: Accepted

Solution code:
s = input()
k = int(input())
flag = -1
n = len(s)

if n >= k:
	n = k

for i in range(n):
	if flag == -1:
		if s[i] != '1':
			flag = i

if flag == -1:
	print('1')
else:
	print(s[flag])

Submission status: Accepted

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

# s = "1124"
# k = 3

ch_cnt = 0
first_num = 1

for ch in s:
    if ch != "1":
        first_num = int(ch)
        break
    ch_cnt += 1

# print(first_num, k)

if k <= ch_cnt:
    print(1)
else:
    print(first_num)

Submission status: Accepted

Solution code:
s = input()
k = int(input())
for i, c in enumerate(s):
    if i + 1 == k or c != '1':
        print(c)
        break

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def solve():
    s = input()
    n = int(input())
    idx = 0
    slen = len(s)
    while idx < slen and s[idx] == "1":
        idx += 1
        if idx == n:
            print(1)
            return
    if idx == slen:
        print(1)
    else:
        print(s[idx])


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
S = input()
K = int(input())
key = 0
i = 0
while True:
    if i >= K:
        break
    if i >= len(S):
        break
    if int(S[i]) != 1:
        print(S[i])
        key = 1
        break
    i += 1

if key == 0:
    print(S[0])

Submission status: Accepted

Solution code:
#encoding utf-8

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

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

        moji = s[i]
        break
    else:
        if i+1 == k:
            moji = "1"

print(moji)

Submission status: Accepted

Solution code:
S = [int(x) for x in list(input())]
K = int(input())
flag = True; i = 0
while flag:
    if S[i] == 1:
        if K == 1:
            print(1)
            flag = False
        else:
            i += 1
            K -= 1
    else:
        print(S[i])
        flag = False

Submission status: Accepted

Solution code:
s = input()
k = int(input())
n = len(s)
index = float("inf")
num = 0
for i in range(n):
    if s[i] != "1":
        index = i + 1
        num = s[i]
        break

if k < index:
    print(1)
else:
    print(num)

Submission status: Accepted

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

for i in S:
    if(i=="1"):
        if(K==1):
            print("1");
            break;
        else:
            K-=1;
    else:
        print(i);
        break;

Submission status: Accepted

Solution code:
import sys


def main(S, K):
    # len(S) <= 100
    # K <= 10^18
    # 5,000,000,000,000,000

    one = 0 
    for d in S:
        if d == '1':
            one += 1
        else:
            c = d
            break
    print("one", one, file=sys.stderr)
    if one != 0 and K <= one:
        return '1'
    else:
        return d

if len(sys.argv) == 3:
    S = sys.argv[1]
    K = int(sys.argv[2])
    print(main(S, K))
else:
    S = input()
    K = int(input())
    print(main(S, K))

Submission status: Accepted

Solution code:
# coding:utf-8

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

days = 5000000000000000
strNum = 0
calcEnd = False
for i in S:
    i_int = int(i)
    iNum = 1
    # iNum = i_int ** days
    if i_int == 1:
        iNum == 1
        if strNum + iNum >= K:
            ans = i
            calcEnd = True
            break

    else:
        for j in range(days):
            iNum *= i_int

            if strNum + iNum >= K:
                ans = i
                calcEnd = True
                break

    strNum += iNum

    if calcEnd == True:
        break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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


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


if len(S)==1:
    ans=S[0]

elif n<=onecount:
    ans=1
else:
    ans=S[onecount]
    
print(ans)

Submission status: Accepted

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

for c in s[:min(len(s),k)]:
    if c != '1':
        print(c)
        exit()
print('1')

Submission status: Accepted

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

ar = [int(s) for s in st]

count = 0
for a in ar:
    if a==1:
        count+=1
    else:
        break

if k<=count:
    print(1)
else:
    print(ar[count])

Submission status: Accepted

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

Submission status: Accepted

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

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

if S[x]=="1":
    print(1)

elif K<x+1:
    print(1)

else:
    print(S[x])

Submission status: Accepted

Solution code:
import sys

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


i=0
while i<len(s) and i<k:
    if s[i]=="1":
        i+=1
    else:
        print(s[i])
        sys.exit()
print("1")

Submission status: Accepted

Solution code:
def c_to_infinity(S, K):
    for k, s in enumerate(S,1):
        if s != '1':
            if k > K:
                return '1'
            else:
                return s
    # Sは1のみで構成されていた
    return 1

S = input().strip()
K = int(input())
print(c_to_infinity(S, K))

Submission status: Accepted

Solution code:
#-*-coding:utf-8-*-
from collections import Counter

def main():
    s = list(map(int, list(input())))
    k = int(input())

    counter = Counter(s[:k])
    if counter[1] == k:
        print(1)
        exit()
    for i in s:
        if i != 1:
            print(i)
            break

if __name__ == '__main__':
    main()

Submission status: Accepted

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

i = 0
while(i<k-1):
    if s[i] != '1':
        break
    else:
        i+=1
        
print(s[i])

Submission status: Accepted

Solution code:
S = input()
K = int(input())
g = 5 * 10**15
if S[0] == '1':
    for i, s in enumerate(S):
        if s != '1':
            break
    if i >= K:
        print(1)
    else:
        print(S[i])
else:
    print(S[0])

Submission status: Accepted

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

if s[0]!="1":
  print(s[0])
else:
  cnt=1
  for j in range(len(s)):
    if s[j]!="1":
      break
    else:
      cnt+=1
  if cnt==1 or n < cnt:
    print(1)
  else:
    print(s[cnt-1])

Submission status: Accepted

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

for i in range(min(K, len(S))):
    if S[i] != '1':
        print(S[i])
        exit()
print('1')

Submission status: Accepted

Solution code:
s=list(input())
k= int(input())
flag=True
cnt=0
for i in range(k):
    if s[i]!='1':
        flag=False
        cnt=i
        break
if flag:
    print('1')
else:
    print(s[cnt])

Submission status: Accepted

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

Submission status: Accepted

Solution code:

a=input()
b=input()

sum=0
for i in range(len(a)):
     if a[i]=='1':
         sum=sum+1
     else:
         temp=a[i]
         break
if(int(b)<=sum):
    print(1)
else:
    print(temp)

Submission status: Accepted

Solution code:
S = input()
K = int(input())
tmp = None
for i,j in enumerate(S):
    if not j == "1":
        tmp = i+1
        break
if tmp == None:
    print("1")
elif K < tmp:
    print("1")
else:
    print(j)

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])
    exit()
print(1)

Submission status: Accepted

Solution code:
s = input()
K = int(input())
a = 0
b = ''
for i, j in enumerate(s):
    if j != '1':
        a = i
        b = j
        break
else:
    a = len(s)

if K <= a:
    print(1)
else:
    print(b)

Submission status: Accepted

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

a = 0
while s[a] == '1':
    a += 1
    if a >= len(s):
        break

if k <= a:
    print('1')
else:
    if a >= len(s):
        print('1')
    else:
        print(s[a])

Submission status: Accepted

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

i=0
while(1):
    if(int(s[i])>1):
        print(s[i])
        break
    if(i == k-1):
        print("1")
        break
    i += 1

Submission status: Accepted

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

m = -1
for i in range(len(s)):
    if s[i] != '1':
        m = i
        break

if k > m:
    print(s[m])
else:
    print('1')