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:
#左側にある連続した1の長さがKより小なら1以外の最初に現れる数、そうでないなら１を出力する
a=input()
k=int(input())
if int(a)<10:
    a=str(int(a)*11)
i=0
x=0
#左から順にみて、1ならKを1小さくし右に一つずれる、１以外があらわれるかｋが負になったら終了
while k>=0:
    if a[i]=='1':
        k-=1
        i+=1
        if k==0:
            x=1
            k=-1
    else: 
        k=-1
#微妙な調整のために、終了ステータスがｘの数を見ればわかるようになっている
#breakの代わりにK=-1で終了させている
print(a[i-x])

Submission status: Accepted

Solution code:
a=input()
k=int(input())
if int(a)<10:
    a=str(int(a)*11)
i=0
x=0
while k>=0:
    if a[i]=='1':
        k-=1
        i+=1
        if k==0:
            x=1
            k=-1
    else: 
        k=-1
print(a[i-x])

Submission status: Accepted

Solution code:
# coding:utf-8

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

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

Submission status: Accepted

Solution code:
class Solver(object):
    def __init__(self):
        self.s = input()
        self.k = int(input())
        self.compressed = self.to_compressed_format(self.s)

    def solve(self):
        if (self.compressed[0][0] == 1) and (self.k <= self.compressed[0][1]):
            print(1)
            return
        else:
            for i in self.s:
                if int(i) != 1:
                    print(i)
                    return
            print(1)
            return

    def wrong_solve(self):
        print(self.compressed)
        counter = 0
        for (n, count) in self.compressed:
            print(n, count)
            counter += self.length_after(n, count)
            print("chk")
            if counter >= self.k:
                return n

    @staticmethod
    def length_after(n, count):
        return count * (n ** (5 * (10 ** 15)))

    @staticmethod
    def to_compressed_format(s):
        res = []
        counter = 1
        prev = int(s[0])
        for c in s[1:]:
            n = int(c)
            if n == prev:
                counter += 1
            else:
                res.append((prev, counter))
                prev = int(n)
                counter = 1
        res.append((prev, counter))
        return res


if __name__ == "__main__":
    s = Solver()
    s.solve()

Submission status: Accepted

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

s_str = str(s)
for i in range(k):
    if s_str[i] != '1':
        print(int(s_str[i]))
        break
else:
    print(1)

Submission status: Accepted

Solution code:
s = input()
K = int(input())
len1 = len(s)-len(s.lstrip("1"))
if len1 >= K:
    print(1)
else:
    print(s.lstrip("1")[0])

Submission status: Accepted

Solution code:
def solve(S, K):
    for s in S[:K]:
        if s != "1":
            return s
    return "1"

if __name__ == "__main__":
    S = input()
    K = int(input())
    print(solve(S, K))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/mnt/c/Users/moiki/bash/env/bin/python
S = input()
K = int(input())

n = len(S)

for i in range(n):
    if not S[i] == "1":
        break
if K <= i:
    print(1)
else:
    print(S[i])

Submission status: Accepted

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

if len(s) == 1:
    print(s)
else:
    if s[0] != '1':
        print(s[0])
    else:
        cnt = 0
        for i in range(len(s)):
            if s[i] == '1':
                cnt += 1
            else:
                not1 = s[i]
                break
                
        if k <= cnt:
            print(1)
        else:
            print(not1)

Submission status: Accepted

Solution code:
s = input()
k = int(input())
# Tyou = 5000000000000000

s_arr = [int(i) for i in s]

one = 0
num = 0
for i in range(len(s_arr)):
    if s_arr[i] == 1:
        one += 1
    else:
        num = s_arr[i]
        break

if k <= one:
    print(1)

else:
    print(num)

Submission status: Accepted

Solution code:
def main(sbj:str,n:int):
    ans =sbj[0]
    if ans!="1":
        return int(ans)
    counter=0
    for i in range(len(sbj)):
        if sbj[i]=="1":
            counter += 1
            if counter >=n:
                return 1
        else:
            return int(sbj[i])
sbj = input()
n =int(input())
print(main(sbj,n))

Submission status: Accepted

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())|	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import collections
def inpl(): return list(map(int, input().split()))

#### START
S = input()
K = int(input())

f = False
for s in S[:K]:
  if s != "1":
    print(s)
    f = True
    break

if not f:
  print(1)

Submission status: Accepted

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

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

Submission status: Accepted

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

for s in S:
  if(s == "1"):
    K -= 1
    if(K == 0):
      ans = 1
      break
  else:
    ans = s
    break
print(ans)

Submission status: Accepted

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

for i in range(len(S)):
  if(S[i] == "1"):
    K -= 1
    if(K == 0):
      print(1)
      break
  else:
    print(S[i])
    break

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = '1'
for a in s[:k]:
    if a != '1':
        ans = a
        break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

for i, s in enumerate(S):
    if s != '1':
        t = i
        break
    if i == len(S)-1:
        t = 0
print (1 if K <= t else S[t] )

Submission status: Accepted

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

for s in S:
    if int(s) == 1:
        K -= 1
        if K <= 0:
            print(1)
            break
    else:
        print(s)
        break

Submission status: Accepted

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

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

count = 0
slist = list(S)
while(len(slist) > 0):
    a = slist.pop(0)
    count += 1
    if a != '1':
        print(a)
        sys.exit(0)
    if count == K:
        print(1)
        sys.exit(0)
print(1)

Submission status: Accepted

Solution code:
s=list(input())
k=int(input())
c=0
ind=-1
indx=-1
f=True
for i in range(len(s)):
  if s[i]=='1':
    c+=1
  else:
    ind=i
    indx=s[i]
    f=False
    break
if f or k<ind+1:
  print(1)
else:
  print(indx)

Submission status: Accepted

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

D=5000000000000000

tmp=0
for s in S:
  if s=='1':
    tmp+=1
    if tmp>=K:
      print(s)
      break
    continue
    
  t=1
  for _ in range(D):
    t=t*int(s)
    if tmp+t>=K:
      print(s)
      break
  else:
    tmp+=t
    continue
  break

Submission status: Accepted

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

for i in range(k):
    if int(s[i]) > 1:
        print(s[i])
        exit()
print(1)

Submission status: Accepted

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

    for i in S:
        if i == 1:
            K -= 1
            if K == 0:
                print(1)
                exit()
            continue
        j = 1
        while i < 5 * 10 ** 15:
            if i ** j >= K:
                print(i)
                exit()
            j += 1
        K -= i ** j


main()

Submission status: Accepted

Solution code:
S = input()
K = int(input())
# DAY = 5000000000000000
if len(S) >= K:
    for i in range(K):
        if S[i] != '1':
            print(int(S[i]))
            break
    else:
        print(1)
else:
    for s in S:
        if s != '1':
            print(int(s))
            break

Submission status: Accepted

Solution code:
# ABC 106
def db(x): 
    global debug
    if debug: print(x)
debug = False
S = input()
K = int(input())
for i in range(len(S)):
    if S[i]!='1': break
if i>=K: print('1')
else:   print(S[i])

Submission status: Accepted

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

if len(s) >=k:
    flag = True
    for i in range(k):
        if s[i] != "1":
            flag = False
            break
    if flag:
        print(1)
        exit()
for i in s:
    if i != "1":
        print(i)
        exit()

Submission status: Accepted

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

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

    m = -1
    c = ''
    for i in range(len(S)):
        if S[i] == '1':
            m = i
        else:
            c = S[i]
            break

    m += 1


    print('1' if K <= m else c)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

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

Submission status: Accepted

Solution code:
S = input()
K = int(input())
if K == 1:
  print(S[0])
else:
  for i in range(len(S)):
    if int(S[i]) != 1 or K - i == 1:
      print(S[i])
      break

Submission status: Accepted

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

ans = '1'
for i in range(len(S)):
    if i + 1 <= k and S[i] != '1':
        ans = S[i]
        break
        
print(ans)

Submission status: Accepted

Solution code:
S = input()
K = int(input())
ans = []

for i in S:
    if i == '1':
        ans.append(i)
    else:
        ans.append(i)
        break

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

Submission status: Accepted

Solution code:
S =input()
K =int(input())
n = len(S)
for i,j in enumerate(S):
    if j!="1":
        n = i+1
        break
if K < n:
    print(1)
else:
    print(S[n-1])

Submission status: Accepted

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

def main():
    s = list(input())
    k = int(input())
    n = len(s)
    for i in reversed(range(n)):
        if s[i] != "1":
            s[i:n] = s[i] * (n - i)
    if k <= n:
        print(s[k - 1])
    else:
        print(s[-1])

main()

Submission status: Accepted

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

flag = 0

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

Submission status: Accepted

Solution code:
S = input()
K = int(input())
cnt = 0
for x in S:
    if x == '1':
        cnt += 1
    else:
      break
#print(cnt)
if cnt < K:
    print(S[cnt])
else:
    print(1)

Submission status: Accepted

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

renzoku=0
for i in S:
    if i=='1':
        renzoku+=1
    else:
        break
if K<=renzoku:
    ans = '1'
else:
    ans = S[renzoku]
print(ans)

Submission status: Accepted

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

if all(c == '1' for c in s[0:k]):
    print('1')
else:
    print(next(c for c in s if c != '1'))

Submission status: Accepted

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

sum=0
for i in range(0,len(S)):
    if(S[i]==1):
        sum+=1
        if(sum>=K):
                print(S[i])
                exit()
    else:
        tmp=S[i]
        for j in range(2,5000000000000000):
            tmp*=S[i]
            if(sum+tmp>=K):
                print(S[i])
                exit()
            else:
                sum+=tmp

Submission status: Accepted

Solution code:
a = list(input())
b = int(input())
total = 0
for i in a:
    i = int(i)
    if(i == 1):
        total += 1
    else:
        print(i)
        break
    if(total >= b):
        print(i)
        break

Submission status: Accepted

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

for i, c in enumerate(S):
    n = int(c)
    if i==K-1:
        ans = int(c)
        break
    if n!=1:
        ans = int(c)
        break

print(ans)

Submission status: Accepted

Solution code:
s=input()
k=int(input())-1
i=0
while s[i]=="1" and k:k,i=k-1,i+1
print(s[i])

Submission status: Accepted

Solution code:
S = input()
K = int(input())
Sdash = [x for x in S if not x == '1'] 

if len(Sdash) == 0:
    n = len(S) 
else:
    n = S.index(Sdash[0])

if n >= K:
    print(1)
else:
    print(Sdash[0])

Submission status: Accepted

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

for a in s:
    if a != '1':
        ans = a
        break
    else:
        count += 1

if count <= k:
    print(ans)
else:
    print(1)

Submission status: Accepted

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

for i, s in enumerate(S):
	if s is not '1' and i + 1 <= K:
		print(s)
		break
else:
	print('1')

Submission status: Accepted

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

ans = 1
for i in range(k):
    if S[i] == '1':
        continue
    else:
        ans = S[i]
        break
        
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
K = int(input())
a = 0
if S[0] != '1':
  print(S[0])
else:
  for i in S:
    if i == '1':
      a += 1
    else:
      temp = i
      break
  if a >= K:
      print('1')
  else:
      print(temp)

Submission status: Accepted

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


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

    for si in s:
        if si == '1':
            count += 1
        else:
            break

    if s[0] != '1':
        print(s[0])
    else:
        if k <= count:
            print(1)
        else:
            print(s[count])


if __name__ == '__main__':
    main()

Submission status: Accepted

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


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

print(solve(S, K))

Submission status: Accepted

Solution code:
S = input()
k = int(input())
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())

for i, s in enumerate(S):
    if s == "1" and i + 1 < k:
        continue
    print(s)
    break
else:
    print(S[-1])

Submission status: Accepted

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

for i, c in enumerate(s):
    if c != '1':
        break

if k > i:
    print(c)
else:
    print(1)

Submission status: Accepted

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

default = '1'
last_one_index = 0
for i, c in enumerate(s):
    if c != '1':
        default = c
        last_one_index = i
        break
if k <= last_one_index:
    print('1')
else:
    print(default)

Submission status: Accepted

Solution code:
S = int(input())
K = int(input())
import numpy as np

S_list = list(map(int, str(S)))

#最初から何文字1が連続するか
count = 0
for i in S_list:
    if int(i) == 1:
        count+=1
    else:
        break

#文字列が1文字ならその文字を返す
if len(S_list) == 1:
    print(int(S_list[0]))
    exit()


if count < K:
    S_list = np.array(S_list).reshape(-1,1)
    print(int(S_list[count]))
else:
    print(1)

Submission status: Accepted

Solution code:
s = list(input())
k = int(input())
nonone = 0
for c in s:
    if c == '1':
        nonone += 1
    else: break
if k - 1 >= nonone:
    print(s[nonone])
else:
    print(1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
k=int(input())
a="1"
for i in range(min(k,100)):
  if s[i]!="1":
    a=s[i]
    break
print(a)

Submission status: Accepted

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n = list(input())
k = int(input())
for i in range(k):
    if n[i] != '1':
        print(n[i])
        sys.exit()
print(1)

Submission status: Accepted

Solution code:
import copy
N=input()
s=int(input())
b=N[0]
c=0
x=[]
for a in N:
	if a != b:
		x.append([int(b),c])
		b=a
		c=0
	c+=1
x.append([int(b),c])
y=[]
while x != y:
	y=copy.deepcopy(x)
	p=0
	for i in range(len(x)):
		p += x[i][1]
		if p > s:
			break
		x[i][1]=x[i][1]*x[i][0]
w=0
for xx in x:
	w += xx[1]
	if w >= s:
		print(xx[0])
		break

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    s = input()
    k = int(input())
    for i in range(0, k - 1):
        if s[i] != '1':
            print(s[i])
            return
    print(s[k - 1])


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 0
n1 = 0

for i in S:
    if i != "1":
        s = int(i)
        break
    
    else:
        n1 += 1

if n1 >= K:
    print(1)

else:
    print(s)

Submission status: Accepted

Solution code:
a = input()
b = int(input())
n1 = 0
s = 0
for i in a:
    if i!="1":
        s = int(i)
        break
    n1 +=1
if n1 >= b:
    print(1)
else:
    print(s)

Submission status: Accepted

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

count = 0
not_one = 0

for i in S:
    num = int(i)
    if num != 1:
        not_one = num
        break
    else:
        count += 1

if K <= count:
    print(1)
else:
    print(not_one)

Submission status: Accepted

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

ans = 1
for i in range(min(K, len(S))):
    if(S[i] != "1"):
        ans = S[i]
        break
        
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
from math import log10

gosen = 5e15

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

logK = log10(K)
Sstr = str(S)

Kres = K
for i in range(0, len(Sstr)):
    Si = int(Sstr[i])
    if Si == 1:
        Kres = Kres - 1
    else:
        print(Si)
        break
    if Kres <= 0:
        print(Si)
        break

Submission status: Accepted

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

d = re.search('[2-9]', S)
if d == None or d.start() >= K:
  print("1")
else:
  print(d.group())

Submission status: Accepted

Solution code:
import re

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

def main():
    global K
    m = re.search(r'[2-9]', S)
    if m:
        i = m.start()
        index = min([m.start(), K - 1])
        ans = list(S).pop(index)
    else:
        ans = 1
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = list(input())
k = int(input())
ans = 0
count = 0

for s in S:
    if s != '1':
        ans = s
        break
    else:
        count += 1
        
if count >= k:
    print('1')
else:
    print(ans)

Submission status: Accepted

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


if S[0] != "1":
    print(S[0])
else:
    i = 0
    count = 0
    while i < len(S) and S[i] == "1":
        count += 1
        i += 1
    if K <= count:
        print(1)
    else:
        print(S[i])

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())
count = 0
ans = 0

for i in S:
    if i != '1':
        ans = i
        break
    else:
        count += 1

if count >= k:
    print('1')
else:
    print(ans)

Submission status: Accepted

Solution code:
a = input()
b = int(input())
br = []
count = 0
if b == 1:
    print(a[0])
else:
    if len(a) >= b:
        for i in range(b):
            if a[i] == "1":
                count += 1
        if count == b:
            print(1)
        else:
            for r in (list(a)):
                if r != "1":
                    print(r)
                    exit()
    else:
            for r in (list(a)):
                if r != "1":
                    print(r)
                    exit()

Submission status: Accepted

Solution code:
S = input()
K = int(input())
counter = 0
num = 1
log = 0
for i in S:
    if int(i) != 1:
        log = counter
        num = int(i)
        break
    counter += 1

if K <= log:
    print(1)
else:
    print(num)

Submission status: Accepted

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


x = "1"
for i in S:
	if i == "1":
		pass
	else:
		x = i
		break

if x != "1":
	if S.index(x) + 1 <= K:
		print(x)
	else:
		print(1)
else:
	print(1)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    s = input()
    k = int(input())
    count = 0
    last_num = 0
    for i in s:
        if i == '1':
            count += 1 
        else:
            last_num = i
            break
    if k > count:
        print(last_num)
    else:
        print(1)
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
# N,M = [int(n) for n in input().split()]
# S = str(input())
# T = str(input())
S = str(input())
K = int(input())

for i in range(len(S)):
    if(S[i] == "1" and i+1 == K):
        print("1")
        sys.exit()
    elif(S[i]!="1"):
        print(S[i])
        sys.exit()

Submission status: Accepted

Solution code:
import sys
# N,M = [int(n) for n in input().split()]
# S = str(input())
# T = str(input())

S = str(input())
K = int(input())
numplace = 0

for i in range(len(S)):
    if (S[i] == "1"):
        numplace+=1
    else:
        numplace+= 5000000000000000**int(S[i])
    if(numplace>=K):
        print(S[i])
        sys.exit()

Submission status: Accepted

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

expi = len(s)
expn = 1
for i in range(1, len(s) + 1):
    if s[i-1] == "1":
        continue
    expi = i
    expn = s[i-1]
    break

if expi <= K:
    print(expn)
else:
    print(s[K-1])

Submission status: Accepted

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

c = 0
for ch in s:
  if not ch == '1':
    break
  c += 1
n = s[c] if c < len(s) else None
a = n if n and c < k else s[0]
print(a)

Submission status: Accepted

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

#a = []
#for i in range(len(s)):
#    a.append([int(s[i]),int(s[i])**k])
#print(a)

a = 1
ocount = 0
for i in range(len(s)):
    t = int(s[i])
    if t != 1:
        a = t
        break
    else:
        ocount += 1

if k <= ocount:
    print(1)
else:
    print(a)

Submission status: Accepted

Solution code:
s = list(input())
k = int(input())
one_count = 0
stop_flag = 0

for i in s:
    if i != '1':
        if one_count >= k:
            print(1)
        else:
            print(i)
        stop_flag = 1
        break
    else:
        one_count += 1
        
if stop_flag == 0:
    if one_count >= k:
        print(1)
    else:
        print(0)

Submission status: Accepted

Solution code:
S = input()
K = int(input())
one_count = 0
ans = 0

for i in range(len(S)):
    if S[i] != '1':
        ans = S[i]
        break
    else:
        one_count += 1

if one_count >= K:
    print('1')
else:
    print(ans)

Submission status: Accepted

Solution code:
S = int(input())
K = int(input())
f = 0
ans = 10

list = [i for i in str(S)]
 
for i in range(K):
    if int(list[i]) > 1:
        ans = min(ans,int(list[i]))
        f = 1
        break

if f == 0:
    print(1)
else:
    print(ans)

Submission status: Accepted

Solution code:
S = input().rstrip()
K = int(input())
c = 0
for item in S:
  if not item == "1":
    break
  c+=1
n = S[c] if c < len(S) else None
a = n if n and c < K else S[0]
print(a)

Submission status: Accepted

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

	is_1 = True
	for i in range(K) :
		if (len(S) < i) :
			break

		# print("S[i] : " + S[i])
		if (S[i] != "1") :
			is_1 = False
			break

	if (is_1) :
		print("1")
		return

	for i in range(len(S)) :
		if (S[i] == "1") :
			continue

		print(S[i])
		break


main()

Submission status: Accepted

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

Submission status: Accepted

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

if len(s)==1:
    print(s[0])
elif k==1:
    print(s[0])
else:
    cnt = 0
    idx = 0
    for c in list(s):
        idx += 1
        if c=="1":
            cnt += 1
        else:
            break
    if k<=cnt:
        print(1)
    else:
        print(s[idx-1])

Submission status: Accepted

Solution code:
S = input()
K = int(input())
cc = 0
st = 0
for i in S:
    if i == "1":
        cc += 1
    else:
        st = i
        break
if cc >= K:
    print(1)
else:
    print(st)

Submission status: Accepted

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

i = None
for i, s in enumerate(S):
    if s != "1":
        break

if i is None:
    print(S[0])
    exit()

if i >= K:
    print(1)
else:
    print(S[i])

Submission status: Accepted

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

for i in range(K):
    if S[i] != '1':
        print(S[i])
        flag = False
        break

if flag:
    print(1)

Submission status: Accepted

Solution code:
S=input()
K=int(input())
f=0
if(K<=len(S)):
    for s in S[:K]:
        if s!="1":
            break
    else:
        print("1")
        f=1
if f==0:      
    for s in S:
        if(s!="1"):
            print(s)
            break

Submission status: Accepted

Solution code:
S = list(input())
K = int(input())
# 5000000000000000 = 5 * 10**15
S = [int(e) for e in S]
days = 5 * 10**15
for e in S:
    result = 1
    if e == 1:
        K -= 1
        if K <= 0:
            print(e)
            exit()
        continue
    for f in range(days):
        result *= e
        if K - result <= 0:
            print(e)
            exit()
        if f == days - 1:
            K -= result

Submission status: Accepted

Solution code:
#coding:utf-8
n=input()
count=0
l=int(input())
for i in range(len(n)):
  if(n[i]=='1'):
    count+=1
    if(l==count):
      print(n[i])
      break;
    continue
  else:
    print(n[i])
    break;

Submission status: Accepted

Solution code:
import sys

s = [int(i) for i in input()]
k = int(input())

for i, j in enumerate(s):
    if j != 1:
        break
    elif i == k-1:
        print(1)
        sys.exit()

for i in s:
    if i != 1:
        print(i)
        sys.exit()

Submission status: Accepted

Solution code:
S=list(input())
K=int(input())
#print(S)
for i in range(K):
    n=int(S[i])
    if n==1:
        if K-1==i:
            print(1)
            exit(0)
    else:
        print(n)
        exit(0)

Submission status: Accepted

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

for i in range(K) :
    if L[i] != "1" :
        print(L[i])
        break
    else :
        if i == K-1 :
            print(1)

Submission status: Accepted

Solution code:
import itertools
s = input()
k = int(input())
g = itertools.groupby(s)
v = -1
t = -1
for a,b in g:
    if v == -1:
        v = len(list(b))
    elif t == -1:
        t = a
        break
if s[0]=='1':
    if k<=v:
        print(1)
    else:
        print(t)
else:
    print(s[0])

Submission status: Accepted

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


if k <= len(s):
    for i in range(k):
        if s[i] != "1":
            print(s[i])
            exit()
    print("1")
else:
    for w in s:
        if w != "1":
            print(w)
            exit()

Submission status: Accepted

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

ans = pos = None
for i in range(len(S)):
    if S[i] != '1':
        pos = i
        ans = S[i]
        break

if pos is None:
    print(1)
elif pos >= K:
    print(1)
else:
    print(ans)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = lc()
k = ni()

not1first_idx = len(s)
not1first = '1'

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

Submission status: Accepted

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

count = 0
while count < K:
    if S[count] != "1":
        print(S[count])
        break
    count += 1
else:
    print("1")

Submission status: Accepted

Solution code:
S = list(input())
K = int(input())
flag = 0
i = 0
while i < K: 
  if int(S[i]) == 1:
    flag = 1
    i = i + 1 
  else:
      print(int(S[i]))
      flag = 0
      break
if flag == 1:
  print(1)