Problem: We have sticks numbered 1, \cdots, N. The length of Stick i (1 \leq i \leq N) is L_i.  In how many ways can we choose three of the sticks with different lengths that can form a triangle?  That is, find the number of triples of integers (i, j, k) (1 \leq i < j < k \leq N) that satisfy both of the following conditions:    * L_i, L_j, and L_k are all different.   * There exists a triangle whose sides have lengths L_i, L_j, and L_k.

Submission attempts (in order):
# coding: utf-8
from pdb import set_trace
from collections import Counter

N = int(input())
L = sorted(list(map(int, input().split(" "))), reverse=True)
C = dict(Counter(L))
L = sorted(list(set(L)), reverse=True)
print(L)

if N<3 or len(L)<3:
    print(0)
    exit()
li = []
for xa, a in enumerate(L[:-2]):
    for xb, b in enumerate(L[xa+1:-1]):
        for xc, c in enumerate(L[xa+2:]):
            if a+b<c:
                break
            if a+b>c and b+c>a and c+a>b and a!=b and b!=c and c!=a:
                _li = sorted([xa, xb+xa+1, xc+xa+2])
                if _li in li:
                    continue
                li.append(_li)
cnt = 0
for l in li:
    a = C[L[l[0]]]
    b = C[L[l[1]]]
    c = C[L[l[2]]]
    cnt += (a * b * c)
print(cnt)

# coding: utf-8
from pdb import set_trace

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

if N<3:
    print(0)
    exit()
LN = [i for i in range(N)]
cnt = []
for xa, a in enumerate(L[:-2]):
    for xb, b in enumerate(L[xa+1:-1]):
        for xc, c in enumerate(L[xa+2:]):
            if a+b>c and b+c>a and c+a>b and a!=b and b!=c and c!=a:
                li = sorted([xa, xb+xa+1, xc+xa+2])
                if li in cnt:
                    continue
                cnt.append(li)
print(len(li))

# coding: utf-8
from pdb import set_trace

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

if N<3:
    print(0)
    exit()
LN = [i for i in range(N)]
cnt = []
for xa, a in enumerate(L[:-2]):
    for xb, b in enumerate(L[xa+1:-1]):
        for xc, c in enumerate(L[xa+2:]):
            if a+b>c and b+c>a and c+a>b and a!=b and b!=c and c!=a:
                li = sorted([xa, xb+xa+1, xc+xa+2])
                flag = True
                for _cnt in cnt:
                    if _cnt==li:
                        flag = False
                if flag:
                    cnt.append(li)
                    print(li, [a, b, c])
print(len(cnt))

# coding: utf-8
from pdb import set_trace
#from collections import Counter
import itertools

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




# if N<3 or len(L)<3:
#     print(0)
#     exit()

# for xa, a in enumerate(L[:-2]):
#     for xb, b in enumerate(L[xa+1:-1]):
#         for xc, c in enumerate(L[xa+2:]):
#             if a+b<c:
#                 break
#             if a+b>c and b+c>a and c+a>b and a!=b and b!=c and c!=a:


#                     continue
#                 li.append(_li)
# cnt = 0
# for l in li:
#     a = C[L[l[0]]]
#     b = C[L[l[1]]]
#     c = C[L[l[2]]]
#     cnt += (a * b * c)
# print(cnt)
cnt = 0
TRI = list(itertools.combinations(L, 3))
for tri in TRI:
    a, b, c = tri
    if a==b or b==c or c==a:
        continue
    elif a+b>c and a+c>b and b+c>a:
        cnt += 1
print(cnt)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted