Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
q_list = [input().split() for i in range(q)]

flag = False
for q_num in q_list:
    if int(q_num[0]) == 1:
        if flag == False:
            flag = True
        else:
            flag = False
    
    else:
        if int(q_num[1]) == 1 and flag == False or int(q_num[1]) == 2 and flag == True:
            s = q_num[2] + s
        else:
            s = s + q_num[2]

if flag:
    print(s[::-1])
else:
    print(s)

Fixed submission:
s = input()
q = int(input())
q_list = [input().split() for i in range(q)]

flag = False
add_after = ""
add_before = ""
for q_num in q_list:
    if int(q_num[0]) == 1:
        if flag == False:
            flag = True
        else:
            flag = False
    
    else:
        if int(q_num[1]) == 1 and flag == False or int(q_num[1]) == 2 and flag == True:
            add_before = q_num[2] + add_before
        else:
            add_after = add_after + q_num[2]

result = add_before + s + add_after
if flag:
    print(result[::-1])
else:
    print(result)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
q_list = [input().split() for i in range(q)]

flag = False
for q_num in q_list:
    if int(q_num[0]) == 1:
        if flag == False:
            flag = True
        else:
            flag = False
    
    if int(q_num[0]) == 2:
        if int(q_num[1]) == 1 and flag == False or int(q_num[1]) == 2 and flag == True:
            s = q_num[2] + s
        else:
            s = s + q_num[2]

if flag:
    print(s[::-1])
else:
    print(s)

Fixed submission:
s = input()
q = int(input())
q_list = [input().split() for i in range(q)]

flag = False
add_after = ""
add_before = ""
for q_num in q_list:
    if int(q_num[0]) == 1:
        if flag == False:
            flag = True
        else:
            flag = False
    
    else:
        if int(q_num[1]) == 1 and flag == False or int(q_num[1]) == 2 and flag == True:
            add_before = q_num[2] + add_before
        else:
            add_after = add_after + q_num[2]

result = add_before + s + add_after
if flag:
    print(result[::-1])
else:
    print(result)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p_list = list(map(int, input().split()))

cad_sum = 0
cad_sum_ori = 0
for i in range(n-k+1):
    cad_p_list = p_list[i:i+k]

    if sum(cad_p_list) < cad_sum_ori:
        continue

    cad_sum_child_list = []
    for cad_p in cad_p_list:
        cad_sum_child = (cad_p+1)/2
        cad_sum_child_list.append(cad_sum_child)

    cad_sum_child = sum(cad_sum_child_list)
    if  cad_sum_child > cad_sum:
        cad_sum = cad_sum_child
        cad_sum_ori = sum(cad_p_list)
        
print(cad_sum)

Fixed submission:
n, k = map(int, input().split())
p_list = list(map(lambda x: (float(x) + 1) / 2, input().split()))

S_i = [0]
for i in range(n):
    S_i.append(S_i[i] + p_list[i])    

# print(S_i)
result_max = 0
for j in range(k, n+1):
    cad_max = S_i[j] - S_i[j-k]
    result_max = max(cad_max, result_max)

print(result_max)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p_list = list(map(int, input().split()))

cad_sum = 0
for i in range(n-k+1):
    cad_p_list = p_list[i:i+k]
    cad_sum_child_list = []
    for cad_p in cad_p_list:
        cad_sum_child = (cad_p+1)/2
        cad_sum_child_list.append(cad_sum_child)

    cad_sum_child = sum(cad_sum_child_list)
    if  cad_sum_child > cad_sum:
        cad_sum = cad_sum_child

print(cad_sum)

Fixed submission:
n, k = map(int, input().split())
p_list = list(map(lambda x: (float(x) + 1) / 2, input().split()))

S_i = [0]
for i in range(n):
    S_i.append(S_i[i] + p_list[i])    

# print(S_i)
result_max = 0
for j in range(k, n+1):
    cad_max = S_i[j] - S_i[j-k]
    result_max = max(cad_max, result_max)

print(result_max)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p_list = list(map(int, input().split()))

cad_sum = 0
for i in range(n-k+1):
    cad_p_list = p_list[i:i+k]
    cad_sum_child_list = []
    for cad_p in cad_p_list:
        cad_sum_child = 0
        for num in range(1, cad_p+1):
            cad_sum_child += num
        cad_sum_child /= cad_p
        cad_sum_child_list.append(cad_sum_child)

    cad_sum_child = sum(cad_sum_child_list)
    if  cad_sum_child > cad_sum:
        cad_sum = cad_sum_child

print(cad_sum)

Fixed submission:
n, k = map(int, input().split())
p_list = list(map(lambda x: (float(x) + 1) / 2, input().split()))

S_i = [0]
for i in range(n):
    S_i.append(S_i[i] + p_list[i])    

# print(S_i)
result_max = 0
for j in range(k, n+1):
    cad_max = S_i[j] - S_i[j-k]
    result_max = max(cad_max, result_max)

print(result_max)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
n, k = map(int, input().split())
hp_list = list(map(int, input().split()))
hp_list.sort(reverse=True)

if k >= len(hp_list):
    print(0)
    sys.exit()

for del_num in range(k):
    del hp_list[0]
print(sum(hp_list))


Fixed submission:
import sys
n, k = map(int, input().split())
hp_list = list(map(int, input().split()))
hp_list.sort(reverse=True)

if k >= len(hp_list):
    print(0)
    sys.exit()

hp_list = hp_list[k:]
print(sum(hp_list))
Buggy python submission (verdict: Runtime Error):
n = int(input())

word_list = list(map(str, input().split()))

result_string = ""
for num in range(len(word_list[0])):
    for i in range(0,n):
        word_selected = word_list[i]
        result_string += word_selected[num]

print(result_string)

Fixed submission:
n = int(input())

word_list = list(map(str, input().split()))

result_string = ""
for num in range(len(word_list[0])):
    for i in range(0,2):
        word_selected = word_list[i]
        result_string += word_selected[num]

print(result_string)
Buggy python submission (verdict: Runtime Error):
n = int(input())
nums = map(int, input().split())

start_num = 1
result_list = []
for num in nums:
    if num == start_num:
        result_list.append(num)
        start_num += 1

if len(result_list) == 0:
    print(-1)
else:
    print(n - len(result_list))

Fixed submission:
#a,bの最小公倍数
a, b = list(map(int, input().split()))

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

def lcm(a, b):
    return a * b // gcd (a, b)

print(lcm(a, b))
Buggy python submission (verdict: Runtime Error):
mod = 10 ** 9 + 7
x, y = map(int,  input().split())

def nCm_mod(A, B, mod):
    mul_one = 1
    mul_two = 1

    for i in range(B):
        mul_one *= A - i
        mul_two *= i + 1
        mul_one %= mod
        mul_two %= mod
    
    return (mul_one * pow(mul_two, mod-2, mod)) % mod

if (x + y) % 3 != 0 or n<0 or n>m:
    print(0)
else:
    n = (2 * y - x) // 3
    m = (2 * x - y) // 3

    comb_num = nCm_mod(n+m, min(n,m), mod)
    print(comb_num)
    

Fixed submission:
mod = 10 ** 9 + 7
x, y = map(int,  input().split())

def nCm_mod(A, B, mod):
    mul_one = 1
    mul_two = 1

    for i in range(B):
        mul_one *= A - i
        mul_two *= i + 1
        mul_one %= mod
        mul_two %= mod
    
    return (mul_one * pow(mul_two, mod-2, mod)) % mod

n = (2 * y - x) // 3
m = (2 * x - y) // 3

if (x + y) % 3 != 0 or n < 0 or m < 0:
    print(0)
else:
    comb_num = nCm_mod(n+m, min(n,m), mod)
    print(comb_num)

Buggy python submission (verdict: Time Limit Exceeded):
mod = 10 ** 9 + 7

def factorial(n):
    result = 1
    for i in range(1, n+1):
        result *= i % mod
    return result

def combinations_count(n, r):
    return factorial(n) % mod // (factorial(n - r) % mod * factorial(r) % mod)

x, y = map(int,  input().split())

if (x + y) % 3 != 0:
    print(0)
else:
    n = (2 * y - x) // 3
    m = (2 * x - y) // 3
    comb_num = combinations_count(n+m, n)
    print(comb_num)

Fixed submission:
mod = 10 ** 9 + 7
x, y = map(int,  input().split())

def nCm_mod(A, B, mod):
    mul_one = 1
    mul_two = 1

    for i in range(B):
        mul_one *= A - i
        mul_two *= i + 1
        mul_one %= mod
        mul_two %= mod
    
    return (mul_one * pow(mul_two, mod-2, mod)) % mod

n = (2 * y - x) // 3
m = (2 * x - y) // 3

if (x + y) % 3 != 0 or n < 0 or m < 0:
    print(0)
else:
    comb_num = nCm_mod(n+m, min(n,m), mod)
    print(comb_num)
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left

n = int(input())
length_list = list(map(int, input().split()))

count = 0
length_list.sort()

for a_idx in range(n - 2):
    for b_idx in range(a_idx + 1, n - 1):
        a = length_list[a_idx]
        b = length_list[b_idx]
        if b > a:
            a, b = b, a
        
        left_count = bisect_left(length_list, a+b)
        count += max(0, left_count - b_idx - 1)


print(count)

Fixed submission:
from bisect import bisect_left

n = int(input())
length_list = list(map(int, input().split()))

count = 0
length_list.sort()

for a_idx in range(n - 2):
    for b_idx in range(a_idx + 1, n - 1):
        a = length_list[a_idx]
        b = length_list[b_idx]

        left_count = bisect_left(length_list, a+b)
        count += max(0, left_count - b_idx - 1)


print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
length_list = list(map(int, input().split()))

count = 0

for a_idx in range(len(length_list) - 2):
    for b_idx in range(a_idx+1, len(length_list) - 1):
        for c_idx in range(b_idx+1, len(length_list)):
            a = length_list[a_idx]
            b = length_list[b_idx]
            c = length_list[c_idx]
            # print(a,b,c)
            if a < b+c and b < c+a and c < a+b:
                count += 1  

print(count)

Fixed submission:
from bisect import bisect_left

n = int(input())
length_list = list(map(int, input().split()))

count = 0
length_list.sort()

for a_idx in range(n - 2):
    for b_idx in range(a_idx + 1, n - 1):
        a = length_list[a_idx]
        b = length_list[b_idx]

        left_count = bisect_left(length_list, a+b)
        count += max(0, left_count - b_idx - 1)


print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
people_count = list(map(int, input().split()))

for order in range(1, n+1):
    people = people_count.index(order) + 1
    print(people, end=" ")

Fixed submission:
import numpy as np
n = int(input())
people_count = list(map(int, input().split()))


people_count = np.array(people_count)
arg = people_count.argsort()
for i in arg:
    print(i+1, end=" ")

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
people_count = list(map(int, input().split()))

order_sort = [i for i in range(1, n+1)]
for order in order_sort:
    people = people_count.index(order) + 1
    print(people, end=" ")

Fixed submission:
import numpy as np
n = int(input())
people_count = list(map(int, input().split()))


people_count = np.array(people_count)
arg = people_count.argsort()
for i in arg:
    print(i+1, end=" ")

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
people_count = list(map(int, input().split()))

order_sort = sorted(people_count)
for order in order_sort:
    people = people_count.index(order) + 1
    print(people, end=" ")

Fixed submission:
import numpy as np
n = int(input())
people_count = list(map(int, input().split()))


people_count = np.array(people_count)
arg = people_count.argsort()
for i in arg:
    print(i+1, end=" ")
Buggy python submission (verdict: Time Limit Exceeded):
n, k, q = map(int, input().split())
a_list = [int(input()) for i in range(q)]

point_dic = []
for i in range(n):
    point_dic.append(k)

for a in a_list:
    # for i in range(n):
    #     if i+1 == a:
    #         pass
    #     else:
    #         point_dic[i+1] -= 1
    point_dic = list(map(lambda x: x-1, point_dic))
    point_dic[a-1] = point_dic[a-1] + 1


for point in point_dic:
    if point > 0:
        print("Yes")
    else:
        print("No")

Fixed submission:
n, k, q = map(int, input().split())
a_list = [int(input()) for i in range(q)]

point_dic = []
for i in range(n):
    point_dic.append(k-q)

for a in a_list:
    point_dic[a-1] = point_dic[a-1] + 1


for point in point_dic:
    if point > 0:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
n, k, q = map(int, input().split())
a_list = [int(input()) for i in range(q)]

point_dic = {}
for i in range(n):
    point_dic[i + 1] = k

for a in a_list:
    for i in range(n):
        if i+1 == a:
            pass
        else:
            point_dic[i+1] -= 1

for point in point_dic.values():
    if point > 0:
        print("Yes")
    else:
        print("No")

Fixed submission:
n, k, q = map(int, input().split())
a_list = [int(input()) for i in range(q)]

point_dic = []
for i in range(n):
    point_dic.append(k-q)

for a in a_list:
    point_dic[a-1] = point_dic[a-1] + 1


for point in point_dic:
    if point > 0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
def check(st,count):
    flag = False
    new_list = []
    for i in st:
        if i % 2 == 0:
            new_list.append(i)
        else:
            flag = True
            break
    if flag:
        print(count)
        return
    else:
      count += 1
      check(new_list, count)
      
n = int(input())
st = list(map(int, input().split()))
count = 0
check(st, count)



Fixed submission:
def check(st,count):
    flag = False
    new_list = []
    for i in st:
        if i % 2 == 0:
            i = i // 2
            new_list.append(i)
        else:
            flag = True
            break
    if flag:
        print(count)
        return
    else:
      count += 1
      check(new_list, count)

n = int(input())
st = list(map(int, input().split()))
count = 0
check(st, count)

Buggy python submission (verdict: Runtime Error):
n = int(input())
st = map(int, input().split())
flag = True
count = 0
check(st, count)
def check(st,count):
    new_list = []
	for i in len(st):
      if i % 2 == 0:
        new_list.append(i)
      else:
        flag = True
        break
    if flag:
      print(count)
      return
    else:
      count += 1
      check(new_list, count)

Fixed submission:
def check(st,count):
    flag = False
    new_list = []
    for i in st:
        if i % 2 == 0:
            i = i // 2
            new_list.append(i)
        else:
            flag = True
            break
    if flag:
        print(count)
        return
    else:
      count += 1
      check(new_list, count)

n = int(input())
st = list(map(int, input().split()))
count = 0
check(st, count)

Buggy python submission (verdict: Runtime Error):
n = int(input())
st = map(int, input().split())
flag = True
count = 0

def check(st,count):
    new_list = []
	for i in len(st):
      if i % 2 == 0:
        new_list.append(i)
      else:
        flag = True
        break
    if flag:
      print(count)
      return
    else:
      count += 1
      check(new_list, count)
      

Fixed submission:
def check(st,count):
    flag = False
    new_list = []
    for i in st:
        if i % 2 == 0:
            i = i // 2
            new_list.append(i)
        else:
            flag = True
            break
    if flag:
        print(count)
        return
    else:
      count += 1
      check(new_list, count)

n = int(input())
st = list(map(int, input().split()))
count = 0
check(st, count)
Buggy python submission (verdict: Runtime Error):
s = input()
s_origin = s
t = ""
word_list = ["dream", "dreamer", "erase", "eraser"]
while True:
    if len(s) <= 4:
        break

    if len(s) == 5:
        s_child_1 = s[-5:]
        if s_child_1 in word_list:
            t = s[-5:] + t
            s = s[:-5]
        break

    s_child_2 = s[-6:]
    if s_child_2 in word_list:
        t = s[-6:] + t
        s = s[:-6]
        flag = False

    s_child_1 = s[-5:]
    if s_child_1 in word_list:
        t = s[-5:] + t
        s = s[:-5]
        flag = False
    
    if flag:
        break

if s_origin == t:
    print("YES")
else:
    print("NO")
    

Fixed submission:
s = input()
s_origin = s
t = ""
word_list = ["dream", "dreamer", "erase", "eraser"]
while True:
    flag = True
    if len(s) <= 4:
        break

    if len(s) == 5:
        s_child_1 = s[-5:]
        if s_child_1 in word_list:
            t = s[-5:] + t
            s = s[:-5]
        break
    
    if len(s) == 6:
        s_child_1 = s[-6:]
        if s_child_1 in word_list:
            t = s[-6:] + t
            s = s[:-6]
        break

    s_child_2 = s[-7:]
    if s_child_2 in word_list:
        t = s[-7:] + t
        s = s[:-7]
        flag = False

    s_child_1 = s[-6:]
    if s_child_1 in word_list:
        t = s[-6:] + t
        s = s[:-6]
        flag = False

    s_child_1 = s[-5:]
    if s_child_1 in word_list:
        t = s[-5:] + t
        s = s[:-5]
        flag = False
    
    if flag:
        break

if s_origin == t:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(input())
ans = 0

for i in range(1, k+1):
    for j in range(1,k+1):
        tmp = gcd(i,j)
        for m in range (1,k+1):
            ans += gcd(tmp,m)

print(ans)


Fixed submission:
import math

k = int(input())
ans = 0

for i in range(1, k+1):
    for j in range(1,k+1):
        tmp = math.gcd(i,j)
        for m in range (1,k+1):
            ans += math.gcd(tmp,m)

print(ans)

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

def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(input())
ans = 0

for i in range(1, k+1, 1):
    for l in range(1, k+1, 1):
        for m in range(1, k+1, 1):
            ans += gcd(i,l,m)

print(ans)


Fixed submission:
import math

k = int(input())
ans = 0

for i in range(1, k+1):
    for j in range(1,k+1):
        tmp = math.gcd(i,j)
        for m in range (1,k+1):
            ans += math.gcd(tmp,m)

print(ans)
Buggy python submission (verdict: Runtime Error):
from scipy.special import comb

n,k = map(int,input().split())
mod = 10**9 + 7

for i in range(k):
    print(comb(k-1,i,exact=True) * comb(n-k+1,i+1,exact=True) % mod)


Fixed submission:
from scipy.misc import comb

n,k = map(int,input().split())
mod = 10**9 + 7

for i in range(k):
    print(comb(k-1,i,exact=True) * comb(n-k+1,i+1,exact=True) % mod)
Buggy python submission (verdict: Runtime Error):
import math

a,b,c,d = map(int,input().split(" "))
dif = 0
plus = 0
lcm = c * d // math.gcd(c,d)
e = b + 1 - a

dif += b // c - (a - 1) // c
dif += b // d - (a - 1) // d
if c != d:
    plus += b // lcm - (a -1) // lcm

print(e - dif + plus)


Fixed submission:
a,b,c,d = map(int,input().split(" "))
dif = 0
plus = 0

gcd = c
t = d
while t:
    gcd, t = t, gcd % t

lcm = c * d // gcd
e = b + 1 - a

dif += b // c - (a - 1) // c
dif += b // d - (a - 1) // d
plus += b // lcm - (a -1) // lcm

print(e - dif + plus)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [0] * n
b = [0] * n

for i in range(n):
    a[i],b[i] = map(int,input().split(" "))

for i in range(n):
    if max(b) < sum(a):
        print("No")
        break
    a.pop(b.index(max(b)))
    b.pop(b.index(max(b)))
else:
    print("Yes")


Fixed submission:
n = int(input())
a = [[0,0]] * n
time = 0

for i in range(n):
    x,y = map(int,input().split(" "))
    a[i] = [y,x]

a.sort()
for i,j in a:
    time += j
    if i < time:
        print("No")
        break
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
w,h,x,y = map(float,input().split(" "))

if a.count(max(a)) > 1:
    print('{:.6f}'.format(w*h/2,1)
else:
    print('{:.6f}'.format(w*h/2,0)


Fixed submission:
w,h,x,y = map(int,input().split(" "))

if x == w/2 and y == h/2:
    print('{:.6f}'.format(w*h/2),1)
else:
    print('{:.6f}'.format(w*h/2),0)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
a = "ABC"
ans = 0

while("ABC" in s):
    s = s.replace("ABC","BCA",1)
    ans += 1

print(ans)


Fixed submission:
s = input()
s = s.replace("BC","X")
ans = []
c = 0

for i in range(1,len(s)+1):
    if s[-1 * i] == "X":
        c += 1
    elif s[-1 * i] == "A":
        ans.append(c)
    else:
        c = 0
print(sum(ans))
Buggy python submission (verdict: Runtime Error):
n = int(input())
mountain = [ s for s in input().split(" ")]
highest = 0
ans = 0

for m in mountain:
  if m >= highest:
    ans += 1
    highest = m

print(ans)

Fixed submission:
n = int(input())
mountain = [ int(s) for s in input().split(" ")]
ans = 0
highest = 0

for m in mountain:
    if m >= highest:
        ans += 1
        highest = m

print(ans)
Buggy python submission (verdict: Runtime Error):
    n, k = map(int, input().split())
    if n < k:
        print(1)
        exit(0)

    MOD = pow(10, 9) + 7
    count = 0
    while n+1 >= k:
        minv = k * (k-1) // 2
        maxv = ((n+1) * n // 2) - ((n-k) * (n-k+1) // 2)

        count += (maxv - minv + 1)
        count %= MOD
        k += 1

    print(count)


Fixed submission:
n, k = map(int, input().split())
if n < k:
    print(1)
    exit(0)

MOD = pow(10, 9) + 7
count = 0
while n+1 >= k:
    minv = k * (k-1) // 2
    maxv = ((n+1) * n // 2) - ((n-k) * (n-k+1) // 2)

    count += (maxv - minv + 1)
    count %= MOD
    k += 1

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

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

m = 0
c = 0
if n<b:
    m = math.floor(a*n/b)
else:
    for x in range(b,n+1,b):
        c = math.floor(a*(x-1)/b)-a*math.floor((x-1)/b)
        if c >= m:
            m=c
        else:
            break
print(m)

Fixed submission:
import math

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

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

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

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

m = 0
c = 0
if n<b:
    m = math.floor(a*n/b)
else:
    for x in range(b,n+1,b):
        c = math.floor(a*(x-1)/b)-a*math.floor((x-1)/b)
        if c >= m:
            m=c
        else:
            break
print(m)

Fixed submission:
import math

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

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

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

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

m = -1
c = 0
for x in range(0,min(b,n)+1):
    c = math.floor(a*x/b)-a*math.floor(x/b)
    #print('a:',c)
    if c >= m:
        m=c
    else:
        break
if n>b:
    for x in range(b,n+1,b):
        c = math.floor(a*x/b)-a*math.floor(x/b)
        #print('b:',c)
        if c >= m:
            m=c
        else:
            break
print(m)

Fixed submission:
import math

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

m = 0
if n<b:
    m = math.floor(a*n/b)
else:
    m = math.floor(a*(b-1)/b)-a*math.floor((b-1)/b)
print(m)
Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = map(int, input().split())

c = 0
while n > 0:
    n = n - a
    if n > 0:
        c += a
    else:
        c += a+n
    n = n - b
print(c)

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

x = n // (a+b)
c = a * x
n -= (a+b)*x
while n > 0:
    n = n - a
    if n > 0:
        c += a
    else:
        c += a+n
    n = n - b
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = [(x+1)/2 for x in map(int, input().split())]
m = 0
for i in range(n-k+1):
    m = max(m, sum(p[i:i+k]))
print(m)

Fixed submission:
n, k = map(int, input().split())
p = [(x+1)/2 for x in map(int, input().split())]
o = sum(p[:k])
m = o
for i in range(n-k):
    o = o-p[i]+p[i+k]
    m = max(m, o)
print(m)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int, input().split()))

c = 0
for i in range(n):
    for j in range(i):
        if p[i] > p[j]:
            break
    else:
        c += 1
print(c)

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

c = 0
m = p[0]
for i in range(n):
    m = min(m, p[i])
    if m >= p[i]:
        c += 1
print(c)