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

for i in range(N-2):
    li = l_list[i]
    a = l_list.count(li)
    if l_list[i] == l_list[i-1]:
        a = 0
    
    for j in range(i+1,N-1):
        lj = l_list[j]
        b = l_list.count(lj)
        if li == lj or lj == l_list[j-1]:
            b = 0
        for k in range(j+1,N):
            lk = l_list[k]
            c = l_list.count(lk)
            if lk == lj or lk == l_list[k-1]:
                c = 0 
            if li + lj > lk:
                total += a*b*c

print(total)

Solution (Python):
from itertools import combinations
import collections


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

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

ans = list(combinations(L, 3))

cnt = 0
for i in range(len(ans)):
    a = ans[i][0]
    b = ans[i][1]
    c = ans[i][2]
    if len(collections.Counter(ans[i])) != 3:
        cnt += 1
    elif not (a + b > c and b + c > a and c + a > b):
        cnt += 1

print(len(ans) - cnt)

Solution (Python):
n=int(input())
s=input().split()
s=[int(i) for i in s]
s.sort()
a=0
for i in range(len(s)-2):
	for j in range(i+1,len(s)-1):
		for k in range(j+1,len(s)):
			if s[i]!=s[j] and s[j]!=s[k] and s[i]+s[j]>s[k]:
				a+=1
				
print(a)

Solution (Python):
import numpy as np
input()
x = list(map(int, input().split()))
x.sort()
x=np.array(x)
ans=0
for i in x[:-2]:
    y = x[x>i]
    for j in y:
        z = y[y>j]
        for k in z:
            if i+j>k:
                ans+=1
print(ans)

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

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

comb=list(itertools.combinations(l,3))
comber=[]
a=[]
kosuu=0
for i in comb:
    a=list(i)
    a.sort()
    comber.append(a)
for i in range(len(comber)):
    if comber[i][2]<comber[i][1]+comber[i][0]:
        if comber[i][0]!=comber[i][1]!=comber[i][2]:
            kosuu+=1
print(kosuu)

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

import itertools
result = 0

for l in itertools.combinations(L, 3):
    if len(set(l)) != 3:continue
    l = list(l)
    l = sorted(l)
    if (l[0]+l[1])>l[2] and l[2]>abs(l[0]-l[1]):result+=1
print(result)

Solution (Python):
import itertools

N = int(input())
L_int_list = list(map(int, input().split()))
L_int_set = set(L_int_list)

ans = 0

if len(L_int_set) < 3:
    print(ans)
    exit()

for i in itertools.combinations(L_int_list, 3):
    if len(set(i)) == 3:
        if max(i) < sum(i) - max(i):
            ans += 1

print(ans)

Solution (Python):

import collections
from functools import lru_cache


def read():
    return input().strip()


def readInt():
    return int(input().strip())


def readList():
    return list(map(int, input().strip().split()))


def solve(N, arr):
    arr.sort()
    ans = 0

    for i in range(N):
        for j in range(i+1, N):
            for k in range(j+1, N):
                a, b, c = arr[i], arr[j], arr[k]

                if len(set([a, b, c])) == 3 and a+b > c:
                    ans += 1

    return ans


N = readInt()
arr = readList()

print(solve(N, arr))

Solution (Python):
import sys
import itertools

n = int(input())

l = sorted(list(map(int, input().split())))
if n < 3 or len(set(l)) < 3:
    print(0)
    sys.exit()
c = list(itertools.combinations(l, 3))
ans = 0
for i in range(len(c)):
    if len(set(c[i])) < 3:
        continue
    if c[i][0] + c[i][1] <= c[i][2]:
        continue
    ans += 1
print(ans)

Solution (Python):
import itertools
n=int(input())
stickl=[]
stickl=input().split()
      
li=list(itertools.combinations(range(n), 3))
count=0
for i in li:
  a=i[0]
  b=i[1]
  c=i[2]
  d=int(stickl[a])
  e=int(stickl[b])
  f=int(stickl[c])
  m=max(d,e,f)
  if d==e or e==f or f==d:
    continue
  if d+e+f>2*m:
    count+=1
print(count)

Solution (Python):
def ok(i,j,k):
    if i<j+k and j<i+k and k<i+j:
        return(True)
    else:
        return(False)

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

an=0
if n<3:
    print('0')
    exit()
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
            else:
                if ok(l[i],l[j],l[k]):
                    an+=1
print(an)

Solution (Python):
import sys
import itertools

sys.setrecursionlimit(10**6)
input = sys.stdin.readline


def main():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()

    if N < 3:
        print(0)
        return
    
    ans = 0
    for i,j,k in itertools.combinations(L, 3):
        if len(set([i, j, k])) != 3:
            continue
        if i + j <= k:
            continue
        ans += 1

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
L = list(map(int, input().split()))
L.append(-1)
L.append(-2)
i =0
j = 0
k = 0
x = 0
for i in range(0,len(L)-2):
  j = i
  k = i
  while not L[1 + j] == -1:
    while not L[2 + k] == -2:
      a,b,c = (L[0+i],L[1+j],L[2+k])
      if not (a == b or a == c or b == c):
        if a+b>c and b+c>a and c+a>b:
          x += 1
      k += 1
    j += 1
    k = j

print(x)

Solution (Python):
def solve():
    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[j] != L[k] and L[k] != L[i]):
                    if(L[i]+L[j] > L[k] and L[j]+L[k] > L[i] and L[k]+L[i] > L[j]):
                        count += 1

    print(count)

if __name__ == "__main__":
    solve()

Solution (Python):



global FLAG_LOG
FLAG_LOG = False


def log(value):
    
    FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    
    N = int(lines[0])
    
    values = list(map(int, lines[1].split()))
    
    
    
    
    
    
    

    
    dct = dict()
    for value in values:
        if value in dct.keys():
            dct[value] += 1
        else:
            dct[value] = 1

    log(dct)

    lengths = list(dct.keys())
    lengths.sort()

    log(f'lengths=[{lengths}]')

    
    lenlen = len(lengths)

    
    if lenlen < 3:
        return [0]

    result = 0
    
    for a in range(lenlen-2):
        for b in range(a+1, lenlen-1):
            for c in range(b+1, lenlen):
                log(str(a) + ':' + str(b) + ':' + str(c))
                log('ABC')
                log(lengths[a])
                log(lengths[b])
                log(lengths[c])
                if lengths[a] + lengths[b] > lengths[c]:
                    result += dct[lengths[a]] * dct[lengths[b]] * dct[lengths[c]]

    return [result]



def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines



def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['5', '4 4 9 7 5']
        lines_export = [5]
    if pattern == 2:
        lines_input = ['6', '4 5 4 3 3 5']
        lines_export = [8]
    if pattern == 3:
        lines_input = ['10', '9 4 6 1 9 6 10 6 6 8']
        lines_export = [39]
    if pattern == 4:
        lines_input = ['2', '1 1']
        lines_export = [0]
    return lines_input, lines_export



def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode



def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    
    
    
    
    
    
    
    
    
    
    



if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict
import numpy as np

if __name__ == '__main__':
    N = int(input())
    L = list(map(int,input().split()))
    L1 = []
    L2 = []
    L.sort()
    L.append(1000000000000)
    c = L[0]
    acc = 0
    for l in L:
        if l != c:
            L1.append(c)
            c = l
            L2.append(acc)
            acc = 1
        else:
            acc += 1

    L3 = list(zip(L1, L2))


    accum = 0

    for i,(i1,i2) in enumerate(L3):
        for j,(j1,j2) in enumerate(L3):
            
            if i >= j:
                continue

            
            lis = list(filter(lambda elem : (i1 + j1 > elem[0]) and (i1 < elem[0]) and (j1 < elem[0]), L3))
            
            
            
            
            if lis != []:
                accum += i2*j2*np.sum(list(elem[1] for elem in lis))

    print(int(accum))

Solution (Python):

N=input()
L =list(map(int, input().split()))
import itertools
combi=list(sorted(itertools.combinations(L,3)))
for i in range(len(combi)):
    combi[i]=sorted(combi[i])
count=0
for i in range(len(combi)):
    if combi[i][2] != combi[i][1] and combi[i][2] != combi[i][0] and combi[i][1] != combi[i][0]:
        if combi[i][2] < combi[i][1] + combi[i][0]:
            count +=1
print(count)

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

count = 0
for i in range(0, 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 int(l[i]) + int(l[j]) > int(l[k]) and int(l[i]) + int(l[k]) > int(l[j]) and int(l[j]) + int(l[k]) > int(l[i]):
        count += 1
        pass
      else:
        pass

print(count)

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

ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        if (Ln[i] == Ln[j]):
            continue
        for k in range(j+1, N):
            if (Ln[i] == Ln[k] or Ln[j] == Ln[k]):
                continue
            if Ln[i] + Ln[j] > Ln[k]:
                ans += 1
print(ans)

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

l = [int(x) for x in input().split()]
if(n<=2):
    print(0)
else:
    
    d = {}
    ss = set();
    for i in l:
        if( i in d.keys()):
            d[i]+=1;
        else:
            d[i] =1
            ss.add(i)
    s = list(ss)
    len = len(s)
    count = 0
    for i in range(len):
        for j in range(i+1,len):
            for k in range(j+1,len):
                if(s[i] + s[j] >s[k] and s[i] + s[k] > s[j] and s[j] + s[k] > s[i]):
                    count = count + d[s[i]] * d[s[j]] * d[s[k]]
    print(count)

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

ans=0

for i in range(N):
    for j in range(N):
        for k in range(N):
            if L[i]!=L[j] and L[k]!=L[j] and L[i]!=L[k] :
                if (L[i]+L[j]>L[k]) and (L[k]>abs(L[i] - L[j])):
                    ans += 1
print(ans//6)

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):
            I=l[i]
            J=l[j]
            K=l[k]
            if I+J>K and J+K>I and K+I>J and I!=J and I!=K and J!=K:
                ans+=1
print(ans)

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

def has_duplicates(seq):
    return len(seq) != len(set(seq))

SList=list(itertools.combinations(List,3))


ans=0

for i in range(len(SList)):
    
    if has_duplicates(SList[i])==False:
        C=sorted(SList[i])[::-1]
        
        if C[2]+C[1]>C[0]:
            ans+=1
            
    
print(ans)

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[i] == L[k]) or (L[j] == L[k])):
        continue
      
      if (((L[i] + L[j]) > L[k])
          and ((L[j] + L[k]) > L[i])
          and ((L[k] + L[i]) > L[j])):
        
        count += 1

print(count)

Solution (Python):
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    N = int(input())
    L = read_list()
    res = 0
    for i in range(N):
        for j in range(i + 1, N):
            for k in range(j + 1, N):
                T = [L[i], L[j], L[k]]
                if len(set(T)) == 3 and sum(T) > 2 * max(T):
                    res += 1
    print(res)



if __name__ == "__main__":
    main()

Solution (Python):
_n = int(input())
_lengths = list(map(int, input().split(" ")))
_lengths.sort()

_pre = 0
_index = -1
_sticks = []
for _length in _lengths:
  if _pre != _length:
    _sticks.append([_length, 1])
    _index += 1
    _pre = _length
  else:
    _sticks[_index][1] +=1

_counter = 0
if len(_sticks) >= 3:
  for _i in range(len(_sticks)):
    for _j in range(_i+1, len(_sticks)):
      for _k in range(_j+1, len(_sticks)):
        if _sticks[_i][0] + _sticks[_j][0] > _sticks[_k][0]:
          _counter += _sticks[_i][1] * _sticks[_j][1] * _sticks[_k][1] 
print(_counter)

Solution (Python):
n=int(input())
c=sorted(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):
            if c[i] != c[j] and c[k] != c[i] and c[k] != c[j]:
                if c[i] + c[j] > c[k]:
                    ans += 1
print(ans)

Solution (Python):
import itertools

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

def triang(a,b,c):
  f0 = not ( (a==b) or (b==c) or (c==a) )
  f1 = (a+b>c) and (b+c>a) and (c+a>b)
  return f0 and f1

count=0
for t in itertools.combinations(L,3):
   if triang(*t):
      count+=1

print(count)

Solution (Python):
N=int(input())
hk=list(input().split())
h=[int(s) for s in hk]
count=0
if N>2:
  for x in range(N):
    for y in range(N):
      for z in range(N):
        if h[x]!=h[y] and h[y]!=h[z] and h[z]!=h[x]:
          if h[x]+h[y]>h[z] and h[y]+h[z]>h[x] and h[z]+h[x]>h[y]:
            count+=1
count=count//6
print(count)

Solution (Python):
import itertools
def has_duplicates(seq):
    return len(seq) != len(set(seq))

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

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

ans = 0
for i in range(len(C)):
    if has_duplicates(list(C[i])):
        continue
    elif list(C[i])[2] >= list(C[i])[0] + list(C[i])[1]:
        continue
    else:
        ans += 1

print(ans)

Solution (Python):
from collections import Counter

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

c = Counter(L)
L = list(set(list(L)))

L.sort()

res = 0

for i in range(len(L) - 2):
  k = i
  for j in range(i + 1, len(L) - 1):
    while k < len(L) and L[k] < L[i] + L[j]:
      k += 1
    
    for p in range(j + 1, k):
      res += c[L[i]] * c[L[j]] * c[L[p]]

print(res)

Solution (Python):

import itertools

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

cnt = 0
all_cnt = 0

def has_duplicates(seq):
    return len(seq) != len(set(seq))

for pair in itertools.combinations(L, 3):
    all_cnt += 1
    if has_duplicates(pair):
        pass
    else:
        b0 = max(pair)
        pair = set(pair) - {b0}
        b1 = list(pair)[0]
        b2 = list(pair)[1]

        if b0 - b1 < b2 < b0 + b1:
            cnt += 1

print(cnt)

Solution (Python):
import itertools

mm = int(input())
kk = list(map(int, input().split()))
pp = list(set(kk))
answer_=[]

if len(kk)<2:
  answer=0
else:
  for qq in itertools.combinations(pp, 3):
    rr = list(qq)
    rrr = sorted(rr)
    a = rrr[0]
    b = rrr[1]
    c = rrr[2]
    if a+b>c:
      aa = kk.count(a)
      bb = kk.count(b)
      cc = kk.count(c)
      d = aa*bb*cc
      answer_.append(d)
    else:
      answer_.append(0)
  answer = sum(answer_)
  
print(answer)

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

Solution (Python):
n=int(input())
x=list(map(int,input().split()))
x=sorted(x,reverse=True)
cnt=0
for i in range(0,n-2):
 l1=x[i]
 for j in range(i+1,n-1):
  l2=x[j]
  for k in range(j+1,n):
   l3=x[k]
   if l1<l2+l3 and l1!=l2 and l2!=l3:
      cnt+=1
print(cnt)

Solution (Python):
import itertools

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

lst=list(itertools.combinations(seq,3))


ans=0

for i in range(len(lst)):
    if lst[i][0]!=lst[i][1]:
        if lst[i][0]!=lst[i][2]:
            if lst[i][1]!=lst[i][2]:
                if lst[i][0]+lst[i][1] > lst[i][2]:
                    if lst[i][1]+lst[i][2] > lst[i][0]:
                        if lst[i][0]+lst[i][2] > lst[i][1]:
                            ans = ans+1
print(ans)

Solution (Python):
N=int(input())
Llist=list(map(int,input().split(' ')))
count=0
Llist_sorted=sorted(Llist)
for i in range(N):
    tri=[]
    tri_i=tri+[Llist_sorted[i]]
    for j in range(i+1,N):
        tri=tri_i
        tri_ij=tri+[Llist_sorted[j]]
        for k in range(j+1,N):
            tri=tri_ij
            tri_ijk=tri+[Llist_sorted[k]]
            if tri_ijk[0]<tri_ijk[1]<tri_ijk[2] and tri_ijk[0]+tri_ijk[1]>tri_ijk[2]:
                count+=1
print(count)

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

if n <= 2:
  print(0)
  exit()

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

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

length.sort()
cnt = 0
y_start = 1
for i in range(0, len(length)-2, 1):
    a = length[i]
    for j in range(i+1, len(length)-1, 1):
        b = length[j]
        for k in range(j+1, len(length), 1):
            c = length[k]
            if a == b or b == c:
                continue
            if (a+b) > c:
                cnt += 1

print(cnt)

Solution (Python):
N = int(input())
x = list(map(int,input().split()))
i = 0
j = 0
k = 0
tri = 0
for i in range(0,N):
    s1 = x[i] 
    j = 0
    for j in range(i+1,N):
        s2 = x[j]
        k = 0
        if s1 != s2:
            for k in range(j+1,N):
                s3 = x[k]
                if s1 != s3 and s2 != s3:
                    sum_1 = s1 + s2
                    sum_2 = s2 + s3
                    sum_3 = s3 + s1
                    if sum_1 > s3 and sum_2 > s1 and sum_3 > s2:
                        tri += 1
print(tri)

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

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

ans = 0
for i in range(N):
    li = L[i]
    for j in range(i+1, N):
        lj = L[j]
        if li == lj:
            continue
        for k in range(j+1, N):
            lk = L[k]
            if lk in [li, lj]:
                continue
            lMax = max(li, lj, lk)
            ans += li + lj + lk - lMax > lMax

print(ans)

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

n = int(input())
l_list = list(map(int, input().split()))
p_list = list(itertools.permutations(l_list, 3))
p_list = list(filter(lambda e: len(set(e)) == len(e), p_list))

if len(p_list) < 3:
    print(0)
else:
    count = 0
    for p in p_list:
        if p[0] < p[1] < p[2] and p[2] < p[0] + p[1]:
            count += 1
    print(count)

Solution (Python):
import sys,bisect,string,math,time,functools,random,fractions
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
rep=range;R=range
def Golf():n,*t=map(int,open(0).read().split())
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def MI():return map(int,input().split())
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def RA():return map(int,open(0).read().split())
def RLI(n=8,a=1,b=10):return [random.randint(a,b)for i in range(n)]
def RI(a=1,b=10):return random.randint(a,b)
def Rtest(T):
    case,err=0,0
    for i in range(T):
        inp=INP()
        a1,ls=naive(*inp)
        a2=solve(*inp)
        if a1!=a2:
            print((a1,a2),inp)
            err+=1
        case+=1
    print('Tested',case,'case with',err,'errors')
def GI(V,E,ls=None,Directed=False,index=1):
    org_inp=[];g=[[] for i in range(V)]
    FromStdin=True if ls==None else False
    for i in range(E):
        if FromStdin:
            inp=LI()
            org_inp.append(inp)
        else:
            inp=ls[i]
        if len(inp)==2:
            a,b=inp;c=1
        else:
            a,b,c=inp
        if index==1:a-=1;b-=1
        aa=(a,c);bb=(b,c);g[a].append(bb)
        if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'
    
    mp=[boundary]*(w+2);found={}
    for i in R(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def accum(ls):
    rt=[0]
    for i in ls:rt+=[rt[-1]+i]
    return rt
def bit_combination(n,base=2):
    rt=[]
    for tb in R(base**n):s=[tb//(base**bt)%base for bt in R(n)];rt+=[s]
    return rt
def gcd(x,y):
    if y==0:return x
    if x%y==0:return y
    while x%y!=0:x,y=y,x%y
    return y
def YN(x):print(['NO','YES'][x])
def Yn(x):print(['No','Yes'][x])
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

mo=10**9+7
inf=float('inf')
FourNb=[(-1,0),(1,0),(0,1),(0,-1)];EightNb=[(-1,0),(1,0),(0,1),(0,-1),(1,1),(-1,-1),(1,-1),(-1,1)];compas=dict(zip('WENS',FourNb));cursol=dict(zip('LRUD',FourNb))
l_alp=string.ascii_lowercase

read=sys.stdin.buffer.read;readline=sys.stdin.buffer.readline;input=lambda:sys.stdin.readline().rstrip()


show_flg=False
show_flg=True

ans=0

n=I()
l=LI()

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

Solution (Python):
import itertools

def duplicate(x):
    return len(x) != len(set(x))

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

cnt = 0

for team in itertools.combinations(S, 3):
    
    if duplicate(team) == True:
        continue
    else:
        if max(team) < sum(team) - max(team):
            cnt += 1
        else:
            continue

print(cnt)

Solution (Python):
N=int(input())
L=list(map(int,input().split()))
L.sort()
c=0
for s in range(N-2):
	for t in range(s+1,N-1):
		two=L[s]+L[t]
		if L[s] != L[t]:
			for u in range(t+1,N):
				if L[u] == L[t]:
					c+=0
				elif two > L[u]:
					c+=1
					
				else:
					break
print(c)

Solution (Python):
import itertools

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

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 = l[i]
            b = l[j]
            c = l[k]
            if a != b and b != c and c != a and a + b > c and b + c > a and c + a > b:
                ans += 1
print(ans)

Solution (Python):
import bisect
import collections
n=int(input())
l=sorted(list(map(int,input().split())))
a=sorted(list(set(l)))
num=len(a)
d=collections.Counter(l)
ans=0
for i in range(num-2):
  for j in range(i+1,num-1):
    c=a[i]+a[j]
    K= bisect.bisect_left(a, c)
    for k in range(j+1,K):
      ans+=d[a[i]]*d[a[j]]*d[a[k]]
print(ans)

Solution (Python):
s=int(input())
a = list(map(int,input().split()))
c=[0]*3
count =0
if len(a)>=3:
    for i in range(0,s-2):
        c[0]=a[i]
        for j in range(i+1,s-1):
            c[1]=a[j]
            for k in range(j+1,s):
                c[2]=a[k]
                b=sorted(c,reverse=True)
                if b[0]!=b[1] and b[2]!=b[1] and b[0]!=b[2] and b[0]<b[1]+b[2]:
                    count+=1
print(count)

Solution (Python):
import collections
import itertools
def resolve():
    n = int(input())
    l = list(map(int, input().split()))
    c = collections.Counter(l)
    keys = c.keys()
    key_combinations = set(itertools.combinations(keys, 3))

    result = 0
    for combination in key_combinations:
        max_key = max(combination)
        if sum(combination) - max_key > max_key:
            
            one_combination_result = 1
            for key in combination:
                one_combination_result = one_combination_result * c[key]
            result += one_combination_result
    print(result)
resolve()

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

Solution (Python):
N=int(input())
L=map(int,input().split())
L=list(L)
L_un=list(set(L))
Lunc=len(L_un)
b=0

for i in range(0,Lunc):
    for m in range(i+1,Lunc):
        for n in range(m+1,Lunc):
            if L_un[i]+L_un[m]>L_un[n] and L_un[m]+L_un[n]>L_un[i] and L_un[n]+L_un[i]>L_un[m]:
                c_i=L.count(L_un[i])
                c_m=L.count(L_un[m])
                c_n=L.count(L_un[n])
                
                b+=c_i*c_m*c_n

print(b)

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



cnt = 0
startnum = 1
secondstartnum = 2

    



        









import itertools
for pair in itertools.combinations(l_lst, 3):
    
    if pair[0] + pair[1] > pair[2] and pair[1] + pair[2] > pair[0] and pair[2] + pair[0] > pair[1]:
        if pair[0] != pair[1] and pair[1] != pair[2] and pair[2] != pair[0]:
            
            cnt += 1

print(cnt)

Solution (Python):
from itertools import combinations

n = int(input())
num_list = list(map(int, input().split()))
combination = combinations(num_list, 3)
count = 0
for i in combination:
  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):
def mulit(a):
  a_copy = list(a)
  return len(a) == len(set(a_copy))
def isTriangle(x):
  return x[0] + x[1] > x[2]

N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
a_len = len(A)
answer = []
for i in range(0, a_len-2):
  for j in range(i+1, a_len-1):
    for k in range(j+1, a_len):
      answer.append([A[i], A[j], A[k]])
      
answer = [i for i in answer if mulit(i)]
answer = [i for i in answer if isTriangle(i)]
answer_len = len(answer)
print(f"{answer_len}")

Solution (Python):
n=int(input()) 
l = list(map(int,input().split())) 
if n<=2:
  print(0)
  exit()
  
cnt = 0
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[j]-l[k])*(l[k]-l[i])==0:
        continue
      if l[i]<l[j]+l[k] and l[j]<l[i]+l[k] and l[k]<l[i]+l[j]:
        cnt+= 1
print(cnt)

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

count = 0

def has_duplicates(seq):
    return len(seq) != len(set(seq))

for i in range(0, n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            threenum_list = [length_list[j],length_list[k], length_list[i]]
            if not has_duplicates(threenum_list):

                if (abs(length_list[j]-length_list[k]) < length_list[i]) and (length_list[i] < length_list[j] + length_list[k]):
                    if (abs(length_list[k] - length_list[i]) < length_list[j]) and (length_list[j] < length_list[i] + length_list[k]):
                        if (abs(length_list[i] - length_list[j]) < length_list[k]) and (length_list[k] < length_list[j] + length_list[i]):
                            count += 1


print(count)

Solution (Python):
n = int(input())
l = list(map(int, input().split()))
cnt = 0
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])&(l[i]+l[k]>l[j])&(l[k]+l[j]>l[i])&(l[i]!=l[j])&(l[i]!=l[k])&(l[k]!=l[j]):
                cnt += 1
print(cnt)

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

ans = 0
a = b = c = 0

for fi in range(n):
    for si in range(fi+1,n):
        for ti in range(si+1,n):
            a = l[fi]
            b = l[si]
            c = l[ti]
            if a == b or b == c or c == a:
                pass
            else:
                if a+b > c and b+c > a and c+a > b:
                    ans += 1 
print(ans)