problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02584
s672511608
Wrong Answer
X,K,D = map(int,input().split()) A = abs(X) if A > D: if A//D > K: A = A - (D * K) K = 0 else: A = A - (A//D)*D K = K - (A//D) if K > 0: if K%2 == 1: A = A - D print(abs(A))
p02982
s654894717
Wrong Answer
import math n, d = map(int, input().split()) x = [list(map(int, input().split())) for i in range(n)] cnt = 0 for i in range(n): for j in range(i+1, n): dis = 0 for k in range(d): dis += (x[i][k]-x[j][k])**2 if math.sqrt(dis) % 1 == 0: cnt += 1 print(cnt)
p03797
s163805635
Accepted
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N, M = map(int, readline().split()) if N >= M // 2: ans = M // 2 else: ans = N L = M - 2 * N ans += L // 4 print(ans) return if __name__ == '__main__': main()
p02659
s198515818
Accepted
A,B=input().split() print(int(A)*int(B.replace('.',''))//100)
p03131
s755968931
Accepted
k, a, b = map(int, input().split()) if a >= b-1: print(k+1) else: if k <= a-1: print(k+1) else: k -= a k += 1 if k % 2 == 1: print(k//2*(b-a)+a+1) else: print(k//2*(b-a)+a)
p03435
s357508699
Wrong Answer
ab = list(list(map(int, input().split())) for _ in range(3)) B = sum(ab[0]) ab2 = sum(ab[1]) ab3 = sum(ab[2]) if (ab2-B)%3 != 0 or (ab3-B)%3 != 0: print('No') else: print('Yes')
p03339
s833639818
Accepted
n = int(input()) s = list(input()) total = s[1:].count('E') ans = total for i in range(n-1): if s[i]=='W': total += 1 if s[i+1]=='E': total -= 1 ans = min(ans, total) print(ans)
p03211
s675092847
Accepted
s=input() ans=-10000 M=753 for i in range(len(s)-2): res=(int)(s[i:i+3]) if(abs(ans-M)>abs(res-M)): ans=res print(abs(M-ans))
p02862
s766376733
Accepted
def nCr(n,r): dividend = 1 divisor = 1 MOD = 10**9+7 d1 = n for i in range(1,r+1): dividend *= d1 divisor *= i d1 -= 1 dividend %= MOD divisor %= MOD return (dividend * pow(divisor, MOD-2, MOD)) % MOD X,Y = map(int,input().split()) if (X+Y) % 3 != 0: print(0) exit() n = (-X+2*Y) // 3 m = (2*X-Y) // 3 if n<0 or m<0: print(0) else: print(nCr(n+m, n))
p02598
s190748014
Accepted
n, k = map(int, input().split()) a = list(map(int, input().split())) def f(m): res = sum([-(-x//m)-1 for x in a]) return res <= k l, r = 0, 10**9+10 while r-l > 1: x = (l+r)//2 if f(x): r = x else: l = x print(r)
p02606
s076379812
Accepted
def getInts(): return [ int(x) for x in input().split() ] [L,R,d] = getInts() c = 0 for i in range(L, R+1): if i%d==0: c+=1 print(c)
p03000
s886795797
Accepted
N,X = map(int, input().split()) l = list(map(int,input().split())) count = 1 d = 0 for i in range(N): d = d + l[i] if d <= X: count += 1 print(count)
p02602
s034496353
Accepted
n,k = map(int,input().split()) a = list(map(int,input().split())) #hyouten = [] for i in range(n-k+1): if i>0: score_old = a[i-1] score = a[i+k-1] # print(score_old,score) if score >score_old: print("Yes") else: print("No")
p02727
s204720594
Accepted
x, y, a, b, c = map(int, input().split()) p = sorted(list(map(int, input().split())), reverse=True)[:x] q = sorted(list(map(int, input().split())), reverse=True)[:y] r = sorted(list(map(int, input().split()))) print(sum(sorted(p + q + r, reverse=True)[:x+y]))
p03624
s956973026
Accepted
S = input() a = [s for s in "abcdefghijklmnopqrstuvwxyz"] for s in list(set(S)): if(s in a): a.remove(s) if(a == []): print("None") else: print(a[0])
p02547
s645876120
Accepted
n = int(input()) cnt = 0 for i in range(n): a, b = map(int, input().split()) if a == b: cnt += 1 if cnt == 3: print("Yes") exit() else: cnt = 0 print("No")
p03821
s245531995
Wrong Answer
import numpy as np import math import collections import fractions import itertools def iput(): return int(input()) def mput(): return map(int, input().split()) def lput(): return list(map(int, input().split())) def solve(): n = int(input()) cost = 0 for i in range(n): a, b = mput() mult = math.ceil(a/b)*b cost += mult - a print(cost) return 0 if __name__ == "__main__": solve()
p02664
s004598804
Accepted
s = input() print(s.replace('?','D'))
p03485
s397620186
Accepted
a, b = map(int, input().split()) print( (a+b+1)//2 )
p03854
s251235689
Accepted
s = input() def solve(query): while 1: for frag in ("erase", "eraser", "dream", "dreamer"): if query.endswith(frag): query = query[:-len(frag)] break else: print("NO") break if not query: print("YES") break solve(s)
p02694
s452577113
Accepted
x = int(input()) #ゴリ押し解法 mny = 100 count = 0 while(x > mny): mny += int(mny*0.01) count += 1 print(count)
p04029
s997579742
Accepted
#!/usr/bin/env python3 N = int(input()) print(N*(N+1)//2)
p02866
s740624980
Accepted
from collections import Counter n = int(input()) l = list(map(int,input().split())) c = Counter(l) mod = 998244353 if l.count(0) != 1 or l[0] != 0: print(0) exit() ans = 1 for i in l[1:]: ans *= c[i-1] ans %= mod print(ans%mod)
p03815
s017147497
Wrong Answer
x=int(input()) ans=2*(x//11) rem=x%11 if rem<=6: ans+=1 else: ans+=2 print(ans) #print(2*ans) if x%11==0 else print(2*ans+1)
p02696
s921139528
Accepted
import math A, B, N = map(int, input().split()) x = min(B-1, N) print(math.floor(A*x/B) - A*math.floor(x/B))
p03474
s596518972
Accepted
a,b = map(int,input().split()) s = input() if s.count("-") ==1: s1,s2 = s.split("-") if a == len(s1) and b == len(s2): print("Yes") else: print("No") else: print("No")
p02576
s574242446
Accepted
N, X, T = map(int, input().split()) count = 1 check = X if X > 1: while True: value = int(N / X) re = N % X if re == 0: count = value TotalTime = T * count break else: count += value TotalTime = T * count break else: TotalTime = T * N print(TotalTime)
p02664
s497559251
Accepted
t = input() s = t.replace('?', 'D') print(s)
p03220
s665225688
Wrong Answer
N=int(input()) T,A=map(int, input().split()) p=0 cc=10**6 A*=1000 for i, T in enumerate(map(lambda h:12000-int(h)*6,input().split())): d=abs(T - A) if cc > d: cc=d p=i+1 print(p)
p03087
s282256666
Accepted
import sys n,q=map(int,input().split()) s=input() c=[0]*n for i in range(2,n+1): if s[i-2:i]=='AC': c[i-1]=c[i-2]+1 else: c[i-1]=c[i-2] lr=sys.stdin.readlines() for i in lr: l,r=map(int,i.split()) print(c[r-1]-c[l-1])
p02571
s898103692
Accepted
S = input() T = input() ans = 0 for i in range(len(S)-len(T)+1): s = S[i:i+len(T)] num = 0 for j in range(len(T)): if s[j] == T[j]: num += 1 if num>ans: ans = num print(len(T)-ans)
p03352
s387871360
Wrong Answer
x = int(input()) if x == 1: print("1") exit() ans = 0 for b in range(2,x): for p in range(2,1000): tmp = pow(b,p) if tmp<=x: ans = max(ans,pow(b,p)) break print(ans)
p03994
s885305196
Wrong Answer
S = list(input()) K = int(input()) l = 0 for i, s in enumerate(S): if ord('z') - ord(s) + 1 <= K: S[i] = 'a' K -= ord('z') - ord(s) + 1 else: l = i else: if K > 0: S[-1] = chr(ord(S[-1]) + K % 26) print("".join(S))
p03730
s137488605
Wrong Answer
a,b,c = map(int,input().split()) l = [] if a % 2 == 0: print("NO") else: for i in range(1,b+1): l.append((a * i) % b) # print(l) if l.count(c) != 0: print("YES") else: print("NO")
p02691
s293874465
Accepted
from collections import Counter N= int(input()) a = list(map(int, input().split())) b = a[:] c = a[:] for i in range(N): b[i] += i c[i] -= i cnt1 = Counter(b) cnt2 = Counter(c) lst = list(cnt1.keys()) lst.sort() ans = 0 for i in range(len(lst)): ans += cnt1[lst[i]] * cnt2[-lst[i]] print(ans)
p02659
s437320737
Accepted
a,x=input().split() a=int(a) b,c=map(int,x.split('.')) b=b*100+c print((a*b)//100)
p02660
s707506758
Accepted
from math import sqrt n = int(input()) cnt = [0]*1000000 ans = 0 for i in range(2,int(sqrt(n))): if(n==1): break j = 1 while n%i==0: n = n//i cnt[i-1]+=1 if cnt[i-1]==j: ans+=1 j+=1 cnt[i-1]=0 if n!=1: ans+=1 print(ans)
p02706
s000091022
Wrong Answer
N , M = input().split(" ") A = input() Ai = A.split(" ") tm = 0 for i in Ai: tm = tm + int(i) print(int(N)-tm)
p03860
s502308665
Wrong Answer
A,x,C = input ().split () n = x[:1] print ('A',n,'C')
p03836
s943453529
Accepted
sx, sy, tx, ty = map(int, input().split()) dx = tx - sx dy = ty - sy ans ='' ans += 'R'*dx + 'U'*dy ans += 'L'*dx + 'D'*dy ans += 'D' + 'R'*(dx+1) + 'U'*(dy+1) + 'L' ans += 'U' + 'L'*(dx+1) + 'D'*(dy+1) + 'R' print(ans)
p02547
s593410278
Wrong Answer
n=int(input()) k=0 for i in range(n): a,b=map(int,input().split()) if(a==b): k+=1 if(k>=3): print("YES") else: print("NO")
p02602
s017307183
Wrong Answer
import numpy as np N, K = map(int, input().split()) A = np.array([int(i) for i in input().split()]) for i in range(N-K): if np.prod(A[i:i+K]) < np.prod(A[i+1:i+K+1]): print('Yes') else: print('No')
p03264
s733694047
Accepted
K = int(input()) if K % 2 == 0: r = (K // 2) **2 else: r = K // 2 * (K // 2 + 1) print(int(r))
p02820
s902103840
Accepted
N,K = map(int,input().split()) R,S,P = map(int,input().split()) T = list("x" * K + input()) win = {"r":P,"s":R,"p":S,"x":0} ans = 0 for i in range(len(T)): if T[i] == T[i - K]: T[i] = "x" else: ans += win[T[i]] print(ans)
p03419
s227255076
Accepted
N,M=map(int,input().split()) ans=abs(N-2)*abs(M-2) print(ans)
p02801
s815471622
Accepted
s=input() k=ord(s) print(chr(k+1))
p02621
s851961150
Accepted
a=int(input()) print(a+a**2+a**3)
p03328
s498509363
Accepted
a, b = list(map(int, input().split())) diff = b - a x = 1 y = 3 i = 3 while True: if y - x == diff: break x = y y = y + i i = i + 1 print(y - b)
p02952
s126284508
Wrong Answer
N = int(input()) cnt = 0 i = 0 for i in range(0, 5, 2): m = 10 ** i print(m) if len(str(m)) > len(str(N)): break M = int("9" * (i + 1)) print(M) if M > N: M = N print(M) cnt += M - m + 1 print(cnt)
p02786
s606734136
Accepted
def f(x): if x==1: return 1 else: return 2*f(x//2)+1 print(f(int(input())))
p02946
s529463945
Accepted
k,x = map(int,input().split()) ans = [i for i in range(x-k+1, x+k)] print(' '.join(map(str,ans)))
p04019
s047707119
Accepted
s = input() sets = set() for v in s: sets.add(v) ans = "Yes" if "N" in sets and "S" not in sets: ans = "No" if "S" in sets and "N" not in sets: ans = "No" if "E" in sets and "W" not in sets: ans = "No" if "W" in sets and "E" not in sets: ans = "No" print(ans)
p02600
s851076006
Wrong Answer
X = int(input()) if 400<=X<=599: print('8') elif 600<=X<=799: print('7') elif 800<=X<=999: print('6') elif 1000<=X<1199: print('5') elif 1200<=X<=1399: print('4') elif 1400<=X<=1599: print('3') elif 1600<=X<1799: print('2') elif 1800<=X<1999: print('1')
p02982
s772360292
Wrong Answer
import math n,d=map(int,input().split()) za=[list(map(int,input().split())) for i in range(n)] ans=0 lon=0 for i in range(n): for j in range(i+1,n): for k in range(d): lon+=(za[i][k]-za[j][k])**2 lon=math.sqrt(lon) else: if lon==int(lon): ans+=1 lon=0 print(ans)
p02695
s874745290
Wrong Answer
N,M,Q = map(int,input().split()) List = [list(map(int, input().split())) for i in range(Q)] ListA = [1]*(N+1) ListB = [] S = 0 for a in range(N): for ListA[N-a] in range(ListA[N-1-a], M+1): for i in range (Q): if ListA[List[i][1]]-ListA[List[i][0]] == List[i][2]: S += List[i][3] ListB.append(S) S = 0 print(max(ListB))
p03037
s655214855
Accepted
N,M = map(int, input().split()) Key = [0 for i in range(N+1)] for _ in range(M): L,R = map(int,input().split()) L -= 1 R -= 1 Key[L] += 1 Key[R+1] -= 1 count = 0 sum = 0 for i in range(len(Key)): sum += Key[i] if sum == M: count += 1 print(count)
p02723
s633725727
Accepted
a,b,c,d,e,f =input() if c == d and e == f : print("Yes") else: print("No")
p03971
s908290236
Wrong Answer
n,a,b=map(int,input().split()) s=input() cnt=0 cnt_f=0 for i in range(n): if s[i] == 'a' and cnt < a+b: print('Yes') cnt+=1 elif s[i] == 'b' and cnt < a+b and cnt_f <= b: print('Yes') cnt+=1 cnt_f+=1 elif s[i] == 'c': print('No') else: print('No')
p04044
s551675368
Wrong Answer
a = input().split() s = [input() for i in range(int(a[0]))] b = '' s.sort() print(s) for i in range(int(a[0]),0): b = s[i] + b print(b)
p02552
s097436813
Accepted
x = int(input()) print(int(not x))
p03043
s590803318
Accepted
N, K = map(int, input().split()) ans = 0 for i in range(1, N + 1): tmp = 1 / N now = i while now < K: now *= 2 tmp /= 2 ans += tmp print(ans)
p03456
s328668051
Accepted
a, b = input().split() X = int(a+b) i = 1 while i*i <= X: if i*i == X: print('Yes') break else: i += 1 else: print('No')
p03644
s164910234
Accepted
n = int(input()) i = True c = 1 while i: c *= 2 if c > n: c = c // 2 i = False print(c)
p02661
s499816694
Wrong Answer
import sys input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(20000000) n = int(input()) a = [] b = [] for i in range(n): a_, b_ = map(int, input().split()) a.append(a_) b.append(b_) a.sort() b.sort() if n % 2 == 0: tmp = [a[n//2-1], a[n//2], b[n//2-1], b[n//2]] tmp.sort() print((tmp[1] + tmp[3]) - (tmp[0] + tmp[2]) + 1) else: mid_l = a[n//2] mid_r = b[n//2] print(mid_r - mid_l + 1)
p03544
s322705969
Accepted
n=int(input()) if n==1: print(1) else: l=[2,1] for i in range(2,n+1): l_i=l[i-2]+l[i-1] l.append(l_i) print(l[n])
p03679
s558494107
Accepted
X, A, B = list(map(int,input().split())) print('delicious' if -A+B <= 0 else 'safe' if B-A <= X else 'dangerous')
p03617
s460167922
Accepted
q, h, s, d = (int(i) for i in input().split()) n = int(input()) x = min(4*q, 2*h, s) y = min(2*x, d) print( (y*(n-n%2)//2) + x*(n%2) )
p03386
s153524693
Accepted
a, b, k = map(int, input().split()) s = set(range(a, min(b + 1, a + k))) s.update(range(b, max(a - 1, b - k), -1)) s = sorted(s) print('\n'.join(map(str, s)))
p04033
s549957603
Accepted
a,b = map(int, input().split()) if a > 0: ans = "Positive" elif b >= 0: ans = "Zero" elif (b-a)%2 == 0: ans = "Negative" else: ans = "Positive" print(ans)
p03657
s498513660
Accepted
a,b = map(int,input().split()) if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0: print("Possible") else: print("Impossible")
p03910
s342825708
Accepted
import sys input = sys.stdin.readline from collections import defaultdict, Counter N = int(input()) n = int((2*N)**0.5) while n*(n+1) < 2*N: n += 1 for i in range(n, 0, -1): if N >= i: print(i) N -= i
p03672
s056693165
Wrong Answer
S = str(input()) S = S[:-2] for _ in range(len(S)//2-2): if S[:len(S)//2] == S[len(S)//2:]: print(len(S)) break else: S = S[:-2]
p02699
s391142728
Wrong Answer
s,w = map(int,input().split()) if w >= s/2: print('unsafe') else: print('safe')
p02639
s034772669
Accepted
X = map(int, input().split()) for i, x in enumerate(X, 1): if not x: print(i)
p02833
s381650409
Wrong Answer
n=int(input()) ans=0 if n % 2==0: for i in range(1,100): waru = 2*5**i if n < waru: break else: tmp = n/waru ans += int(tmp) print(str(ans))
p03448
s224517721
Accepted
a = int(input()) b = int(input()) c = int(input()) x = int(input()) count=0 for i in range(a+1): for j in range(b+1): for k in range(c+1): ans = 500*i + 100*j + 50*k if ans==int(x): count+=1 print(count)
p04031
s215938172
Accepted
n=int(input()) a=list(map(int,input().split())) min_cost=10000000000 for x in range(-100,101): i=0 for y in a: i+=(y-x)**2 min_cost=min(min_cost,i) print(min_cost)
p02633
s908165158
Accepted
x = int(input()) from math import gcd def lcm(x,y): return x // gcd(x, y) * y print(lcm(360,x)//x)
p04020
s191377301
Accepted
n = int(input()) ans = 0 r = 0 for i in range(n): a = int(input()) if a == 0: r = 0 continue else: ans += (a + r) // 2 r = (a + r) % 2 print(ans)
p04034
s300366445
Accepted
N, M = map(int, input().split()) ball = [1 for _ in range(N)] red = [0 for _ in range(N)] red[0] = 1 now_red = 0 for i in range(M): xx, yy = map(int, input().split()) x = xx-1 y = yy-1 ball[x] -= 1 ball[y] += 1 if red[x]: if ball[x] == 0: red[x] = 0 red[y] = 1 now_red = y # print("ball", ball) # print("red", red) # print("now_red", now_red) print(sum(red))
p04043
s163945517
Accepted
a = list(map(int, input().split())) a.sort() if a[0] == 5 and a[1] == 5 and a[2] == 7: print("YES") else: print("NO")
p02988
s826151518
Wrong Answer
N=int(input()) l=[int(x) for x in input().rstrip().split()] now=[] n=[] for i in range(1,N-1): now.append(l[i-1]) now.append(l[i]) now.append(l[i+1]) now=list(set(now)) now.sort() if len(now)==1 or len(now)==2: now=[] continue else: n.append(now[1]) now=[] print(len(set(n)))
p03161
s353319423
Wrong Answer
def main(): N,K = map(int, input().split()) h = list(map(int, input().split())) cost = [10*8]*N cost[0] = 0 for j in range(1,N): for i in range(1,min(j,K)+1): cp = cost[j-i] + abs(h[j]-h[j-i]) if cost[j] > cp : cost[j] = cp print(cost[-1]) return if __name__ == "__main__": main()
p03095
s396785227
Accepted
mod = 10**9+7 n = int(input()) s = input() d = {} for i in s: if i in d: d[i] += 1 else: d[i] = 1 result = 1 for i, j in d.items(): result = (result*(j+1))%mod print((result-1)%mod)
p04020
s170692678
Accepted
N=int(input()) have=0 ans=0 for i in range(N): a=int(input()) now=a+have if a==0: have=0 else: have=now%2 ans+=now//2 print(ans)
p03759
s520356182
Wrong Answer
# 058a a, b, c = map(int, input().split()) if b - a == c - b: print('Yes') else: print('No')
p02796
s131081766
Accepted
import sys input = sys.stdin.readline n = int(input()) arm_range = [] for i in range(n): x, l = map(int, input().split()) arm_range.append([x-l, x+l]) arm_range.sort(key=lambda x: x[1]) high = -float('inf') count = 0 for a in arm_range: if a[0] >= high: high = a[1] count += 1 print(count)
p03077
s674281622
Accepted
from math import ceil n = int(input()) nums = [int(input()) for _ in range(5)] print(ceil(n/min(nums))+4)
p02702
s074730092
Accepted
from collections import Counter S = list(map(int, list(input()))) A = [0] for i, s in enumerate(S[::-1]): A.append((A[-1] + s * pow(10, i, 2019)) % 2019) print(sum([v * (v - 1) // 2 for v in Counter(A).values()]))
p02571
s709108984
Wrong Answer
s = input() t = input() l = len(t) ans = 0 a = 0 for i in range(len(s) - l + 1): ss = list(s[i:i+l]) for j in range(l): if ss[j] ==t[j]: ans += 1 else: if a < ans: a = ans ans = 0 if a < ans: a = ans ans = 0 print(l-a)
p03161
s411203683
Wrong Answer
n,k=map(int,input().split()) h=list(map(int,input().split())) dp=[0]*n rage=range #lol for i in rage(1,n): if i==1: dp[i]=dp[i-1]+abs(h[i]-h[i-1]) else: dp[i]+=min([dp[i-j]+abs(h[i]-h[i-j]) for j in rage(1,k+1)]); print(dp[-1])
p02675
s587349032
Accepted
def main(): N = int(input()) d = N % 10 if(d == 2 or d == 4 or d == 5 or d == 7 or d == 9): print("hon") elif(d == 0 or d == 1 or d == 6 or d == 8): print("pon") elif(d == 3): print("bon") if __name__ == "__main__": main()
p03456
s875858219
Wrong Answer
a=list(input().split()) aa=int(''.join(a)) for i in range(1,101): if i*i==aa: print('Yes') break else: print('No')
p02695
s464519920
Accepted
import itertools import numpy as np d_list = [] sum_d = 0 N, M, Q = map(int, input().split()) abcd = [list(map(int, input().split())) for i in range(Q)] ans = 0 A = [1 for i in range(N)] for A in itertools.combinations_with_replacement(range(1, M+1), N): for i in range(Q): if A[abcd[i][1]-1]-A[abcd[i][0]-1] == abcd[i][2]: d_list.append(abcd[i][3]) if sum_d <= sum(d_list): sum_d = sum(d_list) d_list.clear() print(sum_d)
p03487
s169582961
Accepted
import collections N=int(input()) a=list(map(int,input().split())) a_counter=collections.Counter(a) answer = 0 # print(a_counter) # print(a_counter[0]) # print(a_counter[1]) # print(a_counter[2]) # print(a_counter[3]) for i in a_counter: # print(i) # print(i == a_counter[i]) if i != a_counter[i]: if i < a_counter[i]: answer += a_counter[i] - i else: answer += a_counter[i] print(answer)
p03943
s542100258
Accepted
import sys def solve(inp): A = list(map(int, inp.readline().strip().split(' '))) A = sorted(A) if A[0] + A[1] == A[2]: return "Yes" else: return "No" def main(): result = solve(sys.stdin) if result: print(result) if __name__ == '__main__': main()
p03250
s812447297
Accepted
a, b, c = sorted(map(int, input().split())) print(c*10 + b + a)
p03456
s065562732
Accepted
a, b = input().split() ab = int(a+b) if (ab ** 0.5).is_integer(): print('Yes') else: print('No')
p03385
s345739776
Wrong Answer
s =input() print("Yes" if "a" and "b" and "c" in s else "No")
p03282
s109815474
Accepted
n = list(input()) k = int(input()) if len(n) == 1: print(int(n[0])) exit() x = 0 for i in range(len(n)): if n[i] != "1": x = i break if x+1 > k: print(1) exit() else: print(n[x])