peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
import collections
import sys
n,k = map(int,input().split())
ls = list(map(int,input().split()))
a = list(set(ls))
c = collections.Counter(ls)
p = 0
if len(a) > k:
    di = [0]*(len(a))
    new = c.most_common()[::-1]
    for i in range(len(a)):
        di[i] = new[i][1]
    import numpy 
    new_ls = numpy.cumsum(numpy.array(di))
    for j in range(len(a)):
        if len(a) - k <=new_ls[j]:
            print(new_ls[j])
            sys.exit()
else:
    print(0)
# Judge status: Wrong Answer
n, m = map(int, input().split())
a = list(map(int, input().split()))
if n - sum(a) > 0:
    print(n - sum(a))
else:
    print(-1)
# Judge status: Accepted
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

l,r,d=MI()
print(r//d-(l-1)//d)
# Judge status: Accepted
def main():
    N = int(input())
    S = input()
    ans = 0
    cur = 0
    for s in S:
        if s == "I":
            cur += 1
        else:
            cur -= 1
        ans = max(cur, ans)
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
s=int(input())

mod = 10**9 + 7
ans = 0

m = 10**5 +1 
fac = [1]*m
ninv = [1]*m
finv = [1]*m
for i in range(2,m):
    fac[i] = fac[i-1]*i%mod
    ninv[i] = (-(mod//i)*ninv[mod%i])%mod
    finv[i] = finv[i-1]*ninv[i]%mod

def comb(n,k):
    return (fac[n]*finv[k]%mod)*finv[n-k]%mod

for i in range(s//3):
    ans += comb(s-3*(i+1)+i,i)
    ans %= mod

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

if n == k:
  print(1)
  
if (n-k) % (k-1) == 0:
  ans = 1 + (n-k) // (k-1)

else:
  ans = 2 + (n-k) // (k-1)

print(ans)
# Judge status: Accepted
A,B,C = map(int,input().split())

if A==B and B==C:
  print('No')
elif A != B and B != C and C != A:
  print('No')
else:
  print('Yes')
# Judge status: Accepted
s = input()
t = input()

s = s[::-1]
t = t[::-1]

ans = ""
for i in range(len(s) - len(t)+1):
    for j in range(len(t)):
        if s[i+j] != t[j] and s[i+j] != "?":
            break
    else:
        ans = s[:i] + t + s[i+j+1:]
        ans = ans[::-1]
        print(ans.replace("?", "a"))
        exit()
        
print("UNRESTORABLE")
# Judge status: Accepted
A, B = map(int, input().split())

res = 0
if A > B:
    res += A
    A -= 1
else:
    res += B
    B -= 1

if A > B:
    res += A
    A -= 1
else:
    res += B
    B -= 1

print(res)
# Judge status: Accepted
from math import gcd
x = int(input())
print(360 // gcd(360, x))
# Judge status: Accepted
import numpy as np
X = int(input())

A = int(X / 500)
B = int(int(X % 500) / 5)

print(A * 1000 + B * 5)
# Judge status: Accepted
N = int(input())
A = [int(input()) for i in range(N)]
ans = 0
for i in range(N):
    tmp = A[i]
    ans += (tmp // 2)
    if i < N -1 and tmp % 2 and A[i + 1] > 0:
        ans += 1
        A[i + 1] -= 1
print(ans)
# Judge status: Accepted
x = int(input())
a,b = 0,0

for i in range(-100,300):
    for j in range(-100,300):
        if i**5-j**5==x:
            a,b = i,j
            break

print(a,b)
# Judge status: Wrong Answer
import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if __name__ == '__main__':  
    N, P = map(int, input().split())
    A = list(map(int, input().split()))

    odd = 0
    for a in A:
        if a%2==1:
            odd += 1
    ans = 0
    if P == 0:
        for i in range(0, odd+1, 2):
            ans += comb(N, i)
    else:
        for i in range(1, odd+1, 2):
            ans += comb(N, i)
    print(ans)
# Judge status: Wrong Answer
n,m=map(int,input().split())
if n<m:
    print((2*n+m)//4)
else:
    print(n+(n-m)//4)
# Judge status: Accepted
n,m = map(int, input().split())
ls = []
rs = []
for _ in range(m):
  l,r = map(int, input().split())
  ls.append(l)
  rs.append(r)
  
ans = min(rs) - max(ls) + 1

if ans > 0: print(ans)
else: print(0)
# Judge status: Accepted
n = int(input())
if n%2 == 0:
    print(n//2)
else:
    print((n//2)+1)
# Judge status: Accepted
N, K = map(int, input().split())
H = list(map(int, input().split()))
dp = [10 ** 10] * N
dp[0] = 0
for i in range(1, N):
    for j in range(1, K + 1):
        if i - j < 0:
            break
        dp[i] = min(dp[i], dp[i - j] + abs(H[i - j] - H[i]))
print(dp[-1])
# Judge status: Accepted
A, B, C, X, Y = map(int, input().split())

if (A+B) <= 2*C:
  print(A*X + B*Y)
else:
  Z = 2 * min(X, Y)
  X_rem = X - Z // 2
  Y_rem = Y - Z // 2
  
  if (X_rem != 0) and (A > 2*C):
    print(C*(2*X))
  elif (Y_rem != 0) and (B > 2*C):
    print(C*(2*Y))
  else:
    print(A*X_rem + B*Y_rem + C*Z)
# Judge status: Wrong Answer
H1,M1,H2,M2,K = map(int,input().split())
print(max(0, 60*H2 + M2 - (60*H1 + M2) - K))
# Judge status: Wrong Answer
def main():
    _len = int(input())
    _str = input()

    if _len > 0 or _len < 100 or _len % 2 : 
        print("No")
        return

    print(_len/2)
    a, b = _str[:_len/2], _str[_len/2:]

    print("Yes" if a == b else "No")


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
a,b,c = map(int,input().split())

print("Yes" if (a+b+c)//3 == (a+b+c)/3 else "No")
# Judge status: Wrong Answer
print('YES'if int(input()) in [3,5,7] else 'No')
# Judge status: Accepted
s = input()
for i in range(3):
    if s[i] == s[i+1]:
        print('Bad')
        exit()
print('Good')
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    lis=[[0]*9 for _ in range(9)]
    for i in range(1,n+1):
        si=str(i)
        if int(si[-1])>0:
            lis[int(si[0])-1][int(si[-1])-1]+=1
    cunt=0
    for i in range(9):
        for j in range(9):
            cunt+=lis[i][j]*lis[j][i]
    print(cunt)
    
    

if __name__=='__main__':
    main()
# Judge status: Wrong Answer
a = int(input())
b=list(map(int,input().split()))
c=b
c.sort()
d=[]
print(c)
for i in range(a):
    for j in range(a):
        b[i],b[j]=b[j],b[i]
        print(b)
        if b==c:
            d.append(b)
        else:
            continue
if len(d)!=0:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n,m,k = map(int,input().split())
ans = 0
for i in range(n+1):
    for j in range(m+1):
        a = i*m + j*n - 2*i*j
        if a == k:
            ans = 1
            break
print(["No","Yes"][ans])
# Judge status: Wrong Answer
N, A, B = map(int, input().split())
r = N // (A + B)
m = N % (A + B)
if A != 0:
    if A > N:
        print(N - A)
    else:
        print(A * r + m)
else:
    print(0)
# Judge status: Wrong Answer
n = int(input())
p = [int(x) for x in input().split()]

min_p = 1000000000000

count = 0
 
for i in p:
    # 最小値更新
    print(i)
    if (min_p >= i):
        min_p = i
    if (min_p >= i):
        count += 1

print(count)
# Judge status: Accepted
# ボトムアップ 貰う DP
N = int(input())

INF = 1<<60
dp = [INF]*(N+1)
dp[0] = 0

# 貰う DP --- dp[n] に遷移を集める
for i in range(1, N+1):
  pow6 = 1
  while pow6 <= i:
    dp[i] = min(dp[i], dp[i-pow6] + 1)
    pow6 *= 6
    
  pow9 = 1
  while pow9 <= i:
    dp[i] = min(dp[i], dp[i-pow9] + 1)
    pow9 *= 9

print(dp[N])
# Judge status: Accepted
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N = int(input())
li = [0]*N
for i in range(N):
    A,B = inputlist()
    li[i] = [B,A]
li.sort()
suma = li[0][1]
if suma > li[0][0]:
    print("No")
    exit()
for i in range(1,N):
    suma += li[i][1]
    if suma > li[i][0]:
        print("No")
        exit()
print("Yes")
# Judge status: Accepted
def warikire(n,r):
    if r==1:
        return n+1
    else:
        return n//r+1
a,b,x=map(int,input().split())
if a==0:
    print(warikire(b,x))
else:
    print(warikire(b,x)-warikire(a-1,x))
# Judge status: Wrong Answer
from collections import Counter

N = int(input())
D = list(map(int, input().split()))
c = Counter(D)

# 根は0である必要がある。
if not(0 in c):
    print(0)
    exit(0)

# N = 1の時は1
if N == 1:
    print(1)
    exit(0)

# 親の数*子の数を求める
parent = c[0]
ans = c[0]
for i in range(1, max(D)+1):
    ans = (parent**c[i])*ans
    parent = c[i]
print(ans % 998244353)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

num_looking_for = 1
cnt = 0
for i in range(n):
    if a[i] == num_looking_for:
        num_looking_for += 1
    else:
        cnt += 1
print("-1" if cnt == n else cnt)
# Judge status: Accepted
#!/usr/bin/env python3


def main():
    N = int(input())
    print(
        min(
            [
                sum(list(map(int, str(i)))) + sum(list(map(int, str(N - i))))
                for i in range(1, N)
            ]
        )
    )


main()
# Judge status: Accepted
S = input()

if S[0] == 'A' and S[1] == 'A' and S[2] == 'A':
    print('No')
elif  S[0] == 'B' and S[1] == 'B' and S[2] == 'B':
    print('No')
else:
    print('Yes')
# Judge status: Accepted
a, b = map(int, input().split())
if a * 100 % 8 == 0:
    low = max(a * 100 // 8, b * 10)
else:
    low = max(a * 100 // 8 + 1, b * 10)
if 100 * (a + 1) % 8 == 0:
    a_ = 100 * (a + 1) // 8 - 1
else:
    a_ = 100 * (a + 1) // 8

high = min(a_, 10 * (b+1) -1)

if low <= high:
    print(low)
else:
    print(-1)
# Judge status: Accepted
N=int(input())
a_list = list(map(int, input().split()))

if 0 in a_list:
    print(0)
    exit()

res = 1
for a in a_list:
    res *= a
    if res > 10**18:
        print(-1)
        exit()

print(res)
# Judge status: Wrong Answer
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]

last = [0] * 26
for di in range(d):
    tmpl = [c[i] * (di + 1 - last[i]) for i in range(26)]
    ti = tmpl.index(max(tmpl))
    last[ti] = di + 1
    print(ti)
# Judge status: Accepted
x,y=map(int,input().split())
if x%y == 0:
	print(-1)
else:
	print(x)
# Judge status: Accepted
import sys
import re
S = input()
if not ( 1 <= len(S) <= 10 ): sys.exit()
if not S.isupper: sys.exit()

result = 0
max = max(re.findall('[A|T|G|C]+', S),key=len) if re.findall('[A|T|G|C]+', S) else ''
if len(max) > 0:result = len(max)
print(result)
# Judge status: Wrong Answer
H, N = map(int, input().split())
A = list(map(int, input().split()))
print(sum(A))
if sum(A) >= H:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
four = 0
two = 0 
for e in A:
    if e%4 == 0:
        four += 1
    elif e %2 == 0:
        two += 1
value = four * 3 + (two//2)*2
if value >= N:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import sys
w = input()
d = {}
for c in range(97,97+26):
    d[chr(c)]=0
for c in w:
    d[c]+=1

for c in d.values():
    if c%2 == 1:
        print("No")
        sys.exit()

print("Yes")
# Judge status: Accepted
n,k = map(int, input().split())

ans = 0

while n >= k**ans:
    ans += 1

print(ans)
# Judge status: Wrong Answer
C1 = list(input())
C2 = list(input())

if C1[0] == C2[2] and C1[2] == C2[0] and C1[2] == C2[2]:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
from math import trunc
import sys
import copy
from collections import deque
import collections
import itertools
stdin = sys.stdin
import math

mod = 10**9+7

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

a = na()

ans = []

ans.append(a[0]*a[2])
ans.append(a[0]*a[3])
ans.append(a[1]*a[2])
ans.append(a[1]*a[3])

print(max(ans))
# Judge status: Accepted
_,*a=map(int, open(0))
b=sorted(a)
for i in a:print(b[(i<b[-1])-2])
# Judge status: Accepted
import numpy as np

n,m,x = map(int,input().split())
seen = []
ans = 10**7

for i in range(n):
  seen.append(list(map(int,input().split())))
  
for i in range(2**n):
  temp = 0
  base = np.zeros(m)
  for j in range(n):
    if (i>>j)&1:
      for k in range(m):
        base[k] += seen[j][k+1]
      temp += seen[j][0]
 
  if (np.min(np.where(base >= x,1,0)) == 1) and (ans > temp):
    ans = temp
    
if ans == 10**7:
  ans = -1
  
print(ans)
# Judge status: Accepted
N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
sAB = sorted(AB, key=lambda x: x[0])

ans = 0
cnt = 0
last_cnt = 0
for a, b in sAB:
    cnt += b
    if cnt < M:
        ans += a*b
        last_cnt = cnt
    else:
        ans += a*(M-last_cnt)
        break

print(ans)
# Judge status: Wrong Answer
n = int(input())

ans = ""
while n != 0:
    rest = n % 2
    if rest == 1:
        ans += "1"
    else:
        ans += "0"

    n = (n - rest) // -2

if ans == "":
    ans += "0"

print(ans)
# Judge status: Wrong Answer
n = int(input())
s = [int(input()) for _ in range(n)]
d = sum(s)

result = 0
if d % 10 == 0:
    for i in s:
        if (d-i) % 10 != 0:
            result = d-i
            break
        else:
            d = d-i
else:
    result = d
print(result)
# Judge status: Accepted
def main():
    n=int(input())
    a = list(map(int, input().split()))
    ans = [0] * n
    base = xor(a)
    for i in range(len(a)):
        ans[i] = base ^ a[i]
    print(*ans)

def xor(x):
    r = 0
    for i in x:
        r ^= i
    return r

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
# 入力
a, b, c = map(int, input().split())

# 処理&出力
if b-a == c-b:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
from itertools import accumulate

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

E = [(p + 1) for p in P]

A = [0] + list(accumulate(E))

print("{:.8f}".format(max(A[i + K] - A[i] for i in range(N - K + 1)) / 2))
# Judge status: Accepted
def resolve():
    x=int(input())
    ans=0
    while x>=500:
        x-=500
        ans+=1000
    while x>=5:
        x-=5
        ans+=5
    print(ans)
resolve()
# Judge status: Accepted
H,N = [int(i) for i in input().split()]
AB = [[int(i) for i in input().split()] for j in range(N)]
DP = [10000000000]*(H+1)#DP[h] = 体力をh削るのに必要な魔力のmin
DP[0] = 0
for h,curmp in enumerate(DP):
    for a,b in AB:
        goal = min(h+a,H)
        DP[goal] = min(DP[goal],curmp+b)
print(DP[-1])
# Judge status: Wrong Answer
n=int(input())
if n<1000:
    n_s=str(n).zfill(3)
    print("ABC"+n_s)
else:
    n=n%1000+1
    n_s=str(n).zfill(3)
    print("ABD"+n_s)
# Judge status: Wrong Answer
p = -1
xp = -1
ans = 1
input()
for i in input().split(" "):
  i = int(i)
  if i == p: continue
  if p != -1:
    x = p < i
    if xp != -1:
      ans += x != xp
    if xp != -1 and x != xp:
      xp = -1
    else:
      xp = x
    print(x)
  p = i
print(ans)
# Judge status: Accepted
h, n = map(int, input().split())
a = list(map(int, input().split()))
if sum(a) >= h:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
N=int(input())
P=list(map(int,input().split()))
#S="".join("x" if P[i]==i+1 else "o" for i in range(N))
S=["x" if P[i]==i+1 else "o" for i in range(N)]
count=0
for j in range(N-1):
    if S[j]=="x":
        S[j]="o"
        if S[j+1]=="x":
            S[j+1]="o"
        count+=1
print(count)
# Judge status: Accepted
#copy

y, m, d = map(int, input().split("/"))
print("Heisei" if m <= 4 else "TBD")
# Judge status: Wrong Answer
y=""
a=str(input())
print(len(a))
for i in range (len(a)):
    if a[i]=="B":
        y=y[:-1]
    else:
        y=y+a[i]
print(y)
# Judge status: Wrong Answer
A, B, C = map(int,input().split())

tmp1 = A * B
tmp2 = C // 2
tmp3 = C - tmp2
ans = tmp1 * tmp3 - tmp1 * tmp2
print(ans)
# Judge status: Accepted
a, b = map(int, input().split())
if a < 9 and b < 9:
    print("Yay!")
else:
    print(":(")
# Judge status: Accepted
N = int(input())
Ws = list(map(int, input().split()))

ans = sum(Ws)
for i in range(1, N):
    sum1 = sum(Ws[:i])
    sum2 = sum(Ws[i:])
    diff = abs(sum1-sum2)
    ans = min(ans, diff)

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

if S!=10**9:
    for i in range(K):
        print(S)
    for i in range(N-K):
        print(S+1)
else:
    for i in range(K):
        print(S)
    for i in range(N-K):
        print(3)
# Judge status: Accepted
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]

a, b = map(list, zip(*ab))
a.sort()
b.sort()

if n % 2:
    i = (n + 1) // 2 - 1
    mn = a[i]
    mx = b[i]

else:
    i1, i2 = n // 2 - 1, n // 2
    mn = a[i1] + a[i2]
    mx = b[i1] + b[i2]

ans = mx - mn + 1
print(ans)
# Judge status: Accepted
# 入力をプログラムで扱えるように受け取ること
a, b = map(int, input().split())
# print(a, b)
 
# 受け取った入力値を使い、適切に処理（計算）する
answer = a * b
 
# 計算した結果を出力する
print(answer)
# Judge status: Accepted

def main():
    n = int(input())
    h = list(map(int, input().split()))
    ans = 0
    count = 0

    for i in range(0, n-1):
        if h[i] >= h[i+1]:
            count += 1
            # print(count, h[i], h[i+1])
        else:
            count = 0
        if count > ans:
            ans = count

    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
hl = list(map(int, input().split()))

move = 0
tmp = 0
for i in range(n-1):
    if hl[i] >= hl[i+1]:
        tmp += 1
    else:
        tmp = 0
    if move < tmp:
        move = tmp

print(move)
# Judge status: Accepted
N, Y = map(int, input().split())
 
for x in range(N+1):
    for y in range(N+1):
        if 10000*x + 5000*y + 1000*(N-(x+y)) == Y and N-(x+y) >= 0:
            print(x, y, N-(x+y))
            exit()
 
print(-1,-1,-1)
# Judge status: Accepted
#

# import sys
# input=sys.stdin.readline

def main():
    A,B=map(int,input().split())
    cnt=0
    for i in range(A,B+1):
        s=str(i)
        if s==s[::-1]:
            cnt+=1
    print(cnt)
    
if __name__=="__main__":
    main()
# Judge status: Accepted
n,m,x = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(n)]
prices = []
for i in range(2**n):
  buy = [[] for _ in range(m+1)]
  for j in range(n):
    if ((i >> j) & 1):
      for k in range(m+1):
        buy[k].append(c[j][k])
  for k in range(1,m+1):
    if sum(buy[k]) < x:
      break
  else:
    prices.append(sum(buy[0]))
if len(prices) == 0:
  print(-1)
else:
  print(min(prices))
# Judge status: Accepted
n, a, b = map(int,input().split())
if a % 2 == b % 2:
    print((b-a)//2)
else:
    ans = min(n-b, a-1) + 1 + (b-a-1)//2
    print(ans)
# Judge status: Wrong Answer
def isLun(n):
    n = list(map(int, list(str(n))))
    l = [abs(n[i+1]-n[i]) for i in range(len(n)-1)]
    if set(l) == set([1]) or set(l) == set([0]) or len(n)==1:
        return True
    else:
        return False

n = int(input())
lun, ctr, i = 1, 1, 1
while ctr<=n:
    if isLun(i):
        lun=i
        ctr+=1
    i+=1
print(lun)
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    N = int(readline())
    A = [int(i) for i in readline().split()]
    K = int(1e9)+7
    acum = [0]
    for i  in range(N):
        acum.append(acum[i]+A[i])
    ans = 0
    for i in range(N):
        ans += A[i]*(acum[N]-acum[i+1])
        ans %= K
    print(ans)
if __name__ == '__main__':
    main()
# Judge status: Accepted
S = input()

A, B = int(S[:2]), int(S[2:])

x = 0 <= A <= 99 and 1 <= B <= 12
y = 1 <= A <= 12 and 0 <= B <= 99

if x and y:
    print('AMBIGUOUS')
elif x:
    print('YYMM')
elif y:
    print('MMYY')
else:
    print('NA')
# Judge status: Accepted
import math
N, D = map(int,input().split())
X = [list(map(int, input().split())) for i in range(N)]

seisu_count = 0
for l in range(N):

    for r in range(l+1, N):
        total = 0
        for z in range(D):
            y_z = abs(X[l][z] - X[r][z])
            y_z_2 = y_z * y_z
            total += y_z_2
        
        sqr_total = math.sqrt(total)
        if sqr_total.is_integer():
            seisu_count += 1

print(seisu_count)
# Judge status: Accepted
s = input()

n = len(s)

ans = 0

s1 = s[:int((n - 1) / 2)]
s2 = s[int((n + 3) / 2) - 1:]

s5 = s[::-1]

s3 = s1[::-1]
s4 = s2[::-1]

#print(s5, s3, s4)
if s1 == s3:
    ans += 1

if s2 == s4:
    ans += 1

if s == s5:
    ans += 1

if ans == 3:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())
arr = list(map(int, input().split()))

mini = min(arr)
maxi = max(arr)
cost = 10000000000

for i in range(-100, 101+1):
    add = 0
    for j in range(n):
        add = add + (arr[j] - i)**2
    cost = min(cost, add)
print(cost)
# Judge status: Wrong Answer
n = int(input())
candidate = ['a']


def dfs(s, c):
    if len(s) == n:
        return
    candidate.append(s + c)
    candidate.append(s + chr(ord(c) + 1))
    dfs(s + c, c)
    dfs(s + chr(ord(c) + 1), chr(ord(c) + 1))


dfs('a', 'a')

for c in candidate:
    if len(c) == n:
        print(c)
# Judge status: Wrong Answer
lst = [int(input()) for i in range(int(input()))]
index = 0
count = 0
a = -1
while True:
  index = lst[index] - 1
  if index == 0:
    break
  elif index == 1:
    a = count
  else:
    count += 1
    
print(a)
# Judge status: Accepted
x = int(input())

for t in range(1000000000):
    if 2 * x <= t * (t + 1):
        print(t)
        break
# Judge status: Wrong Answer
A = list(input())
B = list(input())
C = list(input())
A.append("0")
B.append("0")
C.append("0")
x = A[0]
del A[0]
while x != "0":
    if x == "a":
        x = A[0]
        del A[0]
    elif x == "b":
        x = B[0]
        del B[0]
    else:
        x = C[0]
        del C[0]
print(A,B,C,x)
if "0" not in A:
    print("A")
elif "0" not in B:
    print("B")
else:
    print("C")
# Judge status: Wrong Answer
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint,random
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a,b,c = inpl()
x = 4 * a * b
y = a**2 + b**2 + c**2 - (a*c-a*b+b*c)*2
if x-y < 0:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
from collections import deque

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

d = deque()
for i, v in enumerate(arr):
    i += 1
    if n % 2:
        if i % 2:
            d.append(v)
        else:
            d.appendleft(v)
    else:
        if i % 2:
            d.append(v)
        else:
            d.appendleft(v)
print(*d)
# Judge status: Accepted
n=int(input())
A=list(map(int,input().split()))
choice=[0]*n
ans=[]
cnt=0
for i in range(n-1,-1,-1):
    a=i+1
    c=0
    a+=i+1
    while a<=n:
        c+=choice[a-1]
        a+=i+1
    if c%2!=A[i]:
        choice[i]+=1
        ans.append(i+1)
        cnt+=1
if cnt==0:
    print(0)
else:
    print(cnt)
    ans.sort()
    print(*ans, sep=' ')
# Judge status: Wrong Answer
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

cnt = 0
for tt in range(1, t + 1):
    res = (w - v) * tt + (b - a)
    if res == 0:
        cnt = 1

if a >= b and w >= v:
    cnt = 0
if cnt == 1:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
# coding: utf-8
import numpy as np

k = int(input())

s = 0
cnt = 0
flg = False

while (cnt < 1e7):
    cnt += 1
    print(cnt)
    s = s * 10 + 7 
    # print(s)

    if s % k == 0:
        flg = True
        break

    if k < 7:
        flg = False
        break

    if k % 2 == 0:
        flg = False
        break


if flg == True:
    print(cnt)
else:
    print(-1)
# Judge status: Accepted
import math
a = int(input())
print(math.factorial(a)%(10**9+7))
# Judge status: Wrong Answer
import sys

x, n = map(int, input().split())

if n == 0:
  print(x)
  sys.exit()
  
if n == 1:
  print(abs(x - int(input())))
  sys.exit()

p = list(map(int, input().split()))

p.sort()
min = [100, 100]

for i in range(100):
  if i in p:
    continue
  hoge = abs(x - i)
  if min[0] > hoge:
    min[0] = hoge
    min[1] = i

print(min[1])
# Judge status: Accepted
T = input()
N = len(T)
res = []
for t in T:
    if t == "P":
        res.append("P")
    else:
        res.append("D")
print("".join(map(str, res)))
# Judge status: Accepted
n = int(input())

if n % 1000 == 0:
    print(0)
else:
    print(((n // 1000 + 1) * 1000) - n)
# Judge status: Accepted
def f(x):
    return (A*x)//B-A*(x//B)
    
A, B, N = map(int, input().split())
print(f(min(B-1, N)))