Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = sorted(list(map(int, input().split())))
answer = 0

for i in range(n - 2):
    for j in range(i + 1, n - 1):
        lij = l[i] + l[j]
        for k in range(j + 1, n):
            if l[k] < lij:
               answer += 1
            else:
               break
print(answer)


Fixed submission:
from bisect import bisect_left

n = int(input())
l = sorted(list(map(int, input().split())))
answer = 0

for i in range(n - 2):
    for j in range(i + 1, n - 1):
        lij = l[i] + l[j]
        r = bisect_left(l, lij)
        answer += max(0, r - j - 1)
        
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

n = int(input())
l = list(map(int, input().split()))
answer = 0
for a, b, c in combinations(l, 3):
    if a < b + c and b < a + c and c < a + b:
        answer += 1
print(answer)


Fixed submission:
from bisect import bisect_left

n = int(input())
l = sorted(list(map(int, input().split())))
answer = 0

for i in range(n - 2):
    for j in range(i + 1, n - 1):
        lij = l[i] + l[j]
        r = bisect_left(l, lij)
        answer += max(0, r - j - 1)
        
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

answer = sum(range(1, n))
print(answer)

Fixed submission:
n = int(input())

answer = n * (n - 1) // 2
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
l, r = map(int, input().split())
card = set(range(l, r + 1))
for _ in range(1, m):
    l, r = map(int, input().split())
    card &= set(range(l, r + 1))

print(len(card))

Fixed submission:
n, m = map(int, input().split())
lr = [tuple(map(int, input().split())) for _ in range(m)]
maxl = max(_[0] for _ in lr)
minr = min(_[1] for _ in lr)
if minr - maxl >= 0:
    answer = minr - maxl + 1
else:
    answer = 0
print(answer)
Buggy python submission (verdict: Runtime Error):
t = [int(input()) for _  in range(5)]
total = 0
amari = []

for ti in t:
    d, m = divmod(ti, 10)
    total += ti - m
    if m > 0:
        amari.append(m)
total += min(amari) + 10 * (len(amari) - 1)
print(total)

Fixed submission:
t = [int(input()) for _  in range(5)]
total = 0
amari = []

for ti in t:
    d, m = divmod(ti, 10)
    total += ti - m
    if m > 0:
        amari.append(m)
if amari:
    total += min(amari) + 10 * (len(amari) - 1)
print(total)
Buggy python submission (verdict: Time Limit Exceeded):
import re

n, q = map(int, input().split())
s = input()
for _ in range(q):
    l, r = map(int, input().split())
    li = re.findall("AC", s[l-1:r])
    print(len(li))


Fixed submission:
from bisect import bisect, bisect_left

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

bi = []

for i in range(n - 1):
    if s[i:i+2] == "AC":
        bi.append(i)

for _ in range(q):
    l, r = map(int, input().split())
    answer = bisect(bi, r - 1) - bisect_left(bi, l - 1)
    if r < n and s[r - 1:r + 1] == "AC":
        answer -= 1
    print(answer)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
ans = max(len(set(s[:i]) & set(s[i:])) for i in range(1, n - 1))
print(ans)


Fixed submission:
n = int(input())
s = input()
ans = max(len(set(s[:i]) & set(s[i:])) for i in range(1, n))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
while s.count("WE"):
    s = s.replace("WE", "")
ans = (n - len(s)) // 2
print(ans)


Fixed submission:
n = int(input())
s = input()
wcount = 0
wecount = 0
prev = ""
for c in s:
    if c == "W":
        if prev == "E": wcount = 0
        wcount += 1
    if wcount and c == "E":
        wcount -= 1
        wecount += 1
print(wecount)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
while s.count("WE"):
    s = s.replace("WE", "")
ans = (n - len(s)) // 2
print(ans)


Fixed submission:
n = int(input())
s = input()
wcount = 0
wecount = 0
prev = ""
for c in s:
    if c == "W":
        if prev == "E": wcount = 0
        wcount += 1
    if wcount and c == "E":
        wcount -= 1
        wecount += 1
print(wecount)
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = list(map(int, input().split()))

cnt = 0
for i in range(n):
    if p[i] == i+1:
        if i < n:
            p[i], p[i+1] = p[i+1], p[i]
        cnt += 1
print(cnt)


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

cnt = 0
for i in range(n):
    if p[i] == i+1:
        if i+1 < n:
            p[i], p[i+1] = p[i+1], p[i]
        cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ali = list(map(int,input().split()))

ali.sort(reverse=True)

# rings = [ali[0], ali[1]]
comforts = [ali[1], ali[1]]

answer = ali[0]

for i in ali[2:]:
    max_com = comforts.index(max(comforts))
    answer += comforts[max_com]

    comforts.pop(max_com)
    comforts.insert(max_com, i)
    comforts.insert(max_com, i) #新しく入った人の隣同士

print(answer)

Fixed submission:
from collections import deque
import sys

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

ali.sort(reverse=True)

comforts = deque([ali[1], ali[1]])
answer = ali[0]
if len(ali) < 3:
    print(answer)
    sys.exit()

for i in ali[2:]:
    answer += comforts.pop()
    comforts.appendleft(i)
    comforts.appendleft(i)

print(answer)
Buggy python submission (verdict: Runtime Error):
from itertools import combinations

n,m,x = map(int,input().split())
cost_lists = [list(map(int,input().split())) for _ in range(n)]

# print(cost_lists)

min_cost = 10**9
unst_flag = False

for i in range(1, n+1):
    combi_lists = list(combinations(range(n), i))

    for combi_list in combi_lists:
        tmp_list = list()
        for j in range(1,m):
            tmp_unst = 0
            for k in combi_list:
                tmp_unst += cost_lists[k][j]

            tmp_list.append(tmp_unst)
        
        if min(tmp_list) >= x:
            tmp_cost = 0
            for k in combi_list:
                tmp_cost += cost_lists[k][0]

            min_cost = min(min_cost, tmp_cost)
            unst_flag = True

if unst_flag:
    print(min_cost)
else:
    print(-1)


Fixed submission:
from itertools import combinations

n,m,x = map(int,input().split())
cost_lists = [list(map(int,input().split())) for _ in range(n)]

# print(cost_lists)

min_cost = 10**9
unst_flag = False

for i in range(1, n+1):
    combi_lists = list(combinations(range(n), i))

    for combi_list in combi_lists:
        tmp_list = list()
        for j in range(1,m+1):
            tmp_unst = 0
            for k in combi_list:
                tmp_unst += cost_lists[k][j]

            tmp_list.append(tmp_unst)
        
        if min(tmp_list) >= x:
            tmp_cost = 0
            for k in combi_list:
                tmp_cost += cost_lists[k][0]

            min_cost = min(min_cost, tmp_cost)
            unst_flag = True

if unst_flag:
    print(min_cost)
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

n=int(input())
li = list(map(int,input().split()))
cli = collections.Counter(li)
cli_values = tuple(cli.values())

count = 0

for cli_value in cli_values:
    if cli_value > 1:
        count += (cli_value * (cli_value-1))//2

for k in range(n):
    tmp = li.count(li[k])
    answer = count - (tmp * (tmp-1))//2 + ((tmp-1) * (tmp-2))//2
    print(answer)

Fixed submission:
import collections

n=int(input())
li = list(map(int,input().split()))
cli = collections.Counter(li)
cli_values = tuple(cli.values())

count = 0

for cli_value in cli_values:
    if cli_value > 1:
        count += (cli_value * (cli_value-1))//2

for k in range(n):
    tmp = cli[li[k]]
    answer = count - (tmp * (tmp-1))//2 + ((tmp-1) * (tmp-2))//2
    print(answer)

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

n=int(input())
li = list(map(int,input().split()))
cli = collections.Counter(li)
cli_values = tuple(cli.values())

count = 0

for cli_value in cli_values:
    if cli_value > 1:
        count += (cli_value * (cli_value-1))//2

for k in range(n):
    tmp = li.count(li[k])
    answer = count - (tmp * (tmp-1))//2 + ((tmp-1) * (tmp-2))//2
    print(answer)

Fixed submission:
import collections

n=int(input())
li = list(map(int,input().split()))
cli = collections.Counter(li)
cli_values = tuple(cli.values())

count = 0

for cli_value in cli_values:
    if cli_value > 1:
        count += (cli_value * (cli_value-1))//2

for k in range(n):
    tmp = cli[li[k]]
    answer = count - (tmp * (tmp-1))//2 + ((tmp-1) * (tmp-2))//2
    print(answer)

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

count = 0

for i in range(1,n+1):
    tmp = li.count(i)
    count += (tmp * (tmp-1))//2

for k in range(n):
    tmp = li.count(li[k])
    answer = count - (tmp * (tmp-1))//2 + ((tmp-1) * (tmp-2))//2
    print(answer)

Fixed submission:
import collections

n=int(input())
li = list(map(int,input().split()))
cli = collections.Counter(li)
cli_values = tuple(cli.values())

count = 0

for cli_value in cli_values:
    if cli_value > 1:
        count += (cli_value * (cli_value-1))//2

for k in range(n):
    tmp = cli[li[k]]
    answer = count - (tmp * (tmp-1))//2 + ((tmp-1) * (tmp-2))//2
    print(answer)
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int,input().split())

count = 0
p = 10**9+7

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

range2_n1 = range(2, n+1)
range1_n1 = range(1, n+1)

for i in range2_n1:
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

for m in range1_n1:
    if not (m == a or m == b):
        count += cmb(n,m,p)
        count %= p

print(count)

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

if n<10:
    print(r+(100*(10-n)))
else:
    print(r)
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = [input() for i in range(n)]

c = collections.Counter(p)
m = c.most_common()
most = m[0][1]

answer = []

answer.append(m[0][0])

for i in range(len(m)-1):
    if m[i+1][1] == most:
        answer.append(m[i+1][0])
    else:
        break

for output in sorted(answer):
    print(output)

Fixed submission:
import collections

def main():
    n = int(input())
    p = [input() for i in range(n)]

    c = collections.Counter(p)
    m = c.most_common()
    most = m[0][1]

    answer = []

    answer.append(m[0][0])

    for i in range(len(m)-1):
        if m[i+1][1] == most:
            answer.append(m[i+1][0])
        else:
            break

    for output in sorted(answer):
        print(output)
    return


main()

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

n = int(input())
p = [input() for i in range(n)]

c = collections.Counter(p)
m = c.most_common()
most = m[0][1]

answer = []

answer.append(m[0][0])

for i in range(len(m)-1):
    if m[i+1][1] == most:
        answer.append(m[i+1][0])
    else:
        break

for output in sorted(answer):
    print(output)
return

Fixed submission:
import collections

def main():
    n = int(input())
    p = [input() for i in range(n)]

    c = collections.Counter(p)
    m = c.most_common()
    most = m[0][1]

    answer = []

    answer.append(m[0][0])

    for i in range(len(m)-1):
        if m[i+1][1] == most:
            answer.append(m[i+1][0])
        else:
            break

    for output in sorted(answer):
        print(output)
    return


main()
Buggy python submission (verdict: Runtime Error):
def main():
    x,y = map(int,input().split())
    p = list(map(int,input().split()))

    bigNumber = 0

    for i in range(x-y+1):

        number = sum(p[i:i+y])

        if number > bigNumber:
            bigNumber = number

    print((bigNumber + y) / 2)

main()


Fixed submission:
S, T = map(str,input().split())
A, B = map(int,input().split())
U = str(input())

if U == S:
    A = A - 1
else:
    B = B - 1

print(A, B)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

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

for i in range(N):
    x = A[i]
    for j in range(N-i-1):
        if x == A[i+j+1]:
            print('NO')
            sys.exit()

print('YES')

Fixed submission:
import sys

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

if len(A) == len(set(A)):
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
p_lists = [list(map(str,input().split())) for _ in range(m)]

# print(p_list)

AC_count = 0
WA_count = 0

AC_question = []
WA_question = {}

for p_list in p_lists:
    if p_list[0] in AC_question:
        continue

    if p_list[1] == 'AC':
        AC_count += 1

        if p_list[0] in WA_question:
            WA_count += WA_question[p_list[0]]

        AC_question.append(p_list[0])

    if p_list[1] == 'WA':
        if p_list[0] in WA_question:
            WA_question[p_list[0]] = WA_question[p_list[0]] + 1
        else:
            WA_question[p_list[0]] = 1

print(AC_count, WA_count)
    


Fixed submission:
n,m = map(int,input().split())
p_lists = [list(map(str,input().split())) for _ in range(m)]

# print(p_list)

AC_count = 0
WA_count = 0

AC_question = set()
WA_question = dict()

for p_list in p_lists:
    if p_list[0] in AC_question:
        continue

    if p_list[1] == 'AC':
        AC_count += 1

        if p_list[0] in WA_question:
            WA_count += WA_question[p_list[0]]

        AC_question.add(p_list[0])

    if p_list[1] == 'WA':
        if p_list[0] in WA_question:
            WA_question[p_list[0]] = WA_question[p_list[0]] + 1
        else:
            WA_question[p_list[0]] = 1

print(AC_count, WA_count)
Buggy python submission (verdict: Runtime Error):
a,b,k = map(int,input().split())

if k>a:
    k = k-a
    a = 0

    if k>b:
        k = k-b
        b = 0
    else:
        b = b-k
else:
    a = a-k

print(f"{a} {b}")

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

if k>a:
    k = k-a
    a = 0

    if k>b:
        k = k-b
        b = 0
    else:
        b = b-k
else:
    a = a-k

print(a,b)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
s = set(a)
for i in range(1,n+1):
    if i in s:
        print(a.count(i))
    else:
        print(0)

Fixed submission:
import sys
from collections import Counter
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
for i in range(1,n+1):
    if i in c:
        print(c[i])
    else:
        print(0)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
for i in range(1,n+1):
    try:
        print(a.count(i))
    except:
        print(0)

Fixed submission:
import sys
from collections import Counter
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
for i in range(1,n+1):
    if i in c:
        print(c[i])
    else:
        print(0)
Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == '__main__':
    N = int(input())
    a = [int(x) for x in input().split()]
    num_len = len(a)
    ans = 0
    for i in range(1, num_len+1):
        for j in range(1, num_len+1):
            if i == a[j-1] and j == a[i-1]:
                ans += 1
    print(int(ans / 2))


Fixed submission:
if __name__ == '__main__':
    N = int(input())
    a = [int(x) for x in input().split()]
    num_len = len(a)
    ans = 0
    for i in range(num_len):
        if a[a[i]-1] == i+1:
            ans += 1
    print(int(ans / 2))

# if __name__ == '__main__':
#     N = int(input())
#     a = [int(x) for x in input().split()]
#     num_len = len(a)
#     ans = 0
#     for i in range(1, num_len+1):
#         for j in range(1, num_len+1):
#             if i == a[j-1] and j == a[i-1]:
#                 ans += 1
#     print(int(ans / 2))
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
h = input()
ret = ((a + b ) * h) / 2
print(ret)

Fixed submission:
a = int(input())
b = int(input())
h = int(input())
ret = ((a + b ) * h) / 2
print(int(ret))
Buggy python submission (verdict: Runtime Error):
s = list(map(str, input()))
display = []
for action in s:
    if action == '0':
        display.append('0')
    elif action == '1':
        display.append('1')
    elif action == 'B':
        display.pop()
print(''.join(display))

Fixed submission:
s = list(map(str, input()))
display = []
for action in s:
    if action == '0':
        display.append('0')
    elif action == '1':
        display.append('1')
    elif action == 'B':
        if len(display) > 0:
            display.pop()
print(''.join(display))
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())

a = 0
ans = -1

for i in range(K):
    a += 7 * 10**i
    if a % K == 0:
        ans = i+1
        break

print(ans)

Fixed submission:
k = int(input())
if k==1 or k==7:
  print(1)
elif k%2==0:
  print(-1)
else:
  cnt = 1
  pre = 7
  while(True):
    surp = (pre*10+7)%k
    cnt += 1
    if surp==0:
      break
    if cnt>1000000:
      cnt = -1
      break
    pre = surp
  print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())

a = 0
ans = -1

for i in range(K):

    a += 7 * 10**i

    if a % K == 0:
        ans = i+1
        break

print(ans)

Fixed submission:
k = int(input())
if k==1 or k==7:
  print(1)
elif k%2==0:
  print(-1)
else:
  cnt = 1
  pre = 7
  while(True):
    surp = (pre*10+7)%k
    cnt += 1
    if surp==0:
      break
    if cnt>1000000:
      cnt = -1
      break
    pre = surp
  print(cnt)
Buggy python submission (verdict: Runtime Error):
N = input()
sum = 0

for i in range(N):
    sum += i**2
    
print(sum)

Fixed submission:
N = int(input())
sum = 0

for i in range(N):
    sum += i+1

print(sum)
Buggy python submission (verdict: Runtime Error):
N = int(input())
l = list(map(int,input().split()))
l_ans = [[] for _ in range(200)]

for i in range(-100,101):
    sum = 0

    for j in range(N):
        sum = sum + (i-l[j])**2

    l_ans[i+100] = sum

print(l_ans)
print(min(l_ans))

Fixed submission:
N = int(input())
l = list(map(int,input().split()))
l_ans = [[] for _ in range(201)]

for i in range(-100,101):
    sum = 0

    for j in range(N):
        sum = sum + (i-l[j])**2

    l_ans[i+100] = sum

print(min(l_ans))

Buggy python submission (verdict: Runtime Error):
N = int(input())
l = list(map(int,input().split()))
l_ans = []

for i in range(1,101):
    sum = 0

    for j in range(N):
        sum = sum + (i-l[j])**2

    l_ans[i] = sum

print(min(l))

Fixed submission:
N = int(input())
l = list(map(int,input().split()))
l_ans = [[] for _ in range(201)]

for i in range(-100,101):
    sum = 0

    for j in range(N):
        sum = sum + (i-l[j])**2

    l_ans[i+100] = sum

print(min(l_ans))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
q = int(input())
b, c = [0]*q, [0]*q
for i in range(q):
    b[i], c[i] = map(int, input().split())

for j in range(q):
    for k in range(n):
        if a[k] == b[j]:
            a[k] = c[j]
    print(sum(a))

Fixed submission:
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
q = int(input())

C = Counter(a)
ans = sum(a)

for i in range(q):
    b, c = map(int, input().split())
    ans += (c-b)*C[b]
    C[c] += C[b]
    C[b] = 0
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from math import sqrt

n = int(input())

i = 2
j = 0
c = []

while n != 1:
    
    if n%i == 0:
        j += 1
        n = n/i
        if n == 1:
            c.append(j)
    else:
        if j != 0:
            c.append(j)
        i += 1
        j = 0
        
d = 0        
if c == []:
    print(d)
else:
    for k in c:
        d += int((sqrt(1 + 8*k)-1)/2)
    print(d)
            

Fixed submission:
from math import sqrt

n = int(input())

i = 2

c = []

while i*i <= n:
    j = 0
    while n%i == 0:
        j += 1
        n //= i   
    else:
        if j != 0:
            c.append(j)
    i += 1
if n > 1:
    c.append(1)
             
d = 0        
if c == []:
    print(d)
else:
    for k in c:
        d += int((sqrt(1 + 8*k)-1)/2)
    print(d)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())

a = [int(x)-1 for x in input().split()]

v = []
vc = [0]*n
b = 0
c = 0

while True:
    if vc[b]>0:
        stop = v.index(b)
        break
    v.append(b)
    vc[b] += 1
    b = a[b]
    c += 1



if k>c:
    r = (k-stop)%(c-stop)
    print(v[stop+r]+1)
else:
    print(v[k]+1)

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

a = [int(x)-1 for x in input().split()]

v = []
vc = [0]*n
b = 0
c = 0

while True:
    if vc[b]>0:
        stop = v.index(b)
        break
    v.append(b)
    vc[b] += 1
    b = a[b]
    c += 1



if k>stop:
    r = (k-stop)%(c-stop)
    print(v[stop+r]+1)
else:
    print(v[k]+1)

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

a = [int(x)-1 for x in input().split()]

v = []
b = 0

for i in range(n):
    if b not in v:
        v.append(b)
        b = a[b]
    else:
        stop = v.index(b)
        j = i
        break


if k>j:
    r = (k-stop)%(j-stop)
    print(v[stop+r]+1)
else:
    print(v[k]+1)


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

a = [int(x)-1 for x in input().split()]

v = []
vc = [0]*n
b = 0
c = 0

while True:
    if vc[b]>0:
        stop = v.index(b)
        break
    v.append(b)
    vc[b] += 1
    b = a[b]
    c += 1



if k>stop:
    r = (k-stop)%(c-stop)
    print(v[stop+r]+1)
else:
    print(v[k]+1)

Buggy python submission (verdict: Runtime Error):

n, k = map(int, input().split())

a = [int(x)-1 for x in input().split()]

v = []
b = 0
stop = -1

for i in range(n):
    if b not in v:
        v.append(b)
        b = a[b]
    else:
        stop = v.index(b)
        break

v1 = v[:stop]
v2 = v[stop:]
c1 = len(v1)
c2 = len(v2)

if k>c1:
    r = (k-c1)%c2
else:
    r = k
    
print(v[stop+r]+1)



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

a = [int(x)-1 for x in input().split()]

v = []
vc = [0]*n
b = 0
c = 0

while True:
    if vc[b]>0:
        stop = v.index(b)
        break
    v.append(b)
    vc[b] += 1
    b = a[b]
    c += 1



if k>stop:
    r = (k-stop)%(c-stop)
    print(v[stop+r]+1)
else:
    print(v[k]+1)
Buggy python submission (verdict: Time Limit Exceeded):

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

mx = 0

for i in range(n+1):
    if a*i//b-a*(i//b) > mx:
        mx = a*i//b-a*(i//b)
        
print(mx)
    

Fixed submission:

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

mx = 0

nn = n//b

mm = (a*n)//b - a*(nn)

if nn > 0:
    x = b*nn-1
    mx = (a*x)//b - a*(nn-1)
    mm = max(mm, mx)
    
print(mm)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int,input().split())

l = range(n+1)

c = 0

for i in range(k, n+2):
    mn = sum(l[:i])
    mx = sum(l[-i:])
    c = c + mx - mn + 1

print(c%(10**9+7))

Fixed submission:

n, k = map(int,input().split())

l = range(n+1)

c = 0

for i in range(k, n+2):
    mn = (i-1)*i//2
    mx = (2*n+1-i)*i//2
    c = c + mx - mn + 1

print(c%(10**9+7))