Harryxun/stf_run huggingface dataset:
h,w = map(int,input().split())
Array = [list(map(str,input())) for _ in range(h)]
dx = [1,1,0,-1,-1,-1,0,1]
dy = [0,1,1,1,0,-1,-1,-1]
for i in range(h):
  for j in range(w):
    if Array[i][j]='#':
      continue
    num=0
    for d in range(8):
      ni = i+dy[d]
      nj = j+dx[d]
      if ni<0 or h<=ni:
        continue
      if nj<0 or w<=nj:
        continue
      if Array[ni][nj]=='#':
        num=num+1
    Array[i][j]=str(num)
    
for i in Array:
  print(*i,sep='')

### FIXED CODE ###

h,w = map(int,input().split())
Array = [list(map(str,input())) for _ in range(h)]
dx = [1,1,0,-1,-1,-1,0,1]
dy = [0,1,1,1,0,-1,-1,-1]
for i in range(h):
  for j in range(w):
    if Array[i][j]=='#':
      continue
    num=0
    for d in range(8):
      ni = i+dy[d]
      nj = j+dx[d]
      if ni<0 or h<=ni:
        continue
      if nj<0 or w<=nj:
        continue
      if Array[ni][nj]=='#':
        num=num+1
    Array[i][j]=str(num)
    
for i in Array:
  print(*i, sep='')
def main():
    with open("input.txt", "r") as f:
#        t = f.readlines()
#        N = int(t[0].split()[0])
#        K = int(t[0].split()[1])
#        h = t[1].split()
    N, K  = map(int, input().split())
    h = list(map(int, input().split()))
#    print(h)
#    print(len(h))
    dp = [10**9] * max(N,K)
    dp[0] = 0

    for i in range(N):
        j = 0
        L = min(K, i)
        while j <= L:
            #print(i)
            if dp[i] > dp[i-j] + abs(int(h[i])-int(h[i-j])):
                dp[i] = dp[i-j] + abs(int(h[i])-int(h[i-j]))
            j += 1
    print(dp[N-1])

if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    N, K  = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [10**9] * N
    dp[0] = 0

    for i in range(N):
        dp[i] = min([dp[i-j] + abs(h[i]-h[i-j]) for j in range(min(K,i)+1)])
    print(dp[N-1])

if __name__ == "__main__":
    main()
N = int(input())
B = list(map(int,input().split()))
A = []

for i in range(len(B)):

    if i==0:
        if B[i]<B[i+1] or B[i]==B[i+1]:

            A.extend(B[:1]*2)

        elif B[i]>B[i+1]:

            A.extend(B[1:2]*2)
            
        

    elif i<len(B)-1 and B[i]>B[i+1]:

        A.append(B[i+1])

    else:

        A.append(B[i])
            
        

    
from functools import reduce

print(reduce(lambda x,y : x+y,A))

### FIXED CODE ###

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

mx = 0

for i in range(len(B)):

    if i==0 :

        if len(B)==1 :

            mx += B[0]*2

        else:

            if B[i] > B[i+1]:

                mx += B[i]+B[i+1]

            else:

                mx += B[i]*2

    elif i>0 :

        if i != len(B)-1:

            if B[i] < B[i+1]:

                mx += B[i]

            elif B[i] >= B[i+1]:

                mx += B[i+1]

        elif i == len(B)-1:

            mx += B[i]

print(mx)
from fractions import Fraction
a, b = input().split()
b = Fraction(b)
ans = Fraction(a*b)
ans = ans // 1
print(int(ans))

### FIXED CODE ###

from fractions import Fraction
a, b = input().split()
A = int(a)
B = Fraction(b)
ans = A*B
ans = ans // 1
print(int(ans))
N,K,M=map(int,input().split())
point = list(map(int,input().split()))
full = N*K
tar = M*N
all_p = sum(point)

if full- all_p >full-K:
    print(-1)
else:
    print(full-K-sum(point))

### FIXED CODE ###

C = str(input())
Z='abcdefghijklmnopqrtuvwxyz'
alpha = list(Z)
l_in = [alpha[i+1] for i in range(len(alpha)-1) if C in alpha[i]]
print(l_in[0])
def progress():
    for i in range(N):
        hp = A[i]
        for j in range(N):
            if i == j:
                continue
            if A[i] > A[j]:
                A[i] -= A[j]
                progress()
            if min(A) == 1:
                break
        if min(A) == 1:
            break
    return min(A)

ans = progress()
print(ans)

### FIXED CODE ###

import fractions

N = int(input())
A = list(map(int, input().split()))
B = 0
for i in range(N):
    B = fractions.gcd(B, A[i])
print(B)
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

N, M = map(int, input().split())
edge = np.array([input().split() for _ in range(M)], dtype = np.int64)
edge = sorted(edge,key=lambda x:(x[0],x[1],x[2]))

edge2 = np.array(edge[0])
for i in range(1,M):
  if edge[i][0] == edge[i-1][0] and edge[i][1] == edge[i-1][1]:
    continue
  edge2 = np.vstack([edge2,edge[i]])

x = np.arange(N,1,-1)
y = np.arange(N-1,0,-1)
z = np.zeros(N-1,int)
X = np.vstack([x,y,z]).T
edge2 = np.concatenate([X,edge2]).T
graph = csr_matrix((edge2[2], (edge2[:2] - 1)), (N, N))
distance_mat = dijkstra(graph, directed = True, indices = 0)
#print(distance_mat)
print(-1 if distance_mat[-1] == float("inf") else int(distance_mat[-1]))

### FIXED CODE ###

import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N, M = map(int, readline().split())
lines = readlines()
edge = np.array([line.split() for line in lines], dtype = np.int64)
edge = sorted(edge,key=lambda x:(x[0],x[1],x[2]))

for i in range(1,M):
  if edge[i][0] == edge[i-1][0] and edge[i][1] == edge[i-1][1]:
    edge[i][2] = 0
#print(edge)
x = np.arange(N,1,-1)
y = np.arange(N-1,0,-1)
z = np.zeros(N-1,int)
X = np.vstack([x,y,z]).T
edge = np.concatenate([X,edge]).T
graph = csr_matrix((edge[2], (edge[:2] - 1)), (N, N))
distance_mat = dijkstra(graph, directed = True, indices = 0)
#print(distance_mat)
print(-1 if distance_mat[-1] == float("inf") else int(distance_mat[-1]))
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

### 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
n,m=map(int,input().split())
potion=[]
for i in range(N):
    potion_R = list(map(int,input().split())
    potion.append(potion_R)
potion.sort()
ans=0
number=m
for i in potion:
    if i[1]<=number:
        number-= i[1]
        ans+= i[0]*i[1]
    else:
        ans+= i[0]*number
        break
print(ans)

### FIXED CODE ###

n,m=map(int,input().split())
potion=[]
for i in range(n):
    potion_R = list(map(int,input().split()))
    potion.append(potion_R)
potion.sort()
ans=0
number=m
for i in potion:
    if i[1]<=number:
        number-= i[1]
        ans+= i[0]*i[1]
    else:
        ans+= i[0]*number
        break
print(ans)
A,B = list(map(int,input().split()))
B - A = C
if C % (A-1) == 0:
  print(C//(A-1)+1)
else:
  print(C//(A-1)+2)

### FIXED CODE ###

A,B = list(map(int,input().split()))
C = B - A
if C % (A-1) == 0:
  print(C//(A-1)+1)
else:
  print(C//(A-1)+2)
n = int(input())
s = input()

from collections import Counter
left = Counter('')
right = Counter(s[1:])

ans = set()
for i in range(10):
    lefts[str(i)] = []
    rights[str(i)] = []

for i in range(1, n-1):
    left[s[i-1]] += 1
    right[s[i]] -= 1
    # print(left, right)

    left_u = []
    for k in left.keys():
        if left[k] >= 1:
            left_u.append(k)
    right_u = []
    for k in right.keys():
        if right[k] >= 1:
            right_u.append(k)

    for l in left_u:
        for r in right_u:
            tmp = l + s[i] + r
            ans.add(tmp)

print(len(ans))


### FIXED CODE ###

n = int(input())
s = input()

from collections import Counter
left = Counter('')
right = Counter(s[1:])

ans = set()
for i in range(1, n-1):
    left[s[i-1]] += 1
    right[s[i]] -= 1
    # print(left, right)

    left_u = []
    for k in left.keys():
        if left[k] >= 1:
            left_u.append(k)
    right_u = []
    for k in right.keys():
        if right[k] >= 1:
            right_u.append(k)

    for l in left_u:
        for r in right_u:
            tmp = l + s[i] + r
            ans.add(tmp)

print(len(ans))
n = int(input())

one = n % 10
hund = n // 100
thou = n // 1000
cnt = 0

if  n < 10:
    cnt += n

elif 100 > n >= 10:
    cnt += 9

elif 1000 > n >= 100:
    cnt += (n - 99) + 9

elif 10000 > n >= 1000:
    cnt += 909

elif 100000 > n >= 10000:
    cnt += (n - 9999) + 909

elif n = 100000:
    cnt += 90909

print(cnt)


### FIXED CODE ###

n = int(input())

one = n % 10
hund = n // 100
thou = n // 1000
cnt = 0

if  n < 10:
    cnt += n

elif 100 > n >= 10:
    cnt += 9

elif 1000 > n >= 100:
    cnt += (n - 99) + 9

elif 10000 > n >= 1000:
    cnt += 909

elif 100000 > n >= 10000:
    cnt += (n - 9999) + 909

elif n == 100000:
    cnt += 90909

print(cnt)
a,b=map(int,input().split())
lst={0:0,1:300000,2:200000,3:1000000}
if a>4:
    x=0
else:
    x=a
if b>4:
    y=0
else:
    y=b
if x==1 and y==1:
    ans=1000000
else :
    ans=lst[x]+lst[y]


print(ans)

### FIXED CODE ###

a,b=map(int,input().split())
lst={0:0,1:300000,2:200000,3:100000}
if a>3:
    x=0
else:
    x=a
if b>3:
    y=0
else:
    y=b
if x==1 and y==1:
    ans=1000000
else :
    ans=lst[x]+lst[y]


print(ans)
a = 1
b = 1
while True:
	if a != 10:
		while True:
			print(str(a) + 'x' + str(b) + '=' + str(a*b))
			b += 1
			if b != 10:
				continue
			else:
				b = 1
				a += 1
				break
		continue
	else:
	break

### FIXED CODE ###

a = 1
b = 1
while True:
	if a != 10:
		while True:
			print(str(a) + 'x' + str(b) + '=' + str(a*b))
			b += 1
			if b != 10:
				continue
			else:
				b = 1
				a += 1
				break
		continue
	else:
		break
visit_list = []


def topological_sort():
    for s in range(n):
        if color[s] == 0:
            dfs(s)

def dfs(u):
    color[u] = 1
    for v in graph[u]:
        if color[v] == 0:
            dfs(v)
    visit_list.append(u)        
 
 
n = int(input())
color = [0] * n
graph = [[] * n for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    graph[a].append(b)
    graph[b].append(a)    

topological_sort()
c = [int(i) for i in input().split()]
c.sort()
t_list = [[visit_list[i], c[i]] for i in range(n)]
t_list.sort()
print(sum(c[:-1]))
a_list = [str(t[1]) for t in t_list]
print(" ".join(a_list))

### FIXED CODE ###

n = int(input())
graph = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)
c = [int(i) for i in input().split()]
c.sort()
c.reverse()
ans_list = [0 for _ in range(n)]
ans = 0
p_list = [0]
ans_list[0] = c.pop(0)
while len(p_list) > 0:
    p = p_list.pop(0)
    for g in graph[p]:
        if ans_list[g] == 0:
            ans_list[g] = c.pop(0)
            ans += ans_list[g]
            p_list.append(g)
print(ans)
print(' '.join([str(i) for i in ans_list]))
N = int(input())
lst = [int(input()) for _ in range(N)]


def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


def lcm(x, y):
    return x * y // gcd(max(x, y), min(x, y))


ret = lcm(lst[0], lst[1])
for x in lst[2:]:
    ret = lcm(ret, x)
print(ret)


### FIXED CODE ###

N = int(input())
lst = [1] + [int(input()) for _ in range(N)]


def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


def lcm(x, y):
    return x * y // gcd(max(x, y), min(x, y))


ret = lcm(lst[0], lst[1])
for x in lst[2:]:
    ret = lcm(ret, x)
print(ret)
n = int(input())
d_lis = [int(d) for d in input().split()]
ans = 0
c = 0
li = sorted(li)
for a in set(li):
    if a > li[n // 2] and a <= li[(n // 2) + 1]:
        b = a
        c = 1
if c == 1:
    ans = li[(n // 2) + 1] - b + 1
    print()

### FIXED CODE ###

n = int(input())
d_lis = list(map(int,input().split()))
li = sorted(d_lis)
mid = n // 2
print(li[mid] - li[mid-1])
import sys
N = int(input())
X = [int(_) for _ in input().split()]
ans_list = []
if N == 1:
    print('0')
    sys.exit()
for i in range(min(X), max(X)):
    ans = 0
    for j in X:
        ans += (j - i) ** 2
    ans_list.append(ans)

print(min(ans_list))


### FIXED CODE ###

import sys
N = int(input())
X = [int(_) for _ in input().split()]
ans_list = []
if N == 1:
    print('0')
    sys.exit()
for i in range(min(X), max(X) + 1):
    ans = 0
    for j in X:
        ans += (j - i) ** 2
    ans_list.append(ans)

print(min(ans_list))
A, B, C = map(int, input().split(' '))

if A == B and B == C:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

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

if A == B and B == C:
    print('Yes')
else:
    print('No')
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
b, = map(int, input())
print(a[b-1])

### FIXED CODE ###

a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
b = int(input())
print(a[b-1])
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
def fibo(i):
    a, b = 1, 0
    while i > 0:
        a, b = a + b, a
        i -= 1
    return a
m = a[0] + 1
num = fibo(m - 2)
for i in range(M - 1):
    m = a[i + 1] - a[i]
    num = num * fibo(m - 2)
    if m == 1:
        num = 0
        break
num = num * fibo(N - a[M - 1] - 1)
print(num % 1000000007)


### FIXED CODE ###

N, M = map(int, input().split())
kaidan = [0] * (N + 1)
for i in range(M):
    tmp = int(input())
    kaidan[tmp] = -1
kaidan[0] = 1
for i in range(1,N + 1):
    if i == 1:
        if kaidan[i] != -1:
            kaidan[i] = 1
        else:
            kaidan[i] = 0
    else:
        if kaidan[i] != -1:
            kaidan[i] = kaidan[i -1] + kaidan[i - 2]
        else:
            kaidan[i] = 0
print(kaidan[N] % (10 ** 9 + 7))
N = input()
A = map(int, input().split())

print({:16g}.format(1/sum(1/x for x in A)))

### FIXED CODE ###

N = int(input())
A = map(int, input().split())
print('{:.16g}'.format(1 / sum(1 / x for x in A)))
import math
A, B = map(int, input().split())

print(A*B//math.gcd(A, B))


### FIXED CODE ###

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

print(A*B//fractions.gcd(A, B))
n,m=list(map(int,input().split()))
a=list(map(int,input().split()))
a.sort(reverse=True)

cnt=0
for j in range(n):
    cnt+=a[j]

b=[]
for i in range(n):
    if a[i]>(cnt*(1/(4*m))):
        b.append(a[i])

if len(b) > m:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a,b,c=list(map(int,input().split()))

a,b=b,a
a,c=c,a
print(a,b,c)
a,b,x=map(int,input().split())
import math
print(90-math.degrees(math.atan(a/2/(b-x/a**2))))


### FIXED CODE ###

import math
a,b,x=map(int,input().split())
S=x/a
if S<=a*b/2:
    h=2*S/b
    answer=math.degrees(math.atan(b/h))
    print(answer)
else:
    T=a*b-S
    h=2*T/a
    answer=math.degrees(math.atan(h/a))
    print(answer)
import sys
#入力管理
lines, rows = map(int, input().split())
mapmap = []

for i in range(lines):
    mapmap.append(list(input()))

#最初の黒点探し
for i in range(lines):
    for j in range(rows):
        if mapmap[i][j] == '#':
            break
            
if mapmap[i][j] == '.'    
    print('No')
    sys.exit()

startl, startr = i, j

#動き
move_x = [1, -1, 0, 0]
move_y = [0, 0, 1, -1]
Stack = [[startl, startr]]

#探索開始
while Stack:
   x, y= Stack.pop()#今現在の位置
   #現在位置を変換
   mapmap[x][y] = '.'

   for i in range(len(move_x)):
       nx = x + move_x[i]
       ny = y + move_y[i]

       if 0 <= nx and nx < lines and 0 <= ny and ny < rows:
           if mapmap[nx][ny] == '#':
               Stack.append([nx, ny])


#黒点探し
for i in range(lines):
    for j in range(rows):
        if mapmap[i][j] == '#':
            print('No')
            sys.exit()

print('Yes')

### FIXED CODE ###

import sys

line_size, row_size = map(int, input().split())
mapmap = []#地図初期化

for i in range(line_size):
    mapmap.append(list(input()))

#探索
def Start_check(mapmap, px, py):
    start_flg = False
    move_x = [1, -1, 0, 0]
    move_y = [0, 0, 1, -1]
    for i in range(4):#動ける範囲で探索
        nx = px + move_x[i]
        ny = py + move_y[i]
        if 0 <= nx and nx < line_size and 0 <= ny and ny < row_size:
            if mapmap[nx][ny] == '#':#もし黒塗りなら
                start_flg = True
    
    if start_flg == False:
        print('No')
        sys.exit()

#Main
count = 0#探索回数（塗り絵した回数）
for i in range(line_size):
    for j in range(row_size):
        if mapmap[i][j] == '#':
            Start_check(mapmap, i, j)
            count += 1

#何もしなかった場合
print('Yes')
x, n = map(int, input().split())
if n != 0:
  p = list(map(int, input().split()))
else:
  input()
  print(x)

# x, n = 10, 5
# p =  [4, 7, 10, 6, 5]
# ->9が解
# x, n = 6, 5
# p = [4, 7, 10, 6, 5]

# pに含まれない整数リストを、最小値-1最大値+1も含めて求める
pl = min(p)-1
pr = max(p)+2
npl = list(range(pl, pr))
np = list(set(npl) - set(p))
np.sort()

# np内で最もxに近い数値を算出する
mx = x
res = x
for k in np:
  t = abs(k - x)
  if t < mx:
    mx = t
    res = k
 
print(res)

### FIXED CODE ###

x, n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
  print(x)
  exit()
  
# x, n = 10, 5
# p =  [4, 7, 10, 6, 5]
# ->9が解
# x, n = 6, 5
# p = [4, 7, 10, 6, 5]

# x, n = 1, 1
# # p = list(range(1, 101))
# p = [1]

# pに含まれない整数リストを、最小値-1最大値+1も含めて求める
pl = min(p)-1
pr = max(p)+2
npl = list(range(pl, pr))
np = list(set(npl) - set(p))
if len(np) == 0:
  print(x)
  exit()
np.sort()

# np内で最もxに近い数値を算出する
mx = x
res = np[0]
for k in np:
  t = abs(k - x)
  if t < mx:
    mx = t
    res = k
 
print(res)
def sigma(c):
    if c == 1:
        return 1
    elif c == 0:
        return 0
    else:
        return c + sigma(c-1)

n = int(input())
sn = {}
sn_list = []
for i in range(n):
    s = input()
    sn_list.append(s)
for s in sn_list:
    s = "".join(sorted(s))
    if not(s in sn):
        sn[s] = 0
    else:
        sn[s] += 1
        
        
count = 0
for v in sn.values():
    count += sigma(v)
print(count)

### FIXED CODE ###

def main():
    n = int(input())
    array_s = []
    array = []
    for i in range(n):
        array_s.append(input())
 
    for s in array_s:
        array.append(''.join(sorted(s)))
    array = sorted(array)
    ans = 0
    count = 1
    for i in range(n-1):
        if array[i] == array[i+1]:
            count += 1
            if i != n-2:
                continue
        ans += int(count*(count-1)/2)
        count = 1
    print(ans)
 
 
if __name__ == '__main__':
    main()
x,a=map(int,input().split())
b=0
c=0
A=list(map(int,input().split()))
while b<=a:
    b=b+A[c]
    c+=1
print(c)

### FIXED CODE ###

a,b=map(int,input().split())
l=list(map(int,input().split()))
c=1
d=0
r=len(l)
for i in range(r):
    d=d+l[i]
    if d<=b:
        c=c+1
 
        
print(c)
n=map(int,input())
lst=len(set(map(int,input(split))))
if n==lst:
    print("YES")
else:  print("NO")

### FIXED CODE ###

n=input()
lst=input().split()
if len(lst)==len(set(lst)):
    print("YES")
else: print("NO")
N=int(input())
ans=int(sqrt(N))
print(ans**2)

### FIXED CODE ###

import math
N=int(input())
ans=int(math.sqrt(N))
print(ans**2)
K = int(input())
arr = list(map(int, input()))
a = arr[1] % K
b = arr[1] - arr[0]
if a > b:
    print("OK")
else:
    print("NG")


### FIXED CODE ###

K = int(input())
arr = list(map(int, input().split()))
a = arr[1] % K
b = arr[1] - arr[0]
if a <= b:
    print("OK")
else:
    print("NG")
from functools import lru_cache
N = int(input())
A = list(map(int, input().split()))


@lru_cache(maxsize=None)
def rec(i, reverse):
    if i == N - 1:
        return A[i] * reverse

    num_normal = rec(i + 1, +1) + (A[i] * reverse)
    num_reverse = rec(i + 1, -1) + (-A[i] * reverse)

    return max(num_normal, num_reverse)


print(rec(0, 1))


### FIXED CODE ###

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

minus_count = 0

for a in A:
    if a < 0:
        minus_count += 1

total = 0
min_num = 10 ** 9

for a in A:
    total += abs(a)
    min_num = min(min_num, abs(a))

if minus_count % 2 == 1:
    total -= 2 * min_num

print(total)
A, B, K = map(int, input().split())
lista = [a for a in range(1, A + 1) if A % a == 0]
listb = [b for b in range(1, B + 1) if B % b == 0]
listc = list(set(lista) & set(listb))
#print(lista)
#print(listb)
#print(listc)

print(listc[K])


### FIXED CODE ###

A, B, K = map(int, input().split())
lista = [a for a in range(1, A + 1) if A % a == 0]
listb = [b for b in range(1, B + 1) if B % b == 0]
listc = sorted(list(set(lista) & set(listb)))
#print(lista)
#print(listb)
#print(listc)

print(listc[-K])
x,y,z,k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a = sorted(a)
b = sorted(b)
c = sorted(c)
memory = []
ai = x-1
bi = y-1
ci = z-1
p = 10**11
while k>0:
    ps = []
    abc = []
    for dx in range(-5,5):
        for dy in range(-5,5):
            for dz in range(-5,5):
                if not (ai+dx>=0 and ai+dx<x and bi+dy>=0 and bi+dy<y and ci+dz>=0 and ci+dz<z):
                    continue
                tmp = a[ai+dx]+b[bi+dy]+c[ci+dz]
                if p >= tmp and not (ai+dx,bi+dy,ci+dz) in memory:
                    ps.append(tmp) 
                    abc.append((ai+dx, bi+dy, ci+dz))
    p = max(ps)
    i = ps.index(p)
    memory.append(abc[i])
    print(p)
    k -= 1


### FIXED CODE ###

def main():
    X, Y, Z, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)

    T = []
    for a in A:
        for b in B:
            T.append(a + b)

    T = sorted(T, reverse=True)[:min(K, len(T))]

    res = []
    for t in T:
        for c in C:
            res.append(t + c)

    res = sorted(res, reverse=True)[:K]
    for r in res:
        print(r)

if __name__ == "__main__":
    main()
N = str(input())

a = []
for n in range(N):
  a.append(int(N[n]))
  
if sum(a) % 9 == 0:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

N = str(input())
 
a = []
for n in range(len(N)):
  a.append(int(N[n]))
  
if sum(a) % 9 == 0:
  print('Yes')
else:
  print('No')
const fs = require('fs');
const input = fs.readFileSync('/dev/stdin', 'utf8');

const [a, b, c] = input.split(" ").map((s) => parseInt(s, 10));

// ya + vb < Vc
// a + 2yab + b < c
// 2/ab < c - a - b
// c - a - b A5 false
// 4ab < (c - a - b)^2

// console.log(Number.MAX_SAFE_INTEGER);
// expected output: 9007199254740991

//const [a, b, c] = [249999999, 250000000, 999999998];

const d = BigInt(c - a - b);
if (d <= 0) {
  console.log("No");
} else {
  console.log((4 * a) * b < d * d ? "Yes" : "No");
}


### FIXED CODE ###

A, B = input().split()
A = int(A)
B = int(B.replace(".", ""))
print(A * B // 100)
using namespace std;
int main()
int a,b,c,d;
cin >>a>>b>>c>>d;
if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d)) puts("Yes");
else puts("No");

### FIXED CODE ###

a, b, c, d = map(int, input().split())

if d >= abs(a - c) or (d >= abs(a - b) and d >= abs(b - c)):
    print('Yes')
else:
    print('No')
import sys

while True:
    s = input()

    if s == '':
        continue
    elif len(str(s)) >= 10:
        continue
    else:
        s_input = [x for x in s]

    s_output = []

    for n in s_input:
        if n == '1' or n == '0':
            s_output.append(n)
        elif n == 'B':
            backspace = len(s_output)-1
            s_output = s_output[:backspace]

    if '0'  or '1' in s_output:
        print(''.join(s_output))
        break

sys.exit()


### FIXED CODE ###

s = input()
output = []

for n in range(len(s)):
    if s[n] == '1' or s[n] == '0':
        output.append(s[n])
    elif s[n] == 'B' and output != []:
        backspace = len(output)-1
        output = output[:backspace]
print(''.join(output))
a=int(input())
b=int(input())
c=int(input())

if a=b=c:
  print(1)
elif a=b or b=c or c=a:
  print(2)
else:print(3)

### FIXED CODE ###

a,b,c = list(map(int,input().split()))
if a==b==c:print('1')
elif (a==b and c!=a) or (b==c and a!=b) or (c==a and b!=c):print('2')
else:print('3')