Harryxun/stf_run huggingface dataset:
s = str(input())
list_s = list(s)
alp_list = list("abcdefghijklmnopqrstuvwxyz")
dict_alp = {}
ans = 0
for i in range(26):
    dict_alp[alp_list[i]] = i+1
if len(list_s) == 26:
    i = 25
    while True:
        try:
            if dict_alp[list_s[i]] > dict_alp[list_s[i-1]]:
                list_s = list_s[:i]
                x = list_s.pop()
                break
            else:
                i -= 1
        except IndexError:
            ans = -1
            break
    alp_set = []
    for alp in alp_list:
        if not alp in list_s:
            if dict_alp[alp] > dict_alp[x]:
                alp_set.append(alp)
    alp_set.sort()
    list_s.append(alp_set[0])
else:
    for alp in alp_list:
        if not alp in list_s:
            list_s.append(alp)
            break
if ans == -1:
    print(ans)
else:
    print("".join(list_s))


### FIXED CODE ###

s = str(input())
list_s = list(s)
alp_list = list("abcdefghijklmnopqrstuvwxyz")
dict_alp = {}
ans = 0
for i in range(26):
    dict_alp[alp_list[i]] = i+1
if len(list_s) == 26:
    i = 25
    while True:
        try:
            if dict_alp[list_s[i]] > dict_alp[list_s[i-1]]:
                list_s = list_s[:i]
                x = list_s.pop()
                break
            else:
                i -= 1
        except IndexError:
            ans = -1
            break
    if ans != -1:
        alp_set = []
        for alp in alp_list:
            if not alp in list_s:
                if dict_alp[alp] > dict_alp[x]:
                    alp_set.append(alp)
        alp_set.sort()
        list_s.append(alp_set[0])
else:
    for alp in alp_list:
        if not alp in list_s:
            list_s.append(alp)
            break
if ans == -1:
    print(ans)
else:
    print("".join(list_s))
import sys
sys.setrecursionlimit(500*500)
def modpow(a,n,p):
    if n==0:
        return 1
    x=modpow(a,n//2,p)
    x=(x*x)%p
    if (n%2)==1:
        x=(x*a)%p
    return x%p
def modinv(a,p):
    return modpow(a,p-2,p)

r1,c1,r2,c2=map(int,input().split())
n1=r2+c2+2
n2=r2+c1+1
n3=r1+c2+1
n4=r1+c1
l=[r2+1,r2+1,r1,r1]
p=10**9+7
buf=1
cnt=0
l=[0]*(10**6+10)
inv=[0]*(10**6+10)
l[1]=1
for i in range(2,n1+3,1):#n1+1
    l[i]=(l[i-1]*i)%p
print((((l[n1]*modinv(l[r2+1],p)*modinv(l[n1-r2-1],p))%p)-(l[n2]*modinv(l[r2+1],p)*modinv(l[n2-r2-1],p))-(l[n3]*modinv(l[r1],p)*modinv(l[n3-r1],p))+(l[n4]*modinv(l[r1],p)*modinv(l[n4-r1],p)))%p)

### FIXED CODE ###

import sys
sys.setrecursionlimit(500*500)
def modpow(a,n,p):
    if n==0:
        return 1
    x=modpow(a,n//2,p)
    x=(x*x)%p
    if (n%2)==1:
        x=(x*a)%p
    return x%p
def modinv(a,p):
    return modpow(a,p-2,p)

r1,c1,r2,c2=map(int,input().split())
n1=r2+c2+2
n2=r2+c1+1
n3=r1+c2+1
n4=r1+c1
l=[r2+1,r2+1,r1,r1]
p=10**9+7
buf=1
cnt=0
l=[0]*(10**7+10)
inv=[0]*(10**7+10)
l[1]=1
for i in range(2,n1+3,1):#n1+1
    l[i]=(l[i-1]*i)%p
print((((l[n1]*modinv(l[r2+1],p)*modinv(l[n1-r2-1],p))%p)-(l[n2]*modinv(l[r2+1],p)*modinv(l[n2-r2-1],p))-(l[n3]*modinv(l[r1],p)*modinv(l[n3-r1],p))+(l[n4]*modinv(l[r1],p)*modinv(l[n4-r1],p)))%p)
// C/C++ キーワード定義ファイル 関数
// cpp_kw3_functions.kwd
//
//  Created on: 2015/06/13
//      Author: KeitetsuWorks
// CASE=True

#define
#elif
#else
#endif
#error
#if
#ifdef
#ifndef
#include
#line
#pragma
#undef
abort
abs
acos
asctime
asin
assert
atan
atan2
atexit
atof
atoi
atol
bsearch
calloc
ceil
clearerr
clock
cos
cosh
ctime
difftime
div
errno
exit
exp
fabs
fclose
feof
ferror
fflush
fgetc
fgetpos
fgets
floor
fmod
fopen
fprintf
fputc
fputs
fread
free
freopen
frexp
fscanf
fseek
fsetpos
ftell
fwrite
getc
getchar
getenv
gets
gmtime
isalnum
isalpha
iscntrl
isdigit
isgraph
islower
isprint
ispunct
isspace
isupper
isxdigit
labs
ldexp
ldiv
localeconv
localtime
log
log10
longjmp
malloc
mblen
mbstowcs
mbtowc
memchr
memcmp
memcpy
memmove
memset
mktime
modf
perror
pow
printf
putc
putchar
puts
qsort
raise
rand
realloc
remove
rename
rewind
scanf
setbuf
setjmp
setlocale
setvbuf
signal
sin
sinh
sprintf
sqrt
srand
sscanf
strcat
strchr
strcmp
strcoll
strcpy
strcspn
strerror
strftime
strlen
strncat
strncmp
strncpy
strpbrk
strrchr
strspn
strstr
strtod
strtok
strtol
strtoul
strxfrm
system
tan
tanh
time
tmpfile
tmpnam
tolower
toupper
ungetc
va_arg
va_end
va_start
vfprintf
vprintf
vsprintf
wcstombs
wctomb


### FIXED CODE ###

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

ans = [0]*N

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

for i in range(N):
    print(ans[i])
r,t,x=map(int,input().split())
print(a=r*x-t)
print(b=r*a-t)
print(c=r*b-t)
print(d=r*c-t)
print(e=r*d-t)
print(f=r*e-t)
print(g=r*f-t)
print(h=r*g-t)
print(i=r*h-t)
print(j=r*i-t)


### FIXED CODE ###

r,t,x=map(int,input().split())
a=r*x-t
b=r*a-t
c=r*b-t
d=r*c-t
e=r*d-t
f=r*e-t
g=r*f-t
h=r*g-t
i=r*h-t
j=r*i-t
print(a)
print(b)
print(c)
print(d)
print(e)
print(f)
print(g)
print(h)
print(i)
print(j)
x,y = map(int,input().split())
if x > y:
    print(">")
if x == y:
    print("=")
else:
    print("<")

### FIXED CODE ###

x,y = input().split()
li = ["A","B","C","D","E","F"]
nx = li.index(x)
ny = li.index(y)
if nx > ny:
    print(">")
elif nx == ny:
    print("=")
else:
    print("<")
import tensorflow
S, W = map(int, input().split())
def f():
  if W >= S:
    return "unsafe"
  else:
    return "safe"
print(f())


### FIXED CODE ###

S, W = map(int, input().split())
def f():
  if W >= S:
    return "unsafe"
  else:
    return "safe"
print(f())
import math

a, b = map(int, input().split())
print(a * b // math.gcd(a, b))

### FIXED CODE ###

from fractions import gcd
#from math import gcd

a, b = map(int, input().split())
print(a * b // gcd(a, b))
import math

A,B,C,D=[int(x) for x in input().rstrip().split()]
cnt=0


def lcm(x, y):
    return (x * y) // math.gcd(x, y)

    
baisuu=lcm(C,D)
yakusuu=math.gcd(C,D)

u_A=(A-1)-(A-1)//C-(A-1)//D+(A-1)//baisuu

u_B=B-B//C-B//D+B//baisuu

print(u_B-u_A)

### FIXED CODE ###

import fractions
from functools import reduce

A,B,C,D=[int(x) for x in input().rstrip().split()]
cnt=0

import math

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

    
baisuu=lcm(C,D)

u_A=(A-1)-(A-1)//C-(A-1)//D+(A-1)//baisuu

u_B=B-B//C-B//D+B//baisuu

print(u_B-u_A)
import sys

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

if m==0:
    print(0,0)
    sys.exit()

p=[]
s=[]
for i in range(m):
    pp,ss=input().split()
    p.append(int(pp))
    s.append(ss)

p.append(max(p)+1)

sei=0
pena=0

print(len(p))

i=0

while(True):
    #print(i)
    #print("p[i],p[-1]:",p[i],p[-1])
    if p[i]==p[-1]: break
    if s[i]=='WA':
        pena+=1
    else:
        sei+=1
        #print("p[i]+1:",p[i]+1)
        i=p.index(p[i]+1)-1
        #print("i:",i)
    i+=1
            
print(sei,pena)


### FIXED CODE ###

n,m=map(int,input().split())
ac = [0] * n
wa = [0] * n

for i in range(m):
    p,s = map(str,input().split())
    p = int(p)
    if ac[p-1] != 1:
        if s == 'WA':
            wa[p-1] += 1
        elif s == 'AC':
            ac[p-1] += 1

for i in range(n):
    if ac[i] == 1:
        continue
    elif ac[i] == 0:
        wa[i] = 0
        
print(sum(ac),sum(wa))
W, H, x, y = map(int, input().split())

if (x == 0 and y == 0) or (x == W and y == H) or (x == 0 and y == H) or (x == W and y == 0):
    print((W*H)/2, 0)
elif (x/y == W/H) or (y/x == H/W):
    print((W*H)/2, 0)
elif abs(W/2-x) > abs(H/2-y):
    A = W*y
    B = W*(H-y)
    print(min(A,B), 0)
elif abs(H/2-y) > abs(W/2-x):
    A = H*x
    B = H*(W-x)
    print(min(A,B), 0)
else:
    print((W*H)/2, 1)

### FIXED CODE ###

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

if x == W/2 and y == H/2:
    print((W*H)/2, 1)
else:
    print((W*H)/2, 0)
N = int(input())
A = list(map(int, input().strip().split()))



def merge(A, left, mid, right):
    global count
    n1 = mid - left
    n2 = right - mid
    L = []
    R = []
    for i in range(n1):
        L.append(A[left + i])
    for i in range(n2):
        R.append(A[mid + i])

    L.append(float("inf"))
    R.append(float("inf"))
    i, j = 0, 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    count += right - left


def mergeSort(A, left, right):
    if left+1 < right:
        mid = (left + right)//2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

mergeSort(A,0,N)
ans = ""
for i in A:
    ans += str(i) + " "

print(ans)
print(count)

### FIXED CODE ###

def merge(a, left, mid, right):
    global count
    n1 = mid - left
    n2 = right - mid
    L = a[left:left + n1] + [SENTINEL]
    R = a[mid:mid + n2] + [SENTINEL]
    i = j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            a[k] = L[i]
            i += 1
        else:
            a[k] = R[j]
            j += 1
    count += right - left
 
def merge_sort(a, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(a, left, mid)
        merge_sort(a, mid, right)
        merge(a, left, mid, right)
 
SENTINEL = 1000000001
n = int(input())
a = list(map(int, input().strip().split()))
count = 0
merge_sort(a, 0, len(a))
print(' '.join(map(str, a)))
print(count)
X,Y,A,B,C = map(int,input().split())

p = sorted(list(map(int,input().split()))) #A
q = sorted(list(map(int,input().split()))) #B
r = sorted(list(map(int,input().split()))) #C

xlist = p[-X:] #X
ylist = q[-Y:] #Y


for i in range(min(X,Y)):
    if xlist[i] < ylist[i] and min(xlist) < max(r):
        xlist.remove(min(xlist))
        xlist.append(max(r))
        r.pop()
    elif ylist[i] < xlist[i] and min(ylist) < max(r):
        ylist.remove(min(xlist))
        ylist.append(max(r))
        r.pop()
    else:
        continue

print(sum(xlist)+sum(ylist))

### FIXED CODE ###

X,Y,A,B,C = map(int,input().split())

p = sorted(list(map(int,input().split()))) #A
q = sorted(list(map(int,input().split()))) #B
r = sorted(list(map(int,input().split()))) #C

xlist = p[-X:] #X
ylist = q[-Y:] #Y

"""
def main(X,Y,xlist,ylist,r):
    for i in range(min(X,Y)):
        if xlist[i] < ylist[i] and min(xlist) < max(r):
            xlist.remove(min(xlist))
            xlist.append(r.pop())
            
        elif ylist[i] < xlist[i] and min(ylist) < max(r):
            ylist.remove(min(ylist))
            ylist.append(r.pop())
            
        elif min(xlist) >= max(r) and min(ylist) >= max(r):
            break
        else:
            continue
    
    print(sum(xlist + ylist))

main(X,Y,xlist,ylist,r)
"""
all_apples = sorted(xlist + ylist + r)
print(sum(all_apples[-(X+Y):]))
input()
a=input().split(' ')
sum=0
for i in a:
    sum+=i-1
print(sum)


### FIXED CODE ###

input()
a=list(map(int,input().split(' ')))
sum=0
for i in a:
    sum+=i-1
print(sum)
line = input().split

X = line[0]
Y = line[1]
Z = line[2]

print( str(Y) + " " + str(X) + " " + str(Z) )


### FIXED CODE ###

X,Y,Z = map(int,input().split())

print(str(Z) + " " + str(X) + " " + str(Y))
print(round(int(input()/2))

### FIXED CODE ###

import math
print(math.ceil(int(input())/2))
import sys
s = input()
ans = ['a':0,'b':0,'c':0]
for i in s:
	if i in ans:
		ans[i] +=1
    else:
		print('NO')
        sys.exit()
print('YES' if (ans['a']%2==0 and ans['a']%2==0 and ans['a']%2==0) else 'NO')

### FIXED CODE ###

import sys
s = input()
ans = {}
for i in s:
  if i in ans:
    ans[i] +=1
  else:
    ans[i] = 1
for i in ans.values():
  if i%2!=0:
    print('No')
    sys.exit()
print('Yes')
s = input
if s.count("a") == 1 and s.count("b") == 1:
  print("Yes")
else:
  print("No")
s = input

### FIXED CODE ###

s = input()
if s.count("a") == 1 and s.count("b") == 1:
  print("Yes")
else:
  print("No")
n=int(input())
a=[int(input()) for i in range(n)]
cost=abs(a[n-1])
print(a)

### FIXED CODE ###

A,B,C,D=[int(input()) for i in range(4)]
print(min(A,B)+min(C,D))
from collections import deque


k = int(input())
q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])

for i in range(k):
  a = q.popleft()
  if a % 10 == 1:
    q.append([10*a, 10*a+1])
  elif a % 10 == 9:
    q.append([10*a + 8, 10*a + 9])
  else:
    q.append([10*a + a - 1, 10*a + a, 10*a + a + 1])
else:
  print(a)

### FIXED CODE ###

from collections import deque
 
k = int(input())
q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
 
for i in range(k):
  a = q.popleft()
  if a % 10 == 0:
    q.append(10*a)
    q.append(10*a + 1)
  elif a % 10 == 9:
    q.append(10*a + 8)
    q.append(10*a + 9)
  else:
    q.append(10*a + a%10 - 1)
    q.append(10*a + a%10)
    q.append(10*a + a%10 + 1)
else:
  print(a)
import math

r = int(input())
area = math.pi * r**2
length = 2 * math.pi * r
print(f"{area:.6f} {length:.6f}")


### FIXED CODE ###

import math

r = float(input())
area = math.pi * r ** 2
length = 2 * math.pi * r
print(f"{area:.6f} {length:.6f}")
import collections
n = int(input())
a = list(map(int, input().split()))
dif = [0] * n
sum = 0
for i, v in collections.Counter(a).items():
    if v < 2:
        continue
    val = v * (v - 1) // 2
    dif[i] = 2 * (v - 1) // 2
    sum += val
print('\n'.join([int(sum_count - data[i]) for i in a])

### FIXED CODE ###

from collections import Counter

n = int(input())
a = list(map(int, input().split()))
dif = [0] * (n + 1)
sum_c = 0
c = Counter(a)
for i, v in c.items():
    if v < 2:
        continue
    val = v * (v - 1) / 2
    dif[i] = v - 1
    sum_c += val
print('\n'.join([str(int(sum_c - dif[i])) for i in a]))
input()
x = input()
a = x.split()
b = list(map(int,a))
print("{} {} {}".format(min(b),max(b),sum(b)))


### FIXED CODE ###

k = input()
i = list(map(int,input().split()))
print(min(i),max(i),sum(i))
n,q=map(int,input().split())
s=input()
lr=[list(map(int,input().split())) for _ in range(q)]
s1=len(list(s))
l=[0]*(s1-1)
for i in range(s1//2):
    if s[2*i]=='A' and s[2*i+1]=='C':
        l[2*i]+=1
    if s[2*i+1]=='A' and s[2*(i+1)]=='C':
        l[2*i+1]+=1
for j in range(q):
    print( sum( l [lr[j][0]-1:lr[j][1]-1] ))

### FIXED CODE ###

n,q=map(int,input().split())
s=input()
lr=[list(map(int,input().split())) for _ in range(q)]
l=[0]*(n+1)
for i in range(n):
    if s[i:i+2]=='AC':
        l[i+1]=l[i]+1
    else:l[i+1]=l[i]
for j in range(q):
    print( l[lr[j][1]-1] - l[lr[j][0]-1])
N = int(inut())
if N<105:
  print(0)
elif N<135:
  print(1)
elif N<165:
  print(2)
elif N<189:
  print(3)
elif N<195:
  print(4)
else:
  print(5)

### FIXED CODE ###

N = int(input())
if N<105:
  print(0)
elif N<135:
  print(1)
elif N<165:
  print(2)
elif N<189:
  print(3)
elif N<195:
  print(4)
else:
  print(5)
nm = [0,31,29,31,30,31,30,31,31,30,31,30]

while True:

    m,d = map(int,raw_input().split(" "))

    if m == 0:
        break
    nd = 0 
    for i in range(m):
       nd += nm[i]

    nd += d
    n = nd%7
    if n == 1:
        print "Thursday"
    elif n == 2:
        print "Tryday"
    elif n == 3:
        print "Saturday"
    elif n == 4:
        print "Sunday"
    elif n == 5:
        print "Monday"
    elif n == 6:
        print "Tuesday"
    elif n == 7:
        print "Wednesday"
~                                  

### FIXED CODE ###

nm = [0,31,29,31,30,31,30,31,31,30,31,30]
while True:

    m,d = map(int,raw_input().split(" "))

    if m == 0:
        break
    else:
        nd = 0
        for i in range(m):
           nd += nm[i]

        nd += d
        n = nd%7
        if n == 1:
            print "Thursday"
        elif n == 2:
            print "Friday"
        elif n == 3:
            print "Saturday"
        elif n == 4:
            print "Sunday"
        elif n == 5:
            print "Monday"
        elif n == 6:
            print "Tuesday"
        else:                                                                                                                                                                                                
            print "Wednesday"
n = int(inupt())
print(n**3)

### FIXED CODE ###

n = int(input())
print(n**3)
N=int(input())
A=list(map(int,input().split()))

if A==[0]*N:
    print("Yes")
    exit()

T={}
for a in A:
    if a in T:
        T[a]+=1
    else:
        T[a]=1

F=True
for x in T:
    F&=(3*T[x]%N==0)

if not F:
    print("No")
    exit()

x,y,z=list(T.keys())

if x^y==z:
    print("Yes")
else:
    print("No")



### FIXED CODE ###

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

T={}
for a in A:
    if a in T:
        T[a]+=1
    else:
        T[a]=1

F=True
for x in T:
    F&=(3*T[x]%N==0)

if not F:
    print("No")
    exit()

M=max(T,key=lambda x:T[x])
if 3*T[M]==N:
    x,y,z=list(T.keys())
elif 3*T[M]==2*N:
    x=y=M
    del T[M]
    z=tuple(T.keys())[0]
else:
    x=y=z=M

if x^y==z:
    print("Yes")
else:
    print("No")
import math
N,M = (int(x) for x in input().split())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
a = combinations_count(N, 2) + combinations_count(M, 2)
print(a)

### FIXED CODE ###

from scipy.misc import comb
N,M = (int(x) for x in input().split())
a = comb(N, 2, exact=True) + comb(M, 2, exact=True)
print(a)
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
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()))

n,m = inpl()
a = inpl()
a.sort()
bc = [inpl() for _ in range(m)]
bc.sort(key=lambda x:x[1], reverse = True)
ind = -1
now = -1
cnt = 0
for i in range(n):
    if cnt == 0:
        ind += 1
        cnt, now = bc[ind]
    if a[i] >= now:
        break
    a[i] = now
    cnt -= 1
print(sum(a))

### FIXED CODE ###

from collections import Counter,defaultdict
import sys,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n,m = inpl()
a = inpl()
sum_a = sum(a)
bc = []
for i in range(m):
    b,c = inpl()
    bc.append([b,c])
a.sort()
bc.sort(key=lambda x:x[1],reverse=True)

start = 0
flag = True
for i,q in enumerate(bc):
    end = start+q[0]
    if end >= n:
        flag = False
        end = n
    for j in range(start,end):
        if a[j] < q[1]:
            a[j] = q[1]
        else:
            flag = False
            break
    start += q[0]
    if not flag:
        break
print(sum(a))
N,M = map(int,input().split())
S = input()
N0 = 2**N.bit_length()
INF = 2**31-1

# k番目の要素をxに更新
def update(k, x, data):
    k += N0-1
    data[k] = x
    while k >= 0:
        k = (k - 1) // 2
        data[k] = min(data[2*k+1], data[2*k+2])

# [l,r)の最小値
def query(l, r, data):
    L = l + N0; R = r + N0
    s = INF
    while L < R:
        if R & 1:
            R -= 1
            s = min(s, data[R-1])

        if L & 1:
            s = min(s, data[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s



data1 = [INF]*(2*N0)
update(0,0,data1)
for n in range(N):
    if S[n+1]=='0':
        update(n+1,query(n-M+1,n+1,data1)+1,data1)

S = S[::-1]
data2 = [INF]*(2*N0)
update(0,0,data2)
for n in range(N):
    if S[n+1]=='0':
        update(n+1,query(n-M+1,n+1,data2)+1,data2)

cost1 = [INF]*(N+1)
cost2 = [INF]*(N+1)
for n in range(N+1):
    cost1[n] = query(n,n+1,data1)
    cost2[n] = query(N-n,N-n+1,data2)

ans = []
cost = 0
for n in range(N+1):
    if cost != cost1[n] and cost1[n]+cost2[n]==cost1[N]:
        ans.append(n)
        cost = cost1[n]
ans = [0]+ans
for i in range(len(ans)-2,-1,-1):
    ans[i+1] = ans[i+1]-ans[i]

ans = ' '.join([str(c) for c in ans[1:]])
if cost2[0]==INF:
    ans = '-1'
print(ans)

### FIXED CODE ###

N,M = map(int,input().split())
S = input()
N0 = 2**(N-1).bit_length()
INF = 2**31-1

# k番目の要素をxに更新
def update(k, x, data):
    k += N0-1
    data[k] = x
    while k >= 0:
        k = (k - 1) // 2
        data[k] = min(data[2*k+1], data[2*k+2])

# [l,r)の最小値
def query(l, r, data):
    L = l + N0; R = r + N0
    s = INF
    while L < R:
        if R & 1:
            R -= 1
            s = min(s, data[R-1])

        if L & 1:
            s = min(s, data[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s



data1 = [INF]*(3*N0)
update(0,0,data1)
for n in range(N):
    if S[n+1]=='0':
        update(n+1,query(max(0,n-M+1),n+1,data1)+1,data1)

S = S[::-1]
data2 = [INF]*(3*N0)
update(0,0,data2)
for n in range(N):
    if S[n+1]=='0':
        update(n+1,query(max(0,n-M+1),n+1,data2)+1,data2)

cost1 = [INF]*(N+1)
cost2 = [INF]*(N+1)
for n in range(N+1):
    cost1[n] = query(n,n+1,data1)
    cost2[n] = query(N-n,N-n+1,data2)

ans = []
cost = 0
for n in range(N+1):
    if cost != cost1[n] and cost1[n]+cost2[n]==cost1[N]:
        ans.append(n)
        cost = cost1[n]
ans = [0]+ans
for i in range(len(ans)-2,-1,-1):
    ans[i+1] = ans[i+1]-ans[i]

ans = ' '.join([str(c) for c in ans[1:]])
if cost2[0]==INF:
    ans = '-1'
print(ans)
X = int(input())
Y = int(input())

print(round(X+Y/2))    

### FIXED CODE ###

X,Y = map(int,input().split())
print(X+Y//2)
C=[[int(i) for i in input().split()] for j in range(3)]
ans=False
for a1 in range(101):
  for a2 in range(101):
    for a3 in range(101):
      if len(set([c[i][0]-a1 for i in range(3)]))==1:
        if len(set(c[j][1]-a2 for j in range(3)))==1:
          if len(set(c[k][2]-a3 for k in range(3)))==1:
            ans=True
print('Yes' if ans else 'No') 

### FIXED CODE ###

c=[[int(i) for i in input().split()] for j in range(3)]
ans='No'
for x in range(101):
  for y in range(101):
    for z in range(101):
      d=[]
      d.append([c[0][j]-x for j in range(3)])
      d.append([c[1][j]-y for j in range(3)])
      d.append([c[2][j]-z for j in range(3)])
      if sum(len(set(d[i][j] for i in range(3))) for j in range(3))==3:
             ans='Yes'
print(ans)
a, b, x = [int(x) for x in input().split()]
print(b // x - a // x + (a % x == 0))a,b,x=map(int,input().strip().split(" "))
count=0

count_a=a//x
count_b=b//x

if(a%x==0):
    count_a-=-1

count=count_b-count_a

print(count)



### FIXED CODE ###

a, b, x = [int(x) for x in input().split()]
print(b // x - a // x + (a % x == 0))
from sys import stdin
input = stdin.readline

def VI(N, init=0):
  return [init for _ in range(N)]
def VVI(N, M, init=0):
  return [[init for _ in range(M)] for _ in range(N)]

def VD(N, init=0.0):
  return [init for _ in range(N)]
def VVD(N, M, init=0.0):
  return [[init for _ in range(M)] for _ in range(N)]

def Decimal(x):
  print("{0:.10f}".format(x))

class Pair:
  def __init__(self, x=0, y=0):
    self.first = x
    self.second = y

  def __repr__(self):
    return '{0} {1}'.format(self.first, self.second)

  def __lt__(self, pi):
    return self.first < pi.second

def POW(x, n):
  ret = 1
  while n:
    if n&1:
      ret *= x
    x *= x
    n >>= 1
  return ret

N = int(input().rsplit())
if N < 1000:
  print("ABC")
else:
  print("ABD")


### FIXED CODE ###

from sys import stdin
input = stdin.readline

def VI(N, init=0):
  return [init for _ in range(N)]
def VVI(N, M, init=0):
  return [[init for _ in range(M)] for _ in range(N)]

def VD(N, init=0.0):
  return [init for _ in range(N)]
def VVD(N, M, init=0.0):
  return [[init for _ in range(M)] for _ in range(N)]

def Decimal(x):
  print("{0:.10f}".format(x))

class Pair:
  def __init__(self, x=0, y=0):
    self.first = x
    self.second = y

  def __repr__(self):
    return '{0} {1}'.format(self.first, self.second)

  def __lt__(self, pi):
    return self.first < pi.second

def POW(x, n):
  ret = 1
  while n:
    if n&1:
      ret *= x
    x *= x
    n >>= 1
  return ret

N = int(input().rstrip())
if N < 1000:
  print("ABC")
else:
  print("ABD")
# D

inp = input().split(' ')
A, B, N = int(inp[0]), int(inp[1]), int(inp[2])

alpha, beta = math.floor(A/B), A%B
if B-1 < N:
    x = B-1
else:
    x = N
    
print(math.floor(A*x/B) - A * math.floor(x/B))

### FIXED CODE ###

# D

import math
inp = input().split(' ')
A, B, N = int(inp[0]), int(inp[1]), int(inp[2])

alpha, beta = math.floor(A/B), A%B
if B-1 < N:
    x = B-1
else:
    x = N
    
print(math.floor(A*x/B) - A * math.floor(x/B))