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:
import itertools
N = int(input())
L = list(map(int,input().split()))
l_list = list(itertools.combinations(L, 3))
counter = 0
for n in l_list:
    i = n[0]
    j = n[1]
    k = n[2]
    if i != j and j != k and k != i:
        if (i < j + k) and (j < i + k) and (k < i + j):
            counter += 1
print(counter)

Submission status: Accepted

Solution code:
import numpy as np

n=int(input())

a=list(map(int,input().split()))
a.sort(reverse=True)
#print(a)
r=0
for ii in range(len(a)-2):
	for jj in np.arange(ii+1,len(a)-1):
		for kk in np.arange(jj+1,len(a)):
			if a[ii]==a[jj] or a[jj]==a[kk] or a[kk]==a[ii]:
				pass
			else:
				if a[ii]<a[jj]+a[kk]:
					#print(ii,jj,kk,a[ii],a[jj],a[kk])
					r+=1

print(r)

Submission status: Accepted

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

#logging.debug(l)
ans = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j + 1, n):
#            logging.debug("{},{},{}".format(l[i],l[j],l[k]))
            if l[i] + l[j] > l[k] and l[i] != l[j] and l[j] != l[k] and l[i] != l[k]:
#                logging.debug("{},{}".format(l[i] + l[j],l[k]))
                ans += 1
#            logging.debug(ans)
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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


def check(a, b, c):
    if a == b or b == c or a == c:
        return False
    if a < b + c and b < a + c and c < a + b:
        return True
    else:
        return False


count = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            count += check(L[i], L[j], L[k])


print(count)

Submission status: Accepted

Solution code:
n = int(input())
l_list = list(map(int, input().split()))
# print(l_list)
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] or l_list[j] == l_list[k] or l_list[k] == l_list[i]:
                continue
            else:
                total = l_list[i] + l_list[j] + l_list[k]
                max_l = max(l_list[i], l_list[j], l_list[k])
                # print(total)
                # print(max_l)
                if total - max_l*2 > 0:
                    count += 1

print(count)

Submission status: Accepted

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

L = list(reversed(sorted(L)))
cnt = 0
for i1, l1 in enumerate(L):
    for i2, l2 in enumerate(L[i1+1:]):
        for i3, l3 in enumerate(L[(i1 + i2 + 1):]):
            if len(set([l1, l2, l3])) != 3:
                continue
            if l1 >= (l2 + l3):
                break
            cnt += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
Ls = list(map(int, input().split()))
 
# print(N)
# print(Ls)
count = 0 
for i in range(N):
  for j in range(N - (i + 1)):
    # print(i + j)
    for k in range(N - (i + j + 2)):
      # print ( i + j + k)
      # print(i, i + j + 1, i + j + k + 2)
      # print(Ls[i], Ls[i + j + 1], Ls[i + j + k + 2])
      # count += 1
      Ss = sorted([Ls[i],Ls[i + j + 1], Ls[i + j + k + 2]])
      if (Ss[0] + Ss[1] > Ss[2]) and (Ss[0] != Ss[1]) and (Ss[1] != Ss[2]):
        # print(Ss)
        count += 1
print(count)

Submission status: Accepted

Solution code:
import numpy as np

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

result = 0
tmp = []
for i, L1 in enumerate(Ls):
    for j, L2 in enumerate(Ls[i+1:]):
        j+=1+i
        if L1==L2 or len(Ls)<=j:
            continue
        if i==j:
            continue
        for k, L3 in enumerate(Ls[j+1:]):
            k+=1+j
            if L1==L3 or L2==L3:
                continue
            if len(Ls)<=k:
                continue
            if i==k or j==k:
                continue
            tri = [L1,L2,L3]
            arg = np.argmax(tri)
            max_ = 0
            residual = 0
            for l, length in enumerate(tri):
                if arg == l:
                    max_+=length
                else:
                    residual+=length
            if max_<residual:
                result+=1
print(result)

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

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    L = list(map(int, input().split()))

    if N < 3:
        print(0)
        return

    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[i] == L[k] or L[j] == L[k]:
                    continue
                a = sorted([L[i], L[j], L[k]])
                if a[0] + a[1] > a[2]:
                    ans += 1
    print(ans)


main()

Submission status: Accepted

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

c = 0
s = []
l.sort()

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] and l[k] != l[i]:
                c = c + 1

print(c)

Submission status: Accepted

Solution code:
import itertools
n = int(input())
li = list(map(int,input().split()))	
c = 0
L = []

for v in itertools.combinations(li, 3):
    
    #print(v[0],v[1],v[2])
    L.append(v)
  
for i in L:
    if(i[0] == i[1] or i[1] == i[2] or i[2] == i[0]):
        c += 0
    else:
        #print(i[0],i[1],i[2])
        if(i[0] + i[1] > i[2] and i[1] + i[2] > i[0] and i[0] + i[2] > i[1]):
            c += 1

print(c)

Submission status: Accepted

Solution code:
N = int(input())
L = sorted(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 len(set([L[i],L[j],L[k]])) != 3:
                continue
            elif L[i]+L[j]>L[k]:
                cnt += 1
            else:
                continue
print(cnt)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
if N < 3:
    print(0)
    exit()
L = list(map(int, input().split()))
r = 0
for x, y, z in itertools.combinations(L, 3):
    if x == y or x == z or y == z:
        continue
    if x + y > z and y + z > x and z + x > y:
        r += 1
print(r)

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,n):
        for k in range(j,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)

Submission status: Accepted

Solution code:

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
lst = 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):
      a,b,c = lst[i],lst[j],lst[k]
      if (a != b != c != a) and (a+b > c) and (b+c > a) and (c+a > b):
        ans += 1
print(ans)

Submission status: Accepted

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

import itertools
l = list(itertools.combinations(range(1, N + 1), 3))
ans = 0
for c in l:
    a, b, c = sorted([L[c[0]-1], L[c[1]-1], L[c[2]-1]], reverse = True)
    if (a < b + c) and not (a == b or b == c or c == a):
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import collections
n=int(input())
p=input()
ll=[int(n) for n in p.split()]
x=collections.Counter(ll)
y=list(set(ll))
y.sort()
n=len(y)
c=0
for i in range(n-2):
    for l in range(i+1,n-1):
        for j in range(l+1,n):
            if y[i]+y[l]>y[j]:
                c+=x[y[i]]*x[y[l]]*x[y[j]]
print(c)

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

Submission status: Accepted

Solution code:
import itertools

n = int(input())
list = list(map(int, input().split()))
list2 = itertools.combinations(list, 3)

ans = 0
for ele in list2:
    a = ele[0]
    b = ele[1]
    c = ele[2]
    if a == b or b == c or c == a:
        continue
    if abs(a-b) < c and c < a+b:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

n = int(input())
li = list(map(int,input().split()))
li.sort()
count = 0
for i in range(n-1):
    for j in range(i+1,n-1):
        if li[i] == li[j]:
            continue
        else:
            count += len([k for k in li[j+1:] if k < (li[i] + li[j]) and k != li[i] and k != li[j]])
print(count)

Submission status: Accepted

Solution code:
def check(x, y, z):
    return x+y > z and x+z > y and y+z > x

n = int(input())
a = [int(x) for x in input().split()]
ans = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if a[i] != a[j] and a[j] != a[k] and a[i] != a[k] and check(a[i], a[j], a[k]):
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
from itertools import *
n,*a=map(int,open(0).read().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:
import itertools
N = int(input())
L = list(map(int,input().split()))
count=0
p_list=list(itertools.combinations(range(N),3))
for i in p_list:
    if((L[i[0]]!=L[i[1]]) and (L[i[2]]!=L[i[1]]) and (L[i[0]]!=L[i[2]]) ):
        if((L[i[0]]+L[i[1]]> L[i[2]]) and (L[i[1]]+L[i[2]]> L[i[0]]) and (L[i[0]]+L[i[2]]> L[i[1]])):
            count+=1
print(count)

Submission status: Accepted

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

import itertools
itt = list(itertools.combinations(l, 3))
result = 0
for it in itt:
    if len(set(it)) < 3:
        continue
    else:
        tmp = list(it)
        tmp.sort()
        
        if (tmp[0] + tmp[1] > tmp[2]):
            #print(tmp)
            result += 1
print(result)

Submission status: Accepted

Solution code:
N = int(input())
nums = list(map(int, input().split()))
 
set_nums = sorted(list(set(nums)))
set_dup = set_nums.copy()
 
if N <= 2:
    print(0)
else:
    for i, d in enumerate(set_dup):
        count = 0
        for n in nums:
            if n == d:
                count += 1
        set_dup[i] = count
 
    count = 0
    for a in range(len(set_nums)):
        for b in range(a+1, len(set_nums)):
            for c in range(b+1, len(set_nums)):
                if set_nums[a] + set_nums[b] > set_nums[c]:
                    count += set_dup[a] * set_dup[b] * set_dup[c]
    print(count)

Submission status: Accepted

Solution code:
n = int(input())
l = [int(ln) for ln in input().split()]
ans = 0
if len(l) >= 3:
  for i in range(n-2):
    li = l[i]
    for j in range(i+1, n-1):
      lj = l[j]
      if not (li == lj):
        for k in range(j+1, n):
          lk = l[k]
          if not(li == lk) and not(lj ==lk):
            if (li + lj > lk) and (lj + lk > li) and (lk + li > lj):
              ans += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
sticks = {}
for l in L:
  if l in sticks:
    sticks[l] += 1
  else:
    sticks[l] = 1

sticks = sorted(sticks.items(), key=lambda x:x[0])
targetIndexes = [0, 1, 2]
res = 0
while targetIndexes[0] < len(sticks) - 2:
  if abs(sticks[targetIndexes[0]][0] - sticks[targetIndexes[1]][0]) < sticks[targetIndexes[2]][0] < sticks[targetIndexes[0]][0] + sticks[targetIndexes[1]][0]:
    res += sticks[targetIndexes[0]][1] * sticks[targetIndexes[1]][1] * sticks[targetIndexes[2]][1]

  if targetIndexes[2] < len(sticks) - 1:
    targetIndexes[2] += 1
  elif targetIndexes[1] < len(sticks) - 2:
    targetIndexes[1] += 1
    targetIndexes[2] = targetIndexes[1] + 1
  else:
    targetIndexes[0] += 1
    targetIndexes[1] = targetIndexes[0] + 1
    targetIndexes[2] = targetIndexes[1] + 1


print(res)

Submission status: Accepted

Solution code:
num=int(input().rstrip())
m=list(map(int,input().rstrip().split()))
if num<3:
    count=0
else:
    count=0
    for i in range(num-2):
        for j in range(i+1,num-1):
            for k in range(j+1,num):
                if m[i]==m[j] or m[j]==m[k] or m[k]==m[i]:
                    pass
                elif m[i]<m[j]+m[k] and abs(m[j]-m[k])<m[i]:
                    count+=1
print(count)

Submission status: Accepted

Solution code:
n = int(input())
L = [*map(int, input().split())]
M = {}
for l in L:
    if l in M:
        M[l] +=1
    else:
        M[l] = 1
M = list(M.items())
M.sort()
# print(L)
# print(M)
m=len(M)
c=0
for i in range(m):
    for j in range(i+1, m):
        for k in range(j+1, m):
            if M[i][0]+M[j][0] > M[k][0]:
                c += M[i][1] * M[j][1] * M[k][1]
                # print(i,j,k,M[i][0],M[j][0],M[k][0])
                # print(M[i][1],M[j][1],M[k][1])

print(c)

Submission status: Accepted

Solution code:
import sys

def isTriangle(num1, num2, num3):
    if num1 == num2 or num2 == num3 or num3 == num1:
        return False
    if num1 + num2 <= num3 or num1 + num3 <= num2 or num2 + num3 <= num1:
        return False
    return True



n = int(sys.stdin.readline())
line = sys.stdin.readline()

if not "" == line.rstrip():
        nums = line.rstrip().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 isTriangle( int(nums[i]), int(nums[j]), int(nums[k]) ):
                count += 1

print(count)

Submission status: Accepted

Solution code:
def check(a, b, c):  
    if (a + b <= c) or (a + c <= b) or (b + c <= a) : 
        return False
    else: 
        return True

def solve(n, lst):
    count = 0
    for i in range(n-2):
        for j in range(i+1, n-1):
            for k in range(j+1, n):
                if lst[i] != lst[j] and lst[j] != lst[k] and lst[i] != lst[k] and check(lst[i], lst[j], lst[k]):
                    count += 1
    return count

n = int(input())
lst = list(map(int, input().split(' ')))
print(solve(n, lst))

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    l = tuple([int(t)for t in input().split()])

    ans = 0
    for i in range(n):
        for j in range(i+1,n):
            for k in range(j+1,n):
                lst = sorted([l[i],l[j],l[k]])
                if len(set(lst))==3:
                    if lst[2] < lst[0]+lst[1]:
                        ans+=1
    
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import itertools

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

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

for i in range(len(C)):
    C[i] = list(C[i])

count = 0

for j in C:
    if j[0] < j[1] + j[2] and j[0] + j[1] > j[2] and j[0] + j[2] > j[1] :
        if j[0] != j[1] and j[1] != j[2] and j[2] != j[0] :
            count += 1

print(count)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
s = 0
if n <= 2:
  s = 0
else:
  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>c and b+c>a and c+a>b and a != b and b != c and c != a:
          s += 1
print(s)

Submission status: Accepted

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


import itertools

cnt = 0

for x in itertools.combinations(l, 3):
    i = x[0]
    j = x[1]
    k = x[2]
    if i == j or j == k or k == i: continue
    if i + j > k and j + k > i and k + i > j:
        cnt += 1

print(cnt)

Submission status: Accepted

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

cnt = 0
for i, l1 in enumerate(L):
    for j, l2 in enumerate(L[i+1:]):
        if l1 == l2:
            continue
        for k, l3 in enumerate(L[i+j+2:]):
            if (l2 == l3) or (l1 == l3):
                continue

            if (l1 + l2 > l3) and (l2 + l3 > l1) and (l1 + l3 > l2):
                cnt += 1

print(cnt)

Submission status: Accepted

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

import itertools
p = itertools.combinations(L,3)
cnt=0
for v in p:
    if v[0]!=v[1] and v[1]!=v[2] and v[0]!=v[2]:
        if v[0] < v[1]+v[2] and v[1] < v[0]+v[2] and v[2] < v[0]+v[1]:
            cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
import itertools

n = int(input())
ln = [int(num) for num in input().split()]

count = 0
for a, b, c in itertools.combinations(ln, 3):
  if a != b and b != c and c != a:
    if (a + b) > c and (b + c) > a and (c + a) > b:
      count += 1

print(count)

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
count=0
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[c]+l[b]>l[a]:
                if l[a]==l[b] or l[a]==l[c] or l[b]==l[c]:
                    pass
                else:
                    count=count+1
            else:
                pass
print(count)

Submission status: Accepted

Solution code:
import itertools

N = int(input())
L = list(map(int, input().split()))
count=0
iterL = list(itertools.combinations(L,3))

for LL in iterL:
    if LL[0]==LL[1] or LL[0]==LL[2] or LL[2]==LL[1]:
        continue
    LLL = list(LL)
    LLL = sorted(LLL)

    if LLL[0]+LLL[1]>LLL[2]:
        count+=1

print(count)

Submission status: Accepted

Solution code:
import sys
from itertools import product,combinations
from functools import reduce,lru_cache
import heapq

def vfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:f(*x,**kwargs),*lst))

def rvfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:rvfunc(f)(*x,**kwargs) if all(vfunc(lambda y:isinstance(y,list))(x)) else f(*x,**kwargs),*lst))

def reader():return vfunc(lambda l:l.split())(sys.stdin.readlines())

s=reader()
n,l=int(s[0][0]),vfunc(int)(s[1])
print(sum(vfunc(lambda args:((args[0]+args[1])>args[2]) and ((args[0]+args[2])>args[1]) and ((args[1]+args[2])>args[0]))(list(filter(lambda a:a[0]!=a[1] and a[2]!=a[1] and a[0]!=a[2],combinations(l,3))))))

Submission status: Accepted

Solution code:
import itertools

pair_num = 0
N = int(input())
L_list = list(map(int, input().split()))

if len(L_list) < 3:
    print(0)
else:
    for pair in itertools.combinations(L_list, 3):
        if (pair[0] == pair[1]) or (pair[0] == pair[2]) or (pair[1] == pair[2]):
            continue

        if (pair[0] + pair[1] > pair[2]) and (pair[0] + pair[2] > pair[1]) and (pair[1] + pair[2] > pair[0]):
            pair_num += 1

    print(pair_num)

Submission status: Accepted

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

ans = 0

for i in itertools.combinations(L, 3):
  if len(set(i)) ==3 and sum(i) - 2 * max(i) > 0 :
    ans += 1

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
cnt = 0
for i in range(len(l)):
    for j in range(i, len(l)):
        for k in range(j, len(l)):
            if i != j and j != k and k != i:
                if i <= j <= k <= 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]:
                            cnt +=1
print(cnt)

Submission status: Accepted

Solution code:
from itertools import combinations

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

triplets = combinations(sticks, 3)

count = 0
for triplet in triplets:
    if (
        (triplet[0] + triplet[1] > triplet[2])
        and (triplet[0] + triplet[2] > triplet[1])
        and (triplet[1] + triplet[2] > triplet[0])
    ):
        if len(set(triplet)) < 3:
            continue
        count += 1

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

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int,input().split()))
s=0
if N <=2:
  print(0)
else:
  for i in range(N):
    for j in range(N-i-1):
      for k in range(N-j-i-2):
        n1=i
        n2=i+j+1
        n3=i+j+k+2
        if L[n1] + L[n2] >L[n3] and L[n1] + L[n3] >L[n2] and L[n3] + L[n2] >L[n1] and L[n1]!=L[n2] and L[n3]!=L[n2]and L[n1]!=L[n3] :
           s+=1
            
  print(s)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
L = map(int, input().split())
count = 0

for a, b, c in list(itertools.combinations(L,3)):
  if (a == b ) or (b == c) or ( c == a):
    continue
  if ( a + b > c ) and ( b + c > a ) and ( c + a > b ):
    count += 1

print(count)

Submission status: Accepted

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

ans = 0
for i in range(N):
  for j in range(i,N):
    for k in range(j,N):
      ml = max([L[i],L[j],L[k]])
      if(L[i]!=L[k])and(L[i]!=L[j])and(L[j]!=L[k])and((L[i]+L[j]+L[k]-ml)>ml):
        ans +=1
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N=int(input())
L=list(map(int,input().split()))
count=0
for ii in range(N):
    for jj in range(ii+1,N):
        for kk in range(jj+1,N):
            if L[ii]!=L[jj] and L[jj]!=L[kk] and L[kk]!=L[ii] and L[ii]+L[jj]>L[kk] and L[jj]+L[kk]>L[ii] and L[kk]+L[ii]>L[jj]:
                count+=1
print(count)

Submission status: Accepted

Solution code:
# coding:utf-8
import itertools
n = int(input())
l = list(map(int, input().split()))
# print(l)
seq = list(itertools.combinations(l, 3))
# print(seq)
ans = 0

for item in seq:
    if item[0] == item[1] or item[1] == item[2] or item[2] == item[0]:
        continue
    if (item[0] + item[1] > item[2]) and (item[1] + item[2] > item[0]) and (item[2] + item[0] > item[1]):
        ans += 1
print(ans)

Submission status: Accepted

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

ans=0

for v in itertools.combinations(L,3):
  l=sorted(v)
  if len(set(l))==3:
    if l[2]<(l[1]+l[0]):
      ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    l = list(map(int, input().split()))
    ans = 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] or l[i] == l[k] or l[j] == l[k]:
                    continue
                if (l[i] + l[j]) <= l[k] or (l[i] + l[k]) <= l[j] or (l[j] + l[k]) <= l[i]:
                    continue
                ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import itertools

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

count = 0
for list in itertools.combinations(L, 3):
    if(len(set(list)) == 3 and max(list) < (sum(list) - max(list))):
        count += 1
print(count)

Submission status: Accepted

Solution code:

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


n = int(input())
arr = [int(x) for x in input().split()]
if(n<=2):
    print(0)
else:
    print(ans(arr,n))

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]: 
        a,b,c = L[i], L[j], L[k]
        flg = False
        if abs(a-b) < c < a+b:
          flg = True
        elif abs(b-c) < a < b+c:
          flg = True
        elif abs(c-a) < b < c+a:
          flg = True

        if flg: ans += 1

print(ans)

Submission status: Accepted

Solution code:
num_bars = int(input())
length_list = list(map(int,input().split()))
length_list.sort()
#print(length_list)

count = 0

for i in range(num_bars):
  a = length_list[i]
  for j in range(i + 1,num_bars):
    b = length_list[j]
    if a == b:
      continue
    else :
      for k in range(j + 1,num_bars):
        c = length_list[k]
        if b == c:
          continue
        if a + b <= c:
          continue
        count += 1

        
print(count)
        
#  for j in

Submission status: Accepted

Solution code:
import collections
import itertools
n = int(input())
l = list(map(int, input().split()))
c = collections.Counter(l)
ans = 0
p_list = list(itertools.combinations(c, 3))
for e in p_list:
  if e[0] + e[1] > e[2] and e[1] + e[2] > e[0] and e[2] + e[0] > e[1]:
    ans += c[e[0]] * c[e[1]] * c[e[2]]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
hen_list = list(map(int, input().split()))
count = 0

for x in hen_list:
  for y in hen_list:
    for z in hen_list:
      if (z > x and z > y and y > x) and x + y > z:
        count += 1

print(count)

Submission status: Accepted

Solution code:
from collections import Counter
from itertools import combinations

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

def can_triangle(d):
    d.sort()
    a, b, c = d
    return a+b > c


def solve():
    ans = 0
    for c in combinations(C.keys(), 3):
        if can_triangle(list(c)):
            ans += C[c[0]]*C[c[1]]*C[c[2]]
    return ans

if __name__ == "__main__":
    print(solve())

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
# print(l)
lst=[]
cnt=0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            # lst.append((l[i],l[j],l[k]))
            ln=max ( (l[i] , l[j] , l[k]) )
            if l[i]!=l[j] and l[i]!=l[k] and l[j]!=l[k] and ln<(l[i]+l[j]+l[k]-ln):
                cnt+=1
                # print(i+1,j+1,k+1)
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
L= list(map(int, input().split()))
Ls = list(set(L))
res=[]
for i in range(len(Ls)):
  for j in range(i+1,len(Ls)):
    for k in range(j+1,len(Ls)):
      tmp=[Ls[i],Ls[j],Ls[k]]
      if sum(tmp) > 2*max(tmp):
        res.append(tmp)
        
c=0
for i in range(len(res)):
  ctmp=L.count(res[i][0])*L.count(res[i][1])*L.count(res[i][2])
  c+=ctmp
print(c)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    n=int(input())
    l = sorted(map(int, input().split()))
    ll=len(l)
    count = 0
    for x in range(ll-2):
        for y in range(x+1, ll-1):
            if l[x] == l[y]:
                continue
            for z in range(y+1, ll):
                if l[y] == l[z]:
                    continue
                if l[z] < l[x]+l[y]:
                    count += 1
                else:
                    break
    print(count)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import itertools
N = int(input())
L = list(map(int, input().split()))
count =0
for v in itertools.combinations(L, 3):
    a=v[0]
    b=v[1]
    c=v[2]
    if a+b> c and b+c >a and c+a>b:
        if a!=b and b!=c and c!=a:
            count+=1

print(count)

Submission status: Accepted

Solution code:
import itertools
n = int(input())
l = list(map(int, input().split()))
len_list = list(itertools.combinations(l, 3))
answer = 0
for lens in len_list:
  if len(set(lens)) == 3 and lens[0] < lens[1] + lens[2] and lens[1] < lens[0] + lens[2] and lens[2] < lens[0] + lens[1]:
    answer += 1
print(answer)