peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
def fact(n,mod):
  ret=1
  for i in range(2,n+1):
    ret=(ret*i)%mod
  return ret

def pCq(p,q,mod):
  pCq=1
  for i in range(q):
    pCq*=p-i
    pCq=pCq%mod
    den=fact(q,mod)
    inv=pow(den,mod-2,mod)
    pCq=(pCq*inv)%mod
  return pCq

X,Y=map(int,input().split())
MOD=10**9+7
ans=0
n,m=2*X-Y,2*Y-X
if n%3==0 and m%3==0:
  n//=3
  m//=3
  ans+=pCq(m+n,m,MOD)
print(ans)
# Judge status: Accepted
alp = [chr(i) for i in range(97, 97+26)]
print(alp[alp.index(input())+1])
# Judge status: Wrong Answer
N, M = map(int, input().split())
if N == 1 and M == 1:
    print(0)
elif N == 1 and M != 1:
    print(M - 2)
elif M == 1 and N != 1:
    print(N - 2)
else:
    print((N - 2) * (M - 2))
# Judge status: Accepted
# coding: utf-8
import sys
from collections import Counter

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
T = sr()
cnt_S = Counter(S)
cnt_T = Counter(T)
num_S = sorted(list(cnt_S.values()))
num_T = sorted(list(cnt_T.values()))

bl = num_S == num_T
print('Yes' if bl else 'No')
# Judge status: Wrong Answer
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n ,c, k = inintm()

T = []
ans = 1

for _ in range(n):
    T.append(inint())

T.sort()

f = T[0]

for i in range(1,n):
    if T[i] - f < k:
        continue
    else:
        f = T[i]
        ans += 1

print(ans)
# Judge status: Accepted
from collections import deque
s = input()
de = deque()
for i in s:
    if i == "0":
        de.append("0")
    elif i == "1":
        de.append("1")
    elif i == "B":
        if len(de) != 0:
            de.pop()
ans = "".join(de)
print(ans)
# Judge status: Accepted
from bisect import bisect_left
n=int(input())
L=list(map(int, input().split()))
L.sort()
count = 0
for a in range(n-2):
  for b in range(a+1,n-1):
    count += bisect_left(L, L[a]+L[b]) - b - 1

print(count)
# Judge status: Accepted
def main():
    N, Q = (int(i) for i in input().split())
    S = input()
    LR = [[int(i) for i in input().split()] for j in range(Q)]
    AC = [0]*N
    for i, s in enumerate(S):
        AC[i] = AC[i-1]
        if i > 0 and S[i-1] == "A" and s == "C":
            AC[i] += 1
    S = list([0] + AC)
    for le, ri in LR:
        print(S[ri] - S[le])


if __name__ == '__main__':
    main()
# Judge status: Accepted
x, y = map(int, input().split())

a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
if x in a and y in a:
  print('Yes')
elif x in b and y in b:
  print('Yes')
elif x in c and y in c:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
N=int(input())
A=[]
B=[]
for i in range(N):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)
  
A.sort()
B.sort()


mini=A[(N-1)//2]
maxi=B[(N-1)//2]
if N//2==0:
  print((maxi-mini)*2+1)
else:
  print(maxi-mini+1)
# Judge status: Accepted
x = int(input())
if x%11 == 0:
    print(x//11 * 2)
elif 1 <= x%11 <= 6:
    print(x//11 * 2 + 1)
else:
    print(x//11 * 2 + 2)
# Judge status: Accepted
import math

X = int(input())
maxBeki = 1
for b in range(1, X, 1):
    for p in range(2, X, 1):
        if b**p <= X:
            maxBeki = max(maxBeki, b ** p)
        else:
            break
print(maxBeki)
# Judge status: Accepted
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())
sum = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            sum += gcd(a,b,c)

print(sum)
# Judge status: Wrong Answer
a,b = map(int, input().split())
print(min(min(a,12)-1,min(b,31)-1)+1)
# Judge status: Accepted
l=list(map(int,input().split()))
l.sort()
print(l[0]+l[1])
# Judge status: Accepted
n=int(input())
h=[]
add=[]
diff=[]
diff1=[]
for i in range(n):
  l=list(map(int,input().split()))
  h.append(l)
  p=h[i][0]+h[i][1]
  add.append(p)
  k=h[i][0]-h[i][1]
  diff.append(k)
  r=h[i][1]-h[i][0]
  diff1.append(r)
a=max(add)-min(add)
b=max(diff)-min(diff)
c=max(diff1)-min(diff1)
print(max(a,b,c))
# Judge status: Accepted
a=input()
b=input()
if a[0]==b[2] and a[1]==b[1] and a[2]==b[0]:
  print("YES")
else:
  print("NO")
# Judge status: Accepted
a,b,c,k = map(int,input().split())

if k%2 == 0: 
    ans = a-b
else:
    ans = b-a
if ans > 10**18:
    print('Unfair')
else:
    print(ans)
# Judge status: Accepted
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop

import collections

a,b,x = map(int,input().split())
ab = a+b
if x>=a and x<=ab:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
x, y = map(int, input().split())

# これで通らないのは、y/xが大きな数字になったとき
# print(int(log2(y/x)) + 1)

tmp = y/x
cnt = 0
while tmp > 2:
    cnt += 1
    tmp = tmp // 2
print(cnt + 1)
# Judge status: Accepted
n = int(input())
d = list(map(int ,input().split()))
if d[0] != 0:
  print (0)
  exit()
d.sort()
mod = 998244353
s = [0 for i in range(max(d)+1)]

for i in range(n):
  s[d[i]] += 1
ans = 1
for i in range(len(s)):
  if s[i] == 0:
    print (0)
    exit()
  if i == 0:
    if s[i] > 1:
      print (0)
      exit()
    continue
  ans *= pow(s[i-1],(s[i]),mod)
  ans %= mod
print (ans%mod)
# Judge status: Accepted
ans = 'No'
x, y = map(int, input().split())
for i in range(x+1):
  if (2 * i) + (4 * (x-i)) == y:
    ans = 'Yes'
    break
print(ans)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
dp=[0]*(10**5+1)
ans=sum(A)
for i in range(N):
  dp[A[i]]+=1
for _ in range(Q):
  B,C=map(int,input().split())
  dp[C]+=dp[B]
  ans+=dp[B]*(C-B)
  dp[B]=0
  print(ans)
# Judge status: Wrong Answer
from math import ceil
A,B=map(int, input().split())

print(ceil( B / (A-1)))
# Judge status: Accepted
n = int(input())
d, m = divmod(n, 11)
ans = d*2
if m > 6:
    ans += 2
elif m > 0:
    ans += 1
print(ans)
# Judge status: Accepted
N , K =map(int,input().split())
MOD=10**9+7
ans=0
if N<K:
    print(1)
else:
    tmp_low = sum(range(K))
    tmp_high = sum(range(N-K+1,N+1))
    r=tmp_high-tmp_low+1
    ans+=r
    ans%=MOD
    for sel in range(K+1,N+2):
        tmp_low += sel-1
        tmp_high += N-sel+1
        r= tmp_high-tmp_low+1
        ans+=r
        ans%=MOD
    print(ans%MOD)
# Judge status: Wrong Answer
l,r=map(int,input().split())

if r-l>=2019:
  print(0)
else:
  m=2019
  for i in range(l,r+1,1):
    for j in range(l,r+1,1):
      m=min(i*j%2019,m)
  print(m)
# Judge status: Accepted
import sys
import time
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N = int(input())

def dfs(s, n, m):
    if n > N:
        print(''.join([chr(ss) for ss in s]))
        return True
    for ns in range(97, m+2):
        s[n-1] = ns
        dfs(s, n+1, max(m, ns))

s = [0] * N
dfs(s, 1, 96)
# Judge status: Accepted
n = int(input());
a = input().split(" ");
x = int(a[0]);
y = 0;
for i in range(1,n) :
	y += int(a[i]);

ans = abs(x - y);
for i in range(1,n-1) :
	x += int(a[i]);
	y -= int(a[i]);
	if abs(x - y) < ans :
		ans = abs(x - y);
print(ans);
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    s=input()
    ans='No'
    if 'N' in s and 'S' in s and 'W' in s and 'E' in s:
        ans='Yes'
    elif 'N' in s and 'S' in s and \
            'W' not in s and 'E' not in s:
        ans='Yes'
    elif 'N' not in s and 'S' not in s and\
            'W' in s and 'E' in s:
        ans='Yes'
    print(ans)
resolve()
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N, M = map(int, input().split())
    A = sorted(map(int, input().split()))[::-1]

    if A[M-1] * 4 * M >= sum(A):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
def create_koho(X):
    koho = [1]
    koho_sum = 1
    i = 1
    while koho_sum <= X:
        i += 1
        koho.append(i)
        koho_sum += i

    return koho


X = int(input())
koho = create_koho(X)
nokori = X
ans = 0
for i in reversed(koho):
    if nokori >= i:
        nokori -= i
        ans += 1

print(ans)
# Judge status: Accepted
import math
n, d = map(int, input().split())

x = []
for i in range(n):
    a = list(map(int, input().split()))
    x.append(a)

count = 0
for i in range(n):
    for j in range(i+1,n):
        l = 0
        for k in range(d):
            l += (x[i][k] - x[j][k])**2
        if(math.sqrt(l).is_integer()):
            count += 1
print(count)
# Judge status: Accepted
import collections

N = int(input())
A = list(map(int, input().split()))
B = collections.defaultdict(int)
C = collections.defaultdict(int)

for i in range(N):
    B[i-A[i]] += 1 
    C[i+A[i]] += 1
#print(B)
#print(C)
ans = 0
for i in B:
    #print(i) i=Key
    ans += B[i]*C[i]
print(ans)
# Judge status: Accepted
n,k,*x=map(int,open(0).read().split())
if x[0]>=0:
  ans=x[k-1]
elif x[-1]<=0:
  ans=abs(x[~(k-1)])
else:
  ans=10**10
  for i in range(n-k+1):
    l=x[i]
    r=x[i+k-1]
    if l<=0<=r:
      ll=abs(l)
      rr=abs(r)
      tmp=min(ll+2*rr,2*ll+rr)
      ans=min(ans,tmp)
      
print(ans)
# Judge status: Accepted
q, h, s, d = map(int, input().split())
n = int(input())
s = min(q*4, h*2, s)
if s*2 <= d: print(s*n)
else: print(d*(n//2) + s*(n%2))
# Judge status: Accepted
# https://atcoder.jp/contests/abc055/tasks/abc055_a
n = int(input())
x = n * 800
y = int(n / 15) * 200
print(x - y)
# Judge status: Accepted
h1, m1, h2, m2, k = list(map(int, input().split()))
print((h2 * 60 + m2) - (h1 * 60 + m1) - k)
# Judge status: Accepted
def main():
    D = int(input())
    C = list(map(int, input().split()))
    S = [list(map(int, input().split())) for _ in range(D)]

    score = 0
    last_day = [-1] * 26
    ans = [1] * D
    print(*ans, sep="\n")


if __name__ == '__main__':
    main()
# Judge status: Accepted
def main():
    import sys
    input = sys.stdin.readline
    A, V = [int(x) for x in input().strip().split()]
    B, W = [int(x) for x in input().strip().split()]
    T = int(input())
    if A == B:
        print('YES')
        return
    if W > V:
        print('NO')
        return
    if (V - W) * T >= abs(A - B):
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n = int(input())
a = sorted([int(input()) for _ in range(n)])
ans = 0
tmp = 1
for i in range(n-1):
    if a[i] == a[i+1]:
        tmp += 1
    else:
        if tmp % 2 == 1:
            ans += 1
        tmp = 1
print(ans)
# Judge status: Accepted
N = int(input())
print(800 * N - 200 * (N // 15))
# Judge status: Accepted
n,k =map(int,input().split())
if n%k==0:
  print(0)
else:
  print(min(n%k,abs((n%k)-k)))
# Judge status: Accepted
N, M = map(int, input().split())

# Mの約数列挙
divs = []
for i in range(1, int(M ** 0.5) + 1):
    if M % i == 0:
        divs.append(i)
        divs.append(M // i)

ans = 0
divs.sort(reverse=True)
for d in divs:
    if N * d <= M:
        print(d)
        exit()
# Judge status: Accepted
N, A, B = map(int, input().split())
S = list(input())

n = 0
b = 0

for s in S:
  if s == 'c':
    print('No')
  elif s == 'a':
    if n < A + B:
      print('Yes')
      n += 1
    else:
      print('No')
  else:
    if n < A + B and b < B:
      print('Yes')
      n += 1
      b += 1
    else:
      print('No')
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

satisfy = 0
for i in range(N):
    if A[i] == A[i - 1] + 1 and i >= 1:
        satisfy += C[A[i - 1] - 1]
    satisfy += B[A[i] - 1]
print(satisfy)
# Judge status: Accepted
N = int(input())
print(N * 800 - (N // 15) * 200)
# Judge status: Accepted
r = int(input())
print(6.28*r)
# Judge status: Accepted
N = int(input())
X=[0]*N
for i in range(N):
    X[i] = list(map(int, input().split()))
X.sort(key=lambda x:x[1])
def check():
    now = 0
    for i in range(N):
        now += X[i][0]
        if now > X[i][1]:
            return 'No'
    return 'Yes'
print(check())
# Judge status: Accepted
S=input()
start=0
end=len(S)-1
for i in range(len(S)):
  if S[i]=="A":
    start=i
    break
S=S[::-1]
for i in range(len(S)):
  if S[i]=="Z":
    end = len(S)-i
    break
print(end-start)
# Judge status: Accepted
N=int(input())
s=[]
nin=10**7
for i in range(N):
    temp=int(input())
    if temp%10!=0:
        nin=min(nin,temp)
    s.append(temp)

ans=sum(s)
if ans%10==0:
    ans-=nin
    print(max(ans,0))
else:
    print(ans)
# Judge status: Accepted
X = int(input())

if X==3 or X==5 or X==7:
  print('YES')
else:
  print('NO')
# Judge status: Wrong Answer
import bisect

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

count = 0
for j in range(n):
    i = bisect.bisect_left(A, B[j])
    k = bisect.bisect(C, B[j])
    print(i, j, k)
    count += (i * (n - k))

print(count)
# Judge status: Wrong Answer
N = int(input())
L = list(map(int, input().split()))
Ans = 0
for i in range(N):
    if (L[i] %2 == 1) &( i % 2 == 1):
        Ans += 1
print(Ans)
# Judge status: Accepted
N,T=map(int,input().split())

c_min=1001
for i in range(N):
  c,t=map(int,input().split())
  if t<=T and c<c_min:
    c_min=c
if c_min==1001:
  print('TLE')
else:print(c_min)
# Judge status: Wrong Answer
n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)

print(l)

cnt = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if l[i] < l[j] + l[k]:
                cnt += 1
            else:
                break
        if l[i] >= l[j] + l[j+1]:
            break

print(cnt)
# Judge status: Accepted
n, a, b = map(int, input().split())
if a > b: print(0)
elif a == b:
    print(n*(b-a)+1)
else:
    if n == 1 : print(0)
    else: print((n-1)*b+a - ((n-1)*a+b)+1)
# Judge status: Accepted
A,B,C = map(int,input().split())
if (A==B and A!=C) or (A==C and A!=B) or (B==C and A!=B):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
res = 0
for i in range(0, len(A), 2):
    res += A[i] % 2
print(res)
# Judge status: Accepted
n=int(input())
for i in range(n+1):
    if int(i*1.08) == n:
        print(i)
        exit()
print(':(')
# Judge status: Accepted
NM = input().split()
N, M = NM[0], NM[1]
if N == M:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
import numpy as np


def main(a):
    return a + a*a+a*a*a


a = int(input())
print(main(a))
# Judge status: Accepted
# A - One Card Poker
# https://atcoder.jp/contests/abc054/tasks/abc054_a

A, B = map(int, input().split())

result = 'Alice'

if A == B:
    result = 'Draw'
elif A < B:
    if A == 1:
        result = 'Alice'
    else:
        result = 'Bob'
else:
    if B == 1:
        result = 'Bob'

print(result)
# Judge status: Accepted
s=input()
if s[2]==s[3] and s[4]==s[5]:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
a,b,x=map(int,input().split())
if a<=x and a+b>=x:
  print("No")
else:
  print("Yes")
# Judge status: Wrong Answer
n, r = map(int, input().split())
if n >= 10:
    rating = r
else:
    rating = r - 100 * (10 - n)
print(rating)
# Judge status: Accepted
# https://atcoder.jp/contests/agc021/tasks/agc021_a

s=list(input())
sm=sum(map(int,s))
n=len(s)
res=int(s[0])-1+9*(n-1)
print(max(res,sm))
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
count=0
count2=0
for i in range(n):
    if a[i]%4==0:
        count+=1
    elif a[i]%2==0:
        count2+=1

if (n-count2//2)//2<=count:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
o = input()
e = input()
ans = ''
for i, j in zip(o, e):
    ans += i + j
print(ans)
# Judge status: Wrong Answer

n, a, b = (int(x) for x in input().split())

nokori = n
ans = 0

# 最後の1回前までの処理
while a + b <= nokori :
    ans = ans + a
    nokori = nokori - (a + b)

# 最後の1回の処理
ans = ans + nokori

print(ans)
# Judge status: Accepted
A, B = map(int, input().split())
for i in range(1, 1100):
    if int(i*0.08)==A and int(i*0.1)==B:
        print(i)
        break
else:
    print(-1)
# Judge status: Accepted
def solve():
    N, *a_l = map(int, open(0).read().split())
    a_l = [0] + a_l

    for i in range(N//2, 0, -1):
        a_l[i] = sum(a_l[i::i]) % 2

    b_l = [i for i, x in enumerate(a_l) if x]

    print(len(b_l))
    if len(b_l) != 0:
        print(' '.join(map(str, b_l)))


if __name__ == '__main__':
    solve()
# Judge status: Accepted
x, a, b = map(int, input().split())
distance_a = abs(a - x)
distance_b = abs(b - x)

if distance_a < distance_b:
  print('A')
else:
  print('B')
# Judge status: Wrong Answer
W,H,x,y=map(int,input().split())
if x==int(W/2) and y==int(H/2):
    print(W*H/2,'1')
else:
    print(W*H/2,'0')
# Judge status: Accepted
# C - Subarray Sum
n,k,s=map(int,input().split())
a=[]
a+=[s]*k
if s!=10**9:
    a+=[s+1]*(n-k)
else:
    a+=[1]*(n-k)
print(*a)
# Judge status: Wrong Answer
N,K = map(int,input().split())
S = input()

ans = 0
dif = 0
for i in range(1,N):
    if S[i] != S[i-1]: dif += 1
    else: ans += 1

if K <= dif//2:
    ans += 2*K
else:
    ans += 2*(dif//2) + 1

print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


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


def readstrs():
    return input().split()


def main():
    N = readint()
    if N % 2:
        print(0)
    else:
        ans = 0
        i = 1
        while N >= 5 ** i:
            ans += (N // 5 ** i) // 2
            i += 1
        print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
A, B = map(int, input().split())
if A >= 13:
 print (B)
  
elif 6<=A<=12:
 print (B/2)
  
else:
 print (0)
# Judge status: Accepted
if __name__ == '__main__':
    from sys import stdin
    # from collections import defaultdict
    # from collections import deque
    # from collections import Counter
    # import numpy as np
    import math
    # import random
    input = stdin.readline

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

    total_minutes = 60*h + m
    h_degree = total_minutes*0.5
    m_degree = 6*m
    difference = h_degree - m_degree
    if difference > 180:
        difference = 360 - difference
    print((a**2+b**2-2*a*b*math.cos(math.radians(difference)))**0.5)
# Judge status: Accepted
n=int(input())
h=list(map(int, input().split()))
c=0
if n!=1:
    for i in reversed(range(n-1)):
        if h[i]==h[i+1]+1:
            h[i]-=1
        elif h[i]-h[i+1]>=2:
            c=1
    if c==0:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
n=[a,b,c]
m=len([i for i in n if i==5])
p=len([i for i in n if i==7])
if m==2 and p==1:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
w, h, x, y = map(int, input().split())

if x == w/2 and y == h/2:
    print(w*h/2, int(1))
else:
    print(w*h/2, int(0))
# Judge status: Wrong Answer
n = int(input())
al = list(map(int, input().split()))
a_2 = 0
a_4 = 0
a_not4 = 0

for a in al:
    if a % 4 == 0:
        a_4 += 1
    elif a == 2:
        a_2 += 1
    else:
        a_not4 += 1

if a_2 % 2 == 0:
    if a_not4 <= a_4 + 1:
        print('Yes')
    else:
        print('No')
else:
    if a_not4 <= a_4:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
import itertools

N = int(input())
P = [int(x) for x in input().split()]
Q = [int(x) for x in input().split()]

L = [i for i in range(1, N + 1)]
P = tuple(P)
Q = tuple(Q)

i = 1
for e in itertools.permutations(L):
#     print(e)
    if e == P:
        a = i
    if e == Q:
        b = i
    i += 1
print(abs(a - b))
# Judge status: Wrong Answer
X = int(input())
b = 0.0
c = True

while c:
    if (abs(X + b**5)**0.2).is_integer():
        c = False
        if X + b**5 > 0:
            a = int(abs(X + b**5)**0.2)
        else:
            a =  int( - 1 * (abs(X + b**5)**0.2))
    elif b == 0:
        b = 1.0
    elif b > 0:
        b = -1.0*b
    else:
        b = -1*b + 1
        
print(a, int(b))
# Judge status: Accepted

def resolve():
    S = "0" + input()
    N = len(S)

    dp = [[1<<60]*2 for _ in range(N+1)]
    dp[0][0] = 0
    for i in range(N):
        now = int(S[i])
        dp[i+1][0] = min(dp[i][0]+now, dp[i][1]+(10- now))
        dp[i + 1][1] = min(dp[i][0] + now + 1, dp[i][1] + (10 - now - 1))
    print(dp[N][0])


if __name__ == "__main__":
    resolve()
# Judge status: Wrong Answer
w = list(input())
moji = set()
ans = 'Yes'
for i in range(len(w)):
    moji.add(w[i])
for i in moji:
    if (w.count(moji) % 2)!= 0:
        ans = 'No'
print(ans)
# Judge status: Accepted
d, n = map(int, input().split())

if d == 0:
    if n == 100:
        print(101)
    else:
        print(n)
elif d == 1:
    if n == 100:
        print(10100)
    else:
        print(n*100)
else:
    if n == 100:
        print(1010000)
    else:
        print(n*10000)
# Judge status: Wrong Answer
A,B,C,X,Y = map(int,input().split())
X_piza = X
Y_piza = Y
minimum = 10**10
for i in range(0,10**5+2,2):
  if minimum>C*2*i+max(0,X-i)*A+max(0,Y-i)*B:
    minimum = C*2*i+max(0,X-i)*A+max(0,Y-i)*B
print(minimum)
# Judge status: Wrong Answer
N, K = map(int,input().split())
H = list(map(int,input().split()))

H.reverse()

cnt = 0

for i in range(K,len(H)):
    cnt += H[i]

print(cnt)
# Judge status: Wrong Answer
from math import factorial as f

n, m = (int(i) for i in input().split())
if n == m:
    print((f(n) * f(m) * 2) % (10 ^ 9 + 7))
elif abs(n - m) == 1:
    print((f(n) * f(m)) % (10 ^ 9 + 7)) 
else:
    print(0)
# Judge status: Accepted
import heapq
n,m=map(int,input().split())
ab=[[] for _ in range(m+1)]
for i in range(n):
  a,b=map(int,input().split())
  if a<=m:
    ab[a].append(-b)

cand=[]
heapq.heapify(cand)
ans=0
for i in range(1,m+1):
  for j in range(len(ab[i])):
    heapq.heappush(cand,ab[i][j])
  if len(cand)>0:
    ans-=heapq.heappop(cand)

print(ans)
# Judge status: Wrong Answer
import sys

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

if N == M == 1:
    print(1)
elif N == 1 or M == 1:
    print(max(max(N, M)-2, 0))
    sys.exit()

N = max(0, N-2)
M = max(0, M-2)

print(N*M)
# Judge status: Accepted
import math
n, x, t = map(int, input().split())
print(math.ceil(n / x) * t)
# Judge status: Accepted
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
A = int(input())
S = input()

if A >= 3200:
    print(S)
else:
    print('red')
# Judge status: Accepted
n,m = map(int, input().split())
a = list(map(int,input().split()))

count = 0
for i in range(n):
    if a[i] >= sum(a) / (4*m):
        count += 1
if count >= m:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
A, B = map(float, input().split())
print(int(A*B))
# Judge status: Accepted
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    X=list(map(int,input().split()))
    ans=INF
    for i in range(1,101):
        tmp=0
        for n in X:
            tmp+=(n-i)**2
        ans=min(ans,tmp)
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
H, N = map(int, input().split())
AB=[]
for _ in range(N):
    AB.append(list(map(int, input().split())))

Max_A = max(a for a, b in AB)
# print(Max_A)

dp = [10 ** 18] * (H + Max_A)
dp[0] = 0
for i in range(1, H + Max_A):
    dp[i] = min(dp[i - a] + b for a, b in AB)
print(min(dp[H:]))
# Judge status: Wrong Answer
A, B = map(str, input().split())
l = list(range(int(A), int(B)))
c = 0
for i in l:
  t = str(i)
  if t[0] == t[4] and t[1] == t[3]:
    c += 1
print(c)
# Judge status: Wrong Answer
x, y = map(int,input().split())
arr = list(map(int, input().split()[:y]))
s = 0
for i in arr:
    s += i
re = x - s
if re > 0:
    print(re)
else:
    print(-1)
# Judge status: Accepted
n = int(input())
if(n%2 == 0):print(int(n/2))
else:print(int(n/2)+1)