peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import collections
s = input()

l = [int(s[-1])]
d = 10
for i in range(len(s)-2, -1, -1):
  l.append((l[-1] + int(s[i])*d) % 2019)
  d *= 10
  d %= 2019
c = collections.Counter(l)
ans = 0  
for i in c.values():
  ans += i*(i-1)//2

ans += c[0]

print(ans)
# Judge status: Accepted
h, w = map(int, input().split())
if h==1 or w==1:
    print(1)
elif h%2==0 or w%2==0:
    print(int(h*w/2))
else:
    print(int((h*w+1)/2))
# Judge status: Accepted
N = int(input())
v = list(map(int,input().split()))

v.sort()
tmp = v[0]

for i in range(1,N):
    tmp = (tmp+v[i])/2
    
print(tmp)
# Judge status: Wrong Answer
s = set()
table= {}
for i in range(100):
  s.add(i**5)
  table[i**5] = i
 
x = int(input())
for i in range(100):
  b5 = i**5
  if x-b5 in s:
    print(table[x-b5],-i)
  if x+b5 in s:
    print(table[x+b5],i)
# Judge status: Accepted
k, s = map(int, input().split())

ans = 0
for i in range(k+1):
    for j in range(k+1):
        if 0 <= s-i-j <= k:
            ans += 1
print(ans)
# Judge status: Wrong Answer
A = input()
s = 0
for i in range(0,2):
  if A[i] ==1:
    s = s + 1
print(s)
# Judge status: Accepted
x, y = map(int, input().split())

all_crane_num = x * 2
diff = y - all_crane_num

turtle_num = int(diff / 2)
crane_num = x - turtle_num

if turtle_num >= 0 and crane_num >= 0 and turtle_num*4 + crane_num*2 == y:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
a,b=map(str,input().split())
if len(a)>len(b):
    print(b+a)
else:
    
    print(a+b)
# Judge status: Accepted
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, S, T = read().split()
N = int(N)

def test(n):
    overlap = N + N - n
    if overlap <= 0:
        return True
    return S[-overlap:] == T[:overlap]

for n in range(N, N + N + 10):
    if test(n):
        break
print(n)
# Judge status: Accepted
N=int(input())
A = [int(i) for i in input().split()]
left = [0] * N
right = [0] * N
for i,a in enumerate(A):
    if 0 <= i-a:
        left[i - a] += 1
    if i + a < N:
        right[i + a] += 1
ans = 0
for i in range(N):
    ans += left[i] * right[i]
print(ans)
# Judge status: Accepted
s=input()
n=len(s)
p=0
if n%2==1:
    p=1
else:
    n2=n//2
    for i in range(n2):
        if s[i*2]!='h':
            p=1
        if s[i*2+1]!='i':
            p=1
if p==0:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n = int(input())
l = [0 for x in range(n)]
l = list(map(int,input().split()))
l.sort()
cnt = 0
a = 0
b = 0
c = 0
if n < 3:
    print(0)
else:
    for i in range(n-2):
        a = l[i]
        for j in range(i+1,n-1):
            b = l[j]
            for k in range(j+1,n):
                c = l[k]
                if a+b > c and a != b and b != c:
                    cnt += 1
print(cnt)
# Judge status: Accepted
Q,H,S,D = map(int, input().split())
N = int(input())

ans = 0
if N >= 2:
    ans += N//2 * min(Q*8, H*4, S*2, D)
    N %= 2
if N == 1:
    ans += min(Q*4, H*2, S)
print(ans)
# Judge status: Accepted
N=int(input())
*A,=map(int,input().split())
S=sum(A)

count1=0
count2=[0]*N
i=0
while i<N:
    count1+=A[i]
    count2[i]=abs(S-2*count1)
    i+=1

print(min(count2))
# Judge status: Wrong Answer
a = input()
v = 0
h = 0
if a.count('W') >=1:
  if a.count('E') ==0:
    print('NO')
    exit()
elif a.count('E') >=1:
  if a.count('W') ==0:
    print('NO')
    exit()
elif a.count('N')>= 1:
  if a.count('S') ==0:
    print('NO')
    exit()
elif a.count('S')>= 1:
  if a.count('N')==0:
    print('NO')
    exit()
print('YES')
# Judge status: Accepted
#!/usr/bin/env python3

# input = stdin.readline



def main():
  N = int(input())
  p = list(map(int,input().split()))
  def solve(n,p):
    assert n >= 2
    target = sum(0 if p[i]==i+1 else 1 for i in range(n)) 
    return target == 0 or target == 2
  print("YES" if solve(N,p) else "NO")
  return

if __name__ == '__main__':
  main()
# Judge status: Accepted
n, m = map(int, input().split())
if n*m == 1:
  print(0)
else:
  print(int(n*(n-1)/2+m*(m-1)/2))
# Judge status: Wrong Answer
n,k=map(int,input().split())
a=list(map(int,input().split()))
import numpy as np
a=np.array(a)
temp=np.argmin(a)
import math
if n==k:
  print(1)
else:
  print(math.ceil(temp/(k-1))+math.ceil((n-temp-1-(temp+1)%(k-1))/(k-1)))
# Judge status: Accepted
S = input()

if S[2]==S[3] and S[4]==S[5]:
    print('Yes')

else:
    print('No')
# Judge status: Wrong Answer
import itertools

Length = int(input())
inputList = input()

seq = [int(x) for x in inputList.split(' ')]

a = list(itertools.combinations(seq, 3))

def b(line):
	list = []
	for i in range(len(line)):
		if line[i][0] + line[i][1] > line[i][2] and line[i][1] + line[i][2] > line[i][0] and line[i][2] + line[i][0] > line[i][1]:
			list.append(line[i])
			continue
		else:
			continue
	return list

print(b(a))
# Judge status: Wrong Answer
a,b=map(int,input().split())
ans=a*b
for i in range(2,max(a,b)):
    if a%i==0 and b%i==0:
        ans=ans/i
print(int(ans))
# Judge status: Wrong Answer
n, k = map(int, input().split())
s = input()

target = s[k - 1]

lower = chr(ord(target) + 32) # target.lower()

result = s.replace(target, lower)

print(result)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

res = float('inf')
for v in a:
    cnt = 0
    while v % 2 == 0:
        v //= 2
        cnt += 1
    res = min(res, cnt)

print(res)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
m={}
for i in range(N):
  if A[i] in m:
    m[A[i]] += 1
  else:
    m[A[i]] = 1
ans = 0
for k,n in m.items():
  if k <= n:
    ans += n-k
  else:
    ans += n
print(ans)
# Judge status: Wrong Answer
n = int(input())

for i in range(n + 1) :
	if int(i * 1.08) == n:
		print(i)
		break

print(":(")
# Judge status: Wrong Answer
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
#a.sort()
#b.sort(reverse=True)
#c.sort()
ans = 0
A = []
bs = []
for i in range(n):
  A.append(sum(x>a[i] for x in b))
for i in range(n):
  bs.append(sum(x>b[i] for x in c))
bs.sort(reverse=True)
ans = 0
for i in range(n):
	if A[i] > 1:
		ans += sum(bs[:A[i]-1])
print(ans)
# Judge status: Accepted
n = int(input())
L = list(map(int,input().split()))

maxh = L[0]
sum1 = 0
for i in range(1,n):
    if L[i] > maxh:
        maxh = L[i]
    else:
        sum1 += maxh-L[i]
print(sum1)
# Judge status: Accepted
p = []
for i in range(5):
    p.append(int(input()))

k = int(input())
for i in range(5):
    for j in range(i+1,5):
        if p[j] - p[i] >k:
            print(":(")
            exit()
print("Yay!")
# Judge status: Accepted
n = int(input())
W = [input() for i in range(n)]
word = W[0]
words = [word]
for i in range(1,n):
  if W[i] in words or word[-1] != W[i][0]:
    print("No")
    break
  word = W[i]
  words.append(word)
else:
  print("Yes")
# Judge status: Accepted
def main():
    x = int(input())
    
    h = (x//500)*1000
    res = x % 500
    h += (res//5)*5
    print(h)


if __name__ == "__main__":
    main()
# Judge status: Accepted
n = int(input())
ans = 10**10
for i in range(1,n):
    j = n-i
    l1 = len(str(i))
    l2 = len(str(j))
    l1_cnt,l2_cnt = 0,0
    for k in range(l1):
        l1_cnt +=int(str(i)[k])
    for l in range(l2):
        l2_cnt +=int(str(j)[l])
    ans = min(ans,l1_cnt+l2_cnt)
print(ans)
# Judge status: Wrong Answer
a =list(map(int,input().split()))
if sum(a) == 19 and a.count("7") == 2:
  print("YES")
else:
  print("NO")
# Judge status: Accepted
n,m=map(int,input().split())
cnt=[1]*n
res=[0]*n
res[0]=1
for i in range(m):
    x,y=map(int,input().split())
    if res[x-1]==1:
        res[y-1]=1
        if cnt[x-1]==1:
            res[x-1]=0
    cnt[x-1]-=1
    cnt[y-1]+=1
print(sum(res))
# Judge status: Accepted
N = int(input())

last_a = 0
last_b = 0
last_c = 0

for _ in range(N):
    a, b, c = map(int, input().split())
    last_a, last_b, last_c = a + max(last_b, last_c), b + max(last_c, last_a), c + max(last_a, last_b)

print(max(last_a, last_b, last_c))
# Judge status: Accepted
s = ''.join(sorted(input()))
t = ''.join(reversed(sorted(input())))

print('Yes' if s < t else 'No')
# Judge status: Wrong Answer
a = int(input())
s = str(input())
if a >= 3200:
    print('s')
else:
    print('red')
# Judge status: Accepted
a = list(input())
b = list(input())
counter = 0

for i in range(len(a)):
    if a[i] != b[i]:
        counter += 1

print(counter)
# Judge status: Wrong Answer
n,k=map(int,input().split())
a=[int(input()) for i in range(n)]
a.sort()
x=10**9
for i in range(n-k+1):
  x=min(x,a[i+k-1]-a[k])
print(x)
# Judge status: Accepted
a = int(input())
s = input()

if 3200 <= a:
    print(s)
if a < 3200:
    print("red")
# Judge status: Wrong Answer
s=input()
ans=1000
for i in range(len(s)-2):
    a=abs(int(s[i:i+3])-753)
    if ans>a:
        ans=a
print(a)
# Judge status: Accepted
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
bc=[list(map(int,input().split())) for i in range(m)]
bc.sort(key=lambda x:x[1], reverse=True)
flg=0
cnt=0
for i in range(n):
  if bc[flg][1] > a[i]:
    a[i] = bc[flg][1]
    cnt+=1
    if cnt==bc[flg][0]:
      flg+=1
      cnt=0
  else:
    flg+=1
    cnt=0
  if flg == m:
    break
print(sum(a))
# Judge status: Wrong Answer
import heapq

N, M = list(map(int,input().split()))
A = list(map(int,input().split()))
B = [list(map(int,input().split())) for i in range(M)]
B = sorted(B, key = lambda x: x[1])

for i in range(N):  A[i] *= -1
heapq.heapify(A)
cnt = 0
for i in range(M):
    for _ in range(B[i][0]):  heapq.heappush(A, -max(-heapq.heappop(A), B[i][1]))
    cnt += B[i][0]
    if cnt >= N:  break
print(-sum(A))
# Judge status: Wrong Answer
s = int(input())

a = [0]*1000000
a[0] = s
i = 1
d = {}
while True:
    if a[i-1] % 2 == 0:
        a[i] = a[i-1] // 2
    else:
        a[i] = 3 * a[i-1] + 1

    if d.get(a[i]) is None:
        d[a[i]] = 1
    else:
        print(i+1)
        exit()

    i += 1
# Judge status: Wrong Answer
N, M = map(int, input().split())
A = list(map(int, input().split())) 

A.sort(reverse = True)
if sum(A)/(4*M) < A[M -1]:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
s = list(input())
t = list(input())
n = len(s)
m = len(t)
flag = 0
flag_2 = 0
for i in range(n):
  if s[i] == "?" or s[i] == t[flag]:
    if flag == m-1:
      flag_2 = 1
      for j in range(flag,-1,-1):
        s[i-(m-1-j)] = t[j]
    else:
      flag += 1
  else:
    flag = 0
if flag_2 == 1:
  for i in range(n):
    if s[i] == "?":
      s[i] = "a"
  print("".join(s))
else:
  print("UNRESTORABLE")
# Judge status: Accepted
from math import sqrt
x = int(input())
cnt = 0
l = []
for i in range(1, x + 1):
    for j in range(1, int(sqrt(i)) +1):
        for k in range(2, 10):
            if j ** k == i:
                l.append(i)
print(max(l))
# Judge status: Wrong Answer
from collections import deque
K = int(input())
a = deque(range(1,10))
# a = deque()
pop_count = 0
while pop_count + len(a) < K:
    pop = a.popleft()
    pop_count +=1
    first_digit = pop % 10
    pull = pop * 10 + first_digit
    if first_digit != 9:
        a.extend([pull-1, pull, pull+1])
    else:
        a.extend([pull-1, pull])

print(a[K-pop_count-1])
# Judge status: Accepted
n=int(input())
ans=10**6
for i in range(1,n+1):
    a=i
    b=n-i
    if a<=b:
        asum=sum(map(int,str(a)))
        bsum=sum(map(int,str(b)))
        if ans>(asum+bsum):
            ans=asum+bsum
print(ans)
# Judge status: Wrong Answer
import bisect
n = int(input())
li = list(map(int,input().split()))
li.sort()
#print(li)
count = 0
for i in range(1, max(li)):
    index = bisect.bisect_left(li, i)
    #print(n,index,n//2)
    if index == (n+1)//2:
        #print(index)
        count += 1
print(count)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
a.sort()
sum = a[0]
for i in range(1,n):
    sum = (sum + a[i])/2
print(sum)
# Judge status: Wrong Answer
n=input()
m=int(n)
e2=0
e5=0

while m>1:
    if m%5!=0 and m%2!=0:
        continue
    m2=m
    m5=m
    while m2%2==0:
        e2=e2+1
        m2=m2/2
    while m5%5==0:
        e5=e5+1
        m5=m5/5
    m=m-2

print(min(e2,e5))
# Judge status: Accepted
a, b, c = map(int, input().split())
S = (1/2)*a*b*c/max(a,b,c)
print(int(S))
# Judge status: Wrong Answer
k,x = input().split()
if k*500 >= x:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
n = int(input())
a = [int(input()) for _ in range(n)]

ans = 0
i = 0
while i < n:
    res = 0
    for j in range(i, n):
        if a[j] == 0: break
        res += a[j]
    ans += res // 2
    i = j + 1

print(ans)
# Judge status: Accepted
l=list(map(int,input().split()))
l.sort()
k=int(input())
print(l[0]+l[1]+l[2]*2**k)
# Judge status: Wrong Answer
x=int(input())
for i in range(8):
    if(400+i*200)<=x:
        y=8-i
print(y,'級')
# Judge status: Wrong Answer
P, Q, R = map(int, input().split())
print(max(P+Q, Q+R, R+P))
# Judge status: Accepted
s = input()
n = len(s)
for i in range(n):
  for j in range(n):
    if i!=j and s[i]==s[j]:
      print("no")
      exit()
      
print("yes")
# Judge status: Accepted
n, c, k = map(int, input().split())
t = sorted([int(input()) for _ in range(n)])
ans = 1
passenger = 0
limit = t[0] + k

for p in t:
    if passenger < c and p <= limit:
        passenger += 1
    else:
        ans += 1
        passenger = 1
        limit = p + k
print(ans)
# Judge status: Accepted
S = input()
K = int(input())

# 5 * 10^15
cnt = 0

for i in range(len(S)):
    if int(S[i]) == 1:
        cnt += 1
    else:
        if cnt >= K:
            print(1)
        else:
            print(int(S[i]))
        exit()

print(1)
# Judge status: Accepted
X = int(input())

if 400 <= X and X <= 599:
  print(8)
elif 600 and X <= 799:
  print(7)
elif 800 <= X and X <= 999:
  print(6)
elif 1000 <= X and X <= 1199:
  print(5)
elif 1200 <= X and X <= 1399:
  print(4)
elif 1400 <= X and X <= 1599:
  print(3)
elif 1600 <= X and X <= 1799:
  print(2)
else:
  print(1)
# Judge status: Accepted
n,m=map(int,input().split())
if n==m:
  print('Yes')
else :
 print('No')
# Judge status: Wrong Answer
a,b=open(0).read().split()
a=int(a)
b=int(float(b)*100)
print(a*b//100)
# Judge status: Accepted
S = input()
set_ = set()

for i in S:
    set_.add(i)

if len(set_) == 4:
    print("Yes")
elif len(set_) == 2:
    if 'N' in set_ and 'S' in set_:
        print("Yes")
    elif 'E' in set_ and 'W' in set_:
        print("Yes")
    else:
        print("No")
else:
    print("No")
# Judge status: Accepted
X=int(input())
for a in range(-118,120):
  for b in range(-118,a+1):
    if a**5-b**5==X:
      print("%s %s" % (a,b))
      exit()
# Judge status: Accepted
c = input()
if c == 'a'or c =='i'or c =='u' or c == 'e'or c == 'o':
    print('vowel')
else:
    print('consonant')
# Judge status: Accepted
x=int(input())
cnt=(x//11)*2
res=x%11
if res==0:
    cnt=cnt
elif res<=6:
    cnt=cnt+1
else:
    cnt=cnt+2

print(cnt)
# Judge status: Accepted
import math
p = int(input())
d = math.floor(p / 1.08)
if(math.floor(d * 1.08) == p):
	print(d)
elif(math.floor((d+1) * 1.08) == p):
	print(d+1)
else:
	print(":(")
# Judge status: Wrong Answer
from itertools import product


def main():
    n, m, q = map(int, input().split())
    abcd = [list(map(int, input().split())) for _ in range(q)]

    mm = [_ for _ in range(1, m+1)]
    m_list = product(mm, repeat=n)

    ans = 0
    for l in m_list:
        tmp = 0
        for data in abcd:
            if l[data[1]-1] - l[data[0]-1] == data[2]:
                tmp += data[3]
        if tmp > ans:
            ans = tmp

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
def main():
    k, a, b = map(int, input().split())
    cookie = 1
    if b <= a + 1 or 1 + k <= a:
        cookie += k
    else:
        cookie += a - 1
        k -= a - 1
        if k % 2:
            k -= 1
            cookie += 1
        cookie += (b - a) * max(0, k // 2)
    print(cookie)


if __name__ == '__main__':
    main()
# Judge status: Accepted
import itertools
N, M, Q = map(int, input().split())

dic = {}
for i in range(Q):
  a, b, c, d = map(int, input().split())
  dic[(a-1, b-1, c-1)] = d
ans = 0
for ar in itertools.combinations_with_replacement(range(1, M+1), N):
  D = 0
  for com in dic.keys():
    if ar[com[1]] - ar[com[0]] == com[2]+1:
      D += dic[com]
  if D > ans:
    ans = D
print(ans)
# Judge status: Accepted
N = int(input())
B = [ int (x) for x in input().split()]

sum= B[0]+B[-1]

for i in range(len(B)-1):
  sum += min(B[i],B[i+1])

print(sum)
# Judge status: Wrong Answer
a = list(map(int,input().split()))


if a[2]>a[0] and a[2]<a[1]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
X,A,B=map(int, input().split())
if A>=B:
  print('delicious')
elif A+X>=B:
  print('safe')
else:
  print('dangerous')
# Judge status: Accepted
N=int(input())
dp=[0]*(10**4+1)
for i in range(1,100+1):
  for j in range(1,100+1):
    for k in range(1,100+1):
      a=(i+j)**2+(k+j)**2+(i+k)**2
      if 10**4<a//2:
        break
      dp[a//2]+=1
for l in range(1,N+1):
  print(dp[l])
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

if n == 2:
    a = sorted(a)
    print(a[1], a[0])
    exit()

max_a = max(a)
M = max_a // 2
min_diff = float('inf')
r = 0
for i in range(n):
    if abs(a[i] - M) < min_diff:
        min_diff = abs(a[i] - M)
        r = a[i]

print(max_a, r)
# Judge status: Wrong Answer
c = input()
if c == 'a'or c =='i'or c =='u' or c == 'e'or c == 'o':
    print('vowel')
else:
    print('constant')
# Judge status: Accepted
a=list(map(int,input().split()))
b=sorted(a)
c=b[::-1]
d=10*c[0]+c[1]
print(d+b[0])
# Judge status: Accepted
#1000 8
#1 3 4 5 6 7 8 9
n,k = map(int, raw_input().split())
s = set(map(int, raw_input().split()))
letters = [u for u in range(10) if u not in s]
def dfs(u,n,letters):return min([dfs(u*10 +l,n,letters) for l in letters if u or l]) if u < n else u

print dfs(0,n,letters)
# Judge status: Accepted
S = input()
L = [chr(i) for i in range(ord('a'), ord('z')+1)]

for l in L:
    if l not in S:
        print(l)
        exit(0)

print("None")
# Judge status: Accepted
X  = int(input())

if 400 <= X <= 599:
    print(8)
elif 600 <= X <= 799:
    print(7)
elif 800 <= X <= 999:
    print(6)
elif 1000 <= X <= 1199:
    print(5)
elif 1200 <= X <= 1399:
    print(4)
elif 1400 <= X <= 1599:
    print(3)
elif 1600 <= X <= 1799:
    print(2)
elif 1800 <= X <= 1999:
    print(1)
# Judge status: Accepted
N = int(input())
A = int(input())

if N % 500 > A:
    print('No')
else :
    print('Yes')
# Judge status: Wrong Answer
sx,sy,tx,ty = list(map(int, input().strip().split()))
dx = tx-sx
dy = ty-sy
result = ""
for i in range(dy):
  result += "U"
for i in range(dx):
  result += "R"
for i in range(dy):
  result += "D"
for i in range(dx):
  result += "L"
  
for i in range(dy+1):
  result += "U"
for i in range(dx+1):
  result += "R"
result += "DR"
for i in range(dy+1):
  result += "D"
for i in range(dx+1):
  result += "L"
result += "U"
print(result)
# Judge status: Wrong Answer
import itertools

n = int(input())
s = list(input())
s1 = [1 if s[i] == 'I' else -1 for i in range(n)]
cumsum = list(itertools.accumulate(s1))
print(s1)
print(cumsum)
ans = max(cumsum)
print(max(ans, 0))
# Judge status: Accepted
a,b = map(int,input().split())
delta = b-a
tower_b = (delta+1)*delta//2
print(tower_b - b)
# Judge status: Accepted
#Priority Queueを使った解法
import heapq

N,M = map(int,input().split())
A = list(map(lambda x:(-1)*int(x),input().split()))

heapq.heapify(A)

for i in range(M):
    a = heapq.heappop(A)
    heapq.heappush(A,(-1)*(-a//2))

print(-sum(A))
# Judge status: Accepted
n = int(input())
t = 0
x = 0
y = 0
for i in range(n):
    nt , nx , ny = map(int,input().split())
    if nt - t >= nx - x + ny -y and ((nt - t) - (nx -x + ny -y)) % 2 == 0:
        t = nt
        x = nx
        y = ny
    else:
        print("No")
        exit()
print("Yes")
# Judge status: Wrong Answer
n=int(input())
array=list(map(int,input().split()))
tot=0
x=0
count=[0]*10000000
for c in range(n):
  count[array[c]]+=1
for c in range(n):
  if x<array[c]:
    x=array[c]
    t=count[array[c]]
    tot+=int(t*(t-1)/2)
for i in range(n):
  ans=tot
  l=count[array[i]]
  ans-=int(l*(l-1)/2)
  ans+=int((l-1)*(l-2)/2)
  print(ans)
# Judge status: Wrong Answer
N = input()
s = str(N)
l = len(s)
A = 0
k = 0
for i in range(-1, -l-1,-1):
  j = int(s[i])
  if j < 5:
    A = A + j
    k = 0
  else:
    A = A + 11 - j - k
    k = 2
print(A)
# Judge status: Wrong Answer
import collections

n,m = map(int,input().split())
s = [list(map(int,input().split())) for i in range(m)]

q = collections.deque()
q.append(1)

for k in range(2):
    for j in range(len(q)):
        tmp = q.pop()
        for i in s:
            if tmp in i:
                if tmp > i[0]:
                    q.append(i[0])
                else:
                    q.append(i[1])

if n in q:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
# Judge status: Wrong Answer
import math

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

if a**2*b >= 2*x:
  l, r = 0, 45
  while r-l > pow(10, -15):
    k = (r+l)/2
    if x <= a*b*b*math.atan(math.radians(k))/2:
      r = k
    else:
      l = k
  ans = 90-(r+l)/2
else:
  l, r = 0, 45
  while r-l > pow(10, -15):
    k = (r+l)/2
    if a**2*b-x <= a**3*math.tan(math.radians(k))/2:
      r = k
    else:
      l = k
  ans = (r+l)/2
print(ans)
# Judge status: Accepted
N, D = map(int, input().split())
ans = 0
for _ in range(N):
    x, y = map(int, input().split())
    if x**2+y**2<=D**2:
        ans += 1
print(ans)
# Judge status: Accepted
N = input()
dp = [[0] * 2 for _ in range(len(N) + 1)]
dp[0][1] = 1

for i in range(len(N)):
    n = int(N[i])
    dp[i + 1][0] = min(dp[i][0] + n, dp[i][1] + 10 - n)
    dp[i + 1][1] = min(dp[i][0] + n + 1, dp[i][1] + 10 - (n + 1))

print(dp[-1][0])
# Judge status: Accepted
#!/usr/bin/env python3
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    if (i + 1) % 2 == 1 and a[i] % 2 == 1:
        ans += 1
print(ans)
# Judge status: Accepted
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)


def read_values():
    return map(int, input().split())


def read_index():
    return map(lambda x: x - 1, map(int, input().split()))


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def functional(N, mod):
    F = [1] * (N + 1)
    for i in range(N):
        F[i + 1] = (i + 1) * F[i] % mod
    return F


def main():
    N = int(input())
    print((N - 1) // 2 + 1)


if __name__ == "__main__":
    main()
# Judge status: Accepted
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for i in range(N - M + 1):
    for j in range(N - M + 1):
        flg = True
        for k in range(M):
            if A[i + k][j:j+M] == B[k]:
                continue
            else:
                flg = False
                break
        if flg:
            print('Yes')
            exit()
print('No')
# Judge status: Accepted
s = input() #sys.stdin.readlineは最後が改行
t = input() #sys.stdin.readlineは最後が改行

ans= 1000

for i in range(len(s)-len(t)+1):
    tmp = 0
    for j in range(len(t)):
        if s[i+j]!=t[j]: tmp+=1

    ans = min(ans,tmp)

print(ans)
# Judge status: Wrong Answer
N = int(input())

answers = []

for i in range(1, 10, 1):
    for j in range(1,10, 1):
        answers.append(i*j)

if N in answers:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
N,P = map(int,input().split())
A = list(map(int,input().split()))
n0=0
n1=0
for i in range(N):
    if A[i]%2==0:
        n0 += 1
n1 = N-n0
if n1==0:
    if P==0:
        print(2**n0-1)
    else:
        print(0)
elif P==0 and n0>0:
    print(2**(n1-1)*2**n0-1)
elif P==0 and n0==0:
    print(2**(n1-1)*2**n0)
elif P==1:
    print(2**(n1-1)*2**n0)
# Judge status: Accepted
S = input()

n = len(S)

good = True

for i in range(n):
    if i % 2 == 0:
        if S[i] == 'L':
            good = False
            break
    else:
        if S[i] == 'R':
            good = False
            break

if good:
    print('Yes')
else:
    print('No')