Harryxun/stf_run huggingface dataset:
from itertools import combinations

result = 10 ** 15
N = int(input())

h = [int(x) for x in input().split()]

numbers = []
for i in range(N):
    numbers.append(1)
for i in range(N/2):
    numbers.append(2)
combination = list(dict.fromkeys([seq for i in range(len(numbers), 0, -1) for seq in combinations(numbers, i) if sum(seq) == N - 1]))
for i in range(len(combination)):
    idouti = 0
    for j in range(len(combination[i]) + 1):
        if j == 0:
            #idouti += abs(h[0] - h[combination[i][j]])
            continue
        a = sum(combination[i][0:j])

        b = sum(combination[i][0:j - 1])

        idouti += abs(h[a] - h[b])
    if result > idouti:
        result = idouti

print(result)


### FIXED CODE ###

N = int(input())
h = [int(x) for x in input().split()]
dp = []
dp1 = 0
dp2 = 0
for i in range(N):
    if i == 0:
        dp.append(0)
        continue

    if i == 1:
        dp.append(abs(h[0] - h[1]))
        continue

    dp1 = dp[i - 1] + abs(h[i] - h[i - 1])
    dp2 = dp[i - 2] + abs(h[i] - h[i - 2])

    if dp1 < dp2:
        dp.append(dp1)
    else:
        dp.append(dp2)
print(dp[-1])
# ABC127A

a, b = map(int, input().split()
if a >= 13:
    print(b)
elif a >= 6:
    print(b / 2)
else:
    print(0)


### FIXED CODE ###

# ABC127A

a, b = map(int, input().split())
if a >= 13:
    print(b)
elif a >= 6:
    print(b // 2)
else:
    print(0)
A, B = int(input().split())
list = []
list.append(A + B)
list.append(A - B)
list.append(A * B)
print(max(list))


### FIXED CODE ###

A, B = map(int, input().split())
list = []
list.append(A + B)
list.append(A - B)
list.append(A * B)
print(max(list))
N = int(input())
surveys = [list(map(int, input().split())) for _ in range(N)]
for x in range(101):
  for y in range(101):
    before = -1
    identified = True
    for survey in surveys:
      height = survey[2] + abs(x-survey[0]) + abs(y-survey[1])
      if before != -1 and before != height:
        if surveys[2] == 0 and before <= height:
          continue
        identified = False
        break
      if before == -1:
        before = height
    if identified:
      print(x, y, before)


### FIXED CODE ###

N = int(input())
surveys = [list(map(int, input().split())) for _ in range(N)]
surveys.sort(key = lambda x:-x[2])
for x in range(101):
  for y in range(101):
    before = -1
    identified = True
    for survey in surveys:
      height = survey[2] + abs(x-survey[0]) + abs(y-survey[1])
      if before != -1 and before != height:
        if survey[2] == 0 and before < height:
          continue
        identified = False
        break
      if before == -1:
        before = height
    if identified:
      print(x, y, before)
      break
X=abs(int(input()))
ct=1
sum=1
while X<=sum:
  ct+=1
  sub+=ct
print(ct)X=int(input())
ct=1
sum=1
while X>sum:
  ct+=1
  sum+=ct
print(ct)

### FIXED CODE ###

X=int(input())
ct=1
sum=1
while X>sum:
  ct+=1
  sum+=ct
print(ct)
import sys, math, heapq, bisect





if(__name__ == "__main__"):
    """
    N = int( input().strip() )
    Length = list( map(int, input().strip().split() ) )
    """
    H, W, N_bombs= map(int, input().strip().split() )

    H_N_bomb = [ [0, i]  for i in range(H) ]
    W_N_bomb = [ [0, i]  for i in range(W) ]
    bombs = [ [0]*W for _ in range(H)  ]


    for i in range(N_bombs):
        y, x = map(int, input().strip().split() )

        W_N_bomb[x-1][0] += 1
        H_N_bomb[y-1][0] += 1
        bombs[y-1][x-1] = 1


    W_N_bomb.sort(key = lambda x: x[0])
    H_N_bomb.sort(key = lambda x: x[0])



    Ws = [0] * W
    Hs = [0] * H
    for i in range(W):
        Ws[i] = W_N_bomb[i][0]
    for i in range(H):
        Hs[i] = H_N_bomb[i][0]

    pos_x= bisect.bisect_left(Ws, Ws[-1])
    pos_y= bisect.bisect_left(Hs, Hs[-1])
    #print(W_N_bomb, H_N_bomb, pos_x, pos_y)
    flag = False
    value = Ws[-1] + Hs[-1]
    for i in range(pos_x, W):
        for j in range(pos_y, H):
            pos_i = W_N_bomb[i][1]
            pos_j = H_N_bomb[j][1]
            if(bombs[pos_j][pos_i]==0):
                flag=True
                break
    if(flag==True):
        print(value)
    else:
        print(value-1)


### FIXED CODE ###

import sys, math, bisect



def solve(W_N, V_N, bombs, H, W):

    max_x = 1
    xs = []
    for i in range(W):
        if(W_N[i] > max_x):
            max_x = W_N[i]
            xs = [i]
        elif(W_N[i] == max_x):
            xs.append(i)
    max_y = 1
    ys = []
    for j in range(H):
        if(V_N[j] > max_y):
            max_y = V_N[j]
            ys = [j]
        elif(V_N[j] == max_y):
            ys.append(j)

    value = max_x + max_y

    for j in ys:

        bombs[j].sort()
        for i in xs:
            index = bisect.bisect_left(bombs[j], i)
            if(index == V_N[j] or i != bombs[j][index]):
                return value
            
    return value-1



if(__name__ == "__main__"):
    """
    N = int( input().strip() )
    Length = list( map(int, input().strip().split() ) )
    """
    H, W, N_bombs= map(int, input().strip().split() )


    V_N = [0] * H
    W_N = [0] * W
    bombs = [ [] for _ in range(H) ]


    for i in range(N_bombs):
        y, x = map(int, input().strip().split() )
        """
        W_N_bomb[x-1][0] += 1
        V_N_bomb[y-1][0] += 1
        """
        V_N[y-1] += 1
        W_N[x-1] += 1
        bombs[y-1].append(x-1)




    print( solve(W_N, V_N, bombs, H, W) )
from sys import stdin
from collections import Counter
N = int(stdin.readline().rstrip())
data = [0] * N
for _ in range(N):
    A,B = [int(x) for x in stdin.readline().rstrip().split()]
    data[_] = (A,B)
data=sorted(data)
max_value = 0
diff = []
for j in range(0,N-1):
    for i in range(j+1,N):
        diff.append((data[j][0]-data[i][0],data[j][1]-data[i][1]))
    d=Counter(diff)
    #max_value = max(max_value,max(d.values()))
print(N-max(d.values()))

### FIXED CODE ###

from sys import stdin
from collections import Counter
N = int(stdin.readline().rstrip())
data = [0] * N
if N != 1:
    for _ in range(N):
        A,B = [int(x) for x in stdin.readline().rstrip().split()]
        data[_] = (A,B)
    data=sorted(data)
    max_value = 0
    diff = []
    for j in range(0,N-1):
        for i in range(j+1,N):
            diff.append((data[j][0]-data[i][0],data[j][1]-data[i][1]))
    d=Counter(diff)
        #max_value = max(max_value,max(d.values()))
    print(N-max(d.values()))
else:
    print(1)
n = input()
for number in n:
  taro_string, hanako_string = raw_input().split()
  if taro_string > hanako_string:
    taro += 3
  elif hanako_string > taro_string:
    hanako += 3
  else:
    taro += 1
    hanako += 1
print taro + ' ' + hanako 

### FIXED CODE ###

n = input()
taro, hanako = 0, 0
for number in range(n):
  taro_string, hanako_string = raw_input().split()
  if taro_string > hanako_string:
    taro += 3
  elif hanako_string > taro_string:
    hanako += 3
  else:
    taro += 1
    hanako += 1
print taro, hanako
d, n  = map(int, input().split())

if d == 0:
    if n == 100:
        print 101
    else:
        print(1 * n)
if d == 1:
    if n == 100:
        print 10001
    else:
        print(100 * n)
if d == 2:
    if n == 100:
        print 1000001
    else:
        print(10000 * n)

### FIXED CODE ###

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

if d == 0:
    if n == 100:
        print(101)
    else:
        print(1 * n)
if d == 1:
    if n == 100:
        print(10100)
    else:
        print(100 * n)
if d == 2:
    if n == 100:
        print(1010000)
    else:
        print(10000 * n)
a=[int(input()) for i in range(5)]
k=int(input())
for i in range(n-4):
  for j in range(1,n):
    if abs(a[i]-a[j])>k:
      print(':(')
      exit()
print('Yay')

### FIXED CODE ###

a=[int(input()) for i in range(5)]
k=int(input())
for i in range(4):
  for j in range(1,5):
    if abs(a[i]-a[j])>k:
      print(':(')
      exit()
print('Yay!')
n = int(input())
alist=list(map(int,input().split()))
core = 0
for i in range(1,n-2):
  core +=min(alist[i-1],alist[i],alist[i+1])
print(core +min(alist[-2],alist[-1]) +alist[-1] +min(alist[0],alist[1]))

### FIXED CODE ###

n = int(input())
alist=list(map(int,input().split()))
alist.insert(0,1e7)
alist.append(1e7)
core = 0
for i in range(n):
  core +=min(alist[i],alist[i+1])
print(core)
import sys
import math

N = int(input())
A = [int(x) for x in input().split()]

A2 = [a - i - 1 for i, a in enumerate(A)]

B = sorted(A2)

i1 = math.floor(N / 2)
i2 = math.ceil(N / 2)


b1 = B[i1]
b2 = B[i2]


def calcSad(A2, b):
    sum = 0
    for i in A2:
        sum += abs(i - b)
    return sum


sum = 99999999999999999999999
for b in range(b1, b2+1):
    s = calcSad(B, b)
    sum = min(sum, s)

print(sum)


sys.exit(0)


### FIXED CODE ###

import sys
import math

N = int(input())
A = [int(x) for x in input().split()]
A2 = [a - i - 1 for i, a in enumerate(A)]

B = sorted(A2)

b = B[int(N/2)]


A3 = [abs(a - b) for a in A2]

print(sum(A3))


sys.exit(0)
import statistics  
N = int(input())
A=list(map(int, input().split()))
B=[]
for number, i in enumerate(A, 1):
    B.append(i-number)
median = int(statistics.median(B))
ans2 = 0
for i in B:
    ans2 += abs(i-median)
print(ans2)

### FIXED CODE ###

import statistics  
N = int(input())
A=list(map(int, input().split()))
B=[]
for number, i in enumerate(A, 1):
    B.append(i-number)
median = int(statistics.median(B))
ans2 = 0
for i in B:
    ans2 += abs(i-median)
print(ans2)
S = input()
l = len(S)
if l != 26:
    colors = [0]*26
    for i in range(26):
        colors[ ord(S[i]) - ord('a')]
    for i in range(26):
        if colors[i] == 0:
            ans = S + chr( i + ord('a'))
            break
    print(ans)
elif S == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
else:
    for i in range(25,0,-1):
        if S[i] > S[i-1]:
            now = i
            break
    print(S[:i-1] + S[-1])

### FIXED CODE ###

S = input()
l = len(S)
if l != 26:
    colors = [0]*26
    for i in range(l):
        colors[ ord(S[i]) - ord('a')] = 1
    for i in range(26):
        if colors[i] == 0:
            ans = S + chr( i + ord('a'))
            break
    print(ans)
elif S == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
else:
    for i in range(25,0,-1):
        if S[i] > S[i-1]:
            now = i
            break
    colors = [0]*26
    for i in range(now-1):
        colors[ ord(S[i]) - ord('a')] = 1
    c = 'z'
    for i in range(now-1,26):
        if S[now-1] < S[i]:
            c = min(c, S[i])
    print(S[:now-1]+c)
from collections import deque
# N = int(input())
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
MOD = 10 ** 9 + 7
A_p = []
A_n = []
for a in A:
  if a >= 0:
    A_p.append(a)
  else:
    A_n.append(-a)

A_p.sort(reverse=True)
A_n.sort(reverse=True)
A_p = deque(A_p)
A_n = deque(A_n)

p_top = 0
n_top = 0
ans_p = deque([])
ans_n = deque([])
for i in range(K):
  if len(A_p) == 0:
    ans_n.append(A_n.popleft())
  elif len(A_n) == 0:
    ans_p.append(A_p.popleft())
  elif A_p[0] >= A_n[0]:
    ans_p.append(A_p.popleft())
  else:
    ans_n.append(A_n.popleft())
if len(ans_n) % 2 == 1:
  if len(ans_p) == 0 and len(A_p) > 0:
    ans_n.pop()
    ans_p.append(A_p.popleft())
  elif len(ans_n) == 0 and len(A_n) > 0:
    ans_p.pop()
    ans_n.append(A_n.popleft())
  elif len(ans_p) > 0 and len(ans_n) > 0 and ans_p[-1] >= ans_n[-1] and len(A_p) > 0 and A_p[0] != 0:
    ans_n.pop()
    ans_p.append(A_p.popleft())
  elif len(ans_p) > 0 and len(ans_n) > 0 and ans_p[-1] < ans_n[-1] and len(A_n) > 0:
    ans_p.pop()
    ans_n.append(A_n.popleft())
ans = 1
for a in ans_p:
  ans = (a * ans) % MOD
for a in ans_n:
  ans = (a * ans) % MOD
if ans != 0 and len(ans_n) % 2 == 1:
  ans = 1
  A = [a for a in A if a < 0]
  A.sort(reverse=True)
  for i in range(K):
    ans = (ans * A[i]) % MOD
print(ans)




### FIXED CODE ###

from collections import deque
# N = int(input())
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
MOD = 10 ** 9 + 7
A_p = []
A_n = []
for a in A:
  if a >= 0:
    A_p.append(a)
  else:
    A_n.append(-a)

A_p.sort(reverse=True)
A_n.sort(reverse=True)
A_p = deque(A_p)
A_n = deque(A_n)

p_top = 0
n_top = 0
ans_p = deque([])
ans_n = deque([])
for i in range(K):
  if len(A_p) == 0:
    ans_n.append(A_n.popleft())
  elif len(A_n) == 0:
    ans_p.append(A_p.popleft())
  elif A_p[0] >= A_n[0]:
    ans_p.append(A_p.popleft())
  else:
    ans_n.append(A_n.popleft())
if len(ans_n) % 2 == 1:
  if len(ans_p) == 0 and len(A_p) > 0:
    ans_n.pop()
    ans_p.append(A_p.popleft())
  elif len(ans_n) == 0 and len(A_n) > 0:
    ans_p.pop()
    ans_n.append(A_n.popleft())
  elif len(ans_p) > 0 and len(ans_n) > 0 and len(A_p) > 0 and len(A_n) > 0 and ans_p[-1] * A_p[0] >= ans_n[-1] * A_n[0]:
    ans_n.pop()
    ans_p.append(A_p.popleft())
  elif len(ans_p) > 0 and len(A_n) > 0:
    ans_p.pop()
    ans_n.append(A_n.popleft())
  elif len(ans_n) > 0 and len(A_p) > 0:
    ans_n.pop()
    ans_p.append(A_p.popleft())
ans = 1
for a in ans_p:
  ans = (a * ans) % MOD
for a in ans_n:
  ans = (-a * ans) % MOD
if ans != 0 and len(ans_n) % 2 == 1:
  ans = 1
  A_abs = [abs(a) for a in A]
  A_abs.sort()
  for i in range(K):
    ans = (ans * A_abs[i]) % MOD
  ans = (-ans) % MOD
print(ans)
a = int(input())
op = input()
b = int(input())
if op == "+":
  print(a+b)
else:
  print(a-b)

### FIXED CODE ###

a,b,c = input().split()
a,c = int(a),int(c)
if b == "+":
  print(a+c)
else:
  print(a-c)
#int でsplitを使う場合はmap関数を利用しなければならない
H,N = map(int,input().split())
li=[]
x=[]
for i in range(N):
    A,B = map(int,input().split())
    x.append(A)
    li.append([A,B])
dp = [10**9]*(H+max(x))
dp[0] = 0
for i in range(1,len(dp)):
    dp[i] = min(dp[i-a] + b for a,b in li)
print(min(dp[h:]))


### FIXED CODE ###

#int でsplitを使う場合はmap関数を利用しなければならない
H,N = map(int,input().split())
li=[]
x=[]
for i in range(N):
    A,B = map(int,input().split())
    x.append(A)
    li.append([A,B])
dp = [10**9]*(H+max(x))
dp[0] = 0
for i in range(1,len(dp)):
    dp[i] = min(dp[i-a] + b for a,b in li)
print(min(dp[H:]))
H, A = int(input().split())
i = 1

for j in range(10000):
  # i 回目の攻撃
  H = H - A
  
  # HP判定
  if H <= 0:
    i = i
  else:
    i = i + 1

# 何回攻撃すればよいか
if H <= 0:
  print(i)

### FIXED CODE ###

H, A = map(int, input().split())
i = 1

for j in range(10000):
    H = H - A
    if H <= 0:
        i = i
    else:
        i = i + 1
if H <= 0:
    print(i)
l = []
while True:
  m,f,r = map(int,input().split())
  if m == f == r == -1:
    break
  else:
    l.append([m,f,r])
for i in l:
  s = ''
  x = i[0] + i[1]
  if i[0] == -1 or i[1] == -1:
    s = 'F'
  elif x >= 80:
    s = 'A'
  elif x >= 65:
    s = 'B':
  elif x >= 50:
    s = 'C':
  elif x >= 30:
    s = 'D'
    if i[2] >= 50:
      s = 'C'
  else:
    s = 'F'
  print(s)

### FIXED CODE ###

def code():
	l = []
	while True:
		m,f,r = map(int,input().split())
		if m == f == r == -1:
			break
		else:
			l.append([m,f,r])
	for i in l:
		s = ''
		x = i[0]+i[1]
		if i[0] == -1 or i[1] == -1:
			s = 'F'
		elif x >= 80:
			s = 'A'
		elif x >= 65:
			s = 'B'
		elif x >= 50:
			s = 'C'
		elif x >= 30:
			s = 'D'
			if i[2] >= 50:
				s = 'C'
		else:
			s = 'F'
		print(s)
code()
from math import pi
R=input()
print(2*R*pi)

### FIXED CODE ###

from math import pi
R=float(input())
print(2*R*pi)
N = int(input())
routes = [(0,0,0)]
append = routes.append
for _ in range(0, N):
    t, x, y = map(int, input().split())
    append((t, x, y))
for i in range(1, N+2):
    bt, bx, by = routes[i-1]
    t, x, y = routes[i]
    ct = t - bt
    # xだけで考える。yとxは独立させて考えて問題ない。両方が成立しなければ成立しないため。
    cx = x - bx
    cy = y - by
    if cx > ct or cy > ct:
        print ("No")
        exit()
    if (cx+cy) % 2 != ct % 2:
        print ("No")
        exit()
print ("Yes")

### FIXED CODE ###

N = int(input())
routes = [(0,0,0)]
append = routes.append
for _ in range(0, N):
    t, x, y = map(int, input().split())
    append((t, x, y))
for i in range(1, N+1):
    bt, bx, by = routes[i-1]
    t, x, y = routes[i]
    ct = t - bt
    # xだけで考える。yとxは独立させて考えて問題ない。両方が成立しなければ成立しないため。
    cx = abs(x - bx)
    cy = abs(y - by)
    if cx > ct or cy > ct:
        print ("No")
        exit()
    if (cx+cy) % 2 != ct % 2:
        print ("No")
        exit()
print ("Yes")
n = int(input())
s = input()
if n==1:
    print("No")
    exit()

if n % 2 == 0:
    n //= 2
else:
    n = n // 2 + 1
s2 = s[n:]
for i in range(n):
    if s[i] != s2[i]:
        print("No")
        exit()
print("Yes")

### FIXED CODE ###

n = int(input())
s = input()

if n % 2 == 0:
    n //= 2
else:
    print("No")
    exit()
s2 = s[n:]
for i in range(n):
    if s[i] != s2[i]:
        print("No")
        exit()
print("Yes")
n = int(input())
print(n(n+1)/2)

### FIXED CODE ###

n = int(input())
print(int(n*(n+1)/2))
a,b  = int(input().split())
print(a*b)

### FIXED CODE ###

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

if(a > 9 or b > 9):
    print("-1")
else:

    print(a*b)
def fatora(n):
	ans = []
	for i in range(1, n+1):
		if i*i > n:
			break
		else:
			if n % i == 0:
				ans.append(i)
				ans.append(n//i)
	return set(ans)

def eh_primo(n):
	if n == 0:
		return False
	elif n == 1:
		return True
	elif n == 2:
		return True
	else:
		for i in range(2, n+10):
			if i*i > n:
				break
			else:
				if n % i == 0:
					return False
		return True


import math

a, b = map(int, input().split())
new_gcd = math.gcd(a,b)

print(len(list(filter(eh_primo, fatora(new_gcd)))))

### FIXED CODE ###

def fatora(n):
	ans = []
	for i in range(1, n+1):
		if i*i > n:
			break
		else:
			if n % i == 0:
				ans.append(i)
				ans.append(n//i)
	return set(ans)

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a%b)


def eh_primo(n):
	if n == 0:
		return False
	elif n == 1:
		return True
	elif n == 2:
		return True
	else:
		for i in range(2, n+10):
			if i*i > n:
				break
			else:
				if n % i == 0:
					return False
		return True



a, b = map(int, input().split())
print(len(list(filter(eh_primo, fatora(gcd(a, b))))))
n, m = map(int, input().split())
ps_list = [[i for i in input().split()] for j in range(m)]

ac_list = []
wa_dict = {}
num_wa = 0

for ps in ps_list:
    p = int(ps[0])
    s = ps[1]
    
    if s == 'AC':
        ac_list.append(p)
        num_wa += wa_dict[p]
    elif p not in ac_list:
        if p not in wa_dict.keys():
            wa_dict[p] = 1
        else:
            wa_dict[p] += 1
            
num_ac = len(ac_list)
        
print(num_ac, num_wa)

### FIXED CODE ###

n, m = map(int, input().split())
ps_list = [[i for i in input().split()] for j in range(m)]

ac_list = []
wa_list = [0 for i in range(n)]
num_wa = 0
num_ac = 0

for ps in ps_list:
    p = int(ps[0])
    s = ps[1]
    
    if s == 'AC' and wa_list[p-1] != -1:
        ac_list.append(p)
        num_wa += wa_list[p-1]
        num_ac += 1
        wa_list[p-1] = -1
    elif wa_list[p-1] != -1:
        wa_list[p-1] += 1
        
print(num_ac, num_wa)
x , n= map(int,input().split())
p = list(map(int,input().split()))
ans = []
if n == 0:
    print(x)
else:
    for i in range(1,101):
        if i in p:
            pass
        else:
            ans.append(i)
    sa = []
    for i in range(len(ans)):
        sa.append(abs(ans[i]-x))
    MIN=min(sa)
    for i in range(len(ans)):
        if MIN == abs(ans[i]-x):
            print(ans[i])
            break

### FIXED CODE ###

x , n= map(int,input().split())
p = list(map(int,input().split()))
ans = []
if n == 0:
    print(x)
else:
    for i in range(-10,102):
        if i in p:
            pass
        else:
            ans.append(i)
    sa = []
    for i in range(len(ans)):
        sa.append(abs(ans[i]-x))
    MIN=min(sa)
    for i in range(len(ans)):
        if MIN == abs(ans[i]-x):
            print(ans[i])
            break
def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if x%y == 0:
        return y
    else:
        while x%y!=0:
            z = x%y
            x = y
            y = z
        else:
            return z

# import math
a, b, c, d = map(int, input().split())
b_c = int(b/c)
b_d = int(b/d)
cd = int(c * d / gcd(c,d))
b_cd = int(b / cd)
bn = b_c + b_d - b_cd
# print("bn:",bn)
a -= 1
a_c = int(a/c)
a_d = int(a/d)
a_cd = int(a / cd)
an = a_c + a_d - a_cd
# print("an:",an)

num = b - a - (bn - an)
print(num)

### FIXED CODE ###

S = input()
text = "Good"
for i in range(3):
    if S[i] == S[i+1]:
        text = "Bad"
print(text)
import math

A, B, N= (int(x) for x in input().split())
#x = B * math.floor(N/B) - 1
x =  B - 1
if N < B
    x = N
a = math.floor(A * x / B) - A * math.floor(x / B)
b = math.floor(A * N / B) - A * math.floor(N / B)

if a > b:
    print(a)
else:
    print(b)

### FIXED CODE ###

import math

A, B, N= (int(x) for x in input().split())
#x = B * math.floor(N/B) - 1
x =  B - 1
if N < B:
    x = N
a = math.floor(A * x / B) - A * math.floor(x / B)
# b = math.floor(A * N / B) - A * math.floor(N / B)
print(a)
def generate_block(s):
    table = []
    j = 0
    for i in range(len(s)-1):
        if s[i] != s[i+1]:
            table.append(s[j:i+1])
            j = i + 1
    return table

def happy(s):
    count = 0
    ll = len(s)
    for i in range(ll):
        if i != ll-1 and s[i] == 'R' and s[i+1] == 'R': count += 1
        if i != 0 and s[i] == 'L' and s[i-1] == 'L': count += 1
    return count

n, k = map(int, input().split())
s = input() + '.'
x = 0
table = generate_block(s)[::-1]
while k > 0:
    pos = 2 * x + 1
    if pos > len(table): break
    if 'L' in table[pos]: table[pos] = table[pos].replace('L', 'R')
    else: table[pos] = table[pos].replace('R', 'L')
    k -= 1
    x += 1
print(happy(''.join(table)))

### FIXED CODE ###

def generate_block(s):
    table = []
    j = 0
    for i in range(len(s)-1):
        if s[i] != s[i+1]:
            table.append(s[j:i+1])
            j = i + 1
    return table

def happy(s):
    count = 0
    ll = len(s)
    for i in range(ll):
        if i != ll-1 and s[i] == 'R' and s[i+1] == 'R': count += 1
        if i != 0 and s[i] == 'L' and s[i-1] == 'L': count += 1
    return count

n, k = map(int, input().split())
s = input() + '.'
x = 0
table = generate_block(s)[::-1]
while k > 0:
    pos = 2 * x + 1
    if pos >= len(table): break
    if 'L' in table[pos]: table[pos] = table[pos].replace('L', 'R')
    else: table[pos] = table[pos].replace('R', 'L')
    k -= 1
    x += 1
print(happy(''.join(table)))
def BellmanFord(sv, ev, cv, num_v, source):
  #グラフの初期化
  inf=float("inf")
  dist=[inf for i in range(num_v)]
  dist[source-1]=0
  
  #辺の緩和
  for i in range(num_v):
    for s,e,c in zip(sv, ev, cv):
      if dist[0] != inf and dist[e-1] > dist[s-1] + c:
        dist[e-1] = dist[s-1] + c
        if i==num_v-1: return 1
  
  return dist

N, M = map(int, input().split())
a, b, c = [], [], []
for i in range(M):
  aa, bb, cc = map(int, input().split())
  a.append(aa)
  b.append(bb)
  c.append(cc*-1)

print(BellmanFord(a, b, c, N, 1)[N-1]*-1)


### FIXED CODE ###

import sys

INF = float('inf')

def Bellmanford(n, edges, r): #r: 始点
    d = [INF] * n
    d[r] = 0
    
    for i in range(n):
        for (u, v, c) in edges:
            if d[u] != INF and d[u] + c < d[v]:
                d[v] = d[u] + c
                if i == n-1 and v == n-1:
                    return 'inf'
    
    return -d[n-1]
    

N, M = map(int, sys.stdin.readline().split())
Edges = [None] * M

for i in range(M):
    ai, bi, ci = map(int, sys.stdin.readline().split())
    Edges[i] = (ai-1, bi-1, -ci)
    
ans = Bellmanford(N, Edges, 0)

print(ans)
import numpy as np
(h,w,m),*e=[[*map(int,i.split())]for i in open(0)]
a=np.zeros((h,w),int)
for y,x in e:a[y-1][x-1]=1
y=np.sum(a,axis=1)
x=np.sum(a,axis=0)
mx,my=max(x),max(y)
# b=sum(y[i-1]+x[j-1]==mx+my for i,j in e)
# b-=len(np.where(y==my)[0])*len(np.where(x==mx)[0])
print(mx+my)

### FIXED CODE ###

(h,w,m),*e=[[*map(int,i.split())]for i in open(0)]
a,b=[0]*h,[0]*w
for y,x in e:
    a[y-1]+=1
    b[x-1]+=1
ans=max(a)+max(b)
c=a.count(max(a))*b.count(max(b))-sum(a[y-1]+b[x-1]==ans for y,x in e)
print(ans-(c<=0))
a , b = map(int, input().split())
if a * b % 2 == 0:
print("Even")
else:
  print("Odd")

### FIXED CODE ###

a,b = map(int, input().split())
if a * b % 2 == 0:
  print('Even')
else:
  print('Odd')
N = input()
flag = false
for i in range(N):
  if N[i] == "7":
    flag = true
if flag: print("Yes")
else: print("No")

### FIXED CODE ###

N = input()
flag = False
for i in range(len(N)):
  if(N[i] == "7"):
    flag = True
if flag: 
    print("Yes")
else: 
    print("No")