Buggy python submission (verdict: Time Limit Exceeded):

import math
import sys
sys.setrecursionlimit(2000000)
# import itertools
# import statistics
# import numpy as np
# x = int(input())
a, b, n = list(map(int, input().split()))
ans = a*n//b - a*(n//b)
count = 0
same = 0
# print(ans)
for i in range(n, int(pow(n, 0.75))-1, -1):
    if ans < a*i//b - a*(i//b):
        ans = a*i//b - a*(i//b)
        if count == 1:
            print(ans)
            exit()
    elif a*i//b - a*(i//b) == 0:
        count += 1
    elif a*i//b - a*(i//b) == ans:
        same += 1
    if same > b:
        print(ans)
        exit()

print(ans)


Fixed submission:
a, b, n = list(map(int, input().split()))

x = min(b-1, n)
ans = a*x//b - a*(x//b)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
from functools import reduce
# from collections import deque
# from math import factorial
# import collections
import math
import sys
sys.setrecursionlimit(2000000)
# import itertools
# import statistics
# import numpy as np
# x = int(input())
a, b, n = list(map(int, input().split()))
# a, b = list(map(int, input().split()))
# sy, sx = map(int, input().split())
# gy, gx = map(int, input().split())

ans = a*n//b - a*(n//b)
count = 0
same = 0
# print(ans)
for i in range(n, int(pow(n, 0.75))-1, -1):
    if ans < a*i//b - a*(i//b):
        ans = a*i//b - a*(i//b)
        if count == 1:
            print(ans)
            exit()
    elif a*i//b - a*(i//b) == 0:
        count += 1
print(ans)

Fixed submission:
a, b, n = list(map(int, input().split()))

x = min(b-1, n)
ans = a*x//b - a*(x//b)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys
sys.setrecursionlimit(2000000)
# import itertools
# import statistics
# import numpy as np
# x = int(input())
a, b, n = list(map(int, input().split()))
# a, b = list(map(int, input().split()))
# sy, sx = map(int, input().split())
# gy, gx = map(int, input().split())

ans = a*n//b - a*(n//b)
count = 0
for i in range(n, int(pow(n, 0.5))-1, -1):
    if ans < a*i//b - a*(i//b):
        ans = a*i//b - a*(i//b)
    elif a*i//b - a*(i//b) == 0:
        count += 1
    if count > 1:
        print(ans)
        exit()

print(ans)


Fixed submission:
a, b, n = list(map(int, input().split()))

x = min(b-1, n)
ans = a*x//b - a*(x//b)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys
sys.setrecursionlimit(2000000)
# import itertools
# import statistics
# import numpy as np
# x = int(input())
a, b, n = list(map(int, input().split()))
ans = a*n//b - a*(n//b)

# for i in range(n, int(math.sqrt(n))-1, -1):
for i in range(n, int(pow(n, 0.75))-1, -1):
    if ans < a*i//b - a*(i//b):
        ans = a*i//b - a*(i//b)
    #print(ans, end=" ")
    #print(a*i//b - a*(i//b))

print(ans)


Fixed submission:
a, b, n = list(map(int, input().split()))

x = min(b-1, n)
ans = a*x//b - a*(x//b)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys
sys.setrecursionlimit(2000000)

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


ans = a*n//b - a*(n//b)

for i in range(n, int(math.sqrt(n))-1, -1):
    if ans < a*i//b - a*(i//b):
        ans = a*i//b - a*(i//b)
    #print(ans, end=" ")
    #print(a*i//b - a*(i//b))

print(ans)


Fixed submission:
a, b, n = list(map(int, input().split()))

x = min(b-1, n)
ans = a*x//b - a*(x//b)

print(ans)