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

if len(set(l)) < 3:
    print("0")
    exit()

result = []
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] 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]:
                result.append([l[i], l[j], l[k]])
print(len(result))

Solution (Python):
N=int(input())
S=list(map(int,input().split()))
d=len(S)
S.sort()
r=0
x=1
b=1
for i in range(N):
  x=1
  while d-2>=i+x:
    b=1
    a=S[i]+S[i+x]
    z=abs(S[i]-S[i+x])
    while d-1>=i+x+b:
      if z<S[i+x+b]<a and S[i]!=S[i+x] and S[i]!=S[i+x+b] and S[i+x]!=S[i+x+b]:
        r+=1
      b+=1
    x+=1
print(r)

Solution (Python):
from itertools import combinations

n = int(input())
ls_str_l = input().split()

if n < 3:
  print(0)
else:
  ls_l = []
  for l in ls_str_l:
    ls_l.append(int(l))
  
  count = 0
  ls_tri_n = list(combinations(ls_l, 3))
  for ls_tri in ls_tri_n:
    if ls_tri[0] == ls_tri[1] or ls_tri[0] == ls_tri[2] or ls_tri[1] == ls_tri[2]:
      continue
    if ls_tri[0] + ls_tri[1] > ls_tri[2] and ls_tri[0] + ls_tri[2] > ls_tri[1] and \
        ls_tri[1] + ls_tri[2] > ls_tri[0] :
      count += 1

  print(count)

Solution (Python):
n = int(input())
l = list(map(int,input().split()))
import itertools
ans = 0
for i in itertools.combinations(l, 3):
    if abs(i[0]-i[1])<i[2] and i[2] < i[0]+i[1] and i[0]!=i[1] and i[1]!=i[2] and i[2]!=i[0]:
        ans += 1
print(ans)

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

if len(set(L)) >= 3:
  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] 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]:
            c += 1
print(c)

Solution (Python):
def tri(a, b, c):
    if abs(b-c) < a and a < (b + c):
        return True
    else:
         return False

def solve():
    N = input()
    L = list(map(int,input().split()))
    ans = set()
    count = 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] or L[i] == L[k] or L[j] == L[k]:
                    
                    pass
                elif tri(L[i], L[j], L[k]):
                    
                    ans.add((i, j, k))
    
    print(len(ans))


if __name__ == "__main__":
    solve()

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

result = 0


for i in range(n-2):
    
    
    for j in range(n-i-1):
        
        
        j += i+1
        for k in range(n-j-1):
            
            
            k+= j+1
            if l[i] == l[j] or l[j] == l[k] or l[i] == l[k]:
                pass
            elif max(l[i], l[j], l[k]) < l[i]+l[j]+l[k]-max(l[i], l[j], l[k]):
                result +=1

print(result)

Solution (Python):
def main():
    N=int(input())
    L=list(map(int,input().split()))
    counter=0
    for i in range(len(L)):
        for j in range(i,len(L)):
            for k in range(j,len(L)):
                if L[i]!=L[j] and L[i]!=L[k] and L[j]!=L[k]:
                    triangle=[L[i],L[j],L[k]]
                    triangle.sort()
                    if triangle[0]+triangle[1]>triangle[2]:
                        counter+=1
    print(counter)
if __name__=="__main__":
    main()

Solution (Python):
import sys

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


ans = 0


for i in range(len(L)):
    for j in range(i+1,len(L)):
        for k in range(j+1,len(L)):
            q = []
            q.append(L[i])
            q.append(L[j])
            q.append(L[k])
            q.sort(reverse=True)
            
            if q[0]<(q[1]+q[2]) and (q[1]-q[2])*(q[1]-q[0])*(q[0]-q[2])!=0:
                ans += 1
                

print(ans)

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

t_count = 0;
three_numbers = list(itertools.combinations(L, 3))


for i in range(len(three_numbers)):
    three_number = three_numbers[i];
    
    li = three_number[0]
    lj = three_number[1]
    lk = three_number[2]
    
    
    

    if li == lj:
        continue;
    elif li == lk:
        continue;
    elif lj == lk:
        continue;

    if li+lj <= lk:
        continue;
    elif li+lk <= lj:
        continue;
    elif lj+lk <= li:
        continue;
    t_count+=1;
            
print(t_count);

Solution (Python):
N=int(input())
li = list(map(int, input().split()))
c=0
ali=[]
for i in range(0,N):
  for j in range(0,N):
    for k in range(0,N):
      if li[i]+li[j]>li[k] and li[j]+li[k]>li[i] and li[k]+li[i]>li[j]:
        if li[i]!=li[j] and li[j]!=li[k] and li[k]!=li[i]:
          if i!=j and j!=k and k!=i and i<j and j<k:
            ali.append(sorted([i,j,k]))
print(len(ali))

Solution (Python):
import itertools

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

count = 0
c_list = list(itertools.combinations(L,3))
for i in range(len(c_list)):
    x = int(c_list[i][0])
    y = int(c_list[i][1])
    z = int(c_list[i][2])
    if x != y and y != z and x != z:
        if x + y > z and x + z > y and y + z > x:
            count +=1
print(count)

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

ans = 0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if int(l[i])==int(l[j]) or int(l[i])==int(l[k]) or int(l[k])==int(l[j]):
                ans += 0
            elif int(l[i])+int(l[j])>int(l[k]) and int(l[i])+int(l[k])>int(l[j]) and int(l[k])+int(l[j])>int(l[i]):
                ans += 1
            else:
                ans += 0
                
if n <= 2:
    print(0)
else:
    print(ans)

Solution (Python):
_ = input()
L = [int(i) for i in input().split()]
L.sort()
def countSmaller(num, L, exclude):
  counter = 0
  for i in L:
    if i==exclude: continue
    if num<=i: break
    
    counter += 1
  return counter

counter = 0
for i in range(len(L)):
  for j in range(i+1, len(L)):
    if L[i]==L[j]: continue
    
    counter += countSmaller(L[i]+L[j], L[j+1:], L[j])
print(counter)

Solution (Python):
from collections import Counter
n = int(input())
l = list(map(int,input().split()))
c = Counter(l)
l = list(set(l))
ans = 0
l.sort()

n = len(l)
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[i]+l[k] > l[j] and l[j]+l[k]>l[i]:
                ans += c[l[i]]*c[l[j]]*c[l[k]]
print(ans)

Solution (Python):
import itertools

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


PL = []
c = 1
for l in L:
    PL.append([c, l])
    c += 1

cnt = 0
result = []
for hen in itertools.combinations(PL, 3):
    if(hen[0][1] + hen[1][1] > hen[2][1] and hen[0][1] + hen[2][1] > hen[1][1] and hen[1][1] + hen[2][1] > hen[0][1] and hen[0][1] != hen[1][1] and hen[1][1] != hen[2][1] and hen[0][1] != hen[2][1]):
        
        result.append(hen)
    

print(len(result))

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

cnt = 0
Aorg = A
Aset = set(A)
Aset = list(Aset)
Aset.sort()
l = []
for i in Aset:
    l.append(Aorg.count(i))
    
for i in range(len(Aset)-2):
    for j in range(i+1,len(Aset)-1):
        for k in range(j+1,len(Aset)):
            if Aset[i] + Aset[j] > Aset[k]:
                cnt += l[i]*l[j]*l[k]
print(cnt)

Solution (Python):
from collections import defaultdict

def main():
    n = int(input())
    l = list(map(int, input().split(" ")))
    ans = 0

    for i1, one in enumerate(l):
        for i2, two in enumerate(l):
            if one>=two:
                continue
            for i3, three in enumerate(l):
                if one>=three or two>=three:
                    continue
                if three - two < one and one < three + two:
                    ans+=1
    print(ans)

if __name__=="__main__":
    main()

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
lst1 = list(map(int,readline().split()))
lst1.sort()
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if lst1[i]+lst1[j] > lst1[k] and lst1[i] != lst1[j] and \
                lst1[i] != lst1[k] and lst1[j] != lst1[k]:
                ans += 1
"""import itertools

for i,j,k in itertools.combinations([i for i in range(n)],3):
    if lst1[i] + lst1[j] > lst1[k]:
        ans += 1"""
print(ans)

Solution (Python):
num = int(input())
nums = [int(i) for i in input().split()]
if num < 3:
    print(0)
    exit()
ans = 0
for i in range(0, num-2):
    for j in range(i+1, num-1):
        for k in range(j+1, num):
            t = [nums[i], nums[j], nums[k]]
            temp = sum(t)
            if (temp - max(t)) > max(t) and len(set(t)) == 3:
                
                ans += 1
print(ans)

Solution (Python):
import itertools
n = int(input())
l = list(map(int, input().split()))
c = itertools.combinations(l, 3)
result = 0

for i in c:
  if abs(i[0] - i[1]) < i[2] and i[2] < i[0] + i[1]:
    if i[0] != i[1] and i[0] != i[2] and i[1] != i[2]:
      result += 1
    else:
      continue
  else:
    continue
    
print(result)

Solution (Python):
N = int(input())
mylist = list(map(int, input().split()))
set = 0

if(N<3):
  print(set)
else:
  for num in range(len(mylist)-2):
    for num2 in range(len(mylist)-1):
      if(num < num2 and mylist[num] != mylist[num2]):
        for num3 in range(N):
          if(num2 < num3 and mylist[num3] != mylist[num] and mylist[num3] != mylist[num2]):
            newlist = [mylist[num], mylist[num2], mylist[num3]]
            if(max(newlist) < sum(newlist)-max(newlist)):
               set += 1
            
  print(set)

Solution (Python):
import itertools as it
N=int(input())
ans=0
K=list(map(int,input().split()))
for i in it.combinations_with_replacement(K,3):
  a=i[0]
  b=i[1]
  c=i[2]
  if a!=b and b!=c and c!=a:
    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()))

l=[]
for i in range(N-2):
    for j in range(i+1,N-1):
        if L[i]!=L[j]:
            for k in range(j+1,N):
                if (L[i]!=L[k])&(L[j]!=L[k]):
                    l.append([i+1,j+1,k+1])
                else:
                    continue
        else:
            continue

answer=[]
for m in range(len(l)):
    L_new=[]
    for n in l[m]:
        L_new.append(L[n-1])
    if max(L_new)<(sum(L_new)-max(L_new)):
        answer.append(l[m])
    else:
        continue

print(len(answer))

Solution (Python):
n = int(input())
l = list(map(int, input().split()))
l.sort()
l += [-999]
val = -9
count = 0
new_list = []
for i in range(n + 1):
    if l[i] == val:
        count += 1
    else:
        new_list += [(val, count)]
        count = 1
        val = l[i]
new_list = new_list[1:]

ans = 0

for first in range(len(new_list) - 2):
    val1 = new_list[first][0]
    amo1 = new_list[first][1]
    second = first + 1
    third = second + 1
    while second < len(new_list) - 1 and third < len(new_list):
        val3 = new_list[third][0]
        amo3 = new_list[third][1]
        val2 = new_list[second][0]
        amo2 = new_list[second][1]

        if val1 + val2 <= val3:
            second += 1
            third = second + 1
        else:
            ans += amo1 * amo2 * amo3
            third += 1
        if second == third:
            third += 1
        elif third == len(new_list):
            second += 1
            third = second+1
print(ans)

Solution (Python):
input()

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

cnt = 0
for i in range(len(sticks)):
    for j in range(i + 1, len(sticks)):
        for k in range(j + 1, len(sticks)):
            si = sticks[i]
            sj = sticks[j]
            sk = sticks[k]
            if si != sj and sj != sk and sk != si:
                if si + sj > sk and sj + sk > si and sk + si > sj:
                    cnt += 1

print(cnt)

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

for i in range(n):
    for j in range(n):
        for k in range(n):
            if (l[i]!=l[j])and(l[j]!=l[k])and(l[k]!=l[i])and(abs(l[i]-l[j])<l[k])and(abs(l[j]-l[k])<l[i])and(abs(l[k]-l[i])<l[j]):
                a += 1
print(a//6)

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):
import collections
from itertools import combinations

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

c = collections.Counter(li)

clist = list(c.keys())
var = len(clist)

ll = combinations(clist,3)

cnt = 0

for i,j,k in list(ll):
    if (i+j>k) and (i+k>j) and (j+k>i):
        cnt += 1*c[i]*c[j]*c[k]
print(cnt)

Solution (Python):

N = int(input())
L_L = [int(x) for x in input().split()]

L_L.sort()
ans = 0

for i in range(N):
    _li = L_L[i]
    for j in range(i+1, N):
        _lj = L_L[j]
        if _li == _lj:
            continue
        for k in range(j+1, N):
            _lk = L_L[k]
            if _li == _lk or _lj == _lk:
                continue
            if _li + _lj > _lk:
                ans += 1


print(ans)

Solution (Python):
num = int(input())
length = [int(s) for s in input().split(' ')]

count = 0

for i in range(num):
    for j in range(i+1, num):
        for k in range(j + 1, num):
            l = [length[i], length[j], length[k]]
            if len(l) == len(set(l)) and max(l) < sum(sorted(l)[:2]):
                count += 1

print(str(count))

Solution (Python):
inpl = lambda: list(map(int,input().split()))
N = int(input())
L = inpl()
L.sort()
ans = 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[j] == L[k]:
                continue
            if L[k] < L[i] + L[j]:
                ans += 1
print(ans)

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

for i in range(len(Lis)):
    for j in range(len(Lis)):
        for k in range(len(Lis)):
            if i < j < k:
                if Lis[i] < Lis[j] < Lis[k]:
                    if (Lis[i] < Lis[j] + Lis[k]) and (Lis[j] < Lis[i] + Lis[k]) and (Lis[k] < Lis[j] + Lis[i]):
                        c += 1
print(c)

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

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

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

Solution (Python):
n = int(input())
temparr = input()
temparr = temparr.split()
arr = []
dicts = {}
for i in temparr:
    i = int(i)
    arr.append(int(i))
    if i not in dicts:
        dicts[i] = 1 
    else:
        dicts[i] += 1 
arr = sorted(arr)


keys = []
for key, value in dicts.items():
    keys.append(key)
keys = sorted(keys)
freq = []
total = 0 
nn = len(keys)

for i in range(nn - 2):
    for j in range(i + 1 , nn - 1):
            for k in range(j + 1, nn ):
                
                if keys[i] + keys[j] <= keys[k]:
                    break 
                total += dicts[keys[i]] * dicts[keys[j]] * dicts[keys[k]]
            
print(total)

Solution (Python):

def istri(a, b, c):
	f = False
	if a == b or b == c or c == a:
		return f
	elif a < b+c and b < c+a and c < a+b:
		f = True
	return f

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):
			if istri(l[i], l[j], l[k]):
				ans += 1
print(ans)

Solution (Python):
import math
def func():
    a=int(input())
    b = list(map(int,input().split()))
    f = [[[0 for i3 in range(100)] for i2 in range(100)] for i1 in range(100)]
    
    
    
    z=0
    for i in range(a-2):
        ii=i
        p=b[ii]
        for j in range(a-1-ii):
            jj=ii+j+1
            q=b[jj]
            for k in range(a-1-jj):
                kk=jj+k+1
                r=b[kk]
                if p+q>r and q+r>p and r+p>q:
                    if p!=q and q!=r and r!=p:
                        z=z+1
    print(z)

func()

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

Solution (Python):
import itertools

n=input()
x=0

s=list(map(int,input().split()))
s2=set(s)
s3=sorted(s2)

s4=list(itertools.combinations(s3,3))

for i in s4:
    if i[0]+i[1]>i[2]:
        x=x+s.count(i[0])*s.count(i[1])*s.count(i[2])

print(x)

Solution (Python):
import itertools

N = int(input())
L = list(map(int, input().split()))
cnt = 0
tmp_l = list(itertools.combinations(L,3))
for ls in tmp_l:
    if (ls[0] + ls[1] > ls[2]) & (ls[1] + ls[2] > ls[0]) & (ls[0] + ls[2] > ls[1]):
        if (ls[0] != ls[1] ) & (ls[1] != ls[2] ) & (ls[0] != ls[2] ):
            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):
            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]:
                    ans += 1
print(ans)

Solution (Python):
def checkValidity(a, b, c):  
      
    
    if (a + b <= c) or (a + c <= b) or (b + c <= a) : 
        return False
    else: 
        return True 
n=int(input())
l=list(map(int,input().split()))
count=0
a,b,c=0,0,0
for i in range(n):
    for j in range(i+1,n):
        if l[j]!=l[i]:
            for k in range(j+1,n):
                if (l[k]!=l[j])and (l[k]!=l[i]):
                    a=l[i]
                    b=l[j]
                    c=l[k]
                    if checkValidity(a, b, c):
                        count=count+1
print(count)

Solution (Python):
import itertools
N = int(input())
L = list(map(int, input().split()))
ans = 0
for x in itertools.combinations(L, 3):
    if max(x)*2 < sum(x) and len(x) == len(set(x)):
        ans += 1
print(ans)

Solution (Python):
N = int(input())
L = list(map(int,input().split()))
if len(L)<3:
    print(0)
else:
    Lrev = sorted(L,reverse=True)
    count = 0
    for i in range(len(L)-2):
        e1 = Lrev[i]
        for j in range(i+1,len(L)-1):
            e2 = Lrev[j]
            if e1!=e2:
                for k in range(j+1,len(L)):
                    e3 = Lrev[k]
                    if e1!=e3 and e2!=e3 and e1<e2+e3:
                        count += 1
            
    print(count)

Solution (Python):
def search(num):
    i = num[0]
    ind = 2
    count = 0

    for j in list(num[1:len(num)]):
        for k in list(num[ind:len(num)]):
            if i != j and i != k and j != k:
                lst = []
                lst.append(int(i))
                lst.append(int(j))
                lst.append(int(k))
                lst.sort()
                if lst[2] < lst[0] + lst[1]:
                    count += 1

        ind += 1

    return count


def main():
    n = int(input())
    num = list(map(int, input().split()))
    
    count = 0
    for i in range(len(num)-2):
        count += search(num[i:len(num)])
    
    print(count)

if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
l=[int(x) for x in input().split()]
dicti={}
for i in range(n):
    if(l[i] in dicti):
        dicti[l[i]]+=1
    else:
        dicti[l[i]]=1
l=set(l)
l=list(l)
l.sort()
cout=0
if(len(l)<3):
    print(0)
else:
    i=0
    j=i+1
    while(i<len(l)-2):
        k=j+1
        while(k<len(l) and l[k]<l[i]+l[j]):
            cout+=(dicti[l[i]]*dicti[l[j]]*dicti[l[k]])
            k+=1
        j=j+1
        if(j==len(l)):
            i+=1
            j=i+1 
    print(cout)

Solution (Python):
import itertools

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

ans = 0
for i in itertools.combinations(l, 3):
    x, y, z = i[0], i[1], i[2]

    if x!=y and y!=z and z!=x and x+y>z and y+z>x and x+z>y:
        ans += 1

print(ans)

Solution (Python):


import itertools
triangle = 0

N = int(input())
L = [int(x) for x in input().split(" ")]


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

print(triangle)

Solution (Python):
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy


def main():
    n = int(input())
    alist = list(map(int, input().split()))
    if n < 3:
        print(0)
        sys.exit()

    s = list(combinations(alist, 3))
    count = 0

    for i in s:
        if not(has_duplicates(i)):
            if i[0]+i[1]>i[2] and i[1]+i[2]>i[0] and i[2]+i[0]>i[1]:
                count += 1

    print(count)

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


if __name__ == '__main__':
	main()

Solution (Python):



def main():
    N = int(input())
    l = list(map(int, input().split()))
    c = 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 li == lk or lj == lk:
                    continue
                if li < lj + lk and lj < li + lk and lk < li + lj:
                    c += 1
    print(c)


if __name__ == "__main__":
    main()

Solution (Python):
import itertools
N=int(input())
L=list(map(int,input().split(' ')))
l=0
T=[]
for u in list(itertools.combinations(L, 3)):
    i,j,k=u
    if 2*max(i,j,k)<i+j+k and i!=k and i!=j and j!=k:
        l=l+1
print(l)

Solution (Python):
def max(a,b):
	if(a>b):
		return a
	else:
		return b

def min(a,b):
	if(a<b):
		return a
	else:
		return b

list = []
def segitiga(a, b, c):

	a=int(a)
	b=int(b)
	c=int(c)

	if(a==b or b==c or a==c):
		return False;
	else:
		x=min(a,min(b,c))
		y=max(min(a,b), min(max(a,b),c))
		z=max(a,max(b,c))
		ans = (x+y >z)
		return ans




n=int(input())
sisi=input()
sisi=sisi.split()
cnt=0
for i in range(n):
	for j in range(i+1,n):
		for k in range(j+1,n):
			if(i!=j and i!=k and j!=k):
				if(segitiga(sisi[i], sisi[j], sisi[k])):
					cnt+=1
print(cnt)

Solution (Python):
N = int(input())
list = list(map(int, input().split()))
mydict = {}
number = []
for i in list:
    if i in mydict.keys():
        mydict[i] += 1
    else:
        mydict[i] = 1
        number.append(i)
number.sort()

count = 0
length = len(number)
if length >= 3:
    for i in range(2,length):
        max = number[i]
        for j in range(0,i):
            for k in range(j+1, i):
                if max < number[j]+number[k]:
                    count += mydict[max]*mydict[number[j]]*mydict[number[k]]

print(count)

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

ls.sort(reverse=True)
ans = 0

for i in range(0, n - 2):
    longest = ls[i]
    for j in range(i + 1, n - 1):
        second = ls[j]
        if longest == second:
            continue
        for k in range(j + 1, n):
            shortest = ls[k]
            if second == shortest:
                continue
            elif longest < second + shortest:
                ans += 1
            else:
                break

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())
K = list(map(int, input().split()))
count = 0

for m in range(N):
    for n in range(m+1, N):
        for l in range(n+1, N):
            if K[m] != K[n] and K[m] != K[l] and K[l] != K[n]:
                now_list = sorted([K[m], K[n], K[l]])
                if now_list[2] < now_list[0] + now_list[1]:
                    count += 1

print(count)

Solution (Python):


import sys
import argparse
import logging


logging.basicConfig(filename='logger.log', level=logging.DEBUG)
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)


def f(n: int, l_list: list, i: int = None, j: int = None, k: int = None) -> int:
    '''
    >>> f(0, [])
    0
    >>> f(1, [1])
    0
    >>> f(2, [1, 1])
    0
    >>> f(3, [1, 1, 1])
    0
    >>> f(3, [1, 1, 2])
    0
    >>> f(3, [1, 2, 2])
    0
    >>> f(3, [1, 2, 3])
    0
    >>> f(3, [1, 2, 4])
    0
    >>> f(3, [1, 3, 4])
    0
    >>> f(3, [2, 3, 4])
    1
    >>> f(5, [4, 4, 9, 7, 5])
    5
    >>> f(6, [4, 5, 4, 3, 3, 5])
    8
    >>> f(10, [9, 4, 6, 1, 9, 6, 10, 6, 6, 8])
    39
    '''
    if n <= 2:
        return 0
    result = 0
    for i in range(0, n-2):
        li = l_list[i]
        for j in range(i+1, n-1):
            lj = l_list[j]
            if li == lj:
                continue
            for k in range(j+1, n):
                lk = l_list[k]
                if li == lk or lj == lk:
                    continue
                
                l_ijk = sorted([l_list[i], l_list[j], l_list[k]])
                if l_ijk[0] + l_ijk[1] > l_ijk[2]:
                    
                    result += 1
    return result


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument(
            '--doctest', action='store_true', default=False)
    args = parser.parse_args()
    if args.doctest:
        import doctest
        doctest.testmod(verbose=True)
        sys.exit()

    n = int(sys.stdin.readline().rstrip())
    l_list = list(map(lambda x: int(x), sys.stdin.readline().rstrip().split()))
    print(f(n, l_list))

Solution (Python):
N = int(input())
L = list(map(int, input().split()))
L = sorted(L)
L = L[::-1]
ans = 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]:
        ans += 0
      elif L[i] == L[k]:
        ans += 0
      elif L[j] == L[k]:
        ans += 0
      elif L[i] < L[j]+L[k]:
        ans += 1
print(ans)

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

l = [int(i) for i in 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] and l[j] != l[k] and l[i] != 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()))
L.sort()
ans=0
for i in range(N-1,0,-1):
  for a in range(i-1,-1,-1):
    for b in range(a-1,-1,-1):
      if L[i]<L[a]+L[b] and L[i]!=L[a]!=L[b]:
        ans+=1
print(ans)

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

L.sort()

L_ = []


tmp = L[0]
k = 1
for i in range(1,N):
    if tmp != L[i]:
        L_.append([tmp,k])
        k=1
    else:
        k += 1
    tmp = L[i]
L_.append([tmp,k])
    
ans = 0

for k in range(len(L_)-1,1,-1):
    for j in range(k-1,0,-1):
        for i in range(j-1,-1,-1):
            if L_[j][0] - L_[i][0] < L_[k][0] and L_[j][0] + L_[i][0] > L_[k][0]:
                ans += L_[i][1]*L_[j][1]*L_[k][1]

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

ans = 0

bou = list(map(int,input().split()))
bou.sort(reverse=True)
l_bou = len(bou)

for i in range(l_bou):
    for j in range(i+1, l_bou):
        for k in range(j+1, l_bou):
            if ((bou[i] != bou[j]) and (bou[j] != bou[k]) and (bou[i] != bou[k])): 
                if (bou[i] < bou[j] + bou[k]):
                    ans += 1

print(ans)

Solution (Python):
N=int(input())
L = list(map(int,input().split()))
count=0
for i in range(0,N):
    A =L[i]
    for j in range(i+1, N):
        B =L[j]
        for k in range(j + 1, N):
            C = L[k]
            X =[A,B,C]
            Y =sorted(X)
            if A==B or B == C or C ==A:
                pass
            elif Y[0] + Y[1] <= Y[2]:
                pass
            else:
                count =count +1

print(count)