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):
N = input()

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

A.sort()

ans = 0
for a in range(N-2):
    for b in range(a+1, N-1):
        for c in range(b+1, N):
            if A[c] < (A[a] + A[b]):
                ans += 1
            else:
                break

print(ans)

N = input()

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

A.sort()

ans = 0
for a in range(N-2):
    for b in range(a+1, N-1):
        for c in range(b+1, N):
            if A[c] < (A[a] + A[b]):
                ans += 1
                print(a, b, c)
            else:
                break

print(ans)

import bisect

N = int(input())

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

A.sort()

ans = 0
for a in range(N-2):
    for b in range(a+1, N-1):
        ans += bisect.bisect_left(A, A[a]+A[b])-j-1

print(ans)

import bisect

N = int(input())

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

A.sort()

ans = 0
for a in range(N-2):
    for b in range(a+1, N-1):
        ans += bisect.bisect_left(A, A[a]+A[b])-b-1

print(ans)

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):
n = int(input())
l = list(map(int, input().split()))
l.sort()
triangle = 0
while len(l) >= 3:
  max_l = l.pop()
  inf = -1
  for i in range(1, len(l)):
    rest_l = max_l - l[-i]
    sup = i
    while sup - inf > 1:
      x = (inf + sup) // 2
      if l[x] > rest_l:
        sup = x
      else:
        inf = x
    triangle += i - sup
print(triangle)

from bisect import bisect_left

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

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 -*-
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+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()


# -*- coding:utf-8 -*-
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

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())
S=list(map(int,input().split( )))
tri_sum = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        x = S[i] + S[j]
        for k in range(j+1,N):
            if S[k] < x:
                tri_sum = tri_sum + 1
print(tri_sum)

N=int(input())
S=list(map(int,input().split( )))
S = sorted(S)
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(N-1,j,-1):
            if S[i] + S[j] > S[k]:
                tri_sum = tri_sum + k-j
print(tri_sum)

N=int(input())
S=list(map(int,input().split( )))
S = sorted(S,reverse=True)
tri_num=0
for i in range(N-2):
    j = i+1
    k = N-1
    while k > j:
        if S[i] <= S[j] + S[k]:
            tri_num += k-j
            j+=1
        else:
            k-=1
print(tri_num)


N=int(input())
S=list(map(int,input().split( )))
print(S)
tri=[]
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            a = [S[i],S[j],S[k]]
            a = sorted(a)
            if a[0]+a[1] > a[2]:
                tri.append(a)

for i in range(len(tri)):
    n=0
    for j in range(i+1,len(tri)):
        if tri[i] == tri[j-n]:
            tri.pop(j)
            n=n+1


print(len(tri))

N=int(input())
S=list(map(int,input().split( )))
S = sorted(S)
tri_num=0
for i in range(N-2):
    k=i+2
    for j in range(i+1,N-1):
        while k < N:
            if S[i] + S[j] <= S[k]:
                tri_sum = tri_sum + k-j-1
                k+=1
                break
            else:
                k+=1
print(tri_num)


N=int(input())
S=list(map(int,input().split( )))
S = sorted(S)
tri_num=0
for i in range(N-2):
    k = i+2
    for j in range(i+1,N-1):
        while k < N:
            if S[i] + S[j] <= S[k]:
                tri_num = tri_num + k-j-1
                if k == i+2:
                    k+=1
                break
            elif k == N-1:
                tri_num = tri_num + k-j
            else:
                k+=1
print(tri_num)

N=int(input())
S=list(map(int,input().split( )))
S = sorted(S,reverse=True)
tri_num=0
for i in range(N-2):
    j = i+1
    k = N-1
    while k > j:
        if S[i] < S[j] + S[k]:
            tri_num += k-j
            j+=1
        else:
            k-=1
print(tri_num)


Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Time Limit Exceeded

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()
ans = 0
print(L)
for i in range(n - 1, 0, -1):
    for j in range(i - 1, 0, -1):
        ans += max(0, (j - bisect.bisect_right(L, L[i] - L[j])))
print(ans)


import bisect
n = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(n - 1, 0, -1):
    for j in range(i - 1, 0, -1):
        ans += max(0, (j - bisect.bisect_right(L, L[i] - L[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):
N=int(input())
L=list(map(int,input().split()))
counter=0
for t in range(N):
  for i in range(t+1,N):
    for p in range(i+1,N):
      if L[p]<L[t]+L[i] and L[t]<L[i]+L[p] and L[i]<L[p]+L[t]:
        counter+=1
print(counter

import bisect
counter=0
N=int(input())
L=sorted(list(map(int,input().split())))
for a in range(N-2):
  for b in range(a+1,N-1):
    k=bisect.bisect_left(L,L[a]+L[b])
    counter+=k-b-1
print(counter)
    

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 = sorted(l)

cnt = 0

for i in range(n-1, -1, -1):
    for j in range(i-1, -1, -1):
        imin = 0
        imax = j-1

        while imin <= imax:
            mid = (imin + imax)//2
            if test[mid] + l[j] >= l[i]:
                imax = mid-1
            else:
                imin = mid+1

        cnt += j-imin

print(cnt)

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

cnt = 0

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

print(cnt)

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(reverse=True)

import itertools
from math import factorial

nCr = N*(N-1)*(N-2)/6

count = 0

for i in range(N):
  if L[0]-L[N-1] < L[i]:
    count+=1

print(int(nCr - count*(count-1)))

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

import bisect
ans = 0

L.sort()
for i in range(0,N-2):
    for j in range(i+1,N-1):
        a = L[i]
        b = L[j]
        index = bisect.bisect_left(L,a+b)
        if index > j:
            ans += index-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(reverse=True)
print(l)
ans = 0

for i in range(n-2):
    flag = 0
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i] < l[j] + l[k]:
                ans += 1
            elif k-j == 1:
                flag = 1
                break
            else:
                break
        if flag:
            break

print(ans) 

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):
        ind = bisect.bisect_left(l,l[i]+l[j])
        ans += ind-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):
from bisect import bisect_right
N = int(input(()))
L = list(map(int,input().split()))
count = 0

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

print(count)


from bisect import bisect_left,bisect_right
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 += max(bisect_right(L,L[i]+L[j]-1)-j-1,0)

print(count)


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

for i in range(N):
    k = L[i]
    j = i - 1
    while(j >= 0)and(L[j]>k):
        L[j+1]=L[j]
        j -= 1
    L[j+1] = k
L = L[::-1]
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]) and (L[j]<L[i]+L[k]) and (L[j]>=L[k]):
                count += 1

print(count)


from bisect import bisect_right
N = int(input(()))
L = list(map(int,input().split()))
count = 0

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

for i in range(N-2):
    for j in range(i+1,N-1):
            count += max(bisect_right(L,L[i]+L[j]-1)-j-1,0)

print(count)


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

for i in range(N):
    k = L[i]
    j = i - 1
    while(j >= 0)and(L[j]>k):
        L[j+1]=L[j]
        j -= 1
    L[j+1] = k
L = L[::-1]
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]) and (L[j]<L[i]+L[k]) and (L[j]>L[k]):
                count += 1

print(count)


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

lsum = []
for j in range(N-1):
    for i in range(j+1,N):
        for k in range(i+1,N):
            if(L[i]+L[j]>L[k])and(L[i]+L[k]>L[j])and(L[i]<L[j]+L[k]):
                count += 1
print(count)

from bisect import bisect_left,bisect_right
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 += max(bisect_right(L,L[i]+L[j]-1)-j-1,0)

print(count)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

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()
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
print(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
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 sys import stdin
from itertools import groupby, permutations
import numpy as np



def main():
    N = int(input())
    L = np.sort(np.array([int(x) for x in input().split()]))

    ret = 0
    # print(L)
    for i in range(N-2):
        for j in range(i + 1, N-1):
            k = np.searchsorted(L, L[i] + L[j], side='right')
            # print(L[i], L[j], k, ret)
            ret += k - j - 1
    return ret


if __name__ == "__main__":
    print(main())

from sys import stdin, stderr
from bisect import bisect_right, bisect_left


def main():
    N = int(input())
    L = sorted([int(x) for x in input().split()])
    ret = 0

    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            c = L[i] + L[j] - 1
            k = bisect_right(L, c)
            # print(L[i], L[j], k, ret, file=stderr)
            ret += k - j - 1
    return ret


if __name__ == "__main__":
    print(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()))
ans=0
c=[0]*2101
for i in L:c[i]+=1
for i in range(2100):c[i+1]=c[i]+c[i+1]
for i in range(N):
    for j in range(N):
        if i!=j:
            l,r=abs(L[i]-L[j])+1,L[i]+L[j]
            s=c[r]-c[l]
            if l<=L[i] and L[i]<r:s-=1
            if l<=L[j] and L[j]<r:s-=1
            ans+=max(s,0)
print(ans//6)

N=int(input())
L=list(map(int,input().split()))
ans=0
c=[0]*1001
for i in L:c[i]+=1
for i in range(1000):c[i+1]=c[i]+c[i+1]
for i in range(N-1):
    for j in range(i+1,N):
        l,r=abs(L[i]-L[j]),min(L[i]+L[j]-1,1000)
        ans+=c[r]-c[l]
        if l<L[i] and L[i]<=r:ans-=1
        if l<L[j] and L[j]<=r:ans-=1
print(ans//3)

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):
from math import factorial
N=int(input())
L=input()
L=L.split()
L=[int(item) for item in L]
L.sort()
if N<=3:
    ans=1
else:
    ans=factorial(N)/factorial(3)/factorial(N-3)

from operator import mulfrom operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N=int(input())
L=input()
L=L.split()
L=[int(item) for item in L]
L.sort()
ans=cmb(N,3)
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in reversed(range(j+1,N)):
            if (L[i]+L[j])>=L[k]:
                break
            else:
                ans-=1


print(int(ans))

from math import factorial
N=int(input())
L=input()
L=L.split()
L=[int(item) for item in L]
L.sort()


import sys

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]


N=int(input())
L=input()
L=L.split()
L=[int(item) for item in L]
L.sort()
ans=1000
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]:
                ans-=(N-k)
                break


print(int(ans))

from operator import mul
from functools import reduce
import bisect

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N=int(input())
L=input()
L=L.split()
L=[int(item) for item in L]
L.sort()
ans=cmb(N,3)
ans2=0
for i in reversed(range(2,N)):
    for j in reversed(range(1,i)):
        a=bisect.bisect_right(L,L[i]-L[j])
#        print('{0}:{1}'.format(a,j))
#        print(a)
        if(a<j):
            ans2+=(j-a)
    

print(ans2)


Verdicts: Runtime Error

Runtime Error

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 = list(map(int,input().split()))
ans = 0
L_list.sort()

for i in range(N-2):
    J = i+1
    for x in range(N-i-1):
        j = J+x
        K = j+1
        for y in range(N-j-1):
            k = K+y
            print(L_list[i],L_list[j],L_list[k])
            if L_list[i] + L_list[j] > L_list[k]:
                ans += 1
            else:
                break

print(ans)

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):
        insert_index = bisect.bisect_left(l, l[i] + l[j],j) 
        ans += (insert_index - 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):
import bisect
n=int(input())
l=list(map(int,input().split()))
l.sort()

ans=0
for a in range(n):
    for b in range(a+1,n):
        ans+=bisect.bisect_right(l,l[a]+l[b])-b
        
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):
        r=bisect_left(l, l[a] + l[b], b + 1, n)
        l=b+1
        ans+=r-l
        
print(ans)


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


def triangle(num):
    a,b,c=num
    if a<(b+c) and b<(a+c) and c<(a+b):
        return True
    else:
        return False
ans=0
for a in range(n):
    for b in range(a+1,n):
        ans+=bisect.bisect_right(l,l[a]+l[b])-b-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+=max(0,bisect_left(l, l[a] + l[b])-b-1)
        
        
print(ans)


Verdicts: Wrong Answer

Runtime Error

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 = 1)
ans = 0

for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            a,b,c = l[i],l[j],l[k]
            #print(i,j,k)
            if a >= b+c:
                break
            else:
                ans += 1
            

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

l.sort(reverse = 1)
ans = 0

for i in range(n-2):
    indL = i+1
    indR = len(l)-1
    while 1:
        if indL == indR:
            break
        if l[i] < l[indL] + l[indR]:
            ans += (indR - indL)
            indL += 1
        else:
            indR -= 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):
from bisect import*
_,l=open(0)
*e,=enumerate(sorted(map(int,l.split())))
print(sum(j-bisect(l,a-b,0,j)for i,a in e for j,b in e[:i]))

from bisect import*
n,*l=map(int,open(0).read().split())
l.sort()
print(sum(bisect_left(l,l[i//n]+l[i%n],i%n+1)-i%n-1for i in range(n*n))//2)

from bisect import*
_,l=open(0)
l=sorted(map(int,l.split()))
print(sum(j-bisect(l,a-l[j],0,j)for i,a in enumerate(l)for j in range(i)))

Verdicts: Runtime Error

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_list =  sorted(list(map(int,input().split())))
#print(L_list)
result =0

for i in range(N):
    for j in range(i+1,N):
        a = L_list[i] + L_list[j]
        idx = bisect.bisect_left(L_list,a)
        result = max(0,idx-j-1)
print(result)

import bisect
N = int(input())
L_list =  sorted(list(map(int,input().split())))
#print(L_list)
result =0

for i in range(N):
    for j in range(i+1,N):
        a = L_list[i] + L_list[j]
        idx = bisect.bisect_left(L_list,a)
        result += max(0,idx-j-1)
print(result)

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 numpy as np
import bisect
n = int(input())
l = np.array(list(map(int, input().split())))
l = np.sort(l)
l_unique, l_uniue_index = np.unique(l, return_counts = True)
m = len(l_unique)
ans = 0

ans += len(np.where(l_uniue_index >= 3)[0])
print(ans)

for a in l_unique[np.where(l_uniue_index >= 2)[0]]:
    ans += bisect.bisect_left(l_unique, a * 2) - 1
print(ans)    
    
for i in range(m):
    for j in range(i+1, m):
        ans += bisect.bisect_left(l_unique[j+1:], l_unique[i] + l_unique[j])
print(ans)

import bisect
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
    for j in range(i+1, n):
        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):
N=int(input())
L=list(map(int,input().split()))
L.sort(reverse=True)
print(L)
ans=0
for n in range(N-2):
  for k in range(n+1,N-1):
    if L[n]<L[k]*2:
      for l in range(k+1,N):
        if L[n]<L[k]+L[l]:
          ans+=1
        else:
          break
print(ans)

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

for i in range(N-2):
    a = L[i]
    for j in range(i+1,N-1):
        b = L[j]
        c = bisect.bisect_right(L,a+b)
        ans += c-j-1
print(ans)


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

from bisect import bisect_left

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


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())
arr = list(sorted(map(int, input().split())))

memo = [0]*1001
for x in range(1001):
    for i in arr:
        if i < x:
            memo[x] += 1

result = 0
for a in range(N):
    for b in range(a+1, N):
        aa = arr[a]
        bb = arr[b]
        if aa+bb > 1000:
            result += N-b-1
        else:
            result += memo[aa+bb]-b-1
        print(a,b,result)

print(result)


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

memo = [0]*1001
for x in range(1001):
    for i in arr:
        if i < x:
            memo[x] += 1

result = 0
for a in range(N):
    for b in range(a+1, N):
        aa = arr[a]
        bb = arr[b]
        if aa+bb > 1000:
            result += N-b-1
        else:
            result += memo[aa+bb]-b-1

print(result)


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
from bisect import bisect_left

n = int(input()) 
l = []
for i in range(n):
    l.append(input()) 

l.sort()
result =0
for i in range(n):
    a =l[i]
    for j in range(i+1,n-1):
        b=l[j]
        k = bisect_left(l,a+b)
        result += k-j-1

print(result)




import bisect
from bisect import bisect_left

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

l.sort()
result =0
for i in range(n-2):
    a =l[i]
    for j in range(i+1,n-1):
        b=l[j]
        k = bisect_left(l,a+b-1)
        result += k-j-1

print(result)




import bisect
from bisect import bisect_left

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

l.sort()
result =0
for i in range(n-2):
    a =l[i]
    for j in range(i+1,n-1):
        b=l[j]
        k = bisect_left(l,a+b)
        result += k-j-1

print(result)




Verdicts: Runtime Error

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=list(map(int,input().split()))
 
L.sort()
for i in range(0,N):
  for j in range(i+1,N):
    index=bisect.bisect_left(L,L[i]+L[j])
    count+=index-j-i
print(count)

N=int(input())
L=list(map(int,input().split()))
 
count=0
for i in range(0,N-2):
  for j in range(i+1,N-1):
    for k in range(i+2,N):
      if L[i]+L[j]>L[k] and L[i]+L[k]>L[j] and L[j]+L[k]>L[i]:
        count+=1
print(count)

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

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

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

count=0
for i in range(0,N-2):
  for j in range(i+1,N-1):
    for k in range(i+2,N):
      if L[i]+L[j]>L[k]:
        count+=1
print(count)
    

import bisect
 
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):
    index=bisect.bisect_left(L[j:],L[i]+L[j])
    count+=index
print(count)

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

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

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):
import bisect

if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    a = sorted(a)
    ans = 0
    for i in range(n-2):
        for j in range(i+1, n-1):
            ind = bisect.bisect_right(a, a[i] + a[j])
            ans += ind - j - 1
    print(ans)

import bisect

if __name__ == '__main__':
    n = int(input())
    ans = 0
    a = [int(x) for x in input().split(' ')]
    a.sort()
    for i in range(0, n-1):
        for j in range(i+1, n):
            m = bisect.bisect_right(a, a[i], a[j])
            if i > m:
                ans += i - m
    print(ans)

import bisect

if __name__ == '__main__':
    n = int(input())
    ans = 0
    a = [int(x) for x in input().split(' ')]
    a.sort()
    for i in range(0, n-1):
        for j in range(i+1, n):
            m = bisect.bisect_right(a, a[i] + a[j])
            ans += m - j - 1
    print(ans)

import bisect

if __name__ == '__main__':
    n = int(input())
    ans = 0
    a = [int(x) for x in input().split(' ')]
    a = sorted(a)
    for i in range(0, n-2):
        for j in range(i+1, n-1):
            m = bisect.bisect_right(a, a[i] + a[j])
            ans += m - j - 1
    print(ans)

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

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):
number_of_sticks = int(input())

sticks = [int(x) for x in input().split(' ')]

sticks.sort()

print(sticks)

triangles = 0

import bisect

for i in range (number_of_sticks - 2):
    for j in range (i+2, number_of_sticks):
        # print(sticks[i], sticks[j])
        # find number of sticks between range range sticks[j]-sticks[i], sticks[i] + sticks[j]
        
        max_range = j
        min_range = max(bisect.bisect(sticks, sticks[j] - sticks[i]), i + 1)
        # print("max range: " + str(max_range))
        # print("min range: " + str(min_range))
        triangles += max(0, max_range - min_range)

print(triangles)

number_of_sticks = int(input())

sticks = [int(x) for x in input().split(' ')]

sticks.sort()

triangles = 0

import bisect

for i in range (number_of_sticks - 2):
    for j in range (i+2, number_of_sticks):
        max_range = j
        min_range = max(bisect.bisect(sticks, sticks[j] - sticks[i]), i + 1)
        triangles += max_range - min_range

print(triangles)

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 = sorted(list(map(int, input().split())))
s = 0
for i in range(0,n-2):
  a = l[i]
  for j in range(i+1,n-1):
    b = l[j]
    for k in range(j+1,n-2):
      c = l[k]
      if(a+b<c):
        s += n-k
        break
        
print(n*(n-1)*(n-2)//6 - s)

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

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()))
cnt = 0
l.sort()

for i in range(n):
    for j in range(i+1,n):
        k = bisect.bisect_left(l,l[i]+l[j])
        if k > j:
            cnt += k - j - 1
        else:
            continue
            
print(cnt)

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

import bisect
l.sort()
cnt = 0
for i in range(n):
    for j in range(i+1,n):
        idx = bisect.bisect_left(l,l[i]+l[j])
        #print('idx',idx)
        if j < idx:
            cnt += idx - j - 1


print(cnt)

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 bisect
N=int(input())
L=sorted(list(map(int,input().split())))
count=0
for d1 in range(N-2):
    for d2 in range(d1+1,N-1):
        m=bisect.bisect_right(L,L[d1]+L[d2])
        if m>d2+1:count+=m-(d2+1)
print(count)


N=int(input())
L=sorted(list(map(int,input().split())))
count=0
for d1 in range(N-2):
    for d2 in range(d1+1,N-1):
        m=bisect.bisect_right(L[d1]+L[d2],l)
        if:m>d2:count+=m-d2
print(count)


import bisect
N=int(input())
L=sorted(list(map(int,input().split())))
count=0
for d1 in range(N-2):
    for d2 in range(d1+1,N-1):
        m=bisect.bisect_right(L[d1]+L[d2],l)
        if m>d2:count+=m-d2
print(count)


N=int(input())
L=sorted(list(map(int,input().split())))
L=list(set(L))
N=len(L)
print(L)
exit()
count=0
d2breakFlag=False
for d1 in range(N-2):
    for d2 in range(d1+1,N-1):
        Temp=L[d1]+L[d2]

        """for d3 in range(d2+1,N):
            if L[d1]+L[d2]>L[d3]:count+=1
            else:break
print(count)"""


N=int(input())
L=sorted(list(map(int,input().split())))
count=0
d2breakFlag=False
for d1 in range(N-2):
    for d2 in range(d1+1,N-1):
        Temp=L[d1]+L[d2]

        """for d3 in range(d2+1,N):
            if L[d1]+L[d2]>L[d3]:count+=1
            else:break
print(count)"""


N=int(input())
L=sorted(list(map(int,input().split())))
L=[3,1,5,1,2,3,4,1,5,2,1,3,]
L=list(set(L))
N=len(L)
print(L)
exit()
count=0
d2breakFlag=False
for d1 in range(N-2):
    for d2 in range(d1+1,N-1):
        Temp=L[d1]+L[d2]

        """for d3 in range(d2+1,N):
            if L[d1]+L[d2]>L[d3]:count+=1
            else:break
print(count)"""


N=int(input())
L=sorted(list(map(int,input().split())))
L=list(set(L))
count=0
d2breakFlag=False
for d1 in range(N-2):
    for d2 in range(d1+1,N-1):
        Temp=L[d1]+L[d2]

        """for d3 in range(d2+1,N):
            if L[d1]+L[d2]>L[d3]:count+=1
            else:break
print(count)"""


import bisect
N=int(input())
L=sorted(list(map(int,input().split())))
count=0
for d1 in range(N-2):
    for d2 in range(d1+1,N-1):
        m=bisect.bisect_left(L,L[d1]+L[d2])
        if m>d2+1:count+=m-(d2+1)
print(count)


Verdicts: Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

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 sys
inputs = sys.stdin.readlines()
n = int(inputs[0])
L = list(map(int, inputs[1].split())
A = sorted(L)

ans = 0
for i in range(n-1, 0, -1):
    l, r = 0, i-1
    while l < r:
        if A[i] < A[l] + A[r]:
            ans += r-l
            r -= 1
        else:
            l += 1

print(ans)

import sys
inputs = sys.stdin.readlines()
n = int(inputs[0])
L = list(map(int, inputs[1].split()))
A = sorted(L)
 
ans = 0
for i in range(n-1, 0, -1):
    l, r = 0, i-1
    while l < r:
        if A[i] < A[l] + A[r]:
            ans += r-l
            r -= 1
        else:
            l += 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):
def main():
  	N = int(input())
	l = list(map(int, input().split(" ")))
	k = 0
	for i in range(N-2):
    	a = l[i]
    	for j in range(i+1, N-1):
        	b = l[j]
        	k += len([p for p in l[j+1:] if abs(b-a) < p < (a+b)])
	print(k)
main()

from bisect import bisect_left
def main():
	N = int(input())
	L = list(map(int, input().split(" ")))
	L.sort()
	k = 0
	for i in reversed(range(2, N)):
		a = L[i]
		for j in reversed(range(1, i)):
			b = L[j]
			index = bisect_left(L, a-b, hi=j)
			k += j - index
	print(k)
if __name__ == "__main__":
    main()

from bisect import bisect_right
def main():
	N = int(input())
	L = list(map(int, input().split(" ")))
	L.sort()
	k = 0
	for i in reversed(range(2, N)):
		a = L[i]
		for j in reversed(range(1, i)):
			b = L[j]
			index = bisect_right(L, a-b, hi=j)
			k += j - index
	print(k)
if __name__ == "__main__":
    main()

Verdicts: Runtime Error

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 = [int(i) for i in input().split()]
L.sort()

cnt = 0
for i in range(0,N):
  for j in range(i+1,N):
    t = L[i]+L[j]
    idx = bisect_left(L,t,lo=j+1)
    print(L[i],L[j],idx)
    cnt += max(0,idx-j-1)
print(cnt)

N = int(input())
L = list(map(int, input().split()))
L.sort()
 
from bisect import bisect_left 
cnt = 0
for i in range(0,N-2):
  for j in range(i+1,N-1):
    t = L[i]+L[j]
    idx = bisect_left(L,t,j+1)
    cnt += max(0,idx-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):
import bisect

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

		print(l[j],l[i],bisect.bisect_right(l,l[i]-l[j]),count)


import bisect

n = int(input())
l = sorted(list(map(int,input().split())))
count = 0
for i in range(2,n):
	for j in range(1,i):
		count += max(j - bisect.bisect_right(l, l[i] - l[j]) , 0)

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())
A=sorted([int(i) for i in input().split()])
count=0
for i in range(n - 1, 0, -1): 
    l = 0; 
    r = i - 1; 
    while(l < r): 
        if(A[l] + A[r] > A[i]):  
            count += r - l;  
            print(A[i])
            r -= 1;  
        else: 
            l += 1;  
            
print(count)

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: Wrong Answer

Accepted