Harryxun/stf_run huggingface dataset:
X=int(input())
import numpy as np
dp = np.zeros(X+1, dtype = int) #xに到達できる判定
dp[0] = 1
for t in range(1,X+1):
    if dp[X-t]==1:
        print(t)
        break
    else:
        dp[t:] = dp[:X+1-t]

### FIXED CODE ###

X=int(input())
s=0
for t in range(X+1):
  s+=t
  if s>=X:
    print(t)
    break
s = input()
sc = s.index("C")
if s[0]=="A" and s[2:-1].count("C")==1 and (s[1:sc]+s[sc+1:]).islower():
    print("AC")
else:
    print("WA")

### FIXED CODE ###

s = input()
if s[0]=="A" and s[2:-1].count("C")==1:
    sc = s.index("C")
    if (s[1:sc]+s[sc+1:]).islower():
        print("AC")
    else:
        print("WA")
else:
    print("WA")
n,a,b,c,d=map(int,input().split())
s = input()

if c > d:#追い抜きが必要な場合
    x = 0
    for i in range(b-1,d-1):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            x = 1
    if x == 0:
        print("No")#追い抜きが出来ない
    else:#追い抜き可能な場合
        check = 0#岩が2連続以上だと達成不能
        for i in range(a-1,c-1):
            if s[i] == "#" and s[i+1] == "#":
                check = 1
        if check == 1:
            print("No")
        else:
            print("Yes")
else:#a<b<c<dと並ぶ場合、もしくはacbdと並ぶ場合
    a_check = 0#Aがいけるか
    b_check = 0#Bがいけるか
    for i in range(a-1,c-1):
        if s[i] == "#" and s[i+1] == "#":
            a_check = 1
    for i in range(b-1,d-1):
        if s[i] == "#" and s[i+1] == "#":
            b_check = 1
    if a_check == 0 and b_check == 0:
        print("Yes")
    else:

### FIXED CODE ###

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

if c > d:#追い抜きが必要な場合
    x = 0
    for i in range(b-2,d-1):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            x = 1
    if x == 0:
        print("No")#追い抜きが出来ない
    else:#追い抜き可能な場合
        check = 0#岩が2連続以上だと達成不能
        for i in range(a-1,c-1):
            if s[i] == "#" and s[i+1] == "#":
                check = 1
        if check == 1:
            print("No")
        else:
            print("Yes")
else:#a<b<c<dと並ぶ場合、もしくはacbdと並ぶ場合
    a_check = 0#Aがいけるか
    b_check = 0#Bがいけるか
    for i in range(a-1,c-1):
        if s[i] == "#" and s[i+1] == "#":
            a_check = 1
    for i in range(b-1,d-1):
        if s[i] == "#" and s[i+1] == "#":
            b_check = 1
    if a_check == 0 and b_check == 0:
        print("Yes")
    else:
        print("No")
b = input()
if b == "A":
  print("T")
elif b == "G":
  print("C")
elif b == "C":
  print("G")
else b == "T":
  print("A")
  

### FIXED CODE ###

b = input()
if b == "A":
  print("T")
elif b == "G":
  print("C")
elif b == "C":
  print("G")
else:
  print("A")
str = input()

if(str == 'ARC'){
  print('ABC')
}else{
  print('ARC')
}

### FIXED CODE ###

s = input()


if s == "ARC":
  print("ABC")
else:
  print("ARC")
n,m=map(int,input().split())
mod=10**9+7
sn=1
for i in range(n+1):
    sn*=i
for j in range(m+1):
    sm*=j
if 2<=abs(n-m):
    print(0)
elif abs(n-m)==1:
    print(sn*sm)
elif n==m:
    print(2*sn*sm)
    
    

### FIXED CODE ###

import math
mod=10**9+7
n,m=map(int,input().split())
ans=0
if abs(n-m)==0:
    ans=math.factorial(n)*math.factorial(m)*2
elif abs(n-m)==1:
    ans=math.factorial(n)*math.factorial(m)
else:
    ans=0
ans=ans%mod
print(ans)
n = int(input)
for i in range(n):
    t,x,y = map(int, input(),split())
    if x+y>t or (x+y+t)%2 :
    	print("No")
    	exit()
print("Yes")

### FIXED CODE ###

n = int(input())
for i in range(n):
    t,x,y = map(int, input().split())
    if x+y>t or (x+y+t)%2 :
    	print("No")
    	exit()
print("Yes")
num = int(input())
List = input().split(" ")
height = [int(n) for n in List]
dp = [{} for n in range(10 ** 5 * 2)]
def jump(a,now):
  if now in dp[a]:
    return dp[a][now]
  if a == num:
    res = 0
  elif a+2 > num:
    res = jump(a+1,height[a])+abs(now-height[a])
  else:
    res = min(jump(a+1,height[a])+abs(now-height[a]),jump(a+2,height[a+1])+abs(now-height[a+1]))
  dp[a][now] = res
  return res
print(jump(1,height[0]))

### FIXED CODE ###

num = int(input())
List = input().split(" ")
height = [int(n) for n in List]
dp = [0 for n in range(10 ** 5 * 2)]
a = 0
while dp[num-1] == 0:
  a+= 1
  if a == num:
    break
  if a == 1:
    dp[a] = abs(height[a]-height[a-1])
  else:
    dp[a] = min(abs(height[a]-height[a-1])+dp[a-1],abs(height[a]-height[a-2])+dp[a-2])
print(dp[num-1])
import sys
from itertools import combinations

def input():
    return sys.stdin.readline().rstrip()

if __name__ == "__main__":
    n, k = map(int, input().split())

    for i in range(1, k+1):
        mul = 1
        div = 1

        for j in range(i):
            mul *= ((n-k+1)-j)
            div *= (i-j)

        for j in range(i-1):
            mul *= ((k-1)-j)
            div *= ((i-1)-j)

        print(int(mul / div % (10**9+7)))


### FIXED CODE ###

import sys
import math

def input():
    return sys.stdin.readline().rstrip()

def combination(n, r):
    return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

if __name__ == "__main__":
    n, k = map(int, input().split())

    for i in range(1, k+1):
        if n-k+1 >= i and k-1 >= i-1:
            print((combination(n-k+1, i) * combination(k-1, i-1)) % (10**9+7))
        else:
            print(0)
n = int(input())
ls = []
for _ in n:
  ls.append(input())
  
 print(len(set(ls))

### FIXED CODE ###

n = int(input())
ls = []
for _ in range(n):
  ls.append(input())
  
print(len(set(ls)))
import sys
sys.setrecursionlimit(10000)

N = int(input())
H = [-1] + list(map(int, input().split()))

def func(i):
    if i == 0:
        return 0
    else:
        if i - 2 < 0:
            return 0
        elif i - 1 < 0:
            return 0
        else:
            return min((func(i-1)+abs(H[i-1]-H[i]), func(i-2)+abs(H[i-2]-H[i])))

print(func(N))

### FIXED CODE ###

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

dp = [0] * N
dp[1] = abs(H[1]-H[0])
for i in range(2, N):
    dp[i] = min((dp[i-1]+abs(H[i-1]-H[i]), dp[i-2]+abs(H[i-2]-H[i])))

print(dp[N-1])
N, M = map(int, input().split())
if N == 1 and M == 1:
    print(1)
elif N == 1 and M != 1:
    print(M - 2)
elif M == 1 and N != !:
    print(M - 2)
else:
    print((N-2)*(M-2))

### FIXED CODE ###

N, M = map(int, input().split())
if N == 1 and M == 1:
    print(1)
elif N == 1 and M != 1:
    print(M - 2)
elif M == 1 and N != 1:
    print(N - 2)
else:
    print((N-2)*(M-2))
S = input()

if S[3] == S[4] and S [5] == S[6]:
	print("Yes")
else:
	print("No")

### FIXED CODE ###

S = input()

if S[2] == S[3] and S [4] == S[5]:
	print("Yes")
else:
	print("No")
import math
N = int(input())
X = floor(float(N/(1.08)))

if X==N:
    print(X)
else:
    print(":(")


### FIXED CODE ###

import math
from math import ceil, floor
N = int(input())
X = ceil(N/(1.08))
M = floor(X*1.08)

if M==N:
    print(X)
else:
    print(":(")
# -*- coding: utf-8 -*-
import math,sys

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

print(math.ceil((math.log(Y,10)-math.log(X,10))/math.log(2,10)))


### FIXED CODE ###

# -*- coding: utf-8 -*-
A,B,C,D = map(int,input().split(' '))

if A+B > C+D:
    print('Left')
elif A+B is C+D:
    print('Balanced')
else:
    print('Right')
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

def get_path(start, goal, pred):
    return get_path_row(start, goal, pred[start])
    
def get_path_row(start, goal, pred_row):
    path = []
    i = goal
    while i != start and i >= 0:
        path.append(i)
        i = pred_row[i]
    if i < 0:
        return []
    path.append(i)
    return path[::-1]

n,m = map(int, input().split())
a=[]
b=[]
for i in range(m):
    aa,bb=map(int,input().split())
    a.append(aa)
    b.append(bb)

graph=np.zeros((n,n))

for i in range(m):
    graph[a[i]-1][b[i]-1] = 1
    graph[b[i]-1][a[i]-1] += 1

d,p=shortest_path(graph,return_predecessors=True)

for i in range(1,n):
    for j in range(i,n):
        if graph[i][j] == np.inf:
            print('No')
            break
        if i == n - 1 and j == n -1:
            print('Yes')
            for i in range(1,n):
                michi= get_path(0,i,p)
                print(michi[-2]+1)

### FIXED CODE ###

n,m=map(int,input().split())
g=[[] for _ in range(n)]

for _ in range(m):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

from collections import deque

def bfs(u):
    queue = deque([u])
    d=[-1]*n
    pre=[-1]*n
    d[u]=0
    while queue:
        v=queue.popleft()
        for i in g[v]:
            if d[i] is -1:
                if pre[i] == -1:
                    pre[i]=v
                d[i]=d[v]+1
                queue.append(i)
    return d,pre
d,pre=bfs(0)
print('Yes')

for i in range(n):
    if i==0:
        continue
    print(pre[i]+1)
k,x = map(int,input().split())
c =[]
for i in range(x-k,x+k):
  c.append(i)
print(" ".join(c))

### FIXED CODE ###

k,x = map(int,input().split())
c =[]
for i in range(x-k+1,x+k):
  c.append(i)
print(' '.join(map(str,c)))
S = input()
w = int(input())

Ans = []
for i in range((len(S) // w) + 1):
    Ans.append(S[int(i*w)])

print("".join(Ans))


### FIXED CODE ###

S = input()
w = int(input())

SS = S[::w]
print(SS)
import sys

if __name__=="__main__":
    ab=[]
    cd=[]
    [n,m]=map(int,raw_input().split(" "))
    for i in range(n):
        ab.append( map(int,raw_input().split(" ")) )
    for j in range(m):
        cd.append( map(int,raw_input().split(" ")) )
    for i in range(n):
        min=sys.maxint
        index=0
        for j in range(m):
            distance = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
            if min > distance :
                min=distance 
                index=j
        print(index+1)


### FIXED CODE ###

print(sum(map(int,raw_input().split()))%24)
n,m = int(input().split())


print(m*n)

### FIXED CODE ###

n,m = input().split()

n = int(n)
m = int(m)


print((m-1)*(n-1))
a=int(input());
b=int(input());
c=int(input());
if(a+b>c) print("Yes");
else print("No");

### FIXED CODE ###

a, b, c = map(int, input().split())
if(a+b>=c):
  print("Yes")
else:
  print("No")
import sys
sys.setrecursionlimit(160000)

H,W = map(int,input().split(' '))
S = []
for i in [0]*H:
	l = input()
	S.append([1 if x == '#' else -1 for x in l])

bk = 0
wh = 0
def check(S,x,y):
	global bk
	global wh
	if S[y][x] == 0:
		return
	if S[y][x] == 1:
		bk += 1
		S[y][x]=0
		if 0 < y and S[y-1][x] == -1:
			check(S,x,y-1)
		if 0 < x and S[y][x-1] == -1:
			check(S,x-1,y)
		if y < H-1 and S[y+1][x] == -1:
			check(S,x,y+1)
		if x < W-1 and S[y][x+1] == -1:
			check(S,x+1,y)
		return
	if S[y][x] == -1:
		wh += 1
		S[y][x]=0
		if 0 < y and S[y-1][x] == 1:
			check(S,x,y-1)
		if 0 < x and S[y][x-1] == 1:
			check(S,x-1,y)
		if y < H-1 and S[y+1][x] == 1:
			check(S,x,y+1)
		if x < W-1 and S[y][x+1] == 1:
			check(S,x+1,y)
		return

cnt = 0
for y in range(H):
	for x in range(W):
		if S[y][x] == 1:
			check(S,x,y)
			cnt += wh*bk
			wh = 0
			bk = 0
print(cnt)




### FIXED CODE ###

import sys
sys.setrecursionlimit(200000)

H,W = map(int,input().split(' '))
S = []
for i in [0]*H:
	l = input()
	S.append([1 if x == '#' else -1 for x in l])

bk = 0
wh = 0
def check(S,x,y):
	global bk
	global wh
	if S[y][x] == 0:
		return
	if S[y][x] == 1:
		bk += 1
		S[y][x]=0
		if 0 < y and S[y-1][x] == -1:
			check(S,x,y-1)
		if 0 < x and S[y][x-1] == -1:
			check(S,x-1,y)
		if y < H-1 and S[y+1][x] == -1:
			check(S,x,y+1)
		if x < W-1 and S[y][x+1] == -1:
			check(S,x+1,y)
		return
	if S[y][x] == -1:
		wh += 1
		S[y][x]=0
		if 0 < y and S[y-1][x] == 1:
			check(S,x,y-1)
		if 0 < x and S[y][x-1] == 1:
			check(S,x-1,y)
		if y < H-1 and S[y+1][x] == 1:
			check(S,x,y+1)
		if x < W-1 and S[y][x+1] == 1:
			check(S,x+1,y)
		return

cnt = 0
for y in range(H):
	for x in range(W):
		if S[y][x] == 1:
			check(S,x,y)
			cnt += wh*bk
			wh = 0
			bk = 0
print(cnt)
N,M,K = map(int,input().split())
A_time = list(map(int,input().split()))
B_time = list(map(int,input().split()))
all_time = 0
a_t = A_time.pop(0)
b_t = B_time.pop(0)
count = 1
while all_time < K:
    if a_t <= b_t:
        all_time = all_time + a_t
        if count == 1 and all_time > K:
            count = -1
            break
        a_t = A_time.pop(0)
        count +=1
    else:
        all_time = all_time + b_t
        if count == 1 and all_time > K:
            count = -1
            break
        b_t = B_time.pop()
        count +=1
    if len(A_time)==0 or len(B_time)==0:
        break
        
if all_time > K:
    print(count-1)
elif count == -1:
    print(0)
else:
    if len(A_time)==0:
        while all_time > K:
            all_time = all_time + b_t
            count += 1
            b_t = B_time.pop(0)
        print(count - 1)
    else:
        while all_time > K:
            all_time = all_time + a_t
            count += 1
            b_t = A_time.pop(0)
        print(count - 1)

### FIXED CODE ###

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

a,b = [0],[0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

ans,j = 0,M
for i in range(N+1):
    if a[i]>K:
        break    
    while b[j]>K-a[i]:
        j -= 1    
    ans = max(ans,i+j)
print(ans)
H,K=map(int,input().split())
lst_0=list(map(int,input().split()))
DP[0]=0
lst_2=[]
for i in range(1,H):
    lst_1=[]
    for j in range(1,K+1):
        if i - j >= 0:
            DP[i]=abs(lst_0[i]-lst_0[i-j])+DP[i-j]
            lst_1.append(DP[i])
    DP[i]=min(lst_1)
print(DP[-1])

### FIXED CODE ###

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

def hantei(n,aaa):
	dp = [0]*(n+1)
	dp[0] = 0
	dp[1] = abs(aaa[1]-aaa[0])
	for i in range(n-2):
		dp[i+2] = min(dp[i+1]+abs(aaa[i+2]-aaa[i+1]),dp[i]+abs(aaa[i+2]-aaa[i]))
	return dp[n-1]

print(hantei(n,aaa))
n,m = map(int,input().split())
G = [[] for _ in range(n)]
for _ in range(m):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    G[x].append(y)

dp = [-1]*(n+1)
# dp[i]:頂点iに到達したときの有向辺の最長の長さ
def dfs(cur):
    if dp[cur] != -1:
        return dp[cur]
    res = 0
    for nx in G[cur]:
        res = max(res,dfs(nx)+1)
    dp[cur] = res
    return res
    
for i in range(n):
    dp[i] = max(dp[i],dfs(i))

print(max(dp))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

def dfs(cur):
  if dp[cur]!=-1:
    return dp[cur]
  res=0
  for nx in G[cur]:
    res=max(res,dfs(nx)+1)
  dp[cur]=res
  return res

n,m=map(int,input().split())
G=[[] for i in range(n)]
for i in range(m):
  x,y=map(int,input().split())
  G[x-1].append(y-1)

dp=[-1]*n
for i in range(n):
  dp[i]=max(dp[i],dfs(i))
print(max(dp))
a,b =map(int,input(),split())
ss = (a*b)//2
print(ss)


### FIXED CODE ###

a,b =map(int,input().split())
ss = a*b
hf =ss//2
if a>1 and b>1:
	print(ss-hf)
else:
  print(1)
import numpy as np
N,W=map(int,input().split())
w=[]
v=[]
maxV=0
for i in range(N):
    a,b=map(int,input().split())
    if maxV<b:
        maxV=b
    w.append(a)
    v.append(b)
w=np.array(w)
v=np.array(v)
#dp[n個目のアイテムまでで][V以上を達成する]=最小のw
#dp[0][v]=inf ゼロ個でｖは無理なので
#dp[0][0]=0と初期化する
#だからiの時dp[i][v]=min(dp[i-1][v],dp[i-1][V-v[i-1]]+w[i])である<-i-1なのはvとかにはゼロ個とかないので
#V-v[i]<0ならば、とれないので前者になるね！！
#これをi=0(は初期化でする)->nまでおこない、各iについてはとりうる最大のValueを考えるが
#これは最大で各アイテムについて最大のVがあってこれにアイテム数Nを掛けたものである
#つまりdpのサイズはdp[0->N][0->maxV*N]をとればよい

dp=[[float("inf") for i in range(maxV*(N+1))] for j in range(N+1)]
dp[0][0]=0

for i in range(1,N+1):
    for val in range(maxV*N+1):
        tmp1=dp[i-1][val]#とらない
        if val-v[i-1]<0:#この時、iこめの価値がおおきいので、これをとるだけで達成してしまう
            tmp2=w[i-1]#i=1の時、dp[0][val]=inf
        else:#i=1の時val-v[0]>0で無限になるので
            tmp2=dp[i-1][val-v[i-1]]+w[i-1]#
        res=min(tmp1,tmp2)
        dp[i][val]=res
#ここでW以下となるvalの最大値をたんさくする
max=0
for value in range(len(dp[N])):
    if dp[N][value]<=W:
        if value>max:
            max=value
print(max)



### FIXED CODE ###

N,W=map(int,input().split())
w=[]
v=[]
maxV=0
for i in range(N):
    a,b=map(int,input().split())
    if maxV<b:
        maxV=b
    w.append(a)
    v.append(b)
#dp[n個目のアイテムまでで][V以上を達成する]=最小のw
#dp[0][v]=inf ゼロ個でｖは無理なので
#dp[0][0]=0と初期化する
#だからiの時dp[i][v]=min(dp[i-1][v],dp[i-1][V-v[i-1]]+w[i])である<-i-1なのはvとかにはゼロ個とかないので
#V-v[i]<0ならば、とれないので前者になるね！！
#これをi=0(は初期化でする)->nまでおこない、各iについてはとりうる最大のValueを考えるが
#これは最大で各アイテムについて最大のVがあってこれにアイテム数Nを掛けたものである
#つまりdpのサイズはdp[0->N][0->maxV*N]をとればよい

dp=[[float("inf") for i in range(maxV*(N+1))] for j in range(N+1)]
dp[0][0]=0

for i in range(1,N+1):
    for val in range(maxV*N+1):
        tmp1=dp[i-1][val]#とらない
        if val-v[i-1]<0:#この時、iこめの価値がおおきいので、これをとるだけで達成してしまう
            tmp2=w[i-1]#i=1の時、dp[0][val]=inf
        else:#i=1の時val-v[0]>0で無限になるので
            tmp2=dp[i-1][val-v[i-1]]+w[i-1]#
        res=min(tmp1,tmp2)
        dp[i][val]=res
#ここでW以下となるvalの最大値をたんさくする
max=0
for value in range(len(dp[N])):
    if dp[N][value]<=W:
        if value>max:
            max=value
print(max)
A, B, C = map(int, raw_input().split())

if (C % A) == 0 and (B % A) == 0 or \
        (C % A) % (B % A) == 0:
    print('YES')
else:
    print('NO')


### FIXED CODE ###

import sys

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

for i in range(1, 101):
    if C == 0 and (B * i % A) == 0 or \
            (C % A) == 0 and (B * i % A) == 0 or \
            (B * i % A) != 0 and (C % A) % (B * i % A) == 0:
        print('YES')
        sys.exit()

print('NO')
n,m=map(int,input())
print(n*(n-1)//2+m*(m-1)//2)

### FIXED CODE ###

n,m=map(int,input().split())
print(n*(n-1)//2+m*(m-1)//2)
s = input()
t = input()

s_len = len(s)
t_len = len(t)

result = ''
for i in range(s_len - t_len, -1, -1):
    match = False
    s_part = s[i:i + t_len]
    for j in range(t_len + 1):
        if j == t_len:
            result = (s[0:i] + t + s[i + t_len:]).replace('?', 'a')
            match = True
            break
        if s_part[j] == '?':
            continue
        if s_part[j] != t[j]:
            match = False
            break
    if match:
        break

print(result if match else 'UNRESTORABLE')

### FIXED CODE ###

s = input()
t = input()

s_len = len(s)
t_len = len(t)

result = ''
match = False
for i in range(s_len - t_len, -1, -1):
    match = False
    s_part = s[i:i + t_len]
    for j in range(t_len + 1):
        if j == t_len:
            result = (s[0:i] + t + s[i + t_len:]).replace('?', 'a')
            match = True
            break
        if s_part[j] == '?':
            continue
        if s_part[j] != t[j]:
            match = False
            break
    if match:
        break

print(result if match else 'UNRESTORABLE')
N,K=map(int,input().split())
a=list(map(int,input().split()))
L=[]
for i in range(N):
    for j in range(i+1,N+1):
        L.append(sum(a[i:j]))

L.sort(reverse=True)
M=[]
#print(L)

for j in range(31):
    if 2**(31-j)<=L[0]:
        if 2**(31-j)<=L[K-1]:
            for l in range(N):
                if L[l]>=2**(31-j):
                    M.append(L[l])
            break
        else:
            for k in range(N):
                L[k]=L[k]%(2**(31-j))
            L.sort(reverse=True)
            
ans=0
#print(M)
#print(31-j)
for a in range(31-j):
    M.sort(reverse=True)
    if M[K-1]>=2**(31-j-a):
        ans+=2**(31-j-a)
        for b in range(len(M)):
            if M[b]>=2**(31-j-a):
                M[b]%=2**(31-j-a)
            else:
                del M[b]
    
        
print(ans)


### FIXED CODE ###

N,K=map(int,input().split())
l=list(map(int,input().split()))
L=[0]
for i in range(N):
    L.append(L[-1]+l[i])
#print(L)
A=[]
for i in range(N):
    for j in range(i+1,N+1):
        A.append(L[j]-L[i])
#print(A)
B=[]
for i in range(len(A)):
    B.append(format(A[i],'040b'))
#print(B)


for i in range(40):
    cnt=0
    for j in B:
        if j[i]=="1":
            cnt+=1
    if cnt>=K:
        S=i
        break

ans=2**(39-S)
C=[]
for j in B:
    if j[S]=="1":
        C.append(j)
        
#print(ans)
#print(C)

for i in range(S+1,40):
    D=[]
    for j in C:
        if j[i]=="1":
            D.append(j)
    if len(D)>=K:
        ans+=2**(39-i)
        C=D
print(ans)
# coding: utf-8

def triangles(L, s, c, n):
    if c == len(L):
        return(n)
    if L[c] < s:
        n += 1
        return(triangles(L, s, c + 1, n))
    else:
        return(n)

N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0
dp = []
for i in range(2001):
    dp.append(-1)
for i in range(N):
    for j in range(i + 1, N - 1):
        if dp[L[i] + L[j]] >= 0:
            ans += dp[L[i] + L[j]]
        else:
            dp[L[i] + L[j]] = triangles(L, L[i] + L[j], j + 1, 0)
            ans += dp[L[i] + L[j]]
print(ans)

### FIXED CODE ###

# coding: utf-8
import bisect

N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0
for i in range(N):
    for j in range(i + 1, N - 1):
        ans += max(bisect.bisect_right(L, L[i] + L[j] - 1) - j - 1, 0)
print(ans)
import sys

def my_index(l, x):
    if x in l:
        return l.index(x)
    else:
        return -1

input = sys.stdin.readline
n,m = map(int, input().split())
A = list(map(int,input().split()))
d = {}
for i in range(m):
    b,c = map(int, input().split())
    if d.get(c) == None:
        d[c] = b
    else:
        d[c] = d[c] + b

for c, b in sorted(d.items(), key=lambda x: -x[0]):
    A.sort()
    if b > n:
        b = n
    if A[0] < c:
        if A[b] > c:
            f=0
            for i in range(b):
                if A[i] // c == 0:
                    f = i
                else:
                    break
            A[:f+1]=[c]*(f+1)
        else:
            A[:b]=[c]*b


print(sum(A))

### FIXED CODE ###

import sys
import heapq

input = sys.stdin.readline
n,m = map(int, input().split())
A = list(map(int,input().split()))
d = [list(map(int,input().split())) for _ in range(m)]

d.sort(key=lambda x:-x[1])
total = sum(A)
heapq.heapify(A)

for i in range(m):
    for j in range(d[i][0]):
        tmp = heapq.heappushpop(A, d[i][1])
        if tmp < d[i][1]:
                total += (d[i][1] - tmp)
        else:
            break

print(total)
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

dishes=[I() for i in range(0,5)]
rounded = []
for i in dishes:
    if i%10 != 0:
        i += 10 - i % 10
    rounded.append(i)
result=10**10
for i in range(len(dishes)):
    # order i in the end
    result = min(result, sum([r for ridx, r in rounded if ridx != i] + dishes[i])
    
print(result)
    
    

### FIXED CODE ###

import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

v = []
for i in range(5):
    v.append(I())

# 全探索？
# 1の位が一に一番近いものを求める
str_v = [str(i) for i in v]
min_first_digit = None
for sidx, s in enumerate(str_v):
    if s[-1] == '0':
        continue
    if min_first_digit == None:
        min_first_digit = [sidx , s[-1]]
        continue
    if s[-1] < min_first_digit[1]:
        min_first_digit = [sidx, s[-1]]

if min_first_digit == None:
    print(sum(v))
else:
    result = 0
    for vidx, item in enumerate(v):
        if vidx != min_first_digit[0]:
            result += item
            if item % 10 != 0:
                result += 10 - item % 10
    result += v[min_first_digit[0]]
    print(result)