Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
D = [[] for i in range(M)]
for i in range(N):
    A,B = map(int,input().split())
    if A <= M:
        D[A-1].append(B)
count = 0
Tax = []
for i in range(M):
    for j in D[i]:
        bisect.insort_left(Tax,j)
    if not Tax:
        continue
    count += Tax.pop()
print(count)

Fixed submission:
A,B = map(int,input().split())
C = max(A+B,A-B)
print(max(A*B,C))
Buggy python submission (verdict: Runtime Error):
import math
if __name__ == "__main__":
    A,B,C,D = map(int,input().split())
    ac = A%C
    E = int(C * D / math.gcd(C,D))
    if ac == 0:
        modc = B//C - A//C + 1
    else:
        modc = B//C - A//C
    ad = A%D
    if ad == 0:
        modd = B//D - A//D + 1
    else:
        modd = B//D - A//D
    ae = A%E
    if ae == 0:
        mode = B//E - A//E + 1
    else:
        mode = B//E - A//E
    print(int(B-A+1-modc-modd+mode))

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

if __name__ == "__main__":
    A,B,C,D = map(int,input().split())
    ac = A%C
    E = int(C*D/gcd(C,D))
    if ac == 0:
        modc = B//C - A//C + 1
    else:
        modc = B//C - A//C
    ad = A%D
    if ad == 0:
        modd = B//D - A//D + 1
    else:
        modd = B//D - A//D
    ae = A%E
    if ae == 0:
        mode = B//E - A//E + 1
    else:
        mode = B//E - A//E
    print(int(B-A+1-modc-modd+mode))

Buggy python submission (verdict: Runtime Error):
import math

if __name__ == "__main__":

    A,B,C,D = map(int,input().split())
    ac = A%C
    #bc = B%C
    E = int(C * D / math.gcd(C,D))
    if ac == 0:
        modc = B//C - A//C + 1
    else:
        modc = B//C - A//C
    ad = A%D
    if ad == 0:
        modd = B//D - A//D + 1
    else:
        modd = B//D - A//D
    ae = A%E
    if ae == 0:
        mode = B//E - A//E + 1
    else:
        mode = B//E - A//E
    print(int(B-A+1-modc-modd+mode))


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

if __name__ == "__main__":
    A,B,C,D = map(int,input().split())
    ac = A%C
    E = int(C*D/gcd(C,D))
    if ac == 0:
        modc = B//C - A//C + 1
    else:
        modc = B//C - A//C
    ad = A%D
    if ad == 0:
        modd = B//D - A//D + 1
    else:
        modd = B//D - A//D
    ae = A%E
    if ae == 0:
        mode = B//E - A//E + 1
    else:
        mode = B//E - A//E
    print(int(B-A+1-modc-modd+mode))
Buggy python submission (verdict: Runtime Error):
N = int(input())
B = []
for I in range(N):
    x,y = map(int,input().split())
    B.append([x,y])
B.sort()
minmin = N
for i in range(1,N):
    for j in range(N-i):
        d = [B[j+i][0]-B[j][0],B[j+i][1]-B[j][1]]
        A = [a for a in B]
        L = 1
        st = A.pop(0)
        while len(A)>1:
            next = [st[0]+d[0],st[1]+d[1]]
            if next in A:
                st = next
                A.remove(next)
            else:
                L += 1
                st = A.pop(0)
        if L < minmin:
            minmin = L
print(L)

Fixed submission:
N = int(input())
B = []
for I in range(N):
    x,y = map(int,input().split())
    B.append([x,y])
B.sort()
minmin = N
for i in range(1,N):
    for j in range(N-i):
        d = [B[j+i][0]-B[j][0],B[j+i][1]-B[j][1]]
        A = [a for a in B]
        L = 1
        st = A.pop(0)
        while len(A)>0:
            next = [st[0]+d[0],st[1]+d[1]]
            if next in A:
                st = next
                A.remove(next)
            else:
                L += 1
                st = A.pop(0)
        if L < minmin:
            minmin = L
print(minmin)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
A.sort()
K = N-1
ans = []
while(K>1):
    if A[K-1] < 0:
        break
    l = A[0] - A[K]
    ans.append(str(A[0])+" "+str(A[K]))
    A[0] = l
    K -= 1
if K == 1:
    ans.apend(str(A[1])+" "+str(A[0]))
    print(A[1]-A[0])
else:
    b = A[K]
    for i in range(K-1,0,-1):
        c = A[i]
        ans.append(str(b)+" "+str(c))
        b = b-c
    ans.append(str(b)+" "+str(A[0]))
    print(b-A[0])
for p in ans:
    print(p)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
A.sort()
K = N-1
ans = []
while(K>1):
    if A[K-1] < 0:
        break
    l = A[0] - A[K]
    ans.append(str(A[0])+" "+str(A[K]))
    A[0] = l
    K -= 1
if K == 1:
    ans.append(str(A[1])+" "+str(A[0]))
    print(A[1]-A[0])
else:
    b = A[K]
    for i in range(K-1,0,-1):
        c = A[i]
        ans.append(str(b)+" "+str(c))
        b = b-c
    ans.append(str(b)+" "+str(A[0]))
    print(b-A[0])
for p in ans:
    print(p)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
A.sort()
K = N-1
ans = []
while(K>1):
    if A[K-1] < 0:
        break
    l = A[0] - A[K]
    ans.append(str(A[0])+" "+str(A[K]))
    A[0] = l
    K -= 1
if N == 2:
    ans.apend(str(A[1])+" "+str(A[0]))
    print(A[1]-A[0])
else:
    b = A[K]
    for i in range(K-1,0,-1):
        c = A[i]
        ans.append(str(b)+" "+str(c))
        b = b-c
    ans.append(str(b)+" "+str(A[0]))
    print(b-A[0])
for p in ans:
    print(p)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
A.sort()
K = N-1
ans = []
while(K>1):
    if A[K-1] < 0:
        break
    l = A[0] - A[K]
    ans.append(str(A[0])+" "+str(A[K]))
    A[0] = l
    K -= 1
if K == 1:
    ans.append(str(A[1])+" "+str(A[0]))
    print(A[1]-A[0])
else:
    b = A[K]
    for i in range(K-1,0,-1):
        c = A[i]
        ans.append(str(b)+" "+str(c))
        b = b-c
    ans.append(str(b)+" "+str(A[0]))
    print(b-A[0])
for p in ans:
    print(p)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
A.sort()
K = N-1
ans = []
while(K>1):
    if A[K-1] < 0:
        break
    l = A[0] - A[K]
    ans.append(str(A[0])+" "+str(A[K]))
    A[0] = l
    K -= 1
if N == 2:
    ans.apend(str(A[1])+" "+str(A[0]))
    print(A[1]-A[0])
else:
    b = A[K]
    for i in range(K-1,0,-1):
        c = A[i]
        print(b,c)
        b = b-c
    ans.append(str(b)+" "+str(A[0]))
    print(b-A[0])
for p in ans:
    print(p)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
A.sort()
K = N-1
ans = []
while(K>1):
    if A[K-1] < 0:
        break
    l = A[0] - A[K]
    ans.append(str(A[0])+" "+str(A[K]))
    A[0] = l
    K -= 1
if K == 1:
    ans.append(str(A[1])+" "+str(A[0]))
    print(A[1]-A[0])
else:
    b = A[K]
    for i in range(K-1,0,-1):
        c = A[i]
        ans.append(str(b)+" "+str(c))
        b = b-c
    ans.append(str(b)+" "+str(A[0]))
    print(b-A[0])
for p in ans:
    print(p)
Buggy python submission (verdict: Runtime Error):
L = input()
l = len(L)
a = 1
for i in range(l):
    a = 3 * a
    a = a % 1000000007
b = 2
c = 0
j = l-2
while(j >= 0):
    if L[l-1-j] == "0":
        d = 2 * b % 1000000007
    else:
        b = (2 * b) % 1000000007
    c = (3 * c) % 1000000007
    c = d + c
    j -= 1
a = a - c % 1000000007
print(a)

Fixed submission:
L = input()
l = len(L)
a = 1
for i in range(l):
    a = 3 * a
    a = a % 1000000007
b = 2
c = 0
j = l-2
while(j >= 0):
    d = 0
    if L[l-1-j] == "0":
        d = 2 * b % 1000000007
    else:
        b = (2 * b) % 1000000007
    c = (3 * c) % 1000000007
    c = (d + c) % 1000000007
    j -= 1
a = (a - c) % 1000000007
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

def gcd_array(A):
    n = len(A)
    s = A[0]
    i = 1
    while(i < n):
        s = gcd(s,A[i])
        i += 1
    return s

if __name__ == "__main__":
    N = int(input())
    B = list(map(int,input().split()))
    max = 0
    i = 0
    while(i < N):
        A = [i for i in B]
        A.pop(i)
        d = gcd_array(A)
        if max <= d:
            max = d
        i += 1
    print(max)

Fixed submission:
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

def gcd_array(A):
    n = len(A)
    s = A[0]
    i = 1
    Down = [0]
    while(i < n):
        t = gcd(s,A[i])
        if t < s:
            Down.append(i)
        s = t
        i += 1
    return s,Down

if __name__ == "__main__":
    N = int(input())
    B = list(map(int,input().split()))
    max = 0
    d,Down = gcd_array(B)
    C = [i//d for i in B]
    c = C[0]
    K = 1
    for j in Down:
        A = [i for i in C]
        c = A.pop(j)
        l = gcd_array(A)[0]
        if K < l:
            K = l
    print(K * d)

Buggy python submission (verdict: Time Limit Exceeded):
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

def gcd_array(A):
    n = len(A)
    s = A[0]
    for i in range(1,n):
        s = gcd(s,A[i])
    return s

if __name__ == "__main__":
    N = int(input())
    B = list(map(int,input().split()))
    max = 0
    for i in range(N):
        A = [i for i in B]
        A.pop(i)
        d = gcd_array(A)
        if max <= d:
            max = d
    print(max)

Fixed submission:
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

def gcd_array(A):
    n = len(A)
    s = A[0]
    i = 1
    Down = [0]
    while(i < n):
        t = gcd(s,A[i])
        if t < s:
            Down.append(i)
        s = t
        i += 1
    return s,Down

if __name__ == "__main__":
    N = int(input())
    B = list(map(int,input().split()))
    max = 0
    d,Down = gcd_array(B)
    C = [i//d for i in B]
    c = C[0]
    K = 1
    for j in Down:
        A = [i for i in C]
        c = A.pop(j)
        l = gcd_array(A)[0]
        if K < l:
            K = l
    print(K * d)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
s = list(map(int,input()))
s.append(2)
start = s[0]
choku = [0]
saka = [0]
number = 1
for i in range(N):
    if s[i] == s[i+1]:
        number += 1
    else:
        if s[i] == 0:
            choku.append(number)
            number = 1
        else:
            saka.append(number)
            number = 1
choku.append(0)
saka.append(0)
while(1):
    max_align = 0
    m = len(choku)
    n = len(saka)
    if m <= K:
        print(N)
        break
    if start == 0: #最初が直立の場合
        for i in range(m-K+1):
            if max_align <= sum(choku[i:i+K]) + sum(saka[i-1:i+K]):
                max_align = sum(choku[i:i+K]) + sum(saka[i-1:i+K])
    else:
        for i in range(m-K+1):
            if max_align <= sum(choku[i:i+K]) + sum(saka[i:i+K+1]):
                max_align = sum(choku[i:i+K]) + sum(saka[i:i+K+1])
    print(max_align)
    break

Fixed submission:
A,B = map(int,input().split())
if A == B:
  print(2 * A)
elif A > B:
  print(2 * A -1)
else:
  print(2 * B -1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

mod = 10**9 + 7

if __name__ == "__main__":
    n = int(input())
    a = list(map(int,input().split()))
    ans = 0
    for i in range(n):
        for j in range(i+1,n):
            d = a[i]*a[j]
            d = d%mod
            ans += d
            ans%=mod
    print(ans)

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

mod = 10**9 + 7

if __name__ == "__main__":
    n = int(input())
    a = list(map(int,input().split()))
    a.sort()
    prefix = [a[0]]
    for i in range(1,n):
        prefix.append(prefix[i-1] + a[i])
    ans = 0
    for i in range(n-1):
        d = (a[i]*(prefix[-1] - prefix[i]))%mod
        ans = ans + d
        ans = ans%mod
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

INF = 10**9+7

if __name__ == "__main__":
    k = int(input())
    if k%2 == 0:
        print(-1)
        sys.exit()
    cnt = 1
    a = 7
    while a<10**100000+1:
        if a%k == 0:
            print(cnt)
            sys.exit()
        a*=10
        a+=7
        cnt+=1
    print(k-1)

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

INF = 10**9+7

if __name__ == "__main__":
    k = int(input())
    if k%2 == 0:
        print(-1)
        sys.exit()
    cnt = 1
    a = 7
    d = [a]
    for i in range(10**6+1):
        if d[i]%k == 0:
            print(i+1)
            sys.exit()
        b = 10*d[i]
        b%=k
        b+=7
        b%=k
        d.append(b)
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

INF = 10**9+7

if __name__ == "__main__":
    k = int(input())
    if k%2 == 0:
        print(-1)
        sys.exit()
    a = 7
    p = len(str(k)) + 1
    for i in range(p+10**5):
        if a%k == 0:
            print(i+1)
            sys.exit()
        a*=10
        a+=7
    print(k-1)

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

INF = 10**9+7

if __name__ == "__main__":
    k = int(input())
    if k%2 == 0:
        print(-1)
        sys.exit()
    cnt = 1
    a = 7
    d = [a]
    for i in range(10**6+1):
        if d[i]%k == 0:
            print(i+1)
            sys.exit()
        b = 10*d[i]
        b%=k
        b+=7
        b%=k
        d.append(b)
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

n,k = map(int,input().split())
a = list(map(int,input().split()))
d = 1
for i in range(k):
    d = d*a[i]
b = [d]
for i in range(n-k):
    c = (b[-1]*a[k+i])//a[i]
    b.append(c)
for i in range(n-k):
    if b[i+1]>b[i]:
        print("Yes")
    else:
        print("No")

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect
mod = 10**9+7

n,k = map(int,input().split())
a = list(map(int,input().split()))
d = 1
mina = min(a)+1
for i in range(n-k):
    if a[i] < a[i+k]:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

n,k = map(int,input().split())
a = list(map(int,input().split()))
d = 1
for i in range(k):
    d = d*a[i]
b = [d]
for i in range(n-k):
    c = (b[-1]*a[k+i])//a[i]
    b.append(c)
for i in range(n-k):
    if b[i+1]>b[i]:
        print("Yes")
    else:
        print("No")

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect
mod = 10**9+7

n,k = map(int,input().split())
a = list(map(int,input().split()))
d = 1
mina = min(a)+1
for i in range(n-k):
    if a[i] < a[i+k]:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect
INF = 10**18
def judge(li_tate,li_yoko,li2):
    for i in range(len(li_tate)):
        if li_tate[i]:
            for j in range(len(li2[i])):
                li2[i][j] = "red"
    for i in range(len(li_yoko)):
        if li_yoko[i]:
            for j in range(w-1):
                li2[j][i] = "red"
    cnt = 0
    for i in range(h):
        for j in range(w):
            if li2[i][j] == "#":
                cnt+=1
    return cnt


if __name__ == "__main__":
    h,w,k = map(int,input().split())
    li = []
    for i in range(h):
        s = list(input())
        li.append(s)
    
    ans = 0
    for i in range(2**h):
        li_tate = [False]*(h)
        for j in range(h):
            if (i>>j)&1:
                li_tate[h-j-1] = True
        for j in range(2**w):
            li_yoko = [False]*(w)
            for l in range(w):
                if (j>>l)&1:
                    li_yoko[w-l-1] = True
            li2 = copy.deepcopy(li)
            a = judge(li_tate,li_yoko,li2)
            if a == k:
                ans += 1
    print(ans)

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect
INF = 10**18
def judge(li_tate,li_yoko,li2):
    for i in range(len(li_tate)):
        if li_tate[i]:
            for j in range(len(li2[i])):
                li2[i][j] = "red"
    for i in range(len(li_yoko)):
        if li_yoko[i]:
            for j in range(h):
                li2[j][i] = "red"
    cnt = 0
    for i in range(len(li_tate)):
        for j in range(len(li_yoko)):
            if li2[i][j] == "#":
                cnt+=1
    return cnt


if __name__ == "__main__":
    h,w,k = map(int,input().split())
    li = []
    for i in range(h):
        s = list(input())
        li.append(s)
    
    ans = 0
    for i in range(2**h):
        li_tate = [False]*(h)
        for j in range(h):
            if (i>>j)&1:
                li_tate[h-j-1] = True
        for j in range(2**w):
            li_yoko = [False]*(w)
            for l in range(w):
                if (j>>l)&1:
                    li_yoko[w-l-1] = True
            li2 = copy.deepcopy(li)
            a = judge(li_tate,li_yoko,li2)
            if a == k:
                ans += 1
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy


def make_divisors(n):
    divisors = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            divisors.append(i)
            if i != n//i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

if __name__ == "__main__":
    n = int(input())
    dp = [0]*(10**7+1)
    for i in range(1,n+1):
        for j in range(i,n+1,i):
            dp[j]+=1
    ans = 0
    for i in range(1,n+1):
        ans += i*dp[i]
    print(ans)

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy


def make_divisors(n):
    divisors = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            divisors.append(i)
            if i != n//i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

if __name__ == "__main__":
    n = int(input())
    dp = [0]*(10**7+1)
    for i in range(1,n+1):
        for j in range(i,n+1,i):
            dp[j]+=1
    ans = 0
    for i in range(1,n+1):
        ans += i*dp[i]
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

if __name__ == "__main__":
    n = int(input())
    a = list(map(int,input().split()))
    ans = [0]*(n)
    ans[0] = a[0]
    for i in range(1,n):
        ans[i] = ans[i-1]*a[i]
    if ans[-1]>10**18:
        print(-1)
        sys.exit()
    print(ans[-1])

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

if __name__ == "__main__":
    n = int(input())
    a = list(map(int,input().split()))
    a.sort()
    ans = 1
    for i in range(n):
        if a[i] == 0:
            print(0)
            sys.exit()
        ans *= a[i]
        if ans>10**18:
            print(-1)
            sys.exit()
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

if __name__ == "__main__":
    n = int(input())
    a = list(map(int,input().split()))
    ans = 1
    for i in range(n):
        ans *= a[i]
    if ans >10**18:
        print(-1)
        sys.exit()
    print(ans)

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

if __name__ == "__main__":
    n = int(input())
    a = list(map(int,input().split()))
    a.sort()
    ans = 1
    for i in range(n):
        if a[i] == 0:
            print(0)
            sys.exit()
        ans *= a[i]
        if ans>10**18:
            print(-1)
            sys.exit()
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections


x = int(input())
for i in range(-1000,1001):
    for j in range(-1000,1001):
        if i**5 - j**5 == x:
            print(i,j)

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections


x = int(input())
for i in range(-1000,1001):
    for j in range(-1000,1001):
        if i**5 - j**5 == x:
            print(i,j)
            sys.exit()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

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

for i in range(1,min(b+1,n+1)):
    d = math.floor((a*i)/b)
    e = a*math.floor(i/b)
    if e>0:
        break
    ans = max(ans,d-e)
print(ans)

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

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

if n < b-1:
    ans = math.floor((a*n)/b)
else:
    ans = math.floor((a*(b-1))/b)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

a,b,n = map(int,input().split())
ans = math.floor((a*1)/b) - a*math.floor(1/b)
for i in range(1,n+1):
    d = math.floor((a*i)/b) - a*math.floor(i/b)
    if ans > d:
        break
    ans = max(ans,d)

print(ans)

Fixed submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

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

if n < b-1:
    ans = math.floor((a*n)/b)
else:
    ans = math.floor((a*(b-1))/b)
print(ans)