peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted


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

X.sort()
cnt = 0
arr = [0]*(M-1)
if N >= M:
    ans = 0
else:
    for i in range(1,M):
        arr[i-1] = (abs(X[i-1]-X[i]))
    #print(arr)
    arr.sort()
    ans = sum(arr[0:M-N])
print(ans)
# Judge status: Accepted
# -*- coding: utf-8 -*-

s = sorted(list(str(input())))

if s[0] == s[1] and s[2] == s[3] and s[0] != s[2]:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
INF=10**12
A.append(INF)
B.append(INF)
A=A[::-1]
B=B[::-1]
for i in range(N+M+1):
  if A[-1]<=B[-1]:
    if K<A[-1]:
      print(i)
      exit()
    K-=A[-1]
    del A[-1]
  else:
    if K<B[-1]:
      print(i)
      exit()
    K-=B[-1]
    del B[-1]
# Judge status: Accepted
N = int(input())
p = list(map(int, input().split()))
s = 0
for i in range(0, N):
    if i+1 != p[i]:
        s = s+1
if s > 2:
    print ("NO")
else:
    print ("YES")
# Judge status: Accepted
from collections import defaultdict
import bisect
N, M = map(int, input().split())
PY = []
PYd = defaultdict(list)
for i in range(M):
    x, y = map(int, input().split())
    PYd[x].append(y)
    PY.append((x,y))

for i in PYd.keys():
    PYd[i].sort()

for p,y in PY:
    str_p = str(p).zfill(6)
    index = str(bisect.bisect(PYd[p],y)).zfill(6)
    print(str_p + index)
# Judge status: Accepted
A, B = map(int, input().split())

one = max(A, B)
if one == A:
    two = max(A-1, B)
else:
    two = max(A, B-1)
print(one + two)
# Judge status: Wrong Answer
s = input()
t = input()

for i in range(len(s) - len(t) + 1)[::-1]:
    for j, (ns, nt) in enumerate(zip(s[i:i+len(t)], t)):
        if ns != nt and ns != '?':
            break
        if j == len(t):
            ans = s[:i] + t + s[i+len(t):]
            print(ans.replace('?', 'a'))
            exit()
print('UNRESTORABLE')
# Judge status: Accepted
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]

for i in range(n):
    dis = []
    for j in range(m):
        dis.append(abs(ab[i][0]-cd[j][0]) + abs(ab[i][1]-cd[j][1]))
    print(dis.index(min(dis))+1)
# Judge status: Accepted
A, B = input().split()

import math, decimal
print(int(A) * int(B.replace('.', '')) // 100)
# Judge status: Accepted
a, b, c, x, y = map(int, input().split())
pmin = 10**10
for i in range(max(x, y)+1): # 2i枚のABピザを買う
    bx = max(0, x - i)
    by = max(0, y - i)
    pay = a*bx + b*by + 2*c*i
    pmin = min(pmin, pay)


print(pmin)
# Judge status: Accepted
n = int(input())
a = [int(i) for i in input().split()]
mod = 10**9+7
ans = 0
for i in range(60):
    cnt = 0
    for j in range(n):
        if a[j]>>i & 1 == 0: cnt += 1
    ans = (ans+pow(2,i,mod)*cnt%mod*(n-cnt)%mod)%mod
print(ans)
# Judge status: Wrong Answer
# input
N = int(input())
S = input()

# check
res = N - 1
for idx, s in enumerate(S):

    if idx == 0:
        target = list(S[1:])
    elif idx == N - 1:
        target = list(S[:idx])
    else:
        target = list(S[:idx] + S[idx + 1:])

    turn_cnt = min(target.count("W"), target.count("E"))

    if res > turn_cnt:
        res = turn_cnt

print(res)
# Judge status: Wrong Answer
N=int(input())
H=list(map(int,input().split()))

for i in range(N-1):
    if H[i]>H[i+1]:
        H[i]-=1

F=True
for i in range(N-1):
    F&=(H[i]<=H[i+1])

if F:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
# C - 100 to 105
# https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_c

x = int(input())
d, m = divmod(x, 100)

D = [0] * 5

for i in range(4, -1, -1):
  D[i], m = divmod(m, i + 1)

if d >= sum(D):
  print(1)
else:
  print(0)
# Judge status: Accepted
import fractions
import functools

def lcm(n1, n2):
    return n1 * n2 // fractions.gcd(n1, n2)

N, M = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
    A[i] //= 2

lcmA = functools.reduce(lcm, A)
gcdA = functools.reduce(fractions.gcd, A)
if (lcmA // gcdA) % 2 == 0:
    print(0)
else:
    print((M // lcmA + 1) // 2)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7

ans = 0

for i in range(60):
    cnt = 0
    for a in A:
        cnt += a>>i&1
    ans += cnt*(N-cnt)*2**i
    ans %= mod
    # print(ans)
print(ans)
# Judge status: Accepted
from collections import Counter

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

c = []
for i in a:
    c.extend([i-1, i, i+1])

ans = Counter(c).most_common()

print(ans[0][1])
# Judge status: Accepted
x,a,b=map(int,input().split())
print(["A","B"][abs(x-a)>abs(x-b)])
# Judge status: Accepted
n = int(input())
for i in range(0, 25):
  for j in range(0, 14):
    if i * 4 + j * 7 == n:
      print("Yes")
      exit()
print("No")
# Judge status: Accepted
N=int(input())
cnt=0
n=1
while n<=N:
  n*=2
  cnt+=1
if n>N:
  cnt-=1
print(2**cnt)
# Judge status: Wrong Answer
n = int(input())
ls = list(map(str,input().split()))
a = [0 for j in range(n)]
for i in range(n):
    a[i] = ls[i] + str(i+1)
a.sort()
for k in range(n):
    print(a[k][int(len(a[k]))-1],end=' ')
# Judge status: Wrong Answer
S_list = list(map(int,input().split()))
 
r, g, b = S_list
sum = int(r+g+b)
if sum % 4 == 0 :
    result = "YES"
else:
    result = "NO"
print(result)
# Judge status: Accepted
"""
tuple
"""
n,Y = map(int,input().split())
ans = -1,-1,-1
for x in range(n+1):
    for y in range(n-x+1):
        z = n - x - y 
        if 0 <= z <=2000 and (10000*x+5000*y+z*1000)==Y:
            ans = x,y,z
            break
        else :
            continue
        break
print(*ans)
# Judge status: Accepted
#AGC024-A
a,b,c,k = map(int,input().split())
if k % 2 == 1:
    print(b-a)
else:
    print(a-b)
# Judge status: Wrong Answer
lo = input()
if lo == "Sunny":
    print("Cloudy")
elif lo == "Rainy":
    print("Sunny")
# Judge status: Accepted
L, R = map(int, input().split())
res = [0] * 2019
for i in range(L, R + 1):
    if res[i % 2019] > 0:
        break
    else:
        res[i % 2019] += 1

if res[0] == 1:
    print(0)
else:
    ans = 2019
    for i in range(2019):
        for j in range(i + 1, 2019):
            if res[i] == res[j] == 1:
                ans = min(ans, i * j % 2019)
    print(ans)
# Judge status: Accepted
N = int(input())

C = []
for _ in range(N):
    a, b = map(int, input().split())
    C.append((a, b))
C = list(sorted(C, key=lambda x: x[1]))

t = 0
for a, b in C:
    if t + a > b:
        print("No")
        break
    t += a
else:
    print("Yes")
# Judge status: Accepted
n = int(input())
l = [list(map(int, input().split())) for _ in range(n-1)]

ans = [0]*n
for i in range(n):
    time = 0
    for j in range(i, n-1):
        if l[j][1] - time > 0:
            time += l[j][1] - time
        if time % l[j][2] != 0:
            time += l[j][2] - time % l[j][2]
        time += l[j][0]
    ans[i] += time

for i in ans:
    print(i)
# Judge status: Wrong Answer
from collections import defaultdict
N = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)

for i in a:
    d[i] += 1
ans = []

for v, c in d.items():
    if c >= 2:
        ans.append(v)

ans.sort(reverse=True)
if len(ans) > 1:
    print(ans[0] * ans[1])
else:
    print(0)
# Judge status: Wrong Answer
# n = int(input())
a,b = map(int,input().split())
# A = list(map(int,input().split()))
# An = [list(map(int,input().split())) for i in range(n)]

if a >= 13:
    print(b)
elif 6<= a < 12:
    print(int(b/2))
else:
    print(0)
# Judge status: Accepted
import sys
import itertools

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
P = tuple(LI())
Q = tuple(LI())

li = list(itertools.permutations(range(1,N+1)))

p_index = li.index(P)
q_index = li.index(Q)
print(abs(p_index-q_index))
# Judge status: Accepted
a, b = map(int, input().split(" "))
if a * b % 2 == 0:
    print("Even")
else:
    print("Odd")
# Judge status: Accepted
n,a,b=map(int,input().split())
s=input()

for i in s:
    if i=='a' and a>0:
        a+=-1
        print('Yes')
    elif i!='c' and b>0:
        b+=-1
        print('Yes')
    else:
        print('No')
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))
for i in range(N-1):
    Ai=A[i]+1
    ans=A.count(Ai)
    print(ans)
# Judge status: Wrong Answer
k=input()

list_a=k.split()

n=list_a[0]

int(n)

m=list_a[1]

int(m)

t=input()

list_b=t.split()

h=len(list_b)

list_s=[int(s) for s in list_b]

if m==h and sum(list_s)>=n:
  print(sum(list_s)-n)
elif m==h and sum(list_s)<n:
  print("-1")
# Judge status: Accepted
a, b = map(int, input().split())

if a <= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")
# Judge status: Accepted
print(len(set(map(int,input().split()))))
# Judge status: Accepted
#!/usr/bin/env python3

lis = ["a", "e", "i", "o", "u"]

if input() in lis:
    print("vowel")
else:
    print("consonant")
# Judge status: Accepted
import itertools
N=int(input())
prime=[3,5,7,11,13,17,19]

comb = list(itertools.combinations(prime,3))

lst=[]
for i in range(len(comb)):
    temp=comb[i][0]*comb[i][1]*comb[i][2]
    if temp<=200:
        lst.append(temp)

lst.append(135)
lst.append(189)

ans = sum(N>=x for x in lst)
print(ans)
# Judge status: Wrong Answer
N,M = map(int,input().split())
a = [True]*(N+1)
for _ in range(M):
  b = int(input())
  a[b] = False

mod = 10**9+7
dp = [0]*(N+1)
dp[0] = 1
for i in range(N):
  for j in range(i+1,min(i+2,N)+1):
    if a[j]:
      dp[j] += dp[i]
      dp[j] %= mod


print(dp)
# Judge status: Accepted
n, k = map(int, input().split())

n_l = [1]*n

for i in range(k):
    a = int(input())
    for k in list(map(int, input().split())):
        n_l[k-1] = 0

print(sum(n_l))
# Judge status: Accepted
n = int(input())
w = list(map(int,input().split()))
minnum = sum(w)
for t in range(0,n-1):
  w1 = w[0:t+1]
  w2 = w[t+1:n]
  s1 = sum(w1)
  s2 = sum(w2)
  minnum = min(minnum,abs(s1-s2))
print(minnum)
# Judge status: Accepted
import math
x = int(input())
s = 100
count = 0
while s < x:
    s += math.floor(s*0.01)
    count += 1
print(count)
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))
l.sort()
a=[]
tmp=l.pop(-1)
while len(a)<2 and len(l)>0:
  if tmp==l[-1]:
    a.append(tmp)
    l.pop(-1)
    if len(l)==0:
      break
    tmp=l.pop(-1)
  else:
    tmp=l.pop(-1)
if len(a)<2:
  print(0)
else:
  print(a[-1]*a[-2])
# Judge status: Accepted
x, a, b = map(int, input().split())
print("A" if abs(a - x) < abs(b - x) else "B")
# Judge status: Wrong Answer
# import itertools


def main():
    n = int(input())
    s = input()
    # comb = itertools.combinations(range(n), 3)
    ans = 0
    allc = set(('R', 'G', 'B'))
    for i in range(n):
        for j in range(i + 1, n):
            a, b = s[i], s[j]
            if a == b:
                continue
            rest = (allc - set((a, b))).pop()
            ans += s[j + 1:].count(rest)
    return ans - 1  # -1 for index rule.


if __name__ == '__main__':
    print(main())
# Judge status: Wrong Answer
a = int(input())
b = int(input())
h = int(input())
S = (a+b)*h/2
print(S)
print()
# Judge status: Wrong Answer
s=list(input())
t=list(input())
s.sort()
t.sort(reverse=True)
strs="".join(s)
strt="".join(t)
list1=[strs,strt]
str1=list1[0]
list1.sort()
if str1==list1[0]:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
a, b, c = input().split(' ')
a = int(a)
b = int(b)
c = int(c)
if a-b == c-b:
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
n = int(input())
S = [int(input()) for _ in range(n)]

ans = sum(S)
sort_S = sorted(S)
for s in sort_S:
    if ans % 10 != 0:
        print(ans)
        exit()
    ans -= s

print(0)
# Judge status: Wrong Answer
li=list(map(int,input().split()))
sum=0
for i in range(1,li[0]+1):
    a=i//1000
    b=i//100%10
    c=i//10%10
    d=i%10
    s=a+b+c+d
    if li[1]<=s<=li[2]:
        #print(i)
        sum+=i
print(sum)
# Judge status: Accepted
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
s = input()
t = input()
val = max(i for i in range(n+1) if i==0 or s[-(i):]==t[:i])
ans = 2*n - val
print(ans)
# Judge status: Accepted
n = int(input())

data = []
for i in range(n):
    s,p = input().split()
    p = int(p)
    data.append((s,-p,i))

sorted_data = sorted(data, key=lambda x:(x[0], x[1]), reverse=False)

for i in range(n):
    print(sorted_data[i][2] + 1)
# Judge status: Accepted
# -*- coding: utf-8 -*-
"""
Created on Sat May  9 13:38:00 2020

@author: shinba
"""

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

if 500*k >= x:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
li = [2,1]
for i in range(86):
    li.append(li[i]+li[i+1])
n = int(input())
print(li[n])
# Judge status: Wrong Answer
n=int(input())
k=int(input())
x=int(input())
y=int(input())
a=k*x+(n-k)*y
print(a)
# Judge status: Accepted
from collections import Counter

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

A=Counter(a)
B=list(A.keys())
C=list(A.values())

ans=sum(c*(c-1)//2 for c in C)

for k in range(1,N+1):
    print(ans-A[a[k-1]]+1)
# Judge status: Accepted
import itertools
from collections import Counter
N, M = list(map(int,input().split()))
city_list = [list(map(int,input().split())) +[i+1]  for i in range(M)]
city_list_sorted = sorted(city_list,key=lambda x: (x[0],x[1]) )
city_list_grouped = itertools.groupby(city_list_sorted,key=lambda x:x[0])
ans = [None for i in range(M)]
m =0
for k, v in city_list_grouped:
  counter1 = 1
  for x1 in v:
    ans[m] = [x1[2],format(k,'0>6')+format(counter1,'0>6')]
    counter1 += 1 
    m+=1

for x in sorted(ans):
  print(x[1])
# Judge status: Wrong Answer
import math
x, y = map(int, input().split())
print(int(math.log2(y/x)) + 1)
# Judge status: Accepted
h = int(input())
cnt = 1
while h>1:
    h = int(h/2)
    cnt = cnt + 1
print((2**cnt)-1)
# Judge status: Wrong Answer
import collections
n=int(input())
a=list(map(int,input().split()))
c=collections.Counter(a)
ans=0
for i in range(10**5):
  if i < c[i]:
    ans+=c[i]-i
  elif i > c[i]:
    ans+=c[i]
print(ans)
# Judge status: Wrong Answer
n,a,b = map(int,input().split())


SET = a+b
SET_NUM = n//SET
remain_spot = n%SET
print(a*SET_NUM+remain_spot)
# Judge status: Accepted
N, K = map(int, input().split())

if N % K == 0:
    print(0)
else:
    print(1)
# Judge status: Wrong Answer
#!/usr/bin/env python3

N = int(input())
# S = input()
# N, K = map(int, input().split())
# A = list(map(int, input().split()))
mod = 10 ** 9
import numpy as np
from functools import reduce
from fractions import gcd

def main():
    T = list(set([int(input()) for _ in range(N)]))
    T_max = max(T)
    if T_max > mod:
        print(T_max)
    else:
        print(np.prod(T) // reduce(gcd, T))

if __name__ == "__main__":
    main()
# Judge status: Accepted
N,A,B=map(int,input().split())
if A>B:
  print(0)
  exit()
elif N==1:
  if A!=B:
    print(0)
    exit()
print((N-2)*(B-A)+1)
# Judge status: Accepted
def main():
    D = int(input())
    flag = False
    for a in range(-128, 128):
        for b in range(-128, 128):
            if a ** 5 - b ** 5 == D:
                print(a, b)
                return
        
if __name__ == '__main__':
    main()
# Judge status: Accepted
A,B,C,D = map(int,input().split(" "))
Takahasi = [A,B]
Aoki = [C,D]
while(1):
    Aoki[0]-=Takahasi[1]
    if Aoki[0]<=0:
        print("Yes")
        break
    Takahasi[0]-=Aoki[1]
    if Takahasi[0]<=0:
        print("No")
        break
# Judge status: Accepted
weather = ["Sunny", "Cloudy", "Rainy", "Sunny"]
S = input()
print (weather[1+weather.index(S)])
# Judge status: Wrong Answer
MAXA = 10**5+1
N = int(input())
A = list(map(int,input().split()))
A.append(MAXA)
A.sort()
hurui = [0]*(max(A)+2)
ans = 0
for j in range(N):
    a = A[j]
    if hurui[a] == 0 and A[j+1] != a:
        ans += 1
    for i in range(a,max(A),a):
        if hurui[i]:
            break
        hurui[i] += 1

print(ans)
# Judge status: Accepted
S = str(input())
 
S1 = S.replace("hi", "")
if S1 == "":
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
s = int(input())
x1 = y1 = 0
x2 = y2 = int(s**0.5)
x3 = y3 = 0
diff = s - x2*y2
for i in range(int(diff**0.5), 0, -1):
    if diff % i == 0:
        x3 = i
        y3 = diff // i
print(x1,y1,x2,y2,x3,y3)
# Judge status: Accepted
y, m, d = map(int, input().split('/'))
if y <= 2019 and m <= 4 and d <= 30:
  print('Heisei')
else:
  print('TBD')
# Judge status: Accepted
S = input()
stack = []
for c in S:
    if c == '0' or c == '1':
        stack.append(c)
    elif len(stack) > 0:
        stack.pop()
print("".join(stack))
# Judge status: Accepted
n,m = map(int,input().split())

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

m = sum(A)
if n - m < 0:
    print(-1)
else:
    print(n-m)
# Judge status: Accepted
N = int(input())
 
print(N//2 + N % 2)
# Judge status: Wrong Answer
# 入力
r, g, b = map(str, input().split())

# 処理&出力
number = r + g + b
change_int = int(number)
if change_int % 4 == 0:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
def main(w, a, b):
    if a <= w and b <= w:
        print(0)
    elif a <= b:
        print(b - (w + a))
    else:
        print(a - (w + b))


if __name__ == "__main__":
    w, a, b = map(int, input().split())

    main(w, a, b)
# Judge status: Accepted
n,k = map(int,input().split())
s = set()
for i in range(k):
    d = input()
    a = input().split()
    s |= set(a)
print(n-len(s))
# Judge status: Accepted
n = int(input())
print(n * (n + 1) // 2 - n)
# Judge status: Accepted
s = set(map(int, input().split()))
print(len(s))
# Judge status: Accepted
n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

x = max(x)
y = min(y)

flag = True
for z in range(-100, 100+1):
    if x < z <= y and X < z <= Y:
        flag = False
        
if flag:
    print('War')
else:
    print('No War')
# Judge status: Accepted
n=int(input())
S=[]
for i in range(n):
    a,b=input().split()
    S.append([a,int(b),i+1])
S.sort(key=lambda S:(S[0],-S[1]))
for i in range(n):
    print(S[i][2])
# Judge status: Wrong Answer
n = int(input())

d = [[0]*10 for i in range(10)]

for i in range(1, n+1):
  i_ = str(i)
  x = int(i_[0])
  y = int(i_[-1])
  d[x][y] += 1
  
print(d)
ans = 0
for i in range(10):
  for j in range(10):
    ans += d[i][j]*d[j][i]
    
print(ans)
# Judge status: Accepted
import sys
from collections import Counter
from collections import deque
import math
import fractions
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

s=input()
n=len(s)
c0=0
c1=0
for i in range(n):
    if s[i]=="0":
        c0+=1
    else:
        c1+=1
print(2*min(c0,c1))
# Judge status: Wrong Answer
N=int(input())
T,A=map(int,input().split())
H=list(map(int,input().split()))
h=float("INF")
pos=0
for i in range(N):
    temp=T-H[i]*0.06
    if abs(temp-A)<h:
        h=abs(temp-A)
        pos=i+1
print(pos)
# Judge status: Accepted
N, K = map(int, input().split())
d = []
A =[0]*N
for i in range(K):
    d=input()
    a = list(map(int, input().split()))
    for i in a:
        A[i-1]+=1
print(A.count(0))
# Judge status: Accepted
n=int(input())
a=[int(i) for i in input().split()]
cnt4=0
cnt2=0
oddcnt=0

for i in range(n):
  if a[i]%4==0:
    cnt4+=1
  elif a[i]%2==0:
    cnt2+=1
  else:
    oddcnt+=1

if oddcnt<=cnt4:
  print("Yes")
else:#oddcnt>cnt4
  if cnt2==0 and oddcnt-cnt4==1:
    print("Yes")
  else:
    print("No")
# Judge status: Accepted
from bisect import bisect_right
from itertools import accumulate

N,M,K=map(int,input().split())
A=list(accumulate([0]+[int(x) for x in input().split()]))
B=list(accumulate([0]+[int(x) for x in input().split()]))

m=0
for i in range(0,N+1):
  if K<A[i]:
    break
  m=max(m,i+bisect_right(B,K-A[i])-1)

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

t = []
for c in s:
    if c == "B":
        if len(t) != 0:
            t.pop()
    else:
        t.append(c)
print("".join(t))
# Judge status: Accepted
#128 b むずい
n,x=map(int,input().split())
l=list(map(int,input().split()))
z=0
ans=1
for i in l:
    z+=i
    if z>x:
        break
    ans+=1
print(ans)
# Judge status: Accepted
n,k=map(int,input().split())
p=list(map(int,input().split()))
cnt=0
d=sum(p[:k])

for i in range(n-k):
    cnt=max(cnt,d)
    d+=p[i+k]-p[i]

cnt=max(cnt,d)

print((cnt+k)/2)
# Judge status: Wrong Answer
N = int(input())
otsuri = N % 1000
if otsuri > 0:
    orsuri = 1000 - otsuri
print(otsuri)
# Judge status: Accepted
n,k=map(int,input().split())
x=list(map(int,input().split()))
a=[]
for i in range(n-k+1):
  l=x[i]
  r=x[i+k-1]
  a.append(min(abs(l)+abs(r-l),abs(r)+abs(r-l)))
print(min(a))
# Judge status: Accepted
W, H, N = map(int,input().split())
xya = [list(map(int,input().split())) for _ in range(N)]
ls = list(range(1,W*H+1))
for n in range(N):
  if xya[n][2] == 1:
    ls = [K for K in ls if (K-1)%W >= xya[n][0]]
  if xya[n][2] == 2:
    ls = [K for K in ls if (K-1)%W < xya[n][0]]
  if xya[n][2] == 3:
    ls = [K for K in ls if (K-1)/W >= xya[n][1]]
  if xya[n][2] == 4:
    ls = [K for K in ls if (K-1)/W <= xya[n][1]]
print(len(ls))
# Judge status: Accepted
#138
a,b = map(int, input().split())

res = 0
for i in range(1,21):
    if (a-1) * (i-1) + a >= b:
        res = i
        break
if b==1:
    res = 0
print(res)
# Judge status: Wrong Answer


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


def validate(strNum):
    for i in range(0, len(strNum)):
        if strNum[i] in d:
            return False
    return True


for i in range(0, 10001):
    tf = validate(str(n))
    # print(tf)
    if tf:
        print(n)
        exit()
    n += 1
# Judge status: Accepted
#B
N = int(input())
A = list(map(int, input().split()))
ans = "APPROVED"

for item in A:
    if item % 2 == 0:
        if item % 3 == 0 or item % 5 == 0:
            ans = "APPROVED"
        else:
            ans = "DENIED"
            break

print(ans)
# Judge status: Wrong Answer
x = int(input())
allsm = 6
count = 1

initcount = x // 11
if initcount:
	count += initcount*2
	x -= initcount * 11
	allsm += initcount * 11

while allsm <= x:
	allsm += 5
	count += 1
	if allsm >= x:
		break
	allsm += 6
	count += 1

print(count)
# Judge status: Accepted
a,b,c =map(int, input().split())


if a == b and b == c:
    print('No')
elif a == b or b == c or c == a:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
diff = sum(B) - sum(A)
score = 0
for a, b in zip(A, B):
    if a - b > 0:
        score += a - b
    else:
        score += (b - a - 1) // 2 * 2
print("Yes") if diff >= score else print("No")
# Judge status: Wrong Answer
n = int(input())

if n % 9 == 0 or n % 7 == 0 or n % 5 == 0:
    print("bon")
elif n % 8 == 0 or n % 6 == 0:
    print("pon")
elif n % 2 == 0:
    print("bon")
elif n % 3 == 0:
    print("bon")
else:
    print("pon")
# Judge status: Accepted
n = int(input())
k=int(input())
x = int(input())
y = int(input())
print(min(n,k)*x+max(0,(n-k))*y)
# Judge status: Accepted
N, A, B = list(map(int, input().split()))
C = N % (A+B)
D = N//(A+B)
if A >= C:
  print(A*D+C)
else:
  print(A*D+A)
# Judge status: Accepted
N = int(input())
S = input()
m = 0
p = 0
for i in S:
  if i == "D":
    p -= 1
  else:
    p += 1
  if p >= m:
    m = p
print(m)
# Judge status: Wrong Answer
N,K=map(int,input().split())
arr=[]
ans=[str(i) for  i in range(1,N+1)]
for i in range(K):
    _=input()
    arr.extend((input().split()))
    arr=list(set(arr))
p=0

for n  in  ans:
    if(n in arr)   :
        p=p+1
print(p)
# Judge status: Wrong Answer
a,b=map(int,input().split())
print('Possible' if a%3==0 or b%3==0 or a+b %3==0 else 'Impossible')
# Judge status: Accepted
n, k = (int(x) for x in input().split())
r, s, p = (int(x) for x in input().split())
t_ch = input()
t=[]
for i in range(n):
    t.append(t_ch[i])

for i in range(k, n):
    if t[i] == t[i-k]:
        t[i]=0
for i in range(0,n):
    if t[i]=="r":
        t[i]=p
    elif t[i]=="p":
        t[i]=s
    elif t[i]=="s":
        t[i]=r
print(sum(t))