peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N=int(input())
a=list(map(int,input().split()))
o=0
m=0
u=[0]*8
for i in a:
    if 3199<i:
        o+=1
    else:
        if u[i//400]==0:
            u[i//400]+=1
            m+=1
print(max(m,1),m+o)
# Judge status: Wrong Answer
N = list(input())
l = [int(x) for x in N]
if 0 in l:
    l.remove(0)
ma = max(l)
mi = min(l)
m = str(max(l))
n = str(min(l))
o = int(''.join(N))

if int(n*3) > o:
    print(int(n*3))
else:
    print(int(m*3))
# Judge status: Wrong Answer
N,M = map(int,input().split())
a = list(map(int, input().split()))
for i in range(M):
  N -= a[i]
print(N if N>1 else '-1')
# Judge status: Accepted
def main():
    X = int(input())
    ans = 1
    for i in range(2, X+1):
        for j in range(2, 11):
            if i**j > X:
                break
            else:
                ans = max(ans, i**j)
    print(ans)

if __name__ == "__main__":
    main()
# Judge status: Accepted
A,B,X=map(int,input().split())
if A+B>=X:
    if X<A :
        print('NO')
    else :
        print('YES')
else :
    print('NO')
# Judge status: Accepted
H = int(input())
output = 0
t = 1
while H>0:
    output += t
    H = int(H/2)
    t *= 2
print(output)
# Judge status: Accepted
a, b, c = map(int, input().split())

if a%2 == 0 and a==b==c:
    print(-1)
    exit()

i = 0
a_, b_, c_ = a, b, c

while a%2 == 0 and b%2 == 0 and c%2 == 0:
    i += 1
    a = b_//2 + c_//2
    b = a_//2 + c_//2
    c = a_//2 + b_//2
    a_, b_, c_ = a, b, c

print(i)
# Judge status: Accepted
a=[input() for _ in range(int(input()))]
now=1
cnt=0
while cnt<=len(a):
    now=int(a[now-1])
    cnt+=1
    if now==2: break
print(cnt if now==2 else '-1')
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
ans=10000000
for i in range(-101,102):
    tmp=0
    for j in range(n):
        tmp+=(a[j]-i)**2
    if tmp<ans:
        ans=tmp
print(ans)
# Judge status: Accepted
N, K = map(int, input().split())
if (N - 1) % (K - 1) == 0:
  print((N - 1) // (K - 1))
else:
  print((N - 1) // (K - 1) + 1)
# Judge status: Wrong Answer
N = int(input())
a = list(map(int, input().split()))

t = (0, 0)
for y in range(min(a), max(a)):
    sum = 0
    for x in a:
        sum += (x - y) ** 2
    if t[0] == 0 or t[1] > sum:
        t = (y, sum)

print(t[1])
# Judge status: Accepted
S = input()
T = input()

for _ in range(len(S)):
    S_lst = list(S)
    tmp = S[0]
    for i in range(len(S) - 1):
        S_lst[i] = S_lst[i+1]
    S_lst[-1] = tmp
    S = ''.join(S_lst)
    
    if S == T:
        print("Yes")
        exit()
else:
    print("No")
# Judge status: Wrong Answer
N,K = map(int,input().split())
A = list(map(int,input().split()))

index = A.index(1)
cnt = 1

right = 0
left = 0

if (N-1)//2 < index:
    right = N-1-index
    left = index-(K-1)
else:
    left = index
    right = N-1-index-(K-1)

if left%(K-1) == 0:
    cnt += left//(K-1)
else:
    cnt += left//(K-1)+1
if right%(K-1) == 0:
    cnt += right//(K-1)
else:
    cnt += right//(K-1)+1

print(cnt)
# Judge status: Accepted
a,b,c,d = map(int, input().split())

i = 0
while a > 0 and c > 0:
    if i%2 == 0:
        c -= b
    else:
        a -= d
    i += 1

if a > c:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())

s = []
for i in range(n):
  s.append(input())
  
print(len(set(s)))
# Judge status: Accepted
from bisect import bisect_left as bl,bisect_right as br
n=int(input())
a,b,c=[sorted(list(map(int,input().split()))) for i in range(3)]
ans=0
for v in b:
  if v<=a[0] or v>=c[-1]:continue
  ans+=bl(a,v)*(n-br(c,v))
print(ans)
# Judge status: Wrong Answer
N = int(input())
S = [i for i in str(input())]

print("AC x " + str(S.count('AC')))
print("WA x " + str(S.count('WA')))
print("TLE x " + str(S.count('TLE')))
print("RE x " + str(S.count('RE')))
# Judge status: Accepted
n = int(input().rstrip())
r = int(n / 2) + (n % 2)
print(r / n)
# Judge status: Accepted
  
# Can't Wait for Holiday

S = input()

if S == 'SUN':
    a = 0
elif S == 'MON':
    a = 1
elif S == 'TUE':
    a = 2
elif S == 'WED':
    a = 3
elif S == 'THU':
    a = 4
elif S == 'FRI':
    a = 5
elif S == 'SAT':
    a = 6

answer = 7 - a

print(answer)
# Judge status: Accepted
#
# 172C Go to school
#
a = []
n = input()
nums = [int(e) for e in input().split()]

for i in range(int(n)):
    a.append([i, nums[i]])

a_sorted = sorted(a, key=lambda x: x[1])

for i in range(int(n)):
    print(str(a_sorted[i][0]+1), end=' ')
# Judge status: Accepted
W, H, x, y = map(int, input().split())

R = 0
if W == 2*x and H == 2*y:
    R = 1

print(W*H / 2,R)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
B = [0] * len(A)
C = [0] * len(A)
for i in range(len(A)):
  B[i] = A[i] + 1
  C[i] = A[i] - 1

t= 0
m = 0
for X in range(1 , max(A) + 1):
  t = A.count(X) + B.count(X) + C.count(X)
  m = max(m,t)
print(m)
# Judge status: Accepted
x = int(input())
li = [1]
for i in range(100):
    n = 2
    while x >= (i+2)**n:
        li.append((i+2)**n)
        n += 1
print(max(li))
# Judge status: Wrong Answer
s = int(input())

a = [s]
used = [0] * (10**6+1)
for i in range(2, 10**6+2):
    if a[-1] % 2 == 0:
        a.append(val := a[-1]//2)
    else:
        a.append(val := 3*a[-1]+1)

    if used[val]:
        print(i)
        break
    else:
        used[val] = 1
# Judge status: Wrong Answer
a,b = map(int,input().split())
print("Possible" if a%3==0 or b%3==0 or (a+b)%3==0 else "Impossilbe")
# Judge status: Accepted
n=int(input())
lis=list(map(int,input().split(' ')))
node=[0,abs(lis[1]-lis[0])]+[0]*(n-2)
for i in range(2,n):
    x=abs(lis[i]-lis[i-1])+node[i-1]
    y=abs(lis[i]-lis[i-2])+node[i-2]
    node[i]=min(x,y)
print(node[-1])
# Judge status: Accepted
from collections import deque

K = int(input())
d = deque([1,2,3,4,5,6,7,8,9])

for i in range(K-1):
    num = d.popleft()
    mod = num % 10
    if mod != 0:
        d.append(num*10+mod-1)
    d.append(num*10+mod)
    if mod != 9:
        d.append(num*10+mod+1)
print(d.popleft())
# Judge status: Accepted
s = input()

if "R" not in s:
    print(0)
    exit()
ans = 1
for i in range(2):
    if s[i] == "R" and s[i+1] == "R":
        ans += 1

print(ans)
# Judge status: Accepted
from sys import exit
S = input()

if 0 < int(S[0:2]) < 13:
    if 0 < int(S[2:]) < 13:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 0 < int(S[2:]) < 13:
        print("YYMM")
    else:
        print("NA")
# Judge status: Accepted
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
point = 0
win = [0 for i in range(len(t))]

for i in range(len(t)):
  if t[i] == 'r':
    if (t[i-k] != 'r') or (win[i-k] != 1):
      point += p
      win[i] = 1

  if t[i] == 's':
    if (t[i-k] != 's') or (win[i-k] != 1):
      point += r
      win[i] = 1
    
  if t[i] == 'p':
    if (t[i-k] != 'p') or (win[i-k] != 1):
      point += s
      win[i] = 1

print(point)
# Judge status: Wrong Answer
k, a, b = map(int, input().split())
if 2 >= b - a or k+1 <= a:
    print(k+1)
else:
    i = (k-a+1)//2+1
    ans = k+1 -a*i + b*i -2*i
    print(ans)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
count = 0
d={}
for i in range(n):
    if i - a[i] in d:
        count+=d[i - a[i]]
    if i + a[i] in d:
        d[i+a[i]] + 1
    else:
        d[i+a[i]] = 1

print(count)
# Judge status: Wrong Answer
n = int(input())
a = input().split()

for i in range(n):
    print(a.count(i+1))
# Judge status: Accepted
a, b, x = map(int, input().split())
if a % x == 0:
  b -= b % x
  print((b - a)//x + 1)
else:
  a -= a % x
  b -= b % x
  print((b - a)//x)
# Judge status: Accepted
n,k = map(int,input().strip().split())
d = list(input().split())
for x in range(n,100000):
    for y in d:
        if y in str(x):
            break
    else:
        print(x)
        break
# Judge status: Wrong Answer
h = int(input())
ans = 0
i = 0
while True:
  if(i>=h):
    break
  i+=1
if(i == 0):
  print(1)
else:
  print(2**(i+1)-1)
# Judge status: Accepted
import sys
# import math

N = int(input())
A = list(map(int, input().split()))
kari = [0] * (N+1)

ans = 0
nokori = 1

for i in range(N+1):
    if (nokori == 0)or(A[i] > nokori):
        print(-1)
        sys.exit()

    nokori -= A[i]
    ans += A[i]
    # dump((i,ans,nokori))
    kari[i] = nokori
    nokori *= 2

mx = A[N]

for i in reversed(range(N)):
    mx = min(kari[i], mx)
    ans += mx
    mx += A[i]

print(ans)
# Judge status: Accepted
import numpy as np

N = int(input())
A = list(map(int, input().split()))
sum_A = sum(A)
snuke = np.cumsum(A)[:-1]
kuma =  sum_A - snuke

ans = min(abs(snuke-kuma))
 
print(ans)
# Judge status: Wrong Answer
X = int(raw_input())

def check_prime(X):
    import math
    s = int(math.ceil(math.sqrt(X)))
    print s
    for a in range(2, s):
        print X, a
        if X % a == 0: 
            return False
    return True

while True:
    if check_prime(X): break
    X += 1

print X
# Judge status: Accepted
import  math
N,M = map(int,input().split())

def f(M):
    l = []
    for i in range(1,int(math.sqrt(M))+1):
        if M%i==0:
            l.append(i)
    n = len(l)
    for i in range(n):
        j = l[n-1-i]
        if M/j!=j:
            l.append(M//j)
    return l

l = f(M)

for i in range(len(l)):
    n = l[-1-i]
    if M/n >= N:
        ans = n
        break
print(ans)
# Judge status: Accepted
n = int(input())
s = input()
t = input()

ans = n * 2
chk = False

for i in range(n):
    j = 0
    while i+j < n:
        if s[i+j] == t[j]:
            ans -= 1
            j += 1
            chk = True
        else:
            ans = n * 2
            chk = False
            break
    if chk:
        break

print(ans)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 19:58:50 2020

@author: liang
"""
import math
a, b, x = map(int, input().split())

if x >= a**2*b/2:
    ans = math.degrees(math.atan((b-x/a**2)/a*2))
else:
    ans = 90 - math.degrees(math.atan(x/a/b**2))
print(ans)
# Judge status: Accepted
N = int(input())
s = input()
t = input()
c = 0
for o in range(len(s) + 1):
    d = 0
    for i in range(len(t)):
        if o + i >= len(s): break
        if s[o + i] == t[i]: d += 1
        else: break
    c = max(c, d)
print(len(s) + len(t) - c)
# Judge status: Wrong Answer
X, A, B = map(int, input().split())
if B - A < X:
    print('safe')
else:
    print('dangerous')
# Judge status: Accepted
n,tmax=map(int,input().split())
m=1001
for i in range(n):
  c,t=map(int,input().split())
  if t<= tmax:
    m = min(m,c)
print("TLE" if m == 1001 else m)
# Judge status: Wrong Answer
n = int(input())

x = 1
cnt = 1
while x < n:
  x = 2 ** cnt
  cnt += 1
print(x/2)
# Judge status: Wrong Answer
print(0, 0, 0, 1, input(), 0)
# Judge status: Accepted
h, n = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())

dp = [[1e18] * (h + 1) for _ in range(n + 1)]
dp[0][0] = 0

for i in range(n):
    for j in range(h + 1):
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        dp[i + 1][min(j + a[i], h)] = min(dp[i + 1][min(j + a[i], h)], dp[i + 1][j] + b[i])

print(dp[n][h])
# Judge status: Accepted
import sys

x,y=map(int,input().split())
output=0
while True:
	if x * (2**output) >y :
		print(output)
		sys.exit()
	else:
		output+=1
# Judge status: Accepted
r = int(input())

print(int(r * r))
# Judge status: Accepted
s=input()
if s=='RRR':
    print(3)
elif s=='SRR':
    print(2)
elif s=='RRS':    
    print(2)
elif s=='SSS':
    print(0)
else:
    print(1)
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))
freq={}
for i in range(n):
	freq[l[i]]=0
for i in range(n):
	freq[l[i]]+=1
t=int(input())
sm=sum(l)
for i in range(t):
	a,b=map(int,input().split())
	if(a not in freq.keys()):
		print(sm)
	else:
		if(b not in freq.keys()):
			freq[b]=0
		#diff=abs(freq[b]-freq[a])
		sm=sm-a*freq[a]+b*freq[a]
		freq[b]+=freq[a]
		freq[a]=0
		print(sm)
# Judge status: Accepted
A,B,C=map(int,input().split())
if A<=C and C<=B:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
n=input()
ans=0
for i in range(4):
  if n[i-2]==n[i-1]==n[i]:
    ans+=1
if ans==0:
  print("No")
else:
  print("Yes")
# Judge status: Wrong Answer
A,B,K = map(int, input().split())
ans = []
for i in range(A, A+K):
  ans.append(i)
for i in range(B-K+1, B+1):
  ans.append(i)
ans = set(ans)
for i in ans:
  if i>=A and i<=B:
    print(i)
# Judge status: Accepted
from fractions import gcd
from functools import reduce
N, M = map(int, input().split())
A = list(map(int, input().split()))
AA = list(map(lambda x: x//2, A))
def lcm(x, y):
    return x * y // gcd(x, y)
b0 = AA[0]&-AA[0]
for a in AA[1:]:
    if b0 != a&-a:
        print(0)
        break
else:
    a = reduce(lcm, AA)
    print(M//a - M//(2*a))
# Judge status: Accepted
N = int(input())
ans = 0
for i in range(11):
    if 1000*i >= N:
        ans = 1000*i - N
        break
print(ans)
# Judge status: Accepted
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

H, N=map(int, input().split())
dp = [0 for i in range(H + 10**4 + 1)]

hm = list(list(map(int, input().split())) for i in range(N))

for i in range(1, H+1):
    dp[i] = min(list(dp[i - h] + m for h, m in hm))
print(dp[H])
# Judge status: Accepted
N = int(input())
bs = list(map(int,input().split()))

list_a= [bs[0]]

for i in range(1,len(bs)):
    a = min(bs[i-1],bs[i])
    list_a.append(a)
    
list_a.append(bs[len(bs)-1])

print(sum(list_a))
# Judge status: Wrong Answer
N,W=map(int,input().split())
WV=[]
for i in range(N):
    WV.append(list(map(int,input().split())))
dp=[[-1e-30 for j in range(W+1)] for i in range(N)]
dp[0][0]=0
dp[0][WV[0][0]]=WV[0][1]
for i in range(1,N):
    for j in range(W+1):
        if j-WV[i][0]>=0:
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-WV[i][0]]+WV[i][1])
        else:
            dp[i][j]=dp[i-1][j]
print(int(dp[N-1][W]))
# Judge status: Accepted
a, b = map(int, input().split())
cnt = 0
for i in range(a, b + 1):
    if str(i) == str(i)[::-1]:
        cnt += 1
print(cnt)
# Judge status: Wrong Answer
N, K = list(map(int, input().split()))

print(N%K)
# Judge status: Wrong Answer
N = int(input())
a = list(map(int, input().split()))
#print(a)
b = [0]*(N)

for i in range(N, 0, -1):
    to = 0
    #print(i)

    for j in range(i-1, N ,i):
        to += b[j]

    if to%2 != a[i-1]:
        b[i-1] = 1
    #print(b)
if sum(b)==0:
    print(-1)

else:
    print(sum(b))
    ans = str()
    for i in range(N):
        if b[i]:
            ans += str(i+1)+" "
    print(ans)
# Judge status: Wrong Answer
N=int(input())
goods=[]
for i in range(N):
  s=input()
  goods.append(s)
l=[x for x in set(goods) if goods.count(x)>1]
print(N-len(l))
# Judge status: Wrong Answer
n=int(input())

if n==0:
  print("No")
else:
  print("Yes"if n%4==0 or n%7==0 or n%11==0 or n%18==0 or n%15==0 else "No")
# Judge status: Accepted
N,M  = map(int,input().split())
p_list=["WA"]*N
count = [0]*2
wa_count= [0]*N
for  i in range(M):
    p,s = input().split()
    p = int(p)
    if(p_list[p-1]=="WA" and s=="WA"):
        wa_count[p-1]+=1
    elif(p_list[p-1]=="WA" and s=="AC"):
        p_list[p-1]=s
        count[0]+=1 
        count[1]+=wa_count[p-1]

print(' '.join(list(map(str,count))))
# Judge status: Accepted
def resolve():
    tmp = sum(map(int,input().split()))
    if tmp <=21:
        print("win")
    else:
        print("bust")

if __name__ == "__main__":
    resolve()
# Judge status: Wrong Answer
import math

N = int(input())

use_li = [0]*(math.ceil(math.sqrt(N))+1)
c = 0
while N!=1:
  for i in range(2,math.ceil(math.sqrt(N))+1):
    if(N%i==0 and use_li[i]==0):
      #print(i)
      use_li[i] = 1
      N //= i
      c += 1
      break
  if (i==math.ceil(math.sqrt(N))):
    if(len(use_li)<N or use_li[i] == 1):
      c += 1
    break
      
print(c)
# Judge status: Wrong Answer
N = int(input())


def g(n):
    return (n * (n + 1))//2

total = 0
for i in range(1,N+1):
    total += i * g(N//i)
    
print(total)
# Judge status: Accepted
N, M = map(int, input().split())

ans = 0
if(M//2 >= N):
    ans += N
    M = M - N*2    
    ans += M//4
    
else:
    ans += M//2

print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline
import math
import collections
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n=I()
ps=LI()
count=0
for i in range(n):
    if ps[i]!=i+1:
        count+=1
if count<=2:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
A, s, C = input().split()
print(A[0]+s[0]+C[0])
# Judge status: Wrong Answer


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

a_list = [i for i in range(1,a+1)]
b_list = [i for i in range(1,b+1)]


a_len = len(a_list)
b_len = len(b_list)


if a_len <= b_len:
    print(a_len)
elif a_len == b_len:
    print(a_len)
else:
    print(b_len)
# Judge status: Wrong Answer
import sys
from collections import Counter
N, K, Q = map(int, input().split())
if K > Q:
    for _ in range(N):
        print("Yes")
        sys.exit()

result = ["No"]*N
Npoint = [K-Q]*N

Alist = [int(input())-1 for _ in range(Q)]
Alist = Counter(Alist)

for k, v in Alist.items():
    Npoint[k] += v
    if Npoint[k] >= 1:
        result[k] = "Yes"

for i in result:
    print(i)
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
a=a%2
b=b%2
c=b%2
if a==0 and b==0 and c==1:
    print('NO')
elif a==1 and b==0 and c==0:
    print('NO')
elif a==1:
    print('YES')
else:
    print('YES')
# Judge status: Wrong Answer
N = int(input())
multiple_of_4 = len(list(filter(lambda x : x % 4 == 0, [int(x) for x in input().split()])))
not_4 = N - multiple_of_4

print('Yes' if 2 * multiple_of_4 >= not_4 else 'No')
# Judge status: Accepted
ab,bc,ca=map(int,input().split())
print(ab*bc//2)
# Judge status: Accepted
C = input()

Alphabet = 'abcdefghijklmnopqrstuvwxyz'
Alphabet_list = list(Alphabet)

i = 0
while (i < 26):
  if Alphabet_list[i] == C:
    print(Alphabet_list[i+1])
    break
  else:
    i = i+1
# Judge status: Wrong Answer
N,M=map(int, input().split())
a=N//2
b=a+1
if N&1:
    for i in range(M):
        print(a,b)
        a-=1
        b+=1
else:
    for i in range(M):
        print(a,b)
        a-=1
        b+=1
        if b-a==N//2: b+=1
# Judge status: Accepted
n = int(input())
List = []
for i in range(1, 10**6+1):
    if n%i == 0:
        List.append(i+n//i)
#print(List)
print(min(List)-2)
# Judge status: Wrong Answer
import fractions
import math

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

n, m = map(int, input().split())
a = [i // 2 for i in set(list(map(int, input().split())))]
b = []
for i in a:
    cnt = 0
    while i % 2 == 0:
        i /= 2
        cnt += 1
    b.append(cnt)

L = 1
if len(set(b)) == 1:
    for j in a:
        L = lcm(L, j)
        if m < L:
            print(0)
            break

    print(int((m // L + 1) // 2))
else:
    print(0)
# Judge status: Accepted
N,K=map(int,input().split())
h=[int(i) for i in input().split()]
f_inf=float('inf')
dp=[f_inf]*(N+10)
dp[0]=0
for i in range(1,N):
  for j in range(1,K+1):
    if i-j>=0:
      dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]),dp[i])
print(dp[N-1])
# Judge status: Accepted
def l(): return [input() for _ in range(int(input()))]
p, m = l(), l()
c = 0
for s in set(p):
    c = max(p.count(s) - m.count(s), c)
print(c)
# Judge status: Accepted
from collections import Counter

S = list(input())
c = Counter(S)

if len(c) != 2:
    print("No")
else:
    for k, v in c.items():
        if v != 2:
            print("No")
            break
    else:
        print("Yes")
# Judge status: Wrong Answer
N = str(input().split())

a = N[1]

print(str('A'+ a[0] + 'C'))
# Judge status: Accepted
a, b = map(int, input().split())
s = input()
t = s[:a] + s[a + 1:]
if s[a] == "-" and t.isdigit():
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
info_A = input().split()
info_B = input().split()
T = int(input())

A = int(info_A[0]) #A（鬼）の開始位置
V = int(info_A[1]) #A（鬼）の速度
B = int(info_B[0]) #B（逃げる側）の開始位置
W = int(info_B[1]) #B（逃げる側）の速度

if B + W * T < A + V * T: #T秒後に鬼が追いついているまたは追い越すなら捕まえられる
    print('YES')
else:
    print('NO')
# Judge status: Accepted
import sys

n = sys.stdin.readline().rstrip()
l = len(n)

def main():
    dp0 = [None] * (l + 1)
    dp1 = [None] * (l + 1)
    dp0[0] = 0
    dp1[0] = 1

    for i in range(l):
        d = int(n[i])
        dp0[i+1] = min(dp0[i]+d, dp1[i]+10-d)
        dp1[i+1] = min(dp0[i]+d+1, dp1[i]+10-d-1)
    
    return dp0[l]

if __name__ == '__main__':
    ans = main()
    print(ans)
# Judge status: Wrong Answer
A = list(map(int, input().split()))

K = A[0]
X = A[1]

money = K*500

if X < 500:
	print ("No")
else:
	print("Yes")
# Judge status: Accepted
o=input()
e=input()

a=""

if len(o)!=len(e):
    e+=" "
    for i in range(len(o)):
        a+=o[i]+e[i]
    print(a[:-1])
else:
    for i in range(len(o)):
        a+=o[i]+e[i]
    print(a)
# Judge status: Wrong Answer
s = str(input())
print(s[0:2])
# Judge status: Accepted
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N=int(input())
    A=sorted(list(map(int,input().split())))
    i=0
    cnt=0
    while True:
        try:
            cnt+=A[N+2*i]
            i+=1
        except:
            break
    print(cnt)




resolve()
# Judge status: Wrong Answer
N = int(input())
M = 0
M += 5
for K in range(3, N+1):
    A = [d for d in range(1,K+1) if K % d ==0]
    M += K * len(A)
print(M)
# Judge status: Wrong Answer
card_dict = {}

card_dict['a'] = input()
card_dict['b'] = input()
card_dict['c'] = input()

turn = 'a'

while True:
    card_dict[turn] = card_dict[turn][1:]
    if not card_dict[turn]:
        break
    turn = card_dict[turn][0]
print(turn.upper())
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
count = 0
count2 = 0
for i in a:
    if i%2 == 0:
        count += 1 
        if  i%3 == 0 or i%5 == 0:
            count2 += 1
if count == count2:
    print("APPROVED")       
else:
    print("DENIED")
# Judge status: Wrong Answer
def solve():
    N, M, K = map(int, input().split())

    for i in range(1, N+1):
        for j in range(1, M+1):
            if i*(M-j) + j*(N-i) == K:
                print("Yes")
                return

    print("No")

solve()
# Judge status: Accepted
from fractions import gcd
import math
K = (int)(input())
sum = 0        
for a in range(3,K+1):
    for b in range(2,a):
        for c in range(1,b):
            sum += 6*math.gcd(math.gcd(a,b),c)
for a in range(1,K+1):
    sum += a
for a in range(2,K+1):
    for b in range(1,a):
        sum += 6*math.gcd(a,b)
print(sum)
# Judge status: Accepted
N, K = map(int, input().split())
# 出た目をaとすると、log_2([N/a])回振る必要がある.
# 求めるのは(1/N)*(1/2)**log_2([N/a])

ans = 0
for i in range(1, N+1):
    tmp = 1 / N
    now = i
    while now < K:
        now *= 2
        tmp /= 2
    ans += tmp
print(ans)
# Judge status: Wrong Answer
import sys
N, M = map(int, input().split())
Nlist = [0]*(N+1)
for i in range(1,M+1):
    A, B = map(int, input().split())
    if Nlist[A]>B or Nlist[A]==0:
        Nlist[A]=B
    if Nlist[B]>A or Nlist[B]==0:
        Nlist[B]=A

print('Yes')
for i in range(N-1):
    print(Nlist[i+2])
# Judge status: Wrong Answer
s = list(input())
exist = 'abcdefghijklmnopqrstuvwxyz'

j = 0
s = set(s)
s = sorted(s)

for i in s:
    if i == exist[j]:
        pass    
    elif i != exist[j]:
        print(exist[j])
        break
    if j+1 == len(s):
        print('None')
    j += 1
# Judge status: Accepted
nim = int(input())
if nim <=999:
  print("ABC")
else:
  print("ABD")
# Judge status: Accepted
n = int(input())
list = [int(i) for i in input().split()]

max = max(list)
sum = sum(list)

if sum > 2*max:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
x = str(input())
if x[0]=='9' or x[1]=='9':
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if e-a<=k:print("Yey!")
else:print(":(")
# Judge status: Accepted
N, M = map(int,input().split())
brd = [list(map(int, input().split())) for i in range(M)]
nbrd = sum(brd, [])
for i in range(1, N+1):
    print(nbrd.count(i))