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.



Sample input:
5
4 4 9 7 5


Sample output:
5

Submission status: Accepted

Solution code:
N = int(input())
L = [int(l) for l in input().split(" ")]

def solve():
  ans = 0
  if len(L) < 3:
    return 0
  for i in range(N):
    for j in range(i, N):
      for k in range(j, N):
        if L[i] != L[j] and\
           L[j] != L[k] and\
           L[k] != L[i]:
          d = {i: L[i], j:L[j], k:L[k]}
          max_idx = max(d, key=lambda x: d[x])
          if sum(d.values()) - 2*L[max_idx] > 0:
            ans += 1# .append((i,j,k))
  return ans

print(solve())

Submission status: Accepted

Solution code:
from itertools import *
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=0
for i,j,k in combinations(a,3):
    if i<j<k and i+j>k:
      ans+=1
print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations
N = int(input())
L = sorted(map(int, input().split()))
ans = 0
for a, b, c in combinations(L, 3):
    if a < b < c and a + b > c:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import bisect

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

cnt = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        if Llist[i] == Llist[j]:
            continue

        res = Llist[j+1:]
        while Llist[j] in res:
            res.pop(0)
        l = Llist[i] + Llist[j]
        cnt += bisect.bisect_left(res, l)

print(cnt)

Submission status: Accepted

Solution code:
N = int(input())

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

M = []
for a in range(N):
  for b in range(a+1,N):
    for c in range(b+1,N):
      if L[a]+L[b]>L[c] and L[a]+L[c]>L[b] and L[b]+L[c]>L[a] \
      and L[a] != L[b] and L[a] != L[c] and L[b] != L[c]:
        M.append((a,b,c))

print(len(M))

Submission status: Accepted

Solution code:
import sys; input = sys.stdin.readline
n = int(input())
lis = 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 lis[i] == lis[j] or lis[j] == lis[k] or lis[i] == lis[k]: continue
			s = sorted([lis[i], lis[j], lis[k]])
			if s[2] < s[1] + s[0]: ans += 1
print(ans)

Submission status: Accepted

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

ans=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] 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]:
                    ans+=1

print(ans)

Submission status: Accepted

Solution code:
import itertools
n = int(input())
l = list(map(int, input().split( )))
pettern = 0
for v in itertools.combinations(l, 3):
    if v[0] != v[1] and v[1] != v[2] and v[2] != v[0]:
        if v[0]+v[1] > v[2] and v[1]+v[2] > v[0] and v[2]+v[0] > v[1]:
            pettern += 1
print(pettern)

Submission status: Accepted

Solution code:
petern = 0
n = input()
Ln = input()
L = list(map(int, Ln.split(' ')))
for i in range(0, len(L)) :
    moji1 = L[i]
    for j in range(i+1, len(L)):
        moji2 = L[j]
        for k in range(j+1, len(L)):
            moji3 = L[k]
            if moji1 != moji2 and moji2 != moji3 and moji3 != moji1 :
                if moji1+moji2 > moji3 and moji2+moji3 > moji1 and moji3+moji1 > moji2 :
                    petern += 1
print(petern)

Submission status: Accepted

Solution code:
N=int(input())
l=list(map(int, input().split()))
s=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 l[i]<l[j]+l[k] and l[j]<l[i]+l[k] and l[k]<l[i]+l[j]:
        s+=1
print(int(s/6))

Submission status: Accepted

Solution code:
from itertools import combinations
def triangle(l_tuple):
  if len(set(l_tuple)) == 3:
    if l_tuple[0] + l_tuple[1] > l_tuple[2] and l_tuple[1] + l_tuple[2] > l_tuple[0] and l_tuple[2] + l_tuple[0] > l_tuple[1]:
      return True
  return False
n = int(input())
l = list(map(int, input().split()))
l_comb = list(combinations(l, 3))
cnt = 0
for i in l_comb:
  if triangle(i):
    cnt += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations

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

cnt = 0
for edges in list(combinations(L, 3)):
  if len(set(edges)) != 3:
    continue
  
  e1 = edges[0] < edges[1] + edges[2]
  e2 = edges[1] < edges[0] + edges[2]
  e3 = edges[2] < edges[0] + edges[1]
  
  if e1 and e2  and e3:
    cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
L = sorted([int(i) for i in input().split()], reverse=True)
# print(L)
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]+L[k] and L[i] != L[j] != L[k]:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
L.sort()
count = 0
#print(L)

len = len(L)

for i in range(len):
    for j in range(i + 1, len):
        for k in range(j + 1, len):
            if (L[i] != L[j]) and (L[j] != L[k]) and (L[k] < L[i] + L[j]):
                #print(L[i], L[j], L[k])
                count += 1

print(count)

Submission status: Accepted

Solution code:
import itertools

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

comb = itertools.combinations(L, 3)

ans = 0

for i in comb:
    i = list(i)
    i.sort()
    
    if i[0] + i[1] > i[2] and (i[0] != i[1] and i[1] != i[2] and i[2] != i[0]):
        ans += 1
    
print(ans)

Submission status: Accepted

Solution code:
# B - Making Triangle

N = int(input())
L = list(int(x) for x in input().split())
L.sort()

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

print(ans)

Submission status: Accepted

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

L = sorted(L)

ans = 0

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

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = sorted(list(map(int, input().split())))
ans = 0
ed = []
for i in range(n):
    for j in range(i):
        for k in range(j):
            if (l[k] != l[j] and l[i] != l[j] and l[k] + l[j] > l[i]):ans+=1

print(ans)

Submission status: Accepted

Solution code:
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] and L[i]+L[j]+L[k] > 2*max(L[i],L[j],L[k])):
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
import itertools

n = int(input())
arr = list(map(int, input().split()))
arr.sort()
count = 0
for i in itertools.combinations(arr, 3):
    if i[0] + i[1] > i[2] and i[0] + i[2] > i[1] and i[2] + i[1] > i[0] and i[0] != i[1] != i[2]:
        count += 1
print(count)

Submission status: Accepted

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

L.sort()
cnt = 0

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

print(cnt)

Submission status: Accepted

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

#sL = sorted(L)
#print(sL)
ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            a, b, c = L[i], L[j], L[k]
            if a==b or a==c or b==c: continue
            if a+b > c and a+c > b and b+c > a:
                ans += 1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L_list = list(map(int, input().split()))
L_list.sort()

count = 0
for i in range(N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            if(L_list[i] != L_list[j] != L_list[k]):
                if(L_list[i] + L_list[j] > L_list[k]):
                    count += 1

print(count)

Submission status: Accepted

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

ans = 0

L.sort() #replace in ordered

for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            L1 = L[i]
            L2 = L[j]
            L3 = L[k]
            if L1 == L2 or L2 == L3 or L3 == L1:
                continue
            if L1 + L2 > L3:
                ans += 1
            else:
                break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
array=list(map(int,input().split()))
array1=sorted(array)
import itertools
list1=list(itertools.combinations(array1,3))
ans=0
for n in range(len(list1)):
  if list1[n][0]!=list1[n][1] and list1[n][1]!=list1[n][2]:
    if list1[n][0]+list1[n][1]>list1[n][2]:
      ans=ans+1
print(ans)

Submission status: Accepted

Solution code:
import itertools
n = int(input())
data = list(map(int, input().split()))
data1=sorted(data)
a = list(itertools.combinations(data1,3))
ans=0
for m in range(len(a)):
  if a[m][0]!=a[m][1] and a[m][1]!=a[m][2]:
    if a[m][0]+a[m][1]>a[m][2]:
      ans=ans+1
print(ans)

Submission status: Accepted

Solution code:
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[k]==l[i]:
                ans+=0
            elif abs(l[i]-l[j])<l[k] and l[k]<l[i]+l[j]:
                ans+=1

print(ans)

Submission status: Accepted

Solution code:
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 i < j and j < k:
        if l[i] == l[j]:
          continue
        if l[i] == l[k]:
          continue
        if l[k] == l[j]:
          continue
        if l[i]+l[j]+l[k] <= max(l[i],l[j],l[k])*2:
          continue
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in l:
    for j in l:
        for k in l:
            if i != j != k != i:
                if i + j > k and j + k > i and k + i > j:
                    ans += 1
print(int(ans/6))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
l_list = list(map(int,input().split()))
l_list.sort()
count = 0
for i in range(0, n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            a = l_list[i]
            b = l_list[j]
            c = l_list[k]
            if a == b or b == c or c == b:
                continue
            if a + b > c:
                count += 1
            else:
                break
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
n = int(input())
data = list(map(int, input().split()))
a = list(itertools.combinations(data,3))
b = []
for i in range(len(a)):
  a[i] = sorted(a[i])
  if a[i][0] != a[i][1] and a[i][1] != a[i][2] and a[i][2] != a[i][0]:
    if a[i][2] < a[i][0] + a[i][1]:
      b.append(a[i])
print(len(b))

Submission status: Accepted

Solution code:

import itertools
N = input()
t = map(int,input().split())
cnt = 0
list = itertools.combinations(t,3)
for i in list:
    if i[0]+i[1]>i[2] and i[1]+i[2]>i[0] and i[2]+i[0]>i[1] and i[0]!=i[1] and i[1]!=i[2] and i[2]!=i[0]:
        cnt += 1
     

print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
L = 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 L[i] < L[j] < L[k] and L[i] + L[j] > L[k]:
                ans += 1
print(ans)

Submission status: Accepted

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

ans=0
for i in range(n-2):
  a=L[i]
  for j in range(i+1,n-1):
    b=L[j]
    if a==b:
      continue
    else:
        for k in range(j+1,n):
          c=L[k]
          if a==c or b==c:
            continue
          else:
            if c<a+b and a<b+c and b<c+a:
                ans+=1
print(ans)

Submission status: Accepted

Solution code:
import sys
n = int(input())
l = list(map(int,input().split()))
counter = 0
if n < 3:
    print(0)
    sys.exit(0)
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            data0 = l[i]
            data1 = l[j]
            data2 = l[k]
            if (data0 != data1) and (data0 != data2) and (data1 != data2):
                if (data0 + data1 + data2 - max(data0,data1,data2)*2) > 0:
                    counter += 1    
print(counter)

Submission status: Accepted

Solution code:
n = int(input())

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

L = sorted([int(x) for x in 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[i] != L[k] and L[i] + L[j] > L[k]:
                count += 1

print(count)

Submission status: Accepted

Solution code:
import collections as col
import itertools as iter

n=int(input())
a=list(map(int,input().split()))
ans = 0
for v in iter.combinations(col.Counter(a).items(), 3):
    a, b, c = map(lambda x: x[0], v)
    if a + b > c and b + c > a and c + a > b:
        p, q, r = map(lambda x: x[1], v)
        ans += p * q * r
print(ans)

Submission status: Accepted

Solution code:
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 2*max(L[i],L[j],L[k]) < L[i]+L[j]+L[k]:
                    ans += 1
                
print(ans)

Submission status: Accepted

Solution code:
N=int(input());ans=0
a=sorted(list(map(int,input().split())))
for i in range(N):
	for j in range(i+1,N):
		for k in range(j+1,N):
			if a[i]!=a[j] and a[j]!=a[k] and a[i]+a[j]>a[k]:ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num = int(input())
list = list(map(int,input().split()))
sorted(list)
count = 0
for i in range(len(list)):
    for j in range(len(list)):
        for k in range(len(list)):
            if ( list[i] < list[j] < list[k] ) and ( list[i] + list[j] >  list[k] ):
                count += 1
print(count)

Submission status: Accepted

Solution code:
n = int(input())
L = list(map(int, input().split()))
 
sL = sorted(L)
ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        if sL[i] == sL[j]: continue
        for k in range(j+1, n):
            if (sL[i] == sL[k]) or (sL[j] == sL[k]): continue
            if (sL[i] + sL[j]) > sL[k]:
                ans += 1
 
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if (
                l[i] != l[j]
                and l[j] != l[k]
                and l[i] > l[k] - l[j]
                and l[k] < l[i] + l[j]
            ):
                ans += 1
print(ans)

Submission status: Accepted

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

sL = sorted(L)
#print(sL)
ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        if sL[i] == sL[j]: continue
        for k in range(j+1, n):
            if (sL[i] == sL[k]) or (sL[j] == sL[k]): continue
            #print( sL[i], sL[j], sL[k] )
            if (sL[i] + sL[j]) > sL[k]:
                ans += 1
                #print(ans)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
n=int(input())
l=list(map(int,input().split()))
L=list(itertools.combinations(l,3))
cnt=0
for i in range(len(L)):
  j=0
  ll=L[i]
  for k in range(3):
    if len(set(list(ll)))!=3:
      j+=1
      break
    if abs(ll[k]-ll[(k+1)%3])<ll[(k+2)%3]<ll[k]+ll[(k+1)%3]:
      j=j
    else:
      j+=1
      break
  if j==0:
    cnt+=1
print(cnt)

Submission status: Accepted

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

f_side = 0
s_side = 0
t_side = 0

triangle_cnt = 0

if n < 3:
    print(triangle_cnt)
else:
    for first in range(n - 2):
        f_side = l[first]
        for second in range(first+1, n - 1):
            s_side = l[second]
            for third in range(second+1, n - 0):
                t_side = l[third]
                if f_side != s_side and f_side != t_side and s_side != t_side:
                    if f_side+s_side > t_side and s_side+t_side > f_side and f_side+t_side > s_side:
                        triangle_cnt += 1

    print(triangle_cnt)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
L.sort()
N = len(L)
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[i] + L[j] <= L[k]:
        break
      else:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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 max(a[i], a[j], a[k]) * 2 < sum([a[i], a[j], a[k]]):
                if a[i] != a[j] and a[i] != a[k] and a[j] != a[k]:
                    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
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 len(set([L[i], L[j], L[k]])) != 3:
                continue
            if not ((L[i] + L[j] > L[k]) and (L[j] + L[k] > L[i]) and (L[k] + L[i] > L[j])):
                continue
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
import  itertools

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

ans = 0
for v in itertools.combinations(l, 3):
    if v[0] == v[1] or v[1] == v[2]:
        continue
    elif v[2] < v[0]+v[1]: ans+=1

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
arr = [int(n) for n in input().split()]
arr.sort()
res = 0
for i in range(N-2):
  for j in range(i+1, N-1):
    for k in range(j+1, N):
      if len({arr[k], arr[i], arr[j]}) == 3 and arr[k] < arr[i] + arr[j]:
        res += 1
print(res)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int,input().split()))
L.sort(reverse=True)

cnt = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            c = L[i]
            b = L[j]
            a = L[k]
            if c < a+b and c > b-a and a != b and b != c and c != a:
                cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
if n < 3:
    print(0)
    exit()

lst = [int(n) for n in input().split()]
ct = 0
for i in range(0, n-2):
    for j in range(i+1, n-1): 
        for k in range(j+1, n): 
            l = sorted([lst[i], lst[j], lst[k]])
            if len(set(l)) == 3:
                m = l.pop()
                if m < sum(l):
                    ct += 1
print(ct)

Submission status: Accepted

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


ans = 0
for i in range(N):
  for j in range(i, N):
    for k in range(j, N):
      if len(list(set([L[i], L[j],  L[k]]))) == 3:
      	#print([L[i], L[j], L[k]])
        if L[k] < L[i] + L[j]:
          ans +=  1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
N = int(input())
L = list(map(int, input().split()))
L_c = sorted(list(L))
cnt = 0
for i in range(len(L)):
    for j in range(i+1,len(L_c)):
        for l in range(j+1,len(L_c)):
            if L_c[i]!=L_c[j] and L_c[j] !=L_c[l] and L_c[l]<L_c[i] +L_c[j]:
                cnt+=1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
from collections import Counter 

n = int(input())
l = list(map(int,input().split()))
w = set(l)
r = Counter(l)
cnt = 0

for i,j,k in itertools.combinations(w,3):
    if i+j>k and j+k>i and k+i>j:
        cnt += (r[i]*r[j]*r[k])
    
print(cnt)

Submission status: Accepted

Solution code:
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 L[i] == L[j] or L[j] == L[k] or L[k] == L[i]:
                continue
            lengths = [L[i], L[j], L[k]]
            lengths.sort()
            if lengths[0] + lengths[1] > lengths[2]:
                count += 1

print(count)

Submission status: Accepted

Solution code:
n = int(input())
tree_lens = list(map(int, input().split()))
ans = 0
tree_lens.sort(reverse=True)
if n <= 2:
    print(ans)
else:
    for i in range(len(tree_lens)):
        for j in range(i + 1, len(tree_lens)):
            for k in range(j + 1, len(tree_lens)):
                if tree_lens[i] < tree_lens[j] + tree_lens[k] \
                        and tree_lens[i] != tree_lens[j] \
                        and tree_lens[j] != tree_lens[k]:
                    ans += 1
    print(ans)

Submission status: Accepted

Solution code:
num = int(input())
input_line = input().split(" ")
num_line = [int(n) for n in input_line]

num_line.sort()

#print(num_line)
del_numlis=[num_line[0]]
item_numlis=[]
counter=1

for i in range(1,num):
    if(num_line[i-1]==num_line[i]):
        counter += 1
    
    else:
        item_numlis.append(counter)
        counter = 1
        del_numlis.append(num_line[i])
        
item_numlis.append(counter)

#print(del_numlis)
#print(item_numlis)

del_numlis_len = len(del_numlis)
result = 0

for i  in range(del_numlis_len - 2):
    tri_1 = del_numlis[i]
    for j in range(i+1,del_numlis_len - 1):
        tri_2 = del_numlis[j]
        for k in range(j+1,del_numlis_len):
            tri_3 = del_numlis[k]
            
            if(tri_1 + tri_2 > tri_3):
                result += item_numlis[i]*item_numlis[j]*item_numlis[k]
            
print(result)

Submission status: Accepted

Solution code:
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 and J != K and K != I and I + J > K and J + K > I and K + I > J:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
l = list(map(int, input().split()))
d = {}

for x in l:
    if x in d.keys():
        d[x] = d[x] + 1
    else:
        d[x] = 1

keys = list(d.keys())
keys.sort()

cnt = 0
for i in range(len(keys)):
    for j in range(i + 1, len(keys)):
        for k in range(j + 1, len(keys)):
            if keys[i] + keys[j] <= keys[k]:
                continue
            cnt += d[keys[i]] * d[keys[j]] * d[keys[k]]

print(cnt)

Submission status: Accepted

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

L.sort()
ans = 0

for i in range(len(L)-2):
    for j in range(i+1, len(L)-1):
        if L[j] == L[i]: continue
        for k in range(j+1, len(L)):
            if L[k] == L[j]: continue
            if L[i] + L[j] > L[k]:
                ans += 1

print(ans)

Submission status: Accepted

Solution code:
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[k] == L[i]:
                continue
            _max = max(L[i], L[j], L[k])
            total = sum([L[i], L[j], L[k]])
            if total - _max > _max:
                ans += 1

print(ans)

Submission status: Accepted

Solution code:
#B
N=int(input())
L=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 L[i]!=L[j] and L[j]!=L[k]:
                if L[i]+L[j]>L[k]:
                    ans+=1
print(ans)

Submission status: Accepted

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

if N<=2:
	print(0)
else:
	L.sort()
	cnt=0
	for i in range(len(L)-2):
		for j in range(i+1,len(L)-1):
			for k in range(j+1,len(L)):
				if L[i]!=L[j] and L[j]!=L[k] and L[i]+L[j]>L[k]:
					cnt+=1
	print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
LS = [int(i) for i in input().split()]

cnt = 0
for idxi, i in enumerate(LS):
  for idxj, j in list(enumerate(LS))[idxi+1:]:
    for k in LS[idxj+1:]:
      if i != j and j != k and i != k:
        m = max(i, j, k)
        l = sum([i, j, k]) - m
        if l > m:
          cnt += 1

print(cnt)

Submission status: Accepted

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

trips = []

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]:
                trips.append([L[i], L[j], L[k]])

ans = 0

for i in trips:
    if max(i) < sum(i) - max(i):
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
import sys

def input():
    return sys.stdin.readline().rstrip('\n')


def calc(N, L):
    d = {}
    for l in L:
        d[l] = (d[l] if l in d else 0) + 1
    M = list(d.keys())
    M.sort(key = lambda x: -x)
    ans = 0
    for i in range(len(M)):
        for j in range(i + 1, len(M)):
            for k in range(j + 1, len(M)):
                if M[i] < M[j] + M[k]:
                    ans += d[M[i]] * d[M[j]] * d[M[k]]
    return ans


N = int(input())
L = [int(s) for s in input().split()]
print(calc(N, L))

Submission status: Accepted

Solution code:
N = int(input())
L = [int(l) for l in input().split(" ")]

count = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            if len(set([L[i], L[j], L[k]])) != 3:
                continue
            ls = sorted([L[i], L[j], L[k]])
            if ls[-1] < sum(ls[:-1]):
                count += 1
print(count)

Submission status: Accepted

Solution code:
n = int(input())
l = [int(_) for _ in input().split()]
print(sum(i < j < k < i + j for i in l for j in l for k in l))

Submission status: Accepted

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

from itertools import combinations

ans = 0
for x in combinations(l, 3):
    if max(x)*2 < sum(x) and len(set(x))==3:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int,input().split()))
point = 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[k] != l[i]:
                if max(l[i],l[j],l[k])*2 < l[i]+l[j]+l[k]:
                    point += 1

print(point)

Submission status: Accepted

Solution code:
N = int(input())
L = [int(x) for x in input().split()]
L = sorted(L)

cn = 0
for k in range(N-2):
    a = L[k]
    for l in range(k+1,N-1):
        b = L[l]
        for m in range(l+1,N):
            c = L[m]
            if a + b > c and a != b and b != c and c != a:
                cn += 1

print(cn)

Submission status: Accepted

Solution code:
import itertools

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

ans=0
lis = sorted(lis)
# print(lis)

for v in itertools.combinations(lis, 3):
    if (not(v[0]==v[1] or v[1]==v[2] or v[0]==v[2])) and (v[0]+v[1]>v[2]):
        # print(v)
        ans+=1

print(ans)