peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
import bisect,copy,heapq,itertools,string
from collections import *
from math import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
s = LIST()
count = 0
for i in range(n):
        if s[i] == i+1:
                if i > 0 and s[i-1] == i:
                        continue
                else:
                        count += 1
        
print(count)
# Judge status: Wrong Answer
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T.sort()
time = T.pop(0)+K
people = 1
ans = 1
for t in T:
    if t <= time and people < C:
        people += 1
    else:
        if people == C:
            time += t
        else:
            time += K
        people = 0
        ans += 1
print(ans)
# Judge status: Wrong Answer
k=int(input())
l=list(map(int, input().split(' ')))
a=l[0]
b=l[1]

if (b-a)+1>=k:
    print('OK')
else:
    maybe=(a//k)*k
    ans=False
    while maybe<b:
        if maybe>=a:
            ans=True
            break
        else:
            maybe+=k
    if ans:
        print('OK')
    else:
        print('NG')
# Judge status: Accepted
n,k,*l=map(int,open(0).read().split())
for _ in range(k):
  s=[0]*(n+1)
  for i in range(n):
    s[max(i-l[i],0)]+=1
    s[min(i+l[i]+1,n)]-=1
  for i in range(n):
    s[i+1]+=s[i]
  s.pop()
  if s==l: break
  l=s
print(*l)
# Judge status: Accepted
n, m = map(int, input().split())
ans = ['t'] * n

for _ in range(m):
    s, c = map(int, input().split())
    if ans[s-1] =='t' or ans[s-1] == str(c):
        ans[s-1]= str(c)
    else:
        print(-1)
        exit(0)
if ans[0] == 't' and n >1:
    ans[0]=str(1)

ans = ''.join(ans).replace('t', str(0))
ans = int(ans)
l = str(ans)
if len(l) != n:
    print(-1)
else:
    print(ans)
# Judge status: Accepted
n = list(input())
if n[0]==n[1] and n[1]==n[2]:
  print('Yes')
elif n[1]==n[2] and n[2]==n[3]:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
import numpy as np

W, H, N = input().split()
commands = []
for i in range(int(N)):
  commands.append(input().split())
pic = np.zeros((int(W),int(H)))
for com in commands:
  x = int(com[0])
  y = int(com[1])
  a = int(com[2])
  if a==1:
    pic[:x,:] = 1
  if a==2:
    pic[x:,:] = 1
  if a==3:
    pic[:,:y] = 1
  if a==4:
    pic[:,y:] = 1

area = 0

for w in range(int(W)):
  for h in range(int(H)):
    if pic[w,h]==0:
      area += 1
      
print(area)
# Judge status: Accepted
c = map(int, input().split())
c = sorted(c)
ans = 'Yes' if c[0] + c[1] == c[2] else 'No'
print(ans)
# Judge status: Accepted
import sys

N = int(input())
if N == 1:
    print(0)
    sys.exit()

p= (-2*9**N+8**N+10**N) % (10**9+7)
print(p)
# Judge status: Accepted
# 2020/01/19

n,k,s=map(int,input().split())
if s==10**9:
    rest=10**9-1
else:
    rest=10**9
ans=[s]*k+[rest]*(n-k)
print(*ans)
# Judge status: Accepted
n = int(input())
 
x = n * 800
y = (n // 15) * 200
 
print(x - y)
# Judge status: Accepted
[N, Y] = list(map(int, input().split()))
flag = False
for i in range(0, N+1):
  if 10000*i > Y:
    break
  for j in range(0, N+1-i):
    k = N-i-j
    total = 10000*i + 5000*j + 1000*k
    if total == Y:
      print("{} {} {}".format(i, j, k))
      flag = True
      break
  if flag:
    break

if flag == False:
  print("-1 -1 -1")
# Judge status: Accepted
a,b = map(int,input().split())
s = input()
ans = ["0","1","2","3","4","5","6","7","8","9"]
ch1 = list(map(str,s[:a]))
if a > b:
    ch2 = list(map(str,s[a+b:]))
else:
    ch2 = list(map(str,s[a+1:]))
count = 0
for i in range(len(ch1)):
    if ch1[i] not in ans:
        count +=1
for j in range(len(ch2)):
    if ch2[j] not in ans:
        count += 1
if count == 0 and s[a] == "-":
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
ans = sum(A) - min(A)
print(ans)
# Judge status: Wrong Answer
N,K=map(int,input().split())
*p,= map(int, input().split())

def ex(n):
    return sum(range(1,n+1))/n    
def  ex3(p):
    return sum([ex(n) for n in p])

dp=[0 for _ in range(N)]

M,mi=0,0
for i in range(N-K+1):
    s=sum(p[i:i+K+1])
    if s>M:
        M=s
        mi=i
print(mi)
print(ex3(p[mi+1:mi+K+1]))
# Judge status: Wrong Answer
n,m= map(int, input().split())
a = list(map(int, input().split()))
print(n-sum(a))
# Judge status: Accepted
x=input().split()
h=int(x[0])
n=int(x[1])
import numpy as np
a=np.full(n,0,int)
b=np.full(n,0,int)
for k in range(n):
  x=input().split()
  a[k]=int(x[0])
  b[k]=int(x[1])
m=max(a)  
inf=10**8
dp=np.full(h+m+1,inf,int)
dp[0]=0
for k in range(1,h+m):
  dp[k]=(dp[k-a]+b).min()
print(dp[h:h+m].min())
# Judge status: Accepted
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

# 個数制限なしナップサック問題
W,N = map(int,readline().split())

dp = [INF]*(W+1)
dp[0] = 0

for i in range(N):
    w,v = map(int,readline().split())
    # dp[j] = 重さj以下でつくれる最大の価値
    for j in range(W+1):
        dp[j] = min(dp[j],dp[max(j-w,0)] + v)

print(dp[W])
# Judge status: Accepted
K = int(input())
even = K//2
odd = (K+1)//2
print(even*odd)
# Judge status: Accepted
def main():
    N = int(input())
    A = list(map(int, input().split()))

    for i in A:
        if i % 2 == 0:
            if i % 3 != 0 and i % 5 != 0:
                return ("DENIED")
    return ("APPROVED")

print(main())
# Judge status: Accepted
x = int(input())
xn = 0
i = 0
while xn < x:
    i += 1
    xn += i
print(i)
# Judge status: Wrong Answer
X,Y=map(int,input().split())
if 2*Y<=X or 2*X<=Y or not((2*Y-X)%3==0) or not((2*X-Y)%3==0):
  print(0)
else:
  A=(2*Y-X)//3
  B=(2*X-Y)//3
  k=1
  for i in range(A+1,A+B+1):
    k=(k*i)%1000000007
  j=1
  for i in range(1,B+1):
    j=(j*i)%1000000007
  l=(pow(j,1000000005,1000000007)*k)%1000000007
  print(l)
# Judge status: Wrong Answer
#aからｂの整数。
a,b = map(int,input().split())
count=0
for i in range(a,b):
    i = str(i)
    if i == i[::-1]:
        count +=1
    else :
        pass
print(count)
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
print(min(a*c,a*b,b*c))
# Judge status: Accepted
n=int(input())
A=list(map(int,input().split()))+[0]
c=0
for i in range(n):
  j=i+1
  a=A[i]
  if a==j:
    c+=1
    A[i]=A[i+1]
    A[i+1]=j
print(c)
# Judge status: Wrong Answer
X, K, D = map(int, input().split())

X= abs(X)
min_pos = X%D
min_neg = min_pos - D

if(X/D > K):
  print(X-D*K)
else:
  if(int(X/D)%2 == 0):
    print(min_pos)
  else:
    print(abs(min_neg))
# Judge status: Accepted
S = input()

ans = [""]
j = 0

for i in range(1, len(S) + 1):
    s = S[j:i]
    if s != ans[-1]:
        ans.append(s)
        j = i
    

print(len(ans) - 1)
# Judge status: Accepted
a,b=map(int,input().split())
if a==b:print(2*a)
else:print(max(a,b)*2-1)
# Judge status: Wrong Answer
from collections import Counter

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

l = []

for _ in range(M):
    a, b = input().split()
    l.append(str(a))
    l.append(str(b))

c = Counter(l)
c = sorted(dict(c).items(), key=lambda x:x[0])

"""
collections.Counterを使わない場合

alphabets = []

"""
for v in c:
    print(v[1])
# Judge status: Accepted
x = int(input())
d = 0
for j in range(10 ** 9):
	d += j
	if d >= x:
		print(j)
		exit()
# Judge status: Accepted
n = int(input())
a = sorted(list(map(int,input().split())),reverse = True)
use = []
flag = -1
for i in range(n):
  if flag == a[i]:
    use.append(a[i])
    flag = -1
  else:
    flag = a[i]
if len(use)<2:
  print(0)
else:
  use.sort(reverse =True)
  print(use[0]*use[1])
# Judge status: Accepted
X, Y = [int(i) for i in input().split()]
print(X + int(Y / 2))
# Judge status: Wrong Answer
N = int(input())
S = input()

# 単色のみの場合
if '.' not in S:
    print(0)
    exit()
elif '#' not in S:
    print(0)
    exit()

# それ以外
first_black = 0
white_count = 0
for i in range(N):
    if (S[i] == '.'):
        white_count += 1
    else:
        first_black = i
        break

remain_white = 0
for j in range(first_black, N):
    if S[j] == '.':
        remain_white += 1

print(remain_white)
# Judge status: Wrong Answer
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

A,B,C = I()
if C == A+B or C == A or C == B:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n = int(input())
monster_list = list(map(int, input().split()))
kill_mon = list(map(int, input().split()))

# 配列数を合わせる
kill_mon.append(0)

# 持ち越しパワーの初期化
killed_monster = 0
next_power = 0
for mons, kill in zip(monster_list, kill_mon):
    kill += next_power
    # 全力で倒す
    if mons >= kill:
        killed_monster += kill
        # 持ち越しパワーの初期化
        next_power = 0
    elif mons < kill:
        killed_monster += mons
        next_power = kill - mons
print(killed_monster)
# Judge status: Accepted
n = int(input())
arr = [int(x) for x in input().split()]

mxN = 10**18
if 0 in arr:
    print(0)
    exit()
    
mul = 1
for x in arr:
    mul*=x
    if mul > mxN:
        print(-1)
        exit()

print(mul)
# Judge status: Accepted
from collections import *
_=input()
c=Counter(input())
ans=1
for i in c.values():
    ans*=i+1
    ans%=10**9+7
print(ans-1)
# Judge status: Accepted
n,m,q = map(int,input().split())
arr = [list(map(int,input().split())) for i in range(q)]

ans  = 0
from itertools import combinations_with_replacement

for kumi in combinations_with_replacement(range(1,m+1),n):
    tmp = 0
    for ar in arr:
        if kumi[ar[1]-1]-kumi[ar[0]-1]==ar[2]:
            tmp+=ar[3]
    ans = max(ans,tmp)
print(ans)
# Judge status: Wrong Answer
n, m=map(int, input().split())

if n==1 and m==1:
    print(1)
elif n==1 and m!=1:
    print(m-2)
else:
    ans = (m-2)*(n-2)
    print(ans)
# Judge status: Accepted
K,A,B = map(int,input().split())
if B<=A+2 or K<=A-1:
    ans = 1+K
else:
    cnt = A-1
    ans = A
    while cnt<=K:
        k = min(ans//A,(K-cnt)//2)
        if k>=1:
            cnt += 2*k
            ans = ans-k*A + k*B
        else:
            ans += (K-cnt)
            break
print(ans)
# Judge status: Accepted
X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

a = sorted(P[:X] + Q[:Y])
ans = sum(a)

for i in range(min(X+Y, C)):
    if a[i] < R[i]:
        ans += R[i] - a[i]

print(ans)
# Judge status: Wrong Answer
sx, sy ,tx, ty = map(int,input().split())
momo=""
xz = abs(tx-sx)
yz = abs(ty-sy)
momo += "U" * yz + "R" * xz + "D" * yz + "L" * xz
momo += "L" * 1 + "U" * (yz+1) + "R" * (xz+1) + "D" * 1
momo += "R" * 1 + "D" * yz + "L" * 1 + "D" *1 + "L"*xz
print(momo)
# Judge status: Accepted
a, b = map(int, input().split())
if a*b%2 == 0:
  print("Even")
else:
  print("Odd")
# Judge status: Accepted
x,k,d = map(int,input().split())

min_p = abs(x)//d
min_n = min_p + 1
rest_p = abs(x)- d*min_p
rest_n = rest_p - d

if k < min_p:
  print(abs(x) - k*d)
elif (k-min_p) % 2 == 0:
  print(rest_p)
else:
  print(abs(rest_n))
# Judge status: Accepted
import numpy as np
mod=10**9+7
N=int(input())
A=np.array(list(map(int, input().split())))
ans=0
for i in range(60):
  b=np.count_nonzero(A>>i&1)
  ans+=(2**i)*b*(N-b)
  ans%=mod
  
print(ans)
# Judge status: Accepted
import sys

def resolve():
    D, N = list(map(int, input().split(" ")))
    if D == 0:
        if N == 100:
            print(101)
        else:
            print(N)
    if D == 1:
        if N == 100:
            print(100*101)
        else:
            print(100*N)
    if D == 2:
        if N == 100:
            print(10000*101)
        else:
            print(10000*N)    

if '__main__' == __name__:
    resolve()
# Judge status: Wrong Answer
N = int(input())
ans = 0
n = N
counter = []
for i in range(2, int(N**0.5) + 1):
  if n % i == 0:
    counter.append(1)
    n = n // i
    while n % i == 0:
      counter[-1] += 1
      n = n // i
for c in counter:
  a = 1
  while c - a >= 0:
    c -= a
    a += 1
    ans += 1
print(1 if ans == 0 else ans)
# Judge status: Accepted
N = int(input())
nowt = 0
nowx = 0
nowy = 0
for i in range(N):
  t, x, y = map(int, input().split())
  ti = t - nowt
  xi = x - nowx
  yi = y - nowy
  if ti < abs(xi) + abs(yi):
    print('No')
    exit()
  if ti%2 != (xi+yi)%2:
    print('No')
    exit()
  nowt = t
  nowx = x
  nowy = y
    
print('Yes')
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
c.append(0)
p = 0
ans = 0
for i in range(n):
    ans += b[a[i]-1]
    ans += p
    p = c[a[i]-1]
print(ans)
# Judge status: Accepted
s,w = map(int,input().split())
if s <= w:
  print('unsafe')
else:
  print('safe')
# Judge status: Wrong Answer
N = int(input())

kk_list = []

for a in range(1, 10):
    for b in range(1, 10):
        kk_list.append(a * b)

print(kk_list)

if N in kk_list:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import permutations
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N = int(input())
ans = 0
for a in range(1, N):
    ans += N // a
    if N % a == 0:
        ans -= 1
print(ans)
# Judge status: Accepted
S = input()
if S == "Sunny":
  print("Cloudy")
elif S == "Rainy":
  print("Sunny")
else:
  print("Rainy")
# Judge status: Accepted
a, b = map(int, input().split())
if a%2==0 or b%2==0:
  print('Even')
else:
  print('Odd')
# Judge status: Accepted
n = int(input())
s = input()
num = s.count("R")
L = s[:num]
ans = L.count("W")
print(ans)
# Judge status: Wrong Answer
n, m = map(int, input().split())
students = [list(map(int, input().split())) for i in range(n)]

targets = [list(map(int, input().split())) for i in range(m)]
x = 0
snumber = [(0, x)] * n
  
def md(s, t):
  d = abs(s[0] - t[0]) + abs(s[1] - t[1])
  return d

for i in range(n):
  x = 2 * 10 ** 8
  for j in range(m):    
    if x >= md(students[i], targets[j]):
      x = md(students[i], targets[j])
      snumber[i] = (j+1, md(students[i], targets[j]))
      
for i in range(n):      
  print(snumber[i][0])
# Judge status: Accepted
import itertools

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

if n == 1:
    if a == b:
        print(1)
    else:
        print(0)
elif n == 2:
    print(1)
elif n >= 3:
    if a > b:
        print(0)
    else:
        smin = a * n + (b-a)
        smax = b * n - (b-a)
        print(smax-smin+1)
# Judge status: Accepted



h1, m1, h2, m2, k =map(int, input().split())

ans = (h2-h1)*60+(m2-m1)-k
print(ans)
# Judge status: Accepted

def main():
    N = int(input()) 
    S = input() 
    maxv = 0
    for i in range(1,N-1):
        x = S[0:i]
        y = S[i:N]
        xl = list(set(x))
        yl = list(set(y))
        cnt = 0
        for xx in xl:
            cnt += yl.count(xx)
        maxv = max(maxv,cnt)
    
    print(maxv)






if __name__ == '__main__':
    main()
# Judge status: Accepted
def gcd(m,n):
    while (m % n != 0):
        n,m = m%n,n
    return(n)


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

g = a[0]
for i in range(1,n):
    g = gcd(g,a[i])
print(g)
# Judge status: Accepted
a,b,c=map(int,input().split())
x=max(a,b,c)
print(9*x+a+b+c)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
if len(set(a)) == len(a):
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
n, k = map(int, input().split())
l = list(map(int, input().split()))
if sum(l) == len(l):
  print(0)
else:
  print((n+k-1)//k)
# Judge status: Accepted
s = input()

ans = ((len(s)-1)//2)*2

while True:
  if s[0:ans//2] == s[ans//2:ans]:
    break
  ans -= 2

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

list1=list(map(int,input().split()))
list2=list(map(int,input().split()))

t=sum(list2)
M=list1[0]+t
s=list1[0]

for i in range(1,N):
  s=s+list1[i]
  t=t-list2[i-1]
  M=max(M,s+t)
  
print(M)
# Judge status: Accepted
n,k = map(int, input().split())
a = list(map(int, input().split()))

for i in range(k,n):
  if a[i] > a[i - k]:
    print("Yes")
  else:
    print("No")
# Judge status: Accepted
a, b = map(int, input().split())
print("".join(sorted([input() for _ in range(a)])))
# Judge status: Wrong Answer
a, b = map(int, input().split())
zero = (a == 0 | b == 0) | (a < 0 and 0 < b) | (b < 0 and 0 < a)
negative_a = (a < 0 and 0 < b) and (a + b + 1) % 2 != 0
negative_b = (a < 0 | 0 < b) | (b < 0 | 0 < a)
if zero:
    print("Zero")
elif negative_a | negative_b:
    print("Negative")
else:
    print("Positive")
# Judge status: Accepted
X, Y, Z = input().split()

print(Z + " " + X + " " + Y)
# Judge status: Accepted
N = int(input())
D = sorted([int(i) for i in input().split()])
print(D[N//2]-D[N//2-1])
# Judge status: Wrong Answer
s = list(input())
j= 0
count = 0
if not s[0] == 'A':
    print('WA')
    exit()

for i in s[2:-1]:
    if i == 'C':
        count += 1
        tmp = j
    j += 1
if not count == 1:
    print('WA')
    exit()

del s[0]
del s[tmp-1]
s = ''.join(s)
if s.isupper():
    print('WA')
    exit()

print('AC')
# Judge status: Accepted
import fileinput

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

if a >= k:
    print(a - k, b)
else:
    print(0, max(0, b - (k - a)))
# Judge status: Accepted
def resolve():
	n = input()
	c = [False] * 8
	p = 0
	for i in list(map(int, input().split())):
		if i >= 3200:
			p += 1
		else:
			c[i//400] = True
	print(sum(c) or 1, sum(c) + p)
resolve()
# Judge status: Accepted
s = set([])
for i in range(int(input())):
  s.add(input())
print(len(s))
# Judge status: Wrong Answer
H, W = map(int, input().split())
if H*W % 2 != 0:
    print(H*W//2+1)
else:
    print(H*W//2)
# Judge status: Wrong Answer
n = int(input())

AB = []
for i in range(n):
    ab = list(map(int, input().split()))
    AB.append(ab)

ans = 0
for [a,b] in AB[::-1]:
    if a%b == 0:
        pass
    else:
        quo = (ans +a)//b
        ans = (quo+1)*b - a

print(ans)
# Judge status: Accepted
l = []
l.append(int(input().rstrip()))
l.append(int(input().rstrip()))
print(6 - sum(l))
# Judge status: Accepted
from collections import deque
from bisect import bisect_left

def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    d = deque([])
    d.append(A[0])
    for i in range(1,N):
        p = bisect_left(d, A[i])
        if p == 0:
            d.appendleft(A[i])
        else:
            d[p-1] = A[i]

    print(len(d))


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
X = int(input())

a = X // 500
b = (X % 500) // 5

print(a+b)
# Judge status: Accepted
N = int(input())
ans = 0
for i in range(1,N+1):
    if not (i%3 == 0 or i%5 == 0):
        ans += i
print(ans)
# Judge status: Wrong Answer
n = int(input())
s = input()
al = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
str = ""
for i in range(len(s)):
  str += al[(al.find(s[i])+1+1)%26]
print(str)
# Judge status: Wrong Answer
S = list(input())
prev = S[0]
ans = True
for s in range(1, 4):
    if s == prev:
        ans = False
    prev = s
print("Good" if ans else "Bad")
# Judge status: Accepted
import math

n = int(input())

ans = 0
for i in range(1, n+1):
    if i % 2 != 0:
        prime_num = 0
        for j in range(1, n+1):
            if i % j == 0:
                prime_num += 1
        if prime_num == 8:
            ans += 1

print(ans)
# Judge status: Wrong Answer
a=[int(i) for i in input().split()]
if a[0]==sum(a[1:]) or sum(a[:2])==a[2]:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
cands = [1, 2, 3, 4, 5, 6, 7, 8, 9]

def add_v(v):
  global cands
  global K
  v = str(v)
  v0 = int(v[-1])
  if v0 == 0:
    cands += [int(v+'0'), int(v+'1')]
    K -=2
  elif v0 == 9:
    cands += [int(v+'8'), int(v+'9')]
    K -= 2
  else:
    cands += [int(v+str(v0-1)), int(v+str(v0)), int(v+str(v0+1))]
    K -= 3

K = int(input())
idk = K
K -= 9
idx = 0
while K >= 0:
  add_v(cands[idx])
  idx += 1

print(cands[idk-1])
# Judge status: Accepted
import collections
n,k=map(int,input().split())
a=list(map(int,input().split()))

c=collections.Counter(a)
values = sorted(c.values())

ans=0
sum_values=len(values)
for i in range(len(values)):
    if sum_values<=k:
        break
    else:
        sum_values-=1
        ans+=values[i]
print(ans)
# Judge status: Wrong Answer
S=input()

acgt=["A","C","G","T"]

max_length = 0
length = 0
for word in S:
    if word in acgt:
        length+=1
    else:
        if length!=0:
            if max_length<length:
                max_length=length
            length=0
print(max_length)
# Judge status: Accepted
n = int(input())
w = []
for i in range(n):
    tmp = input()
    w.append(tmp)

ans = True
for i in range(1, n):
    if w[i][0] != w[i-1][len(w[i-1])-1]:
        ans = False
        break
    else:
        for j in range(0, i):
            if w[j] == w[i]:
                ans = False
                break

if ans:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
from math import *
a,b,k=map(int,input().split())
g=gcd(a,b)
for i in range(g,0,-1):
    if(g%i==0):
        k-=1
    if(k==0):
        print(i)
        break
# Judge status: Accepted
N, M = map(int,input().split())

cnt = [1 for i in range(N+1)]
flag = [0 for i in range(N+1)]
flag[1] = 1

for _ in range(M):
    x, y = map(int,input().split())
    if flag[x]:
        flag[y] = 1
    if cnt[x] == 1 and flag[x]:
        flag[x] = 0
    cnt[x] -= 1
    cnt[y] += 1

print(sum(flag))
# Judge status: Accepted

def resolve():
    W,H,x,y=map(int,input().split())
    if (W,H)==(2*x,2*y):
        print(W*H/2, 1)
    else:
        print(W*H/2, 0)



resolve()
# Judge status: Accepted
#abc163c
n=int(input())
a=list(map(int,input().split()))
res=[0]*n
for x in a:
 res[x-1]+=1
for i in res:
 print(i)
# Judge status: Accepted
n = int(input())
s = input()
t = input()

tmp = -1
for i in range(n):
    if s[-i - 1:] == t[:i + 1]:
        tmp = i


print(n + n - (tmp + 1))
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
print('YES' if abs(a-b) == abs(b-c) else 'NO')
# Judge status: Accepted
n = int(input())
l = sorted(list(map(int, input().split())), reverse=True)
print(sum(l[1:2*n:2]))
# Judge status: Accepted
k=int(input())
a,b=map(int,input().split())
t=a
while t<b+1:
    if t%k==0:
        print("OK")
        exit()
    t+=1
print("NG")
# Judge status: Accepted
#Macで実行する時
import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../atcoder/input.txt'))
	sys.stdin = open(name)

l = list(map(str,input().split()))
a,b = map(int,input().split())
check = input()

if check == l[0]:
    a -= 1
else:
    b -= 1

print(a,b)
# Judge status: Accepted
N = int(input())
dp = [[0]*10 for _ in range(10)]

for i in range(1, N+1):
  if i%10==0: continue
  strI = str(i)
  f,l = strI[-1], strI[0]
  dp[int(f)][int(l)] += 1

res = 0
for i in range(1,10):
  for j in range(1,10):
    res += dp[i][j] * dp[j][i]

print(res)
# Judge status: Accepted
S = input()
print('Heisei' if S <= '2019/04/30' else'TBD')
# Judge status: Accepted
import math
N = int(input())
A = list(map(int,input().split()))

for i in range(N):
    A[i] -= i+1

A.sort()
b = A[N//2]
sad = 0
for i in range(N):
    sad += abs(A[i]-b)

print(sad)
# Judge status: Accepted
w = list(input())
x = list(set(w))
for i in x:
    y = w.count(i)
    if y % 2 != 0:
        print('No')
        exit(0)
print('Yes')
# Judge status: Accepted
n=int(input())
a=sorted(list(map(int,input().split())))
c=1
x=[]
for i in range(n-1):
    if a[i]!=a[i+1]:
        if c>=2:
            x.append(a[i])
        if c>=4:
            x.append(a[i])
        c=1
    else:
        c+=1
if c>=2:
    x.append(a[n-1])
if c>=4:
    x.append(a[n-1])
if len(x)<=1:
    print(0)
else:
    print(x[-1]*x[-2])