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:
s = input()
k = int(input())
idx = 0
while idx < len(s) and s[idx] == '1':
    idx += 1
if k <= idx or idx == len(s):
    print(1)
else:
    print(s[idx])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
ss=input()
kk=int(input())

def c(s,k):
    for i in range(len(ss)):
        if int(s[i])==1:
            k-=1
            if k==0:
                return int(s[i])
        else:
            return int(s[i])
    return 0

print(c(ss,kk))

Submission status: Accepted

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

for i,s in enumerate(S):
    if s != '1': break
        
if K<=i: 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":
        print(S[i])
        break
else:
    print(1)

Submission status: Accepted

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

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

if K >= len(T):
    print(T[-1])
else:
    print(1)

Submission status: Accepted

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



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

Submission status: Accepted

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

# 5000兆 = 5 * 10 ** 12

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

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

Submission status: Accepted

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

def solve():
    count = 1
    for si in S:
        if si == "1":
            if count == K:
                print(si)
                break
            count += 1
        else:
            print(si)
            break

solve()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = list(map(int, list(input())))
k = int(input())
res = False
for i, e in enumerate(s):
    if e == 1:
        if i + 1 == k:
            print(1)
            break
    else:
        res = True
        print(e)
        break

Submission status: Accepted

Solution code:
def main():
    S = input()
    K = int(input())
    for i in range(K):
        if S[i] != "1":
            return S[i]
    return "1"

if __name__ == '__main__':
    print(main())

Submission status: Accepted

Solution code:
import numpy as np
import math

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

k = 0
#  
while k < len(S) and S[k] == '1' and k < K:
    k += 1

if k == K or k == len(S):
    print('1')
else:
    print(S[k])

Submission status: Accepted

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

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

digits = 0

res = ""
for c in s:
    if int(c) == 1:
        digits += 1
        if digits == k:
            res = 1
            break
    else:
        res = int(c)
        break
    
print(res)

Submission status: Accepted

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

k = -1
for i in range(N):
    if S[i] != '1':
        break
    k = i

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

Submission status: Accepted

Solution code:
S = input() + '#'
K = int(input())

head1num = 0
while S[head1num] == '1':
  head1num += 1

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

Submission status: Accepted

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

i=0
while i<len(S) and S[i]=='1':
    i+=1

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

Submission status: Accepted

Solution code:
s = map(int,list(raw_input()))

k = int(input())

t = -1

for i in range(len(s)):
	if s[i] == 1:
		t = i

	else :
		break

if t > -1 and k-1 <= t:
	print 1

else :
	print s[t+1]

Submission status: Accepted

Solution code:
S=str(input())
cnt=0
num=0
for i in range(len(S)):
    if S[i]=="1":
        cnt+=1
    else:
        num=S[i]
        break
#print(num)
K=int(input())
if K<=cnt:
    print("1")
elif K>cnt:
    print(num)

Submission status: Accepted

Solution code:
s = input()
k = int(input())
a = 0
for i in s:
    if i == '1':
        a += 1
    else:
        break
if k <= a:
    print(1)
else:
    for i in s:
        if i != '1':
            print(i)
            break

Submission status: Accepted

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

    for c in s:
        k -= 1
        if k == 0:
            print(c)
            return
        if c != "1":
            print(c)
            return


if __name__ == '__main__':
    main()

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:
n=int(input())
k=int(input())

ans=[]

while n>0:
    ans.append(n%10)
    n=n//10
    
ans.reverse()

c = 0

for i in range(len(ans)):
    if ans[i]==1:
        c+=1
    else:
        a=ans[i]
        break

if c>=k:
    print(1)
else:
    print(a)

Submission status: Accepted

Solution code:
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
s=input()
k=i1()
x=[-1,-1]
for i in range(len(s)):
 if s[i]!='1':
    x=[i,s[i]]
    break
if x[0]>=0 and k>=x[0]+1:
   print(x[1])
else:
   print(1)

Submission status: Accepted

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

S2 = ""
for i in range(len(S)):
    if S[i]=="1":
        S2 += "1"
    else:
        S2 += S[i]*101
        break

if K<100:
    print(S2[K-1])
else:
    print(S2[100])

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

for i in S:
    K -= i
    if i!=1 or K <= 0:
        print(i)
        break

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S = list(input())
S = [ int(x) for x in S]
K = int(input())
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:
s = input()
k = int(input())

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

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

Submission status: Accepted

Solution code:
S = input()
K = int(input())
day = 5 * pow(10, 15)


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

#s = "11111"
#k = 5

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

if k <= not1:
    print(1)
else:
    print(first_not1)

Submission status: Accepted

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

for i, si in enumerate(s):
    if si != '1':
        ind = i
        res = si
        break
    if i == len(s) - 1:
        res = 'one'

if res == 'one':
    print(1)
elif ind >= k:
    print(1)
else:
    print(res)

Submission status: Accepted

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

def oneWhenEnd(s) : 
    count = 0
    for c in s : 
        if c != "1" : 
            return count
        count += 1
    return count
    
def getChar(s) : 
    for c in s : 
        if c != "1" : 
            return c
            
def f(s , k) : 
    x = oneWhenEnd(s)
    if x == 0 :
        return getChar(s)
    elif x == len(s) : 
        return 1
    else : 
        if k > x : 
            return getChar(s)
        else : 
            return 1

print(f(s , k) )

Submission status: Accepted

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

ones = 0
for c in S:
    if c == '1':
        ones += 1
    else:
        n = c
        break

print(1 if ones >= K else n)

Submission status: Accepted

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

cnt = 0

for s in S:
    if int(s) != 1:
        print(s)
        exit()
    cnt += 1
    if cnt == k:
        break

print(1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S, K):
    if K <= len(S) and S[:K].count('1') == K:
        return 1

    for c in S:
        if c != '1':
            return c


def main():
    S = read_str()
    K = read_int()
    print(slv(S, K))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

    if s[:k].replace("1", "") == "":
        return 1
    else:
        return (s.replace("1", ""))[0]


print(abc106_c())

Submission status: Accepted

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

Submission status: Accepted

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

num = 0
for i in s:
    if i == "1":
        num += 1
    else:
        break

first = 0
for i in s:
    if i == "1":
        first = 1
    else:
        first = i
        break

if num == 0:
    print(first)
elif k <= num:
    print(1)
else:
    print(first)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import deque
import copy
import heapq

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [S] =  [(input_raw[0])]
    input_raw = read_func().strip().split()
    [K] = [long(input_raw[0])]
    count = 0L;
    for s in S:
        if s != "1":
            break;
        count += 1
    if count >= K:
        print S[K-1]
    else:
        print S[count]

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

if check:
    print('1')

Submission status: Accepted

Solution code:
S=input()
K=int(input())
f=True
count=0
for i in range(len(S)):
    if f :
        if S[i]=='1':
            count+=1
        else:
            num=S[i]
            f=False
if(count>=K):
    print(1)
else :
    print(num)

Submission status: Accepted

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

idx = len(S)
# first not 2
for i in range(len(S)):
    if S[i] != "1":
        idx = i
        res_inf = int(S[i])
        break
if K <= idx:
    print(1)
else:
    print(res_inf)

Submission status: Accepted

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

Submission status: Accepted

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

# g = 5000000000000000

ret = ""
for i,x in enumerate(s):
    # print(i,x)
    if x!="1":
        print(x)
        exit()
    elif i+1==k:
        print(1)
        exit()
print(1)

Submission status: Accepted

Solution code:
S = input()
K = int(input())
if K <= 100:
    if all([s == "1" for s in S[:K]]):
        print(1)
        exit()
print(S.replace("1", "")[0])

Submission status: Accepted

Solution code:
S = input()
N = int(input())
count = 0
for i in range(len(S)):
  if S[i] != '1':
    if count < N:
      print(S[i])
    else:
      print('1')
    exit()
  else:
    count += 1
print('1')

Submission status: Accepted

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

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

if K - k <= 0:
  print(1)
else:
  print(S[k])

Submission status: Accepted

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


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

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

    if K == 1:
        print(S[0])
        return

    i = 0
    while True:
        if S[i] != "1":
            print(S[i])
            return

        if i == K - 1:
            print(1)
            return

        i += 1


main()

Submission status: Accepted

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

Submission status: Accepted

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

#x,y = list(map(int,input().split()))	

S=input()
k=int(input())

c=0
l=0
for i in S:
    if i != "1":
        l=i
        break
    else:
        c+=1

#print(c,l)        
if c>=k:
    print(1)
else:
    print(l)
#if :
#    print("Yes")
#else:
#    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=raw_input()
k=[int(k) for k in raw_input().split(" ")][0]


i=1

while k>1 and s[i-1]=='1' and i<len(s):
    i+=1
    k-=1

print s[i-1]

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=map(int,raw_input())
k=input()
if k<=len(x) and x[:k]==[1]*k:print 1
else:print [c for c in x if c!=1][0]

Submission status: Accepted

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

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

Submission status: Accepted

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

for c in S:
    if c == '1':
        if K == 1:
            print(1)
            break
        K -= 1
        continue
    print(c)
    break

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import sys

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


s=list(s)

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

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

Submission status: Runtime Error

Solution code:
a=input()
b=int(input())
c=0
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:
    if c>=len(a):
      print(1)
    else:
      print(a[c+1])

Submission status: Runtime Error

Solution code:
a=input()
b=int(input())
c=0
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+1])

Submission status: Runtime Error

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: Runtime Error

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: Runtime Error

Solution code:
N = input()
K = int(input())
if len(N) == 1:
  print(N[0])
elif K = 1:
  print(N[0])
elif N[0] == '1':
  print(N[1])
else:
  print(N[0])

Submission status: Runtime Error

Solution code:
N = input()
K = int(input())
if N[0] == '1':
  print(N[1])
else:
  print(N[0])

Submission status: Runtime Error

Solution code:
s=input()
i=1
while 1:
    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: Runtime Error

Solution code:
s=input()
i=1
while 1:
    if s[i-1]!="1":
        t=i 
        ans=s[i-1]
        break
    i+=1
# print(t)
if int(input())<=t:
    print(1);exit()
print(ans)

Submission status: Runtime Error

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: Runtime Error

Solution code:
a=input()
b=int(input())
c=0
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[1])

Submission status: Runtime Error

Solution code:
a=input()
b=int(input())
c=0
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[1])

Submission status: Runtime Error

Solution code:
S=input()
i=0
while S[i]!='1':
  i+=1
else:
  i=0
print(S[i])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

    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: Runtime Error

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

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

    c = 0
    for i in range(len(S)):
        if S[i] == '1':
            c += 1
        else:
            break
    if c >= 1 and K <= c:
        print(1)

    T = S.replace('1', '')
    print(T[0])


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

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

if __name__=="__main__":
    main()

Submission status: Runtime Error

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

def main():
    s = s_input()
    k = i_input()
    if k == 1:
        print(s[0])
    else:
        for i in range(k-1):
            if s[i] != "1":
                print(s[i+1])
                exit()
        print(s[-1])


if __name__=="__main__":
    main()

Submission status: Runtime Error

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

def main():
    s = s_input()
    k = i_input()
    if s[0] == "1":
        print(s[1])
    else:
        print(s[0])


if __name__=="__main__":
    main()

Submission status: Runtime Error

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

if S[0] == '1':
  count  = 0
  while S[i] == '1':
    count += 1
  if count >= K:
    print(1)
  else:
    print(S[count])
else:
  print(S[0])

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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: Runtime Error

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

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

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: Runtime Error

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

if K > 100:
    print(S[0])
else:
    for i in range(K + 1):
        if S[i] != "1":
            print(S[i])
            break
        if i == K:
            print(S[K])

Submission status: Runtime Error

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

print(s[1])

Submission status: Runtime Error

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

if S[0]=="1":
  print(S[1])
  
else:
  print(S[0])

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

i = 0
while S[i]=='1':
    i += 1

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

Submission status: Runtime Error

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

if S[0]=="1":
  print(S[1])
else:
  print(S[0])

Submission status: Runtime Error

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

for j in range(len(S)):
    if S[j]=='1':
        if j==K:
            ans=1
    else:
        x=[i for i in S if i!="1"]
        ans=x[0]

print(ans)

Submission status: Runtime Error

Solution code:
s = list(input())
k = int(input())
number = 0
count = 0
for i in range(k):
    if s[i] == "1":
        count += 1
        if count == k - 1:
            number = 1
    elif s[i] != "1" and number == 0:
        number = s[i]
print(number)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

if ind == -1:
  print(S[0])
elif ind + 1 >= K:
  print(1)
else:
  print(S[ind+1])

Submission status: Runtime Error

Solution code:
s=input()
k=int(input())
if s[0]=="1":
	print(int(s[1]))
else:
	print(int(s[0]))

Submission status: Runtime Error

Solution code:
s=input()
k=int(input())
if s[0]=="1":
	print(int(s[1])
else:
	print(int(s[0]))

Submission status: Runtime Error

Solution code:
S=list(input())
K=int(input())
#print(S)
i=0;p=0
while S[i]=="1":
  p=p+1
  i=i+1
#print(p)
print(S[p])

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
from collections import deque
S=deque(list(map(int,list(input()))))
K=int(input())
i=0
while True:
    if S[0]==1:
        S.popleft()
        i+=1
    else:
        break
result=1 if K<=i else S[0]
print(result)

Submission status: Runtime Error

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

    m = 0
    ans = ""

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



if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

    m = 0
    ans = ""

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



if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

    m = 0
    ans = ""

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



if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

    m = 0
    ans = ""

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



if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
s = input()
k = int(input())
if s[0] != "1":
    print(s[0])
elif s[:k] == "1"*k:
    print("1")
else:
    print(s.replace("1","")[0])

Submission status: Runtime Error

Solution code:
def count(x,y):
    return abs((x-y)/2)

N,A,B=map(int,input().split())


if (A-B)%2==0:
    ans=count(A,B)

else:
    
    if (A-1)<(N-B):
        ans=A
        A=1
        B=B-ans
    else:
        ans=N-B+1
        A=A+ans
        B=N
    
    ans+=count(A,B)

print(int(ans))