peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
S = list(input())
s = set(S)
lis = {}
for x in S:
  if x in lis:
    lis[x] += 1
  else:
    lis[x] = 1
ans = True
if len(lis) == 2:
  for x in s:
    if lis[x] != 2:
      ans = False
else:
  ans = False
if ans:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
a = [list(map(int,input().split()))for _ in range(3)]
n = int(input())
for i in range(n):
    b= int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:a[j][k ] = 0
ans = "No"
for i in range(3):
    if a[i][0] == a[i][1] == a[i][2] == 0:ans = "Yes"
    if a[0][i] == a[1][i] == a[2][i] == 0:ans = "Yes"
if a[0][0] == a[1][1] == a[2][2] == 0:ans = "Yes"
if a[0][2] == a[1][1] == a[2][0] == 0:ans = "Yes"
print(ans)
# Judge status: Accepted
a, b = map(int, input().split())
ans = 0
tmp = 1
while tmp < b:
  tmp += a-1
  ans += 1
print(ans)
# Judge status: Wrong Answer
bingo = [list(map(int,input().split())) for i in range(3)]
n= int(input())
bs = [int(input()) for i in range(n)]

bingo.append([bingo[0][0], bingo[1][1], bingo[2][2]])
bingo.append([bingo[0][2], bingo[1][1], bingo[2][0]])
bingo.append([bingo[0][0], bingo[1][0], bingo[2][0]])
bingo.append([bingo[0][1], bingo[1][1], bingo[2][1]])
bingo.append([bingo[0][2], bingo[1][2], bingo[2][2]])


print(any([len([j for j in k if j in bs])==3 for k in bingo]))
# Judge status: Accepted
def main():
    s = input()
    l = "abcdefghijiklmopqrstuvwxyz"

    for i in range(len(s)):
        l = l.replace(s[i], '')

    if l == "":
        print('None')
    else:
        print(l[0])


if __name__ == "__main__":
    main()
# Judge status: Accepted
from collections import deque

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

d = deque([1])

while d:
  v = d.popleft()
  for i in g[v]:
    if yet[i] == -1:
      yet[i] = v
      d.append(i)
      
ans = yet[2:]
print("Yes")
print(*ans, sep="\n")
# Judge status: Wrong Answer
a, b = map(int, input().split())
s = input()
ans = 'No'
s_a = s[:a]
s_h = s[a]
s_b = s[b:]
if s_a.isdecimal() and s_b.isdecimal() and s_h =='-':
    ans = 'Yes'
print(ans)
# Judge status: Accepted
from collections import deque
k = int(input())
queue = deque(range(1, 10))
for _ in range(k):
    x = queue.popleft()
    y = x % 10
    if y != 0:
        queue.append(10*x + y-1)
    queue.append(10*x + y)
    if y != 9:
        queue.append(10*x + y+1)
print(x)
# Judge status: Wrong Answer
S = list("<>>><<><<<<<>>><")
lis = [0] * (len(S)+1)

#最初は < を処理する
for i in range(len(S)):
    if S[i] == "<":
        lis[i+1] = lis[i] + 1

num = len(lis)
for i in reversed(S):
    num = num-1
    if i == "<":
        lis[num] = lis[num] + 1
# Judge status: Accepted
a, b, c, d = map(int, input().split())
rst = max(a*c, b*d, b*c, a*d)
print(rst)
# Judge status: Accepted
N=int(input())
s=set([])
for i in range(N):
  t=input()
  if t not in s:
    s.add(t)
  else:
    s.remove(t)
print(len(s))
# Judge status: Accepted
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    s = input()[:-1].decode()
    l = int(s[:2])
    r = int(s[2:])
    if (l >= 13 or l == 0) and 1 <= r <= 12:
        print('YYMM')
    elif 1 <= l <= 12 and (r >= 13 or r == 0):
        print('MMYY')
    elif 1 <= l <= 12 and 1 <= r <= 12:
        print('AMBIGUOUS')
    else:
        print('NA')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
# Judge status: Accepted
n,a,b=map(int,input().split())
if (a+b)%2==0:
    print((b-a)//2)
else:
    print(min(((a-1)+(b-1)+1)//2,((n-a)+(n-b)+1)//2))
# Judge status: Wrong Answer
a,b,c = map(int, input().split())
if b//a >= c:
  print(c)
if b//a <= c:
  print(b//a)
# Judge status: Wrong Answer
n, k = map(int, input().split())
H = list(map(int, input().split()))
sH = sorted(H, reverse=True)
ans = sum(sH[k-1:n-1:])
print(ans)
# Judge status: Accepted
h, n = map(int, input().split())
monster = [[0, 0] for i in range(n)]
 
for i in range(n):
  a, b = map(int, input().split())
  monster[i][0], monster[i][1] = a, b

dps = [0 for i in range(h + 1)]
for i in range(1, h + 1):
  ans = 10 ** 10
  for m in monster:
    ans = min(ans, dps[max(i - m[0], 0)] + m[1])
  dps[i] = ans

print(dps[h])
# Judge status: Accepted
import math

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

def calc_theta(a, b, x):
    if x >= 0.5 * a ** 2 * b:
        # tmp = (a ** 3) / (2 * ((a **2) * b - x)) これだと 0divになる
        tmp = (2/a)*(b-(x/a**2))
    else:
        tmp = (a * b * b) / (2 * x)
    return math.degrees(math.atan(tmp))

ans = calc_theta(a, b, x)

print('{:.10f}'.format(ans))
# Judge status: Accepted
s = input()
s = s[:-1]
while True:
    if len(s) == 0:
        print(0)
        exit()
    if len(s)%2 == 0:
        half = len(s)//2
        if s[:half] == s[half:]:
            print(len(s))
            exit()
        else:
            s = s[:-2]
    else:
        s = s[:-1]
# Judge status: Wrong Answer
import sys
a=int(input())
b=list(input())
c=0
if a==1:
  print('No')
  sys.exit()
for i in range(a//2):
  if  b[i]==b[i+(a//2)]:
    c+=1
  else:
    pass
  if c>=a//2:
    break
  
if c==a//2:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
#ABC156 - Virtual
sel='C'

#C
if sel=='C':
    def ceilT(a,b): #ceil(a/b)
        return (a+b-1)//b

    N=int(input())
    X=[int(i) for i in input().split()]
    p=ceilT(sum(X),N)
    ans=sum((x-p)**2 for x in X)
    p-=1
    ans=min(ans,sum((x-p)**2 for x in X))
    print(ans)
# Judge status: Accepted
mod = 1000000007
N = int(input())
A = list(map(int, input().split()))
S = [0] # 累積和のリスト
ans = 0
for i in range(N):
    S.append(A[i] + S[i] % mod)
for i in range(N):
    sum = S[N] - S[i + 1]
    if sum < 0:
        sum += mod
    ans += A[i] * sum
print(ans % mod)
# Judge status: Accepted
from decimal import *
def resolve():
    X,Y = map(Decimal,input().split())
    print(int(X*Y))
resolve()
# Judge status: Accepted
N,M = map(int,input().split())
route_list = [0] * N
for i in range(M):
    a,b = map(int,input().split())
    route_list[a-1] += 1
    route_list[b-1] += 1
for ans in route_list:
    print(ans)
# Judge status: Wrong Answer
d,t,s=map(int,input().split())
if d/s<=t:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
import sys
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=A+B
d=0
C.sort()
if sum(C)<=K :
    print(len(C))
    sys.exit()
for i in range(len(C)) :
    d=d+C[i]
    if d>K :
        print(i+1)
        sys.exit()
# Judge status: Accepted
N=int(input())
i1 = round(N**0.5)
while True:
  if N%i1==0: break
  i1 -= 1

print(i1+round(N/i1)-2)
# Judge status: Accepted
import sys
def main():
    input = sys.stdin.readline
    N,M=map(int, input().split())
    *A,=map(int, input().split())
    BC=[tuple(map(int, input().split())) for _ in range(M)]

    A.sort()
    BC.sort(key=lambda x:x[1], reverse=True)
    ans=0
    i=0
    from bisect import bisect_right
    for b,c in BC:
        j = bisect_right(A, c, i, min(N,i+b))
        ans += c*(j-i)
        i=j
    for j in range(i,N):
        ans+=A[j]
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
n,m=map(int,input().split())
M=[[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    a-=1;b-=1
    M[a].append(b)
    M[b].append(a)
yes="POSSIBLE";no="IMPOSSIBLE"

for i in M[0]:
    if n-1 in M[i]:
        print(yes);exit()
print(no)
# Judge status: Accepted
x,y=map(int,input().split())
ANS=1
X=x
while True:
  if 2 * X <= y:
    X = X * 2
    ANS += 1
  else:
    break
print(ANS)
# Judge status: Wrong Answer
n,m = map(int,input().split())
ls = []
for i in range(m):
    p,y = map(int,input().split())
    ls.append([p,y])
ls.sort(key= lambda x:x[1])
ls.sort(key= lambda x:x[0])
pre = ls[0][0]
cnt = 1
for p,y in ls:
    if p==pre:
        print(str(p).zfill(6) + str(cnt).zfill(6))
        cnt+=1
    else:
        pre = p
        print(str(p).zfill(6) + str(1).zfill(6))
        cnt=2
# Judge status: Accepted
tmp = 10 ** 9 + 7

def div(n,T):
    _ = 1
    for t in range(T):
        _ *= n
        _ %= tmp
    return _
    
N = int(input())
a = div(10,N)
b = div(9,N)
c = div(8,N)

print((a + c - 2 * b) % tmp)
# Judge status: Wrong Answer
w,h,x,y = map(int, input().split())
if abs(2*x-w) == abs(2*y-h):
    print(h*w/2,1)
else:
    print(w*h/2,0)
# Judge status: Wrong Answer
A ,B = list(map(int,input().split()))
if (A+B)%2==0:
    print((A+B)/2)
else:
    print('IMPOSSIBLE')
# Judge status: Wrong Answer
n = int(input())
s = input()
wh = [0] * n
bl = [0] * n

w , b = 0,0
for i in range(n):
  if s[i] == '.':
    w += 1
  else:
    b += 1
  wh[i] = w
  bl[i] = b

ans = n
wtot = wh[-1]
btot = bl[-1]
for i in range(n):
  x = (wtot - wh[i]) + bl[i]
  ans = min(ans, x)
ans = min(ans, btot)
print (ans)
# Judge status: Accepted
n,T = map(int,input().split())
cands = [tuple(map(int,input().split())) for _ in range(n)]
cands.sort()
for c,t in cands:
  if t<= T:
    print(c)
    break
else:
  print('TLE')
# Judge status: Wrong Answer
def funcx(a, i):
    cnt = 0
    for num in a:
        if num == i:
            cnt = cnt + 1
    return cnt


def func(a, i, ptr, n):
    cnt = 0
    # print("xxx", i, ptr)
    while ptr < n and a[ptr] == i:
        ptr = ptr + 1
        cnt = cnt + 1
        # print("yyy", ptr)
    return cnt, ptr


n = int(input())
a = list(map(int, input().split()))
ptr = 0
for i in range(n):
    # print(i+1)
    cnt, ptr = func(a, i + 1, ptr, n - 1)
    print(cnt)
# Judge status: Accepted
n = int(input())
dict = {1:"a", 2:"b", 3:"c", 4:"d", 5:"e", 6:"f", 7:"g", 8:"h", 9:"i", 10:"j"}
ans = [["a", 1]]
for i in range(n-1):
    newans = []
    for lis in ans:
        now = lis[0]
        count = lis[1]
        for j in range(1, count + 2):
            newans.append([now + dict[j], max(j, count)])
    ans = newans
for lis in ans:
    print(lis[0])
# Judge status: Accepted
a, b, t = map(int, input().split())
print(b * int((t + 0.5) // a))
# Judge status: Wrong Answer
a, b, c, x, y = map(int, input().split())
max_value = max(a, b)
min_value = min(a, b)
boundary_value = 2 * c

if boundary_value <= (min_value + max_value):
    if boundary_value <= min_value:
        print(boundary_value * max(x, y))
    elif (a == max_value and y <= x) or (b == max_value and x <= y):
        print(boundary_value * max(x, y))
    else:
        print(boundary_value * (max(x, y) - abs(x - y)) +
              min_value * abs(x - y))
elif (min_value + max_value) < boundary_value:
    print(a * x + b * y)
# Judge status: Accepted
S = str(input())

if (S[0]==S[1] and S[2]==S[3]) or (S[0]==S[2] and S[1]==S[3]) or (S[0]==S[3] and S[1]==S[2]):
  if S[0]==S[1] and S[1]==S[2] and S[2]==S[3]:
    print("No")
  else:
    print("Yes")
else:
  print("No")
# Judge status: Accepted
A, B, C = input().split()

print(max(
    int(A+B) + int(C),
    int(B+A) + int(C),
    int(B+C) + int(A),
    int(C+B) + int(A),
    int(A+C) + int(B),
    int(C+A) + int(B)
))
# Judge status: Accepted
import fractions
from functools import reduce

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

def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

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

a_2 = list(a[i] // 2 for i in range(n))
t = lcm_list(a_2)

if not all([(t // i) % 2 for i in a_2]):
    print(0)
    quit()

p = (m - t) // (2 * t) + 1
print(p)
# Judge status: Accepted
def main():
    s = input()
    a = len(s); z = 0
    for i, t in enumerate(s):
        if t == 'A':
            a = min(a, i)
        if t == 'Z':
            z = max(z, i)
    ans = z-a+1
    print(ans)

if __name__ == "__main__":
    main()
# Judge status: Accepted
def main():
    f, t = [int(v) for v in input().split(' ')]
    count = 0
    d = 1
    tmp = f
    while True:
        tmp = tmp * 2
        if tmp > t:
            break
        count += 1

    print(count + 1)



if __name__ == '__main__':
    main()
# Judge status: Accepted
A,B,C = map(int, input().split())
flag = False
K = int(input())
for i in range (K+1):
    for t in range (K+1):
        for u  in range(K+1):
            if i + t + u == K:
                if B * (2**t) > A * (2**i) and C * (2**u) > B * (2**t):
                    flag = True
if flag:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())
A = list(map(int,input().split()))

ans = 1
d = 0
for i in range(1,n):
    diff = A[i] - A[i-1]
    if not d:
        d = diff
    elif d*diff < 0:
        d = 0
        ans += 1
print(ans)
# Judge status: Accepted
s,t = input().split()
a,b = (int(x) for x in input().split())
u = input()

if u==s:
    print("{} {}".format(a-1,b))
else:
    print("{} {}".format(a,b-1))
# Judge status: Wrong Answer
N = input()
S = input()
N = int(N)

A = ""
num = 0
for s in S:
    num = (ord(s) + N) if ord(s) + N < 90 else (ord(s) + N - 25)
    A += chr(num)

print(A)
# Judge status: Accepted
c = input()
vowels = ['a', 'i', 'u', 'e', 'o']
if c in vowels:
    print("vowel")
else:
    print("consonant")
# Judge status: Accepted
s=input()
t=input()

lst=[]
for i in range(len(s)-len(t)+1):
  ss=s[i:i+len(t)]
  f=True
  for a,b in zip(ss,t):
    if a!=b and a!="?":
      f=False
      break
  if f:
    st=s[:i]+t+s[i+len(t):]
    lst.append(st.replace("?","a"))
if lst==[]:
  print("UNRESTORABLE")
else:
  lst.sort()
  print(lst[0])
# Judge status: Accepted
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
A = 0

if N < K:
    A = X * N
else:
    A = X * K + Y * (N - K)

print(A)
# Judge status: Accepted
x=int(input())
ans=2*(x//11)
x%=11
if 0<x and x<7:ans+=1
elif x!=0:ans+=2
print(ans)
# Judge status: Accepted
S = list(input())
for i in range(len(S)):
    if S[i] == "?":
        S[i] = "D"
print("".join(S))
# Judge status: Accepted
n = int(input())

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

dp = [[float('-inf')] * 3 for _ in range(n)]

from copy import deepcopy

dp[0] = deepcopy(eff[0])

for i in range(1, n):
    for yi in range(3):
        for ti in range(3):
            if yi != ti:
                dp[i][ti] = max(dp[i][ti], dp[i-1][yi] + eff[i][ti])

print(max(dp[-1]))
# Judge status: Accepted
n = int(input())
cnt_tb = [0]*(n+1)
for i in range(1, n + 1):
    j = 1
    tmp = i*j
    while (tmp < n+1):
        cnt_tb[tmp] += 1
        j += 1
        tmp = i*j
ans = 0
for i in range(1, len(cnt_tb)):
    ans += i * cnt_tb[i]
print(ans)
# Judge status: Accepted
def main():
    from collections import Counter

    n, k, *a = map(int, open(0).read().split())
    c = Counter(a).values()
    v = len(c) - k
    l = list(c)
    l.sort()
    ans = sum(l[:v])
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
W,a,b = map(int,input().split())
if b <= a+W <= b+W:
    print(0)
else:
    print(min(abs(b-(a+W)),abs(a-(b+W))))
# Judge status: Wrong Answer
a,b = map(int, input().split())
s = input()

ok = True
ok = ok and  s[0:a].isdecimal()
ok = ok and s[a] == '-'
ok = ok and s[a+1:-1].isdecimal()

if ok:
    print("yes")
else:
    print("no")
# Judge status: Wrong Answer
import math

l, r, d = map(int, input().split())

if l % d == 0 or r % d == 0:
  print(math.floor(r/d) - math.floor(r/d) + 1)
else:
  print(math.floor(r/d) - math.floor(r/d))
# Judge status: Accepted
n,a,b = map(int, input().split())
s = input()
c = 0
d = 1
for i in range(n):
    if s[i] == "a" and c <(a+b):
        print("Yes")
        c += 1
    elif s[i] == "b" and c < (a+b) and d <= b:
        print("Yes")
        c += 1
        d += 1
    else:
        print("No")
# Judge status: Wrong Answer
print('Yes' if input() >= '30' else 'No')
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split(' ')))
ans = []
if A.count(A[0]) == len(A):
    print(0)
    exit(0)
for i in range(-100,101):
    cost = 0
    for j in range(N):
        if A[j] == i:
            continue
        else:
            cost += (A[j] - i)**2
    ans.append(cost)
import heapq
heapq.heapify(ans)
print(heapq.heappop(ans))
# Judge status: Accepted
N, R = (int(x) for x in input().split())
print(R if N >= 10 else R + (100 * (10 - N)))
# Judge status: Accepted
import math
abc = [int(input()) for _ in range(5)]
tmp = 9
ans = 0
ii = 0
for i in range(5):
    tmpp = min(tmp, (abc[i]-1)%10)
    if tmp != tmpp:
        tmp = tmpp
        ii = i
for i in range(5):
    if i == ii:
        ans += abc[i]
    else:
        ans += (math.ceil(abc[i]/10))*10
print(ans)
# Judge status: Wrong Answer
n, m = map(int, input().split())
if n > 2 and m > 2:
  print((n-2) * (m-2))
elif n == 2 or m == 2:
  print(0)
else:
  print(m*n - 2)
# Judge status: Accepted
n = int(input())
a = list(map(int,(input().split()))) #食べた料理
b = list(map(int,(input().split()))) #料理iの満足度
c = list(map(int,(input().split()))) 

result = 0
mae = 1111
for i in a:
    #print("result",result)
    result += b[i-1]
    #print("mae,b[i-1]",mae,i)
    if mae == i -1:
        #print("if",result)
        result += c[i-2]
    mae = i

print(result)
# Judge status: Wrong Answer
S = input()
count = 0
for i in range(len(S)):
  for j in range(i+1,i+7):
    if int(S[i:j]) % 2019 == 0 and int(S[i:j]) != 0:
      count = count + 1
      if j >= len(S):
        break
print(count)
# Judge status: Accepted
n = int(input())
a = [int(i) for i in input().split()]
sum_abs, min_abs, cnt_minus = 0, 10**9, 0
for ai in a:
    if ai < 0:
        cnt_minus += 1
    abs_ai = abs(ai)
    sum_abs += abs_ai
    if abs_ai < min_abs:
        min_abs = abs_ai
if cnt_minus % 2 == 0 or 0 in a:
    print(sum_abs)
else:
    print(sum_abs - 2*min_abs)
# Judge status: Accepted
n = int(input())

if n==1:
    print(1/float(1))
elif n%2==0:
    print((n//2)/float(n))
else:
    print(((n//2)+1)/float(n))
# Judge status: Wrong Answer
N = int(input())
L = []

for i in range(N):
  S, P = input().split()
  L.append([S, int(P), i+1])

LS = sorted(L)

for i in range(N):
  print(LS[i][2])
# Judge status: Accepted
import collections

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

c = collections.Counter(A)
keys = c.keys()
comb = 0
for i in keys:
    comb += (c[i] * (c[i]-1)) //2

for i in A:
    ans = comb - (c[i]-1)
    print(ans)
# Judge status: Accepted
def main():
    n, k, *x = map(int, open(0).read().split())
    l = x[k - 1] - x[0] + min(abs(x[k - 1]), abs(x[0]))

    for i, j in zip(x, x[k - 1:]):
        y = j - i + min(abs(i), abs(j))
        if y - l < 0:
            l = y

    print(l)


if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

def func(b):
    return sum([abs(val - b) for val in I])

#y seppen wo motomeru

I=[A[i]-i-1 for i in range(N)]
I.sort()

if N % 2 ==1:
    print(func(I[N//2]))
else:
    print(func(I[N//2]))
# Judge status: Accepted
n = int(input())
print(-(int(-n//2)))
# Judge status: Accepted
N = "0" + input()
ans, carry = 0, 0
for i in range(len(N) - 1, 0, -1):
    n = int(N[i]) + carry
    ans += min(10 - n, n)
    carry = 1 if n > 5 or (n == 5 and int(N[i - 1]) >= 5) else 0

print(ans + carry)
# Judge status: Wrong Answer
N, K = map(int, input().split())
P = list(map(int, input().split()))

E = []
for p in P:
    e = ((p * p + p) / 2) * (1 / p)
    E.append(e)

ans = 0
memo = sum(E[:K])
for i in range(0, N - K):
    memo = memo - E[i] + E[i + K]
    ans = max(ans, memo)

print(ans)
# Judge status: Accepted
from fractions import gcd


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


A, B, C, D = map(int, input().split())
SUM = B - A + 1
c = (B // C - (A - 1) // C)
d = (B // D - (A - 1) // D)
cd = (B // lcm(C, D) - (A - 1) // lcm(C, D))
print(B - A + 1 - (B // C - (A - 1) // C + B // D - (A - 1) // D - (B // lcm(C, D) - (A - 1) // lcm(C, D))))
# Judge status: Wrong Answer
s = input()
n = len(s)

x = []

for i in range(n):
    if s[i] == 'A':
        x.append(i)
    elif s[i] == 'Z':
      x.append(i)
      
print(len(s[x[0]:x[1]]))
# Judge status: Accepted


s,w = (int(x) for x in input().split())
# xl = map(int, input().split())

if w >= s:
	print('unsafe')
else:
	print('safe')
# Judge status: Wrong Answer
N = int(input())
S = []
for _ in range(N):
    S.append(int(input()))

s = sum(S)
S.sort()
i = 0
while s != 0:
    if s % 10 != 0:
        break
    s -= S[i]
    i += 1
    
print(s)
# Judge status: Accepted
import bisect
from collections import deque
n = int(input())
l = deque([])
l.append(int(input()))
for i in range(n-1):
    a = int(input())
    if l[0] >= a:
        l.appendleft(a)
    else:
        l[bisect.bisect_left(l,a)-1] = a
print(len(l))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

if N == 0:
    print(A[0] if A[0] <= 1 else -1)
    exit()

if A[0] and N >= 1:
    print(-1)
    exit()

# 根の数
node = 1
root = 0

s = sum(A)

for i in range(len(A) - 1):
    node = min(s, node * 2) - A[i + 1]
    
    if node < 0:
        print(-1)
        exit()
    
    s -= A[i + 1]
    root += node

print(root + sum(A) + 1 if not node else -1)
# Judge status: Accepted
s = int(input())

mod = 10**9 + 7
dp = [0]*(s+1)
dp[0] = 1
for i in range(1,s+1):
    for j in range((i-3)+1):
        dp[i] +=dp[j]
        dp[i] %=mod
        
print(dp[s])
# Judge status: Accepted
import sys
n = int(sys.stdin.readline())
m = map(int, sys.stdin.read().split())
ab = list(zip(m, m))
res = 0
for i, j in ab[::-1]:
  mmod = (i + res) % j
  if mmod:
  	res += j - mmod
print(res)
# Judge status: Wrong Answer
n = int(input())
if n % 9 == 0:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
n,c,k=map(int,input().split())
T=[int(input()) for i in range(n)]

i=0
ans=0
T.sort()
while(i<n):
    time=T[i]+k
    i+=1
    ans+=1

    x=0
    while(x<c-1 and i+x<n):
        if T[i+x]<=time:
            i+=1
        x+=1

print(ans)
# Judge status: Wrong Answer
n = int(input())
D = [] * n

for i in range(n):
    D.append(list(map(int, input().split())))

ans = 0
count = 0

for i in range(1, n):
    if D[i][0] == D[i][1]:
        count += 1
    else:
        ans = max(count, ans)
        count = 0

if count == n-1:
    print('Yes' if count >= 3 else 'No')
else:
    print('Yes' if ans >= 3 else 'No')
# Judge status: Accepted
N,K=map(int,input().split())
D=list(map(int,input().split()))

n=[str(N)[i] for i in range(len(str(N)))]
#print(n)
for i in range(N,10*N+1):
  flag=True
  for j in range(len(str(i))):
    if(int(str(i)[j]) in D):
      flag=False
  if(flag==True):
    ans=i
    break
print(ans)
# Judge status: Accepted
import sys
import math

read = sys.stdin.readline
S = read()

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

fin = False
for i in range(1000+1):
    if a == math.floor(i * 0.08):
        if b == math.floor(i * 0.1):
            print(i)
            fin = True
            break
if not fin:
    print(-1)
# Judge status: Accepted
s=list(map(int,input()))
a=len(s)
b=0
c=0
for i in range(a):
  if s[i]==0:
    b+=1
  else:
    c+=1
d=min(b,c)*2
print(d)
# Judge status: Accepted
n = int(input())
mod = 10 ** 9 + 7
print((pow(10, n, mod) - pow(9, n, mod) - pow(9, n, mod) + pow(8, n, mod)) % mod)
# Judge status: Accepted
import sys
ss=input().strip()
for s in ss:
  if s=="9":
    print("Yes")
    sys.exit()
print("No")
# Judge status: Wrong Answer
S=input()
T=input()

print("Yes" if S+T[-1]==T else "NG")
# Judge status: Accepted
a, b = map(int, input().split())

t = b - a

total = 0
for i in range(1,t+1):
    total += i
    
print(total - b)
# Judge status: Wrong Answer
S=input()
K=int(input())
for i in range(10**6):
  if S[i]!=1:
      print(S[i])
      break
# Judge status: Wrong Answer
N,A,B = map(int,input().split())

sa = (A-B) if A>B else (B-A)

if( sa%2 == 0):
   print( sa/2 )
# Judge status: Wrong Answer
from collections import Counter
n = int(input())
ns = list(map(int, input().split()))
dic = Counter(ns)
dic = {key:value for key, value in dic.items() if value>=2}
if len(dic) < 2:
    print(0)
else:
    sorted_dic = sorted(dic.items(), key=lambda x: x[0])
    print(sorted_dic[-1][0] * sorted_dic[-2][0])
# Judge status: Accepted
A, B, C, D = map(int, input().split())
print(max(min(B, D)-max(A, C), 0))
# Judge status: Accepted
# AtCoder
s = sorted(input())
t = sorted(input(), reverse=True)

if s < t:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
A, B, C, K = map(int, input().split())

if A+B >= K:
    print(A)
else:
    print(A-(K-A-B))