Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
a,b,c,d = map(int,input().split())
count_c = 0
count_d = 0
count_cd = 0
count = 0
j = 1
g = c*d//fractions.gcd(c,d)
while(1):
    if c*j <= b and c*j>=a:
        count_c += 1
    if d*j <=b and d*j >= a:
        count_c += 1
    if g*j <=b and g*j >= a:
        count_cd += 1
    if c*j > b and d*j > b and g*j > b:
        break
    j += 1
s = count_c+count_d-count_cd
print(b-a +1-s)

Fixed submission:
import fractions
a,b,c,d = map(int,input().split())
count_c = 0
count_d = 0
count_cd = 0
count = 0
j = 1
g = c*d//fractions.gcd(c,d)

count_c = b//c - (a-1)//c
count_d = b//d - (a-1)//d
count_cd = b//g -(a-1)//g
count_s = count_c+count_d-count_cd
print(b-a+1-count_s)

Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
count_c = 0
count_d = 0
count_cd = 0
count = 0
j = 1
g = c*d//math.gcd(c,d)
while(1):
    if c*j <= b and c*j>=a:
        count_c += 1
    if d*j <=b and d*j >= a:
        count_c += 1
    if g*j <=b and g*j >= a:
        count_cd += 1
    if c*j > b and d*j > b and g*j > b:
        break
    j += 1
s = count_c+count_d-count_cd
print(b-a +1-s)

Fixed submission:
import fractions
a,b,c,d = map(int,input().split())
count_c = 0
count_d = 0
count_cd = 0
count = 0
j = 1
g = c*d//fractions.gcd(c,d)

count_c = b//c - (a-1)//c
count_d = b//d - (a-1)//d
count_cd = b//g -(a-1)//g
count_s = count_c+count_d-count_cd
print(b-a+1-count_s)

Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
count_c = 0
count_d = 0
count_cd = 0
count = 0
j = 1
g = c*d//math.gcd(c,d)
while(1)
    if c*j <= b and c*j>=a:
        count_c += 1
    if d*j <=b and d*j >= a:
        count_c += 1
    if g*j <=b and g*j >= a:
        count_cd += 1
    if c*j > b and d*j > b and g*j > b:
        break
    j += 1
s = count_c+count_d-count_cd
print(b-a +1-s)

Fixed submission:
import fractions
a,b,c,d = map(int,input().split())
count_c = 0
count_d = 0
count_cd = 0
count = 0
j = 1
g = c*d//fractions.gcd(c,d)

count_c = b//c - (a-1)//c
count_d = b//d - (a-1)//d
count_cd = b//g -(a-1)//g
count_s = count_c+count_d-count_cd
print(b-a+1-count_s)

Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
count_c = 0
count_d = 0
count_cd = 0
count = 0
j = 1
g = c*d//math.gcd(c,d)
for i in range(a,b+1):
    if c*j <= b and c*j>=a:
        count_c += 1
    if d*j <=b and d*j >= a:
        count_c += 1
    if g*j <=b and g*j >= a:
        count_cd += 1
    j += 1
s = count_c+count_d-count_cd
print(b-a +1-s)

Fixed submission:
import fractions
a,b,c,d = map(int,input().split())
count_c = 0
count_d = 0
count_cd = 0
count = 0
j = 1
g = c*d//fractions.gcd(c,d)

count_c = b//c - (a-1)//c
count_d = b//d - (a-1)//d
count_cd = b//g -(a-1)//g
count_s = count_c+count_d-count_cd
print(b-a+1-count_s)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
S = input()
S[K] = S[K].lower()
print(S)

Fixed submission:
N,K=map(int,input().split())
S = input()
list = [b.lower() if a+1==K else b for (a,b) in enumerate(S)]
moji = ''.join(list)
print(moji)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for i in range(5)]
ninzu = [n,0,0,0,0,0]
count = 0
while True:
    if ninzu[5] == n:
        break
    count += 1
    for i,number in enumerate(a[::-1]):
        i = 4-i
        if number>=ninzu[i]:
            ninzu[i+1] += ninzu[i]
            ninzu[i] = 0
        else:
            ninzu[i+1] += number
            ninzu[i] -= number
print(count)

Fixed submission:
n = int(input())
a = [int(input()) for i in range(5)]
min_a = min(a)
ans = 4
ans += n//min_a
if n%min_a != 0:
    ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for i in range(5)]
ninzu = [n,0,0,0,0,0]
count = 0
while True:
    if ninzu[5] == n:
        break
    count += 1
    for i,number in enumerate(a[::-1]):
        i = 4-i
        if number>=ninzu[i]:
            ninzu[i+1] += ninzu[i]
            ninzu[i] = 0
        else:
            ninzu[i+1] += number
            ninzu[i] -= number
print(count)


Fixed submission:
n = int(input())
a = [int(input()) for i in range(5)]
min_a = min(a)
ans = 4
ans += n//min_a
if n%min_a != 0:
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
a = input()
s = [int(i) for i in a]
count = 0
ans = 0
while True:
    if (len(s) == count+1) or len(s) == 0:
        break
    if (s[count] == 0 and s[count+1] == 1) or (s[count] == 1 and s[count+1] == 0):
        ans += 1
        s.pop(count)
        s.pop(count)
        count -= 1
    else:
        count += 1
print(ans*2)


Fixed submission:
a = input()
s = [int(i) for i in a]
count = 0
ans = 0
while True:
    if (len(s) == count+1) or len(s) == 0:
        break
    if (s[count] == 0 and s[count+1] == 1) or (s[count] == 1 and s[count+1] == 0):
        ans += 1
        s.pop(count)
        s.pop(count)
        if count != 0:
            count -= 1
    else:
        count += 1
print(ans*2)
Buggy python submission (verdict: Runtime Error):
import heapq
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
x_range = []
cut = [0]
count = 0
for i in range(m-1):
    x_range.append(abs(x[i]-x[i+1]))
h = heapq.nlargest(n-1,x_range)


for i in h:
    cut.append(x_range.index(i)+1)
cut.append(len(x))

if n>=m:
    print(0)
else:
    for i in range(len(cut)-1):
        sum_range = x[cut[i]:cut[i+1]]
        count += abs(sum_range[0]-sum_range[len(sum_range)-1])
print(count)


Fixed submission:
n,m = map(int,input().split())
x = list(map(int,input().split()))
dist = []
x.sort()
if n > m:
    print(0)
else:
    for i in range(m-1):
        dist.append(x[i+1] -x[i])
    dist.sort()
    print(sum(dist[:m-n]))

Buggy python submission (verdict: Runtime Error):
import heapq
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
x_range = []
cut = [0]
count = 0
for i in range(m-1):
    x_range.append(abs(x[i]-x[i+1]))
h = heapq.nlargest(n-1,x_range)


for i in h:
    cut.append(x_range.index(i)+1)
cut.append(len(x))


for i in range(len(cut)-1):
    sum_range = x[cut[i]:cut[i+1]]
    print(1)
    count += abs(sum_range[0]-sum_range[len(sum_range)-1])
#print(count)


Fixed submission:
n,m = map(int,input().split())
x = list(map(int,input().split()))
dist = []
x.sort()
if n > m:
    print(0)
else:
    for i in range(m-1):
        dist.append(x[i+1] -x[i])
    dist.sort()
    print(sum(dist[:m-n]))

Buggy python submission (verdict: Runtime Error):
import heapq
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
x_range = []
cut = [0]
count = 0
for i in range(m-1):
    x_range.append(abs(x[i]-x[i+1]))
h = heapq.nlargest(n-1,x_range)
for i in h:
    cut.append(x_range.index(i)+1)
cut.append(len(x))
for i in range(len(cut)-1):
    sum_range = x[cut[i]:cut[i+1]]
    count += abs(sum_range[0]-sum_range[len(sum_range)-1])
print(count)


Fixed submission:
n,m = map(int,input().split())
x = list(map(int,input().split()))
dist = []
x.sort()
if n > m:
    print(0)
else:
    for i in range(m-1):
        dist.append(x[i+1] -x[i])
    dist.sort()
    print(sum(dist[:m-n]))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
count = 0
ans = [i for i in range(1,n+1) if i%2==1]
def gcd(a,b):
    c = max(a,b)
    d = min(a,b)
    if b == 0:
        return a
    return gcd(b,a%b)

for i in ans:

    i_str = str(i)
    if i_str[0]=='3' or i_str[0]=='5' or i_str[0]=='7':
        three = i_str.count('3')
        five = i_str.count('5')
        seven = i_str.count('7')
        sum_number = three + five + seven
        if len(i_str) == sum_number and three>0 and five>0 and seven>0:
            count += 1

print(count)


Fixed submission:
n = int(input())
ans = []
count = 0
def dfs(s):

    if int(s)>n:
        return 0
    ans.append(s)
    for c in '753':
        dfs(s+c)
dfs('0')
for i in ans:
    if all(i.count(j)>0 for j in '753'):
        count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
count = 0
ans = [i for i in range(1,n+1) if str(i)[0]=='3' or str(i)[0]=='5' or str(i)[0]=='7']
def gcd(a,b):
    c = max(a,b)
    d = min(a,b)
    if b == 0:
        return a
    return gcd(b,a%b)

for i in ans:

    i_str = str(i)
    if i_str[0]=='3' or i_str[0]=='5' or i_str[0]=='7':
        three = i_str.count('3')
        five = i_str.count('5')
        seven = i_str.count('7')
        sum_number = three + five + seven
        if len(i_str) == sum_number and three>0 and five>0 and seven>0:
            count += 1

print(count)


Fixed submission:
n = int(input())
ans = []
count = 0
def dfs(s):

    if int(s)>n:
        return 0
    ans.append(s)
    for c in '753':
        dfs(s+c)
dfs('0')
for i in ans:
    if all(i.count(j)>0 for j in '753'):
        count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
count = 0
def gcd(a,b):
    c = max(a,b)
    d = min(a,b)
    if b == 0:
        return a
    return gcd(b,a%b)

for i in range(1,n+1):

    i_str = str(i)
    if i_str[0]=='3' or i_str[0]=='5' or i_str[0]=='7':
        three = i_str.count('3')
        five = i_str.count('5')
        seven = i_str.count('7')
        sum_number = three + five + seven
        if len(i_str) == sum_number and three>0 and five>0 and seven>0:
            count += 1

print(count)


Fixed submission:
n = int(input())
ans = []
count = 0
def dfs(s):

    if int(s)>n:
        return 0
    ans.append(s)
    for c in '753':
        dfs(s+c)
dfs('0')
for i in ans:
    if all(i.count(j)>0 for j in '753'):
        count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
count = 0
for i in range(1,n+1):
    i_str = str(i)
    three = i_str.count('3')
    five = i_str.count('5')
    seven = i_str.count('7')
    sum_number = three + five + seven
    if len(i_str) == sum_number and three>0 and five>0 and seven>0:
        count += 1
print(count)


Fixed submission:
n = int(input())
ans = []
count = 0
def dfs(s):

    if int(s)>n:
        return 0
    ans.append(s)
    for c in '753':
        dfs(s+c)
dfs('0')
for i in ans:
    if all(i.count(j)>0 for j in '753'):
        count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = 10**9
for i in range(n):
    count = 0
    key = s[i]
    count = (s[:i].count('W') + s[i+1:].count('E'))
    ans = min(ans,count)
print(ans)


Fixed submission:
n = int(input())
s = input()
ans = 10**9
w = s.count('W')
e = s.count('E')
w_count = 0
e_count = 0
for i in range(n):
    if s[i] == 'W':
        w -= 1
        ans = min(ans,e+w_count)
        w_count += 1
    else:
        e -= 1
        ans = min(ans,e+w_count)
        e_count += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,k = map(int,input().split())


for i in range(k):
    a,b,c = (b+c),(a+c),(a+b)
    #print('a:{} b:{} c:{}'.format(a,b,c))
    
print(a-b)


Fixed submission:
a,b,c,k = map(int,input().split())
ans = a-b
if k%2==0:
    print(ans)
else:
    print(ans*(-1))
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = set(a)
syurui = []
ans = 0
for i in b:
    syurui.append(a.count(i))
syurui.sort()
if len(b) <= k:
    print(0)
else:
    for i in range(len(b)-k):
        ans += syurui[i]
    print(ans)


Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
ans = 0
key = a[0]
a_syurui = []
count = 1
for i in a[1:]:
    if key == i:
        count += 1
    else:
        a_syurui.append(count)
        count = 1
        key = i
a_syurui.append(count)
a_syurui.sort()
if len(a_syurui) <= k:
    print(0)
else:
    for i in range(len(a_syurui)-k):
        ans += a_syurui[i]
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(len(a)):
    if i%2 == 0:
        b.append(str(a[i]))
    else:
        b.insert(0,str(a[i]))
if n%2 != 0:
    b.reverse()
    print(*b)
else:
    print(*b)


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = []
ans1 = a[0::2]
ans2 = a[1::2]
if n%2 == 0:
    ans2.reverse()
    b.extend(ans2)
    b.extend(ans1)
    print(*b)
else:
    ans1.reverse()
    b.extend(ans1)
    b.extend(ans2)
    print(*b)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = []
for i,j in enumerate(a):
    if i%2 == 0:
        b.append(str(j))
    else:
        b.insert(0,str(j))
if j%2 != 0:
    b.reverse()
    print(' '.join(b))
else:
    print(' '.join(b))


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = []
ans1 = a[0::2]
ans2 = a[1::2]
if n%2 == 0:
    ans2.reverse()
    b.extend(ans2)
    b.extend(ans1)
    print(*b)
else:
    ans1.reverse()
    b.extend(ans1)
    b.extend(ans2)
    print(*b)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = []
for i in a:
    b.append(str(i))
    b.reverse()
print(' '.join(b))


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = []
ans1 = a[0::2]
ans2 = a[1::2]
if n%2 == 0:
    ans2.reverse()
    b.extend(ans2)
    b.extend(ans1)
    print(*b)
else:
    ans1.reverse()
    b.extend(ans1)
    b.extend(ans2)
    print(*b)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
color = [0 for i in range(9)]
a.sort()
for i in a:
    number = i//400
    color[number] += 1
left = 8 - color[:8].count(0)
right = color[8]
if left == 8:
    print('{} {}'.format(8,8))
else:
    sum_color = left + right
    if sum_color >= 8:
        print('{} {}'.format(left,8))
    else:
        print('{} {}'.format(left,sum_color))


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
color = [0 for i in range(9)]
a.sort()
for i in a:
    number = i//400
    if number >=8:
        color[8] += 1
    else:
        color[number] += 1
left = 8 - color[:8].count(0) #3200未満が何種類あるか
right = color[8]              #3200以上が何人いるか
if left == 0:
    print('{} {}'.format(1,right))
else:
    sum_color = left + right
    print('{} {}'.format(left,sum_color))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
c = [0, 0, 0]
col1 = []
col2 = []
col3 = []
res = 0

for i in range(n):
    if s[i] == "R":
        col1.append(i)
    elif s[i] == "G":
        col2.append(i)
    else:
        col3.append(i)

for i1 in col1:
    for i2 in col2:
        for i3 in col3:
            if abs(i2 - i1) == abs(i3 - i2) or abs(i3 - i1) == abs(i3 - i2) or abs(i2 - i1) == abs(i3 - i1):
                continue
            else:
                res = res + 1
    
print(res)

Fixed submission:
n = int(input())
s = input()
c = [0, 0, 0]
col1 = []
col2 = []
col3 = []
res = 0

for i in range(n):
    if s[i] == "R":
        col1.append(i)
    elif s[i] == "G":
        col2.append(i)
    else:
        col3.append(i)

res = len(col1) * len(col2) * len(col3)

for i in range((n + 1) // 2):
    for j in range(n - (i + 1) * 2):
        x = s[j]
        y = s[j + i + 1]
        z = s[j + (i + 1) * 2]
        if x == y or y == z or x == z:
            continue
        else:
            res = res - 1

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
import math
def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

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

num = [0] * N

for i in A:
    num[i - 1] = num[i - 1] + 1

a = [0] * N
b = [0] * N

for i in range(N):
    if num[i] >= 3:
        a[i] = comb(num[i] - 1, 2)
        b[i] = comb(num[i] - 1, 1)
    elif num[i] == 2:
        a[i] = 0
        b[i] = 1

for i in A:
    print(sum(a) + sum(b) - b[i - 1])

Fixed submission:
import math

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

num = [0] * N

for i in A:
    num[i - 1] = num[i - 1] + 1

a = [0] * N
b = [0] * N

for i in range(N):
    if num[i] >= 2:
        a[i] = (num[i] - 1) * (num[i] - 2) // 2
        b[i] = num[i] - 1

sum_a = sum(a)
sum_b = sum(b)

for i in A:
    print(sum_a + sum_b - b[i - 1])

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

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

num = [0] * N

for i in range(N):
    num[A[i] - 1] = num[A[i] - 1] + 1

a = [0] * N
b = [0] * N

for i in range(N):
    if num[i] >= 3:
        a[i] = comb(num[i] - 1, 2)
        b[i] = comb(num[i] - 1, 1)
    if num[i] == 2:
        a[i] = 0
        b[i] = 1

for i in range(N):
    print(sum(a) + sum(b) - b[A[i] - 1])

Fixed submission:
import math

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

num = [0] * N

for i in A:
    num[i - 1] = num[i - 1] + 1

a = [0] * N
b = [0] * N

for i in range(N):
    if num[i] >= 2:
        a[i] = (num[i] - 1) * (num[i] - 2) // 2
        b[i] = num[i] - 1

sum_a = sum(a)
sum_b = sum(b)

for i in A:
    print(sum_a + sum_b - b[i - 1])

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

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def add(num):
    n = 0
    for i in range(N):
        if num[i] >= 2:
            n = n + comb(num[i], 2)
    return n


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

num = [0] * N

for i in range(N):
    num[A[i] - 1] = num[A[i] - 1] + 1

for i in range(N):
    num[A[i] - 1] = num[A[i] - 1] - 1
    print(add(num))
    num[A[i] - 1] = num[A[i] - 1] + 1

Fixed submission:
import math

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

num = [0] * N

for i in A:
    num[i - 1] = num[i - 1] + 1

a = [0] * N
b = [0] * N

for i in range(N):
    if num[i] >= 2:
        a[i] = (num[i] - 1) * (num[i] - 2) // 2
        b[i] = num[i] - 1

sum_a = sum(a)
sum_b = sum(b)

for i in A:
    print(sum_a + sum_b - b[i - 1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
res = 0

for i in range(n):
    if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C':
        res += 1

print(res) 

Fixed submission:
n = int(input())
s = input()
res = 0

for i in range(n - 2):
    if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C':
        res += 1

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(x) for x in input().split()]
for i in range(n):
    print(a.count(i+1))

Fixed submission:
n=int(input())
a=[int(x) for x in input().split()]
d=[0]*(n+1)
for i in range(n-1):
    d[a[i]]+=1
for i in range(1,len(d)):print(d[i])
Buggy python submission (verdict: Runtime Error):
a=int(input())
b,c=[int(x) for x in input().split()]
s=input()
print(a+b+c, s)



Fixed submission:
b,c=[int(x) for x in input().split()]
if c>=b:
    print("unsafe")
else:
    print("safe")
Buggy python submission (verdict: Runtime Error):
A,B,N = map(int,input().split())

l = None
if B <= N:
    l = [0]*(B-1)
else:
    l = [0]*N
#print('len: ', len(l))



for x in range(1, len(l) + 1):
    l[x-1] = ((A*x)//B) - A*(x//B)

print(max(l))



'''m = 0
for x in range(1, N+1):
    j =  ((A*x)//B) - A*(x//B)
    m = max(m,j)


print('MAX',m)
'''


Fixed submission:
A,B,N = map(int,input().split())

l = None
if B <= N:
    l = B-1
else:
    l = N
#print('len: ', len(l))


'''
for x in range(1, len(l) + 1):
    l[x-1] = ((A*x)//B) - A*(x//B)
'''

print(((A*l)//B) - A*(l//B))



'''m = 0
for x in range(1, N+1):
    j =  ((A*x)//B) - A*(x//B)
    m = max(m,j)


print('MAX',m)
'''

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, N: int):
    m = -1
    for i in range(N+1):
        x = i
        m = max([m, int((A*x)/B) - A * int(x/B)])
    return m


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    # N = pow(10, 9)
    print(solve(A, B, N))

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, N: int):
    if A == 1: return 0

    if N < B:
        x = N
    else:
        md = N % B
        x = int(N - (md + 1))
    return int((A*x)//B) - A * int(x//B)

    # m = -1
    # for i in range(N+1):
    #     x = i
    #     m = max([m, int((A*x)/B) - A * int(x/B)])
    # return m


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    # N = pow(10, 9)
    print(solve(A, B, N))

if __name__ == '__main__':
    main()

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

A, B, N = map(int, input().split())
max = 0
i = 1
while True:
  x = i * B -1
  if x > N:
    if i == 1:
      x = N
    else:
      break
  k = int(((x / B) - (x // B)) * A)
  if k > max:
    max = k
  i +=1
print(max)

Fixed submission:
A, B, N = map(int, input().split())
max = 0
i = 1
p = int((N + 1) / B)
if p == 0:
  x = N
else:
  x = B * p -1
print(int(((x / B) - (x // B)) * A))
Buggy python submission (verdict: Runtime Error):
r=input()
print(3*r*r)

Fixed submission:
r=int(input())
print(3*r*r)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [float("inf") for _ in range(N)]
derta = [[-1 for i in range(N)] for j in range(N)]

def cost(n, m):
  if derta[n][m] == -1:
    derta[n][m] = abs(h[n] - h[m])
    return derta[n][m]
  else:
    return derta[n][m]

dp[0] = 0

for i in range(N):
  for j in range(1, K + 1):
    if (i + j) <= N -1:
      dp[i + j] = min(dp[i + j], dp[i] + cost(i, i + j))

print(dp[N - 1])

Fixed submission:
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [float("inf") for _ in range(N)]

def cost(n, m):
  return abs(h[n] - h[m])

dp[0] = 0

for i in range(N):
  for j in range(1, K + 1):
    if (i + j) <= N -1:
      dp[i + j] = min(dp[i + j], dp[i] + cost(i, i + j))

print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [float("inf") for _ in range(N)]

def cost(n, m):
  return abs(h[n] - h[m])

dp[0] = 0

for i in range(N):
  for j in range(1, K + 1):
    if (i + j) <= N -1:
      dp[i + j] = min(dp[i + j], dp[i] + cost(i, i + j))

print(dp[N - 1])

Fixed submission:
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [float("inf") for _ in range(N)]

def cost(n, m):
  return abs(h[n] - h[m])

dp[0] = 0

for i in range(N):
  for j in range(1, K + 1):
    if (i + j) <= N -1:
      dp[i + j] = min(dp[i + j], dp[i] + cost(i, i + j))

print(dp[-1])