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
n = int(input())
arr = list(map(int, input().split()))

res = 0
for c in combinations(arr, 3):
    if len(set(c)) < 3:
        continue
    if max(c) < sum(c) - max(c):
        res += 1

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            if L[i] != L[j] != L[k] != L[i] 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:
N=int(input())
L=list(map(int,input().split()))
L=sorted(L)
c=0
for i in range(N-2):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if(L[i]!=L[j]):
                if(L[j]!=L[k]):
                    if(L[i]+L[j]>L[k]):
                        c+=1
print(c)

Submission status: Accepted

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

Submission status: Accepted

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

ans = []
for i in range(n):
    for j in range(n):
        for k in range(n):
            if l[i] != l[j] and l[j] != l[k] and l[i] != l[k]:
                a, b, c = sorted([l[i], l[j], l[k]])
                if a + b > c:
                    ans.append([i, j, k])


print(len(set(frozenset(i) for i in ans)))

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,n-1):
        for k in range(j,n):
            li = [l[i],l[j],l[k]]
            if len(set(li))==3 and max(li)*2<sum(li):
                cnt +=1
print(cnt)

Submission status: Accepted

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

n = int(input())
llist = list(map(int, input().split()))
llist.sort()
ans = 0

for i in range(n-2):
  for j in range(i+1,n-1):
    if llist[i] != llist[j]:
      for k in range(j+1,n):
        if llist[j] != llist[k]:
          if llist[i] + llist[j] > llist[k]:
            ans += 1

print(ans)

Submission status: Accepted

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

cnt=0
for i in range(n):
    for j in range(i+1,n):
        if l[i]==l[j]:
            continue
        else:
            for k in range(j+1,n):
                if l[j]==l[k]:
                    continue
                else:
                    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:
N = int(input())
L = list(map(int, input().split()))

cnt = 0

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

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

count = sum([True for (a, b, c) in itertools.combinations(L, 3) if not(a==b or a==c or b==c) and (a+b>c and a+c>b and b+c>a)])
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
li.sort()

for i in range(n):
    for j in range(n-i):
        for k in range(n-i-j):
            if li[i]+li[i+j]>li[i+j+k] and li[i]<li[i+j] and li[i+j]<li[i+j+k]:
                ans+=1
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
L=map(int,input().split())
from collections import defaultdict
d = defaultdict(int)
for l in L:
  d[l]+=1
def chkTRI(X,i,j,k):
  if X[i]+X[j]>X[k] and X[i]+X[k]>X[j] and X[k]+X[j]>X[i]:
    return True
  return False
ans=0
X=list(d.keys())
for i in range(len(X)-2):
  for j in range(i+1,len(X)-1):
    for k in range(j+1,len(X)):
      if chkTRI(X,i,j,k):
        ans+=d[X[i]]*d[X[j]]*d[X[k]]
print(ans)

Submission status: Accepted

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

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

print(Sum)

Submission status: Accepted

Solution code:
import itertools

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

ans = 0
for v in itertools.combinations(l, 3):
    if len(set(v)) == 3:
        a = v[0]
        b = v[1]
        c = v[2]
        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()))
a = 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] and l[j] < l[k]+l[i] and l[k] < l[i]+l[j]:
                    a += 1
print(a)

Submission status: Accepted

Solution code:
import sys
import math

#https://atcoder.jp/contests/agc008/submissions/15248942
sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()
L = inl()

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

print(ans)

Submission status: Accepted

Solution code:
import itertools
n=int(input())
l=list(map(int,input().split()))
cnt=0
for a,b,c in itertools.combinations(l,3):
    if a!=b and b!=c and c!=a and abs(b-c)<a and a<b+c :
        cnt+=1
print(cnt)

Submission status: Accepted

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


for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            if (L[i] < L[j] + L[k]) and (L[i] != L[j] != L[k]):
                cnt += 1


print(cnt)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
L = list(map(int,input().split()))
count = 0
for l in itertools.combinations(L,3):
    l = sorted(l)
    if l[1] == l[2] or l[0] == l[1]:
        continue
    if l[2] < l[1]+l[0]:
        count+=1
print(count)

Submission status: Accepted

Solution code:
import sys
import itertools

N = int(sys.stdin.readline())
L = list(map(int, sys.stdin.readline().split()))

ans = 0
for (a, b, c) in itertools.combinations(L, 3):
    if a == b or b == c or c == a:
        continue
    a, b, c = sorted((a, b, c))
    # print(a, b, c)
    if a + b > c:
        ans += 1
print(ans)

Submission status: Accepted

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

cnt = 0
for i in range(n-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]:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
# import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
enu = enumerate
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")

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

cnt = 0
a = 0
c = combinations(range(N), 3)
for ci in c:
    i, j, k = ci
    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]
    ):
        flg = True
    else:
        flg = False
    if flg:
        cnt += 1
print(cnt)
# for i, li in enu(L):
#     for j, lj in enu(L[i + 1 :]):
#         for k, lk in enu(L[i + 1 + j + 1 :]):
#             a += 1
#             if li + lj > lk:
#                 cnt += 1
# print(a, cnt)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            I = L[i]
            J = L[j]
            K = L[k]
            if max(I,J,K)*2 < I + J + K and I != J and J != K and K != I:
                ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    N = int(input())
    L = list(map(int, input().split()))

    L.sort()
    count = 0
    for n in range(N):
        for nn in range(n+1, N):
            for nnn in range(nn+1, N):
                if L[n] != L[nn] and L[nn] != L[nnn]:
                    if L[n] + L[nn] > L[nnn]:
                        count += 1

    print(count)



if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
N = int(input())

L = list(map(int,input().split()))
ans = 0
for a in L:
    for b in L:
        for c in L:
            if  a not in [b,c] and b != c:
                if abs(a-b) < c and a+b >c:
                    # print("a",a,b,c)
                    ans += 1
print(ans//6)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
N=int(input())
L=list(map(int,input().split()))
ans=0
for i,j,k in itertools.combinations(range(N),3):
    if L[i]==L[j] or L[j]==L[k] or L[k]==L[i]:
        continue
    x=max(L[i],L[j],L[k])
    if L[i]+L[j]+L[k]>2*x:
        ans+=1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

Solution code:
import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
count = 0
for i in range(N):
    for j in range(i+1, N):
        if L[i] == L[j]:
            continue
        count += 1
        if j < N-1 and L[j] == L[j+1]:
            continue

        l = L[i] + L[j]

        id = bisect.bisect_left(L, l)
        # print(L[i], L[j], id)
        ans += (id - j - 1)*count
        count = 0
# print(L)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Ls.sort()
ans=0
for i in range(N-2):
    Li=Ls[i]
    for j in range(i,N-1):
        Lj=Ls[j]
        if Li==Lj:
            continue
        for k in range(j,N):
            Lk=Ls[k]
            if Lj==Lk:
                continue
            if Li+Lj>Lk:
                ans+=1
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 15 17:35:39 2020

@author: Paras
"""

n = int(input())

sides = list(map(int, input().split()))
l = len(sides)
cnt=0
for i in range(l):
    for j in range(i+1,l):
        if sides[j]!=sides[i]:
            k = j+1
            while k<l:
                if (sides[k]>abs(sides[i]-sides[j]) and sides[k]<abs(sides[i]+sides[j])) and (sides[k]!=sides[i] and sides[k]!=sides[j]):
                    cnt+=1
                k+=1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

count=0
for i in range(len(L)):
    for j in range(i+1,len(L)):
        for k in range(j+1,len(L)):
            if (L[i]!=L[j] and L[j]!=L[k]):
                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:
import sys
input = sys.stdin.readline

n = int(input()) 
arr = list(map(int, input().split()))
arr = sorted(arr)
cnt = 0

for i in range(n-2):
  for j in range(i, n-1):
    for k in range(j, n):
      ai, aj, ak = arr[i], arr[j], arr[k]
      if ai != aj and aj != ak and ak < ai + aj:
        cnt += 1

print(cnt)

Submission status: Accepted

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

import itertools

ans = 0
for p in itertools.combinations(l,3):
    ab = p[0] + p[1]
    bc = p[1] + p[2]
    ca = p[0] + p[2]
    if (ab > p[2]) and (bc > p[0]) and (ca > p[1]) and (p[0] != p[1]) and (p[1] != p[2]) and (p[0] != p[2]):
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ls = list(map(int,input().split()))
ii = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if ls[i] == ls[j] or ls[i] == ls[k] or ls[j] == ls[k]:
                pass
            else:
                ls2 = [ls[i],ls[j],ls[k]]
                ls2.sort()
                if ls2[2] < ls2[1] + ls2[0]:
                    ii += 1
print(ii)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
N = int(input())
if N < 3:
    print(0)
    exit()
L = [int(i) for i in input().split()]
L.sort()
ans = 0
for a,b,c in itertools.combinations(L,3):
    if a == b or b == c:
        continue
    if a + b > c:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
def solve():
    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] or 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[i] + L[k] > L[j]:
                    ans += 1 

    print(ans)

if __name__ == '__main__':
    solve()

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):
      if i < j < k:
        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:
#!python3.8
# -*- coding: utf-8 -*-
# abc175/abc175_b
import sys
from itertools import combinations

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    L = i2nn()
    ans = 0
    for cmb in combinations(L, 3):
        a, b, c = sorted(cmb)
        if a != b and b != c and a + b > c:
            ans += 1
    print(ans)
    return

main()

Submission status: Accepted

Solution code:

N = int(input())
L = list(map(int,input().split()))
from itertools import combinations


Cs = list(combinations(L,3))
cnt=0
for C in Cs:
    # print('C*',C)
    if len(set(C)) == 3:
        a,b,c = C[0],C[1],C[2]
        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 = list(map(int, input().split()))
count = 0
for i in range(n):
  for j in range(n - i - 1):
    for t in range(n - i - j - 2):
      a = l[i]
      b = l[j + i + 1]
      c = l[t + j + i + 2]
      if abs(a - b) < c and c < a + b and a != b and b != c and c != a:
        count += 1
print(count)

Submission status: Accepted

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

lst = list(combinations(range(N), 3))

ans = 0
for a, b, c in lst:
    if L[a] + L[b] <= L[c]:
        continue
    elif L[b] + L[c] <= L[a]:
        continue
    elif L[c] + L[a] <= L[b]:
        continue
    elif L[a] == L[b] or L[a] == L[c] or L[b] == L[c]:
        continue
    else:
        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):
        if L[j] == L[i]:
            continue
        for k in range(j+1,n):
            if L[k] == L[i] or L[k] == L[j]:
                continue
            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:
count=0
n=int(input())
l=list(map(int,input().split()))
if n==1 or n==2:
    print(0)
else:
    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] and abs(l[i]-l[j])<l[k]<l[i]+l[j]:
                    count+=1
                    
    print(count)

Submission status: Accepted

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

ans = 0
for v in c:
    a = v[0]
    b = v[1]
    c = v[2]
    if a != b and b != c and a != c:
        s = sum(v)
        m = max(a, b, c)
        if s > 2 * m:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
import itertools

def main():

    input = stdin.readline

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

    ans = 0

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

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B
# CreatedDate:  2020-08-15 20:38:49 +0900
# LastModified: 2020-08-15 21:11:14 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    N = int(input())
    L = sorted(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[k] < L[i] + L[j] and L[k] != L[i] and L[k] != L[j] and L[i] != L[j]:
                    cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
from itertools import combinations


def _i(): return int(sys.stdin.readline().strip())


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    n = _i()
    a = list(_ia())

    cnt = 0
    for c in combinations(a, 3):
        l1, l2, l3 = sorted(c)
        if l1 == l2 or l2 == l3 or l3 == l1:
            continue

        if l1 < l2 + l3 and l2 < l3 + l1 and l3 < l1 + l2:
            cnt += 1
    return cnt


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

Submission status: Accepted

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

if N < 3:
  print(0)
else:
  sum = 0
  for i in range(N):
    for j in range(i, N):
      for k in range(j, N):
        x = L[i]
        y = L[j]
        z = L[k]
        if (x<y) and (y<z) and (z < (x+y)):
          sum += 1
  print(sum)

Submission status: Accepted

Solution code:
N = int(input())
L = map(int, input().split())
L = sorted(L)
ans = 0
for li, l in enumerate(L):
    for mi, m in enumerate(L[li+1:]):
        for ni, n in enumerate(L[li+mi+2:]):
            if l + m <= n or l == m or m == n:
                continue
            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(i):
        for k in range(j):
            if l[i] == l[j] or l[k] == l[j] or l[k] == l[i]:
                continue
            if l[i] + l[j] > l[k] and l[i] + l[k] > l[j] and l[j] + l[k] > l[i]:
                cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    L = [int(a) for a in 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] + L[k] and L[j] < L[i] + L[k] 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)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n = int(input())
l = [int(x) for x in input().split()]
cnt = 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 abs(b - c) < a < b + c and abs(a - b) < c < a + b and abs(c - a) < b < c + a and a != b and b != c and a != c:
                cnt += 1
               
print(cnt)

Submission status: Accepted

Solution code:
def resolve():
    ans = 0
    N = int(input())
    L = list(map(int, input().split()))
    for i in range(N):
        for j in range(i):
            for p in range(j):
                count = [L[i], L[j], L[p]]
                sei = sorted(count)
                if L[i] != L[j] and L[j] != L[p] and L[p] != L[i] and sei[0] + sei[1] > sei[2]:
                    ans += 1
    print(ans)
resolve()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

cnt = 0
for i in itertools.combinations(L, 3):
    # print(i)
    # print(i[0],i[1],i[2])

    if i[0] == i[1] or i[0] == i[2] or i[1] == i[2]:
        continue

    ij = i[0]+i[1] > i[2]
    ik = i[0]+i[2] > i[1]
    jk = i[1]+i[2] > i[0]

    if ij + ik + jk == 3:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
L = list(map(int, input().split()))
M = list(itertools.combinations(L,3))
Ans = 0
for i in M:
    i = sorted(list(i))
    if len(set(i)) == 3:
        if i[0] + i[1] > i[2]:
            if i[1] - i[0] < i[2] :
                Ans += 1
                
print(Ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int, input().split()))
cnt=0
import itertools
for a, b, c in itertools.combinations(l, 3):
  if a==b or a==c or b==c:
    cnt+=0
  elif a+b<=c or a+c<=b or b+c<=a:
    cnt+=0
  else:
    cnt+=1
print(cnt)