Harryxun/stf_run huggingface dataset:
from heapq import heapify, heappop, heappush, nsmallest
n, m = map(int, raw_input().split())
X = map(int, raw_input().split())
X.sort()
heap = []
for i in range(1, m):
    diff = X[i] - X[i-1]
    if len(heap) >= n - 1 and nsmallest(1, heap)[0][0] < diff:
        heappop(heap)
        heappush(heap, (diff, X[i-1], X[i]))
    elif len(heap) < n - 1:
        heappush(heap, (diff, X[i-1], X[i]))
    else:
        continue
heap.sort(key=lambda X : X[1])
cp = X[0]
move = 0
for j in range(len(heap)):
    diff, left, right = heap[j]
    move += left - cp
    cp = right
move += (X[-1] - cp)
print move

### FIXED CODE ###

from heapq import heapify, heappop, heappush, nsmallest
n, m = map(int, raw_input().split())
X = map(int, raw_input().split())
X.sort()
if m == 1:
    print 0
    exit()
elif n == 1:
    print X[-1] - X[0]
    exit()
heap = []
heapify(heap)
for i in range(1, m):
    diff = X[i] - X[i-1]
    if len(heap) >= n - 1 and heap[0][0] < diff:
        heappop(heap)
        heappush(heap, (diff, X[i-1], X[i]))
    elif len(heap) < n - 1:
        heappush(heap, (diff, X[i-1], X[i]))
    else:
        continue
heap.sort(key=lambda X : X[1])
cp = X[0]
move = 0
for j in range(len(heap)):
    diff, left, right = heap[j]
    move += left - cp
    cp = right
move += (X[-1] - cp)
print move
s=list(input().split())
n=int(input())
t=[input() for i in range(n)]
r=[]
for x in s:
    for y in t:
        if len(x)==len(y):
            l=list(x)
            for z in range(len(x)):
                if y[z]=="*":l[z]="*"
            if "".join(l)==y:
                r.append("*"*len(x))
                break
    else:r.append(x)
print(*r)

### FIXED CODE ###

a,b,c=map(int,input().split())
d=0
while a%2==0 and b%2==0 and c%2==0:
    if a==b==c:
        print(-1)
        break
    d+=1
    ha=a//2
    hb=b//2
    hc=c//2
    a=hb+hc
    b=ha+hc
    c=ha+hb
else:print(d)
D=int(input())
if D=25:
  print('Christmas')
elif D=24:
  print('Christmas Eve')
elif D=23:
  print('Christmas Eve Eve')
elif D=22:
  print('Christmas Eve Eve Eve')

### FIXED CODE ###

D=int(input())
if D==25:
  print('Christmas')
elif D==24:
  print('Christmas Eve')
elif D==23:
  print('Christmas Eve Eve')
elif D==22:
  print('Christmas Eve Eve Eve')
N = int(input())
A = [0]
A.extend(list(map(int, input().split())))

buka_num = []

for i in range(1,N):
    buka_num.append(A.count(i))
    
buka_num.append(0)
for ele in buka_num:
    print(ele)

### FIXED CODE ###

import math
R = int(input())
print(R*2*math.pi)
S=input()
T=input()
j=0
i=-1
flag = False
while i>=-1*len(S)-1+len(T):
    while j>=-1*len(T):
        if i==-1*len(S)-1+len(T):
            A="UNRESTORABLE"
            flag=True
            break
        elif j==-1*len(T):
            if i!=-1:
                P=S.replace(S[i-len(T)+1:i+1],T,1)
                A=P.replace("?","a")
                i=-1*len(S)-1+len(T)
                flag=True
                break
            else:
                P=S.replace(S[i-len(T)+1:],T,1)
                A=P.replace("?","a")
                flag=True
                break
        elif S[i+j]==T[j-1] or S[i+j]=="?":
            j=j-1
        else:
            j=0
            i=i-1
    if flag:
        break
print(A)

### FIXED CODE ###

R=int(input())
G=int(input())
print(2*G-R)
N,M=map(int,input().split())
a=[int(input()) for _ in range(M)]
mod=10**9+7
#Dynamic Programming
dp=[0]*(N+1)
dp[0]=1
if 1 not in a:
	dp[1]=1
else:
	dp[1]=0
for i in range(2,N+1):
	if i in a:
		continue
	dp[i]=(dp[i-1]+dp[i-2])%mod
print(ans)

### FIXED CODE ###

N,M=map(int,input().split())
dp=[0]*(N+1)
dp[0]=1
mod=10**9+7
a=[False for _ in range(N+1)]
for _ in range(M):
    a[int(input())]=True
    
for i in range(1,N+1):
    if a[i]:
        continue
    dp[i]=(dp[i-1]+dp[i-2])%mod
 
print(dp[N])
s = input()
ans = ""
for c in s:
  if c == '?':
    ans.append('d')
  else:
    ans.append(c)
print(ans)

### FIXED CODE ###

s = input().replace("?", "D")
print(s)
n = int(input())

ans = [0 for _ in range(10000)]

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            s = x*x + y*y + z*z + z*y + y*z + z*x
            if s <= 10000:
                ans[s] += 1

for i in range(1, n+1):
    print(ans[i])


### FIXED CODE ###

n = int(input())

ans = [0 for _ in range(10001)]

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            s = x*x + y*y + z*z + x*y + y*z + z*x
            if s <= 10000:
                ans[s] += 1

for i in range(1, n+1):
    print(ans[i])
N = int(input())
list_n = list(map(int, input().split()))
flag = 0
for i in range(N):
  if list_n[i] % 2 == 0:
    if (list_n[i] % 3 != 0) and (list_n[i] % 5 != 0):
      print('DENIED')
      flag = 1
      break
    else:
      continue
if flag == 0:
  print('APPROVED')

### FIXED CODE ###

a,b,c = map(int, input().split())
if a == b:
  if a != c:
    print('Yes')
  else:
    print('No')
else:
  if (a == c) or (b == c):
    print('Yes')
  else:
    print('No')
m = min(a, b)

for i in reversed(range(m+1)):
    if a % i == 0 and b % i == 0:
        k -= 1
        if k == 0:
            print(i)
            exit()

### FIXED CODE ###

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

m = min(a, b)
l = []

for i in range(1, m+1):
    if a % i == 0 and b % i == 0:
        l.append(i)
print(l[-k])
a

### FIXED CODE ###

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

if C >= A and C <= B:
    print("Yes")
else:
    print("No")
from math import ceil, log10, sqrt

n = int(input())
ans = 0
for i in range(ceil(sqrt(n)))[::-1]:
    if n % i == 0:
        a = i
        b = n//i
        ans = max(len(str(a)), len(str(b)))
        break
print(ans)


### FIXED CODE ###

from math import ceil, log10, sqrt

n = int(input())
ans = 0
for i in range(1, ceil(sqrt(n))+1)[::-1]:
    if n % i == 0:
        a = i
        b = n//i
        ans = max(len(str(a)), len(str(b)))
        break
print(ans)
N = int(input())
AB = []
for _ in range(N-1):
    AB.append([int(i) for i in input().split()])
ans = [0]*(N-1)
ans[0] = 0
for i,ab in enumerate(AB):
    if i==0:
        pass
    else:
        used = set()
        AB_temp = AB[0:i]
        for  j,ab_temp in enumerate(AB_temp):
            if ab_temp[0] == ab[0] or ab_temp[0] == ab[1] or ab_temp[1] == ab[0] or ab_temp[1] == ab[1]:
                used.add(ans[j])
        ans[i] = min(set(range(max(used) + 2)) - used)
print(max(ans)+1)
for a in ans:
    print(a+1)

### FIXED CODE ###

N = int(input())
AB = [[]]*(N-1)
for i in range(N-1):
    AB[i] = list(map(int,input().split()))
from collections import defaultdict as ddict
from collections import deque
tree = ddict(list)
B = [0]*(N-1)
for i,ab in enumerate(AB):
    tree[ab[0]].append(ab[1])
    B[i] = ab[1]
# 各エッジの色を格納する変数の初期化
# C[0]は使わない
C = [0]*N
# 幅優先探索用のcue
Q = deque([1])
while Q:
    q = Q.popleft()
    c = 0
    for w in tree[q]:
        # 色をインクリメントした際に親の色とかぶったら更に1を加算する
        # 他は単純なインクリメント
        c += 1 + int(C[q-1] == c+1)
        # エッジの色を格納
        C[w-1] = c
        # 子供をcueに追加
        Q.append(w)
print(max(C))
for b in B:
    print(C[b-1])
k,s=map(int,input().split())
a=0
for i in range(k+1):
  for j in range(k+1):
    if s-i-j <=k and s-i-j >=0:
      a+=1
print(ans)

### FIXED CODE ###

k,s=map(int,input().split())
a=0
for i in range(k+1):
  for j in range(k+1):
    if s-i-j <=k and s-i-j >=0:
      a+=1
print(a)
a,b = map(int, input().split())
c,d = map(int, input().split())
if c == a+1:
  return 1
else:
  return 0


### FIXED CODE ###

li = []
for i in range(2):
  a,b = map(int, input().split())
  li.append(a)
  
if li[1] == li[0]+1:
  print(1)
else:
  print(0)
N = input()
L = input()
A = list(map(str, input().split()))
A.sort()

res = ''
for a in A:
    res += a

print(res)


### FIXED CODE ###

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

input_str_list = []
for input_str_index in range(N):
    input_str_list.append(input())

input_str_list.sort()

print(''.join(input_str_list))
def main():
    a,b = map(int,input().split())
    if a%2!=0 and b%2!=0:
        print('Yes')
        return
    print('No')


if __name __ == '__main__':
    main()


### FIXED CODE ###

def main():
    a,b = map(int,input().split())
    if a%2!=0 and b%2!=0:
        print('Yes')
        return
    print('No')


if __name__ == '__main__':
    main()
import math
a,b = map(str,input().split())
a = int(a)
b = b.remove(,)
# print(a,b)
b = int((b))
ans = (a*b)//100
print(ans)

### FIXED CODE ###

import math
a,b = map(str,input().split())
a = int(a)
b_ =str()
for i in b:
    if(i != "."):
        b_ = b_ +i
# print(b_)
b_ = int(b_)
ans = (a*b_)//100
print(ans)
N = int(input())
p_x = []
p_y = []
p_h = []
for i in range(N):
    x1,y1,h1 = [int(i) for i in input().split()]
    p_x.append(x1)
    p_y.append(y1)
    p_h.append(h1)


#h = H - |X-CX| - |Y-CY|　⇔　H = h + |X-CX| + |Y-CY|
#方針：上記式から与えられた全座標でHの値が一致する点を見つける。
for x in range(101):
    count = 0
    hantei = 1
    for y in range(101):
        hantei1 = 0
        for i in range(N):
            if i == 0 :
                tmp = p_h[i] + abs(x - p_x[i]) + abs(y - p_y[i])
                if tmp < 0:
                   hantei = 0
            else:
                if hantei == 1:
                    tmp1 = p_h[i] + abs(x - p_x[i]) + abs(y - p_y[i])
                    if tmp == tmp1:
                        #print(tmp,tmp1,x,y)
                        count += 1
                    else :
                        break
                else :
                    break
        if count == N-1: 
            #print (x,y,tmp)
            Cx = x
            Cy = y
            H = tmp
            hantei1 = 1
            break  
    if hantei1 == 1:
        break

print(Cx," ", Cy, " ",H)

### FIXED CODE ###

N = int(input())
p_x = []
p_y = []
p_h = []
for i in range(N):
    x1,y1,h1 = [int(i) for i in input().split()]
    p_x.append(x1)
    p_y.append(y1)
    p_h.append(h1)


#h = H - |X-CX| - |Y-CY|　⇔　H = h + |X-CX| + |Y-CY|
#方針：上記式から与えられた全座標でHの値が一致する点を見つける。
for x in range(101):
    for y in range(101):
        #点を見つけたときにfor文から離脱
        hantei1 = 0
        #一致したときにカウント
        count = 0
        #判定用の変数
        tmp = -1
        #判定用の変数(0) or 判定する値（1）
        tmp_count = 0
        #h[i]==0の保留リスト
        horyu = []
        for i in range(N):
            if p_h[i] == 0:
                horyu.append(i)
            else:
                tmp1 = p_h[i] + abs(x - p_x[i]) + abs(y - p_y[i])
                if tmp1 < 0 :
                    break
                elif tmp_count == 0:
                    tmp = tmp1
                    tmp_count += 1
                elif tmp_count != 0 and tmp1 > 0:
                    if tmp == tmp1:
                        count += 1
            
        if count == N-1 or N-1 == count + len(horyu):
            if len(horyu) == 0:
                Cx = x
                Cy = y
                H = tmp
                hantei1 = 1
                break
            else:
                count2 = 0
                for j in range(len(horyu)):
                    if 0 == max(0, tmp -abs(p_x[horyu[j]] - x) -abs(p_y[horyu[j]] - y)):
                        count2 += 1
                if count2 == len(horyu):
                    Cx = x
                    Cy = y
                    H = tmp
                    hantei1 = 1
    if hantei1 == 1:
        break

print(Cx,Cy,H)
a, b = map(int,input())
print(6-a-b)

### FIXED CODE ###

number1 = int(input())
number2 = int(input())
choices = [1,2,3]
choices.remove(number1)
choices.remove(number2)
print(*choices)
while True:
    n=int(input())
    if n==0:
        break;
    li=[input() for i in range(n)]
    index=0
    def pls(depth):
        k=0
        global index
        while len(li[index])>depth and li[index][depth-1]=='.':
            if (not li[index][depth]=='+') and (not li[index][depth]=='*'):
                k+=int(li[index][depth])
                if not index==n-1:
                    index+=1
                else:
                    return k
            elif li[index][depth]=='+':
                index+=1
                k+=pls(depth+1)
            elif li[index][depth]=='*':
                index+=1
                k+=prd(depth+1)
        else:
            return k
    def prd(depth):
        k=1
        global index
        while len(li[index])>depth and li[index][depth-1]=='.':
            if (not li[index][depth]=='+') and (not li[index][depth]=='*'):
                k*=int(li[index][depth])
                if not index==n-1:
                    index+=1
                else:
                    return k
            elif li[index][depth]=='+':
                index+=1
                k*=pls(depth+1)
            elif li[index][depth]=='*':
                index+=1
                k*=prd(depth+1)
        else:
            return k
    if li[0]=='+':
        index+=1
        print(pls(1))
    elif li[0]=='*':
        index+=1
        print(prd(1))

### FIXED CODE ###

while True:
    n=int(input())
    if n==0:
        break;
    elif n==1:
        print(input())
        continue;
    li=[input() for i in range(n)]
    index=0
    def pls(depth):
        k=0
        global index
        while len(li[index])>depth and li[index][depth-1]=='.':
            if (not li[index][depth]=='+') and (not li[index][depth]=='*'):
                k+=int(li[index][depth])
                index+=1
            elif li[index][depth]=='+':
                index+=1
                k+=pls(depth+1)
            elif li[index][depth]=='*':
                index+=1
                k+=prd(depth+1)
            if index==n:
                return k    
        else:
            return k
    def prd(depth):
        k=1
        global index
        while len(li[index])>depth and li[index][depth-1]=='.':
            if (not li[index][depth]=='+') and (not li[index][depth]=='*'):
                k*=int(li[index][depth])
                index+=1
            elif li[index][depth]=='+':
                index+=1
                k*=pls(depth+1)
            elif li[index][depth]=='*':
                index+=1
                k*=prd(depth+1)
            if index==n:
                return k
        else:
            return k
    if li[0]=='+':
        index+=1
        print(pls(1))
    elif li[0]=='*':
        index+=1
        print(prd(1))
import math
a, b = map(int, input().split())
print((a * b) // math.gcd(a, b))


### FIXED CODE ###

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

i = 1
flag = True
while(flag):
    if (a * i) % b == 0:
        flag = False
        ans = a * i
        break
    i += 1

print(ans)
X, Y, A, B, C = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)

red = p[:X]
green = q[:Y]

red_no_eat = 0
green_no_eat = 0
for no in r:
    if no > red[-red_no_eat - 1] or no > green[-green_no_eat - 1]:
        if red[-red_no_eat - 1] < green[-green_no_eat-1]:
            red_no_eat += 1
        else:
            green_no_eat += 1
print(sum(p[:X-red_no_eat]) + sum(q[:Y-green_no_eat]) + sum(r[:red_no_eat+green_no_eat]))


### FIXED CODE ###

X, Y, A, B, C = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)

red = p[:X]
green = q[:Y]

red_no_eat = 0
green_no_eat = 0
for no in r:
    red_worst = red[-red_no_eat - 1] if red_no_eat < X else 10 ** 10
    green_worst = green[-green_no_eat - 1] if green_no_eat < Y else 10 ** 10
    if no > red_worst or no > green_worst:
        if red_worst < green_worst:
            red_no_eat += 1
        else:
            green_no_eat += 1
print(sum(p[:X-red_no_eat]) + sum(q[:Y-green_no_eat]) + sum(r[:red_no_eat+green_no_eat]))
N = int(input())
A = list(map(int, input().split()))
import numpy as np
import sys

if 0 in A:
    print(0)
    sys.exit()

ans = np.prod(A)
if ans<= 10**18:
    print(ans)
    sus.exit()
if 10**18 < ans:
    print(-1)


### FIXED CODE ###

import sys  # sys.exit()を使いたいので

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

if 0 in a:
# 0が1つでもあれば0です
    print(0)
else:
# 0がない場合
    cur = 1  # 現在の数値
    for x in a:
        cur *= x
        if cur > 10 ** 18:
        # 10**18を超えたので終了します
            print(-1)
            sys.exit()
    print(cur)  # 10**18以下なので、出力します
N,M=map(int, input().split())
L = []
R = []
for i in range(M):
    l, r = input().split()
    L.append(int(l))
    R.append(r)


x = min(R)-max(L)


print(0 if x <0 else x+1)

### FIXED CODE ###

N,M=map(int, input().split())
L = []
R = []
for i in range(M):
    l, r = input().split()
    L.append(int(l))
    R.append(int(r))


x = min(R)-max(L)


print(0 if x <0 else x+1)
import sys

def main():
    input = sys.stdin.readline
    n, k = map(int, input().split())
    a = [int(x) for x in input().split()]
    key = 1
    nn = n
    while nn > 0:
        key += 1
        nn //= 2
    
    for _ in range(min([key*2, k])):
        b = [0]*n
        for i in range(n):
            l, r = max([i-a[i], 0]), min([i+a[i], n-1])
            b[l] += 1
            if r != n-1:
                b[r+1] -= 1
        for i in range(n):
            a[i] = 0
            a[i] += b[i]
            if i != 0:
                 a[i] += a[i-1]
    print(*a)

if __name__ == "__main__":
    main()

### FIXED CODE ###

s = input()
print(s[:3])
n=int(input())
k=1000
for i in range(1,10001):
  if n>k:
    k=k*i
  else:
    prinr(k-n)
    break
     
      

### FIXED CODE ###

n=int(input())
if n%1000==0:
  print(0)
else:
  k=n%1000
  l=1000-k
  print(l)
a=input()
if a="Sunny":
  print("Cloudy")
elif a="Cloudy":
  print("Rainy")
else:
  print("Sunny")

### FIXED CODE ###

a=input()
if a=="Sunny":
  print("Cloudy")
elif a=="Cloudy":
  print("Rainy")
else:
  print("Sunny")
def challenge(X, numlist, vec):
  for i in range(len(numlist)):
    try:
      numlist.index(X)
    except:
      return(X)
    if vec:
      X -= 1
    else:
      X += 1

list1 = input().split()
X = int(list1[0])
N = int(list1[1])
  
if N == 0:
  print(X)
else:
  list2 = input().split()
  numlist = []
  for i in list2:
    numlist.append(int(i))

  num1 = challenge(X, numlist,True)
  num2 = challenge(X, numlist,False)
  wk1 = abs(X - num1)
  wk2 = abs(X - num2)
  if wk1 > wk2:
    print(num2)
  else:
    print(num1)


### FIXED CODE ###

def challenge(X, numlist, vec):
  while True:
    try:
      numlist.index(X)
    except:
      return(X)
    if vec:
      X -= 1
    else:
      X += 1

list1 = input().split()
X = int(list1[0])
N = int(list1[1])
  
if N == 0:
  print(X)
else:
  list2 = input().split()
  numlist = []
  for i in list2:
    numlist.append(int(i))

  num1 = challenge(X, numlist,True)
  num2 = challenge(X, numlist,False)
  wk1 = abs(X - num1)
  wk2 = abs(X - num2)
  if wk1 > wk2:
    print(num2)
  else:
    print(num1)
H,W=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))

grid=[[0 for i in range(W)] for j in range(H)]
cur=0
curcnt=0
for i in range(H):
  for j in range(W):
    p=j
    if i%2==1:
      p=W-1-j
    grid[i][p]=cur+1
    curcnt+=1
    if curcnt=a[cur]:
      cur+=1
      curcnt=0
      
for i in range(H):
  print(*grid[i])
    
    
       

### FIXED CODE ###

H,W=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))

grid=[[0 for i in range(W)] for j in range(H)]
cur=0
curcnt=0
for i in range(H):
  for j in range(W):
    p=j
    if i%2==1:
      p=W-1-j
    grid[i][p]=cur+1
    curcnt+=1
    if curcnt==a[cur]:
      cur+=1
      curcnt=0
      
for i in range(H):
  print(*grid[i])
import numpy as np

H, W = map(int, input().split(" "))

lines = np.asarray([list(input().replace("\n", "")) for h in range(H)])

h_indexs, w_indexs = map(set, np.where(lines == "#"))

outlines = lines[list(h_indexs), :][:, list(w_indexs)]
for outline in outlines:
    print("".join(outline))

### FIXED CODE ###

inputs = raw_input().replace("\n", "")
N, i = map(int, inputs.split(" "))
print N + 1 - i
from bisect import bisect_right

sum_list = []
nm = 1
sm = 1
while sm <= 10**7:
    sum_list.append(sm)
    nm += 1
    sm += nm
    
n = int(input())

k = bisect_right(sum_list, n)

ans_set = set([i for i in range(1,k+2)])
ans_set.remove(sum_list[k] - n)
ans = list(ans_set)

for a in ans:
    print(a)

### FIXED CODE ###

from bisect import bisect_right

sum_list = []
nm = 1
sm = 1
while sm <= 10**8:
    sum_list.append(sm)
    nm += 1
    sm += nm
    
n = int(input())

k = bisect_right(sum_list, n)

ans_set = set([i for i in range(1,k+2)])
ans_set.remove(sum_list[k] - n)
ans = list(ans_set)

for a in ans:
    print(a)
a,b=map(int,input().split())
print(a*b if a or b >= 10 "-1")

### FIXED CODE ###

a,b=map(int,input().split())
if a >=10:
  print(-1)
elif b >= 10:
  print(-1)
else:
  print(a*b)
N_str, q_str = raw_input().spilit()
N = int(N_str)
q = int (q_str)
A =[]
B =[]
total =0

for i in N:
    t = raw_input().spilit()
    A.append(t[0],int(t[1]))

while A:
    name, time = A.pop(0)
    if time < q:
        total += time
        B.append(name, time)
       
    else:
        time -= q
        total += q
        A.append(name, time)

print " ".join(B)

### FIXED CODE ###

N_str, q_str = raw_input().split()
N = int(N_str)
q = int (q_str)
A =[]
B =[]
total =0

for i in range(N):
    t = raw_input().split()
    A.append([t[0],int(t[1])])

while A:
    name, time = A.pop(0)
    if time <= q:
        total += time
        B.append(name+" "+ str(total))
       
    else:
        time -= q
        total += q
        A.append([name, time])

print '\n'.join(B)
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
dishes = [a,b,c,d,e]
n = list()
ans = 0
for i in range(5):
  if dishes[i]%10==0:
    ans += dishes[i]//10
  else:
    ans += dishes[i]//10+1
    n.append(dishes[i]%10) 
ans = ans*10-10+min(n)
print(ans)

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
dishes = [a,b,c,d,e]
n = []
ans = 0
for i in range(5):
  if dishes[i]%10==0:
    ans += dishes[i]//10
  else:
    ans += dishes[i]//10+1
    n.append(dishes[i]%10)
if len(n)==0:
  print(ans*10)
else:
  ans = ans*10-10+min(n)
  print(ans)