Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8


def solve(*args: str) -> str:
    n = int(args[0])
    ln = sorted(list(map(int, args[1].split())))

    s = 0
    for i in range(n):
        for j in range(i+1, n):
            for k in range(n-1, j, -1):
                if (
                    (ln[i] < ln[j] + ln[k]) and
                    (ln[j] < ln[i] + ln[k]) and
                    (ln[k] < ln[i] + ln[j])
                ):
                    s += 1

    return str(s)


if __name__ == "__main__":
    print(solve(*[input() for _ in range(2)]))


Fixed submission:
# coding: utf-8
import bisect


def solve(*args: str) -> str:
    n = int(args[0])
    ln = sorted(list(map(int, args[1].split())))
    s = 0
    for i in range(n-1, 1, -1):
        for j in range(i-1, 0, -1):
            small = bisect.bisect_right(ln, ln[i] - ln[j])
            big = bisect.bisect_left(ln, ln[i] + ln[j], small, j)
            s += big - small

    return str(s)


if __name__ == "__main__":
    print(solve(*[input() for _ in range(2)]))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8


def solve(arg: str) -> str:
    a, b = map(int, arg.split())
    div = [1]
    for n in range(2, min(a, b) + 1):
        if a % n == 0 and b % n == 0:
            if(all([n % m != 0 for m in div if m != 1])):
                div.append(n)

    return str(len(div))


if __name__ == "__main__":
    print(solve(input()))


Fixed submission:
# coding: utf-8


def solve(arg: str) -> str:
    N = int(arg)
    return str(int((N+1) / 2) / N)


if __name__ == "__main__":
    print(solve(input()))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8


def solve(*args: str) -> str:
    n, k, q = map(int, args[0].split())
    A = list(map(int, args[1:]))
    ret = ''
    p = 0
    for a in sorted(set(A)):
        ret += ('Yes\n' if 0 < k-q else 'No\n')*(a-p-1)
        ret += ('Yes' if 0 < k - (q - A.count(a)) else 'No') + '\n'
        p = a

    ret += ('Yes\n' if 0 < k-q else 'No\n')*(n-p)
    return ret.rstrip('\n')


if __name__ == "__main__":
    nkq = input()
    _, _, q = map(int, nkq.split())
    print(solve(*([nkq]+[input() for _ in range(q)])))


Fixed submission:
# coding: utf-8


def solve(*args: str) -> str:
    s = args[0]
    r = ''
    if(s == 'Sunny'):
        r = 'Cloudy'
    elif(s == 'Cloudy'):
        r = 'Rainy'
    elif(s == 'Rainy'):
        r = 'Sunny'

    return str(r)


if __name__ == "__main__":
    print(solve(*[input() for _ in range(1)]))
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8


def solve(*args: str) -> str:
    n, k, q = map(int, args[0].split())
    A = list(map(int, args[1:]))
    ret = ''
    p = 0
    for a in sorted(set(A)):
        ret += ('Yes\n' if 0 < k-q else 'No\n')*(a-p-1)
        ret += ('Yes' if 0 < k - (q - A.count(a)) else 'No') + '\n'
        p = a

    ret += ('Yes\n' if 0 < k-q else 'No\n')*(n-p)
    return ret.rstrip('\n')


if __name__ == "__main__":
    nkq = input()
    _, _, q = map(int, nkq.split())
    print(solve(*([nkq]+[input() for _ in range(q)])))


Fixed submission:
# coding: utf-8


def solve(*args: str) -> str:
    n, k, q = map(int, args[0].split())
    A = sorted(map(int, args[1:]))
    S = [k-q for _ in range(n)]
    ret = ''

    for a in A:
        S[a-1] += 1

    for s in S:
        ret += ('Yes' if 0 < s else 'No') + '\n'

    return ret.rstrip('\n')


if __name__ == "__main__":
    nkq = input()
    _, _, q = map(int, nkq.split())
    print(solve(*([nkq]+[input() for _ in range(q)])))

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8


def solve(*args: str) -> str:
    n, k, q = map(int, args[0].split())
    A = list(map(int, args[1:]))
    ret = ''
    p = 0
    for a in sorted(set(A)):
        ret += ('Yes\n' if 0 < k-q else 'No\n')*(a-p-1)
        ret += ('Yes' if 0 < k - (q - A.count(a)) else 'No') + '\n'
        p = a

    ret += ('Yes\n' if 0 < k-q else 'No\n')*(n-p)
    return ret.rstrip('\n')


if __name__ == "__main__":
    nkq = input()
    _, _, q = map(int, nkq.split())
    print(solve(*([nkq]+[input() for _ in range(q)])))


Fixed submission:
# coding: utf-8


def solve(*args: str) -> str:
    n, k, q = map(int, args[0].split())
    A = sorted(map(int, args[1:]))
    S = [k-q for _ in range(n)]
    ret = ''

    for a in A:
        S[a-1] += 1

    for s in S:
        ret += ('Yes' if 0 < s else 'No') + '\n'

    return ret.rstrip('\n')


if __name__ == "__main__":
    nkq = input()
    _, _, q = map(int, nkq.split())
    print(solve(*([nkq]+[input() for _ in range(q)])))
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
import bisect


def solve(*args: str) -> str:
    n, m = map(int, args[0].split())
    A = sorted(map(int, args[1].split()))

    for _ in range(m):
        a = A[-1]
        A = A[0:-1]
        bisect.insort_left(A, int(a/2))

    return str(sum(A))


if __name__ == "__main__":
    print(solve(*[input() for _ in range(2)]))


Fixed submission:
# coding: utf-8
import heapq


def solve(*args: str) -> str:
    n, m = map(int, args[0].split())
    A = list(map(lambda _: -int(_), args[1].split()))
    heapq.heapify(A)

    for _ in range(m):
        a = heapq.heappop(A)
        heapq.heappush(A, int(a/2))

    return str(-sum(A))


if __name__ == "__main__":
    print(solve(*[input() for _ in range(2)]))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8


def solve(*args: str) -> str:
    n = int(args[0])
    A = tuple(map(int, args[1].split()))

    ret = 0

    xor = [0]*(2**n)
    xor[1] = A[0]

    for i in range(1, n):
        for j in range(2**i):
            xor[2**i+j] = A[i] ^ xor[j]

    for i in range(1, 2**(n-1)):
        ret = max(ret, xor[i] + xor[-1-i])

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Fixed submission:
# coding: utf-8
import numpy as np


def solve(*args: str) -> str:
    n = int(args[0])
    A = np.array(args[1].split(), dtype=np.int64)

    n_bit = len(np.binary_repr(max(A)))

    xor = np.bitwise_xor.reduce(A)
    A &= ~xor

    for b in reversed(range(n_bit)):
        b_set = A & 1 << b != 0
        msb_args = np.where(b_set & (A < 1 << b+1))[0]
        if len(msb_args):
            b_set[msb_args[0]] = False
            A[b_set] ^= A[msb_args[0]]

    ret = 2*np.bitwise_xor.reduce(A) + xor

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8


def solve(*args: str) -> str:
    d, g = map(int, args[0].split())
    g //= 100
    pc = [tuple(map(int, a.split())) for a in args[1:]]
    inf = 10**12
    dp = {}

    for i, (p, c) in enumerate(pc):
        c //= 100
        if i == 0:
            for k in range(p):
                s = min(g, (i+1)*(k+1) + (c if k+1 == p else 0))
                dp[s] = k+1
        else:
            items = tuple(dp.items())
            for t, m in items:
                for k in range(p):
                    s = min(g, (i+1)*(k+1) + (c if k+1 == p else 0))
                    s_t = min(g, s+t)
                    dp[s] = min(dp.get(s, inf), k+1)
                    dp[s_t] = min(dp.get(s_t, inf), k+1+m)
    return str(dp[g])


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Fixed submission:
# coding: utf-8


def solve(*args: str) -> str:
    d, g = map(int, args[0].split())
    pc = [tuple(map(int, a.split())) for a in args[1:]]
    inf = 10**5

    count = inf
    for b in range(2**d):
        score, cnt = 0, 0

        for i in range(d):
            p, c = pc[i]
            if b >> i & 1:
                score += p*100*(i+1)+c
                cnt += p

        if score < g:
            for i in reversed(range(d)):
                if b >> i & 1:
                    continue
                else:
                    p, c = pc[i]
                    j = 0
                    while score < g and j < p:
                        score += 100*(i+1)
                        cnt += 1
                        j += 1

                    if j == p:
                        score += c

        count = min(count, cnt)

    return str(count)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
from collections import defaultdict, deque

import numpy as np


def solve(*args: str) -> str:
    n = int(args[0])
    P = list(map(int, args[1].split()))
    X = list(map(int, args[2].split()))

    T = defaultdict(set)
    for i, p in enumerate(P):
        T[p-1].add(i+1)

    stack = []
    Q = deque()
    Q.append(0)
    while Q:
        i = Q.popleft()
        stack.append(i)
        for c in T[i]:
            Q.append(c)

    ret = 'POSSIBLE'
    inf = 2**32-1
    Y = [0]*n
    for i in stack[::-1]:
        dp = np.full(X[i]+1, inf, np.int64)
        dp[0] = 0
        x_acc, y_acc = 0, 0
        for c in T[i]:
            x, y = X[c], Y[c]
            x_acc += x
            y_acc += y
            dp = np.minimum(
                np.concatenate((dp[:x], dp[:-x]+y)),
                np.concatenate((dp[:y], dp[:-y if 0 < y else len(dp)]+x))
            )

        A = np.sort(dp[1:])
        if len(T[i]) == 0:
            Y[i] = 0
        elif A[0] < inf:
            Y[i] = A[0]
        elif y_acc != 0:
            ret = 'IMPOSSIBLE'
            break
        else:
            Y[i] = x_acc

    return ret


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Fixed submission:
# coding: utf-8
from collections import defaultdict, deque

import numpy as np


def solve(*args: str) -> str:
    n = int(args[0])
    P = list(map(int, args[1].split()))
    X = list(map(int, args[2].split()))

    T = defaultdict(set)
    for i, p in enumerate(P):
        T[p-1].add(i+1)

    stack = []
    Q = deque()
    Q.append(0)
    while Q:
        i = Q.popleft()
        stack.append(i)
        for c in T[i]:
            Q.append(c)

    ret = 'POSSIBLE'
    inf = 2**32-1
    Y = [0]*n
    for i in stack[::-1]:
        prev = np.full(X[i]+1, inf, np.int64)
        prev[0] = 0
        x_acc, y_acc = 0, 0
        for c in T[i]:
            cur = np.full(X[i]+1, inf, np.int64)
            x, y = X[c], Y[c]
            x_acc += x
            y_acc += y
            cur[x:] = np.minimum(cur[x:], y+prev[:-x if 0 < x else len(prev)])
            cur[y:] = np.minimum(cur[y:], x+prev[:-y if 0 < y else len(prev)])
            prev = np.copy(cur)

        y = np.min(prev)
        if y < inf:
            Y[i] = y
        else:
            ret = 'IMPOSSIBLE'
            break

    return ret


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))
Buggy python submission (verdict: Time Limit Exceeded):
n, x, m = map(int, input().split())
A = [x]
ans = x

for i in range(1,n):
    buf = A[i-1]*A[i-1] % m
    if buf in A:
        idx = A.index(buf)
        back = len(A) - idx
        nokori = n-len(A)
        sumKurikaeshi = sum(A[idx:])
        ans += int(nokori/back)*sumKurikaeshi
        last = nokori%back
        ans += sum(A[idx:idx+last])
        break
    else:
        A.append(buf)
        ans += buf

print(ans)

Fixed submission:
n, x, m = map(int, input().split())
A = [x]
checkA = {x}
ans = x

for i in range(1,n):
    buf = A[i-1]*A[i-1] % m
    if buf in checkA:
        idx = A.index(buf)
        back = len(A) - idx
        nokori = n-len(A)
        sumKurikaeshi = sum(A[idx:])
        ans += int(nokori/back)*sumKurikaeshi
        last = nokori%back
        ans += sum(A[idx:idx+last])
        break
    else:
        A.append(buf)
        checkA.add(buf)
        ans += buf

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def f(x, m):
    return x%m

n, x, m = map(int, input().split())
A = [x]
ans = x

for i in range(1,n):
    buf = f(A[i-1]**2, m)
    if buf in A:
        idx = A.index(buf)
        back = len(A) - idx
        nokori = n-len(A)
        sumKurikaeshi = sum(A[idx:])
        ans += int(nokori/back)*sumKurikaeshi
        last = nokori%back
        for j in range(last):
            ans += A[idx+j]
        break
        
    else:
        A.append(buf)
        ans += buf

print(ans)

Fixed submission:
n, x, m = map(int, input().split())
A = [x]
checkA = {x}
ans = x

for i in range(1,n):
    buf = A[i-1]*A[i-1] % m
    if buf in checkA:
        idx = A.index(buf)
        back = len(A) - idx
        nokori = n-len(A)
        sumKurikaeshi = sum(A[idx:])
        ans += int(nokori/back)*sumKurikaeshi
        last = nokori%back
        ans += sum(A[idx:idx+last])
        break
    else:
        A.append(buf)
        checkA.add(buf)
        ans += buf

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
total = 0
MOD = 10**9+7

for i in range(n-1):
    back = sum(a[i+1:n])
    total += a[i] * back
    total = total % MOD
print(total)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
total = 0
MOD = 10**9+7
back= sum(a)

for i in range(n-1):
    back -= a[i]
    total += a[i] * back
    total = total % MOD
print(total)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ex = [0 for i in range(n)]
fri = {}

for i in range(m):
    a, b = map(int, input().split())
    if ex[a-1] == 0 and ex[b-1] == 0:
        if a > b:
            a, b = b,a
        ex[a-1] = a
        ex[b-1] = a
        fri[a] = [a, b]
    elif ex[a-1] == 0:
        ex[a-1] = ex[b-1]
        fri[ex[b-1]].append(a)
    elif ex[b-1] == 0:
        ex[b-1] = ex[a-1]
        fri[ex[a-1]].append(b)
    elif ex[a-1] == ex[b-1]:
        continue
    else:
        shozoku = min(ex[a-1], ex[b-1])
        mu = max(ex[a-1], ex[b-1])
        fri[shozoku].extend(fri.pop(mu))

ans = 0
for key in fri:
    ans = max(ans, len(fri[key]))
print(ans)

Fixed submission:
n, m = map(int, input().split())
ex = [0 for i in range(n)]
fri = {}

for i in range(m):
    a, b = map(int, input().split())
    if ex[a-1] == 0 and ex[b-1] == 0:
        if a > b:
            a, b = b, a
        ex[a-1] = a
        ex[b-1] = a
        fri[a] = [a, b]
    elif ex[a-1] == 0:
        ex[a-1] = ex[b-1]
        fri[ex[b-1]].append(a)
    elif ex[b-1] == 0:
        ex[b-1] = ex[a-1]
        fri[ex[a-1]].append(b)
    elif ex[a-1] == ex[b-1]:
        continue
    else:
        shozoku = min(ex[a-1], ex[b-1])
        mu = max(ex[a-1], ex[b-1])
        for j in range(len(fri[mu])):
            ex[fri[mu][j]-1] = shozoku
        fri[shozoku].extend(fri.pop(mu))

ans = 1
for key in fri:
    ans = max(ans, len(fri[key]))
print(ans)
Buggy python submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0

# もしすべてaから選んだ場合
time = k
aOnly = 0
for i in range(len(a)):
    time -= a[i]
    if time < 0:
        time += a[i]
        i -= 1
        break
    aOnly += 1
a_idx = i
b_idx = -1

for i in range(len(b)):
    time -= b[i]
    if time < 0:
        time += b[i]
        i -= 1
        break
    aOnly += 1
b_idx = i
ans = aOnly

ans_kari = ans
for i in range(a_idx, -1, -1):
    time += a[i]
    ans_kari -= 1
    for j in range(b_idx+1, len(b)):
        time -= b[i]
        if time < 0:
            time += b[i]
            b_idx = i-1
            break
        ans_kari += 1
    ans = max(ans, ans_kari)
    
print(ans)

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

# もしすべてaから選んだ場合
time = k
aOnly = 0
for i in range(len(a)):
    time -= a[i]
    if time < 0:
        time += a[i]
        i -= 1
        break
    aOnly += 1
a_idx = i
b_idx = -1

for i in range(len(b)):
    time -= b[i]
    if time < 0:
        time += b[i]
        i -= 1
        break
    aOnly += 1
b_idx = i
ans = aOnly

ans_kari = ans
for i in range(a_idx, -1, -1):
    time += a[i]
    ans_kari -= 1
    for j in range(b_idx+1, len(b)):
        time -= b[j]
        if time < 0:
            time += b[j]
            b_idx = j-1
            break
        ans_kari += 1
    ans = max(ans, ans_kari)
    
print(ans)

Buggy python submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0

# もしすべてaから選んだ場合
time = k
aOnly = 0
for i in range(len(a)):
    time -= a[i]
    if time < 0:
        time += a[i]
        break
    aOnly += 1
a_idx = i-1
b_idx = -1
if time > 0:
    for i in range(len(b)):
        time -= b[i]
        if time < 0:
            break
        aOnly += 1
    b_idx = i-1
    ans = aOnly
    time += b[i]

else:
    ans = aOnly
    time += a[i]

ans_kari = ans
for i in range(a_idx, -1, -1):
    time += a[i]
    ans_kari -= 1
    for j in range(b_idx+1, len(b)):
        time -= b[i]
        if time < 0:
            time += b[i]
            b_idx = i-1
            break
        ans_kari += 1
    ans = max(ans, ans_kari)
    
print(ans)

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

# もしすべてaから選んだ場合
time = k
aOnly = 0
for i in range(len(a)):
    time -= a[i]
    if time < 0:
        time += a[i]
        i -= 1
        break
    aOnly += 1
a_idx = i
b_idx = -1

for i in range(len(b)):
    time -= b[i]
    if time < 0:
        time += b[i]
        i -= 1
        break
    aOnly += 1
b_idx = i
ans = aOnly

ans_kari = ans
for i in range(a_idx, -1, -1):
    time += a[i]
    ans_kari -= 1
    for j in range(b_idx+1, len(b)):
        time -= b[j]
        if time < 0:
            time += b[j]
            b_idx = j-1
            break
        ans_kari += 1
    ans = max(ans, ans_kari)
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
dic = dict()

for i in A:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1

for i in range(Q):
    b, c = list(map(int, input().split()))
    if b in dic:
        if c in dic:    
            dic[c] += dic.pop(b)
        else:
            dic[c] = dic.pop(b)
    ans = 0
    for num in dic:
        ans += num * dic[num]
    print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
dic = dict()

for i in A:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1

ans = 0
for num in dic:
    ans += num * dic[num]

for i in range(Q):
    b, c = list(map(int, input().split()))
    x = 0
    if b in dic:
        x = dic.pop(b)
        if c in dic:    
            dic[c] += x
        else:
            dic[c] = x
    ans += x * (c-b)
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
dic = dict()

a = set(A)
for i in a:
    dic[i] = A.count(i)

for i in range(Q):
    b, c = list(map(int, input().split()))
    if b in dic:
        if c in dic:    
            dic[c] += dic.pop(b)
        else:
            dic[c] = dic.pop(b)
    ans = 0
    for num in dic:
        ans += num * dic[num]
    print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
dic = dict()

for i in A:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1

ans = 0
for num in dic:
    ans += num * dic[num]

for i in range(Q):
    b, c = list(map(int, input().split()))
    x = 0
    if b in dic:
        x = dic.pop(b)
        if c in dic:    
            dic[c] += x
        else:
            dic[c] = x
    ans += x * (c-b)
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
dic = dict()

for i in A:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1

for i in range(Q):
    b, c = list(map(int, input().split()))
    if b in dic:
        if c in dic:    
            dic[c] += dic.pop(b)
        else:
            dic[c] = dic.pop(b)
    ans = 0
    for num in dic:
        ans += num * dic[num]
    print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
dic = dict()

for i in A:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1

ans = 0
for num in dic:
    ans += num * dic[num]

for i in range(Q):
    b, c = list(map(int, input().split()))
    x = 0
    if b in dic:
        x = dic.pop(b)
        if c in dic:    
            dic[c] += x
        else:
            dic[c] = x
    ans += x * (c-b)
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = [None]*n

for i in range(n):
    buf = 0
    for j in range(n):
        if i != j:
            buf = buf^a[j]
    ans[i]=str(buf)
print(' '.join(ans))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = [None]*n
all = 0

for i in range(n):
    all = all^a[i]

for i in range(n):
    ans[i]=str(all^a[i])
print(' '.join(ans))
Buggy python submission (verdict: Runtime Error):
oni_x, oni_speed = map(int, input().split())
chi_x, chi_speed = map(int, input().split())
time = int(input())
ans = False


if oni_speed > chi_speed:
    sa = abs(oni_x, chi_x)
    sa_speed = oni_speed - chi_speed
    if sa_speed*time >= sa:
        ans = True

if ans:
    print('YES')
else:
    print('NO')

Fixed submission:
oni_x, oni_speed = map(int, input().split())
chi_x, chi_speed = map(int, input().split())
time = int(input())
ans = False


if oni_speed > chi_speed:
    sa = abs(oni_x - chi_x)
    sa_speed = oni_speed - chi_speed
    if sa_speed*time >= sa:
        ans = True

if ans:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
a, b, n = map(int, input().split())

M = 0
for x in range(n+1):
    M = max(int(a*x/b)-(a*int(x/b)), M)

print(M)

Fixed submission:
import math

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

M = 0
t = min(b-1, n)
M = math.floor(a*t/b) - a*math.floor(t/b)

print(M)