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: Time Limit Exceeded

Solution code:
s = input()
k,counter,n = int(input()),0,0
while counter < len(s):
    if s[counter] == "1":
        n += 1
    counter += 1
if n == len(s):
    print(1)
else:
    counter = 0
    while counter < k:
        if s[counter] != "1":
            print(s[counter])
            break

Submission status: Time Limit Exceeded

Solution code:
S = list(map(int,input().split()))
K=int(input())
x=0
i=0
while i <= len(S):
  x += pow(S[i],5000000000000000)
  if x<K:
    i=i+1
  elif x==K:
    print(S[i])
    break
  else:
    print(S[i-1])
    break

Submission status: Time Limit Exceeded

Solution code:
S = list(map(int,input().split()))
K=int(input())
x=0
i=0
while i <= len(S):
  x += pow(S[i],5000000000000000)
  if x<K:
    i=i+1
  elif x==K:
    print(S[i])
  else:
    print(S[i-1])

Submission status: Time Limit Exceeded

Solution code:
s = int(input())
k = int(input())
 
ans=0
 
n  = 5000000000000000
 
S = str(s) #文字列にする
saisho = 0
 
for i in range(len(S)):
  N = int(S[i])
  if k <= saisho+1:#最初からの文字数
    ans = N
    break
    
  else:
    if N ==1:
      Nn = 1
    else:
      Nn = N**n
    saisho += Nn
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
S = input().strip()
K = int(input().strip())
bits = 0
for t in S:
    if t == "1":
        bits += 1
        if bits >= K:
            print(1)
            break
    elif t == "2":
        bits += (2 ** (5 * (10 ** 15)))
        if bits >= K:
            print(2)
            break
    elif t == "3":
        bits += (3 ** (5 * (10 ** 15)))
        if bits >= K:
            print(3)
            break
    elif t == "4":
        bits += (4 ** (5 * (10 ** 15)))
        if bits >= K:
            print(4)
            break
    elif t == "5":
        bits += (5 ** (5 * (10 ** 15)))
        if bits >= K:
            print(5)
            break
    elif t == "6":
        bits += (6 ** (5 * (10 ** 15)))
        if bits >= K:
            print(6)
            break
    elif t == "7":
        bits += (7 ** (5 * (10 ** 15)))
        if bits >= K:
            print(7)
            break
    elif t == "8":
        bits += (8 ** (5 * (10 ** 15)))
        if bits >= K:
            print(8)
            break
    else:
        bits += (9 ** (5 * (10 ** 15)))
        if bits >= K:
            print(9)
            break

Submission status: Time Limit Exceeded

Solution code:
S = input()
K = int(input())
s = [int(S[i:i+1]) for i in range(len(S))]
x=5000000000000000
m=0 
def fx(n):
    return n**x
y=list(map(fx, s))
for num in y:
    m=m+num
    if K <=m:
        a=num
        print(a)
        break

Submission status: Time Limit Exceeded

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

strlist = list(S)

ret = None
x = 0
for s in strlist:
    n = int(s)
    m = 1
    for k in range(1, K+1):
        m = m * n
        if (x + m >= K):
            ret = s
            break
    if (ret is not None):
        break
    x += m
        
print(ret)

Submission status: Time Limit Exceeded

Solution code:
s = int(input())
k = int(input())
 
ans=0
 
n  = 5000000000000000
 
S = str(s) #文字列にする
saisho = 0
 
for i in range(len(S)):
  N = int(S[i])
  if k <= saisho+1:#最初からの文字数
    ans = N
    break
    
  else:
    saisho += N**n
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
s = int(input())
k = int(input())
 
ans=0
 
n  = 5000000000000000
 
S = str(s) #文字列にする
L = len(S)
saisho = 0
 
for i in range(L):
  N = int(S[i])
  Nn = N**n
  if saisho <= k <= saisho + Nn:#最初からの文字数
    ans = N
    break
    
  else:
    saisho += Nn
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
S = input()
K = int(input())
s = [int(S[i:i+1]) for i in range(len(S))]
x=5000000000000000
m=0 
for num in s:
    m=m+num**x
    if K <=m:
        a=num
        print(a)
        break

Submission status: Time Limit Exceeded

Solution code:
S = input()
K = int(input())
n=1
while n <= 5000e12:
    if len(S) > K:
        S = S[:K-1]
    str_new_number = ""
    for str_number in S:
        number = int(str_number)
        str_new_number = str_new_number + str_number*number
    S = str_new_number
    n += 1
print(S[K-1])

Submission status: Time Limit Exceeded

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

ans=0

n  = 5000000000000000

S = str(s) #文字列にする
saisho = 0

for i in range(len(S)):
  N = int(S[i])
  if saisho <= k <= saisho + N**n:#最初からの文字数
    ans = N
    break
    
  else:
    saisho += N**n
    
print(ans)

Submission status: Time Limit Exceeded

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

a = list(map(int, S))

for i in range(len(a)):
    for j in range(5000000000000000):
        a.insert(i, a[i])

print(a[K])

Submission status: Time Limit Exceeded

Solution code:
S=input()
K=int(input())
while True:
    if S[0]!="1":
        print(S[0])
        break
    else:
        continue

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
p=5000000000000000
s=input()
n=int(input())

ans=chk=1
for i in s:
    chk=1
    for j in range(2,p):
        chk*=int(i)
        ans+=chk
        if ans>=p:
            print(i)
            exit()

Submission status: Time Limit Exceeded

Solution code:
l=list(input())
k=int(input())
m=[0]*len(l)
for i in range(len(l)):
    var=pow(int(l[i]),5*pow(10,15))
    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: Time Limit Exceeded

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


def do(s):
    s_n =""
    for c in s:
        c_int= int(c)
        s_n+=(c*c_int)
    return s_n

while True:
    s_n=do(s)[:min(len(s)+1,k+1)]
    #print(s)
    if s_n==s:
        break
    else:s=s_n

#print(len(s))
print(s[k-1])

Submission status: Accepted

Solution code:
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush

input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]

def mod_pow(x,n):
    res = 1
    while n > 0:
        if n & 1:
            res = res * x
            x = x * x
            n >>= 1
    return res


def main():
    S = input().rstrip()
    K = I()
    for i in range(len(S)):
        if int(S[i]) >= 2 or K == 1:
            print(S[i])
            break
        else:
            K -= 1
            
        
    
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    S = input().rstrip()
    k = int(input())
    
    for i in range(k):
        if S[i]!="1":
            break
    print(S[i])

if __name__=="__main__":
    main()

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
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(S, K):
    ans = ''
    for i in range(len(S)):
        if i + 1 == K:
            ans = S[i]
            break
        if S[i] != '1':
            ans = S[i]
            break
    print(ans)


if __name__ == '__main__':
    S = input()
    K = int(input())
    # N, M = map(int, input().split())
    # A = [int(i) for i in input().split()]
    # B = [int(i) for i in input().split()]
    # AB = [[int(i) for i in input().split()] for _ in range(N)]
    solve(S, K)

    # # test
    # from random import randint
    # from func import random_str
    # solve()

Submission status: Accepted

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

if k == 1 or len(s) == 1:
    ans = list(s)[0]
else:
    ans = None
    for i, j in enumerate(list(s)):
        if i < k-1:
            if j != '1':
                ans = j
                break
        elif i == k-1:
            ans = j           
            break
        else:
            continue
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8


def main():
    S = input()
    K = int(input())
    ans = '1'
    tmp = -1
    for i, s in enumerate(S):
        if s != '1':
            ans = s
            break
        else:
            tmp = i

    if K - 1 <= tmp:
        ans = '1'

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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])
    break
else:
  print("1")

Submission status: Accepted

Solution code:
import sys
def input():
  return sys.stdin.readline().rstrip()

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

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

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

Submission status: Accepted

Solution code:
def main():
    s = input()
    k = int(input())
    ans = 0
    tyou = 500000000000000
    for v in s:
        if v == '1':
            ans += 1
        else:
            ans += tyou ** int(v)
        if ans >= k:
            print(v)
            exit()


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(len(s)):
  if s[i] == '1':
    one_cnt += 1
  else:
    break

if k <= one_cnt:
  print(1)
  exit()

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

Submission status: Accepted

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

if k == 1:
    print(int(s[0]))
elif s[0] == "1":
    cnt = 0
    while  cnt < len(s) and s[cnt] == "1" :
        cnt += 1
    if cnt >= k:
        print(1)
    elif cnt == len(s):
        print("1")
    else:
        print(s[cnt])
else:
    print(int(s[0]))

Submission status: Accepted

Solution code:
import sys

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


s=list(s)

c=0
for i in range(len(s)):
        if s[i]=='1':
                c+=1
if c==len(s):
        print('1')
        sys.exit()

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

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

Submission status: Accepted

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

for i,s in enumerate(S):
  if s != "1" and i < K: 
    print(s)
    exit()
print(1)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    S = input()
    k = input_int()
    one = 0
    for s in S:
        if s == "1":
            one += 1
        else:
            tmp = s
            break
    if k <= one:
        print(1)
    else:
        print(tmp)

    return


if __name__ == "__main__":
    main()

Submission status: Accepted

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

for i in range(len(S)):
  if S[i] != "1":
    print(S[i])
    break
  elif i+1 < K and S[i] == "1":
    continue
  else:
    print(1)
    break

Submission status: Accepted

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

l = 0
for i in range(len(S)):
    if S[i] == '1':
        l += 1
    if l >= K:
        print(S[i])
        exit()
    if S[i] != '1':
        print(S[i])
        exit()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

while k:
    v = s.pop(0)
    if v != '1':
        print(v)
        sys.exit(0)
    else:
        k -= 1
print(1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 16 01:17:00 2020

@author: liang
"""

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

#count = 0
for i in range(len(S)):
    if S[i] != '1':
        break
#print("i",i)

if K < i + 1:
    print(1)
    #print("A")
else:
    print(S[i])
    #print("B")

Submission status: Accepted

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

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

if K<i+1:
    print(1)
else:
    print(S[i])

Submission status: Accepted

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    s = S()
    k = min(len(s),I())

    ans = 1

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

    print(ans)
main()

Submission status: Accepted

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

s1=0
sn1='0'
for i in range(len(s)):
    if(s[i] == '1'):
        s1+=1
    else:
        sn1=s[i]
        break
ans='0'
if(s1>=k):
    ans='1'
else:
    ans=sn1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
txt = input()
n = int(input())
for i in range(n):
  if txt[i] != '1':
    print(txt[i])
    break
else:
  print("1")

Submission status: Accepted

Solution code:
a=input()
b=int(input())
c=1
if a[0]!="1":
  print(a[0])
if a[0]=="1":
  for i in range(len(a)-1):
    if a[i]=="1" and a[i+1]=="1":
      c=c+1
    else:
      break
  if c>=b:
    print(1)
  else:
    print(a[c])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    S = list(map(int, list(input().rstrip())))
    K = int(input())
    if sum(S[:K]) == K and len(set(S[:K])) == 1:
        print(1)
    else:
        for s in S:
            if s != 1:
                print(s)
                exit()


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s=input()
k = int(input())
cnt = 0
for i in s:
    if i == '1':
        cnt +=1
    else:
        x = i
        break
if cnt >= k:
    print(1)
else:
    print(x)

Submission status: Accepted

Solution code:
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    s = input().rstrip()
    k = int(input().rstrip())

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

    print(1)


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

# 5 * 10^15
cnt = 0

for i in range(len(S)):
    if int(S[i]) == 1:
        cnt += 1
    else:
        if cnt >= K:
            print(1)
        else:
            print(int(S[i]))
        exit()

print(1)

Submission status: Accepted

Solution code:
N = list(input())
N = [int(N[i]) for i in range(len(N))]
K = int(input())
if len(N) < K:
  for i in range(len(N)):
    if not N[i] == 1:
      print(N[i])
      break
  else:
    print(1)
else:
  for i in range(K):
    if not N[i] == 1:
      print(N[i])
      break
  else:
    print(1)

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in range(len(s)):
    n = int(s[i])
    if i+1==k:
        print(n)
        break
    elif n!=1:
        print(n)
        break

Submission status: Accepted

Solution code:
s=str(input())
k=int(input())
con=0
for i in s:
  if i=="1":
    con+=1
  else:
    break
if con>=k:
  print(1)
else:
  print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
K = int(input())
def main():
    cnt = 1
    for i in S:
        if i == '1':
            if K == cnt:
                return '1'
            else:
                cnt += 1
                continue
        else:
            return i
        return '1'
print(int(main()))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = list(input())
s = list(map(int,s))
k = int(input())
for _ in s[:k]:
    if _ != 1:
        print(_)
        exit(0)
print(1)

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()
i=1
while 1:
    if i==len(s)+1:
        print(1);exit()
    if s[i-1]!="1":
        t=i 
        ans=int(s[i-1])
        break
    i+=1
# print(t)
if int(input())<t:
    print(1);exit()
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 1
for i in range(len(S)):
    if int(S[i]) > 1 and i < K:
        ans = int(S[i])
        break
        
print(ans)

Submission status: Accepted

Solution code:
S=input()
K=int(input())
i=0
while S[i]=='1' and K>i+1 and i<len(S):
  i+=1
if i==len(S):
  i=0
print(S[i])

Submission status: Accepted

Solution code:
S = list(input())
K = int(input())
lsS = [int(i) for i in S]
ii = 0
for i in range(len(S)):
    if lsS[i] == 1:
        ii += 1
    else:
        a = lsS[i]
        break
if ii >= K:
    print(1)
else:
    print(a)

Submission status: Accepted

Solution code:
S=input()
a=int(input())
List=list(S)
res = 1
for i in range(a):
  if List[i] != "1":
    res = List[i]
    break
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

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

    if index < k:
        print(s[index])
    else:
        print(1)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s=input()
k=int(input())
d=5*10**15
for i in s:
  if i=='1':
    k-=1
  else:
    print(i)
    exit()
  if k<=0:
    print(1)
    exit()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

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

    if K >= 1e3:
        K = 105

    T = ''
    for i in range(len(S)):
        if S[i] == '1':
            T += '1'
        else:
            T += S[i] * K

        if S[i] != '1':
            break

    print(T[K - 1])


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

if sum(S)==len(S):
    print(1)
else:
    for i in range(len(S)):
        if S[i]!=1:
            print(S[i])
            break
        elif S[i]==1 and K-1<=i:
            print(1)
            break

Submission status: Accepted

Solution code:
import sys, math
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
s = lines.pop(0)
k, = [int(num) for num in lines.pop(0).split(" ")]
days = 5000 * (10 ** 12)
for n in s:
    log_k = math.log10(k)
    n = int(n)
    log_n_days = math.log10(n) * days
    if log_k > log_n_days:
        k -= n ** days
    else:
        break
print(n)

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

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

for i in range(K):
	if S[i] == '1':
		continue
	else:
		print(S[i])
		sys.exit()

print(S[K-1])

Submission status: Accepted

Solution code:
s = input()
k = int(input())
n = 5000 * 10**12

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

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 = input()
K = int(input())
count = 0

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(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 in range(K):
    if S[i] != '1':
        print(S[i])
        exit()
    
    if i == K - 1:
        print('1')
        exit()

Submission status: Accepted

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

S=input().strip()
K=int(input().strip())

n = 0
m = 0
for c in S:
    if c != '1':
        m = int(c)
        break
    n += 1
if K <= n:
    print(1)
else:
    print(m)

Submission status: Accepted

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


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

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()) - 1


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

print(s[i])

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
s = str(input())
k = int(input())
if s[:k].count('1') == len(s[:k]):
    print(1)
else:
    for i in s:
        if i != '1':
            print(i)
            break

Submission status: Accepted

Solution code:
s = input()
k = int(input())
cnt = 0
for j in range(len(s)):
	cnt += 1
	if s[j] == "1":
		if cnt == k:
			print("1")
			exit()
	else:
		print(s[j])
		exit()

Submission status: Accepted

Solution code:
s = str(input())
k = int(input())
len_s = len(s)
cnt_1 = 0
for i in range(len_s):
    if s[i] == '1':
        cnt_1 += 1
    else:
        moji = s[i]
        break
if cnt_1 >= k:
    print(1)
else:
    print(s[i])

Submission status: Accepted

Solution code:
s=list(input())

k=int(input())

cnt=0
ans=0
for i in s:
  if int(i)==1:
    cnt+=1
    continue
    
  else:
    ans+=int(i)
    break
    
if k<=cnt:
  print(1)
  
else:
  print(ans)

Submission status: Accepted

Solution code:
# ABC-106-C
S = input().rstrip()
K = int(input())


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

Submission status: Accepted

Solution code:
S = input().rstrip()
K = int(input())
for s in S[:K]:
    if s!="1":
        print(s)
        exit()
print(1)

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[cnt])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def examA():
    N = DI()/dec(7)
    ans = N
    print(N)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    S = SI()
    K = I()
    ans = "1"
    for i,s in enumerate(S,start=1):
        if s!="1":
            ans = s
            break
        if i==K:
            ans = s
            break
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examC()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC106-C

import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし

S = LI2()
K = I()

for i in range(K):
    if S[i] != 1:
        print(S[i])
        break
    elif i == K-1 and S[i] == 1:
        print(1)

Submission status: Accepted

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

idx = min(K, len(S))
for s in S[:idx]:
    if s != "1": 
      print(s)
      break
else:
  print(1)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys


def input():
    return sys.stdin.readline().rstrip()


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

    i = 0

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

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

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

Submission status: Accepted

Solution code:
s = list(map(str, input().rstrip()))
k = int(input())

ans = 1
for x in s[:k]:
    if int(x) != 1:
        ans = int(x)
        break
print(ans)

Submission status: Accepted

Solution code:
S = input()
K = int(input())
OK = True
for i in range(min(K, len(S))):
    if S[i] != '1':
        OK = False
if OK:
    print('1')
    exit()
for i in range(len(S)):
    if S[i] != '1':
        print(S[i])
        exit()