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

Fixed submission:
import bisect
import itertools
def find_ge(a, x):
    i = bisect.bisect_right(a,x)
    return i

def solve(n, a, b, c):

    tmp = len(c)
    b_count =list(itertools.accumulate([tmp - find_ge(c, x) for x in b]))
    ans = 0
    for i in a:
        min_index = find_ge(b, i)
        
        ans += b_count[-1] -(0 if min_index == 0 else b_count[min_index-1])
    
    return ans

if __name__ == "__main__":
    n = int(input())
    a = sorted([int(i) for i in input().split()])
    b = sorted([int(i) for i in input().split()])
    c = sorted([int(i) for i in input().split()])
    print(solve(n, a, b, c))

Buggy submission (verdict: Runtime Error):
def solve(n, a, b, c):

    b_count = [0]*len(b)
    for i, x in enumerate(b):
        b_count[i] = len(c) - find_ge(c, x)

    ans = 0
    for i in a:
        x = find_ge(b, i)
        ans += sum(b_count[x:])
        
    return ans

if __name__ == "__main__":
    n = int(input())
    a = sorted([int(i) for i in input().split()])
    b = sorted([int(i) for i in input().split()])
    c = sorted([int(i) for i in input().split()])
    print(solve(n, a, b, c))
Problem p03573 (python)

Fixed submission:
a, b, c = [int(i) for i in input().split()]

if a == b:
  print(c)
elif b == c:
  print(a)
else:
  print(b)

Buggy submission (verdict: Runtime Error):
a, b, c = [int(i) for i in input().splt()]

if a == b:
  print(c)
elif b == c:
  print(a)
else:
  print(b)
Problem p03605 (python)

Fixed submission:
n = input()
  
if "9" in n:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = input()

for "9" in n:
  print("Yes")
else:
  print("No")
Problem p03637 (python)

Fixed submission:
import sys
def slove(n, k):
    a_list = [int(i) for i in k.split()]
    num = len([i for i in a_list if i % 4 == 0])
    tmp =  [i for i in a_list if i % 4 != 0]
    num2 = len([i for i in tmp if i % 2 == 0]) // 2
    return "Yes" if (num + num2)>= n // 2 else "No"

if __name__ == "__main__":
    input = sys.stdin.readline
    n = int(input())
    k = input()
    print(slove(n, k))

Buggy submission (verdict: Runtime Error):
def slove(n, k):
    a_list = [int(i) for i in k.split()]
    num = len([i for i in a_list if i % 4 == 0])
    tmp =  [i for i in a_list if i % 4 != 0]
    num2 = tmp.count(2) // 2
    return "Yes" if (num + num2)>= n // 2 else "No"

if __name__ == "__main__":
    input = sys.stdin.readline
    n = int(input())
    k = input()
    print(slove(n, k))
Problem p03695 (python)

Fixed submission:
import collections
def solve(n, a_list):

    count = collections.Counter()
    for i in a_list:
        no = 8 if i // 400 >= 8 else i // 400
        count[no] += 1

    tmp = len([i for i in count.keys() if i != 8])
    max_value = tmp + count[8]
    min_value = 1 if tmp == 0 else tmp

    return "{0} {1}".format(min_value, max_value)

if __name__ == "__main__":
    n = int(input())
    a_list = [int(i) for i in input().split()]
    print(solve(n, a_list))

Buggy submission (verdict: Runtime Error):
import collections
def solve(n, a_list):

    count = collections.Counter()
    for i in a_list:
        count[i // 400] += 1

    max_value = len([i for i in count.keys() if i != 8]) + count[8]
    min_value =  1 if max_value - count[8] == 0 else max_value - count[8]
    return "{0} {1}".format(min_value, max_value)

if __name__ == "__main__":
    n = int(input())
    a_list = sorted([int(input()) for i in range(n)])
    print(solve(n, a_list))

Buggy submission (verdict: Runtime Error):
import collections
def solve(n, a_list):

    count = collections.Counter()
    for i in a_list:
        count[i // 400] += 1

    min_value = len([i for i in count.keys() if i != 8])
    max_value = min_value + count[8]
    return "{0} {1}".format(min_value, max_value)

if __name__ == "__main__":
    n = int(input())
    a_list = [int(input()) for i in range(n)]
    print(solve(n, a_list))

Buggy submission (verdict: Runtime Error):
import collections
def solve(n, a_list):

    count = collections.Counter()
    for i in a_list:
        count[i // 400] += 1

    min_value = len([i for i in count.keys() if i != 8])
    max_value = min_value + count[8]
    return "{0} {1}".format(min_value, max_value)

if __name__ == "__main__":
    n = int(input())
    a_list = sorted([int(input()) for i in range(n)])
    print(solve(n, s_list))
Problem p03699 (python)

Fixed submission:
def solve(n, s_list):
    max_score = sum(s_list)

    if max_score % 10 != 0:
        return max_score
    else:
        for i in s_list:
            if (max_score - i) % 10 != 0:
                return max_score - i
    return 0

if __name__ == "__main__":
    n = int(input())
    s_list = sorted([int(input()) for i in range(n)])
    print(solve(n, s_list))

Buggy submission (verdict: Runtime Error):
def solve(n, s_list):
    max_score = sum(s_list)

    if max_score % 10 != 0:
        return max_score
    else:
        for i in tmp:
            if (max_score - i) % 10 != 0:
                return max_score - i

if __name__ == "__main__":
    n = int(input())
    s_list = sorted([int(input()) for i in range(n)])
    print(solve(n, s_list))

Buggy submission (verdict: Runtime Error):
def solve(n, s_list):
    max_score = sum(tmp)

    if max_score % 10 != 0:
        return max_score
    else:
        for i in tmp:
            if (max_score - i) % 10 != 0:
                return max_score - i

if __name__ == "__main__":
    n = int(input())
    s_list = sorted([int(input()) for i in range(n)])
    print(solve(n, s_list))
Problem p03779 (python)

Fixed submission:
def slove(x):
    t = 1
    ans = t
    while ans <x:
        t += 1
        ans += t
    return t
if __name__ == "__main__":
    x = int(input())
    print(slove(x))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(40000)
def func(pos, t, x):

    if pos + t == x:
        return t
    elif pos + t < x:
        new_pos = pos + t
        t += 1
        return func(new_pos, t, x)
    else:
        new_pos = pos - t
        t -= 1
        return func(new_pos, t, x)
    
def slove(x):
    ans = func(0,0,x)
    return ans
if __name__ == "__main__":
    x = int(input())
    print(slove(x))

Buggy submission (verdict: Runtime Error):
def func(pos, t, x):
    if pos + t == x:
        return t
    elif pos + t < x:
        new_pos = pos + t
        t += 1
        return func(new_pos, t, x)
    else:
        new_pos = pos - t
        t -= 1
        return func(new_pos, t, x)
      
def slove(x):
    ans = func(0,0,x)
    return ans

if __name__ == "__main__":
    x = int(input())
    print(slove(x))
Problem p03797 (python)

Fixed submission:
def slove(n, m):
    tmp = n if n < m // 2 else m // 2
    tmp2 = (m - tmp * 2) // 4
    return tmp + tmp2
    
if __name__ == "__main__":
    n, m = [int(i) for i in input().split()]
    print(slove(n, m))

Buggy submission (verdict: Runtime Error):
def slove(n, m):
    tmp = n if n < m // 2 else m // 2
    tmp2 = (m - tmp * 2) // 4
    return tmp + tmp2
    
if __name__ == "__main__":
    n, m = [i for i in input().split()]
    print(slove(n, m))
Problem p03854 (python)

Fixed submission:
def solve(n):

    while len(n) > 4:
        if n[-5:] == "dream":
            n = n[:-5]
        elif n[-7:] == "dreamer":
            n = n[:-7]
        elif n[-5:] == "erase":
            n = n[:-5]
        elif n[-6:] == "eraser":
            n = n[:-6]
        else:
            break

    return "YES" if len(n) == 0 else "NO"

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

Buggy submission (verdict: Runtime Error):
def func(x):

    if len(x) == 0:
        return True
    elif len(x) < 5:
        return False
    else:
        if x[-5:] == "dream":
            return func(x[:-5])
        elif x[-7:] == "dreamer":
            return func(x[:-7])
        elif x[-5:] == "erase":
            return func(x[:-5])
        elif x[-6:] == "eraser":
            return func(x[:-6])
        else:
            return False

def solve(n):

    ans = func(n)
    return "YES" if ans else "NO"

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

Buggy submission (verdict: Runtime Error):
sys.setrecursionlimit(10000)
def func(x):

    if len(x) == 0:
        return True
    elif len(x) < 5:
        return False
    else:
        tmp = False
        if x[:5] == "dream":
            tmp = func(x[5:])

        if x[:7] == "dreamer" and not tmp:
            tmp = func(x[7:])

        if x[:5] == "erase" and not tmp:
            tmp = func(x[5:])

        if x[:6] == "eraser" and not tmp:
            tmp = func(x[6:])

    return tmp

def solve(n):

    ans = func(n)
    return "YES" if ans else "NO"

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

Buggy submission (verdict: Runtime Error):
def func(x):

    if len(x) == 0:
        return True
    elif len(x) < 5:
        return False
    else:
        tmp = False
        if x[:5] == "dream":
            tmp = func(x[5:])

        if x[:7] == "dreamer" and not tmp:
            tmp = func(x[7:])

        if x[:5] == "erase" and not tmp:
            tmp = func(x[5:])

        if x[:6] == "eraser" and not tmp:
            tmp = func(x[6:])

    return tmp

def solve(n):

    ans = func(n)
    return "YES" if ans else "NO"

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

Buggy submission (verdict: Runtime Error):
def func(x):

    if len(x) == 0:
        return True
    elif len(x) < 5:
        return False
    else:
        tmp = False
        if x[:5] == "dream":
            tmp = func(x[5:])

        if x[:7] == "dreamer" and not tmp:
            tmp = func(x[7:])

        if x[:5] == "erase" and not tmp:
            tmp = func(x[5:])

        if x[:6] == "eraser" and not tmp:
            tmp = func(x[6:])

    return tmp

def solve(n):

    t = ""
    ans = func(n, t)
    return "YES" if ans else "NO"

if __name__ == "__main__":
    n = input()
    print(solve(n))
Problem p04045 (python)

Fixed submission:
def solve(n, k, xs):

    tmp = n
    num = len(xs)
    
    while True:
        if num == len([i for i in xs if i not in str(tmp)]):
            break
        else:
            tmp += 1
    
    return tmp

if __name__ == "__main__":
    n, k = [int(i) for i in input().split()]
    xs = [i for i in input().split()]
    print(solve(n, k, xs))

Buggy submission (verdict: Runtime Error):
import itertools
def solve(n, k, xs):

    tmp = [str(i) for i in range(10) if i not in xs]
    str_len = len(str(n))

    hoge = [i for i in map(lambda x: int("".join(x)),
                            itertools.product(tmp, repeat=str_len)) if i >= n]

    return hoge[0]

if __name__ == "__main__":
    n, k = [int(i) for i in input().split()]
    xs = [int(i) for i in input().split()]
    print(solve(n, k, xs))
Problem p03563 (python)

Fixed submission:
pres_rate = int(input())
goal_rate = int(input())
next_rate = goal_rate * 2 - pres_rate
print(next_rate)

Buggy submission (verdict: Runtime Error):
pres_rate = input()
goal_rate = input()
next_rate = goal_rate * 2 - pres_rate
print(next_rate)
Problem p02687 (python)

Fixed submission:
import sys
input = sys.stdin.readline

def main():
    s = input().rstrip()

    if s == 'ABC':
        print('ARC')
    else:
        print('ABC')


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
X = int(input())
C= [i**5 for i in range(119)]

a = 0
b = 0

for a in range(len(C)):
    for b in range(len(C)):
        if C[a] + C[b] == X:
            print(a, -b)
            exit(0)
        elif C[a] - C[b] == X:
            print(a, b)
            exit(0)
Problem p02690 (python)

Fixed submission:
X = int(input())
C= [i**5 for i in range(120)]

a = 0
b = 0

for a in range(len(C)):
    for b in range(len(C)):
        if C[a] + C[b] == X:
            print(a, -b)
            exit(0)
        elif C[a] - C[b] == X:
            print(a, b)
            exit(0)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

def main():
    x = int(input())

    for b in range(10**9):
        y = ((x + (-1*b)**5)**(1/5)).is_integer()
        if y:
            print(int((x + (-1*b)**5)**(1/5)), -1*b)
            break


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

def main():
    x = int(input())

    for b in range(10**9):
        y = ((x + (-1 * b)**5)**(1/5)).is_integer()
        if y:
            print(int((x - b**5)**(1/5)), -1*b)
            break


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

Fixed submission:
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    li = list(input().rstrip())

    r = []
    g = []
    b = []

    for i in range(n):
        if li[i] == 'R':
            r.append(i)
        elif li[i] == 'G':
            g.append(i)
        elif li[i] == 'B':
            b.append(i)

    if (len(r) < 1 or len(g) < 1) or len(b) < 1:
        print(0)
    else:
        all_c = len(r) * len(g) * len(b)

        for i in range(n):
            for j in range(i+1,n):
                k = 2*j-i
                if k >= n:
                    continue

                if (li[i] != li[j] and li[j] != li[k]) and li[i] != li[k]:
                    all_c -= 1

        print(all_c)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    s_li = list(input().rstrip())

    r_li = []
    g_li = []
    b_li = []

    for i in range(n):
        if s_li[i] == 'R':
            r.append(i)
        elif s_li[i] == 'G':
            g.append(i)
        elif s_li[i] == 'B':
            b.append(i)

    if (len(r_li) < 1 or len(g_li) < 1) or len(b_li) < 1:
        print(0)
    else:
        all_c = len(r_li) * len(g_li) * len(b_li)

        for i in range(n):
            for j in range(i+1,n):
                k = 2*j-i
                if k >= n:
                    continue

                if (s_li[i] != s_li[j] and s_li[j] != s_li[k]) and s_li[i] != s_li[k]:
                    all_c -= 1

        print(all_c)

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

Fixed submission:
import sys
input = sys.stdin.readline

import numpy as np

def main():
    n = int(input())
    a_list = np.array(list(map(int, input().split())))

    print(*np.argsort(a_list)+1)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

import numpy as np

def main():
    n = int(input())
    a_list = list(map(int, input().split()))

    ans = ''
    for i in range(1, n+1):
        ans += str(a_list.index(i)+1)

    print(' '.join([*ans]))

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

Fixed submission:
r = int(input())

print(3 * r * r)

Buggy submission (verdict: Runtime Error):
import copy
n=int(input())
num_list=[int(input()) for i in range(n)]

buf = []

for i in range(n):
  buf = copy.copy(num_list)
  buf.pop(i)
  print(max(buf))
Problem p02642 (python)

Fixed submission:
from collections import Counter

n = int(input())
alist = [int(v) for v in input().split()]
dup_set = {k for k, v in Counter(alist).items() if v >= 2}
alist = sorted(set(alist))
adict = {a: False for a in alist}
a_max = alist[-1]
max_ind = -1

count = 0
if 1 in adict:
    count = 0 if 1 in dup_set else 1
else:
    for a, f in adict.items():
        if f:
            continue
        if a not in dup_set:
            count += 1
        for k in range(a, a_max + 1, a):
            if k in adict:
                adict[k] = True
                if k == a_max:
                    max_ind -= 1
                    if abs(max_ind) <= len(alist):
                        a_max = alist[max_ind]

print(count)

Buggy submission (verdict: Runtime Error):
from collections import Counter

n = int(input())
alist = [int(v) for v in input().split()]
dup_set = {k for k, v in Counter(alist).items() if v >= 2}
alist = sorted(set(alist))
adict = {a: False for a in alist}
a_max = alist[-1]
max_ind = -1

count = 0
if 1 in adict:
    count = 0 if 1 in dup_set else 1
else:
    for a, f in adict.items():
        if f:
            continue
        if a not in dup_set:
            count += 1
        for k in range(a, a_max + 1, a):
            if k in adict:
                adict[k] = True
                if k == a_max:
                    max_ind -= 1
                    a_max = alist[max_ind]

print(count)
Problem p02960 (python)

Fixed submission:
s = input().strip()

DIV = 10**9 + 7
new = list(range(13))
old = None

c = s[-1]
if c == '?':
    old = [int(t < 10) for t in range(13)]
else:
    c = int(c)
    old = [int(t == c) for t in range(13)]

digit = 10
for i, c in enumerate(reversed(s[:-1])):
    for j in range(13):
        new[j] = 0
    if c == '?':
        for m in range(10):
            for mod, cnt in enumerate(old):
                shifted = (mod + m * digit) % 13
                new[shifted] += cnt
    else:
        c = int(c)
        for mod, cnt in enumerate(old):
            shifted = (mod + c * digit) % 13
            new[shifted] += cnt
    for j in range(13):
        new[j] %= DIV
    new, old = old, new
    digit = (digit * 10) % 13

print(old[5])

Buggy submission (verdict: Runtime Error):
s = input().strip()

DIV = 10**9 + 7
new = list(range(13))
old = None

if s[-1] == '?':
    old = [int(t < 10) for t in range(13)]
else:
    old = [int(t == int(c)) for t in range(13)]

digit = 10
for i, c in enumerate(reversed(s[:-1])):
    for j in range(13):
        new[j] = 0
    if c == '?':
        for m in range(10):
            for mod, cnt in enumerate(old):
                shifted = (mod + m * digit) % 13
                new[shifted] += cnt
    else:
        c = int(c)
        for mod, cnt in enumerate(old):
            shifted = (mod + c * digit) % 13
            new[shifted] += cnt
    for j in range(13):
        new[j] %= DIV
    new, old = old, new
    digit = (digit * 10) % 13

print(old[5])

Buggy submission (verdict: Runtime Error):
s = input().strip()

mod = 1
stable = 0
calc = {i: 0 for i in range(13)}
for c in reversed(s):
    if c == '?':
        calc[mod] += 1
    else:
        stable = (int(c) * mod + stable) % 13
    mod = (mod * 10) % 13

value = stable % 13

DIV = 10**9 + 7

# combis = {}
# def combi(n, r):
#     if r == 0:
#         return 1
#     elif (n, r) in combis:
#         return combis[n, r]
#     else:
#         res = combi(n, r - 1) * (n + 1 - r) // r
#         combis[n, r] = res
#         return res

patterns = {}
def get_pattern(d, n):
    if n == 0 or d * 9 == n:
        return 1
    elif d * 9 < n:
        return 0
    elif d == 1:
        return 1
    elif (d, n) in patterns:
        return patterns[d, n]
    else:
        res = 0
        for i in range(1, d):
            for j in range(9 * d + 1):
                res = get_pattern(i, j) * get_pattern(d-i, n-j)
        patterns[d, n] = res % DIV
        return res

def get_chance(point, value, chance):
    if point == 13:
        if value == 5:
            pat = 1
            for pt, val in enumerate(chance):
                pt += 1
                pat = (pat * get_pattern(calc[pt], val)) % DIV
            return pat
        else:
            return 0
    res = 0
    if calc[point] == 0:
        res = get_chance(point + 1, value, chance + [0])
    else:
        for i in range(calc[point] * 9 + 1):
            res += get_chance(point + 1, (value + i * point) % 13, chance + [i])
    return res

result = get_chance(1, value, [])

print(result)
Problem p03029 (python)

Fixed submission:
a, p = (int(v) for v in input().split(' '))
print((a*3 + p)//2)

Buggy submission (verdict: Runtime Error):
a, p = (int(v) for f in input().split(' '))
print((a*3 + p)//2)
Problem p02772 (python)

Fixed submission:
input()
A = map(int, input().split())
for a in A:
  if a % 2 == 0:
    if a % 3 != 0 and a % 5 != 0:
      print('DENIED')
      exit()
print('APPROVED')

Buggy submission (verdict: Runtime Error):
input()
A = map(int, input().split())
for a in A:
  if A % 2 == 0:
    if A % 3 != 0 and A % 5 != 0:
      print('DENIED')
      exit()
print('APPROVED')
Problem p02993 (python)

Fixed submission:
s = input()
for c, d in zip(s, s[1:]):
  if c == d:
    print('Bad')
    break
else:
  print('Good')

Buggy submission (verdict: Runtime Error):
s = input()
for c, d in zip(s, s[1:]):
  if c == d:
    print('Bad')
 	break
else:
  print('Good')
Problem p03043 (python)

Fixed submission:
import math

N, K = map(int, input().split())
if K <= N:
  p = 1 - (K-1)/N
else:
  p = 0
for i in range(1, min(N+1, K)):
  n = math.ceil(math.log(K/i, 2))
  p += 1/N * (1/2 ** n)
print(p)

Buggy submission (verdict: Runtime Error):
import math

N, K = map(int, input().split())
p = 1 - K/N
for i in range(1, K):
  n = floor(math.log(N/i, 2))
  p += 1/N * (1/2 ** n)
print(p)
Problem p03062 (python)

Fixed submission:
input()
A=list(map(int,input().split()))
s=0
for a in A:
  if a < 0:
    s += 1
S=0
if s % 2 == 0:
  S = sum([abs(a) for a in A])
else:
  B = [abs(a) for a in A]
  m = min(B)
  S = sum(B) - 2*m
print(S)

Buggy submission (verdict: Runtime Error):
input()
A=list(map(int,input()))
s=0
for a in A:
  if a < 0:
    s += 1
S=0
if s % 2 == 0:
  S = sum([abs(a) for a in A])
else:
  B = [abs(a) for a in A]
  m = min(B)
  S = sum(B) - 2*m
print(S)

Buggy submission (verdict: Runtime Error):
input()
A=list(map(int,input()))
s=0
for a in A:
  if a < 0:
    s += 1
S=0
if s % 2 == 0:
  S = sum([abs(a) for a in A])
else:
  B = [abs(a) for a in A]
  m = min(B)
  S = sum(B) - 2*m
print(S)

Buggy submission (verdict: Runtime Error):
input()
A=list(map(int,input()))
s=0
for a in A:
  if a < 0:
    s += 1
if s % 2 == 0:
  S = sum([abs(a) for a in A])
else:
  B = [abs(a) for a in A]
  m = min(B)
  S = sum(B) - 2*m
print(S)
Problem p03068 (python)

Fixed submission:
N=int(input())
S=input()
K=int(input())
C=S[K-1]
S_=''
for c in S:
  if c == C:
    S_+=c
  else:
    S_+="*"
print(S_)

Buggy submission (verdict: Runtime Error):
N=input()
S=input()
K=input()
C=S[K-1]
S_=''
for c in S:
  if c == C:
    S_+=c
  else:
    S_+="*"
print(S_)
Problem p03101 (python)

Fixed submission:
H, W = map(int, input().split())
h, w = map(int, input().split())

print((H - h) * (W - w))

Buggy submission (verdict: Runtime Error):
def get_ints():
  return map(int, input().split())

N, _, C = get_ints()
B = list(get_ints())

n = 0
for _ in range(N):
  A = list(get_ints())
  J = sum(a * b for a, b in zip(A, B)) + C
  if J > 0:
  	n += 1
    
print(n)
Problem p03105 (python)

Fixed submission:
A, B, C = map(int, input().split())
print(min(B // A, C))

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
n = min(B / A, C)
print n
Problem p02687 (python)

Fixed submission:
a = input()
if a == 'ABC':
  print('ARC')
else:
  print('ABC')

Buggy submission (verdict: Runtime Error):
a = input()
if a == ABC:
  print('ARC')
else:
  print('ABC')
Problem p02696 (python)

Fixed submission:
import math
a, b, n = map(int, input().split())

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

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

y = b-1
if x < n:
  x = y
else:
  x = n

print(math.floor(a*x/b))
Problem p02780 (python)

Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split()))
A = [0]
for i in range(1, 1001):
    A.append(A[i-1]+i)
S = [0]*n
for j in range(n):
    S[j] = A[p[j]]/p[j]
ANS = [sum(S[a] for a in range(k))]
for i in range(n-k):
    ANS.append(ANS[i]-S[i]+S[k+i])
print(max(ANS))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = list(map(int, input().split()))
A = [0]
for i in range(1, 1000):
    A.append(A[i-1]+i)
S = [0]*n
for j in range(n):
    S[j] = A[p[j]]/p[j]
ANS = [sum(S[a] for a in range(k))]
for i in range(n-k):
    ANS.append(ANS[i]-S[i]+S[k+i])
print(max(ANS))