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())
if n == 1 or n == 2:
    print(0)

else:
    len = list(map(int, input().split()))

    number = 0
    for i in range(n):
        for j in range(i + 1, n):
            for k in range(j + 1, n):
                len.sort()
                if len[i] == len[j] or len[j] == len[k]:
                    continue
                elif len[j] - len[i] < len[k] and len[k] < len[i] + len[j]:
                    number += 1
                else:
                    continue
    print(number)

Submission status: Accepted

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

if n == 1 or n == 2:
    print(0)
else:
    ans = 0
    for i in range(n):
        for j in range(i + 1,n):
            for k in range(j+1,n):
                len.sort()
                if len[i] == len[j] or len[j] == len[k]:
                    continue
                if len[j] - len[i] < len[k] and len[j]  + len[i] > len[k]:
                    ans = ans + 1
                else :
                    continue
    print(ans)

Submission status: Accepted

Solution code:
#棒の組み合わせを算出するためにitertoolsモジュールをインポートする
import itertools

# 棒の数を入力する
N = int(input())
# 棒の長さをスペース区切りで入力し、格納する
L = map(int,input().split())

#カウントを初期化する
count = 0
#　入力された棒から3本の組み合わせをxに代入してループさせる
for x in itertools.combinations(L,3) :
    #　そもそも同じ長さの棒が含まれていないことを確認する
    if x[0] != x[1] and x[0] != x[2] and x[1] != x[2]:
        # 三角形の辺の条件である2辺の和＞残りの1辺であるか判定する
        if x[0] + x[1] > x[2] and x[0] + x[2] > x[1] and x[1] + x[2] > x[0]:
            count = count + 1   
    
print(count)

Submission status: Accepted

Solution code:
def judge(li, lj, lk):
    return li != lj and lj != lk and li != lk and li + lj > lk and lj + lk > li and li + lk > lj


if __name__ == "__main__":
    N = int(input())
    L = list(map(int, input().split()))
    ans = 0
    for i in range(N-2):
        for j in range(i+1, N-1):
            for k in range(j+1, N):
                if judge(L[i], L[j], L[k]):
                    ans += 1
    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):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            if L[i] + L[j] > L[k] and L[j] + L[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:
def is_exist_triangle(a, b, c):
    l = [a, b, c]
    l.sort()
    return l[0] + l[1] > l[2] if len(set(l)) == 3 else False


def main():
    n = int(input())
    length = 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):
                ans += 1 if is_exist_triangle(length[i], length[j], length[k]) else 0
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
l=[*map(int,input().split())]
ans=0
for i in range(n-2):
    for j in range(i,n-1):
        for k in range(j,n):
            if abs(l[i]-l[j])<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 = input()
L = list(map(int, input().split()))
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[i]!=L[j] and L[j]!=L[k] and L[k]!=L[i]:
                m = max(list([L[i],L[j],L[k]]))
                if 2*m < L[i]+L[j]+L[k]:
                    cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int,input().split()))
sticks = sorted(l)
count = 0
if n <= 2:
    print(0)
else:
    for x in range(n-2):
        for y in range(x+1,n-1):
            for z in range(y+1,n):
                if sticks[x] != sticks[y] and sticks[y] != sticks[z] and sticks[z] != sticks[x] and sticks[x] + sticks[y] > sticks[z]:
                    count += 1
    print(count)

Submission status: Accepted

Solution code:
#! env/bin/local python3
# -*- coding: utf-8 -*-

from itertools import combinations


def is_tri(_a, _b, _c):
    if (_a + _b > _c) and (_b + _c > _a) and (_c + _a > _b):
        return True
    else:
        return False


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

h = combinations(sticks, 3)

counter = 0
for a, b, c in h:
    if is_tri(a, b, c):
        # a, b, c = sorted([a, b, c])
        if (a != b) and (b != c) and (c != a):
            counter += 1

print(counter)

Submission status: Accepted

Solution code:
#! env/bin/local python3
# -*- coding: utf-8 -*-

from itertools import combinations


def is_tri(_a, _b, _c):
    if (_a + _b > _c) and (_b + _c > _a) and (_c + _a > _b):
        return True
    else:
        return False


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

h = combinations(sticks, 3)

counter = 0
for a, b, c in h:
    if is_tri(a, b, c):
        a, b, c = sorted([a, b, c])
        if (a != b) and (b != c):
            counter += 1

print(counter)

Submission status: Accepted

Solution code:
N = int(input())
leng = list(map(int, input().split( )))
count = 0
for i in range(N-2):
  for j in range(i+1, N-1):
    if leng[i] == leng[j]:continue
    for k in range(j+1, N):
      if leng[i] == leng[k] or leng[j] == leng[k]:continue
      L = [leng[i],leng[j],leng[k]]
      if max(L) < sum(L)-max(L):
        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(len(l)-2):
    x = l[i]
    for j in range(i+1,len(l)-1):
        y = l[j]
        for k in range(j+1,len(l)):
            z = l[k]
            if x+y>z and y+z>x and z+x>y:
                if x!=y and y!=z:
                    ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

Solution code:
it = lambda: list(map(int, input().strip().split()))

def solve():
    N = int(input())
    L = it()
    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] and L[i] + L[j] > L[k] and L[i] + L[k] > L[j] and L[k] + L[j] > L[i]:
                    ans += 1
    return ans


if __name__ == '__main__':
    ans = solve()
    print(ans)

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
d_pre=input().split()
d=[int(s) for s in d_pre]
ans=0
for i in range(N-2):
    for j in range(i,N-1):
        for k in range(j,N):
            if (d[i]+d[j]>d[k]) and (d[i]+d[k]>d[j]) and (d[k]+d[j]>d[i]) and d[i]!=d[k] and d[i]!=d[j] and d[k]!=d[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 range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i] != l[j]:
                if l[i] != l[k]:
                    if 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]:
                            cnt += 1
print(cnt)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
l = [int(x) for x in input().split()]
l = sorted(l)
m = {}
for x in l:
    if x in m:
        m[x] += 1
    else:
        m[x] = 1

awa = []
last = -1
for x in l:
    if x == last:
        continue
    awa.append(x)
    last = x

num = 0
for x in range(len(awa)-2):
    for y in range(x+1,len(awa)-1):
        for z in range(y+1,len(awa)):
            if awa[x] + awa[y] > awa[z] and awa[x] + awa[z] > awa[y] and awa[y] + awa[z] > awa[x]:
                num += m[awa[x]] * m[awa[y]] * m[awa[z]]

print(num)

Submission status: Accepted

Solution code:
N = int(input())
dic = {}
L = list(map(int, input().split()))
L.sort()
s = 0
for i in range(0, 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[i] != L[j] and L[j] != L[k] and L[i] != L[k] :
                s+=1
print (s)

Submission status: Accepted

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

n = len(L)
c = 0
result = []
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if L[i]!=L[j] and L[j]!=L[k] and L[i]!=L[k]:
                if L[i]+L[j]>L[k] and L[j]+L[k]>L[i] and L[i]+L[k]>L[j]:
                    #print(L[i], L[j], L[k])
                    c += 1
print(c)

Submission status: Accepted

Solution code:
import sys

# B - Making Triangle
import itertools

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

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

for combi in combis:
	a, b, c = combi

	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=list(map(int,input().split()))
a.sort()
r=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] and a[j]!=a[k] and a[k]!=a[i]:
                r+=1
                #print(a[i],a[j],a[k])
print(r)

Submission status: Accepted

Solution code:
import itertools as it


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


c = it.combinations(s, 3)

for i in c:
    if i[0] == i[1] or i[1] == i[2] or i[2] == i[0]:
        continue
    elif (i[0] + i[1]) > i[2]:
        count += 1

print(count)

Submission status: Accepted

Solution code:
import itertools as it


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


c = it.combinations(s, 3)

for i in c:
    listed = list(i)
    if listed[0] == listed[1] or listed[1] == listed[2] or listed[2] == listed[0]:
        continue
    if (listed[0] + listed[1]) > listed[2]:
        count += 1

print(count)

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+1, n):
        for k in range(j+1, n):
            a = l[i]
            b = l[j]
            c = l[k]
            if not len(set([a, b, c])) == 3:
                continue
            if abs(a-b) < c < a + b:
                cnt += 1
                
print(cnt)

Submission status: Accepted

Solution code:
import itertools as it


N = int(input()) - 1
s = list(map(int, input().split()))
count = 0

c = it.combinations(s, 3)

for i in c:
    listed = list(i)
    if listed[0] == listed[1] or listed[1] == listed[2] or listed[2] == listed[0]:
        continue
    maximum = max(listed)
    listed.remove(maximum)
    if (listed[0] + listed[1]) > maximum:
        count += 1

print(count)

Submission status: Accepted

Solution code:
import math
import itertools
from itertools import combinations
N = int(input())
A = input().split()
list = [int(n) for n in A]
a = 0
for v in itertools.combinations(list, 3):
    u = sorted(v)
    if u[0] != u[1] != u[2]:
        if u[2] < u[1]+u[0] and u[1]-u[0] < u[2]:
            a = a+1
        else:
            continue
    else:
        continue
print(a)

Submission status: Accepted

Solution code:
import math
import itertools
from itertools import combinations
N = int(input())
A = [[]] * N
A = input().split()
list = [int(n) for n in A]
a = 0
for v in itertools.combinations(list, 3):
    u = sorted(v)
    if u[0] != u[1] != u[2]:
        if u[2] < u[1]+u[0] and u[1]-u[0] < u[2]:
            a = a+1
        else:
            continue
    else:
        continue
print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

L.sort()

candidates = itertools.combinations(L, 3)

count = 0

for t in candidates:
    if t[0] == t[1] or t[1] == t[2]:
        continue
    if t[0] + t[1] > t[2]:
        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(n):
    if i ==	j:
      continue
    for k in range(n):
      if j == k:
        continue
      elif i == k:
        continue
      if l[i] < 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

def f(x,y,z):
    global L
    if L[x] + L[y] > L[z]:
        return True
    else:
        return False

def g(x,y,z):
    global L
    if L[x] != L[y] and L[z] != L[y] and L[x] != L[z]:
        return True
    else:
        return False

for p in range(len(L)-2):
    for q in range(p+1,len(L)-1):
        for r in range(q+1,len(L)):
            if f(p,q,r) and f(q,r,p) and f(r,p,q) and g(p,q,r):
                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):
    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] and l[k]+l[j] > l[i] and l[k]+l[i] > l[j]:
                ans += 1

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import math
from operator import mul
from functools import reduce
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)

# lis_of_lis = [[] for _ in range(N)]


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


N = z()
L = zz()
L = sorted(L)
ans = 0
for i, j, k in itertools.combinations_with_replacement(range(N), 3):
    if((L[i] + L[j] > L[k]) and (not ((L[i] == L[k]) or (L[i] == L[j]) or (L[j] == L[k])))):
        # print(L[i], L[j], L[k])
        ans += 1
print(ans)

Submission status: Accepted

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

L=[]
for i in array:
    L.append(i)

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

L.sort()

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

M=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]:
                    M+=1
print(M)

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

Submission status: Accepted

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

sorted_Long = sorted(Long)

count = 0

for i in range(0,N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if sorted_Long[i] + sorted_Long[j] > sorted_Long[k]:
                if sorted_Long[i] != sorted_Long[j] and sorted_Long[j] != sorted_Long[k]:
                    # print(sorted_Long[i] , sorted_Long[j], sorted_Long[k])
                    count += 1

print(count)

Submission status: Accepted

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


def next_line():
    return input()


def next_int():
    return int(input())


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


def next_int_array_multi_lines(size):
    return [int(input()) for _ in range(size)]


def next_str_array(size):
    return [input() for _ in range(size)]


def main():
    n = next_int()
    ar = sorted(next_int_array_one_line())
    res = 0
    for i in range(n):
        for j in range(i+1, n):
            for k in range(j+1, n):
                if ar[i] < ar[j] and ar[j] < ar[k] and ar[i] + ar[j] > ar[k]:
                    res += 1
    print(res)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))
  
n=int(input())
L=input_array()
count=0
for i in range(0,n):
	for j in range(i+1,n):
		for k in range(j+1,n):
			if L[i]!=L[j] and L[j]!=L[k] and L[i]!=L[k]:
				a=L[i]+L[j]
				b=L[j]+L[k]
				c=L[i]+L[k]
				if a>L[k] and b>L[i] and c>L[j]:
					count+=1

print(count)

Submission status: Accepted

Solution code:
N = int(input())
l = sorted([int(x) for x 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):
        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]:
                ans += 1
print(ans)

Submission status: Accepted

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

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

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 checkValidity(L[i], L[j],L[k]):
                res += 1
 
print(res)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
# -*- using:utf-8 -*-
from itertools import combinations

class main:
  def T(array):
    cnt = 0
    for i in array:
      a, b, c = i
      if a != b and a != c and b != c and a < b + c:
        cnt += 1
    print(cnt)

  def Sort(array):
    for i in range(len(array)):
      array[i] = sorted(array[i], reverse=True)
    return array

if __name__ == "__main__":
  n = int(input())
  l = list(map(int, input().split()))
  array = list(combinations(l, 3))
  array = main.Sort(array)
  main.T(array)

Submission status: Accepted

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

counter = 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[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[j]+L[k] > L[i]:
                counter += 1
                """
                print("i:%d" % (i+1))
                print("j:%d" % (j+1))
                print("k:%d" % (k+1))
                print("\n")
                """
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+1,n):
    for k in range(j+1,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[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(" ")))
count = 0
for i in range(n):
    li = l[i]
    for j in range(i + 1, n):
        lj = l[j]
        if li == lj:
            continue
        for k in range(j + 1, n):
            lk = l[k]
            if li == lk or lj == lk:
                continue
            if (
                li + lj > lk and
                lj + lk > li and
                lk + li > lj
            ):
                count += 1
print(count)

Submission status: Accepted

Solution code:
import itertools

N=int(input())
L=list(map(int,input().split()))
L.sort()
l=list(itertools.combinations(L,3))

ans=0
for i in l:
    if len(i)==len(set(i)) and i[2]<i[1]+i[0]:
        ans+=1

print(ans)

Submission status: Accepted

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

L.sort()
#print(L)

count = 0
for i in range(N):
	for j in range(N):
		for k in range(N):
			if (i <j and j<k ) and (L[i] != L[j] and L[j] != L[k] and L[k] !=L[i]) and (L[i] +L[j] > L[k]):
				count = count + 1
#				print(i,j,k,"/",L[i],L[j],L[k])
print(count)

Submission status: Accepted

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

print(count)

Submission status: Accepted

Solution code:
import sys
from itertools import combinations

n, *lll = map(int, sys.stdin.buffer.read().split())
ans = 0
for i, j, k in combinations(lll, 3):
    if i == j or j == k or k == i:
        continue
    l = max(i, j, k)
    if (i + j + k - l) > l:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
nums = map(int, input().split(" "))
num_comb = list(itertools.combinations(nums, 3))

counter = 0
for _nums in num_comb:
    nums = list(_nums)
    nums.sort()
    n_pure = len(set(nums))
    # print(nums, n_pure)
    if (nums[0] + nums[1] > nums[2]) & (n_pure == 3):
        counter += 1
        
print(counter)

Submission status: Accepted

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

ans = 0
for i, ai in enumerate(a):
    for f, af in enumerate(a[i + 1:], i + 1):
        if ai == af:
            continue
        for ag in a[f + 1:]:
            if ag == af:
                continue
            if ai + af > ag:
                ans += 1
print(ans)

Submission status: Accepted

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

count = 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 len(set([l[i], l[j], l[k]])) == 3:
                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:
from collections import Counter
from itertools import combinations

N = int(input())
L = Counter(list(map(int, input().split())))
ans = 0
for sides in combinations(L.keys(), 3):
    a, b, c = sorted(sides)
    if a + b > c:
        ans += L[a]*L[b]*L[c]
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[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()))
L.sort()
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 and b != c and a + b > c:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
n, *L = map(int, open(0).read().split())
L.sort()
c = 0
for i in range(n-2):
  li = L[i]
  for j in range(i+1, n-1):
    lj = L[j]
    if li == lj:
      continue
    for k in range(j+1, n):
      lk = L[k]
      if lj == lk or li + lj <= lk:
        continue
      c += 1
print(c)

Submission status: Accepted

Solution code:
#aaa
N = int(input())
L = input().split(" ")
#print(L)
vec = [int(i) for i in L ]
#print(vec)
vec.sort()
#print(vec)
ans = 0

for i in range(N):
  for j in range(N):
    if j < i :
      for k in range(N):
        if k < j:
          if vec[k] != vec[j] and vec[i] != vec[j] and vec[j]+vec[k] > vec[i]:
            ans += 1
            
print(ans)

Submission status: Accepted

Solution code:
def main():
  n = int(input())
  l = sorted(list(map(int,input().split())))
  ans = 0
  for i in range(n-2):
    for j in range(i+1,n-1):
      for k in range(j+1,n):
        a = l[i]
        b = l[j]
        c = l[k]
        if a+b>c and abs(a-b)<c and a!=b and b!=c and c!=a:
          ans += 1
  print(ans)
  
if __name__=="__main__":
  main()

Submission status: Accepted

Solution code:
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):
			a = l[i]
			b = l[j]
			c = l[k]
			if (a+b>c) and (abs(a-b)<c) and (a!=b) and (b!=c) and (c!=a):
				count += 1
print(count)

Submission status: Accepted

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

ans=0
for i in range(N):
    for j in range(i,N):
        for k in range(j,N):
            e1 = L_list[i]
            e2 = L_list[j]
            e3 = L_list[k]
            if e1 != e2 and e2 != e3 and e1 != e3:
                edge_list = sorted([e1,e2,e3])
                if edge_list[2] - edge_list[1] < edge_list[0]:
                    ans += 1
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(i,N):
        for k in range(j,N):
            if (L[i] != L[j] and L[j] != L[k]):
                    if (L[i] + L[j] > L[k]):
                            count += 1
                        
print(count)