Harryxun/stf_run huggingface dataset:
n = int(input()) 
lst = [int(input()) for i in range(n)]
while(1):
    hps = sorted(hps)
    #print(hps)
    if(hps[0]==0): break
    hps[1] = hps[1] - hps[0]
print(hps[1])

### FIXED CODE ###

def gcd(a,b):
    r = a%b
    #print(a,b,r)
    if(r==0): return b
    return gcd(b,r)
n = int(input()) 
#n=4
hps = [int(i) for i in input().split()]
#lst = [2, 2, 8, 40]
#lst = [5, 13, 8, 1000000000]
#lst = [0, 1, 0]
    ##2 4 5 -> 1
    ## minと全ての要素のgcd
hps = sorted(hps)
for i in range(1,n):
    hps[0] = gcd(hps[i], hps[0])
#print(hps)
for i in range(len(hps)):
    if(hps[i]==0): continue
    print(hps[i])
    break
#!/usr/bin/python
# coding: UTF-8

import re

len = int(input())
src = input()
t = int(input())
pt = "[^"+src[t]+"]"
print(re.sub(pt,"*",src))

### FIXED CODE ###

#!/usr/bin/python
# coding: UTF-8

import re

len = int(input())
src = input()
t = int(input())
pt = "[^"+src[t-1]+"]"
print(re.sub(pt,"*",src))
a, b = map(int, input().split())
if a >= 13:
  print(B)
else if a >= 6 and a < 12:
  print(B/2)
else:
  print(0)
  


### FIXED CODE ###

a, b = map(int, input().split())
if a >= 13:
    print(b)
elif (a >= 6 and a <= 12):
    print(b//2)
else:
    print(0)
b,c=map(int,input().split())
a=list(map(int,input().split()))
d=sum(a)
new_a=sorted(a)
e=-1
f=0
g=4*c
while new_a[e] >= d/g:
    e=e-1
    f=f+1
if f >= c:
    print("Yes")
else :
    print("No")

### FIXED CODE ###

b,c=map(int,input().split())
a=list(map(int,input().split()))
d=sum(a)
new_a=sorted(a)
e=-1
f=0
g=4*c

while new_a[e] >= d/g:
    e=e-1
    f=f+1
    if -e>b:
        break

if f >= c:
    print("Yes")
else :
    print("No")
while 1 :
	m,f,r = map(int , raw_input().split())
	
	s = m + f
	
	if m == f == s == -1 :
		break
	elif m == -1 or f == -1 or s < 30 :
		print "F"
	elif s >= 80 :
		print "A"
	elif s >= 65 :	
		print "B"
	elif s >= 50 : 
		print "C"
	elif s >= 30 and r >= 50 :
		print "C"
	else :
		print "D"

### FIXED CODE ###

while 1 :
	m,f,r = map(int , raw_input().split())
	
	s = m + f
	
	if m == f == r == -1 :
		break
	elif m == -1 or f == -1 or s < 30 :
		print "F"
	elif s >= 80 :
		print "A"
	elif s >= 65 :	
		print "B"
	elif s >= 50 : 
		print "C"
	elif s >= 30 and r >= 50 :
		print "C"
	else :
		print "D"
N,X = map(int, input().split())
D=0
L=list(map(int, input().split()))
i=0
while (D<X):
  D+=L[i]
  i+=1
  if i>N:
    break
print(i)
  
  


### FIXED CODE ###

N,X = map(int, input().split())
D=0
L=list(map(int, input().split()))
i=0
while (D<=X)and(i<N+1):
  if (i<N):
    D+=L[i]
  i+=1
#  if i>N:
 #   break
print(i)
ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	n=int(raw_input())
	if n==10:break
	e=0
	#for i in range(n):
	#	a=ref[int(raw_input())]
	#	print "{:07b}".format(a^e)
	#	e=a

### FIXED CODE ###

ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	try:
		n=input()
		if n==-1:break
		e=0
		for i in range(n):
			a=ref[input()]
			print "{:07b}".format(a^e)
			e=a
	except:
		pass
n = int(input())
print(,end=' ')
for i in range(3, n + 1):
    if i % 3 == 0 or i % 10 == 3:
        print(i, end=' ')

### FIXED CODE ###

n = int(input())
for i in range(3, n + 1):
    if i % 3 == 0 or i % 10 == 3 or '3' in str(i):
        print('',i,end='')
print()
a=["k","e","y","e","n","c","e"]
s=input()

if a==s[:7] or a==s[-7:]:
  print("YES")
else:
  i=0
  sw=0
  while 1:
    if a[i]==s[i]:
      i+=1
    else:
      break
  while 1:
    if a[i]==s[-7+i]:
      i+=1
    else:
      sw=1
      break
    if i==7:
      break
  print("NO" if sw==1 else "YES")
  

### FIXED CODE ###

a="keyence"
s=input()
#print(s[:7],s[-7:])
if a==s[:7] or a==s[-7:]:
  print("YES")
else:
  i=0
  sw=0
  while 1:
    if a[i]==s[i]:
      i+=1
    else:
      break
  while 1:
    if a[i]==s[-7+i]:
      i+=1
    else:
      sw=1
      break
    if i==7:
      break
  print("NO" if sw==1 else "YES")
N = int(input())
A = int(input())
if N % 500 <= A
    print("Yes")
else:
    print("No")

### FIXED CODE ###

N = int(input())
A = int(input())
if N % 500 <= A:
    print("Yes")
else:
    print("No")
s = input()
print(min(s.count(1), s.count(0))*2)

### FIXED CODE ###

s = input()
print(min(s.count('1'), s.count('0'))*2)
N = int(input().strip())
x = [[] for x in range(N)]
for i in range(N-1):
     u, v, w = list(map(int, input().split()))
     x[u-1].append([v-1, w])
     x[v-1].append([u-1,w])



ret = {}
done = []

queue = [0]

for i in range(N):
    curr = queue.pop()
    if curr == 0:
        ret[0] = 0

    for neigh in x[curr]:
        if neigh in done:
            continue
        if neigh[1] % 2 == 0:
            ret[neigh[0]] = ret[curr]
        else:
            ret[neigh[0]] = 0 if ret[curr] == 1 else 1

        queue.append(neigh[0])
    done.append(curr)


for i in range(N):
    print(ret[i])


### FIXED CODE ###

N,K = map(int, input().strip().split())
S = input().strip()

for ix, c in enumerate(S):
    if K == (ix + 1):
        print(c.lower(), end='')
    else:
        print(c, end='')
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    N, Q = LI()
    s = SI()
    TD = []
    for _ in range(Q):
        TD.append(LS())
    rev = TD[::-1]
    l, r = -1, N
    for t, d in rev:
        if t == s[l + 1] and d == 'L':
            l += 1
        elif t == s[r - 1] and d == 'R':
            r -= 1
        if l > -1 and t == s[l] and d == 'R':
            l -= 1
        elif r < N and t == s[r] and d == 'L':
            r += 1
        if r <= l:
            break
    ans = max(0, r - l - 1)
    return ans

print(main())

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    N, Q = LI()
    s = SI()
    TD = []
    for _ in range(Q):
        TD.append(LS())
    rev = TD[::-1]
    l, r = -1, N
    for t, d in rev:
        if t == s[l + 1] and d == 'L':
            l += 1
        elif t == s[r - 1] and d == 'R':
            r -= 1
        if l > -1 and t == s[l] and d == 'R':
            l -= 1
        elif r < N and t == s[r] and d == 'L':
            r += 1
        if r == 0 or l == N - 1:
            break
    ans = max(0, r - l - 1)
    return ans

print(main())
def cur(current,e,dist,color):
    for it in e[current]:
        if color[it]!=-1: continue
        color[it]=(color[current]+dist[(it,current)])%2
        cur(it,e,dist,color)

N=int(input())
e=[[] for i in range(N+1)]
dist={}
for i in range(N-1):
    u,v,w=map(int,input().split())
    e[u].append(v)
    e[v].append(u)
    dist[(u,v)],dist[(v,u)]=w,w
memo=[-1]*N




color=[-1]*(N+1)
color[1]=0
cur(1,e,dist,color)

for i in range(1,N+1):
    print(color[i])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

def cur(current,e,dist,color):
    for it in e[current]:
        if color[it]!=-1: continue
        color[it]=(color[current]+dist[(it,current)])%2
        cur(it,e,dist,color)

N=int(input())
e=[[] for i in range(N+1)]
dist={}
for i in range(N-1):
    u,v,w=map(int,input().split())
    e[u].append(v)
    e[v].append(u)
    dist[(u,v)],dist[(v,u)]=w,w
memo=[-1]*N




color=[-1]*(N+1)
color[1]=0
cur(1,e,dist,color)

for i in range(1,N+1):
    print(color[i])
if __name__ == '__main__':
    N,K,X,Y = map(int, raw_input().split())
    if(N <= K):
        print (N * X)
    else :
        print (K * X) + ((N-K) * Y)

### FIXED CODE ###

if __name__ == '__main__':
    N = input()
    K = input()
    X = input()
    Y = input()
    if(N <= K):
        print (N * X)
    else :
        print (K * X) + ((N-K) * Y)
import numpy as np

N = int(input())
A = np.empty(N, dtype=np.int)
B = np.empty(N, dtype=np.int)
for i in range(N):
	A[i], B[i] = map(int, input().split())

for i in range(N):
	print(A[i] * B[i])
	


### FIXED CODE ###

A, B = map(int, input().split())
if 13 <= A:
	print(B)
elif 5 < A:
	print(B // 2)
else:
	print(0)
N = int(input())
if N == 1:
    print('Hello World)
if N == 2:
    A =int(input())
    B =int(input())
    print(A+B)

### FIXED CODE ###

N = int(input())
if N == 1:
    print('Hello World')
else:
    A =int(input())
    B =int(input())
    print(A+B)
n=int(input())
a=list(map(int,input()).split())
if 0 in a:exit(print(0))
ans=1
for i in a:
  ans*=i
  if ans>10**18:exit(print(-1))
print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=1
if 0 in a:exit(print(0))
for i in a:
  ans*=i
  if ans>10**18:
    print(-1)
    exit()
print(ans)
n = int(input())
card_list = list(map(int, input().split()))

alice_point = 0
bob_point = 0

def pick_card(card_list):
    # print(card_list)
    max = 0
    max_index = 0
    for i in range(card_list.__len__()):
        # print('-------', i)
        if card_list[i] > max:
            # print('@', i, ':', max, '<', card_list[i])
            max = card_list[i]
            max_index = i
    
    del card_list[max_index]

    # print('----', card_list)

    return max, card_list

def sort_card(card_list: list):
    return card_list.sort()

turn = 0
while turn < n:
    # print('--', turn)
    sorted_list = sort_card(card_list)
    if turn % 2 == 0:
        # alice_get, remain_list = pick_card(card_list)
        # alice_point += alice_get
        alice_point += sorted_list.pop()
    else:
        # bob_get, remain_list = pick_card(card_list)
        # bob_point += bob_get
        bob_point += sorted_list.pop()

    card_list = remain_list
    # print(alice_point, bob_point, card_list)

    turn += 1

print(alice_point - bob_point)

### FIXED CODE ###


n = int(input())
card_list = list(map(int, input().split()))

alice_point = 0
bob_point = 0

def pick_card(card_list):
    # print(card_list)
    max = 0
    max_index = 0
    for i in range(card_list.__len__()):
        # print('-------', i)
        if card_list[i] > max:
            # print('@', i, ':', max, '<', card_list[i])
            max = card_list[i]
            max_index = i
    
    del card_list[max_index]

    # print('----', card_list)

    return max, card_list

turn = 0
while turn < n:
    # print('--', turn)
    remain_list = []
    if turn % 2 == 0:
        alice_get, remain_list = pick_card(card_list)
        alice_point += alice_get
    else:
        bob_get, remain_list = pick_card(card_list)
        bob_point += bob_get

    card_list = remain_list
    # print(alice_point, bob_point, card_list)

    turn += 1

print(alice_point - bob_point)
import sys
sys.setrecursionlimit(10**6)


def f(n):
    p = n % popcnt(n)
    if p == 0:
        return 1
    else:
        return f(p) + 1


def popcnt(n):
    c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333)
    c = (c & 0x0f0f0f0f0f0f0f0f) + ((c >> 4) & 0x0f0f0f0f0f0f0f0f)
    c = (c & 0x00ff00ff00ff00ff) + ((c >> 8) & 0x00ff00ff00ff00ff)
    c = (c & 0x0000ffff0000ffff) + ((c >> 16) & 0x0000ffff0000ffff)
    c = (c & 0x00000000ffffffff) + ((c >> 32) & 0x00000000ffffffff)
    return c


def main(input, print):
    N = int(input())
    X = int(input(), 2)
    for i in reversed(range(N)):
        b = 1 << i
        a = X ^ b
        print(f(a))


if __name__ == '__main__':
    main(sys.stdin.readline, print)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)


def f(n):
    if n == 0:
        return 1
    p = n % (bin(n).count('1'))
    return f(p) + 1


def main(input, print):
    N = int(input())
    X = list(map(int, list(input().strip())))
    ans = [0] * N

    pcnt = 0
    for i in range(N):
        if X[i] == 1:
            pcnt += 1
    for is_up in range(2):
        current_pcnt = pcnt
        if is_up:
            current_pcnt -= 1
        else:
            current_pcnt += 1
        if current_pcnt <= 0:
            continue
        total = 0
        for i in range(N):
            total = (total*2) % current_pcnt
            total += X[i]
        current_mask = 1
        for i in reversed(range(N)):
            if(X[i] == is_up):
                current_total = total
                if is_up:
                    current_total = (current_total-current_mask+current_pcnt) % current_pcnt
                else:
                    current_total = (current_total+current_mask) % current_pcnt
                ans[i] = f(current_total)
            current_mask = current_mask * 2 % current_pcnt

    for i in range(N):
        print(ans[i])


if __name__ == '__main__':
    main(sys.stdin.readline, print)
a,b=input().split()

if a == "H":
  print("H")
else if a == "D" and b == "H":
  print("D")
else:
  print("H")

### FIXED CODE ###

a,b=input().split()

if a == b:
  print("H")
else:
  print("D")
import sys
sys.setrecursionlimit(2147483647)


n=int(input())

mod=10**9+7

pp={}
pp_k=set([])

pm={}
pm_k=set([])

from fractions import gcd


for _ in range(n):
    a,b=map(int,input().split())
    tmp=gcd(a,b)
    a=a//tmp
    b=b//tmp

    if a*b>0:
        if (a,b) in pp_k:
            pp[(a,b)]+=1
        else:
            pp[(a,b)]=1
            pp_k.add((a,b))
    else:
        if (a,b) in pm_k:
            pm[(a,b)]+=1
        else:
            pm[(a,b)]=1
            pm_k.add((a,b))

result=pow(2,n,mod)-1

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = mod #割る数
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

#print(pp_k,pm_k)
for item in pp_k:

    tmp=0

    a,b=item[0],item[1]
    cnt_pp=pp[item]
    aa=-1*a
    bb=b
    cnt_pm=0
    hoge=(bb,aa)
    #print(hoge)
    if hoge in pm_k:
        #print("Yes")
        cnt_pm+=pm[hoge]
    aa=a
    bb=-1*b
    hoge=(bb,aa)
    if hoge in pm_k:
        cnt_pm+=pm[hoge]
    #print(item,cnt_pm)
    if cnt_pm>0:
        tmp+=pow(2,max(0,n-cnt_pm-cnt_pp),mod)*(pow(2,cnt_pp,mod)-1)*(pow(2,cnt_pp,mod)-1)
        #print(pow(2,max(0,n-cnt_pm-cnt_pp),mod),(pow(2,cnt_pp,mod)-1),(pow(2,cnt_pp,mod)-1))
        result-=tmp

print(result%mod)
    

    

### FIXED CODE ###

n=int(input())

mod=10**9+7

#初期値が0の辞書
from collections import defaultdict
pp = defaultdict(lambda: 0) 
pm = defaultdict(lambda: 0) 

def seiki(x,y):
    tmp=gcd(x,y)
    return (x//tmp,y//tmp)

from math import gcd
zero=0
for _ in range(n):
    a,b=map(int,input().split())

    if a==0 and b==0:
        zero+=1
    elif a*b>0:
        tmp=seiki(abs(a),abs(b))
        pp[tmp]+=1
    elif a==0:
        pp[(1,0)]+=1
    elif b==0:
        pm[(1,0)]+=1
        pp[(1,0)]+=0
    else:
        tmp=seiki(abs(b),abs(a))
        pm[tmp]+=1
        pp[tmp]+=0
#print(pm)
#print(pp)
result=1
for key in pp.keys():
    pp_v=pp[key]
    pm_v=pm[key]
    result*=(pow(2,pm_v,mod)+pow(2,pp_v,mod)-1)
    result%=mod

print((result-1+zero)%mod)
k = int(input())
anss = [1,2,3,4,5,6,7,8,9]
for i in range(12):
    if len(anss) > k:
        print(new_anss[k-1])
        break
    new_anss = []
    for ans in anss:
        if ans % 10 != 0:
            new_anss += [ans*10+ans-1]
        new_anss += [ans*10+ans]
        if ans % 10 != 9:
            new_anss += [ans*10+ans+1]
    k -= len(anss)
    anss = new_anss

### FIXED CODE ###

k = int(input())
anss = [1,2,3,4,5,6,7,8,9]
for i in range(12):
    if len(anss) > k:
        print(anss[k-1])
        break
    new_anss = []
    for ans in anss:
        if ans % 10 != 0:
            new_anss += [ans*10+ans%10-1]
        new_anss += [ans*10+ans%10]
        if ans % 10 != 9:
            new_anss += [ans*10+ans%10+1]
    k -= len(anss)
    anss = new_anss
def sum(l):
	s=0
	for i in l:
		s+=i
	return s
r,c=map(int,raw_input().split())
su=[0]*c
for i in range(r):
	l=map(int,raw_input().split())
	for j in l:print j,
	print sum(l)
	for j in range(c):su[j]+=l[j]
for j in su:print j,
	print sum(su)

### FIXED CODE ###

r, c = map(int, input().split())
a = []

for i in range(r):
    a.append(list(map(int, input().split())))
    a[i].append(sum(a[i]))

for i in range(r):
    print(" ".join(list(map(str, a[i]))))

col_sum = []
for j in range(c+1):
    su = 0
    for i in range(r):
        su += a[i][j]
    col_sum.append(su)

print(" ".join(list(map(str, col_sum))))
n = int(input())
ais = list(map(int, input().split()))
a_mini = ais[0]
a_max = ais[0]
for i in rnage(1, n):
  if ais[i] < a_mini:
    a_mini = ais[i]
  if ais[i] > a_max:
    a_max = ais[i]
print(a_max - a_mini)

### FIXED CODE ###

n = int(input())
ais = list(map(int, input().split()))
ais_sort = sorted(ais)
print(ais_sort[n-1] - ais_sort[0])
import math

a, b, x = map(int, input().split())

def calc_theta(a, b, x):
    if x >= 0.5 * a ** 2 * b:
        tmp = (a ** 3) / (2 * ((a **2) * b - x))
    else:
        tmp = (2 * x) / ((b ** 2) * a)

    return 90 - math.degrees(math.atan(tmp))

ans = calc_theta(a, b, x)

print(ans)






### FIXED CODE ###

import math

a, b, x = map(int, input().split())

def calc_theta(a, b, x):
    if x >= 0.5 * a ** 2 * b:
        # tmp = (a ** 3) / (2 * ((a **2) * b - x)) これだと 0divになる
        tmp = (2/a)*(b-(x/a**2))
    else:
        tmp = (a * b * b) / (2 * x)
    return math.degrees(math.atan(tmp))

ans = calc_theta(a, b, x)

print('{:.10f}'.format(ans))
A, B = map(int, input().split())
A -= 1
B -= 1

print('100 100')

for i in range(25):
    print('#' * 100)
    if A:
        x = min(A, 50)
        A = A - x
        print('#.'*x + '##'*(50-x))
    else:
        print('#' * 100)

for i in range(25):
    print('.' * 100)
    if B:
        x = min(B, 50)
        B = B - x
        print('.#'*x + '..'*(50-x))
    else:
        print('.' * 100)
A, B = map(int, input().split())
A -= 1
B -= 1

print('100 100')

for i in range(25):
    print('#' * 100)
    if A:
        x = min(A, 50)
        A = A - x
        print('#.'*x + '##'*(50-x))
    else:
        print('#' * 100)

for i in range(25):
    print('.' * 100)
    if B:
        x = min(B, 50)
        B = B - x
        print('.#'*x + '..'*(50-x))
    else:
        print('.' * 100)


### FIXED CODE ###

def print_component(a, b, n):
    for _ in range(25):
        print(a * 100)
        if n:
            x = min(n, 50)
            n -= x
            print((a+b)*x + a*2*(50-x))
        else:
            print(a * 100)


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

print('100 100')
print_component('#', '.', A - 1)
print_component('.', '#', B - 1)
a,b = map.(int,input().split())

if ( a * b ) % 2 == 0:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

a,b = map(int,input().split())
 
if ( a * b ) % 2 == 0:
  print("No")
else:
  print("Yes")
n = int(input())
max_step = 0
step = 0
pre_h = 0
for h in map(int, input().split()):
  if h <= pre_h:
    step += 1
  else:
    if max_step < step:
      max_step = step
    step = 0
  pre_h = h
print(max[max_step, step])

### FIXED CODE ###

n = int(input())
max_step = 0
step = 0
pre_h = 0
for h in map(int, input().split()):
  if h <= pre_h:
    step += 1
  else:
    if max_step < step:
      max_step = step
    step = 0
  pre_h = h
print(max([max_step, step]))
import numpy as np
import itertools

S = input()

nums = [s for s in S]
idxs = np.arange(1, len(nums))
masks = list(itertools.product([False, True], repeat=len(idxs)))

ret = 0 
for mask in masks:
    selected_idxs = [0] +list( idxs[ np.array(mask)]) + [len(nums)]
    for i in range(len(selected_idxs) - 1):
        ret += (int(''.join(nums[selected_idxs[i]: selected_idxs[i+1]])))

print(ret)

### FIXED CODE ###

import numpy as np
import itertools

def calc_sum(nums):
    if len(nums) == 1: return nums[0]
    idxs = np.arange(1, len(nums))
    masks = list(itertools.product([False, True], repeat=len(idxs)))

    ret = 0 
    for mask in masks:
        selected_idxs = [0] +list( idxs[ np.array(mask)]) + [len(nums)]
        for i in range(len(selected_idxs) - 1):
            ret += (int(''.join(nums[selected_idxs[i]: selected_idxs[i+1]])))
    return ret


S = input()
nums = [s for s in S]

print(calc_sum(nums))
def resolve():
    s = input()
    k = int(input())
    cnt = -1
    for i in range(len(s)):
        if s[i] != '1':
            break
        cnt = i + 1
    if cnt > k:
        print(1)
    else:
        print(s[cnt] if cnt > -1 else s[0])

if __name__ == '__main__':
    resolve()


### FIXED CODE ###

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

#go = 5000000000000000
C = '1'
for i in range(len(S)):
    if S[i] != '1' or i+1 == K:
        C = S[i]
        break
print(C)
def e_flatten_prime_factorization(MOD=10**9 + 7):
    N = int(input())
    A = [int(i) for i in input().split()]

    def prime_factorization_dict(n):
        from collections import defaultdict
        """nを素因数分解したときの素数とその指数の辞書"""
        if n == 1:
            return {2: 0}  # 1は素数の0乗の積とみなす
        i, table = 2, defaultdict(int)
        while i**2 <= n:
            while n % i == 0:
                table[i] += 1
                n //= i
            i += 1
        if n > 1:
            table[n] = 1
        return table

    def prime_table(n):
        """n以下の素数のリスト(エラトステネスの篩)"""
        is_prime = [True] * (n + 1)
        is_prime[0] = is_prime[1] = False  # 0と1は素数でない
        for j in range(2, int(n**0.5) + 1):
            if not is_prime[j]:
                continue
            for k in range(j * 2, n + 1, j):
                is_prime[k] = False  # jの倍数は素数でない
        return {i: 0 for i in range(n + 1) if is_prime[i]}

    lcm_prime = prime_table(1000)
    for a in A:
        for base, exp in prime_factorization_dict(a).items():
            lcm_prime[base] = max(lcm_prime[base], exp)
    lcm = 1
    for base, exp in lcm_prime.items():
        lcm *= pow(base, exp, MOD)
        lcm %= MOD
    coefficient = sum(pow(a, MOD - 2, MOD) for a in A)
    return (lcm * coefficient) % MOD

print(e_flatten_prime_factorization())

### FIXED CODE ###

def e_flatten(MOD=10**9 + 7):
    from fractions import gcd
    from functools import reduce
    N = int(input())
    A = [int(i) for i in input().split()]

    def lcm(a, b):
        return a * b // gcd(a, b)

    def inv(n, mod=MOD):
        return pow(n, mod - 2, mod)

    l = reduce(lcm, A) % MOD
    ans = [(l * inv(a)) % MOD for a in A]
    return sum(ans) % MOD

print(e_flatten())
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

manzoku=0;

for i in range(len(A)):
	manzoku+=B[A[i]-1]
	if i+1<n and A[i+1]-A[i]==1:
		manzoku+=C[A[i]-1]
print(manzoku)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
sum =0;
for i in range(len(a)):
    sum += b[a[i]-1]
    if i +1 < n and a[i+1] - a[i] == 1:
        sum += c[a[i]-1]
print(sum)
x, k, d = list(map(lambda x: int(x), input().split()))

min_pos = x % d
min_neg = min_pos - d

num_to_min_pos = x // d
if k <= num_to_min_pos:
    print(x - d * k)
    
else:
    if (k - num_to_min_pos) % 2 == 0:
        print(min_pos)
    else:
        print(abs(min_neg))


### FIXED CODE ###

import re
s = input()
array = re.split(r'S+', s)
print(max([len(e) for e in array]))
inputs = input().split()
a = int(inputs[0])
b = int(inputs[1])
if abs(a - b) % 2 = 0:
  print( (a + b) / 2 )
else:
  print('IMPOSSIBLE')


### FIXED CODE ###

inputs = input().split()
a = int(inputs[0])
b = int(inputs[1])
if (a - b) % 2 == 0:
  print( int((a + b) / 2 ))
else:
  print('IMPOSSIBLE')