TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
import bisect

N = int(input())
L = list(map(int, input().split()))
L = sorted(L)

count = 0
for n in range(N-2):
    for m in range(n+1,N-1):
        count += bisect.bisect_left(L,L[m]-L[n]+1) -m-1

print(count)

import bisect

N = int(input())
L = list(map(int, input().split()))
L = sorted(L)

count = 0
for n in range(N-2):
    for m in range(n+1,N-1):
        count += bisect.bisect_left(L,L[m]+L[n]) -m-1

print(count)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
N=int(input())
L=list(map(int,input().split()))

def aaa(l):
    x=0
    a=l[0]
    b=l[1]
    c=l[2]
    if a+b>c:
        if b+c>a:
            if c+a>b:
                x=1
    return x
ans=0
for l in list(itertools.combinations(L, 3)):
    ans+=aaa(list(l))
print(ans)

import bisect
N=int(input())
L=sorted(list(map(int,input().split())))
ans=0
for i in range(N-2):
    for j in range(i+1,N-1):
        ab=L[i]+L[j]
        r=bisect.bisect_left(L,ab)
        l=j+1
        ans+=r-l
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
N = int(input())
L = list(map(int, input().split()))
L.sort()
cnt = 0
print(L)
for i in range(N - 1):
    for j in range(i + 1, N):
        k = j + 1
        while k<N:
            if L[i]+L[j]<=L[k]:
                cnt += k - j - 1
                break
            k += 1
        if k == N:
            cnt += k - 1 - j
print(cnt)

N = int(input())
L = list(map(int, input().split()))
L.sort()
import numpy as np
L = np.array(L)
m = [0] * (L[-1] + 10)
for i in range(L[-1] + 10):
    m[i] = np.count_nonzero(L <= i)
print(L)
print(m)
cnt = 0
for i in range(N):
    for j in range(i + 1, N):
        tot = L[i] + L[j]
        if tot >= len(m) + 1:
            tot = len(m) - 2
        cnt += m[tot + 1] - m[L[j] + 1]
        print(i,j,tot,m[tot + 1],m[L[j] + 1])
print(cnt)


N=int(input())
L=list(map(int,input().split()))
L.sort()
ans = 0
i = 0
while i < N - 2:
    j = i + 1
    k = j + 1
    while j < N - 1:
        while k < N:
            if L[i] + L[j] <= L[k]:
                ans += k - j - 1
                break
            k += 1
        if k == N:
            ans += k - 1 - j
        j += 1
    i += 1
print(ans)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
= int(input())
L = map(int, input().split())

import itertools
l = list(itertools.combinations(L, 3))

a = 0
n = 0

for x in range(len(l)):
  if max(l[n]) < sum(l[n]) - max(l[n]):
    a += 1
    n += 1
  else:
    n += 1
    
print(a)

n = int(input())
l = sorted(list(map(int, input().split())))
ans = 0
import bisect
for i in range(n-2):
    for j in range(i+1, n-1):
        ab = l[i]+l[j]
        idx = bisect.bisect_left(l, ab)
        ans += max(0, idx-j-1)
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
import itertools
n = int(input())
a = list(map(int,input().split()))
s = itertools.permutations(n,3)
count = 0
for i in range(len(s)):
  r = [a[s[0]],a[s[1]],a[s[2]]]
  if (sum(r) - max(r)) >= max(r):
    count += 1
print(count)

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

Verdicts: Runtime Error

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
n=int(input())
L=sorted(list(map(int,input().split())))
dp=[0]*n
M=[]
dp[2]=0 if L[0]+L[1]>L[2] else 1
if dp[2]==0:
  M.append(L[0]+L[1])
if n!=3:
    for i in range(3,n):
        dp[i]=dp[i-1]
        N=[]
        for m in M:
          if L[i]>=m:
            dp[i]+=1
          else:
            N.append(m)
        M=N
        for j in range(i-1):
            if L[i-1]+L[j]<=L[i]:
                dp[i]+=1
            else:
                M.append(L[i-1]+L[j])
print(n*(n-1)*(n-2)//6-sum(dp))
print(dp)

import bisect
n=int(input())
L=sorted(list(map(int,input().split())))
c=0
for i in range(n-1,1,-1):
    for j in range(i-1,0,-1):
        a=j-bisect.bisect(L,L[i]-L[j])
        if a>0:
            c+=a
print(c)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
N = int(input())

L = list(map(int, input().split()))

count = 0 
L.sort()

for i in range(N-2):
    k = i + 2
    for j in range(i+1,N):
        while (k<N and L[i] + L[j]):
            k += 1

        if k > j:
            count += k - j - 1


print(count)



N = int(input())

L = list(map(int, input().split()))

count = 0 
L.sort()

for i in range(N-2):
    k = i + 2
    for j in range(i+1,n):
        while (k<n and L[i] + L[j]):
            k += 1

        if k > j:
            count += k - j - 1


print(count)



N = int(input())

L = list(map(int, input().split()))

count = 0 
L.sort()

for i in range(N-2):
    k = i + 2
    for j in range(i+1,N):
        while (k<N and L[i] + L[j] > L[k]):
            k += 1

        if k > j:
            count += k - j - 1


print(count)



Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
n = int(input())
l = list(map(int,input().split()))
import bisect
l.sort()
count = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        count += bisect.bisect_left(l[j+1:],l[a]+l[b])
        # print(l,a,b,s)
print(count)

import sys
input = sys.stdin.radline
n = int(input())
l = list(map(int,input().split()))
import bisect
l.sort()
count = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        s = bisect.bisect_left(l[j+1:],l[a]+l[b])
        count += s
        # print(l,a,b,s)
print(count)

import sys
input = sys.stdin.readline
n = int(input())
l = list(map(int,input().split()))
import bisect
l.sort()
count = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        s = bisect.bisect_left(l[j+1:],l[a]+l[b])
        count += s
        # print(l,a,b,s)
print(count)

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

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
def main():
    N = int(input())
    rod_list = list(map(int, input().split()))

    pattern = set()

    for i in range(N):
        rod1 = rod_list[i]
        for j in range(i + 1, N):
            rod2 = rod_list[j]
            for k in range(j + 1, N):
                rod3 = rod_list[k]
                print(rod1, rod2, rod3)
                if rod1 >= rod2+rod3 or rod2 >= rod1+rod3 or rod3 >= rod1+rod2:
                    continue

                tmp = sorted([str(rod1), str(rod2), str(rod3)])
                if "-".join(tmp) in pattern:
                    continue

                pattern.add("-".join(tmp))

    print(len(pattern))


if __name__ == '__main__':
    main()


import bisect


def main():
    n = int(input())
    l = [int(i) for i in input().split()]

    l.sort()
    ans = 0

    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            ans += bisect.bisect_left(l, l[i] + l[j]) - j - 1

    print(ans)


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
N = int(input())
L = list(map(int, input().split()))

L.sort()

dp = [0]*(1005)
frm = 0
cnt = 0
Lcopy = [1001] + L[::-1]
while Lcopy:
  to = Lcopy.pop()
  for i in range(frm, to):
    dp[i] = cnt
  frm = to
  cnt += 1
  
ans = 0
b = 1
c = 2
while b < N-1:
  sub = L[c] - L[b]

  x = dp[L[b]-1] - dp[sub-1]
  if x > 0:
    ans += x
  else:
    b += 1
    c = b
    
  c += 1
  if c >= N:
    b += 1
    c = b + 1

print(ans)

from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))
 
L.sort()
 
ans = 0

for b in range(n):
  for a in range(b):
    ab = L[a] + L[b]
    r = bisect_left(L, ab)
    l = b + 1
    
    ans += r-l

print(ans)

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

L.sort()

dp = [0]*(1005)
frm = 0
cnt = 0
Lcopy = L[::-1]
while Lcopy:
  to = Lcopy.pop() + 1
  for i in range(frm, to):
    dp[i] = cnt
  frm = to
  cnt += 1
  
ans = 0
b = 1
c = 2
while b < N-1:
  sub = L[c] - L[b]

  x = dp[L[b]] - dp[min(sub, L[b])]
  if x > 0:
    ans += x
  else:
    b += 1
    c = b
    
  c += 1
  if c >= N:
    b += 1
    c = b + 1

print(ans)

N = int(input())
L = list(map(int, input().split()))
 
L.sort()
 
dp = [0]*(1005)
frm = 0
cnt = 0
Lcopy = [1001] + L[::-1]
while Lcopy:
  to = Lcopy.pop()
  for i in range(frm, to):
    dp[i] = cnt
  frm = to
  cnt += 1
  
ans = 0
b = 1
c = 2
while b < N-1:
  sub = L[c] - L[b]
 
  x = dp[L[b]-1] - dp[sub+1]
  if x > 0:
    ans += x
  else:
    b += 1
    c = b
    
  c += 1
  if c >= N:
    b += 1
    c = b + 1

print(ans)

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

L.sort()

dp = [0]*(1005)
frm = 0
cnt = 0
Lcopy = L[::-1]
while Lcopy:
  to = Lcopy.pop()
  for i in range(frm, to):
    dp[i] = cnt
  frm = to
  cnt += 1
  
ans = 0
b = 1
c = 2
while b < N-1:
  sub = L[c] - L[b]

  x = dp[L[b]-1] - dp[sub-1]
  if x > 0:
    ans += x
  else:
    b += 1
    c = b
    
  c += 1
  if c >= N:
    b += 1
    c = b + 1

print(ans)

from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))
 
L.sort()
 
ans = 0

for b in range(N):
  for a in range(b):
    ab = L[a] + L[b]
    r = bisect_left(L, ab)
    l = b + 1
    
    ans += r-l

print(ans)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
n = int(input())
l = list(map(int, input().split()))

l.sort(reverse=True)
ans = 0
for i in range(n-2):
    j = i+1
    k = n-1
    while (j < k):
        if l[i] - l[j] - l[k] <= 0:
            ans += k - j
            j += 1
        else:
            k -= 1

print(ans)


 

 


                                        




    




        


    







        



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

l.sort(reverse=True)
ans = 0
for i in range(n-2):
    j = i+1
    k = n-1
    while (j < k):
        if l[i] - l[j] - l[k] < 0:
            ans += k - j
            j += 1
        else:
            k -= 1

print(ans)


 

 


                                        




    




        


    







        



Verdicts: Wrong Answer

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
# -*- coding: utf-8 -*-

# input
N = int(input())
L = list(map(int, input().split()))

# solve
ans = 0
L.sort()
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        for k in range(k + 1, N):
            if L[k] < L[j] + L[i]:
                ans += 1

# output
print(ans)


# -*- coding: utf-8 -*-
import bisect

# input
N = int(input())
L = list(map(int, input().split()))

# solve
ans = 0
L.sort()
for i in range(N):
    for j in range(i + 1, N):
        r = bisect.bisect_left(L, L[i] + L[j])
        l = j + 1
        ans += max(0, r - l)

# output
print(ans)


Verdicts: Runtime Error

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
N=int(input())
L=[int(i) for i in input().split()]
L.sort()
count=0
for i in range(N-2):
    a=0
    for j in range(i+1,N-1):
        l=L[i]+L[j]
        if l<=L[j+1]:
            a=0
        elif l>L[N-1]:
            a=1
            break
        else:
            for k in range(j+1,N):
                if l>L[k]:
                    count+=1
                else:
                    break
    if a==1:
        b=N-j-1
        B=(b+1)*b//2
        count=count+B
    print(count)
print(count)

import bisect
N=int(input())
L=[int(i) for i in input().split()]
L.sort()
count=0
for i in range(N-2):
    a=0
    for j in range(i+1,N-1):
        l=L[i]+L[j]
        if l<=L[j+1]:
            a=0
        elif l>L[N-1]:
            a=1
            break
        else:
            idx=bisect.bisect_left(L,l)
            count=count+(idx-j-1)
    if a==1:
        b=N-j-1
        B=(b+1)*b//2
        count=count+B
print(count)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
N = int(input())
L = list(map(int,input().split()))
import bisect

L.sort()
ans = 0
 
for i in range(N-2):
  for j in range(i+1,N-1):
    ans += bisect.bisect_left(L,L[i]+L[j])
        
print(ans)

N = int(input())
L = list(map(int,input().split()))
import bisect
 
L.sort()
ans = 0
 
for i in range(N-2):
  for j in range(i+1,N-1):
    ans += bisect.bisect_left(L,L[i]+L[j])-(j+1)
    
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
# coding: utf-8

n = int(input().rstrip())
bo = [j * -1 for j in sorted([int(i) * -1 for i in input().rstrip().split(" ")])]

ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        canTriangle = True
        for k in range(j+1,n):
            if bo[j] + bo[k] < bo[i]:
                canTriangle = False
                break
            ans += 1
        if not canTriangle:
            break

print(ans)


# coding: utf-8
from bisect import bisect_left, bisect_right

n = int(input().rstrip())
bo = sorted([int(i) * -1 for i in input().rstrip().split(" ")])

ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        if j < int(i/2):
            break
        idx = bisect_left(bo, bo[i]-bo[j], j+1)
        ans += idx - j - 1

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
n = int(input())
length = list(map(int, input().split()))
length = sorted(length)
count = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(n-1, j+1, -1):
               if length[k] >= length[i]+length[j]:
                   pass
               else:
                   count += k-j+1
                   break
                
print(count)

import bisect
n = int(input())
length = list(map(int, input().split()))
length = sorted(length)
count = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        insert_index = bisect.bisect_left(length, length[i]+length[j])
                   count += insert_index-j               
print(count)

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

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
N = int(input())
d = list(map(int, input().split()))

s = 0
for i, di in enumerate(d):
    d2 = d[i+1:]
    for j, dj in enumerate(d2):
        d3 = d2[j+1:]
        for dk in d3:
            if (di < dj + dk) and (dj < di + dk) and (dk < di + dj):
                print(di, dj, dk)
                s += 1

print(s)

import bisect

n=int(input())
L=sorted(list(map(int,input().split())))

ans=0
for i in range(n-1):
  for j in range(i+1,n):
    idx=bisect.bisect_left(L,L[j]+L[i])
    ans+=max(0,idx-j-1)

    print(ans)

n = int(input())
L = list(map(int, input().split()))
ans = 0
c = 0

L.sort()

for i in range(n-2):
    for j in range(i+1, n):
        c = L[i]+L[j]
        l = j
        r = bisect.bisect_left(L, c, lo=l) -1
        ans += (r-l)

print(ans)

n = int(input())
L = list(map(int, input().split()))
ans = 0
c = 0

L.sort()

for i in range(n-2):
    for j in range(i+1, n):
        c = L[i]+L[j]
        l = j
        r = bisect.bisect_left(L, c, lo=l) -1
        ans += (r-l)

print(ans)

n = int(input())
L = list(map(int, input().split())
ans = 0
c = 0

L.sort()

for i in range(n-2):
  for j in range(i+1, n):
    c = L[i]+L[j]
    l = j
    r = bisect.bisect_left(L, c, lo=l) -1
    ans += (r-l)

print(ans)

import bisect

n=int(input())
L=sorted(list(map(int,input().split())))

ans=0
for i in range(n-1):
  for j in range(i+1,n):
    idx=bisect.bisect_left(L,L[j]+L[i])
    ans+=max(0,idx-j-1)

print(ans)

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):

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

L_sorted = sorted(L)

def bis(left, right, SrcList, value):
    if SrcList[left] > value:
        return -1
    elif SrcList[right] < value:
        return right
    while (left + 1 < right):
        mid = (left + right) // 2
        if SrcList[mid] < value:
            left = mid
        else:
            right = mid
    return left


count = 0
for i in range(0, N-2):
    for j in range(i+1,N-1):
        r = bis(j+1, N-1, L_sorted, L_sorted[i] + L_sorted[j])
        if r != -1:
            count += r-j

print(count)


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

L_sorted = sorted(L)

def bis(left, right, SrcList, value):
    if SrcList[left] >= value:
        return -1
    elif SrcList[right] < value:
        return right
    while (left + 1 < right):
        mid = (left + right) // 2
        if SrcList[mid] < value:
            left = mid
        else:
            right = mid
    return left


count = 0
for i in range(0, N-2):
    for j in range(i+1,N-1):
        r = bis(j+1, N-1, L_sorted, L_sorted[i] + L_sorted[j])
        if r != -1:
            print(i,j,r)
            count += r-j

print(count)

from bisect import bisect_left

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

L_sorted = sorted(L)

count = 0
for i in range(N):  
    for j in range(i+1, N):  # second shortest stick
        r = bisect_left(L_sorted, L_sorted[i] + L_sorted[j], j)
        count += r - j - 1

print(count)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
import bisect

n = int(input())
l = sorted(map(int, input().split())) + [float('INF')]

ans = 0
for i in range(2,n)[::-1]:
    for j in range(1,i)[::-1]:
        a = bisect.bisect_right(l, l[i] + l[j], 0, j)
        b = bisect.bisect_left(l, l[i] - l[j], 0, j)
        # print(l[i] + l[j], l[i] - l[j], l[i] , l[j], l[i] - l[j] < l[a], a, b, l[:j])
        ans += a - b
print(ans)


import bisect

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

ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        ans += bisect.bisect_left(l,l[j]+l[i])-j-1
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
N = int(input())
L = list( map( int, input().split() ) )

import bisect
L=sorted(L)
comb = 0
for a in range(N-2):
    for b in range(1+a,N-1):
        posIndex = bisect.bisect_left(L, L[a] + L[b])
        comb += N - posIndex if posIndex != 0 else 0
print(comb)

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

import bisect
L=sorted(L)
comb = 0
for a in range(N-2):
    for b in range(1+a,N-1):
        posIndex = bisect.bisect_left(L, L[a] + L[b])
        comb += posIndex - b - 1 if posIndex != 0 else 0
print(comb)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
import sys
from bisect import bisect_left
N=int(input())
L=list(map(int,input().split()))
L.sort()
total = 0
for i in range(N):
  for j in range(i + 1, N):
    a = L[i] - L[j]
    total += max(bisect_left(L, a) - j - 1, 0)

print(total)

import sys
from bisect import bisect_left
N=int(input())
L=list(map(int,input().split()))
L.sort()
total = 0
for i in range(N):
  for j in range(i + 1, N):
    a = L[i] + L[j]
    total += max(bisect_left(L, a) - j - 1, 0)

print(total)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
import bisect
n=int(input())
l=sorted(map(int,input().split()))
ans=0
for i in range(n):
  for j in range(i+1,n):
    idx=bisect.bisect_left(l,l[i]+l[j])
    ans=max(0,idx-j-1)
    
print(ans)

import bisect
n=int(input())
l=sorted(map(int,input().split()))
ans=0
for i in range(n):
  for j in range(i+1,n):
    idx=bisect.bisect_left(l,l[i]+l[j])
    ans+=max(0,idx-j-1)
    
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
N=int(input())
L=list(map(int,input().split()))
L.sort()
count = 0
for i in range(N):
  for j in range(i+1,N):
    summation = L[i] + L[j]
    subtract  = L[j] - L[i]
    D=L.copy()
    E=[ D[k] for k in range(N) if k!= i and k!= j ]
    
    high = N-3
    low = 0
    if E[0] >= summation:
      upper = 0 
      #print(L[i],L[j],E,upper)
    elif E[-1] < summation:
      upper = N-2 
    else:
      while high > low+1:
        mid =(high + low) // 2
        if E[mid] >= summation: 
          high = mid
          # mid = low
        else: 
          low = mid
          # mid =high 
      upper = high
    #print("summation",summation,E,upper)
    
    high = N-3
    low = 0
    if E[0] > subtract:
      lower = 0 
    elif E[-1] <= subtract:
      lower = N-2 
    else:
      while high > low+1:
        mid =(high + low) // 2
        if E[mid] > subtract: 
          high = mid
          # mid = low
        else: 
          low = mid 
          # mid =high 
      lower = high
    #print("subtract",subtract,E,lower)
    count += upper - lower
print(count/3)  

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

Verdicts: Wrong Answer

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
import bisect
N = int(input())
dlist = list(map(int, input().split()))

sum = 0
count_b = 0
count_c = 0
for a in range(N):
    count_b = count_b + 1
    for b in range(count_b, N):
        sum += bisect.bisect_left(dlist,dlist[a] - dlist[b]) 
print(sum-1)


N = int(input())
dlist = list(map(int, input().split()))
dlist.sort(reverse=True)
sum = 0
N_2 = 2 ** N
for i in range(N_2):
    if bin(i).count('1') == 3:
        bin_i = bin(i)
        i_2 = bin_i.split('0b')[1]
        if len(i_2) < N:
            N_i = (N - len(i_2))
            N_0 = '0' * N_i
            i_2 = N_0 + i_2
        a_find = i_2.find('1')
        b_find = i_2.find('1',a_find + 1)
        c_find = i_2.find('1',b_find + 1)
        a = dlist[a_find]
        b = dlist[b_find]
        c = dlist[c_find]
        if a < b + c:
            sum += 1
print(sum

import bisect
N=int(input())
L=sorted(list(map(int,input().split())))

ans=0
for i in range(N-2):
  for j in range(i+1,N-1):
    ans+=bisect.bisect_left(L,L[i]+L[j])-j-1 # Code 1 
    # ans+=bisect.bisect_left(L,L[i]+L[j],j)-j-1 # Code 2 
print(ans)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
from bisect import bisect_left
n = int(input())
l = [int(i) for i in input().split()]
l.sort()
ans = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    ans += 1
print(ans)


from bisect import bisect_left
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for a in range(n-2):
    for b in range(a+1, n-1):
        ans += bisect_left(l, l[a]+l[b]) - b - 1
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
import itertools

n = int(input())

l = list(map(int, input().split()))

zzz = list(itertools.combinations(l,2))


cnt = 0
print(zzz)

for z in zzz:

    b = z[0]
    c = z[1]

    b_flg = True

    c_flg = True

    for i in l:
        if b_flg and i == b:
            continue

        if c_flg and i == c:
            continue
                
        if abs(b-c) < i < b+c:
            cnt += 1

print(cnt / 3)


import itertools

n = int(input())

l = list(map(int, input().split()))

zzz = list(itertools.combinations(l,2))


cnt = 0

for z in zzz:

    b = z[0]
    c = z[1]

    b_flg = True

    c_flg = True

    for i in l:
        if b_flg and i == b:
            continue

        if c_flg and i == c:
            continue
                
        if abs(b-c) < i < b+c:
            cnt += 1

print(cnt / 3)


import bisect

n = int(input())

l = list(map(int, input().split()))

l.sort()

cnt = 0

for i in range(n):
    for j in range(i):
        cnt += bisect.bisect_left(l,l[i]+l[j]) - (i + 1)

print(cnt)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
N = int(input())
Ls = list(map(int, input().split()))
Ls.sort()

ans = 0
for a_i in range(N):
  for b_i in range(a_i+1, N):
    c_i = bisect.bisect_left(Ls, Ls[a_i]+Ls[b_i])
    if c_i > b_i:
　     ans += c_i - b_i - 1
    else:
       pass
print(ans)

   Ls = list(map(int, input().split()))
    Ls.sort()

    
    ans = 0
    for a_i in range(N):
        for b_i in range(a_i+1, N):
            c_i = bisect.bisect_left(Ls, Ls[a_i]+Ls[b_i])
            if c_i > b_i:
                ans += c_i - b_i - 1
            else:
                pass

    print(ans)

import bisect

def solve():
    N = int(input())
    Ls = list(map(int, input().split()))
    Ls.sort()

    
    ans = 0
    for a_i in range(N):
        for b_i in range(a_i+1, N):
            c_i = bisect.bisect_left(Ls, Ls[a_i]+Ls[b_i])
            if c_i > b_i:
                ans += c_i - b_i - 1
            else:
                pass

    print(ans)

if __name__ == "__main__":
    solve()

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
n = int(input())
l = list(map(int, input().split()))
ans = 0

for i in range(n):
    for j in range(i, n - i):
        a = l[i]
        b = l[j]
        for k in range(j, n - i - j):
            c = l[k]
            if (a < b + c) and (b < c + a) and (c < a + b):
                ans += 1

print(ans)


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

for i in range(n):
    for j in range(i, n - i):
        a = l[i]
        b = l[j]
        for k in range(j, n - i - j):
            c = l[k]
            if (a < b + c) and (b < c + a) and (c < a + b):
                ans += 1

print(ans)


from bisect import bisect_left

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

ans = 0
l.sort()

for i in range(n):
    for j in range(i + 1, n):
        a = l[i]
        b = l[j]
        idx = bisect_left(l, a + b)
        # print(a, b, idx)

        ans += idx - (j + 1)


print(ans)


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
import bisect

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

total = 0
for a in range(n-2):
    for b in range(a+1, n-1):
        c = bisect.bisect_left(l, l[a] + l[b]) - b - 1
        total += c

print(total)

import itertools

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

for v in itertools.combinations(l, 3):
    pass

import bisect

n = int(input())
l = list(map(int, input().split()))
l.sort()

total = 0
for a in range(n-2):
    for b in range(a+1, n-1):
        c = bisect.bisect_left(l, l[a] + l[b]) - b - 1
        total += c

print(total)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
n = int(input())
L = sorted(list(map(int, input().split())))

ans = 0
for i in range(n-1, 1, -1):
    for j in range(i-1, 0, -1):
        ans += j - bisect.bisect_right(L[:j], L[i]-L[j])

print(ans)

import bisect

n = int(input())
L = sorted(list(map(int, input().split())))

ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        ans += bisect.bisect_left(L, L[i]+L[j]) - (j+1)

print(ans)


Verdicts: Runtime Error

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
import copy
import bisect
N = int(input())
L = list(map(int,input().split()))
count = 0
L.sort()
for i in range(N-2):
    for j in range(i+1,N-1):
        print(L[i])
        print(L[j])
        maxi = L[i] + L[j] -1
        mini = abs(L[i] - L[j]) +1
        print("maxi"+str(maxi)+"mini"+str(mini))
        cL = copy.copy(L)
        del cL[:j+1]
        print(cL)
        mi = bisect.bisect_left(cL,mini)
        ma = bisect.bisect_right(cL, maxi)
        print("mi"+str(mi)+"ma"+str(ma))
        if ma >= mi:
            count += ma-mi
print(count)


import copy
import bisect
N = int(input())
L = list(map(int,input().split()))
count = 0
L.sort()
for i in range(N-2):
    for j in range(i+1,N-1):
        print(L[i])
        print(L[j])
        maxi = L[i] + L[j] -1
        mini = abs(L[i] - L[j]) +1
        print("maxi"+str(maxi)+"mini"+str(mini))
        cL = copy.copy(L)
        del cL[:j+1]
        print(cL)
        mi = bisect.bisect_left(cL,mini)
        ma = bisect.bisect_right(cL, maxi)
        print("mi"+str(mi)+"ma"+str(ma))
        if ma >= mi:
            count += ma-mi
print(count)


import copy
import bisect
N = int(input())
L = list(map(int,input().split()))
count = 0
L.sort()
for i in range(N-2):
    for j in range(i+1,N-1):
        #print(L[i])
        #print(L[j])
        maxi = L[i] + L[j] -1
        mini = abs(L[i] - L[j]) +1
        #print("maxi"+str(maxi)+"mini"+str(mini))
        #cL = copy.copy(L)
        #print(cL)
        mi = bisect.bisect_left(L[:j+1],mini)
        ma = bisect.bisect_right(L[:j+1], maxi)
        #print("mi"+str(mi)+"ma"+str(ma))
        if ma >= mi:
            count += ma-mi
print(count)



import bisect
N = int(input())
L = list(map(int,input().split()))
count = 0
L.sort()
for i in range(N-2):
    for j in range(i+1,N-1):
        count += bisect.bisect(L,L[i]+L[j]-1)-j-1
print(count)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
from bisect import bisect_left
N=int(input())
L=list(map(int,input().split()))

L.sort()
a=0
for i in range(N-2):
    for j in range(i+1,N-1):
        a+=bisect_left(L,L[i]+L[j])-j-1
print(result)


N=int(input())
L=map(int, input().split())
a=0
for i in range(0,N-2,1):
  for j in range(i+1,N-1,1):
    for q in range(j+1,N,1):
        if L[i]<L[j]+L[q] and L[j]<L[i]+L[q] and L[q]<L[i]+L[j]:
          a+=1
print(a)

from bisect import bisect_left
N=int(input())
L=list(map(int,input().split()))

L.sort()
a=0
for i in range(N-2):
    for j in range(i+1,N-1):
        a+=bisect_left(L,L[i]+L[j])-j-1
print(a)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
import bisect

n=int(input())
L=list(map(int,input().split()))
L.sort()
count=0
print(L)

for i in range(n):
    for j in range(i+1,n):
        T=bisect.bisect_left(L,L[i]+L[j])
        count += T-j-1

print(count)

import bisect
 
n = int(input())
bar_list = list(map(int,input().split()))


bar_list.sort()

cnt = 0


for i in range(n):
    
    for j in range(i+1,n):
        
        x = bisect.bisect_left(bar_list,bar_list[i]+bar_list[j])
        
        
        cnt += x-j-1
 
print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	N := readInt()
	L := make([]int, N)
	for i := 0; i < N; i++ {
		L[i] = readInt()
	}

	sort.Sort(sort.IntSlice(L))
	result := 0
	for i := 0; i < N-2; i++ {
		for j := i + 1; j < N-1; j++ {
			result += sort.SearchInts(L, L[i]+L[j]) - j - 1
		}
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


from bisect import bisect_left

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

L.sort()
result = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        result += bisect_left(L, L[i] + L[j], j + 1) - j - 1
print(result)


Verdicts: Runtime Error

Accepted
Problem: Takahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.  He is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied:    * a < b + c   * b < c + a   * c < a + b  How many different triangles can be formed? Two triangles are considered different when there is a stick used in only one of them.

Submission attempts (in order):
from bisect import bisect
INF = float("inf")
N = int(input())
L = list(map(lambda x:int(x),input().split())) + [INF]
L.sort()
cnt = 0
print(*L)
for i in range(N-1):
    a = L[i]
    for j in range(i+1,N-1):
        b = L[j]
        c = bisect(L,a+b)
        cnt += c-j-1
print(cnt)

from bisect import bisect
INF = float("inf")
N = int(input())
L = list(map(lambda x:int(x),input().split())) + [INF]
L.sort()
cnt = 0
for i in range(N-1):
    a = L[i]
    for j in range(i+1,N-1):
        b = L[j]
        c = bisect(L,a+b)
        cnt += c-j-1
print(cnt)

from bisect import bisect_left
INF = float("inf")
N = int(input())
L = list(map(lambda x:int(x),input().split())) + [INF]
L.sort()
cnt = 0
print(*L)
for i in range(N-1):
    a = L[i]
    for j in range(i+1,N):
        b = L[j]
        c = bisect_left(L,a+b)
        cnt += max(0,c-j-1)
print(cnt)

from bisect import bisect_left
INF = float("inf")
N = int(input())
L = list(map(lambda x:int(x),input().split())) + [INF]
L.sort()
cnt = 0
for i in range(N-1):
    a = L[i]
    for j in range(i+1,N):
        b = L[j]
        c = bisect_left(L,a+b)
        cnt += max(0,c-j-1)
print(cnt)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted