Problem:
 Score : 200 points    Problem Statement 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 .       Constraints  1 \leq N \leq 100  1 \leq L_i \leq 10^9  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  L_1  L_2  \cdots  L_N       Output Print the number of ways to choose three of the sticks with different lengths that can form a triangle.        Sample Input 1 5
4 4 9 7 5      Sample Output 1 5  The following five triples (i, j, k) satisfy the conditions: (1, 3, 4) , (1, 4, 5) , (2, 3, 4) , (2, 4, 5) , and (3, 4, 5) .       Sample Input 2 6
4 5 4 3 3 5      Sample Output 2 8  We have two sticks for each of the lengths 3 , 4 , and 5 . To satisfy the first condition, we have to choose one from each length.  There is a triangle whose sides have lengths 3 , 4 , and 5 , so we have 2 ^ 3 = 8 triples (i, j, k) that satisfy the conditions.       Sample Input 3 10
9 4 6 1 9 6 10 6 6 8      Sample Output 3 39       Sample Input 4 2
1 1      Sample Output 4 0  No triple (i, j, k) satisfies 1 \leq i < j < k \leq N , so we should print 0 .

Solution (Python):
N = int(input())
L = list(map(int, input().split()))
L = sorted(L)
N = len(L)
ans = 0

for i in range(N-2):
    for j in range(i+1, N-1, 1):
        if L[i] == L[j]:
            continue
        min = L[j] - L[i]
        max = L[j] + L[i]
        for k in range(j+1, N, 1):
            if L[j] == L[k]:
                continue
            if (min < L[k]) and (L[k] < max):
                ans += 1

print(ans)

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

count = 0
for i in range(N-2):
    for j in range(i+1, N-1, 1):
        for k in range(j+1, N, 1):
            if L[i] != L[j] and L[i] != L[k] and L[j] != L[k]:
                if max(L[i], L[j], L[k]) < (L[i]+L[j]+L[k])-max(L[i], L[j], L[k]):
                    count += 1

print(count)

Solution (Python):
import itertools

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

count = 0
p = itertools.combinations(M, 3)
for l in p:
  a = l[0]
  b = l[1]
  c = l[2]
  if ((a == b) or (b == c) or (c == a)):
    continue
  if ((a + b > c) and (b + c > a) and (c + a > ｂ)):
    count += 1
print(count)

Solution (Python):
from itertools import combinations as comb

def fits(m: iter):
    a, b, c = m
    return a!=b!=c and c!=a and a<b+c and b<a+c and c<a+b

n = int(input())
l = map(int, input().split())
ans = 0

for cwr in comb(l, 3): ans += fits(cwr)
print(ans)

Solution (Python):
N = int(input())
L = list(map(int, input().split(" ")))
cnt =0 

for i in range(len(L)):
    for j in range(len(L) - (i+1)):
        for k in range(len(L) - (i+1+j+1)):
            if L[i] != L[j+i+1] and L[i] != L[k+i+j+2] and L[j+i+1] != L[k+i+j+2]:
                if L[i]+L[j+i+1] > L[k+i+j+2] and L[i]+L[k+i+j+2] > L[j+i+1] and L[k+i+j+2]+L[j+i+1] > L[i]:
                    cnt += 1
print(cnt)

Solution (Python):
import itertools

N = input()
L = input().split()

num = 0
for x in itertools.combinations(L, 3):
  if x[0] != x[1] and x[0] != x[2] and x[1] != x[2]:
      if int(x[0]) + int(x[1]) > int(x[2]) and int(x[0]) + int(x[2]) > int(x[1]) and int(x[1]) + int(x[2]) > int(x[0]) :
          num = num+1

print(num)

Solution (Python):
from itertools import combinations as C

N = int(input())
L = list(map(int, input().split()))
L = list(C(L, 3))
ans = 0
for l in L:
    l = list(l)
    l.sort()
    
    if l[0] == l[1] or l[1] == l[2] or l[0] == l[2]:
        continue
    if l[0] + l[1] > l[2]:
        ans += 1
        
print(ans)

Solution (Python):
import sys
N = int(input())
Ls = sorted(list(map(int, input().split())))

if len(Ls) < 3:
    print("0")
    sys.exit(0)

count = 0
for i in reversed(range(len(Ls))):
    max_l = Ls[i]
    for j in range(1,i+1):
        sec_l = Ls[i-j]

        if sec_l < max_l/2:
            break
        if sec_l == max_l:
            continue

        for k in range(j+1,i+1):
            thi_l = Ls[i-k]

            if sec_l == thi_l:
                continue

            if thi_l + sec_l > max_l:
                count += 1
            else:
                break
print(count)

Solution (Python):
from itertools import combinations

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

count = 0
for C in combinations(L, 3):
    l_list = list(C)
    l_list.sort()

    if l_list[2] > l_list[1] and l_list[1] > l_list[0]:
        if l_list[2] < l_list[1] + l_list[0]:
            count += 1

print(count)

Solution (Python):
from collections import Counter
n=int(input())
l=list(map(int,input().split()))
c=Counter(l)
l=list(set(l))
if n<=2:
    print(0)
    exit()
else:
    t=len(l)
    ans=0
    for i in range(t-2):
        for j in range(i+1,t-1):
            for k in range(j+1,t):
                if l[i]+l[j]>l[k] and l[i]+l[k]>l[j] and l[j]+l[k]>l[i]:
                    ans=ans+c[l[i]]*c[l[j]]*c[l[k]]
    print(ans)

Solution (Python):
from itertools import combinations
n = int(input())
lst = list(map(int, input().split()))
comb = combinations(lst, 3)
count = 0
for i in comb:
  if i[0] != i[1] and i[1] != i[2] and i[0] != i[2]:
    if i[0] + i[1] > i[2] and i[1] + i[2] > i[0] and i[0] + i[2] > i[1]:
      count += 1
print(count)

Solution (Python):
N = int(input())
L = [int(_) for _ in input().split()]

ans = 0
for i in range(N):
    for j in range(i+1, N):
        if L[i] == L[j]:
            continue
        for k in range(j+1, N):
            if L[i] == L[k] or L[j] == L[k]:
                continue
            X = (L[i], L[j], L[k])
            if max(X) < sum(X) - max(X):
                ans += 1
print(ans)

Solution (Python):
import itertools

n=int(input())
l=[int(x) for x in input().split()]

if n<3:
    print(0)
    exit()

ans=0
for x in itertools.combinations(l,3):
    x=list(x)
    x.sort(reverse=True)
    if x[0]<x[1]+x[2]:
        if x[0]!=x[1] and x[1]!=x[2] and x[2]!=x[0]:
            ans+=1
print(ans)

Solution (Python):
N = int(input())
L = list(map(int, input().split()))
l = len(L)
cnt = 0
for i in range(l):
  for j in range(i+1, l):
    for k in range(j+1, l):
      if L[i] != L[j] and L[i] != L[k] and L[j] != L[k] and (L[i] + L[j]) > L[k] and (L[j] + L[k]) > L[i] and (L[i] + L[k]) > L[j]:
        cnt = cnt + 1
print(cnt)

Solution (Python):
import collections

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

c = collections.Counter(l)

num = list(c.keys())
val = list(c.values())

ans = 0

for i in range(len(num) - 2):
    for j in range(len(num) - 2 - i):
        for k in range(len(num) - 2 - i -j):
            sel = [num[i],num[i + j + 1],num[i + j + 2 + k]]
            if 2 * max(sel) < sum(sel):
                ans += val[i]*val[i + j + 1]*val[i + j + 2 + k]

print(ans)

Solution (Python):
n = int(input())
li = list(map(int,input().split()))
count = 0
for i in range(n):
    for ii in range(n-i):
        if li[i] != li[i+ii]:
            for iii in range (n-i-ii):
                if li[i] != li[i+ii+iii] and li[i+ii]!=li[i+ii+iii]:
                    tri = []
                    tri.append(li[i])
                    tri.append(li[i+ii])
                    tri.append(li[i+ii+iii])
                    if max(tri)<(sum(tri)-max(tri)):
                        count +=1
print(count)

Solution (Python):
N = int(input())
h = list(map(int,input().split()))

l = list(set(h))
l.sort()
a = []
for i in range(len(l)):
    a.append(h.count(l[i]))
ans = 0
for i in range(len(l)):
    for j in range(i+1, len(l)):
        for k in range(j +1, len(l)):
            if l[i] + l[j] > l[k]:
                ans += a[i] * a[j] * a[k]
print(ans)

Solution (Python):
n = int(input())
l = list(map(int, input().split()))
ans = 0
l = sorted(l)

for a in range(n-2):
    for b in range(a, n-1):
        for c in range(b, n):
            if l[a] != l[b] != l[c]:
                if abs(l[b] - l[c]) < l[a] < l[b] + l[c]:
                    ans += 1

print(ans)

Solution (Python):
from collections import Counter
n=int(input())
brr=list(map(int,raw_input().split()))

def solve(arr,n):
    if n<=2:
        return 0

    freq=Counter(brr)
    arr=list(set(brr))
    arr.sort()
    count=0
    for i in range(len(arr)-2):
        for j in range(i+1,len(arr)-1):
            for k in range(j+1,len(arr)):
                if arr[i]+arr[j]>arr[k]:
                    count+=freq[arr[i]]*freq[arr[j]]*freq[arr[k]]
    return count

print(solve(brr,n))

Solution (Python):
n = int(input())
L = list(map(int,input().split()))
count = 0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if L[i] == L[j] or L[j] == L[k] or L[i] == L[k]:
                pass
            elif L[i] + L[j] > L[k] and L[k] + L[i] > L[j] and L[j] + L[k] > L[i]:
                count +=1
print(count)

Solution (Python):
import collections

def main():
    n = int(input())
    l = list(map(int, input().split()))
    
    if n<3:
        print(0)
        return
    
    leng = n
    ans = 0
    for i in range(leng-2):
        a = l[i]
        for j in range(i+1, leng-1):
            b = l[j]
            if a==b:
                continue
            
            for j in range(j+1, leng):
                c = l[j]
                if c==a or c==b:
                    continue
                
                if a<b+c:
                    if b<c+a:
                        if c<a+b:
                            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
x = int(input())
xyz = list(map(int, input().split()))
ans=0
xyz.sort(reverse=True)
for i in range(x):
    a=xyz[i]
    for j in range(i+1,x):
        b=xyz[j]
        if a>b:
            for k in range(j+1,x):
                c=xyz[k]
                if b>c:
                    if a+b>c and b+c>a and c+a>b:
                        ans+=1
print(ans)

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

c=0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i]==l[j] or l[j]==l[k] or l[k]==l[i]:
                continue
               
            if abs(l[j]-l[k])<l[i] and l[i]<l[j]+l[k]:
                c+=1
print(c)

Solution (Python):
import itertools
N = int(input())
L = list(map(int, input().split()))
Lset= list(set(L))
ans = 0
count = 0

for n in itertools.combinations(Lset, 3):
    if n[0]+n[1]>n[2] and n[1]+n[2]>n[0] and n[2]+n[0]>n[1]:
        ans += 1
        count += ans*L.count(n[0])*L.count(n[1])*L.count(n[2])
        ans = 0
print(count)

Solution (Python):
n = int(input())
l = list(map(int, input().split()))
cnt = 0
for a in range(0, n-2):
    for b in range(a+1, n-1):
        for c in range(b+1, n):
            if l[a] + l[b] > l[c] and l[b] + l[c] > l[a] and l[c] + l[a] > l[b] and l[a] != l[b] and l[a] != l[c] and l[b] != l[c]:
                cnt += 1
print(cnt)

Solution (Python):
import itertools
N=int(input())
L=list(map(int,input().split()))

l= list(itertools.combinations_with_replacement(L, 3))
ans=0
for ll in l:
    if ll[0]!=ll[1] and ll[0]!=ll[2] and ll[1]!=ll[2]:
        if (ll[0]+ll[1])>ll[2] and (ll[1]+ll[2])>ll[0] and (ll[2]+ll[0])>ll[1]:
            ans+=1
                    
print(ans)

Solution (Python):
n = int(input())
line = list(map(int, input().split()))
count = 0
for i in range(n):
    result = []
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if line[i] != line[k] and line[i] != line[j] and line[j] != line[k]:
                _len = line[i] + line[k] + line[j]
                max_r = max(line[i], line[k], line[j])
                if max_r < _len - max_r:
                    count += 1
print(count)

Solution (Python):
N = int(input())

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

A.sort()
count = 0
for i in range(N):
    a = A[i]
    for j in range(i+1, N):
        b = A[j]
        if b == a:
            continue
        for k in range(j+1, N):
            c = A[k]
            if b == c:
                continue
            if c < a + b:
                count += 1
            else:
                break

print(count)

Solution (Python):
import collections
import itertools
N = int(input())
L = list(map(int,input().split()))
s = list(set(L))
c = collections.Counter(L)
ans = 0
for x in itertools.combinations(s, 3):
  if (max(x) < sum(x)-max(x)):
    prd = 1
    for i in range(len(x)):
      prd *= c[x[i]]
    ans += prd
print(ans)

Solution (Python):
import itertools


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


cL = list(itertools.combinations(L, 3))

cLlen = len(cL)

for num in range(cLlen):
    if (
        cL[num][0] + cL[num][1] > cL[num][2]
        and cL[num][1] + cL[num][2] > cL[num][0]
        and cL[num][2] + cL[num][0] > cL[num][1]
    ):
        if (
            cL[num][0] != cL[num][1]
            and cL[num][1] != cL[num][2]
            and cL[num][2] != cL[num][0]
        ):
            cnt = cnt + 1


print(cnt)

Solution (Python):
n = int(input())
l = list(map(int,input().split()))
l.sort()
max = len(l)
l.append(10000000000)
ans = 0
for i in range(max-2):
    for j in range(i+1,max-1):
        if l[i] != l[j]:
            k = j+1
            while l[j] == l[k]:
                k += 1
            while l[i] + l[j] > l[k]:
                ans += 1
                k += 1
print(ans)

Solution (Python):
n=int(input())
L=list(map(int,input().split()))
ans=0
for i in range(n):
    for j in range(i):
        for k in range(j):
            q=L[i];w=L[j];e=L[k]
            
            if sum([q,w,e])>max(q,w,e)*2:
                if q!=w and w!=e and e!=q:
                    ans+=1
print(ans)

Solution (Python):
N = int(input())
L = list(map(int, input().split()))
ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            x, y, z = L[i], L[j], L[k]
            if x != y and x != z and y != z:
                if max(x, y, z) < x + y + z - max(x, y, z):
                    ans += 1
print(ans)

Solution (Python):
from itertools import combinations
n = int(input())
l = list(map(int,input().split()))

count = 0
for i,j,k in combinations(range(n),3):
    if i != j and j != k and i != k and l[i] + l[j] > l[k] and l[j] + l[k] > l[i] and l[k]+l[i] > l[j] and l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
        count += 1
print(count)

Solution (Python):
n=int(input())
a_list=list(map(int,input().split()))
ans=0
for i in range(n):
    for j in range(n):
        for k in range(n):
            if i==j or j==k or i==k:
                ans+=0
            elif a_list[i]==a_list[j]or a_list[k]==a_list[i] or a_list[j]==a_list[k]:
                ans+=0
            else:
                
                if max(a_list[i],a_list[j],a_list[k]) < a_list[i]+a_list[j]+a_list[k]-max(a_list[i],a_list[j],a_list[k]):
                    
                    ans+=1
print(ans//6)

Solution (Python):
import numpy as np

N=int(input())
L=np.array(list(map(int,input().split())))
L.sort(axis=0)
c=0
for i,L1 in enumerate(L):
  for j,L2 in enumerate(L[i+1:]):
    if L1==L2:
      continue
    c+=np.count_nonzero(L[i+j+2:]<L1+L2)-np.count_nonzero(L[i+j+2:]==L2)
print(c)

Solution (Python):
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
if n < 3:
    print(ans)
else:
    for i in range(n-2):
        for j in range(i+1, n-1):
            for k in range(j+1, n):
                if l[k] < l[i] + l[j] and l[i] != l[j] and l[j] != l[k]:
                    ans += 1
                
    print(ans)

Solution (Python):
a = int(input())
lengt = list(map(int, input().split()))
lengt.sort(reverse = False)

count = 0

for m, x in enumerate(lengt[:-2]):
  for n, y in enumerate(lengt[m+1:-1]):
    if x == y:
      count += 0
    else:
      for p, z in enumerate(lengt[m+n+1:]):
        if x+y>z and x!=z and y!=z:
          count += 1
        else:
          count += 0

print(count)

Solution (Python):
def CountTriangles(arr, n): 

    count = 0

    for i in range(n): 
        for j in range(i + 1, n): 

            for k in range(j + 1, n): 
                  
                if (arr[i] + arr[j] > arr[k] and 
                    arr[i] + arr[k] > arr[j] and 
                    arr[k] + arr[j] > arr[i] and len(set([arr[i],arr[j],arr[k]]))==3): 
                    count += 1
    return count 


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

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

Solution (Python):




import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5
4 4 9 7 5"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """6
4 5 4 3 3 5"""
        output = """8"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """10
9 4 6 1 9 6 10 6 6 8"""
        output = """39"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """2
1 1"""
        output = """0"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    L = list(map(int, input().split()))
    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            for k in range(j+1, N):
                if L[i] == L[j] or L[j] == L[k] or L[i] == L[k]:
                    continue
                if abs(L[j] - L[k]) < L[i] < L[j] + L[k]:
                    ans += 1
    print(ans)


if __name__ == "__main__":
    
    resolve()

Solution (Python):
from itertools import combinations

n = int(input())
lst = list(map(int, input().split()))
comb = combinations(lst, 3)
count = 0

for i in comb:
  if i[0] != i[1] and i[1] != i[2] and i[0] != i[2]:
    if i[0] + i[1] > i[2] and i[1] + i[2] > i[0] and i[0] + i[2] > i[1]:
      count += 1
    
print(count)

Solution (Python):
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            a,b,c = sorted([l[i], l[j], l[k]])
            if a==b or b==c:
                continue
            if a+b>c and b+c>a and c+a>b:
                ans += 1
print(ans)

Solution (Python):
N = int(input())

lst = input().split()

for i in range(N):
   lst[i] = int(lst[i])



lst.sort()

L = len(lst)

count = 0

if 3 <= L:
   for i in range(L - 2):
      for j in range(i + 1, L - 1):
         if lst[i] != lst[j]:
            for k in range(j + 1, L):
               if lst[i] + lst[j] > lst[k] and lst[i] != lst[k] and lst[j] != lst[k]:
                  count += 1

print(count)

Solution (Python):
def is_triangle(x,y,z):
  return x+y>z and x!=y and y!=z and x!=z
N=int(input())
L=sorted(list(map(int,input().split())))
from itertools import combinations
print(len([(x,y,z) for (x,y,z) in combinations(L,3) if is_triangle(x,y,z)]))

Solution (Python):
N = int(input())
stick = [ int(v) for v in input().split(" ") ]

def check_triangle(i, j, k):
  if i + j > k and j + k > i and i + k > j:
    return True
  return False

num = 0
candidate = []
for i in range(N):
  for j in range(i, N):
    for k in range(j, N):
      if i == j or j == k or i == k:
        continue
      if stick[i] == stick[j] or stick[j] == stick[k] or stick[i] == stick[k]:
        continue
      if check_triangle(stick[i],stick[j],stick[k]):
        
        num += 1
      

print(num)

Solution (Python):
import itertools

N = int(input())
List  = list(map(int,input().split()))
List_triangle = []
count = 0

for triangle in itertools.combinations(List,3):
    List_triangle.append(triangle)

for i in range(len(List_triangle)):
    if len(set(List_triangle[i])) == len(List_triangle[i]):
        if sorted(List_triangle[i])[-1] < sorted(List_triangle[i])[-2] + sorted(List_triangle[i])[-3]:
            count += 1
        else:
            pass
    else:
        pass

print(count)

Solution (Python):
import itertools
n = int(input())
l = list(map(int, input().split()))
lis = list(set(l))

if n < 3:
    print(0)
    exit()
flag = 0
for i in itertools.combinations(lis, 3):
    a = list(i)
    if (a[0] + a[1] > a[2]) and (a[1] + a[2] > a[0]) and (a[0] + a[2] > a[1]):
        max_ = l.count(a[0])*l.count(a[1])*l.count(a[2])
        flag += max_ 
print(flag)

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

Solution (Python):
import itertools

n = int(input())
dt = input()
l = dt.split()
count = 0
for team in itertools.combinations(l,3):
    team1 = list(team)
    for i in range(3):
        team1[i] = int(team1[i])
        
    if team1[0] != team1[1] and team1[1] != team1[2] and team1[0] != team1[2]:
        if team1[0] + team1[1] > team1[2] and team1[0] + team1[2] > team1[1] and team1[1] + team1[2] > team1[0]:
            count += 1

print(count)

Solution (Python):
from sys import stdin
import collections


input = stdin.readline

def main():
    ans = 0
    N = int(input())
    L = list(map(int, input().rstrip().split()))
    l = collections.Counter(L)
    ll = sorted(l.items())
    for i in range(len(ll)):
        for j in range(i):
            for k in range(j):
                if ll[i][0] < ll[j][0] + ll[k][0]:
                    ans += ll[i][1] * ll[j][1] * ll[k][1]
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):



import collections
import sys
import copy
import re
import math
import itertools


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()
    LArray = LI()
    ans = 0
    if N < 3:
        print(ans)
        return

    for v in list(itertools.combinations(LArray, 3)):
        v = list(v)
        v.sort()

        if v[0] == v[1] or v[2] == v[1] or v[0] == v[2]:
            continue
        elif v[0]+v[1] <= v[2]:
            continue
        else:
            ans += 1
        
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
from collections import Counter
from itertools import combinations

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    L = list(map(int, readline().split()))
    count = Counter(L)
    ans = 0
    for a in combinations(count.keys(),3):
        if sum(a)-max(a)*2>0:
            ans += count[a[0]]*count[a[1]]*count[a[2]]
    print(ans)




if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
l=list((map(int,input().split())))
l.sort()
ans=0
for i in range(n-2):
    for j in range(1,n-1):
        for k in range(2,n):
            if i<j<k:
                kari=[l[i],l[j],l[k]]
                if kari[0]!=kari[1]!=kari[2] :
                    if kari[0]+kari[1]>kari[2] and kari[1]-kari[0]<kari[2]:
                        ans+=1    
print(ans)

Solution (Python):
import itertools

n = int(input())

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

li = list(itertools.combinations(li, 3))

count = 0

for i in li:
    amari = sum(i) - max(i)
    if amari > max(i):
        if len(set(i)) == 3:
            count += 1

print(count)

Solution (Python):
import itertools
N = int(input())
L = list(map(int,input().split()))
res = 0
for i in itertools.combinations(L,3):
    i = list(i)
    i.sort()
    if i[0] != i[1] and i[1] != i[2]: 
        if i[2] < i[0]+i[1]:
            res += 1
print(res)

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



import itertools
work_list = list()
for i in itertools.combinations(l, 3):
    if i[0] != i[1] and i[0] != i[2] and i[1] != i[2]:
        work_list.append(i)

def check(set_value):
    if set_value[0] + set_value[1] > set_value[2] and \
       set_value[1] + set_value[2] > set_value[0] and \
       set_value[2] + set_value[0] > set_value[1]:
        return 'ok'
    else:
        return 'ng'
ans = 0
for i in work_list: 
    if check(i) == 'ok':
        ans += 1
print(ans)

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

ans=0
a=len(l)
for i in range(a):
    for j in range(i,a):
        if l[i] == l[j]:
            continue
        for k in range(j,a):
            if l[j]==l[k]:
                continue
            elif l[k]>=l[i]+l[j]:
                continue
            
            ans+=1
        
print(ans)

Solution (Python):
n = int(input())
l = [0 for x in range(n)]
l = list(map(int,input().split()))
l.sort()
cnt = 0
a = 0
b = 0
c = 0
if n < 3:
    print(0)
else:
    for i in range(n-2):
        a = l[i]
        for j in range(i+1,n-1):
            b = l[j]
            for k in range(j+1,n):
                c = l[k]
                if a+b > c and a != b and b != c:
                    cnt += 1
    print(cnt)

Solution (Python):

from itertools import combinations
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    CMB = list(combinations(A, 3))
    ans = 0
    for (i, j, k) in CMB:
        if i==j or i==k or j==k:
            continue
        x = sorted([i,j,k])
        if (sum(x[:2])) > x[-1]:
            ans += 1
    print(ans)

if __name__ == "__main__":
    resolve()

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

l.sort(reverse=True)
ans = 0
if n < 3:
  ans = 0
else:
  for k in range(0, n-2):
    for j in range(k+1, n-1):
      if l[k]/2 > l[j]:
        break
      if l[k] == l[j]:
        continue
      for i in range(j+1, n):
        if l[k] >= l[j] + l[i] or l[j] == l[i]:
          continue
        else:
          ans += 1
print(ans)

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

L.sort()

length = len(L)
count = 0


if N <= 2:
    print("0")

else:
    for i in range(0, length - 2):
        for j in range(i + 1, length - 1):
            for k in range(j + 1, length):
                if (L[i] + L[j] > L[k] and L[i] != L[j] and L[j] != L[k] and L[k] != L[i]):
                    
                    count += 1

    print(count)

Solution (Python):
N = int(input())

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

cnt = 0

for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if a[i] == a[j] or a[j] == a[k] or a[i] == a[k]:
                continue
            if a[i] + a[j] <= a[k] or a[i] + a[k] <= a[j] or a[k] + a[j] <= a[i]:
                continue
            cnt += 1

print(cnt)

Solution (Python):
n = int(input())
l = [ int(x) for x in input().split() ]
l.sort()

if n < 3:
    print(0)
    exit()

c = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1,n):
            if l[i] != l[j] and l[j] != l[k] and l[i] != l[k]:
                if l[i]+l[j] > l[k]:
                    c += 1

print(c)

Solution (Python):
import sys
readline = sys.stdin.readline

N = int(readline().strip())
l = list(map(int, readline().split()))

L = {}
S = []
for i in range(N):
  if l[i] not in L:
    L[l[i]] = 1
    S.append(l[i])
  else:
    L[l[i]] += 1
S.sort()

n = len(S)
ans = 0

if n < 3:
  print(ans)
  exit()

for i in range(n):
  for j in range(i+1, n):
    for k in range(j+1, n):
      if S[k] < S[i] + S[j]:
        ans += L[S[i]] * L[S[j]] * L[S[k]]
print(ans)

Solution (Python):
import itertools

n = int(input())

s = list(map(int,input().split()))
p = list(itertools.combinations(s, 3))


ans = 0
for i in range(len(p)):
    if sum(p[i]) - max(p[i]) > max(p[i]) and len(p[i]) == len(set(p[i])):
        ans = ans + 1
        


print(ans)

Solution (Python):
import itertools
N=int(input())
L=sorted(list(map(int,input().split())))
S=list(itertools.combinations(L,3))
n=int(N*(N-1)*(N-2)/6)
ans=0

for i in range(n) :
    if S[i][0]==S[i][1] or S[i][1]== S[i][2] :
        continue
    if S[i][0]+S[i][1]>S[i][2] :
        ans+=1

print(ans)

Solution (Python):
import itertools
N = int(input())
li = list(map(int, input().split()))
c = 0
for a in itertools.combinations(li, 3):
  b = sorted(a, reverse=True)
  if b[0] != b[1] and b[1] != b[2] and b[2] != b[0]:
    if b[0] < b[1] + b[2]:
      c = c + 1
print(c)

Solution (Python):
import sys
import copy
input = sys.stdin.readline

N=int(input())

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

T.sort()
count=0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if T[i]+T[j]>T[k] and T[i]!=T[j] and T[j]!=T[k] and T[k]!= T[i]:
                count+=1
print(count)

Solution (Python):
import sys
import collections
import itertools
import operator
import bisect
import heapq
import fractions
import math as mt
import copy
import numpy
import scipy

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

lst=list(itertools.combinations(L,3))
cnt=0
for a in lst:
  if a[0]>abs(a[1]-a[2]) and a[0]<a[1]+a[2] and a[0]!=a[1] and a[0]!=a[2] and a[1]!=a[2]:
    cnt+=1
print(cnt)

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
l.sort()
s=0
for i in range(n-2):
    for j in range(i+1,n-1):
        s+=sum([1 for k in l[j+1:] if l[j]<k and k<l[i]+l[j]]) if l[i]<l[j] else 0
print(s)

Solution (Python):
N=int(input())
li = list(map(int,input().split()))
cnt=0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if li[i]!=li[j] and li[i]!=li[k] and li[j]!=li[k]:
                q=[]
                q.append(li[i])
                q.append(li[j])
                q.append(li[k])
                q.sort(reverse=True)
                if q[0]<q[1]+q[2]:
                    cnt+=1
print(cnt)

Solution (Python):
N = int(input())
nums = list(map(int, input().split()))
cnt = 0

for i in range(N):
    for j in range(N):
        for k in range(N):
            tmp_list = [nums[i], nums[j], nums[k]]
            if i >= j or j >= k:
                continue
            if len(tmp_list) != len(set(tmp_list)):
                continue
            else:
                tmp_list.sort()
                if tmp_list[-1] >= sum(tmp_list[:-1]):
                    continue
                else:
                    cnt += 1
print(cnt)

Solution (Python):
N = int(input())
Ln = [int(i) for i in input().split()]

def exist(l1, l2, l3):
    array = [l1, l2, l3]
    array.sort()
    return array[0] + array[1] > array[2]

count = 0
for i in range(N - 2):
    Li = Ln[i]
    for j in range(i + 1, N - 1):
        Lj = Ln[j]
        if Li == Lj:
            continue
        for k in range(j + 1, N):
            Lk = Ln[k]
            if Li == Lk or Lj == Lk:
                continue
            if exist(Li, Lj, Lk):
                count += 1

print(count)

Solution (Python):
N = int(input())
l = list(map(int, input().split()))
q = 0
c = 0
l.sort()
for i in range(N-2):
  for j in range(i+1, N-1):
    for k in range(j+1, N):
      n1 = l[i]
      n2 = l[j]
      n3 = l[k]
      c += 1
      if n1 == n2 or n2 == n3 or n3 == n1:
        continue
      if n1 + n2 > n3:
        q += 1
print(q)