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(sorted(map(int, input().split())))
x = 0
if n >= 3:
    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:
import itertools
 
N = int(input())
L = list(map(int,(input().split())))
 
Combination = list(itertools.permutations(L, 3))
count = 0
for i in Combination:
    # a+b>c かつ b+c>a かつ c+a>b
    a = int(i[0])
    b = int(i[1])
    c = int(i[2])
    if((a+b)> c and (b+c) >a and (c+a) >b and a!=b and b!= c and a!= c and a<b and b<c):
        count+=1
 
print(count)

Submission status: Accepted

Solution code:
import itertools
 
N = int(input())
L = list(map(int,(input().split())))
L.sort()
Combi = list(itertools.combinations(L, 3))
count = 0
 
for i in Combi:
    a = int(i[0])
    b = int(i[1])
    c = int(i[2])
    if((a+b)> c and a!=b != c and  a<b <c ):
        count+=1
 
print(count)

Submission status: Accepted

Solution code:
import itertools

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

for i, j, k in Combi:

    if((i+j)> k and i!=j!=k and  i<j <k ):
        count+=1
print(count)

Submission status: Accepted

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

ans = 0
for i in range(N):
    for j in range(i):
        for k in range(j):
            if L[i] != L[j] and L[j] != L[k] and L[k] != L[i] and 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:
N = int(input())

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

L.sort()

ans = 0

if N >= 3 :
    for i in range(0, N - 1) :
        for j in range(1, N - 1 - i) :
            for k in range(2, N - i):
                if L[i] < L[i+j] < L[i+k] and L[i] + L[i+j] > L[i+k]:
                    ans += 1

print(ans)

Submission status: Accepted

Solution code:
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

n = iinp()
l = lmiinps()

ans = 0

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

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().rstrip().split())
inl = lambda: list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))

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

n = ini()
a = inl()
ans = 0
for i in range(n):
    for j in range(i+1, n):
        for t in range(j+1, n):
            if check(a[i], a[j], a[t]):
                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 l[i] + l[j] > l[k] and l[j]+l[k]>l[i] and l[k]+l[i]>l[j]  and i<j and j<k and l[i] != l[j] != l[k] != l[i]:
        c += 1

print(c)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int,input().split()))
count = 0
for i in range(n):
    for ii in range(n):
        for iii in range(n):
            if l[i] + l[ii] > l[iii] and l[ii] + l[iii] > l[i] and l[iii] + l[i] > l[ii] and i<ii and ii < iii and l[i] != l[ii] and l[i] != l[iii] and l[ii] != l[iii]:
                count += 1
print(count)

Submission status: Accepted

Solution code:
import numpy as np
from numba import *

N = int(input())
length = np.array(input().split(), np.int64)

length = np.sort(length)

@njit
def calc(cache=True):
    cnt = 0

    for i in range(N):
        for j in range(i + 1, N):
            for k in range(j + 1, N):
                l1, l2, l3 = length[i], length[j], length[k]
                if (l1 != l2 and l1 != l3 and l2 != l3):
                    if (l1 + l2 > l3):
                        cnt += 1
    
    return (cnt)

ans = calc()
print(ans)

Submission status: Accepted

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

ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if L[i]!=L[j] and L[i]!=L[k] and L[j]!=L[k] and abs(L[j]-L[k])<L[i]<L[j]+L[k]:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int,input().split()))
count = 0
l.sort()
for a,i in enumerate(l):
    for b,j in enumerate(l,a+1):
        if i >= j:
            continue
        for c,k in enumerate(l,b+1):
            if j >= k:
                continue
            if k-j<i:
                count+=1
                
print(count)

Submission status: Accepted

Solution code:
n=int(input())

a=input().split(' ')
b=[int(i) for i in a]
s=0
for k in range(2,n):
  for j in range(1,k):
    for i in range(j):
      if (b[i]!=b[j] and b[j]!=b[k] and b[k]!=b[i]):
        m=max(b[i],b[j],b[k])
        if 2*m<b[i]+b[j]+b[k]:
          s+=1
print(s)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for x in L:
    for y in L:
        for z in L:
            if x != y:
                if x < z:
                    if y < z:
                        if x + y > z:
                            ans += 1

print(int(ans/2))

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int,input().split()))
if N < 3:
    print(0)
    exit()
count = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        if L[i] == L[j]:
            continue
        else:
            for k in range(j+1,N):
                if L[i]==L[k] or L[j]==L[k]:
                    continue
                elif abs(L[i]+L[j])>L[k]and abs(L[i]-L[j])<L[k]:
                    count += 1
print(count)

Submission status: Accepted

Solution code:
def execute(N, L):
    c = 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]):
                    c += 1

    return c

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

if __name__ == '__main__':
    N = int(input())
    L = list(map(int, input().split()))

    print(execute(N, L))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

arr_arr = []

for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            arr = sorted([l[i], l[j], l[k]])
            if (arr[0] + arr[1] > arr[2]) and ((arr[0] != arr[1])and(arr[1] != arr[2])):
                arr_arr.append(arr)

print(len(arr_arr))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

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

x = read().rstrip().decode()
"""

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

def solve():
    ret = 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]:
            ret += 1
            #print(i,j,k)
    
    return ret

print(solve())

Submission status: Accepted

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

    for i, li in enumerate(ls):
        for j, lj in enumerate(ls[i+1:]):
            if li == lj:
                continue
            for lk in ls[i+j+2:]:
                if lj == lk:
                    continue

                if li + lj > lk:
                    ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import itertools
N = int(input())
L = list(map(int,input().split()))
tri_list = list(itertools.combinations(L,3))
num = 0
for i in range(len(tri_list)):
    combi = tri_list[i]
    if (combi[0] != combi[1]) and (combi[1] != combi[2]) and (combi[2] != combi[0]):
        if ((abs(combi[0] - combi[1])) < combi[2]) and (combi[2] < (combi[0] + combi[1])):
            num += 1
print(num)

Submission status: Accepted

Solution code:
# B - Making Triangle

n = int(input())
l = list(map(int, input().split()))
assert n == len(l)

count = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]:
                continue
            a, b, c = sorted((l[i], l[j], l[k]))
            if a + b > c:
                count += 1
print(count)

Submission status: Accepted

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

l_dic = {}
for i in range(n):
    if l[i] not in l_dic:
        l_dic[l[i]] = 0
    l_dic[l[i]] += 1

l_item = list(l_dic.items())
l_item.sort(key = lambda x:x[0])

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

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
if n < 3:
    print(0)
    exit()
L = list(map(int,input().split()))
ans = 0
for i in range(n):
    for j in range(i,n):
        for k in range(j,n):
            if L[i] != L[j] and L[i] != L[k] and L[j] != L[k]:
                m = max(L[i],L[j],L[k])
                s = L[i]+L[j]+L[k]
                if m < s-m:
                    ans += 1
print(ans)

Submission status: Accepted

Solution code:
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for x in combinations(l, 3):
    if x[0]!=x[1] and x[0]!=x[2] and x[1]!=x[2]:
        if x[0] + x[1] > x[2]:
            ans+=1
print(ans)

Submission status: Accepted

Solution code:
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
ans = 0
for x in combinations(l, 3):
    if x[0]!=x[1] and x[0]!=x[2] and x[1]!=x[2]:
        if x[0] + x[1] > x[2]:
            ans+=1
print(ans)

Submission status: Accepted

Solution code:
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
t = defaultdict(int)
ans = 0
for x in combinations(l, 3):
    if x[0]!=x[1] and x[0]!=x[2] and x[1]!=x[2]:
        if x[0] + x[1] > x[2]:
            ans+=1
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
input = stdin.readline
N = map(int, input().split())
L = list(map(int, input().split()))

c=0

for i in range(len(L)-2):
    for j in range(i+1,len(L)):
        for k in range(j+1,len(L)):
            if L[i]+L[j]>L[k] and L[j]+L[k]>L[i] and L[k]+L[i]>L[j] and L[i]!=L[j] and L[j]!=L[k] and L[k]!=L[i]:c=c+1

print(c)

Submission status: Accepted

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


main()

Submission status: Accepted

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

cnt = 0

for i in range(N-2):
    a = L[i]
    
    for j in range(i+1,N-1):
        b = L[j]
        if a != b:
            
            for k in range(j+1,N):
                c = L[k]
                if b != c & c != a:
                    if a + b > c:
                        cnt += 1
print(cnt)

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

print(cnt)

Submission status: Accepted

Solution code:
n, *a = map(int, open(0).read().split())
print(sum(i < j < k < i + j for k in a for j in a for i in a))

Submission status: Accepted

Solution code:
import itertools

def is_triangle(list_L):
    
    if (list_L[0] + list_L[1] > list_L[2]) and (list_L[1] + list_L[2] > list_L[0]) and (list_L[2] + list_L[0] > list_L[1]) :
        return True
    else :
        return False

def is_uniqueL(list_L):

    return len(list_L) == len(set(list_L))

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

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

sum = 0

for a_comb_L in comb_L :

    if is_uniqueL(a_comb_L) == True and is_triangle(a_comb_L) == True:
        sum += 1

print(sum)

Submission status: Accepted

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

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])&(L[i]!=L[k])&(L[j]!=L[k]):
                if (L[i]+L[j]>L[k])&(L[i]+L[k]>L[j])&(L[j]+L[k]>L[i]):
                    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 - 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]:
                    M = [L[i], L[j], L[k]]
                    M.sort()
                    if M[2] < M[0] + M[1]:
                        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import itertools as it
n=int(input())
a=sorted(map(int,input().split()))
print(sum(sum(x)>2*x[2]and len(x)==len(set(x))for x in it.combinations(a,3)))

Submission status: Accepted

Solution code:
import itertools as it
n=int(input())
a=sorted(map(int,input().split()))
print(sum(sum(x)>2*x[2]and len(x)==len(set(x))for x in it.combinations(a, 3)))

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

Submission status: Accepted

Solution code:
import itertools
N=int(input())
L=list(map(int,input().split()))
c=0
if len(L) >=3:
    for v in itertools.combinations(L, 3):
        if (v[0] != v[1] and v[1] != v[2]) and v[0] != v[2]:
            if sorted(v)[-2]+min(v) > max(v):
                c=c+1
            else:
                c=c
        else:
            c=c
else:
    c=0
print(c)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

num = int(input())
count = 0
str = input().split()
table = [int(i) for i in str]
#全探索
for j in range(num): #ループ1
    for k in range(j+1, num): #ループ2
        for l in range(k+1, num): #ループ3
            if table[j] != table[k] and table[k] != table[l] and table[j] != table[l]:
                len = table[j] + table[k] + table[l] #周の長さ
                ma = max(table[j], max(table[k], table[l])) #一番長い辺
                rest = len - ma #残りの2辺の合計
                if ma < rest: #最大の辺が残り2辺より小さければ三角形は成立する
                    count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = [int(x) for x in input().split()]
c = 0
for i in range(n):
  for j in range(i+1,n):
    if a[i] == a[j]:
      continue
    for k in range(j+1,n):
      if a[i] == a[k] or a[j] == a[k]:
        continue
      if a[i] + a[j] > a[k] and a[j] + a[k] > a[i] and a[k] + a[i] > a[j]:
        c += 1
        
print(c)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

import itertools as it
per = it.combinations(S,r=3)

cnt = 0
for r in per:
  a,b,c = r
  if a ==  b or b == c or a == c:
    continue
    
  if a+b > c and b+c > a and a+c > b:
    #print(a,b,c)
    cnt += 1
    
print(cnt)

Submission status: Accepted

Solution code:
from itertools import combinations 

N=input()
L=[int(x) for x in input().split()]
comb = combinations(L, 3)
c = 0
for x in comb:
    t=list(x)
    t.sort()
    if t[0]!=t[1] and t[1]!=t[2] and t[0]!=t[2] and t[0]+t[1]>t[2]:
        c += 1
print(c)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

count = 0

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


print(count)

Submission status: Accepted

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

# n = 1 or 2
if n == 1 or n == 2:
  print(0)
  exit()

# n >= 3
len_count = {}
for l in length:
  if l not in len_count:
    len_count[l] = 1
  else:
    len_count[l] += 1

uniq_len = sorted(list(set(length)))
n_len = len(uniq_len)
triangle = []

from itertools import combinations
for c in combinations(uniq_len,3):
  c = sorted(list(c))
  if c[0] + c[1] > c[2]:
    triangle.append(c)
      
ans = 0
for t in triangle:
  ans += len_count[t[0]] * len_count[t[1]] * len_count[t[2]]

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):
            _lst = [l[i], l[j], l[k]]

            if len(set(_lst)) == 3:
                _max = max(_lst)
                _lst.remove(_max)
                if _max < sum(_lst):
                    ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]:
                continue
            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:
# 175 B
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 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] and L[j] != L[k] and (L[k] < L[i] + L[j]):
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
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,n-1):
            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]:
                    break
                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):
  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[k] + L[j] > L[i]) and (L[i] + L[k] > L[j]):
          count += 1
          
print(count)

Submission status: Accepted

Solution code:
N = int(input())
L = [int(x) for x in 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)):
            a = L[i]
            b = L[j]
            c = L[k]
            p = a + b > c
            s = a != b
            t = b != c
            if p and s and t:
                cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
L = [int(x) for x in 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)):
            a = L[i]
            b = L[j]
            c = L[k]
            p = a + b > c
            q = b + c > a
            r = c + a > b
            s = a != b
            t = b != c
            u = c != a
            if p and q and r and s and t and u:
                cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
N = input()
L = list(map(int, 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] or L[j] == L[k] or L[k] == L[i]:
                continue
            elif L[i] + L[j] <= L[k] or L[j] + L[k] <= L[i] or L[k] + L[i] <= L[j]:
                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):
    for j in range(i+1, N):
        for k in range(j+1, N):

            edge_list = sorted([L[i], L[j], L[k]])
            if edge_list[0] != edge_list[1] != edge_list[2] and edge_list[2] < edge_list[0] + edge_list[1]:

                ans += 1


print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations

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

count = 0
for C in combinations(L, 3):
    l_list = list(C)
    l_list.sort()

    if l_list[2] > l_list[1] and l_list[1] > l_list[0]:
        if l_list[2] < l_list[1] + l_list[0]:
            count += 1

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
n = int(sys.stdin.readline().rstrip("\n"))
l = [int(s) for s in sys.stdin.readline().rstrip("\n").split()]
l.sort()
ans = 0
for a in range(n):
    for b in range(a+1,n):
        for c in range(b+1,n):
            if l[a] != l[b] and l[b] != l[c] and l[a] != l[c]:
                if l[a] + l[b] > l[c]:
                    ans += 1
print(ans)