peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import math

def Div(a,b,c):
  #a<=x<=bのうちcで割り切れるものの数を返す
  l = ((a-1)//c+1)*c
  r = (b//c)*c
  return (r-l)//c+1

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

print(B-A+1-(Div(A,B,C)+Div(A,B,D)-Div(A,B,C*D//math.gcd(C,D))))
# Judge status: Accepted
n=int(input())
if n>=30:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
minus_num = 0
for i in range(n):
    if a[i] < 0:
        minus_num += 1
if minus_num % 2 == 0:
    ans = 0
    for i in range(n):
        ans += abs(a[i])
else:
    min_abs = abs(a[0])
    ans = 0
    for i in range(n):
        ans += abs(a[i])
        min_abs = min(min_abs, abs(a[i]))
    ans = ans - min_abs * 2
print(ans)
# Judge status: Accepted
n,m=map(int,input().split())
if 2*n<=m:
    ans=n
    m-=2*n
    ans+=m//4
    print(ans)
else:
    print(m//2)
# Judge status: Wrong Answer
k = int(input())
if k % 2 == 0:
    print(-1)
if k % 7 == 0:
    k //= 7
x = 1
s = 0
for i in range(1, 1000005):
    s += x
    s %= k
    if s == 0:
        print(i)
        exit()
    x *= 10
    x %= k
# Judge status: Accepted
for i in range(365):
    print(26-i%26)
# Judge status: Wrong Answer
A, B, N = map(int, input().split())
if B == 1:
    result = 0
elif N >= B-1:
    result = B-1
else:
    result = N
    
print(result)
# Judge status: Accepted
a = int(input())
b = list(map(int,input().split()))
c = 1
k = b[0]
for i in range(1,a):
  if k>b[i]:
  	
  	k = b[i]
  	c+=1
print(c)
# Judge status: Accepted
s = input()
l = len(s)
a = [int(x) for x in s]
 
if int(s) == 10 ** (l - 1):
  print(10)
else:
  print(sum(a))
# Judge status: Accepted
P, Q, R = map(int,input().split())
print(min(P+Q,P+R,Q+R))
# Judge status: Accepted
N = int(input())
ab = []
for i in range(N):
    ab.append(tuple(map(int,input().split())))
 
up = sorted(ab,key=lambda a:a[1],reverse=True)
down = sorted(ab,key=lambda a:a[0],reverse=True)
 
if N%2 == 1:
    print(up[N//2][1]-down[N//2][0]+1)
else:
    r = (up[N//2][1]+up[N//2-1][1])
    l = (down[N//2][0]+down[N//2-1][0])
    print(r-l+1)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

cnt = {}

for a in A:
    cnt.setdefault(a, 0)
    cnt[a] += 1

cnt_filter = list(filter(lambda x: x[1] >= 2, cnt.items()))
cnt_filter.sort(key=lambda x: x[0], reverse=True)

x = 0
y = 0

if len(cnt_filter) >= 2:
    x = cnt_filter[0][0]
    y = cnt_filter[1][0]
    if cnt_filter[0][1] >= 4:
        y = x

ans = x * y

print(ans)
# Judge status: Accepted


MOD = 10**9+7

def kake(x,y):
    return (x*y)%MOD

N = int(input())

ans = 1 if N >=3 else 0
tmp = 1
for i in range(2,(N//3)+1):
    tmp = kake(tmp,N-3*(i-1))
    tmp = kake(tmp,N-3*(i-1)-1)
    tmp = kake(tmp,N-3*(i-1)-2)
    tmp = kake(tmp,pow(i-1,MOD-2,MOD))
    tmp = kake(tmp,pow(N-2*(i-1)-1,MOD-2,MOD))
    tmp = kake(tmp,pow(N-2*(i-1)-2,MOD-2,MOD))

    ans = (ans+tmp)%MOD


    

print(ans)
# Judge status: Wrong Answer
def main():
    from collections import Counter
    n = int(input())
    s = [input() for _ in range(n)]
    cs = Counter(s)
    m = int(input())
    t = [input() for _ in range(m)]
    print(cs.most_common()[0][1] - t.count(cs.most_common()[0][0]))

if __name__ == '__main__':
    main()
# Judge status: Accepted
s = input()
print('Yes' if 'AB' in s or 'BA' in s else 'No')
# Judge status: Wrong Answer
from collections import Counter

n = int(input())
a = [int(x) for x in input().split()]

count = Counter(a)
#print(count)
unique = list(set(a))
print(unique)

ans = 0
for uni in unique:
    #print(count[3], uni)
    if count[uni] < uni:
        continue
    else:
        ans += uni

print(len(a) - ans)
# Judge status: Accepted
o = input()
e = input()
ans = ''
if len(o) == len(e):
    time = len(o) * 2
else:
    time = len(o) * 2 - 1
for i in range(time):
    if i % 2 == 0:
        ans += o[i // 2]
    else:
        ans += e[i // 2]
print(ans)
# Judge status: Wrong Answer
import math
n = int(input())
if (n-1)%2 == 0:
    ans = n*((n-1)/2)
else:
    ans = n * math.floor((n-1)/2) + math.ceil((n-1)/2)

print(int(ans))
# Judge status: Accepted
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B, C = map(int, readline().split())

    if A <= C <= B:
        print('Yes')
    else:
        print('No')
    return


if __name__ == '__main__':
    main()
# Judge status: Accepted
A,B,C=map(int,input().split())
print(min(B//A,C))
# Judge status: Accepted
S,W=map(int,input().split())
if S>W:
    print('safe')
else:
    print('unsafe')
# Judge status: Accepted
mod = 10**9+7
n,a,b = map(int,input().split())
def combination(n, a):
    res = 1
    div = 1
    for i in range(a):
        res *= n-i
        res %= mod
        div *= a - i
        div %= mod
    res = (res * pow(div, mod-2, mod)) % mod
    return res
print((pow(2,n,mod)-1-combination(n,a)-combination(n,b))%mod)
# Judge status: Wrong Answer
n, k = map(int, input().split())
data = list(map(int, input().split()))
l = 0
r = k - 1
ans = 1000000
while True:
    if r == n:
        break
    ans = min(ans, abs(data[l]) + abs(data[l] - data[r]), abs(data[r]) + abs(data[r]) - data[l])
    l += 1
    r += 1
print(ans)
# Judge status: Wrong Answer
k,a,b=map(int,input().split())
import sys

if k <a or b-a <2:
  print(k+1)
  sys.exit()
if (k-a) %2 ==0:
  print(a+(b-a)*(k-a)//2+1)
else:
  print(a+(b-a)*((k-a)//2-1)+2)
# Judge status: Accepted
N, M = map(int, input().split())
shops = list(list(map(int, input().split())) for _ in range(N))
shops.sort()
ans = 0
for value, count in shops:
    tmp_M = max(M - count , 0)
    ans += (M - tmp_M) * value
    M = tmp_M
    if M == 0:
        break
print(ans)
# Judge status: Wrong Answer
#n種類からk種類買う
n,k = map(int,input().split())
p = list(map(int,input().split()))
print(p)
#値段を昇順
p.sort()
#値段を足す
s = 0

for i in range(k):
    s += p[i]

print(s)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
b=0
c=0
for i in range(n):
  if a[i]>1 and a[i]%2==0:
    if a[i]>3 and a[i]%4==0:
      c+=1
    else:
      b+=1
print("Yes") if n<=(b//2)+3*c else print("No")
# Judge status: Wrong Answer
from collections import Counter


def main():
    s = list(input())
    Count = Counter(s)
    if "0" not in s or "1" not in s:
        ans = 0
        exit()
    min_key = min(Count, key=Count.get)
    ans = Count[min_key] * 2
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
a, b, k = map(int, input().split())

a_ans = 0 if k >= a else a - k

b = 0 if k >= (a + b) else (b - k + a if k >= a else b)

print(str(a_ans) + ' ' + str(b))
# Judge status: Accepted
from collections import Counter

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

dic = dict(Counter(A))
ls = list(dic.items())
ls.sort(key=lambda x: x[1])

i=0
ans=0
res=len(ls)
while 1:
  if res <= K or i >= N:
    break
  ans += ls[i][1]
  i+=1
  res-=1
print(ans)
# Judge status: Wrong Answer
S = input()
n = 0
stack = 0
for s in S:
    if s == S[0]:
        stack += 1
    else:
        if stack > 0:
            n += 2
            stack -= 1
print(n)
# Judge status: Accepted
n=int(input())

if 100<=n<=111:
            print(111)
a=0
for a in range(1,9):
            if 1+111*a<=n<=111*(a+1):
                        
                        print(111*(a+1))
# Judge status: Accepted
X = int(input())
C = X // 100

if 100 * C  <= X <= 105 * C:
    print(1)
else:
    print(0)
# Judge status: Accepted
import math
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def myinput():
    return map(int,readline().split())

n = int(readline())
a = list(myinput())
mod = 10**9 + 7
ans = 0

for j in range(60):
    k = 2**j
    one = 0
    zero = 0
    for i in range(n):
        if (a[i]&k):
            one += 1
        else:
            zero += 1
    ans_bit = zero * one
    ans += (ans_bit)*(2**j) 
    ans %= mod   

print(ans%mod)
# Judge status: Accepted
N,K = map(int, input().split())
i = 1
while i > 0:
    if N - pow(K, i) < 0:
        print(i)
        break
    else:
        i += 1
# Judge status: Accepted
import bisect

_n = input()
ls = list(sorted(map(int, input().strip().split())))
total = 0

for i in range(len(ls) - 2):
    for j in range(i + 1, len(ls) - 1):
        a = ls[i]
        b = ls[j]
        left = j + 1
        num = bisect.bisect_left(ls, a + b) - left
        total += num

print(total)
# Judge status: Wrong Answer
s= str(input())
t = str(input())
s = list(s)
t = list(t)
a=0
for i in range(len(s)-1):
            if s[i]==t[i]:
               a = a+1
if a == len(s)-1:
    if len(t)-len(s)==1:
        print("Yes")
    else:
        print("No")
else:
    print("No")
# Judge status: Wrong Answer
import numpy as np

N = int(input())
SP = []
for i in range(N):
    sp = list(input().split())
    sp[1] = int(sp[1])
    sp.append(i+1)
    SP.append(sp)
SP = np.array(SP)
SP = SP[np.argsort(SP[:,1].astype("int"))[::-1]]
SP = SP[np.argsort(SP[:,0])]

for i in SP:
    print(i[2])
# Judge status: Wrong Answer
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    for i in range(N):
        if A[i] > 2**i:
            print(-1)
            break
        else:
            pass
resolve()
# Judge status: Wrong Answer
N = int(input())
T, A = map(int, (input().split(" ")))
H = list(map(int,input().split(" ")))
ans_t = 10000
ans = 0
for i in H:
  t = T - i * 0.006
  l = abs(A - T)
  if l < ans_t:
    ans_t = l
    ans = i
print(i)
# Judge status: Wrong Answer
N,K = map(int, input().split())
A = [int(a) for a in input().split()]

def f(X):
    cnt = 0
    for a in A:
        cnt += int(a/X)
    return max(1, cnt)

l = 1
r = max(A)
while r-l > 0.1:
    m = (r+l)/2
    if f(m) <= K:
        r = m
    else:
        l = m

if K == 0:
    print(max(A))
elif f(int(r)+1) >= K:
    print(int(r)+1)
elif f(int(r)) >= K:
    print(int(r))
# Judge status: Wrong Answer
a,b=map(float,input().split())
print(int(a*b//1))
# Judge status: Wrong Answer
n, s = int(input()), input()

ans = prev = 0
for i in range(n):
        if s[i]=="." and prev=="#":
                ans += 1
                prev = "#"
        else: prev = s[i]
print(ans)
# Judge status: Wrong Answer
S=input()
print(["x" for s in S])
# Judge status: Accepted
a=input()
flag=False
ans=0
hold=0
for i in range(3):
    if a[i]=='R' and not flag:
        ans=1
        flag=not flag
        hold=max(hold,ans)

    elif a[i]=='R' and flag:
        ans+=1
        hold=max(hold,ans)

    else:
        ans=0
        flag=False


print(hold)
# Judge status: Accepted
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
l.sort(key=lambda x:x[0])
cnt=0
ans=0
num=0
for i in range(n):
  if cnt>=m:
    break
  cnt+=l[i][1]
  ans+=l[i][0]*l[i][1]
  num=i
print(ans-(cnt-m)*l[num][0])
# Judge status: Wrong Answer
n = int(input())

l = [2,1]
for i in range(n):
    l.append(l[-1]+l[-2])

print(l[n-1])
# Judge status: Accepted
N, Y= map(int, input().split())
flag = False
for i in range(N+1):
	zandaka = Y - (10000*i)
	for j in range(N+1-i):
		k = (zandaka - 5000*j)//1000
		if(i + j + k == N):
			flag = True
			print(i, j, k)
			break
	if flag is True:
		break
if flag is False:
	print(-1,-1,-1)
# Judge status: Wrong Answer
a,b,k = map(int, input().split())

if a >= k:
    print(a-k, b)
elif a < k:
    print(0, b-(k-a))
elif b-(k-a) < 0:
    print(0, 0)
# Judge status: Accepted
def resolve():
    n = int(input())
    for i in range(n, 0, -1):
        if (i**0.5)%1 == 0:
            print(i)
            break
resolve()
# Judge status: Wrong Answer
l = int(input())
l = l / 3
print(int(l**3))
# Judge status: Accepted
H, A = map(int,input().split())
i = 1

while 0 < (H-A):
    H = H - A
    i = i+1

print(i)
# Judge status: Accepted
from collections import defaultdict

n = int(input())
s = input()

ans = 0
for i in range(n):
    dic = defaultdict(int)
    for j in range(i):
        for k in range(i, n):
            if s[j] == s[k]:
                dic[s[j]] += 1
                break
    ans = max(ans, len(dic))
    
print(ans)
# Judge status: Accepted
from collections import Counter

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

m=a[-1]+1
dp=[1]*m
c=Counter(a)
ans=0
for i in a:
    if dp[i] and c[i]==1:
        ans+=1

    for j in range(2*i, m, i):
        dp[j]=0

print(ans)
#print(c)
# Judge status: Accepted
from itertools import accumulate
from bisect import bisect_right
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = list(accumulate(A))
b = list(accumulate(B))

ans = 0
for i in range(N):
    tmp = a[i]
    if tmp <= K:
        j = bisect_right(b, K-tmp)
        ans = max(ans, i+j+1)
ans = max(ans, bisect_right(b, K))
print(ans)
# Judge status: Wrong Answer
n = int(input())
if (n%1000) <=500:
  print(n%1000)
else:
  print(1000-(n%1000))
# Judge status: Accepted
# -*- coding: utf-8 -*-

#----------
N = int(input().strip())
A_list = [list(map(int, input().rstrip().split())) for _ in range(2)]
#----------

count_list=[]
for i in range(N):  # 下移動するタイミング(N通り)
    count_list += [ sum(A_list[0][0:i+1]) + sum(A_list[1][i:]) ]

print( max(count_list) )
# Judge status: Accepted
A, B, K = map(int, input().split())
divisors = []

for i in range(1, max(A,B)+1):
    if A%i == B%i == 0:
        divisors.append(i)

divisors.reverse()
print(divisors[K-1])
# Judge status: Wrong Answer
n,k=map(int, input().split())
if n==k:
    print(1)
else:
    print((n + k - 2) // (k - 1))
# Judge status: Accepted
N = int(input())
S = str(input())

count = S.count('R')*S.count('G')*S.count('B')

for i in range (0, N-2):
  colour1 = S[i]
  for j in range (i+1, N-1):
    colour2 = S[j]
    if colour1 == colour2:
      continue
    else:
      if 2*j-i > N-1:
        continue
      elif colour1 != S[2*j-i] and colour2 != S[2*j-i]:
          count-=1
      else:
          continue

print(count)
# Judge status: Accepted
import math
from collections import Counter
n=int(input())
s = [str(sorted(list(input()))) for i in range(n)]
c = Counter(s)
#l=[]
#for si in set(s):
#    l.append(s.count(si))
ans=0
for i in c.values():
    if i>=2:
        x = (math.factorial(i) // (math.factorial(i - 2) * math.factorial(2)))
        ans+=x
print(ans)
# Judge status: Wrong Answer
n,m=map(int,input().split());print([(n-2)*(m-2),n*m-2][n<2 or m<2])
# Judge status: Accepted
import collections

def primes(n):
  cnt=collections.defaultdict(int)
  for i in range(2,int(n**0.5)+1):
    if n%i==0:
      while n%i==0:
        cnt[i]+=1
        n//=i
  if n!=1:
    cnt[n]+=1
  return cnt

n=int(input())
cnt=primes(n)
ans=0
for key in cnt.keys():
  val=cnt[key]
  for i in range(100):
    if (i*(i+1))//2>val:
      ans+=i-1
      break
print(ans)
# Judge status: Accepted
x, y = map(int, input().split())


def group(n):
    if n in [1, 3, 5, 7, 8, 10, 12]:
        return 1
    elif n in [4, 6, 9, 11]:
        return 2
    else:
        return 3


print("Yes" if group(x) == group(y) else "No")
# Judge status: Wrong Answer
k,s=map(int,input().split())
res=0
for x in range(k+1):
    for y in range(x,k+1):
        for z in range(y,k+1):
            if x+y+z==s:
                res+=1
print(res)
# Judge status: Wrong Answer
a,b = map(int,input().split())
print(round((a+b)/2))
# Judge status: Wrong Answer
import math

a=input()
a=sorted(a)
print("Yes" if a=="abc" else "No")
# Judge status: Wrong Answer
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    x=int(input())
    mai,y=divmod(x,100)
    if 5*mai>y:
        print(1)
    else:
        print(0)
resolve()
# Judge status: Wrong Answer
# 2020/06/03
# AtCoder Beginner Contest 084 - B

# Input
a, b = map(int,input().split())
s = input()

# Calc
is_a_dec = str.isdecimal(s[0:a])
is_b_dec = str.isdecimal(s[a+1:len(s)])

if is_a_dec and is_b_dec:
    ans = 'Yes'
else:
    ans = 'No'

# Output
print(ans)
# Judge status: Accepted
str = input()

# print("str:{}({})".format(str, type(str)))

if(str == "ABC"):
    print("ARC")
    
else:
    print("ABC")
# Judge status: Accepted
a,b = map(int,input().split())

if a >= 13:
	print(b)
elif 6 <= a <= 12:
	print(b//2)
else:
	print(0)
# Judge status: Accepted
n = int(input())
a = sorted(list(map(int,input().split())))
ans = a[-1]
x = ans//2
m = x-a[0]
ans2 = a[0]
for i in a[1:]:
    if i!=ans:
        z = min(i,ans-i)
        dif = x-z
        if m>dif:
            m,ans2 = dif,i
print(ans,ans2)
# Judge status: Accepted
N, X, Y = map(int, input().split())

ans = [0] * (N + 1)

for i in range(1, N):
  for j in range(i+1, N+1):
    dis1 = j-i
    dis2 = abs(X-i) + 1 + abs(Y - j)
    dis3 = abs(Y-i) + 1 + abs(X - j)
    d = min(dis1,dis2,dis3)
    ans[d] += 1

for i in range(1, N):
  print(ans[i])
# Judge status: Accepted
s, t = input().split()
A, B = list(map(int, input().split()))

dic = {s: A, t: B}
u = input()
dic[u] = dic[u] - 1
print(dic[s], dic[t])
# Judge status: Accepted
A, B = map(int, input().split())
if A>=10 or B>=10:
    print('-1')
    exit()
else:
    print(A*B)
# Judge status: Accepted
s = list(input())
n = len(s)

s1 = [s[i] for i in range((n-1)//2)]
s2 = [s[i] for i in range((n+3)//2-1, n)]

sr = list(reversed(s))
s1r = list(reversed(s1))
s2r = list(reversed(s2))

if s == sr and s1 == s1r and s2 == s2r:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
A, B, C, D = map(int,input().split())

while A > 0 and C > 0:
    A -= D
    C -= B

if C <= 0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
print("NO" if int("".join(input().split())) % 4 else "YES")
# Judge status: Accepted
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]

mod = 10 ** 9 + 7

dp = [-1] * (n + 1)
dp[0] = 1
dp[1] = 1

for i in a:
    dp[i] = 0

for i in range(2, n + 1):
    if dp[i] != 0:
        dp[i] = (dp[i - 2] + dp[i - 1]) % mod
print(dp[n])
# Judge status: Accepted
import sys
input=lambda: sys.stdin.readline().rstrip()
n,k=map(int,input().split())
A=[int(i) for i in input().split()]
ct=0
while min(A)<n and ct<k:
  B=[0]*n
  for i,a in enumerate(A):
    l,r=max(0,i-a),min(n,i+a+1)
    B[l]+=1    
    if r<n:
      B[r]-=1
  A[0]=B[0]
  for i in range(1,n):
    A[i]=A[i-1]+B[i]
  ct+=1
print(*A)
# Judge status: Accepted
n=int(input())
 
a=list(map(int,input().split()))
b=list(map(int,input().split()))
 
num=sum(b)-sum(a)
if num<0:
    print("No")
    exit()
 
need=0
for i in range(n):
    aa=a[i]
    bb=b[i]
    if aa>bb:
        need+=aa-bb
    elif aa<bb:
        need-=(bb-aa)//2
 
if need<=0:print("Yes")
else:print("No")
# Judge status: Accepted
n = int(input())
s = 'abcdefghijklmnopqrstuvwxyz'
ans = ''
while n > 0:
    n -= 1
#    print(n//26,n%26)
    ans = s[n%26] + ans
    n = n // 26
print(ans)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
cnt=0
zero=0
ans=0
mn=1000000001
for x in a:
  mn=min(mn,abs(x))
  if x<0:
    cnt+=1
    ans-=x
  else:
    ans+=x
  print(ans)
cnt%=2
if cnt==0:
  print(ans)
else:
  print(ans-mn*2)
  
  
  
  
  
#print(ans,cnt,mn)
# Judge status: Accepted
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	n = len(l)
	

N = int(stdin.readline())
print(ceil(N/2))
# Judge status: Wrong Answer
N = int(input())

#administrasion nas
ans = 0
def g1(x,p):
    if x == 0:
        return 0
    elif x < p:
        return 0
    else:
        return  g1(x/p,p)+int(x/p)

def g2(x,p):
    if p == 2:
        return g1(x/2,p)+int(x/2)
    else:
        return g1(x/2,p)

if N % 2 == 1:
    print(0)
else:
   ans = min(g2(N,2),g2(N,5)) 
   print(ans)
# Judge status: Wrong Answer
N = int(input())
s = sorted([input() for i in range(N)])
M = int(input())
t = sorted([input() for i in range(M)])
a = 0
for i in range(N):
    for j in range(M):
        if a < s.count(s[i])-t.count(t[j]):
            a = s.count(s[i])-t.count(t[j])
print(a)
# Judge status: Accepted
from bisect import bisect_left, bisect_right

n = int(input())
stick = list(map(int, input().split()))
stick.sort()

count = 0
for i in range(n):
    for j in range(i + 1, n):
        l = bisect_left(stick, stick[j] - stick[i] + 1)
        r = bisect_right(stick, stick[i] + stick[j] - 1) - 1
        if r < 0 or l >= n:
            break
        count += r - l + 1
        if l <= i <= r:
            count -= 1
        if l <= j <= r:
            count -= 1
print(count // 3)
# Judge status: Accepted
n,k=map(int,input().split())
p=sorted(list(map(int,input().split())))
print(sum(p[:k]))
# Judge status: Accepted
a,b,x=map(int,input().split())
print("YES" if a<=x<=a+b else "NO")
# Judge status: Accepted
def keycount(li):
    from collections import defaultdict
    count = defaultdict(int)
    for i in li:
        count[i] += 1
    dst = sorted([i for k, i in count.items()])
    return dst
num, shurui = map(int, input().split())
ball = input().split()
ballset = set(ball)
if shurui < len(ballset):
    count = len(ballset) - shurui
    dst = sum(keycount(ball)[:count])
else:
    dst = 0
print(dst)
# Judge status: Wrong Answer
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n, m = nm()
    X = nl()
    X = sorted(X)
    D = [X[i + 1] - X[i] for i in range(m - 1)]
    D = sorted(D)
    print(sum(D[:-n + 1]))


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
total = int(input())
sort_list = list(map(int, input().split()))

total_count = 0
check = 0
for x in range(0, total-1):
  s_1 = sort_list[x]
  counter = 0
  for y in range(x+1, total-1):
    if s_1 > y:
      counter += 1
      total_count += 1
  if counter > 1:
    print("NO")
    check = 1
    break

if check == 0:
  if total_count <= 1:
    print("OK")
  else:
    print("NO")
# Judge status: Accepted
import numpy as np

X, Y, A, B, C = map(int, input().split())
p = np.array(tuple(map(int, input().split())))
q = np.array(tuple(map(int, input().split())))
r = np.array(tuple(map(int, input().split())))

p.partition(A - X)
q.partition(B - Y)

pqr = np.concatenate((p[-X:], q[-Y:], r))
pqr.partition(len(pqr) - (X + Y))

ans = sum(pqr[-(X + Y) :])

print(ans)
# Judge status: Accepted
A,B,C,K = map(int,input().split())
if(K == 0):
  ans = A - B
elif(K % 2 == 1):
  ans = B - A
else:
  ans = A - B
if(ans > 10 ** 18):
  print("Unfair")
else:
  print(str(ans))
# Judge status: Accepted
s = input()
cnt = [0]*3
for i in s:
    cnt[ord(i)-ord('a')] += 1
if max(cnt)-min(cnt)<=1:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
from functools import reduce
mod = 10**9+7

def P(n, k):
  return reduce(lambda x, y:x*y%mod, range(n-k+1, n+1))

def factorial(n):
  return 1 if n == 0 else P(n, n)

X, Y = map(int, input().split())
L, S = max(X, Y), min(Y, X)
if (S-(L-S))%3 != 0 or S-(L-S) < 0:
  print(0)
else:
  s = (S-(L-S))//3
  l = (S-(L-S))//3+(L-S)
  bunshi = factorial(s+l)
  bunbo = (factorial(s)*factorial(l))%mod
  print((bunshi*pow(bunbo,mod-2, mod))%mod)
# Judge status: Wrong Answer
import math
n = int(input())
print(math.factorial(n), math.factorial(n)%(10**9+7))
# Judge status: Accepted
n=int(input())
ans=0
if n%2!=0:
    print(ans)
elif n==0:
    print(ans)
else:
    for i in range(1,50):
        ans+=n//((5**i)*2)
    print(ans)
# Judge status: Accepted
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()

import bisect
ans=0
for i in b:
    q=bisect.bisect_left(a,i)
    s=bisect.bisect_right(c,i)
    ans=ans+q*(n-s)
print(ans)
# Judge status: Wrong Answer
N=int(input())
n=str(N)
Length=len(n)

ans=(int(n[0])-1)+9*(Length-1)

print(ans)
# Judge status: Accepted
X, K, D = map(int, input().split())
if X < 0:
    X = -X

a = X // D
if a > K:
    print(X - K * D)
else:
    if (K - a) % 2:
        print(D - X % D)
    else:
        print(X % D)