Harryxun/stf_run huggingface dataset:
#ノードの数,橋の数
N,M = map(int, input().split())

#最初は自分自身が親（根）
par = [i for i in range(N+1)]
#ランク(深さ）
rank = [0]*(N+1)
#各要素が属するグループのサイズ（連結成分の個数）
size = [1]*(N+1)

#木の根を求める
def root(x):
    if par[x] == x:  #自分が親のときは自分が根ということ
        return x
    else:
        #経路圧縮
        par[x] = root(par[x])#自分が親ではないときは，根を自分の親に設定
        return par[x]

#xとyが同じ集合（連結成分）に属するかどうか
def same(x, y):
    return root(x) == root(y)

#xとyの属する集合を併合
def unite(x,y):
    xx = root(x)
    yy = root(y)
    #xとyのルートが同じなので操作は必要ない（同じ集合に属する）
    if xx == yy:
        return
    ####ランクあり
    if rank[xx] < rank[yy]:
        par[xx] = yy
        size[yy] += size[xx]
    else:
        par[yy] = xx
        size[xx] += size[yy]
        if rank[xx] == rank[yy]:
            rank[yy] += 1

    ####ランクなし
    ###
    ### #ｘとyのrootが異なるので,xの親をyのrootに設定
    #par[x] = yy

#出力する不便度
ans = [0]*M
#すべての橋が壊れているときの不満度はN個の島から2個の島の選び方の総数と等しい
ans[M-1] = N*(N-1)//2

#橋の情報
B = [list(map(int,input().split())) for i in range(M)]

#橋の情報を逆順に取り出す
for i in range(M-1,0,-1):
    a = B[i][0]
    b = B[i][1]
    if root(a) != root(b):
        ans[i-1] = ans[i] -size[root(a)]*size[root(b)]
    else:
        ans[i-1] = ans[i]
    #橋をつなげる
    unite(a,b)

for a in ans:
    print(a)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

#ノードの数,橋の数
N,M = map(int, input().split())

#最初は自分自身が親（根）
par = [i for i in range(N+1)]
#ランク(深さ）
rank = [0]*(N+1)
#各要素が属するグループのサイズ（連結成分の個数）
size = [1]*(N+1)

#木の根を求める
def root(x):
    if par[x] == x:  #自分が親のときは自分が根ということ
        return x
    else:
        #経路圧縮
        par[x] = root(par[x])#自分が親ではないときは，根を自分の親に設定
        return par[x]

#xとyが同じ集合（連結成分）に属するかどうか
def same(x, y):
    return root(x) == root(y)

#xとyの属する集合を併合
def unite(x,y):
    xx = root(x)
    yy = root(y)
    #xとyのルートが同じなので操作は必要ない（同じ集合に属する）
    if xx == yy:
        return
    ####ランクあり
    if rank[xx] < rank[yy]:
        par[xx] = yy
        size[yy] += size[xx]
    else:
        par[yy] = xx
        size[xx] += size[yy]
        if rank[xx] == rank[yy]:
            rank[yy] += 1

    ####ランクなし
    ###
    ### #ｘとyのrootが異なるので,xの親をyのrootに設定
    #par[x] = yy

#出力する不便度
ans = [0]*M
#すべての橋が壊れているときの不満度はN個の島から2個の島の選び方の総数と等しい
ans[M-1] = N*(N-1)//2

#橋の情報
B = [list(map(int,input().split())) for i in range(M)]

#橋の情報を逆順に取り出す
for i in range(M-1,0,-1):
    a = B[i][0]
    b = B[i][1]
    if root(a) != root(b):
        ans[i-1] = ans[i] -size[root(a)]*size[root(b)]
    else:
        ans[i-1] = ans[i]
    #橋をつなげる
    unite(a,b)

for a in ans:
    print(a)
from collections import deque, Counter


class UnionFind:
    def __init__(self, v):
        self.v = v
        self._tree = list(range(v + 1))
        self._counter = Counter(self._tree)

    def _root(self, a):
        queue = deque()
        while self._tree[a] != a:
            queue.append(a)
            a = self._tree[a]
        while queue:
            index = queue.popleft()
            self._tree[index] = a
        return a

    def union(self, a, b):
        root_a = self._root(a)
        root_b = self._root(b)
        if root_a == root_b:
            return

        self._tree[root_b] = root_a
        ca = self._counter[root_a]
        cb = self._counter[root_b]
        self._counter[root_a] += cb
        self._counter[root_b] = 0
        return ca * cb

    def find(self, a, b):
        return self._root(a) == self._root(b)


N, M = map(int, input().split(' '))
edges = [tuple(map(int, input().split(' '))) for _ in range(M)]

dp = [0] * (M + 1)
dp[-1] = N * (N - 1) // 2
union_find = UnionFind(N)

try:
    for i in reversed(range(M)):
        if dp[i + 1] == 0:
            break
        a, b = edges[i]
        minus = union_find.union(a, b)
        dp[i] = dp[i + 1] - minus

    for i in range(M):
        print(dp[i + 1])
except Error:
    print(-1)


### FIXED CODE ###

from collections import deque, Counter


class UnionFind:
    def __init__(self, v):
        self.v = v
        self._tree = list(range(v + 1))
        self._counter = Counter(self._tree)

    def _root(self, a):
        queue = deque()
        while self._tree[a] != a:
            queue.append(a)
            a = self._tree[a]
        while queue:
            index = queue.popleft()
            self._tree[index] = a
        return a

    def union(self, a, b):
        root_a = self._root(a)
        root_b = self._root(b)
        if root_a == root_b:
            return 0

        self._tree[root_b] = root_a
        ca = self._counter[root_a]
        cb = self._counter[root_b]
        self._counter[root_a] += cb
        self._counter[root_b] = 0
        return ca * cb

    def find(self, a, b):
        return self._root(a) == self._root(b)


N, M = map(int, input().split(' '))
edges = [tuple(map(int, input().split(' '))) for _ in range(M)]

score = N * (N - 1) // 2
union_find = UnionFind(N)
scores = []

for a, b in reversed(edges):
    scores.append(score)
    if score == 0:
        continue
    minus = union_find.union(a, b)
    score -= minus

for s in reversed(scores):
    print(s)
import sys
import fractions
from collections import Counter, deque, defaultdict
from math import factorial
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n = INT()
t = [0]*n
for i in range(n):
    t[i] = INT()

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

for i in range(n-1):
    res = lcm(t[i], t[i+1])
    
print(res)




### FIXED CODE ###

import sys
import fractions
from collections import Counter, deque, defaultdict
from math import factorial
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n = INT()
t = [0]*n
for i in range(n):
    t[i] = INT()

def lcm(a,b):
    gcd = fractions.gcd(a,b)
    a//=gcd
    b//=gcd
    return a*b*gcd
    
if n == 1:
    print(t[0])
    sys.exit()

res = lcm(t[0],t[1])
for i in range(1,n-1):
    res = lcm(res, t[i+1])

print(res)
N = int(input())
H = list(map(int, input().split()))
ans = 'Yes'

H[0] -= 1
for i in range(N-1):
    if H[i] < H[i+1]
        H[i+1] -= 1
    elif H[i] > H[i+1]
        ans = 'No'
        break

print(ans)


### FIXED CODE ###

N = int(input())
H = list(map(int, input().split()))
ans = 'Yes'

H[0] -= 1
for i in range(N-1):
    if H[i] < H[i+1]:
        H[i+1] -= 1
    elif H[i] > H[i+1]:
        ans = 'No'
        break

print(ans)
x = input()

n = 100000
while x > 0:
    n *= 1.05
    mod = n % 1000
    if mod != 0:
        n = n + 1000 - mod
    x -= 1

print(int(n))

### FIXED CODE ###

x = int(input())

n = 100000
while x > 0:
    n *= 1.05
    mod = n % 1000
    if mod:
        n += 1000 - mod
    x -= 1

print(int(n))
h,w=map(int,input().split())
lists=[]
from collections import deque
d=deque()
e=deque()
field=[]
distance=0
field.append([True for i in range(w+2)])
for i in range(h):
    sub=[True]
    s=input()
    for j in range(w):
        if s[j]=="#":
            sub.append(True)
        else:
            sub.append(False)
            lists.append((i+1,j+1))
    sub.append(True)
    field.append(sub)
field.append([True for i  in range(w+2)]  )           

fieldss=field.copy()
maxi=0
for i in range(len(lists)):
        distance=0
        fields=fieldss
        sy,sx=lists[i][0],lists[i][1]
        d=deque()
        e=deque()
        d.append((sy,sx))
        fields[sy][sx]=True
        while d:
            for some in d:
                some=d.popleft()
                index1,index2=some[0],some[1]

                if fields[index1-1][index2]==False:
                    fields[index1-1][index2]=True
                    e.append((index1-1,index2))
                    
                if fields[index1+1][index2]==False:
                    fields[index1+1][index2]=True
                    e.append((index1+1,index2))
                    
                if fields[index1][index2+1]==False:
                    fields[index1][index2+1]=True
                    e.append((index1,index2+1))
                    
                if  fields[index1][index2-1]==False:
                    fields[index1][index2-1]=True
                    e.append((index1,index2-1))
        distance+=1
        d=e
        e=deque()
        maxi=max(maxi,distance)
print(maxi)       
        

### FIXED CODE ###

h,w=map(int,input().split())
field=[]
field.append([True for i in range(w+2)])
start=[]
for i  in range(h):
    s=input()
    sub=[True]
    for j in range(w):
        if s[j]=="#":
            sub.append(True)
        else:
            sub.append(False)
            start.append((i+1,j+1))
    
    sub.append(True)
    field.append(sub)

            
        
    
field.append([True for i in range(w+2)])

from collections import deque
import copy
dis=[]
for i in range(len(start)):

        fields=copy.deepcopy(field)
        d=deque()
        e=deque()
        distance=0
        fields[start[i][0]][start[i][1]]=True

        d.append((start[i][0],start[i][1]))
        while d:
            for some in d:
                index1,index2=some[0],some[1]
                if fields[index1-1][index2]==False:
                    fields[index1-1][index2]=True
                    e.append((index1-1,index2))
                if fields[index1+1][index2]==False:
                    fields[index1+1][index2]=True
                    e.append((index1+1,index2))
                if fields[index1][index2+1]==False:
                    fields[index1][index2+1]=True
                    e.append((index1,index2+1))
                if  fields[index1][index2-1]==False:
                    fields[index1][index2-1]=True
                    e.append((index1,index2-1))
            distance+=1
            d=e
            e=deque()

        dis.append(distance)
    


print(max(dis)  -1)
import sys

MEMO = dict()

def search(n, data):
    global MEMO

    if n in MEMO:
        return MEMO[n]
    else:
        if not n in data:
            MEMO[n] = 0
            return 0

        MEMO[n] = max(search(i, data) for i in data[n]) + 1
        return MEMO[n]


def main():
    sys.setrecursionlimit(65535)
    N, M = map(int, input().split())
    data = dict()
    for _ in range(M):
        x, y = map(int, input().split())
        if x not in data:
            data[x] = [y]
        else:
            data[x].append(y)

    print(max(search(n, data) for n in range(1, N+1)))



if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/python3
import sys

MEMO = dict()

def search(n, data):
    global MEMO

    if n in MEMO:
        return MEMO[n]
    else:
        if not n in data:
            MEMO[n] = 0
            return 0

        MEMO[n] = max(search(i, data) for i in data[n]) + 1
        return MEMO[n]


def main():
    # sys.setrecursionlimit(65535)
    sys.setrecursionlimit(10**9)
    N, M = map(int, input().split())
    data = dict()
    for _ in range(M):
        x, y = map(int, input().split())
        if x not in data:
            data[x] = [y]
        else:
            data[x].append(y)

    print(max(search(n, data) for n in range(1, N+1)))



if __name__ == '__main__':
    main()
N,K=map(int,input().split())
P=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=-10**10
for st in range(N):
  now = st+1
  temp=[0]
  while(P[now-1] != st+1):
    temp.append(temp[-1]+C[P[now-1]-1])
    now = P[now-1]
    temp.append(temp[-1]+C[P[now-1]-1])
  if len(temp)>=K+1:
    ans=max(ans, max(temp[1:K+1]))
    continue
  if temp[-1]<=0:
    ans = max(ans, (max(temp[1:])))
  else:
    t=temp[-1]*(K//(len(temp)-1))-temp[-1]
    pりんt(temp+[temp[-1]+temp[i+1] for i in range(K%(len(temp)-1))])
    ans=max(ans, t)
		
print(int(ans))


### FIXED CODE ###

N, K = map(int, input().split())
P = list(map(lambda x: int(x) - 1, input().split()))
C = list(map(int, input().split()))

maxscore = -(10 ** 18)

for st in range(N):
	cumsum = [0]
	now = st
	while(P[now] != st):
		now = P[now]
		cumsum.append(cumsum[-1] + C[now])
	cumsum.append(cumsum[-1] + C[st])
	
	m = len(cumsum) - 1
	loopsum = cumsum[-1]
	
	if loopsum < 0:
		maxscore = max(maxscore, max(cumsum[1:min(K + 1, m + 1)]))
		continue
	
	score = (K // m - 1) * loopsum
	extended_cumsum = cumsum + [cumsum[i] + loopsum for i in range(1, K % m + 1)]
	score += max(extended_cumsum)
	maxscore = max(maxscore, score)
print(maxscore)
from __future__ import print_function
import numpy as np
import sys

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

cnt=0
S=list(input())
# eprint(S)

L=list()
L.append(S.pop())
while len(S)!=0:
    if S[-1]==L[-1]: # SのfrontとLのfrontが0と0とか一致しちゃった時だから，消せない．次のSのfrontを見よう 
        L.append(S.pop())
        # eprint("S: " + str(S))
        # eprint("L: " + str(L))
    else: # SのfrontとLのfrontが0と1となっている場合．消す．
        S.pop()
        L.pop()
        if L==[]:
            L.append(S.pop())
        cnt=cnt+2
        # eprint("S: " + str(S))
        # eprint("L: " + str(L))

print(cnt)

#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#


### FIXED CODE ###

from __future__ import print_function
import numpy as np
import sys

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

cnt=0
S=list(input())
# eprint(S)

L=list()
L.append(S.pop())
while len(S)!=0:
    if S[-1]==L[-1]: # SのfrontとLのfrontが0と0とか一致しちゃった時だから，消せない．次のSのfrontを見よう 
        L.append(S.pop())
        # eprint("S: " + str(S))
        # eprint("L: " + str(L))
    else: # SのfrontとLのfrontが0と1となっている場合．消す．
        S.pop()
        L.pop()
        if L==[] and S!=[]:
            L.append(S.pop())
        cnt=cnt+2
        # eprint("S: " + str(S))
        # eprint("L: " + str(L))

print(cnt)

#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
def solve(pos):
    start = pos
    ans = 0
    a = 0
    b = N - 1
    for i in range(N-1):
        if a==start:
            a += 1
        elif b==start:
            b -= 1
        if abs(A[a]-A[pos])>=abs(A[b]-A[pos]):
            ans += abs(A[a]-A[pos])
            pos = a
            a += 1
        else:
            ans += abs(A[b]-A[pos])
            pos = b
            b -= 1
        #print(ans, a, b)
    #print(ans)
    return ans

N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
A.sort()

if N<=10000:
    pos_list = list(range(N))
else:
    M = (a+b)/2
    for i in range(N-1):
        if A[i]<=M and M<A[i+1]:
            break
    a = max(0, i - 500)
    b = min(N - 1, i + 500)
    pos_list = list(range(a, b+1))
    if pos_list[0]!=0:
        pos_list = [0] + pos_list
    if pos_list[-1]!= N - 1:
        pos_list.append(N-1)
#print(pos_list)

ans = 0
for pos in pos_list:
    tmp = solve(pos)
    ans = max(ans, tmp)
print(ans)


### FIXED CODE ###

N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
A.sort()

PLUS = A[int((N+1)//2):]
MINUS = A[:int((N+1)//2)]
#print(PLUS, MINUS)
ans = sum(PLUS)*2 - sum(MINUS)*2
if N%2==0:
    ans += MINUS[-1] - PLUS[0]
else:
    ans += sum(MINUS[-2:])

PLUS = A[int(N//2):]
MINUS = A[:int(N//2)]
#print(PLUS, MINUS)
ans2 = sum(PLUS)*2 - sum(MINUS)*2
if N%2==0:
    ans2 += MINUS[-1] - PLUS[0]
else:
    ans2 -= sum(PLUS[:2])

print(max(ans, ans2))
H,W = map(int,input())
h,w = map(int,input())
print((H-h)*(W-w))

### FIXED CODE ###

H,W = map(int,input().split())
h,w = map(int,input().split())
print((H-h)*(W-w))
tmp=b
 b=c
 c=tmp
if(a>b):
 tmp=a
 a=b
 b=tmp
print str(a)+" "+str(b)+" "+str(c)

### FIXED CODE ###

a,b,c=map(int,raw_input().split())
if(a>b):
 tmp=a
 a=b
 b=tmp
if(b>c):
 tmp=b
 b=c
 c=tmp
if(a>b):
 tmp=b
 b=a
 a=tmp
print str(a)+" "+str(b)+" "+str(c)
a=int(input())
b=int(input())
if a=!3 and b=!3:
    print("3")
elif a=!2 and b=!2:
    print("2")
elif a=!1 and b=!1:
    print("1")

### FIXED CODE ###

a=int(input())
b=int(input())
if a!=3 and b!=3:
    print("3")
elif a!=2 and b!=2:
    print("2")
elif a!=1 and b!=1:
    print("1")
N = input()
lis = input().split(" ")
cnt = 1
for i in range(int(N)+1):
    for j in range(i-1,-1,-1):
        if int(lis[i])>int(lis[j]):
            break
        else:
            cnt +=1
        break
print(cnt)

### FIXED CODE ###

test = input().split(" ")
if int(test[0])== int(test[1]):
	print("Yes")
else:
	print("No")
A=int(input())
B=int(input())
list[1,2,3]
list.remove(A)
list.remove(B)
print(list[0])

### FIXED CODE ###

A=int(input())
B=int(input())
if A==1 and B==2:
  print(3)
elif A==2 and B==3:
  print(1)
elif A==3 and B==1:
  print(2)
elif A==1 and B==3:
  print(2)
elif A==2 and B==1:
  print(3)
elif A==3 and B==2:
  print(1)
import sys,collections as cl,bisect as bs,math
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(float,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

a,b = m()
co = 0
po = b
while True:
	if int(po) == po:
		break

	else:
		po *= 10
		co += 1 
	


print(int(a)*po//(10**co)))



### FIXED CODE ###

import sys,collections as cl,bisect as bs,math
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(float,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

a,b = m()

b = int(b*1000)

	


print(int((int(a)*b)//(1000)))
N = int(input())
p = list(map(int, input().split()))
p.insert(0, -1)

j = [0] * N
for i in range(1, N + 1):
    if p[i] == i and j[i - 1] == 0:
        j[i] = 1
print(sum(j))

### FIXED CODE ###

N = int(input())
p = list(map(int, input().split()))
p.insert(0, -1)

j = [0] * (N + 1)
for i in range(1, N + 1):
    if p[i] == i and j[i - 1] == 0:
        j[i] = 1
print(sum(j))
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


mod = 10 ** 9 + 7
N, M = list(map(int, input().split()))
A = [0]*N
B = [0]*N
# 日数別にもらえる額を管理
# money = defaultdict(list)
keys = list(range(1, 10**5))
# print(keys)
values = [[] for i in range(1, 10**5)]
job = dict(zip(keys, values))
for i in range(N):
    a, b = map(int, input().split())
    job[a].append(b)
    # A[i], B[i] = a, b
# A日後にB円もらえる、M日後に報酬最大化
ans = 0
can_work = []
for delay in range(1, 1+M):
    can_work.extend(job[delay])
    # print('delay', delay)
    # print(job)
    if (len(can_work) != 0):
        max_money = max(can_work)
        ans += max_money
        can_work.remove(max_money)

    # for i in range(delay):
    #     print(delay-i)
    #     if len(jpb[delay-i]) != 0:
    #         print('found')
    #         max_money = max(jpb[delay-i])
    #         ans += max_money
    #         jpb[delay-i].remove(max_money)
    #         jpb[delay-i]
    #         break
    #     print('===========')
print(ans)


### FIXED CODE ###

# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


mod = 10 ** 9 + 7
N, M = list(map(int, input().split()))
A = [0]*N
B = [0]*N
# 日数別にもらえる額を管理
# money = defaultdict(list)
keys = list(range(1, 1+10**5))
# print(keys)
values = [[] for i in range(1, 1+10**5)]
job = dict(zip(keys, values))
for i in range(N):
    a, b = map(int, input().split())
    job[a].append(-b)
    # A[i], B[i] = a, b
# A日後にB円もらえる、M日後に報酬最大化
ans = 0
can_work = []
heapq.heapify(can_work)
for delay in range(1, 1+M):
    for item in job[delay]:
        heapq.heappush(can_work, item)
    # print('delay', delay)
    # print(job)
    if (len(can_work) != 0):
        ans -= heapq.heappop(can_work)

    # for i in range(delay):
    #     print(delay-i)
    #     if len(jpb[delay-i]) != 0:
    #         print('found')
    #         max_money = max(jpb[delay-i])
    #         ans += max_money
    #         jpb[delay-i].remove(max_money)
    #         jpb[delay-i]
    #         break
    #     print('===========')
print(ans)
stdin << A, B, C
lst = [A, B, C]
sl = sort(lst)
if sl[0] == 5 && sl[1] == 5 && sl[2] == 7
  print('YES')
else
  print('NO')

### FIXED CODE ###

huga = list(map(int, input().split()))
huga.sort()
if huga[0] == 5 and huga[1] == 5 and huga[2] == 7:
  print('YES')
else:
  print('NO')
n, w = map(int, input().split())
weights, values = zip(*[tuple(map(int, input().split()))for _ in range(n)])
min_w = min(weights)-1
weights = [weight-min_w for weight in weights]
W_MAX = 4*200
dp = [[0]*(W_MAX+1) for _ in range(n+1)]
for i in range(1, n+1):
    for k in reversed(range(1, n+1)):
        for j in range(1, W_MAX+1):
            if j-weights[i-1] < 0:
                continue
            dp[k][j] = max(dp[k][j], dp[k-1][j-weights[i-1]]+values[i-1])

ans = 0
for k in range(n+1):
    w_max = w-k*min_w
    if w_max < 0 <= W_MAX:
        continue
    ans = max(ans, dp[k][w_max])
print(ans)

### FIXED CODE ###

n, w = map(int, input().split())
weights, values = zip(*[tuple(map(int, input().split()))for _ in range(n)])
min_w = min(weights)-1
weights = [weight-min_w for weight in weights]
W_MAX = 4*200
dp = [[0]*(W_MAX+1) for _ in range(n+1)]
for i in range(1, n+1):
    for k in reversed(range(1, n+1)):
        for j in range(1, W_MAX+1):
            if j-weights[i-1] < 0:
                continue
            dp[k][j] = max(dp[k][j], dp[k-1][j-weights[i-1]]+values[i-1])

ans = 0
for k in range(n+1):
    w_max = min(w-k*min_w, W_MAX)
    if w_max < 0:
        continue
    ans = max(ans, dp[k][w_max])
print(ans)
import math
from functools import reduce


def solve():
    n = int(input())
    a = list(map(int, input().split()))
    lcm_a = lcm(*a)
    fm = sum([(lcm_a - 1) % ai for ai in a])
    return fm


def lcm_base(x, y):
    return x * y // math.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


if __name__ == "__main__":
    print(solve())


### FIXED CODE ###

import fractions
from functools import reduce


def solve():
    n = int(input())
    a = list(map(int, input().split()))
    lcm_a = lcm(*a)
    fm = sum([(lcm_a - 1) % ai for ai in a])
    return fm


def lcm_base(x, y):
    return x * y // fractions.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


if __name__ == "__main__":
    print(solve())