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:
#!/usr/bin/env python3

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(0)
	n = int(sys.stdin.readline())
	l = list(map(int, sys.stdin.readline().split()))
	cnt = 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[i] != l[k] and l[j] != l[k]:
					a = sorted([l[i], l[j], l[k]])
					log.print(a)
					if (a[0] + a[1] <= a[2]):
						continue
					cnt += 1
	print(cnt)
	


main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

answer = 0
for i in range(N):
  Li = L[i]
  if N-i < 3:
    break
  for j in range(i+1,N):
    Lj = L[j]
    if N-j < 2:
      break
    if Li==Lj:
      continue
    for k in range(j+1,N):
      Lk = L[k]
      if Lk==Li or Lk==Lj:
        continue
      if 2*max(Li,Lj,Lk)<Li+Lj+Lk:
        answer += 1

print(answer)

Submission status: Accepted

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

cnt = 0

for i in range(n):
    li = ls[i]
    for j in range(i+1, n):
        lj = ls[j]
        if li == lj:
            continue
        for k in range(j+1, n):
            lk = ls[k]
            if lj == lk:
                continue
            if li + lj <= lk:
                break
            cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
import sys
n = int(input())
l = list(map(int, input().split()))
d = {}
set_l = list(set(l))
if len(set_l)<3:
    print(0)
    sys.exit()
for i in set_l:
    d[i] = l.count(i)
set_l.sort()
ans = 0
for i in range(len(set_l)-2):
    for j in range(i+1, len(set_l)-1):
        for k in range(j+1, len(set_l)):
            if set_l[i]+set_l[j]>set_l[k] and set_l[i]+set_l[k]>set_l[j] and set_l[k]+set_l[j]>set_l[i]:
                ans += d[set_l[i]]*d[set_l[j]]*d[set_l[k]]
print(ans)

Submission status: Accepted

Solution code:
import itertools
n = int(input())
l = list(map(int,input().split()))
ans = 0
for i, j, k in itertools.combinations(l, 3):
	if i + j > k > abs(i-j) or j + k > i > abs(j-k) or k + i > j > abs(k-i):
		if i != j and j != k and k != i:
			ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
L = sorted([int(i) for i 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] > L[k] and len(set([L[i], L[j], L[k]]))==3:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)

from itertools import combinations


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n = gete(int)
    l = tuple(geta(int))

    cnt = 0

    for c in combinations(range(n), 3):

        p, q, r = l[c[0]], l[c[1]], l[c[2]]

        if p == q or p == r or q == r:
            continue

        if abs(p - q) < r and r < p + q:
            cnt += 1

    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
s=0
b=[]
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[k]!=a[i] and a[i]+a[j]>a[k] and a[i]+a[k]>a[j] and a[j]+a[k]>a[i]:
                s+=1

print(s)

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, n - 1):
        if l[i] == l[j]:
            continue
        for k in range(j, n):
            if l[i] == l[k] or l[j] == l[k]:
                continue
            a, b, c = sorted([l[i], l[j], l[k]])
            if c - a < b:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
L = list(map(int, input().split()))
ans = 0
for (a, b, c) in itertools.combinations(L, 3):
    if len(set({a, b, c})) == 3:
    #if a != b != c:
        if 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()))

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

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
Array = list(map(int, input().strip().split()))
array=list(set(Array))
array.sort()
n=len(array)
f=0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        for w in range(j+1,n):
            if array[i]+array[j]>array[w]:
                f+=Array.count(array[i])*Array.count(array[j])*Array.count(array[w])
print(f)

Submission status: Accepted

Solution code:
n = int(input())
sticks = list(map(int, input().split()))
cnt = 0
for i in range(0, n):
    for j in range(i+1, n):
        if sticks[i] == sticks[j]: continue

        for k in range(j + 1, n):
            if sticks[i] == sticks[k] or sticks[j] == sticks[k]: continue
            
            if sticks[i] + sticks[j] > sticks[k] and sticks[i] + sticks[k] > sticks[j] and sticks[j] + sticks[k] > sticks[i]:
                cnt+=1

print(cnt)

Submission status: Accepted

Solution code:
import sys

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

L = sorted(L)

c = 0

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

for i in range(N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            li, lj, lk = L[i], L[j], L[k]
            if li == lj or lj == lk or lk == li:
                continue
            if max(li, lj, lk) < (li + lj + lk - max(li, lj, lk)):
                c += 1

print(c)

Submission status: Accepted

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

l.sort()

from itertools import combinations

ans = 0
for i in combinations(list(range(0, n)), 3):
    if l[i[0]] == l[i[1]] or l[i[1]] == l[i[2]] or l[i[2]] == l[i[0]]:
        continue
    if l[i[0]] + l[i[1]] > l[i[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(0, N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            ssum = L[i] + L[j] + L[k]
            mmax = max(L[i], L[j], L[k])
            if mmax < ssum - mmax and L[i] != L[j] and L[j] != L[k] and L[i] != L[k]:
                cnt += 1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

count = 0
for l1 in listL:
    for l2 in listL:
        for l3 in listL:
            if l2 > l1 and l3 > l2 and l1+l2 > l3:
                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+1,N):
        for k in range(j+1,N):
            T=[L[i],L[j],L[k]]
            T.sort()
            if T[2]<T[0]+T[1] and T[0]<T[1] and T[1]<T[2]:
                #print(i,j,k)
                ans+=1
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
data_str=input().split()
data=[int(s) for s in data_str]
ans=0
for i in range(N-2):
    for j in range(i,N-1):
        for k in range(j,N):
            if data[i]!=data[j] and data[i]!=data[k] and data[k]!=data[j] and data[i]+data[j]>data[k] and data[i]+data[k]>data[j] and data[j]+data[k]>data[i]:
                ans+=1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

if n < 3:
    print(0)
else:
    import itertools
    cnt = 0
    for d in itertools.combinations(data, 3):
        if d[0] != d[1] and d[1] != d[2] and d[2] != d[0]:
            mx = max(d)
            if mx * 2 - sum(d) < 0:
                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] > L[k] and L[k] + L[i] > L[j] and L[j] + L[k] > L[i] and L[i] != L[j] and L[i] != L[k] and L[j] != L[k]:
                
                cnt += 1
print(cnt)

Submission status: Accepted

Solution code:

#!/usr/bin/python
# -*- coding: utf-8 -*-

# def
def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return x

def str_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(input()))
    return x

def int_map():
    return map(int,input().split())

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

def print_space(l):
    return print(" ".join([str(x) for x in l]))

# import
import numpy as np



# main code
N = int(input())
L = int_list()

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[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:
import itertools
n = int(input())
L=sorted(list(map(int,input().split())), reverse=True)

ans = 0
'''for i,l in enumerate(L):
	for j,s1 in enumerate(L[i+1:]):
		for k,s2 in enumerate(L[j+1:]):
			if l<s1+s2:
				ans += 1
'''
for i,j,k in itertools.combinations(L, 3):
	l = sorted([i,j,k])
	if l[0]+l[1]>l[2] and l[0]!=l[1]!=l[2]!=l[0]:
		#print(l)
		ans +=1
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):
    for j in range(i+1,n):
        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:
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    n = int(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    L = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    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] and L[i] != L[k]:
                    big = max(L[i],L[j],L[k])
                    s = L[i] + L[j] + L[k]
                    if s-big > big:
                        ans += 1
                else:
                    pass
    print(ans)




if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
n = int(input())
l = [int(i) for i in 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] 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()))

ans = 0

for i in range(len(L)):
    for j in range(i+1, len(L)):
        for k in range(j+1, len(L)):
            if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                maxL = max(L[i], L[j], L[k])
                if maxL < L[i] + L[j] + L[k] - maxL:
                    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 a,b,c in combinations(L, 3):
    if a != b and b != c and c != a:
        if a+b>c and b+c>a and c+a>b:
            cnt += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def check(li,lj,lk):
    if (li+lj > lk) and (li+lk > lj) and (lj+lk > li):
        return True
    else:
        return False

def main():
    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] and l[i]!=l[k] and l[j]!=l[k] and check(l[i],l[j],l[k]):
                    count += 1

    print(count)
    
if __name__=='__main__':
    main()

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

Submission status: Accepted

Solution code:
N = int(input())
li = list(map(int,input().split()))
li.sort(reverse=True)
c = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1, N):
            if li[i] == li[j] or li[j] == li[k] or li[i] == li[k]:
                continue

            if li[i] < li[j] + li[k]:
#                print(i,j,k)
                c += 1
print(c)

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+1, N):
        for k in range(j+1, N):
            if i==j or j==k:
                continue
            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()))

ans = 0
for i in range(n):
    for g in range(i+1, n):
        for m in range(g+1, n):
            a = l[i]
            b = l[g]
            c = l[m]
            if a != b and b != c and c != a:
                if a+b > c and b+c > a and c+a > b:
                    ans += 1
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
A = [int(x) for x in input().split()]
A.sort()
score=0
for i in range(N):
  for j in range(i,N):
    for k in range(j,N):
      if A[i]!=A[j] and A[j]!=A[k] and A[i]+A[j]>A[k]:
        score+=1
print(score)

Submission status: Accepted

Solution code:
# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))


def solve():
    N = int(input())
    Ls = 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):
                l1 = Ls[i]
                l2 = Ls[j]
                l3 = Ls[k]

                if l1 == l2 or l2 == l3 or l3 == l1:
                    continue
                if l1 + l2 <= l3:
                    continue
                if l2 + l3 <= l1:
                    continue
                if l3 + l1 <= l2:
                    continue
                count += 1
    return count


def main():
    print(solve())


if __name__ == "__main__":
    main()

Submission status: Accepted

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

ans = 0
for i in range(N):
    for j in range(i,N):
        if A[i] == A[j]:
            continue
        for k in range(j,N):
            if A[i] == A[k] or A[j] == A[k]:
                continue
            l = [A[i],A[j],A[k]]
            n = sum(l) - 2*max(l)
            if n > 0:
                ans += 1

print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

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

    ans = 0
    for l in itertools.combinations(L, 3):
        l = list(l)
        l.sort()
        if l[0]!=l[1] and l[1]!=l[2] and l[2]!=l[0]:
            if l[2] < l[0]+l[1]:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

nums.sort()

ans= 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            a, b, c = nums[i], nums[j], nums[k]
            if a < b < c:
                if a + b > c:
                    ans += 1
                # if i + j >= k:
                #     ans += 1
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math
import bisect

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()
a = readInts()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
c = 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] or L[i] == L[k]:
                continue
            if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[k] + L[i] > L[j]:
                c += 1

print(c)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    L = list(map(int, input().split()))
    CNT = 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[i] != L[k] and L[j] != L[k]:
                        S = L[i] + L[j] + L[k]
                        M = max(max(L[i], L[j]), L[k])
                        if S - M > M:
                            CNT += 1
    print(CNT)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from itertools import combinations as cmb
n = int(input())
L = list(map(int, input().split()))
#print(L)
counter = 0
for l1, l2, l3 in cmb(L, 3):
    #print(l1, l2, l3)
    if l1 + l2 > l3 and l2 + l3 > l1 and l3 + l1 > l2 and l1 != l2 and l2 != l3 and l3 != l1:
        counter += 1
print(counter)

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]:
                sum_edge=L[i]+L[j]+L[k]
                max_edge=max(L[i],L[j],L[k])
                if max_edge<(sum_edge-max_edge):
                    ans+=1

print(ans)

Submission status: Accepted

Solution code:
num = int(input())
l_i = list(map(int, input().split()))
ans = 0
for i in range(len(l_i)):
    ival = l_i[i]
    for j in range(len(l_i)):
        if j <= i: continue
        jval = l_i[j]
        if ival == jval: continue
        for k in range(len(l_i)):
            if k <= j: continue
            kval = l_i[k]
            if ival == kval or jval == kval: continue
            if ival < jval + kval and jval < ival + kval and kval < ival + jval: ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
lst = [int(i) for i in input().split()]
if n == 1 or n == 2:
  print(0)
else:
  lst.sort()
  #print(lst)
  count = 0
  for i in range(n-2):
    for j in range(i+1, n-1):
      if lst[j] == lst[i]:
        continue
      for k in range(j+1, n):
        if lst[k] == lst[j]:
          continue
        if lst[i] + lst[j] > lst[k]:
          count += 1
  print(count)

Submission status: Accepted

Solution code:
from itertools import combinations

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

ans = 0
for i, j, k in combinations(range(N), 3):
    Li, Lj, Lk = sorted([L[i], L[j], L[k]])
    if Li != Lj and Lj != Lk and Lk != Li and Li + Lj > Lk:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
import itertools

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

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

Submission status: Accepted

Solution code:
import sys
from itertools import combinations


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    l = list(map(int, input().split()))
    ans = 0
    for i, j, k in combinations(range(n), 3):
        if (
            abs(l[j] - l[i]) < l[k] != l[i]
            and l[k] < l[i] + l[j]
            and l[i] != l[j]
            and l[k] != l[j]
        ):
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[12]:


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


# In[13]:


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


# In[ ]:

Submission status: Accepted

Solution code:
from itertools import combinations

[N],*li = [list(map(int,i.split())) for i in open(0)]
li = li[0]
count = 0
for k in combinations(li,3):
    k = sorted(list(k))
    if k[2]<k[0]+k[1] and k[0]!=k[1] and k[1]!= k[2]:
        count += 1
print(count)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
n= int(input())
a = [int(i) for i in input().split()]
ans = 0
a.sort()
# ~ print(a)
for i in range(n):
	for j in range(i+1,n):
		for k in range(j+1,n):
			if a[i]+a[j]>a[k] and len(set([a[i],a[j],a[k]]))==3:
				# ~ print(a[i],a[j],a[k])
				ans+=1
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    n = kwargs["n"]
    L = kwargs["L"]
    res = 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 abs(L[i] - L[j]) < L[k] < L[i] + L[j]:
                        res += 1

    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    kwargs["n"] = [int(i) for i in cin][0]

    cin = input().split()
    kwargs["L"] = [int(i) for i in cin]

    cout = main(kwargs)
    print(cout)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
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[k] < l[i] + l[j]:
                count += 1

print(count)

Submission status: Accepted

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

import itertools
X = list(itertools.combinations(L, 3))
     
ans = 0

for i in X:
    temp = list(sorted(list(i)))
    if temp[0]+temp[1]>temp[2] and len(list(set(temp)))==3:
        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):
      S = [L[i], L[j], L[k]]
      S.sort()
      if S[2] < S[0] + S[1] and (S[0] != S[1] and S[1] != S[2] and S[2] != S[0]):
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
L.sort(reverse=True)
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]: continue
            ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

a.sort()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
N  = input()
L =  (map(int, input().split()))
ans = 0
for x, y, z in itertools.combinations(L, 3):
  ans += x + y > z and y+z>x and z+x>y and x != y and y != z and z != x
print(ans)

Submission status: Accepted

Solution code:
mod = 10**9 + 7
def solve():
    n = int(input())
    a = list(map(int, input().split()))

    ans = 0
    a.sort()
    for i in range(n):
        for j in range(i + 1, n):
            for k in range(j + 1, n):
                if a[i] + a[j] > a[k] and a[i] != a[j] and a[j] != a[k]:
                    ans += 1
    print(ans)
t = 1
while t > 0:
    solve()
    t -= 1

Submission status: Accepted

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

Submission status: Accepted

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