Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
import numpy as np
import random

N, M, Q = map(int, input().rstrip().split(' '))

count = np.zeros((N+1, N+1)).astype(int)
memo = np.zeros((N+1, N+1)).astype(int)

for _ in range(M):
    p, q = map(int, input().rstrip().split(' '))
    count[p, q] += 1

for i in range(1,N+1):
    for j in range(1,N+1):
        memo[i][j] = count[i][j] + memo[i-1][j-1] + (memo[i-1][j] - memo[i-1][j-1]) + (memo[i][j-1] - memo[i-1][j-1])

for i in range(Q):
    p, q = map(int, input().rstrip().split(' '))
    print(memo[q][q] - memo[p-1][q] - memo[q][p-1] + memo[p-1][p-1])
    


Fixed submission:
# coding: utf-8
# Your code here!

N, M, Q = map(int, input().rstrip().split(' '))

count = [[0] * (N + 1) for _ in range(N+1)]
memo = [[0] * (N + 1) for _ in range(N+1)]

for _ in range(M):
    p, q = map(int, input().rstrip().split(' '))
    count[p][q] += 1

for i in range(1,N+1):
    for j in range(1,N+1):
        memo[i][j] = count[i][j] + memo[i-1][j] + memo[i][j-1] - memo[i-1][j-1]

for i in range(Q):
    p, q = map(int, input().rstrip().split(' '))
    print(memo[q][q] - memo[p-1][q] - memo[q][p-1] + memo[p-1][p-1])

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import numpy as np
 
N, M, Q = map(int, input().rstrip().split(' '))
 
memo = np.zeros((N, N)).astype(int)
 
for _ in range(M):
    p, q = map(int, input().rstrip().split(' '))
    memo[:p, q-1:] += 1
 
for i in range(Q):
    p, q = map(int, input().rstrip().split(' '))
    print(memo[p-1][q-1])

Fixed submission:
# coding: utf-8
# Your code here!

N, M, Q = map(int, input().rstrip().split(' '))

count = [[0] * (N + 1) for _ in range(N+1)]
memo = [[0] * (N + 1) for _ in range(N+1)]

for _ in range(M):
    p, q = map(int, input().rstrip().split(' '))
    count[p][q] += 1

for i in range(1,N+1):
    for j in range(1,N+1):
        memo[i][j] = count[i][j] + memo[i-1][j] + memo[i][j-1] - memo[i-1][j-1]

for i in range(Q):
    p, q = map(int, input().rstrip().split(' '))
    print(memo[q][q] - memo[p-1][q] - memo[q][p-1] + memo[p-1][p-1])

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
import numpy as np

N, M, Q = map(int, input().rstrip().split(' '))

memo = np.zeros((N, N)).astype(int)

for _ in range(M):
    p, q = map(int, input().rstrip().split(' '))
    memo[:p, q-1:] += 1

for i in range(Q):
    p, q = map(int, input().rstrip().split(' '))
    print(memo[p-1][q-1])


Fixed submission:
# coding: utf-8
# Your code here!

N, M, Q = map(int, input().rstrip().split(' '))

count = [[0] * (N + 1) for _ in range(N+1)]
memo = [[0] * (N + 1) for _ in range(N+1)]

for _ in range(M):
    p, q = map(int, input().rstrip().split(' '))
    count[p][q] += 1

for i in range(1,N+1):
    for j in range(1,N+1):
        memo[i][j] = count[i][j] + memo[i-1][j] + memo[i][j-1] - memo[i-1][j-1]

for i in range(Q):
    p, q = map(int, input().rstrip().split(' '))
    print(memo[q][q] - memo[p-1][q] - memo[q][p-1] + memo[p-1][p-1])
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

import bisect

N = int(input())

plus = [2 ** x for x in range(0, 35, 2)]
minus = [2 ** x for x in range(1, 35, 2)]

cum_plus = [sum(plus[:x]) for x in range(1, len(plus))]
cum_minus = [sum(minus[:x]) for x in range(1, len(minus))]

flags = []
answer = 0
while answer != N:
    if N - answer > 0:
        insert_index = bisect.bisect_left(cum_plus, N - answer)
        flags.append(insert_index * 2)
        answer += plus[insert_index]
        cum_plus = cum_plus[:insert_index]
    else:
        insert_index = bisect.bisect_left(cum_minus, abs(N - answer))
        flags.append(insert_index * 2 + 1)
        answer -= minus[insert_index]
        cum_minus = cum_minus[:insert_index]
        
output = [0] * (flags[0] + 1)
for flag in flags:
    output[flag] = 1
 
print(''.join([str(x) for x in output[::-1]]))

Fixed submission:
# coding: utf-8
# Your code here!

import bisect

N = int(input())

if N == 0:
    print(0)
else:
    plus = [2 ** x for x in range(0, 35, 2)]
    minus = [2 ** x for x in range(1, 35, 2)]
    
    cum_plus = [sum(plus[:x]) for x in range(1, len(plus))]
    cum_minus = [sum(minus[:x]) for x in range(1, len(minus))]
    
    flags = []
    answer = 0
    while answer != N:
        if N - answer > 0:
            insert_index = bisect.bisect_left(cum_plus, N - answer)
            flags.append(insert_index * 2)
            answer += plus[insert_index]
            cum_plus = cum_plus[:insert_index]
        else:
            insert_index = bisect.bisect_left(cum_minus, abs(N - answer))
            flags.append(insert_index * 2 + 1)
            answer -= minus[insert_index]
            cum_minus = cum_minus[:insert_index]
            
    output = [0] * (flags[0] + 1)
    for flag in flags:
        output[flag] = 1
     
    print(''.join([str(x) for x in output[::-1]]))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
 
import sys
sys.setrecursionlimit(1000000)
 
N = int(input())
A = list(map(int, input().rstrip().split(' ')))
 
A_dash = [x - i - 1 for i, x in enumerate(A)]
 
def recursive(X):
    if len(X) == 1:
        return sum([abs(x - X[0]) for x in A_dash])
    elif len(X) == 2:
        if sum([abs(x - X[1]) for x in A_dash]) - sum([abs(x - X[0]) for x in A_dash]) > 0:
            return sum([abs(x - X[0]) for x in A_dash])
        else:
            return sum([abs(x - X[1]) for x in A_dash])
        
    if sum([abs(x - X[len(X)//2]) for x in A_dash]) - sum([abs(x - X[len(X)//2 - 1]) for x in A_dash]) < 0:
        return recursive(X[len(X)//2:])
    else:
        return recursive(X[:len(X)//2 + 1])
 
print(recursive(list(range(min(A_dash), max(A_dash) + 1))))

Fixed submission:
# coding: utf-8
# Your code here!
 
import statistics
 
N = int(input())
A = list(map(int, input().rstrip().split(' ')))
 
A_dash = sorted([x - i - 1 for i, x in enumerate(A)])
med = int(statistics.median(A_dash))

print(sum([abs(x - med) for x in A_dash]))

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

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

A_dash = [x - i - 1 for i, x in enumerate(A)]

def recursive(X):
    if len(X) == 1:
        return sum([abs(x - X[0]) for x in A_dash])
    elif len(X) == 2:
        if sum([abs(x - X[1]) for x in A_dash]) - sum([abs(x - X[0]) for x in A_dash]) > 0:
            return sum([abs(x - X[0]) for x in A_dash])
        else:
            return sum([abs(x - X[1]) for x in A_dash])
        
    if sum([abs(x - X[len(X)//2]) for x in A_dash]) - sum([abs(x - X[len(X)//2 - 1]) for x in A_dash]) < 0:
        return recursive(X[len(X)//2:])
    else:
        return recursive(X[:len(X)//2 + 1])

print(recursive(list(range(min(A_dash), max(A_dash) + 1))))


Fixed submission:
# coding: utf-8
# Your code here!
 
import statistics
 
N = int(input())
A = list(map(int, input().rstrip().split(' ')))
 
A_dash = sorted([x - i - 1 for i, x in enumerate(A)])
med = int(statistics.median(A_dash))

print(sum([abs(x - med) for x in A_dash]))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

from collections import defaultdict

n = int(input())
x = [input() for _ in range(n)]
m = int(input())
y = [input() for _ in range(n)]

dx = defaultdict(int)
dy = defaultdict(int)

for temp_x in x:
    dx[temp_x] += 1
for temp_y in y:
    dy[temp_y] += 1
    
max_count = 0
for k in dx.keys():
    max_count = max(max_count, dx[k] - dy[k])
    
print(max_count)

Fixed submission:
# coding: utf-8
# Your code here!

from collections import defaultdict

n = int(input())
x = [str(input()) for _ in range(n)]
m = int(input())
y = [str(input()) for _ in range(m)]

dx = defaultdict(int)
dy = defaultdict(int)

for temp_x in x:
    dx[temp_x] += 1
for temp_y in y:
    dy[temp_y] += 1
    
max_count = 0
for k in dx.keys():
    max_count = max(max_count, dx[k] - dy[k])
    
print(max_count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= l[i]
if ans <= 10**18:
    print(ans)
else:
    print(-1)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
l.sort()
if l[0] == 0:
    print(0)
    exit()
ans = 1
for i in range(n):
    ans *= l[i]
    if ans > 10**18:
        print(-1)
        exit()
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= l[i]
if ans <= 10**18:
    print(ans)
else:
    print(-1)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
l.sort()
if l[0] == 0:
    print(0)
    exit()
ans = 1
for i in range(n):
    ans *= l[i]
    if ans > 10**18:
        print(-1)
        exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque

n, m = map(int, input().split())
l = [[] for i in range(n + 1)]
for i in range(m):
    a, b = map(int, input().split())
    l[a].append(b)
    l[b].append(a)
ans = [0] * (n + 1)
f = [0] * (n + 1)
d = deque()
d.append(1)
print(len(d))
while len(d) > 0:
    print(d)
    k = d.popleft()
    f[k] = 1
    for i in l[k]:
        if f[i] == 1:
            continue
        ans[i] = k
        d.append(i)
        f[i] = 1
for i in range(2, n + 1):
    if ans[i] == 0:
        print("No")
        exit()
print("Yes")
for i in range(2, n + 1):
    print(ans[i])

Fixed submission:
from collections import deque

n, m = map(int, input().split())
l = [[] for i in range(n + 1)]
for i in range(m):
    a, b = map(int, input().split())
    l[a].append(b)
    l[b].append(a)
ans = [0] * (n + 1)
f = [0] * (n + 1)
d = deque()
d.append(1)
while len(d) > 0:
    k = d.popleft()
    f[k] = 1
    for i in l[k]:
        if f[i] == 1:
            continue
        ans[i] = k
        d.append(i)
        f[i] = 1
for i in range(2, n + 1):
    if ans[i] == 0:
        print("No")
        exit()
print("Yes")
for i in range(2, n + 1):
    print(ans[i])
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
f = [0] * n
f[0] = 1
s, g = 0, 0
j = a[0] - 1
jpre = 0
c = 1
i = 0
while True:
    if i >= n:
        break
    if f[j] != 0:
        s = jpre
        g = j
        break
    else:
        f[j] = c
        c += 1
        jpre = j
        j = a[j] - 1
    i += 1
f[0] = 0
ans = (k - g) % (s - g) + f[g]
for i in range(n):
    if f[i] == ans:
        print(i + 1)
        break

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
f = [-1] * n
f[0] = 0
s1, s2, g1, g2 = 0, 0, 0, 0
j = a[0] - 1
jpre = 0
c = 1
i = 0
while True:
    if i >= k:
        s1, s2 = f[jpre], jpre
        g1, g2 = 0, 0
        break
    if f[j] != -1:
        s1, s2 = f[jpre], jpre
        g1, g2 = f[j], j
        break
    else:
        f[j] = c
        c += 1
        jpre = j
        j = a[j] - 1
    i += 1
ans = (k - g1) % (s1 - g1 + 1) + f[g2]
for i in range(n):
    if f[i] == ans:
        print(i + 1)
        break
Buggy python submission (verdict: Runtime Error):
a, b, x = map(int, input())
print(a * (b - 1) // b)

Fixed submission:
a, b, n = map(int, input().split())
print(a * min(n, b - 1) // b)

Buggy python submission (verdict: Runtime Error):
a, b, x = map(int, input())
print(b - 1)

Fixed submission:
a, b, n = map(int, input().split())
print(a * min(n, b - 1) // b)
Buggy python submission (verdict: Time Limit Exceeded):
import math

k = int(input())
sum = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        for m in range(1, k + 1):
            sum += math.gcd(math.gcd(i, j), m)
print(sum)

Fixed submission:
from math import gcd

k = int(input())
sum = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        for m in range(1, k + 1):
            sum += gcd(gcd(i, j), m)
print(sum)

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

k = int(input())
sum = 0
for i in range(k):
    for j in range(k):
        for m in range(k):
            sum += math.gcd(math.gcd(i + 1, j + 1), m + 1)
print(sum)



Fixed submission:
from math import gcd

k = int(input())
sum = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        for m in range(1, k + 1):
            sum += gcd(gcd(i, j), m)
print(sum)

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

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

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

k = int(input())
sum = 0
for i in range(k):
    for j in range(k):
        for m in range(k):
            sum += gcd(i + 1, j + 1, m + 1)
print(sum)



Fixed submission:
from math import gcd

k = int(input())
sum = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        for m in range(1, k + 1):
            sum += gcd(gcd(i, j), m)
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
c = s.count('R') * s.count('G') * s.count('B')
for i in range(n):
    for j in range(i + 1, n):
        if s[i] == s[j]:
            continue
        for k in range(j + 1, n):
            if s[j] == s[k] or s[k] == s[i]:
                continue
            if j - i == k - j:
                c -= 1
print(c)

Fixed submission:
n = int(input())
s = input()
c = s.count('R') * s.count('G') * s.count('B')
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        k = j + (j - i)
        if k >= n:
            continue
        if s[i] == s[j] or s[j] == s[k] or s[k] == s[i]:
            continue
        c -= 1
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
c = 0
for i in range(len(s) - 2):
    for j in range(i + 1, len(s) - 1):
        if s[i] == s[j]:
            continue
        for k in range(j + 1, len(s)):
            if j - i == k - j:
                continue
            if s[j] != s[k] and s[k] != s[i]:
                c += 1
print(c)

Fixed submission:
n = int(input())
s = input()
c = s.count('R') * s.count('G') * s.count('B')
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        k = j + (j - i)
        if k >= n:
            continue
        if s[i] == s[j] or s[j] == s[k] or s[k] == s[i]:
            continue
        c -= 1
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
c = 0
for i in range(len(s) - 2):
    for j in range(i + 1, len(s) - 1):
        for k in range(j + 1, len(s)):
            if j - i == k - j:
                continue
            if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                c += 1
print(c)

Fixed submission:
n = int(input())
s = input()
c = s.count('R') * s.count('G') * s.count('B')
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        k = j + (j - i)
        if k >= n:
            continue
        if s[i] == s[j] or s[j] == s[k] or s[k] == s[i]:
            continue
        c -= 1
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = map(int, input().split())
l = list('')
while len(l) <= n:
    for i in range(a):
        l.append('blue')
    for i in range(b):
        l.append('red')
count = 0
for i in range(n):
    if l[i] == 'blue':
        count += 1
print(count)

Fixed submission:
n, a, b = map(int, input().split())
mod = int(n % (a + b))
cycle = n // (a + b)
if mod == 0:
    print(a * cycle)
elif mod > a:
    print(a * cycle + a)
else: 
    print(a * cycle + mod)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

d = deque(list(input()))
q = int(input())
flag = 1
for i in range(q):
    query = input().split()
    if query[0] == '1':
        flag = - flag
    elif query[0] == '2':
        if flag == 1:
            if query[1] == '1':
                d.appendleft(query[2])
            elif query[1] == '2':
                d.append(query[2])
        else:
            if query[1] == '1':
                d.append(query[2])
            elif query[1] == '2':
                d.appendleft(query[2])
if flag == -1:
    d.reverse()
ans = ''
l = len(d)
for i in range(l):
    ans += d[i]
print(ans)

Fixed submission:
from collections import deque

d = deque(list(input()))
q = int(input())
flag = 1
for i in range(q):
    query = input().split()
    if query[0] == '1':
        flag = - flag
    elif query[0] == '2':
        if flag == 1:
            if query[1] == '1':
                d.appendleft(query[2])
            elif query[1] == '2':
                d.append(query[2])
        else:
            if query[1] == '1':
                d.append(query[2])
            elif query[1] == '2':
                d.appendleft(query[2])
if flag == -1:
    d.reverse()
print(''.join(list(d)))

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

s = list(input())
q = int(input())
d = deque(s)
flag = 1
for i in range(q):
    query = input().split()
    if query[0] == '1':
        flag = - flag
    elif query[0] == '2':
        if flag == 1:
            if query[1] == '1':
                d.appendleft(query[2])
            elif query[1] == '2':
                d.append(query[2])
        else:
            if query[1] == '1':
                d.append(query[2])
            elif query[1] == '2':
                d.appendleft(query[2])
if flag == -1:
    d.reverse()
ans = ''
l = len(d)
for i in range(l):
    ans += d[i]
print(ans)

Fixed submission:
from collections import deque

d = deque(list(input()))
q = int(input())
flag = 1
for i in range(q):
    query = input().split()
    if query[0] == '1':
        flag = - flag
    elif query[0] == '2':
        if flag == 1:
            if query[1] == '1':
                d.appendleft(query[2])
            elif query[1] == '2':
                d.append(query[2])
        else:
            if query[1] == '1':
                d.append(query[2])
            elif query[1] == '2':
                d.appendleft(query[2])
if flag == -1:
    d.reverse()
print(''.join(list(d)))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list("")
for i in range(n):
    l.append(input())
s = list(set(l))
s.sort()
max = 0
a = list("")
for i in range(len(s)):
    c = l.count(s[i])
    a.append(c)
    if c > max:
        max = c
for i in range(len(s)):
    if a[i] == max:
        print(s[i])

Fixed submission:
from collections import Counter

n = int(input())
l = list("")
for i in range(n):
    l.append(input())
c = Counter(l)
c = c.most_common()
max = c[0][1]
a = list("")
for i in range(len(c)):
    if c[i][1] == max:
        a.append(c[i][0])
    else:
        break
a.sort()
for i in range(len(a)):
    print(a[i])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l, s = list(""), list("")
for i in range(n):
    l.append(input())
s = list(set(l))
max = 0
a = list("")
for i in range(len(s)):
    if l.count(s[i]) > max:
        max = l.count(s[i])
        a.clear()
        a.append(s[i])
    elif l.count(s[i]) == max:
        a.append(s[i])
a.sort()
for i in range(len(a)):
    print(a[i])

Fixed submission:
from collections import Counter

n = int(input())
l = list("")
for i in range(n):
    l.append(input())
c = Counter(l)
c = c.most_common()
max = c[0][1]
a = list("")
for i in range(len(c)):
    if c[i][1] == max:
        a.append(c[i][0])
    else:
        break
a.sort()
for i in range(len(a)):
    print(a[i])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))
max = 0
x = 0
for i in range(n - k + 1):
    s = sum(p[i : i + k])
    if s > max:
        max = s
        x = i
ans = 0
for i in range(x, x + k):
    ans += (p[i] + 1) / 2
print('{:.12f}'.format(ans))

Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split()))
s = max = sum(p[0 : k])
x = 0
for i in range(0, n - k):
    s = s - p[i] + p[i + k]
    if s > max:
        max = s
        x = i + 1
ans = 0
for i in range(x, x + k):
    ans += (p[i] + 1) / 2
print('{:.12f}'.format(ans))
Buggy python submission (verdict: Runtime Error):
h, n = map(int, input().split())
l = list(map(int, input().split()))
if h > sum(l):
    print("No")
else:
    print("Yes")

Fixed submission:
h, a = map(int, input().split())
count = 0
while h > 0:
    h -= a
    count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
s = input()
print(chr(ord(s + 1)))

Fixed submission:
s = input()
print(chr(ord(s) + 1))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
l = list("")
ac, wa = 0, 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if l[p - 1] != -1 and s == "AC":
        ac += 1
        wa += l[p - 1]
        l[p - 1] = -1
    if l[p - 1] != -1 and s == "WA":
        l[p - 1] += 1
print(ac, wa)

Fixed submission:
n, m = map(int, input().split())
l = [0] * n
ac, wa = 0, 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if l[p - 1] != -1 and s == "AC":
        ac += 1
        wa += l[p - 1]
        l[p - 1] = -1
    if l[p - 1] != -1 and s == "WA":
        l[p - 1] += 1
print(ac, wa)
Buggy python submission (verdict: Runtime Error):
from math import gcd

a, b = map(int, input().split())
print(int(a * b / gcd(a, b)))

Fixed submission:
from fractions import gcd
a, b = map(int, input().split())
print(a * b // gcd(a, b))

Buggy python submission (verdict: Runtime Error):
from math import gcd

a, b = map(int, input().split())
print(int(a * b / gcd(a, b)))

Fixed submission:
from fractions import gcd
a, b = map(int, input().split())
print(a * b // gcd(a, b))

Buggy python submission (verdict: Runtime Error):
from math import gcd

a, b = map(int, input().split())
print(int(a * b / gcd(a, b)))

Fixed submission:
from fractions import gcd
a, b = map(int, input().split())
print(a * b // gcd(a, b))

Buggy python submission (verdict: Runtime Error):
n = int(input())
s, t = input().split()
a = ''
for i in range(n):
    a += s[i] + t[i]
print(a)

Fixed submission:
from fractions import gcd
a, b = map(int, input().split())
print(a * b // gcd(a, b))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
l.sort()
c = 0
for i in range(n - 2):
    x = l[i]
    for j in range(i + 1, n - 1):
        y = l[j]
        for k in range(j + 1, n):
            if x + y <= l[k]:
                break    
            c += 1
print(c)

Fixed submission:
import bisect

n = int(input())
l = list(map(int, input().split()))
l.sort()
c = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):   
        c += bisect.bisect_left(l, l[i] + l[j]) - j - 1
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
l.sort()
c = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        for k in range(j + 1, n):
            if l[i] + l[j] <= l[k]:
                break    
            c += 1
print(c)

Fixed submission:
import bisect

n = int(input())
l = list(map(int, input().split()))
l.sort()
c = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):   
        c += bisect.bisect_left(l, l[i] + l[j]) - j - 1
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
l.sort(reverse = True)
c = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        for k in range(j + 1, n):
            if l[j] + l[k] > l[i]:
                c += 1
print(c)

Fixed submission:
import bisect

n = int(input())
l = list(map(int, input().split()))
l.sort()
c = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):   
        c += bisect.bisect_left(l, l[i] + l[j]) - j - 1
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
for i in range(n - 1):
    ans += i + 1
print(ans)

Fixed submission:
n = int(input())
if n % 2 == 1:
    print(n * (n // 2))
else:
    print((n * n - n) // 2)