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


def main():
    n = int(input())
    l = list(map(int, input().split()))
    c = Counter(l)
    s = list(c.keys())

    ans = 0
    for item in combinations(s, 3):
        item = sorted(item)
        if item[2] < item[0] + item[1]:
            ans_this = 1
            for i in item:
                ans_this *= c[i]
            ans += ans_this
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

def calc(a, b, c):
    max = a
    mid = b
    min = c

    if a < b:
        max = b
        mid = a
        min = c
    if a < c:
        max = c
        mid = a
        min = b
    if abs(mid-min) < max and max < mid + min:
        return True
    else:
        return False

for i in range(0, N):
    for k in range(i + 1, N):
        for l in range(k+ 1, N):
            if L[i] != L[k] and L[k] != L[l] and L[l] != L[i]:
                if calc(L[i], L[k], L[l]) == True:
                    count += 1
print(str(count))

Submission status: Accepted

Solution code:
import itertools


num_sticks = int(input())

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

stick_combinations = list(itertools.combinations(sticks, 3))

counter = 0

for a, b, c in stick_combinations:
    if a == b or b == c or c == a:
        continue

    if abs(b - c) < a < (b + c):
        counter += 1

print(counter)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int,input().split()))
length = len(l)
count = 0
if length < 3:
    print(0)
    exit()

for i in range(length-2):
    for j in range(i+1,length-1):
        for k in range(j+1,length):
            if len(set([l[i],l[j],l[k]])) == 3:
                li = sorted([l[i],l[j],l[k]])
                if li[0] + li[1] > li[2]:
#                    print(i+1,j+1,k+1)
#                    print(li)
#                    print(l[i],l[j],l[k])
                    count+=1

print(count)

Submission status: Accepted

Solution code:
from collections import Counter
import numpy as np


num_bar = int(input())
bar_list = list(map(int, input().split()))
counter = Counter(bar_list)
bars = np.unique(bar_list)

ans = 0
for longest in bars:
    for b1 in bars:
        min_b2 = longest - b1
        if min_b2 <= 0:
            continue
        target = bars[(bars < longest) & (bars > min_b2)]
        for t in target:
            if t - b1 >= 0:
                continue
            ans += counter[longest] * counter[b1] * counter[t]

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
L = list(map(int,input().split()))
L = sorted(L)
ans = 0
if n >= 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] or L[j] == L[k] or L[i] == L[k]:
                    pass
                else:
                    if L[i] + L[j] > L[k]:
                        if L[j] + L[k] > L[i]:
                            if L[i] + L[k] > L[j]:
                                ans += 1
            
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

lista = input().split(' ')
lista = list(map(int, lista))

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



print(count)

Submission status: Accepted

Solution code:
import math

n = int(input())
lL = sorted(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([lL[i], lL[j], lL[k]])) != 3:
                continue
            sm, no, lo = sorted([lL[i], lL[j], lL[k]])
            if lo < no + sm:
                ans += 1

print(ans)

Submission status: Accepted

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

import itertools

count = 0
L = sorted(L)
Cmb = itertools.combinations(L,3)
for cmb in Cmb:
    a = cmb[0]
    b = cmb[1]
    c = cmb[2]
    if not(a == b or b == c or c == a):
        if a + b > c:
            count += 1
print(count)

Submission status: Accepted

Solution code:
import collections

def main():
    N = input()
    LList = list(map(int, input().split()))
    LListLen = len(LList)

    answer = 0

    if(LListLen < 3):
        print(answer)
        return

    for i in range(LListLen):
        a_key = LList[i]
        
        for j in range(i, LListLen):
            b_key = LList[j]

            if a_key == b_key:
                continue

            for k in range(j, LListLen):
                c_key = LList[k]

                if (a_key == c_key) or (b_key == c_key):
                    continue
                
                if (a_key + b_key > c_key) and (b_key + c_key > a_key) and (c_key + a_key > b_key):
                    answer = answer + 1

    print(answer)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
T = []
cnt = 0

import itertools

for t in itertools.combinations(L, 3):
  if len(set(t)) == len(list(t)):
                        T.append(list(t))
  
for i in range(len(T)):
  T[i].sort()
  if T[i][0] + T[i][1] > T[i][2]:
    cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
nn = int(input())
ll = list(map(int,input().split()))

uniqlen = sorted(set(ll),reverse=True)
mydb = [[0]*2 for i in range(len(uniqlen))]
for ind in range(len(uniqlen)):
    mydb[ind][0] = uniqlen[ind]
    mydb[ind][1] = ll.count(uniqlen[ind])

ans = 0

for i in range(len(mydb)):
    for j in range(i+1,len(mydb)):
        for k in range(j+1,len(mydb)):
                if max([mydb[i][0],mydb[j][0],mydb[k][0]])*2 < sum([mydb[i][0],mydb[j][0],mydb[k][0]]):
 #                   print(mydb[i][0],mydb[j][0], mydb[k][0])
                    ans += mydb[i][1]*mydb[j][1]*mydb[k][1]

print(ans)

Submission status: Accepted

Solution code:
import itertools

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

for p in itertools.combinations(L, 3):
  if len(set(p)) != 3:
    continue
  else:
    if p[0] < p[1] + p[2] and p[1] < p[0] + p[2] and p[2] < p[0] + p[1]:
      count += 1
print(count)

Submission status: Accepted

Solution code:
N=int(input())
bou=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):
            max_bou=max(bou[i],bou[j],bou[k])
            if ((bou[i]!=bou[j]) and (bou[j]!=bou[k]) and (bou[k]!=bou[i])):
                if bou[i]+bou[j]+bou[k]-max_bou>max_bou:
                    count=count+1
print(count)

Submission status: Accepted

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

count = 0

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

print(count)

Submission status: Accepted

Solution code:
N = int(input())

line = input().split()

num1 = 0
num2 = 0
temp = 0
ans = 0

for i in range(N) :
    num1 = int(line[i])
    for j in range(i+1,N) :
        if int(line[j]) != num1 :
            num2 = int(line[j])
            temp = j
            for k in range(temp+1,N) :
                temp = int(line[k])
                if temp == num1 or temp == num2 :
                    continue
                if num1 + num2 > temp and num1 + temp > num2 and num2 + temp > num1 :
                    ans += 1


print(ans)

Submission status: Accepted

Solution code:
n=int(input())

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

if n<=2:
    print('0')
else:
    for i in range(n-2):
        for e in range(1,n-1):
            for o in range(2,n):
                if o<=e or o<=i or e<=i or l[i]==l[e] or l[e]==l[o] or l[i]==l[o]:
                    con+=0
 
                elif l[i]+l[e]>l[o] and l[e]+l[o]>l[i] and l[o]+l[i]>l[e]:
                    con+=1
                                         
    print(con)

Submission status: Accepted

Solution code:
from itertools import permutations, combinations, combinations_with_replacement, product
import fractions
from collections import Counter

n = int(input())
listA = map(int, input().split())
Cs = list(combinations(listA, 3)) # C
ans = 0
for li in Cs:
  if (li[0]+li[1]>li[2]) and (li[1]+li[2]>li[0]) and (li[0]+li[2]>li[1]) and not li[0] == li[1] and not li[1] == li[2] and not li[2]==li[0]:
    ans+=1
print(ans)

Submission status: Accepted

Solution code:
import collections

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

L = collections.Counter(L_list)
L_modi = list(L.keys())
#print(L_modi)
#print(L[L_modi[0]])
#print(L.items())

cnt = 0

for i in range(len(L_modi)-2):
    for j in range(i+1, len(L_modi)-1):
        for k in range(j+1, len(L_modi)):
            if L_modi[i] + L_modi[j] > L_modi[k]:
                cnt += L[L_modi[i]]*L[L_modi[j]]*L[L_modi[k]]
                #print(i,j,k,L[L_modi[i]]*L[L_modi[j]]*L[L_modi[k]])

print(cnt)

Submission status: Accepted

Solution code:
import itertools
n=int(input())
length=list(map(int,input().split()))
combination=list(itertools.combinations(length,3))
new_list=[]
for com in combination:
    a=com[0]
    b=com[1]
    c=com[2]
    if a!=b and b!=c and a!=c:
        if com[0]+com[1]>com[2] and com[1]+com[2]>com[0] and com[0]+com[2]>com[1]:
            new_list.append(com)
        else:
            continue
print(len(new_list))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations

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


def isRectangle(pair):
    if len(pair) < 3:
        return False
    if pair[0] == pair[1] or pair[1] == pair[2] or pair[2] == pair[0]:
        return False
    return (
        pair[0] + pair[1] > pair[2]
        and pair[1] + pair[2] > pair[0]
        and pair[0] + pair[2] > pair[1]
    )


c = list(combinations(L, 3))

count = 0
for i in range(len(c)):
    if isRectangle(c[i]):
        count += 1
print(count)

Submission status: Accepted

Solution code:
import sys,math
from collections import deque,defaultdict
import operator as op
from functools import reduce
sys.setrecursionlimit(10**6) 

I=sys.stdin.readline

 #s="abcdefghijklmnopqrstuvwxyz"

#
def ii():
	return int(I().strip())
def li():
	return list(map(int,I().strip().split()))
def mi():
	return map(int,I().strip().split())

def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer // denom

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x





	

def main():
	n=ii()
	arr=sorted(li())
	cnt=0
	for i in range(n-2):
		for j in range(i+1,n-1):
			if arr[i]!=arr[j]:
				for k in range(j+1,n):
					if arr[j]!=arr[k]:
						if arr[i]+arr[j]>arr[k] and arr[k]+arr[j]>arr[i] and arr[i]+arr[k]>arr[j]:
							cnt+=1
	print(cnt)













	
	
	






		







		
		
	
		

	







		









if __name__ == '__main__':
	main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
l = [int(i) for i in input().split()]
cnt = 0
for i in range(0, len(l) - 2):
    for j in range(i + 1, len(l) - 1):
        for k in range(j + 1, len(l)):
            length = l[i] + l[j] + l[k]
            max_len = max(l[i], l[j], l[k])
            rest = length - max_len
            if max_len < rest and l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
                cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
numl = list(map(int, input().split()))
#numl = list(set(lis))
res = 0
for i in range(len(numl)):
    for j in range(len(numl)):
        if(i <= j):
            break
        else:
            for k in range(len(numl)):
                if((numl[i] + numl[j]> numl[k]) and (i < k) and (numl[k] + numl[j]> numl[i]) and (numl[i] + numl[k]> numl[j])and numl[i] != numl[j]and numl[j] != numl[k] and numl[k] != numl[i]):
                    #print(numl[j], numl[i], numl[k])
                    #print(i, j, k)
                    res+=1
print(res)

Submission status: Accepted

Solution code:
n = int(input()) 
  
# input the array 
arr = [int(x) for x in input().split()] 
ans = 0
if n>=3:
	for i in range(0,n):
		for j in range(i+1,n):
			if arr[i]==arr[j]:
				continue
			for k in range(j+1,n):
				if arr[j]==arr[k] or arr[i]==arr[k]:
					continue
				
				if arr[i]+arr[j]>arr[k] and abs(arr[i]-arr[j])<arr[k]:
					ans+=1

print(ans)

Submission status: Accepted

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

import itertools

for i in itertools.combinations(L, 3):
    if i[0] != i[1] and i[1] != i[2] and i[2] != i[0]:
        j = sorted(i)
        if j[0] + j[1] > j[2]:
            ans += 1

print(ans)

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

Solution code:
import itertools
N=int(input())
A=list(map(int, input().split()))
ans=0
for any_pair in itertools.combinations(A, 3):
    pair=sorted(any_pair)
    #print(type(pair))
    if pair[0]+pair[1]>pair[2] and pair[1]+pair[2]>pair[0] and pair[0]+pair[2]>pair[1] and pair[0]!=pair[1] and pair[1]!=pair[2]:
        ans+=1
        #print(pair)
print(ans)

Submission status: Accepted

Solution code:
import itertools

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

count = 0
for tuple in itertools.combinations(L, 3):
    a, b, c = list(tuple)
    if tuple[0]!=tuple[1] and tuple[1]!=tuple[2] and tuple[2]!=tuple[0]:
        if a+b>c and b+c>a and c+a>b:
            count += 1 
print(count)

Submission status: Accepted

Solution code:
x=int(input())
arr=list(map(int, input().split()))
d=dict()
for i in arr:
  if i in d:
    d[i]+=1
  else:
    d[i]=1
coun=0
a=sorted(d.keys())
l=len(a)
for i in range(l-2):
  for j in range(i+1,l-1):
    k=j+1
    temp=a[i]+a[j]
    curr=d[a[i]]*d[a[j]]
    while k<l:
      if temp>a[k]:
        coun+=(curr*d[a[k]])
        k+=1
      else:
        break
print(coun)

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

Submission status: Accepted

Solution code:
def abc175b_making_triangle():
    n = int(input())
    l = list(map(int, input().split()))
    cnt = 0
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            if l[i] == l[j]:
                continue
            for k in range(j + 1, n):
                if l[i] == l[k] or l[j] == l[k]:
                    continue
                longest = max(l[i], l[j], l[k])
                total = l[i] + l[j] + l[k]
                if longest < total - longest:
                    cnt += 1
    print(cnt)

abc175b_making_triangle()

Submission status: Accepted

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

for i in range(N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if (L[i] == L[j]) or (L[j] == L[k]) or (L[k] == L[i]):
        continue
      else:
        if (L[i]+L[j]>L[k]) and (L[j]+L[k]>L[i]) and (L[k]+L[i]>L[j]):
          count += 1
         
print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

ans = 0
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            arr = [L[i], L[j], L[k]]
            arr.sort()
            if (arr[0] != arr[1] & arr[1] != arr[2]):
                if (arr[2] < arr[0] + arr[1]):
                    ans = ans + 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

N = I()
L = LI()
count =0
for i in range(N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      flag = 0
      l1 = [L[i],L[j],L[k]]
      l = sorted(l1)
      for n in range(3):
        if(l.count(l[n])>1):
          flag = 1
      if(flag == 0):
        if(l[1]-l[0] < l[2] and l[1]+l[0] > l[2]):
          count += 1
print(count)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
L = input().split()
L = [int(x) for x in L]
counter = 0
if N < 3:
  print(0)
  exit()
listed = {}
set_li = []
for i in L:
  if i in listed:
    listed[i] += 1
  else:
    listed[i] = 1
for i in L:
  if i in set_li:
    continue
  else:
    set_li.append(i)
p_lis = []
for p in itertools.combinations(set_li, 3):
  p_lis.append(p)
for i in p_lis:
  a, b, c = i[0], i[1], i[2]
  if a + b > c and a + c > b and b + c > a:
    counter += 1 * listed[a] * listed[b] * listed[c]
print(counter)

Submission status: Accepted

Solution code:
n = int(input())
lst = list(map(int, input().split()))
res = 0
if n <= 2:
  print(0)
  exit()
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[k] != lst[i] and lst[i] + lst[j] > lst[k] and lst[j] + lst[k] > lst[i] and lst[k] + lst[i] > lst[j]:
        res += 1
print(res)

Submission status: Accepted

Solution code:
n = int(input())
l = tuple(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] or l[j] == l[k] or l[k] == l[i]:
        continue
      ll = [l[i],l[j],l[k]]
      ll.sort()
      if ll[2] < ll[0]+ll[1]:
        #print(ll)
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
import math
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
n=int(input())
l=get_array()
ans=0
for x in range(n):
    for y in range(x+1,n):
        for z in range(y+1,n):
            if l[x]!=l[y] and l[y]!=l[z] and l[x]!=l[z]:
                if l[y]+l[z]>l[x] and l[x]+l[y]>l[z] and l[x]+l[z]>l[y]:
                    ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
if N < 3:
  ans = 0
else:
  ans_list = []
  for i in range(N - 2):
    for j in range(i+1, N - 1):
      if L[i] == L[j]:
        pass
      else:
        for k in range(j + 1, N):
          if L[i] != L[k] and L[j] != L[k]:
            l_list = [L[i], L[j], L[k]]
            L_max = max(l_list)
            L_other = [l for l in l_list if l != L_max]
            if L_max < sum(L_other):
              ans_list.append(i)
  ans = len(ans_list)
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
list = list(map(int, input().split()))
count = 0
for i_1 in range(n-2):
    for i_2 in range(i_1+1,n-1):
        for i_3 in range(i_2+1,n):
            if list[i_1] != list[i_2] and list[i_1] != list[i_3] and list[i_2] != list[i_3]:
                if abs(list[i_2]-list[i_3]) < list[i_1] < list[i_2]+list[i_3]:
                    count += 1
print(count)

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):
        if i==j:
            continue
        else:
            for k in range(j,N):
                if i==k:
                    continue
                elif j==k:
                    continue
                else:
                    temp_max = max(L[i],L[j],L[k])
                    if L[i]+L[j]+L[k] > 2*temp_max:
                        if L[i]==L[j] or L[j]==L[k] or L[k]==L[i]:
                            continue
                        else:
                            ans += 1

print(ans)

Submission status: Accepted

Solution code:
def triangle(a, b, c):
    return (a + b > c and b + c > a and c + a > b)

def differ_num(a,b,c):
    return not (a == b or b == c or c == a)

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

print(ans)

Submission status: Accepted

Solution code:
# Making Triangle

def main(l):
    if len(l) < 3:
        return 0

    l.sort()
    p = 0
    for i in range(0, N - 2):
        for j in range(i + 1, N - 1):
            if l[j] == l[i]:
                continue
            for k in range(j + 1, N):
                if l[k] == l[j]:
                    continue
                if l[i] + l[j] <= l[k]:
                    break
                p += 1
    return p


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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
bar = [int(n) for n in input().split(' ')]
count = 0
if N >= 3:
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            for k in range(j + 1, N):
                if (bar[i] != bar[j]) and (bar[j] != bar[k]) and (bar[k] != bar[i]):
                    if (bar[i] + bar[j] > bar[k]) and (bar[i] + bar[k] > bar[j]) and (bar[k] + bar[j] > bar[i]):
                        count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations

n = int(input())
l = map(int, input().split())
count = 0
for i in  combinations(l, 3):
	c = sorted(set(i))
	if len(c) == 3:
		if c[0] + c[1] > c[2]:
			count += 1
print(count)

Submission status: Accepted

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

count = 0
for a, b, c in l:
    if a+b>c and b+c>a and c+a>b:
        count +=1*L.count(a)*L.count(b)*L.count(c)
print(count)

Submission status: Accepted

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

count = 0
if N<=2:
    print(0)
    exit()

for i in range(N-2):
    L1 =L[i]
    for s in range(i+1,N-1):
        L2 = L[s]
        if L1 == L2:
            continue
        for n in range(s+1,N):
            L3=L[n]
           
            if L1==L3 or L2 == L3:
                continue

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

Submission status: Accepted

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

Submission status: Accepted

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

import itertools


def is_triangle(a, b, c):
    return abs(b - c) < a < b + c


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

for triangle in triangles:
    a = triangle[0]
    b = triangle[1]
    c = triangle[2]

    if (a != b and b != c and c != a) and is_triangle(a, b, c):
        count += 1

print(count)

Submission status: Accepted

Solution code:
import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort(reverse=True)
if N < 3:
    print(0)
    exit()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
n = int(input())
boulist = list(map(int,input().split()))
com = list(itertools.combinations(boulist,3))
ans = 0
if len(com) == 0:
  print(0)
else:
  for i in range(len(com)):
    if com[i][0] + com[i][1] > com[i][2] and com[i][1] + com[i][2] > com[i][0] and com[i][2] + com[i][0] > com[i][1] and com[i][0] != com[i][1] and com[i][1] !=com[i][2] and com[i][0] != com[i][2]:
      ans = ans + 1
  print(ans)

Submission status: Accepted

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

t = 0
for i in range(n):
    for j in range(i + 1, n):
        if l[i] == l[j]:
            continue
        for k in range(j + 1, n):
            if l[i] == l[k] or l[j] == l[k]:
                continue
            if l[i] < l[j] + l[k] and l[j] < l[i] + l[k] and l[k] < l[j] + l[i]:
                t += 1

print(t)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def a():
    N = int(input())
    L = list(map(int,input().split()))
    ans = 0

    if(N<3):
        print(ans)
        return 0
    for x in range(N):
        for y in range(x+1,N):
            for z in range(y+1,N):
                if(L[x]!=L[y] and L[y]!=L[z] and L[z]!=L[x]):
                    if(L[x]+L[y]>L[z] and L[y]+L[z]>L[x] and L[z]+L[x]>L[y]):
                        ans+=1
    print(ans)

a()

Submission status: Accepted

Solution code:
def main():
  n = int(input())
  num_set = list(map(int, input().split()))
  if n < 3:
    print(0)
    exit()
  cnt = 0
  for i in range(len(num_set)):
    for j in range(i+1, len(num_set)):
      for k in range(j+1, len(num_set)):
        if num_set[i]==num_set[j] or num_set[i]==num_set[k] or num_set[j]==num_set[k]:
          continue
        if num_set[i]+num_set[j] > num_set[k] and num_set[k]+num_set[j] > num_set[i] and num_set[i]+num_set[k] > num_set[j]:
          cnt += 1
  print(cnt)
if (__name__=='__main__'):
  main()