peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
from collections import defaultdict

N, M = map(int, input().split())
PYm = [0] * M

order = dict()
for i in range(M):
    key = input().strip()
    PYm[i] = list(map(int, key.split()))
    order[key] = i

d = defaultdict(list)
for i in range(M):
    d[PYm[i][0]].append(PYm[i][1])

res = dict()
for pi, ys in d.items():
    for i, y in enumerate(sorted(ys), 1):
        res["{} {}".format(pi, y)] = "{:0>6}{:0>6}".format(pi, i)

for key, _ in sorted(order.items(), key=lambda x: x[1]):
    print(res[key])
# Judge status: Accepted
# 2020/04/29
# AtCoder Beginner Contest 149 - D

# Input
n, k = map(int,input().split())
r, s, p = map(int,input().split())
t = input()

# Init
d = dict()
d['r'] = r
d['s'] = s
d['p'] = p

d['wintr'] = 'p'
d['wints'] = 'r'
d['wintp'] = 's'

ngt = [''] * n

# Calc
ans = 0
for i in range(n-1, -1, -1):
    wint = d['wint' + t[i]]
    if ngt[i] != wint:
        ans = ans + d[wint]
        if i - k >= 0:
            ngt[i-k] = wint

# Output
print(ans)
# Judge status: Accepted
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

x,y = map(int,input().split())
a = set([1,3,5,7,8,10,12])
b = set([4,6,9,11])
c = set([2])
if (x in a and y in a) or (x in b and y in b) or(x in c and y in c):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
s = input()
ans = True
if "a" not in s:
    ans = False
if "b" not in s:
    asn = False
if "c" not in s:
    ans = False
    
if ans:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

cum = [0] * (n+1)
for i in range(n):
    cum[i+1] = cum[i] + a[i]

s = sum(a)
ans = 10 ** 18
for i in range(n-1):
    ans = min(ans, abs(s - 2*cum[i+1]))
print(ans)
# Judge status: Accepted
C = [list(map(int,input().split())) for _ in range(3)]
K = C[0][0]
b1,b2 = C[0][1]-K,C[0][2]-K
a1,a2 = C[1][0]-K,C[2][0]-K
if C[1][1]==K+a1+b1 and C[1][2]==K+a1+b2 and C[2][1]==K+a2+b1 and C[2][2]==K+a2+b2:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
N = int(input())
S = input()

#print(N)
#print(S)

if N < len(S):
  print(S[:N] + "...")
else:
  print(S)
# Judge status: Accepted
n, x = map(int, input().split())
a = list(map(lambda x: int(x), input().split()))
#in1 = '5 9'
#in2 = '3 1 4 1 5'
#n, x = map(int, in1.split())
#a = list(map(lambda x: int(x), in2.split()))

RC = 0
if a[0] > x:
    RC += a[0] - x
    a[0] = x

for idx1 in range(1, len(a)):
    if a[idx1 - 1] + a[idx1] > x:
        RC += a[idx1 - 1] + a[idx1] - x
        a[idx1] = x - a[idx1 - 1]

print(RC)
# Judge status: Accepted
a, b, c, d = map(int, input().split())
print('Yes' if any([all([abs(a-b) <= d, abs(b-c)<= d]), abs(a-c) <= d]) else 'No')
# Judge status: Accepted
n = int(input())
s_lst = [int(input()) for _ in range(n)]

maximum = sum(s_lst)
s_lst.sort()


if maximum % 10 != 0:
    answer = maximum
else:

    for i in range(n):
        maximum -= s_lst[i]
        if maximum % 10 != 0:
            answer = maximum
            break
        else:
            maximum += s_lst[i]

        if i == n - 1 and maximum == sum(s_lst):
            answer = 0

print(answer)
# Judge status: Accepted
time = [int(input()) for _ in range(5)]
dif = 0
dif_max = 0
for i in time:
    tmp = abs(10-int(str(i)[-1]))
    tmp = 0 if tmp == 10 else tmp
    dif += tmp
    dif_max = max(dif_max,tmp)

print(sum(time)+dif-dif_max)
# Judge status: Accepted
x = int(input())

ans = 0
for i in range(10**5):
    ans += i
    if ans >= x:
        print(i)
        exit()
# Judge status: Accepted
n = int(input())
x = list(map(int, input().split()))

a = 0
b = 0
x = sorted(x)

for i in range(n):
    if i % 2 == 0:
        a += x.pop()
    else:
        b += x.pop()

print(a-b)
# Judge status: Wrong Answer
a = int(input())
b = int(input())
h = int(input())
print((a+b)*h/2)
# Judge status: Wrong Answer
N, R = map(int, input().split())
print(R if 10>=N else R+1000-N*100)
# Judge status: Accepted
n = int(input())
a = map(int, input().split())
cnt = 0


def half(_a):
    ret = list()
    for i in _a:
        if i % 2 != 0:
            return None
        else:
            ret.append(i//2)
    return ret


while True:
    a = half(a)
    if not a:
        break
    cnt += 1

print(cnt)
# Judge status: Accepted
from fractions import gcd;from functools import reduce;n,*a=map(int,open(0).read().split());l=reduce(lambda a,b:a*b//gcd(a,b),a);print(sum(l//i for i in a)%1000000007)
# Judge status: Accepted
S = input()
d1 = ""
d2 = ""
res = 0
for i in range(len(S)):
  d1 += S[i]
  if d1 != d2:
    d2 = d1
    d1 = ""
    res += 1
print(res)
# Judge status: Wrong Answer
s = input()
n = len(s)

l = set(s)
m = len(l)

if n == m:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
from collections import defaultdict
def main():
    N = int(input())
    D = [int(x) for x in input().split()]
    dic = defaultdict(int)
    mod = 998244353
    for i in D:
        dic[i] += 1

    if dic[0]!=1:
        print(0)
        exit()
    ans = 1
    for i in range(1,max(dic.keys())+1):
        ans *= dic[i-1]**dic[i]
        ans %= mod
    
    print(ans)    
if __name__ == '__main__':
    main()
# Judge status: Accepted
a,b,c=map(int,input().split())
if c-a-b<0:
    print("No")
elif 4*a*b<(c-a-b)**2:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
a=input()

if a.isupper:
    print("A")
else:
    print("a")
# Judge status: Accepted
n, a, b = map(int, input().split(" "))

wholeSum = 0

def digitSum(n):
  basis = 10
  transDigit = list()
  while n > 0:
    transDigit.append(n % basis)
    n = int(n / basis)
  result = sum(transDigit)
  return result

for pivot in range(n+1):
  target = digitSum(pivot)
  if target <= b\
  and a <= target:
    wholeSum += pivot

print(wholeSum)
# Judge status: Accepted
import sys

x, y = map(int, sys.stdin.readline().split())

def main(x):
    cnt = 0
    while x <= y:
        cnt += 1
        x *= 2
    print(cnt)
        
if __name__ ==  '__main__':
    main(x)
# Judge status: Accepted
_=int(input());print(sum(ord(x)<_ for x in "h¤¼Â"))
# Judge status: Accepted
n,m = map(int,input().split())
e = [[] for _ in range(n)]
for i in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  e[a].append(b)
  e[b].append(a)

q = [0]
i = 1
ans = [-1 for _ in range(n)]
while(len(q) > 0):
  qq = []
  for v in q:
    for u in e[v]:
      if ans[u] == -1:
        ans[u] = v
        qq.append(u)
  q = qq[:]
  i += 1

for i in range(1,n):
  if ans[i] == -1:
    print('No')
    exit()
print('Yes')
for i in range(1,n):
  print(ans[i]+1)
# Judge status: Accepted
s = input()
if s == "ABC":
  print("ARC")
else:
  print("ABC")
# Judge status: Wrong Answer
n=int(input())
lists=list(map(int,input().split()))
 
mn=(2*10)^5+1
cnt=0
for li in lists:
  if mn>li:
    mn=li
    cnt+=1
print(cnt)
# Judge status: Accepted
MOD = 10**9 + 7
def mySum(a, b):
    return (a + b) * (b - a + 1) // 2 % MOD

N, K = list(map(int, input().split()))
l = mySum(N-K+1, N) - mySum(0, K-1) + 1
res = l
for i in range(K, N+1):
    l = l - i + (N-i)
    res += l
    res %= MOD
print(res)
# Judge status: Accepted
n = int(input())
s = input()
ans = ""
for i in range(len(s)):
    ans +=chr((ord(s[i]) -65 +n)%26+65)
print(ans)
# Judge status: Wrong Answer
import collections
import functools

n = int(input())
s = input()

total = functools.reduce(lambda x, y : x * y , (collections.Counter(s).values()))

minus = 0
for i in range(n):
    for j in range(i, n):
        for k in range(j, n):
            if (s[i] != s[j] and s[j] != s[k] and s[i] != s[k]) and j - i == k - j:
                print(i, j , k)
                minus += 1
print(total - minus)
# Judge status: Wrong Answer
A, B, C, D = map(int, input().split())
P = [0 for _ in range(202)]
for p in range(A, A + B + 1): P[p] += 1
for p in range(C, C + D + 1): P[p] += 1
count = 0
for p in P:
  if p == 2: count += 1
print(count)
# Judge status: Accepted
a,b,c=sorted(input().split())
print(["NO","YES"][a==b=="5" and c=="7"])
# Judge status: Wrong Answer
s = input()
for i in range(len(s) - 1):
    if s[i] == s[i+1]:
        print('no')
        exit()
print('yes')
# Judge status: Wrong Answer
# https://atcoder.jp/contests/abc119/tasks/abc119_a
y, m, d = map(int, input().split('/'))
if y > 2019:
    print('TBD')
elif m > 5:
    print('TBD')
elif d > 31:
    print('TBD')
else:
    print('Heisei')
# Judge status: Accepted
C=input()
C=ord(C)+1
print(chr(C))
# Judge status: Accepted
n=int(input())
sp=[]
for i in range(n):
    s,p=input().split()
    sp.append([s,int(p),i+1])
    
sort=sorted(sp, key=lambda sp: (sp[0], -sp[1]))

for i in sort:
    print(i[2])
# Judge status: Wrong Answer
N = int(input())
S = [input() for _ in range(N)]

S_set = list(set(S))



print(len(S))
# Judge status: Accepted
N = int(input())
A = [int(input()) for _ in range(N)]
ans = 0
for i in range(N):
    ans += A[i] // 2
    A[i] %= 2
    if A[i] == 1 and i < N-1 and A[i+1] > 0:
        A[i+1] -= 1
        ans += 1
print(ans)
# Judge status: Wrong Answer
import math
a,b,x = map(int,input().split())

ans = 0

sw = 2*x - a**3
sw_c = abs(math.atan(sw))

ans = abs(math.atan(2/a*(b-x/(a**2))))
ans_1 = abs(math.atan(a*b**2/(2*x)))

if(ans < sw_c):
    print(math.degrees(ans))
else:
    print(math.degrees(ans_1))

#print(math.degrees(ans))
#print(sw_c)
# Judge status: Wrong Answer
N = int(input())
S = input()

import collections
C = collections.Counter(S)



count = 0

for i in range(N):
    j = 1
    while i - j >= 0 and i + j < N:
        if S[i-j] != S[i] and S[i+j] != S[i] and S[i-j] != S[i+j]:
            count += 1
        j += 1

ans = 1
for k, v in C.items():
    ans *= v

print(ans - count)
# Judge status: Accepted
a,b=map(int,input().split())
print(a+(b//2))
# Judge status: Accepted
S = input()
T = input()
ans = float('inf')

for i in range(len(S)-len(T)+1):
  tmp = 0
  for a,b in zip(S[i:i+len(T)],T):
    if a!=b:
      tmp+=1
  ans = min(ans,tmp)
  
print(ans)
# Judge status: Wrong Answer
n = input()
r = sum(map(int,list(n)))
print(r)
# Judge status: Wrong Answer
# coding: utf-8
# Your code here!

input_line = input().split()
A_HP = int(input_line[0])
A_ATTACK = int(input_line[1])
B_HP = int(input_line[2])
B_ATTACK = int(input_line[3])

X = A_HP//B_ATTACK
Y = B_HP//A_ATTACK
if X >= Y:
  print('Yes')
    
elif Y > X:
  print('No')

else:
  print('Yes')
# Judge status: Accepted
n = int(input())

s_list = []
for i in range(n):
    s = str(input())
    s_list.append(s)
    
print(len(set(s_list)))
# Judge status: Accepted
X, N = map(int, input().split())
p = list(map(int, input().split()))

score = 1000
answer = -1
for i in range(-1, 102):
    if i in p:
        continue
    if abs(X - i) < score:
        score = abs(X - i)
        answer = i
print(answer)
# Judge status: Wrong Answer
l,r=map(int,input().split())
a=[]
for i in range(l,min(l+2020,r+1)):
  a.append(i%2019)
a.sort()
print((a[0]*a[1])%2019)
# Judge status: Wrong Answer
N, M = map(int, input().split())
if(N == 1 and M == 1):
    print(0)
elif(N == 1):
    if(M == 2):
        print(2)
    else:
        print(1 * M-2)
elif(M == 1):
    if(N == 2):
        print(1 * N-2)
else:
    print((N - 2) * (M - 2))
# Judge status: Accepted
import bisect
n = int(input())
a = [int(input()) for i in range(n)]
ans = 0
color = [a[n-1]]
for i in range(n-2,-1,-1):
    if a[i]>=color[-1]:
        color.append(a[i])
    else:
        x = bisect.bisect_right(color,a[i])
        color[x] = a[i]
print(len(color))
# Judge status: Wrong Answer
n=int(input())
w=list(map(int,input().split()))
half=sum(w)*0.5
wa=0
num=0
for i in range(n):
  if wa>half:
    break
  wa+=w[i]
  num=i
print(abs(sum(w)-2*sum(w[:num])))
# Judge status: Accepted
import math
a, b = input().split()
ab = a + b

if math.sqrt(int(ab)).is_integer() == True:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500 * i + 100 * j + 50 * k == x:
                ans += 1
print(ans)
# Judge status: Accepted
n=int(input())
print((n-1)*n//2)
# Judge status: Accepted
w, h, n = map(int, input().split())
r, l, u, d = w, 0, h, 0
for _ in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        l = max(l, x)
    elif a == 2:
        r = min(r, x)
    elif a == 3:
        d = max(d, y)
    else:
        u = min(u, y)
print(max(0, r-l) * max(0, u-d))
# Judge status: Accepted
S = sorted(input())
setS = set(S)
if len(setS) == len(S):
    print("yes")
else:
    print("no")
# Judge status: Accepted
N=int(input())
*A,=map(int,input().split())
d={}
for a in A:
    d[a] = d.get(a, 0)+1
s=sorted([(k,v) for k,v in d.items() if 2<=v], reverse=True)

if len(s)<2:
    print(0)
else:
    if 4<=s[0][1]:
        print(s[0][0]**2)
    else:
        print(s[0][0]*s[1][0])
# Judge status: Accepted
x = list(input())
cnt = 0
a = 0
for i in x:
  if i == 'S':
    cnt += 1
  elif i == 'T':
    if cnt > 0:
      cnt -= 1
    else:
      a += 1
print(a+cnt)
# Judge status: Wrong Answer
a,b=map(int,input().split())
print(max(a,b)+max(a-1,b-1))
# Judge status: Accepted
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    interview=[]
    n,m = map(int,input().split())
    interview=[list(map(int,input().split())) for _ in range(n)]
    set_data={}

    for data in interview:
        if len(set_data)==0:
            set_data  = set(data[1:])
        else:
            set_data=set_data & set(data[1:])
    print(len(set_data))


if __name__=="__main__":
    main()
# Judge status: Accepted
a = int(input())

if a <= 6:
    print(1)
else:
    if 7 <= a <= 11:
        print(2)
    else:
        t = a // 11
        a -= t * 11
        if 1 <= a <= 6:
            s = 1
        elif 7 <= a:
            s = 2
        else:
            s = 0
        print(t*2 + s)
# Judge status: Accepted
import math

n = int(input())
sums = 0
for k in range(1,n+1):
    for l in range(1,n+1):
        a =math.gcd(k,l)
        for p in range(1,n+1):
            sums += math.gcd(a,p)

print(sums)
# Judge status: Accepted
N, M = map(int, input().split())
a = list(map(int, input().split()))

from math import floor
from fractions import gcd
from functools import reduce


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


b = [n // 2 for n in a]

lcm_b = reduce(lcm, b)

for n in b:
    if (lcm_b // n) % 2 == 0:
        print(0)
        exit()

n = floor((M / lcm_b - 1) / 2) + 1

print(n)
# Judge status: Accepted
N = int(input())
nums = list(map(int, input().split(" ")))

all_sum = sum(nums)
sums = [None] * N

min_diff_value = float('inf')
min_diff_index = -1


for i in range(N-1):
    if i==0:
        sums[i] = nums[i]
    else:
        sums[i] = sums[i-1] + nums[i]

    lhs_value = sums[i]
    rhs_value = all_sum - lhs_value
    diff_value = abs(lhs_value - rhs_value)

    if diff_value < min_diff_value:
        min_diff_value = diff_value

print(min_diff_value)
# Judge status: Wrong Answer
N,M=list(map(int, input().split()))
if N>1 and M>1:
  print((N-2)*(M-2))
else:
  print(N*M-2)
# Judge status: Wrong Answer
N = int(input())
l = len(str(N))
ans = 0
n = 1
while l >= n:
	c = 9 * 10 ** (n - 1)
	if 10 ** n - 1 <= N:
		ans += c
	else:
		ans += N - (10 ** (n - 1))
	n += 2
print(ans)
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))

i = 0
for j in range(N):
    if a[j] == i+1:
        i += 1
else:
    if i == 0:
        print(-1)
    else:
        print(N-i)
# Judge status: Accepted
import sys
readline = sys.stdin.readline

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

DIV = 10 ** 9 + 7
ans = 0
cur = 0
for i in range(1, N):
  cur += A[i - 1]
  ans += A[i] * cur
  ans %= DIV
  
print(ans)
# Judge status: Wrong Answer
S, W = map(int, input().split())

if (S <= W):
    print('unsafe')
else:
    print('same')
# Judge status: Wrong Answer
a,b=list(map(int,input().split()))
if abs(int((a-b)/2))==abs(int((b-a)/2)):
  print(int((a+b)/2))
else:
  print('IMPOSSIBLE')
# Judge status: Accepted
n, m = map(int, input().split())
start = []
for i in range(n):
    a, b = map(int, input().split())
    start.append([a, b])
check = []
for i in range(m):
    c, d = map(int, input().split())
    check.append([c, d])

for a, b in start:
    distance = 1001001001
    ans = 0
    for i in range(len(check)):
        c, d = check[i][0], check[i][1]
        if abs(a - c) + abs(b - d) < distance:
            distance = abs(a - c) + abs(b - d)
            ans = i + 1
    print(ans)
# Judge status: Accepted
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

a,b,c,x,y = iim()

print(min(a*x+b*y,2*y*c+max(x-y,0)*a,2*x*c+max(y-x,0)*b))
# Judge status: Accepted
import math
a, b = map(int, input().split())

for i in range(1, 1250):
    if math.floor(i * 0.08) == a and math.floor(i * 0.1) == b:
        print(i)
        exit()
else:
    print(-1)
# Judge status: Accepted
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N, L = rl()

aji = [0]*N

minaji = float('inf')
for i in range(N):
	aji[i] = L+i
	if abs(minaji) > abs(aji[i]):
		minaji = aji[i]
print(sum(aji)-minaji)
# Judge status: Accepted
n = int(input())
ns = [int(input()) for _ in range(5)]
print((n-1)//min(ns)+5)
# Judge status: Wrong Answer
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

ans = K*X+(N-K)*Y
print(ans)
# Judge status: Accepted
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
n,m=map(int,input().split())
ans=1
for i in make_divisors(m):
    if i>=n:
        ans=max(ans,m//i)
print(ans)
# Judge status: Wrong Answer
n, m = map(int, input().split())

c = n*2+m
print(c//4)
# Judge status: Wrong Answer
import math
x, y = map(int, input().split())

ans = int(math.log2(y) - math.log2(x))

print(ans + 1)
# Judge status: Accepted
n = int(input())
arr = [0 for i in range(n)]
for i in range(n):
    it = i+1
    if not ((it %3 == 0 and it%5==0) or it%3 == 0 or it%5 == 0):
        arr[i] = i+1
# print(arr)
print(sum(arr))
# Judge status: Wrong Answer
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
B.append(0)

ans = 0
for i in range(N+1):
  taosukazu1 = min(A[i],B[i])
  B[i] -= taosukazu1
  ans += taosukazu1
  if B[i] > 0:
    taosukazu2 = min(A[i+1],B[i])
    B[i] -= taosukazu2
    ans += taosukazu2
print(ans)
# Judge status: Wrong Answer
n=int(input())
s=input()
x=[0]*n
t=0
for i in range(n):
    if s[i]=="E":
        t+=1
    x[i]=t
M=x[n-1]
c=0
ans=10**9
print(x)
for i in range(n):
    ans=min(ans,i-c+M-x[i])
    c=x[i]
print(ans)
# Judge status: Accepted
X, K, D = map(int,input().split())
res = 0
X = abs(X)
if X >= K * D:
    res = X - K * D
else:
    i = X // D
    j = K - i
    if j % 2 == 0:
        res = X - D * i
    else:
        res = X - D * (i + 1)
print(abs(res))
# Judge status: Accepted
from sys import setrecursionlimit, exit
setrecursionlimit(1000000000)

from heapq import heapify, heappush, heappop, heappushpop, heapreplace

n, k = map(int, input().split())
r, s, p = map(int, input().split())
point = {'r':p, 's':r, 'p': s}
t = input()
ans = 0
for i in range(k):
    j = i
    prev = False
    while j < n:
        if prev and t[j] == t[j-k]:
            prev = False
        else:
            ans += point[t[j]]
            prev = True
        j += k
print(ans)
# Judge status: Accepted
A,B = map(int,input().split())

print(A*B)
# Judge status: Wrong Answer
b = input().split() #aの文字列を空白で区切る
c = [int(s) for s in b] #bのそれぞれの要素に対して数値にしてリストに格納
print(c)
num5 = 0
num7 = 0
for i in range(len(c)):
    if c[i] == 5:
        num5 += 1
        continue
    if c[i] == 7:
        num7 +=1
        continue
if num5 == 2 and num7 == 1:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
N,M = list(map(int,input().split()))

f=[]
for m in range(1,int(M**(1/2))+3):
    if M % m == 0:
        f.extend([m,M//m])
f.sort(reverse=True)

for f_ in f:
    if N <= M/f_:
        ans=f_
        break
print(ans)
# Judge status: Accepted
n = input()
 
if int(n) % 10 == 0:
	print(10)
else:
	ans = 0
	for i in n:
		ans += int(i)
	print(ans)
# Judge status: Wrong Answer
A,B = list(map(int,input().split()))
if A >= B:
  print(A*(A-1))
else:
  print(B*(B-1))
# Judge status: Accepted
import sys
n,m = map(int, sys.stdin.readline().rstrip("\n").split())
city = {}
yton = {}
for i in range(m):
    p,y = map(int, sys.stdin.readline().rstrip("\n").split())
    if p not in city.keys():
        city[p] = []
        city[p].append(y)
        yton[y] = i
    else:
        city[p].append(y)
        yton[y] = i
ans = [None]*m
for p in city.keys():
    city[p].sort()
    for i,y in enumerate(city[p]):
        ans[yton[y]] = str(p*(10**6)+i+1).zfill(12)
print(*ans, sep = '\n')
# Judge status: Wrong Answer
n,k = map(int,input().split())
sai = sorted(list(map(int,input().split())),reverse=True)
for x in range(len(sai)):
    sai[x] = ((sai[x]+1)*sai[x])/2/sai[x]

print(sum(sai[:k]))
# Judge status: Wrong Answer
from math import ceil

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

y = ceil((max(numeros) + min(numeros))/2)
soma = 0
for v in numeros:
	soma += (v-y)**2

print(soma)
# Judge status: Accepted
import re

S = input()

m = re.findall(r"[ACGT]+", S)
if m:
    print(max(map(len, m)))
else:
    print(0)
# Judge status: Accepted
S=input()

if S=="Sunny" :
  print("Cloudy")
else :
  if S=="Cloudy" :
    print("Rainy")
  else :
    print("Sunny")
# Judge status: Accepted
import math 
a,b,x = map(int,input().split())
if 0.5*b*(a**2)<=x:
  t = math.degrees(math.atan(2*(a**2*b-x)/(a**3)))
  print(t)
else:
  t = 90-math.degrees(math.atan(2*x/(a*(b**2))))
  print(t)
# Judge status: Accepted
N,K=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(N)]
A=sorted(A, key=lambda x: x[0])

cnt=0
for i in range(N):
    a,b=A[i]
    A[i][1]+=cnt
    cnt=A[i][1]

for i in range(N):
    a,b=A[i]
    if K<=b:break
print(a)
# Judge status: Wrong Answer
from collections import defaultdict,deque
import math
def main():
    n,h=map(int, input().split())
    ab = [list(map(int, input().split())) for i in range(n)]
    tmp = max([int(i[0]) for i in ab])
    bs = [int(i[1]) for i in ab]
    bs.sort(reverse = True)
    i = 0
    while(bs[i] > tmp):
        h-=bs[i]
        i+=1
        if(h<=0 or i==n):
            break

    print(i+math.ceil(h/tmp))





if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(s-x-y):
            if 0<=z<=k and x+y+z==s:
              ans += 1
print(ans)
# Judge status: Accepted
n = int(input())
s = list(int(input()) for i in range(n))

s.sort()

ans = sum(s)

if ans % 10 != 0:
    print(ans)
    exit()
else:
    for x in s:
        if x % 10 != 0:
            ans -= x
            print(ans)
            exit()
print(0)
# Judge status: Accepted
a=int(input())
print(a+(a*a)+(a*a*a))
# Judge status: Wrong Answer
h1,m1,h2,m2,k = map(int,input().split())
if m2 < m1:
    m2 += 60
    h1 -= 1
time = (h2 - h1) * 60 + (m2 - m1)

print(time - k)
# Judge status: Wrong Answer
import math

n = int(input())

mx = math.ceil(n ** 0.5)

for i in reversed(range(1, mx)):
    if n % i == 0:
        print(int(i + n / i - 2))
        break
# Judge status: Accepted
s=input()
#左に>が続く個数、右に<が続く個数
l=[0]
r=[0]
l_,r_=0,0
for i in range(len(s)):
    if s[i]=='<':
        l_+=1
    else:
        l_=0
    l.append(l_)
    if s[-1-i]=='>':
        r_+=1
    else:
        r_=0
    r.append(r_)
r.reverse()
ans=0
for i in range(len(s)+1):
    ans+=max(l[i],r[i])
print(ans)