peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
ns = 0
for i in range(N):
    ns += (A[i]-(i+1))
b = round(ns/N)
ans = 0
for i in range(N):
    ans += abs(A[i]-(b+i+1))
print(ans)
# Judge status: Wrong Answer
n, k = map(int, input().split())
query = sorted([tuple(map(int, input().split()))[-1::-1] for _ in range(n)])

cnt = 0
i = 0
while cnt < k:
    b, a = query[i]
    cnt += b
    i += 1
print(query[i - 1][1])
# Judge status: Wrong Answer
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n = int(input())
    A = list(map(int,input().split()))
    kabu = 0
    kane = 1000
    for i in range(n-1):
        if A[i+1] > A[i]:
            kabu = kane // A[i]
            kane %= A[i]
        elif A[i+1] < A[i]:
            kane += kabu * A[i]
            kabu = 0
    kane += kabu * A[n-1]
    print(kane)

if __name__=='__main__':
    main()
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=1)
ans = 0
for i in range(n):
    if i % 2 == 0:
        ans += a[i]
    else:
        ans -= a[i]
print(ans)
# Judge status: Accepted
n=int(input())
alist=list(map(int,input().split()))

answer_list=[]
for i in range(n-1,-1,-2):
  answer_list.append(alist[i])
if n%2==0:
  for i in range(0,n,2):
    answer_list.append(alist[i])
else:
  for i in range(1,n,2):
    answer_list.append(alist[i])
    
print(*answer_list)
# Judge status: Accepted
n,k=map(int,input().split())
l=[True]*n
h=list(map(int,input().split()))
for i in range(k):
    a,b=map(int,input().split())
    a-=1
    b-=1
    if l[a] and h[a]<=h[b]:
        l[a]=False
    if l[b] and h[a]>=h[b]:
        l[b]=False
count=0
for i in range(n):
    if l[i]:
        count+=1
print(count)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))

prev = A[0]
isUp = True
isDown = True

ans = 0
for a in A[1:]:
  if prev == a:
    pass
  elif prev < a:
    isDown = False
    if not isUp:
      isUp = True
      isDown = True
      ans += 1
  elif a < prev:
    isUp = False
    if not isDown:
      isUp = True
      isDown = True
      ans += 1
      
  prev = a
  
print(ans+1)
# Judge status: Accepted
S=input()
m=0
count=0
for s in S:
    if s in "A":count+=1
    elif s in "C":count+=1
    elif s in "G":count+=1
    elif s in "T":count+=1
    else:count=0
    m=max(m,count)
print(m)
# Judge status: Wrong Answer
O = list(input())
E = list(input())
for o,e in zip(O,E):
    print(o+e,end="")
# Judge status: Accepted
a,b,k = [int(x) for x in input().split()]

num = b-a
l = []
if num > k:
    for i in range(a,a+k):
        l.append(i)
    for i in range(b-k+1, b+1):
        l.append(i)
    for x in sorted(list(set(l))):
        print(x)
else:
    for i in range(a,b+1):
        print(i)
# Judge status: Wrong Answer


N = int(input())
A = [int(input()) for i in range(N)]
 
 
cnt = 1
a = A[0]
while True:
	a = A[a-1]
	cnt += 1
	if a == 2:
		print(cnt)
		break

	if cnt > N:
		print(-1)
		break
# Judge status: Accepted
N = int(input())
S = input()
ans = 0
for i in range(1, N):
    X = set(S[:i])
    Y = set(S[i:])
    ans = max(ans, len(X.intersection(Y)))
print(ans)
# Judge status: Accepted
a,b,c,x,y = map(int,input().split())

ans = 0
if a+b <= 2*c:
    ans = a*x+b*y
else:
    if x>y:
        ans += 2*c*y
        l = x-y
        r = a
    else:
        ans += 2*c*x
        l = y-x
        r = b
    if 2*c < r:
        ans += 2*c*l
    else:
        ans += l*r

print(ans)
# Judge status: Accepted
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

s = list(input())
t = list(input())
s.sort()
t.sort(reverse = True)
print('Yes' if s < t else 'No')
# Judge status: Accepted
n,a,b = map(int,input().split())
x = b-a
if x % 2 == 0 : 
  print(x//2)
else:
  m = (a-1)+1+((b-a-1)//2)
  l = (n-b)+1+((b-a-1)//2)
  print(min(m,l))
# Judge status: Wrong Answer
A = input()
S = input()
if int(A) >= 3200:
    print(S)
else:
    print("Red")
# Judge status: Wrong Answer
a,b = map(int,input().split())
print(round(a+b)/2)
# Judge status: Wrong Answer
X, A, B = map(int, input().split())

if A - B > 0:
    print('delicious')
elif A - B > -X:
    print('safe')
else:
    print('dangerous')
# Judge status: Accepted
import random

D = int(input())
c_list = list(map(int, input().split()))
for i in range(D):
    S_list = list(map(int, input().split()))
for i in range(1,D+1):
    print(5)
    # print(random.randint(1,26))
# Judge status: Wrong Answer
x,a,b = map(int, input().split())
if abs(x-a) > abs(x-b):
    print("A")
else:
    print("B")
# Judge status: Accepted
from itertools import combinations_with_replacement
n,m,q = map(int,input().split())
ans = -1
li = [tuple(map(int,input().split())) for i in range(q)]
for K in combinations_with_replacement(range(1,m+1),n):
    s = 0
    for a,b,c,d in li:
        a -= 1
        b -= 1
        if K[b]-K[a] == c:
            s += d
    ans = max(ans,s)
print(ans)
# Judge status: Accepted
a,b=map(int,input().split())
if a>=13:
    print(b)
elif a>=6 and a<=12:
    print(int(b/2))
else:
    print(0)
# Judge status: Accepted
n, m = map(int, input().split())
l = list(map(int, input().split()))

import fractions
from functools import reduce

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

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

#print(lcm_list(l))

x = lcm_list(l)

for i in range(n):
  if (x//l[i])%2 == 0:
    print(0)
    exit()

ans = (m*2)//lcm_list(l)
if ans%2 == 1:
  print((ans+1)//2)
else:
  print(ans//2)
# Judge status: Accepted
import math
def f(x,y):
  s = 0
  for i in range(len(x)):
    s += (x[i]-y[i]) ** 2
  return math.sqrt(s)

n,d = map(int, input().split())
X = [list(map(int, input().split())) for i in range(n)]
ans = 0
for i in range(n-1):
  for j in range(i+1,n):
    if f(X[i],X[j]) == math.floor(f(X[i],X[j])):
      ans += 1
 
print(ans)
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    a=int(input())
    b=int(input())
    c=int(input())
    d=int(input())
    e=int(input())
    print(-(-n//min(a,b,c,d,e))+4)

if __name__=='__main__':
    main()
# Judge status: Accepted
s=input()
flag=0
for i in range(len(s)):
  if s[i]!=s[len(s)-1-i]:
    flag=1
for i in range(int((len(s)-1)/2)):
  if s[i]!=s[int((len(s)-1)/2)-1-i]:
    flag=1
for i in range(int((len(s)+3)/2)-1,len(s)):
  if s[i]!=s[len(s)-1-i]:
    flag=1
if flag==1:
  print("No")
else:
  print("Yes")
# Judge status: Accepted
m=[]
cnt=0
for i in range(5):
    x=int(input())
    m.append(x)
m10=[i % 10 for i in m if i %10 >=1]
if m10:
    t=min(m10)
    for i in m:
        if i %10==0:
            cnt += i
        else:
            cnt += ((i//10)+1)*10
    print(cnt-10+t)
else:
    print(sum(m))
# Judge status: Wrong Answer
S = input()
if(S[2] == S[3] and S[4]==S[5] ):
	print("YES")
else :
	print("No")
# Judge status: Wrong Answer
x = int(input())
print((1+x)*x/2)
# Judge status: Accepted
n = int(input())
p_n = list(map(int, input().split()))

count = 0
for i in range(1, n - 1):
    if ((p_n[i - 1] < p_n[i] and p_n[i] < p_n[i + 1]) or
        (p_n[i - 1] > p_n[i] and p_n[i] > p_n[i + 1])):
        count += 1

print(count)
# Judge status: Wrong Answer
k=int(input())
if k//10==0:
    print(k)
    exit()

cnt=0
x=9
while k>=cnt:
    x+=1
    l=str(x)
    a = [int(c) for c in l]
    for i in range(len(a)-1):
        if a[i]-a[i+1]==1 or a[i]-a[i+1]==-1:
            cnt+=1

    if k-11==cnt:
        print(x)
        exit()
# Judge status: Accepted
a = input()

if a.isupper():
  print("A")
else:
  print("a")
# Judge status: Accepted
N=int(input())
d=list(map(int,input().split()))
d.sort()
print(d[N//2]-d[N//2-1])
# Judge status: Accepted
import math
a, b = map(str, input().split())
n = int(a + b)
if math.sqrt(n).is_integer():
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
a,b,c = map(int,input().split())

if a <= b <= c:
   print("No")
elif a >= b >= c:
   print("No")
else:
   print("Yes")
# Judge status: Wrong Answer
n=int(input())
s=input()

from collections import Counter

ans = 1
for t in Counter(s).values():
    ans*=t

for step in range(1,n//2+2):
    for start in range(n):
#         print(start,step,start+2*step,n)
        if start+2*step>=n:
#             print("out!")
            break
        ans-=len(set((s[start], s[start+step],s[start+2*step])))==3
ans
# Judge status: Wrong Answer
N=int(input())
H=list(map(int,input().split()))
max=0
ans=0
for i in range(N-1):
    if H[i]>=H[i+1]:
        max+=1
        print(i)
    else:
        max=0
    if ans<=max:
        ans=max
print(ans)
# Judge status: Accepted
n = int(input())
d = {}
d['AC'] = 0
d['WA'] = 0
d['TLE'] = 0
d['RE'] = 0
for i in range(n):
    s = str(input())
    d[s] += 1

print('AC', 'x', d['AC'])
print('WA', 'x', d['WA'])
print('TLE', 'x', d['TLE'])
print('RE', 'x', d['RE'])
# Judge status: Wrong Answer
w, h, n = map(int, input().split())
x1 = 0
y1 = 0
x2 = w
y2 = h
for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        x1 = x
    elif a == 2:
        x2 = x
    elif a == 3:
        y1 = y
    else:
        y2 = y

if x1 >= x2 or y1 >= y2:
    print("0")
else:
    print((x2-x1)*(y2-y1))
# Judge status: Accepted
x,y = map(int,input().split())
"""
1zi houteisiki
2a+2b = 2x
2a+4b = y
2b = y-2x
2a = 4x-y
"""
if (y-2*x) % 2 == 0 and (4*x-y) % 2 == 0 and y-2*x >= 0 and 4*x-y >= 0:
	print("Yes")
else:
	print("No")
# Judge status: Wrong Answer
n = int(input())
A = list(map(int, input().split()))

left = max(A)

right = 0
dif_min = 10**10
mid = (max(A)//2) + 1

for i in range(n):
    if A[i] == left:
        continue
    dif = abs(A[i] - mid)
    if dif <= dif_min:
        dif_min = dif
        right = A[i]

print(str(left) + ' ' + str(right))
# Judge status: Accepted
n = int(input())
s = input()
x = 0
ans = 0
for i in range(n):
    if s[i]=="I":
       x+=1
    else :
        x-=1
    ans = max(ans,x)
print(ans)
# Judge status: Wrong Answer
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
mod = 10**9 +7
dp = [0]*(N+1)
dp[0] = 1
if len(A)>=1 and N>=1:
    if A[0]==1:
        dp[1]=0
    else:
        dp[1]=1
for i in range(2, N+1):
    if i not in A:
        dp[i] = (dp[i-1]+dp[i-2])%mod
print(dp[-1])
# Judge status: Accepted
h,n=map(int,input().split())
a=list(map(int,input().split()))

print('Yes' if h<=sum(a) else 'No')
# Judge status: Accepted
import numpy as np

N = int(input())

AC = 0
WA = 0
TLE = 0
RE = 0

for i in range(N):
    
    S = input()

    if S == "AC":
        AC += 1
    elif S == "WA":
        WA += 1
    elif S == "TLE":
        TLE += 1
    elif S == "RE":
        RE += 1

print("AC x {0}".format(AC))
print("WA x {0}".format(WA))
print("TLE x {0}".format(TLE))
print("RE x {0}".format(RE))
# Judge status: Wrong Answer
num = list(map(int, input().split()))
a, b = num

if(a%b == 0):
    print(0)
else:    
    print(int(abs(a%b - a//b)))
# Judge status: Accepted
s = sorted(input())
t = sorted(input(), reverse=True)
if s < t:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if V <= W:
    print('NO')
    exit()

tmp = abs(B - A)
k = V - W
if tmp <= k * T:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
s = str(input())
for i in range(len(s)):
    for j in range(i,len(s)):
        if (s[:i] + s[j:]) == "keyence":
            print("YES")
            exit()
print("NO")
# Judge status: Wrong Answer
N, M = map(int, input().split())
A = list(map(int, input().split()))
magic = [list(map(int, input().split())) for _ in range(M)]
magic = sorted(magic, key=lambda x: -x[0])

hold = []
now = 0
for k, v in magic:
    hold.extend([v]*k)
    now += k
    if now >= N:
        break
A.extend(hold)
A.sort(reverse=True)
print(sum(A[:N]))
# Judge status: Wrong Answer
N,L=map(int,input().split())

tot=N*L+(N-1)*N/2
ans=[]


for i in range(N):
    ans.append(abs(tot-(L+i)))

print(int(max(ans)))
# Judge status: Wrong Answer
a,b,m=map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
tickets=list()
for i in range(m):
    tickets.append(list(map(int,input().split())))

price_min=float("INF")
for ticket in tickets:
    price = A[ticket[0]-1] + B[ticket[1]-1] - ticket[2]
    price_min = price if price_min>price else price_min

# 割引券を使わない場合
for _a in A:
    for _b in B:
        price=_a + _b
        if price_min > price: price_min=price
        else: break
print(price_min)
# Judge status: Accepted
l = int(input())

print((l/3)*(l/3)*(l/3))
# Judge status: Accepted
n, k = map(int, input().split())
li = list(map(int, input().split()))

for i in range(n-k):
    if li[i] < li[i + k]:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
a,b,c=map(int,input().split())
print(a*b//2)
# Judge status: Accepted
import sys
from math import sqrt
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A =[[int(_) for _ in input().split()] for i in range(n)]
    ans=0
    for i in range(n-1):
        for j in range(i+1,n):
            ans+=sqrt((A[i][0]-A[j][0])**2+(A[i][1]-A[j][1])**2)
    print(ans*2/n)
if __name__=='__main__':
    main()
# Judge status: Accepted
import sys
N = int(input())

for i in range(1,10):
    a = N / i
    if(a <= 9 and N % i ==0):
        print("Yes")
        sys.exit()
print("No")
# Judge status: Wrong Answer
a, b, c = map(int, input().split())

if a % b == 0 and c != 0:
    print('NO')
else:
    print('YES')
# Judge status: Accepted
X = int(input())
c, r = 0, X % 100
for d in range(5, 0, -1):
    c += r // d
    r = r % d
if c > X // 100:
    print(0)
else:
    print(1)
# Judge status: Wrong Answer
x,a,b=map(int,input().split())
if (a-x)>(b-x):
    print("B")
else:
    print("A")
# Judge status: Accepted
[x,y] = list(map(int, input().split()))
if y%2 == 0:
    if 2*x <= y <= 4*x:
        print('Yes')
    else:
        print('No')
else:
    print('No')
# Judge status: Accepted
import math
import sys
a, b, x = map(int, input().split())
up, down = 0, b
a_dec = 2*x / (a * b)
if a_dec > a:
    up = 2 * x/(a**2) - b
    up = b - up
    c = (a**2+up**2)**(1/2)
    print(math.degrees(math.asin(up/c)))
    sys.exit(0)
c = (a_dec**2+b**2)**(1/2)
print(math.degrees(math.asin(b/c)))
# Judge status: Accepted
from itertools import accumulate
n = int(input())
a = list(map(int, input().split()))

total = sum(a)
cum_sum = list(accumulate(a))

ans = float("INF")
for former in cum_sum:
    ans = min(ans, abs(former - (total - former)))
print(ans)
# Judge status: Wrong Answer
n, d = map(int, input().split())

print(n, d)

x = []
y = []

for i in range(n):
    tempx, tempy = map(int, input().split())
    x.append(tempx)
    y.append(tempy)

count = 0


for i in range(n):
    if(d ** 2 >= x[i] ** 2 + y[i] ** 2):
        count += 1

print(count)
# Judge status: Wrong Answer
import sys
import math
import itertools

n = int(input())
l0=2
l1 = 1
l = l0 + l1
for i in range(n-2):
    l0 = l1
    l1 = l
    l = l0 + l1
if n == 1:
    l = 2
elif n == 2:
    l = 1
    
print(l)
# Judge status: Wrong Answer
S = input()
count = 0
for s in S:
  if s == "0":
    count += 1
print(count)
# Judge status: Accepted
h = int(input())

def attack(health):
    if health == 1:
        return 1
    else:
        return 1 + (attack(int(health/2)) * 2)

print(attack(h))
# Judge status: Accepted
N = int(input())
P = [int(p) for p in input().split()]
Q = [int(q) for q in input().split()]

import itertools

L = []
for temp in itertools.permutations(P):
    L.append(temp)
    
L.sort()
for i in range(len(L)):
    if list(L[i]) == P:
        a = i
    if list(L[i]) == Q:
        b = i
        
print(abs(a-b))
# Judge status: Accepted
N,K=map(int,input().split())
H=sorted([int(_) for _ in input().split()])
print(0 if N<=K else sum(H[:N-K]))
# Judge status: Accepted
k,a,b= map(int,input().split())
cur = 1
#交換しないほうがいい
if b - a <= 2:
  print(cur + k)
  exit()
#交換できない
if cur + k <= a+1:
  print(cur + k)
  exit()
#交換するまで増やす
cur, k, = a, k-a+cur
#偶数回交換する
cur += (b - a) * (k // 2)
k %= 2
#最後に足す
cur += k
print(cur)
# Judge status: Accepted
import sys
N = int(input())
H = list(map(int, input().split()))

H.reverse()
for n in range(1, N):
    if H[n]-H[n-1]==1:
        H[n] -= 1
    elif H[n]-H[n-1] > 1:
        print("No")
        sys.exit(0)
print("Yes")
# Judge status: Accepted
N,*a = map(int, open(0).read().split())
b = [x for x in a if x % 4 == 0]
c = [x for x in a if x % 2 == 0]
d = [x for x in a if x % 2 == 1]
if len(b) >= len(a) // 2:
    print('Yes')
elif len(d) <= len(b):
    print('Yes')
elif len(c) == len(a):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N,*A = map(int,open(0).read().split())
print(5+(N-1)//min(A))
# Judge status: Wrong Answer
x=int(input())
y=19
z=[5,11,15]

ans=0
ans+=x//11*2
cnt=x%11
if cnt>=6:
  ans+=2
elif cnt>=1:
  ans+=1
  
print(ans)
# Judge status: Accepted
A, B, K = map(int, input().split())

if A > K:
  A -= K
else:
  K -= A
  A = 0
  if B > K:
    B -= K
  else:
    B = 0

print(A, B)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

S, T = input().split()
A, B = map(int, input().split())
U = input()

if S==U:
  print(A-1,B)
else:
  print(A,B-1)
# Judge status: Accepted
import math

N = int(input())

ans = 0

for i in range(int(math.log10(N)) + 1):
    if i % 2 != 0:
        pass
    elif i == int(math.log10(N)):
        ans += N - 10**i + 1
    else:
        ans += 10**(i+1) - 10**i

print(ans)
# Judge status: Wrong Answer
A, B, X = map(int, input().split())
if A < X and (X-A) <= B:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
from collections import defaultdict
d = defaultdict(int)
A, B, C = map(int, input().split())
d[A] += 1
d[B] += 1
d[C] += 1
if d[5] == 2 and d[7] == 1:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
import collections
n,k,q=map(int,input().split())
a=list(map(int,input().split()))
c=collections.Counter(a)

for i in range(n):
  if k-q+c[i+1]>0:
    print('Yes')
  else:
    print('No')
# Judge status: Accepted
import math
n=int(input())
sum=0
for i in range(1,n):
  sum+=math.ceil(n/i)-1
print(sum)
# Judge status: Accepted
n=int(input())
ab=[list(map(int,input().split())) for _ in range(n)]



sort_ab = sorted(ab, key=lambda x:(x[1], x[0]))
#print(sort_ab)
count=0
for i in range(n):
    count+=sort_ab[i][0]
    if sort_ab[i][1]<count:
        print("No")
        break
else:
    print("Yes")
# Judge status: Wrong Answer
n, x = list(map(int, input().split(' ')))

ss = list(map(int, input().split(' ')))
    
r = x
count = 0    
for s in sorted(ss):
    if r - s < 0:
        break
    else:
        r -= s
        count += 1
print(count)
# Judge status: Accepted
s = list(input())
t = list(input())
leng = len(s)
if s[0:leng] == t[0:leng]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
X = int(input())

N = 100
C = 0

while True:
    N = int(N * 1.01)
    C += 1
    if N >= X:
        break

print(C)
# Judge status: Accepted
N = input()
total = 0
for i in N:
    total = (total + int(i)) % 9

if total == 0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n=int(input())
s=[]
for _ in range(n):
    s.append(int(input()))
s.sort()
ans=sum(s)
i=0
while ans % 10 ==0 and i < n:
    if s[i]%10!=0:
        ans-=s[i]
    i+=1
if i==n:
    print(0)
else:
    print(ans)
# Judge status: Accepted
from bisect import bisect_left
from bisect import bisect_right

n = int(input().strip())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
ans = 0
for elem in b:
    idx_c = bisect_right(c, elem)
    rep = (n - idx_c)
    idx_a = bisect_left(a, elem)
    ans += rep * idx_a
print(ans)
# Judge status: Wrong Answer
from collections import defaultdict
N,M = map(int,input().split())
cand = defaultdict(set)

for i in range(M):
  s,c = map(int,input().split())
  cand[s].add(c)

ans = ""
for i in range(1,N+1):
  if cand[i]:
    if len(cand[i])>1:
      print(-1)
      exit()
    else:
      for j in cand[i]:
          ans += str(j)
  else:
    ans += "0"
                    
if ans[0]== "0":
  print(-1)
else:
  print(ans)
# Judge status: Wrong Answer
a = list(input().split())
print(a[2],a[1],a[0])
# Judge status: Accepted
def count(x1,x2):
    if x1<=4 or (x1==5 and x2 <=4):
        return x1,0 
    else:
        return 10-x1,1

n='0'+input()
count_sum = 0
digit_plus = 0
for c1,c2 in zip(n[::-1],n[-2::-1]):
    count_add, digit_plus = count(int(c1)+digit_plus,int(c2))
    count_sum += count_add
if digit_plus: count_sum += 1
print(count_sum)
# Judge status: Accepted
n,a,b=map(int,input().split())
x=a+b
y=n//x
z=n%x
if z==0:
    print(a*y)
    exit()
else:
    if z>=a:
        print(y*a+a)
    else:
        print(y*a+z)
# Judge status: Accepted
X,Y=map(int,input().split())
print(X if X%Y!=0 else -1)
# Judge status: Wrong Answer
n=int(input())
a=n%10
if a in [1,6,8]:
  print('pon')
elif a in [2,4,5,7,9]:
  print('hon')
else:
  print('bon')
# Judge status: Accepted
n = len(input())

if n <= 3:
  print("ABC")
  
else:
  print("ABD")
# Judge status: Wrong Answer
w,a,b = map(int,input().split())
if a + w <= b:
    print(b - (a + w))
else:
    print(a - (b + w))
# Judge status: Wrong Answer
n = sorted(list(input()))
if n[0] == n[1] and n[1] == n[2]:
  print('Yes')
  exit()
if n[1] == n[2] and n[2] == n[3]:
  print('Yes')
  exit()
print('No')
# Judge status: Accepted
N,A,B = map(int,input().split())
S = input()

d = 0
o = 0
p = 0

for i in range(N):
  if S[i]=="a":
    d+=1
    if p<A+B:
      p+=1
      print("Yes")
    else:
      print("No")
  elif S[i]=="b":
    o+=1
    if p<A+B and o <= B:
      p+=1
      print("Yes")
    else:
      print("No")
  else:
    print("No")
# Judge status: Accepted
n = int(input())
rest = [list(input().split()) for i in range(n)]

for i in range(n):
    rest[i].append(i+1)
    rest[i][1] = int(rest[i][1])*-1

rest.sort()
for re in rest:
    print(re[2])
# Judge status: Wrong Answer
o,cost = map(int,input().split())
if o > 12:
  cost = cost
elif o >= 6:
  cost = cost / 2
else:
  cost = 0
print(cost)
# Judge status: Accepted
k, x = map(int, input().split())
for i in range(x - (k - 1), x + (k - 1)):
    print(i, end=' ')
print(x + (k - 1))
# Judge status: Accepted
A = []
for i in range(3):
  a = input()
  A.append(a)
x = 0
while 1:
  if len(A[x]) == 0:
    print(chr(65 + x))
    break
  s = A[x][0]
  A[x] = A[x][1:]
  x = ord(s) - 97
# Judge status: Accepted
s=input()
t=input()
ans=[]
for i in range(len(s)-len(t)+1):
  start=i
  end=i+len(t)
  ok=True
  for j in range(len(t)):
    if s[start+j]!='?' and s[start+j]!=t[j]:
      ok=False
      break
  if ok:
    a=s[:start]+t+s[end:]
    ans.append(a.replace('?','a'))
if ans:
  ans=sorted(ans)
  print(ans[0])
else:
  print('UNRESTORABLE')
# Judge status: Accepted
inf = 10 ** 9
h,n = map(int, input().split())
a = []
b = []
for i in range(n):
    aa,bb = map(int, input().split())
    a.append(aa)
    b.append(bb)

dp = [0] * (h + 1)

for i in range(1, h + 1):
    x = inf
    for j in range(n):
        p = max(0, i - a[j])
        x = min(x, b[j] + dp[p])
    dp[i] = x

print(dp[h])
# Judge status: Wrong Answer
s=input()
print('AC' if s[0]=='A' and s[2]=='C' and s[1].islower() and s[3:].islower() else 'WA')
# Judge status: Accepted
n,k = map(int,input().split())

ans = [[0]*k for i in range(n)]
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in a:
        ans[j-1][i] = 1

ass = 0
for i in range(n):
    if sum(ans[i]) == 0:
        ass += 1
        
print(ass)
# Judge status: Wrong Answer
import math
A,B,H,M = map(int,input().split())
angle = 360*abs(H/12-M/60)
angle = math.radians(angle)
print((A**2 + B**2 - 2*A*B*math.cos(angle))**(1/2))
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    if N >= 1000: print("ABD")
    else: print("ABC")


if __name__ == "__main__":
    main()