peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
n,k=map(int,input().split())
A=list(map(int,input().split()))

C=[]
c=0
mina=min(A)
for i in range(len(A)):
    if mina==A[i]:
        C.append(c)
        c=0
    else:
        c+=1
C.append(c)

ans=0
for i in range(len(C)):
    ans += (C[i]+k-2)//(k-1)

print(ans)
# Judge status: Accepted
N, M = map(int, input().split())

def divisible(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors

div = divisible(M)

div = [d for d in div if d <= M / N]

print(max(div))
# Judge status: Accepted
N = int(input())
S = [int(input()) for _ in range(N)]

p = []
for v in S:
    if (v % 10 != 0):
        p.append(v)

if (len(p) == 0):
    print(0)
    exit()

minimum = min(p)
if (sum(S) % 10 != 0):
    print(sum(S))
    exit()

print(sum(S) - minimum)
# Judge status: Accepted
n = int(input())
ans = 0
for i in range(1,n+1):
    if len(str(i)) % 2 ==1:
        ans+=1
print(ans)
# Judge status: Accepted
N, A, B = map( int, input().split() )
MOD = 10 ** 9 + 7

def comb( n, r ):
  c = 1
  m = 1
  r = min( r, n - r )
  for i in range( r ):
    c = ( c * ( n - i )) % MOD
    m = ( m * ( i + 1 )) % MOD 
  return c * pow( m, MOD - 2, MOD ) % MOD

n = pow( 2, N, MOD ) - 1
a = comb( N, A )
b = comb( N, B )
print(( n - a - b ) % MOD )
# Judge status: Wrong Answer
l = int(input())
l1 = l // 3
l2 = (l - l1) // 2
l3 = l - l1 - l2
print(l1 * l2 * l3)
# Judge status: Accepted
n,y = map(int,input().split())
for i in range(n+1):
  for j in range(n+1-i):
    if y==i*10000+j*5000+(n-i-j)*1000:
      print(i,j,(n-i-j))
      exit()
print('-1 -1 -1')
# Judge status: Accepted
N = int(input())
D = list(map(int, input().split(" ")))
mod = 998244353

count = [0 for i in range(N)]
for i in range(N):
    count[D[i]] += 1
max_dist = max(D)
ans = count[0]

for i in range(1, max_dist + 1):
    ans *= (count[i - 1] ** count[i]) % mod
    ans %= mod

if count[0] > 1 or D[0] != 0:
    ans = 0

print(ans % 998244353)
# Judge status: Accepted
n=int(input())
x=list(map(int,input().split()))

for i in range(n):
    x[i]-=1

cost=[0]*100

for i in range(100):
    tai=0
    for j in range(n):
        tai+=(i-x[j])**2
    cost[i]=tai

print(min(cost))
# Judge status: Accepted
s = input()

if s =="ABC":
    print("ARC")
elif s == "ARC":
    print("ABC")
# Judge status: Accepted
s = list(input())
cnt = 0
for i in range(3):
    if(s[i]=='1'):
        cnt += 1
print(cnt)
# Judge status: Wrong Answer
l,r,d = (int(i) for i in input().split())
z = int(r/d-l/d)
if l%d == 0:
	print(z+1)
else:
	print(z)
# Judge status: Accepted
a, b, c = map(int, input().split())

if a<=c<=b:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    S = input().strip()
    T = input().strip()

    cnt = float("inf")
    for i in range(len(S) - len(T)):
        tmp = 0
        for j in range(len(T)):
            if S[i + j] != T[j]:
                tmp += 1

        cnt = min(cnt, tmp)

    print(cnt)




if __name__ == '__main__':
    main()
# Judge status: Accepted
import sys
import math
import bisect

def main():
    n = int(input())
    A = [2, 1]
    while len(A) - 1 < n:
        A.append(A[-2] + A[-1])
    print(A[n])

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
from collections import Counter

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

count = 0

for i, j in Counter(a).items():
    print(i, j, j-i, j)
    if j-i < 0:
        count += j
    else:
        count += min(j-i, j)

print(count)
# Judge status: Wrong Answer
N, D = map(int, input().split())
total = 0

for i in range(N):
    x, y = map(int, input().split())
    d = (x**2 + y**2)**.5
    if d >= D:
        total += 1

print(total)
# Judge status: Accepted
n=int(input())
print(n//2*(n-n//2))
# Judge status: Accepted
l = list(map(int, input().split()))

five = 0
seven = 0

for i in l:
  if i == 5:
    five += 1
  elif i == 7:
    seven += 1
if five ==2 and seven ==1:
  print("YES")
else:
  print("NO")
# Judge status: Accepted
N = int(input())
mn=10**8
for A in range(1,N):
    B=N-A
    sm=0
    while A!=0:
        sm+=A%10
        A//=10
    while B!=0:
        sm+=B%10
        B//=10
    if mn>sm:
        mn=sm
print(mn)
# Judge status: Accepted
n, k = map(int, input().split())
nn = set(range(1,n+1))

for i in range(k):
    input()
    a = set(map(int, input().split()))
    nn -= a

print(len(nn))
# Judge status: Wrong Answer
n,k=map(int,input().split())
#表で得点2倍、ウラで0
#0かKで終わり
cnt=0
ans=0
j=2
t=k
for i in range(min(n,k)):
    while t//j>=1:
        t=t//j
        cnt+=1 #kがある数j-1で割れる回数
    j+=1
    t=k
    ans+= 1/3*(0.5)**(cnt+1)
    cnt=0
print(ans)
# Judge status: Wrong Answer
import numpy as np
#入力
N, K = map(int, input().split())
li = list(map(int,input().split()))
list.sort(li, reverse = True)

#出力
a = list(np.zeros(K))
if N - K>0:
    b = list(np.ones(N-K))
    a.extend(b)
else:
    a = list(np.zeros(N))

print(np.dot(a, li))
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
ha = pow(a, 0.5)
hb = pow(b, 0.5)
hc = pow(c, 0.5)
if ha + hb < hc:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
hight = A[0]
k = 0
for i in range(1, N):
  if hight > A[i]:
    k += (hight - A[i])
  else:
    hight = A[i]
print(k)
# Judge status: Accepted
a=input()

if a.islower()==True:
    print("a")

else:
    print("A")
# Judge status: Accepted
N = int(input())
A = [int(input()) for _ in range(N)]
ans = 0
for i in range(N):
    ans += A[i] // 2
    A[i] %= 2
    if i < N - 1:
        if A[i] * A[i + 1] > 0:
            ans += 1
            A[i] = 0
            A[i+1] -= 1
print(ans)
# Judge status: Accepted
n, m = map(int, input().split())
ps = [[0, 0] for i in range(n)]  
wa_count = 0
ac_count = 0
for i in range(m):
    input_p, input_s = input().split()
    if ps[int(input_p)-1][0] <= 0:
        if input_s == 'AC':
            ps[int(input_p)-1][0] += 1
        else:
            ps[int(input_p)-1][1] += 1
for i in ps:
    if i[0] == 1:
        ac_count += 1
        wa_count += i[1]

print(ac_count, wa_count)
# Judge status: Wrong Answer
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[0]*n
c=[0]*n
cnt=0
while cnt<101:
  cnt+=1
  for i in range(n):
    b[max(0,i-a[i])]+=1
    if i+a[i]<n-1:
      b[i+a[i]+1]-=1
    c[0]=b[0]
  for j in range(n-1):
    c[j+1]=c[j]+b[j+1]
  a=c
  b=[0]*n
  c=[0]*n
print(*a)
# Judge status: Accepted
#E
from collections import deque
import bisect
n = int(input())
a = [int(input()) for _ in range(n)]
result = deque()

for i in a:
    idx = bisect.bisect_left(result,i)
    if idx == 0:
        result.appendleft(i)
        
    else:
        result[idx-1] = i
        
print(len(result))
# Judge status: Accepted
N,K = map(int, input().split())
ans = 0
for i in range(K,N+1):
    ans += (N*i - i**2 + i +1)%(10**9 +7)
print(ans%(10**9 +7) +1)
# Judge status: Accepted
import collections
w = [i for i in input()]
c = collections.Counter(w)
ls = list(c.values())
for i in ls:
  if i % 2 != 0:
    print("No")
    exit()
print("Yes")
# Judge status: Accepted
import sys

N = int(sys.stdin.readline())
X = list(map(int, sys.stdin.readline().split()))

sort = sorted(X)
first = sort[N//2 - 1]
second = sort[N//2]

for i in range(N):
    if X[i] <= first:
        print(second)
    else:
        print(first)
# Judge status: Accepted
H = int(input())
W = int(input())
N = int(input())

co = 0
ans = 0

if H >= W:
    for i in range(W):
        co += H
        ans += 1
        if co >= N:
            break
else:
    for i in range(H):
        co += W
        ans += 1
        if co >= N:
            break

print(ans)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
k=sum(b)-sum(a)
p=0
for i in range(n):
    if a[i]>b[i]:
        p+=a[i]-b[i]
    else:
        p-=a[i]-b[i]//2
print('Yes' if k>=p else 'No')
#print(k)
# Judge status: Accepted
a,b,c = map(int,input().split())
print ("Yes") if a < c < b or b < c < a else print ("No")
# Judge status: Wrong Answer
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for a in range(A):
  for b in range(B):
    for c in range(C):
      if 500*a + 100*b + 50*c == X:
        count += 1
print(count)
# Judge status: Wrong Answer
n, m = map(int, input().split())
mizu = [1]*n
iro = [1] + [0]*(n-1)
for i in range(m):
    x, y = list(map(lambda tmp: tmp-1, map(int, input().split())))
    iro[y] = (iro[y]*mizu[y]+iro[x])/(mizu[y]+1)
    iro[x] = (iro[x]-1)/(mizu[x]-1+1e-5)
    mizu[x]-=1; mizu[y]+=1
    if mizu[x]==0:
        iro[x] = 0
print(sum(map(lambda x: int(bool(x)), iro)))
# Judge status: Wrong Answer
import math
k=int(input())
ans=0
if k==1:
  print(ans)
i=0
while True:
  k=math.floor(k/2)
  ans+=2**i
  i+=1
  if k<=1:
    print(ans)
    exit()
# Judge status: Accepted
N, K = map(int, input().split())
S = input()
S = S[:K-1]+S[K-1].lower()+S[K:]
print(S)
# Judge status: Accepted
N,M = map(int,input().split())
ans = []
if N%2:
    for i in range(N//2):
        ans.append((i+1, N-1-i))
else:
    m = N//2
    for i in range(m//2):
        ans.append((i+1, m-i))
    for i in range((m-1)//2):
        ans.append((m+i+1, N-1-i))
for a,b in ans[:M]:
    print(a,b)
# Judge status: Wrong Answer
S = 'Rainy'
if S == 'Sunny':
    print('Cloudy')

elif S == 'Cloudy':
    print('Rainy')

elif S == 'Rainy':
    print('Sunny')
# Judge status: Accepted
input()

cur = 0
max_value = 0
for c in input():
  x = 1 if c == 'I' else -1
  cur += x
  max_value = max(max_value, cur)
  
print(max_value)
# Judge status: Accepted
A, B, C, D = map(int, input().split())
ans = 'Yes'
while True:
    C -= B
    if C <= 0:
        break

    A -= D
    if A <= 0:
        ans = 'No'
        break

print(ans)
# Judge status: Accepted
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    n = II()
    dd = [MII() for i in range(n)]
    cnt = 0
    for d1, d2 in dd:
        if d1 != d2:
            cnt = 0
        else:
            cnt += 1
        if cnt == 3:
            print('Yes')
            return
    print('No')

if __name__ == '__main__':
    main()
# Judge status: Accepted
a, b, c, d = map(int, input().split())
print(max([a*c, a*d, b*c, b*d]))
# Judge status: Accepted
a,b,c=map(int, input().split("/"))
if a<2019 or a<=2019 and b<=4 and c<=30:
  print("Heisei")
else:
  print("TBD")
# Judge status: Wrong Answer
n = int(input())
h = list(map(int,input().split()))
i = 1

while i < n:
    if h[i] < h[i-1]:
        h[i-1] -= 1
    elif h[i] > h[i-1]:
        h[i] -= 1
    else:
        pass

    i += 2

l = list(h)
l.sort()
if h == l:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
s= str(input())

for i in range(len(s)):
    if (i+1)%2==1:
        if s[i] not in "RUD":
            print('No')
            exit(0)
        else:
            pass
    else:
        if s[i] not in "LUD":
            print('No')
            exit(0)
        else:
            pass
print("Yes")
# Judge status: Accepted
N, M, K= map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))

Asum=[0]
Bsum=[0]

for i in range(N):
    Asum.append(Asum[-1]+A[i])
        
for i in range(M):
    Bsum.append(Bsum[-1]+B[i])
    
m=0
j=M

for i in range(len(Asum)):
    if Asum[i]>K:
        break
    while Asum[i]+Bsum[j]>K:
        j-=1
    if m<i+j:
        m=i+j
        
print(m)
# Judge status: Accepted
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = list(input())
score = 0
for i in range(N):
    if(T[i]=="r"):
        score +=P
    elif(T[i]=="s"):
        score +=R
    elif(T[i]=="p"):
        score +=S
    if(i <= N-K-1):
        if(T[i]==T[i+K]):
            T[i+K] = "0"
print(score)
# Judge status: Accepted
n,m=map(int,input().split())
a=[0]*m
for _ in range(n):
    b=list(map(int,input().split()))
    for i in b[1:]:
        a[i-1]+=1
print(sum(x==n for x in a))
# Judge status: Wrong Answer
a,b=map(int,input().split())
if round(b/4)<=a and b//2>=a:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
N = input()
cnt = 0
n = len(N)
flg = 0
for i,d in enumerate(N):
    if int(d) == 9:
        cnt += int(d)
    else:
        if i == 0:
            cnt += int(N[i])-1 
            cnt += 9 * (n-i-1)
            break
        else:
            cnt += int(N[i-1])-1 
            cnt += 9 * (n-i-1)
            break
print(cnt)
# Judge status: Wrong Answer
N=int(input())
x=2*N
for i in range(1,N//2):
    if N%i==0:
        x=min(x,i+N//i)
print(x-2)
# Judge status: Wrong Answer
A, B = map(int, input().split())
if A == B:
    print("Draw")
elif A == 1:
    print("Alice")
elif B == 1:
    print("Bod")
else:
    print("Alice" if A >B else "Bob")
# Judge status: Accepted
N = int(input())
prev = input()
said = {prev}
for _ in range(1, N):
    now = input()
    if now not in said and prev[-1] == now[0]:
        said.add(now)
        prev = now
        continue
    print("No")
    break
else:
    print("Yes")
# Judge status: Accepted
a=list(map(int,input().split()))
a=set(a)
print(len(a))
# Judge status: Accepted
import heapq

N,M=map(int,input().split())
jobs=[[] for i in range(M)]

for i in range(N):
  a,b=map(int,input().split())
  if a>M:
    continue
  else:
    jobs[M-a].append(b)
ans=0
l=[]
for i in range(M-1,-1,-1):
  for j in jobs[i]:
    heapq.heappush(l,-j)
  if len(l):
    ans+=-heapq.heappop(l)
print(ans)
# Judge status: Accepted
import heapq
n,m=map(int,input().split())
a=list(map(lambda x:int(x)*(-1),input().split()))

heapq.heapify(a)
for i in range(m):
    mx=heapq.heappop(a)
    heapq.heappush(a, (-1)*(-mx//2))

print(-sum(a))
# Judge status: Accepted
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)

x, y, z = list(map(int, input().split()))

print((x-z)//(y+z))
# Judge status: Wrong Answer
# For taking integer inputs.
import math


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


x, y = invr()

a = y // x

res = int(math.log(a) // math.log(2)) + 1
print(res)
# Judge status: Wrong Answer
def main():
    M, N = map(int, input().split())
    A = list(map(int, input().split()))
    votes = sum(A)//(4*M)
    count = 0
    for i in A:
        if i >= votes:
            count += 1
    print("Yes") if count >= N else print("No")


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n = int(input())
num = 0
count = 0
a_list = []

for i in range(n):
    a = int(input())
    a -= 1
    a_list.append(a)

if a_list.count(1) == 0:
    print(-1)
    exit()

for i in range(n):
    count += 1
    num = a_list[num]
    if num == 1:
        break

print(count)
# Judge status: Accepted
n, m = map(int, input().split())
if n % 2 == 1:
    tmp = n
    for i in range(1, m+1):
        print(i, tmp)
        tmp -= 1
else:
    tmp = n
    for i in range(1, m+1):
        print(i, tmp)
        if tmp - i == n//2 + 1:
            tmp -= 2
        elif tmp - i == n//2 + 2:
            tmp -= 2
        else:
            tmp-= 1
# Judge status: Accepted
n = input()
for i in n:
  if i is '9':
    print('Yes')
    exit()
print('No')
# Judge status: Accepted
def main():
    string = input()
    target = input()
    result = False
    for _ in range(len(target)):
        if string == target:
            result = True
            break
        string = string[-1] + string[:-1]
    if result:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()
# Judge status: Accepted
import math
def is_square(N):
    return math.sqrt(N) - int(math.sqrt(N)) == 0

def get_divisor_count(N):
    divisor_count = 0
    for i in range(1,int(math.sqrt(N))+1):
        if N%i == 0:
            divisor_count += 1
    return divisor_count*2 if is_square(N) == False else divisor_count*2 - 1
if __name__ == "__main__":
    N = int(input())
    count = 0
    for i in range(1,N+1,2):
        if get_divisor_count(i) == 8:
            count += 1
    print(count)
# Judge status: Wrong Answer
N = int(input())
ans = 0
now = - float('inf')
for _ in range(N):
    a = int(input())
    if a <= now:
        ans += 1
    now = a

print(ans)
# Judge status: Accepted
k,s= [int(i) for i in input().split()]

x=0
j=0

for j in range(k+1):
	if s-j<=k and s-j>=0:
		x=x+s-j+1
	elif (s-j)<=2*k and s-j>=0:
		x=x+(2*k-(s-j)+1)

print(x)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))

b = [-1] * n
l = 0
r = n-1
for i in range(n-1, -1, -1):
    if i % 2:
        b[l] = a[i]
        l += 1
    else:
        b[r] = a[i]
        r -= 1

if n % 2:
    b.reverse()
b = [str(i) for i in b]
print(' '.join(b))
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
a.sort()

l=a[0]
r=a[-1]

ans=float('inf')
for pin in range(l,r+1):
  cnt=0
  for i in range(n):
    cnt+=(a[i]-pin)**2
    
  ans=min(ans,cnt)
  
print(ans)
# Judge status: Wrong Answer
S = list(input())
if S[2] == S[3] and S[4] == S[5]:
    print("Yse")
else:
    print("No")
# Judge status: Accepted
k, x = map(int, input().split())

if k >= x / 500:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
s = int(input())
if s%10 == 7:
    print("Yes")
elif int(s/10)%10 == 7:
    print("Yes")
elif int(int(s/10)/10)%10 == 7:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
AB, BC, CA = map(int, input().split())

print(AB*BC//2)
# Judge status: Accepted
# -*- coding: utf-8 -*-
N,A,B=map(int, raw_input().split())
if N==1:    #整数が1個のとき
    if A!=B:    #minとmaxが異なる場合はない
        print 0
    else:
        print 1
else:   #整数が2個以上のとき
    if B<A:
        print 0
    elif B==A:
        print 1  
    elif A<B:
        print A+B+B*(N-2)-(A+B+A*(N-2))+1
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

dic1 = {}
dic2 = {}

sum = 0

for i in range(N):
    v = i-A[i]
    if v < 0:
        continue
    if not v in dic1:
        dic1[v] = 0
    dic1[v] += 1

for i in range(N):
    v = i+A[i]
    if not v in dic2:
        dic2[v] = 0
    dic2[v] += 1


for k, v in dic1.items():
    if not k in dic2:
        continue
    sum += dic1[k]*dic2[k]

print(sum)
# Judge status: Wrong Answer
n=int(input())
l=sorted(list(map(int,input().split())))
print(l[n//2]-l[n//2-1]-1)
# Judge status: Accepted
A, B, C = map(int,input().split())

if C >= A and C <= B:
  print("Yes")
  
else:
  print('No')
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))
m = A[0]
ans = 0
for a in A[1:]:
    m = max(m,a)
    if m > a:
        ans += m-a
print(ans)
# Judge status: Accepted
s=input()
ans=[]
for i in s:
    if i!="B":
        ans.append(i)
    else:
        ans=ans[:-1]
        
print("".join(ans))
# Judge status: Wrong Answer
N=int(input())
A=int(input())
check=N-N%500
print("Yes" if check<=A else "No")
# Judge status: Wrong Answer
n, k = map(int, input().split())
r, s, p = map(int, input().split())
S = input()
pt = []
for i in range(n):
    if S[i]=='r': t = p
    elif S[i]=='s': t = r
    else: t=s
    pt.append(t)
for i in range(n-k):
    if pt[i]==pt[i+k]:
        pt[i+k]=0
print(sum(pt))
# Judge status: Accepted
n = int(input())
xl_lis = []
for i in range(n):
    xl_lis.append(list(map(int, input().split())))
fe_lis = []

for x, l in xl_lis:
    fe_lis.append([x - l, x + l])
fe_lis.sort(key = lambda x:x[1])        
curr = float("-inf")
cnt = 0
for f, e in fe_lis:
    if curr <= f:
        cnt += 1
        curr = e
print(cnt)
# Judge status: Accepted
# coding: utf-8


def main():
    N = int(input())
    A = sorted(list(map(int, input().split())))
    ans = sum([A[i] for i in range(3*N-2, N-1, -2)])

    print(ans)

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
N=int(input())
A=[]
B=[]
for i in range(N):
    a=int(input())
    A.append(a)
    B.append(a)
if B.count(max(B))==1:
    B.remove(max(B))
    b=max(B)
else:
    b=max(B)
print(A)
for j in range(N):
    if A[j]==max(A):
        print(b)
    else:
        print(max(A))
# Judge status: Accepted
n=int(input())
h=list(map(int,input().split()))
ans=0
kari=0
for i in range(n-1):
        if h[i+1]<=h[i]:
            kari+=1
        else:
            if ans<kari:
                ans=kari
            kari=0
        
       
print(max(ans,kari))
# Judge status: Wrong Answer
from itertools import permutations

s = int(input())

alist = [int(x) for x in input().split(maxsplit=(s-1))]
blist = [int(x) for x in input().split(maxsplit=(s-1))]

if alist == blist:
    print(0)

perm = permutations(sorted(alist))

count = 1
a = 0
b = 0

for i in list(perm):
    if alist == list(i):
        a = count
        pass
    elif blist == list(i):
        b = count
        pass
    count += 1

print(abs(a-b))
# Judge status: Accepted
ans = 100
H = int(input())
W = int(input())
N = int(input())

for i in range(H+1):
    for j in range(W+1):
        if i * W + j * H - i * j >= N:
            ans = min(ans, i+j)

print(ans)
# Judge status: Accepted
n = int(input())
h = list(map(int,input().split()))
ans = 0
running = 0
for i in range(1,n):
  if h[i] <= h[i-1]:
    running += 1
  else:
    ans = max(ans, running)
    running = 0
ans = max(ans, running)
print(ans)
# Judge status: Accepted
# coding: utf-8
from functools import reduce

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

def nCr(n, r):
    r = min(n-r, r)
    if r == 0: return 1
    numer = reduce(lambda x, y: x * y % mod, range(n, n - r, -1))
    denom = reduce(lambda x, y: x * y % mod, range(1, r + 1))
    return numer * pow(denom, mod - 2, mod) % mod

mod = 10 ** 9 + 7

tnmo = pow(2, n, mod) - 1
an = nCr(n, a)
bn = nCr(n, b)
ans = (tnmo - an - bn) % mod

print(ans)
# Judge status: Accepted
N, Y = map(int, input().split())
flag = False
for x in range(N + 1):
    for y in range(0, N - x + 1):
        if 10000 * x + 5000 * y + 1000 * (N - x - y) == Y:
            print(x, y, N - x - y)
            flag = True
            exit()
if (not flag): print("-1 -1 -1")
# Judge status: Accepted
from itertools import accumulate
n,x = map(int, input().split())
a = [0] + list(map(int, input().split()))
print(len([i for i in accumulate(a) if i < x+1]))
# Judge status: Accepted
a,b = map(int,input().split())
if a <= 8 and b <= 8:
    print('Yay!')
else:
    print(':(')
# Judge status: Accepted
s = int(input())
a = [s]
for i in range(1, 1000001):
    if a[i-1]%2 == 0:
        x = a[i-1]//2
        if x in a:
            print(i+1)
            break
        else:
            a.append(x)
    else:
        y = a[i-1]*3 + 1
        if y in a:
            print(i+1)
            break
        else:
            a.append(y)
# Judge status: Accepted
S=int(input())
c=S//3
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

f=0
for i in range(1,c+1):
    #i個の箱にansを分ける
    ans=S-3*i#振り分けるべき残りの数
    #ball ans個
    #i-1 仕切りの数
    #print(ans,i)
    f+=combinations_count(ans+i-1,i-1)
print(f%(10**9+7))
# Judge status: Accepted
a, b, c = map(int, input().split())

x = c - a - b

if x <= 0:
    print("No")

else:
    if 4 * a * b < x * x:
        print("Yes")
    else:
        print("No")
# Judge status: Wrong Answer
from math import factorial as f
S = int(input())

ans, MOD, N = 0, 1000000007, S // 3

if N == 0:
  print(0)
  exit()

for i in range(1, N+1):
  S -= 3
  if S == 0:
    ans += 1
    continue
  if i == 1:
    ans += 1
    continue
  ans += f(S + i - 1)

print(ans % MOD)
# Judge status: Accepted
N = int(input())
S = [input() for i in range(N)]
 
c0 = 0
c1 = 0
c2 = 0
c3 = 0
 
for i in range(N):
  if S[i] == 'AC':
    c0 += 1
  elif S[i] == 'WA':
    c1 += 1
  elif S[i] == 'TLE':
    c2 += 1
  elif S[i] == 'RE':
    c3 += 1
 
print('AC x %d' %c0)
print('WA x %d' %c1)
print('TLE x %d' %c2)
print('RE x %d' %c3)