peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n, m = map(int, input().split())
list_X = list(map(int, input().split()))

list_X.sort()
list_Y = []

for i in range(m-1):
    list_Y.append(list_X[i+1]-list_X[i])

list_Y.sort()

if n >= m:
    print(0)
else:
    print(sum(list_Y[:m-n]))
# Judge status: Wrong Answer
s = input()
k = int(input())
l = [26 - (ord(c) - ord('a')) % 26 for c in s]
for i in range(len(s) - 1):
    if k >= l[i]:
        k -= l[i]
        s = s[:i] + 'a' + s[i + 1 :]

k %= 26
s = s[:-1] + chr(ord('a') + (ord(s[-1]) - ord('a') + k) % 26)
print(s)
# Judge status: Accepted
N,M = map(int,input().split())

print(N*(N-1)//2+M*(M-1)//2)
# Judge status: Accepted
a, b, c, d = map(int, input().split())

result = a*c
result = max(result, a*d)
result = max(result, b*c)
result = max(result, b*d)
print(result)
# Judge status: Wrong Answer
K,A,B=map(int,input().split())
bis=1
if K==1:
  bis+=1
elif A>=B-1 or K-A+1<=0:
  bis+=K
else:
  if (K-(A-1))%2==0:
    bis=A+(B-A)*(K-(A-1))//2
  else:
    bis=A+(B-A)*(K-(A-1))//2+1
print(int(bis))
# Judge status: Accepted
a = list(map(int,input().split()))
ans = int(1e10)
a.sort()
print(a[0] + a[1] + 10*a[2])
# Judge status: Wrong Answer
n, m = map(int, input().split())
a, b, c, d = [0] * n, [0] * n, [0] * m, [0] * m
for i in range(n):
    a[i], b[i] = map(int, input().split())
for i in range(m):
    c[i], d[i] = map(int, input().split())

for i in range(n):
    min_dist, min_c = abs(a[0]-c[0]) + abs(b[0]-d[0]), 0
    for j in range(m):
        dist = abs(a[i]-c[j]) + abs(b[i]-d[j])
        if dist < min_dist:
            min_dist = dist
            min_c = j
    print(min_c+1)
# Judge status: Accepted
from math import gcd
#================================================
N=int(input())
A=list(map(int,input().split()))

F=[0]*N
G=[0]*N

F[0]=A[0]
G[-1]=A[-1]

for i in range(1,N):
    F[i]=gcd(F[i-1],A[i])
    G[-(i+1)]=gcd(G[-i],A[-(i+1)])

F=[0]+F+[F[-1]]
G=[G[0]]+G+[0]

M=0
for i in range(N):
    M=max(M,gcd(F[i],G[i+2]))
print(M)
# Judge status: Wrong Answer
N = int(input())

SP = []
for _ in range(N):
  S,P = input().split()
  SP.append([S,-int(P)])
  
sort_SP = sorted(SP)

for i in SP:
  print(sort_SP.index(i)+1)
# Judge status: Accepted
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
ret = 0
for i in range(k):
    last = 'x'
    for c in t[i::k]:
        if last != c:
            ret += p if c == 'r' else r if c == 's' else s
            last = c
        else:
            last = 'x'
print(ret)
# Judge status: Accepted
a, b, x = map(int, input().split())
print(b//x - a//x + (a%x == 0))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

s = [a[i] for i in range(0,n,2)]
t = [a[i] for i in range(1,n,2)[::-1]]
if n % 2 == 0:
    print(*t, end=' ')
    print(*s)
else:
    # print(s,t)
    print(*s[::-1], end=' ')
    print(*t[::-1])
# Judge status: Accepted
S = input()
ans = ["-1"]
t = ""
for c in S:
    t += c
    if t != ans[-1]:
        ans.append(t)
        t = ""
print(len(ans)-1)
# Judge status: Accepted
n,a,b=map(int,input().split())
ca,cb=0,0
s=input()
for i in range(n):
    if s[i]=="a":
        if ca<a+b:
            print("Yes")
            ca+=1
        else: print("No")
    elif s[i]=="b":
        if ca<a+b and cb<b:
            print("Yes")
            ca+=1;cb+=1
        else: print("No")
    else: print("No")
# Judge status: Accepted
from itertools import accumulate

N, *A = map(int, open(0).read().split())

S = list(accumulate(A))

ans = 1
cur = 1
for a, s in zip(A, S):
    if (cur := min(2 * (cur - a), S[-1] - s)) < 0:
        print(-1)
        quit()

    ans += cur

print(ans)
# Judge status: Accepted
#!/usr/bin/env python3
import sys


def solve(S: str):
    print("ABC" if S == "ARC" else "ARC")
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()
# Judge status: Accepted
s = str(input())
for i in range(len(s)):
    if s[i] == "A":
        start = i + 1
        break
for j in range(len(s)):
    if s[j] == "Z":
        end = j + 1
print(end - start + 1)
# Judge status: Accepted
n = int(input())
c = list(input())

r_cnt = c.count('R')
w_cnt = c.count('W')

cnt = 0

for i in range(r_cnt):
    if c[i] == 'R':
        continue
    else:
        cnt += 1

print(cnt)
# Judge status: Accepted
a, b =input().split()
s = int(a + b)
ans = 'No'

for i in range(317):
  if i ** 2 == s:
    ans = 'Yes'
    break

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

n = int(input())
l0=2
l1 = 1
l = l0 + l1
for i in range(n-2):
    l0 = l1
    l1 = l
    l = l0 + l1
print(l)
# Judge status: Accepted
l = list(input())
for i in range(8):
  s = int(l[0])
  b = bin(i)[2:].zfill(3)
  op = ["", "", ""]
  for j in range(len(b)):
    if b[j] == "0":
      s += int(l[j+1])
      op[j] = "+"
    else:
      s -= int(l[j+1])
      op[j] = "-"
  if s == 7:
    print(l[0]+op[0]+l[1]+op[1]+l[2]+op[2]+l[3]+"=7")
    break
# Judge status: Wrong Answer
n=int(input())
lst=list(map(int, input().split()))

'''
lst=sorted(lst, reverse=True)
new=[lst[i]*(1/2)**(i+1) for i in range(n-1)]
print(sum(new)+lst[-1]*(1/2)**(n-1))
'''
total=0
for i in range(n-1):
    total+=lst[i]*(1/2)**(i+1)
print(total+lst[-1]*(1/2)**(n-1))
# Judge status: Accepted
x = int(input())
fivehundred = (x//500)*1000
five = ((x%500)//5) * 5
print(fivehundred + five)
# Judge status: Wrong Answer
X = input()
X = int(X)
cash = 100
count = 0
while cash < X:
    cash*=1.01
    count += 1
print(count)
# Judge status: Wrong Answer
s = input()
print("Yes" if s[2] == s[3] and s[4] == s[5] else "NO")
# Judge status: Accepted
# import bisect
# import copy
import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    A,B=map(int,input().split())
    print(A*B//fractions.gcd(A,B))


resolve()
# Judge status: Accepted
N=int(input())
L=(int, input().split())[1]
for i in range(N):
  L[i] = int(L[i])
a=sum(L)
b=max(L)
c=a-b
if c>b:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
x = list(input().split())

for i in range(5):
  x[i] = int(x[i])
  if x[i] == 0:
    print(i+1)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
can_root=1
ls=[1]
for i in range(n):
    if can_root<a[i]:
        print(-1);exit()
    can_root=(can_root-a[i])*2
    ls.append(can_root)
if can_root < a[-1]:print(-1);exit()
ans=a[-1]
start=a[-1]
for i in range(n)[::-1]:
    start+=a[i]
    ans+=min(ls[i],start)
print(ans)
# Judge status: Wrong Answer
S = input()
T = input()

max_count = 0
for start in range(len(T)):
    for end in range(start, len(T)):
        if T[start] == S[start]:
            if T[start:end+1] in S[start:-(len(T)-end)]:

                max_count = max(max_count, len(T[start:end+1]))

answer = len(T) - max_count
print(answer)
# Judge status: Accepted
n,k=map(int,input().split())
ans=0
for i in range(1,n+1):
    tp=i
    coin=0
    while k>tp:
        tp*=2
        coin+=1
    ans+=(1/n)*(1/2**coin)
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
S1 = A[0]
S2 = sum(A)-A[0]
B = [abs(S1-S2)]

for i in range(N-2):
  S1 += A[i+1]
  S2 -= A[i+1]
  B.append(abs(S1-S2))

print(min(B))
# Judge status: Accepted
# import sys
# input = sys.stdin.readline
import collections
import itertools

def main():
    n, k = input_list()
    a = input_list()
    b = n - 1
    x = k - 1
    ans = b // x
    if b % x == 0:
        print(ans)
    else:
        print(ans + 1)

def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()
# Judge status: Accepted
# -*- coding: <encoding name> -*-

X, Y = map(int,input().split())
print(X + Y // 2)
# Judge status: Accepted
N, L = map(int, input().split())
l = [L+i-1 for i in range(1,N+1)]
min = l[0]
for i in range(N):
    if abs(min) > abs(l[i]):
        min = l[i]
print(sum(l)-min)
# Judge status: Accepted
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#l = list(map(int, input().split()))

n = input()

if "7" in n:
    print ("Yes")
else:
    print ("No")
# Judge status: Accepted
N,A,B=map(int,input().split())
S=str(input())
M=A+B
K=0
Foreign=0
for j in S:
  if j=="c":
    print("No")
  else:
    if j=="a":
      K+=1
      if K<=M:
        print("Yes")
      else:
        print("No")
    else:
      Foreign+=1
      if Foreign<=B:
        K+=1
        if K<=M:
          print("Yes")
        else:
          print("No")
      else:
        print("No")
# Judge status: Accepted
A, B = map(int, input().split())

def kaibun(num) :
    num_str = str(num)
    for i in range((len(num_str)+1)//2) :
        if num_str[i] != num_str[-(i+1)] :
            return False
    return True

ans = 0

for i in range(A,B+1) :
    if kaibun(i) == True :
        ans += 1

print(ans)
# Judge status: Accepted
S = input()
T = input()
for i in range(len(S)):
  if S[-i:]+S[:-i] == T:
    print('Yes')
    exit()
print('No')
# Judge status: Accepted
'''
Created on 2020/08/17

@author: harurun
'''

import sys
pin=sys.stdin.readline
pout=sys.stdout.write
perr=sys.stderr.write

mod=1000000000000000000
A,B,C,K=map(int,pin().split())
if abs(A-B)>mod:
  print("Unfair")
elif K%2==0:
  print(A-B)
else:
  print(B-A)
# Judge status: Accepted
W, H, N = map(int, input().split())
minx, maxx = 0, W
miny, maxy = 0, H

for _ in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        minx = max(x, minx)
    elif a == 2:
        maxx = min(x, maxx)
    elif a == 3:
        miny = max(y, miny)
    elif a == 4:
        maxy = min(y, maxy)

width = max(0, maxx-minx)
height = max(0, maxy-miny)

print(width*height)
# Judge status: Accepted

def abc122_b():
    s = input()
    acgt = ['A', 'C', 'G', 'T']

    check = [1 if s[i] in acgt else 0 for i in range(len(s))]

    result = 0
    for i in range(len(check)):
        for j in range(i, len(check)):
            if check[i : j + 1].count(0) == 0:
                if result < len(check[i:j + 1]):
                    result = len(check[i:j + 1])

    print(result)

if __name__ == '__main__':
    abc122_b()
# Judge status: Accepted
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
li = sorted(rl(), reverse=True)
a = 0
b = 0
for i in range(n):
  if i & 1 == 0:
    a += li[i]
  else:
    b += li[i]
print(a-b)
# Judge status: Accepted
ABCD = input()
ans = ''
def dfs(i, s):
    global ans
    s += ABCD[i]
    if i == 3:
        if eval(s) == 7:
            ans = s
        return
    i += 1
    dfs(i, s+'+')
    dfs(i, s+'-')
dfs(0, '')
print(ans+'=7')
# Judge status: Wrong Answer
n = int(input())
k = int(input())
x = int(input())
y = int(input())

ans = 0
for i in range(n):
  if i <= k:
    ans += x
  else:
    ans += y
    
print(ans)
# Judge status: Accepted
N = int(input())
A = [int(x) for x in input().split(' ')]

left = [0] * N
right = [0] * N

for i, a in enumerate(A):
  if i - a >=0:
    right[i-a] += 1
  if i + a < N:
    left[i + a] += 1
#print(right)
#print(left)
ans = 0
for l, r in zip(left, right):
  ans += l*r
print(ans)
# Judge status: Wrong Answer
N, A, B = input().split()
count=0
for i in range(int(N)):
    if int(A) <= sum(map(int, N)) <= int(B):
        count+=1
print(count)
# Judge status: Wrong Answer
n, q = map(int, input().split())
s = input()

L = [0]*len(s)
for i in range(1,len(s)):
    L[i] = L[i-1]
    if s[i-1] == "A" and s[i] == "C":
        L[i] += 1


for _ in range(q):
    l, r = map(int, input().split())
    print(L[r-1]-L[l]+1)
# Judge status: Wrong Answer
import sys
a,b,c = map(int,input().split())
sum = 0
for i in range(1,100):
	sum += a*i
	if (sum)%b == c:
		print("YES")
		sys.exit()
print("NO")
# Judge status: Accepted
A=list(input())
from collections import deque
que=deque()
for i in A:
   if i=="T":
      if que==deque():
         que.append("T")
      elif que[-1]=="T":
         que.append("T")
      else:
         que.pop()
   else:
      que.append("S")
print(len(que))
# Judge status: Accepted
A, B, C, X, Y = map(int, input().split())

ans = 1000000007
for i in range(max(X, Y) + 1):
    i_C = 2 * i
    i_A = max(0, X - i)
    i_B = max(0, Y - i)
    #
    ans = min(ans, A * i_A + B * i_B + C * i_C)

print(ans)
# Judge status: Accepted
line = input()
rain_day = 0
k = 0
for wether in line:
  #当日雨
  if wether == "R":
    rain_day += 1
  #当日晴れ、前日は雨
  elif rain_day != 0:
    k = rain_day
    rain_day = 0
  #当日晴れ、前日も晴れ
  else:
    pass
if k > rain_day:
  print(k)
else:
  print(rain_day)
# Judge status: Accepted
K,X = map(int,input().split())
L = []
for i in range(X-K+1,X+K):
  L.append(i)
[print(i,end=' ') for i in L]
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
if n % 2 == 1:
    print(0)
else:
    n //= 2
    ans = 0
    while n:
        n //= 5
        ans += n
    print(ans)
# Judge status: Accepted
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  r = int(input())
  print(r**2)

if __name__=='__main__':
  main()
# Judge status: Wrong Answer
import sys
stdin = sys.stdin
import itertools

mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

N = ni()
A = list()
for _ in range(N):
    A.append(ni())
cnt = 0
s = sum(A)
for i in range(N-1):
    #print(A)
    ccnt = (A[i] + A[i+1]) //2
    A[i+1] -= max(0, ccnt*2 - A[i])
    A[i] = max(0, A[i]-ccnt*2)
    cnt += ccnt
#print(A)
#print(cnt)
print((s - sum(A))//2)
# Judge status: Accepted
a,b,c=map(int,input().split())
aa,bb,cc=a%2,b%2,c%2
def check(a,b,c):
    max_=max(a,b,c)
    ans=((max_-a)//2)+((max_-b)//2)+((max_-c)//2)
    return ans
if aa==bb==cc:
    print(check(a,b,c))
else:
    if aa==bb and aa!=cc:
        print(check(a+1,b+1,c)+1)
    elif cc==bb and aa!=cc:
        print(check(a,b+1,c+1)+1)
    else:
        print(check(a+1,b,c+1)+1)
# Judge status: Wrong Answer
import numpy as np

N = int(input())
W = input().split()

for i in range(N):
    W[i] = int(W[i])
min_w= 100000
for i in range(N-2):
    w1 = W[:i+1]
    w2 = W[i+1:]
    w1 = np.array(w1)
    w2 = np.array(w2)
    print(w1)
    print(w2)
    min_w = min(min_w, abs(np.sum(w2)-np.sum(w1)))

print(min_w)
# Judge status: Accepted
n=int(input())
print((n//2)*((n+2-1)//2))
# Judge status: Accepted
n = input()[-1]
if n in '24579':
    print('hon')
elif n in '0168':
    print('pon')
else:
    print('bon')
# Judge status: Wrong Answer
a,b,c,x,y=list(map(int,input().split()))
ans=0
if 2*c*max(x,y)<=a*x+b*y:
  ans+=2*c*max(x,y)
elif a+b>2*c:
  ans+=2*c*min(x,y)
  if x>y:
    ans+=a*(x-y)
  else:
    ans+=b*(y-x)
else:
  ans+=a*x+b*y
print(ans)
# Judge status: Wrong Answer
a,b=map(int,input().split())

c=[input() for i in range(b)]
sum=0
d=[]

for k in range(1,a+1):
    for j in range(b):
    
        sum=sum+c[j].split()[0].count(str(k))+c[j].split()[1].count(str(k))
    d.append(sum)
    sum=0
for m in d:
    print(m)
# Judge status: Accepted
import math

N=int(input())

ans=0
arr=[]

tmp=1

#print(int(math.sqrt(N))+5)

for i in range(int(math.sqrt(N))+5):
    tmp=1

    while N % ((i+2)**tmp) == 0:
        N=N / ((i+2)**tmp)
        #print((i+2)**tmp)
        ans+=1
        tmp+=1

    while N % (i+2) == 0:
        N = N // (i+2)

if N > 1 :
    ans+=1

print(ans)
# Judge status: Wrong Answer
list=[1, 1, 1, 1, 1]
for i in range(1, 7):
  list.append(6**i)
for j in range(1, 7):
  list.append(9**j)
sorted(list, reverse=True)
N=int(input())
count=0
for i in list:
  if i < N:
    N=N-i
    count+=1
  if i == N:
    count+=1
    print(count)
# Judge status: Wrong Answer
from scipy.special import comb
n, p, *A = map(int, open(0).read().split())
odd = sum(a%2 for a in A)
even = n - odd

if p:
  s = 0
  for i in range(1, odd, 2):
    s += comb(odd, i, exact=True)
  s *= pow(2, even)
  print(s)
else:
  s = 0
  for i in range(0, odd, 2):
    s += comb(odd, i, exact=True)
  s *= pow(2, even)
  print(s)
# Judge status: Wrong Answer
def count_up(d, cut):
    ABC = len([1 for i in d if i < cut])
    ARC = len(d) - ABC
    if ABC == ARC:
        return True
    return False

N = int(input())
d = list(map(int, input().split()))
counter = 0
for i in range(max(d)):
    if count_up(d, i):
        counter += 1
print(counter)
# Judge status: Wrong Answer
N = int(input())
NList = []
x = N
for i in range(3):
    NList.append(x % 10)
    x = x // 10
NList.sort()
for i in range(3):
    if N <= NList[i] * 111:
        print(NList[i] * 111)
        break
# Judge status: Accepted
N = int(input())
D = list(map(int, input().split()))
ans = 0
if not D[0] == 0 or not D.count(0) == 1:
    print(0)
else:
    co = [0] * (max(D)+1)
    for i in D:
        co[i] += 1
    ans = 1
    for i in range(2, max(D)+1):
        ans = ans * (co[i-1]**co[i]) % 998244353
    print(ans)
# Judge status: Accepted
import sys
from bisect import bisect_left, bisect_right

n, *l = map(int, sys.stdin.read().split())
l.sort()
ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        # i: 1番目に長い棒　j: 2番目に長い棒
        # 3番目に長い棒の条件 -> jよりも短く a<b+cよりa-bより大きい
        cnt = (n - 1) - j - bisect_right(l, l[-(i+1)] - l[-(j+1)])
        if cnt > 0:
            ans += cnt
print(ans)
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, x, *a = map(int, read().split())
memo = 0
cnt = 0
if a[0] > x:
    cnt += a[0] - x
    a[0] = x
for i in range(n - 1):
    if a[i + 1] > x:
        cnt += a[i + 1] - x
        a[i + 1] = x
    v = a[i] + a[i + 1] - memo
    if v > x:
        memo = v - x
    else:
        memo = 0
    cnt += memo
print(cnt)
# Judge status: Accepted
N,M,X,Y=map(int,input().split())
x=max(list(map(int,input().split())))
y=min(list(map(int,input().split())))
if max(X,x)+1<=min(y,Y):
  print("No War")
else:
  print("War")
# Judge status: Accepted
n,m,x,y=map(int,input().split())
xs=list(map(int,input().split()))
ys=list(map(int,input().split()))
x_=max(xs)
y_=min(ys)
for z in range(x_+1,y_+1):
    if x<z<=y:
        print('No War')
        exit()
print('War')
# Judge status: Wrong Answer
def test_cases(N, M):
  if N==M:
    return 'Yes'
  else:
    return 'No'
# Judge status: Accepted
S = input()

for i in range(len(S)-1):
    for j in range(i,len(S)):
        memo = S[:i]+S[j:]
        #print(memo)
        if memo == 'keyence':
            print('YES')
            exit()
print('NO')
# Judge status: Wrong Answer
w,h,n=map(int,input().split())
a=[[int(i)for i in input().split()]for j in range(n)]
S=[[0,w],[0,h]]
for i in a:
    if i[2]==1:
        S[0][0]=i[0]

    if i[2]==2:
        S[0][1]=i[0]

    if i[2]==3:
        S[1][0]=i[1]

    if i[2]==4:
        S[1][1]=i[1]

ans=max(0,(S[0][1]-S[0][0]))*max(0,(S[1][1]-S[1][0]))
print(ans)
# Judge status: Accepted
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

new_list = list()

for x in range(n):
    num = a[x]
    num_plus = num + 1
    num_minus = num - 1
    new_list.append(num_plus)
    new_list.append(num_minus)
    new_list.append(num)

d = dict(Counter(new_list))

print(max(d.values()))
# Judge status: Accepted
a, b = input().split()
if (int(a + b) ** 0.5).is_integer():
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import itertools

n = int(input())
p = tuple(map(int, input().split())) # 横入力
q = tuple(map(int, input().split())) # 横入力
seq = [0]*n
for i in range(1,n+1):
    seq[i-1] = i
nnn = list(itertools.permutations(seq, n))
print(abs(nnn.index(q) - nnn.index(p)))
# Judge status: Wrong Answer
n = int(input())
s = input()
res = 2000000 
for i in range(1,n):
	w = s.count('W',0,i)
	r = s.count('R',i)
	if (max(r,w) < res):
		res = max(r,w)

print(str(res))
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
count = 0
for i in A:
  if i//3 == 0 or i//5 == 0:
    count += 1
  else:
    count += 0
    
if count == N:
  print('APPROVED')
else:
  print('DENIED')
# Judge status: Wrong Answer
a,b,c, = map(int,input().split())
if a<b:
    if c<b:
        print("Yes")
    else:
        print("No")
else:
    if b<c:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()

ta = []
for i in range(n) :
  ta.append([t[i],1])

for i in range(n-k) :
  if ta[i][0] == ta[i+k][0] and ta[i][1] == ta[i+k][1]: 
    ta[i+k][1] = 0

ans = 0
for i in range(n) :
  if ta[i][1] == 1 :
    if ta[i][0] == 'r' :
      ans += p
    if ta[i][0] == 's' :
      ans += r
    if ta[i][0] == 'p' :
      ans += s

print(ans)
# Judge status: Accepted
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()

if n < 1000:
    print('ABC')
else:
    print('ABD')
# Judge status: Accepted
def main():
    from collections import Counter

    MOD = 10 ** 9 + 7

    N = int(input())
    S = input()

    ctr = Counter(S)

    ret = 1
    for count in ctr.values():
        ret = (ret * (count + 1)) % MOD
    print(ret - 1)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
h, a = map(int, input().split(" "))
print((h // a) + 1)
# Judge status: Wrong Answer
import math

H,W = map(int,input().split())

print(math.ceil(H*W/2))
# Judge status: Accepted
L,R,d = map(int,input().split())

cnt = 0
for i in range(L,R+1):
  if i%d == 0:
    cnt += 1
    
print(cnt)
# Judge status: Accepted
N=int(input())
print(len(range(1,N+1,2))/N)
# Judge status: Accepted
import math
n, d = map(int, input().split())
l = []
for i in range(n):
    l.append(list(map(int, input().split())))
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        sum  = 0
        if i != j:
            for k in range(d):
                sum += (l[i][k] -l[j][k]) ** 2
            dis = math.sqrt(sum)
            if dis % 1 == 0:
                ans += 1
print(ans)
# Judge status: Accepted

N = int(input())
K = int(input())
X = int(input())
Y = int(input())

if N <= K:
    print(N * X)
else:
    print(K * X + (N-K) * Y)
# Judge status: Accepted
import math

N = int(input())

def factortwo(N):
    factors = []
    for i in range(1, int(math.sqrt(N))+1):
        if N % i == 0:
            factors.append((i, N // i))
    return factors

print(sum(factortwo(N)[-1]) - 2)
# Judge status: Accepted
import sys
readline = sys.stdin.readline

N = int(readline())
A = list(map(int,readline().split()))

# 最も大きい数と、その1/2との差が最も小さい数を選ぶ
A = sorted(A, reverse = True)
one = A[0]
diff = one
ans = -1
for i in range(1,len(A)):
  if abs(one / 2 - A[i]) < diff:
    diff = abs(one / 2 - A[i])
    ans = A[i]
    
print(one, ans)
# Judge status: Accepted
import sys

def resolve():
    x=int(input())
    i=1
    while 1:
        for j in range(i):
            if x==i**5-j**5:
                print(i,j)
                sys.exit()
            elif x==i**5+j**5:
                print(i, -1*j)
                sys.exit()
        i+=1
resolve()