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:


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    L = read_ints()
    answer = 0
    for i in range(N):
        for j in range(i+1, N):
            for k in range(j+1, N):
                if L[i] != L[j] and L[j] != L[k] and L[i] != L[k] and L[i]+L[j] > L[k] and L[k]+L[j] > L[i] and L[i]+L[k] > L[j]:
                    answer += 1
    return answer


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

Submission status: Accepted

Solution code:
import itertools
N = int(input())
L = list(map(int, input().split()))
ans = 0
for a, b, c in itertools.combinations(L, 3):
  if a+b>c and b+c>a and c+a>b and len(set([a, b, c]))==3:
    ans += 1
print(ans)

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations

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

cnt = 0
for a,b,c in combinations(L,3):
    if a == b or b == c or c == a:
        continue
    cnt += int(max(a,b,c)*2 < a+b+c)

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

Submission status: Accepted

Solution code:
n,*l=map(int,open(0).read().split())
l.sort()
c=0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if len({l[i],l[j],l[k]})==3 and l[i]+l[j]>l[k]: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] and  L[i]!=L[k] and  L[k]!=L[j]:
        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, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
L = LIST()

ans = 0
for x in combinations(L, 3):
	if len(set(x)) == 3 and max(x) < sum(x)-max(x):
		ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int,input().split()))
from itertools import combinations
Ms = list(combinations(L,3))
cnt = 0
for M in Ms:
    L1,L2,L3 = M[0],M[1],M[2]
    if L1!=L2 and L2!=L3 and L1!=L3:
        if abs(L1-L2) < L3 and L3 < L1+L2:
            cnt+=1
print(cnt)

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 = [A[i], A[j], A[k]]
            a = sorted(a)
            if A[i] == A[j] or A[j] == A[k] or A[i] == A[k]:
                continue
            if a[0] + a[1] > a[2]:
                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] != L[k] != L[i]:
        if L[i]+L[j]>L[k] and L[j]+L[k]>L[i] and L[k]+L[i]>L[j]:
          ans += 1
print(ans)

Submission status: Accepted

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

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

ans=0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            A=[L[i],L[j],L[k]]
            A = sorted(A)
            if len(set(A))!=3:
                continue
            if A[0]+A[1]>A[2]:
                ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations
n = int(input())
l_ls = list(map(int, input().split()))
ans = 0
for a,b,c in combinations(l_ls,3):
    if a != b and b != c and c != a and a < b+c and b < a+c and c < a+b:
        ans += 1
print(ans)

Submission status: Accepted

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

ans = 0
for a in range(N):
    La = Ls[a]
    for b in range(a+1, N):
        Lb = Ls[b]
        for c in range(b+1, N):
            Lc = Ls[c]
            if La != Lb and Lb != Lc and Lc != La:
                if La+Lb > Lc and Lb+Lc > La 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(0, N-2):
  for j in range(i+1, N-1):
    for k in range(j+1, N):
      if L[i]!=L[j] and L[j]!=L[k] and L[k]!=L[i]:
        tmp=[L[i], L[j], L[k]]
        tmp.sort(reverse=True)
        if tmp[0]<tmp[1]+tmp[2]:
          ans+=1
print(ans)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
L = [int(_) for _ in input().split()]
ans = 0
for i, j, k in itertools.combinations(range(N), 3):
    a, b, c = sorted([L[i], L[j], L[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()))
cnt=0
for i in range(N):
    for j in range(i):
        for k in range(j):
            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]:
                cnt+=1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, a = input(), sorted(map(int, raw_input().split()))

ans = 0
for i in xrange(n):
    for j in xrange(i):
        for k in xrange(j):
            ans += a[i] > a[j] > a[k] and a[k] + a[j] > a[i]

print ans

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *L = map(int, read().split())

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

    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
L.sort()
res = 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]:
                res += 1
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def is_tri(a, b, c):
    if a == b or b == c or a == c:  return 0
    ma = max(a, b, c)
    rest = a + b + c - ma
    if rest > ma:  return 1
    return 0

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

Submission status: Accepted

Solution code:
import sys
from itertools import combinations

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    L = list(map(int, input().split()))

    res = 0
    for a, b, c in combinations(L, 3):
        if a == b or b == c or c == a:
            continue
        if a + b > c and b + c > a and c + a > b:
            res += 1
    print(res)


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
N = int(input())
L = [int(_n) for _n in 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] or L[j] == L[k] or L[k] == L[i]:
                continue
            if abs(L[j]-L[k]) < L[i] < abs(L[j] + L[k]):
                cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    c = 0
    for i in range(N):
        for j in range(i):
            if A[i] == A[j]:
                continue
            for k in range(j):
                if A[k] == A[i] or A[k] == A[j]:
                    continue
                if A[j] + A[k] > A[i]:
                    c += 1

    return c

print(main())

Submission status: Accepted

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

nums.sort()

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

print(ans)

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from itertools import combinations


N, *L = map(int, open(0).read().split())

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache

#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')
AZ = "abcdefghijklmnopqrstuvwxyz"

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


#####Shorten#####
def DD(arg): return defaultdict(arg)

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n): return kaijo_memo[n]
  if(len(kaijo_memo) == 0): kaijo_memo.append(1)
  while(len(kaijo_memo) <= n): kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n): return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0): gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n): gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if n == r: return 1
  if n < r or r < 0: return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1: arr.append([temp, 1])
  if arr==[]: arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b: a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n-1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n: return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

def base_10_to_n_without_0(X, n):
  X -= 1
  if X//n: return base_10_to_n_without_0(X//n, n)+[X%n]
  return [X%n]

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N = I()
A = IL()
ans = 0
for i in range(N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if not(A[i] == A[j]) and not(A[j] == A[k]) and not(A[k] == A[i]) and A[i]+A[j]>A[k] and A[k]+A[i]>A[j] and A[j]+A[k]>A[i]:
        ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

n = int(input())
A = list(map(int,input().split()))
# A = list(set(A))
# n = len(A)
A.sort()
# print(A)
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[j] > A[k]:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
# import sys; input = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

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

#処理内容
def main():
	N = int(input())
	L = getlist()
	ans = 0
	for i in range(N):
		for j in range(i + 1, N):
			for k in range(j + 1, N):
				x, y, z = list(sorted([L[i], L[j], L[k]])) 
				if x != y and y != z and x + y > z:
					ans += 1

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

Submission status: Accepted

Solution code:
import itertools

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=0
for x in range(n):
    for y in range(x+1,n):
        for z in range(y+1,n):
            if a[x]!=a[y] and a[y]!=a[z] and a[z]!=a[x] and a[x]+a[y]>a[z] and a[y]+a[z]>a[x] and a[z]+a[x]>a[y]:
                ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import *

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] and 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:
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    n = int(ipt())
    nm = 0
    l = [int(i) for i in ipt().split()]
    for i in range(n):
        li = l[i]
        for j in range(i+1,n):
            lj = l[j]
            for k in range(j+1,n):
                lk = l[k]
                if li == lj or lj == lk or lk == li or li >= lj+lk or lj >= li+lk or lk >= lj+li:
                    continue
                else:
                    nm += 1

    print(nm)

    return None

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

Submission status: Accepted

Solution code:
(N,) = [int(x) for x in input().split()]
L = [int(x) for x 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, b, c = L[i], L[j], L[k]
            if len(set([a, b, c])) == 3 and a + b > c and a + c > b and b + c > a:
                count += 1
print(count)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
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] and (a[j] != a[k]) and (a[k] != a[i]):
        if a[i] + a[j] > a[k] and (a[j] + a[k] > a[i]) and (a[k] + a[i] > a[j]): res += 1
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

import sys
sys.setrecursionlimit(300000)


def solve(N: int, L: "List[int]"):
    ret = 0
    for i in range(N):
        for j in range(i + 1, N):
            for k in range(j + 1, N):
                s = L[i] + L[j] + L[k]
                m = max(L[i], L[j], L[k])
                if L[i] != L[j] and L[j] != L[k] and L[k] != L[i] and m < s - m:
                    ret += 1
                    #print(i, j, k)
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, L)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

K=0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            a,b,c=sorted([L[i],L[j],L[k]])
            if a!=b and b!=c and a+b>c:
                K+=1
print(K)

Submission status: Accepted

Solution code:
import sys
from itertools import combinations

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
l.sort()
ret = 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]: ret += 1
print(ret)

Submission status: Accepted

Solution code:
N=int(input())
L=list(map(int,input().split()))
L.sort()
P=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 len(set([L[i],L[j],L[k]]))==3:
        P+=1
print(P)

Submission status: Accepted

Solution code:
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------- fast io --------------------
from math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi


def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

def lcm(a, b): return a * b // gcd(a, b)


def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y


for _ in range(int(input()) if not True else 1):
    n = int(input())
    #n, k = map(int, input().split())
    #a, b = map(int, input().split())
    #c, d = map(int, input().split())
    a = sorted(list(map(int, input().split())))
    #b = list(map(int, input().split()))
    from itertools import combinations
    ans = 0
    for x,y,z in combinations(a, 3):
        if x == y or y == z:continue
        if x+y > z and x+z > y and y+z > x:
            ans += 1
    print(ans)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
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)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    l = LI()
    l.sort()
    ans = 0
    for i in range(n):
        for j in range(i):
            for k in range(j):
                if l[j]+l[k] > l[i] and l[i] != l[j] and l[j] != l[k] and l[i] != l[k]:
                    ans += 1
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ni()
L = na()
L.sort()

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