Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, X, Y = map(int, input().split())
X -= 1
Y -= 1
if X > Y:
    X, Y = Y, X

ans = [0] * (N - 1)
for i in range(N - 1):
    for j in range(i + 1, N):
        ij = j - i
        ix = abs(i - X)
        iy = abs(i - Y)
        jx = abs(j - X)
        jy = abs(j - Y)

        minn = ij
        minn = min(minn, ix + 1 + jy)
        minn = min(minn, iy + 1 + jx)

        ans[minn - 1] += 1

for i in ans:
    print(i)

Fixed submission:
N, X, Y = map(int, input().split())
X -= 1
Y -= 1
if X > Y:
    X, Y = Y, X

ans = [0] * (N - 1)
for i in range(N - 1):
    for j in range(i + 1, N):
        ij = j - i
        ix = abs(i - X)
        iy = abs(i - Y)
        jx = abs(j - X)
        jy = abs(j - Y)

        minn = ij
        minn = min(minn, ix + 1 + jy)
        minn = min(minn, iy + 1 + jx)

        ans[minn - 1] += 1

for i in ans:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
N, X, Y = map(int, input().split())
X -= 1
Y -= 1
if X > Y:
    X, Y = Y, X

ans = [0] * (N - 1)
for i in range(N - 1):
    minn = 9999999999
    for j in range(i + 1, N):
        ij = abs(i - j)
        ix = abs(i - X)
        iy = abs(i - Y)
        jx = abs(j - X)
        jy = abs(j - Y)

        minn = ij
        minn = min(minn, ix + 1 + jy)
        minn = min(minn, iy + 1 + jx)

        ans[minn - 1] += 1

for i in ans:
    print(i)

Fixed submission:
N, X, Y = map(int, input().split())
X -= 1
Y -= 1
if X > Y:
    X, Y = Y, X

ans = [0] * (N - 1)
for i in range(N - 1):
    for j in range(i + 1, N):
        ij = j - i
        ix = abs(i - X)
        iy = abs(i - Y)
        jx = abs(j - X)
        jy = abs(j - Y)

        minn = ij
        minn = min(minn, ix + 1 + jy)
        minn = min(minn, iy + 1 + jx)

        ans[minn - 1] += 1

for i in ans:
    print(i)
Buggy python submission (verdict: Runtime Error):
# li = [[0] * 4 for i in range(3)]

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

N, P = map(int, input().split())

S = input()


memo = {}


def dfs(n):
    # print(n)
    if n in memo:
        return memo[n]

    i = n + 1
    while i <= N:
        temp_int = int(S[n:i])
        # print(temp_int)
        if temp_int % P == 0:
            memo[n] = 1 + dfs(i)
            return memo[n]

        i += 1
    return 0


ans = 0
for i in range(N):
    temp = dfs(i)
    ans += temp

print(ans)


Fixed submission:
N, P = map(int, input().split())
S = input()
now = 0
hyou = [0] * P
hyou[0] = 1
cnt = 1
ans = 0

if P == 2 or P == 5:
    for i, t in enumerate(S[::-1]):
        temp = int(t)
        if temp % P == 0:

            ans += N - i
    print(ans)
    exit()

for i, t in enumerate(S[::-1]):
    now = (now + int(t) * pow(10, i, P)) % P
    ans += hyou[now]
    hyou[now] += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# li = [[0] * 4 for i in range(3)]

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

N, P = map(int, input().split())

S = input()


memo = {}


def dfs(n):
    if n in memo:
        return memo[n]

    i = n + 1
    while i <= N:
        temp_int = int(S[n:i])
        if temp_int % P == 0:
            if temp_int == 0:
                continue

            memo[n] = 1 + dfs(i)
            return memo[n]

        i += 1
    return 0


ans = 0
for i in range(N):
    temp = dfs(i)
    ans += temp

print(ans)



Fixed submission:
N, P = map(int, input().split())
S = input()
now = 0
hyou = [0] * P
hyou[0] = 1
cnt = 1
ans = 0

if P == 2 or P == 5:
    for i, t in enumerate(S[::-1]):
        temp = int(t)
        if temp % P == 0:

            ans += N - i
    print(ans)
    exit()

for i, t in enumerate(S[::-1]):
    now = (now + int(t) * pow(10, i, P)) % P
    ans += hyou[now]
    hyou[now] += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

state = [[-1] * N for i in range(N)]
for index in range(N):
    Ai = int(input())
    for naka in range(Ai):
        x, y = map(int, input().split()) 
        state[index][x - 1] = y
        # state[index][naka] = [x, y]


# print(state)


maxx = 0
for index in range(2 ** N):
    # print(index)
    person = index
    tempM = 0
    Ai = 0
    ok = 1
    while person > 0:
        if person % 2 == 1:
            tempM += 1
            for i in range(N):
                if state[Ai][i] != -1:
                    # print(str(Ai) + " " + str(i))
                    # print(str(state[Ai][i]) + " " + str((index // (2 ** i)) % 2))
                    # print()
                    if state[Ai][i] != (index // (2 ** i)) % 2:
                        ok = 0
                
        
        person //= 2
        Ai += 1
    
    if ok == 1:
        maxx = max(maxx, tempM)

print(maxx)

Fixed submission:
N = int(input())

state = [[-1] * N for i in range(N)]
for index in range(N):
    Ai = int(input())
    for naka in range(Ai):
        x, y = map(int, input().split()) 
        state[index][x - 1] = y
        # state[index][naka] = [x, y]


# print(state)


maxx = 0
for index in range(1, 2 ** N):
    # print(index)
    person = index
    tempM = 0
    Ai = 0
    ok = 1
    while person > 0:
        if ok == 0:
            break
        if person % 2 == 1:
            tempM += 1
            for i in range(N):
                if state[Ai][i] != -1:
                    # print(str(Ai) + " " + str(i))
                    # print(str(state[Ai][i]) + " " + str((index // (2 ** i)) % 2))
                    # print()
                    if state[Ai][i] != (index // (2 ** i)) % 2:
                        ok = 0
                        break
                
        
        person //= 2
        Ai += 1
    
    if ok == 1:
        maxx = max(maxx, tempM)

print(maxx)
Buggy python submission (verdict: Runtime Error):
N, K, Q = [int(e) for e in input().split()]
A = [0] * N

for index in range(Q):
    temp = int(input())
    A[temp - 1] += 1

for index in range(N):
    if A[index] > Q - K:
        print("Yes")
    else:
 

Fixed submission:
N, K, Q =  map(int, input().split())
A = [0] * N

for index in range(Q):
    temp = int(input())
    A[temp - 1] += 1

for index in range(N):
    if A[index] > Q - K:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
import math

s = int(input())

rot = int(math.sqrt(s) // 1)
if s == rot**2:
    print(f"0 0 0 {rot} 0 0 {rot}")
    exit()

rot += 1
ans = (rot**2) - s
print(f"0 0 {rot} 1 {ans} {rot}")


Fixed submission:
import math

s = int(input())

rot = int(math.sqrt(s) // 1)
if s == rot**2:
    print("0 0 " + str(rot) + " 0 0 " + str(rot))
    exit()

rot += 1
ans = (rot**2) - s
print("0 0 " + str(rot) + " 1 " + str(ans) + " " + str(rot))
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())

ansL = []
for i in range(5020):
    if L + i > R:
        break

    ansL.append((L + i) % 2019)

ans = []
for i in range(len(ansL)):
    for j in range(len(ansL)):
        if i == j:
            continue
        
        ans.append((ansL[i] * ansL[j]) % 2019)
        

ans = sorted(ans)
print(ans[0])

Fixed submission:
L, R = map(int, input().split())

ansL = []
for i in range(2019):
    if L + i > R:
        break

    ansL.append((L + i) % 2019)

ans = 999999
for i in range(len(ansL)):
    for j in range(i, len(ansL)):
        if i == j:
            continue
        
        ans = min([ans, ((ansL[i] * ansL[j] ) % 2019)])

print(ans)
Buggy python submission (verdict: Runtime Error):
a = input()
if a.isUpper():
  print('A')
else:
  print('a')

Fixed submission:
a = input()
if a.isupper():
  print('A')
else:
  print('a')
Buggy python submission (verdict: Runtime Error):
K = int(input())
S = input()

n = len(s)
if n > K:
  print(S)
else:
  print(S[0:K+1]+'...')

Fixed submission:
K = int(input())
S = input()

n = len(S)
if n <= K:
    print(S)
else:
    print(S[0:K] + '...')
Buggy python submission (verdict: Runtime Error):
a = int(input())
c['AC'] = c['WA'] = c['TLE'] = c['RE'] = 0
for _ in range(a):
  c[input()]+=1
print('AC x ', en = '')
print(c['AC'])

print('WA x ', en = '')
print(c['WA'])

print('TLE x ', en = '')
print(c['TLE'])

print('RE x ', en = '')
print(c['RE'])

Fixed submission:
a = int(input())
c = {}
c['AC'] = c['WA'] = c['TLE'] = c['RE'] = (int)(0)
for _ in range(a):
  c[input()]+=1
print('AC x ', end = '')
print(c['AC'])

print('WA x ', end = '')
print(c['WA'])

print('TLE x ', end = '')
print(c['TLE'])

print('RE x ', end = '')
print(c['RE'])
Buggy python submission (verdict: Runtime Error):
x, y = [int(x) for x in input().split()]
if 4 * x >= y and (y%4 ==0 or (y %2 == 0 and (y-2)%4==0)):
  print("Yes")
else:
  print("No")


Fixed submission:
a = [int(x) for x in input().split()]
for i in range(5):
  if a[i] == 0:
    print(i+1)
    exit(0)
Buggy python submission (verdict: Runtime Error):
X, N = map(int, input().split())
p = list(map(int, input().split()))
for d in range(X + 1):
  for s in [-1, +1]: a=X+s*d
    if p.count(a) == 0:
      print(a)
      exit(0)


Fixed submission:
X, N = map(int, input().split())
p = list(map(int, input().split()))
for d in range(X + 1):
  for s in [-1, +1]: 
    a=X+s*d
    if p.count(a) == 0:
      print(a)
      exit(0)

Buggy python submission (verdict: Runtime Error):
X, N = map(int, input().split())
p = list(map(int, input().split()))
for d in range(X + 1):
  for s in [-1, +1]: a=X+s*d
    if p.count(a) == 0:
      print(a)
      exit(0)

Fixed submission:
X, N = map(int, input().split())
p = list(map(int, input().split()))
for d in range(X + 1):
  for s in [-1, +1]: 
    a=X+s*d
    if p.count(a) == 0:
      print(a)
      exit(0)
Buggy python submission (verdict: Time Limit Exceeded):
import math
n=int(input())
b=1
a=list(map(int,input().split()))
x=1000000000000000000
for i in range(n):
    if(a[i]==0):
        print(0)
        exit(0);
    b=b*a[i]

if(b>x):
    b=-1
print(b);


Fixed submission:
import math
n=int(input())
b=1
a=list(map(int,input().split()))
x=1000000000000000000
for i in range(n):
    if(a[i]==0):
        print(0)
        exit(0);

for i in range(n):
    b=b*a[i]
    if(b>x):
        print(-1)
        exit(0)

print(b);

Buggy python submission (verdict: Time Limit Exceeded):
import math
n=int(input())
b=1
a=list(map(int,input().split()))
for i in range(n):
    b=b*a[i]
x=math.pow(10,18)
if(b>x):
    b=-1
print(b);

Fixed submission:
import math
n=int(input())
b=1
a=list(map(int,input().split()))
x=1000000000000000000
for i in range(n):
    if(a[i]==0):
        print(0)
        exit(0);

for i in range(n):
    b=b*a[i]
    if(b>x):
        print(-1)
        exit(0)

print(b);
Buggy python submission (verdict: Time Limit Exceeded):
import copy

arrays = []
n,m,q = 0,0,0

def main():
    global n, m, q
    global arrays
    n, m, q = map(int, input().split())
    abcd = [list(map(int, input().split())) for _ in range(q)]
    ans = 0
    dfs([], 1)
    for array in arrays:
        tmp = 0
        for i in range(q):
            if array[abcd[i][1]-1] - array[abcd[i][0]-1] == abcd[i][2]:
                tmp += abcd[i][3]
        ans = max(ans, tmp)
    print(ans)

def dfs(stack, i):
    stack.append(i)
    if len(stack) == n:
        arrays.append(copy.deepcopy(stack))
        if i < m:
            stack.pop()
            dfs(copy.deepcopy(stack), i + 1)
        return
    dfs(copy.deepcopy(stack), i)
    if i < m:
        stack.pop()
        dfs(copy.deepcopy(stack), i + 1)

if __name__ == '__main__':
    main()


Fixed submission:
import copy

arrays = []
n,m,q = 0,0,0

def main():
    global n, m, q
    global arrays
    n, m, q = map(int, input().split())
    abcd = [list(map(int, input().split())) for _ in range(q)]
    ans = 0
    dfs([], 1)
    for array in arrays:
        tmp = 0
        for i in range(q):
            if array[abcd[i][1]-1] - array[abcd[i][0]-1] == abcd[i][2]:
                tmp += abcd[i][3]
        ans = max(ans, tmp)
    print(ans)

def dfs(stack, i):
    stack.append(i)
    if len(stack) == n:
        arrays.append(copy.deepcopy(stack))
        if i < m:
            stack.pop()
            dfs(copy.deepcopy(stack), i + 1)
        return
    dfs(copy.deepcopy(stack), i)
    if i < m:
        stack.pop()
        dfs(copy.deepcopy(stack), i + 1)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

def fact(n):
    fact = 1
    for i in range(1,n+1):
        fact *= i
    return fact

def combinations_count(n,r):
    return fact(n) // (fact(n - r) * fact(r))

def main():
    N = int(input())
    A = list(map(int, input().split()))
    c = Counter(A)
    comb = 0
    for i in c.values():
        if i >= 2:
            comb += combinations_count(i, 2)
    for i in range(N):
        print(comb - (c[A[i]] - 1))

if __name__ == '__main__':
    main()

Fixed submission:
from collections import Counter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    c = Counter(A)
    comb = 0
    for i in c.values():
        if i >= 2:
            comb += i*(i-1)//2
    for i in range(N):
        print(comb - (c[A[i]] - 1))

if __name__ == '__main__':
    main()

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

def fact(n):
    fact = 1
    for i in range(1,n+1):
        fact *= i
    return fact

def combinations_count(n,r):
    return fact(n) // (fact(n - r) * fact(r))

def main():
    N = int(input())
    A = list(map(int, input().split()))
    c = Counter(A)
    d = defaultdict(lambda:-1)
    for i in range(N):
        ans = 0
        if d[A[i]] != -1:
            ans += d[A[i]]
        else:
            c[A[i]] -= 1
            v = list(c.values())
            for j in v:
                if j >= 2:
                    ans += combinations_count(j, 2)
            d[A[i]] = ans
            c[A[i]] += 1
        print(ans)


if __name__ == '__main__':
    main()

Fixed submission:
from collections import Counter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    c = Counter(A)
    comb = 0
    for i in c.values():
        if i >= 2:
            comb += i*(i-1)//2
    for i in range(N):
        print(comb - (c[A[i]] - 1))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n,a,b = map(int,input().split())
    tmp = 1
    ans = 0
    for n,r in zip(range(n,-1,-1),range(1,n+1)):
        tmp = tmp*n//r
        if r != a and r != b:
            ans += tmp
    print(ans%(10**9+7))

if __name__ == '__main__':
    main()

Fixed submission:
def mod_comb(n,k,mod):
    result = 1
    for i in range(n-k+1,n+1):
        result *= i
        result %= mod
    for i in range(1,k+1):
        result *= pow(i,mod-2,mod)
        result %= mod
    return result


def main():
    n,a,b = map(int,input().split())
    mod = 10**9+7
    ans = pow(2,n,mod)-1
    ans = (ans - mod_comb(n,a,mod))%mod
    ans = (ans - mod_comb(n,b,mod))%mod
    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def DE(n):
    return float((float(n)+1)/2)

def main():
    N,K = map(int,input().split())
    p = list(map(DE,input().split()))
    ans = 0
    for i in range(N-K+1):
        ans = max(ans,sum(p[i:i+K]))
    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
def DE(n):
    return float((float(n)+1)/2)

def main():
    N,K = map(int,input().split())
    p = list(map(DE,input().split()))
    ans = 0
    tmp = [sum(p[:K])]
    for i in range(K,N):
        tmp.append(tmp[i-K]+p[i]-p[i-K])
    print(max(tmp))

if __name__ == '__main__':
    main()

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

def DE(n):
    return float((n+1)*(n/2)/n)

def main():
    N,K = map(int,input().split())
    p = list(map(int,input().split()))
    p = list(map(DE,p))
    ls = deque(p[:K])
    ans = sum(ls)
    for i in range(K,N):
        ls.append(p[i])
        ls.popleft()
        ans = max(ans,sum(ls))
    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
def DE(n):
    return float((float(n)+1)/2)

def main():
    N,K = map(int,input().split())
    p = list(map(DE,input().split()))
    ans = 0
    tmp = [sum(p[:K])]
    for i in range(K,N):
        tmp.append(tmp[i-K]+p[i]-p[i-K])
    print(max(tmp))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int,input().split()))
ans = 0
for i in range(N):
    flag = True
    for j in range(i):
        if P[i] > P[j]:
            flag = False
            break
    if flag:
        ans += 1
print(ans)

Fixed submission:
N = int(input())
P = list(map(int,input().split()))
ans = 0
minx = 10**9
for i in range(N):
    if minx > P[i]:
        ans += 1
        minx = P[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
from collections import Counter
N,M = map(int,input().split())
a = list(map(int,input().split()))
maxa = max(a)
i = 1
p = 1
while True:
    tmp = (i+0.5)*maxa
    if math.ceil(tmp) == math.floor(tmp):
        p = i
        break
    i += 1
lcm = 0
flag = False
for i in range(p,M+1):
    if flag:
        break
    for j in range(N):
        if flag:
            break
        tmp = i/a[j]
        if int(tmp)+0.5 != tmp:
            break
        if int(tmp)+0.5 == tmp and j == N-1:
            lcm = i
            flag = True
if lcm == 0:
    print(0)
else:
    ans = M/lcm
    print(math.ceil(math.floor(ans)/2))

Fixed submission:
from itertools import permutations
N = int(input())
P = "".join(list(map(str,input().split())))
Q = "".join(list(map(str,input().split())))
ls = permutations(list(range(1,N+1)))
ans = []
for i in list(ls):
    ans.append("".join(list(map(str,i))))
ans = sorted(ans)
a,b = 0,0
for i in range(len(ans)):
    if ans[i] == P:
        a = i+1
    if ans[i] == Q:
        b = i+1
print(abs(int(a)-int(b)))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
S = input()
comb = list(itertools.combinations(list(range(N)),3))
ans = []
for i in comb:
    pw = []
    for j in range(len(comb[0])):
        pw.append(S[i[j]])
    pw = "".join(pw)
    if pw not in ans:
        ans.append(pw)
print(len(ans))

Fixed submission:
N = int(input())
S = list(input())
pas = []
for i in range(10):
    for j in range(10):
        for k in range(10):
            pas.append(str(i)+str(j)+str(k))
ans = 0
for pw in pas:
    if pw[0] in S:
        ind = S.index(pw[0])
        tmp = S[ind+1:]
    else:
        continue
    if pw[1] in tmp:
        ind = tmp.index(pw[1])
        tmp = tmp[ind+1:]
    else:
        continue
    if pw[2] in tmp:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
tmp = 0
std = sum(A)/2
index = 0
while tmp < std:
    tmp += A[index]
    index += 1
print(abs(sum(a)-sum(b)))

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
mid = sum(A)/2
length = 0
i = 0
while True:
    if length >= mid:
        length = min(abs(length-mid),abs(length-mid-A[i-1]))+mid
        break
    length += A[i]
    i += 1
print(int(length-(sum(A)-length)))
Buggy python submission (verdict: Runtime Error):
import math
X,Y = map(int,input().split())
def comb(n,r):
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))
if (X+Y)%3 != 0:
    print(0)
else:
    n = int((2*Y-X)/3)
    m = int((2*X-Y)/3)
    if n < 0 or m < 0:
        print(0)
    else:
        print((comb(n+m,min([n,m])))%(10**9+7))

Fixed submission:
r = int(input())
print(int(r**2))

Buggy python submission (verdict: Runtime Error):
import math
X,Y = map(int,input().split())
def comb(n,r):
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))
if (X+Y)%3 != 0:
    print(0)
else:
    n = int((2*Y-X)/3)
    m = int((2*X-Y)/3)
    if n < 0 or m < 0:
        print(0)
    else:
        print((comb(n+m,min([n,m])))%(10**9+7))

Fixed submission:
r = int(input())
print(int(r**2))

Buggy python submission (verdict: Runtime Error):
import math
X,Y = map(int,input().split())
def comb(n,r):
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))
if (X+Y)%3 != 0:
    print(0)
else:
    n = int((2*Y-X)/3)
    m = int((2*X-Y)/3)
    print((comb(n+m,min([n,m])))%(10**9+7))

Fixed submission:
r = int(input())
print(int(r**2))
Buggy python submission (verdict: Runtime Error):
import itertools
N = int(input())
xy = [list(map(int,input().split())) for i in range(N)]
tmp = list(itertools.permutations(list(range(N)),N))
length = []
for i in range(len(tmp)):
    tmplen = ((xy[tmp[i][0]][0]-xy[tmp[i][1]][0])**2+(xy[tmp[i][0]][1]-xy[tmp[i][1]][1])**2)**(1/2)
    tmplen += ((xy[tmp[i][1]][0]-xy[tmp[i][2]][0])**2+(xy[tmp[i][1]][1]-xy[tmp[i][2]][1])**2)**(1/2)
    length.append(tmplen)
print(sum(length)/len(length))
print(xy)

Fixed submission:
import itertools
N = int(input())
xy = [list(map(int,input().split())) for i in range(N)]
tmp = list(itertools.permutations(list(range(N)),N))
length = []
for i in range(len(tmp)):
    tmplen = 0
    for j in range(N-1):
        tmplen += ((xy[tmp[i][j]][0]-xy[tmp[i][j+1]][0])**2+(xy[tmp[i][j]][1]-xy[tmp[i][j+1]][1])**2)**(1/2)
    length.append(tmplen)
print(sum(length)/len(length))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
L = map(int,input().split())
tmp = list(itertools.combinations(L,3))
ans = 0
for i in range(len(tmp)):
    if abs(tmp[i][1] - tmp[i][2]) < tmp[i][0]:
        if tmp[i][0] < (tmp[i][1] + tmp[i][2]):
            ans += 1
print(ans)

Fixed submission:
import itertools
import bisect
N = int(input())
L = sorted(list(map(int,input().split())))
ans = 0
for i in range(N-2):
    a = L[i]
    for j in range(i+1,N-1):
        b = L[j]
        ind_cmin = j+1
        ind_cmax = bisect.bisect_left(L,a+b)-1
        ans += ind_cmax - ind_cmin + 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
L = map(int,input().split())
tmp = list(itertools.combinations(L,3))
ans = 0
for i in range(len(tmp)):
    if abs(tmp[i][1] - tmp[i][2]) < tmp[i][0] < (tmp[i][1] + tmp[i][2]):
        ans += 1
print(ans)

Fixed submission:
import itertools
import bisect
N = int(input())
L = sorted(list(map(int,input().split())))
ans = 0
for i in range(N-2):
    a = L[i]
    for j in range(i+1,N-1):
        b = L[j]
        ind_cmin = j+1
        ind_cmax = bisect.bisect_left(L,a+b)-1
        ans += ind_cmax - ind_cmin + 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
L = map(int,input().split())
tmp = list(itertools.combinations(L,3))
ans = 0
for i in range(len(tmp)):
    if tmp[i][0] < (tmp[i][1] + tmp[i][2]):
        if tmp[i][1] < (tmp[i][0] + tmp[i][2]):
            if tmp[i][2] < (tmp[i][0] + tmp[i][1]):
                ans += 1
print(ans)

Fixed submission:
import itertools
import bisect
N = int(input())
L = sorted(list(map(int,input().split())))
ans = 0
for i in range(N-2):
    a = L[i]
    for j in range(i+1,N-1):
        b = L[j]
        ind_cmin = j+1
        ind_cmax = bisect.bisect_left(L,a+b)-1
        ans += ind_cmax - ind_cmin + 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
print(sum(list(range(1,N))))

Fixed submission:
N = int(input())
if N == 1:
    print(0)
elif N%2 != 0:
    print((1+(N-1))*((N-1)//2))
else:
    print((1+(N-1))*((N-1)//2)+(N-1)//2+1)