peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
S = str(input())
l = len(S)
mod = [0] * 2019
dp = 0
pw = 1
for i in range(l):
    mod[dp % 2019] += 1
    dp = dp + pw * int(S[-1-i])
    pw = (pw * 10) % 2019
mod[dp % 2019] += 1
cnt = 0
for i in range(2019):
    cnt += (mod[i]*(mod[i]-1))//2
print(cnt)
# Judge status: Accepted
def main():
    s=list(input())
    k=int(input())
    i=0
    while k>=0 and i<len(s)-1:
        if s[i]!='a' and k>=123-ord(s[i]):
            k-=123-ord(s[i])
            s[i]="a"
        i+=1
    if i==len(s)-1:
        s[-1]=chr(97+(k-(123-ord(s[i])))%26)
    print("".join(s))
if __name__=="__main__":
    main()
# Judge status: Accepted
a,b = list(map(int,input().split()))
if a<=8 and b<=8:
    print("Yay!")
else:
    print(":(")
# Judge status: Accepted
N=int(input())
P=list(map(int,input().split()))
S=["x" if P[i]==i+1 else "o" for i in range(N)]
count=0
for j in range(N-1):
    if S[j]=="x":
        S[j]="o"
        if S[j+1]=="x":
            S[j+1]="o"
        count+=1
if S[N-1]=="x":
    count+=1
print(count)
# Judge status: Accepted
a, b, c = map(int, input().split())


A = []

for i in range(c):
    A.append(a+i) if a <= a+i <= b else a
j = 0
for _ in range(c):
    A.append(b - j) if a <= b - j <= b else a
    j += 1
A = list(sorted(set(A)))

for i in A:
    print(i)
# Judge status: Accepted
N = int(input())
P = list(map(int,input().split()))
num = 1
min_P = P[0]
for i in range(1,N):
    if P[i] < min_P:
        min_P = P[i]
        num += 1
print(num)
# Judge status: Accepted
s = input()
t = input()
print("YES" if s == t[::-1] else "NO")
# Judge status: Accepted
a, b, c = list(map(str, input().split()))
print(a[0] + b[0] + c[0])
# Judge status: Accepted
n = int(input())
m = []
for i in range(n):
    m.append(input())
    
if len(set(m)) != len(m):
    print("No")
    exit()

for j in range(n-1):
    if m[j][-1] != m[j+1][0]:
        print("No")
        exit()
print("Yes")
# Judge status: Accepted
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for i in range(a+1):
	for j in range(b+1):
		for k in range(c+1):
			money = 500 * i + 100 * j + 50 * k
			if money == x:
				cnt += 1
print(cnt)
# Judge status: Wrong Answer
n,m=map(int,input().split())
import math

if abs(n-m) > 1:
    print(0)
else:
    a=math.factorial(n)
    b=math.factorial(m)
    print((a*b)%(10**9+7))
# Judge status: Accepted
ans = input()
que = input()
l = len(que)
que_s = que[:l-1]
if ans == que_s:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]

ab_sorted = sorted(ab, key=lambda x:(x[0], -x[1]))
print(ab_sorted)

num = 0
amount_of_money = 0
for i in range(n):
  buy = min(ab_sorted[i][1], m-num)
  num += buy
  amount_of_money += ab_sorted[i][0] * buy
    
  if num >= m:
    print(amount_of_money)
# Judge status: Wrong Answer
import collections


N = int(input())
S = [input() for _ in range(N)]
S.sort()
c = collections.Counter(S)
values, counts = zip(*c.most_common())
if len(values) == 1:
    print(values[0])
else:
    for i in range(N):
        if counts[i] == counts[0]:
            print(values[i])
        else:
            exit()
# Judge status: Wrong Answer
n, r = map(int, input().split())
print(r if n >= 10 else r - (100 * (10 - n)))
# Judge status: Wrong Answer
S='ABC'
if S is 'ABC':
  print('ARC')
else:
  print('ABC')
# Judge status: Accepted
from heapq import heappop,heappush
n,m = map(int,input().split())
lst = [[int(i) for i in input().split()] for _ in range(n)]
PQ = []
idx = 0
ans = 0
lst.sort(key = lambda x:x[0])
for i in range(1,m+1):
    while idx < n and lst[idx][0] <= i:
        heappush(PQ,-(lst[idx][1]))
        idx += 1
    if PQ: ans -= heappop(PQ)
print(ans)
# Judge status: Accepted
from math import ceil
x = int(input())
ans = ceil(((1+8*x)**.5 -1)/2)
print(ans)
# Judge status: Accepted
N, A, B = map(int, input().split())
S = input()
a, b = 0, 0
for s in S:
    if s == "a":
        if a+b < A+B:
            a += 1
            print("Yes")
        else:
            print("No")
    elif s == "b":
        if a+b < A+B and b < B:
            b += 1
            print("Yes")
        else:
            print("No")
    else:
        print("No")
# Judge status: Wrong Answer
#A - Next Alphabet
A = str(input())

print(chr(ord('a') + 1))
# Judge status: Wrong Answer

n, k = map(int, input().split())

p = list(map(int, input().split()))

total = sum(p[:k])
ans = total
print(ans)
for i in range(n-k):
    total -= p[i]
    total += p[i+k]
    ans = max(total,ans)
    print(ans)

print((ans+k)/2)
# Judge status: Wrong Answer
import sys
s = list(input())
if s[0] == 'A' and s[2] == 'C':
    del s[2]
    del s[0]
    s = ''.join(s)
    if s.islower():
        print("AC")
        sys.exit()
print("WA")
# Judge status: Accepted
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
l=list(map(int,input().split()))
ok=max(l)
ng=0
def solve(m):
    s=0
    for i in l:
        s+=-((-i)//m)-1
    return s

while ok-ng>1:
    m=(ok+ng)//2
    if k<solve(m):
        ng=m
    else:
        ok=m
print(ok)
# Judge status: Accepted

[A,V] = list(map(int,input().split()))
[B,W] = list(map(int,input().split()))
T = int(input())

if A<B:
    if A+V*T >= B+W*T:
        out='YES'
    else:
        out='NO'

else:
    if B-W*T >= A-V*T:
        out='YES'
    else:
        out='NO'
print(out)
# Judge status: Accepted
H = int(input())
W = int(input())
N = int(input())

#行をa回、列をb回選んで操作した場合
#塗られるマスの数は(H *a + W *b - a * b)

A = list(range(H+1))
B = list(range(W+1))
AB = [[a, b] for a in A for b in B]

ANS = []
for ab in AB:
  a = ab[0]
  b = ab[1]
  SUM = H * a + W * b - a * b
  if N <= SUM:
    sum_N = a + b
    ANS.append(sum_N)

ANS.sort()
ans = ANS[0]
print(ans)
# Judge status: Wrong Answer
import math
N,P = map(int,input().split())
A = list(map(int,input().split()))

odd = []
even = []
ans = 0
for i in A:
  if (i % 2 == 1):
    odd.append(i)
  else:
    even.append(i)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
  
if (P == 0):
  l_odd = len(odd)
  num = 0
  while l_odd >= num:
    ans += combinations_count(l_odd, num)
    num += 2
  if (len(even)!=0):
    ans *= 2**len(even)
else:
  if (len(odd)!=0):
    ans *= 2**len(odd)*2**len(even)
print(ans)
# Judge status: Accepted
#!/usr/bin/env python3
n, h, *A = map(int, open(0).read().split())
a = max(A[::2])
b = sorted(A[1::2])[::-1]
for i in range(n):
    if h <= 0:
        print(i)
        exit()
    if b[i] < a:
        print(i - (-h // a))
        exit()
    h -= b[i]
print(n - (-h // a))
# Judge status: Accepted
import sys

input = sys.stdin.readline


def main():
    S = input().rstrip()

    if "RRR" in S:
        ans = 3
    elif "RR" in S:
        ans = 2
    elif "R" in S:
        ans = 1
    else:
        ans = 0

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
X, K, D = map(int, input().split())

d, r = divmod(X, D)
if K > d:
    if (K - d) % 2 == 0:
        print(min(r, abs(X - D*K)))
    else:
        print(min(abs(r - D), abs(X - D*K)))
else:
     print(abs(X - D*K))
# Judge status: Accepted
a, b, c = map(int, input().split())
t = 0

if a == b == c:
  if a % 2 == 1:
    print(t)
  else:
    print(-1)

else:
  while (a % 2 + b % 2 + c % 2) == 0:
    a, b, c = (b + c) / 2, (a + c) / 2, (a + b) / 2
    t += 1

  print(t)
# Judge status: Accepted


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

def floor(x):
    return int(a*x/b) - a*int(x/b)

x = min(b-1,n)
print(floor(x))
# Judge status: Accepted
n=int(input())
l=[[0 for i in range(10)]for s in range(10)]
for  i in range(n+1):
  if i%10:
    l[int(str(i)[0])-1][int(str(i)[-1])-1]+=1
ans=0
for i in range(9):
  for j in range(9):
    ans+=l[i][j]*l[j][i]
print(ans)
# Judge status: Accepted
s=input()
while len(s)>0:
  s=s[:-2]
  a=len(s)
  if s[:(a//2)]*2==s:
    print(a)
    exit()
# Judge status: Wrong Answer
n = str(input())
ans = 0
count = 0
for i in range(len(n)):
    if int(n[i]) <= 5:
        ans += int(n[i])
    else:
        ans += 10 - int(n[i]) + 1
        if i != 0 and i != 1:
            count += 1
print(ans-count)
# Judge status: Accepted
S = input()
T = input()

for i in range(len(S)):
  S = S[-1] + S[:-1]
  if S == T:
    print("Yes")
    exit()
print("No")
# Judge status: Accepted
n = input()
a, b = 0, 100
for i in n:
  j = int(i)
  a, b = min(a+j,b+j), min(a+11-j,b+9-j)
  if j == 0:
    b = a+100
print(min(a,b))
# Judge status: Wrong Answer
MOD = 1000000007

def fpow(x, n):
    e = 1
    while n > 1:
        if n & 1: e = (e*x) % MOD
        x = (x*x) % MOD
        n >>=1
    return (x*e)%MOD

N = int(input())
print((fpow(10, N) - 2*fpow(9, N) + fpow(8, N))%MOD)
# Judge status: Wrong Answer
def buffet(n, ali, bli, cli):

    ans = 0
    count = 0

    for i in range(n):
        ans += bli[ali[i]-1]

        if ali[i] == count+1:
            ans += cli[count-1]
        count = ali[i]
    return ans

def main():
    n = int(input())
    ali = list(map(int, input().split()))
    bli = list(map(int, input().split()))
    cli = list(map(int, input().split()))
    print(buffet(n, ali, bli, cli))

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
if int(input()) == 30:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
a = input()
b = []
for i in range(int(a[0])):
    b.append(input())
b.sort()
for j in b:
    print(j, end = "")
# Judge status: Accepted
hw,mw,hs,ms,k=map(int,input().split())
waking=(hs*60+ms)-(hw*60+mw)-k
print(max(0,waking))
# Judge status: Accepted
from math import ceil

# print('input >>')
N, X, T = map(int,(input().split()))

# print('-----output-----')
print(ceil(N / X) * T)
# Judge status: Wrong Answer
n = int((input()))
a = list(map(int, input().split()))

f = False
for i in a:
    if i % 2 == 0:
        if i % 3 == 0 or i % 5 == 0:
            f = True
        else:
            f = False
            break
if f:
    print("APPROVED")
else:
    print("DENIED")
# Judge status: Accepted
n = int(input())
for i in range(1, 10):
    if n % i == 0:
        if n // i < 10:
            print('Yes')
            exit()
print('No')
# Judge status: Accepted
n = int(input())
a_input = list(map(int,input().split()))

#左から単調非増加、単調非減少を試して行って長いほうを採用すればよいO(N)
#値の増減の反転するポイントを探索する
ans=1
tmp=0
for i in range(1,n):
    if (a_input[i]-a_input[i-1])*tmp<0:
        ans+=1
        tmp=0
    elif a_input[i]-a_input[i-1]!=0:
        tmp=a_input[i]-a_input[i-1]

print(ans)
# Judge status: Accepted
n = int(input())

print( ( (n + 1) // 2) / n )
# Judge status: Wrong Answer
from fractions import *
n,*a=map(int,open(0).read().split())
l=[0]+[a[0]]*(n-1)
r=[a[-1]]*(n-1)+[0]
ans=0
for i in range(2,n):
  l[i]=gcd(l[i-1],a[i])
for i in range(n-3,-1,-1):
  r[i]=gcd(r[i+1],a[i+1])
for i in range(n):
  ans=max([0,l[i],r[i],gcd(l[i],r[i])][(l[i]>0)+2*(r[i]>0)],ans)
print(ans)
# Judge status: Accepted
import itertools

n,m,q=map(int,input().split())
Q=[]
for i in range(q):
    Q.append(list(map(int,input().split())))
ans=0
l=[i+1 for i in range(m)]
for i in itertools.combinations_with_replacement(l,n):
    temp=0
    for j in range(q):
        if i[Q[j][1]-1]-i[Q[j][0]-1]==Q[j][2]:
            temp+=Q[j][3]
    ans=max(ans,temp)
print(ans)
# Judge status: Accepted
N = int(input())
P = list(map(int, input().split()))

mn = N + 1
ans = 0
for p in P:
    if p < mn:
        ans += 1
    mn = min(mn, p)
print(ans)
# Judge status: Accepted
def main():
    N, M = list(map(int, input().split(' ')))
    n = 1
    ans = 1
    while n**2 <= M:
        if M % n == 0:
            if n * N <= M:
                ans = max([ans, n])
            m = M // n
            if m * N <= M:
                ans = max([ans, m])
        n += 1
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
S = input()
T = input()
L = len(S)
St = []
Tr = []
ans = 'no'
for i in range(L-1):
    St.append(S[i:i+1])
    Tr.append(S[i:i+1])
for i in range(L):
    if St == Tr:
        ans = 'yes'
    else:
        St.insert(0,St[L-1])
        St.remove(St[L-1])

print(ans)
# Judge status: Accepted
n = int(input())
print(int(n/2)+n%2)
# Judge status: Accepted
N=int(input())

print(1 - ((N // 2) / N))
# Judge status: Accepted
import bisect

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

ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        tmp=a[i]+a[j]
        index=bisect.bisect_left(a,tmp)
        ans+=index-j-1

print(ans)
# Judge status: Wrong Answer
from collections import defaultdict
S = input()
T = input()
d = defaultdict(str)
ans = 'Yes'
for s, t in zip(S, T):
    if s != t:
        if d[s] == t and d[t] == s:
            continue
        if d[s] == '' and d[t] == '':
            d[s] = t
            d[t] = s
        else:
            ans = 'No'
            break

print(ans)
# Judge status: Accepted
n,m = map(int,input().split())
if n>12:
    print(m)
elif n>5:
    print(m//2)
else:
    print(0)
# Judge status: Accepted
from fractions import gcd
n = int(input())
ns = list(map(int, input().split()))
l = [0]
r = [0]
for i in range(n-1):
    l += [gcd(l[i], ns[i])]
    r += [gcd(r[i], ns[-i-1])]
print(max(gcd(l[i], r[-i-1]) for i in range(n)))
# Judge status: Accepted
a, b, k = map(int, input().split())
print_max = 0
for i in range(a, a + k):
    if a <= i <= b:
        print(i)
        print_max = i
for i in range(b - k + 1, b + 1):
    if print_max < i <= b:
        print(i)
# Judge status: Accepted
import numpy as np

N = int(input())
T, A = map(int, input().split())
H = np.array(list(map(int, input().split())))

H = np.abs(T - H * 0.006 - A)

print(H.argmin()+1)
# Judge status: Wrong Answer
n,m = map(int, input().split())
A = [int(input()) for i in range(m)]
if m == 0:
  Fib = [1,2]
  for i in range(2,n):
    Fib.append(Fib[i-2]+Fib[i-1])
  print(Fib)
  print(Fib[n-1])
  exit()

B = [A[i+1]- A[i] for i in range(m-1)]
B.insert(0,A[0]+1)
B.append(n+1-A[m-1])

M = max(A)

Fib = [0,1]
for i in range(2,M+10):
  Fib.append(Fib[i-2]+Fib[i-1])

ans = 1
for i in range(len(B)):
  ans = (ans * Fib[B[i]-1])%1000000007
  
print(ans)
# Judge status: Wrong Answer
n,m = map(int, input().split())
A = list(map(int,input().split()))

min_limit = 1 / (4*m)
select_ok = 0

for i in A:
  if i >= min_limit:
    select_ok += 1

if select_ok >= m:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
n=int(input())

dp=[float('inf')]*(n+1)
dp[0]=0

for i in range(1,n+1):
  
  power=1
  while(power<=i):
    dp[i]=min(dp[i],dp[i-power]+1)
    power*=6
  
  power=1
  while(power<=i):
    dp[i]=min(dp[i],dp[i-power]+1)
    power*=9

print(dp[n])
# Judge status: Accepted
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict
from fractions import gcd

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	K = int(input())
	ans = 0
	D = defaultdict(int)
	for i in range(1, K + 1):
		for j in range(1, K + 1):
			s = gcd(i, j)
			D[s] += 1

	for i in range(1, K + 1):
		for j in range(1, K + 1):
			ans += gcd(i, j) * D[j]

	print(ans)

if __name__ == '__main__':
	main()
# Judge status: Accepted
#import numpy as np
n = int(input())
a = list(map(int,input().split()))
base = [0]*n
ans = 0

for i in range(n):
  if a[i] > n:
    ans += 1
  else:
    base[a[i]-1] += 1
    
for i in range(n):
  if base[i] == 0:
    continue
  elif base[i] == i+1:
    continue
  elif (base[i] < i+1) and (0 < base[i]):
    ans += base[i]
  elif i+1 < base[i]:
    ans += (base[i] - (i+1))
    
print(ans)
# Judge status: Wrong Answer
n = int(input())
a_list = list(map(int, input().split()))
a_list.sort(reverse=True)

a_set = list(set(a_list))
a_set.sort(reverse=True)
candidate = []
for i in a_set:
    if a_list.count(i) >= 2:
        candidate.append(i)
    if len(candidate) == 2:
        print(candidate[0] * candidate[1])
        exit()
print(0)
# Judge status: Wrong Answer
import itertools
n, m, x = map(int, input().split())
a_list = []
for i in range(n):
	targets = list(map(int, input().split()))
	a_list.append(targets)
r_list = []
for i, _ in enumerate(a_list, 1):     
	for j in itertools.combinations(a_list, r=i):
		targets = [0] * (m+1)
		for t in j:
			k = 0
			for target in t:
				targets[k] += target
				k += 1
		if min(targets) >= x:
			r_list.append(targets)
if len(r_list) == 0:
	print(-1)
else:
	result = sorted(r_list, key=lambda x: x[0])
	print(result[0][0])
# Judge status: Wrong Answer
n, m = map(int, input().split())
mod = lambda x:x%n+1
for i in range((m+1)//2):
    print(mod(-i), mod(i+1))
for i in range(m//2):
    print(mod(-i+(m+1)//2+1), mod(i+2+(m+1)//2+1))
# Judge status: Wrong Answer
D=int(input())
c=list(map(int,input().split()))
s=[]
t=[]
v=0
lastday=[0 for i in range(26)]

for i in range(D):
  tmp=list(map(int,input().split()))
  s.append(tmp)
  
for i in range(D):
  print((D-i)%26)
# Judge status: Wrong Answer
N, K = map(int, input().split())
MOD = 10**9 + 7
nac = [0] * (N + 2)
ninv = [0] * (N + 2)
inv = [0] * (N + 2)
nac[0],nac[1] = 1,1
inv[1] = 1
ninv[0],ninv[1] = 1,1
N = N + 1
for i in range(2, N + 1):
    nac[i] = (nac[i-1] * i % MOD)
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD
    ninv[i] = int(ninv[i - 1] * inv[i] % MOD)

ret = 0
for i in range(K,N+1):
    ret += int(nac[N] * (ninv[i] * ninv[N - i] % MOD) % MOD)
print(int(ret))
# Judge status: Wrong Answer
import sys
import math
import bisect
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n, l = na()
if l > 0:
    print((l+1 + l+n-1) * (n-1) // 2)
elif l + n < 0:
    print((l + l+n-2) * (n-1) // 2)
else:
    print((l + l+n-1) * n // 2)
# Judge status: Accepted
A,B,C,D=map(int,input().split())
import fractions
lcm=C*D//fractions.gcd(C,D)

c=B // C - (A-1)//C
d=B//D - (A-1)//D
cd=B//lcm - (A-1)//lcm

print(B-A+1 - (c+d-cd))
# Judge status: Wrong Answer
x = input()

if x in "753":
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer

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

def main(N, M):

    if N //2 <= M:
        print(int(N + (M - (N*2))//4))
    else:
        print(int(N//2))

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

sign = 0

for i in range(0,num):
  if num_list[i]%2 == 0:
    if not (num_list[i]%3 == 0 or num_list[i]%5 == 0):
      sign = 1

if sign == 0:
  ans = "APPROVED"
elif sign == 1:
  ans = "DENIED"
  
print(ans)
# Judge status: Wrong Answer
S = input()
s = "keyence"
flag = False
ans = "NO"
for i in range(len(S)):
  if s[:i] in S:
    s1 = s[:i]
    s2 = s[i:]
    flag = True
    
if flag:
  for i in range(len(S)-len(s1)):
    if s1 == S[i:i+len(s1)]:
      if s2 in S[i+len(s1):]:
        ans = "YES"
        break

print(ans)
# Judge status: Accepted
s=input()

n=len(s)

ans=100000
for i in range(n-2):
  t=str(s[i])+str(s[i+1])+str(s[i+2])
  x=abs(753-int(t))
  
  ans=min(ans,x)
  
print(ans)
# Judge status: Accepted
n = int(input())
a = [int(input()) for i in range(n)]
not10 = [i for i in a if i % 10 != 0]
a10 = [i for i in a if i % 10 == 0]
maxn10 = sum(not10)
if maxn10 % 10 == 0 and maxn10:
    maxn10 -= min(not10)
ans = maxn10 + sum(a10)
print(0) if ans % 10 == 0 else print(ans)
# Judge status: Accepted
def c():
    n = int(input())
    arr = []
    for _ in range(n):
        line = list(map(int, input().split() ))
        arr.append(line)
    
    dp = [[0 for _ in range(3)] for _ in range(n)]

    for i in range(n):
        for j in range(3):
            if i == 0:
                dp [i][j] = arr[i][j]
            else:
                dp[i][j] = arr[i][j] + max([x for ii, x in enumerate(dp[i-1]) if ii != j])

    return max(dp[-1])


print(c())
# Judge status: Wrong Answer
a,b,c,d=map(int,input().split( ))
print(b*d)
# Judge status: Wrong Answer
S = input()
minimum=653
for i in range(len(S)-2):
    number=abs(int(S[i:i+3])-753)
    print(S[i:i+3])
    minimum = min(minimum, number)
print(minimum)
# Judge status: Wrong Answer
N, K = map(int, input().split())
X = list(map(int, input().split()))

max = 10000000000000000000000000
for i in range(N - K + 1):
    # i = 0
    t = abs(X[i])
    t += X[i + K - 1] - X[i]
    if t < max:
        max = t

print(max)
# Judge status: Accepted
#copy

a = int(input())
print(a // 2 * (a - a // 2))
# Judge status: Accepted
import sys
input = sys.stdin.readline

N, M = [int(x) for x in input().split()]
ans = ["0"] * N
sc = []
for _ in range(M):
    tmp = [int(x) for x in input().split()]
    sc.append(tmp)
for i in range(1000):
    flag = 1
    i = str(i)
    if len(i) != N:
        continue
    for j in sc:
        if i[j[0] - 1] != str(j[1]):
            flag = 0
            break
    if flag:
        print(i)
        sys.exit()
print(-1)
# Judge status: Accepted
n = int(input())
x = []
y = []
z = []
for i in range(n):
  a,b = map(int, input().split())
  x.append(a+b)
  y.append(a-b)
  z.append(b-a)
print(max(max(x) - min(x),max(y) - min(y),max(z) - min(z)))
# Judge status: Wrong Answer
def resolve():
    S = input()
    if S == "kesence":
        print("YES")
    else:
        for i in range(len(S)):
            for j in range(i+1, len(S)):
                if S[:i+1]+S[j:] == S:
                    print("YES")
                    exit()
        print("NO")
resolve()
# Judge status: Accepted
n,m=map(int,input().split())
a=[list(map(int,input().split())) for a in range(n)]
c=[list(map(int,input().split())) for b in range(m)]
dist=0
minnum=0
for indi,i in enumerate(a):
    min=10**10
    minnum=0
    for indj,j in enumerate(c):
        dist=0 
        dist+=abs(i[0]-j[0])
        dist+=abs(i[1]-j[1])
        #print("dist={}".format(dist))
        if min>dist:
            min=dist
            minnum=indj
    print(minnum+1)
# Judge status: Accepted
N=int(input())
ans=10**13
from math import sqrt
for i in range(1, int(sqrt(N))+1):
    if N%i==0:
        temp=(i-1)+(N//i-1)
        if temp<ans:
            ans=temp
print(ans)
# Judge status: Accepted
input_str = input().split()
k = int(input_str[0])
s = int(input_str[1])

count = 0
for x in range(k+1):
  for y in range(k+1):
    if x+y <= s:
      z = s-(x+y)
      if z <= k:
        count += 1
print(count)
# Judge status: Accepted
a, b, t = list(map(int, input().split()))

print((t//a)*b)
# Judge status: Accepted
import sys  
import numpy as np

input = sys.stdin.readline
N = int(input())
S = list(input())

S = S[:-1]

temp = []
for i in range(1,N):
    a = S[:i]
    b = S[i:]
    a = list(set(a))
    b = list(set(b))

    j = list(set(a+b))
    
    temp.append(len(a) + len(b) - len(j))
    

print(max(temp))
# Judge status: Accepted
N, M = map(int, input().split())
possibility = [False] * N  # True: 赤いボールが入っている可能性がある
possibility[0] = True
balls = [1] * N  # 箱に入っているボールの数
for i in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    if possibility[x]:
        possibility[y] = True
    balls[x] -= 1
    balls[y] += 1
    if balls[x] == 0:
        possibility[x] = False

ans = possibility.count(True)
print(ans)
# Judge status: Accepted
import numpy as np


n = int(input())
ajs_str = input().split()
ajs = [int(aj) for aj in ajs_str]

ajs_sorted = np.sort(ajs)[::-1]

score = ajs_sorted[0]
count = 1
current_idx = 1


max_idx = int( (n-2) / 2 )

for idx in range(1, 1+max_idx):
  score += 2 * ajs_sorted[idx]

if (n-2) % 2 != 0:
  score += ajs_sorted[1+max_idx]

print(score)
# Judge status: Accepted
#n , m , l = map(int , input().split())

# list_n = list(map(int , inpuut().split()))<Paste>

#n = input()
# list = [input() for i in range(N)

#list = [[i for i in range(N)] for _ in range(M)]


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

list_A.sort(reverse=True)
print(sum(list_A[0::2]) - sum(list_A[1::2]))
# Judge status: Accepted
l = list(map(int, input().split()))
A = l[0]
B = l[1]
C = l[2]

if(A == B):
    if(A != C):
        print("Yes")
    else:
        print("No")
else:
    if(A != C):
        if(B == C):
            print("Yes")
        else: print("No")
    else:
        print("Yes")
# Judge status: Accepted
n, k = map(int, input().split())
p = list(map(int, input().split()))

l = sorted(p)
sum = 0
for i in range(k):
    sum += l[i]
print(sum)