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:
count = 0
N = int(input())
L = list(map(int, input().split())) #1行にN個の整数を入力したい.
L.sort(reverse=True) #リストLを降順に並び替えたい(昇順の時は"()"の中身は何も書かない)
for i in range(0, N-2): #全探索
    for j in range(i, N-1):
        for k in range(j, N):
            if L[i] == L[j] or L[j] == L[k] or L[i] == L[k]:
                count += 0
            elif L[i] < L[j] + L[k]:
                #print(L[i])
                count += 1
print(count)

Submission status: Accepted

Solution code:
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math
INT_MIN=-10**13
import bisect as B
###############################################################################\
n=int(input())
A=INPUT()
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])>A[k] and (A[i]+A[k])>A[j] and (A[j]+A[k])>A[i] and A[i]!=A[j] and A[i]!=A[k] and A[j]!=A[k]:
                ans+=1
                #print(A[i],A[j],A[k])
print(ans)

Submission status: Accepted

Solution code:
a=input()
b=input()
c=b.split(" ")
for i in range( len(c)):
  c[i]=int(c[i])
count=0
for i in range(len(c)):
  for j in range(i+1,len(c)):
    for k in range(j+1,len(c)):
      if (c[j]<c[i]and c[k]<c[i]and c[j]!=c[k]and c[i]<c[j]+c[k])or (c[i]<c[j]and c[k]<c[j]and c[i]!=c[k]and c[j]<c[i]+c[k])or (c[j]<c[k]and c[i]<c[k]and c[j]!=c[i]and c[k]<c[j]+c[i]):
        count+=1
print(count)

Submission status: Accepted

Solution code:
from itertools import combinations

N = int(input())
L = list(map(int, input().split()))
cnt = 0
if N >= 3:
    for edges in combinations(L, 3):
        a, b, c = edges
        if len(set(edges)) == 3 and a < b + c and b < c + a and c < a + b:
            cnt += 1
print(cnt)

Submission status: Accepted

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

is_counted = defaultdict(lambda: 0)
cnt = 0
for t in combinations(range(n), 3):
    t = [l[x] for x in t]
    if len(set(t)) != 3:
        continue
    if sum(t) - max(t) > max(t):
        cnt += 1
print(cnt)

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 len(set([L[i],L[j],L[k]]))==3 and L[i]+L[j]>L[k]:
        ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

for i in itertools.combinations(L, 3):
    if i[0] != i[1] and i[0] != i[2] and i[2] != i[1]:
        if i[0] + i[1] > i[2] and i[1] + i[2] > i[0] and i[2] + i[0] > i[1]:
            cnt += 1


print(cnt)

Submission status: Accepted

Solution code:
import sys
import itertools

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    L = [int(x) for x in input().split()]

    ans = 0
    for abc in itertools.combinations(L, r=3):
        if len(set(abc)) != 3:
            continue
        if sum(abc) - max(abc) > max(abc):
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

cnt = 0
for i in range(n):
    for j in range(i + 1 , n):
        for k in range(j + 1, n):
            if len(set([l[i], l[j], l[k]])) == 3:
                if l[i] + l[j] > l[k]:
                    cnt += 1
print(cnt)

Submission status: Accepted

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

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


def main():
	n=II()
	A=LI()
	A.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 A[i]==A[j] or A[j]==A[k]:
					continue
				if A[i]+A[j]>A[k]:
					ans+=1

	print(ans)








if __name__ == "__main__":
	main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = (int(x) for x in input().split())

b = list(a)

cnt = 0

for i in range(len(b)) :
        for j in range(len(b)) :
                for k in range(len(b)):
                        c = [i,j,k]
                        if len(c) == len(set(c)) :
                                d = [b[i],b[j],b[k]]
                                m = max(d) 
                                if m < sum(d) - m and b[i] != b[j] and b[j] != b[k] and b[k] !=b[i]:
                                        cnt += 1
                                else :
                                        None
                        else :
                                None
                                
print(int(cnt/6))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from itertools import combinations


def main():
    ll = read_ll()
    result = c(ll)
    print(result)

def c(ll):
    count = 0
    for i, j, k in combinations(ll, 3):
        if i != j and j != k and i != k:
            if i + j > k:
                count += 1
    return count

def read_ll():
    n = int(input())

    ll = input().split()
    ll = list(map(int, ll))
    ll.sort()
    return ll

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
import sys
#####sorting a dictionary by the values#####
def dict_sort(ans):
    ans=sorted(ans.items(),reverse=True,key=lambda kv:(kv[1]))
##### naive method for testing prime or not#####
def is_prime(n):
    if n==1:
        return 0
    for i in range(2,int(math.sqrt(n))+1):
        if n%i==0:
            return False
    return True
#####greatest common divisor of two numbers#####
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)
#####least common multiplyer of two numbers#####
def lcm(a,b):
    return (a*b)//gcd(a,b)
#####function that return all the letters#####
def alphbates():
    return "abcdefghijklmnopqrstuvwxyz"
#####binary search#####
def binary_search(ls,n,flag):
    low=0
    hi=n-1
    while(low<=hi):
        mid=(low+hi)//2
        if ls[mid]==flag:
            return mid
        elif ls[mid]>flag:
            hi=mid-1
        else:
            low=mid+1
    return -1
#####taking an array/list as input#####
def inp():
    ls=list(map(int,input().split()))
    return ls
#####taking multiple inputs#####
def mult_inp():
    return map(int,input().split())
#####Main function starts from here#####
n=int(input())
ls=inp()
if n<3:
    print(0)
    exit(0)
ls.sort()
ans=0
for i in range(n):
        for j in range(i+1,n):
                for k in range(j+1,n):
                        if ls[i]+ls[j]>ls[k] and ls[i]+ls[k]>ls[j] and ls[k]+ls[j]>ls[i] and ls[i]!=ls[j] and ls[j]!=ls[k] and ls[k]!=ls[i]:
                            ans+=1
print(ans)

Submission status: Accepted

Solution code:
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

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] or 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]:
                cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
*l,=map(int,[*open(0)][1].split())
print(sum(i<j<k<i+j for i in l for j in l for k in l))

Submission status: Accepted

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

    print(ans)

Submission status: Accepted

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

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(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 2*max([l[i],l[j],l[k]])<sum([l[i],l[j],l[k]]):
				c+=1

print(c)

Submission status: Accepted

Solution code:
import itertools
N=int(input())
A=list(map(int, input().split()))
ans=0
for any_pair in itertools.combinations(A, 3):
    pair=sorted(any_pair)#新しいリストを作成
    #print(type(pair))
    if pair[0]+pair[1]>pair[2] and pair[0]!=pair[1] and pair[1]!=pair[2]:
        ans+=1
        #print(pair)
print(ans)

Submission status: Accepted

Solution code:
import itertools
N = input()
A = map(int, input().split())
cnt = 0

for pair in itertools.combinations(A, 3):
    if (pair[0]!=pair[1]) and (pair[1]!=pair[2]) and (pair[0]!=pair[2]):
        if (pair[0]+pair[1] > pair[2]) and (pair[1]+pair[2] > pair[0]) and (pair[0]+pair[2] > pair[1]):
            cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
long_list = input().split()
count = 0
for i in range(N):
    long_i = int(long_list[i])
    for j in range(N-i-1):
        long_j = int(long_list[i+j+1])
        for k in range(N-i-j-2):
            long_k = int(long_list[i+j+k+2])
            if long_i == long_j or long_j == long_k or long_k == long_i:
                pass
            elif long_i + long_j > long_k and long_i + long_k > long_j and long_j + long_k > long_i:
                count += 1    
            else:
                pass

print("{0}".format(count))

Submission status: Accepted

Solution code:
from itertools import (
    accumulate,  # 累積和のイテレータ
    groupby,  # 値をkey,同じ値の集まりをgroup
    permutations,  # 順列
    combinations,  # 組み合わせ
    product,  # 重複あり順列（直積, 深いネストにも使える）
    combinations_with_replacement,  # 重複あり組み合わせ
)

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

def check(i, j, k):
    if i != j and j != k and k != i:
        maxi = max(i, j, k)
        total = i + j + k
        return maxi < total - maxi
    else:
        return 0


cnt = 0
for i, j, k in combinations(L, 3):
    cnt += check(i, j, k)

print(cnt)

Submission status: Accepted

Solution code:
n,*l=map(int,open(0).read().split())
cnt=0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      a,b,c=l[i],l[j],l[k]
      if a==b or b==c or c==a:
        continue
      if abs(b-c)<a<b+c:
        cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
from sys import exit, stdin

# import copy
# from collections import deque,Counter
# import numpy as np
input = stdin.readline

(N,) = map(int, input().split())
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[j] == L[k] or L[k] == L[i]:
                continue
            elif max([L[i], L[j], L[k]]) * 2 < sum([L[i], L[j], L[k]]):
                cnt += 1


print(cnt)

Submission status: Accepted

Solution code:
from math import *
import sys,bisect,copyreg,copy,statistics,os
def inp(): return sys.stdin.readline().strip()
def IIX(): return (int(x) for x in sys.stdin.readline().split())
def II(): return (int(inp()))
def LI(): return list(map(int, inp().split()))
def LS(): return list(map(str, inp().split()))
def L(x):return list(x)
def out(var): return sys.stdout.write(str(var))


n=II()
sizes=LI()
t=0
sizes.sort()

for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if sizes[i] + sizes[j]> sizes[k] and sizes[i]!=sizes[j] and sizes[j]!=sizes[k]:
                t+=1

out(t)

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]:
                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 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
            else:
                ver = [l[i],l[j],l[k]]
                ver.sort()
                if ver[0] + ver[1] > ver[2]:
                    ans += 1

print(ans)

Submission status: Accepted

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

nums = set([])
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
            else:
                ver = [l[i],l[j],l[k]]
                num = [i,j,k]
                ver.sort()
                num.sort()
                if ver[0] + ver[1] > ver[2]:
                    nums.add(tuple(num))

print(len(nums))

Submission status: Accepted

Solution code:
n = int(input())
l = sorted(map(int, input().split()))[::-1]

ans = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if l[k] < l[j] < l[i] < l[k] + l[j]:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
l.sort()
i = len(l)-1
j = len(l) -2
k = len(l) -3
ans = 0
while i >= 2:
  j = i-1
  while j >= 1:
    k = j -1
    while k >= 0:
      if l[i] > l[j] > l[k] and l[i] - l[k] < l[j]:
        ans += 1
      else:
        pass
      k -= 1
    j -= 1
  i -= 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(N-2-i):
    for k in range(N-2-i-j):
      J = 1 + i + j
      K = 2 + i + j + k
      L_list = [L[i], L[J], L[K]]
      L_list.sort()
      
      if L[i] == L[J] or L[J] == L[K] or L[K] == L[i]:
        pass
      else:
        if L_list[0] + L_list[1] > L_list[2]:
          ans += 1
          
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
import sys
from itertools import combinations


def main():
    ll = read_ll()
    result = c(ll)
    print(result)

def c(ll):
    count = 0
    for i, j, k in combinations(ll, 3):
        if i != j and j != k and i != k:
            if i + j > k:
                count += 1
    return count

def read_ll():
    n = int(input())

    ll = input().split()
    ll = list(map(int, ll))
    ll.sort()
    return ll

main()

Submission status: Accepted

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

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

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
L = list(map(int, input().split()))
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]:
        ans += 1
print(ans)

Submission status: Accepted

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


def calcu(N,L):

    if N <= 2:
        return 0

    res = 0
    for i in range(N-2):
        for j in range(i+1,N-1):
            for k in range(j+1,N):
                a = L[i]
                b = L[j]
                c = L[k]
                if a == b or b == c or c == a:
                    pass
                elif a+b>c and b+c>a and c+a>b:
                    res += 1
    return res

print(calcu(N,L))

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] > 2 * max(l[i],l[j],l[k]) 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())
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]:
                sum_=L[i]+L[j]+L[k]
                if max(L[i],L[j],L[k])*2<sum_:
                    count+=1                

print(count)

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

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int,input().split()))
# ソートすることで k が三角形の長辺になるように出来る
L.sort()
ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        # 同じ長さであればcontinue
        if L[i]==L[j]:
            continue
        for k in range(j+1,N):
            # 同じ長さであればcontinue
            if L[i]==L[k] or L[j]==L[k]:
                continue
            # 長辺が他の2辺の長さの合計よりも短ければ
            # 三角形になる
            if L[k]<L[i]+L[j]:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

con = 0

for p in range(n):
    for q in range(p+1,n):
        for r in range(q+1,n):
            if x[p] != x[q] and x[q] != x[r] and x[r] < (x[p] + x[q]):
                con += 1
                
print(con);

Submission status: Accepted

Solution code:


N = int(input())
L = []
L.append(input())

A = L[0].split()
B = [0] * N
for i in range(N):
	B[i] = int(A[i])


ans = 0

C = [0] *3
C2 = [0] *3

for i in range(N-2):
	C[0] = B[i]
	for j in range(N-1):
		C[1] = B[j]
		for k in range(N):
			C[2] = B[k]
			C2 = sorted(C)
			if i<j<k and  C2[2] < C2[1] + C2[0] and B[i] != B[j] and B[j] != B[k] and B[k] != B[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):
    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]:
                ans += 1
 
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = [int(num) for num in input().split()]
L.sort()
a = 0
b = 0
c = 0
ans = 0
for i in range(N):
    if N < 3:
        break
    a = L[i]
    for j in range(i+1,N):
        b = L[j]
        for k in range(j+1,N):
            c = L[k]
            if a != b and a != b and b != c:
                if c-b < a and a < b+c:
                    ans = ans + 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import itertools
sys.setrecursionlimit(10000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

if __name__ == "__main__":
    n = int(input())
    l = sorted(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 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]:
                        cnt+=1
    print(cnt)

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from pprint import pprint
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

n = I()
L = LI()
cnt = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            Li = [L[i], L[j], L[k]]
            if len(set(Li)) != 3:
                continue
            Li.sort()
            if Li[2] < Li[0] + Li[1]:
                cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
def f(a,b,c):
    if a==b or b==c or c==a:
        return False
    if a+b>c and b+c>a and c+a>b:
        return True
    else:
        return False
from itertools import combinations
n=int(input())
l=[int(i) for i in input().split()]
ans=0
for a,b,c in combinations(l,3):
    if f(a,b,c):
        ans+=1
print(ans)

Submission status: Accepted

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

for a in range(n-2):
    for b in range(a+1, n-1):
        if sortl[a] == sortl[b]:
            continue
        for c in range(b+1, n):
            if sortl[b] == sortl[c]:
                continue
            else:
                if sortl[a] + sortl[b] > sortl[c]:
                    count += 1

            

print(count)

Submission status: Accepted

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

count=0
if len(A)<=2:
    print(0)
else:
    for ｔ in itertools.combinations(A, 3):
        if t[2]<t[0]+t[1] and t[1]<t[0]+t[2] and t[0]<t[1]+t[2] and t[0]!=t[1]!=t[2]!=t[0]:

            count+=1

    print(count)

Submission status: Accepted

Solution code:
# coding: utf-8
from pdb import set_trace
#from collections import Counter
import itertools

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

# C = dict(Counter(L))
# L = sorted(list(set(L)), reverse=True)

# if N<3 or len(L)<3:
#     print(0)
#     exit()
# li = []
# for xa, a in enumerate(L[:-2]):
#     for xb, b in enumerate(L[xa+1:-1]):
#         for xc, c in enumerate(L[xa+2:]):
#             if a+b<c:
#                 break
#             if a+b>c and b+c>a and c+a>b and a!=b and b!=c and c!=a:
#                 _li = sorted([xa, xb+xa+1, xc+xa+2])
#                 if _li in li:
#                     continue
#                 li.append(_li)
# cnt = 0
# for l in li:
#     a = C[L[l[0]]]
#     b = C[L[l[1]]]
#     c = C[L[l[2]]]
#     cnt += (a * b * c)
# print(cnt)
cnt = 0
TRI = list(itertools.combinations(L, 3))
for tri in TRI:
    a, b, c = tri
    if a==b or b==c or c==a:
        continue
    elif a+b>c and a+c>b and b+c>a:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
l=list(map(int,input().split()))

r=[i for i in range(n)]
if n<3:
    print(0)
    exit()
ans=0
for res in itertools.combinations(r,3):
    a,b,c=res
    if l[a]!=l[b] and l[b]!=l[c] and l[c]!=l[a]:
        la=l[a]
        lb=l[b]
        lc=l[c]
        if la<lb+lc and lb<la+lc and lc<la+lb:
            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):
            li = l[i]
            lj = l[j]
            lk = l[k]
            if li == lj or lj == lk or lk == li:
                continue
            else:
                s = max(li, lj, lk)
                if li+lj+lk > 2*s:
                    ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
N = int(input())
L = [int(i) for i in input().split()]
L.sort()
if N <= 2:
    print(0)
    sys.exit()
ans = 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[i] != L[k]:
                m = max(L[i], L[j], L[k])
                if m < L[i]+L[j]+L[k] - m:
                    ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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


ans = list(combinations(L,3))
ans1 = 0
for i in ans:
    if (i[0]+i[1]>i[2] and i[0]+i[2]>i[1] and i[1]+i[2]>i[0] and i[0]!=i[1] and i[0]!=i[2] and i[1]!=i[2]):
        ans1+=1

print(ans1)

Submission status: Accepted

Solution code:
def main():
    n=int(input())
    l=list(map(int,input().split()))
    ans=0
    for i in range(n):
        for k in range(i+1,n):
            for j in range(k+1,n):
                temp=[l[i],l[k],l[j]]
                if len(set(temp))==len(temp):
                    temp.sort()
                    if temp[0]+temp[1]>temp[2]:
                        ans+=1
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
ans=0
for a in l:
  for b in l:
    for c in l:
      if (a==b or b==c or a==c):
        continue
      if max([a,b,c])<a+b+c-max([a,b,c]):
        ans+=1
print(ans//6)

Submission status: Accepted

Solution code:
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n = int(input())
    L = list(map(int, input().split()))
    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 len(set([a, b, c])) != 3:
                    continue
                if 2 * max(a, b, c) < sum([a, b, c]):
                    ans += 1
    print(ans)
resolve()

Submission status: Accepted

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