Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03238 (python)

Fixed submission:
Age = int(input())
if Age ==1:
    print("Hello World")
else:
    AB = [int(input()) for i in range(2)]
    print(AB[0]+AB[1])

Buggy submission (verdict: Runtime Error):
Age = int(input())
if Age ==1:
  	print("Hello World")
else:
	AB = [int(input()) for i in range(2)]
    print(AB[0]+AB[1])
Problem p03273 (python)

Fixed submission:
def tenchi(gr):
    gr_t=[[0]*len(gr) for i in range(len(gr[0]))]
    for i in range(len(gr)):
        for j in range(len(gr[i])):
            gr_t[j][i] = gr[i][j]
    return gr_t

H, W = map(int,input().split())
a=[list(input()) for i in range(H)]
#yoko
while a.count(["."]*len(a[0]))>0:
    a.remove(["."]*len(a[0]))

a_t = tenchi(a)
while a_t.count(["."]*len(a_t[0]))>0:
    a_t.remove(["."]*len(a_t[0]))
ans = tenchi(a_t)
for i in range(len(ans)):
    ansa = "".join(ans[i])
    print(ansa)

Buggy submission (verdict: Runtime Error):
H, W = map(int,input().split())
a=[list(input()) for i in range(H)]
#yoko
while a.count(["."]*len(a[0]))>0:
    a.remove(["."]*len(a[0]))

a_t = tenchi(a)
while a_t.count(["."]*len(a_t[0]))>0:
    a_t.remove(["."]*len(a_t[0]))
ans = tenchi(a_t)
for i in range(len(ans)):
    ansa = "".join(ans[i])
    print(ansa)

def tenchi(gr):
    gr_t=[[0]*len(gr) for i in range(len(gr[0]))]
    for i in range(len(gr)):
        for j in range(len(gr[i])):
            gr_t[j][i] = gr[i][j]
    return gr_t

Buggy submission (verdict: Runtime Error):
H, W = map(int,input().split())
a=[list(input()) for i in range(H)]
for i in range(1,H):
    if a[-i]==["."]*W:
        a.pop(-i)
a_t = tenchi(a)
for i in range(1,len(a_t)):
    if a_t[-i]==["."]*len(a):
        a_t.pop(-i)
ans = tenchi(a_t)
for i in range(len(ans)):
    ansa = "".join(ans[i])
    print(ansa)

def tenchi(gr):
    gr_t=[[0]*len(gr) for i in range(len(gr[0]))]
    for i in range(len(gr)):
        for j in range(len(gr[i])):
            gr_t[j][i] = gr[i][j]
    return gr_t

Buggy submission (verdict: Runtime Error):
H, W = map(int,input().split())
a=[list(input()) for i in range(H)]
#yoko
for i in range(1,H):
    if a[-i]==["."]*W:
        a.pop(-i)
a_t = tenchi(a)
for i in range(1,len(a_t)):
    if a_t[-i]==["."]*len(a):
        a_t.pop(-i)
ans = tenchi(a_t)
for i in range(len(ans)):
    ansa = "".join(ans[i])
    print(ansa)

def tenchi(gr):
    gr_t=[[0]*len(gr) for i in range(len(gr[0]))]
    for i in range(len(gr)):
        for j in range(len(gr[i])):
            gr_t[j][i] = gr[i][j]
    return gr_t
Problem p03385 (python)

Fixed submission:
S =list(input())
S.sort()
if S ==["a","b","c"]:
    print("Yes")
else: print("No")

Buggy submission (verdict: Runtime Error):
S = input()
S.sort()
if S == "abc":
	print("Yes")
else: print("No")
Problem p03399 (python)

Fixed submission:
A = [int(input()) for i in range(4)]
print(min(A[0],A[1])+min(A[2],A[3]))

Buggy submission (verdict: Runtime Error):
A = [int(input()) for i in range(4)]
print(min(A[0]+A[1])+min(A[2]+A[3]))
Problem p03425 (python)

Fixed submission:
import collections
N = int(input())
S = [input() for i in range(N)]
SI = [S[i][0] for i in range(N)]
cnt = collections.Counter(SI)
n = [cnt["M"],cnt["A"],cnt["R"],cnt["C"],cnt["H"]]
ans = 0
for i in range(3):
    for j in range(i+1,5):
        for k in range(j+1,5):
            ans += n[i]*n[j]*n[k]
print(ans)

Buggy submission (verdict: Runtime Error):
5
CHOKUDAI
RNG
MAKOTO
AOKI
RINGO
Problem p03543 (python)

Fixed submission:
N = input()
if N[0]==N[1]==N[2] or N[1]==N[2]==N[3]:
	print("Yes")
else: print("No")

Buggy submission (verdict: Runtime Error):
N =input()
if N.count(N[0])>2 or N.count(N[1]>2):
	print("Yes")
else: print("No")
Problem p03609 (python)

Fixed submission:
x, t =map(int,input().split())
print(max(0,x-t))

Buggy submission (verdict: Runtime Error):
print(max(0,int(input())-int(input())))
Problem p03638 (python)

Fixed submission:
H, W = map(int,input().split())
N = int(input())
a = list(map(int,input().split()))
b =[0]*(H*W)
k = 0
for i in range(N):
    for j in range(a[i]):
        b[k] = i + 1
        k += 1
x, y = 0, 0
ans =[[0]*W for i in range(H)]
for i in range(H*W):
    ans[y][x] = b[i]
    if (x == 0 and y%2 == 1) or (x == W - 1 and y%2 == 0):
        y += 1
    elif y%2 == 0:
        x += 1
    else:
        x -= 1
for _ in range(H):
    print(*ans[_])

Buggy submission (verdict: Runtime Error):
H, W = map(int,input().split())
N = int(input())
a = list(map(int,input().split()))
b =[0]*(H*W)
k = 0
for i in range(N):
    for j in range(a[i]):
        b[k] = i + 1
        k += 1
x, y = 0, 0
ans =[[0]*W for i in range(W)]
for i in range(H*W):
    ans[y][x] = b[i]
    if x == 0 and y%2 == 1 or x == W - 1 and y%2 == 0:
        y += 1
    elif y%2 == 0:
        x += 1
    else:
        x -= 1
for _ in range(H):
    print(*ans[_])
Problem p03795 (python)

Fixed submission:
N =int(input())
print(N*800-(N//15)*200)

Buggy submission (verdict: Runtime Error):
N =int(input())
print(N*800-(n//8)*200)
Problem p03813 (python)

Fixed submission:
if int(input())>=1200:
    print("ARC")
else: print("ABC")

Buggy submission (verdict: Runtime Error):
if int(input())>=1200:
    print("ARC")
else print("ABC")

Buggy submission (verdict: Runtime Error):
if int(input())>=1200:
	print("ARC")
else print("ABC")
Problem p03861 (python)

Fixed submission:
a, b, x = map(int,input().split())
print(b//x-(a-1)//x)

Buggy submission (verdict: Runtime Error):
a, b, x = map(int,input().split())
print((b//x-a//x)
Problem p03999 (python)

Fixed submission:
S = list(input())
form = "0"+str(len(S)-1)+"b"
ans = 0
if len(S)==1:
    print(int(S[0]))
else:
    for i in range(2**(len(S)-1)):
        b = format(i, form)
        eq = [S[0]]
        for j in range(len(b)):
            if b[j] == "1":
                sign = "+"
            else: sign = ""
            eq.append(sign)
            eq.append(S[j+1])
        eqstr = str("".join(eq))
        ans += eval(eqstr)
    print(ans)

Buggy submission (verdict: Runtime Error):
S = list(input())
form = "0"+str(len(S)-1)+"b"
ans = 0
for i in range(2**(len(S)-1)):
    b = format(i, form)
    eq = [S[0]]
    for j in range(len(b)):
        if b[j] == "1":
            sign = "+"
        else: sign = ""
        eq.append(sign)
        eq.append(S[j+1])
    eqstr = str("".join(eq))
    ans += eval(eqstr)
print(ans)
Problem p04045 (python)

Fixed submission:
N, K = map(int,input().split())
D = list(input())
for i in range(N, 100000):
    M = list(str(i))
    if all([M[j] not in D for j in range(len(M))]):
        ans = int("".join(M))
        break
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int,input().split())
D = list(input())
for i in range(N, 10000):
    M = list(str(i))
    if all([M[j] not in D for j in range(len(M))]):
        ans = int("".join(M))
        break
print(ans)
Problem p02553 (python)

Fixed submission:
a, b, c, d =[int(s) for s in input().split()]
print(max(a * c, a * d, b * c, b * d))

Buggy submission (verdict: Runtime Error):
a, b, c, d =[int(s) for s in input().split()]
print(max(a * c, a * d, b * c, b * d)

Buggy submission (verdict: Runtime Error):
a, b, c, d = [int(s) for s in input().split()]
return max(a * c, a * d, b *c, b * d)
Problem p02573 (python)

Fixed submission:
import collections

class UnionFind:
    def __init__(self, n):
        self.parent = list(range(n))
        self.rank = [0] * n

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

N, M = map(int, input().split())
tree = UnionFind(N)

for i in range(M):
    A, B = map(int, input().split())
    tree.unite(A-1, B-1)

roots = [tree.find(p) for p in tree.parent]
count = collections.Counter(roots).most_common(1)[0][1]
print(count)

Buggy submission (verdict: Runtime Error):
import collections

class UnionFind:
    def __init__(self, n):
        self.parent = list(range(n))

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        else:
            self.parent[x] = y

N, M = map(int, input().split())
tree = UnionFind(N)

for i in range(M):
    A, B = map(int, input().split())
    tree.unite(A-1, B-1)

roots = [tree.find(p) for p in tree.parent]
count = collections.Counter(roots).most_common(1)[0][1]
print(count)
Problem p02684 (python)

Fixed submission:
int1 = lambda s: int(s)-1

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

X = []
visited = set()
now = 0
while now not in visited:
    visited.add(now)
    X.append(now)
    now = A[now]

if K < len(X):
    print(X[K] + 1)
else:
    s = X.index(now)
    print(X[s + ((K - s) % (len(X) - s))] + 1)

Buggy submission (verdict: Runtime Error):
int1 = lambda s: int(s)-1

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

X = []
visited = set()
now = 0
while now not in visited:
    visited.add(now)
    X.append(now)
    now = A[now]

if K < len(X):
    print(X[k])
else:
    s = X.index(now)
    print(X[s + ((K - s) % (len(X) - s))] + 1)
Problem p02696 (python)

Fixed submission:
def f(x, A, B):
    return ((A*x)//B) - A*(x // B)

def main():
    A, B, N = map(int, input().split())
    ans = -1
    for x in range(min(B-1, N), max(min(B-1, N)-N, -1), min(-B+1, -1)):
        ans = max(ans, f(x, A, B))
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def f(x, A, B):
    return ((A*x)//B) - A*(x // B)

def main():
    A, B, N = map(int, input().split())
    ans = -1
    for x in range(min(B-1, N), max(min(B-1, N)-N, -1), -B+1):
        ans = max(ans, f(x, A, B))
    print(ans)

if __name__ == '__main__':
    main()
Problem p02947 (python)

Fixed submission:
import collections

m = [0] * (10**6)
for i in range(1, len(m)):
    m[i] = m[i-1] + i

n = int(input())
s = [''.join(sorted(input())) for i in range(n)]

c = 0
for k, v in collections.Counter(s).items():
    if v <= 1:
        continue
    c += m[v-1]

print(c)

Buggy submission (verdict: Runtime Error):
import collections

m = dict()
def f(n):
    if n <= 1:
        return 0
    else:
        if n in m:
            return m[n]
        else:
            m[n] = (n-1) + f(n-1)
            return m[n]

n = int(input())
s = [''.join(sorted(input())) for i in range(n)]

c = 0
for k, v in collections.Counter(s).items():
    if v <= 1:
        continue
    c += f(v)

print(c)

Buggy submission (verdict: Runtime Error):
import collections

m = dict()
def f(n):
    if n == 0:
        return 1
    elif n in m:
        return m[n]
    else:
        m[n] = n * f(n-1)
        return m[n]

n = int(input())
s = [''.join(sorted(input())) for i in range(n)]

c = 0
for k, v in collections.Counter(s).items():
    c += (f(v) // 2)

print(c)
Problem p02994 (python)

Fixed submission:
N, L = map(int, input().split())
a = [x+L for x in range(N)]
print(sum(a) - min(a, key=lambda x:abs(x)))

Buggy submission (verdict: Runtime Error):
N, L = map(int, input().split())
a = [x+L for x in range(N)]
print(sum(a) - min(a, map(abs, a)))
Problem p02995 (python)

Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

A, B, C, D = map(int, input().split())
A -= 1

X1 = A - ((A // C) + (A // D) - (A // lcm(C, D)))
X2 = B - ((B // C) + (B // D) - (B // lcm(C, D)))
print(X2 - X1)

Buggy submission (verdict: Runtime Error):
import math

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

A, B, C, D = map(int, input().split())
B += 1

X1 = A - ((A // C) + (A // D) - (A // lcm(C, D)))
X2 = B - ((B // C) + (B // D) - (B // lcm(C, D)))
print(X2 - X1)
Problem p02603 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
money  = 1000
stock = 0
min_price = a[0]
max_price = a[0]
is_first_time_of_drop = False
for i in range(1, n):
    if a[i] > max_price:
        max_price = a[i]
        is_first_time_of_drop = True
        if i == n - 1:
            money = (money // min_price) * max_price + money % min_price
    elif a[i] == max_price:
        if i == n - 1:
            money = (money // min_price) * max_price + money % min_price
        continue
    else:
        if is_first_time_of_drop:
            money = (money // min_price) * max_price + money % min_price
            min_price = a[i]
            max_price = a[i]
            is_first_time_of_drop = False
        else:
            if a[i] < min_price:
                min_price = a[i]
                max_price = a[i]
            elif a[i] == min_price:
                continue
            else:
                is_first_time_of_drop = True
print(money)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

state_of_up_or_down = False
money = 1000
min_price = a[0]
for i in range(1, n):
    if a[i] > a[i - 1]:
        # min_price = min(a[i - 1], min_price)
        max_price = a[i]
        state_of_up_or_down = True
        if i == n - 1:
            money = (money // min_price) * max_price + money % min_price
    elif a[i] == a[i - 1]:
        if i == n - 1:
            money = (money // min_price) * max_price + money % min_price        
        pass
    else:
        if state_of_up_or_down:
            money = (money // min_price) * max_price + money % min_price
            state_of_up_or_down = False
        # max_price = a[i]
        min_price = a[i]
    # print(money, min_price, state_of_up_or_down)
print(money)
Problem p02743 (python)

Fixed submission:
from decimal import Decimal
import math
a,b,c=map(int,input().split())
if c-a-b>0 and 4*a*b<(c-a-b)**2:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
from decimal import Decimal
import math
a,b,c=map(int,input().split())
if a+b+2*Decimal(math.sqrt(a))*Demical(math.sqrt(b))<c:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
from decimal import Decimal
import math
a,b,c=map(int,input().split())
if Demical(str(a))+Demical(str(b))+Decimal(str(2*math.sqrt(a*b)))<Demical(str(c)):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
from decimal import Decimal
import math
a,b,c=map(int,input().split())
if Demical(a)+Demical(b)+Decimal(2*math.sqrt(a*b))<Demical(c):
  print("Yes")
else:
  print("No")
Problem p02756 (python)

Fixed submission:
def main():
    moji=input()
    cycle=int(input())
    flont_or_back=0
    flont=""
    back=""
    for i in range(cycle):
        line=input()
        if line[0]=="1":
            flont_or_back+=1
        else:
            fi=line[2]
            ci=line[4]
            if flont_or_back%2==0:
                if fi=="1":
                    flont=ci+flont
                else:
                    back+=ci
            else:
                if fi=="1":
                    back+=ci
                else:
                    flont=ci+flont
    moji=flont+moji+back
    if flont_or_back%2==0:
        print(moji)
    else:
        print(moji[::-1])
    

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from collections import deque
import sys
input = lambda: sys.stdin.readline().rstrip() 
def main():
    moji=input()
    d=deque(moji)
    cycle=int(input())
    flont_or_back=0
    for i in range(cycle):
        line=input()
        if line[0]=="1":
            flont_or_back+=1
        else:
            fi=line[2]
            ci=line[4]
            if flont_or_back%2==0:
                if fi=="1":
                    d.appendleft(ci)
                else:
                    d.append(ci)
            else:
                if fi=="1":
                    d.append(ci)
                else:
                    d.appendleft(ci)
    if flont_or_back%2==0:
        print("".join(d))
    else:
        print("".join(d[::-1]))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline.rstrip()
def main():
    moji=input()
    cycle=int(input())
    flont_or_back=0
    flont=""
    back=""
    for i in range(cycle):
        line=input()
        if line[0]=="1":
            flont_or_back+=1
        else:
            fi=line[2]
            ci=line[4]
            if flont_or_back%2==0:
                if fi=="1":
                    flont=ci+flont
                else:
                    back+=ci
            else:
                if fi=="1":
                    back+=ci
                else:
                    flont=ci+flont
    moji=flont+moji+back
    if flont_or_back%2==0:
        print(moji)
    else:
        print(moji[::-1])
    

if __name__ == '__main__':
    main()
Problem p02780 (python)

Fixed submission:
num,renzoku=map(int,input().split())
dices=list(map(int,input().split()))
expects=[0]*num
for i in range(num):
  pi=dices[i]
  expects[i]=(1+pi)/2
Si=[0]*(num+1)
for i in range(1,num+1):
  Si[i]=Si[i-1]+expects[i-1]
max_Si=0
for i in range(0,num-renzoku+1):
  if max_Si<Si[i+renzoku]-Si[i]:
    max_Si=Si[i+renzoku]-Si[i]
print(max_Si)

Buggy submission (verdict: Runtime Error):
num,renzoku=map(int,input().split())
dices=list(map(int,input().split()))
max_renzoku=[]
for i in range(0,num-renzoku):
  max_renzoku.append(sum(dices[i:i+renzoku]))
print((max(max_renzoku)+renzoku)/2)
Problem p02983 (python)

Fixed submission:
l, r = map(int, input().split())
if r - l >= 2018:
    print(0)
else:
    min_ij = 2018
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            min_ij = min(min_ij, ((i % 2019) * (j % 2019)) % 2019)
    print(min_ij)

Buggy submission (verdict: Runtime Error):
l, r = map(int, input().split())
if r - l >= 2018:
    print(0)
else:
    min_ij = 2018 ** 2
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            min_ij = min(min_ij, (i % 2019) * (j % 2019))

print(min_ij)
Problem p03606 (python)

Fixed submission:
n = int(input())
seat = [0] * 10 ** 6
for i in range(n):
    l, r = map(int, input().split())
    for j in range(l, r + 1):
        seat[j - 1] = 1

res = 0
for i in range(10 ** 6):
    if seat[i] == 1:
        res += 1
print(res)

Buggy submission (verdict: Runtime Error):
n = int(input())
seat = [0] * 10 ** 5
for i in range(n):
    l, r = map(int, input().split())
    seat[l - 1] += 1
    seat[r] -= 1

for i in range(1, 10 ** 5):
    seat[i] += seat[i - 1]

res = 0
for i in range(10 ** 5):
    if seat[i] == 1:
        res += 1
print(res)
Problem p02612 (python)

Fixed submission:
from collections import deque, defaultdict, Counter
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
a = N % 1000
# if 0 <= N < 1000:
#     print(N)
if N % 1000 == 0:
    print(0)
else:
    print(1000 - a)


# for i in range(1, 10+1):
#     have = 1000 * i

#     if 0 <= have - N < 1000:
#         print(have - N)
#         exit()

Buggy submission (verdict: Runtime Error):
from collections import deque, defaultdict, Counter
from math import floor, ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
a = N % 1000
if 0 <= N < 1000:
    print(N)
else:
    print(a)


# for i in range(1, 10+1):
#     have = 1000 * i

#     if 0 <= have - N < 1000:
#         print(have - N)
#         exit()

Buggy submission (verdict: Runtime Error):
from collections import deque, defaultdict, Counter
from math import floor, ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
a = N % 1000

if a == 0:
    print(0)
else:
    print(1000 -  a)
Problem p02696 (python)

Fixed submission:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
A, B, N = MAP()

x = N

ans1 = (A * (B-1)//B) - A * ((B-1) // B)
ans2 = ((A * N)//B) - A * (N // B)
# print(ans2)
# ans = max(A-1, ans2)

if N < B:
    print(ans2)
else:
    
    print(ans1)

# exit()

exit()
# exit()
memo = [0] * (B+1)
ma = 0
for x in range(1, B+1):
    memo[x] = int((A * (x)/B)) - A * ((x)  // B)
    ma = max(memo[x], ma)
# print(memo[N-1])
print(memo)
# print(N)

# exit()
if N >= B:
    ans = ma
else:
    ans = memo[N]
print(ans)

Buggy submission (verdict: Runtime Error):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
A, B, N = MAP()

x = N
ans = (A * x//B) - A * (x // B)

memo = [0] * (B+1)
for x in range(1, B+1):
    memo[x] = (A * (x)//B) - A * ((x)  // B)
# print(memo[N-1])
# print(memo)
# print(N)

# exit()
if N >= B:
    ans = memo[-2]
else:
    ans = memo[N]
print(ans)