Problem:


Score : 200 points

Problem Statement

We have sticks numbered 1, \cdots, N. The length of Stick i (1 \leq i \leq N) is L_i.

In how many ways can we choose three of the sticks with different lengths that can form a triangle?

That is, find the number of triples of integers (i, j, k) (1 \leq i < j < k \leq N) that satisfy both of the following conditions:

L_i, L_j, and L_k are all different.

There exists a triangle whose sides have lengths L_i, L_j, and L_k.

Constraints

1 \leq N \leq 100

1 \leq L_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
L_1 L_2 \cdots L_N

Output

Print the number of ways to choose three of the sticks with different lengths that can form a triangle.

Sample Input 1

5
4 4 9 7 5

Sample Output 1

5

The following five triples (i, j, k) satisfy the conditions: (1, 3, 4), (1, 4, 5), (2, 3, 4), (2, 4, 5), and (3, 4, 5).

Sample Input 2

6
4 5 4 3 3 5

Sample Output 2

8

We have two sticks for each of the lengths 3, 4, and 5. To satisfy the first condition, we have to choose one from each length.

There is a triangle whose sides have lengths 3, 4, and 5, so we have 2 ^ 3 = 8 triples (i, j, k) that satisfy the conditions.

Sample Input 3

10
9 4 6 1 9 6 10 6 6 8

Sample Output 3

39

Sample Input 4

2
1 1

Sample Output 4

0

No triple (i, j, k) satisfies 1 \leq i < j < k \leq N, so we should print 0.



Sample input:
5
4 4 9 7 5


Sample output:
5

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        if L[i] == L[j]:
            continue
        for k in range(j + 1, N):
            if L[j] == L[k]:
                continue
            if L[i] + L[j] > L[k]:
                # print(i, j, k)
                ans += 1
            else:
                break
print(ans)

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

Submission status: Accepted

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

L.sort()

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

Submission status: Accepted

Solution code:
import itertools

# print('input >>')
N = int(input())
Ls = list(map(int,(input().split())))
Ls.sort()

combs = itertools.combinations(Ls, 3)

ans = 0
for comb in combs:
    if (comb[0] != comb[1] and comb[1] != comb[2] and comb[2] != comb[0] 
      and comb[0] + comb[1] > comb[2]):
        ans += 1

# print('-----output-----')
print(ans)

Submission status: Accepted

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

for k in range(2, N):
    for j in range(1, k):
        if L[k] == L[j]:
            continue
        for i in range(0, j):
            if L[i] == L[j]:
                continue
            if L[k] == L[i]:
                continue
            if L[i] + L[k] <= L[j]:
                continue
            if L[i] + L[j] <= L[k]:
                continue
            if L[j] + L[k] <= L[i]:
                continue
            res += 1

print(res)

Submission status: Accepted

Solution code:
# |b−c|< a < b+c
# a+b>c  かつ b+c>a かつ c+a>b

n = int(input())
side = list(map(int,input().split()))
ans = 0
for i in range(0,len(side)):
    for j in range(i+1,len(side)):
        for k in range(j+1,len(side)):
            if(abs(side[j]-side[k]) < side[i] < side[j]+side[k] and side[i]!=side[j]and side[k]!=side[j]and side[i]!=side[k]):
                ans+=1
                # print(side[i],side[j],side[k])
print(ans)

Submission status: Accepted

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

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

c = 0
for i in range(N-2):
  for j in range(i, N-1):
    for k in range(j, N):
      if sum([lst[i], lst[j], lst[k]]) > 2*max([lst[i], lst[j], lst[k]]):
        if lst[i] != lst[j] and lst[j] != lst[k] and lst[k] != lst[i]:
          c += 1
print(c)

Submission status: Accepted

Solution code:
from collections import defaultdict

N = int(input())
dic = defaultdict(int)
for l in map(int, input().split()):
  dic[l] += 1

if len(dic) < 3:
  print(0)
  exit()

dic = sorted(dic.items())

ans = 0
for i in range(len(dic)-2):
  Li = dic[i][0]
  cnt_i = dic[i][1]
  for j in range(i+1, len(dic)-1):
    Lj = dic[j][0]
    cnt_j = dic[j][1]
    for k in range(j+1, len(dic)):
      Lk = dic[k][0]
      cnt_k = dic[k][1]
      
      if ((Li+Lj) > Lk) and ((Li+Lk) > Lj):
        ans += cnt_i * cnt_j * cnt_k
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int,input().split()))
ans = 0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
                if 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()))
s=list(itertools.combinations(l,3))
count=0
for i in s:
	a,b,c=i
	if a+b>c and b+c>a and c+a>b 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()))
l.sort()
ans=0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if len(set([l[i],l[j],l[k]]))==3 and l[i]+l[j]>l[k]:
                ans+=1
print(ans)

Submission status: Accepted

Solution code:
import itertools as it

N = int(input())
L = [*map(int, input().split())]

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

Submission status: Accepted

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

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

Submission status: Accepted

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

L.sort()

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):
            li,lj,lk = L[i],L[j],L[k]
            if li + lj > lk:
                if li != lj and lj != lk and li != lk:
                    ans += 1

print(ans)

Submission status: Accepted

Solution code:
import sys
import bisect as bi
import math
from collections import defaultdict as dd
input=sys.stdin.readline
##sys.setrecursionlimit(10**7)
def cin():
    return map(int,sin().split())
def ain():            
    return list(map(int,sin().split()))
def sin():
    return input()
def inin():
    return int(input())
for _ in range(1):
    n=inin()
    l=ain()
    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[k]!=l[j] and l[k]!=l[i]):
                        a=[l[i],l[j],l[k]]
                        a.sort()
                        if(a[0]+a[1]>a[2]):
                            ans+=1
    print(ans)

Submission status: Accepted

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

from itertools import combinations
ans = 0
for c in combinations(range(N),3):
    c1,c2,c3 =c
    if A[c1] != A[c2] and A[c1] != A[c3] and A[c2] != A[c3]:
        if A[c1]+A[c2] > A[c3] and A[c3]+A[c2] > A[c1] and A[c1]+A[c3] > A[c2]:
#             print(c1+1,c2+1,c3+1)
            ans+=1
            
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
ans=0
if n==1 or n==2:
    print(0)
    exit()
l=sorted(l)

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

Submission status: Accepted

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

count = 0

for i in range (0, 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[j] >L[k]:
                count+=1

print(count)

Submission status: Accepted

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

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

counter = 0
for c in C:
    if c[0] != c[1] and c[1] != c[2] and c[2] != c[0] and c[0]+c[1] > c[2] and c[1]+c[2] > c[0] and c[2]+c[0] > c[1]:
        counter += 1

print(counter)

Submission status: Accepted

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

Submission status: Accepted

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

    cnt = 0
    for i, x in enumerate(L[:-2]):
        for j, y in enumerate(L[i+1:-1]):
            for z in L[i+j+2:]:
                if len({x, y, z}) == 3:
                    cnt += int(x + y > z)
    print(cnt)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:

n=int(input())
a=[int(c) for c in input().split()]
a.sort()
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
       if a[i]==a[j]:
           continue    
       for k in range(j+1,n):
           
           if a[k]!=a[i] and a[k]!=a[j]:
              
                if a[i]+a[j]>a[k]:
                    ans+=1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

for i in range(N-2):
    a = L[i]

    for j in range(i+1, N-1):
        b = L[j]
        if a == b:
            continue

        for k in range(j+1, N):
            c = L[k]
            if  b == c:
                continue

            if a + b <= c:
                continue

            ans += 1

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = [int(i) for i in input().split()]
sort_L = sorted(L,reverse=True)
p = []
for i,l in enumerate(sort_L):
    for j,m in enumerate(sort_L[i+1:]):
        for k,n in enumerate(sort_L[i+j+1:]):
            if l < m+n and l != m and m != n and l!=n:
                p.append([l,m,n])
print(len(p))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
N = int(input())
# = str(input())
# = map(int, input().split())
L = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]
count = 0
numbers = []
for i in range(N):
    numbers.append(i)

c = list(itertools.combinations(numbers, 3))

cn = len(c)
for i in range(cn):
    if L[c[i][0]]+L[c[i][1]]>L[c[i][2]] and L[c[i][1]]+L[c[i][2]]>L[c[i][0]] and L[c[i][2]]+L[c[i][0]]>L[c[i][1]]:
        if L[c[i][0]] != L[c[i][1]] and L[c[i][1]] != L[c[i][2]] and L[c[i][2]] != L[c[i][0]]:
            count+=1

print(count)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

def solve():
    N = int(input())
    Ls = 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 Ls[i] < Ls[j]+Ls[k] and Ls[j] < Ls[k]+Ls[i] and Ls[k] < Ls[j]+Ls[i]:
                    if Ls[i] != Ls[j] and Ls[j] != Ls[k] and Ls[k] != Ls[i]:
                        ans += 1
    print(ans)

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
from itertools import combinations

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

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

cnt = 0
for i in combinations(rods, 3):
    if len(set(i)) != 3:
        continue
    i = sorted(i)
    if i[0] + i[1] <= i[2]:
        continue
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
from itertools import combinations


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

    c = combinations(L, 3)

    ans = 0
    for cc in c:
        if cc[0] == cc[1] or cc[1] == cc[2] or cc[2] == cc[0]:
            continue
        if cc[0] + cc[1] > cc[2] and cc[0] + cc[2] > cc[1] and cc[1] + cc[2] > cc[0]:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
import itertools
N = int(stdin.readline())
L = [int(i) for i in stdin.readline().split()]
counter = 0
for i in itertools.combinations(L,  3):
    if i[0] != i[1]:
        if i[1] != i[2]:
            if i[2] != i[0]:
                if i[0] + i[1] > i[2]:
                    if i[1] + i[2] > i[0]:
                        if i[2] + i[0] > i[1]:
                            counter += 1
print(counter)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    s = input()
    l = [int(i) for i in s.split(' ')]

    d = {}

    for i in l:
        if i not in d:
            d[i] = 0
        d[i] += 1

    l = list(d.keys())

    l.sort()
    ans = 0
    for i in range(len(l)):
        for j in range(i + 1, len(l)):
            a = l[i] + l[j]
            for k in range(j + 1, len(l)):
                if a > l[k]:
                    ans += (d[l[i]] * d[l[j]] * d[l[k]])
                else:
                    break

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    n = int(input().rstrip())

    l_map = {}
    for l in input().rstrip().split(" "):
        l = int(l)
        if l not in l_map:
            l_map[l] = 0
        l_map[l] += 1
    ans = 0
    import itertools
    for c in list(itertools.combinations(l_map.keys(), 3)):
        if max(c) >= sum(c) - max(c):
            continue
        ans += l_map[c[0]] * l_map[c[1]] * l_map[c[2]]
    print(ans)


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
import sys
import math
from collections import defaultdict, deque
from copy import deepcopy
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
def end_of_loop():raise StopIteration
    
    
def main():
    N = I()
    result = 0
    mylist = sorted(LI())
    for i in range(N-2):
        for j in range(i+1,N-1):
            for k in range(j+1,N):
                if mylist[i] < mylist[j] and mylist[j] < mylist[k] and mylist[k] < mylist[i]+mylist[j]:                    
                    result+=1
    print(result)
    
if __name__ == "__main__":
    main()

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

print(ans)

Submission status: Accepted

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

ans=0

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] 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()))
C = []
ans = 0

for c in itertools.combinations(L,3):
  C.append(c)
  
for a in C:
  a = sorted(a)
  if a[0]+a[1]>a[2] and a[0]!=a[1] and a[1]!=a[2]:
    ans+=1
    
print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations

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


pare = list(combinations(L, 3))
count = 0
#print(pare)

for x, y, z in pare:
    if x+y > z and y+z > x and z+x > y and x != y and y != z and z != x:
        count += 1
        #print(x, y, z)
print(count)

Submission status: Accepted

Solution code:
def INT():
    return int(input())

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

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

from itertools import combinations
N = INT()
L = LI()
ans = 0

for c in combinations(L, 3):
    Li, Lj, Lk = c
    if len(set(c)) != 3:
        continue
    if Li + Lj > Lk and Lj + Lk > Li and Li + Lk > Lj:
        ans += 1
        
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
from itertools import combinations
n,*ll = map(int, open(0).read().split())
c = Counter(ll)

ans = 0
for a in combinations(c, 3):
    x,y,z = sorted(a)
    if z < y + x:
        ans += c[z] * c[y] * c[x]

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split(' ')))
l.sort(reverse=True)
length = len(l)
ans = 0
for i in range(length-2):
    for j in range(i+1,length-1):
        if not l[i]==l[j]:
            for k in range(j+1,length):
                if not 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()))

c = 0

for i in range(N):
    for j in range(N):
        for k in range(N):
            if j <= i or k <= j:
                continue

            if L[i] == L[j] or L[j] == L[k] or L[k] == L[i]:
                continue

            if L[i] + L[j] <= L[k] or L[k] <= abs(L[i] -L[j]):
                continue

            c += 1 

print(c)

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

print(cnt)

Submission status: Accepted

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

ret = 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 > c and b + c > a and c + a > b and a != b and b != c and c != a:
        ret += 1

print(ret)

Submission status: Accepted

Solution code:
from itertools import combinations
N = int(input())
L = sorted(map(int, input().split()))
c = 0
for a in combinations(L, 3):
  if a[0]==a[1] or a[0]==a[2] or a[1]==a[2]:
    continue
  if a[0]+a[1]>a[2]:
    c += 1
print(c)

Submission status: Accepted

Solution code:
from itertools import combinations
N = int(input())
L = [int(i) for i in input().split()]
nums = list(combinations(L, 3))

cnt = 0
for pos in nums:
    pos = list(pos)
    pp = sorted(pos)
    if pp[0] != pp[1] and pp[1] != pp[2] and pp[0] + pp[1] > pp[2]:
        cnt += 1

print(cnt)

Submission status: Accepted

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

def solve():
    N = int(readline())
    L = list(map(int, readline().split()))

    if N <= 2:
        print(0)
        return

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

solve()

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 2*max(l[i],l[j],l[k])<l[i]+l[j]+l[k] and len({l[i],l[j],l[k]})==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):
    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 != c != a and a + b > c and  b + c > a and c + a > b:
                # print(a, b, c)
                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(len(L)):
  for j in range(i,len(L)):
    for k in range(j,len(L)):
      if (L[i]!=L[j]!=L[k]) and (L[i]+L[j]>L[k]):
        count += 1
print(count)

Submission status: Accepted

Solution code:
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((i8[:], ), cache=True)
def main(L):
    L.sort()
    N = len(L)
    ans = 0
    for k in range(N):
        for j in range(k):
            for i in range(j):
                if L[i] == L[j] or L[j] == L[k]:
                    continue
                if L[i] + L[j] > L[k]:
                    ans += 1
    return ans

L = np.array(read().split(), np.int64)[1:]

print(main(L))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
def main():
    from itertools import combinations

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

    ans = 0
    for i, j, k in combinations(L, 3):
        if i == j or j == k or k == i:
            continue
        tri = sorted([i, j, k])
        ans += 1 if tri[2] < sum(tri[:2]) else 0
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import itertools

def chkTrg(a,b,c):
    if (a + b > c and b + c > a and c + a > b) and (a != b and b != c and c != a):
        return True
    else:
        return False

N = int(input())
bars = [int(i) for i in input().split(" ")]

cnt = 0

for bar in itertools.combinations(bars, 3):
    if chkTrg(bar[0],bar[1],bar[2]):
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
def differ_length(i, j, k):
  return (i != j) and (j != k) and (i != k)

def exist_triangle(i, j, k):
  return (i + j > k) and (j + k > i) and (i + k > j)

n_stick = int(input())

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

count = 0

for i in range(n_stick):
  for j in range(i + 1, n_stick):
    for k in range(j + 1, n_stick):
      
      if differ_length(length[i], length[j], length[k]) and exist_triangle(length[i], length[j], length[k]):
        count += 1
        
print(count)

Submission status: Accepted

Solution code:
(n,),l = [list(map(int, s.split())) for s in open(0)]
ans = 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[i] + l[k] > l[j] and \
               l[k] + l[j] > l[i]:
                ans += 1
#                 print(i+1,j+1,k+1)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
L.sort()
p = []
d = {}
for i in range(N):
  if(L[i] in d):
    d[L[i]] += 1
  else:
    p.append(L[i])
    d[L[i]] = 1
ans = 0
if(len(p)<3):
  print(0)
else:
  for i in range(len(p)-2):
    for j in range(i+1,len(p)-1):
      for k in range(j+1,len(p)):
        if(p[i]+p[j]>p[k] and p[i]+p[k]>p[j] and p[k]+p[j]>p[i]):
          ans += d[p[i]]*d[p[j]]*d[p[k]]
  print(ans)

Submission status: Accepted

Solution code:
import itertools

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

if n<=2:
  print(0)
  exit()
  
ans=0

for y in list(itertools.combinations(x,3)):
  lst=sorted(y)
  if lst[0]!=lst[1]:
      if lst[0]!=lst[2]:
          if lst[1]!=lst[2]:
            if abs(lst[1]-lst[0])<lst[2]<(lst[0]+lst[1]):
              ans+=1
      
      
print(ans)

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

print(ans)

Submission status: Accepted

Solution code:
import sys
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    ans = 0
    for i in range(n):
        a = l[i]
        for j in range(i+1,n):
            b = l[j]
            for k in range(j+1,n):
                c = l[k]
                if a!=b and a!=c and b!=c:
                    if a+b>c and b+c>a and c+a>b:
                        ans += 1
    print(ans)
    return

if __name__=='__main__':
    n = I()
    l = list(IL())
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
L_list = []
for L in map(int, input().split()):
	L_list.append(L)

L_list.sort()

count = 0
for i in range(N):
	a = L_list[i]
	for j in range(i + 1, N):
		b = L_list[j]
		if a == b:
			continue
		for k in range(j + 1, N):
			c = L_list[k]
			if a == c or b == c:
				continue
			x, y, z = sorted([a, b, c])
			if z < x + y:
				count += 1
print(count)

Submission status: Accepted

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

L.sort()
ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# map(int, input().split())
N = int(input())
L = list(map(int, input().split()))

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

    print(score)

Submission status: Accepted

Solution code:
from collections import defaultdict
n = int(input())
L = list(map(int, input().split()))
L.sort()
s = defaultdict(int)
for l in L:
    s[l] += 1
L = set(L)

s = dict(s)
ans = 0
for a in L:
    for b in L:
        for c in L:
            if a < b and b < c and a+b > c and b+c > a and c+a > b:
                ans += s[a]*s[b]*s[c]
print(ans)

Submission status: Accepted

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