Harryxun/stf_run huggingface dataset:
w,h,n=map(int,input().split())
record=[]
xmin=[]
xmax=[]
ymin=[]
ymax=[]

for i in range(n):
    x,y,a=list(map(int,input().split()))
    record.append([x,y,a])
    
for i in range(n):
    if record[i][2] == 1:
        xmin.append(record[i][0])
    elif record[i][2] == 2:
        xmax.append(record[i][0])
    elif record[i][2] == 3:
        ymin.append(record[i][1])
    else:
        ymax.append(record[i][1])

if xmax==[]:
    X=w-max(xmin)
elif ymax==[]:
    X=min(xmax)-0
else:
    X=min(xmax)-max(xmin)

if ymax==[]:
    Y=h-max(ymin)
elif ymin==[]:
    Y=min(ymax)-0
else:
    Y=min(ymax)-max(ymin)
    
print(X*Y) if (X > 0 and Y > 0) else print(0) 


### FIXED CODE ###

w,h,n=map(int,input().split())
record=[]
xmin=[]
xmax=[]
ymin=[]
ymax=[]

for i in range(n):
    x,y,a=list(map(int,input().split()))
    record.append([x,y,a])
    
for i in range(n):
    if record[i][2] == 1:
        xmin.append(record[i][0])
    elif record[i][2] == 2:
        xmax.append(record[i][0])
    elif record[i][2] == 3:
        ymin.append(record[i][1])
    else:
        ymax.append(record[i][1])

if xmax==[] and xmin==[]:
    X=w
elif xmax==[]:
    X=w-max(xmin)
elif xmin==[]:
    X=min(xmax)-0
else:
    X=min(xmax)-max(xmin)

if ymax==[] and ymin==[]:
    Y=h
elif ymax==[]:
    Y=h-max(ymin)
elif ymin==[]:
    Y=min(ymax)-0
else:
    Y=min(ymax)-max(ymin)
    
print(X*Y) if (X > 0 and Y > 0) else print(0)
import math

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

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

print(lcm(a,b))

### FIXED CODE ###

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a


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

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

print(lcm(a,b))
N,X = map(int,input().split())
L = list(map(int,input().split()))
zahyou = 0
count = 0

for i in range(N+1):
  if zahyou <= X:
    zahyou +=  L[i]
    count += 1
print(count)

### FIXED CODE ###

N,X = map(int,input().split())
L = list(map(int,input().split()))
zahyou = 0
count = 0

for i in range(N):
  if zahyou <= X:
    zahyou +=  L[i]
    count += 1
if zahyou <= X:
  count += 1
print(count)
import fractions as math
#import fractions as math
n = int(input())
list1 = list(map(int,input().split()))
a = math.gcd(list1[0],list1[-1])
b = 0
for i in range(0,n):
	if a > math.gcd(a,list1[i]):
		a = math.gcd(a,list1[i])
		b = list1.index(list1[i])
del list1[b]
a = list1[0]
for i in range(0,len(list1)):
	a = min(a,math.gcd(a,list1[i]))
print(a)


### FIXED CODE ###

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

print(t//a*b)
N = int(input())

prime = [3, 5, 7, 11, 13]

# 約数が8個ということは、素因数分解した時の素因数の個数が0/7, 1/3, 1/1/1以外ありえない
zero_seven = 0
one_three = [a * (b ** 3) for a in prime for b in prime if a != b]
one_three = [i for i in one_three if i <= 200]
one_one_oen = [a * b * c for a in prime for b in prime for c in prime
               if a != b and b != c and c != a]
one_one_oen = [i for i in one_one_oen if i <= 200]

ans = sorted(set(one_three + one_one_oen))
i = 0
if ans[-1] < N:
    print(len(ans))
else: 
    while ans[i] <= N:
        i += 1
        if ans[i] > N:
            print(i)
            quit()

print(i)

### FIXED CODE ###

N = int(input())

prime = [3, 5, 7, 11, 13]

# 約数が8個ということは、素因数分解した時の素因数の個数が0/7, 1/3, 1/1/1以外ありえない
zero_seven = 0
one_three = [a * (b ** 3) for a in prime for b in prime if a != b]
one_three = [i for i in one_three if i <= 200]
one_one_one = [a * b * c for a in prime for b in prime for c in prime
               if a != b and b != c and c != a]
one_one_one = [i for i in one_one_one if i <= 200]

ans = sorted(set(one_three + one_one_one))
if N <= 104:
    print(0)
elif 105 <= N <= 134:
    print(1)
elif 135 <= N <= 164:
    print(2)
elif 165 <= N <= 188:
    print(3)
elif 189 <= N <= 194:
    print(4)
elif 195 <= N:
    print(5)
n=int(input())
listx=list(map(int,input().split()))
listx.sort()
x=1
if listx[0]!=0:
  x=0
else:
  for i in range(listx[-1]):
    x*=listx.count(int(i+1))+1
print(x)

### FIXED CODE ###

n=int(input())
if n%2==0:
  print(int(n/2-1))
else:
  print(int((n-1)/2))
import sys
N = int(input())
A = [int(i) for i in input().split()]
for i,a in enumerate(A):
    if a in A[i+1:]
        print("NO")
        sys.exit(0)
print("YES")

### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]
def test(A):
    return len(A)!= len(set(A))
if test(A)==False:
    print("YES")
else:
    print("NO")
N=int(input())
s=input()

ans=0
i,j=0,N-2
while i<j:
    if s[i]=='R':
        i+=1
    elif s[j]=='W':
        j-=1
    else:
        k+=1
        i+=1
        j-=1

print(k)


### FIXED CODE ###

import sys

N=int(input())
s=list(input().strip())

#print(s)

k=0
i,j=0,N-1
while i<j:
    if s[i]=='R':
        i+=1
    elif s[j]=='W':
        j-=1
    else:
        s[i]='W'
        s[j]='R'
        k+=1
        i+=1
        j-=1

print(k)
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
import numpy as np

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, Q = MAP()
A = [LIST() for i in range(N-1)]
P = [LIST() for i in range(Q)]

tree = defaultdict(list)

# ノードの重み

cnt = [0] * N

# tree 隣接リスト
for i in range(N-1):
    tree[A[i][0]-1].append(A[i][1]-1)
    tree[A[i][1]-1].append(A[i][0]-1)

for i in range(Q):
    cnt[P[i][0]-1] += P[i][1]

ans = [0] * N
q = deque([])
# 始点
q.append(0)
# 各頂点を見たかどうかのフラグ
checked = [0] * N
checked[0] = 1

while q:
    v = q.popleft()
    checked[v] = 1
    for u in tree[v]:
        if checked[u] == 1:
            continue
        cnt[u] += cnt[v]
        q.append(u)
print(*cnt)


### FIXED CODE ###

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
import numpy as np

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, Q = MAP()

tree = defaultdict(list)

# ノードの重み

cnt = [0] * N

# tree 隣接リスト
for i in range(N-1):
    a, b = LIST()
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

for i in range(Q):
    node, point = LIST()
    cnt[node-1] += point

ans = [0] * N
q = deque([])
# 始点
q.append(0)
# 各頂点を見たかどうかのフラグ
checked = [0] * N
checked[0] = 1

while q:
    v = q.pop()
    checked[v] = 1
    for u in tree[v]:
        if checked[u] == 1:
            continue
        cnt[u] += cnt[v]
        q.append(u)
print(*cnt)
while True:
    
    a,b= map(int,input().split())
    if a==A:
        a=10
    if a==B:
        a=11
    if a==C:
        a=12
    if a==D:
        a=13

    if a==E:
        a=14
    if a==F:
        a=15

    if b==A:
        b=10
    if b==B:
        b=11
    if b==C:
        b=12
    if b==D:
        b=13

    if b==E:
        b=14
    if b==F:
        b=15

    if a>b:
        print(">")
    elif b>a:
        print("<")
    else:
        print("=")
    

### FIXED CODE ###


s=0
s=input().split()
a=s[0]
b=s[1]
if a=="A":
    a=10
if a=="B":
    a=11
if a=="C":
    a=12
if a=="D":
    a=13

if a=="E":
    a=14
if a=="F":
    a=15

if b=="A":
    b=10
if b=="B":
    b=11
if b=="C":
     b=12
if b=="D":
    b=13

if b=="E":
     b=14
if b=="F":
     b=15

if a>b:
    print(">")
if b>a:
    print("<")
if a==b:
    print("=")
S = input()
if S == "Sunny":
    print("Cloudy")
elif S =="Cloudy":
    print("Rainy"):
else:
    print("Sunny")

### FIXED CODE ###

S = input()
if S == "Sunny":
    print("Cloudy")
elif S =="Cloudy":
    print("Rainy")
elif S==("Rainy"):
    print("Sunny")
x, y = map(int, input().split())
 
    if abs(x - y) <= 1:
        print('Brown')
    else:
        print('Alice')
 

### FIXED CODE ###

x, y = map(int, input().split())
 
if abs(x - y) <= 1:print('Brown')
else:
  print('Alice')
N = int(input())
a = map(int, input().split())
a = [0] + list(a)
b = [0 for i in range(N+1)]
result_str = ''

for i in range(N, 0, -1):
  i_sum = 0
  for j in range(1, N // i + 1):
    i_sum += b[j*i]
  if i_sum % 2 != a[i]:
    b[i] = 1
    result_str = '{}　'.format(i) + result_str

print(sum(b))
if sum(b) != 0:
    print(result_str[:-1])


### FIXED CODE ###

a = int(input())
print(3*(a**2))
N, Q = map(int, input().split())
str = input()
length = [list(map(int, input().split())) for _ in range(Q)]

ans = [0 for _ in range(N)]
for i in range(1, N):
    if (str[i-1] == "A"):
        if (str[i] == "C"):
            ans[i] = ans[i-1] + 1
        else:
            ans[i] = ans[i-1]
    else:
        ans[i] = ans[i-1]
        ans[i+1] = ans[i-1]
        i += 1

for l1, l2 in length:
    # print(ans)
    print(ans[l2-1] - ans[l1-1])


### FIXED CODE ###

N, Q = map(int, input().split())
str = input()
length = [list(map(int, input().split())) for _ in range(Q)]

ans = [0 for _ in range(N)]
for i in range(1, N):
    if (str[i-1] == "A") and (str[i] == "C"):
        ans[i] = ans[i-1] + 1
    else:
        ans[i] = ans[i-1]

for l1, l2 in length:
    # print(ans)
    print(ans[l2-1] - ans[l1-1])
,b=map(int,input().split())

List=[]
for i in range(a):
    List.append(input())

print("".join(sorted(List)))

### FIXED CODE ###

a,b,c,=map(int,input().split())
if a+b+c==17:
  print("YES")
else:
  print("NO")
s=input()
print("ABC"+f"{s}")


### FIXED CODE ###

s=input()
print("ABC"+s)
N,K=int(input().split())
lists=[0]*N
while 1:
    tmp=int(input())
    if not tmp:
        break
    have_count=int(input().split())
    for i in have_count:
        lists[i-1]=1
print(lists.count(0))

### FIXED CODE ###

N,K=(int(x) for x in input().split())
lists=[0]*N
while 1:
    try:
        tmp=int(input())
    except :
        break
    have_count=(int(x) for x in input().split())
    for i in have_count:
        lists[i-1]=1
print(lists.count(0))
#D
from collections import deque
n,k=map(int,input().split())
s=input()

a=deque([])
if s[0]=="1":
    a.append([0])
for i in range(1,n):
    if s[i-1:i+1]=="01":
        a.append([i])
    elif s[i-1:i+1]=="10":
        a[-1].append(i-1)
if s[n-1]=="1":
    a[-1].append(n-1)

if a[0][0]!="0":
    a.appendleft([0,0])
if a[-1][1]!="n-1":
    a.append([n-1,n-1])

if len(a)-1<=k:
    print(n)
else:
    t=[]
    for i in range(len(a)-1-k):
        t.append(a[i+k][1]-a[i][0])
    print(max(t)+1)

### FIXED CODE ###

#D
from collections import deque
n,k=map(int,input().split())
s=input()
if n==1:
    print(1)
elif "1" not in s:
  	print(len(s))
else:
    a=deque([])
    if s[0]=="1":
        a.append([0])
    for i in range(1,n):
        if s[i-1:i+1]=="01":
            a.append([i])
        elif s[i-1:i+1]=="10":
            a[-1].append(i-1)
    if s[n-1]=="1":
        a[-1].append(n-1)
    if a[0][0]!=0:
        a.appendleft([0,0])
    if a[-1][1]!=n-1:
        a.append([n-1,n-1])
    if len(a)-1<=k:
        print(n)
    else:
        t=0
        for i in range(len(a)-k):
            t=max(t,a[i+k][1]-a[i][0]+1)
        print(t)
import functools
import math

def gcd(x,y):
    a,b = max(x,y), min(x,y)
    while a % b != 0:
        a,b = b,a%b

    return b

def lcm2(x,y):
    return int(x*y / gcd(x,y))
    
N = int(input())
T = []
for i in range(N):
    ti = int(input())
    T.append(ti)

result = 1
for t in T:
    result = lcm2(result, t)

print(result)


    

### FIXED CODE ###

import functools
import math

def gcd(x,y):
    a,b = max(x,y), min(x,y)
    while b != 0:
        a,b = b,a%b

    return a

def lcm2(x,y):
    return x*y // gcd(x,y)
    
N = int(input())
T = []
for i in range(N):
    ti = int(input())
    T.append(ti)

result = 1
for t in T:
    result = lcm2(result, t)

print(result)
s=str(input())
a,b=s.find("A"),s,rfind("Z")
print(b-a+1)

### FIXED CODE ###

s=str(input())
a,b=s.find("A"),s.rfind("Z")
print(b-a+1)
n, a, b = map(int, input().split())
x = list(map(int, input().split()))
edges = [[b]*n for i in range(n)]
for i in range(n):
    edges[i][i] = 0
for i in range(n-1):
    edges[i][i+1] = edges[i+1][i] = min(b, (x[i+1]-x[i])*a)

import numpy as np
from scipy.sparse.csgraph import minimum_spanning_tree
ans = np.sum(minimum_spanning_tree(edges))
print(int(ans))

### FIXED CODE ###

n, a, b = map(int, input().split())
x = list(map(int, input().split()))
uf = [1]*n
ans = 0
for i in range(n-1):
    if a*(x[i+1]-x[i]) <= b:
        ans += a*(x[i+1]-x[i])
        uf[i+1] = 0
ans += b*(sum(uf)-1)
print(ans)
S = input()
T = input()
ev = [0] * (len(S) - len(T))
for i in range(len(S) - len(T)):
  commit = 0
  for j in range(len(T)):
    if S[i + j] == T[j]:
      commit += 1
  ev[i] = commit

greatest = max(ev)
print(len(T) - greatest)

### FIXED CODE ###

S = input()
T = input()
ev = []
for i in range(len(S) - len(T) + 1):
  commit = 0
  for j in range(len(T)):
    if S[i + j] == T[j]:
      commit += 1
  ev.append(commit)

ev.sort(reverse=True)
print(len(T) - ev[0])
import math

#S     G     S
#RRR..RLL...LRR...

s = list(input())
leng = len(s)
tmp = "R"
s[0] = "S"

for i in range(1,leng):
    if s[i] == "L":
        if tmp == "R":
            s[i] = "G"
        tmp = "L"
    else:
        if tmp == "L":
            s[i] = "S"
        tmp = "R"

lis = [0]*(leng)
tmp_s = 0

for i in range(1,leng):
    if s[i] == "S" or i == leng-1:
        if i == leng-1:
            i += 1
        if (tmp_g - tmp_s) % 2 == 0:
            lis[tmp_g-1] = math.floor((i - tmp_s)/2)
            lis[tmp_g] = math.floor((i - tmp_s)/2 + 0.5)
        else:
            lis[tmp_g-1] = math.floor((i - tmp_s)/2 + 0.5)
            lis[tmp_g] = math.floor((i - tmp_s)/2)
        tmp_s = i
        continue
    if s[i] == "G":
        tmp_g = i
    continue

print (*lis)

### FIXED CODE ###

import math
import sys
sys.setrecursionlimit(100000)

#S     G     S
#RRR..RLL...LRR...

s = list(input())
leng = len(s)
tmp = "R"
s[0] = "S"

for i in range(1,leng):
    if s[i] == "L":
        if tmp == "R":
            s[i] = "G"
        tmp = "L"
    else:
        if tmp == "L":
            s[i] = "S"
        tmp = "R"
lis = [0]*(leng)
tmp_s = 0
tmp_g = leng - 1

for i in range(1,leng):
    if s[i] == "G":
        tmp_g = i
    if s[i] == "S" or i == leng-1:
        if i == leng-1:
            i += 1
        if (tmp_g - tmp_s) % 2 == 0:
            lis[tmp_g-1] = math.floor((i - tmp_s)/2)
            lis[tmp_g] = math.floor((i - tmp_s)/2 + 0.5)
        else:
            lis[tmp_g-1] = math.floor((i - tmp_s)/2 + 0.5)
            lis[tmp_g] = math.floor((i - tmp_s)/2)
        tmp_s = i
        continue

    continue

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

lst = [0] * N

ans = 0
for i in range(N):
    if i + 1 + A[i] < n: #iは0から始まるので +1 してあげる
        lst[i + A[i]] += 1
    if i + 1 - A[i] >= 1:
        ans += lst[i - A[i]]

print(ans)

### FIXED CODE ###

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

d = [0] * n

cnt = 0
for i in range(len(l)):
    if i + l[i] + 1 < n:
        d[i + l[i]] += 1
    if i - l[i] + 1 > 0:
        cnt += d[i - l[i]]
print(cnt)
N = int(input())
h = list(map(int, input().split()))

memo = [10**10 for _ in range(N+1)]

def dp(i):
    if i == 1:
        return 0
    elif i == 2:
        memo[i] = abs(h[i-2]-h[i-1])
        return memo[i]
    elif memo[i] < 10**10:
        return memo[i]
    else:
        memo[i] = min(
            dp(i-1) + abs(h[i-2]-h[i-1]),
            dp(i-2) + abs(h[i-3]-h[i-1]),
            dp(i-2) + abs(h[i-3]-h[i-2]) + abs(h[i-2]-h[i-1])
        )
        return memo[i]
try:
    print(dp(N))
except IndexError:
    print(0)

### FIXED CODE ###

import sys

sys.setrecursionlimit(1000000)

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

memo = [10**10 for _ in range(N+1)]

def dp(i):
    if i == 1:
        return 0
    elif i == 2:
        memo[i] = abs(h[i-2]-h[i-1])
        return memo[i]
    elif memo[i] < 10**10:
        return memo[i]
    else:
        memo[i] = min(
            dp(i-1) + abs(h[i-2]-h[i-1]),
            dp(i-2) + abs(h[i-3]-h[i-1]),
            dp(i-2) + abs(h[i-3]-h[i-2]) + abs(h[i-2]-h[i-1])
        )
        return memo[i]
print(dp(N))
n,m=map(int,input().split())
p=[[]for _ in range(n)]
c=[0]*n
import sys
sys.setrecursionlimit(10**5)
for i in range(m):
    x,y=map(int,input().split())
    p[x-1].append(y-1)
from functools import lru_cache
@lru_cache(maxsize=n)
def l(k):
    return max([l(i)for i in p[k]]+[0])+1
print(max([l(i)for i in range(n)])-1)

### FIXED CODE ###

n,m=map(int,input().split())
p=[[]for _ in range(n)]
c=[0]*n
import sys
sys.setrecursionlimit(10**6)
for i in range(m):
    x,y=map(int,input().split())
    p[x-1].append(y-1)
from functools import lru_cache
@lru_cache(maxsize=n)
def l(k):
    return max([l(i)for i in p[k]]+[0])+1
print(max([l(i)for i in range(n)])-1)
from sys import stdin
n = int(stdin.readline.rstrip())
if n<1200:
  print('ABC')
elif n>=1200 and n<2800:
  print('ARC')
elif n>=2800:
  print('AGC')

### FIXED CODE ###

from sys import stdin
n = int(stdin.readline().rstrip())
if n<1200:
  print('ABC')
elif n>=1200 and n<2800:
  print('ARC')
elif n>=2800:
  print('AGC')
MOD=10**9+7
N,K=[int(s) for s in input().split()]
ls=[int(s) for s in input().split()]
ans=set()
if 0 in ls:
  ans.add(0)
ls=sorted(ls, key=lambda x: -abs(x))
mul=1
for i in range(K):
  mul*=ls[i]
if mul>0:
  ans.add(mul)
else:
 #残りのプラスのものをマイナスと取り換える
 for j in range(K,N):
    if ls[j]>0:
      for k in range(K):
        if ls[K-1-k]<0:
          ans.add(mul*ls[j]//ls[K-1-k])
          break
      break
 #残りのマイナスのものをプラスと取り換える
 for j in range(K,N):
    if ls[j]<0:
      for k in range(K):
        if ls[K-1-k]>0:
          ans.add(mul*ls[j]//ls[K-1-k])
          break
      break
print(max(ans)%MOD)


### FIXED CODE ###

MOD=10**9+7
N,K=[int(s) for s in input().split()]
ls=[int(s) for s in input().split()]
ans=set()
ls=sorted(ls, key=lambda x: -abs(x))
mul=1
sign=0
zeroflag=0
flag=[0 for _ in range(N)]
for i in range(K):
  flag[i]=1
  if ls[i]<0:
    sign=(sign+1)%2
if sign==1:
  if 0 in ls:
    zeroflag=1
  a=[0,0,0,0]
  b=[0,0,0,0]
  for j in range(K,N):
    if ls[j]>0:
      for k in range(K):
        if ls[K-1-k]<0:
          a[0]=ls[j]
          b[0]=j
          a[1]=ls[K-1-k]
          b[1]=K-1-k
          break
      break
  for j in range(K,N):
    if ls[j]<0:
      for k in range(K):
        if ls[K-1-k]>0:
          a[2]=ls[j]
          b[2]=j
          a[3]=ls[K-1-k]
          b[3]=K-1-k
          break
      break
  if a==[0,0,0,0]:
    flag.reverse()
  elif b[0]==0 and b[1]==0:
    flag[b[2]]=1
    flag[b[3]]=0
  elif b[2]==0 and b[3]==0:
    flag[b[0]]=1
    flag[b[1]]=0
  elif abs(a[0]*a[3])>abs(a[1]*a[2]):
    flag[b[0]]=1
    flag[b[1]]=0
  else:
    flag[b[2]]=1
    flag[b[3]]=0
if sign==1 and a==[0,0,0,0] and zeroflag==1:
  print(0)
else:
  mul=1
  for i in range(N):
    if flag[i]==1:
      mul=mul*ls[i]%MOD
  print(mul)
import math
import numpy as np

a, b, n = map(int, input().split())
arr = np.arange(1, n+1)

print(np.vectorize(lambda x: math.floor(a*x / b) - a * math.floor(x / b))( np.arange(1, n+1)).max())
# np.vectorize(lambda x: math.floor(a*x / b) - a * math.floor(x / b))( np.arange(1, n+1)).max()

### FIXED CODE ###

from math import floor

a, b, n = map(int, input().split())
        
x = min(n, b-1)
if x < 0:
    x = 0
    
print(floor(a*x / b) - a * floor(x / b))
N,M = map(int,input().split())
A =list(map(int,input().split()))
A.sort(reverse=True)
A_len =len(A)
count =0
for l in range(0,M):
    comp = A[0]/2
    for i in range(0,A_len-1,1):
        if count >= M:
            break
        if A[i+1]<comp:
            break
        while True:
            count +=1
            if A[i]/2 > A[i+1]:
                A[i] = A[i]/2
            else:
                A[i] = A[i]/2
                break
    A.sort(reverse=True)
    if count>=M:
        break
A = [int(i) for i in A]
sumN =sum(A)
print(sumN)


### FIXED CODE ###

S = input()
if S =="Sunny":
    print("Cloudy")
if S =="Rainy":
    print("Sunny")
if S =="Cloudy": 
    print("Rainy")
T = list(input())
 
for i in range(len(T)):
  if T[i] == "?":
    if 1 <= i：
      if T[i-1] == "P":
      	T[i] = "D"
    elif T[i+1] == "?":
      T[i] = "P"
      T[i+1] = "D"
    elif T[i+1] == "D":
      T[i] = "P"
    else:
      T[i] = "D"
      
print("".join(T))

### FIXED CODE ###

T = list(input())
 
for i in range(len(T)):
  if T[i] == "?":
    if 1 <= i and T[i-1] == "P":
      T[i] = "D"
    elif i < len(T)-1 and T[i+1] == "?":
      T[i] = "P"
      T[i+1] = "D"
    elif i < len(T)-1 and T[i+1] == "D":
      T[i] = "P"
    else:
      T[i] = "D"
      
print("".join(T))
from math import sqrt

i = input().sqlit()
a = i[0]
b = i[1]

n = int(a+b)
s = int(sqrt(n))
if s*s==n:
	print("Yes")
else:
	print("No")

### FIXED CODE ###

import math
string = input().split(" ")
number = int(string[0]+string[1])
result = math.sqrt(number)
if int(result)*int(result) == number:
    print("Yes")
else:
    print("No")
import numpy

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

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

bl=[]
for i in range(2**n):
    bli=list(map(int,format(i,"b").zfill(n)))
    bl.append(bli)


p=-1
for i in range(2**n):
    u=numpy.zeros(m,dtype=int)
    pi=0
    for j in range(n):
        if bl[i][j]==1:
            pi+=l[j][0]
            for k in range(m):
                u[k]+=l[j][k+1]
    if min(u)>=x:
        if p==-1:
            p=pi
        else:
            p=min(p,pi)

print(p)

### FIXED CODE ###

import numpy

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

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

bl=[]
for i in range(2**n):
    bli=list(map(int,format(i,"b").zfill(n)))
    bl.append(bli)


p=-1
for i in range(2**n):
    u=numpy.zeros(m,dtype=int)
    pi=0
    for j in range(n):
        if bl[i][j]==1:
            pi+=l[j][0]
            for k in range(m):
                u[k]+=l[j][k+1]
    if min(u)>=x:
        if p==-1:
            p=pi
        else:
            p=min(p,pi)

print(p)
a, b, c = sorted(map(int, input().split()), reverse=True)
k = int(intpu())
print(a*2**k + b + c)


### FIXED CODE ###

a, b, c = sorted(map(int, input().split()), reverse=True)
k = int(input())
print(a*2**k + b + c)
N=int(input())

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

#重複した値だけを集めて消す

sets={}
for i in A:
    if i in sets:
        sets[i]+=1
    else:
        sets[i]=1

sets

duplicate=0
for k,v in sets.items():
    if v>1:
        duplicate+=(v-1)

duplicate %=2

print(set(A))-duplicate

### FIXED CODE ###

N=int(input())

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

#重複した値だけを集めて消す

sets={}
for i in A:
    if i in sets:
        sets[i]+=1
    else:
        sets[i]=1

duplicate=0
for k,v in sets.items():
    if v>1:
        duplicate+=(v-1)

duplicate %=2

print(len(set(A))-duplicate)
n,m=map(int,input().split())
a=[-1 for i in range(n)]

for i in range(m):
    s,c=map(int,input().split())
    s-=1

    if a[s]!=-1 and a[s]!=c:
        print(-1)
        sys.exit()
    elif s==0 and c==0:
        print(-1)
        sys.exit()
    else:
        a[s]=c
        
x=""
for i in range(n):
    if a[i]==-1: a[i]=0
    x+=str(a[i])
print(x)
    

### FIXED CODE ###

import sys
n,m=map(int,input().split())
a=[-1 for i in range(n)]

for i in range(m):
    s,c=map(int,input().split())
    s-=1

    if n!=1 and s==0 and c==0:
        print(-1)
        sys.exit()

    if a[s]!=-1 and a[s]!=c:
        print(-1)
        sys.exit()
    else:
        a[s]=c


if n==1 and (a[0]==0 or a[0]==-1):
    print(0)
    sys.exit()

x=""
if a[0]==-1: a[0]=1
for i in range(n):
    if a[i]==-1: a[i]=0
    x+=str(a[i])
print(x)