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()))

import itertools
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
l = [int(_) for _ in input().split()]
count = 0
for i,s1 in enumerate(l):
  for j,s2 in enumerate(l[i+1:]):
    for s3 in l[i+j+2:]:
      # print(s1, s2, s3)
      if len(set([s1, s2, s3]))!=3:
        continue
      elif ((s1+s2)>s3)&((s1+s3)>s2)&((s2+s3)>s1):
        count += 1
print(count)

Submission status: Accepted

Solution code:
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


N=int(input())
L=nl()
L.sort()
ans=0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if(L[i]==L[j] or L[j]==L[k] or L[i]==L[k]):
                continue 
            if((L[i]+L[j])>L[k]):
                ans+=1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = [int(a) for a in input().split()]
count = 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(a != b and b != c and c != a):
                if(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()))

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

print(ans)

Submission status: Accepted

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


    comb = itertools.combinations(L, 3)
    ans = 0
    for a in list(comb):
        if len(a) == len(set(a)):
            max_len = max(a)
            sum_all = sum(a)
            if sum_all - max_len > max_len:
                ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
p = list(map(int,input().split()))
import collections
import itertools
c = collections.Counter(p)
c_keys = list(c.keys())
com_list = list(itertools.combinations(c_keys, 3))

ans = 0
for i in range(len(com_list)):
    p_sort = sorted(com_list[i])
    if p_sort[0] + p_sort[1] > p_sort[2]:
        ans += c[p_sort[0]] * c[p_sort[1]] * c[p_sort[2]]

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

Submission status: Accepted

Solution code:
n=int(input())
ll=list(map(int,input().split()))
t=0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      if ll[i]==ll[j]:continue
      if ll[i]==ll[k]:continue
      if ll[k]==ll[j]:continue
      sa=[ll[i], ll[j], ll[k]]
      ma=max(sa)
      sal=sum(sa)-ma
      if ma<sal:t+=1
      
print(t)

Submission status: Accepted

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

cnt = 0

for i in range(n - 2):
    for j in range(i + 1, n - 1):
        for k in range(j + 1, n):
            if a[k] < a[i] + a[j]:
                if a[i]!=a[j]:
                    if a[j]!=a[k]:
                        cnt += 1

print(cnt)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
import itertools

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

L.sort()

ans = 0
edge = list(itertools.combinations(L, 3))
for now in edge:
    if now[0] == now[1] or now[1] == now[2] or now[2] == now[0]:
        continue
    if now[0] + now[1] > now[2]:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

import itertools

ans = 0
for i, j, k in itertools.combinations(range(n), 3):
    if (l[i] == l[j]) or (l[i] == l[k]) or (l[j] == l[k]):
        continue
    else:
        if (l[i] + l[j] > l[k]) and (l[i] + l[k] > l[j]) and (l[j] + l[k] > l[i]):
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations

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

result = 0
for lines in combinations(L, 3):
    if len(set(lines)) != 3:
        continue

    a, b, c = lines
    if a + b > c and b + c > a and c + a > b:
        result += 1

print(result)

Submission status: Accepted

Solution code:
number = int(input())
score = list(map(int,input().split()))
score.sort()
answer = 0
for i in range(len(score)):
    for j in range(len(score)-i-1):
        if score[i] != score[i+j+1]:
            for k in range(len(score)-i-j-2):
                if score[i+j+1] != score[i+j+k+2]:
                    if score[i]+score[i+j+1] > score[i+j+k+2]:
                        answer += 1
print(answer)

Submission status: Accepted

Solution code:
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=tf-8
#

"""
"""

from collections import defaultdict
from itertools import combinations
import bisect

import sys
input = sys.stdin.readline

def solve(a):
    ans = 0
    for a1, a2, a3 in combinations(a,3):
        a_max = max(a1,a2,a3)
        if a1 + a2 + a3 > 2*a_max and a1 != a2 and a1 != a3 and a2 != a3:
            ans += 1
    print(ans)



            

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

list_comb = list(itertools.combinations(L_list, 3))

result_sum = 0
for i in list_comb:
    if i[0] == i[1] or i[1] == i[2] or i[2] == i[0]:
        continue
    if i[0]+i[1]>i[2] and i[1]+i[2]>i[0] and i[2]+i[0]>i[1]:
        result_sum += 1
print(result_sum)

Submission status: Accepted

Solution code:
n = int(input())

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

count = 0
for a in range(n):
    for b in range(a+1,n):
        for c in range(b+1,n):
            a_r = l_list[a]
            b_r = l_list[b]
            c_r = l_list[c]
            if a_r + b_r > c_r and b_r+c_r > a_r and c_r + a_r > b_r and a_r != b_r and b_r != c_r and c_r != a_r:
                count+=1
print(count)

Submission status: Accepted

Solution code:
def possible_triangle(x, y, z):
    length_req = (x + y > z) and (y + z > x) and (x + z > y)
    diff_sides = (x != y) and (x != z) and (y != z)
    return length_req and diff_sides


n = int(input())
sticks = [int(i) for i in input().split()]
sticks.sort()
count = 0

for i in range(n - 2):
    for j in range(i, n - 1):
        for k in range(j, n):
            if possible_triangle(sticks[i], sticks[j], sticks[k]):
                count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import copy
from collections import deque
import collections
import itertools
stdin = sys.stdin

mod = 10**9+7

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

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

_ = ni()
l = na()

cnt = 0
for a, b, c in itertools.combinations(l, 3):
    if calc(a, b, c):
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
import itertools

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

a = list(itertools.combinations(l, 3))
ans = 0
for i in a:
    tmp = sorted(i)
    if tmp[0] != tmp[1] != tmp[2] and tmp[0]+tmp[1] > tmp[2]:
        ans += 1
print(ans)

Submission status: Accepted

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

arr.sort()
c=0
for i in range(len(arr)-2):
    for j in range(i+1,len(arr)-1):
        if(arr[i]!=arr[j]):
            for k in range(j+1,len(arr)):
                if(arr[i]!=arr[k] and arr[j]!=arr[k] and arr[i]+arr[j]>arr[k]):
                    c=c+1
                    # print(str(i)+str(j)+str(k))
print(c)

Submission status: Accepted

Solution code:
from collections import Counter

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

l_counter = Counter(l)
l_set = sorted(list(l_counter.keys()))

length = len(l_set)
ans = 0
if n < 3:
    print(0)
else:
    for i in range(length - 2):
        for j in range(i + 1, length - 1):
            for k in range(j + 1, length):
                if l_set[k] < l_set[i] + l_set[j]:
                    ans += l_counter[l_set[i]] * l_counter[l_set[j]] * l_counter[l_set[k]]

    print(ans)

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
r=0
for i in range(n):
	li=l[i]
	for j in range(i,n):
		lj=l[j]
		if li==lj:continue
		for k in range(j,n):
			lk=l[k]
			if li==lk or lj==lk:continue
			if li<lj+lk and lj<li+lk and lk<lj+li:r+=1
print(r)

Submission status: Accepted

Solution code:
from collections import deque
import sys, copy,itertools
input = sys.stdin.readline

n = int(input())
L = list(map(int,input().split()))
A = sorted(L)

JR = list(itertools.combinations(A,3))

#print(A)
#print(JR)
cnt = 0

for i in range(len(JR)):
  if not(JR[i][0]==JR[i][1])and not(JR[i][1]==JR[i][2]) and (JR[i][0]+JR[i][1] > JR[i][2]):
    cnt += 1
    
print(cnt)

Submission status: Accepted

Solution code:
import sys,math
try:sys.stdin,sys.stdout=open('input.txt','r'),open('out.txt','w')
except:pass
from sys import stdin,stdout;mod=int(1e9 + 7);from statistics import mode
from collections import *;from math import ceil,floor,inf,factorial,gcd,log2,sqrt,log
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
# print('{:.3f}'.format(1),round(1.123456789,4))
# sys.setrecursionlimit(500000)
def lcm(a,b): return (a*b)//gcd(a,b)
def setbits(n):return bin(n).count('1')
def resetbits(n):return bin(n).count('0')
def modinv(n,p):return pow(n,p-2,p)
def ncr(n,r):
    num,den=1,1;r=min(n,n-r)
    for i in range(r):num*=(n-i);den*=(i+1)
    return num//den
def ncr_p(n, r, p):
    num,den=1,1;r=min(r,n-r)
    for i in range(r):num = (num * (n - i)) % p ;den = (den * (i + 1)) % p
    return (num * modinv(den,p)) % p
def isPrime(num) :
    if num<=1:return False
    if num==2 or n==3:return True
    if (num % 2 == 0 or num % 3 == 0) :return False
    m = int(num**0.5)+1
    for i in range(5,m,6):
        if (num % i == 0 or num % (i + 2) == 0) :return False
    return True
def bin_search(arr, low, high, val):
    while low <= high:
        mid = low + (high - low) // 2;
        if arr[mid] == val:return mid
        elif arr[mid] < val:low = mid + 1
        else:high = mid - 1
    return -1
def sumofdigit(num):
    count=0;
    while num : count+=num % 10;num //= 10;
    return count;
def inputmatrix():
    r,c=iia();mat=[0]*r;
    for i in range(r):mat[i]=iia();
    return r,c,mat;
def prefix_sum(n,arr):
    for i in range(1,n):arr[i]+=arr[i-1]
    return arr;
def binomial(n, k):
    if 0 <= k <= n:
        ntok = 1;ktok = 1
        for t in range(1, min(k, n - k) + 1):ntok *= n;ktok *= t;n -= 1
        return ntok // ktok
    else:return 0
def divisors(n):
    res = [];
    for i in range(1,ceil(sqrt(n))+1):
        if n%i == 0:
            if i==n//i:res.append(i)
            else:res.append(i);res.append(n//i)
    return res;
# code start from here-

n= ii1()
arr = iia()
# arr= list(set(arr))
arr.sort()
count=0

n=len(arr)
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] and arr[j]+arr[k]>arr[i] and arr[k]+arr[i]>arr[j]:
                    count+=1
print(count)

Submission status: Accepted

Solution code:
from collections import Counter

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

d = Counter(L)
l = list(set(L))
l.sort()

ans = 0
n = len(l)
for i in range(n-2):
    a = l[i]
    for j in range(i+1, n-1):
        b = l[j]
        for k in range(j+1, n):
            if (abs(a-b) < l[k]) and l[k] < a+b:
                ans += d[a]*d[b]*d[l[k]]
print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations

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

ls = list(combinations(L,3))

cnt = 0
for (i,j,k) in ls:
  if i != j and j != k and k != i:
    T = sorted([i,j,k])
    if T[2] < (T[0] + T[1]):
      cnt += 1
print(cnt)

Submission status: Accepted

Solution code:

n = int(input())

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

def sol(arr, n):

    arr.sort()

    count = 0

    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            for k in range(j + 1, n):

                if (arr[i] != arr[j]) and (arr[i] != arr[k]) and (arr[k] != arr[j]) and ( arr[i] + arr[j] > arr[k] and arr[i] + arr[k] > arr[j] and arr[k] + arr[j] > arr[i] ):
                    count += 1

    return count


print (sol(arr, n))

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

Submission status: Accepted

Solution code:
#Problem B

n = int(input())
a = list(map(int,input().split()))
cnt = 0
for i in range(n-2):
    for j in range(n-i-2):
        for k in range(n-i-j-2):
            len = a[i] + a[i+j+1] + a[i+j+k+2]
            ma = max(a[i],  a[i+j+1],  a[i+j+k+2])
            rest = len - ma

            if ma < rest:
                 if a[i] != a[i+j+1] and a[i+j+1] != a[i+j+k+2]:
                        if a[i+j+k+2] != a[i]:
                            cnt += 1


print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
l = [int(x) for x in input().split()]
ans = 0
l.sort()

for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if (l[i]-l[j])*(l[k]-l[j]) != 0:
                if l[k]<(l[i]+l[j]):
                    ans += 1

print(ans)

Submission status: Accepted

Solution code:
import collections
N = int(input())
L = collections.Counter([int(T) for T in input().split()]).most_common()
Count = 0
for A in range(0,len(L)):
    for B in range(A+1,len(L)):
        for C in range(B+1,len(L)):
            if (L[A][0]+L[B][0]>L[C][0]) and (L[B][0]+L[C][0]>L[A][0]) and (L[C][0]+L[A][0]>L[B][0]):
                Count += L[A][1]*L[B][1]*L[C][1]
print(Count)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import itertools
import collections

input = sys.stdin.readline


def S():
    return input().rstrip()


def I():
    return int(input())


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


n = I()
ll = list(MI())

count = collections.Counter(ll)


def check(a, b, c):
    if 2 * max(a, b, c) < (a + b + c):
        return True
    else:
        return False


ans = 0
for a, b, c in itertools.combinations(count.keys(), 3):
    if check(a, b, c):
        ans += count[a] * count[b] * count[c]

print(ans)

Submission status: Accepted

Solution code:
def check_tri(a, b, c):
  if a == b or a == c or b == c:
    return False
  return a + b > c and b + c > a and c + a > b

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

count = 0
for i in range(n - 2):
  for j in range(i + 1, n - 1):
    for k in range(j + 1, n):
      if check_tri(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()))
count = 0

for v in itertools.combinations(l,3):
    if v[0] != v[1] and v[1] != v[2] and v[2] != v[0]:
        if v[0]+v[1] > v[2] and v[1]+v[2] > v[0] and v[2]+v[0] > v[1]:
            count += 1

print(count)

Submission status: Accepted

Solution code:
n = int(input())
ls = list(map(int, input().split()))
#res = {}
res = 0
for i in range(len(ls)):
    for j in range(i+1,len(ls)):
        for k in range(j+1, len(ls)):
            a,b,c = ls[i],ls[j],ls[k]
            if a+b>c and b+c>a and c+a>b and a!=b and b!=c and c!=a:
                #print((a,b,c))
                #if tuple(sorted((a,b,c))) not in res:
                    #res[tuple(sorted((a,b,c)))] = 0
                res += 1
#print(len(res))
print(res)

Submission status: Accepted

Solution code:
def b(x, y, z):
    flag = False
    if (z < x + y) and (y < z + x) and (x < z + y):
        if (x != y) and (y != z) and (x != z):
            flag = True
    return flag
cnt = 0
N = int(input())
L = list(map(int, input().split()))
for i in range(N):
    x = L[i]
    for j in range(i + 1, N):
        y = L[j]
        for k in range(j + 1, N):
            z = L[k]
            if b(x, y, z):
                cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
import itertools as it

def li():
    return [int(x) for x in input().split()]

N = int(input())
L = li()

# 組み合わせ列挙
c = it.combinations(L, 3)
c_list = list(c)

cnt = 0
for l in c_list:
    unique_l = len(set(l))
    if unique_l != 3:
        continue
    sum_l = l[0] + l[1] + l[2]
    max_l = max(l)
    sum_lest = sum_l - max_l
    if sum_lest > max_l:
        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[i] != l[k]) and (l[j] != l[k]):
      	if (l[i] < (l[j] + l[k])) and (l[j] < (l[i] + l[k])) 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

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 not (L[i] == L[j] or L[j] == L[k] or L[k] == L[i]):
                tmp = sorted([L[i], L[j], L[k]], reverse=True)
                if tmp[0] < tmp[1]+tmp[2]:
                    ans+=1
                    # print(i,j,k)
                    # print(tmp[1]+tmp[2])
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
ct=0
b=0
for i in range(0,n-2):
  p=a[i]
  for j in range(i+1,n-1):
    q=a[j]
    for k in range(j+1,n):
      r=a[k]
      if p!=q and q!=r and r!=p and 2*max(p,q,r)<p+q+r:
        ct+=1
print(ct)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
L=list(map(int,input().split()))
ans=0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            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
                else:
                    pass
print(ans)

Submission status: Accepted

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

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

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int,input().split()))
counter = 0
for i in range(0,N-2):
    for j in range(i+1,N-1):
        if L[i] == L[j]:
            continue
        for k in range(j+1,N):
            if L[j] == L[k] or L[i] == L[k]:
                continue
            else:
                longest = max(L[i],L[j],L[k])
                if 2*longest < L[i]+L[j]+L[k]:
                    counter += 1
print(counter)

Submission status: Accepted

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

count = 0
for i in range(len(l)-2):
    for j in range(i, len(l)-1):
        for k in range(j, len(l)):
            if l[i]<l[j]+l[k] and l[j]<l[i]+l[k] and l[k]<l[i]+l[j] and l[i]!=l[j] and l[j]!=l[k] and l[k]!=l[i]:
                count += 1
                
print(count)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int,input().split()))
L.sort()
def Ju(x,y,z):
    if x + y > z:
        if x != y and y != z and z != x :
            return 0
        else:
            return 1
    else:
        return 1
A = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1, N):
            if Ju(L[i],L[j],L[k]) == 0:
                A += 1
print(A)

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] and L[i] != L[k] and L[j] != L[k]:
                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())

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

if len(N_list) <= 2:
  print(0)
  
else:
  cnt = 0
  for i in range(len(N_list)-2):
    for j in range(i+1,len(N_list)-1):
      for k in range(j+1,len(N_list)):
        if (abs(N_list[i]-N_list[j])<N_list[k]<N_list[i]+N_list[j]) and (abs(N_list[j]-N_list[k])<N_list[i]<N_list[j]+N_list[k]) and (abs(N_list[i]-N_list[k])<N_list[j]<N_list[i]+N_list[k]) and (N_list[i]!=N_list[j]) and (N_list[j]!=N_list[k]) and (N_list[i]!=N_list[k]):
          cnt+=1
          
  print(cnt)

Submission status: Accepted

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

ans = 0
for subset in combinations(L, 3):
    subset = sorted(subset)
    if len(set(subset)) != 3:
        continue
    a, b, c = subset
    if c < a+b:
        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(len(l)):
    for j in range(i, len(l)):
        for k in range(j, len(l)):
            if l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
                if l[i] + l[j] > l[k]:
                    ans += 1

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
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[k] == L[i]:
                continue
            
            edges = [L[i],L[j],L[k]]
            edges = sorted(edges)
            
            if edges[2] >= edges[1] + edges[0]:
                continue
            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):
        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]:
                cnt += 1
                
print(cnt)

Submission status: Accepted

Solution code:
def linked_merge_sort(l): #マージソート
    if len(l) == 1:
        return
    q, r = divmod(len(l), 2)
    left = [l.pop() for _ in range(q)]
    right = [l.pop() for _ in range(q + r)]
    
    linked_merge_sort(left)
    linked_merge_sort(right)
    
    left.reverse()
    right.reverse()
    while left and right:
        if left[-1] <= right[-1]:
            l.append(left.pop())
        else:
            l.append(right.pop())
    while left:
        l.append(left.pop())
    while right:
        l.append(right.pop())
    return

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

linked_merge_sort(l)

ans=0

for x in l:
    i=0
    while l[i]<x:
        j=i+1
        while l[j]<x:
            if l[i]+l[j]>x and l[i]!=l[j]:
                ans+=1
            j+=1
        i+=1

print(ans)

Submission status: Accepted

Solution code:
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College

'''
from os import path
import sys
from heapq import heappush,heappop
from functools import cmp_to_key as ctk
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input().rstrip()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
mod=1000000007
# mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def bo(i):
    return ord(i)-ord('a')

file=1




def solve():
    
    

    # for _ in range(ii()):

        n= ii()
        a = li()
        ans=0
        for i in range(n):
            for j in range(i+1,n):
                for k in range(j+1,n):
                    if a[i]!=a[j] and a[j]!=a[k] and a[i]!=a[k]:
                        s = a[i]+a[j]+a[k]
                        mx = max(a[i],max(a[j],a[k]))
                        if s > 2*mx:
                            ans+=1

        print(ans)













        
if __name__ =="__main__":

    if(file):

        if path.exists('input.txt'):
            sys.stdin=open('input.txt', 'r')
            sys.stdout=open('output.txt','w')
        else:
            input=sys.stdin.readline
    solve()

Submission status: Accepted

Solution code:
import itertools
n=int(input())
data=list(map(int,input().split()))
count=0
if len(data) < 3:
    print(0)
else:
    for d in itertools.combinations(data,3):
        
        triple=list(d)
        if (triple[0]+triple[1] > triple[2]) and (triple[1]+triple[2] > triple[0]) and (triple[2]+triple[0] > triple[1]):
            if triple[0] != triple[1] and triple[1] != triple[2] and triple[2] != triple[0]:
                count += 1
        
        else:
            pass
    print(count)

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

Solution code:
import itertools
n=int(input())
l=sorted([int(i) for i in input().split()])
ans=0

for i in range(n-2):
    A=list(itertools.combinations(l[:i+2],2))
    for a in A:
        if a[0]!=a[1]!=l[i+2] and sum(a)>l[i+2] :
            
            ans+=1
print(ans)

Submission status: Accepted

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

if n > 2:
    ls.sort()
    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] and ls[j] < ls[k] and ls[k] < ls[i] + ls[j]:
                    ans += 1

print(ans)

Submission status: Accepted

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