Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n,m = map(int,input().split())

from fractions import gcd
a = gcd(n,m)

import numpy as np

def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

t = seachPrimeNum(10*8)
for item in t:
    if a % item == 0:
        c += 1

print(c)

Fixed submission:
import sys
input = sys.stdin.readline
n,m = map(int,input().split())

from fractions import gcd
a = gcd(n,m)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

t = factorization(a) 

if (n == 1) or (m == 1):
    print(1)
else:
    print(len(t)+1)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    s = list(map(int,input().split()))
    r = []
    for i in range(n,0,-1):
        c = sum(x % i == 0 for x in r)
        c1 = c % 2
        if c1 != s[i-1]:
            r.append(int(i))

    print(len(r))
    if len(r) > 0:
        for i in range(len(r)):
            r[i] = str(r[i])
        print(" ".join(r))
    
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n = int(input())
    s = list(map(int,input().split()))
    r = [0] * n
    for i in range(n,n//2,-1):
        if s[i-1] == 1:
            r[i-1] = 1
    for i in range(n//2,0,-1):
        p = n // i
        c = 0
        for j in range(1,p+1):
            if r[(j * i) - 1] == 1:
                c += 1
        if c % 2 != s[i-1]:
            r[i-1] = 1

    o = sum(r)
    print(o)
    if o > 0:
        u = []
        for i in range(len(r)):
            if r[i] == 1:
                u.append(str(i+1))
        print(" ".join(u))
    
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    s = list(map(int,input().split()))
    r = []
    for i in range(n,0,-1):
        c = sum(x % i == 0 for x in r)
        c1 = c % 2
        if c1 != s[i-1]:
            r.append(str(i))

    print(len(r))
    if len(r) > 0:
        print(" ".join(r))
    
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n = int(input())
    s = list(map(int,input().split()))
    r = [0] * n
    for i in range(n,n//2,-1):
        if s[i-1] == 1:
            r[i-1] = 1
    for i in range(n//2,0,-1):
        p = n // i
        c = 0
        for j in range(1,p+1):
            if r[(j * i) - 1] == 1:
                c += 1
        if c % 2 != s[i-1]:
            r[i-1] = 1

    o = sum(r)
    print(o)
    if o > 0:
        u = []
        for i in range(len(r)):
            if r[i] == 1:
                u.append(str(i+1))
        print(" ".join(u))
    
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    s = list(map(int,input().split()))
    r = []
    for i in range(n,0,-1):
        c = sum(x % i == 0 for x in r)
        c1 = c % 2
        if c1 != s[i-1]:
            r.append(str(i))
            
    print(len(r))
    print(" ".join(r))
    

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n = int(input())
    s = list(map(int,input().split()))
    r = [0] * n
    for i in range(n,n//2,-1):
        if s[i-1] == 1:
            r[i-1] = 1
    for i in range(n//2,0,-1):
        p = n // i
        c = 0
        for j in range(1,p+1):
            if r[(j * i) - 1] == 1:
                c += 1
        if c % 2 != s[i-1]:
            r[i-1] = 1

    o = sum(r)
    print(o)
    if o > 0:
        u = []
        for i in range(len(r)):
            if r[i] == 1:
                u.append(str(i+1))
        print(" ".join(u))
    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    w1 = list(map(int,input().split()))
    w2 = list(map(int,input().split()))
    v1 = [0,0,0]
    for i in range(3):
        v1[i] = w2[i] - w1[i]
    dp1 = [0] * (n+1)
    for i in range(n):
        p = 0
        q = 0
        r = 0
        if i+1 - w1[0] >= 0:
            p = dp1[i+1 - w1[0]] + v1[0]
        if i+1 - w1[1] >= 0:
            q = dp1[i+1 - w1[1]] + v1[1]
        if i+1 - w1[2] >= 0:
            r = dp1[i+1 - w1[2]] + v1[2]
        dp1[i+1] = max(p,q,r,dp1[i])
    m = dp1[-1] + n

    v2 = [0,0,0]
    for i in range(3):
        v2[i] = w1[i] - w2[i]
    dp2 = [0] * (m+1)
    for i in range(m):
        p = 0
        q = 0
        r = 0
        if i+1 - w2[0] >= 0:
            p = dp2[i+1 - w2[0]] + v2[0]
        if i+1 - w2[1] >= 0:
            q = dp2[i+1 - w2[1]] + v2[1]
        if i+1 - w2[2] >= 0:
            r = dp2[i+1 - w2[2]] + v2[2]
        dp2[i+1] = max(p,q,r,dp2[i])
    print(m + dp2[-1])
    
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n = int(input())
    w1 = list(map(int,input().split()))
    w2 = list(map(int,input().split()))
    v1 = [0,0,0]
    for i in range(3):
        v1[i] = w2[i] - w1[i]
    dp1 = [0] * (n+1)
    for i in range(n):
        p = 0
        q = 0
        r = 0
        if i+1 - w1[0] >= 0:
            p = dp1[i+1 - w1[0]] + v1[0]
        if i+1 - w1[1] >= 0:
            q = dp1[i+1 - w1[1]] + v1[1]
        if i+1 - w1[2] >= 0:
            r = dp1[i+1 - w1[2]] + v1[2]
        dp1[i+1] = max(p,q,r,dp1[i])
    m = dp1[-1] + n

    v2 = [0,0,0]
    for i in range(3):
        v2[i] = w1[i] - w2[i]
    dp2 = [0] * (m+1)
    for i in range(m):
        p = 0
        q = 0
        r = 0
        if i+1 - w2[0] >= 0:
            p = dp2[i+1 - w2[0]] + v2[0]
        if i+1 - w2[1] >= 0:
            q = dp2[i+1 - w2[1]] + v2[1]
        if i+1 - w2[2] >= 0:
            r = dp2[i+1 - w2[2]] + v2[2]
        dp2[i+1] = max(p,q,r,dp2[i])
    print(m + dp2[-1])
    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
n = int(input())
s = [list(map(int,input().split())) for i in range(n-1)]
c = list(map(int,input().split()))
c.sort()
t = [-1] * n 
p = sum(c[:n-1])
q = defaultdict(list)
for i in range(n-1):
    q[s[i][0]] += [s[i][1]]
    q[s[i][1]] += [s[i][0]]

t1 = [t,1]

def find(q,x,t1):
    r = q[x]
    t1[0][x-1] = 0
    for i in range(len(r)):
        if t1[0][r[i]-1] == 0:
            continue
        else:
            t1 = find(q,r[i],t1)
    t1[0][x-1] = t1[1]
    t1[1] += 1
    return t1

o = find(q,1,t1)
o1 = o[0]
print(p)
b = ""
for i in range(n):
    b += str(c[o1[i]-1]) + " "

print(b)

Fixed submission:
from collections import defaultdict
import sys

sys.setrecursionlimit(10 ** 7)
n = int(input())
s = [list(map(int,input().split())) for i in range(n-1)]
c = list(map(int,input().split()))
c.sort()
t = [-1] * n 
p = sum(c[:n-1])
q = defaultdict(list)
for i in range(n-1):
    q[s[i][0]] += [s[i][1]]
    q[s[i][1]] += [s[i][0]]

t1 = [t,1]

def find(q,x,t1):
    r = q[x]
    t1[0][x-1] = 0
    for i in range(len(r)):
        if t1[0][r[i]-1] == 0:
            continue
        else:
            t1 = find(q,r[i],t1)
    t1[0][x-1] = t1[1]
    t1[1] += 1
    return t1

o = find(q,1,t1)
o1 = o[0]
print(p)
b = ""
for i in range(n):
    b += str(c[o1[i]-1]) + " "

print(b)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
import sys
sys.setrecursionlimit(10000)
n = int(input())
s = [list(map(int,input().split())) for i in range(n-1)]
t = defaultdict(list)
for i in range(n-1):
    p = [s[i][1],s[i][2]]
    q = [s[i][0],s[i][2]]
    t[s[i][0]] += [p]
    t[s[i][1]] += [q]

a = [-1]*n
a[0] = 0

def Tree(dic,a,x,lo):
    for i in range(len(dic[x])):
        if a[dic[x][i][0]-1] != -1:
            continue
        else:
            save = lo
            lo += dic[x][i][1]
            a[dic[x][i][0]-1] = lo
            a = Tree(dic,a,dic[x][i][0],lo)
            lo = save
    return a

lis = Tree(t,a,1,0)
for i in range(n):
    if lis[i] % 2 == 0:
        print(0)
    else:
        print(1)

Fixed submission:
from collections import defaultdict
import sys
sys.setrecursionlimit(1000000)

n = int(input())
s = [list(map(int,input().split())) for i in range(n-1)]
t = defaultdict(list)
for i in range(n-1):
    p = [s[i][1],s[i][2]]
    q = [s[i][0],s[i][2]]
    t[s[i][0]] += [p]
    t[s[i][1]] += [q]

a = [-1]*n
a[0] = 0

def Tree(dic,a,x,lo):
    for i in range(len(dic[x])):
        if a[dic[x][i][0]-1] != -1:
            continue
        else:
            save = lo
            lo += dic[x][i][1]
            a[dic[x][i][0]-1] = lo
            a = Tree(dic,a,dic[x][i][0],lo)
            lo = save
    return a

lis = Tree(t,a,1,0)
for i in range(n):
    if lis[i] % 2 == 0:
        print(0)
    else:
        print(1)

Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
n = int(input())
s = [list(map(int,input().split())) for i in range(n-1)]
t = defaultdict(list)
for i in range(n-1):
    p = [s[i][1],s[i][2]]
    q = [s[i][0],s[i][2]]
    t[s[i][0]] += [p]
    t[s[i][1]] += [q]

a = [-1]*n
a[0] = 0

def Tree(dic,a,x,lo):
    for i in range(len(dic[x])):
        if a[dic[x][i][0]-1] != -1:
            continue
        else:
            save = lo
            lo += dic[x][i][1]
            a[dic[x][i][0]-1] = lo
            a = Tree(dic,a,dic[x][i][0],lo)
            lo = save
    return a

lis = Tree(t,a,1,0)
for i in range(n):
    if lis[i] % 2 == 0:
        print(0)
    else:
        print(1)

Fixed submission:
from collections import defaultdict
import sys
sys.setrecursionlimit(1000000)

n = int(input())
s = [list(map(int,input().split())) for i in range(n-1)]
t = defaultdict(list)
for i in range(n-1):
    p = [s[i][1],s[i][2]]
    q = [s[i][0],s[i][2]]
    t[s[i][0]] += [p]
    t[s[i][1]] += [q]

a = [-1]*n
a[0] = 0

def Tree(dic,a,x,lo):
    for i in range(len(dic[x])):
        if a[dic[x][i][0]-1] != -1:
            continue
        else:
            save = lo
            lo += dic[x][i][1]
            a[dic[x][i][0]-1] = lo
            a = Tree(dic,a,dic[x][i][0],lo)
            lo = save
    return a

lis = Tree(t,a,1,0)
for i in range(n):
    if lis[i] % 2 == 0:
        print(0)
    else:
        print(1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
n_1 = int(n ** (1/2))
s = 0
 
for i in range(1,n_1):
    if n % i == 0:
        if i < n // i -1:
            s += (n // i) - 1

print(s)

Fixed submission:
n,k = map(int,input().split())
print(n -k + 1)
Buggy python submission (verdict: Runtime Error):
n,q = map(int,input().split())
s = list(input())
o = [1 for  i in range(n)]
t = []
r = []
for i in range(q):
    a,b = map(str,input().split())
    if a not in t:
        t.append(a)
        r.append([i for i, x in enumerate(s) if x == a])
    index1 = t.index(a)
    if b == "L":
        for i in range(len(r[index1])):
            if r[index1][i] == 0:
                n = n - o[0]
                o[0] = 0
            else:
                o[r[index1][i]-1] += o[r[index1][i]]
                o[r[index1][i]] = 0
    else:
        for i in range(len(r[index1])):
            if r[index1][i] == len(s)-1:
                n = n - o[-1]
                o[-1] = 0
            else:
                o[r[index1][i]+1] += o[r[index1][i]]
                o[r[index1][i]] = 0

print(n)

Fixed submission:
a,b,c=map(int,input().split())
if a == b and b == c:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
s = [int(input()) for i in range(n)]
s.sort()
c = s[n-k-1] - s[0]
for i in range(1,n-k+1):
    if s[i+n-k] - s[i] < c:
        c = s[i+n-k] - s[i]

print(c)

Fixed submission:
n,k = map(int,input().split())
s = [int(input()) for i in range(n)]
s.sort()
c = s[k-1] - s[0]
for i in range(1,n-k+1):
    if s[i+k-1] - s[i] < c:
        c = s[i+k-1] - s[i]

print(c)

Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
s = [int(input()) for i in range(n)]
s.sort()
c = s[n-k] - s[0]
for i in range(1,n-k+1):
    t = s[i+n-k] - s[i]
    if s[i+n-k] - s[i] < c:
        c = t

print(c)

Fixed submission:
n,k = map(int,input().split())
s = [int(input()) for i in range(n)]
s.sort()
c = s[k-1] - s[0]
for i in range(1,n-k+1):
    if s[i+k-1] - s[i] < c:
        c = s[i+k-1] - s[i]

print(c)

Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
s = [int(input()) for i in range(n)]
s.sort()
c = 10 ** 12
for i in range(n-k+1):
    t = s[i+n-k] - s[i]
    if s[i+n-k] - s[i] < c:
        c = t

print(c)

Fixed submission:
n,k = map(int,input().split())
s = [int(input()) for i in range(n)]
s.sort()
c = s[k-1] - s[0]
for i in range(1,n-k+1):
    if s[i+k-1] - s[i] < c:
        c = s[i+k-1] - s[i]

print(c)
Buggy python submission (verdict: Runtime Error):
n,x = map(int,input().split())
s = list(map(int,input().split()))
import math
for i in range(n):
    s[i] = s[i] - x

if s[0] != 0:
    t = s[0]
    for i in range(n-1):
        if s[i+1] == 0:
            continue
        else:
            t = math.gcd(t,s[i+1])
else:
    t = s[-1]
    for i in range(n-1):
        if s[-i-2] == 0:
            continue
        else:
            t = math.gcd(t,s[-i-1])

print(t)

Fixed submission:
n,x = map(int,input().split())
s = list(map(int,input().split()))

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

for i in range(n):
    s[i] = abs(s[i] - x)

if s[0] != 0:
    t = s[0]
    for i in range(n-1):
        if s[i+1] == 0:
            continue
        else:
            t = gcd(t,s[i+1])
else:
    t = s[-1]
    for i in range(n-1):
        if s[-i-2] == 0:
            continue
        else:
            t = gcd(t,s[-i-1])

print(t)

Buggy python submission (verdict: Runtime Error):
n,x = map(int,input().split())
s = list(map(int,input().split()))
import math
for i in range(n):
    s[i] = s[i] - x

t = s[0]
for i in range(n-1):
    t = math.gcd(t,s[i+1])

print(t)

Fixed submission:
n,x = map(int,input().split())
s = list(map(int,input().split()))

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

for i in range(n):
    s[i] = abs(s[i] - x)

if s[0] != 0:
    t = s[0]
    for i in range(n-1):
        if s[i+1] == 0:
            continue
        else:
            t = gcd(t,s[i+1])
else:
    t = s[-1]
    for i in range(n-1):
        if s[-i-2] == 0:
            continue
        else:
            t = gcd(t,s[-i-1])

print(t)
Buggy python submission (verdict: Runtime Error):
import  numpy as np
h,w=map(int,input().split())
s = [[0]*(w+2)]
for i in range(h):
    s.append([0]+list(input())+[0])
s.append([0]*(w+2))

t = np.array(s)
c = 0
b = 0

def sirabe(t,i,j):
    if t[i-1][j] != "#" and t[i][j-1] != "#" and t[i+1][j] != "#" and t[i][j+1] != "#":
        return False
    else:
        return True


for i in range(1,h+1):
    for j in range(1,w+1):
        if t[i][j] == "#":
            if sirabe(t,i,j):
                continue
            else:
                c = 1
                break
    if c == 1:
        break


if c == 0:
    print("Yes")
else:
    print("No")


Fixed submission:
import  numpy as np
h,w=map(int,input().split())
s = [[0]*(w+2)]
for i in range(h):
    s.append([0]+list(input())+[0])
s.append([0]*(w+2))

t = np.array(s)
c = 0
b = 0

def sirabe(t,i,j):
    if t[i-1][j] != "#" and t[i][j-1] != "#" and t[i+1][j] != "#" and t[i][j+1] != "#":
        return False
    else:
        return True


for i in range(1,h+1):
    for j in range(1,w+1):
        if t[i][j] == "#":
            if sirabe(t,i,j):
                continue
            else:
                c = 1
                break
    if c == 1:
        break


if c == 0:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
import  numpy as np
h,w=map(int,input().split())
s = [[0]*(w+2)]
for i in range(h):
    s.append([0]+list(input())+[0])
s.append([0]*(w+2))

t = np.array(s)
c = 0

def sirabe(t,i,j):
    if t[i-1][j] != "#" and t[i][j-1] != "#" and t[i+1][j] != "#" and t[i][j+1] != "#":
        return False
    else:
        return True


for i in range(1,h+1):
    for j in range(1,w+1):
        if sirabe(t,i,j):
            continue
        else:
            c = 1
            break
    if c == 1:
        break

if c == 0:
    print("Yes")
else:
    print("No")

Fixed submission:
import  numpy as np
h,w=map(int,input().split())
s = [[0]*(w+2)]
for i in range(h):
    s.append([0]+list(input())+[0])
s.append([0]*(w+2))

t = np.array(s)
c = 0
b = 0

def sirabe(t,i,j):
    if t[i-1][j] != "#" and t[i][j-1] != "#" and t[i+1][j] != "#" and t[i][j+1] != "#":
        return False
    else:
        return True


for i in range(1,h+1):
    for j in range(1,w+1):
        if t[i][j] == "#":
            if sirabe(t,i,j):
                continue
            else:
                c = 1
                break
    if c == 1:
        break


if c == 0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(map(int, input().split()))
s.sort()
t = list(set(s))

for i in range(len(t)):
    s.remove(t[i])

if len(s) % 2 == 0:
    x = len(s)
else:
    x = len(s) + 1

print(n - x)

Fixed submission:
n = int(input())
s = list(map(int, input().split()))
t = list(set(s))

for i in range(len(t)):
    s.remove(t[i])

if len(s) % 2 == 0:
    x = len(s)
else:
    x = len(s) + 1

print(n - x)
Buggy python submission (verdict: Runtime Error):
N = int(input())

s = map(int,input().split())

list(s).sort(reverse=True)

sum = 0

for i in range(N):
  sum = sum +list(s)[2*i]

print(sum)

Fixed submission:
N = int(input())

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

s.sort()

sum = 0

for i in range(N):
  sum = sum + s[2*i]

print(sum)

Buggy python submission (verdict: Runtime Error):
N = int(input())

s = map(int,input().split())

s.sort()

sum = 0

for i in range(N):
  sum = sum + s[2*i+1]

print(sum)

Fixed submission:
N = int(input())

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

s.sort()

sum = 0

for i in range(N):
  sum = sum + s[2*i]

print(sum)

Buggy python submission (verdict: Runtime Error):
N = int(input())

s = map(int,input().split())

s.sort()

sum = 0

for i in range(N):
  sum = sum + s[2*i]

print(sum)

Fixed submission:
N = int(input())

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

s.sort()

sum = 0

for i in range(N):
  sum = sum + s[2*i]

print(sum)

Buggy python submission (verdict: Runtime Error):
N = int(input())

s = map(int,input().split())

s.sort(reverse=True)

sum = 0

for i in range(N):
  sum = sum + s[2*i]

print(sum)

Fixed submission:
N = int(input())

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

s.sort()

sum = 0

for i in range(N):
  sum = sum + s[2*i]

print(sum)

Buggy python submission (verdict: Runtime Error):
N = int(input())

s = input().split()

s.sort(reverse=True)

sum = 0

for i in range(N):
  sum = sum + s[2*i]

print(sum)

Fixed submission:
N = int(input())

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

s.sort()

sum = 0

for i in range(N):
  sum = sum + s[2*i]

print(sum)
Buggy python submission (verdict: Runtime Error):

X = int(input())
m = 100
y = 0
while True:
    if X <= m: break
    m = math.floor(m * 1.01)
    y += 1
print(y)


Fixed submission:
import math

X = int(input())
m = 100
y = 0
while True:
    if X <= m: break
    m = math.floor(m * 1.01)
    y += 1
print(y)
Buggy python submission (verdict: Time Limit Exceeded):
import math

A, B, N = map(int, input().split(' '))
ans = 0
for x in range(min(B, N + 1)):
    res = math.floor((A * x) / B) - A * (math.floor(x / B))
    ans = max(res, ans)
print(int(ans))


Fixed submission:
import math

A, B, N = map(int, input().split(' '))
ans = 0
x = min(B, N + 1) - 1
ans = math.floor((A * x) / B) - A * (math.floor(x / B))
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):

A, B, N = map(int, input().split(' '))
ans = 0
for x in range(min(B, N + 1)):
    # if not x % B: continue
    res = ((A * (x % B)) - ((A * x) % B)) / B
    ans = max(ans, res)
print(int(ans))


Fixed submission:
import math

A, B, N = map(int, input().split(' '))
ans = 0
x = min(B, N + 1) - 1
ans = math.floor((A * x) / B) - A * (math.floor(x / B))
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int, input().split(' '))
ans = 0
for x in range(N + 1):
    if not x % B: continue
    res = ((A * (x % B)) - ((A * x) % B)) / B
    ans = max(ans, res)
print(int(ans))


Fixed submission:
import math

A, B, N = map(int, input().split(' '))
ans = 0
x = min(B, N + 1) - 1
ans = math.floor((A * x) / B) - A * (math.floor(x / B))
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
import math

A, B, N = map(int, input().split(' '))
ans = 0
for x in range(N + 1):
    if not x % B: continue
    res = math.floor((A * x / B) - A * math.floor(x / B))
    ans = max(ans, res)
print(ans)


Fixed submission:
import math

A, B, N = map(int, input().split(' '))
ans = 0
x = min(B, N + 1) - 1
ans = math.floor((A * x) / B) - A * (math.floor(x / B))
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
import math

A, B, N = map(int, input().split(' '))
ans = 0
for x in range(N + 1):
    res = math.floor((A * x / B) - A * math.floor(x / B))
    ans = max(ans, res)
print(ans)


Fixed submission:
import math

A, B, N = map(int, input().split(' '))
ans = 0
x = min(B, N + 1) - 1
ans = math.floor((A * x) / B) - A * (math.floor(x / B))
print(int(ans))

Buggy python submission (verdict: Runtime Error):

A, B, N = map(int, input().split(' '))
ans = 0
for x in range(N + 1):
    res = math.floor((A * x / B) - A * math.floor(x / B))
    ans = max(ans, res)
print(ans)


Fixed submission:
import math

A, B, N = map(int, input().split(' '))
ans = 0
x = min(B, N + 1) - 1
ans = math.floor((A * x) / B) - A * (math.floor(x / B))
print(int(ans))

Buggy python submission (verdict: Runtime Error):

def resolve():
A, B, N = map(int, input().split(' '))
ans = 0
for x in range(N + 1):
    res = math.floor((A * x / B) - A * math.floor(x / B))
    ans = max(ans, res)
print(ans)


Fixed submission:
import math

A, B, N = map(int, input().split(' '))
ans = 0
x = min(B, N + 1) - 1
ans = math.floor((A * x) / B) - A * (math.floor(x / B))
print(int(ans))
Buggy python submission (verdict: Runtime Error):
k=int(input())
a=int(input())
b=int(input())
c=0
for i in range(a,b+1):
  if i%k==0:
    c=c+1
if c==0:
  print("NG")
else:
  print("OK")

Fixed submission:
k=int(input())
A,B = input().split(" ")
A = int(A)
B = int(B)
c=0
for i in range(A,B+1):
  if i%k==0:
    c=c+1
if c==0:
  print("NG")
else:
  print("OK")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
R = []
G = []
B = []
RD = []
GD = []
BD = []

S = input().rstrip()

for i, s in enumerate(S):
    if s == "R":
        R.append(i)
        RD.append(i*2)
    if s == "G":
        G. append(i)
        GD.append(i*2)
    if s == "B":
        B.append(i)
        BD.append(i*2)

ans = len(R) * len(G) * len(B)
for r in R:
    for b in B:
        if r + b in GD:
            ans -= 1
for b in B:
    for g in G:
        if b + g in RD:
            ans -= 1
for r in R:
    for g in G:
        if r + g in BD:
            ans -= 1
print(ans)


Fixed submission:
N = int(input())
R = []
G = []
B = []
RD = {}
GD = {}
BD = {}

S = input().rstrip()

for i, s in enumerate(S):
    if s == "R":
        R.append(i)
        RD[i*2] = 1
    if s == "G":
        G. append(i)
        GD[i*2] = 1
    if s == "B":
        B.append(i)
        BD[i*2] = 1

ans = len(R) * len(G) * len(B)
for r in R:
    for b in B:
        if r + b in GD:
            ans -= 1
for b in B:
    for g in G:
        if b + g in RD:
            ans -= 1
for r in R:
    for g in G:
        if r + g in BD:
            ans -= 1
print(ans)