Harryxun/stf_run huggingface dataset:
from math import ceil
def chk(A, C, x, K):
    cnt = 0
    for i in range(N):
        cnt += max(ceil(A[i]-x/C[i]), 0)
        if cnt > K:
            return False
    return True
def main():
    N, K = map(int,input().split())
    A = list(map(int,input().split()))
    C = list(map(int,input().split()))
    A.sort(reverse=True)
    C.sort()
    ng, ok = -1, 10**12
    while ok - ng > 1:
        m = (ok+ng)//2
        if chk(A, C, m, K):
            ok = m
        else:
            ng = m
    print(ok)
if __name__ == "__main__":
    main()

### FIXED CODE ###

from math import ceil
def main():
    N, K = map(int,input().split())
    A = list(map(int,input().split()))
    C = list(map(int,input().split()))
    A.sort(reverse=True)
    C.sort()
    def chk(x):
        cnt = 0
        for i in range(N):
            cnt += max(ceil(A[i]-x/C[i]), 0)
            if cnt > K:
                return False
        return True
    ng, ok = -1, 10**12
    while ok - ng > 1:
        m = (ok+ng)//2
        if chk(m):
            ok = m
        else:
            ng = m
    print(ok)
if __name__ == "__main__":
    main()
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for c500 in range(a+1):
    for c100 in range(b+1):
        for c50 in range(c+1):
            if c500*500 + c100*100 + c50*50 == x:
                cnt += 1
        
print(cnt)

### FIXED CODE ###

x = int(input())
a = int(input())
b = int(input())
print((x-a)%b)
#! /usr/bin/env python3
# -*- coding:utf-8 -*-

def generate_children(num_children, pl):
    children = ["0"]*num_children
    if num_children == 0: return []
    if num_children%2 == 0:
        children[pl-1] = str(int(num_children/2))
        children[pl] = str(int(num_children/2))
    else:
        if (num_children - pl)%2 == 0:
            children[pl-1] = str(int((num_children+1)/2))
            children[pl] = str(int((num_children-1)/2))
        else:
            children[pl-1] = str(int((num_children-1)/2))
            children[pl] = str(int((num_children+1)/2))
    return children


def gathering(s):
    children = []
    pr = 0
    pl = 0
    now = ""
    for i, x in enumerate(s):
        if i == len(s)-1:
            children.extend(generate_children(i+1-pr, pl-pr))
        if x == now: continue
        if x == 'L': pl = i
        if x == 'R':
            children.extend(generate_children(i-pr, pl-pr))
            pr = i
        now = x
    return ' '.join(children)

def main():
    s = input()
    print(gathering(s))

if __name__ == '__main__':
    main()


### FIXED CODE ###

#! /usr/bin/env python3
# -*- coding:utf-8 -*-

def generate_children(num_children, pl):
    children = ["0"]*num_children
    if num_children == 0: return []
    if num_children%2 == 0:
        children[pl-1] = str(int(num_children/2))
        children[pl] = str(int(num_children/2))
    else:
        if (num_children - pl)%2 == 0:
            children[pl-1] = str(int((num_children+1)/2))
            children[pl] = str(int((num_children-1)/2))
        else:
            children[pl-1] = str(int((num_children-1)/2))
            children[pl] = str(int((num_children+1)/2))
    return children


def gathering(s):
    children = []
    pr = 0
    pl = 0
    now = ""
    for i, x in enumerate(s):
        if x == now: continue
        if x == 'L': pl = i
        if x == 'R':
            children.extend(generate_children(i-pr, pl-pr))
            pr = i
        now = x
    children.extend(generate_children(len(s)-pr, pl-pr))
    return ' '.join(children)

def main():
    s = input()
    print(gathering(s))

if __name__ == '__main__':
    main()
s = raw_input()
k = x = 0
while 1:
        x += 1
        if "J"*x+"O"*x+"I"*x in s:
                k = x
        elif not "J"*x in s:
                print(k)
                break
        elif not "O"*x in s:
                print(k)
                break
        elif not "I"*x in s:
                print(k)
                break

### FIXED CODE ###

s = raw_input()
k = x = 0
try:
        while 1:
                cj = co = ci = 0
                while s[x] == "J":
                        cj += 1
                        x += 1
                while s[x] == "O":
                        co += 1
                        x += 1
                while s[x] == "I":
                        ci += 1
                        x += 1
                if co <= cj and co <= ci:
                        k = max(co,k)
except IndexError:
        if co <= cj and co <= ci:
                k = max(co,k)
        print(k)
N,K = map(int,input().split())
A = list(map(int,input().split()))
x = 1
step = 0
count = [0]*N
count[0] += 1
memo = [-1]*N
memo[0] = 0
M = K
for i in range(M):
    x = A[x-1]
    count[x-1] += 1
    step += 1
    K -= 1
    if memo[x-1] != -1:
        s = memo[x-1]
        t = step-s
#        print(s,t)
        break
    memo[x-1] = step
#    print(step,x,count,memo)

K %= t
for i in range(K):
    x = A[x-1]
print(x)


### FIXED CODE ###

N,K = map(int,input().split())
A = list(map(int,input().split()))
x = 1
step = 0
count = [0]*N
count[0] += 1
memo = [-1]*N
memo[0] = 0
M = K
flag = 0
for i in range(M):
    x = A[x-1]
    count[x-1] += 1
    step += 1
    K -= 1
    if memo[x-1] != -1:
        s = memo[x-1]
        t = step-s
#        print(s,t)
        flag = 1
        break
    memo[x-1] = step
#    print(step,x,count,memo)
if flag == 0:
    print(x)
else:
    if t>= 1:
        K %= t
    else:
        K = 1
    for i in range(K):
        x = A[x-1]
    print(x)
ipt1 = [int(i) for i in input().split()]
a = [int(i) for i  in input().split()]
n = ipt1[0]
m = ipt1[1]
x = ipt1[2]
cost_0 = 0
cost_n = 0
for i in range(m):
    if a[i] < x:
        cost_0 += 1
    else:
        cost_n += 1

print(min(cost_0, cost_n))


### FIXED CODE ###

ipt = [int(i) for i in input().split()]
a = ipt[0]
b = ipt[1]
x = ipt[2]

if a <= x and x <= a+b:
    print("YES")
else:
    print("NO")
N,M = map(int, input().split())
am = list(map(int, input().split()))
c = [0,2,5,5,4,5,6,3,7,6]
f = [-1]*10010
f[0]=0
for i in range(1,n+1):
    for x in am:
        if i-c[x] >= 0:
            f[i] = max(f[i], f[i-c[x]]*10 +x)
            
print(f[n])

### FIXED CODE ###

N,M = map(int, input().split())
am = list(map(int, input().split()))
c = [0,2,5,5,4,5,6,3,7,6]
f = [-1]*10010
f[0]=0
for i in range(1,N+1):
    for x in am:
        if i-c[x] >= 0:
            f[i] = max(f[i], f[i-c[x]]*10 +x)
            
print(f[N])
A, B, C, D = map(int,input().split())

d={}
d[(A,B)]=1
for i in range(A+1,C+1):
  d[(i,B)] *= B*d[(i-1,B)] % 998244353
for j in range(B+1,D+1):
  d[(A,j)] *= A*d[(A,j-1)] % 998244353
 
for i in range(A+1,C+1):
  for j in range(B+1,D+1):
    d[(i,j)]=(j*d[(i-1,j)]+i*d[(i,j-1)]-(i-1)*(j-1)*d[(i-1,j-1)]) % 998244353
    
print(d[(C,D)] % 998244353)

### FIXED CODE ###

import sys
import numpy as np
#from functools import lru_cache
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
MOD = 998_244_353
 
def main(A, B, C, D):
	d = np.zeros((C + 1, D + 1), np.int64)
	d[A,B]=1
	for i in range(A+1,C+1):
  		d[i,B] = B*d[i-1,B] % MOD
	for j in range(B+1,D+1):
		d[A,j] = A*d[A,j-1] % MOD
 
	for i in range(A+1,C+1):
		for j in range(B+1,D+1):
			d[i,j]=((((j*d[i-1,j]) % MOD + i*d[i,j-1] % MOD) % MOD) -((i-1)*((j-1)*d[i-1,j-1] % MOD)% MOD)% MOD)
    
	return d[C,D] % MOD
          
"""    
    print(d[C][D] % MOD)
    dp = np.zeros((C + 1, D + 1), np.int64)
    dp[C, D] = 1
    for d in range(D, 0, -1):
        dp[C, d - 1] = dp[C, d] * C % MOD
    for c in range(C - 1, -1, -1):
        x = 0
        for d in range(D, -1, -1):
            dp[c, d] = (d * dp[c + 1, d] + x) % MOD
            x += dp[c + 1, d]
            x *= c
            x %= MOD
    return dp[A, B]
"""

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.from_dtype(np.int64)
    signature = (i8, i8, i8, i8)
 
    cc = CC('my_module')
    cc.export('main', signature)(main)
    cc.compile()
 
from my_module import main
 
A, B, C, D = map(int, read().split())
print(main(A, B, C, D))
N = int(input())
x = []
y = []
for i in range(N):
    x[i], y[i] = map(int, (input().split( )))
roop = []
import itertools
for i in itertools.permutations(range(N), r=2):
    roop.append(i)
aaa = 0
for i in roop:
    aaa += ((x[i[0]] - x[i[1]])**2+(y[i[0]] - y[i[1]])**2)**0.5
print(aaa/N)

### FIXED CODE ###

N = int(input())
x = []
y = []
for i in range(N):
    a,b = map(int, (input().split()))
    x.append(a)
    y.append(b)

aaa = 0
for i in range(N):
    for k in range(N):
        aaa += ((x[i] - x[k])**2+(y[i] - y[k])**2)**0.5
print(aaa/N)
x, y = int(input())
if x % y == 0 or  y % x == 0:
    print(-1)
else:
    print(x * 1)

### FIXED CODE ###

x, y = map(int, input().split())
if x > y:
    if x % y == 0:
        print(-1)
    else:
        print(x * 1)
elif x == y:
    print(-1)
elif x < y:
    print(x * 1)
A, B = map(int,input().split())

one = A/0.08
two = (A+1)/0.08
three = B/0.1
four = (B+1)/0.1


if two <= three or one > four:
    kai = -1
if three <= one and four > one:
    kai = one
if one <= three and four < two:
    kai = three

print(kai)

### FIXED CODE ###

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

count = 0

for n in range(10000):
    za = n*0.08
    zb = n*0.1
    count += 1
    if A == math.floor(za) and B == math.floor(zb):
        print(n)
        break


if count == 10000:
    print(-1)
n=int(input())
a=list(map(int,input().split()))
num=[0]*(max(a)+1)
for i in range(n):
    num[a[i]]+=1
ans=0
for i in range(1,len(a)-1):
    num2=num[i-1]+num[i]+num[i+1]
    if ans<num2:
        ans=num2
print(ans)


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
num=[0]*(max(a)+1)
for i in range(n):
    num[a[i]]+=1
ans=0
if max(a)<3:
    ans=sum(num)
else:
    for i in range(1,max(a)):
        num2=num[i-1]+num[i]+num[i+1]
        if ans<num2:
            ans=num2
print(ans)
d = {"A":1, "B":0, "C":0}
while True:
    try:
        swap1, awap2 = input().split(",")
        d[swap1], d[swap2] = d[swap2], d[swap1]
    except:
        break
print(d.keys()[d.values().index(1)])



### FIXED CODE ###

d = {"A":1, "B":0, "C":0}
while True:
    try:
        swap1, swap2 = input().split(",")
        d[swap1], d[swap2] = d[swap2], d[swap1]
    except:
        break
print(list(d.keys())[list(d.values()).index(1)])
n, k = map(int, input().split())
p = list(map(int, input().split()))
a = sum(p[0:k])
l = [a]
for i in range(n-k):
    a = a-p[i]+p[i+k]
    l.append(a)
print((max(l)+k)/2)

### FIXED CODE ###

n=int(input())
s=list(map(int,input().split()))
d=list(set(s))
if len(s)==len(d):
  print("YES")
else:
  print("NO")
n = int(input())
a = list(map(int,input().split()))
a.sort()
if a>2*a[-1]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
a.sort()
if sum(a)>2*a[-1]:
  print("Yes")
else:
  print("No")
import sys

x = sys.argv[1]

print(x*x*x)

### FIXED CODE ###

print(int(input())**3)
def main():
    import sys
    import numpy as np
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    N, S = [int(x) for x in input().strip().split()]
    An = [int(x) for x in input().strip().split()]
    dp = np.array([[0] * (S + 1) for _ in range(2)], dtype=int)
    dp[0, 0] = 2
    if An[0] <= S:
        dp[0, An[0]] = 1

    for n in range(1, N):
        dp[(n)%2, :] *= 0
        for k in range(S + 1):
            dp[n%2, k] += dp[(n-1)%2, k] * 2
            if k + An[n] > S:
                continue
            dp[n%2, k+An[n]] += dp[(n-1)%2, k]

    print(dp[(N-1)%2, S])
                
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    import sys
    import numpy as np
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    N, S = [int(x) for x in input().strip().split()]
    An = [int(x) for x in input().strip().split()]
    dp = np.zeros((S+1), dtype=int)
    dp[0] = 2
    if An[0] <= S:
        dp[An[0]] = 1

    for n in range(1, N):
        dp *= 2
        dp[An[n]:] += dp[:-An[n]] // 2
        dp %= 998244353

    print(dp[S])
                
if __name__ == '__main__':
    main()
import math
a, b = map(int, input().split())
print(math.floor((a*b) / math.gcd(a, b)))

### FIXED CODE ###

import math
import fractions
a, b = map(int, input().split())
print(math.floor((a*b) / fractions.gcd(a, b)))
N = int(input())
K = int(input())
p = []

for i in range(N):
    x = int(input())
    p.append(x)

p.sort()

y = 0

for i in range(K):
    y += p[i]

print(y)


### FIXED CODE ###

K = list(map(int, input().split()))
p = list(map(int, input().split()))
p.sort()
y = 0
for i in range(K[1]):
    y += p[i]
print(y)
d = {}


def calc_step_combination(num):
    if num <= 0:
        return 0
    if num == 1 or num == 2:
        return 1
    if num in d:
        return d[num]
    res = calc_step_combination(num - 1) + calc_step_combination(num - 2)
    d[num] = res
    return res


def sol(n, a_list):
    step_batch = []
    batch_start = 0
    for a in a_list:
        step_batch.append(a - batch_start)
        batch_start = a + 1
    step_batch.append(n - batch_start + 1)

    result = 1
    for i, steps in enumerate(step_batch):
        result *= calc_step_combination(steps)
    print(result % 1000000007)


def main():
    n, m = map(int, input().split())
    a_list = []
    for i in range(0, m):
        a_list.append(int(input()))
    sol(n, a_list)


main()


### FIXED CODE ###

import sys

sys.setrecursionlimit(110000)

d = {}


def calc_step_combination(num):
    if num == 0:
        return 0
    if num == 1 or num == 2:
        return 1
    if num in d:
        return d[num]
    res = calc_step_combination(num - 1) + calc_step_combination(num - 2)
    d[num] = res
    return res


def sol(n, a_list):
    step_batch = []
    batch_start = 0
    for a in a_list:
        step_batch.append(a - batch_start)
        batch_start = a + 1
    step_batch.append(n - batch_start + 1)

    result = 1
    for i, steps in enumerate(step_batch):
        result *= calc_step_combination(steps)
    print(result % 1000000007)


def main():
    n, m = map(int, input().split())
    a_list = []
    for i in range(0, m):
        a_list.append(int(input()))
    sol(n, a_list)


main()
n = int(input())
A_list = list(map(int, input().split()))
for i in range(n):
    A_list[i] -= i
A_list.sort()
A_cum = [0] * n
for i in range(n):
    if i == 0:
        A_cum[0] = A_list[0]
    else:
        A_cum[i] = A_cum[i-1] + A_list[i]

def findinfindex(sortedlist, key, l, r):
    if r - l <= 0:
        return l
    m = (l+r+1)//2
    if sortedlist[m] > key:
        return findinfindex(sortedlist, key, l, m-1)
    else:
        return findinfindex(sortedlist, key, m, r)

sadmin = -1
for b in range(A_list[n//2],A_list[(n+1)//2]+1):
    lastminus = findinfindex(A_list, b, 0, n-1)
    sadness = (2*lastminus - n + 2)*b - 2*A_cum[lastminus] + A_cum[n-1]
    if sadmin == -1:
        sadmin = sadness
    elif sadness < sadmin:
        sadmin = sadness
    else:
        break
print(sadmin)


### FIXED CODE ###

n = int(input())
A_list = list(map(int, input().split()))
for i in range(n):
    A_list[i] -= i
A_list.sort()

def sadness(a, mid):
    sad = 0
    for i in range(mid):
        sad += a[mid] - a[i]
    for i in range(mid+1,len(a)):
        sad += a[i] - a[mid]
    return sad

if n % 2 != 0:
    print(sadness(A_list, n//2))
else:
    print(min(sadness(A_list, n//2), sadness(A_list, n//2+1)))
def run():
  N, X = map(int, input().split())
  y = N-X
  ans = y+X
  while True:
    a = y//X
    ans += a*X*2
    if y%X == 0:
      break
    y, X = max(X, a), min(X, a)
  print(ans-X)
  
  
if __name__ == '__main__':
  run()

### FIXED CODE ###

def run():
  N, X = map(int, input().split())
  y = N-X
  ans = N
  while True:
    y, X = max(y, X), min(y, X)
    a = y//X
    b = y%X
    ans += a*X*2
    if b == 0:
      break
    y, X = X, b
  print(ans-X)
  
  
if __name__ == '__main__':
  run()
import sys

def input():
    return sys.stdin.readline()[:-1]


n = int(input())

max_x = int(((2*n-3)**0.5-1)//1)
list_count = [0]*n
for x in range(1,max_x+1):
    for y in range(x, max_x+2-x):
        for z in range(y, max_x+2-x-y):
            s = x**2+y**2+z**2+x*y+y*z+z*x
            if s>=n:
                continue
            if len(set([x,y,z]))==3:
                list_count[s-1] += 6
            elif len(set([x,y,z]))==2:
                list_count[s-1] += 3
            else:
                list_count[s-1] += 1
for i in range(n):
    print(list_count[i])




### FIXED CODE ###

import sys

def input():
    return sys.stdin.readline()[:-1]


n = int(input())
if n==1:
    print(0)
else:
    max_x = int(((2*n-3)**0.5-1)//1)
    list_count = [0]*n
    for x in range(1,max_x+1):
        for y in range(1, max_x+2-x):
            for z in range(1, max_x+2-x-y):
                s = x**2+y**2+z**2+x*y+y*z+z*x
                if s>n:
                    continue
                else:
                    list_count[s-1] += 1
    for i in range(n):
        print(list_count[i])
N = int(input())
A = list(map(int, input().split()))

a=A[0]; c=1; i=1; w=0
def f(x):
    return A[x], x+1

while True:
    if w==0:
        if A[i]==a:
            a,i=f(i)
        elif A[i] > a:
            w=1; a,i=f(i)
        else:
            w=-1; f(i)
    elif w>0:
        if A[i]>=a:
            a,i=f(i)
        else:
            c+=1; a,i=f(i); w=0
    elif w<0:
        if A[i]<=a:
            a,i=f(i)
        else:
            c+=1; a,i=f(i); w=0
    if i==N:
        break

print(c)


### FIXED CODE ###

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

c = 1; w = 0
for i in range(N-1):
    if w == 0:
        if A[i] < A[i+1]:
            w = 1
        elif A[i] > A[i+1]:
            w = -1
    elif (w > 0 and A[i] > A[i+1]) or (w < 0 and A[i] < A[i+1]):
         w = 0
         c += 1

print(c)
A,B,C = input().split()
print(A.upper[0]+B.upper[0]+C.upper[0])

### FIXED CODE ###

A,B,C = input().split()
print(A.upper()[0]+B.upper()[0]+C.upper()[0])
k=int(input())
if k%2==0:
  print(n**2/4)
else:
  print((n**2-1)/4)

### FIXED CODE ###

k=int(input())
if k%2==0:
  print(k**2//4)
else:
  print((k**2-1)//4)
import queue
r,c=map(int,input().split())
#sy,sx=map(int,input().split())
#gy,gx=map(int,input().split())
a=[list(input()) for i in range(r)]
sy,sx = (1,1)
#gy,gx = (2,2)
def minload(sy,sx,a):
    sy-=1
    sx-=1
    #gy-=1
    #gx-=1
    q = queue.Queue()
    d=[(-1,0),(1,0),(0,-1),(0,1)]
    a[sy][sx]=0
    for i in d:
        if 0<=sy+i[0]<r and 0<=sx+i[1]<c and a[sy+i[0]][sx+i[1]]==".":
            a[sy+i[0]][sx+i[1]]=1
            q.put((sy+i[0],sx+i[1]))
    while True:
        if queue.Queue.empty(q):
            break
        y,x=q.get()
        #if y==r and x==c:
            #break
        for i in d:
            if 0<=y+i[0]<r and 0<=x+i[1]<c and a[y+i[0]][x+i[1]]==".":
                a[y+i[0]][x+i[1]]=a[y][x]+1
                q.put((y+i[0],x+i[1]))
    #print(a[gy][gx])
    max = 0
    for i in a:
        for j in i:
            if j != '#' and j !='.':
                if j > max:
                    max = j
    return(max)
ans = 0
for sy in range(1,r+1): 
    for sx in range(1,c+1):
        b = []
        for i in a:
            b.append(list(i))
        if a[sy-1][sx-1]==".":
            local_max = minload(sy,sx,b)
            #print(local_max)
            #print(b)
        if local_max > ans:
            ans = local_max
print(ans)

### FIXED CODE ###

import queue
r,c=map(int,input().split())
#sy,sx=map(int,input().split())
#gy,gx=map(int,input().split())
a=[list(input()) for i in range(r)]
sy,sx = (1,1)
#gy,gx = (2,2)
def minload(sy,sx,a):
    sy-=1
    sx-=1
    #gy-=1
    #gx-=1
    q = queue.Queue()
    d=[(-1,0),(1,0),(0,-1),(0,1)]
    a[sy][sx]=0
    for i in d:
        if 0<=sy+i[0]<r and 0<=sx+i[1]<c and a[sy+i[0]][sx+i[1]]==".":
            a[sy+i[0]][sx+i[1]]=1
            q.put((sy+i[0],sx+i[1]))
    while True:
        if queue.Queue.empty(q):
            break
        y,x=q.get()
        #if y==r and x==c:
            #break
        for i in d:
            if 0<=y+i[0]<r and 0<=x+i[1]<c and a[y+i[0]][x+i[1]]==".":
                a[y+i[0]][x+i[1]]=a[y][x]+1
                q.put((y+i[0],x+i[1]))
    #print(a[gy][gx])
    max = 0
    for i in a:
        for j in i:
            if j != '#' and j !='.':
                if j > max:
                    max = j
    return(max)
ans = 0
for sy in range(1,r+1): 
    for sx in range(1,c+1):
        b = []
        for i in a:
            b.append(list(i))
        if a[sy-1][sx-1]==".":
            local_max = minload(sy,sx,b)
            #print(local_max)
            #print(b)
        else:
            local_max = 0
        if local_max > ans:
            ans = local_max
print(ans)
n = int(input())
S,H,C,D = [0 for i in range(13)]
for i in range(n):
	data = input().split()
	num = int(data[1])
	if data[0]=='S':
		S[num-1] = 1
	elif data[0]=='H':
		H[num-1] = 1
	elif data[0]=='C':
		C[num-1] = 1
	else:
		D[num-1] = 1
for j in range(13):
	if S[j]==0:
		print('S %d' % (j+1))
for j in range(13):
	if H[j]==0:
		print('H %d' % (j+1))
for j in range(13):
	if C[j]==0:
		print('C %d' % (j+1))
for j in range(13):
	if D[j]==0:
		print('D %d' % (j+1))


### FIXED CODE ###

n = int(input())
S = [0 for i in range(13)]
H = [0 for i in range(13)]
C = [0 for i in range(13)]
D = [0 for i in range(13)]
for i in range(n):
	data = input().split()
	num = int(data[1])
	if data[0]=='S':
		S[num-1] = 1
	elif data[0]=='H':
		H[num-1] = 1
	elif data[0]=='C':
		C[num-1] = 1
	else:
		D[num-1] = 1
for j in range(13):
	if S[j]==0:
		print('S %d' % (j+1))
for j in range(13):
	if H[j]==0:
		print('H %d' % (j+1))
for j in range(13):
	if C[j]==0:
		print('C %d' % (j+1))
for j in range(13):
	if D[j]==0:
		print('D %d' % (j+1))
def g(n):
    D = [[0]*10 for i in range(10)]
    for i in range(1,n+1):
        si = str(i)
        D[int(si[0])][int(si[-1])] += 1

    res = 0
    for i in range(10):
        for j in range(10):
            res += D[i][j]*D[j][i]
    return res
print(g(int(n)))


### FIXED CODE ###

def g(n):
    D = [[0]*10 for i in range(10)]
    for i in range(1,n+1):
        si = str(i)
        D[int(si[0])][int(si[-1])] += 1

    res = 0
    for i in range(10):
        for j in range(10):
            res += D[i][j]*D[j][i]
    return res
print(g(int(input())))
import numpy as np
H, W = map(int, raw_input().split())
h, w = map(int, raw_input().split())

print int((H-h)*(W-w)     

### FIXED CODE ###

import numpy as np
H, W = map(int, raw_input().split())
h, w = map(int, raw_input().split())

print int((H-h)*(W-w))
n = input()
minSeq = input()
maxv = -float("inf")
for i in range(n):
    R = input()
    if R - minSeq > maxv:
        maxv = R - minSeq
    if R < minSeq:
        minSeq = R
print(maxv)

### FIXED CODE ###

n = input()
minSeq = input()
maxv = -float("inf")
for i in range(n-1):
    R = input()
    if R - minSeq > maxv:
        maxv = R - minSeq
    if R < minSeq:
        minSeq = R
print(maxv)
import queue
K = int(intut())
q = queue.Queue()
ans = 0
for i in range(9):
  q.put(i + 1)
for i in range(K):
  ans = q.get()
  if tmp % 10 == 0:
    q.put(10 * tmp)
    q.put(10 * tmp + 1)
  elif tmp % 10 == 9:
    q.put(10 * tmp + 8)
    q.put(10 * tmp + 9)
  else:
    for t in range(-1,2):
      q.put(10 * tmp + tmp % 10 + t)
print(ans)


### FIXED CODE ###

import queue
K = int(input())
q = queue.Queue()
count = 0
for i in range(1,10):
  q.put(str(i))
while count < K:
  tmp = q.get()
  count += 1
  if count == K:
    print(tmp)
    break
  if tmp[-1] == '0':
    for add in ['0', '1']:
      q.put(tmp + add)
  elif tmp[-1] == '9':
    for add in ['8', '9']:
      q.put(tmp + add)
  else:
    for add in [str(int(tmp[-1]) - 1),tmp[-1], str(int(tmp[-1]) + 1)]:
      q.put(tmp + add)
a = int(input())
b = int(input())
print(len(str(a+b)))

### FIXED CODE ###

while True:
    try:
        a,b=map(int,input().split(' '))
        print(len(str(a+b)))
    except:
        break
S = input()
K = int(input())
if S[0] == "1":
    print(S[1])
else:
    print(S[0])


### FIXED CODE ###

S = list(input())
K = int(input())
for i in range(K):
    if S[i] != "1":
        print(S[i])
        break
else:
    print("1")