peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
import string
# print(string.ascii_letters)
# print(string.ascii_lowercase)
# print(string.ascii_uppercase)

n = input()
# print(n)

if n in string.ascii_lowercase:
  print("B")
elif n in string.ascii_uppercase:
  print("A")
# Judge status: Wrong Answer
n,k=map(int,input().split())
p=list(map(int,input().split()))
x=sum(p[:k])
idx=0
for i in range(k,n):
  dx=x+p[i]-p[i-k]
  if x<dx:
    idx=i-k+1
    x=dx
ans=0
for i in range(idx,idx+k):
  ans+=(p[i]*(p[i]+1)//2)/p[i]
print(ans)
# Judge status: Wrong Answer
n = int(input())
a = sorted(map(int, input().split()))
p = a[-1]
b =100000
c = 0
for i in range(n-1):
  if abs(a[i]-p/2) < b:
    b = abs(a[i]-p/2)
    c = a[i]
print(str(p)+' '+str(c))
# Judge status: Accepted
def compare(a, b):
    result = 0
    for i in range(len(a)):
        if a[i] != b[i]:
            result += 1
    return result

s = input()
t = input()

ls = len(s)
lt = len(t)

diff = []
for i in range(ls-lt+1):
    diff.append(compare(s[i:i+lt], t))
print(min(diff))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

cnt_1 = 0
cnt_2 = 0
cnt_4 = 0

for a in A:
    if a % 4 == 0: 
        cnt_4 += 1
    elif a % 2 == 0:
        cnt_2 += 1
    else:
        cnt_1 += 1

if cnt_4 >= cnt_1:
    print('Yes')
else:
    if cnt_2 == 0 and cnt_1 - cnt_4 == 1:
        print('Yes')
    else:
        print('No')
# Judge status: Wrong Answer
q,h,s,d = map(int, input().split())
n = int(input())

cost_2000 = min(8*q,4*h,2*s,d)
cost_1000 = min(4*q,2*h,s)
cost_500 = min(2*q,h)
cost_250 = q

c = [cost_2000,cost_1000,cost_500,cost_250]
amo = [2,1,0.5,0.25]
ans = 0
for i in range(4):
	uni,mod = divmod(n,amo[i])
	ans += c[i] * uni
	n = mod

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

flag = False
for a in range(-118, 120):
    if(flag): break
    for b in range(-118, 119):
        if(flag): break
        if pow(a, 5) - pow(b, 5) == x:
            print(a,b)
            flag = True
            break
# Judge status: Accepted
n,k = map(int,input().split())
oppo = list(input().split())
for i in range(len(oppo)):
    oppo[i] = int(oppo[i])

oppo = sorted(oppo)
attack = 0

if  k >= n:
    print(0)
else:
    for i in range(0,len(oppo)-k):
        attack = attack + oppo[i]
    print(attack)
# Judge status: Wrong Answer
s = input()
if int(s[5])>=5: print('TBD')
else: print('Heisei')
# Judge status: Wrong Answer
n = int(input())
l = list(map(int,input().split()))
m = max(l)
s = sum(l)
if m < s:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
import numpy as np
n = int(input())
p = np.array(list(map(int,input().split())))

a = np.arange(1, n+1)
tmp = p - a
cnt = np.count_nonzero(tmp != 0)

flg = False
if cnt == 0 or (cnt == 2 and tmp.sum() == 0):
    flg = True

print('YES') if flg else print('NO')
# Judge status: Accepted
n,k,*a=map(int,open(0).read().split())
for _ in range(k):
 b=[0]*n
 for i,q in enumerate(a):
  b[max(0,i-q)]+=1
  if i+q+1<n:b[i+q+1]-=1
 for i in range(1,n):b[i]+=b[i-1]
 if b==a:break
 a=b[:]
print(*a)
# Judge status: Accepted
x, y = map(int, input().split())
cnt = 1
while x * 2 ** cnt <= y:
    cnt += 1
print(cnt)
# Judge status: Accepted
n = int(input())
s = [0] * n
for i in range(n):
    s[i] = int(input())
    

judge = 0
answer = 0

for i in s:
    answer += i
    if i%10 == 0:
        judge += 1 

#print(answer)

s.sort()
mi = 0
#print(s)

for i in s:
    if i%10 != 0:
        mi = i
        break


#print(mi)

if judge == len(s):
    print(0)
else:
    if answer%10 == 0:
        answer -= mi

    print(answer)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    if a[i] == i+1:
        a[i], a[i+1] = a[i+1], a[i]
        ans += 1
if a[-1] == n:
    ans += 1
print(ans)
# Judge status: Accepted
n = int(input())
x = list(map(int, input().split()))

# print(max(x))
# print(min(x))

tsukare = [0 for i in range(max(x)-min(x)+1)]

# print(tsukare)
# print(len(x))

for i in range(min(x), max(x)+1):
    for k in range(len(x)):
        tsukare[i-min(x)] += (i-x[k])**2

print(min(tsukare))
# Judge status: Accepted
import math
def main():
    d = int(input())
    th = 90

    eps = 10**(-12)
    x = y = ans = 0
    while True:
        x += math.cos(math.radians(th))
        y += math.sin(math.radians(th))
        ans += 1

        if abs(x) <= eps and abs(y) <= eps:
            print(ans)
            break
        else:
            th += d

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
N=int(input())
M = (N * (N+1))
print(M/2)
# Judge status: Accepted
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
cnt=Counter(a)
ans=sum(a)
q=int(input())
for i in range(q):
    b,c=map(int,input().split())
    ans+=(c-b)*cnt[b]
    ##print(cnt)#Counter({1: 1, 2: 1, 3: 1, 4: 1})
    cnt[c]+=cnt[b]
    ##print(cnt)#Counter({2: 2, 1: 1, 3: 1, 4: 1})
    cnt[b]=0
    ##print(cnt)#Counter({2: 2, 3: 1, 4: 1, 1: 0})
    print(ans)
# Judge status: Wrong Answer
a,b,n=map(int,input().split())
x=0
if b < n:
    x=b
else:
    x=n
#while x<=b and x<=n:
    #x+=1
print((int((a*x)//b) - a*(int(x//b))))
# Judge status: Accepted
import numpy as np

n = int(input())
A = np.array(list(int(input()) for i in range(n)))
A_sort = np.sort(A)
A_1 = A_sort[n-1]
A_2 = A_sort[n-2]


for i in range(n):
    if A[i] != A_1:
        print(A_1)
    else:
        print(A_2)
# Judge status: Accepted
N,M=map(int,input().split())
print(int(N*(N-1)/2+M*(M-1)/2))
# Judge status: Wrong Answer
n = int(input())
a = [int(x) for x in input().split()]

res = 10 ** 9
for i in range(1000):
  c = 0
  for j in range(n):
    c += abs(a[j] - (i + j + 1))
  res = min(res,c)

print(res)
# Judge status: Accepted
*a,=map(int,[*open(0)][1].split())
c=sum(a)
s=b=1
for a in a:c-=a;b=min(c,(b-a)*2);s+=b
print(max(-1,s))
# Judge status: Accepted
M=10**9+7
x,y=map(int,input().split())
ans=0
if (x+y)%3==0:
  a=(2*y-x)//3
  b=(2*x-y)//3
  if a>=0 and b>=0:
    f1,f2=1,1
    for i in range(a+1,a+b+1):
      f1*=i
      f1%=M
    for i in range(1,b+1):
      f2*=i
      f2%=M
    ans=f1*pow(f2,M-2,M)

print(ans%M)
# Judge status: Wrong Answer
a, b, c = (int(i) for i in input().split())
print('Yes') if a+b <= c else print('No')
# Judge status: Accepted
N,K,*A=map(int,open(0).read().split())
for _ in range(K):
  B=[0]*(N+1)
  for i in range(N):
    B[max(0,i-A[i])]+=1
    B[min(N,i+A[i]+1)]-=1
  for i in range(N):B[i+1]+=B[i]
  if A==B:break
  A=B
print(*A[:-1])
# Judge status: Accepted
N = int(input())
l = []

for _ in range(N):
    a, b, c = map(int, input().split())
    l.append([a,b,c])

dp = [[0]*3 for _ in range(N+1)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + l[i][k])
ans = 0
for i in range(3):
    ans = max(ans, dp[N][i])
print(ans)
# Judge status: Accepted
#!/usr/bin/env python3

A, B, C, D= map(int, input().split())
while A > 0 or C > 0:
    C -= B
    if C <= 0:
        ans = "Yes"
        break
    A -= D
    if A <= 0:
        ans = "No"
        break
print(ans)
# Judge status: Accepted
#import math
#import collections
#n,m = map(int, input().split( ))
n = int(input())
A = list(map(int, input().split( )))
arr = [0]*n
for a in A:
  arr[a-1] += 1
for a in arr:
  print(a)
# Judge status: Accepted
w,h,x,y=map(int,input().split())
ans1=(w*h)/2.0
ans2=0
if (w/2==x)and(h/2==y):
    ans2=1
print('%f %d'%(ans1,ans2))
# Judge status: Wrong Answer
import math
r=int(input())
s=(r*r) * math.pi
b=int(s//math.pi)
print(b)
# Judge status: Accepted
n = int(input())
D = sorted(list(map(int,input().split())))
print(D[n//2]-D[n//2-1])
# Judge status: Accepted
from collections import Counter
from collections import defaultdict

S = list(map(str, input().rstrip()))

s = Counter(S)
d = defaultdict(int)

for i in ["a", "b", "c"]:
    d[i] = 0

for l, n in s.items():
    d[l] += n

d = list(d.values())

print("YES" if max(d) - min(d) <= 1 else "NO")
# Judge status: Accepted
s=input()
n=len(s)
d=[]
for i in range(n):
  d.append(int(s[i]))
s1=[0]
s2=[1]
for i in range(1,n):
  if s1[i-1]==0:
    s1.append(1)
  else:
    s1.append(0)
  if s2[i-1]==1:
    s2.append(0)
  else:
    s2.append(1)
a,b=0,0
for i in range(n):
  if d[i]!=s1[i]:
    a+=1
  if d[i]!=s2[i]:
    b+=1
print(min(a,b))
# Judge status: Accepted
n,m = map(int, input().split())
d = m//n
ans = []
for i in range(1,min(d+1,int(m**0.5)+1)):
    if (m % i == 0):
        ans.append(i)
        if (m//i<=d):
            ans.append(m//i)
print(max(ans))
# Judge status: Accepted
def resolve():
    N = int(input())
    ls = []
    for i in range(N):
        tmp = input().split()
        tmp.append(i+1)
        ls.append(tmp)

    ls = sorted(ls, key=lambda x: (x[0], -int(x[1])))

    for l in ls:
        print(l[2])
    return

resolve()
# Judge status: Wrong Answer
n = int(input())
xy_list = []
for i in range(n):
    xy_list.append(list(map(int, input().split())))

import itertools
import math
comb = list(itertools.permutations(xy_list))
ans = 0
for s in comb:
    #print(ans)
    for zyun in range(len(s)-1):
        ans += math.sqrt((s[zyun][0] - s[zyun+1][0])**2 + (s[zyun][1] - s[zyun+1][1])**2)
print(round(ans/n/(len(s)-1), 12))
# Judge status: Accepted
n,k = map(int,input().split())
a = list(map(int,input().split()))
t=[[0 for i in range(n)] for j in range(64)]
for i in range(64):
    for j in range(n):
        if i == 0:
            t[i][j]=a[j]
        else:
            t[i][j]=t[i-1][t[i-1][j]-1]
ans=1
for i in range(64):
    r = k%2
    k = k//2
    if r == 1:
        ans = t[i][ans-1]
    if k == 0:
        print(ans)
        exit()
# Judge status: Accepted
import math

N, D = map(int, input().strip().split(' '))
count = 0
for i in range(N):
    X, Y = map(int, input().strip().split(' '))
    if math.sqrt(X**2 + Y**2) <= D:
        count += 1
    else:
        pass

print(count)
# Judge status: Accepted
S = input()

a = S.count("a")
b = S.count("b")
c = S.count("c")

if max(a, b, c) - min(a, b, c) >= 2:
    print("NO")
else:
    print("YES")
# Judge status: Accepted
n=int(input())
lst=list(map(int,input().split()))
_max=lst[0]
st=0
for i in lst:
  if i>=_max:
    _max=i
  else:
    st=st+(_max-i)
print(st)
# Judge status: Accepted
x = int(input())

a = x // 500
x = x - a*500
b = x // 5
print(a*1000+b*5)
# Judge status: Accepted
N,L = map(int, input().split())
S = []
for i in range(N):
    s = input()
    S.append(s)
S.sort()
print(''.join(S))
# Judge status: Accepted
import numpy as np

c = np.array([list(map(int, input().split())) for i in range(3)])

flag = True
for a1 in range(c.max()+1):
  b1 = c[0][0] - a1
  b2 = c[0][1] - a1
  b3 = c[0][2] - a1
  if (c[1][0] - b1 != c[1][1] - b2 or c[1][0] - b1 != c[1][2] - b3):
    flag = False
  
  if (c[2][0] - b1 != c[2][1] - b2 or c[2][0] - b1 != c[2][2] - b3):
   	flag = False
  
print("Yes" if flag else "No")
# Judge status: Accepted
n = int(input())
D=dict()
for i in range(n):
	s= input()
	s=sorted(s)
	S=''.join(s)
	if S in D:
		D[S]+=1
	else:
		D[S]=1

cnt=0
for s in D:
	cnt+=D[s]*(D[s]-1)//2
print(cnt)
# Judge status: Accepted
n = int(input())
s = input()

l = [0]*n
r = [0]*n
for i in range(1,n):
    l[i] = l[i-1]+(s[i-1]=="W")
for i in range(n-1)[::-1]:
    r[i] = r[i+1]+(s[i+1]=="E")

ans = 10**6
for a,b in zip(l,r):
    ans = min(a+b,ans)
print(ans)
# Judge status: Wrong Answer
import collections

N=int(input())
P=[input() for i in range(N)]
print(P)
c=collections.Counter(P)
print(len(c))
# Judge status: Accepted
n = int(input())
s = list(input())
ans = 0
for i in range(n):
    l = list(set(s[:i]))
    r = list(set(s[i:]))
    cnt = 0
    for j in range(len(l)):
        if l[j] in r:
            cnt += 1
    ans = max(ans,cnt)
print(ans)
# Judge status: Accepted
N,K = map(int,input().split())
ans = 0
for k in range(K,N+2):
    ans += N*k-k*(k-1)/2-k*(k-1)/2+1
ans %= 10**9+7
print(int(ans))
# Judge status: Wrong Answer
def main():
    s = list(input())
    k = int(input())

    ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
    D = dict(zip(ascii_lowercase,list(range(0,len(ascii_lowercase)))))

    n = len(ascii_lowercase)

    for i in range(0,len(s)):
        j = D[s[i]]
        if j != 0 and 26 -j <= k:
            k -= (26-j)
            s[i] ='a'
    print(''.join(s))

main()
# Judge status: Accepted
w,a,b = map(int,input().split())
if b>=a:
  print(max(0,b-(a+w)))
else:
  print(max(0,a-(b+w)))
# Judge status: Wrong Answer
S = input()
T = input()

if S in T:
    print("Yes")
else: print("No")
# Judge status: Accepted
a, b, n = map(int, input().split())
if b > n:
  x = n
else:
  x = b - 1
print(int(a * x / b) - a * int(x / b))
# Judge status: Accepted
k = int(input())
a,b = map(int,input().split())
chk = False

for i in range(a,b+1):
    if i % k == 0:
        chk = True
        break
      
print("OK") if chk else print("NG")
# Judge status: Wrong Answer
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count=0

for s in range(a+1):
    if s*500 == x:
        count += 1
    for t in range(b+1):
        if s*500 + t*100 == x:
            count += 1
        for u in range(c+1):
            if s*500 + t*100 + u*50 == x:
                count += 1

print(count)
# Judge status: Wrong Answer
L=int(input())
ans=0
tmp=0
d=10
L_=int(L**(1/3))
for i in range(max(0,int(L_-10)*d),int(L_+10)*d):
  for j in range(max(0,int(L_-10)*d-i),int(L_+1)*d-i):
    tmp=(i/d)*(j/d)*(L-(i/d)-(j/d))
    ans=max(ans,tmp,0)
print(ans)
# Judge status: Accepted
k = int(input())
s = input()
ls = len(s)

if ls <= k:
    print(s)
else :
    print(s[0:k]+"...")
# Judge status: Accepted
a,b=map(int,input().split())
if a<9 and b<9:
    print("Yay!")
else:
    print(":(")
# Judge status: Wrong Answer
def main():
    s = input().rstrip()
    cnt_t, cnt_s = 0, 0
    for i in range(len(s)):
        if s[i] == "S":
            cnt_t = i
            break
    for i in range(len(s)):
        if s[len(s)-1-i] == "T":
            cnt_s = i
            break
    print(2*max(cnt_t, cnt_s))

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

MOD = 10**9 + 7
ans = 0
if abs(N-M) < 2:
    A, B = max(N, M), min(N, M)
    res = 1
    if A == B:
        for i in range(1, A+1):
            res = (i**2 % MOD) * res % MOD
        ans = res * 2 % MOD
    else:
        for a in range(1, A+1):
            res = res * a % MOD
        for b in range(1, B+1):
            res = res * b % MOD
        ans = res % MOD

print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
a = list(map(int, input().split()))
print(*['Yes' if a[i] < a[k + i] else 'No' for i in range(n - k)], sep='\n')
# Judge status: Wrong Answer
N = int(input())
if N == 1:
  print(1)
elif N%2 != 0:
  print((N-2)/5)
else:
  print(N/2)
# Judge status: Wrong Answer
import heapq
n,m=map(int,input().split())
t=[[0] for _ in range(m)]
for i in range(n):
    a,b=map(int,input().split())
    if a>m:
        continue
    t[a-1].append(b)
h=[]
for i in range(m):
    t[i].sort(reverse=True)
    for j in range(min(len(t[i]),m-i)):
            h.append(-t[i][j])
heapq.heapify(h)
ans=0
for i in range(m):
    ans+=-heapq.heappop(h)
print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline

def main():
    N,M,K = map(int,input().split())
    
    for i in range(N+1):
        for j in range(M+1):
            b = N*M-(i*j+(N-i)*(M-j))
            if b == K:
                print("Yes")
                exit()
    
    print("No")
    
if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
X=int(input())
n=1
for b in range(2,X):
   p=2
   while(True):
      x=b**p
      print(x)
      if x<=X:
         n=x
         p+=1
      else:
         break
   
print(n)
# Judge status: Wrong Answer
n = int(input())
l = list(map(int, input().split()))
l.sort()
triangle = 0
for i in range(n-2):
  min_l = l[i]
  for j in range(i+1, n-1):
    sum_l = min_l + l[j]
    inf = j
    sup = n
    while sup - inf > 1:
      x = (inf + sup) // 2
      if l[x] < sum_l:
        sup = x
      else:
        inf = x
    triangle += n - sup
print(triangle)
# Judge status: Accepted
import sys

input = sys.stdin.readline
n, m = map(int, input().split())
x = set()
y = set()
for _ in range(m):
    a, b = map(int, input().split())
    if a == 1:
        x.add(b)
    if b == n:
        y.add(a)
print(("POSSIBLE", "IMPOSSIBLE")[len(x & y) == 0])
# Judge status: Accepted
n = int(input())
al = list(int(input()) for _ in range(n))

s = set()

for a in al:
    s ^= {a}

print(len(s))
# Judge status: Accepted
a = input().split(' ')
a[0] = int(a[0])
a[1] = int(a[1])

if (a[0] == 1): a[0] += 99
if (a[1] == 1): a[1] += 99

if (a[0] == a[1]): print("Draw")
elif (a[0]) > a[1]: print("Alice")
else: print("Bob")
# 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
def paint():
    s = input()
    slist = s.split(' ')

    a = int(slist[0])
    b = int(slist[1])
    c = int(slist[2])
    count = 1
    if a != b:
        count += 1
    if a != c and b != c:
        count += 1

    print(count)

paint()
# Judge status: Wrong Answer
n = int(input())
s = []
for i in range(n):
  s.append(int(input()))
for i in range(n):
  if sum(s)%10 != 0:
    print(sum(s))
    break
  else:
    s.remove(min(s))
  if s == []:
    print(0)
    break
# Judge status: Accepted
a,b = map(int,input().split())
s = str(input())

if len(s)== a+b+1 \
    and s[a:a+1] =='-' \
    and str.isdecimal(s[0:a]) \
    and str.isdecimal(s[a+1:a+1+b]):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
K = int(input())
print((K // 2) * ((K + 1) // 2))
# Judge status: Accepted
from operator import itemgetter
X = []
L = []

n = int(input())
for i in range(n):
    x, l = map(int, input().split())
    X.append(x)
    L.append(l)

robo = sorted([(X[i]-L[i], X[i]+L[i]) for i in range(n)], key=itemgetter(1))

ans = 0
end = -float("inf")
for i in range(n):
    if end <= robo[i][0]:
        ans += 1
        end = robo[i][1]

print(ans)
# Judge status: Wrong Answer
n,k = map(int, input().split())
al = list(map(int, input().split()))

res= 10**6

for i in range(n-k+1):
    st = al[i]
    en = al[i+k-1]
    if st *en <0:
        temp = min(abs(st),abs(en))*2+max(abs(st),abs(en))
    else:
        temp = max(abs(st),abs(en))
    res = min(temp,res)

print(res)
# Judge status: Wrong Answer
s = input()

sl = list(s)

for i in range(0,len(sl)-1):
    if sl[i] == "A":
        st = i

for j in range(len(sl),0,-1):
    if sl[j-1] =="Z":
        en = j-1


print (en-st+1)
# Judge status: Accepted
from collections import Counter

n = int(input())
s = list(input())
mod = 10**9 + 7

cnt = Counter(s)

ans = 1
for k, v in cnt.items():
    ans *= (v + 1) % mod

print((ans - 1) % mod)
# Judge status: Accepted
a, b = map(int, input().split())

if (a * b) % 2 == 1:
    ans = 'Odd'
else:
    ans = 'Even'

print(ans)
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    if set(input())=={'a','b','c'}:
        print('Yes')
    else:
        print('No')
resolve()
# Judge status: Wrong Answer
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():
    N, L = map(int, readline().split())
    S = [readline().strip() for _ in range(L)]

    S.sort()
    ans = ''.join(S)
    print(ans)
    return


if __name__ == '__main__':
    main()
# Judge status: Accepted
a,b,k = (int(w) for w in input().split()[:3])

if a > k:
    print(a-k, b)
    exit()
else:
    k -= a

if b > k:
    print(0, b-k)
else:
    print(0, 0)
# Judge status: Wrong Answer
r = int(input())
S = r * r
print('半径{}の円の面積は半径1の円の面積の{}倍です'.format(r,S))
# Judge status: Accepted
a,b = map(int,input().split())
print((a+b)//2 if (a+b)%2==0 else 'IMPOSSIBLE')
# Judge status: Accepted
n,d = map(int, input().split())
a = [list(map(int,input().split())) for _ in range(n)]
cnt = 0
for i in range(n-1):
    for j in range(i+1,n):
        s = 0
        for k in range(d):
            s+=(abs(a[i][k]-a[j][k]))**2
        if s**0.5==int(s**0.5):
            cnt+=1
print(cnt)
# Judge status: Accepted
A=[int(input()) for i in range(5)]
k=int(input())
for i in range(5):
    for j in range(i,5):
        if abs(A[i]-A[j])>k:
            print(":(")
            exit()
print("Yay!")
# Judge status: Accepted
n = int(input())

power = 1
for i in range(1, n + 1):
    power = power * i % 1000000007

print(power)
# Judge status: Accepted
# -*- coding: utf-8 -*-

N, K = [int(i) for i in input().split()]
H = [int(input()) for i in range(N)]

sorted_H = sorted(H)
distance = 1000000000
for i in range(N-K+1):
    if sorted_H[i+K-1] - sorted_H[i]  < distance:
        distance = sorted_H[i+K-1] - sorted_H[i]
print(distance)
# Judge status: Accepted
n = int(input())
count = 0
for i in range(10):
  for j in range(10):
    if i*j == n:
      count = 1
      break

if count == 1:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
L = [A[0]]
R = [A[-1]]

for i in range(N-1):
    L.append(gcd(L[-1], A[i+1]))
    R.append(gcd(R[-1], A[N-i-1]))
ans = max(L[-2], R[-2])
for i in range(1, N-1):
    ans = max(ans, gcd(L[i-1], R[-i-1]))

print(ans)
# Judge status: Wrong Answer
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(x, y):
    return x / gcd(x, y) * y
n=int(input())
a=list(map(int,input().split()))
mod = 10**9+7
lc=1
for i in range(n):
    lc = lcm(lc,a[i])
a = list(map(lambda x : (lc/x)%mod,a))
print(sum(a)%mod)
# Judge status: Wrong Answer
s=""
n=int(input())
while n!=0:s=str(n%2)+s;n=-(n//2)
print(s)
# Judge status: Accepted
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Created: Jul, 14, 2020 11:34:55 by Nobody
# $Author$
# $Date$
# $URL$
__giturl__ = "$URL$"


from sys import stdin
input = stdin.readline


def main():
  N = int(input())

  print((N-1)*N//2)


if(__name__ == '__main__'):
  main()
# Judge status: Accepted
s=str(input())
if s[0] == "A" and s[2:-1].count("C") == 1:
    if s[1].islower() and s[-1].islower():
        print("AC")
    else:
        print("WA")
else:
    print("WA")
# Judge status: Accepted
N = int(input())
A = [int(i) for i in input().split()]
ans = [0 for i in range(N)]
for i in A:
    ans[i-1] += 1
for i in ans:
    print(i)
# Judge status: Accepted
N,M=map(int,input().split())

if N==M:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
n = int(input())
s = [input() for i in range(n)]

print('AC x ' + str(s.count('AC')))
print('WA x ' + str(s.count('WA')))
print('TLE x ' + str(s.count('TLE')))
print('RE x ' + str(s.count('RE')))
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))

ans = 1
sq = 0
a = A[0]
for i in range(1,n):
    #print(a,A[i], sq)
    if sq == 0 and A[i] < a:
        sq = -1
    elif sq == 0 and A[i] > a:
        sq = 1
    elif (sq == 1 and A[i] < a) or (sq == -1 and A[i] > a):
        #print('---')
        ans += 1
        sq = 0
    a = A[i]

print(ans)
# Judge status: Accepted
T = list(input()) 
ans = []
for i in T:
    if i == "?":
        ans.append("D")
    else:
        ans.append(i)
print("".join(ans))
# Judge status: Accepted
h, w = map(int, input().split())

a = h * w

if h == 1 or w == 1:
    print("1")
else:
    if a % 2 == 0:
        print(a // 2)
    else:
        print((a // 2) + 1)
# Judge status: Accepted
def main():
  
  N, M = (int(_) for _ in input().split())
  X = sorted([int(_) for _ in input().split()])
  if N >= M:
    print(0)
    return
  Y = sorted([X[i] - X[i-1] for i in range(1, M)])
  print(sum(Y[:M-N]))
  return

if __name__ == '__main__':
  main()
# Judge status: Accepted
A, B, C, D = [int(x) for x in input().split()]
ans = min(B, D)-max(A, C)
if ans < 0:
    ans = 0
print(ans)
# Judge status: Accepted
X, K, D = map(int, input().split())

if abs(X) // D > K:
    print(abs(X) - K * D)
    exit()

mod = abs(X) % D
if (K - (abs(X) // D)) % 2 == 0:
    print(mod)
else:
    print(abs(mod - D))
# Judge status: Wrong Answer
N, Q = map(int, input().split())
S = list(input())
L = [0]
cnt = 0

for i in range(1, N):
  if S[i-1] == "A" and S[i] == "C":
    cnt += 1
  L.append(cnt)

print(L)

for _ in range(Q):
  l, r = map(int, input().split())
  print(L[r-1] - L[l-1])