Harryxun/stf_run huggingface dataset:
import math

n,g=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(n)]
comp=[(100*(i+1)*arr[i][0]+arr[i][1]) for i in range(n)]
ans=10**10
for i in range(2**n):
  flag=format(i,'b')
  if len(flag)<n:
    flag='0'*(n-len(flag))+flag
  tsum=0
  tans=0
  for i in range(n):
    if flag[i]=='1':
      tsum+=comp[i]
      tans+=arr[i][0]
  if tsum>=g:
    ans=min(ans,tans)
  else:
    pos=flag[::-1].index('0')
    tq=math.ceil(g-tsum)/(100*(n-pos)))
    if tq<=arr[n-pos-1][0]:
      ans=min(ans,tans+tq)
print(ans)

### FIXED CODE ###

import math

n,g=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(n)]
comp=[(100*(i+1)*arr[i][0]+arr[i][1]) for i in range(n)]
ans=10**10
for i in range(2**n):
  flag=format(i,'b')
  if len(flag)<n:
    flag='0'*(n-len(flag))+flag
  tsum=0
  tans=0
  for i in range(n):
    if flag[i]=='1':
      tsum+=comp[i]
      tans+=arr[i][0]
  if tsum>=g:
    ans=min(ans,tans)
  else:
    pos=flag[::-1].index('0')
    tq=math.ceil((g-tsum)/(100*(n-pos)))
    if tq<=arr[n-pos-1][0]:
      ans=min(ans,tans+tq)
print(ans)
n = int(input())
a = input().split()
mi = abs(int(a[0]))
ans =  0 
for i in range(n):
    ans = ans + abs(int(a[i]))
    if mi > abs(int(a[i])):
        mi = abs(int(a[i]))
print(ans-2*mi)


### FIXED CODE ###

i = input().split()
a = float(i[0])
b = float(i[1])
t = float(i[2])
f = True
n = 0
while(f):

    if t  + 0.5 < n * a:
       f = False
       break
    n = n + 1
n = n-1
print(int(n * b))
sum = 0

num = int(input())

for i in range(num) :
    money = int(input())
    currency = input()
    if currency == 'JPY' :
        sum += money
    else :
        sum += money * 380000

print(sum)

### FIXED CODE ###

sum = 0

num = int(input())

for i in range(num) :
    money, currency = input().split()
    money = float(money)
    if currency == 'JPY' :
        sum += money
    else :
        sum += money * 380000

print(sum)
N_input = int(input())
t_input = []
x_input = []
y_input = []

for _ in range(N_input):
    t, x, y = map(int, input().split())
    t_input.append(t)
    x_input.append(x)
    y_input.append(y)

def can_reach(t_now, n_now, x_now, y_now): # 残り時間で到達可能かチェック
    distance = abs(x_input[n_now] - x_now) + abs(y_input[n_now] - y_now)
    if distance <= t_input[n_now] - t_now and (distance + (t_input[n_now] - t_now))%2 == 0: # 到達可能圏内かつ距離と残り時間の偶奇が一致
        return True
    else:
        return False

def rest_travel(t_now, n_now, x_now, y_now): # 現在時刻t、通過済チェックポイント数n、現在位置x, y
    if t_now == max(t_input): # ゴール
        print("Yes")
        exit()
    elif can_reach(t_now, n_now, x_now, y_now):
        rest_travel(t_input[n_now+1], n_now+1, x_input[n_now+1], y_input[n_now+1])
    else: # 到達不可
        return

rest_travel(0,0,0,0)
print("No")

### FIXED CODE ###

N = int(input())

t_b = x_b = y_b = 0 # 直前の時刻と位置保存用

def dist(x, x_b, y, y_b):
    return abs(x-x_b) + abs(y-y_b)

miss_flg = 0

for i in range(N):
    t, x, y = map(int, input().split())
    if dist(x, x_b, y, y_b) > t - t_b or ((t - t_b) + dist(x, x_b, y, y_b))% 2 == 1: # 到達不能もしくは距離と残り時間の偶奇が不一致
        miss_flg = 1
    t_b, x_b, y_b = t, x, y

print("Yes" if miss_flg == 0 else "No")
a,b = map(int,input().split())

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

aa = []
aa.append(0)
aa.append(c[0])

l = []
for i in range(1,a):
	aa.append(aa[i]+c[i])
d = 0
p = len(aa)
for i in range(p):
	for j in range(i+1,p):
		l.append(aa[j]-aa[i])

l.sort()
l.reverse()
l = list(map(bin,l))
pp = []
for i in range(len(l)-b):
	k = l[i]
	for j in range(1,b):
		k = l[i+b] & k
		if k <= min(pp):
			break
	pp.append(int(k))

pp.sort()
pp.reverse()
print(pp[0])

### FIXED CODE ###

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

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

aa = []
aa.append(0)
aa.append(c[0])

l = []
for i in range(1,a):
	aa.append(aa[i]+c[i])
d = 0
p = len(aa)
for i in range(p):
	for j in range(i+1,p):
		l.append(aa[j]-aa[i])
co = 0
la = 0
for i in range(40,-1,-1):
	for j in range(len(l)):
		if l[j] & (la + 2 ** i) == (la + 2 ** i):
			co += 1
	if co >= b:
		la += (2 ** i)
	co = 0

print(la)
N = int(input())
S = input()
K = int(input())
flag = S[K]
ans = []
for x in S:
    if x == flag:
        ans.append(x)
    else:
        ans.append('*')
print(''.join(ans))


### FIXED CODE ###

N = int(input())
S = input()
K = int(input())
flag = S[K-1]
ans = []
for x in S:
    if x == flag:
        ans.append(x)
    else:
        ans.append('*')
print(''.join(ans))
n,k=map(int,input().split())
pre="P"
for i in range(1,n):
  cur="B"+pre+"P"+pre+"B"
  pre=cur
print(cur[:k].count("P"))

### FIXED CODE ###

n,x=map(int,input().split())
length=[0]*n;p=[0]*n
length[0]=1
p[0]=1
for i in range(1,n):
  length[i]=length[i-1]*2+3
  p[i]=p[i-1]*2+1
def meat(n,x):
  if n==0:
    return 0 if x<=0 else 1
  elif x<=1+length[n-1]:
    return meat(n-1,x-1)
  elif x==2+length[n-1]:
    return p[n-1]+1
  else:
    return p[n-1]+1+meat(n-1,x-length[n-1]-2)
print(meat(n,x))
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = 0
b = 0
ans = 0
if sum(A) + sum(B) <= K:
    print(N+M)
    exit()
while min(A[a],B[b]) <= K:
    if A[a] == min(A[a],B[b]):
        K -= A[a]
        a += 1
    else:
        K -= B[b]
        b += 1
    ans += 1
print(ans)

### FIXED CODE ###

N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
AA = A
BB = B
for i in range(1,N):
    AA[i] += AA[i-1]
for i in range(1,M):
    BB[i] += BB[i-1]
AA = [0] + AA
BB = [0] + BB
import bisect
c = bisect.bisect_right(AA,K)
ans = 0
for i in range(c):
    ans = max(ans, i + bisect.bisect_right(BB,K-AA[i]) - 1)
print(ans)
import itertools

H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]

VALID = [[False] * W for _ in range(H)]

def dfs(h,w,parent):
  if parent:
    VALID[h][w] = True

  nxt = [-1,0,1]
  ok = False
  for x,y in itertools.product(nxt,repeat=2):
    if not (abs(x) + abs(y) == 1):
      continue
    nx = h + x
    ny = w + y
    if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == '#' and not VALID[nx][ny]:
      if not ok:
        ok = True
        VALID[h][w] = True
      dfs(nx,ny,True)
  
  if not parent and ok:
    VALID[h][w] = True
      
for i in range(H):
  for j in range(W):
    if S[i][j] == '.':
      VALID[i][j] = True
    else:
      if not VALID[i][j]:
        dfs(i,j,False)
        
if all(sum(VALID,[])):
  print('Yes')
else:
  print('No')


### FIXED CODE ###

import itertools

H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]

ok = True        
for i in range(H):
  for j in range(W):
    if S[i][j] == '#':
      flg = False
      for x,y in itertools.product([-1,0,1],repeat=2):
        if not (abs(x) + abs(y) == 1):
          continue
        nx = i + x;ny = j + y
        if 0 <= nx < H and 0 <= ny < W:
          if S[nx][ny] == '#':
            flg = True
      if not flg:
        ok = False
        break
if ok:
  print('Yes')
else:
  print('No')
import sys
from scipy.sparse.csgraph import shortest_path
from scipy.sparse import csr_matrix
from itertools import permutations
read = sys.stdin.read
readline = sys.stdin.readline

N, M, R = map(int, readline().split())
r = list(map(int, readline().split()))
ABC = map(int, read().split())
A, B, C = map(list, zip(*zip(ABC, ABC, ABC)))

for i in range(N + 1):
    A.append(i)
    B.append(i)
    C.append(0)

csr = csr_matrix((C, (A, B)), (N + 1, N + 1))
distance = shortest_path(csr, directed=False)

answer = 10 ** 9
for tour in permutations(r):
    tmp = 0
    for i, j in zip(tour, tour[1:]):
        tmp += distance[i][j]

    if tmp < answer:
        answer = tmp

print(int(answer))

### FIXED CODE ###

import sys
from scipy.sparse.csgraph import floyd_warshall
from itertools import permutations
read = sys.stdin.read
readline = sys.stdin.readline

N, M, R = map(int, readline().split())
r = list(map(int, readline().split()))

INF = float('inf')
graph = [[INF] * (N + 1) for _ in range(N + 1)]
ABC = map(int, read().split())

for i in range(N + 1):
    graph[i][i] = 0

for A, B, C in zip(*[iter(ABC)] * 3):
    graph[A][B] = C
    graph[B][A] = C

distance = floyd_warshall(graph, directed=False)
answer = 10 ** 9
for tour in permutations(r):
    tmp = 0
    for i in range(R - 1):
        tmp += distance[tour[i]][tour[i + 1]]

    if tmp < answer:
        answer = tmp

print(int(answer))
# 2019-11-25 06:26:24(JST)
import sys

def main():
    s, k = sys.stdin.read().split()
    k = int(k)

    count = 0
    same = 1
    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            same += 1
        else:
            if count == 0:
                first_same = same
            count += same // 2
            same = 1
    
    bl = False
    if s[-1] == s[0]:
        if same % 2 == 1 and first_same % 2 == 1:
            count += same // 2 + 1
            bl = True
        else:
            count += same // 2
    else:
        count += same // 2

    ans = count * k
    if bl:
        ans -= 1

    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

# 2019-11-25 06:26:24(JST)
import sys

def main():
    s, k = sys.stdin.read().split()
    k = int(k)

    if len(s) == 1:
        print(k // 2)
        sys.exit()
    
    if s.count(s[0]) == len(s):
        if len(s) % 2 == 0:
            ans = len(s) // 2 * k
        else:
            # if k % 2 == 0:
            ans = len(s) * k // 2
            # else:
            #     ans = len(s) // 2 * (k // 2 + 1) + (len(s) // 2 + 1) * k // 2
        print(ans)
        sys.exit()

    count = 0
    same = 1
    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            same += 1
        else:
            if count == 0:
                first_same = same
            count += same // 2
            same = 1
    
    bl = False
    if s[-1] == s[0]:
        if same % 2 == 1 and first_same % 2 == 1:
            count += same // 2 + 1
            bl = True
        else:
            count += same // 2
    else:
        count += same // 2

    ans = count * k
    if bl:
        ans -= 1

    print(ans)

if __name__ == '__main__':
    main()
a,b,c = map(int,input().split(" ")
if a + b + c >= 22:
	print("bust")
else:
	print("win")
            

### FIXED CODE ###

a,b,c = map(int,input().split(" "))
if a + b + c >= 22:
	print("bust")
else:
	print("win")
N,X=map(int,input().split())

from functools import lru_cache
import sys

sys.setrecursionlimit(10*10)

@lru_cache(maxsize=None)
def count(N):
    if N == 0:
        return 1
    else:
        temp = pan(N-1)
        return 3 + 2 * count(N-1)
    
@lru_cache(maxsize=None)
def calc(N,X):
    if N == 0:
        return 1
    center = count(N-1) + 1
    if X == 0 :
        return 0
    elif X < center:
        return calc(N-1,X-1)
    elif X == center:
        return calc(N-1,center-2) + 1
    elif X > center:
        return calc(N-1,X-center-1) + calc(N,center)
print(calc(N,X-1))

### FIXED CODE ###

N,X=map(int,input().split())

from functools import lru_cache
import sys

sys.setrecursionlimit(10*20)

@lru_cache(maxsize=None)
def count(N):
    if N == 0:
        return 1
    else:
        return 3 + 2 * count(N-1)
    
@lru_cache(maxsize=None)
def calc(N,X):
    if N == 0:
        return 1
    center = count(N-1) + 1
    if X == 0 :
        return 0
    elif X < center:
        return calc(N-1,X-1)
    elif X == center:
        return calc(N-1,center-2) + 1
    elif X > center:
        return calc(N-1,X-center-1) + calc(N,center)
print(calc(N,X-1))
A,B,C,D,E,F = map(int, input().split())

val_max = 0
for a in range(0,1+F//(100*A)):
  for b in range(0,1+(F-100*A*a)//(100*B)):
    if (a==0)&(b==0):
      continue
    for c in range(0,1+(F-100*A*a-100*B*b)//C):
      for d in range(0,1+(F-100*A*a-100*B*b-C*c)//D):
        if C*c+D*d <= E*(A*a+B*b):
          val = (C*c+D*d)/(100*A*a+100*B*b+C*c+D*d)
          if val > val_max:
            val_max = val
            ans1 = 100*A*a+100*B*b+C*c+D*d
            ans2 = C*c+D*d
print(ans1,ans2)


### FIXED CODE ###

A,B,C,D,E,F = map(int, input().split())

val_max = 0
for a in range(0,1+F//(100*A)):
  for b in range(0,1+(F - 100*A*a)//(100*B)):
    if (a==0)&(b==0):
      continue
    for c in range(0,1+(F - 100*A*a - 100*B*b)//C):
      for d in range(0,1+(F - 100*A*a - 100*B*b - C*c)//D):
        if C*c+D*d <= E*(A*a+B*b):
          val = (C*c + D*d)/(100*A*a + 100*B*b + C*c + D*d)
          if val >= val_max:
            val_max = val
            ans1 = 100*A*a + 100*B*b + C*c + D*d
            ans2 = C*c + D*d
print(int(ans1),int(ans2))
import sys
from heapq import*
def g(s,g):
 F=[1e7]*-~n;F[s]=0
 H=[(0,s)]
 while H:
  c,u=heappop(H)
  if u==g:return c
  for f,v in E[u]:
   t=c+f
   if t<F[v]:
    F[v]=t
    heappush(H,(t,v))
 return-1
for e in iter(input,'0 0'):
 n,k=map(int,e.split())
 E=[[]for _ in[0]*-~n]
 for _ in[0]*k:
  f=input()
  if f[0]:
   c,d,e=map(int,f.split())
   E[c]+=[(e,d)];E[d]+=[(e,c)]
  else:print(g(map(int,f[2:])))


### FIXED CODE ###

def s():
 import sys
 r=sys.stdin.readline
 I=float('inf')
 for e in iter(r,'0 0\n'):
  n,k=map(int,e.split())
  F=[[I]*-~n for _ in[0]*-~n]
  for i in range(1,n+1):F[i][i]=0
  for _ in[0]*k:
   f=r();g=map(int,f[2:].split())
   if'0'==f[0]:a,b=g;A=F[a][b];print([A,-1][A==I])
   else:
    c,d,e=g
    if e<F[c][d]:
     for i in range(2,n+1):
      for j in range(1,i):
       F[i][j]=F[j][i]=min(F[i][j],F[i][c]+e+F[d][j],F[i][d]+e+F[c][j])
s()
n=str(input())
if n[1]==n[2]==n[3] or n[2]==n[3]==n[4]:
  print('Yes')
else:
  print('N')


### FIXED CODE ###

n=str(input())
if n[0]==n[1]==n[2] or n[1]==n[2]==n[3]:
  print('Yes')
else:
  print('No')
S=list(input())
K=int(input())
#基本は文字列一単位内でひっくり返す×単位数ですが、文字列が一つの場合と文字列の両端が同じ場合を考慮してね。
P=0
if len(S)==1:
	P=K//2
else:
	for G in range(1,len(S):
		B=S[G-1]
		if S[G] in B:
			S[G]='O'
			P+=1
		else:
			continue
	P=P*K
	if S[0]==S[len(S)-1]:
		P+=K-1
print(P)

### FIXED CODE ###

S=list(input())
K=int(input())
SS=S*2
F=S[0]
if len(S)==1:
	P=int(K//2)
elif S==[F]*len(S):
	P=int((len(S))*K//2)
else:
	for G in range(1,len(S)):
		if S[G-1]==S[G]:
			S[G]="O"
		else:
			continue
	A=S.count("O")
	for J in range(1,len(SS)):
		if SS[J-1]==SS[J]:
			SS[J]="O"
		else:
			continue
	B=SS.count("O")
	P=A+(B-A)*(K-1)
print(P)
import sys
input = sys.stdin.readline

N, W = map(int, input().split())

w = [0] * N
v = [0] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())

def func(N, W):
    dp = [0] * (W+1)
    for i in range(N):
        for j in range(W, w[i]-1, -1):
            a = dp[j-w[i]] + v[i]
            if dp[j] < a:
                dp[j] = a
    return dp[W]

print(func(N, W))

### FIXED CODE ###

N = int(input())

abc = [list(map(lambda x: int(x), input().split())) for _ in range(N)]

happy = [[0] * 3 for _ in range(N)]
for i in range(3):
	happy[0][i] = abc[0][i]

for i in range(1, N):
	for j in range(3):
		for k in range(3):
			if j != k and happy[i][j] < happy[i - 1][k]:
				happy[i][j] = happy[i - 1][k]
		happy[i][j] += abc[i][j]

print(max(happy[N - 1][0], happy[N - 1][1], happy[N - 1][2]))
def main():
    from builtin import min
    N = int(input())

    a = 0 // carried
    b = 0 // not carried
    while N != 0:
        t = N % 10
        a = min(a + t + 1, b + t)
        b = min(a + 9 - t, a + 10 - t)
        n //= 10
    print(min(a + 1, b))


main()


### FIXED CODE ###

N = input()

N = '0' + N
result = 0
carry = 0
for i in range(len(N) - 1, 0, -1):
    c = int(N[i]) + carry
    n = int(N[i - 1])
    if c < 5 or (c == 5 and n < 5):
        result += c
        carry = 0
    else:
        result += 10 - c
        carry = 1
result += carry
print(result)
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def dfs(graph, nd, toprogy, is_visited):
    is_visited.add(nd)
    for adj in graph[nd]:
        if adj not in is_visited:
            dfs(graph, adj, toprogy, is_visited)

    toprogy.appendleft(nd)

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [int(input_raw[0]), int(input_raw[1])]
    graph = {}
    inv_graph = {}
    for i in range(1, N + 1):
        graph[i] = []
        inv_graph[i] = []

    for i in range(N - 1 + M):
        input_raw = read_func().strip().split()
        [a, b] = [int(input_raw[0]), int(input_raw[1])]
        graph[a].append(b)
        inv_graph[b].append(a)

    sys.setrecursionlimit(20000)
    toprogy = deque([])
    is_visited = set([])
    for i in range(1, N + 1):
        if i not in is_visited:
            dfs(graph, i, toprogy, is_visited)

    toprogical_order = {}
    for i in range(N):
        toprogical_order[toprogy[i]] = i + 1

    for i in range(1, N + 1):
        max_toprogy = 0
        true_parent = 0
        for pare in inv_graph[i]:
            if max_toprogy < toprogical_order[pare]:
                max_toprogy =toprogical_order[pare]
                true_parent = pare
        print true_parent

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def dfs(graph, nd, toprogy, is_visited):
    is_visited.add(nd)
    for adj in graph[nd]:
        if adj not in is_visited:
            dfs(graph, adj, toprogy, is_visited)

    toprogy.appendleft(nd)

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [int(input_raw[0]), int(input_raw[1])]
    graph = {}
    inv_graph = {}
    for i in range(1, N + 1):
        graph[i] = []
        inv_graph[i] = []

    for i in range(N - 1 + M):
        input_raw = read_func().strip().split()
        [a, b] = [int(input_raw[0]), int(input_raw[1])]
        graph[a].append(b)
        inv_graph[b].append(a)

    sys.setrecursionlimit(200000)
    toprogy = deque([])
    is_visited = set([])
    for i in range(1, N + 1):
        if i not in is_visited:
            dfs(graph, i, toprogy, is_visited)

    toprogical_order = {}
    for i in range(N):
        toprogical_order[toprogy[i]] = i + 1

    for i in range(1, N + 1):
        max_toprogy = 0
        true_parent = 0
        for pare in inv_graph[i]:
            if pare not in toprogical_order:
                continue
            if max_toprogy < toprogical_order[pare]:
                max_toprogy =toprogical_order[pare]
                true_parent = pare
        print true_parent

if __name__ == '__main__':
    main()
import heapq

N,X = map(int,input().split())
m=[]
for _ in range(N):
    M = int(input())
    m.append(M)

sum_m = sum(m)
heapq.heapify(m)
min_m = heapq.heappop(m)

ans = N

A=X-sum_m
while A-min_m >0:
    A-=min_m
    ans+=1
print(ans)

### FIXED CODE ###

S=input()
ans=700
for i in S:
  if i=="o":
    ans+=100
print(ans)
N = 10**6
mod = 10**9 + 7
fact = [1]
for i in range(1, N+1):
    fact.append(fact[-1]*i%mod)

n, m = map(int, input().split())

if n - m > 1 or m - n > 1:
    ans = 0
elif n - m == 0:
    ans = 2 * fact[n] * fact[m] % mod
else:
    ans = fact[n] * fact[m] % mod
    
print(ans)

### FIXED CODE ###

x, a, b = map(int, input().split())
ans = "delicious" if b <= a else "dangerous" if b > a+x else "safe"
print(ans)
def main():
    #input = input()
    input = 76500
    if 0 <= input < 86400:
        hour = input % 3600
        minute = hour % 60
        seconde = minute % 60
        #print("{0}:{1}:{2}".format(h, m, s))
        print("{0}:{1}:{2}".format(hour,minute,seconde))

if __name__ == "__main__":
    print("main start!")
    main()
    print("main end!")ute,seconde)

### FIXED CODE ###

input = int(input())
if 0 <= input < 86400:
    hour = input / 3600
    minute = (input / 60) % 60
    second = input % 60
    print("%d:%d:%d" % (hour,minute,second))
n = int(input())
f = []
for _ in range(n):
    f.append(list(map(int, input().split())))
p = []
for _ in range(n):
    p.append(list(map(int, input().split())))
ans = - (10 ** 9)
for i in range(1, 2 ** 10):
    store = {i : 0 for i in range(10)}
    k = "0" * (10 - len(bin(i)) + 2) + bin(i)[2:]
    for j, kk in enumerate(k):
        if kk == "1":
            for nn in range(n):
                if f[nn][j] == 1:
                    store[nn] += 1
    calc = 0
    for x, y in enumerate(p):
        calc += y[store[x]]
    ans = max(ans, calc)
print(ans)

### FIXED CODE ###

n = int(input())
f = []
for _ in range(n):
    f.append(list(map(int, input().split())))
p = []
for _ in range(n):
    p.append(list(map(int, input().split())))
ans = - (10 ** 9)
for i in range(1, 1<<10):
    store = {lll : 0 for lll in range(10)}
    k = "0" * (10 - len(bin(i)) + 2) + bin(i)[2:]
    calc = 0
    for nn in range(n):
        count = 0
        for j, kk in enumerate(k):
            if kk == "1":
                if f[nn][j] == 1:
                    count += 1
        calc += p[nn][count]
    ans = max(ans, calc)
print(ans)
def main():
    s = input()
    total = 0
    for i in range(len(s)):
        total += int(s[i])

    if int(s) % total == 0:
        print("Yes")
    else:
        print("No")


def main2():
    n = int(input())
    total = 0
    tmp = n
    while tmp > 0:
        total += n % 10
        tmp /= 10

    if n % total == 0:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main2()


### FIXED CODE ###

def main():
    s = input()
    total = 0
    for i in range(len(s)):
        total += int(s[i])

    if int(s) % total == 0:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()
f = int(input()) / 3.0
return(f * f * f)

### FIXED CODE ###

f = int(input()) / 3.0
print("{:.9f}".format(f * f * f))
print(int(input())*int(input()))

### FIXED CODE ###

import math;print(math.prod(map(int,input().split())))
import sys
N,X=(int(x) for x in input().split())

L=int(y) for y in input().split()
count = 0
D=[0]
for k in range(0,N+1):
  if(D(k)<=X):
    count += 1
  D.append(D(k)+L(k))
  
print(count)
  
  


### FIXED CODE ###

s=list(input().split())
l=list(input().split())
n=int(s[0])
x=int(s[1])
count=1
d=0
for i in range(n):
  d=d+int(l[i])
  if d<=x:
    count+=1
print(count)
N = int(input())
aA=list(set(int(_) for _ in input().split()))
def ggg(i,j):
    if i < j :
        i,j = j,i
    i %= j
    if i == 0:
        return j
    else:
        return ggg(j,i)

if len(aA) == 1:
    print(aA[0])
else:
    iMin = min(aA)
    iMax = max(aA)
    if iMin  == 1:
        print(1)
    else:
        iDm = [i % iMin for i in aA]
        if max(iDm) == 0:
            print(iMin)
            exit()
        else:
            iM = iMax
            for i in range(N):
                iA = aA[i]
                for j in range(i+1,N):
                    iMt = ggg(iA,aA[j])
                    if 0 < iMt and iMt < iM:
                        iM = iMt
                    if iM == 1:
                        print(1)
                        exit()
            print(iM)


### FIXED CODE ###

#gcdか....
def fgcd(a,b):
    while b:
        a,b = b,a%b
    return a

N = int(input())
aA = sorted(set(int(_) for _ in input().split()))
b = aA[0]
for a in aA[1:]:
    b = fgcd(a,b)
print(b)
n = int(input())
s = input()
k = int(input())
m = s[k-1]

for i in range(n):
  if s[i] != m:
    s[i] = "*"

### FIXED CODE ###

n = int(input())
s = input()
k = int(input())
m = s[k-1]

for i in range(n):
  if s[i] != m:
    s = s.replace(s[i], "*")
print(s)